mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 01:48:11 +00:00
CrashReporter: Don't keep the coredump file open longer than necessary
Let's be nice and close the file after we've extracted what we need.
This commit is contained in:
parent
8df1f6951e
commit
10b5b9ee66
1 changed files with 12 additions and 9 deletions
|
@ -59,10 +59,15 @@ int main(int argc, char** argv)
|
||||||
args_parser.add_positional_argument(coredump_path, "Coredump path", "coredump-path");
|
args_parser.add_positional_argument(coredump_path, "Coredump path", "coredump-path");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
auto coredump = CoreDump::Reader::create(coredump_path);
|
Optional<CoreDump::Backtrace> backtrace;
|
||||||
if (!coredump) {
|
|
||||||
warnln("Could not open coredump '{}'", coredump_path);
|
{
|
||||||
return 1;
|
auto coredump = CoreDump::Reader::create(coredump_path);
|
||||||
|
if (!coredump) {
|
||||||
|
warnln("Could not open coredump '{}'", coredump_path);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
backtrace = coredump->backtrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
|
@ -72,15 +77,13 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto backtrace = coredump->backtrace();
|
|
||||||
|
|
||||||
String executable_path;
|
String executable_path;
|
||||||
// FIXME: Maybe we should just embed the process's 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.
|
// 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
|
// Such a process section could also include the PID, which currently we'd have
|
||||||
// to parse from the filename.
|
// to parse from the filename.
|
||||||
if (!backtrace.entries().is_empty()) {
|
if (!backtrace.value().entries().is_empty()) {
|
||||||
executable_path = backtrace.entries().last().object_name;
|
executable_path = backtrace.value().entries().last().object_name;
|
||||||
} else {
|
} else {
|
||||||
warnln("Could not determine executable path from coredump");
|
warnln("Could not determine executable path from coredump");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -143,7 +146,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
StringBuilder backtrace_builder;
|
StringBuilder backtrace_builder;
|
||||||
auto first = true;
|
auto first = true;
|
||||||
for (auto& entry : backtrace.entries()) {
|
for (auto& entry : backtrace.value().entries()) {
|
||||||
if (first)
|
if (first)
|
||||||
first = false;
|
first = false;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue