• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_module.h: Carries information about code modules that are loaded
31 // into a process.
32 //
33 // This is a basic concrete implementation of CodeModule.  It cannot be
34 // instantiated directly, only based on other objects that implement
35 // the CodeModule interface.  It exists to provide a CodeModule implementation
36 // a place to store information when the life of the original object (such as
37 // a MinidumpModule) cannot be guaranteed.
38 //
39 // Author: Mark Mentovai
40 
41 #ifndef PROCESSOR_BASIC_CODE_MODULE_H__
42 #define PROCESSOR_BASIC_CODE_MODULE_H__
43 
44 #include <string>
45 
46 #include "common/using_std_string.h"
47 #include "google_breakpad/processor/code_module.h"
48 
49 namespace google_breakpad {
50 
51 class BasicCodeModule : public CodeModule {
52  public:
53   // Creates a new BasicCodeModule given any existing CodeModule
54   // implementation.  This is useful to make a copy of the data relevant to
55   // the CodeModule interface without requiring all of the resources that
56   // other CodeModule implementations may require.
BasicCodeModule(const CodeModule * that)57   explicit BasicCodeModule(const CodeModule *that)
58       : base_address_(that->base_address()),
59         size_(that->size()),
60         shrink_down_delta_(that->shrink_down_delta()),
61         code_file_(that->code_file()),
62         code_identifier_(that->code_identifier()),
63         debug_file_(that->debug_file()),
64         debug_identifier_(that->debug_identifier()),
65         version_(that->version()),
66         is_unloaded_(that->is_unloaded()) {}
67 
68   BasicCodeModule(uint64_t base_address, uint64_t size,
69                   const string &code_file,
70                   const string &code_identifier,
71                   const string &debug_file,
72                   const string &debug_identifier,
73                   const string &version,
74                   const bool is_unloaded = false)
base_address_(base_address)75       : base_address_(base_address),
76         size_(size),
77         shrink_down_delta_(0),
78         code_file_(code_file),
79         code_identifier_(code_identifier),
80         debug_file_(debug_file),
81         debug_identifier_(debug_identifier),
82         version_(version),
83         is_unloaded_(is_unloaded)
84     {}
~BasicCodeModule()85   virtual ~BasicCodeModule() {}
86 
87   // See code_module.h for descriptions of these methods and the associated
88   // members.
base_address()89   virtual uint64_t base_address() const { return base_address_; }
size()90   virtual uint64_t size() const { return size_; }
shrink_down_delta()91   virtual uint64_t shrink_down_delta() const { return shrink_down_delta_; }
SetShrinkDownDelta(uint64_t shrink_down_delta)92   virtual void SetShrinkDownDelta(uint64_t shrink_down_delta) {
93     shrink_down_delta_ = shrink_down_delta;
94   }
code_file()95   virtual string code_file() const { return code_file_; }
code_identifier()96   virtual string code_identifier() const { return code_identifier_; }
debug_file()97   virtual string debug_file() const { return debug_file_; }
debug_identifier()98   virtual string debug_identifier() const { return debug_identifier_; }
version()99   virtual string version() const { return version_; }
Copy()100   virtual CodeModule* Copy() const { return new BasicCodeModule(this); }
is_unloaded()101   virtual bool is_unloaded() const { return is_unloaded_; }
102 
103  private:
104   uint64_t base_address_;
105   uint64_t size_;
106   uint64_t shrink_down_delta_;
107   string code_file_;
108   string code_identifier_;
109   string debug_file_;
110   string debug_identifier_;
111   string version_;
112   bool is_unloaded_;
113 
114   // Disallow copy constructor and assignment operator.
115   BasicCodeModule(const BasicCodeModule &that);
116   void operator=(const BasicCodeModule &that);
117 };
118 
119 }  // namespace google_breakpad
120 
121 #endif  // PROCESSOR_BASIC_CODE_MODULE_H__
122