Add support to the StackWalker for resolving symbols, using a

caller-implemented SymbolSupplier object to get a symbol file.

Add a CrashReportProcessor object which provides a simple API for processing
a CrashReport struct, given a SymbolSupplier and a minidump file.

r=mmentovai (#17))


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@18 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
bryner 2006-09-08 02:35:53 +00:00
parent 39716226cf
commit d5e66382d1
17 changed files with 14492 additions and 3332 deletions

View file

@ -37,7 +37,10 @@ lib_LTLIBRARIES = src/libairbag.la
src_libairbag_la_SOURCES = \
src/google/airbag_types.h \
src/google/crash_report.h \
src/google/crash_report_processor.h \
src/google/stack_frame.h \
src/google/symbol_supplier.h \
src/processor/crash_report_processor.cc \
src/processor/memory_region.h \
src/processor/minidump.cc \
src/processor/minidump.h \
@ -60,7 +63,8 @@ bin_PROGRAMS = \
## Tests
check_PROGRAMS = \
src/processor/range_map_unittest \
src/processor/source_line_resolver_unittest
src/processor/source_line_resolver_unittest \
src/processor/crash_report_processor_unittest
check_SCRIPTS = \
src/processor/minidump_dump_test \
src/processor/minidump_stackwalk_test
@ -75,6 +79,14 @@ src_processor_source_line_resolver_unittest_SOURCES = \
src_processor_source_line_resolver_unittest_LDADD = \
src/processor/source_line_resolver.lo
src_processor_crash_report_processor_unittest_SOURCES = \
src/processor/crash_report_processor_unittest.cc
src_processor_crash_report_processor_unittest_LDADD = \
src/processor/crash_report_processor.lo \
src/processor/minidump.lo \
src/processor/stackwalker.lo \
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
## Non-installables
noinst_PROGRAMS =
@ -90,7 +102,8 @@ src_processor_minidump_stackwalk_SOURCES = \
src_processor_minidump_stackwalk_LDADD = \
src/processor/minidump.lo \
src/processor/stackwalker.lo \
src/processor/stackwalker_x86.lo
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
## Additional files to be included in a source distribution
@ -99,6 +112,8 @@ EXTRA_DIST = \
src/processor/testdata/minidump1.dmp \
src/processor/testdata/minidump1.out \
src/processor/testdata/minidump1.stack.out \
src/processor/testdata/minidump2.dmp \
src/processor/testdata/minidump2.sym \
src/processor/testdata/module1.out \
src/processor/testdata/module2.out \
src/processor/testdata/module3_bad.out

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -31,6 +31,8 @@
SOURCES = $(src_libairbag_la_SOURCES) $(src_processor_crash_report_processor_unittest_SOURCES) $(src_processor_minidump_dump_SOURCES) $(src_processor_minidump_stackwalk_SOURCES) $(src_processor_range_map_unittest_SOURCES) $(src_processor_source_line_resolver_unittest_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
@ -56,7 +58,8 @@ host_triplet = @host@
bin_PROGRAMS = src/processor/minidump_dump$(EXEEXT) \
src/processor/minidump_stackwalk$(EXEEXT)
check_PROGRAMS = src/processor/range_map_unittest$(EXEEXT) \
src/processor/source_line_resolver_unittest$(EXEEXT)
src/processor/source_line_resolver_unittest$(EXEEXT) \
src/processor/crash_report_processor_unittest$(EXEEXT)
noinst_PROGRAMS =
DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
@ -86,12 +89,22 @@ libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
src_libairbag_la_LIBADD =
am__dirstamp = $(am__leading_dot)dirstamp
am_src_libairbag_la_OBJECTS = src/processor/minidump.lo \
am_src_libairbag_la_OBJECTS = src/processor/crash_report_processor.lo \
src/processor/minidump.lo \
src/processor/source_line_resolver.lo \
src/processor/stackwalker.lo src/processor/stackwalker_x86.lo
src_libairbag_la_OBJECTS = $(am_src_libairbag_la_OBJECTS)
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
am_src_processor_crash_report_processor_unittest_OBJECTS = \
src/processor/crash_report_processor_unittest.$(OBJEXT)
src_processor_crash_report_processor_unittest_OBJECTS = \
$(am_src_processor_crash_report_processor_unittest_OBJECTS)
src_processor_crash_report_processor_unittest_DEPENDENCIES = \
src/processor/crash_report_processor.lo \
src/processor/minidump.lo src/processor/stackwalker.lo \
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
am_src_processor_minidump_dump_OBJECTS = \
src/processor/minidump_dump.$(OBJEXT)
src_processor_minidump_dump_OBJECTS = \
@ -103,7 +116,8 @@ src_processor_minidump_stackwalk_OBJECTS = \
$(am_src_processor_minidump_stackwalk_OBJECTS)
src_processor_minidump_stackwalk_DEPENDENCIES = \
src/processor/minidump.lo src/processor/stackwalker.lo \
src/processor/stackwalker_x86.lo
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
am_src_processor_range_map_unittest_OBJECTS = \
src/processor/range_map_unittest.$(OBJEXT)
src_processor_range_map_unittest_OBJECTS = \
@ -136,11 +150,13 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(src_libairbag_la_SOURCES) \
$(src_processor_crash_report_processor_unittest_SOURCES) \
$(src_processor_minidump_dump_SOURCES) \
$(src_processor_minidump_stackwalk_SOURCES) \
$(src_processor_range_map_unittest_SOURCES) \
$(src_processor_source_line_resolver_unittest_SOURCES)
DIST_SOURCES = $(src_libairbag_la_SOURCES) \
$(src_processor_crash_report_processor_unittest_SOURCES) \
$(src_processor_minidump_dump_SOURCES) \
$(src_processor_minidump_stackwalk_SOURCES) \
$(src_processor_range_map_unittest_SOURCES) \
@ -273,7 +289,10 @@ lib_LTLIBRARIES = src/libairbag.la
src_libairbag_la_SOURCES = \
src/google/airbag_types.h \
src/google/crash_report.h \
src/google/crash_report_processor.h \
src/google/stack_frame.h \
src/google/symbol_supplier.h \
src/processor/crash_report_processor.cc \
src/processor/memory_region.h \
src/processor/minidump.cc \
src/processor/minidump.h \
@ -301,6 +320,16 @@ src_processor_source_line_resolver_unittest_SOURCES = \
src_processor_source_line_resolver_unittest_LDADD = \
src/processor/source_line_resolver.lo
src_processor_crash_report_processor_unittest_SOURCES = \
src/processor/crash_report_processor_unittest.cc
src_processor_crash_report_processor_unittest_LDADD = \
src/processor/crash_report_processor.lo \
src/processor/minidump.lo \
src/processor/stackwalker.lo \
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
noinst_SCRIPTS = $(check_SCRIPTS)
src_processor_minidump_dump_SOURCES = \
src/processor/minidump_dump.cc
@ -314,13 +343,16 @@ src_processor_minidump_stackwalk_SOURCES = \
src_processor_minidump_stackwalk_LDADD = \
src/processor/minidump.lo \
src/processor/stackwalker.lo \
src/processor/stackwalker_x86.lo
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
EXTRA_DIST = \
$(SCRIPTS) \
src/processor/testdata/minidump1.dmp \
src/processor/testdata/minidump1.out \
src/processor/testdata/minidump1.stack.out \
src/processor/testdata/minidump2.dmp \
src/processor/testdata/minidump2.sym \
src/processor/testdata/module1.out \
src/processor/testdata/module2.out \
src/processor/testdata/module3_bad.out
@ -412,6 +444,9 @@ src/processor/$(am__dirstamp):
src/processor/$(DEPDIR)/$(am__dirstamp):
@$(mkdir_p) src/processor/$(DEPDIR)
@: > src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/crash_report_processor.lo: \
src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/minidump.lo: src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/source_line_resolver.lo: src/processor/$(am__dirstamp) \
@ -467,6 +502,12 @@ clean-noinstPROGRAMS:
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
src/processor/crash_report_processor_unittest.$(OBJEXT): \
src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/crash_report_processor_unittest$(EXEEXT): $(src_processor_crash_report_processor_unittest_OBJECTS) $(src_processor_crash_report_processor_unittest_DEPENDENCIES) src/processor/$(am__dirstamp)
@rm -f src/processor/crash_report_processor_unittest$(EXEEXT)
$(CXXLINK) $(src_processor_crash_report_processor_unittest_LDFLAGS) $(src_processor_crash_report_processor_unittest_OBJECTS) $(src_processor_crash_report_processor_unittest_LDADD) $(LIBS)
src/processor/minidump_dump.$(OBJEXT): src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/minidump_dump$(EXEEXT): $(src_processor_minidump_dump_OBJECTS) $(src_processor_minidump_dump_DEPENDENCIES) src/processor/$(am__dirstamp)
@ -493,6 +534,9 @@ src/processor/source_line_resolver_unittest$(EXEEXT): $(src_processor_source_lin
mostlyclean-compile:
-rm -f *.$(OBJEXT)
-rm -f src/processor/crash_report_processor.$(OBJEXT)
-rm -f src/processor/crash_report_processor.lo
-rm -f src/processor/crash_report_processor_unittest.$(OBJEXT)
-rm -f src/processor/minidump.$(OBJEXT)
-rm -f src/processor/minidump.lo
-rm -f src/processor/minidump_dump.$(OBJEXT)
@ -509,6 +553,8 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/crash_report_processor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/crash_report_processor_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/minidump.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/minidump_dump.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/minidump_stackwalk.Po@am__quote@

1481
aclocal.m4 vendored

File diff suppressed because it is too large Load diff

4852
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,44 @@
// Copyright (C) 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CRASH_REPORT_PROCESSOR_H__
#define GOOGLE_CRASH_REPORT_PROCESSOR_H__
#include <string>
namespace google_airbag {
using std::string;
struct CrashReport;
class SymbolSupplier;
class CrashReportProcessor {
public:
// Initializes this CrashReportProcessor. supplier should be an
// implementation of the SymbolSupplier abstract base class.
CrashReportProcessor(SymbolSupplier *supplier);
~CrashReportProcessor();
// Fills in the stack and other derived data for the CrashReport,
// using the supplied minidump file. Returns true on success.
bool ProcessReport(CrashReport *report, const string &minidump_file);
private:
SymbolSupplier *supplier_;
};
} // namespace google_airbag
#endif // GOOGLE_CRASH_REPORT_PROCESSOR_H__

View file

@ -0,0 +1,41 @@
// Copyright (C) 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// The caller may implement the SymbolSupplier abstract base class
// to provide symbols for a given module.
#ifndef GOOGLE_SYMBOL_SUPPLIER_H__
#define GOOGLE_SYMBOL_SUPPLIER_H__
#include <string>
namespace google_airbag {
using std::string;
class MinidumpModule;
struct CrashReport;
class SymbolSupplier {
public:
virtual ~SymbolSupplier() {}
// Returns the path to the symbol file for the given module.
// report will be the pointer supplied to ProcessReport().
virtual string GetSymbolFile(MinidumpModule *module,
const CrashReport *report) = 0;
};
} // namespace google_airbag
#endif // GOOGLE_SYMBOL_SUPPLIER_H__

View file

@ -0,0 +1,72 @@
// Copyright (C) 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "google/crash_report.h"
#include "google/crash_report_processor.h"
#include "processor/minidump.h"
#include "processor/stackwalker_x86.h"
namespace google_airbag {
CrashReportProcessor::CrashReportProcessor(SymbolSupplier *supplier)
: supplier_(supplier) {
}
CrashReportProcessor::~CrashReportProcessor() {
}
bool CrashReportProcessor::ProcessReport(CrashReport *report,
const string &minidump_file) {
int fd = open(minidump_file.c_str(), O_RDONLY);
if (fd == -1) {
return false;
}
Minidump dump(fd);
if (!dump.Read()) {
return false;
}
MinidumpException *exception = dump.GetException();
if (!exception) {
return false;
}
MinidumpThreadList *threads = dump.GetThreadList();
if (!threads) {
return false;
}
// TODO(bryner): get all the threads
MinidumpThread *thread = threads->GetThreadByID(exception->GetThreadID());
if (!thread) {
return false;
}
MinidumpMemoryRegion *thread_memory = thread->GetMemory();
if (!thread_memory) {
return false;
}
// TODO(bryner): figure out which StackWalker we want
StackwalkerX86 walker(exception->GetContext(), thread_memory,
dump.GetModuleList(), supplier_, report);
walker.Walk(&report->stack_frames);
return true;
}
} // namespace google_airbag

View file

@ -0,0 +1,107 @@
// Copyright (C) 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Unit test for CrashReporter. Uses a pre-generated minidump and
// corresponding symbol file, and checks the contents of the CrashReport.
#include <string>
#include "google/crash_report.h"
#include "google/crash_report_processor.h"
#include "google/symbol_supplier.h"
#include "processor/minidump.h"
using std::string;
using google_airbag::CrashReportProcessor;
using google_airbag::CrashReport;
#define ASSERT_TRUE(cond) \
if (!(cond)) { \
fprintf(stderr, "FAILED: %s at %s:%d\n", #cond, __FILE__, __LINE__); \
return false; \
}
#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
namespace google_airbag {
class TestSymbolSupplier : public SymbolSupplier {
public:
virtual string GetSymbolFile(MinidumpModule *module,
const CrashReport *report);
};
string TestSymbolSupplier::GetSymbolFile(MinidumpModule *module,
const CrashReport *report) {
if (*(module->GetName()) == "c:\\test_app.exe") {
return string(getenv("srcdir") ? getenv("srcdir") : ".") +
"/src/processor/testdata/minidump2.sym";
}
return "";
}
} // namespace google_airbag
using google_airbag::TestSymbolSupplier;
static bool RunTests() {
TestSymbolSupplier supplier;
CrashReportProcessor processor(&supplier);
CrashReport report;
string minidump_file = string(getenv("srcdir") ? getenv("srcdir") : ".") +
"/src/processor/testdata/minidump2.dmp";
ASSERT_TRUE(processor.ProcessReport(&report, minidump_file));
ASSERT_EQ(report.stack_frames.size(), 4);
ASSERT_EQ(report.stack_frames[0].module_base, 0x400000);
ASSERT_EQ(report.stack_frames[0].module_name, "c:\\test_app.exe");
ASSERT_EQ(report.stack_frames[0].function_name, "CrashFunction");
ASSERT_EQ(report.stack_frames[0].source_file_name, "c:\\test_app.cc");
ASSERT_EQ(report.stack_frames[0].source_line, 36);
ASSERT_EQ(report.stack_frames[1].module_base, 0x400000);
ASSERT_EQ(report.stack_frames[1].module_name, "c:\\test_app.exe");
ASSERT_EQ(report.stack_frames[1].function_name, "main");
ASSERT_EQ(report.stack_frames[1].source_file_name, "c:\\test_app.cc");
ASSERT_EQ(report.stack_frames[1].source_line, 42);
// This comes from the CRT
ASSERT_EQ(report.stack_frames[2].module_base, 0x400000);
ASSERT_EQ(report.stack_frames[2].module_name, "c:\\test_app.exe");
ASSERT_EQ(report.stack_frames[2].function_name, "__tmainCRTStartup");
ASSERT_EQ(report.stack_frames[2].source_file_name,
"f:\\rtm\\vctools\\crt_bld\\self_x86\\crt\\src\\crt0.c");
ASSERT_EQ(report.stack_frames[2].source_line, 318);
// No debug info available for kernel32.dll
ASSERT_EQ(report.stack_frames[3].module_base, 0x7c800000);
ASSERT_EQ(report.stack_frames[3].module_name,
"C:\\WINDOWS\\system32\\kernel32.dll");
ASSERT_TRUE(report.stack_frames[3].function_name.empty());
ASSERT_TRUE(report.stack_frames[3].source_file_name.empty());
ASSERT_EQ(report.stack_frames[3].source_line, 0);
return true;
}
int main(int argc, char *argv[]) {
if (!RunTests()) {
return 1;
}
return 0;
}

View file

@ -30,13 +30,10 @@
#define open _open
#endif // !_WIN32
#include <memory>
#include "processor/minidump.h"
#include "processor/stackwalker_x86.h"
using std::auto_ptr;
using namespace google_airbag;
@ -95,17 +92,15 @@ int main(int argc, char** argv) {
exit(1);
}
StackwalkerX86 stackwalker = StackwalkerX86(context, stack_memory, modules);
StackwalkerX86 stackwalker = StackwalkerX86(context, stack_memory,
modules, NULL, NULL);
auto_ptr<StackFrames> stack(stackwalker.Walk());
if (!stack.get()) {
fprintf(stderr, "stackwalker->Walk() failed\n");
exit(1);
}
StackFrames stack;
stackwalker.Walk(&stack);
unsigned int index;
for (index = 0 ; index < stack->size() ; index++) {
StackFrame frame = stack->at(index);
for (index = 0 ; index < stack.size() ; index++) {
StackFrame frame = stack.at(index);
printf("[%2d] ebp = 0x%08llx eip = 0x%08llx \"%s\" + 0x%08llx\n",
index,
frame.frame_pointer,

View file

@ -145,7 +145,7 @@ bool SourceLineResolver::LoadModule(const string &module_name,
void SourceLineResolver::FillSourceLineInfo(StackFrame *frame) const {
ModuleMap::const_iterator it = modules_->find(frame->module_name);
if (it != modules_->end()) {
it->second->LookupAddress(frame->instruction, frame);
it->second->LookupAddress(frame->instruction - frame->module_base, frame);
}
}

View file

@ -23,6 +23,8 @@
#include "processor/stackwalker.h"
#include "processor/minidump.h"
#include "processor/source_line_resolver.h"
#include "google/symbol_supplier.h"
namespace google_airbag {
@ -31,13 +33,19 @@ namespace google_airbag {
using std::auto_ptr;
Stackwalker::Stackwalker(MemoryRegion* memory, MinidumpModuleList* modules)
: memory_(memory), modules_(modules) {
Stackwalker::Stackwalker(MemoryRegion* memory, MinidumpModuleList* modules,
SymbolSupplier *supplier, const CrashReport *report)
: memory_(memory),
modules_(modules),
supplier_(supplier),
report_(report) {
}
StackFrames* Stackwalker::Walk() {
auto_ptr<StackFrames> frames(new StackFrames());
void Stackwalker::Walk(StackFrames *frames) {
frames->clear();
bool resolve_symbols = (modules_ && supplier_);
SourceLineResolver resolver;
// Begin with the context frame, and keep getting callers until there are
// no more.
@ -56,6 +64,13 @@ StackFrames* Stackwalker::Walk() {
if (module) {
frame->module_name = *(module->GetName());
frame->module_base = module->base_address();
if (resolve_symbols) {
string symbol_file = supplier_->GetSymbolFile(module, report_);
if (!symbol_file.empty()) {
resolver.LoadModule(*(module->GetName()), symbol_file);
}
resolver.FillSourceLineInfo(frame.get());
}
}
}
@ -70,8 +85,6 @@ StackFrames* Stackwalker::Walk() {
// Get the next frame.
valid = GetCallerFrame(frame.get());
}
return frames.release();
}

View file

@ -36,24 +36,31 @@ namespace google_airbag {
class MinidumpModuleList;
class SymbolSupplier;
struct CrashReport;
class Stackwalker {
public:
virtual ~Stackwalker() {}
// Produces a vector of StackFrames by calling GetContextFrame and
// Fills the given vector of StackFrames by calling GetContextFrame and
// GetCallerFrame, and populating the returned frames with module
// offset and name information if possible. The caller takes ownership
// of the StackFrames object and is responsible for freeing it.
StackFrames* Walk();
// offset and name information if possible.
void Walk(StackFrames *frames);
protected:
// memory identifies a MemoryRegion that provides the stack memory
// for the stack to walk. modules, if non-NULL, is a MinidumpModuleList
// that is used to look up which code module each stack frame is
// associated with.
Stackwalker(MemoryRegion* memory, MinidumpModuleList* modules);
// associated with. supplier is an optional caller-supplied SymbolSupplier
// implementation. If supplier is NULL, source line info will not be
// resolved. The CrashReport object will be passed to the SymbolSupplier's
// GetSymbolFile method.
Stackwalker(MemoryRegion* memory,
MinidumpModuleList* modules,
SymbolSupplier* supplier,
const CrashReport* report);
// The stack memory to walk. Subclasses will require this region to
// get information from the stack.
@ -74,6 +81,12 @@ class Stackwalker {
// A list of modules, for populating each StackFrame's module information.
// This field is optional and may be NULL.
MinidumpModuleList* modules_;
// The optional SymbolSupplier for resolving source line info.
SymbolSupplier* supplier_;
// The CrashReport object which is passed to the SymbolSupplier. May be null.
const CrashReport* report_;
};

View file

@ -28,8 +28,10 @@ namespace google_airbag {
StackwalkerX86::StackwalkerX86(MinidumpContext* context,
MemoryRegion* memory,
MinidumpModuleList* modules)
: Stackwalker(memory, modules),
MinidumpModuleList* modules,
SymbolSupplier* supplier,
const CrashReport* report)
: Stackwalker(memory, modules, supplier, report),
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.

View file

@ -40,11 +40,13 @@ class StackwalkerX86 : public Stackwalker {
public:
// context is a MinidumpContext object that gives access to x86-specific
// register state corresponding to the innermost called frame to be
// included in the stack. memory and modules are passed directly through
// included in the stack. The other arguments are passed directly through
// to the base Stackwalker constructor.
StackwalkerX86(MinidumpContext* context,
MemoryRegion* memory,
MinidumpModuleList* modules);
MinidumpModuleList* modules,
SymbolSupplier* supplier,
const CrashReport* report);
private:
// Implementation of Stackwalker, using x86 context (%ebp, %eip) and

BIN
src/processor/testdata/minidump2.dmp vendored Executable file

Binary file not shown.

10686
src/processor/testdata/minidump2.sym vendored Executable file

File diff suppressed because it is too large Load diff

45
src/processor/testdata/test_app.cc vendored Normal file
View file

@ -0,0 +1,45 @@
// This file is used to generate minidump2.dmp and minidump2.sym.
// cl /Zi /Fetest_app.exe test_app.cc dbghelp.lib
// Then run test_app to generate a dump, and dump_syms to create the .sym file.
#include <windows.h>
#include <dbghelp.h>
static LONG HandleException(EXCEPTION_POINTERS *exinfo) {
HANDLE dump_file = CreateFile("dump.dmp",
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
MINIDUMP_EXCEPTION_INFORMATION except_info;
except_info.ThreadId = GetCurrentThreadId();
except_info.ExceptionPointers = exinfo;
except_info.ClientPointers = false;
MiniDumpWriteDump(GetCurrentProcess(),
GetCurrentProcessId(),
dump_file,
MiniDumpNormal,
&except_info,
NULL,
NULL);
CloseHandle(dump_file);
return EXCEPTION_EXECUTE_HANDLER;
}
void CrashFunction() {
int *i = NULL;
*i = 5; // crash!
}
int main(int argc, char *argv[]) {
__try {
CrashFunction();
} __except(HandleException(GetExceptionInformation())) {
}
return 0;
}