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