aboutsummaryrefslogtreecommitdiff
path: root/src/tools/mac
diff options
context:
space:
mode:
authorSiyangXie@gmail.com <SiyangXie@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-11-01 17:31:31 +0000
committerSiyangXie@gmail.com <SiyangXie@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-11-01 17:31:31 +0000
commita8c1c466a16ad4c85bfd1ca20ab8fc056d669abe (patch)
treea2125b96e08b34b828364885d9cd52845a1eff93 /src/tools/mac
parentAdd missing module_serializer.h and module_serializer.cc for class ModuleSeri... (diff)
downloadbreakpad-a8c1c466a16ad4c85bfd1ca20ab8fc056d669abe.tar.xz
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
Diffstat (limited to 'src/tools/mac')
-rw-r--r--src/tools/mac/crash_report/on_demand_symbol_supplier.h9
-rw-r--r--src/tools/mac/crash_report/on_demand_symbol_supplier.mm26
2 files changed, 31 insertions, 4 deletions
diff --git a/src/tools/mac/crash_report/on_demand_symbol_supplier.h b/src/tools/mac/crash_report/on_demand_symbol_supplier.h
index 2bad776d..28002c6b 100644
--- a/src/tools/mac/crash_report/on_demand_symbol_supplier.h
+++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.h
@@ -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);
diff --git a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
index e1db9203..f71aebd9 100644
--- a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
+++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
@@ -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;
}