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/defs.h b/defs.h
index 8be668a..0b960f9 100644
--- a/defs.h
+++ b/defs.h
@@ -401,6 +401,7 @@
 #define TCB_SIGTRAPPED	00200	/* Process wanted to block SIGTRAP */
 #define TCB_FOLLOWFORK	00400	/* Process should have forks followed */
 #define TCB_REPRINT	01000	/* We should reprint this syscall on exit */
+#define TCB_FILTERED	02000	/* This system call has been filtered out */
 #ifdef LINUX
 /* x86 does not need TCB_WAITEXECVE.
  * It can detect execve's SIGTRAP by looking at eax/rax.
@@ -410,7 +411,7 @@
   || defined(POWERPC) || defined(IA64) || defined(HPPA) \
   || defined(SH) || defined(SH64) || defined(S390) || defined(S390X) \
   || defined(ARM) || defined(MIPS) || defined(BFIN) || defined(TILE)
-#  define TCB_WAITEXECVE 02000	/* ignore SIGTRAP after exceve */
+#  define TCB_WAITEXECVE 04000	/* ignore SIGTRAP after exceve */
 # endif
 # define TCB_CLONE_THREAD  010000 /* CLONE_THREAD set in creating syscall */
 # define TCB_GROUP_EXITING 020000 /* TCB_EXITING was exit_group, not _exit */
@@ -452,6 +453,7 @@
 #define syserror(tcp)	((tcp)->u_error != 0)
 #define verbose(tcp)	(qual_flags[(tcp)->scno] & QUAL_VERBOSE)
 #define abbrev(tcp)	(qual_flags[(tcp)->scno] & QUAL_ABBREV)
+#define filtered(tcp)	((tcp)->flags & TCB_FILTERED)
 
 struct xlat {
 	int val;
@@ -553,6 +555,7 @@
 #ifdef HAVE_SIGINFO_T
 extern void printsiginfo(siginfo_t *, int);
 #endif
+extern const char *getfdpath(struct tcb *, int);
 extern void printfd(struct tcb *, int);
 extern void printsock(struct tcb *, long, int);
 extern void print_sock_optmgmt(struct tcb *, long, int);
@@ -574,6 +577,9 @@
 extern const char *sprint_open_modes(mode_t);
 extern int is_restart_error(struct tcb *);
 
+extern int pathtrace_select(const char *);
+extern int pathtrace_match(struct tcb *);
+
 extern int change_syscall(struct tcb *, int);
 extern int internal_fork(struct tcb *);
 extern int internal_exec(struct tcb *);
@@ -706,3 +712,5 @@
 #endif
 
 extern int not_failing_only;
+extern int show_fd_path;
+extern int tracing_paths;