Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 972970 - Add annotation for which symbols were actually used in processing a dump #1891

Merged
merged 1 commit into from Feb 21, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 43 additions & 3 deletions minidump-stackwalk/stackwalker.cc
Expand Up @@ -35,6 +35,7 @@
#include <iostream>
#include <ostream>
#include <vector>
#include <set>
#include <cstdlib>

#include <errno.h>
Expand All @@ -55,6 +56,7 @@
#include "google_breakpad/processor/process_state.h"
#include "google_breakpad/processor/stackwalker.h"
#include "google_breakpad/processor/stack_frame_cpu.h"
#include "google_breakpad/processor/stack_frame_symbolizer.h"
#include "processor/pathname_stripper.h"
#include "processor/simple_symbol_supplier.h"

Expand All @@ -80,8 +82,10 @@ using google_breakpad::StackFramePPC;
using google_breakpad::StackFrameSPARC;
using google_breakpad::StackFrameX86;
using google_breakpad::StackFrameAMD64;
using google_breakpad::StackFrameSymbolizer;
using google_breakpad::Stackwalker;
using google_breakpad::SymbolSupplier;
using google_breakpad::SystemInfo;

using std::string;
using std::vector;
Expand Down Expand Up @@ -109,6 +113,36 @@ static string ToInt(int value) {
return buffer;
}

class StackFrameSymbolizerForward : public StackFrameSymbolizer {
public:
StackFrameSymbolizerForward(SymbolSupplier* supplier,
SourceLineResolverInterface* resolver)
: StackFrameSymbolizer(supplier, resolver) {}

virtual SymbolizerResult FillSourceLineInfo(const CodeModules* modules,
const SystemInfo* system_info,
StackFrame* stack_frame) {
SymbolizerResult res =
StackFrameSymbolizer::FillSourceLineInfo(modules,
system_info,
stack_frame);
RecordResult(stack_frame->module, res);
return res;
}

bool SymbolsLoadedFor(const CodeModule* module) const {
return loaded_modules_.find(module) != loaded_modules_.end();
}

private:
void RecordResult(const CodeModule* module, SymbolizerResult result) {
if (result == SymbolizerResult::kNoError && !SymbolsLoadedFor(module)) {
loaded_modules_.insert(module);
}
}
std::set<const CodeModule*> loaded_modules_;
};

string FrameTrust(StackFrame::FrameTrust trust) {
switch (trust) {
case StackFrame::FRAME_TRUST_NONE:
Expand Down Expand Up @@ -208,6 +242,7 @@ bool ConvertStackToJSON(const ProcessState& process_state,
}

int ConvertModulesToJSON(const ProcessState& process_state,
const StackFrameSymbolizerForward& symbolizer,
Json::Value& json) {
const CodeModules* modules = process_state.modules();
const vector<const CodeModule*>* modules_without_symbols =
Expand Down Expand Up @@ -245,6 +280,9 @@ int ConvertModulesToJSON(const ProcessState& process_state,
if (ContainsModule(modules_with_corrupt_symbols, module)) {
module_data["corrupt_symbols"] = true;
}
if (symbolizer.SymbolsLoadedFor(module)) {
module_data["loaded_symbols"] = true;
}
json.append(module_data);
}
return main_module_index;
Expand Down Expand Up @@ -282,6 +320,7 @@ static string ExploitabilityString(ExploitabilityRating exploitability) {
}

static void ConvertProcessStateToJSON(const ProcessState& process_state,
const StackFrameSymbolizerForward& symbolizer,
Json::Value& root) {
// OS and CPU information.
Json::Value system_info;
Expand Down Expand Up @@ -312,7 +351,7 @@ static void ConvertProcessStateToJSON(const ProcessState& process_state,
root["crash_info"] = crash_info;

Json::Value modules(Json::arrayValue);
int main_module = ConvertModulesToJSON(process_state, modules);
int main_module = ConvertModulesToJSON(process_state, symbolizer, modules);
if (main_module != -1)
root["main_module"] = main_module;
root["modules"] = modules;
Expand Down Expand Up @@ -689,7 +728,8 @@ int main(int argc, char** argv)
Json::Value root;
SimpleSymbolSupplier symbol_supplier(symbol_paths);
BasicSourceLineResolver resolver;
MinidumpProcessor minidump_processor(&symbol_supplier, &resolver, true);
StackFrameSymbolizerForward symbolizer(&symbol_supplier, &resolver);
MinidumpProcessor minidump_processor(&symbolizer, false);
ProcessState process_state;
ProcessResult result =
minidump_processor.Process(&minidump, &process_state);
Expand All @@ -711,7 +751,7 @@ int main(int argc, char** argv)
root["status"] = ResultString(result);
root["sensitive"] = Json::Value(Json::objectValue);
if (result == google_breakpad::PROCESS_OK) {
ConvertProcessStateToJSON(process_state, root);
ConvertProcessStateToJSON(process_state, symbolizer, root);
}
ConvertLargestFreeVMToJSON(minidump, raw_root, root);
Json::Writer* writer;
Expand Down