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 // basic_code_modules.h: Contains all of the CodeModule objects that 31 // were loaded into a single process. 32 // 33 // This is a basic concrete implementation of CodeModules. It cannot be 34 // instantiated directly, only based on other objects that implement 35 // the CodeModules interface. It exists to provide a CodeModules 36 // implementation a place to store information when the life of the original 37 // object (such as a MinidumpModuleList) cannot be guaranteed. 38 // 39 // Author: Mark Mentovai 40 41 #ifndef PROCESSOR_BASIC_CODE_MODULES_H__ 42 #define PROCESSOR_BASIC_CODE_MODULES_H__ 43 44 #include "google_breakpad/processor/code_modules.h" 45 46 namespace google_breakpad { 47 48 template<typename T> class linked_ptr; 49 template<typename AddressType, typename EntryType> class RangeMap; 50 51 class BasicCodeModules : public CodeModules { 52 public: 53 // Creates a new BasicCodeModules object given any existing CodeModules 54 // implementation. This is useful to make a copy of the data relevant to 55 // the CodeModules and CodeModule interfaces without requiring all of the 56 // resources that other implementations may require. A copy will be 57 // made of each contained CodeModule using CodeModule::Copy. 58 explicit BasicCodeModules(const CodeModules *that); 59 60 virtual ~BasicCodeModules(); 61 62 // See code_modules.h for descriptions of these methods. 63 virtual unsigned int module_count() const; 64 virtual const CodeModule* GetModuleForAddress(uint64_t address) const; 65 virtual const CodeModule* GetMainModule() const; 66 virtual const CodeModule* GetModuleAtSequence(unsigned int sequence) const; 67 virtual const CodeModule* GetModuleAtIndex(unsigned int index) const; 68 virtual const CodeModules* Copy() const; 69 70 protected: 71 BasicCodeModules(); 72 73 // The base address of the main module. 74 uint64_t main_address_; 75 76 // The map used to contain each CodeModule, keyed by each CodeModule's 77 // address range. 78 RangeMap<uint64_t, linked_ptr<const CodeModule> > *map_; 79 80 private: 81 // Disallow copy constructor and assignment operator. 82 BasicCodeModules(const BasicCodeModules &that); 83 void operator=(const BasicCodeModules &that); 84 }; 85 86 } // namespace google_breakpad 87 88 #endif // PROCESSOR_BASIC_CODE_MODULES_H__ 89