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
This commit is contained in:
kmixter@chromium.org 2010-12-08 18:48:28 +00:00
parent 6c05f5ddd9
commit e41dc09252

View File

@ -33,9 +33,12 @@
// Author: Mark Mentovai
#include <stdio.h>
#include <string.h>
#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<char> 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<char *>(
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;
}