aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-11-15 14:29:58 -0500
committerSteven Rostedt <rostedt@goodmis.org>2011-11-15 14:29:58 -0500
commitd012896cecf1fd498aa4af2f43c567af4795254d (patch)
tree6e3cbdfc6edb07e87a24f099ccf46f7fcbac64d4
parent4e8a9729cd528bb8f41ce0e3dfe70050866bc208 (diff)
parse-event: 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>
-rw-r--r--parse-filter.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/parse-filter.c b/parse-filter.c
index fce0694..bc62f1f 100644
--- a/parse-filter.c
+++ b/parse-filter.c
@@ -1711,18 +1711,43 @@ static int test_num(struct event_format *event,
1711 1711
1712static const char *get_field_str(struct filter_arg *arg, struct record *record) 1712static const char *get_field_str(struct filter_arg *arg, struct record *record)
1713{ 1713{
1714 const char *val = record->data + arg->str.field->offset; 1714 struct event_format *event;
1715 struct pevent *pevent;
1716 unsigned long long addr;
1717 const char *val = NULL;
1718 char hex[64];
1715 1719
1716 /* 1720 /* If the field is not a string convert it */
1717 * We need to copy the data since we can't be sure the field 1721 if (arg->str.field->flags & FIELD_IS_STRING) {
1718 * is null terminated. 1722 val = record->data + arg->str.field->offset;
1719 */ 1723
1720 if (*(val + arg->str.field->size - 1)) { 1724 /*
1721 /* copy it */ 1725 * We need to copy the data since we can't be sure the field
1722 memcpy(arg->str.buffer, val, arg->str.field->size); 1726 * is null terminated.
1723 /* the buffer is already NULL terminated */ 1727 */
1724 val = arg->str.buffer; 1728 if (*(val + arg->str.field->size - 1)) {
1729 /* copy it */
1730 memcpy(arg->str.buffer, val, arg->str.field->size);
1731 /* the buffer is already NULL terminated */
1732 val = arg->str.buffer;
1733 }
1734
1735 } else {
1736 event = arg->str.field->event;
1737 pevent = event->pevent;
1738 addr = get_value(event, arg->str.field, record);
1739
1740 if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG))
1741 /* convert to a kernel symbol */
1742 val = pevent_find_function(pevent, addr);
1743
1744 if (val == NULL) {
1745 /* just use the hex of the string name */
1746 snprintf(hex, 64, "0x%llx", addr);
1747 val = hex;
1748 }
1725 } 1749 }
1750
1726 return val; 1751 return val;
1727} 1752}
1728 1753