diff --git a/src/processor/minidump_dump.cc b/src/processor/minidump_dump.cc index 6ec777f1..9581da9e 100644 --- a/src/processor/minidump_dump.cc +++ b/src/processor/minidump_dump.cc @@ -33,9 +33,12 @@ // Author: Mark Mentovai #include +#include +#include "client/linux/minidump_writer/minidump_extension_linux.h" #include "google_breakpad/processor/minidump.h" #include "processor/logging.h" +#include "processor/scoped_ptr.h" namespace { @@ -49,6 +52,42 @@ using google_breakpad::MinidumpSystemInfo; using google_breakpad::MinidumpMiscInfo; using google_breakpad::MinidumpBreakpadInfo; +static void DumpRawStream(Minidump *minidump, + u_int32_t stream_type, + const char *stream_name, + int *errors) { + u_int32_t length = 0; + if (!minidump->SeekToStreamType(stream_type, &length)) { + return; + } + + printf("Stream %s:\n", stream_name); + + if (length == 0) { + printf("\n"); + return; + } + std::vector contents(length); + if (!minidump->ReadBytes(&contents[0], length)) { + ++*errors; + BPLOG(ERROR) << "minidump.ReadBytes failed"; + return; + } + size_t current_offset = 0; + while (current_offset < length) { + size_t remaining = length - current_offset; + printf("%.*s", remaining, &contents[current_offset]); + char *next_null = reinterpret_cast( + memchr(&contents[current_offset], 0, remaining)); + if (next_null == NULL) + break; + printf("\\0\n"); + size_t null_offset = next_null - &contents[0]; + current_offset = null_offset + 1; + } + printf("\n\n"); +} + static bool PrintMinidumpDump(const char *minidump_file) { Minidump minidump(minidump_file); if (!minidump.Read()) { @@ -121,6 +160,27 @@ static bool PrintMinidumpDump(const char *minidump_file) { breakpad_info->Print(); } + DumpRawStream(&minidump, + MD_LINUX_CMD_LINE, + "MD_LINUX_CMD_LINE", + &errors); + DumpRawStream(&minidump, + MD_LINUX_ENVIRON, + "MD_LINUX_ENVIRON", + &errors); + DumpRawStream(&minidump, + MD_LINUX_LSB_RELEASE, + "MD_LINUX_LSB_RELEASE", + &errors); + DumpRawStream(&minidump, + MD_LINUX_PROC_STATUS, + "MD_LINUX_PROC_STATUS", + &errors); + DumpRawStream(&minidump, + MD_LINUX_CPU_INFO, + "MD_LINUX_CPU_INFO", + &errors); + return errors == 0; }