1 // Copyright 2019 Google LLC 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google LLC nor the names of its 14 // contributors may be used to endorse or promote products derived from 15 // this software without specific prior written permission. 16 // 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // 29 // exception_record.h: A snapshot of an exception record. 30 // 31 // Author: Ivan Penkov 32 33 #ifndef THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_ 34 #define THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_ 35 36 #include <vector> 37 38 namespace google_breakpad { 39 40 // Additional argument that describes the exception. 41 class ExceptionParameter { 42 public: ExceptionParameter(uint64_t value,const string & description)43 ExceptionParameter(uint64_t value, const string& description) 44 : value_(value), description_(description) {} 45 // Accessors. See the data declarations below. value()46 uint64_t value() const { return value_; } set_value(uint64_t value)47 void set_value(uint64_t value) { value_ = value; } description()48 const string& description() const { return description_; } set_description(const string & description)49 void set_description(const string& description) { 50 description_ = description; 51 } 52 53 private: 54 // Parameter value. 55 uint64_t value_; 56 // Human readable description/interpretation of the above value. 57 string description_; 58 }; 59 60 // A snapshot of an exception record. Contains exception record details: code, 61 // flags, address, parameters. 62 class ExceptionRecord { 63 public: 64 // Accessors. See the data declarations below. code()65 uint32_t code() const { return code_; } code_description()66 const string& code_description() const { return code_description_; } set_code(uint32_t code,const string & description)67 void set_code(uint32_t code, const string& description) { 68 code_ = code; 69 code_description_ = description; 70 } 71 flags()72 uint32_t flags() const { return flags_; } flags_description()73 const string& flags_description() const { return flags_description_; } set_flags(uint32_t flags,const string & description)74 void set_flags(uint32_t flags, const string& description) { 75 flags_ = flags; 76 flags_description_ = description; 77 } 78 nested_exception_record_address()79 uint64_t nested_exception_record_address() const { 80 return nested_exception_record_address_; 81 } set_nested_exception_record_address(uint64_t nested_exception_record_address)82 void set_nested_exception_record_address( 83 uint64_t nested_exception_record_address) { 84 nested_exception_record_address_ = nested_exception_record_address; 85 } 86 address()87 uint64_t address() const { return address_; } set_address(uint64_t address)88 void set_address(uint64_t address) { address_ = address; } 89 parameters()90 const std::vector<ExceptionParameter>* parameters() const { 91 return ¶meters_; 92 } add_parameter(uint64_t value,const string & description)93 void add_parameter(uint64_t value, const string& description) { 94 parameters_.push_back(ExceptionParameter(value, description)); 95 } 96 97 private: 98 // Exception code. 99 uint32_t code_; 100 string code_description_; 101 102 // Exception flags. 103 uint32_t flags_; 104 string flags_description_; 105 106 // The address of an associated MDException structure. Exception records can 107 // be chained together to provide additional information when nested 108 // exceptions occur. 109 uint64_t nested_exception_record_address_; 110 111 // The memory address that caused the exception. For data access errors, 112 // this will be the data address that caused the fault. For code errors, 113 // this will be the address of the instruction that caused the fault. 114 uint64_t address_; 115 116 // An array of additional arguments that describe the exception. 117 std::vector<ExceptionParameter> parameters_; 118 }; 119 120 } // namespace google_breakpad 121 122 123 #endif // THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_ 124