toolkit/crashreporter/google-breakpad/src/client/windows/handler/exception_handler.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2006, Google Inc.
michael@0 2 // All rights reserved.
michael@0 3 //
michael@0 4 // Redistribution and use in source and binary forms, with or without
michael@0 5 // modification, are permitted provided that the following conditions are
michael@0 6 // met:
michael@0 7 //
michael@0 8 // * Redistributions of source code must retain the above copyright
michael@0 9 // notice, this list of conditions and the following disclaimer.
michael@0 10 // * Redistributions in binary form must reproduce the above
michael@0 11 // copyright notice, this list of conditions and the following disclaimer
michael@0 12 // in the documentation and/or other materials provided with the
michael@0 13 // distribution.
michael@0 14 // * Neither the name of Google Inc. nor the names of its
michael@0 15 // contributors may be used to endorse or promote products derived from
michael@0 16 // this software without specific prior written permission.
michael@0 17 //
michael@0 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 29
michael@0 30 // ExceptionHandler can write a minidump file when an exception occurs,
michael@0 31 // or when WriteMinidump() is called explicitly by your program.
michael@0 32 //
michael@0 33 // To have the exception handler write minidumps when an uncaught exception
michael@0 34 // (crash) occurs, you should create an instance early in the execution
michael@0 35 // of your program, and keep it around for the entire time you want to
michael@0 36 // have crash handling active (typically, until shutdown).
michael@0 37 //
michael@0 38 // If you want to write minidumps without installing the exception handler,
michael@0 39 // you can create an ExceptionHandler with install_handler set to false,
michael@0 40 // then call WriteMinidump. You can also use this technique if you want to
michael@0 41 // use different minidump callbacks for different call sites.
michael@0 42 //
michael@0 43 // In either case, a callback function is called when a minidump is written,
michael@0 44 // which receives the unqiue id of the minidump. The caller can use this
michael@0 45 // id to collect and write additional application state, and to launch an
michael@0 46 // external crash-reporting application.
michael@0 47 //
michael@0 48 // It is important that creation and destruction of ExceptionHandler objects
michael@0 49 // be nested cleanly, when using install_handler = true.
michael@0 50 // Avoid the following pattern:
michael@0 51 // ExceptionHandler *e = new ExceptionHandler(...);
michael@0 52 // ExceptionHandler *f = new ExceptionHandler(...);
michael@0 53 // delete e;
michael@0 54 // This will put the exception filter stack into an inconsistent state.
michael@0 55
michael@0 56 #ifndef CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__
michael@0 57 #define CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__
michael@0 58
michael@0 59 #include <stdlib.h>
michael@0 60 #include <Windows.h>
michael@0 61 #include <DbgHelp.h>
michael@0 62 #include <rpc.h>
michael@0 63
michael@0 64 #pragma warning( push )
michael@0 65 // Disable exception handler warnings.
michael@0 66 #pragma warning( disable : 4530 )
michael@0 67
michael@0 68 #include <list>
michael@0 69 #include <string>
michael@0 70 #include <vector>
michael@0 71
michael@0 72 #include "client/windows/common/ipc_protocol.h"
michael@0 73 #include "client/windows/crash_generation/crash_generation_client.h"
michael@0 74 #include "common/scoped_ptr.h"
michael@0 75 #include "google_breakpad/common/minidump_format.h"
michael@0 76
michael@0 77 namespace google_breakpad {
michael@0 78
michael@0 79 using std::vector;
michael@0 80 using std::wstring;
michael@0 81
michael@0 82 // These entries store a list of memory regions that the client wants included
michael@0 83 // in the minidump.
michael@0 84 struct AppMemory {
michael@0 85 ULONG64 ptr;
michael@0 86 ULONG length;
michael@0 87
michael@0 88 bool operator==(const struct AppMemory& other) const {
michael@0 89 return ptr == other.ptr;
michael@0 90 }
michael@0 91
michael@0 92 bool operator==(const void* other) const {
michael@0 93 return ptr == reinterpret_cast<ULONG64>(other);
michael@0 94 }
michael@0 95 };
michael@0 96 typedef std::list<AppMemory> AppMemoryList;
michael@0 97
michael@0 98 class ExceptionHandler {
michael@0 99 public:
michael@0 100 // A callback function to run before Breakpad performs any substantial
michael@0 101 // processing of an exception. A FilterCallback is called before writing
michael@0 102 // a minidump. context is the parameter supplied by the user as
michael@0 103 // callback_context when the handler was created. exinfo points to the
michael@0 104 // exception record, if any; assertion points to assertion information,
michael@0 105 // if any.
michael@0 106 //
michael@0 107 // If a FilterCallback returns true, Breakpad will continue processing,
michael@0 108 // attempting to write a minidump. If a FilterCallback returns false,
michael@0 109 // Breakpad will immediately report the exception as unhandled without
michael@0 110 // writing a minidump, allowing another handler the opportunity to handle it.
michael@0 111 typedef bool (*FilterCallback)(void* context, EXCEPTION_POINTERS* exinfo,
michael@0 112 MDRawAssertionInfo* assertion);
michael@0 113
michael@0 114 // A callback function to run after the minidump has been written.
michael@0 115 // minidump_id is a unique id for the dump, so the minidump
michael@0 116 // file is <dump_path>\<minidump_id>.dmp. context is the parameter supplied
michael@0 117 // by the user as callback_context when the handler was created. exinfo
michael@0 118 // points to the exception record, or NULL if no exception occurred.
michael@0 119 // succeeded indicates whether a minidump file was successfully written.
michael@0 120 // assertion points to information about an assertion if the handler was
michael@0 121 // invoked by an assertion.
michael@0 122 //
michael@0 123 // If an exception occurred and the callback returns true, Breakpad will treat
michael@0 124 // the exception as fully-handled, suppressing any other handlers from being
michael@0 125 // notified of the exception. If the callback returns false, Breakpad will
michael@0 126 // treat the exception as unhandled, and allow another handler to handle it.
michael@0 127 // If there are no other handlers, Breakpad will report the exception to the
michael@0 128 // system as unhandled, allowing a debugger or native crash dialog the
michael@0 129 // opportunity to handle the exception. Most callback implementations
michael@0 130 // should normally return the value of |succeeded|, or when they wish to
michael@0 131 // not report an exception of handled, false. Callbacks will rarely want to
michael@0 132 // return true directly (unless |succeeded| is true).
michael@0 133 //
michael@0 134 // For out-of-process dump generation, dump path and minidump ID will always
michael@0 135 // be NULL. In case of out-of-process dump generation, the dump path and
michael@0 136 // minidump id are controlled by the server process and are not communicated
michael@0 137 // back to the crashing process.
michael@0 138 typedef bool (*MinidumpCallback)(const wchar_t* dump_path,
michael@0 139 const wchar_t* minidump_id,
michael@0 140 void* context,
michael@0 141 EXCEPTION_POINTERS* exinfo,
michael@0 142 MDRawAssertionInfo* assertion,
michael@0 143 bool succeeded);
michael@0 144
michael@0 145 // HandlerType specifies which types of handlers should be installed, if
michael@0 146 // any. Use HANDLER_NONE for an ExceptionHandler that remains idle,
michael@0 147 // without catching any failures on its own. This type of handler may
michael@0 148 // still be triggered by calling WriteMinidump. Otherwise, use a
michael@0 149 // combination of the other HANDLER_ values, or HANDLER_ALL to install
michael@0 150 // all handlers.
michael@0 151 enum HandlerType {
michael@0 152 HANDLER_NONE = 0,
michael@0 153 HANDLER_EXCEPTION = 1 << 0, // SetUnhandledExceptionFilter
michael@0 154 HANDLER_INVALID_PARAMETER = 1 << 1, // _set_invalid_parameter_handler
michael@0 155 HANDLER_PURECALL = 1 << 2, // _set_purecall_handler
michael@0 156 HANDLER_ALL = HANDLER_EXCEPTION |
michael@0 157 HANDLER_INVALID_PARAMETER |
michael@0 158 HANDLER_PURECALL
michael@0 159 };
michael@0 160
michael@0 161 // Creates a new ExceptionHandler instance to handle writing minidumps.
michael@0 162 // Before writing a minidump, the optional filter callback will be called.
michael@0 163 // Its return value determines whether or not Breakpad should write a
michael@0 164 // minidump. Minidump files will be written to dump_path, and the optional
michael@0 165 // callback is called after writing the dump file, as described above.
michael@0 166 // handler_types specifies the types of handlers that should be installed.
michael@0 167 ExceptionHandler(const wstring& dump_path,
michael@0 168 FilterCallback filter,
michael@0 169 MinidumpCallback callback,
michael@0 170 void* callback_context,
michael@0 171 int handler_types);
michael@0 172
michael@0 173 // Creates a new ExceptionHandler instance that can attempt to perform
michael@0 174 // out-of-process dump generation if pipe_name is not NULL. If pipe_name is
michael@0 175 // NULL, or if out-of-process dump generation registration step fails,
michael@0 176 // in-process dump generation will be used. This also allows specifying
michael@0 177 // the dump type to generate.
michael@0 178 ExceptionHandler(const wstring& dump_path,
michael@0 179 FilterCallback filter,
michael@0 180 MinidumpCallback callback,
michael@0 181 void* callback_context,
michael@0 182 int handler_types,
michael@0 183 MINIDUMP_TYPE dump_type,
michael@0 184 const wchar_t* pipe_name,
michael@0 185 const CustomClientInfo* custom_info);
michael@0 186
michael@0 187 // As above, creates a new ExceptionHandler instance to perform
michael@0 188 // out-of-process dump generation if the given pipe_handle is not NULL.
michael@0 189 ExceptionHandler(const wstring& dump_path,
michael@0 190 FilterCallback filter,
michael@0 191 MinidumpCallback callback,
michael@0 192 void* callback_context,
michael@0 193 int handler_types,
michael@0 194 MINIDUMP_TYPE dump_type,
michael@0 195 HANDLE pipe_handle,
michael@0 196 const CustomClientInfo* custom_info);
michael@0 197
michael@0 198 ~ExceptionHandler();
michael@0 199
michael@0 200 // Get and set the minidump path.
michael@0 201 wstring dump_path() const { return dump_path_; }
michael@0 202 void set_dump_path(const wstring &dump_path) {
michael@0 203 dump_path_ = dump_path;
michael@0 204 dump_path_c_ = dump_path_.c_str();
michael@0 205 UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_.
michael@0 206 }
michael@0 207
michael@0 208 // Requests that a previously reported crash be uploaded.
michael@0 209 bool RequestUpload(DWORD crash_id);
michael@0 210
michael@0 211 // Writes a minidump immediately. This can be used to capture the
michael@0 212 // execution state independently of a crash. Returns true on success.
michael@0 213 bool WriteMinidump();
michael@0 214
michael@0 215 // Writes a minidump immediately, with the user-supplied exception
michael@0 216 // information.
michael@0 217 bool WriteMinidumpForException(EXCEPTION_POINTERS* exinfo);
michael@0 218
michael@0 219 // Convenience form of WriteMinidump which does not require an
michael@0 220 // ExceptionHandler instance.
michael@0 221 static bool WriteMinidump(const wstring &dump_path,
michael@0 222 MinidumpCallback callback, void* callback_context);
michael@0 223
michael@0 224 // Write a minidump of |child| immediately. This can be used to
michael@0 225 // capture the execution state of |child| independently of a crash.
michael@0 226 // Pass a meaningful |child_blamed_thread| to make that thread in
michael@0 227 // the child process the one from which a crash signature is
michael@0 228 // extracted.
michael@0 229 static bool WriteMinidumpForChild(HANDLE child,
michael@0 230 DWORD child_blamed_thread,
michael@0 231 const wstring& dump_path,
michael@0 232 MinidumpCallback callback,
michael@0 233 void* callback_context);
michael@0 234
michael@0 235 // Get the thread ID of the thread requesting the dump (either the exception
michael@0 236 // thread or any other thread that called WriteMinidump directly). This
michael@0 237 // may be useful if you want to include additional thread state in your
michael@0 238 // dumps.
michael@0 239 DWORD get_requesting_thread_id() const { return requesting_thread_id_; }
michael@0 240
michael@0 241 // Controls behavior of EXCEPTION_BREAKPOINT and EXCEPTION_SINGLE_STEP.
michael@0 242 bool get_handle_debug_exceptions() const { return handle_debug_exceptions_; }
michael@0 243 void set_handle_debug_exceptions(bool handle_debug_exceptions) {
michael@0 244 handle_debug_exceptions_ = handle_debug_exceptions;
michael@0 245 }
michael@0 246
michael@0 247 // Returns whether out-of-process dump generation is used or not.
michael@0 248 bool IsOutOfProcess() const { return crash_generation_client_.get() != NULL; }
michael@0 249
michael@0 250 // Calling RegisterAppMemory(p, len) causes len bytes starting
michael@0 251 // at address p to be copied to the minidump when a crash happens.
michael@0 252 void RegisterAppMemory(void* ptr, size_t length);
michael@0 253 void UnregisterAppMemory(void* ptr);
michael@0 254
michael@0 255 private:
michael@0 256 friend class AutoExceptionHandler;
michael@0 257
michael@0 258 // Initializes the instance with given values.
michael@0 259 void Initialize(const wstring& dump_path,
michael@0 260 FilterCallback filter,
michael@0 261 MinidumpCallback callback,
michael@0 262 void* callback_context,
michael@0 263 int handler_types,
michael@0 264 MINIDUMP_TYPE dump_type,
michael@0 265 const wchar_t* pipe_name,
michael@0 266 HANDLE pipe_handle,
michael@0 267 const CustomClientInfo* custom_info);
michael@0 268
michael@0 269 // Function pointer type for MiniDumpWriteDump, which is looked up
michael@0 270 // dynamically.
michael@0 271 typedef BOOL (WINAPI *MiniDumpWriteDump_type)(
michael@0 272 HANDLE hProcess,
michael@0 273 DWORD dwPid,
michael@0 274 HANDLE hFile,
michael@0 275 MINIDUMP_TYPE DumpType,
michael@0 276 CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
michael@0 277 CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
michael@0 278 CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
michael@0 279
michael@0 280 // Function pointer type for UuidCreate, which is looked up dynamically.
michael@0 281 typedef RPC_STATUS (RPC_ENTRY *UuidCreate_type)(UUID* Uuid);
michael@0 282
michael@0 283 // Runs the main loop for the exception handler thread.
michael@0 284 static DWORD WINAPI ExceptionHandlerThreadMain(void* lpParameter);
michael@0 285
michael@0 286 // Called on the exception thread when an unhandled exception occurs.
michael@0 287 // Signals the exception handler thread to handle the exception.
michael@0 288 static LONG WINAPI HandleException(EXCEPTION_POINTERS* exinfo);
michael@0 289
michael@0 290 #if _MSC_VER >= 1400 // MSVC 2005/8
michael@0 291 // This function will be called by some CRT functions when they detect
michael@0 292 // that they were passed an invalid parameter. Note that in _DEBUG builds,
michael@0 293 // the CRT may display an assertion dialog before calling this function,
michael@0 294 // and the function will not be called unless the assertion dialog is
michael@0 295 // dismissed by clicking "Ignore."
michael@0 296 static void HandleInvalidParameter(const wchar_t* expression,
michael@0 297 const wchar_t* function,
michael@0 298 const wchar_t* file,
michael@0 299 unsigned int line,
michael@0 300 uintptr_t reserved);
michael@0 301 #endif // _MSC_VER >= 1400
michael@0 302
michael@0 303 // This function will be called by the CRT when a pure virtual
michael@0 304 // function is called.
michael@0 305 static void HandlePureVirtualCall();
michael@0 306
michael@0 307 // This is called on the exception thread or on another thread that
michael@0 308 // the user wishes to produce a dump from. It calls
michael@0 309 // WriteMinidumpWithException on the handler thread, avoiding stack
michael@0 310 // overflows and inconsistent dumps due to writing the dump from
michael@0 311 // the exception thread. If the dump is requested as a result of an
michael@0 312 // exception, exinfo contains exception information, otherwise, it
michael@0 313 // is NULL. If the dump is requested as a result of an assertion
michael@0 314 // (such as an invalid parameter being passed to a CRT function),
michael@0 315 // assertion contains data about the assertion, otherwise, it is NULL.
michael@0 316 bool WriteMinidumpOnHandlerThread(EXCEPTION_POINTERS* exinfo,
michael@0 317 MDRawAssertionInfo* assertion);
michael@0 318
michael@0 319 // This function is called on the handler thread. It calls into
michael@0 320 // WriteMinidumpWithExceptionForProcess() with a handle to the
michael@0 321 // current process. requesting_thread_id is the ID of the thread
michael@0 322 // that requested the dump. If the dump is requested as a result of
michael@0 323 // an exception, exinfo contains exception information, otherwise,
michael@0 324 // it is NULL.
michael@0 325 bool WriteMinidumpWithException(DWORD requesting_thread_id,
michael@0 326 EXCEPTION_POINTERS* exinfo,
michael@0 327 MDRawAssertionInfo* assertion);
michael@0 328
michael@0 329 // This function is used as a callback when calling MinidumpWriteDump,
michael@0 330 // in order to add additional memory regions to the dump.
michael@0 331 static BOOL CALLBACK MinidumpWriteDumpCallback(
michael@0 332 PVOID context,
michael@0 333 const PMINIDUMP_CALLBACK_INPUT callback_input,
michael@0 334 PMINIDUMP_CALLBACK_OUTPUT callback_output);
michael@0 335
michael@0 336 // This function does the actual writing of a minidump. It is
michael@0 337 // called on the handler thread. requesting_thread_id is the ID of
michael@0 338 // the thread that requested the dump, if that information is
michael@0 339 // meaningful. If the dump is requested as a result of an
michael@0 340 // exception, exinfo contains exception information, otherwise, it
michael@0 341 // is NULL. process is the one that will be dumped. If
michael@0 342 // requesting_thread_id is meaningful and should be added to the
michael@0 343 // minidump, write_requester_stream is |true|.
michael@0 344 bool WriteMinidumpWithExceptionForProcess(DWORD requesting_thread_id,
michael@0 345 EXCEPTION_POINTERS* exinfo,
michael@0 346 MDRawAssertionInfo* assertion,
michael@0 347 HANDLE process,
michael@0 348 bool write_requester_stream);
michael@0 349
michael@0 350 // Generates a new ID and stores it in next_minidump_id_, and stores the
michael@0 351 // path of the next minidump to be written in next_minidump_path_.
michael@0 352 void UpdateNextID();
michael@0 353
michael@0 354 FilterCallback filter_;
michael@0 355 MinidumpCallback callback_;
michael@0 356 void* callback_context_;
michael@0 357
michael@0 358 scoped_ptr<CrashGenerationClient> crash_generation_client_;
michael@0 359
michael@0 360 // The directory in which a minidump will be written, set by the dump_path
michael@0 361 // argument to the constructor, or set_dump_path.
michael@0 362 wstring dump_path_;
michael@0 363
michael@0 364 // The basename of the next minidump to be written, without the extension.
michael@0 365 wstring next_minidump_id_;
michael@0 366
michael@0 367 // The full pathname of the next minidump to be written, including the file
michael@0 368 // extension.
michael@0 369 wstring next_minidump_path_;
michael@0 370
michael@0 371 // Pointers to C-string representations of the above. These are set when
michael@0 372 // the above wstring versions are set in order to avoid calling c_str during
michael@0 373 // an exception, as c_str may attempt to allocate heap memory. These
michael@0 374 // pointers are not owned by the ExceptionHandler object, but their lifetimes
michael@0 375 // should be equivalent to the lifetimes of the associated wstring, provided
michael@0 376 // that the wstrings are not altered.
michael@0 377 const wchar_t* dump_path_c_;
michael@0 378 const wchar_t* next_minidump_id_c_;
michael@0 379 const wchar_t* next_minidump_path_c_;
michael@0 380
michael@0 381 HMODULE dbghelp_module_;
michael@0 382 MiniDumpWriteDump_type minidump_write_dump_;
michael@0 383 MINIDUMP_TYPE dump_type_;
michael@0 384
michael@0 385 HMODULE rpcrt4_module_;
michael@0 386 UuidCreate_type uuid_create_;
michael@0 387
michael@0 388 // Tracks the handler types that were installed according to the
michael@0 389 // handler_types constructor argument.
michael@0 390 int handler_types_;
michael@0 391
michael@0 392 // When installed_handler_ is true, previous_filter_ is the unhandled
michael@0 393 // exception filter that was set prior to installing ExceptionHandler as
michael@0 394 // the unhandled exception filter and pointing it to |this|. NULL indicates
michael@0 395 // that there is no previous unhandled exception filter.
michael@0 396 LPTOP_LEVEL_EXCEPTION_FILTER previous_filter_;
michael@0 397
michael@0 398 #if _MSC_VER >= 1400 // MSVC 2005/8
michael@0 399 // Beginning in VC 8, the CRT provides an invalid parameter handler that will
michael@0 400 // be called when some CRT functions are passed invalid parameters. In
michael@0 401 // earlier CRTs, the same conditions would cause unexpected behavior or
michael@0 402 // crashes.
michael@0 403 _invalid_parameter_handler previous_iph_;
michael@0 404 #endif // _MSC_VER >= 1400
michael@0 405
michael@0 406 // The CRT allows you to override the default handler for pure
michael@0 407 // virtual function calls.
michael@0 408 _purecall_handler previous_pch_;
michael@0 409
michael@0 410 // The exception handler thread.
michael@0 411 HANDLE handler_thread_;
michael@0 412
michael@0 413 // True if the exception handler is being destroyed.
michael@0 414 // Starting with MSVC 2005, Visual C has stronger guarantees on volatile vars.
michael@0 415 // It has release semantics on write and acquire semantics on reads.
michael@0 416 // See the msdn documentation.
michael@0 417 volatile bool is_shutdown_;
michael@0 418
michael@0 419 // The critical section enforcing the requirement that only one exception be
michael@0 420 // handled by a handler at a time.
michael@0 421 CRITICAL_SECTION handler_critical_section_;
michael@0 422
michael@0 423 // Semaphores used to move exception handling between the exception thread
michael@0 424 // and the handler thread. handler_start_semaphore_ is signalled by the
michael@0 425 // exception thread to wake up the handler thread when an exception occurs.
michael@0 426 // handler_finish_semaphore_ is signalled by the handler thread to wake up
michael@0 427 // the exception thread when handling is complete.
michael@0 428 HANDLE handler_start_semaphore_;
michael@0 429 HANDLE handler_finish_semaphore_;
michael@0 430
michael@0 431 // The next 2 fields contain data passed from the requesting thread to
michael@0 432 // the handler thread.
michael@0 433
michael@0 434 // The thread ID of the thread requesting the dump (either the exception
michael@0 435 // thread or any other thread that called WriteMinidump directly).
michael@0 436 DWORD requesting_thread_id_;
michael@0 437
michael@0 438 // The exception info passed to the exception handler on the exception
michael@0 439 // thread, if an exception occurred. NULL for user-requested dumps.
michael@0 440 EXCEPTION_POINTERS* exception_info_;
michael@0 441
michael@0 442 // If the handler is invoked due to an assertion, this will contain a
michael@0 443 // pointer to the assertion information. It is NULL at other times.
michael@0 444 MDRawAssertionInfo* assertion_;
michael@0 445
michael@0 446 // The return value of the handler, passed from the handler thread back to
michael@0 447 // the requesting thread.
michael@0 448 bool handler_return_value_;
michael@0 449
michael@0 450 // If true, the handler will intercept EXCEPTION_BREAKPOINT and
michael@0 451 // EXCEPTION_SINGLE_STEP exceptions. Leave this false (the default)
michael@0 452 // to not interfere with debuggers.
michael@0 453 bool handle_debug_exceptions_;
michael@0 454
michael@0 455 // Callers can request additional memory regions to be included in
michael@0 456 // the dump.
michael@0 457 AppMemoryList app_memory_info_;
michael@0 458
michael@0 459 // A stack of ExceptionHandler objects that have installed unhandled
michael@0 460 // exception filters. This vector is used by HandleException to determine
michael@0 461 // which ExceptionHandler object to route an exception to. When an
michael@0 462 // ExceptionHandler is created with install_handler true, it will append
michael@0 463 // itself to this list.
michael@0 464 static vector<ExceptionHandler*>* handler_stack_;
michael@0 465
michael@0 466 // The index of the ExceptionHandler in handler_stack_ that will handle the
michael@0 467 // next exception. Note that 0 means the last entry in handler_stack_, 1
michael@0 468 // means the next-to-last entry, and so on. This is used by HandleException
michael@0 469 // to support multiple stacked Breakpad handlers.
michael@0 470 static LONG handler_stack_index_;
michael@0 471
michael@0 472 // handler_stack_critical_section_ guards operations on handler_stack_ and
michael@0 473 // handler_stack_index_. The critical section is initialized by the
michael@0 474 // first instance of the class and destroyed by the last instance of it.
michael@0 475 static CRITICAL_SECTION handler_stack_critical_section_;
michael@0 476
michael@0 477 // The number of instances of this class.
michael@0 478 volatile static LONG instance_count_;
michael@0 479
michael@0 480 // disallow copy ctor and operator=
michael@0 481 explicit ExceptionHandler(const ExceptionHandler &);
michael@0 482 void operator=(const ExceptionHandler &);
michael@0 483 };
michael@0 484
michael@0 485 } // namespace google_breakpad
michael@0 486
michael@0 487 #pragma warning( pop )
michael@0 488
michael@0 489 #endif // CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__

mercurial