aboutsummaryrefslogtreecommitdiff
path: root/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
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/crash_report/on_demand_symbol_supplier.mm
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/crash_report/on_demand_symbol_supplier.mm')
-rw-r--r--src/tools/mac/crash_report/on_demand_symbol_supplier.mm26
1 files changed, 22 insertions, 4 deletions
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;
}