summaryrefslogtreecommitdiff
path: root/tests/select-trace-fd-7.c
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2023-04-04 22:06:18 +0200
committerDmitry V. Levin <ldv@strace.io>2023-04-22 08:00:00 +0000
commit67eb44c4de45e89af0e34937ff6a2ea1ebff14ae (patch)
treed1ef03cdbab754d32813ec0f85209656a3ad6d76 /tests/select-trace-fd-7.c
parent9800b413bc9412c2e3a118bd6a1c7e9ff99b5381 (diff)
downloadstrace-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/select-trace-fd-7.c')
-rw-r--r--tests/select-trace-fd-7.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/select-trace-fd-7.c b/tests/select-trace-fd-7.c
new file mode 100644
index 000000000..6aeaf180f
--- /dev/null
+++ b/tests/select-trace-fd-7.c
@@ -0,0 +1,2 @@
+#define TRACING_FD 7
+#include "select.c"