mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-26 17:25:04 +01:00
Add an abstract interface to SourceLineResolver, and allow any implementation
to be used with MinidumpProcessor. The basic SourceLineResolver is now a public interface (#89) git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@83 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
65dbfcc15f
commit
fd38d48e6d
18 changed files with 252 additions and 157 deletions
|
|
@ -38,7 +38,7 @@
|
|||
#include "processor/contained_range_map-inl.h"
|
||||
#include "processor/range_map-inl.h"
|
||||
|
||||
#include "processor/source_line_resolver.h"
|
||||
#include "google_airbag/processor/basic_source_line_resolver.h"
|
||||
#include "google_airbag/processor/code_module.h"
|
||||
#include "google_airbag/processor/stack_frame.h"
|
||||
#include "processor/linked_ptr.h"
|
||||
|
|
@ -52,7 +52,7 @@ using __gnu_cxx::hash;
|
|||
|
||||
namespace google_airbag {
|
||||
|
||||
struct SourceLineResolver::Line {
|
||||
struct BasicSourceLineResolver::Line {
|
||||
Line(MemAddr addr, MemAddr code_size, int file_id, int source_line)
|
||||
: address(addr)
|
||||
, size(code_size)
|
||||
|
|
@ -65,7 +65,7 @@ struct SourceLineResolver::Line {
|
|||
int line;
|
||||
};
|
||||
|
||||
struct SourceLineResolver::Function {
|
||||
struct BasicSourceLineResolver::Function {
|
||||
Function(const string &function_name,
|
||||
MemAddr function_address,
|
||||
MemAddr code_size,
|
||||
|
|
@ -83,7 +83,7 @@ struct SourceLineResolver::Function {
|
|||
RangeMap< MemAddr, linked_ptr<Line> > lines;
|
||||
};
|
||||
|
||||
struct SourceLineResolver::PublicSymbol {
|
||||
struct BasicSourceLineResolver::PublicSymbol {
|
||||
PublicSymbol(const string& set_name,
|
||||
MemAddr set_address,
|
||||
int set_parameter_size)
|
||||
|
|
@ -100,7 +100,7 @@ struct SourceLineResolver::PublicSymbol {
|
|||
int parameter_size;
|
||||
};
|
||||
|
||||
class SourceLineResolver::Module {
|
||||
class BasicSourceLineResolver::Module {
|
||||
public:
|
||||
Module(const string &name) : name_(name) { }
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ class SourceLineResolver::Module {
|
|||
StackFrameInfo* LookupAddress(StackFrame *frame) const;
|
||||
|
||||
private:
|
||||
friend class SourceLineResolver;
|
||||
friend class BasicSourceLineResolver;
|
||||
typedef hash_map<int, string> FileMap;
|
||||
|
||||
// The types for stack_info_. This is equivalent to MS DIA's
|
||||
|
|
@ -173,10 +173,10 @@ class SourceLineResolver::Module {
|
|||
stack_info_[STACK_INFO_LAST];
|
||||
};
|
||||
|
||||
SourceLineResolver::SourceLineResolver() : modules_(new ModuleMap) {
|
||||
BasicSourceLineResolver::BasicSourceLineResolver() : modules_(new ModuleMap) {
|
||||
}
|
||||
|
||||
SourceLineResolver::~SourceLineResolver() {
|
||||
BasicSourceLineResolver::~BasicSourceLineResolver() {
|
||||
ModuleMap::iterator it;
|
||||
for (it = modules_->begin(); it != modules_->end(); ++it) {
|
||||
delete it->second;
|
||||
|
|
@ -184,8 +184,8 @@ SourceLineResolver::~SourceLineResolver() {
|
|||
delete modules_;
|
||||
}
|
||||
|
||||
bool SourceLineResolver::LoadModule(const string &module_name,
|
||||
const string &map_file) {
|
||||
bool BasicSourceLineResolver::LoadModule(const string &module_name,
|
||||
const string &map_file) {
|
||||
// Make sure we don't already have a module with the given name.
|
||||
if (modules_->find(module_name) != modules_->end()) {
|
||||
return false;
|
||||
|
|
@ -201,11 +201,11 @@ bool SourceLineResolver::LoadModule(const string &module_name,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SourceLineResolver::HasModule(const string &module_name) const {
|
||||
bool BasicSourceLineResolver::HasModule(const string &module_name) const {
|
||||
return modules_->find(module_name) != modules_->end();
|
||||
}
|
||||
|
||||
StackFrameInfo* SourceLineResolver::FillSourceLineInfo(
|
||||
StackFrameInfo* BasicSourceLineResolver::FillSourceLineInfo(
|
||||
StackFrame *frame) const {
|
||||
if (frame->module) {
|
||||
ModuleMap::const_iterator it = modules_->find(frame->module->code_file());
|
||||
|
|
@ -216,7 +216,7 @@ StackFrameInfo* SourceLineResolver::FillSourceLineInfo(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool SourceLineResolver::Module::LoadMap(const string &map_file) {
|
||||
bool BasicSourceLineResolver::Module::LoadMap(const string &map_file) {
|
||||
FILE *f = fopen(map_file.c_str(), "r");
|
||||
if (!f) {
|
||||
return false;
|
||||
|
|
@ -252,8 +252,8 @@ bool SourceLineResolver::Module::LoadMap(const string &map_file) {
|
|||
return false;
|
||||
}
|
||||
} else if (strncmp(buffer, "MODULE ", 7) == 0) {
|
||||
// Ignore these. They're not of any use to SourceLineResolver, which
|
||||
// is fed modules by a SymbolSupplier. These lines are present to
|
||||
// Ignore these. They're not of any use to BasicSourceLineResolver,
|
||||
// which is fed modules by a SymbolSupplier. These lines are present to
|
||||
// aid other tools in properly placing symbol files so that they can
|
||||
// be accessed by a SymbolSupplier.
|
||||
//
|
||||
|
|
@ -275,8 +275,8 @@ bool SourceLineResolver::Module::LoadMap(const string &map_file) {
|
|||
return true;
|
||||
}
|
||||
|
||||
StackFrameInfo* SourceLineResolver::Module::LookupAddress(StackFrame *frame)
|
||||
const {
|
||||
StackFrameInfo* BasicSourceLineResolver::Module::LookupAddress(
|
||||
StackFrame *frame) const {
|
||||
MemAddr address = frame->instruction - frame->module->base_address();
|
||||
|
||||
linked_ptr<StackFrameInfo> retrieved_info;
|
||||
|
|
@ -360,8 +360,8 @@ StackFrameInfo* SourceLineResolver::Module::LookupAddress(StackFrame *frame)
|
|||
}
|
||||
|
||||
// static
|
||||
bool SourceLineResolver::Module::Tokenize(char *line, int max_tokens,
|
||||
vector<char*> *tokens) {
|
||||
bool BasicSourceLineResolver::Module::Tokenize(char *line, int max_tokens,
|
||||
vector<char*> *tokens) {
|
||||
tokens->clear();
|
||||
tokens->reserve(max_tokens);
|
||||
|
||||
|
|
@ -387,7 +387,7 @@ bool SourceLineResolver::Module::Tokenize(char *line, int max_tokens,
|
|||
return tokens->size() == static_cast<unsigned int>(max_tokens);
|
||||
}
|
||||
|
||||
void SourceLineResolver::Module::ParseFile(char *file_line) {
|
||||
void BasicSourceLineResolver::Module::ParseFile(char *file_line) {
|
||||
// FILE <id> <filename>
|
||||
file_line += 5; // skip prefix
|
||||
|
||||
|
|
@ -407,8 +407,8 @@ void SourceLineResolver::Module::ParseFile(char *file_line) {
|
|||
}
|
||||
}
|
||||
|
||||
SourceLineResolver::Function* SourceLineResolver::Module::ParseFunction(
|
||||
char *function_line) {
|
||||
BasicSourceLineResolver::Function*
|
||||
BasicSourceLineResolver::Module::ParseFunction(char *function_line) {
|
||||
// FUNC <address> <size> <stack_param_size> <name>
|
||||
function_line += 5; // skip prefix
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ SourceLineResolver::Function* SourceLineResolver::Module::ParseFunction(
|
|||
return new Function(name, address, size, stack_param_size);
|
||||
}
|
||||
|
||||
SourceLineResolver::Line* SourceLineResolver::Module::ParseLine(
|
||||
BasicSourceLineResolver::Line* BasicSourceLineResolver::Module::ParseLine(
|
||||
char *line_line) {
|
||||
// <address> <line number> <source file id>
|
||||
vector<char*> tokens;
|
||||
|
|
@ -444,7 +444,7 @@ SourceLineResolver::Line* SourceLineResolver::Module::ParseLine(
|
|||
return new Line(address, size, source_file, line_number);
|
||||
}
|
||||
|
||||
bool SourceLineResolver::Module::ParsePublicSymbol(char *public_line) {
|
||||
bool BasicSourceLineResolver::Module::ParsePublicSymbol(char *public_line) {
|
||||
// PUBLIC <address> <stack_param_size> <name>
|
||||
|
||||
// Skip "PUBLIC " prefix.
|
||||
|
|
@ -474,7 +474,7 @@ bool SourceLineResolver::Module::ParsePublicSymbol(char *public_line) {
|
|||
return public_symbols_.Store(address, symbol);
|
||||
}
|
||||
|
||||
bool SourceLineResolver::Module::ParseStackInfo(char *stack_info_line) {
|
||||
bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) {
|
||||
// STACK WIN <type> <rva> <code_size> <prolog_size> <epliog_size>
|
||||
// <parameter_size> <saved_register_size> <local_size> <max_stack_size>
|
||||
// <has_program_string> <program_string_OR_allocates_base_pointer>
|
||||
|
|
@ -554,7 +554,7 @@ bool SourceLineResolver::Module::ParseStackInfo(char *stack_info_line) {
|
|||
return true;
|
||||
}
|
||||
|
||||
size_t SourceLineResolver::HashString::operator()(const string &s) const {
|
||||
size_t BasicSourceLineResolver::HashString::operator()(const string &s) const {
|
||||
return hash<const char*>()(s.c_str());
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include "processor/source_line_resolver.h"
|
||||
#include "google_airbag/processor/basic_source_line_resolver.h"
|
||||
#include "google_airbag/processor/code_module.h"
|
||||
#include "google_airbag/processor/stack_frame.h"
|
||||
#include "processor/linked_ptr.h"
|
||||
|
|
@ -49,10 +49,10 @@
|
|||
namespace {
|
||||
|
||||
using std::string;
|
||||
using google_airbag::BasicSourceLineResolver;
|
||||
using google_airbag::CodeModule;
|
||||
using google_airbag::linked_ptr;
|
||||
using google_airbag::scoped_ptr;
|
||||
using google_airbag::SourceLineResolver;
|
||||
using google_airbag::StackFrame;
|
||||
using google_airbag::StackFrameInfo;
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ static bool RunTests() {
|
|||
string testdata_dir = string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
||||
"/src/processor/testdata";
|
||||
|
||||
SourceLineResolver resolver;
|
||||
BasicSourceLineResolver resolver;
|
||||
ASSERT_TRUE(resolver.LoadModule("module1", testdata_dir + "/module1.out"));
|
||||
ASSERT_TRUE(resolver.HasModule("module1"));
|
||||
ASSERT_TRUE(resolver.LoadModule("module2", testdata_dir + "/module2.out"));
|
||||
|
|
@ -38,8 +38,9 @@
|
|||
|
||||
namespace google_airbag {
|
||||
|
||||
MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier)
|
||||
: supplier_(supplier) {
|
||||
MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier,
|
||||
SourceLineResolverInterface *resolver)
|
||||
: supplier_(supplier), resolver_(resolver) {
|
||||
}
|
||||
|
||||
MinidumpProcessor::~MinidumpProcessor() {
|
||||
|
|
@ -164,7 +165,8 @@ MinidumpProcessor::ProcessResult MinidumpProcessor::Process(
|
|||
Stackwalker::StackwalkerForCPU(context,
|
||||
thread_memory,
|
||||
process_state->modules_,
|
||||
supplier_));
|
||||
supplier_,
|
||||
resolver_));
|
||||
if (!stackwalker.get()) {
|
||||
return PROCESS_ERROR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
// corresponding symbol file, and checks the stack frames for correctness.
|
||||
|
||||
#include <string>
|
||||
#include "google_airbag/processor/basic_source_line_resolver.h"
|
||||
#include "google_airbag/processor/call_stack.h"
|
||||
#include "google_airbag/processor/code_module.h"
|
||||
#include "google_airbag/processor/code_modules.h"
|
||||
|
|
@ -43,6 +44,7 @@
|
|||
namespace {
|
||||
|
||||
using std::string;
|
||||
using google_airbag::BasicSourceLineResolver;
|
||||
using google_airbag::CallStack;
|
||||
using google_airbag::CodeModule;
|
||||
using google_airbag::MinidumpProcessor;
|
||||
|
|
@ -93,7 +95,8 @@ SymbolSupplier::SymbolResult TestSymbolSupplier::GetSymbolFile(
|
|||
|
||||
static bool RunTests() {
|
||||
TestSymbolSupplier supplier;
|
||||
MinidumpProcessor processor(&supplier);
|
||||
BasicSourceLineResolver resolver;
|
||||
MinidumpProcessor processor(&supplier, &resolver);
|
||||
|
||||
string minidump_file = string(getenv("srcdir") ? getenv("srcdir") : ".") +
|
||||
"/src/processor/testdata/minidump2.dmp";
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include "google_airbag/processor/basic_source_line_resolver.h"
|
||||
#include "google_airbag/processor/call_stack.h"
|
||||
#include "google_airbag/processor/code_module.h"
|
||||
#include "google_airbag/processor/code_modules.h"
|
||||
|
|
@ -50,6 +51,7 @@
|
|||
namespace {
|
||||
|
||||
using std::string;
|
||||
using google_airbag::BasicSourceLineResolver;
|
||||
using google_airbag::CallStack;
|
||||
using google_airbag::CodeModule;
|
||||
using google_airbag::CodeModules;
|
||||
|
|
@ -192,7 +194,8 @@ static bool PrintMinidumpProcess(const string &minidump_file,
|
|||
symbol_supplier.reset(new SimpleSymbolSupplier(symbol_path));
|
||||
}
|
||||
|
||||
MinidumpProcessor minidump_processor(symbol_supplier.get());
|
||||
BasicSourceLineResolver resolver;
|
||||
MinidumpProcessor minidump_processor(symbol_supplier.get(), &resolver);
|
||||
|
||||
// Process the minidump.
|
||||
ProcessState process_state;
|
||||
|
|
|
|||
|
|
@ -1,98 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// SourceLineResolver returns function/file/line info for a memory address.
|
||||
// It uses address map files produced by a compatible writer, e.g.
|
||||
// PDBSourceLineWriter.
|
||||
|
||||
#ifndef PROCESSOR_SOURCE_LINE_RESOLVER_H__
|
||||
#define PROCESSOR_SOURCE_LINE_RESOLVER_H__
|
||||
|
||||
#include <string>
|
||||
#include <ext/hash_map>
|
||||
#include "google_airbag/common/airbag_types.h"
|
||||
|
||||
namespace google_airbag {
|
||||
|
||||
using std::string;
|
||||
using __gnu_cxx::hash_map;
|
||||
|
||||
struct StackFrame;
|
||||
struct StackFrameInfo;
|
||||
|
||||
class SourceLineResolver {
|
||||
public:
|
||||
typedef u_int64_t MemAddr;
|
||||
|
||||
SourceLineResolver();
|
||||
~SourceLineResolver();
|
||||
|
||||
// Adds a module to this resolver, returning true on success.
|
||||
//
|
||||
// module_name may be an arbitrary string. Typically, it will be the
|
||||
// filename of the module, optionally with version identifiers.
|
||||
//
|
||||
// map_file should contain line/address mappings for this module.
|
||||
bool LoadModule(const string &module_name, const string &map_file);
|
||||
|
||||
// Returns true if a module with the given name has been loaded.
|
||||
bool HasModule(const string &module_name) const;
|
||||
|
||||
// Fills in the function_base, function_name, source_file_name,
|
||||
// and source_line fields of the StackFrame. The instruction and
|
||||
// module_name fields must already be filled in. Additional debugging
|
||||
// information, if available, is returned. If the information is not
|
||||
// available, returns NULL. A NULL return value does not indicate an
|
||||
// error. The caller takes ownership of any returned StackFrameInfo
|
||||
// object.
|
||||
StackFrameInfo* FillSourceLineInfo(StackFrame *frame) const;
|
||||
|
||||
private:
|
||||
template<class T> class MemAddrMap;
|
||||
struct Line;
|
||||
struct Function;
|
||||
struct PublicSymbol;
|
||||
struct File;
|
||||
struct HashString {
|
||||
size_t operator()(const string &s) const;
|
||||
};
|
||||
class Module;
|
||||
|
||||
// All of the modules we've loaded
|
||||
typedef hash_map<string, Module*, HashString> ModuleMap;
|
||||
ModuleMap *modules_;
|
||||
|
||||
// Disallow unwanted copy ctor and assignment operator
|
||||
SourceLineResolver(const SourceLineResolver&);
|
||||
void operator=(const SourceLineResolver&);
|
||||
};
|
||||
|
||||
} // namespace google_airbag
|
||||
|
||||
#endif // PROCESSOR_SOURCE_LINE_RESOLVER_H__
|
||||
|
|
@ -41,11 +41,11 @@
|
|||
#include "google_airbag/processor/code_module.h"
|
||||
#include "google_airbag/processor/code_modules.h"
|
||||
#include "google_airbag/processor/minidump.h"
|
||||
#include "google_airbag/processor/source_line_resolver_interface.h"
|
||||
#include "google_airbag/processor/stack_frame.h"
|
||||
#include "google_airbag/processor/symbol_supplier.h"
|
||||
#include "processor/linked_ptr.h"
|
||||
#include "processor/scoped_ptr.h"
|
||||
#include "processor/source_line_resolver.h"
|
||||
#include "processor/stack_frame_info.h"
|
||||
#include "processor/stackwalker_ppc.h"
|
||||
#include "processor/stackwalker_x86.h"
|
||||
|
|
@ -54,14 +54,17 @@ namespace google_airbag {
|
|||
|
||||
|
||||
Stackwalker::Stackwalker(MemoryRegion *memory, const CodeModules *modules,
|
||||
SymbolSupplier *supplier)
|
||||
: memory_(memory), modules_(modules), supplier_(supplier) {
|
||||
SymbolSupplier *supplier,
|
||||
SourceLineResolverInterface *resolver)
|
||||
: memory_(memory),
|
||||
modules_(modules),
|
||||
supplier_(supplier),
|
||||
resolver_(resolver) {
|
||||
}
|
||||
|
||||
|
||||
bool Stackwalker::Walk(CallStack *stack) {
|
||||
assert(stack);
|
||||
SourceLineResolver resolver;
|
||||
stack->Clear();
|
||||
|
||||
// stack_frame_info parallels the CallStack. The vector is passed to the
|
||||
|
|
@ -88,14 +91,16 @@ bool Stackwalker::Walk(CallStack *stack) {
|
|||
modules_->GetModuleForAddress(frame->instruction);
|
||||
if (module) {
|
||||
frame->module = module;
|
||||
if (!resolver.HasModule(frame->module->code_file()) && supplier_) {
|
||||
if (resolver_ &&
|
||||
!resolver_->HasModule(frame->module->code_file()) &&
|
||||
supplier_) {
|
||||
string symbol_file;
|
||||
SymbolSupplier::SymbolResult symbol_result =
|
||||
supplier_->GetSymbolFile(module, &symbol_file);
|
||||
|
||||
switch (symbol_result) {
|
||||
case SymbolSupplier::FOUND:
|
||||
resolver.LoadModule(frame->module->code_file(), symbol_file);
|
||||
resolver_->LoadModule(frame->module->code_file(), symbol_file);
|
||||
break;
|
||||
case SymbolSupplier::NOT_FOUND:
|
||||
break; // nothing to do
|
||||
|
|
@ -103,7 +108,7 @@ bool Stackwalker::Walk(CallStack *stack) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
frame_info.reset(resolver.FillSourceLineInfo(frame.get()));
|
||||
frame_info.reset(resolver_->FillSourceLineInfo(frame.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,22 +129,26 @@ bool Stackwalker::Walk(CallStack *stack) {
|
|||
|
||||
|
||||
// static
|
||||
Stackwalker* Stackwalker::StackwalkerForCPU(MinidumpContext *context,
|
||||
MemoryRegion *memory,
|
||||
const CodeModules *modules,
|
||||
SymbolSupplier *supplier) {
|
||||
Stackwalker* Stackwalker::StackwalkerForCPU(
|
||||
MinidumpContext *context,
|
||||
MemoryRegion *memory,
|
||||
const CodeModules *modules,
|
||||
SymbolSupplier *supplier,
|
||||
SourceLineResolverInterface *resolver) {
|
||||
Stackwalker *cpu_stackwalker = NULL;
|
||||
|
||||
u_int32_t cpu = context->GetContextCPU();
|
||||
switch (cpu) {
|
||||
case MD_CONTEXT_X86:
|
||||
cpu_stackwalker = new StackwalkerX86(context->GetContextX86(),
|
||||
memory, modules, supplier);
|
||||
memory, modules, supplier,
|
||||
resolver);
|
||||
break;
|
||||
|
||||
case MD_CONTEXT_PPC:
|
||||
cpu_stackwalker = new StackwalkerPPC(context->GetContextPPC(),
|
||||
memory, modules, supplier);
|
||||
memory, modules, supplier,
|
||||
resolver);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ namespace google_airbag {
|
|||
StackwalkerPPC::StackwalkerPPC(const MDRawContextPPC *context,
|
||||
MemoryRegion *memory,
|
||||
const CodeModules *modules,
|
||||
SymbolSupplier *supplier)
|
||||
: Stackwalker(memory, modules, supplier),
|
||||
SymbolSupplier *supplier,
|
||||
SourceLineResolverInterface *resolver)
|
||||
: Stackwalker(memory, modules, supplier, resolver),
|
||||
context_(context) {
|
||||
if (memory_->GetBase() + memory_->GetSize() - 1 > 0xffffffff) {
|
||||
// This implementation only covers 32-bit ppc CPUs. The limits of the
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ class StackwalkerPPC : public Stackwalker {
|
|||
StackwalkerPPC(const MDRawContextPPC *context,
|
||||
MemoryRegion *memory,
|
||||
const CodeModules *modules,
|
||||
SymbolSupplier *supplier);
|
||||
SymbolSupplier *supplier,
|
||||
SourceLineResolverInterface *resolver);
|
||||
|
||||
private:
|
||||
// Implementation of Stackwalker, using ppc context (stack pointer in %r1,
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ static u_int32_t GetPC() {
|
|||
static unsigned int CountCallerFrames() __attribute__((noinline));
|
||||
static unsigned int CountCallerFrames() {
|
||||
SelfMemoryRegion memory;
|
||||
BasicSourceLineResolver resolver;
|
||||
|
||||
#if defined(__i386__)
|
||||
MDRawContextX86 context = MDRawContextX86();
|
||||
|
|
@ -224,13 +225,15 @@ static unsigned int CountCallerFrames() {
|
|||
context.ebp = GetEBP();
|
||||
context.esp = GetESP();
|
||||
|
||||
StackwalkerX86 stackwalker = StackwalkerX86(&context, &memory, NULL, NULL);
|
||||
StackwalkerX86 stackwalker = StackwalkerX86(&context, &memory, NULL, NULL,
|
||||
&resolver);
|
||||
#elif defined(__ppc__)
|
||||
MDRawContextPPC context = MDRawContextPPC();
|
||||
context.srr0 = GetPC();
|
||||
context.gpr[1] = GetSP();
|
||||
|
||||
StackwalkerPPC stackwalker = StackwalkerPPC(&context, &memory, NULL, NULL);
|
||||
StackwalkerPPC stackwalker = StackwalkerPPC(&context, &memory, NULL, NULL,
|
||||
&resolver);
|
||||
#endif // __i386__ || __ppc__
|
||||
|
||||
scoped_ptr<CallStack> stack(stackwalker.Walk());
|
||||
|
|
|
|||
|
|
@ -49,8 +49,9 @@ namespace google_airbag {
|
|||
StackwalkerX86::StackwalkerX86(const MDRawContextX86 *context,
|
||||
MemoryRegion *memory,
|
||||
const CodeModules *modules,
|
||||
SymbolSupplier *supplier)
|
||||
: Stackwalker(memory, modules, supplier),
|
||||
SymbolSupplier *supplier,
|
||||
SourceLineResolverInterface *resolver)
|
||||
: Stackwalker(memory, modules, supplier, resolver),
|
||||
context_(context) {
|
||||
if (memory_->GetBase() + memory_->GetSize() - 1 > 0xffffffff) {
|
||||
// The x86 is a 32-bit CPU, the limits of the supplied stack are invalid.
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ class StackwalkerX86 : public Stackwalker {
|
|||
StackwalkerX86(const MDRawContextX86 *context,
|
||||
MemoryRegion *memory,
|
||||
const CodeModules *modules,
|
||||
SymbolSupplier *supplier);
|
||||
SymbolSupplier *supplier,
|
||||
SourceLineResolverInterface *resolver);
|
||||
|
||||
private:
|
||||
// Implementation of Stackwalker, using x86 context (%ebp, %esp, %eip) and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue