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();
|
||||
|
||||
// Fills in the given StackFrames vector by processing the minidump file.
|
||||
// supplier_data is an opaque pointer which is passed to
|
||||
// SymbolSupplier::GetSymbolFile(). Returns true on success.
|
||||
bool Process(const string &minidump_file, void *supplier_data,
|
||||
StackFrames *stack_frames);
|
||||
// Returns true on success.
|
||||
bool Process(const string &minidump_file, StackFrames *stack_frames);
|
||||
|
||||
private:
|
||||
SymbolSupplier *supplier_;
|
||||
|
|
|
@ -30,9 +30,7 @@ class SymbolSupplier {
|
|||
virtual ~SymbolSupplier() {}
|
||||
|
||||
// Returns the path to the symbol file for the given module.
|
||||
// supplier_data is passed through from MinidumpProcessor::Process().
|
||||
virtual string GetSymbolFile(MinidumpModule *module,
|
||||
void *supplier_data) = 0;
|
||||
virtual string GetSymbolFile(MinidumpModule *module) = 0;
|
||||
};
|
||||
|
||||
} // namespace google_airbag
|
||||
|
|
|
@ -26,7 +26,6 @@ MinidumpProcessor::~MinidumpProcessor() {
|
|||
}
|
||||
|
||||
bool MinidumpProcessor::Process(const string &minidump_file,
|
||||
void *supplier_data,
|
||||
StackFrames *stack_frames) {
|
||||
Minidump dump(minidump_file);
|
||||
if (!dump.Read()) {
|
||||
|
@ -56,7 +55,7 @@ bool MinidumpProcessor::Process(const string &minidump_file,
|
|||
|
||||
// TODO(bryner): figure out which StackWalker we want
|
||||
StackwalkerX86 walker(exception->GetContext(), thread_memory,
|
||||
dump.GetModuleList(), supplier_, supplier_data);
|
||||
dump.GetModuleList(), supplier_);
|
||||
walker.Walk(stack_frames);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,22 +36,10 @@ namespace google_airbag {
|
|||
|
||||
class TestSymbolSupplier : public SymbolSupplier {
|
||||
public:
|
||||
TestSymbolSupplier() : has_supplier_data_(false) {}
|
||||
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_;
|
||||
virtual string GetSymbolFile(MinidumpModule *module);
|
||||
};
|
||||
|
||||
string TestSymbolSupplier::GetSymbolFile(MinidumpModule *module,
|
||||
void *supplier_data) {
|
||||
if (supplier_data == &has_supplier_data_) {
|
||||
has_supplier_data_ = true;
|
||||
}
|
||||
|
||||
string TestSymbolSupplier::GetSymbolFile(MinidumpModule *module) {
|
||||
if (*(module->GetName()) == "c:\\test_app.exe") {
|
||||
return string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
||||
"/src/processor/testdata/minidump2.sym";
|
||||
|
@ -73,9 +61,7 @@ static bool RunTests() {
|
|||
string minidump_file = string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
||||
"/src/processor/testdata/minidump2.dmp";
|
||||
|
||||
ASSERT_TRUE(processor.Process(minidump_file,
|
||||
&supplier.has_supplier_data_, &stack_frames));
|
||||
ASSERT_TRUE(supplier.has_supplier_data_);
|
||||
ASSERT_TRUE(processor.Process(minidump_file, &stack_frames));
|
||||
ASSERT_EQ(stack_frames.size(), 4);
|
||||
|
||||
ASSERT_EQ(stack_frames[0].module_base, 0x400000);
|
||||
|
|
|
@ -80,7 +80,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
StackwalkerX86 stackwalker = StackwalkerX86(context, stack_memory,
|
||||
modules, NULL, NULL);
|
||||
modules, NULL);
|
||||
|
||||
StackFrames stack;
|
||||
stackwalker.Walk(&stack);
|
||||
|
|
|
@ -34,11 +34,10 @@ using std::auto_ptr;
|
|||
|
||||
|
||||
Stackwalker::Stackwalker(MemoryRegion* memory, MinidumpModuleList* modules,
|
||||
SymbolSupplier* supplier, void* supplier_data)
|
||||
SymbolSupplier* supplier)
|
||||
: memory_(memory),
|
||||
modules_(modules),
|
||||
supplier_(supplier),
|
||||
supplier_data_(supplier_data) {
|
||||
supplier_(supplier) {
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +64,7 @@ void Stackwalker::Walk(StackFrames *frames) {
|
|||
frame->module_base = module->base_address();
|
||||
if (modules_ && supplier_) {
|
||||
string symbol_file =
|
||||
supplier_->GetSymbolFile(module, supplier_data_);
|
||||
supplier_->GetSymbolFile(module);
|
||||
if (!symbol_file.empty()) {
|
||||
resolver.LoadModule(*(module->GetName()), symbol_file);
|
||||
resolver.FillSourceLineInfo(frame.get());
|
||||
|
|
|
@ -54,12 +54,10 @@ class Stackwalker {
|
|||
// that is used to look up which code module each stack frame is
|
||||
// associated with. supplier is an optional caller-supplied SymbolSupplier
|
||||
// implementation. If supplier is NULL, source line info will not be
|
||||
// resolved. supplier_data will be passed to the SymbolSupplier's
|
||||
// GetSymbolFile method.
|
||||
// resolved.
|
||||
Stackwalker(MemoryRegion* memory,
|
||||
MinidumpModuleList* modules,
|
||||
SymbolSupplier* supplier,
|
||||
void* supplier_data);
|
||||
SymbolSupplier* supplier);
|
||||
|
||||
// The stack memory to walk. Subclasses will require this region to
|
||||
// get information from the stack.
|
||||
|
@ -83,9 +81,6 @@ class Stackwalker {
|
|||
|
||||
// The optional SymbolSupplier for resolving source line info.
|
||||
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,
|
||||
MemoryRegion* memory,
|
||||
MinidumpModuleList* modules,
|
||||
SymbolSupplier* supplier,
|
||||
void* supplier_data)
|
||||
: Stackwalker(memory, modules, supplier, supplier_data),
|
||||
SymbolSupplier* supplier)
|
||||
: Stackwalker(memory, modules, supplier),
|
||||
last_frame_pointer_(0) {
|
||||
if (memory_->GetBase() + memory_->GetSize() - 1 > 0xffffffff) {
|
||||
// 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,
|
||||
MemoryRegion* memory,
|
||||
MinidumpModuleList* modules,
|
||||
SymbolSupplier* supplier,
|
||||
void* supplier_data);
|
||||
SymbolSupplier* supplier);
|
||||
|
||||
private:
|
||||
// Implementation of Stackwalker, using x86 context (%ebp, %eip) and
|
||||
|
|
Loading…
Reference in a new issue