Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: obsolete/breakpad/google_breakpad/processor/stackwalker.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 // stackwalker.h: Generic stackwalker.
31 //
32 // The Stackwalker class is an abstract base class providing common generic
33 // methods that apply to stacks from all systems. Specific implementations
34 // will extend this class by providing GetContextFrame and GetCallerFrame
35 // methods to fill in system-specific data in a StackFrame structure.
36 // Stackwalker assembles these StackFrame strucutres into a CallStack.
37 //
38 // Author: Mark Mentovai
39
40
41 #ifndef GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
42 #define GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
43
44 #include <set>
45 #include <string>
46 #include "google_breakpad/common/breakpad_types.h"
47
48 namespace google_breakpad {
49
50 class CallStack;
51 class CodeModule;
52 class CodeModules;
53 class MemoryRegion;
54 class MinidumpContext;
55 class SourceLineResolverInterface;
56 struct StackFrame;
57 class SymbolSupplier;
58 class SystemInfo;
59
60 using std::set;
61
62
63 class Stackwalker {
64 public:
65 virtual ~Stackwalker() {}
66
67 // Populates the given CallStack by calling GetContextFrame and
68 // GetCallerFrame. The frames are further processed to fill all available
69 // data. Returns true if the stackwalk completed, or false if it was
70 // interrupted by SymbolSupplier::GetSymbolFile().
71 bool Walk(CallStack *stack);
72
73 // Returns a new concrete subclass suitable for the CPU that a stack was
74 // generated on, according to the CPU type indicated by the context
75 // argument. If no suitable concrete subclass exists, returns NULL.
76 static Stackwalker* StackwalkerForCPU(const SystemInfo *system_info,
77 MinidumpContext *context,
78 MemoryRegion *memory,
79 const CodeModules *modules,
80 SymbolSupplier *supplier,
81 SourceLineResolverInterface *resolver);
82
83 protected:
84 // system_info identifies the operating system, NULL or empty if unknown.
85 // memory identifies a MemoryRegion that provides the stack memory
86 // for the stack to walk. modules, if non-NULL, is a CodeModules
87 // object that is used to look up which code module each stack frame is
88 // associated with. supplier is an optional caller-supplied SymbolSupplier
89 // implementation. If supplier is NULL, source line info will not be
90 // resolved. resolver is an instance of SourceLineResolverInterface
91 // (see source_line_resolver_interface.h and basic_source_line_resolver.h).
92 // If resolver is NULL, source line info will not be resolved.
93 Stackwalker(const SystemInfo *system_info,
94 MemoryRegion *memory,
95 const CodeModules *modules,
96 SymbolSupplier *supplier,
97 SourceLineResolverInterface *resolver);
98
99 // This can be used to filter out potential return addresses when
100 // the stack walker resorts to stack scanning.
101 // Returns true if any of:
102 // * This address is within a loaded module, but we don't have symbols
103 // for that module.
104 // * This address is within a loaded module for which we have symbols,
105 // and falls inside a function in that module.
106 // Returns false otherwise.
107 bool InstructionAddressSeemsValid(u_int64_t address);
108
109 // Information about the system that produced the minidump. Subclasses
110 // and the SymbolSupplier may find this information useful.
111 const SystemInfo *system_info_;
112
113 // The stack memory to walk. Subclasses will require this region to
114 // get information from the stack.
115 MemoryRegion *memory_;
116
117 // A list of modules, for populating each StackFrame's module information.
118 // This field is optional and may be NULL.
119 const CodeModules *modules_;
120
121 protected:
122 // The SourceLineResolver implementation.
123 SourceLineResolverInterface *resolver_;
124
125 private:
126 // Obtains the context frame, the innermost called procedure in a stack
127 // trace. Returns NULL on failure. GetContextFrame allocates a new
128 // StackFrame (or StackFrame subclass), ownership of which is taken by
129 // the caller.
130 virtual StackFrame* GetContextFrame() = 0;
131
132 // Obtains a caller frame. Each call to GetCallerFrame should return the
133 // frame that called the last frame returned by GetContextFrame or
134 // GetCallerFrame. To aid this purpose, stack contains the CallStack
135 // made of frames that have already been walked. GetCallerFrame should
136 // return NULL on failure or when there are no more caller frames (when
137 // the end of the stack has been reached). GetCallerFrame allocates a new
138 // StackFrame (or StackFrame subclass), ownership of which is taken by
139 // the caller.
140 virtual StackFrame* GetCallerFrame(const CallStack *stack) = 0;
141
142 // The optional SymbolSupplier for resolving source line info.
143 SymbolSupplier *supplier_;
144
145 // A list of modules that we haven't found symbols for. We track
146 // this in order to avoid repeatedly looking them up again within
147 // one minidump.
148 set<std::string> no_symbol_modules_;
149 };
150
151
152 } // namespace google_breakpad
153
154
155 #endif // GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698