core_handler: coredump handler to produce minidump

On Linux, it is possible to register a core handler via
/proc/sys/kernel/core_pattern. Doing so invokes the core handler when
a process crash. The core_handler uses /proc/<pid>/mem to access the
process memory. This way it is not necessary to process the full
coredump which takes time and consumes memory.

In order to profit from this core handler, for example, one can
integrate dump_syms into Yocto and generate an archive with the
breakpad symbols of all the binaries in the rootfs. Minidumps are
especially useful on embedded systems since they are lightweight and
provide contextual information.

Change-Id: I9298d81159029cefb81c915831db54884310ad05
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2536917
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Ludovic Guegan 2020-11-23 22:58:05 +01:00 committed by Mike Frysinger
parent e3d485f73f
commit bd4a28c08b
7 changed files with 361 additions and 41 deletions

View file

@ -137,6 +137,16 @@ bool LinuxCoreDumper::EnumerateThreads() {
return false;
}
char proc_mem_path[NAME_MAX];
if (BuildProcPath(proc_mem_path, pid_, "mem")) {
int fd = open(proc_mem_path, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1) {
core_.SetProcMem(fd);
} else {
fprintf(stderr, "Cannot open %s (%s)\n", proc_mem_path, strerror(errno));
}
}
core_.SetContent(mapped_core_file_.content());
if (!core_.IsValid()) {
fprintf(stderr, "Invalid core dump file\n");