diff options
author | Masatake YAMATO <yamato@redhat.com> | 2021-09-09 22:43:36 +0900 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2021-11-14 08:00:00 +0000 |
commit | cb1650559273daa41fef08ab91da35860d1cf26f (patch) | |
tree | 07a2114bb9721d065bf505cd7dc8caf9ea879c4b /src/strace.c | |
parent | 8cebeebcb587d557f1a870c4c544d308fb675362 (diff) | |
download | strace-cb1650559273daa41fef08ab91da35860d1cf26f.tar.gz |
Extend -Y option to decode PIDs in arguments and return values
This change extends -Y/--decode-pids=comm option. In addition to the
information printed before this change, command names would be printed
also for PIDs appeared in syscall arguments and return values.
For example:
getppid() = 3781395<strace>
getpid() = 3781398<a.out>
pidfd_open(1<systemd>, 0) = 3<pid:1<systemd>>
NOTE: The code printing the pid in printclockname() is not changed in
this commit. CLOCKID_TO_FD macro used in printclockname() was removed
from the kernel, so printclockname() may change drastically in the
near future.
* src/defs.h (maybe_printpid_comm): New function declaration.
* src/strace.c (maybe_printpid_comm): New function printing
command name for the given PID.
* src/pidns.c (printpid_translation): Call `maybe_printpid_comm'.
* tests/strace--decode-pids-comm.c (do_default_action): Update expected
output.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Co-authored-by: Dmitry V. Levin <ldv@strace.io>
Diffstat (limited to 'src/strace.c')
-rw-r--r-- | src/strace.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/strace.c b/src/strace.c index 950644040..38165a1a3 100644 --- a/src/strace.c +++ b/src/strace.c @@ -948,6 +948,19 @@ load_pid_comm(int pid, char *buf, size_t buf_size) } void +maybe_printpid_comm(int pid) +{ + if (!(pid_decoding & PID_DECODING_COMM)) + return; + + char buf[PROC_COMM_LEN]; + load_pid_comm(pid, buf, sizeof(buf)); + tprints("<"); + tprints(buf); + tprints(">"); +} + +void maybe_load_task_comm(struct tcb *tcp) { if (!(pid_decoding & PID_DECODING_COMM)) |