From bde65ba7ca21fe7762d43e97d94ba0ca94ed90e7 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 30 Dec 2020 13:22:26 +0100 Subject: [PATCH] CrashReporter: Read executable path from coredump process info We no longer have to look at the backtrace and guess the executable, it's now embedded in the coredump's ProcessInfo notes entry directly. Fixes #4645. --- Applications/CrashReporter/main.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Applications/CrashReporter/main.cpp b/Applications/CrashReporter/main.cpp index 4e03a8ecb2..815fec911d 100644 --- a/Applications/CrashReporter/main.cpp +++ b/Applications/CrashReporter/main.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ int main(int argc, char** argv) args_parser.parse(argc, argv); Optional backtrace; + String executable_path; { auto coredump = CoreDump::Reader::create(coredump_path); @@ -67,7 +69,9 @@ int main(int argc, char** argv) warnln("Could not open coredump '{}'", coredump_path); return 1; } + auto& process_info = coredump->process_info(); backtrace = coredump->backtrace(); + executable_path = String(process_info.executable_path); } auto app = GUI::Application::construct(argc, argv); @@ -77,18 +81,6 @@ int main(int argc, char** argv) return 1; } - String executable_path; - // FIXME: Maybe we should just embed the process's executable path - // in the coredump by itself so we don't have to extract it from the backtrace. - // Such a process section could also include the PID, which currently we'd have - // to parse from the filename. - if (!backtrace.value().entries().is_empty()) { - executable_path = backtrace.value().entries().last().object_name; - } else { - warnln("Could not determine executable path from coredump"); - return 1; - } - if (unveil(executable_path.characters(), "r") < 0) { perror("unveil"); return 1;