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 | // code_modules.h: Contains all of the CodeModule objects that were loaded |
31 | // into a single process. |
32 | // |
33 | // Author: Mark Mentovai |
34 | |
35 | #ifndef GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__ |
36 | #define GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__ |
37 | |
38 | #include <stddef.h> |
39 | |
40 | #include <vector> |
41 | |
42 | #include "google_breakpad/common/breakpad_types.h" |
43 | #include "processor/linked_ptr.h" |
44 | |
45 | namespace google_breakpad { |
46 | |
47 | class CodeModule; |
48 | |
49 | class CodeModules { |
50 | public: |
51 | virtual ~CodeModules() {} |
52 | |
53 | // The number of contained CodeModule objects. |
54 | virtual unsigned int module_count() const = 0; |
55 | |
56 | // Random access to modules. Returns the module whose code is present |
57 | // at the address indicated by |address|. If no module is present at this |
58 | // address, returns NULL. Ownership of the returned CodeModule is retained |
59 | // by the CodeModules object; pointers returned by this method are valid for |
60 | // comparison with pointers returned by the other Get methods. |
61 | virtual const CodeModule* GetModuleForAddress(uint64_t address) const = 0; |
62 | |
63 | // Returns the module corresponding to the main executable. If there is |
64 | // no main executable, returns NULL. Ownership of the returned CodeModule |
65 | // is retained by the CodeModules object; pointers returned by this method |
66 | // are valid for comparison with pointers returned by the other Get |
67 | // methods. |
68 | virtual const CodeModule* GetMainModule() const = 0; |
69 | |
70 | // Sequential access to modules. A sequence number of 0 corresponds to the |
71 | // module residing lowest in memory. If the sequence number is out of |
72 | // range, returns NULL. Ownership of the returned CodeModule is retained |
73 | // by the CodeModules object; pointers returned by this method are valid for |
74 | // comparison with pointers returned by the other Get methods. |
75 | virtual const CodeModule* GetModuleAtSequence( |
76 | unsigned int sequence) const = 0; |
77 | |
78 | // Sequential access to modules. This is similar to GetModuleAtSequence, |
79 | // except no ordering requirement is enforced. A CodeModules implementation |
80 | // may return CodeModule objects from GetModuleAtIndex in any order it |
81 | // wishes, provided that the order remain the same throughout the life of |
82 | // the CodeModules object. Typically, GetModuleAtIndex would be used by |
83 | // a caller to enumerate all CodeModule objects quickly when the enumeration |
84 | // does not require any ordering. If the index argument is out of range, |
85 | // returns NULL. Ownership of the returned CodeModule is retained by |
86 | // the CodeModules object; pointers returned by this method are valid for |
87 | // comparison with pointers returned by the other Get methods. |
88 | virtual const CodeModule* GetModuleAtIndex(unsigned int index) const = 0; |
89 | |
90 | // Creates a new copy of this CodeModules object, which the caller takes |
91 | // ownership of. The new object will also contain copies of the existing |
92 | // object's child CodeModule objects. The new CodeModules object may be of |
93 | // a different concrete class than the object being copied, but will behave |
94 | // identically to the copied object as far as the CodeModules and CodeModule |
95 | // interfaces are concerned, except that the order that GetModuleAtIndex |
96 | // returns objects in may differ between a copy and the original CodeModules |
97 | // object. |
98 | virtual const CodeModules* Copy() const = 0; |
99 | |
100 | // Returns a vector of all modules which address ranges needed to be shrunk |
101 | // down due to address range conflicts with other modules. |
102 | virtual std::vector<linked_ptr<const CodeModule> > |
103 | GetShrunkRangeModules() const = 0; |
104 | }; |
105 | |
106 | } // namespace google_breakpad |
107 | |
108 | #endif // GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__ |
109 | |