diff options
author | Steven Rostedt <srostedt@redhat.com> | 2012-05-22 01:45:21 -0400 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2012-07-04 00:40:30 -0400 |
commit | e84c282b40251f314c429f39b044785e323f2648 (patch) | |
tree | b9211cae3213ad8b1d771363068ab3eda5ac3dc0 /tools/lib | |
parent | 17d7a1123f0f6d532830152564cc812cc73db2f3 (diff) |
tools lib traceevent: Let filtering numbers by string use function names
As a pointer can be converted into a function name, let the filters
work with the function name as well as with the pointer number. If
the comparison expects a string, then convert numbers into functions,
but only when the number is the same size as a long.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-oxsa1qkr2eq7u8d7r0aapedu@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/traceevent/parse-filter.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index dfcfe2c131de..80d872a81f26 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c | |||
@@ -1710,18 +1710,43 @@ static int test_num(struct event_format *event, | |||
1710 | 1710 | ||
1711 | static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record) | 1711 | static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record) |
1712 | { | 1712 | { |
1713 | const char *val = record->data + arg->str.field->offset; | 1713 | struct event_format *event; |
1714 | struct pevent *pevent; | ||
1715 | unsigned long long addr; | ||
1716 | const char *val = NULL; | ||
1717 | char hex[64]; | ||
1714 | 1718 | ||
1715 | /* | 1719 | /* If the field is not a string convert it */ |
1716 | * We need to copy the data since we can't be sure the field | 1720 | if (arg->str.field->flags & FIELD_IS_STRING) { |
1717 | * is null terminated. | 1721 | val = record->data + arg->str.field->offset; |
1718 | */ | 1722 | |
1719 | if (*(val + arg->str.field->size - 1)) { | 1723 | /* |
1720 | /* copy it */ | 1724 | * We need to copy the data since we can't be sure the field |
1721 | memcpy(arg->str.buffer, val, arg->str.field->size); | 1725 | * is null terminated. |
1722 | /* the buffer is already NULL terminated */ | 1726 | */ |
1723 | val = arg->str.buffer; | 1727 | if (*(val + arg->str.field->size - 1)) { |
1728 | /* copy it */ | ||
1729 | memcpy(arg->str.buffer, val, arg->str.field->size); | ||
1730 | /* the buffer is already NULL terminated */ | ||
1731 | val = arg->str.buffer; | ||
1732 | } | ||
1733 | |||
1734 | } else { | ||
1735 | event = arg->str.field->event; | ||
1736 | pevent = event->pevent; | ||
1737 | addr = get_value(event, arg->str.field, record); | ||
1738 | |||
1739 | if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG)) | ||
1740 | /* convert to a kernel symbol */ | ||
1741 | val = pevent_find_function(pevent, addr); | ||
1742 | |||
1743 | if (val == NULL) { | ||
1744 | /* just use the hex of the string name */ | ||
1745 | snprintf(hex, 64, "0x%llx", addr); | ||
1746 | val = hex; | ||
1747 | } | ||
1724 | } | 1748 | } |
1749 | |||
1725 | return val; | 1750 | return val; |
1726 | } | 1751 | } |
1727 | 1752 | ||