* filter_action.c (default_flags, clear_default_flags): Add default flags. (add_action): Clear default flags. (filter_syscall): Add default_flags to qual_flg. * strace.c (init): Remove default filters. --- filter_action.c | 21 +++++++++++++++++++++ strace.c | 3 --- 2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/filter_action.c b/filter_action.c index bb1dda7..1879ede 100644 --- a/filter_action.c +++ b/filter_action.c @@ -86,6 +86,7 @@ struct filter_action { void* _priv_data; }; +static int default_flags = DEFAULT_QUAL_FLAGS; static struct filter_action *filter_actions; static unsigned int nfilter_actions; @@ -109,6 +110,8 @@ compare_action_priority(const void *a, const void *b) void filtering_parsing_finish(void) { + if (nfilter_actions == 0) + return; qsort(filter_actions, nfilter_actions, sizeof(struct filter_action), &compare_action_priority); /* Allocate variables_buf sufficient for any action */ @@ -120,6 +123,22 @@ filtering_parsing_finish(void) } variables_buf = xcalloc(maxfilters, sizeof(bool)); } +static void +clear_default_flags(const char *name) +{ + if ((default_flags & QUAL_TRACE) && !strcmp(name, "trace")) { + default_flags &= ~QUAL_TRACE; + return; + } else if ((default_flags & QUAL_ABBREV) && !strcmp(name, "abbrev")) { + default_flags &= ~QUAL_ABBREV; + return; + } else if ((default_flags & QUAL_VERBOSE) && !strcmp(name, "verbose")) { + default_flags &= ~QUAL_VERBOSE; + return; + } + +} + static const struct filter_action_type * lookup_filter_action_type(const char *str) @@ -136,6 +155,7 @@ lookup_filter_action_type(const char *str) static struct filter_action * add_action(const struct filter_action_type *type) { + clear_default_flags(type->name); filter_actions = xreallocarray(filter_actions, ++nfilter_actions, sizeof(struct filter_action)); struct filter_action *action = &filter_actions[nfilter_actions - 1]; @@ -193,6 +213,7 @@ set_qualify_mode(struct filter_action *action) void filter_syscall(struct tcb *tcp) { + tcp->qual_flg |= default_flags; unsigned int i; for (i = 0; i < nfilter_actions; ++i) { run_filter_action(tcp, &filter_actions[i]); diff --git a/strace.c b/strace.c index f634d40..75a3dab 100644 --- a/strace.c +++ b/strace.c @@ -1637,9 +1637,6 @@ init(int argc, char *argv[]) shared_log = stderr; set_sortby(DEFAULT_SORTBY); set_personality(DEFAULT_PERSONALITY); - parse_qualify_filter("trace=all"); - parse_qualify_filter("abbrev=all"); - parse_qualify_filter("verbose=all"); #if DEFAULT_QUAL_FLAGS != (QUAL_TRACE | QUAL_ABBREV | QUAL_VERBOSE) # error Bug in DEFAULT_QUAL_FLAGS #endif -- 2.1.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel