From 99d912988fb3edf4a3b41aed358d9da5960f73f6 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Wed, 17 Jan 2024 08:22:07 +0200 Subject: [PATCH] threadsnoop: increase PID field width and align to the right for better readability. Justifications: https://ux.stackexchange.com/questions/13795/is-there-a-standard-to-left-justify-text-and-right-justify-numeric-values wc -L /proc/sys/kernel/pid_max 7 /proc/sys/kernel/pid_max --- tools/threadsnoop.bt | 4 ++-- tools/threadsnoop_example.txt | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/threadsnoop.bt b/tools/threadsnoop.bt index 33e500408899..017764025736 100755 --- a/tools/threadsnoop.bt +++ b/tools/threadsnoop.bt @@ -15,12 +15,12 @@ BEGIN { - printf("%-15s %-6s %-16s %s\n", "TIME", "PID", "COMM", "FUNC"); + printf("%-15s %7s %-16s %s\n", "TIME", "PID", "COMM", "FUNC"); } uprobe:libpthread:pthread_create, uprobe:libc:pthread_create { - printf("%15s %-6d %-16s %s\n", strftime("%H:%M:%S.%f", nsecs), pid, comm, + printf("%15s %7d %-16s %s\n", strftime("%H:%M:%S.%f", nsecs), pid, comm, usym(arg2)); } diff --git a/tools/threadsnoop_example.txt b/tools/threadsnoop_example.txt index e8f1753b1ca9..cc16392118db 100644 --- a/tools/threadsnoop_example.txt +++ b/tools/threadsnoop_example.txt @@ -5,20 +5,20 @@ Tracing new threads via phtread_create(): # ./threadsnoop.bt Attaching 2 probes... -TIME PID COMM FUNC -10:20:31.938572 28549 dockerd threadentry -10:20:31.939213 28549 dockerd threadentry -10:20:31.939405 28549 dockerd threadentry -10:20:31.940642 28549 dockerd threadentry -10:20:31.949060 28549 dockerd threadentry -10:20:31.958319 28549 dockerd threadentry -10:20:31.939152 28549 dockerd threadentry -10:20:31.950978 28549 dockerd threadentry -10:20:32.013269 28579 docker-containe 0x562f30f2e710 -10:20:32.036764 28549 dockerd threadentry -10:20:32.083780 28579 docker-containe 0x562f30f2e710 -10:20:32.116738 629 systemd-journal 0x7fb7114955c0 -10:20:32.116844 629 systemd-journal 0x7fb7114955c0 +TIME PID COMM FUNC +10:20:31.938572 28549 dockerd threadentry +10:20:31.939213 28549 dockerd threadentry +10:20:31.939405 28549 dockerd threadentry +10:20:31.940642 28549 dockerd threadentry +10:20:31.949060 28549 dockerd threadentry +10:20:31.958319 28549 dockerd threadentry +10:20:31.939152 28549 dockerd threadentry +10:20:31.950978 28549 dockerd threadentry +10:20:32.013269 28579 docker-containe 0x562f30f2e710 +10:20:32.036764 28549 dockerd threadentry +10:20:32.083780 28579 docker-containe 0x562f30f2e710 +10:20:32.116738 629 systemd-journal 0x7fb7114955c0 +10:20:32.116844 629 systemd-journal 0x7fb7114955c0 [...] The output shows a dockerd process creating several threads with the start