Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: src/processor/stackwalker_unittest_utils.h

Issue 2060663002: Server-side workaround to handle overlapping modules. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Fix whitespace. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/processor/range_map-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // -*- mode: C++ -*- 1 // -*- mode: C++ -*-
2 2
3 // Copyright (c) 2010, Google Inc. 3 // Copyright (c) 2010, Google Inc.
4 // All rights reserved. 4 // All rights reserved.
5 // 5 //
6 // Redistribution and use in source and binary forms, with or without 6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are 7 // modification, are permitted provided that the following conditions are
8 // met: 8 // met:
9 // 9 //
10 // * Redistributions of source code must retain the above copyright 10 // * Redistributions of source code must retain the above copyright
(...skipping 30 matching lines...) Expand all
41 #include <string> 41 #include <string>
42 #include <vector> 42 #include <vector>
43 43
44 #include "common/using_std_string.h" 44 #include "common/using_std_string.h"
45 #include "google_breakpad/common/breakpad_types.h" 45 #include "google_breakpad/common/breakpad_types.h"
46 #include "google_breakpad/processor/code_module.h" 46 #include "google_breakpad/processor/code_module.h"
47 #include "google_breakpad/processor/code_modules.h" 47 #include "google_breakpad/processor/code_modules.h"
48 #include "google_breakpad/processor/memory_region.h" 48 #include "google_breakpad/processor/memory_region.h"
49 #include "google_breakpad/processor/symbol_supplier.h" 49 #include "google_breakpad/processor/symbol_supplier.h"
50 #include "google_breakpad/processor/system_info.h" 50 #include "google_breakpad/processor/system_info.h"
51 #include "processor/linked_ptr.h"
51 52
52 class MockMemoryRegion: public google_breakpad::MemoryRegion { 53 class MockMemoryRegion: public google_breakpad::MemoryRegion {
53 public: 54 public:
54 MockMemoryRegion(): base_address_(0) { } 55 MockMemoryRegion(): base_address_(0) { }
55 56
56 // Set this region's address and contents. If we have placed an 57 // Set this region's address and contents. If we have placed an
57 // instance of this class in a test fixture class, individual tests 58 // instance of this class in a test fixture class, individual tests
58 // can use this to provide the region's contents. 59 // can use this to provide the region's contents.
59 void Init(uint64_t base_address, const string &contents) { 60 void Init(uint64_t base_address, const string &contents) {
60 base_address_ = base_address; 61 base_address_ = base_address;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const string &code_file, const string &version) 108 const string &code_file, const string &version)
108 : base_address_(base_address), size_(size), code_file_(code_file) { } 109 : base_address_(base_address), size_(size), code_file_(code_file) { }
109 110
110 uint64_t base_address() const { return base_address_; } 111 uint64_t base_address() const { return base_address_; }
111 uint64_t size() const { return size_; } 112 uint64_t size() const { return size_; }
112 string code_file() const { return code_file_; } 113 string code_file() const { return code_file_; }
113 string code_identifier() const { return code_file_; } 114 string code_identifier() const { return code_file_; }
114 string debug_file() const { return code_file_; } 115 string debug_file() const { return code_file_; }
115 string debug_identifier() const { return code_file_; } 116 string debug_identifier() const { return code_file_; }
116 string version() const { return version_; } 117 string version() const { return version_; }
117 const google_breakpad::CodeModule *Copy() const { 118 google_breakpad::CodeModule *Copy() const {
118 abort(); // Tests won't use this. 119 abort(); // Tests won't use this.
119 } 120 }
121 virtual uint64_t shrink_down_delta() const { return 0; }
122 virtual void SetShrinkDownDelta(uint64_t shrink_down_delta) {}
120 123
121 private: 124 private:
122 uint64_t base_address_; 125 uint64_t base_address_;
123 uint64_t size_; 126 uint64_t size_;
124 string code_file_; 127 string code_file_;
125 string version_; 128 string version_;
126 }; 129 };
127 130
128 class MockCodeModules: public google_breakpad::CodeModules { 131 class MockCodeModules: public google_breakpad::CodeModules {
129 public: 132 public:
130 typedef google_breakpad::CodeModule CodeModule; 133 typedef google_breakpad::CodeModule CodeModule;
131 typedef google_breakpad::CodeModules CodeModules; 134 typedef google_breakpad::CodeModules CodeModules;
132 135
133 void Add(const MockCodeModule *module) { 136 void Add(const MockCodeModule *module) {
134 modules_.push_back(module); 137 modules_.push_back(module);
135 } 138 }
136 139
137 unsigned int module_count() const { return modules_.size(); } 140 unsigned int module_count() const { return modules_.size(); }
138 141
139 const CodeModule *GetModuleForAddress(uint64_t address) const { 142 const CodeModule *GetModuleForAddress(uint64_t address) const {
140 for (ModuleVector::const_iterator i = modules_.begin(); 143 for (ModuleVector::const_iterator i = modules_.begin();
141 i != modules_.end(); i++) { 144 i != modules_.end(); i++) {
142 const MockCodeModule *module = *i; 145 const MockCodeModule *module = *i;
143 if (module->base_address() <= address && 146 if (module->base_address() <= address &&
144 address - module->base_address() < module->size()) 147 address - module->base_address() < module->size())
145 return module; 148 return module;
146 } 149 }
147 return NULL; 150 return NULL;
148 }; 151 };
149 152
150 const CodeModule *GetMainModule() const { return modules_[0]; } 153 const CodeModule *GetMainModule() const { return modules_[0]; }
151 154
152 const CodeModule *GetModuleAtSequence(unsigned int sequence) const { 155 const CodeModule *GetModuleAtSequence(unsigned int sequence) const {
153 return modules_.at(sequence); 156 return modules_.at(sequence);
154 } 157 }
155 158
156 const CodeModule *GetModuleAtIndex(unsigned int index) const { 159 const CodeModule *GetModuleAtIndex(unsigned int index) const {
157 return modules_.at(index); 160 return modules_.at(index);
158 } 161 }
159 162
160 const CodeModules *Copy() const { abort(); } // Tests won't use this. 163 CodeModules *Copy() const { abort(); } // Tests won't use this
161 164
162 private: 165 virtual std::vector<google_breakpad::linked_ptr<const CodeModule> >
166 GetShrunkRangeModules() const {
167 return std::vector<google_breakpad::linked_ptr<const CodeModule> >();
168 }
169
170 // Returns true, if module address range shrink is enabled.
171 bool IsModuleShrinkEnabled() const {
172 return false;
173 }
174
175 private:
163 typedef std::vector<const MockCodeModule *> ModuleVector; 176 typedef std::vector<const MockCodeModule *> ModuleVector;
164 ModuleVector modules_; 177 ModuleVector modules_;
165 }; 178 };
166 179
167 class MockSymbolSupplier: public google_breakpad::SymbolSupplier { 180 class MockSymbolSupplier: public google_breakpad::SymbolSupplier {
168 public: 181 public:
169 typedef google_breakpad::CodeModule CodeModule; 182 typedef google_breakpad::CodeModule CodeModule;
170 typedef google_breakpad::SystemInfo SystemInfo; 183 typedef google_breakpad::SystemInfo SystemInfo;
171 MOCK_METHOD3(GetSymbolFile, SymbolResult(const CodeModule *module, 184 MOCK_METHOD3(GetSymbolFile, SymbolResult(const CodeModule *module,
172 const SystemInfo *system_info, 185 const SystemInfo *system_info,
(...skipping 29 matching lines...) Expand all
202 } 215 }
203 } 216 }
204 217
205 private: 218 private:
206 // List of symbol data to be freed upon destruction 219 // List of symbol data to be freed upon destruction
207 typedef std::vector<char*> SymbolDataVector; 220 typedef std::vector<char*> SymbolDataVector;
208 SymbolDataVector symbol_data_to_free_; 221 SymbolDataVector symbol_data_to_free_;
209 }; 222 };
210 223
211 #endif // PROCESSOR_STACKWALKER_UNITTEST_UTILS_H_ 224 #endif // PROCESSOR_STACKWALKER_UNITTEST_UTILS_H_
OLDNEW
« no previous file with comments | « src/processor/range_map-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698