diff options
author | ted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-02-05 18:21:31 +0000 |
---|---|---|
committer | ted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-02-05 18:21:31 +0000 |
commit | f480ba116971a56d4de25ae1df2369e3d5503d16 (patch) | |
tree | 8623b5348123d092c2ac7111d9140db933c1bac1 /src/client/linux/handler/exception_handler.cc | |
parent | Breakpad processor: Move STACK WIN record parsing into its own function. (diff) | |
download | breakpad-f480ba116971a56d4de25ae1df2369e3d5503d16.tar.xz |
Refactor Chrome's out-of-process Linux code into CrashGeneration{Server,Client} classes. Upstreamed from the Mozilla repository. Patch by Chris Jones <jones.chris.g@gmail.com> r=me at https://bugzilla.mozilla.org/show_bug.cgi?id=516759
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@515 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/linux/handler/exception_handler.cc')
-rw-r--r-- | src/client/linux/handler/exception_handler.cc | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc index a9e2fca2..7cb85473 100644 --- a/src/client/linux/handler/exception_handler.cc +++ b/src/client/linux/handler/exception_handler.cc @@ -114,23 +114,26 @@ ExceptionHandler::ExceptionHandler(const std::string &dump_path, MinidumpCallback callback, void *callback_context, bool install_handler) - : filter_(filter), - callback_(callback), - callback_context_(callback_context), - dump_path_(), - handler_installed_(install_handler), - crash_handler_(NULL) { - set_dump_path(dump_path); - - if (install_handler) { - InstallHandlers(); + : filter_(filter), + callback_(callback), + callback_context_(callback_context), + handler_installed_(install_handler) +{ + Init(dump_path, -1); +} - pthread_mutex_lock(&handler_stack_mutex_); - if (handler_stack_ == NULL) - handler_stack_ = new std::vector<ExceptionHandler *>; - handler_stack_->push_back(this); - pthread_mutex_unlock(&handler_stack_mutex_); - } +ExceptionHandler::ExceptionHandler(const std::string &dump_path, + FilterCallback filter, + MinidumpCallback callback, + void* callback_context, + bool install_handler, + const int server_fd) + : filter_(filter), + callback_(callback), + callback_context_(callback_context), + handler_installed_(install_handler) +{ + Init(dump_path, server_fd); } // Runs before crashing: normal context. @@ -138,6 +141,28 @@ ExceptionHandler::~ExceptionHandler() { UninstallHandlers(); } +void ExceptionHandler::Init(const std::string &dump_path, + const int server_fd) +{ + crash_handler_ = NULL; + + if (0 <= server_fd) + crash_generation_client_ + .reset(CrashGenerationClient::TryCreate(server_fd)); + + if (handler_installed_) + InstallHandlers(); + + if (!IsOutOfProcess()) + set_dump_path(dump_path); + + pthread_mutex_lock(&handler_stack_mutex_); + if (handler_stack_ == NULL) + handler_stack_ = new std::vector<ExceptionHandler *>; + handler_stack_->push_back(this); + pthread_mutex_unlock(&handler_stack_mutex_); +} + // Runs before crashing: normal context. bool ExceptionHandler::InstallHandlers() { // We run the signal handlers on an alternative stack because we might have @@ -280,6 +305,9 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) { // This function may run in a compromised context: see the top of the file. bool ExceptionHandler::GenerateDump(CrashContext *context) { + if (IsOutOfProcess()) + return crash_generation_client_->RequestDump(context, sizeof(*context)); + static const unsigned kChildStackSize = 8000; PageAllocator allocator; uint8_t* stack = (uint8_t*) allocator.Alloc(kChildStackSize); |