/ src / google_breakpad / processor / fast_source_line_resolver.h
fast_source_line_resolver.h
  1  // Copyright 2010 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  // fast_source_line_resolver.h: FastSourceLineResolver is derived from
 30  // SourceLineResolverBase, and is a concrete implementation of
 31  // SourceLineResolverInterface.
 32  //
 33  // FastSourceLineResolver is a sibling class of BasicSourceLineResolver.  The
 34  // difference is FastSourceLineResolver loads a serialized memory chunk of data
 35  // which can be used directly a Module without parsing or copying of underlying
 36  // data.  Therefore loading a symbol in FastSourceLineResolver is much faster
 37  // and more memory-efficient than BasicSourceLineResolver.
 38  //
 39  // See "source_line_resolver_base.h" and
 40  // "google_breakpad/source_line_resolver_interface.h" for more reference.
 41  //
 42  // Author: Siyang Xie (lambxsy@google.com)
 43  
 44  #ifndef GOOGLE_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H__
 45  #define GOOGLE_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H__
 46  
 47  #include <map>
 48  #include <string>
 49  
 50  #include "google_breakpad/processor/source_line_resolver_base.h"
 51  
 52  namespace google_breakpad {
 53  
 54  using std::map;
 55  
 56  class FastSourceLineResolver : public SourceLineResolverBase {
 57   public:
 58    FastSourceLineResolver();
 59    virtual ~FastSourceLineResolver() { }
 60  
 61    using SourceLineResolverBase::FillSourceLineInfo;
 62    using SourceLineResolverBase::FindCFIFrameInfo;
 63    using SourceLineResolverBase::FindWindowsFrameInfo;
 64    using SourceLineResolverBase::HasModule;
 65    using SourceLineResolverBase::IsModuleCorrupt;
 66    using SourceLineResolverBase::LoadModule;
 67    using SourceLineResolverBase::LoadModuleUsingMapBuffer;
 68    using SourceLineResolverBase::LoadModuleUsingMemoryBuffer;
 69    using SourceLineResolverBase::UnloadModule;
 70  
 71   private:
 72    // Friend declarations.
 73    friend class ModuleComparer;
 74    friend class ModuleSerializer;
 75    friend class FastModuleFactory;
 76  
 77    // Nested types that will derive from corresponding nested types defined in
 78    // SourceLineResolverBase.
 79    struct Line;
 80    struct Function;
 81    struct Inline;
 82    struct InlineOrigin;
 83    struct PublicSymbol;
 84    class Module;
 85  
 86    // Deserialize raw memory data to construct a WindowsFrameInfo object.
 87    static WindowsFrameInfo CopyWFI(const char *raw_memory);
 88  
 89    // FastSourceLineResolver requires the memory buffer stays alive during the
 90    // lifetime of a corresponding module, therefore it needs to redefine this
 91    // virtual method.
 92    virtual bool ShouldDeleteMemoryBufferAfterLoadModule();
 93  
 94    // Disallow unwanted copy ctor and assignment operator
 95    FastSourceLineResolver(const FastSourceLineResolver&);
 96    void operator=(const FastSourceLineResolver&);
 97  };
 98  
 99  }  // namespace google_breakpad
100  
101  #endif  // GOOGLE_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H__