aboutsummaryrefslogtreecommitdiff
path: root/options.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-04-02 00:38:46 +0200
committerPetr Machata <pmachata@redhat.com>2012-04-19 01:35:45 +0200
commit0b55b5852b9fe2ed6cceada004db303fe6efe6ce (patch)
tree44ce3b110eed888cfa1250bc7ff294d65e45ff0f /options.c
parente0973cbbd208c84d9646481c33a2ebb511d68381 (diff)
downloadltrace-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.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/options.c b/options.c
index 4f026ea..193b650 100644
--- a/options.c
+++ b/options.c
@@ -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);