summaryrefslogtreecommitdiffstats
path: root/breakpad/linux
diff options
context:
space:
mode:
Diffstat (limited to 'breakpad/linux')
-rw-r--r--breakpad/linux/minidump_writer.cc48
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];