From e41dc092521c602a6c45545966cb7d2ae4292f34 Mon Sep 17 00:00:00 2001 From: "kmixter@chromium.org" Date: Wed, 8 Dec 2010 18:48:28 +0000 Subject: Enable dumping of the Linux extension streams. We now dump information about process's environment/command line/status, Linux release, and CPU info. Review URL: http://breakpad.appspot.com/238001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@738 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/processor/minidump_dump.cc | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) 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; } -- cgit v1.2.1