diff options
author | Petr Machata <pmachata@redhat.com> | 2012-04-02 00:38:46 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-04-19 01:35:45 +0200 |
commit | 0b55b5852b9fe2ed6cceada004db303fe6efe6ce (patch) | |
tree | 44ce3b110eed888cfa1250bc7ff294d65e45ff0f /options.c | |
parent | e0973cbbd208c84d9646481c33a2ebb511d68381 (diff) | |
download | ltrace-0b55b5852b9fe2ed6cceada004db303fe6efe6ce.tar.gz |
Implement @MAIN, @/path/name -e selectors, make former default for now
- the default might become "*" in future, but keep things more or less
the same as they always were for now
Diffstat (limited to 'options.c')
-rw-r--r-- | options.c | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -207,18 +207,26 @@ add_filter_rule(struct filter *filt, const char *expr, goto fail; } - regex_t lib_re; - status = (lib_re_p ? regcomp : globcomp)(&lib_re, lib, 0); - if (status != 0) { - char buf[100]; - regerror(status, &lib_re, buf, sizeof buf); - error(0, 0, "rule near '%s' will be ignored: %s", expr, buf); - - regfree(&symbol_re); - goto fail; + if (strcmp(lib, "MAIN") == 0) { + filter_lib_matcher_main_init(matcher); + } else { + enum filter_lib_matcher_type type + = lib[0] == '/' ? FLM_PATHNAME : FLM_SONAME; + + regex_t lib_re; + status = (lib_re_p ? regcomp : globcomp)(&lib_re, lib, 0); + if (status != 0) { + char buf[100]; + regerror(status, &lib_re, buf, sizeof buf); + error(0, 0, "rule near '%s' will be ignored: %s", + expr, buf); + + regfree(&symbol_re); + goto fail; + } + filter_lib_matcher_name_init(matcher, type, lib_re); } - filter_lib_matcher_name_init(matcher, lib_re); filter_rule_init(rule, type, matcher, symbol_re); filter_add_rule(filt, rule); } @@ -628,8 +636,11 @@ process_options(int argc, char **argv) { opt_F = egg; } + /* Set default filter. Use @MAIN for now, as that's what + * ltrace used to have in the past. XXX Maybe we should make + * this "*" instead. */ if (options.filter == NULL) - parse_filter_chain(&options, "*"); + parse_filter_chain(&options, "@MAIN"); if (!opt_p && argc < 1) { fprintf(stderr, "%s: too few arguments\n", progname); |