1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-30 17:20:26 +02:00

* Updated breakpad to latest version.

This commit is contained in:
Christian Muehlhaeuser
2012-06-24 18:25:34 +02:00
parent 0a3a9a7e97
commit d3eb5c3f88
186 changed files with 9184 additions and 5835 deletions

View File

@@ -51,18 +51,29 @@ extern "C" { // necessary for Leopard
namespace MacFileUtilities {
using google_breakpad::MD5Init;
using google_breakpad::MD5Update;
using google_breakpad::MD5Final;
MachoID::MachoID(const char *path)
: file_(0),
: memory_(0),
memory_size_(0),
crc_(0),
md5_context_(),
update_function_(NULL) {
strlcpy(path_, path, sizeof(path_));
}
MachoID::MachoID(const char *path, void *memory, size_t size)
: memory_(memory),
memory_size_(size),
crc_(0),
md5_context_(),
update_function_(NULL) {
strlcpy(path_, path, sizeof(path_));
file_ = open(path, O_RDONLY);
}
MachoID::~MachoID() {
if (file_ != -1)
close(file_);
}
// The CRC info is from http://en.wikipedia.org/wiki/Adler-32
@@ -144,10 +155,8 @@ void MachoID::Update(MachoWalker *walker, off_t offset, size_t size) {
bool MachoID::UUIDCommand(int cpu_type, unsigned char bytes[16]) {
struct breakpad_uuid_command uuid_cmd;
MachoWalker walker(path_, UUIDWalkerCB, &uuid_cmd);
uuid_cmd.cmd = 0;
if (!walker.WalkHeader(cpu_type))
if (!WalkHeader(cpu_type, UUIDWalkerCB, &uuid_cmd))
return false;
// If we found the command, we'll have initialized the uuid_command
@@ -162,10 +171,8 @@ bool MachoID::UUIDCommand(int cpu_type, unsigned char bytes[16]) {
bool MachoID::IDCommand(int cpu_type, unsigned char identifier[16]) {
struct dylib_command dylib_cmd;
MachoWalker walker(path_, IDWalkerCB, &dylib_cmd);
dylib_cmd.cmd = 0;
if (!walker.WalkHeader(cpu_type))
if (!WalkHeader(cpu_type, IDWalkerCB, &dylib_cmd))
return false;
// If we found the command, we'll have initialized the dylib_command
@@ -204,29 +211,39 @@ bool MachoID::IDCommand(int cpu_type, unsigned char identifier[16]) {
}
uint32_t MachoID::Adler32(int cpu_type) {
MachoWalker walker(path_, WalkerCB, this);
update_function_ = &MachoID::UpdateCRC;
crc_ = 0;
if (!walker.WalkHeader(cpu_type))
if (!WalkHeader(cpu_type, WalkerCB, this))
return 0;
return crc_;
}
bool MachoID::MD5(int cpu_type, unsigned char identifier[16]) {
MachoWalker walker(path_, WalkerCB, this);
update_function_ = &MachoID::UpdateMD5;
MD5Init(&md5_context_);
if (!walker.WalkHeader(cpu_type))
if (!WalkHeader(cpu_type, WalkerCB, this))
return false;
MD5Final(identifier, &md5_context_);
return true;
}
bool MachoID::WalkHeader(int cpu_type,
MachoWalker::LoadCommandCallback callback,
void *context) {
if (memory_) {
MachoWalker walker(memory_, memory_size_, callback, context);
return walker.WalkHeader(cpu_type);
} else {
MachoWalker walker(path_, callback, context);
return walker.WalkHeader(cpu_type);
}
}
// static
bool MachoID::WalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
bool swap, void *context) {