bcc icon indicating copy to clipboard operation
bcc copied to clipboard

tools/memleak: support user-space tracing without a PID

Open ghedo opened this issue 2 years ago • 3 comments

Sometimes it is useful to attach user probes before starting a process (e.g. see https://github.com/iovisor/bcc/issues/3834), however memleak currently requires a PID in order to enable user-space probing.

This change adds a new option --kernel-trace to explicitly enable kernel tracing, and allow user-space tracing without providing a PID.

In order to do this, a stack's PID need to be stored in the BPF map, in order to be able to later resolve symbols correctly.

ghedo avatar Aug 26 '22 11:08 ghedo

This change adds a new option --kernel-trace to explicitly enable kernel tracing, and allow user-space tracing without providing a PID.

This is a behavior change as kernel tracing now needs explicit option. We cannot do this.

What is your expected command line for user space tracing?

yonghong-song avatar Aug 28 '22 06:08 yonghong-song

The way I've been running this is something like memleak --obj /path/to/binary and once the probes are attached I actually run /path/to/binary.

In order to avoid breaking previous use cases I guess I could add a --user-trace option rather than --kernel-trace, and then have user-space tracing enabled when either a PID is available, or --user-trace is passed. This way existing use cases should still work. Thoughts?

ghedo avatar Aug 30 '22 14:08 ghedo

I think adding a --user-trace option is better. This way, we can maintain the backward compatibility.

yonghong-song avatar Sep 06 '22 01:09 yonghong-song