minidump_stackwalk should use MinidumpProcessor (#64). r=bryner

- minidump_stackwalk is now much more useful as a debugging tool and
   even as a standalone tool.
 - Reimplementation of minidump_stackwalk around MinidumpProcessor.
 - minidump_stackwalk displays all pertinent information returned by
   MinidumpProcessor in the ProcessState.
 - New PathnameStripper::File static utility method to display only the
   leaf file name in a pathname, cleaning up minidump_stackwalk's output.
 - New SimpleSymbolSupplier class, which implements a simple
   filesystem-based symbol supplier compatible with the layout used by
   Microsoft Symbol Server and its client cache.
 - minidump_stackwalk now accepts an optional second argument, a pathname
   to use as a symbol directory for a SimpleSymbolSupplier.
 - Updated test data to be compatible with SimpleSymbolSupplier, and added
   test data for kernel32.pdb.  Test data converted from CRLF line endings
   to LF.

http://groups.google.com/group/airbag-dev/browse_thread/thread/cce30a84f6b2d728


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@53 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mmentovai 2006-10-27 00:40:56 +00:00
parent f944ba3fbb
commit c34850a202
14 changed files with 21920 additions and 11660 deletions

View File

@ -68,12 +68,16 @@ src_libairbag_la_SOURCES = \
src/processor/minidump.h \
src/processor/minidump_format.h \
src/processor/minidump_processor.cc \
src/processor/pathname_stripper.cc \
src/processor/pathname_stripper.h \
src/processor/postfix_evaluator.h \
src/processor/postfix_evaluator-inl.h \
src/processor/process_state.cc \
src/processor/range_map.h \
src/processor/range_map-inl.h \
src/processor/scoped_ptr.h \
src/processor/simple_symbol_supplier.cc \
src/processor/simple_symbol_supplier.h \
src/processor/source_line_resolver.cc \
src/processor/source_line_resolver.h \
src/processor/stack_frame_info.h \
@ -96,6 +100,7 @@ check_PROGRAMS = \
src/processor/address_map_unittest \
src/processor/contained_range_map_unittest \
src/processor/minidump_processor_unittest \
src/processor/pathname_stripper_unittest \
src/processor/postfix_evaluator_unittest \
src/processor/range_map_unittest \
src/processor/source_line_resolver_unittest
@ -130,6 +135,11 @@ src_processor_minidump_processor_unittest_LDADD = \
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
src_processor_pathname_stripper_unittest_SOURCES = \
src/processor/pathname_stripper_unittest.cc
src_processor_pathname_stripper_unittest_LDADD = \
src/processor/pathname_stripper.lo
src_processor_postfix_evaluator_unittest_SOURCES = \
src/processor/postfix_evaluator_unittest.cc
@ -165,6 +175,10 @@ src_processor_minidump_stackwalk_SOURCES = \
src_processor_minidump_stackwalk_LDADD = \
src/processor/call_stack.lo \
src/processor/minidump.lo \
src/processor/minidump_processor.lo \
src/processor/pathname_stripper.lo \
src/processor/process_state.lo \
src/processor/simple_symbol_supplier.lo \
src/processor/stackwalker.lo \
src/processor/stackwalker_ppc.lo \
src/processor/stackwalker_x86.lo \

View File

@ -73,6 +73,7 @@ bin_PROGRAMS = src/processor/minidump_dump$(EXEEXT) \
check_PROGRAMS = src/processor/address_map_unittest$(EXEEXT) \
src/processor/contained_range_map_unittest$(EXEEXT) \
src/processor/minidump_processor_unittest$(EXEEXT) \
src/processor/pathname_stripper_unittest$(EXEEXT) \
src/processor/postfix_evaluator_unittest$(EXEEXT) \
src/processor/range_map_unittest$(EXEEXT) \
src/processor/source_line_resolver_unittest$(EXEEXT) \
@ -111,7 +112,9 @@ src_libairbag_la_LIBADD =
am__dirstamp = $(am__leading_dot)dirstamp
am_src_libairbag_la_OBJECTS = src/processor/call_stack.lo \
src/processor/minidump.lo src/processor/minidump_processor.lo \
src/processor/pathname_stripper.lo \
src/processor/process_state.lo \
src/processor/simple_symbol_supplier.lo \
src/processor/source_line_resolver.lo \
src/processor/stackwalker.lo src/processor/stackwalker_ppc.lo \
src/processor/stackwalker_x86.lo
@ -152,9 +155,19 @@ src_processor_minidump_stackwalk_OBJECTS = \
$(am_src_processor_minidump_stackwalk_OBJECTS)
src_processor_minidump_stackwalk_DEPENDENCIES = \
src/processor/call_stack.lo src/processor/minidump.lo \
src/processor/minidump_processor.lo \
src/processor/pathname_stripper.lo \
src/processor/process_state.lo \
src/processor/simple_symbol_supplier.lo \
src/processor/stackwalker.lo src/processor/stackwalker_ppc.lo \
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
am_src_processor_pathname_stripper_unittest_OBJECTS = \
src/processor/pathname_stripper_unittest.$(OBJEXT)
src_processor_pathname_stripper_unittest_OBJECTS = \
$(am_src_processor_pathname_stripper_unittest_OBJECTS)
src_processor_pathname_stripper_unittest_DEPENDENCIES = \
src/processor/pathname_stripper.lo
am_src_processor_postfix_evaluator_unittest_OBJECTS = \
src/processor/postfix_evaluator_unittest.$(OBJEXT)
src_processor_postfix_evaluator_unittest_OBJECTS = \
@ -206,6 +219,7 @@ SOURCES = $(src_libairbag_la_SOURCES) \
$(src_processor_minidump_dump_SOURCES) \
$(src_processor_minidump_processor_unittest_SOURCES) \
$(src_processor_minidump_stackwalk_SOURCES) \
$(src_processor_pathname_stripper_unittest_SOURCES) \
$(src_processor_postfix_evaluator_unittest_SOURCES) \
$(src_processor_range_map_unittest_SOURCES) \
$(src_processor_source_line_resolver_unittest_SOURCES) \
@ -216,6 +230,7 @@ DIST_SOURCES = $(src_libairbag_la_SOURCES) \
$(src_processor_minidump_dump_SOURCES) \
$(src_processor_minidump_processor_unittest_SOURCES) \
$(src_processor_minidump_stackwalk_SOURCES) \
$(src_processor_pathname_stripper_unittest_SOURCES) \
$(src_processor_postfix_evaluator_unittest_SOURCES) \
$(src_processor_range_map_unittest_SOURCES) \
$(src_processor_source_line_resolver_unittest_SOURCES) \
@ -370,12 +385,16 @@ src_libairbag_la_SOURCES = \
src/processor/minidump.h \
src/processor/minidump_format.h \
src/processor/minidump_processor.cc \
src/processor/pathname_stripper.cc \
src/processor/pathname_stripper.h \
src/processor/postfix_evaluator.h \
src/processor/postfix_evaluator-inl.h \
src/processor/process_state.cc \
src/processor/range_map.h \
src/processor/range_map-inl.h \
src/processor/scoped_ptr.h \
src/processor/simple_symbol_supplier.cc \
src/processor/simple_symbol_supplier.h \
src/processor/source_line_resolver.cc \
src/processor/source_line_resolver.h \
src/processor/stack_frame_info.h \
@ -411,6 +430,12 @@ src_processor_minidump_processor_unittest_LDADD = \
src/processor/stackwalker_x86.lo \
src/processor/source_line_resolver.lo
src_processor_pathname_stripper_unittest_SOURCES = \
src/processor/pathname_stripper_unittest.cc
src_processor_pathname_stripper_unittest_LDADD = \
src/processor/pathname_stripper.lo
src_processor_postfix_evaluator_unittest_SOURCES = \
src/processor/postfix_evaluator_unittest.cc
@ -447,6 +472,10 @@ src_processor_minidump_stackwalk_SOURCES = \
src_processor_minidump_stackwalk_LDADD = \
src/processor/call_stack.lo \
src/processor/minidump.lo \
src/processor/minidump_processor.lo \
src/processor/pathname_stripper.lo \
src/processor/process_state.lo \
src/processor/simple_symbol_supplier.lo \
src/processor/stackwalker.lo \
src/processor/stackwalker_ppc.lo \
src/processor/stackwalker_x86.lo \
@ -556,8 +585,13 @@ src/processor/minidump.lo: src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/minidump_processor.lo: src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/pathname_stripper.lo: src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/process_state.lo: src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/simple_symbol_supplier.lo: \
src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/source_line_resolver.lo: src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/stackwalker.lo: src/processor/$(am__dirstamp) \
@ -642,6 +676,12 @@ src/processor/minidump_stackwalk.$(OBJEXT): \
src/processor/minidump_stackwalk$(EXEEXT): $(src_processor_minidump_stackwalk_OBJECTS) $(src_processor_minidump_stackwalk_DEPENDENCIES) src/processor/$(am__dirstamp)
@rm -f src/processor/minidump_stackwalk$(EXEEXT)
$(CXXLINK) $(src_processor_minidump_stackwalk_LDFLAGS) $(src_processor_minidump_stackwalk_OBJECTS) $(src_processor_minidump_stackwalk_LDADD) $(LIBS)
src/processor/pathname_stripper_unittest.$(OBJEXT): \
src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
src/processor/pathname_stripper_unittest$(EXEEXT): $(src_processor_pathname_stripper_unittest_OBJECTS) $(src_processor_pathname_stripper_unittest_DEPENDENCIES) src/processor/$(am__dirstamp)
@rm -f src/processor/pathname_stripper_unittest$(EXEEXT)
$(CXXLINK) $(src_processor_pathname_stripper_unittest_LDFLAGS) $(src_processor_pathname_stripper_unittest_OBJECTS) $(src_processor_pathname_stripper_unittest_LDADD) $(LIBS)
src/processor/postfix_evaluator_unittest.$(OBJEXT): \
src/processor/$(am__dirstamp) \
src/processor/$(DEPDIR)/$(am__dirstamp)
@ -680,10 +720,15 @@ mostlyclean-compile:
-rm -f src/processor/minidump_processor.lo
-rm -f src/processor/minidump_processor_unittest.$(OBJEXT)
-rm -f src/processor/minidump_stackwalk.$(OBJEXT)
-rm -f src/processor/pathname_stripper.$(OBJEXT)
-rm -f src/processor/pathname_stripper.lo
-rm -f src/processor/pathname_stripper_unittest.$(OBJEXT)
-rm -f src/processor/postfix_evaluator_unittest.$(OBJEXT)
-rm -f src/processor/process_state.$(OBJEXT)
-rm -f src/processor/process_state.lo
-rm -f src/processor/range_map_unittest.$(OBJEXT)
-rm -f src/processor/simple_symbol_supplier.$(OBJEXT)
-rm -f src/processor/simple_symbol_supplier.lo
-rm -f src/processor/source_line_resolver.$(OBJEXT)
-rm -f src/processor/source_line_resolver.lo
-rm -f src/processor/source_line_resolver_unittest.$(OBJEXT)
@ -706,9 +751,12 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/minidump_processor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/minidump_processor_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/minidump_stackwalk.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/pathname_stripper.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/pathname_stripper_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/postfix_evaluator_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/process_state.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/range_map_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/simple_symbol_supplier.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/source_line_resolver.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/source_line_resolver_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/processor/$(DEPDIR)/stackwalker.Plo@am__quote@

View File

@ -62,8 +62,11 @@ class TestSymbolSupplier : public SymbolSupplier {
string TestSymbolSupplier::GetSymbolFile(MinidumpModule *module) {
if (*(module->GetName()) == "c:\\test_app.exe") {
// The funny-looking pathname is so that the symbol file can also be
// reached by a SimpleSymbolSupplier.
return string(getenv("srcdir") ? getenv("srcdir") : ".") +
"/src/processor/testdata/minidump2.sym";
"/src/processor/testdata/symbols/"
"test_app.pdb/63FE4780728D49379B9D7BB6460CB42A1/test_app.sym";
}
return "";

View File

@ -27,104 +27,206 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// minidump_stackwalk.cc: Print the stack of the exception thread from a
// minidump.
// minidump_stackwalk.cc: Process a minidump with MinidumpProcessor, printing
// the results, including stack traces.
//
// Author: Mark Mentovai
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <string>
#include "google/call_stack.h"
#include "google/stack_frame.h"
#include "google/minidump_processor.h"
#include "google/process_state.h"
#include "google/stack_frame_cpu.h"
#include "processor/minidump.h"
#include "processor/pathname_stripper.h"
#include "processor/scoped_ptr.h"
#include "processor/stackwalker_x86.h"
#include "processor/simple_symbol_supplier.h"
using std::string;
using google_airbag::CallStack;
using google_airbag::MemoryRegion;
using google_airbag::Minidump;
using google_airbag::MinidumpContext;
using google_airbag::MinidumpException;
using google_airbag::MinidumpModuleList;
using google_airbag::MinidumpThread;
using google_airbag::MinidumpThreadList;
using google_airbag::MinidumpModule;
using google_airbag::MinidumpProcessor;
using google_airbag::PathnameStripper;
using google_airbag::ProcessState;
using google_airbag::scoped_ptr;
using google_airbag::SimpleSymbolSupplier;
using google_airbag::StackFrame;
using google_airbag::Stackwalker;
using google_airbag::StackFramePPC;
using google_airbag::StackFrameX86;
// PrintRegister prints a register's name and value to stdout. It will
// print four registers on a line. For the first register in a set,
// pass 0 for |sequence|. For registers in a set, pass the most recent
// return value of PrintRegister. Note that PrintRegister will print a
// newline before the first register (with |sequence| set to 0) is printed.
// The caller is responsible for printing the final newline after a set
// of registers is completely printed, regardless of the number of calls
// to PrintRegister.
static int PrintRegister(const char *name, u_int32_t value, int sequence) {
if (sequence % 4 == 0) {
printf("\n ");
}
printf(" %5s = 0x%08x", name, value);
return ++sequence;
}
// PrintStack prints the call stack in |stack| to stdout, in a reasonably
// useful form. Module, function, and source file names are displayed if
// they are available. The code offset to the base code address of the
// source line, function, or module is printed, preferring them in that
// order. If no source line, function, or module information is available,
// an absolute code offset is printed.
//
// If |cpu| is a recognized CPU name, relevant register state for each stack
// frame printed is also output, if available.
static void PrintStack(const CallStack *stack, const string &cpu) {
int frame_count = stack->frames()->size();
for (int frame_index = 0; frame_index < frame_count; ++frame_index) {
const StackFrame *frame = stack->frames()->at(frame_index);
printf("%2d ", frame_index);
if (!frame->module_name.empty()) {
printf("%s", PathnameStripper::File(frame->module_name).c_str());
if (!frame->function_name.empty()) {
printf("!%s", frame->function_name.c_str());
if (!frame->source_file_name.empty()) {
string source_file = PathnameStripper::File(frame->source_file_name);
printf(" [%s : %d + 0x%llx]", source_file.c_str(),
frame->source_line,
frame->instruction -
frame->source_line_base);
} else {
printf(" + 0x%llx", frame->instruction - frame->function_base);
}
} else {
printf(" + 0x%llx", frame->instruction - frame->module_base);
}
} else {
printf("0x%llx", frame->instruction);
}
int sequence = 0;
if (cpu == "x86") {
const StackFrameX86 *frame_x86 =
reinterpret_cast<const StackFrameX86*>(frame);
if (frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_EIP)
sequence = PrintRegister("eip", frame_x86->context.eip, sequence);
if (frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_ESP)
sequence = PrintRegister("esp", frame_x86->context.esp, sequence);
if (frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_EBP)
sequence = PrintRegister("ebp", frame_x86->context.ebp, sequence);
if (frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_EBX)
sequence = PrintRegister("ebx", frame_x86->context.ebx, sequence);
if (frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_ESI)
sequence = PrintRegister("esi", frame_x86->context.esi, sequence);
if (frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_EDI)
sequence = PrintRegister("edi", frame_x86->context.edi, sequence);
if (frame_x86->context_validity == StackFrameX86::CONTEXT_VALID_ALL) {
sequence = PrintRegister("eax", frame_x86->context.eax, sequence);
sequence = PrintRegister("ecx", frame_x86->context.ecx, sequence);
sequence = PrintRegister("edx", frame_x86->context.edx, sequence);
sequence = PrintRegister("efl", frame_x86->context.eflags, sequence);
}
} else if (cpu == "ppc") {
const StackFramePPC *frame_ppc =
reinterpret_cast<const StackFramePPC*>(frame);
if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_SRR0)
sequence = PrintRegister("srr0", frame_ppc->context.srr0, sequence);
if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_GPR1)
sequence = PrintRegister("r1", frame_ppc->context.gpr[1], sequence);
}
printf("\n");
}
}
// Processes |minidump_file| using MinidumpProcessor. |symbol_path|, if
// non-empty, is the base directory of a symbol storage area, laid out in
// the format required by SimpleSymbolSupplier. If such a storage area
// is specified, it is made available for use by the MinidumpProcessor.
//
// Returns the value of MinidumpProcessor::Process. If processing succeeds,
// prints identifying OS and CPU information from the minidump, crash
// information if the minidump was produced as a result of a crash, and
// call stacks for each thread contained in the minidump. All information
// is printed to stdout.
static bool PrintMinidumpProcess(const string &minidump_file,
const string &symbol_path) {
scoped_ptr<SimpleSymbolSupplier> symbol_supplier;
if (!symbol_path.empty()) {
// TODO(mmentovai): check existence of symbol_path if specified?
symbol_supplier.reset(new SimpleSymbolSupplier(symbol_path));
}
MinidumpProcessor minidump_processor(symbol_supplier.get());
// Process the minidump.
scoped_ptr<ProcessState> process_state(
minidump_processor.Process(minidump_file));
if (!process_state.get()) {
fprintf(stderr, "MinidumpProcessor::Process failed\n");
return false;
}
// Print OS and CPU information.
string cpu = process_state->cpu();
string cpu_info = process_state->cpu_info();
printf("Operating system: %s\n", process_state->os().c_str());
printf(" %s\n", process_state->os_version().c_str());
printf("CPU: %s\n", cpu.c_str());
if (!cpu_info.empty()) {
// This field is optional.
printf(" %s\n", cpu_info.c_str());
}
printf("\n");
// Print crash information.
if (process_state->crashed()) {
printf("Crash reason: %s\n", process_state->crash_reason().c_str());
printf("Crash address: 0x%llx\n", process_state->crash_address());
} else {
printf("No crash\n");
}
// If there's a crash thread, print it first.
int crash_thread = -1;
if (process_state->crashed()) {
crash_thread = process_state->crash_thread();
printf("\n");
printf("Thread %d (crashed)\n", crash_thread);
PrintStack(process_state->threads()->at(crash_thread), cpu);
}
// Print all of the threads in the dump.
int thread_count = process_state->threads()->size();
for (int thread_index = 0; thread_index < thread_count; ++thread_index) {
if (thread_index != crash_thread) {
// Don't print the crash thread again, it was already printed.
printf("\n");
printf("Thread %d\n", thread_index);
PrintStack(process_state->threads()->at(thread_index), cpu);
}
}
return true;
}
int main(int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "usage: %s <file>\n", argv[0]);
exit(1);
if (argc < 2 || argc > 3) {
fprintf(stderr, "usage: %s <minidump-file> [symbol-path]\n", argv[0]);
return 1;
}
Minidump minidump(argv[1]);
if (!minidump.Read()) {
fprintf(stderr, "minidump.Read() failed\n");
exit(1);
const char *minidump_file = argv[1];
const char *symbol_path = "";
if (argc == 3) {
symbol_path = argv[2];
}
MinidumpException *exception = minidump.GetException();
if (!exception) {
fprintf(stderr, "minidump.GetException() failed\n");
exit(1);
}
MinidumpThreadList *thread_list = minidump.GetThreadList();
if (!thread_list) {
fprintf(stderr, "minidump.GetThreadList() failed\n");
exit(1);
}
MinidumpThread *exception_thread =
thread_list->GetThreadByID(exception->GetThreadID());
if (!exception_thread) {
fprintf(stderr, "thread_list->GetThreadByID() failed\n");
exit(1);
}
MemoryRegion *stack_memory = exception_thread->GetMemory();
if (!stack_memory) {
fprintf(stderr, "exception_thread->GetStackMemory() failed\n");
exit(1);
}
MinidumpContext *context = exception->GetContext();
if (!context) {
fprintf(stderr, "exception->GetContext() failed\n");
exit(1);
}
MinidumpModuleList *modules = minidump.GetModuleList();
if (!modules) {
fprintf(stderr, "minidump.GetModuleList() failed\n");
exit(1);
}
scoped_ptr<Stackwalker> stackwalker(
Stackwalker::StackwalkerForCPU(context, stack_memory, modules, NULL));
if (!stackwalker.get()) {
fprintf(stderr, "Stackwalker::StackwalkerForCPU failed\n");
exit(1);
}
scoped_ptr<CallStack> stack(stackwalker->Walk());
unsigned int index;
for (index = 0; index < stack->frames()->size(); ++index) {
StackFrame *frame = stack->frames()->at(index);
printf("[%2d] instruction = 0x%08llx \"%s\" + 0x%08llx\n",
index,
frame->instruction,
frame->module_base ? frame->module_name.c_str() : "0x0",
frame->instruction - frame->module_base);
}
return 0;
return PrintMinidumpProcess(minidump_file, symbol_path) ? 0 : 1;
}

View File

@ -30,7 +30,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
testdata_dir=$srcdir/src/processor/testdata
./src/processor/minidump_stackwalk $testdata_dir/minidump1.dmp | \
tr -s '\015' '\012' | \
diff -u $testdata_dir/minidump1.stack.out -
./src/processor/minidump_stackwalk $testdata_dir/minidump2.dmp \
$testdata_dir/symbols | \
tr -d '\015' | \
diff -u $testdata_dir/minidump2.stackwalk.out -
exit $?

View File

@ -0,0 +1,56 @@
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// pathname_stripper.cc: Manipulates pathnames into their component parts.
//
// See pathname_stripper.h for documentation.
//
// Author: Mark Mentovai
#include "processor/pathname_stripper.h"
namespace google_airbag {
// static
string PathnameStripper::File(const string &path) {
string::size_type slash = path.rfind('/');
string::size_type backslash = path.rfind('\\');
string::size_type file_start = 0;
if (slash != string::npos &&
(backslash == string::npos || slash > backslash)) {
file_start = slash + 1;
} else if (backslash != string::npos) {
file_start = backslash + 1;
}
return path.substr(file_start);
}
} // namespace google_airbag

View File

@ -0,0 +1,53 @@
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// pathname_stripper.h: Manipulates pathnames into their component parts.
//
// Author: Mark Mentovai
#ifndef PROCESSOR_PATHNAME_STRIPPER_H__
#define PROCESSOR_PATHNAME_STRIPPER_H__
#include <string>
namespace google_airbag {
using std::string;
class PathnameStripper {
public:
// Given path, a pathname with components separated by slashes (/) or
// backslashes (\), returns the trailing component, without any separator.
// If path ends in a separator character, returns an empty string.
static string File(const string &path);
};
} // namespace google_airbag
#endif // PROCESSOR_PATHNAME_STRIPPER_H__

View File

@ -0,0 +1,78 @@
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "processor/pathname_stripper.h"
#define ASSERT_TRUE(condition) \
if (!(condition)) { \
fprintf(stderr, "FAIL: %s @ %s:%d\n", #condition, __FILE__, __LINE__); \
return false; \
}
#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
using google_airbag::PathnameStripper;
static bool RunTests() {
ASSERT_EQ(PathnameStripper::File("/dir/file"), "file");
ASSERT_EQ(PathnameStripper::File("\\dir\\file"), "file");
ASSERT_EQ(PathnameStripper::File("/dir\\file"), "file");
ASSERT_EQ(PathnameStripper::File("\\dir/file"), "file");
ASSERT_EQ(PathnameStripper::File("dir/file"), "file");
ASSERT_EQ(PathnameStripper::File("dir\\file"), "file");
ASSERT_EQ(PathnameStripper::File("dir/\\file"), "file");
ASSERT_EQ(PathnameStripper::File("dir\\/file"), "file");
ASSERT_EQ(PathnameStripper::File("file"), "file");
ASSERT_EQ(PathnameStripper::File("dir/"), "");
ASSERT_EQ(PathnameStripper::File("dir\\"), "");
ASSERT_EQ(PathnameStripper::File("dir/dir/"), "");
ASSERT_EQ(PathnameStripper::File("dir\\dir\\"), "");
ASSERT_EQ(PathnameStripper::File("dir1/dir2/file"), "file");
ASSERT_EQ(PathnameStripper::File("dir1\\dir2\\file"), "file");
ASSERT_EQ(PathnameStripper::File("dir1/dir2\\file"), "file");
ASSERT_EQ(PathnameStripper::File("dir1\\dir2/file"), "file");
ASSERT_EQ(PathnameStripper::File(""), "");
ASSERT_EQ(PathnameStripper::File("1"), "1");
ASSERT_EQ(PathnameStripper::File("1/2"), "2");
ASSERT_EQ(PathnameStripper::File("1\\2"), "2");
ASSERT_EQ(PathnameStripper::File("/1/2"), "2");
ASSERT_EQ(PathnameStripper::File("\\1\\2"), "2");
ASSERT_EQ(PathnameStripper::File("dir//file"), "file");
ASSERT_EQ(PathnameStripper::File("dir\\\\file"), "file");
ASSERT_EQ(PathnameStripper::File("/dir//file"), "file");
ASSERT_EQ(PathnameStripper::File("\\dir\\\\file"), "file");
ASSERT_EQ(PathnameStripper::File("c:\\dir\\file"), "file");
ASSERT_EQ(PathnameStripper::File("c:\\dir\\file.ext"), "file.ext");
return true;
}
int main(int argc, char **argv) {
return RunTests() ? 0 : 1;
}

View File

@ -0,0 +1,97 @@
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// simple_symbol_supplier.cc: A simple SymbolSupplier implementation
//
// See simple_symbol_supplier.h for documentation.
//
// Author: Mark Mentovai
#include "processor/simple_symbol_supplier.h"
#include "processor/minidump.h"
#include "processor/pathname_stripper.h"
namespace google_airbag {
string SimpleSymbolSupplier::GetSymbolFile(MinidumpModule *module) {
// For now, only support modules that have GUIDs - which means
// MDCVInfoPDB70.
if (!module)
return "";
const MDCVInfoPDB70 *cv_record =
reinterpret_cast<const MDCVInfoPDB70*>(module->GetCVRecord());
if (!cv_record)
return "";
if (cv_record->cv_signature != MD_CVINFOPDB70_SIGNATURE)
return "";
// Start with the base path.
string path = path_;
// Append the pdb file name as a directory name.
path.append("/");
string pdb_file_name = PathnameStripper::File(
reinterpret_cast<const char *>(cv_record->pdb_file_name));
path.append(pdb_file_name);
// Append the uuid and age as a directory name.
path.append("/");
char uuid_age_string[43];
snprintf(uuid_age_string, sizeof(uuid_age_string),
"%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%d",
cv_record->signature.data1, cv_record->signature.data2,
cv_record->signature.data3,
cv_record->signature.data4[0], cv_record->signature.data4[1],
cv_record->signature.data4[2], cv_record->signature.data4[3],
cv_record->signature.data4[4], cv_record->signature.data4[5],
cv_record->signature.data4[6], cv_record->signature.data4[7],
cv_record->age);
path.append(uuid_age_string);
// Transform the pdb file name into one ending in .sym. If the existing
// name ends in .pdb, strip the .pdb. Otherwise, add .sym to the non-.pdb
// name.
path.append("/");
string pdb_file_extension = pdb_file_name.substr(pdb_file_name.size() - 4);
transform(pdb_file_extension.begin(), pdb_file_extension.end(),
pdb_file_extension.begin(), tolower);
if (pdb_file_extension == ".pdb") {
path.append(pdb_file_name.substr(0, pdb_file_name.size() - 4));
} else {
path.append(pdb_file_name);
}
path.append(".sym");
return path;
}
} // namespace google_airbag

View File

@ -0,0 +1,102 @@
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// simple_symbol_supplier.h: A simple SymbolSupplier implementation
//
// SimpleSymbolSupplier is a straightforward implementation of SymbolSupplier
// that stores symbol files in a filesystem tree. A SimpleSymbolSupplier is
// created with a base directory, which is the root for all symbol files.
// Each symbol file contained therien has a directory entry in the base
// directory with a name identical to the corresponding pdb file. Within
// each of these directories, there are subdirectories named for the uuid and
// age of each pdb file. The uuid is presented in hexadecimal form, with
// uppercase characters and no dashes. The age is appended to it in decimal
// form, without any separators. Within that subdirectory,
// SimpleSymbolSupplier expects to find the symbol file, which is named
// identically to the pdb file, but with a .sym extension. This sample
// hierarchy is rooted at the "symbols" base directory:
//
// symbols
// symbols/test_app.pdb
// symbols/test_app.pdb/63FE4780728D49379B9D7BB6460CB42A1
// symbols/test_app.pdb/63FE4780728D49379B9D7BB6460CB42A1/test_app.sym
// symbols/kernel32.pdb
// symbols/kernel32.pdb/BCE8785C57B44245A669896B6A19B9542
// symbols/kernel32.pdb/BCE8785C57B44245A669896B6A19B9542/kernel32.sym
//
// In this case, the uuid of test_app.pdb is
// 63fe4780-728d-4937-9b9d-7bb6460cb42a and its age is 1.
//
// This scheme was chosen to be roughly analogous to the way that
// symbol files may be accessed from Microsoft Symbol Server. A hierarchy
// used for Microsoft Symbol Server storage is usable as a hierarchy for
// SimpleSymbolServer, provided that the pdb files are transformed to dumped
// format using a tool such as dump_syms, and given a .sym extension.
//
// TODO(mmentovai): verify that MSSS stores the age as presented as decimal
// and not hexadecimal or something else. Adjust here to match if necessary.
//
// SimpleSymbolSupplier presently only supports symbol files that have
// the MSVC 7.0 CodeView record format. See MDCVInfoPDB70 in
// minidump_format.h.
//
// Author: Mark Mentovai
#ifndef PROCESSOR_SIMPLE_SYMBOL_SUPPLIER_H__
#define PROCESSOR_SIMPLE_SYMBOL_SUPPLIER_H__
#include <string>
#include "google/symbol_supplier.h"
namespace google_airbag {
using std::string;
class MinidumpModule;
class SimpleSymbolSupplier : public SymbolSupplier {
public:
// Creates a new SimpleSymbolSupplier, using path as the root path where
// symbols are stored.
explicit SimpleSymbolSupplier(const string &path) : path_(path) {}
virtual ~SimpleSymbolSupplier() {}
// Returns the path to the symbol file for the given module. See the
// description above.
virtual string GetSymbolFile(MinidumpModule *module);
private:
string path_;
};
} // namespace google_airbag
#endif // PROCESSOR_SIMPLE_SYMBOL_SUPPLIER_H__

View File

@ -283,15 +283,15 @@ StackFrame* StackwalkerX86::GetCallerFrame(
// These are nonvolatile (callee-save) registers, and the program string
// may have filled them in.
if (dictionary_validity.find("$ebx") == dictionary_validity.end()) {
if (dictionary_validity.find("$ebx") != dictionary_validity.end()) {
frame->context.ebx = dictionary["$ebx"];
frame->context_validity |= StackFrameX86::CONTEXT_VALID_EBX;
}
if (dictionary_validity.find("$esi") == dictionary_validity.end()) {
if (dictionary_validity.find("$esi") != dictionary_validity.end()) {
frame->context.esi = dictionary["$esi"];
frame->context_validity |= StackFrameX86::CONTEXT_VALID_ESI;
}
if (dictionary_validity.find("$edi") == dictionary_validity.end()) {
if (dictionary_validity.find("$edi") != dictionary_validity.end()) {
frame->context.edi = dictionary["$edi"];
frame->context_validity |= StackFrameX86::CONTEXT_VALID_EDI;
}

View File

@ -1,23 +0,0 @@
[ 0] instruction = 0x020a1515 "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x00221515
[ 1] instruction = 0x020a03e2 "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x002203e2
[ 2] instruction = 0x023c8a27 "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x00548a27
[ 3] instruction = 0x023ccfd8 "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x0054cfd8
[ 4] instruction = 0x0222fd11 "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x003afd11
[ 5] instruction = 0x022311dc "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x003b11dc
[ 6] instruction = 0x034eb0f0 "c:\lizard\trunk\mozilla\dist\bin\components\xpc3250.dll" + 0x0005b0f0
[ 7] instruction = 0x0049bda3 "c:\lizard\trunk\mozilla\dist\bin\js3250.dll" + 0x0007bda3
[ 8] instruction = 0x0047b92e "c:\lizard\trunk\mozilla\dist\bin\js3250.dll" + 0x0005b92e
[ 9] instruction = 0x0046c944 "c:\lizard\trunk\mozilla\dist\bin\js3250.dll" + 0x0004c944
[10] instruction = 0x0046d344 "c:\lizard\trunk\mozilla\dist\bin\js3250.dll" + 0x0004d344
[11] instruction = 0x00430ec2 "c:\lizard\trunk\mozilla\dist\bin\js3250.dll" + 0x00010ec2
[12] instruction = 0x02213b7e "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x00393b7e
[13] instruction = 0x02249cec "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x003c9cec
[14] instruction = 0x0224a80f "c:\lizard\trunk\mozilla\dist\bin\components\gklayout.dll" + 0x003ca80f
[15] instruction = 0x002ebff7 "c:\lizard\trunk\mozilla\dist\bin\xpcom_core.dll" + 0x0007bff7
[16] instruction = 0x002ec8eb "c:\lizard\trunk\mozilla\dist\bin\xpcom_core.dll" + 0x0007c8eb
[17] instruction = 0x029193b4 "c:\lizard\trunk\mozilla\dist\bin\components\gkwidget.dll" + 0x000293b4
[18] instruction = 0x03174b18 "c:\lizard\trunk\mozilla\dist\bin\components\tkitcmps.dll" + 0x00004b18
[19] instruction = 0x10008e5f "c:\lizard\trunk\mozilla\dist\bin\xul.dll" + 0x00008e5f
[20] instruction = 0x00401035 "c:\lizard\trunk\mozilla\dist\bin\firefox.exe" + 0x00001035
[21] instruction = 0x004011bb "c:\lizard\trunk\mozilla\dist\bin\firefox.exe" + 0x000011bb
[22] instruction = 0x7c816d4e "C:\WINDOWS\system32\kernel32.dll" + 0x00016d4e

File diff suppressed because it is too large Load Diff