Module API (#32). r=waylonis, bryner

- Introduces a standard API for dealing with modules.  MinidumpModule
   is now a concrete implementation of this API.  Code may interact with
   single modules using the CodeModule interface, and collections of
   modules using its container, the CodeModules interface.
 - CodeModule is used directly by SymbolSupplier implementations and
   SourceLineResolver.  Reliance on the specific implementation in
   MinidumpModule has been eliminated.
 - Module lists are now added to ProcessState objects.  Module references
   in each stack frame are now pointers to objects in these module lists.
 - The sample minidump_stackwalk tool prints the module list after printing
   all threads' stacks.

http://groups.google.com/group/airbag-dev/browse_frm/thread/a9c0550edde54cf8


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@74 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mmentovai 2006-12-05 22:52:28 +00:00
parent ed61ae0bbd
commit db3342a10e
36 changed files with 1515 additions and 351 deletions

View file

@ -37,6 +37,8 @@
#include <string>
#include "google_airbag/processor/call_stack.h"
#include "google_airbag/processor/code_module.h"
#include "google_airbag/processor/code_modules.h"
#include "google_airbag/processor/minidump.h"
#include "google_airbag/processor/minidump_processor.h"
#include "google_airbag/processor/process_state.h"
@ -49,6 +51,8 @@ namespace {
using std::string;
using google_airbag::CallStack;
using google_airbag::CodeModule;
using google_airbag::CodeModules;
using google_airbag::MinidumpModule;
using google_airbag::MinidumpProcessor;
using google_airbag::PathnameStripper;
@ -90,8 +94,8 @@ static void PrintStack(const CallStack *stack, const string &cpu) {
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->module) {
printf("%s", PathnameStripper::File(frame->module->code_file()).c_str());
if (!frame->function_name.empty()) {
printf("!%s", frame->function_name.c_str());
if (!frame->source_file_name.empty()) {
@ -104,7 +108,7 @@ static void PrintStack(const CallStack *stack, const string &cpu) {
printf(" + 0x%llx", frame->instruction - frame->function_base);
}
} else {
printf(" + 0x%llx", frame->instruction - frame->module_base);
printf(" + 0x%llx", frame->instruction - frame->module->base_address());
}
} else {
printf("0x%llx", frame->instruction);
@ -147,6 +151,29 @@ static void PrintStack(const CallStack *stack, const string &cpu) {
}
}
static void PrintModules(const CodeModules *modules) {
if (!modules)
return;
printf("\n");
printf("Loaded modules:\n");
u_int64_t main_address = modules->GetMainModule()->base_address();
unsigned int module_count = modules->module_count();
for (unsigned int module_sequence = 0;
module_sequence < module_count;
++module_sequence) {
const CodeModule *module = modules->GetModuleAtSequence(module_sequence);
u_int64_t base_address = module->base_address();
printf("0x%08llx - 0x%08llx %s %s%s\n",
base_address, base_address + module->size() - 1,
PathnameStripper::File(module->code_file()).c_str(),
module->version().empty() ? "???" : module->version().c_str(),
module->base_address() == main_address ? " (main)" : "");
}
}
// 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
@ -217,6 +244,8 @@ static bool PrintMinidumpProcess(const string &minidump_file,
}
}
PrintModules(process_state->modules());
return true;
}