mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:37:35 +00:00
Kernel: Generate coredumps for profiled processes
These coredumps will be used by the Profile Viewer to symbolicate the profiling samples.
This commit is contained in:
parent
39890af833
commit
5392f42731
2 changed files with 18 additions and 3 deletions
|
@ -587,15 +587,24 @@ void Process::finalize()
|
||||||
dbg() << "Finalizing process " << *this;
|
dbg() << "Finalizing process " << *this;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (is_profiling()) {
|
||||||
|
auto coredump = CoreDump::create(*this, LexicalPath { String::format("/tmp/profiler_coredumps/%d", pid().value()) });
|
||||||
|
if (coredump) {
|
||||||
|
coredump->write();
|
||||||
|
} else {
|
||||||
|
dbgln("Could not create coredump");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (m_should_dump_core) {
|
if (m_should_dump_core) {
|
||||||
dbgln("Generating coredump for pid: {}", m_pid.value());
|
dbgln("Generating coredump for pid: {}", m_pid.value());
|
||||||
|
|
||||||
auto coredump_path = String::format("/tmp/coredump/%s_%u", name().characters(), RTC::now());
|
auto coredump_path = String::format("/tmp/coredump/%s_%d_%u", name().characters(), m_pid.value(), RTC::now());
|
||||||
auto coredump = CoreDump::create(*this, LexicalPath { coredump_path });
|
auto coredump = CoreDump::create(*this, LexicalPath { coredump_path });
|
||||||
if (!coredump) {
|
if (coredump) {
|
||||||
|
coredump->write();
|
||||||
|
} else {
|
||||||
dbgln("Could not create coredump");
|
dbgln("Could not create coredump");
|
||||||
}
|
}
|
||||||
coredump->write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_perf_event_buffer) {
|
if (m_perf_event_buffer) {
|
||||||
|
|
|
@ -56,6 +56,12 @@ int Process::sys$profiling_disable(pid_t pid)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
process->set_profiling(false);
|
process->set_profiling(false);
|
||||||
Profiling::stop();
|
Profiling::stop();
|
||||||
|
|
||||||
|
// We explicitly unlock here because we can't hold the lock when writing the coredump VFS
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
|
auto coredump = CoreDump::create(*process, LexicalPath { String::format("/tmp/profiler_coredumps/%d", pid) });
|
||||||
|
coredump->write();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue