trace, argdist: Treat small USDT arguments correctly
authorSasha Goldshtein <goldshtn@gmail.com>
Mon, 20 Feb 2017 15:42:57 +0000 (15:42 +0000)
committerSasha Goldshtein <goldshtn@gmail.com>
Mon, 20 Feb 2017 15:42:57 +0000 (15:42 +0000)
commit3a5256f101d43a8b9167df01dd3fc0dfdb0e6f00
tree3e026df6771e08cab91c4b3d085ec572081deb7a
parent203fd2760d5bc027e907eab509abc5bee1e20a93
trace, argdist: Treat small USDT arguments correctly

trace and argdist currently only work correctly for USDT arguments
whose size is exactly 8 bytes. Smaller types, such as chars, shorts,
ints (signed or unsigned) are not treated correctly. The reason is
that the produced program would invoke the `bpf_usdt_readarg` helper
with the address of a u64 local variable, and then cast that variable
to the user-specified type derived from the format string. However,
the `bpf_usdt_readarg` rewriting then passes `sizeof(u64)` to the
generated `bpf_..._readarg` macro, which then fails to read anything
because the provided size doesn't match the argument size it knows
about.

The fix is fairly easy: instead of declaring a u64 unconditionally
and reading into that variable with `bpf_usdt_readarg`, declare a
variable that has the correct type according to what we know about
the USDT probe.
tools/argdist.py
tools/trace.py