mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-01-04 05:34:45 +01:00
Restrict ownership of symbol data buffers to symbol supplier.
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@721 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
eabfff133d
commit
a8c1c466a1
18 changed files with 200 additions and 126 deletions
|
|
@ -61,10 +61,16 @@ class OnDemandSymbolSupplier : public SymbolSupplier {
|
|||
const SystemInfo *system_info,
|
||||
string *symbol_file,
|
||||
string *symbol_data);
|
||||
// Allocates data buffer on heap, and takes the ownership of
|
||||
// the data buffer.
|
||||
virtual SymbolResult GetCStringSymbolData(const CodeModule *module,
|
||||
const SystemInfo *system_info,
|
||||
string *symbol_file,
|
||||
char **symbol_data);
|
||||
|
||||
// Delete the data buffer allocated for module in GetCStringSymbolData().
|
||||
virtual void FreeSymbolData(const CodeModule *module);
|
||||
|
||||
protected:
|
||||
// Search directory
|
||||
string search_dir_;
|
||||
|
|
@ -74,6 +80,9 @@ class OnDemandSymbolSupplier : public SymbolSupplier {
|
|||
// and the path to that module's symbol file.
|
||||
map<string, string> module_file_map_;
|
||||
|
||||
// Map of allocated data buffers, keyed by module->code_file().
|
||||
map<string, char *> memory_buffers_;
|
||||
|
||||
// Return the name for |module| This will be the value used as the key
|
||||
// to the |module_file_map_|.
|
||||
string GetNameForModule(const CodeModule *module);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
|
||||
#include "google_breakpad/processor/basic_source_line_resolver.h"
|
||||
#include "google_breakpad/processor/minidump.h"
|
||||
|
|
@ -49,7 +50,7 @@ using google_breakpad::PathnameStripper;
|
|||
using google_breakpad::SymbolSupplier;
|
||||
using google_breakpad::SystemInfo;
|
||||
|
||||
OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir,
|
||||
OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir,
|
||||
const string &symbol_search_dir)
|
||||
: search_dir_(search_dir) {
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
|
|
@ -169,10 +170,27 @@ OnDemandSymbolSupplier::GetCStringSymbolData(const CodeModule *module,
|
|||
system_info,
|
||||
symbol_file,
|
||||
&symbol_data_string);
|
||||
strcpy(*symbol_data, symbol_data_string.c_str());
|
||||
if (result == FOUND) {
|
||||
unsigned int size = symbol_data_string.size() + 1;
|
||||
*symbol_data = new char[size];
|
||||
if (*symbol_data == NULL) {
|
||||
// Should return INTERRUPT on memory allocation failure.
|
||||
return INTERRUPT;
|
||||
}
|
||||
strcpy(*symbol_data, symbol_data_string.c_str());
|
||||
memory_buffers_.insert(make_pair(module->code_file(), *symbol_data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void OnDemandSymbolSupplier::FreeSymbolData(const CodeModule *module) {
|
||||
map<string, char *>::iterator it = memory_buffers_.find(module->code_file());
|
||||
if (it != memory_buffers_.end()) {
|
||||
delete [] it->second;
|
||||
memory_buffers_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) {
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
const char *moduleStr = module->code_file().c_str();
|
||||
|
|
@ -281,9 +299,9 @@ bool OnDemandSymbolSupplier::GenerateSymbolFile(const CodeModule *module,
|
|||
} else {
|
||||
printf("Unable to open %s (%d)\n", name.c_str(), errno);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf("Architecture %s not available for %s\n",
|
||||
printf("Architecture %s not available for %s\n",
|
||||
system_info->cpu.c_str(), name.c_str());
|
||||
result = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue