|
1 // -*- mode: C++ -*- |
|
2 |
|
3 // Copyright (c) 2010 Google Inc. |
|
4 // All rights reserved. |
|
5 // |
|
6 // Redistribution and use in source and binary forms, with or without |
|
7 // modification, are permitted provided that the following conditions are |
|
8 // met: |
|
9 // |
|
10 // * Redistributions of source code must retain the above copyright |
|
11 // notice, this list of conditions and the following disclaimer. |
|
12 // * Redistributions in binary form must reproduce the above |
|
13 // copyright notice, this list of conditions and the following disclaimer |
|
14 // in the documentation and/or other materials provided with the |
|
15 // distribution. |
|
16 // * Neither the name of Google Inc. nor the names of its |
|
17 // contributors may be used to endorse or promote products derived from |
|
18 // this software without specific prior written permission. |
|
19 // |
|
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
31 |
|
32 // stackwalker_arm.h: arm-specific stackwalker. |
|
33 // |
|
34 // Provides stack frames given arm register context and a memory region |
|
35 // corresponding to an arm stack. |
|
36 // |
|
37 // Author: Mark Mentovai, Ted Mielczarek |
|
38 |
|
39 |
|
40 #ifndef PROCESSOR_STACKWALKER_ARM_H__ |
|
41 #define PROCESSOR_STACKWALKER_ARM_H__ |
|
42 |
|
43 #include "google_breakpad/common/breakpad_types.h" |
|
44 #include "google_breakpad/common/minidump_format.h" |
|
45 #include "google_breakpad/processor/stackwalker.h" |
|
46 |
|
47 namespace google_breakpad { |
|
48 |
|
49 class CodeModules; |
|
50 |
|
51 class StackwalkerARM : public Stackwalker { |
|
52 public: |
|
53 // context is an arm context object that gives access to arm-specific |
|
54 // register state corresponding to the innermost called frame to be |
|
55 // included in the stack. The other arguments are passed directly through |
|
56 // to the base Stackwalker constructor. |
|
57 StackwalkerARM(const SystemInfo* system_info, |
|
58 const MDRawContextARM* context, |
|
59 int fp_register, |
|
60 MemoryRegion* memory, |
|
61 const CodeModules* modules, |
|
62 StackFrameSymbolizer* frame_symbolizer); |
|
63 |
|
64 // Change the context validity mask of the frame returned by |
|
65 // GetContextFrame to VALID. This is only for use by unit tests; the |
|
66 // default behavior is correct for all application code. |
|
67 void SetContextFrameValidity(int valid) { context_frame_validity_ = valid; } |
|
68 |
|
69 private: |
|
70 // Implementation of Stackwalker, using arm context and stack conventions. |
|
71 virtual StackFrame* GetContextFrame(); |
|
72 virtual StackFrame* GetCallerFrame(const CallStack* stack, |
|
73 bool stack_scan_allowed); |
|
74 |
|
75 // Use cfi_frame_info (derived from STACK CFI records) to construct |
|
76 // the frame that called frames.back(). The caller takes ownership |
|
77 // of the returned frame. Return NULL on failure. |
|
78 StackFrameARM* GetCallerByCFIFrameInfo(const vector<StackFrame*> &frames, |
|
79 CFIFrameInfo* cfi_frame_info); |
|
80 |
|
81 // Use the frame pointer. The caller takes ownership of the returned frame. |
|
82 // Return NULL on failure. |
|
83 StackFrameARM* GetCallerByFramePointer(const vector<StackFrame*> &frames); |
|
84 |
|
85 // Scan the stack for plausible return addresses. The caller takes ownership |
|
86 // of the returned frame. Return NULL on failure. |
|
87 StackFrameARM* GetCallerByStackScan(const vector<StackFrame*> &frames); |
|
88 |
|
89 // Stores the CPU context corresponding to the youngest stack frame, to |
|
90 // be returned by GetContextFrame. |
|
91 const MDRawContextARM* context_; |
|
92 |
|
93 // The register to use a as frame pointer. The value is -1 if frame pointer |
|
94 // cannot be used. |
|
95 int fp_register_; |
|
96 |
|
97 // Validity mask for youngest stack frame. This is always |
|
98 // CONTEXT_VALID_ALL in real use; it is only changeable for the sake of |
|
99 // unit tests. |
|
100 int context_frame_validity_; |
|
101 }; |
|
102 |
|
103 |
|
104 } // namespace google_breakpad |
|
105 |
|
106 |
|
107 #endif // PROCESSOR_STACKWALKER_ARM_H__ |