15ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// Copyright (c) 2006, Google Inc. 25ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// All rights reserved. 35ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// 45ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// Redistribution and use in source and binary forms, with or without 55ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// modification, are permitted provided that the following conditions are 65ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// met: 75ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// 85ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// * Redistributions of source code must retain the above copyright 95ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// notice, this list of conditions and the following disclaimer. 105ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// * Redistributions in binary form must reproduce the above 115ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// copyright notice, this list of conditions and the following disclaimer 125ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// in the documentation and/or other materials provided with the 135ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// distribution. 145ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// * Neither the name of Google Inc. nor the names of its 155ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// contributors may be used to endorse or promote products derived from 165ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// this software without specific prior written permission. 175ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// 185ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 195ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 205ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 215ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 225ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 235ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 245ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 255ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 265ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 275ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 285ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 305ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// exception_handler.h: MacOS exception handler 315ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// This class can install a Mach exception port handler to trap most common 325ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// programming errors. If an exception occurs, a minidump file will be 335ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// generated which contains detailed information about the process and the 345ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// exception. 355ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 365ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#ifndef CLIENT_MAC_HANDLER_EXCEPTION_HANDLER_H__ 375ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#define CLIENT_MAC_HANDLER_EXCEPTION_HANDLER_H__ 385ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 395ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#include <mach/mach.h> 40f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#include <TargetConditionals.h> 415ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 425ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#include <string> 435ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 44a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org#include "client/mac/handler/ucontext_compat.h" 452cc15ba4327831f917ff55b87e6d5fc3c7750085ted.mielczarek@gmail.com#include "common/scoped_ptr.h" 46315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com 47f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#if !TARGET_OS_IPHONE 48f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#include "client/mac/crash_generation/crash_generation_client.h" 49f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#endif 50f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org 51e5dc60822e5938fea2ae892ccddb906641ba174emmentovainamespace google_breakpad { 525ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 535ac2b9a569890f165478f91670dcdd553ce2d10ewaylonisusing std::string; 545ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 555ac2b9a569890f165478f91670dcdd553ce2d10ewaylonisstruct ExceptionParameters; 565ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 570d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.comenum HandlerThreadMessage { 580d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com // Message ID telling the handler thread to write a dump. 590d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com kWriteDumpMessage = 0, 600d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com // Message ID telling the handler thread to write a dump and include 610d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com // an exception stream. 620d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com kWriteDumpWithExceptionMessage = 1, 630d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com // Message ID telling the handler thread to quit. 640d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com kShutdownMessage = 2 650d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com}; 660d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com 675ac2b9a569890f165478f91670dcdd553ce2d10ewaylonisclass ExceptionHandler { 685ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis public: 69e5dc60822e5938fea2ae892ccddb906641ba174emmentovai // A callback function to run before Breakpad performs any substantial 705ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // processing of an exception. A FilterCallback is called before writing 715ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // a minidump. context is the parameter supplied by the user as 725ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // callback_context when the handler was created. 735ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // 74e5dc60822e5938fea2ae892ccddb906641ba174emmentovai // If a FilterCallback returns true, Breakpad will continue processing, 75e5dc60822e5938fea2ae892ccddb906641ba174emmentovai // attempting to write a minidump. If a FilterCallback returns false, Breakpad 765ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // will immediately report the exception as unhandled without writing a 775ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // minidump, allowing another handler the opportunity to handle it. 785ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis typedef bool (*FilterCallback)(void *context); 7932441cc0608ddaf81885d23acf63f4b53cb73744nealsid 805ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // A callback function to run after the minidump has been written. 815ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // |minidump_id| is a unique id for the dump, so the minidump 825ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // file is <dump_dir>/<minidump_id>.dmp. 8332441cc0608ddaf81885d23acf63f4b53cb73744nealsid // |context| is the value passed into the constructor. 845ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // |succeeded| indicates whether a minidump file was successfully written. 85e5dc60822e5938fea2ae892ccddb906641ba174emmentovai // Return true if the exception was fully handled and breakpad should exit. 8632441cc0608ddaf81885d23acf63f4b53cb73744nealsid // Return false to allow any other exception handlers to process the 875ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // exception. 885ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis typedef bool (*MinidumpCallback)(const char *dump_dir, 895ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis const char *minidump_id, 905ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis void *context, bool succeeded); 915ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 92de2fd15db9a480c807ba337690669538a97756a4ladderbreaker // A callback function which will be called directly if an exception occurs. 93de2fd15db9a480c807ba337690669538a97756a4ladderbreaker // This bypasses the minidump file writing and simply gives the client 94de2fd15db9a480c807ba337690669538a97756a4ladderbreaker // the exception information. 95de2fd15db9a480c807ba337690669538a97756a4ladderbreaker typedef bool (*DirectCallback)( void *context, 96de2fd15db9a480c807ba337690669538a97756a4ladderbreaker int exception_type, 97de2fd15db9a480c807ba337690669538a97756a4ladderbreaker int exception_code, 9861e88c7ad7eb072977b4d4d26bcf8929b75af2d4ted.mielczarek int exception_subcode, 99de2fd15db9a480c807ba337690669538a97756a4ladderbreaker mach_port_t thread_name); 100de2fd15db9a480c807ba337690669538a97756a4ladderbreaker 1015ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Creates a new ExceptionHandler instance to handle writing minidumps. 1025ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Minidump files will be written to dump_path, and the optional callback 1035ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // is called after writing the dump file, as described above. 1045ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // If install_handler is true, then a minidump will be written whenever 1055ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // an unhandled exception occurs. If it is false, minidumps will only 1065ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // be written when WriteMinidump is called. 107315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com // If port_name is non-NULL, attempt to perform out-of-process dump generation 108315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com // If port_name is NULL, in-process dump generation will be used. 10932441cc0608ddaf81885d23acf63f4b53cb73744nealsid ExceptionHandler(const string &dump_path, 1105ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis FilterCallback filter, MinidumpCallback callback, 111315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com void *callback_context, bool install_handler, 112315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com const char *port_name); 113de2fd15db9a480c807ba337690669538a97756a4ladderbreaker 114de2fd15db9a480c807ba337690669538a97756a4ladderbreaker // A special constructor if we want to bypass minidump writing and 115de2fd15db9a480c807ba337690669538a97756a4ladderbreaker // simply get a callback with the exception information. 116de2fd15db9a480c807ba337690669538a97756a4ladderbreaker ExceptionHandler(DirectCallback callback, 117de2fd15db9a480c807ba337690669538a97756a4ladderbreaker void *callback_context, 118de2fd15db9a480c807ba337690669538a97756a4ladderbreaker bool install_handler); 119de2fd15db9a480c807ba337690669538a97756a4ladderbreaker 1205ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis ~ExceptionHandler(); 1215ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 1225ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Get and set the minidump path. 1235ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis string dump_path() const { return dump_path_; } 1245ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis void set_dump_path(const string &dump_path) { 1255ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis dump_path_ = dump_path; 1265ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis dump_path_c_ = dump_path_.c_str(); 1275ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_. 1285ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis } 12932441cc0608ddaf81885d23acf63f4b53cb73744nealsid 1305ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Writes a minidump immediately. This can be used to capture the 1315ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // execution state independently of a crash. Returns true on success. 1320d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com bool WriteMinidump() { 1330d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com return WriteMinidump(false); 1340d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com } 1350d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com 1360d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com bool WriteMinidump(bool write_exception_stream); 1375ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 1385ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Convenience form of WriteMinidump which does not require an 1395ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // ExceptionHandler instance. 1405ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis static bool WriteMinidump(const string &dump_path, MinidumpCallback callback, 1410d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com void *callback_context) { 1420d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com return WriteMinidump(dump_path, false, callback, callback_context); 1430d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com } 1440d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com 1450d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com static bool WriteMinidump(const string &dump_path, 1460d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com bool write_exception_stream, 1470d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com MinidumpCallback callback, 1485ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis void *callback_context); 1495ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 150144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com // Write a minidump of child immediately. This can be used to capture 151144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com // the execution state of a child process independently of a crash. 152144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com static bool WriteMinidumpForChild(mach_port_t child, 153144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com mach_port_t child_blamed_thread, 154144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com const std::string &dump_path, 155144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com MinidumpCallback callback, 156144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com void *callback_context); 157144938cf22243407a56601bd5b75147f796a8424ted.mielczarek@gmail.com 158315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com // Returns whether out-of-process dump generation is used or not. 159315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com bool IsOutOfProcess() const { 160f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#if TARGET_OS_IPHONE 161f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org return false; 162f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#else 163315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com return crash_generation_client_.get() != NULL; 164f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#endif 165315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com } 166315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com 1675ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis private: 1685ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Install the mach exception handler 1695ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis bool InstallHandler(); 1705ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 1715ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Uninstall the mach exception handler (if any) 172de2fd15db9a480c807ba337690669538a97756a4ladderbreaker bool UninstallHandler(bool in_exception); 17332441cc0608ddaf81885d23acf63f4b53cb73744nealsid 1745ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Setup the handler thread, and if |install_handler| is true, install the 1755ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // mach exception port handler 1765ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis bool Setup(bool install_handler); 17732441cc0608ddaf81885d23acf63f4b53cb73744nealsid 1785ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Uninstall the mach exception handler (if any) and terminate the helper 1795ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // thread 1805ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis bool Teardown(); 1815ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 1820d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com // Send a mach message to the exception handler. Return true on 1830d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com // success, false otherwise. 1840d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com bool SendMessageToHandlerThread(HandlerThreadMessage message_id); 1855ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 18660a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org // All minidump writing goes through this one routine. 18760a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org // |task_context| can be NULL. If not, it will be used to retrieve the 18860a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org // context of the current thread, instead of using |thread_get_state|. 1890d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com bool WriteMinidumpWithException(int exception_type, 1900d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com int exception_code, 1910d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com int exception_subcode, 192a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org breakpad_ucontext_t *task_context, 1930d9bd40775211c223c75543890d862135f677d67ted.mielczarek@gmail.com mach_port_t thread_name, 194094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org bool exit_after_write, 195094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org bool report_current_thread); 1965ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 1975ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // When installed, this static function will be call from a newly created 1985ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // pthread with |this| as the argument 1995ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis static void *WaitForMessage(void *exception_handler_class); 2005ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 201094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org // Signal handler for SIGABRT. 202094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org static void SignalHandler(int sig, siginfo_t* info, void* uc); 203094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org 2045ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // disallow copy ctor and operator= 2055ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis explicit ExceptionHandler(const ExceptionHandler &); 2065ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis void operator=(const ExceptionHandler &); 2075ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 2085ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Generates a new ID and stores it in next_minidump_id_, and stores the 2095ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // path of the next minidump to be written in next_minidump_path_. 2105ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis void UpdateNextID(); 211530a7ad99eba824dcca7fd300e85f1faa5828a3dladderbreaker 21232441cc0608ddaf81885d23acf63f4b53cb73744nealsid // These functions will suspend/resume all threads except for the 213530a7ad99eba824dcca7fd300e85f1faa5828a3dladderbreaker // reporting thread 214530a7ad99eba824dcca7fd300e85f1faa5828a3dladderbreaker bool SuspendThreads(); 215530a7ad99eba824dcca7fd300e85f1faa5828a3dladderbreaker bool ResumeThreads(); 21632441cc0608ddaf81885d23acf63f4b53cb73744nealsid 2175ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // The destination directory for the minidump 2185ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis string dump_path_; 21932441cc0608ddaf81885d23acf63f4b53cb73744nealsid 2205ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // The basename of the next minidump w/o extension 2215ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis string next_minidump_id_; 22232441cc0608ddaf81885d23acf63f4b53cb73744nealsid 2235ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // The full path to the next minidump to be written, including extension 2245ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis string next_minidump_path_; 22532441cc0608ddaf81885d23acf63f4b53cb73744nealsid 2265ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Pointers to the UTF-8 versions of above 2275ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis const char *dump_path_c_; 2285ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis const char *next_minidump_id_c_; 2295ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis const char *next_minidump_path_c_; 2305ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 2315ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // The callback function and pointer to be passed back after the minidump 2325ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // has been written 2335ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis FilterCallback filter_; 2345ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis MinidumpCallback callback_; 2355ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis void *callback_context_; 2365ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 237de2fd15db9a480c807ba337690669538a97756a4ladderbreaker // The callback function to be passed back when we don't want a minidump 238de2fd15db9a480c807ba337690669538a97756a4ladderbreaker // file to be written 239de2fd15db9a480c807ba337690669538a97756a4ladderbreaker DirectCallback directCallback_; 240de2fd15db9a480c807ba337690669538a97756a4ladderbreaker 2415ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // The thread that is created for the handler 2425ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis pthread_t handler_thread_; 2435ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 2445ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // The port that is waiting on an exception message to be sent, if the 2455ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // handler is installed 2465ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis mach_port_t handler_port_; 2475ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 2485ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // These variables save the previous exception handler's data so that it 2495ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // can be re-installed when this handler is uninstalled 2505ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis ExceptionParameters *previous_; 2515ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 2525ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // True, if we've installed the exception handler 2535ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis bool installed_exception_handler_; 25432441cc0608ddaf81885d23acf63f4b53cb73744nealsid 2555ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // True, if we're in the process of uninstalling the exception handler and 2565ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // the thread. 2575ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis bool is_in_teardown_; 25832441cc0608ddaf81885d23acf63f4b53cb73744nealsid 2595ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // Save the last result of the last minidump 2605ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis bool last_minidump_write_result_; 26132441cc0608ddaf81885d23acf63f4b53cb73744nealsid 26232441cc0608ddaf81885d23acf63f4b53cb73744nealsid // A mutex for use when writing out a minidump that was requested on a 2635ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // thread other than the exception handler. 2645ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis pthread_mutex_t minidump_write_mutex_; 26532441cc0608ddaf81885d23acf63f4b53cb73744nealsid 2665ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis // True, if we're using the mutext to indicate when mindump writing occurs 2675ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis bool use_minidump_write_mutex_; 268315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com 269094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org // Old signal handler for SIGABRT. Used to be able to restore it when 270094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org // uninstalling. 271094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org scoped_ptr<struct sigaction> old_handler_; 272094ca0f8a92d3f154fc78e31c2f6722b0785d5c5qsr@chromium.org 273f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#if !TARGET_OS_IPHONE 274315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com // Client for out-of-process dump generation. 275315fd78199bc606ee02cb085dacadd58e0fc40c8ted.mielczarek@gmail.com scoped_ptr<CrashGenerationClient> crash_generation_client_; 276f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#endif 2775ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis}; 2785ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 279e5dc60822e5938fea2ae892ccddb906641ba174emmentovai} // namespace google_breakpad 2805ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis 2815ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#endif // CLIENT_MAC_HANDLER_EXCEPTION_HANDLER_H__ 282