trace, argdist: -I switch for trace and miscellaneous fixes (#761)
* trace: Additional include files support
Similarly to `argdist`, `trace` now has a `-I` option for adding
include files that can be used in filter and print expressions.
This also required a slight modification to `argdist`'s syntax
for consistency: where previously we would allow `-I header1 header2`,
we now require `-I header1 -I header2` to avoid any mixups with
which argument is a header file and which is a probe for `trace`.
This is very unlikely to break anyone, because I haven't seen the
`-I` option used at all, not to mention extensively with multiple
headers.
Also made sure the man and example pages are up to date.
* argdist: Update -C and -H switches for consistency
This commit updates `argdist`'s `-H` and `-C` switches for consistency
with the `-I` switch and `trace`'s switches. Specifically, each probe
needs an explicit `-C` or `-H` specifier in front of it. This also
allows safe and understandable mixing of histogram and counting probes,
for example:
```
argdist -C 'p:c:write()' -H 'p::vfs__write(int fd, const void *buf, size_t size):size_t:size#write sizes'
```
* trace: Fix stack trace support for tracepoints
Tracepoint probes don't have a `ctx` argument, it's called `args`
instead. The recently-added stack trace support code didn't take
this into account, and consequently didn't work for tracepoints.
This commit fixes the issue, so we can now do things like
`trace -K t:block:block_rq_complete`.
diff --git a/tools/argdist.py b/tools/argdist.py
index a4aab70..2bb44c0 100755
--- a/tools/argdist.py
+++ b/tools/argdist.py
@@ -3,11 +3,8 @@
# argdist Trace a function and display a distribution of its
# parameter values as a histogram or frequency count.
#
-# USAGE: argdist [-h] [-p PID] [-z STRING_SIZE] [-i INTERVAL]
-# [-n COUNT] [-v] [-c] [-T TOP]
-# [-C specifier [specifier ...]]
-# [-H specifier [specifier ...]]
-# [-I header [header ...]]
+# USAGE: argdist [-h] [-p PID] [-z STRING_SIZE] [-i INTERVAL] [-n COUNT] [-v]
+# [-c] [-T TOP] [-C specifier] [-H specifier] [-I header]
#
# Licensed under the Apache License, Version 2.0 (the "License")
# Copyright (C) 2016 Sasha Goldshtein.
@@ -545,9 +542,8 @@
Print frequency of function addresses used as a pthread start function,
relying on the USDT pthread_start probe in process 1337
-argdist -H \\
- 'p:c:sleep(u32 seconds):u32:seconds' \\
- 'p:c:nanosleep(struct timespec *req):long:req->tv_nsec'
+argdist -H 'p:c:sleep(u32 seconds):u32:seconds' \\
+ -H 'p:c:nanosleep(struct timespec *req):long:req->tv_nsec'
Print histograms of sleep() and nanosleep() parameter values
argdist -p 2780 -z 120 \\
@@ -577,15 +573,15 @@
parser.add_argument("-T", "--top", type=int,
help="number of top results to show (not applicable to " +
"histograms)")
- parser.add_argument("-H", "--histogram", nargs="*",
+ parser.add_argument("-H", "--histogram", action="append",
dest="histspecifier", metavar="specifier",
help="probe specifier to capture histogram of " +
"(see examples below)")
- parser.add_argument("-C", "--count", nargs="*",
+ parser.add_argument("-C", "--count", action="append",
dest="countspecifier", metavar="specifier",
help="probe specifier to capture count of " +
"(see examples below)")
- parser.add_argument("-I", "--include", nargs="*",
+ parser.add_argument("-I", "--include", action="append",
metavar="header",
help="additional header files to include in the BPF program")
self.args = parser.parse_args()