aboutsummaryrefslogtreecommitdiff
path: root/filter.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 /filter.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 'filter.c')
-rw-r--r--filter.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/filter.c b/filter.c
index 74a158f..8aa5881 100644
--- a/filter.c
+++ b/filter.c
@@ -18,15 +18,13 @@
* 02110-1301 USA
*/
-#include <stddef.h>
+#include <stdlib.h>
#include <error.h>
#include <assert.h>
#include "filter.h"
#include "library.h"
-void abort(void); //xxx
-
void
filter_init(struct filter *filt)
{
@@ -71,10 +69,19 @@ filter_add_rule(struct filter *filt, struct filter_rule *rule)
void
filter_lib_matcher_name_init(struct filter_lib_matcher *matcher,
+ enum filter_lib_matcher_type type,
regex_t libname_re)
{
- matcher->type = FLM_NAME;
- matcher->libname_re = libname_re;
+ switch (type) {
+ case FLM_MAIN:
+ assert(type != type);
+ abort();
+
+ case FLM_SONAME:
+ case FLM_PATHNAME:
+ matcher->type = type;
+ matcher->libname_re = libname_re;
+ }
}
void
@@ -87,7 +94,8 @@ void
filter_lib_matcher_destroy(struct filter_lib_matcher *matcher)
{
switch (matcher->type) {
- case FLM_NAME:
+ case FLM_SONAME:
+ case FLM_PATHNAME:
regfree(&matcher->libname_re);
break;
case FLM_MAIN:
@@ -115,12 +123,14 @@ static int
matcher_matches_library(struct filter_lib_matcher *matcher, struct library *lib)
{
switch (matcher->type) {
- case FLM_NAME:
- return re_match_or_error(&matcher->libname_re, lib->name,
- "library name");
+ case FLM_SONAME:
+ return re_match_or_error(&matcher->libname_re, lib->soname,
+ "library soname");
+ case FLM_PATHNAME:
+ return re_match_or_error(&matcher->libname_re, lib->pathname,
+ "library pathname");
case FLM_MAIN:
- assert(!"FLM_MAIN not implemented yet!");
- abort();
+ return lib->next == NULL;
}
assert(matcher->type != matcher->type);
abort();