Eric Radman : a Journal

Dynamic Tracing on OpenBSD

btrace(8) is a tool that provices dtrace(1) functionality on OpenBSD. The syntax is analogous to awk(1)

probe / filter / { action }

Examples

All system read operations

# btrace -e 'syscall:read:entry { @[comm] = count() }'
^C
@[chrome]: 14609
@[Xorg]: 2005
@[firefox]: 153
@[tailscaled]: 3
@[pflogd]: 1
@[st]: 1

Read size distribution

# btrace -e 'syscall:read:return { @readsize = hist(retval) }'
^C
@readsize:
[0]              505 |@@                                                  |
[0, 1)          9010 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[1, 2)            14 |                                                    |
[8, 16)           26 |                                                    |
[16, 32)         410 |@@                                                  |
[32, 64)         388 |@@                                                  |
[64, 128)        497 |@@                                                  |
[128, 256)         9 |                                                    |
[256, 512)        43 |                                                    |
[512, 1K)        197 |@                                                   |
[1K, 2K)         216 |@                                                   |
[2K, 4K)         220 |@                                                   |
[4K, 8K)          40 |                                                    |
[8K, 16K)       1400 |@@@@@@@@                                            |
[16K, 32K)       277 |@                                                   |

History

7.7

7.6

7.5

7.4

7.2

7.1

7.0

6.9

6.8

Traditional Tools

Setting LD_DEBUG prints the linking operations for ld.so

ktrace(1) trace system calls

ltrace(1) trace shared library function calls