Refactor the logic of resolving source line info into helper class.

http://breakpad.appspot.com/459002/


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1068 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
SiyangXie@gmail.com 2012-10-10 21:41:52 +00:00
parent f72b9c6ff4
commit bab770045b
22 changed files with 813 additions and 926 deletions

View file

@ -36,6 +36,7 @@
#include "google_breakpad/processor/minidump.h"
#include "google_breakpad/processor/process_state.h"
#include "google_breakpad/processor/exploitability.h"
#include "google_breakpad/processor/stack_frame_symbolizer.h"
#include "processor/logging.h"
#include "processor/scoped_ptr.h"
#include "processor/stackwalker_x86.h"
@ -44,18 +45,29 @@ namespace google_breakpad {
MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier,
SourceLineResolverInterface *resolver)
: supplier_(supplier), resolver_(resolver),
: frame_symbolizer_(new StackFrameSymbolizer(supplier, resolver)),
own_frame_symbolizer_(true),
enable_exploitability_(false) {
}
MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier,
SourceLineResolverInterface *resolver,
bool enable_exploitability)
: supplier_(supplier), resolver_(resolver),
: frame_symbolizer_(new StackFrameSymbolizer(supplier, resolver)),
own_frame_symbolizer_(true),
enable_exploitability_(enable_exploitability) {
}
MinidumpProcessor::MinidumpProcessor(StackFrameSymbolizer *frame_symbolizer,
bool enable_exploitability)
: frame_symbolizer_(frame_symbolizer),
own_frame_symbolizer_(false),
enable_exploitability_(enable_exploitability) {
assert(frame_symbolizer_);
}
MinidumpProcessor::~MinidumpProcessor() {
if (own_frame_symbolizer_) delete frame_symbolizer_;
}
ProcessResult MinidumpProcessor::Process(
@ -126,6 +138,10 @@ ProcessResult MinidumpProcessor::Process(
bool interrupted = false;
bool found_requesting_thread = false;
unsigned int thread_count = threads->thread_count();
// Reset frame_symbolizer_ at the beginning of stackwalk for each minidump.
frame_symbolizer_->Reset();
for (unsigned int thread_index = 0;
thread_index < thread_count;
++thread_index) {
@ -208,8 +224,7 @@ ProcessResult MinidumpProcessor::Process(
context,
thread_memory,
process_state->modules_,
supplier_,
resolver_));
frame_symbolizer_));
if (!stackwalker.get()) {
BPLOG(ERROR) << "No stackwalker for " << thread_string;
return PROCESS_ERROR_NO_STACKWALKER_FOR_THREAD;
@ -1160,7 +1175,8 @@ string MinidumpProcessor::GetAssertion(Minidump *dump) {
break;
default: {
char assertion_type[32];
sprintf(assertion_type, "0x%08x", raw_assertion->type);
snprintf(assertion_type, sizeof(assertion_type),
"0x%08x", raw_assertion->type);
assertion_string = "Unknown assertion type ";
assertion_string += assertion_type;
break;
@ -1184,7 +1200,7 @@ string MinidumpProcessor::GetAssertion(Minidump *dump) {
if (raw_assertion->line != 0) {
char assertion_line[32];
sprintf(assertion_line, "%u", raw_assertion->line);
snprintf(assertion_line, sizeof(assertion_line), "%u", raw_assertion->line);
assertion_string.append(" at line ");
assertion_string.append(assertion_line);
}