]> granicus.if.org Git - strace/commitdiff
Remove variable tracing_paths and check in pathtrace_match
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 5 Mar 2013 15:01:53 +0000 (16:01 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 5 Mar 2013 15:01:53 +0000 (16:01 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
defs.h
pathtrace.c
strace.c

diff --git a/defs.h b/defs.h
index 1d607c709de9554c14f62b95b414d5c10d64fc8a..ca5d0883f4a1b594bbe6b2df76c4ad7a7b1cf4b6 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -523,7 +523,9 @@ extern bool Tflag;
 extern bool qflag;
 extern bool not_failing_only;
 extern bool show_fd_path;
-extern bool tracing_paths;
+/* are we filtering traces based on paths? */
+extern const char **paths_selected;
+#define tracing_paths (paths_selected != NULL)
 extern bool need_fork_exec_workarounds;
 extern unsigned xflag;
 extern unsigned followfork;
index 19110348b68875029a2f087b93e2a4a62bd503b0..95643c673ae8ab2526b0d08fe4de915833aa95eb 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "syscall.h"
 
-static const char **selected = NULL; /* paths selected for tracing */
+const char **paths_selected = NULL;
 static unsigned num_selected = 0;
 
 /*
@@ -49,7 +49,7 @@ pathmatch(const char *path)
        unsigned i;
 
        for (i = 0; i < num_selected; ++i) {
-               if (strcmp(path, selected[i]) == 0)
+               if (strcmp(path, paths_selected[i]) == 0)
                        return 1;
        }
        return 0;
@@ -91,10 +91,10 @@ storepath(const char *path)
                return; /* already in table */
 
        i = num_selected++;
-       selected = realloc(selected, num_selected * sizeof(selected[0]));
-       if (!selected)
+       paths_selected = realloc(paths_selected, num_selected * sizeof(paths_selected[0]));
+       if (!paths_selected)
                die_out_of_memory();
-       selected[i] = path;
+       paths_selected[i] = path;
 }
 
 /*
@@ -154,9 +154,6 @@ pathtrace_match(struct tcb *tcp)
 {
        const struct_sysent *s;
 
-       if (!selected)
-               return 1;
-
        s = tcp->s_ent;
 
        if (!(s->sys_flags & (TRACE_FILE | TRACE_DESC)))
index 9ec354dab65580c005865cbd518b0ea8b72b2fb9..0440832f0cfb127e7b010e434fa912f97f917d35 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -123,9 +123,6 @@ bool not_failing_only = 0;
 /* Show path associated with fd arguments */
 bool show_fd_path = 0;
 
-/* are we filtering traces based on paths? */
-bool tracing_paths = 0;
-
 static bool detach_on_execve = 0;
 static bool skip_startup_execve = 0;
 
@@ -1648,7 +1645,6 @@ init(int argc, char *argv[])
                        process_opt_p_list(optarg);
                        break;
                case 'P':
-                       tracing_paths = 1;
                        pathtrace_select(optarg);
                        break;
                case 's':