process_state.h revision e5dc60822e5938fea2ae892ccddb906641ba174e
1// Copyright (c) 2006, Google Inc. 2// All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions are 6// met: 7// 8// * Redistributions of source code must retain the above copyright 9// notice, this list of conditions and the following disclaimer. 10// * Redistributions in binary form must reproduce the above 11// copyright notice, this list of conditions and the following disclaimer 12// in the documentation and/or other materials provided with the 13// distribution. 14// * Neither the name of Google Inc. nor the names of its 15// contributors may be used to endorse or promote products derived from 16// this software without specific prior written permission. 17// 18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30// process_state.h: A snapshot of a process, in a fully-digested state. 31// 32// Author: Mark Mentovai 33 34#ifndef GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__ 35#define GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__ 36 37#include <string> 38#include <vector> 39#include "google_breakpad/processor/system_info.h" 40 41namespace google_breakpad { 42 43using std::string; 44using std::vector; 45 46class CallStack; 47class CodeModules; 48 49class ProcessState { 50 public: 51 ProcessState() : modules_(NULL) { Clear(); } 52 ~ProcessState(); 53 54 // Resets the ProcessState to its default values 55 void Clear(); 56 57 // Accessors. See the data declarations below. 58 u_int32_t time_date_stamp() const { return time_date_stamp_; } 59 bool crashed() const { return crashed_; } 60 string crash_reason() const { return crash_reason_; } 61 u_int64_t crash_address() const { return crash_address_; } 62 int requesting_thread() const { return requesting_thread_; } 63 const vector<CallStack*>* threads() const { return &threads_; } 64 const SystemInfo* system_info() const { return &system_info_; } 65 const CodeModules* modules() const { return modules_; } 66 67 private: 68 // MinidumpProcessor is responsible for building ProcessState objects. 69 friend class MinidumpProcessor; 70 71 // The time-date stamp of the minidump (time_t format) 72 u_int32_t time_date_stamp_; 73 74 // True if the process crashed, false if the dump was produced outside 75 // of an exception handler. 76 bool crashed_; 77 78 // If the process crashed, the type of crash. OS- and possibly CPU- 79 // specific. For example, "EXCEPTION_ACCESS_VIOLATION" (Windows), 80 // "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS" (Mac OS X), "SIGSEGV" 81 // (other Unix). 82 string crash_reason_; 83 84 // If the process crashed, and if crash_reason implicates memory, 85 // the memory address that caused the crash. For data access errors, 86 // this will be the data address that caused the fault. For code errors, 87 // this will be the address of the instruction that caused the fault. 88 u_int64_t crash_address_; 89 90 // The index of the thread that requested a dump be written in the 91 // threads vector. If a dump was produced as a result of a crash, this 92 // will point to the thread that crashed. If the dump was produced as 93 // by user code without crashing, and the dump contains extended Breakpad 94 // information, this will point to the thread that requested the dump. 95 // If the dump was not produced as a result of an exception and no 96 // extended Breakpad information is present, this field will be set to -1, 97 // indicating that the dump thread is not available. 98 int requesting_thread_; 99 100 // Stacks for each thread (except possibly the exception handler 101 // thread) at the time of the crash. 102 vector<CallStack*> threads_; 103 104 // OS and CPU information. 105 SystemInfo system_info_; 106 107 // The modules that were loaded into the process represented by the 108 // ProcessState. 109 const CodeModules *modules_; 110}; 111 112} // namespace google_breakpad 113 114#endif // GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__ 115