diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-03-09 00:40:41 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-03-09 00:40:41 +0100 |
commit | 655457ce666e2ed6da3c8e21210bb2aa0901676d (patch) | |
tree | bf5f8167cfa817df2576bed7ef7db3d0c9ffcc18 | |
parent | 3b6feb872a1da1f77d2179ee4fe1a25d5d056bcd (diff) |
write /proc/PID/exe to minidump
-rw-r--r-- | format.h | 22 | ||||
-rw-r--r-- | minidump.c | 33 |
2 files changed, 39 insertions, 16 deletions
@@ -76,21 +76,21 @@ enum { MINIDUMP_ASSERTION_INFO_STREAM = 0x47670002, /* Breakpad/Linux extensions */ - MINIDUMP_LINUX_CPU_INFO = 0x47670003, - MINIDUMP_LINUX_PROC_STATUS = 0x47670004, - MINIDUMP_LINUX_LSB_RELEASE = 0x47670005, - MINIDUMP_LINUX_CMD_LINE = 0x47670006, - MINIDUMP_LINUX_ENVIRON = 0x47670007, - MINIDUMP_LINUX_AUXV = 0x47670008, - MINIDUMP_LINUX_MAPS = 0x47670009, + MINIDUMP_LINUX_CPU_INFO = 0x47670003, /* done */ + MINIDUMP_LINUX_PROC_STATUS = 0x47670004, /* done */ + MINIDUMP_LINUX_LSB_RELEASE = 0x47670005, /* done */ + MINIDUMP_LINUX_CMD_LINE = 0x47670006, /* done */ + MINIDUMP_LINUX_ENVIRON = 0x47670007, /* done */ + MINIDUMP_LINUX_AUXV = 0x47670008, /* done */ + MINIDUMP_LINUX_MAPS = 0x47670009, /* done */ MINIDUMP_LINUX_DSO_DEBUG = 0x4767000A, /* libminidump extensions */ MINIDUMP_LINUX_OS_RELEASE = 0x4c500001, - MINIDUMP_LINUX_EXE = 0x4c500002, - MINIDUMP_LINUX_COMM = 0x4c500003, - MINIDUMP_LINUX_PRPSINFO = 0x4c500004, - MINIDUMP_LINUX_COREDUMP_EHDR = 0x4c500005 + MINIDUMP_LINUX_EXE = 0x4c500002, /* done */ + MINIDUMP_LINUX_COMM = 0x4c500003, /* done */ + MINIDUMP_LINUX_PRPSINFO = 0x4c500004, /* done */ + MINIDUMP_LINUX_CORE_EHDR = 0x4c500005 /* done */ }; @@ -682,6 +682,30 @@ static int write_proc_file_stream(struct context *c, uint32_t stream_type, const return r; } +static int write_proc_readlink_stream(struct context *c, uint32_t stream_type, const char *fname) { + char *p; + int r; + char path[PATH_MAX]; + + assert(c); + + if (!HAVE_PROCESS(c)) + return 0; + + if (asprintf(&p, "/proc/%lu/%s", (unsigned long) c->pid, fname) < 0) + return -ENOMEM; + + r = readlink(p, path, sizeof(path)); + free(p); + + if (r < 0) + return -errno; + if (r == sizeof(path)) + return -E2BIG; + + return write_blob_stream(c, stream_type, path, r); +} + static int write_directory(struct context *c) { size_t offset; struct minidump_header *h; @@ -726,6 +750,8 @@ static int write_dump(struct context *c) { /* write memory list */ /* write exception */ /* write system info */ + /* write rpm info */ + /* write debug */ /* This is a Ubuntuism, but Google is doing this, hence let's stay compatible here */ write_file_stream(c, MINIDUMP_LINUX_LSB_RELEASE, "/etc/lsb-release"); @@ -738,6 +764,7 @@ static int write_dump(struct context *c) { write_proc_file_stream(c, MINIDUMP_LINUX_CMD_LINE, "cmdline"); write_proc_file_stream(c, MINIDUMP_LINUX_ENVIRON, "environ"); write_proc_file_stream(c, MINIDUMP_LINUX_COMM, "comm"); + write_proc_readlink_stream(c, MINIDUMP_LINUX_EXE, "exe"); r = write_proc_file_stream(c, MINIDUMP_LINUX_MAPS, "maps"); if (r < 0) @@ -754,15 +781,11 @@ static int write_dump(struct context *c) { if (r < 0) return r; - r = write_blob_stream(c, MINIDUMP_LINUX_COREDUMP_EHDR, &c->header, sizeof(c->header)); + r = write_blob_stream(c, MINIDUMP_LINUX_CORE_EHDR, &c->header, sizeof(c->header)); if (r < 0) return r; } - /* write rpm info */ - /* write /proc/$PID/exe */ - /* write debug */ - r = write_directory(c); if (r < 0) return r; |