diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2023-04-04 22:06:18 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-04-22 08:00:00 +0000 |
commit | 67eb44c4de45e89af0e34937ff6a2ea1ebff14ae (patch) | |
tree | d1ef03cdbab754d32813ec0f85209656a3ad6d76 /tests/gen_tests.in | |
parent | 9800b413bc9412c2e3a118bd6a1c7e9ff99b5381 (diff) | |
download | strace-67eb44c4de45e89af0e34937ff6a2ea1ebff14ae.tar.gz |
Implement an ability to filter syscalls that operate on specific FDs
Introduce -e trace-fds= qualifier that allows specifying a set of FDs
of interest, operations on which are to be traced. Works in conjunction
(or, more specifically, inclusive disjunction) with the path tracing
functionality.
* src/defs.h: Include "number_set.h".
(tracing_fds): New external variable.
(pathtrace_match_set): Add new fdset argument to the declaration.
(pathtrace_match): Pass trace_fd_set in the new argument
to the pathtrace_match_set call.
(qualify_trace_fd): New function declaration.
* src/filter_qualify.c (trace_fd_set): New variable.
(qualify_trace_fd): New function.
(qual_options): Add various FD tracing-related items.
* src/number_set.h (trace_fd_set): New external variable declaration.
* src/pathtrace.c (pathmatch, upathmatch): Bail out if set is NULL.
(fdmatch): Add fdset argument, check fd for non-negativity and presence
in fdset if fdset is non-NULL.
(match_xselect_args): Add fdset argument, pass it to the fdmatch call.
(pathtrace_match_set): Add fdset argument, pass it to fdmatch
and match_xselect_args calls.
* src/syscall.c (syscall_entering_trace): Check tracing_fds in addition
to tracing_paths as a predicate for performing pathtrace_match check.
* src/strace.c (tracing_fds): New variable.
(init) <GETOPT_QUAL_TRACE_FD>: New enum item.
(init) <longopts>: Add"trace-fds" option.
(init) <case GETOPT_QUAL_TRACE_FD>: Call qualify_trace_fd.
(usage): Document -e trace-fds.
* doc/strace.1.in: Likewise.
* tests/.gitignore: Add dup-trace-fds-0, dup-trace-fds-0-9,
dup-trace-fds-0-P, dup-trace-fds-not-9, dup2-e-fd-0, dup2-e-fd-0-9,
dup2-e-fd-0-P, dup2-e-fd-not-9, ppoll-e-trace-fds-23,
ppoll-e-trace-fds-23-42, ppoll-e-trace-fds-not-9-42-P,
select-trace-fd-7, select-trace-fd-7-9, and select-trace-fd-7-P.
* tests/Makefile.am (check_PROGRAMS): Add ppoll-e-trace-fds-23,
ppoll-e-trace-fds-23-42, ppoll-e-trace-fds-not-9-42-P,
select-trace-fd-7, select-trace-fd-7-9, and select-trace-fd-7-P.
* tests/dup-P.c (PATH_TRACING): Set to 1.
* tests/dup2-P.c (PATH_TRACING): Likewise.
* tests/dup.c: Accommodate test for checking tracing-fds functionality.
* tests/dup2.c: Likewise.
* tests/ppoll.c: Likewise.
* tests/xselect.c: Likewise.
* tests/gen_tests.in (dup-trace-fds-0, dup-trace-fds-0-9,
dup-trace-fds-0-P, dup-trace-fds-not-9, dup2-e-fd-0, dup2-e-fd-0-9,
dup2-e-fd-0-P, dup2-e-fd-not-9, ppoll-e-trace-fds-23,
ppoll-e-trace-fds-23-42, ppoll-e-trace-fds-not-9-42-P,
select-trace-fd-7, select-trace-fd-7-9, select-trace-fd-7-P): New tests.
* tests/options-syntax.test: Add trace-fds-related option syntax checks.
* tests/pure_executables.list: Add dup-trace-fds-0, dup-trace-fds-0-9,
dup-trace-fds-0-P, dup-trace-fds-not-9, dup2-e-fd-0, dup2-e-fd-0-9,
dup2-e-fd-0-P, and dup2-e-fd-not-9.
* tests/dup-trace-fds-0-9.c: New file.
* tests/dup-trace-fds-0-P.c: Likewise.
* tests/dup-trace-fds-0.c: Likewise.
* tests/dup-trace-fds-not-9.c: Likewise.
* tests/dup2-e-fd-0-9.c: Likewise.
* tests/dup2-e-fd-0-P.c: Likewise.
* tests/dup2-e-fd-0.c: Likewise.
* tests/dup2-e-fd-not-9.c: Likewise.
* tests/ppoll-e-trace-fds-23-42.c: Likewise.
* tests/ppoll-e-trace-fds-23.c: Likewise.
* tests/ppoll-e-trace-fds-not-9-42-P.c: Likewise.
* tests/select-trace-fd-7-9.c: Likewise.
* tests/select-trace-fd-7-P.c: Likewise.
* tests/select-trace-fd-7.c: Likewise.
* NEWS: Mention it.
Suggested-by: Marty Leisner <maleisner@gmail.com>
Link: https://lists.strace.io/pipermail/strace-devel/2023-March/011209.html
Diffstat (limited to 'tests/gen_tests.in')
-rw-r--r-- | tests/gen_tests.in | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/gen_tests.in b/tests/gen_tests.in index 74d9984c9..6432e3409 100644 --- a/tests/gen_tests.in +++ b/tests/gen_tests.in @@ -81,10 +81,18 @@ dev--decode-fds-socket -a9 -e trace=openat,fsync -P "/dev/full" -P "/dev/zero" - dev-yy -a30 -e trace=openat,fsync -P "/dev/full" -P "/dev/zero" -P "/dev/sda" -yy dup -a7 9>>/dev/full dup-P -a7 --trace=dup -P /dev/full 9>>/dev/full +dup-trace-fds-0 -a7 --trace=dup --trace-fds=0 9>>/dev/full +dup-trace-fds-0-9 -a7 --trace=dup --trace-fds=0,9 9>>/dev/full +dup-trace-fds-0-P -a7 --trace=dup --trace-fds=0 -P /dev/full 9>>/dev/full +dup-trace-fds-not-9 -a7 --trace=dup --trace-fds='!9' 9>>/dev/full dup-y -a8 --trace=dup -y 9>>/dev/full dup-yy -a8 --trace=dup -yy 9>>/dev/full dup2 -a11 9>>/dev/full dup2-P -a11 --trace=dup2 -P /dev/full 9>>/dev/full +dup2-e-fd-0 -a11 --trace=dup2 -e fd=0 9>>/dev/full +dup2-e-fd-0-9 -a11 --trace=dup2 -e fd=0,9 9>>/dev/full +dup2-e-fd-0-P -a11 --trace=dup2 -e fd=0 -P /dev/full 9>>/dev/full +dup2-e-fd-not-9 -a11 --trace=dup2 -e fd='!9' 9>>/dev/full dup2-y -a13 --trace=dup2 -y 9>>/dev/full dup2-yy -a13 --trace=dup2 -yy 9>>/dev/full dup3 -a13 7>>/dev/full @@ -697,9 +705,12 @@ pkey_alloc -a17 pkey_free -a13 pkey_mprotect -a37 poke-sendfile --trace=/sendfile --inject=all:poke_enter=@arg3=0000000000000000:poke_exit=@arg3=ffffffffffffffff -ppoll -s2 -ppoll-P -s2 -e trace=ppoll -P /dev/full 9>>/dev/full -ppoll-v -v -s2 -e trace=ppoll +ppoll -s2 +ppoll-P -s2 -e trace=ppoll -P /dev/full 9>>/dev/full +ppoll-e-trace-fds-23 -s2 -e trace=ppoll -e trace-fds=23 +ppoll-e-trace-fds-23-42 -s2 -e trace=ppoll -e trace-fds=23,42 +ppoll-e-trace-fds-not-9-42-P -s2 -e trace=ppoll -e trace-fds='!9,42' -P /dev/full 9>>/dev/full +ppoll-v -v -s2 -e trace=ppoll prctl-arg2-intptr +prctl.sh -a25 prctl-cap-ambient +prctl.sh -a21 prctl-capbset +prctl.sh -a21 @@ -892,6 +903,9 @@ segv_accerr -qq --trace=none segv_pkuerr -qq --trace=none select -a36 select-P -a36 -e trace=select -P /dev/full 9>>/dev/full +select-trace-fd-7 -a36 -e trace=select -e trace-fd=7 7>>/dev/null 9>>/dev/full +select-trace-fd-7-9 -a36 -e trace=select -e trace-fd=7,9 7>>/dev/null 9>>/dev/full +select-trace-fd-7-P -a36 -e trace=select -e trace-fd=7 -P /dev/full 7>>/dev/null 9>>/dev/full semop -a32 semop-indirect -a32 -e trace=semop semtimedop |