mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 12:30:31 +00:00
SystemMonitor: Use SymbolServer to symbolicate thread stacks
This commit is contained in:
parent
b7d16e3496
commit
5dd555fe2f
Notes:
sideshowbarker
2024-07-18 22:35:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5dd555fe2fc
3 changed files with 20 additions and 10 deletions
|
@ -13,4 +13,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_app(SystemMonitor ICON app-system-monitor)
|
||||
target_link_libraries(SystemMonitor LibGUI LibPCIDB)
|
||||
target_link_libraries(SystemMonitor LibGUI LibSymbolClient LibPCIDB)
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -29,6 +29,7 @@
|
|||
#include <LibCore/File.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibSymbolClient/Client.h>
|
||||
|
||||
ThreadStackWidget::ThreadStackWidget()
|
||||
{
|
||||
|
@ -55,14 +56,18 @@ void ThreadStackWidget::set_ids(pid_t pid, pid_t tid)
|
|||
|
||||
void ThreadStackWidget::refresh()
|
||||
{
|
||||
auto file = Core::File::construct(String::formatted("/proc/{}/stacks/{}", m_pid, m_tid));
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
m_stack_editor->set_text(String::formatted("Unable to open {}", file->filename()));
|
||||
return;
|
||||
auto symbols = SymbolClient::symbolicate_thread(m_pid, m_tid);
|
||||
|
||||
StringBuilder builder;
|
||||
|
||||
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() != new_text) {
|
||||
m_stack_editor->set_text(new_text);
|
||||
if (m_stack_editor->text() != builder.string_view()) {
|
||||
m_stack_editor->set_text(builder.string_view());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ int main(int argc, char** 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");
|
||||
return 1;
|
||||
}
|
||||
|
@ -137,6 +137,11 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/tmp/portal/symbol", "rw") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/bin", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue