• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2019 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 // exception_record.h: A snapshot of an exception record.
31 //
32 // Author: Ivan Penkov
33 
34 #ifndef THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_
35 #define THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_
36 
37 #include <vector>
38 
39 namespace google_breakpad {
40 
41 // Additional argument that describes the exception.
42 class ExceptionParameter {
43  public:
ExceptionParameter(uint64_t value,const string & description)44   ExceptionParameter(uint64_t value, const string& description)
45       : value_(value), description_(description) {}
46   // Accessors. See the data declarations below.
value()47   uint64_t value() const { return value_; }
set_value(uint64_t value)48   void set_value(uint64_t value) { value_ = value; }
description()49   const string& description() const { return description_; }
set_description(const string & description)50   void set_description(const string& description) {
51     description_ = description;
52   }
53 
54  private:
55   // Parameter value.
56   uint64_t value_;
57   // Human readable description/interpretation of the above value.
58   string description_;
59 };
60 
61 // A snapshot of an exception record. Contains exception record details: code,
62 // flags, address, parameters.
63 class ExceptionRecord {
64  public:
65   // Accessors. See the data declarations below.
code()66   uint32_t code() const { return code_; }
code_description()67   const string& code_description() const { return code_description_; }
set_code(uint32_t code,const string & description)68   void set_code(uint32_t code, const string& description) {
69     code_ = code;
70     code_description_ = description;
71   }
72 
flags()73   uint32_t flags() const { return flags_; }
flags_description()74   const string& flags_description() const { return flags_description_; }
set_flags(uint32_t flags,const string & description)75   void set_flags(uint32_t flags, const string& description) {
76     flags_ = flags;
77     flags_description_ = description;
78   }
79 
nested_exception_record_address()80   uint64_t nested_exception_record_address() const {
81     return nested_exception_record_address_;
82   }
set_nested_exception_record_address(uint64_t nested_exception_record_address)83   void set_nested_exception_record_address(
84       uint64_t nested_exception_record_address) {
85     nested_exception_record_address_ = nested_exception_record_address;
86   }
87 
address()88   uint64_t address() const { return address_; }
set_address(uint64_t address)89   void set_address(uint64_t address) { address_ = address; }
90 
parameters()91   const std::vector<ExceptionParameter>* parameters() const {
92     return &parameters_;
93   }
add_parameter(uint64_t value,const string & description)94   void add_parameter(uint64_t value, const string& description) {
95     parameters_.push_back(ExceptionParameter(value, description));
96   }
97 
98  private:
99   // Exception code.
100   uint32_t code_;
101   string code_description_;
102 
103   // Exception flags.
104   uint32_t flags_;
105   string flags_description_;
106 
107   // The address of an associated MDException structure. Exception records can
108   // be chained together to provide additional information when nested
109   // exceptions occur.
110   uint64_t nested_exception_record_address_;
111 
112   // The memory address that caused the exception.  For data access errors,
113   // this will be the data address that caused the fault.  For code errors,
114   // this will be the address of the instruction that caused the fault.
115   uint64_t address_;
116 
117   // An array of additional arguments that describe the exception.
118   std::vector<ExceptionParameter> parameters_;
119 };
120 
121 }  // namespace google_breakpad
122 
123 
124 #endif  // THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_
125