Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146107
b: refs/heads/master
c: e8808c1
h: refs/heads/master
i:
  146105: c422ee2
  146103: b28e5c7
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed May 7, 2009
1 parent e58bc28 commit 782d18e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8ae79a138e88aceeeb07077bff2883245fb7c218
refs/heads/master: e8808c1019b048a43686dbd25c188a035842c2e2
44 changes: 41 additions & 3 deletions trunk/kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static int filter_pred_or(struct filter_pred *pred __attribute((unused)),
return val1 || val2;
}

/* Filter predicate for fixed sized arrays of characters */
static int filter_pred_string(struct filter_pred *pred, void *event,
int val1, int val2)
{
Expand All @@ -164,6 +165,30 @@ static int filter_pred_string(struct filter_pred *pred, void *event,
return match;
}

/*
* Filter predicate for dynamic sized arrays of characters.
* These are implemented through a list of strings at the end
* of the entry.
* Also each of these strings have a field in the entry which
* contains its offset from the beginning of the entry.
* We have then first to get this field, dereference it
* and add it to the address of the entry, and at last we have
* the address of the string.
*/
static int filter_pred_strloc(struct filter_pred *pred, void *event,
int val1, int val2)
{
int str_loc = *(int *)(event + pred->offset);
char *addr = (char *)(event + str_loc);
int cmp, match;

cmp = strncmp(addr, pred->str_val, pred->str_len);

match = (!cmp) ^ pred->not;

return match;
}

static int filter_pred_none(struct filter_pred *pred, void *event,
int val1, int val2)
{
Expand Down Expand Up @@ -446,10 +471,18 @@ static int filter_add_pred_fn(struct filter_parse_state *ps,
return 0;
}

enum {
FILTER_STATIC_STRING = 1,
FILTER_DYN_STRING
};

static int is_string_field(const char *type)
{
if (strchr(type, '[') && strstr(type, "char"))
return 1;
return FILTER_STATIC_STRING;

if (!strcmp(type, "__str_loc"))
return FILTER_DYN_STRING;

return 0;
}
Expand Down Expand Up @@ -512,6 +545,7 @@ static int filter_add_pred(struct filter_parse_state *ps,
struct ftrace_event_field *field;
filter_pred_fn_t fn;
unsigned long long val;
int string_type;

pred->fn = filter_pred_none;

Expand All @@ -536,8 +570,12 @@ static int filter_add_pred(struct filter_parse_state *ps,
return -EINVAL;
}

if (is_string_field(field->type)) {
fn = filter_pred_string;
string_type = is_string_field(field->type);
if (string_type) {
if (string_type == FILTER_STATIC_STRING)
fn = filter_pred_string;
else
fn = filter_pred_strloc;
pred->str_len = field->size;
if (pred->op == OP_NE)
pred->not = 1;
Expand Down

0 comments on commit 782d18e

Please sign in to comment.