mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
bt: Enumerate all threads when symbolizing stacks in the bt utility.
Enumerate tid's from /proc/{pid}/stacks/ and use it to print the backtrace for all active threads in the specified process.
This commit is contained in:
parent
f1c98dc5ea
commit
ca213ab374
1 changed files with 33 additions and 22 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibSymbolClient/Client.h>
|
||||
|
@ -54,8 +55,16 @@ int main(int argc, char** argv)
|
|||
args_parser.parse(argc, argv);
|
||||
Core::EventLoop loop;
|
||||
|
||||
// FIXME: Support multiple threads in the same process!
|
||||
auto symbols = SymbolClient::symbolicate_thread(pid, pid);
|
||||
Core::DirIterator iterator(String::formatted("/proc/{}/stacks", pid), Core::DirIterator::SkipDots);
|
||||
if (iterator.has_error()) {
|
||||
warnln("Error: pid '{}' doesn't appear to exist.", pid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (iterator.has_next()) {
|
||||
pid_t tid = iterator.next_path().to_int().value();
|
||||
outln("tid: {}", tid);
|
||||
auto symbols = SymbolClient::symbolicate_thread(pid, tid);
|
||||
for (auto& symbol : symbols) {
|
||||
out("{:p} ", symbol.address);
|
||||
if (!symbol.name.is_empty())
|
||||
|
@ -82,5 +91,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
outln("");
|
||||
}
|
||||
outln("");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue