janestreet / magic-trace

magic-trace collects and displays high-resolution traces of what a process is doing
https://magic-trace.org
MIT License
4.58k stars 87 forks source link

Add print PID option under MAGIC_TRACE_DEBUG (`-z-print-pid`) #266

Open DMaroo opened 1 year ago

DMaroo commented 1 year ago

This PR introduces an option (-z-print-pid) to be used when Env_vars.debug is set to true. This would print the PIDs of all the processes which magic-trace attaches to.

A demo output looks like this:

$ MAGIC_TRACE_DEBUG=1 magic-trace attach -p 245085,251541 -z-print-pid
Passed PIDs to perf: 245085,251541
<rest of the output>
<Ctrl+C>
$ /bin/cat &
[2] 251834
[2]  + suspended (tty input)  cat
$ MAGIC_TRACE_DEBUG=1 magic-trace attach -z-print-pid
<choose /bin/cat process using fzf>
Passed PIDs to perf: 251834
<rest of the output>
<Ctrl+C>

Done in collaboration with @Mantra-7.

Fixes #256.