Add crash reason extraction to microdump processor

BUG=754715

Change-Id: I00fe62ed06dbbab4c8f6c416d56e2d444be11571
Reviewed-on: https://chromium-review.googlesource.com/621307
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Tobias Sargeant 2017-08-18 17:29:38 +01:00 committed by Tobias Sargeant
parent b1e7ec065d
commit 2b3be5179e
5 changed files with 1457 additions and 1 deletions

View File

@ -119,11 +119,15 @@ class Microdump {
MicrodumpModules* GetModules() { return modules_.get(); }
SystemInfo* GetSystemInfo() { return system_info_.get(); }
string GetCrashReason() { return crash_reason_; }
uint64_t GetCrashAddress() { return crash_address_; }
private:
scoped_ptr<MicrodumpContext> context_;
scoped_ptr<MicrodumpMemoryRegion> stack_region_;
scoped_ptr<MicrodumpModules> modules_;
scoped_ptr<SystemInfo> system_info_;
string crash_reason_;
uint64_t crash_address_;
};
} // namespace google_breakpad

View File

@ -54,6 +54,7 @@ static const char kMicrodumpBegin[] = "-----BEGIN BREAKPAD MICRODUMP-----";
static const char kMicrodumpEnd[] = "-----END BREAKPAD MICRODUMP-----";
static const char kOsKey[] = ": O ";
static const char kCpuKey[] = ": C ";
static const char kCrashReasonKey[] = ": R ";
static const char kGpuKey[] = ": G ";
static const char kMmapKey[] = ": M ";
static const char kStackKey[] = ": S ";
@ -212,7 +213,9 @@ Microdump::Microdump(const string& contents)
: context_(new MicrodumpContext()),
stack_region_(new MicrodumpMemoryRegion()),
modules_(new MicrodumpModules()),
system_info_(new SystemInfo()) {
system_info_(new SystemInfo()),
crash_reason_(),
crash_address_(0u) {
assert(!contents.empty());
bool in_microdump = false;
@ -350,6 +353,15 @@ Microdump::Microdump(const string& contents)
} else {
std::cerr << "Unsupported architecture: " << arch << std::endl;
}
} else if ((pos = line.find(kCrashReasonKey)) != string::npos) {
string crash_reason_str(line, pos + strlen(kCrashReasonKey));
std::istringstream crash_reason_tokens(crash_reason_str);
string signal;
string address;
crash_reason_tokens >> signal;
crash_reason_tokens >> crash_reason_;
crash_reason_tokens >> address;
crash_address_ = HexStrToL<uint64_t>(address);
} else if ((pos = line.find(kGpuKey)) != string::npos) {
string gpu_str(line, pos + strlen(kGpuKey));
if (strcmp(gpu_str.c_str(), kGpuUnknown) != 0) {

View File

@ -94,6 +94,8 @@ ProcessResult MicrodumpProcessor::Process(const string &microdump_contents,
process_state->crashed_ = true;
process_state->requesting_thread_ = 0;
process_state->system_info_ = *microdump.GetSystemInfo();
process_state->crash_reason_ = microdump.GetCrashReason();
process_state->crash_address_ = microdump.GetCrashAddress();
return PROCESS_OK;
}

View File

@ -123,6 +123,22 @@ TEST_F(MicrodumpProcessorTest, TestProcess_Invalid) {
ASSERT_EQ(google_breakpad::PROCESS_ERROR_NO_THREAD_LIST, result);
}
TEST_F(MicrodumpProcessorTest, TestProcess_WithoutCrashReason) {
ProcessState state;
AnalyzeDump("microdump-arm64.dmp", true /* omit_symbols */,
2 /* expected_cpu_count */, &state);
ASSERT_EQ(state.crash_reason(), "");
ASSERT_EQ(state.crash_address(), 0x0u);
}
TEST_F(MicrodumpProcessorTest, TestProcess_WithCrashReason) {
ProcessState state;
AnalyzeDump("microdump-withcrashreason.dmp", true /* omit_symbols */,
8 /* expected_cpu_count */, &state);
ASSERT_EQ(state.crash_reason(), "SIGTRAP");
ASSERT_EQ(state.crash_address(), 0x4A7CB000u);
}
TEST_F(MicrodumpProcessorTest, TestProcess_MissingSymbols) {
ProcessState state;
AnalyzeDump("microdump-arm64.dmp", true /* omit_symbols */,

File diff suppressed because it is too large Load Diff