From: Denys Vlasenko Date: Tue, 5 Mar 2013 15:01:53 +0000 (+0100) Subject: Remove variable tracing_paths and check in pathtrace_match X-Git-Tag: v4.8~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38cfe7c92328e940c71074c9b579b5bf9f2cb2f6;p=strace Remove variable tracing_paths and check in pathtrace_match Signed-off-by: Denys Vlasenko --- diff --git a/defs.h b/defs.h index 1d607c70..ca5d0883 100644 --- 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; diff --git a/pathtrace.c b/pathtrace.c index 19110348..95643c67 100644 --- a/pathtrace.c +++ b/pathtrace.c @@ -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))) diff --git a/strace.c b/strace.c index 9ec354da..0440832f 100644 --- 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':