1 // Copyright 2006 Google LLC 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google LLC nor the names of its 14 // contributors may be used to endorse or promote products derived from 15 // this software without specific prior written permission. 16 // 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29 // code_modules.h: Contains all of the CodeModule objects that were loaded 30 // into a single process. 31 // 32 // Author: Mark Mentovai 33 34 #ifndef GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__ 35 #define GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__ 36 37 #include <stddef.h> 38 39 #include <vector> 40 41 #include "google_breakpad/common/breakpad_types.h" 42 #include "processor/linked_ptr.h" 43 44 namespace google_breakpad { 45 46 class CodeModule; 47 48 class CodeModules { 49 public: ~CodeModules()50 virtual ~CodeModules() {} 51 52 // The number of contained CodeModule objects. 53 virtual unsigned int module_count() const = 0; 54 55 // Random access to modules. Returns the module whose code is present 56 // at the address indicated by |address|. If no module is present at this 57 // address, returns NULL. Ownership of the returned CodeModule is retained 58 // by the CodeModules object; pointers returned by this method are valid for 59 // comparison with pointers returned by the other Get methods. 60 virtual const CodeModule* GetModuleForAddress(uint64_t address) const = 0; 61 62 // Returns the module corresponding to the main executable. If there is 63 // no main executable, returns NULL. Ownership of the returned CodeModule 64 // is retained by the CodeModules object; pointers returned by this method 65 // are valid for comparison with pointers returned by the other Get 66 // methods. 67 virtual const CodeModule* GetMainModule() const = 0; 68 69 // Sequential access to modules. A sequence number of 0 corresponds to the 70 // module residing lowest in memory. If the sequence number is out of 71 // range, returns NULL. Ownership of the returned CodeModule is retained 72 // by the CodeModules object; pointers returned by this method are valid for 73 // comparison with pointers returned by the other Get methods. 74 virtual const CodeModule* GetModuleAtSequence( 75 unsigned int sequence) const = 0; 76 77 // Sequential access to modules. This is similar to GetModuleAtSequence, 78 // except no ordering requirement is enforced. A CodeModules implementation 79 // may return CodeModule objects from GetModuleAtIndex in any order it 80 // wishes, provided that the order remain the same throughout the life of 81 // the CodeModules object. Typically, GetModuleAtIndex would be used by 82 // a caller to enumerate all CodeModule objects quickly when the enumeration 83 // does not require any ordering. If the index argument is out of range, 84 // returns NULL. Ownership of the returned CodeModule is retained by 85 // the CodeModules object; pointers returned by this method are valid for 86 // comparison with pointers returned by the other Get methods. 87 virtual const CodeModule* GetModuleAtIndex(unsigned int index) const = 0; 88 89 // Creates a new copy of this CodeModules object, which the caller takes 90 // ownership of. The new object will also contain copies of the existing 91 // object's child CodeModule objects. The new CodeModules object may be of 92 // a different concrete class than the object being copied, but will behave 93 // identically to the copied object as far as the CodeModules and CodeModule 94 // interfaces are concerned, except that the order that GetModuleAtIndex 95 // returns objects in may differ between a copy and the original CodeModules 96 // object. 97 virtual const CodeModules* Copy() const = 0; 98 99 // Returns a vector of all modules which address ranges needed to be shrunk 100 // down due to address range conflicts with other modules. 101 virtual std::vector<linked_ptr<const CodeModule> > 102 GetShrunkRangeModules() const = 0; 103 }; 104 105 } // namespace google_breakpad 106 107 #endif // GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__ 108