From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 4/5] tools lib traceevent: Let function symbols be used in operations
Date: Wed, 08 Jul 2020 16:28:54 -0400 [thread overview]
Message-ID: <20200708203017.319177062@goodmis.org> (raw)
In-Reply-To: 20200708202850.764168067@goodmis.org
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
The preemptirq events records only 32 bits for the locations of where the
events occur. It records the offset from _stext to do so. But the
libtraceevent does not handle function names in operations to add offsets
to.
Have the eval_num_arg() check if the value found is zero and then check if
it is a string. If it is a string value, check if that string matches any
function. If it does, then evaluate the function symbol and replace the
value with the actual number to complete the calculation.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=205953
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
lib/traceevent/event-parse.c | 49 +++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index ee16be96697b..77c3249220d3 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -3649,6 +3649,50 @@ tep_find_event_by_name(struct tep_handle *tep,
return event;
}
+static unsigned long long test_for_symbol(struct tep_handle *tep,
+ struct tep_print_arg *arg)
+{
+ unsigned long long val = 0;
+ struct func_list *item = tep->funclist;
+ char *func;
+ int i;
+
+ if (isdigit(arg->atom.atom[0]))
+ return 0;
+
+ /* Linear search but only happens once (see after the loop) */
+ for (i = 0; i < (int)tep->func_count; i++) {
+ unsigned long long addr;
+ const char *name;
+
+ if (tep->func_map) {
+ addr = tep->func_map[i].addr;
+ name = tep->func_map[i].func;
+ } else if (item) {
+ addr = item->addr;
+ name = item->func;
+ item = item->next;
+ } else
+ break;
+
+ if (strcmp(arg->atom.atom, name) == 0) {
+ val = addr;
+ break;
+ }
+ }
+
+ /*
+ * This modifies the arg to hardcode the value
+ * and will not loop again.
+ */
+ func = realloc(arg->atom.atom, 32);
+ if (func) {
+ snprintf(func, 32, "%lld", val);
+ arg->atom.atom = func;
+ }
+ return val;
+}
+
static unsigned long long
eval_num_arg(void *data, int size, struct tep_event *event, struct tep_print_arg *arg)
{
@@ -3665,7 +3709,10 @@ eval_num_arg(void *data, int size, struct tep_event *event, struct tep_print_arg
/* ?? */
return 0;
case TEP_PRINT_ATOM:
- return strtoull(arg->atom.atom, NULL, 0);
+ val = strtoull(arg->atom.atom, NULL, 0);
+ if (!val)
+ val = test_for_symbol(tep, arg);
+ return val;
case TEP_PRINT_FIELD:
if (!arg->field.field) {
arg->field.field = tep_find_any_field(event, arg->field.name);
--
2.26.2
next prev parent reply other threads:[~2020-07-08 20:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-08 20:28 [PATCH 0/5] trace-cmd: Triaging bugzillas and fixes Steven Rostedt
2020-07-08 20:28 ` [PATCH 1/5] trace-cmd: Fix trace-cmd report -t to show full timestamp Steven Rostedt
2020-07-08 20:28 ` [PATCH 2/5] tools lib traceveent: Fix kbuffer_start_of_data() to return the first record Steven Rostedt
2020-07-08 20:28 ` [PATCH 3/5] trace-cmd: Explicitly state what trace-cmd report -f does Steven Rostedt
2020-07-08 20:28 ` Steven Rostedt [this message]
2020-07-08 20:28 ` [PATCH 5/5] trace-cmd: Print raw hex for flags when trace-cmd report -R Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200708203017.319177062@goodmis.org \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).