Index: components/nacl/loader/nacl_listener.cc |
diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc |
index d7c97ad918bfcb7dcc51b58814021539e049d367..b7a3044e6c583f6a9b5b57624ebd13ceb85869d4 100644 |
--- a/components/nacl/loader/nacl_listener.cc |
+++ b/components/nacl/loader/nacl_listener.cc |
@@ -7,6 +7,7 @@ |
#include <errno.h> |
#include <fcntl.h> |
#include <stdlib.h> |
+#include <string.h> |
#if defined(OS_POSIX) |
#include <unistd.h> |
@@ -46,6 +47,19 @@ |
#endif |
namespace { |
+NaClListener* g_listener; |
+ |
+void FatalLogHandler(const char* data, size_t bytes) { |
+ // We copy the length of the crash data to the start of the shared memory |
+ // segment so we know how much to copy. |
+ memcpy(g_listener->crash_info_shmem_memory(), &bytes, sizeof(bytes)); |
Mark Seaborn
2014/08/17 20:13:45
On Windows, sizeof(bytes) might be different in th
teravest
2014/08/18 16:16:26
Done.
|
+ |
+ size_t copy_bytes = std::min<size_t>(bytes, nacl::kNaClCrashInfoMaxLogSize); |
+ memcpy((char*)g_listener->crash_info_shmem_memory() + sizeof(bytes), |
+ data, |
+ copy_bytes); |
+} |
+ |
#if defined(OS_MACOSX) |
// On Mac OS X, shm_open() works in the sandbox but does not give us |
@@ -85,9 +99,6 @@ int CreateMemoryObject(size_t size, int executable) { |
} |
#elif defined(OS_WIN) |
- |
-NaClListener* g_listener; |
- |
// We wrap the function to convert the bool return value to an int. |
int BrokerDuplicateHandle(NaClHandle source_handle, |
uint32_t process_id, |
@@ -213,18 +224,14 @@ NaClListener::NaClListener() : shutdown_event_(true, false), |
main_loop_(NULL) { |
io_thread_.StartWithOptions( |
base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
-#if defined(OS_WIN) |
DCHECK(g_listener == NULL); |
g_listener = this; |
-#endif |
} |
NaClListener::~NaClListener() { |
NOTREACHED(); |
shutdown_event_.Signal(); |
-#if defined(OS_WIN) |
g_listener = NULL; |
-#endif |
} |
bool NaClListener::Send(IPC::Message* msg) { |
@@ -269,9 +276,14 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
} |
NaClChromeMainSetUrandomFd(urandom_fd); |
#endif |
- |
struct NaClApp* nap = NULL; |
NaClChromeMainInit(); |
+ |
+ crash_info_shmem_.reset(new base::SharedMemory(params.crash_info_shmem_handle, |
+ false)); |
+ if (crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize)) |
Mark Seaborn
2014/08/17 20:13:45
Can we make this
CHECK(crash_info_shmem_->Map(nacl
teravest
2014/08/18 16:16:26
Done.
|
+ NaClSetFatalErrorCallback(&FatalLogHandler); |
+ |
nap = NaClAppCreate(); |
if (nap == NULL) { |
LOG(ERROR) << "NaClAppCreate() failed"; |