Make SourceLineResolver fill a StackFrame rather than using its own struct (#16), r=mmentovai.

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@17 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
bryner 2006-09-07 17:26:17 +00:00
parent 53d0f69d35
commit 39716226cf
4 changed files with 57 additions and 66 deletions

View file

@ -18,6 +18,7 @@
#include <vector>
#include <utility>
#include "processor/source_line_resolver.h"
#include "google/stack_frame.h"
using std::map;
using std::vector;
@ -26,12 +27,6 @@ using __gnu_cxx::hash;
namespace google_airbag {
void SourceLineResolver::SourceLineInfo::Reset() {
function_name.clear();
source_file.clear();
source_line = 0;
}
// MemAddrMap is a map subclass which has the following properties:
// - stores pointers to an "entry" type, which are deleted on destruction
// - suitable for address lookup via FindContainingEntry
@ -97,9 +92,9 @@ class SourceLineResolver::Module {
// Loads the given map file, returning true on success.
bool LoadMap(const string &map_file);
// Looks up the given relative address, and fills the SourceLineInfo struct
// Looks up the given relative address, and fills the StackFrame struct
// with the result.
void LookupAddress(MemAddr address, SourceLineInfo *info) const;
void LookupAddress(MemAddr address, StackFrame *frame) const;
private:
friend class SourceLineResolver;
@ -147,13 +142,10 @@ bool SourceLineResolver::LoadModule(const string &module_name,
return true;
}
void SourceLineResolver::LookupAddress(MemAddr address,
const string &module_name,
SourceLineInfo *info) const {
info->Reset();
ModuleMap::const_iterator it = modules_->find(module_name);
void SourceLineResolver::FillSourceLineInfo(StackFrame *frame) const {
ModuleMap::const_iterator it = modules_->find(frame->module_name);
if (it != modules_->end()) {
it->second->LookupAddress(address, info);
it->second->LookupAddress(frame->instruction, frame);
}
}
@ -192,13 +184,13 @@ bool SourceLineResolver::Module::LoadMap(const string &map_file) {
}
void SourceLineResolver::Module::LookupAddress(MemAddr address,
SourceLineInfo *info) const {
StackFrame *frame) const {
Function *func = functions_.FindContainingEntry(address);
if (!func) {
return;
}
info->function_name = func->name;
frame->function_name = func->name;
Line *line = func->lines.FindContainingEntry(address);
if (!line) {
return;
@ -206,9 +198,9 @@ void SourceLineResolver::Module::LookupAddress(MemAddr address,
FileMap::const_iterator it = files_.find(line->source_file_id);
if (it != files_.end()) {
info->source_file = files_.find(line->source_file_id)->second;
frame->source_file_name = files_.find(line->source_file_id)->second;
}
info->source_line = line->line;
frame->source_line = line->line;
}
void SourceLineResolver::Module::ParseFile(char *file_line) {