OLD | NEW |
| (Empty) |
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 #ifndef GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__ | |
31 #define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__ | |
32 | |
33 #include <string> | |
34 #include "google_breakpad/common/breakpad_types.h" | |
35 | |
36 namespace google_breakpad { | |
37 | |
38 class CodeModule; | |
39 | |
40 using std::string; | |
41 | |
42 struct StackFrame { | |
43 // Indicates how well the instruction pointer derived during | |
44 // stack walking is trusted. Since the stack walker can resort to | |
45 // stack scanning, it can wind up with dubious frames. | |
46 // In rough order of "trust metric". | |
47 enum FrameTrust { | |
48 FRAME_TRUST_NONE, // Unknown | |
49 FRAME_TRUST_SCAN, // Scanned the stack, found this | |
50 FRAME_TRUST_CFI_SCAN, // Scanned the stack using call frame info, found this | |
51 FRAME_TRUST_FP, // Derived from frame pointer | |
52 FRAME_TRUST_CFI, // Derived from call frame info | |
53 FRAME_TRUST_CONTEXT // Given as instruction pointer in a context | |
54 }; | |
55 | |
56 StackFrame() | |
57 : instruction(), | |
58 module(NULL), | |
59 function_name(), | |
60 function_base(), | |
61 source_file_name(), | |
62 source_line(), | |
63 source_line_base(), | |
64 trust(FRAME_TRUST_NONE) {} | |
65 virtual ~StackFrame() {} | |
66 | |
67 // Return a string describing how this stack frame was found | |
68 // by the stackwalker. | |
69 string trust_description() const { | |
70 switch (trust) { | |
71 case StackFrame::FRAME_TRUST_CONTEXT: | |
72 return "given as instruction pointer in context"; | |
73 case StackFrame::FRAME_TRUST_CFI: | |
74 return "call frame info"; | |
75 case StackFrame::FRAME_TRUST_CFI_SCAN: | |
76 return "call frame info with scanning"; | |
77 case StackFrame::FRAME_TRUST_FP: | |
78 return "previous frame's frame pointer"; | |
79 case StackFrame::FRAME_TRUST_SCAN: | |
80 return "stack scanning"; | |
81 default: | |
82 return "unknown"; | |
83 } | |
84 }; | |
85 | |
86 // The program counter location as an absolute virtual address. For the | |
87 // innermost called frame in a stack, this will be an exact program counter | |
88 // or instruction pointer value. For all other frames, this will be within | |
89 // the instruction that caused execution to branch to a called function, | |
90 // but may not necessarily point to the exact beginning of that instruction. | |
91 u_int64_t instruction; | |
92 | |
93 // The module in which the instruction resides. | |
94 const CodeModule *module; | |
95 | |
96 // The function name, may be omitted if debug symbols are not available. | |
97 string function_name; | |
98 | |
99 // The start address of the function, may be omitted if debug symbols | |
100 // are not available. | |
101 u_int64_t function_base; | |
102 | |
103 // The source file name, may be omitted if debug symbols are not available. | |
104 string source_file_name; | |
105 | |
106 // The (1-based) source line number, may be omitted if debug symbols are | |
107 // not available. | |
108 int source_line; | |
109 | |
110 // The start address of the source line, may be omitted if debug symbols | |
111 // are not available. | |
112 u_int64_t source_line_base; | |
113 | |
114 // Amount of trust the stack walker has in the instruction pointer | |
115 // of this frame. | |
116 FrameTrust trust; | |
117 }; | |
118 | |
119 } // namespace google_breakpad | |
120 | |
121 #endif // GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__ | |
OLD | NEW |