Add ability to print file descriptor paths and filter by those paths
* pathtrace.c: New file, implements matching syscall arguments to
user-specified file paths.
* Makefile.am (strace_SOURCES): Add pathtrace.c.
* defs.h (TCB_FILTERED, filtered): New defines.
(getfdpath, pathtrace_select, pathtrace_match, show_fd_path,
tracing_paths): New declarations.
* strace.c (show_fd_path, tracing_paths): New global variables.
(usage, main): Implement handling of -y and -P options.
* strace.1: Add descriptions of -y and -P options.
* syscall.c (trace_syscall_entering): Add path matching logic to the
print/noprint decision and set the TCB_FILTERED bit appropriately.
(trace_syscall_exiting): Use filtered() macro that checks the
TCB_FILTERED bit to determine print/noprint status.
* util.c (printfd): Use getfdpath().
diff --git a/util.c b/util.c
index 711e614..8704a46 100644
--- a/util.c
+++ b/util.c
@@ -418,7 +418,12 @@
void
printfd(struct tcb *tcp, int fd)
{
- tprintf("%d", fd);
+ const char *p;
+
+ if (show_fd_path && (p = getfdpath(tcp, fd)))
+ tprintf("%d<%s>", fd, p);
+ else
+ tprintf("%d", fd);
}
void