2 * This file is part of ltrace.
3 * Copyright (C) 2012 Petr Machata, Red Hat Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 /* This file contains declarations and types for working with symbol
27 #include <sys/types.h>
32 enum filter_lib_matcher_type {
33 /* Match by soname. */
35 /* Match by path name. */
37 /* Match main binary. */
41 struct filter_lib_matcher {
42 enum filter_lib_matcher_type type;
46 enum filter_rule_type {
52 struct filter_rule *next;
53 struct filter_lib_matcher *lib_matcher;
54 regex_t symbol_re; /* Regex for matching symbol name. */
55 enum filter_rule_type type;
60 struct filter_rule *rules;
63 void filter_init(struct filter *filt);
64 void filter_destroy(struct filter *filt);
66 /* Both SYMBOL_RE and MATCHER are owned and destroyed by RULE. */
67 void filter_rule_init(struct filter_rule *rule, enum filter_rule_type type,
68 struct filter_lib_matcher *matcher,
71 void filter_rule_destroy(struct filter_rule *rule);
73 /* RULE is added to FILT and owned and destroyed by it. */
74 void filter_add_rule(struct filter *filt, struct filter_rule *rule);
76 /* Create a matcher that matches library name. RE is owned and
77 * destroyed by MATCHER. TYPE shall be FLM_SONAME or
79 void filter_lib_matcher_name_init(struct filter_lib_matcher *matcher,
80 enum filter_lib_matcher_type type,
83 /* Create a matcher that matches main binary. */
84 void filter_lib_matcher_main_init(struct filter_lib_matcher *matcher);
86 void filter_lib_matcher_destroy(struct filter_lib_matcher *matcher);
88 /* Ask whether FILTER might match a symbol in LIB. 0 if no, non-0 if
89 * yes. Note that positive answer doesn't mean that anything will
90 * actually be matched, just that potentially it could. */
91 int filter_matches_library(struct filter *filt, struct library *lib);
93 /* Ask whether FILTER matches this symbol. Returns 0 if it doesn't,
94 * or non-0 value if it does. */
95 int filter_matches_symbol(struct filter *filt, const char *sym_name,