1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:47:35 +00:00

Userland: Tweak the visual display of the bt utility

This patch adds a few minor visual features to the `bt` utility:
- Number each frame of the back trace.
- Color the address based on if it's in kernel or user space.
- Add a "frames:" heading to visually seperate the thread id.
- Rename "tid: <tid>" -> "thread: <tid>" as it's more visually
  appealing since it aligns vertically with "frames:"
- Add a visual " | " seperate between the address and symbol name.
This commit is contained in:
Brian Gianforcaro 2021-05-22 17:11:39 -07:00 committed by Ali Mohammad Pur
parent 786f6841b3
commit 529a8664f4

View file

@ -37,10 +37,14 @@ int main(int argc, char** argv)
while (iterator.has_next()) { while (iterator.has_next()) {
pid_t tid = iterator.next_path().to_int().value(); pid_t tid = iterator.next_path().to_int().value();
outln("tid: {}", tid); outln("thread: {}", tid);
outln("frames:");
auto symbols = Symbolication::symbolicate_thread(pid, tid); auto symbols = Symbolication::symbolicate_thread(pid, tid);
auto frame_number = symbols.size() - 1;
for (auto& symbol : symbols) { for (auto& symbol : symbols) {
out("{:p} ", symbol.address); // Make kernel stack frames stand out.
int color = symbol.address < 0xc0000000 ? 35 : 31;
out("{:3}: \033[{};1m{:p}\033[0m | ", frame_number, color, symbol.address);
if (!symbol.name.is_empty()) if (!symbol.name.is_empty())
out("{} ", symbol.name); out("{} ", symbol.name);
if (!symbol.filename.is_empty()) { if (!symbol.filename.is_empty()) {
@ -64,6 +68,7 @@ int main(int argc, char** argv)
out(")"); out(")");
} }
outln(""); outln("");
frame_number--;
} }
outln(""); outln("");
} }