1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

SystemMonitor: Use SymbolServer to symbolicate thread stacks

This commit is contained in:
Andreas Kling 2021-02-04 23:18:25 +01:00
parent b7d16e3496
commit 5dd555fe2f
3 changed files with 20 additions and 10 deletions

View file

@ -13,4 +13,4 @@ set(SOURCES
) )
serenity_app(SystemMonitor ICON app-system-monitor) serenity_app(SystemMonitor ICON app-system-monitor)
target_link_libraries(SystemMonitor LibGUI LibPCIDB) target_link_libraries(SystemMonitor LibGUI LibSymbolClient LibPCIDB)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,6 +29,7 @@
#include <LibCore/File.h> #include <LibCore/File.h>
#include <LibCore/Timer.h> #include <LibCore/Timer.h>
#include <LibGUI/BoxLayout.h> #include <LibGUI/BoxLayout.h>
#include <LibSymbolClient/Client.h>
ThreadStackWidget::ThreadStackWidget() ThreadStackWidget::ThreadStackWidget()
{ {
@ -55,14 +56,18 @@ void ThreadStackWidget::set_ids(pid_t pid, pid_t tid)
void ThreadStackWidget::refresh() void ThreadStackWidget::refresh()
{ {
auto file = Core::File::construct(String::formatted("/proc/{}/stacks/{}", m_pid, m_tid)); auto symbols = SymbolClient::symbolicate_thread(m_pid, m_tid);
if (!file->open(Core::IODevice::ReadOnly)) {
m_stack_editor->set_text(String::formatted("Unable to open {}", file->filename())); StringBuilder builder;
return;
for (auto& symbol : symbols) {
builder.appendff("{:p}", symbol.address);
if (!symbol.name.is_empty())
builder.appendff(" {}", symbol.name);
builder.append('\n');
} }
auto new_text = file->read_all(); if (m_stack_editor->text() != builder.string_view()) {
if (m_stack_editor->text() != new_text) { m_stack_editor->set_text(builder.string_view());
m_stack_editor->set_text(new_text);
} }
} }

View file

@ -112,7 +112,7 @@ int main(int argc, char** argv)
auto app = GUI::Application::construct(argc, argv); auto app = GUI::Application::construct(argc, argv);
if (pledge("stdio proc recvfd sendfd accept rpath exec", nullptr) < 0) { if (pledge("stdio proc recvfd sendfd accept rpath exec unix", nullptr) < 0) {
perror("pledge"); perror("pledge");
return 1; return 1;
} }
@ -137,6 +137,11 @@ int main(int argc, char** argv)
return 1; return 1;
} }
if (unveil("/tmp/portal/symbol", "rw") < 0) {
perror("unveil");
return 1;
}
if (unveil("/bin", "r") < 0) { if (unveil("/bin", "r") < 0) {
perror("unveil"); perror("unveil");
return 1; return 1;