diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-23 00:32:29 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-23 00:32:29 +0000 |
commit | ab61ec6bd60b56436693c20a2d71d55ad0a8bfa5 (patch) | |
tree | 9dc7899b39edb92a9bf83c482bd46b30422402df /breakpad/linux | |
parent | 70b340dae988354ac3e5722224ebb02a66bd55ae (diff) | |
download | chromium_src-ab61ec6bd60b56436693c20a2d71d55ad0a8bfa5.zip chromium_src-ab61ec6bd60b56436693c20a2d71d55ad0a8bfa5.tar.gz chromium_src-ab61ec6bd60b56436693c20a2d71d55ad0a8bfa5.tar.bz2 |
Fill in sys_info->csd_version_rva on Linux.
BUG=none
TEST=none
This is (cleaned up) code from Breakpad's /client/linux/handler/minidump_generator.cc.
Review URL: http://codereview.chromium.org/146001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'breakpad/linux')
-rw-r--r-- | breakpad/linux/minidump_writer.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/breakpad/linux/minidump_writer.cc b/breakpad/linux/minidump_writer.cc index c938809..ac0ab94 100644 --- a/breakpad/linux/minidump_writer.cc +++ b/breakpad/linux/minidump_writer.cc @@ -51,6 +51,7 @@ #include <errno.h> #include <sys/ucontext.h> #include <sys/user.h> +#include <sys/utsname.h> #include "client/minidump_file_writer.h" #include "google_breakpad/common/minidump_format.h" @@ -599,6 +600,7 @@ class MinidumpWriter { dirent->location = si.location(); WriteCPUInformation(si.get()); + WriteOSInformation(si.get()); return true; } @@ -770,6 +772,52 @@ class MinidumpWriter { return true; } + bool WriteOSInformation(MDRawSystemInfo* sys_info) { + sys_info->platform_id = MD_OS_LINUX; + + struct utsname uts; + if (uname(&uts)) + return false; + + static const size_t buf_len = 512; + char buf[buf_len] = {0}; + size_t space_left = buf_len - 1; + const char* info_table[] = { + uts.sysname, + uts.release, + uts.version, + uts.machine, + NULL + }; + bool first_item = true; + for (const char** cur_info = info_table; *cur_info; cur_info++) { + static const char* separator = " "; + size_t separator_len = strlen(separator); + size_t info_len = strlen(*cur_info); + if (info_len == 0) + continue; + + if (space_left < info_len + (first_item ? 0 : separator_len)) + break; + + if (!first_item) { + strcat(buf, separator); + space_left -= separator_len; + } + + first_item = false; + strcat(buf, *cur_info); + space_left -= info_len; + } + + MDLocationDescriptor location; + if (!minidump_writer_.WriteString(buf, 0, &location)) + return false; + sys_info->csd_version_rva = location.rva; + + return true; + } + bool WriteProcFile(MDLocationDescriptor* result, pid_t pid, const char* filename) { char buf[80]; |