From 2cfab3ea663dc29b98ed06981c85fcf32e405352 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 18 Jan 2024 15:20:15 +0200 Subject: [PATCH] killsnoop: align numbers to the right Justifications: https://ux.stackexchange.com/questions/13795/is-there-a-standard-to-left-justify-text-and-right-justify-numeric-values --- CHANGELOG.md | 3 ++- tools/killsnoop.bt | 4 ++-- tools/killsnoop_example.txt | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e367728e423..d6aeb1c91966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,7 +66,8 @@ and this project adheres to - [#2790](https://github.com/iovisor/bpftrace/pull/2790) - Update mdflush.bt to use blkdev.h instead of genhd.h for non-BTF builds. - [#2849](https://github.com/iovisor/bpftrace/pull/2849) -- Add milliseconds to timestamp in `threadsnoop.bt` +- Add milliseconds to timestamp and align numbers to the right in `threadsnoop.bt` + - [#2936](https://github.com/iovisor/bpftrace/pull/2936) ## [0.19.0] 2023-09-19 diff --git a/tools/killsnoop.bt b/tools/killsnoop.bt index ce27f06ef031..1be081d237a2 100755 --- a/tools/killsnoop.bt +++ b/tools/killsnoop.bt @@ -18,7 +18,7 @@ BEGIN { printf("Tracing kill() signals... Hit Ctrl-C to end.\n"); - printf("%-15s %7s %-16s %-4s %-6s %s\n", + printf("%-15s %7s %-16s %4s %6s %s\n", "TIME", "PID", "COMM", "SIG", "TPID", "RESULT"); } @@ -31,7 +31,7 @@ tracepoint:syscalls:sys_enter_kill tracepoint:syscalls:sys_exit_kill /@tpid[tid]/ { - printf("%-15s %7d %-16s %-4d %-6d %d\n", + printf("%-15s %7d %-16s %4d %6d %6d\n", strftime("%H:%M:%S.%f", nsecs), pid, comm, @tsig[tid], @tpid[tid], args.ret); delete(@tpid[tid]); diff --git a/tools/killsnoop_example.txt b/tools/killsnoop_example.txt index dd3a36d5a0af..0596a48cc90b 100644 --- a/tools/killsnoop_example.txt +++ b/tools/killsnoop_example.txt @@ -7,10 +7,10 @@ This traces signals sent via the kill() syscall. For example: # ./killsnoop.bt Attaching 3 probes... Tracing kill() signals... Hit Ctrl-C to end. -TIME PID COMM SIG TPID RESULT -00:09:37.345938 22485 bash 2 23856 0 -00:09:40.838452 22485 bash 2 23856 -3 -00:09:31.437104 22485 bash 15 23814 -3 +TIME PID COMM SIG TPID RESULT +00:09:37.345938 22485 bash 2 23856 0 +00:09:40.838452 22485 bash 2 23856 -3 +00:09:31.437104 22485 bash 15 23814 -3 The first line showed a SIGINT (2) sent from PID 22485 (a bash shell) to PID 23856. The result, 0, means success. The next line shows the same signal