Skip to content

Commit

Permalink
threadsnoop: use strftime instead of elapsed
Browse files Browse the repository at this point in the history
because `elapsed` gives relative time,
and `strftime` gives absolute time which
is more readable and practical.
  • Loading branch information
makelinux committed Jan 12, 2024
1 parent e68c8e9 commit 40c6250
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ and this project adheres to
- [#2876](https://github.com/iovisor/bpftrace/pull/2876)
- Use `strftime` instead of `elapsed` in `execsnoop.bt`
- [#2904](https://github.com/iovisor/bpftrace/pull/2904)
- Use `strftime` instead of `elapsed` in `threadsnoop.bt`
- [#2917](https://github.com/iovisor/bpftrace/pull/2917)
- Update runqlen.bt to remove `runnable_weight` field from cfs_rq struct.
- [#2790](https://github.com/iovisor/bpftrace/pull/2790)
- Update mdflush.bt to use blkdev.h instead of genhd.h for non-BTF builds.
Expand Down
4 changes: 2 additions & 2 deletions tools/threadsnoop.bt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

BEGIN
{
printf("%-10s %-6s %-16s %s\n", "TIME(ms)", "PID", "COMM", "FUNC");
printf("%-15s %-6s %-16s %s\n", "TIME", "PID", "COMM", "FUNC");
}

uprobe:libpthread:pthread_create,
uprobe:libc:pthread_create
{
printf("%-10u %-6d %-16s %s\n", elapsed / 1e6, pid, comm,
printf("%15s %-6d %-16s %s\n", strftime("%H:%M:%S.%f", nsecs), pid, comm,
usym(arg2));
}
28 changes: 14 additions & 14 deletions tools/threadsnoop_example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ Tracing new threads via phtread_create():

# ./threadsnoop.bt
Attaching 2 probes...
TIME(ms) PID COMM FUNC
1938 28549 dockerd threadentry
1939 28549 dockerd threadentry
1939 28549 dockerd threadentry
1940 28549 dockerd threadentry
1949 28549 dockerd threadentry
1958 28549 dockerd threadentry
1939 28549 dockerd threadentry
1950 28549 dockerd threadentry
2013 28579 docker-containe 0x562f30f2e710
2036 28549 dockerd threadentry
2083 28579 docker-containe 0x562f30f2e710
2116 629 systemd-journal 0x7fb7114955c0
2116 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
Expand Down

0 comments on commit 40c6250

Please sign in to comment.