Follow-up to #26: get rid of supplier_data, it's not really needed since
the caller can implement their own supplier object. r=mmentovai. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@27 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
cce3492afc
commit
0170bea32f
9 changed files with 16 additions and 43 deletions
|
@ -32,10 +32,8 @@ class MinidumpProcessor {
|
||||||
~MinidumpProcessor();
|
~MinidumpProcessor();
|
||||||
|
|
||||||
// Fills in the given StackFrames vector by processing the minidump file.
|
// Fills in the given StackFrames vector by processing the minidump file.
|
||||||
// supplier_data is an opaque pointer which is passed to
|
// Returns true on success.
|
||||||
// SymbolSupplier::GetSymbolFile(). Returns true on success.
|
bool Process(const string &minidump_file, StackFrames *stack_frames);
|
||||||
bool Process(const string &minidump_file, void *supplier_data,
|
|
||||||
StackFrames *stack_frames);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SymbolSupplier *supplier_;
|
SymbolSupplier *supplier_;
|
||||||
|
|
|
@ -30,9 +30,7 @@ class SymbolSupplier {
|
||||||
virtual ~SymbolSupplier() {}
|
virtual ~SymbolSupplier() {}
|
||||||
|
|
||||||
// Returns the path to the symbol file for the given module.
|
// Returns the path to the symbol file for the given module.
|
||||||
// supplier_data is passed through from MinidumpProcessor::Process().
|
virtual string GetSymbolFile(MinidumpModule *module) = 0;
|
||||||
virtual string GetSymbolFile(MinidumpModule *module,
|
|
||||||
void *supplier_data) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace google_airbag
|
} // namespace google_airbag
|
||||||
|
|
|
@ -26,7 +26,6 @@ MinidumpProcessor::~MinidumpProcessor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinidumpProcessor::Process(const string &minidump_file,
|
bool MinidumpProcessor::Process(const string &minidump_file,
|
||||||
void *supplier_data,
|
|
||||||
StackFrames *stack_frames) {
|
StackFrames *stack_frames) {
|
||||||
Minidump dump(minidump_file);
|
Minidump dump(minidump_file);
|
||||||
if (!dump.Read()) {
|
if (!dump.Read()) {
|
||||||
|
@ -56,7 +55,7 @@ bool MinidumpProcessor::Process(const string &minidump_file,
|
||||||
|
|
||||||
// TODO(bryner): figure out which StackWalker we want
|
// TODO(bryner): figure out which StackWalker we want
|
||||||
StackwalkerX86 walker(exception->GetContext(), thread_memory,
|
StackwalkerX86 walker(exception->GetContext(), thread_memory,
|
||||||
dump.GetModuleList(), supplier_, supplier_data);
|
dump.GetModuleList(), supplier_);
|
||||||
walker.Walk(stack_frames);
|
walker.Walk(stack_frames);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,22 +36,10 @@ namespace google_airbag {
|
||||||
|
|
||||||
class TestSymbolSupplier : public SymbolSupplier {
|
class TestSymbolSupplier : public SymbolSupplier {
|
||||||
public:
|
public:
|
||||||
TestSymbolSupplier() : has_supplier_data_(false) {}
|
virtual string GetSymbolFile(MinidumpModule *module);
|
||||||
virtual ~TestSymbolSupplier() {}
|
|
||||||
|
|
||||||
virtual string GetSymbolFile(MinidumpModule *module, void *supplier_data);
|
|
||||||
|
|
||||||
// This member is used to test the data argument to GetSymbolFile.
|
|
||||||
// If the argument is correct, it's set to true.
|
|
||||||
bool has_supplier_data_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
string TestSymbolSupplier::GetSymbolFile(MinidumpModule *module,
|
string TestSymbolSupplier::GetSymbolFile(MinidumpModule *module) {
|
||||||
void *supplier_data) {
|
|
||||||
if (supplier_data == &has_supplier_data_) {
|
|
||||||
has_supplier_data_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*(module->GetName()) == "c:\\test_app.exe") {
|
if (*(module->GetName()) == "c:\\test_app.exe") {
|
||||||
return string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
return string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
||||||
"/src/processor/testdata/minidump2.sym";
|
"/src/processor/testdata/minidump2.sym";
|
||||||
|
@ -73,9 +61,7 @@ static bool RunTests() {
|
||||||
string minidump_file = string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
string minidump_file = string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
||||||
"/src/processor/testdata/minidump2.dmp";
|
"/src/processor/testdata/minidump2.dmp";
|
||||||
|
|
||||||
ASSERT_TRUE(processor.Process(minidump_file,
|
ASSERT_TRUE(processor.Process(minidump_file, &stack_frames));
|
||||||
&supplier.has_supplier_data_, &stack_frames));
|
|
||||||
ASSERT_TRUE(supplier.has_supplier_data_);
|
|
||||||
ASSERT_EQ(stack_frames.size(), 4);
|
ASSERT_EQ(stack_frames.size(), 4);
|
||||||
|
|
||||||
ASSERT_EQ(stack_frames[0].module_base, 0x400000);
|
ASSERT_EQ(stack_frames[0].module_base, 0x400000);
|
||||||
|
|
|
@ -80,7 +80,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StackwalkerX86 stackwalker = StackwalkerX86(context, stack_memory,
|
StackwalkerX86 stackwalker = StackwalkerX86(context, stack_memory,
|
||||||
modules, NULL, NULL);
|
modules, NULL);
|
||||||
|
|
||||||
StackFrames stack;
|
StackFrames stack;
|
||||||
stackwalker.Walk(&stack);
|
stackwalker.Walk(&stack);
|
||||||
|
|
|
@ -34,11 +34,10 @@ using std::auto_ptr;
|
||||||
|
|
||||||
|
|
||||||
Stackwalker::Stackwalker(MemoryRegion* memory, MinidumpModuleList* modules,
|
Stackwalker::Stackwalker(MemoryRegion* memory, MinidumpModuleList* modules,
|
||||||
SymbolSupplier* supplier, void* supplier_data)
|
SymbolSupplier* supplier)
|
||||||
: memory_(memory),
|
: memory_(memory),
|
||||||
modules_(modules),
|
modules_(modules),
|
||||||
supplier_(supplier),
|
supplier_(supplier) {
|
||||||
supplier_data_(supplier_data) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ void Stackwalker::Walk(StackFrames *frames) {
|
||||||
frame->module_base = module->base_address();
|
frame->module_base = module->base_address();
|
||||||
if (modules_ && supplier_) {
|
if (modules_ && supplier_) {
|
||||||
string symbol_file =
|
string symbol_file =
|
||||||
supplier_->GetSymbolFile(module, supplier_data_);
|
supplier_->GetSymbolFile(module);
|
||||||
if (!symbol_file.empty()) {
|
if (!symbol_file.empty()) {
|
||||||
resolver.LoadModule(*(module->GetName()), symbol_file);
|
resolver.LoadModule(*(module->GetName()), symbol_file);
|
||||||
resolver.FillSourceLineInfo(frame.get());
|
resolver.FillSourceLineInfo(frame.get());
|
||||||
|
|
|
@ -54,12 +54,10 @@ class Stackwalker {
|
||||||
// that is used to look up which code module each stack frame is
|
// that is used to look up which code module each stack frame is
|
||||||
// associated with. supplier is an optional caller-supplied SymbolSupplier
|
// associated with. supplier is an optional caller-supplied SymbolSupplier
|
||||||
// implementation. If supplier is NULL, source line info will not be
|
// implementation. If supplier is NULL, source line info will not be
|
||||||
// resolved. supplier_data will be passed to the SymbolSupplier's
|
// resolved.
|
||||||
// GetSymbolFile method.
|
|
||||||
Stackwalker(MemoryRegion* memory,
|
Stackwalker(MemoryRegion* memory,
|
||||||
MinidumpModuleList* modules,
|
MinidumpModuleList* modules,
|
||||||
SymbolSupplier* supplier,
|
SymbolSupplier* supplier);
|
||||||
void* supplier_data);
|
|
||||||
|
|
||||||
// The stack memory to walk. Subclasses will require this region to
|
// The stack memory to walk. Subclasses will require this region to
|
||||||
// get information from the stack.
|
// get information from the stack.
|
||||||
|
@ -83,9 +81,6 @@ class Stackwalker {
|
||||||
|
|
||||||
// The optional SymbolSupplier for resolving source line info.
|
// The optional SymbolSupplier for resolving source line info.
|
||||||
SymbolSupplier* supplier_;
|
SymbolSupplier* supplier_;
|
||||||
|
|
||||||
// Caller-supplied data to be passed to the symbol supplier
|
|
||||||
void* supplier_data_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,8 @@ namespace google_airbag {
|
||||||
StackwalkerX86::StackwalkerX86(MinidumpContext* context,
|
StackwalkerX86::StackwalkerX86(MinidumpContext* context,
|
||||||
MemoryRegion* memory,
|
MemoryRegion* memory,
|
||||||
MinidumpModuleList* modules,
|
MinidumpModuleList* modules,
|
||||||
SymbolSupplier* supplier,
|
SymbolSupplier* supplier)
|
||||||
void* supplier_data)
|
: Stackwalker(memory, modules, supplier),
|
||||||
: Stackwalker(memory, modules, supplier, supplier_data),
|
|
||||||
last_frame_pointer_(0) {
|
last_frame_pointer_(0) {
|
||||||
if (memory_->GetBase() + memory_->GetSize() - 1 > 0xffffffff) {
|
if (memory_->GetBase() + memory_->GetSize() - 1 > 0xffffffff) {
|
||||||
// The x86 is a 32-bit CPU, the limits of the supplied stack are invalid.
|
// The x86 is a 32-bit CPU, the limits of the supplied stack are invalid.
|
||||||
|
|
|
@ -45,8 +45,7 @@ class StackwalkerX86 : public Stackwalker {
|
||||||
StackwalkerX86(MinidumpContext* context,
|
StackwalkerX86(MinidumpContext* context,
|
||||||
MemoryRegion* memory,
|
MemoryRegion* memory,
|
||||||
MinidumpModuleList* modules,
|
MinidumpModuleList* modules,
|
||||||
SymbolSupplier* supplier,
|
SymbolSupplier* supplier);
|
||||||
void* supplier_data);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Implementation of Stackwalker, using x86 context (%ebp, %eip) and
|
// Implementation of Stackwalker, using x86 context (%ebp, %eip) and
|
||||||
|
|
Loading…
Reference in a new issue