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

@ -39,6 +39,7 @@
#include "processor/range_map-inl.h"
#include "processor/source_line_resolver.h"
#include "google_airbag/processor/code_module.h"
#include "google_airbag/processor/stack_frame.h"
#include "processor/linked_ptr.h"
#include "processor/scoped_ptr.h"
@ -111,7 +112,7 @@ class SourceLineResolver::Module {
// returned. If no additional information is available, returns NULL.
// A NULL return value is not an error. The caller takes ownership of
// any returned StackFrameInfo object.
StackFrameInfo* LookupAddress(MemAddr address, StackFrame *frame) const;
StackFrameInfo* LookupAddress(StackFrame *frame) const;
private:
friend class SourceLineResolver;
@ -206,10 +207,11 @@ bool SourceLineResolver::HasModule(const string &module_name) const {
StackFrameInfo* SourceLineResolver::FillSourceLineInfo(
StackFrame *frame) const {
ModuleMap::const_iterator it = modules_->find(frame->module_name);
if (it != modules_->end()) {
return it->second->LookupAddress(frame->instruction - frame->module_base,
frame);
if (frame->module) {
ModuleMap::const_iterator it = modules_->find(frame->module->code_file());
if (it != modules_->end()) {
return it->second->LookupAddress(frame);
}
}
return NULL;
}
@ -273,8 +275,10 @@ bool SourceLineResolver::Module::LoadMap(const string &map_file) {
return true;
}
StackFrameInfo* SourceLineResolver::Module::LookupAddress(
MemAddr address, StackFrame *frame) const {
StackFrameInfo* SourceLineResolver::Module::LookupAddress(StackFrame *frame)
const {
MemAddr address = frame->instruction - frame->module->base_address();
linked_ptr<StackFrameInfo> retrieved_info;
// Check for debugging info first, before any possible early returns.
//
@ -318,7 +322,7 @@ StackFrameInfo* SourceLineResolver::Module::LookupAddress(
parameter_size = func->parameter_size;
frame->function_name = func->name;
frame->function_base = frame->module_base + function_base;
frame->function_base = frame->module->base_address() + function_base;
linked_ptr<Line> line;
MemAddr line_base;
@ -328,7 +332,7 @@ StackFrameInfo* SourceLineResolver::Module::LookupAddress(
frame->source_file_name = files_.find(line->source_file_id)->second;
}
frame->source_line = line->line;
frame->source_line_base = frame->module_base + line_base;
frame->source_line_base = frame->module->base_address() + line_base;
}
} else if (public_symbols_.Retrieve(address,
&public_symbol, &public_address) &&
@ -336,7 +340,7 @@ StackFrameInfo* SourceLineResolver::Module::LookupAddress(
parameter_size = public_symbol->parameter_size;
frame->function_name = public_symbol->name;
frame->function_base = frame->module_base + public_address;
frame->function_base = frame->module->base_address() + public_address;
} else {
// No FUNC or PUBLIC data available.
return frame_info.release();