mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02:00
Update breakpad to make it work with MinGW
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "common/using_std_string.h"
|
||||
#include "google_breakpad/common/breakpad_types.h"
|
||||
#include "google_breakpad/processor/code_module.h"
|
||||
#include "google_breakpad/processor/code_modules.h"
|
||||
@@ -54,24 +55,24 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
|
||||
// Set this region's address and contents. If we have placed an
|
||||
// instance of this class in a test fixture class, individual tests
|
||||
// can use this to provide the region's contents.
|
||||
void Init(u_int64_t base_address, const std::string &contents) {
|
||||
void Init(uint64_t base_address, const string &contents) {
|
||||
base_address_ = base_address;
|
||||
contents_ = contents;
|
||||
}
|
||||
|
||||
u_int64_t GetBase() const { return base_address_; }
|
||||
u_int32_t GetSize() const { return contents_.size(); }
|
||||
uint64_t GetBase() const { return base_address_; }
|
||||
uint32_t GetSize() const { return contents_.size(); }
|
||||
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int8_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
|
||||
// Fetch a little-endian value from ADDRESS in contents_ whose size
|
||||
// is BYTES, and store it in *VALUE. Return true on success.
|
||||
template<typename ValueType>
|
||||
bool GetMemoryLittleEndian(u_int64_t address, ValueType *value) const {
|
||||
bool GetMemoryLittleEndian(uint64_t address, ValueType *value) const {
|
||||
if (address < base_address_ ||
|
||||
address - base_address_ + sizeof(ValueType) > contents_.size())
|
||||
return false;
|
||||
@@ -92,32 +93,32 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
u_int64_t base_address_;
|
||||
std::string contents_;
|
||||
uint64_t base_address_;
|
||||
string contents_;
|
||||
};
|
||||
|
||||
class MockCodeModule: public google_breakpad::CodeModule {
|
||||
public:
|
||||
MockCodeModule(u_int64_t base_address, u_int64_t size,
|
||||
const std::string &code_file, const std::string &version)
|
||||
MockCodeModule(uint64_t base_address, uint64_t size,
|
||||
const string &code_file, const string &version)
|
||||
: base_address_(base_address), size_(size), code_file_(code_file) { }
|
||||
|
||||
u_int64_t base_address() const { return base_address_; }
|
||||
u_int64_t size() const { return size_; }
|
||||
std::string code_file() const { return code_file_; }
|
||||
std::string code_identifier() const { return code_file_; }
|
||||
std::string debug_file() const { return code_file_; }
|
||||
std::string debug_identifier() const { return code_file_; }
|
||||
std::string version() const { return version_; }
|
||||
uint64_t base_address() const { return base_address_; }
|
||||
uint64_t size() const { return size_; }
|
||||
string code_file() const { return code_file_; }
|
||||
string code_identifier() const { return code_file_; }
|
||||
string debug_file() const { return code_file_; }
|
||||
string debug_identifier() const { return code_file_; }
|
||||
string version() const { return version_; }
|
||||
const google_breakpad::CodeModule *Copy() const {
|
||||
abort(); // Tests won't use this.
|
||||
}
|
||||
|
||||
private:
|
||||
u_int64_t base_address_;
|
||||
u_int64_t size_;
|
||||
std::string code_file_;
|
||||
std::string version_;
|
||||
uint64_t base_address_;
|
||||
uint64_t size_;
|
||||
string code_file_;
|
||||
string version_;
|
||||
};
|
||||
|
||||
class MockCodeModules: public google_breakpad::CodeModules {
|
||||
@@ -131,7 +132,7 @@ class MockCodeModules: public google_breakpad::CodeModules {
|
||||
|
||||
unsigned int module_count() const { return modules_.size(); }
|
||||
|
||||
const CodeModule *GetModuleForAddress(u_int64_t address) const {
|
||||
const CodeModule *GetModuleForAddress(uint64_t address) const {
|
||||
for (ModuleVector::const_iterator i = modules_.begin();
|
||||
i != modules_.end(); i++) {
|
||||
const MockCodeModule *module = *i;
|
||||
@@ -165,16 +166,42 @@ class MockSymbolSupplier: public google_breakpad::SymbolSupplier {
|
||||
typedef google_breakpad::SystemInfo SystemInfo;
|
||||
MOCK_METHOD3(GetSymbolFile, SymbolResult(const CodeModule *module,
|
||||
const SystemInfo *system_info,
|
||||
std::string *symbol_file));
|
||||
string *symbol_file));
|
||||
MOCK_METHOD4(GetSymbolFile, SymbolResult(const CodeModule *module,
|
||||
const SystemInfo *system_info,
|
||||
std::string *symbol_file,
|
||||
std::string *symbol_data));
|
||||
MOCK_METHOD4(GetCStringSymbolData, SymbolResult(const CodeModule *module,
|
||||
string *symbol_file,
|
||||
string *symbol_data));
|
||||
MOCK_METHOD5(GetCStringSymbolData, SymbolResult(const CodeModule *module,
|
||||
const SystemInfo *system_info,
|
||||
std::string *symbol_file,
|
||||
char **symbol_data));
|
||||
string *symbol_file,
|
||||
char **symbol_data,
|
||||
size_t *symbol_data_size));
|
||||
MOCK_METHOD1(FreeSymbolData, void(const CodeModule *module));
|
||||
|
||||
// Copies the passed string contents into a newly allocated buffer.
|
||||
// The newly allocated buffer will be freed during destruction.
|
||||
char* CopySymbolDataAndOwnTheCopy(const std::string &info,
|
||||
size_t *symbol_data_size) {
|
||||
*symbol_data_size = info.size() + 1;
|
||||
char *symbol_data = new char[*symbol_data_size];
|
||||
memcpy(symbol_data, info.c_str(), info.size());
|
||||
symbol_data[info.size()] = '\0';
|
||||
symbol_data_to_free_.push_back(symbol_data);
|
||||
return symbol_data;
|
||||
}
|
||||
|
||||
virtual ~MockSymbolSupplier() {
|
||||
for (SymbolDataVector::const_iterator i = symbol_data_to_free_.begin();
|
||||
i != symbol_data_to_free_.end(); i++) {
|
||||
char* symbol_data = *i;
|
||||
delete [] symbol_data;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// List of symbol data to be freed upon destruction
|
||||
typedef std::vector<char*> SymbolDataVector;
|
||||
SymbolDataVector symbol_data_to_free_;
|
||||
};
|
||||
|
||||
#endif // PROCESSOR_STACKWALKER_UNITTEST_UTILS_H_
|
||||
|
Reference in New Issue
Block a user