[PATCH 05/12] perf, tools, probe: Print location for resolved variables
From: Andi Kleen
Date: Mon Nov 27 2017 - 19:26:24 EST
From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Print the location, e.g. the register, for resolved variables
with perf probe -V. This is useful for debugging, and manually
making sense of disassembly. I also have some scripts
which can make use of this information.
Before:
% perf probe -x ./tsrc/tstruct -V main+20
Available variables at main+20
@<main+20>
struct str* xp
After:
% perf probe -x ./tsrc/tstruct -V main+20
Available variables at main+20
@<main+20>
struct str* xp %ax
Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
---
tools/perf/util/probe-finder.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 0149428d453e..699f29d8a28e 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1369,6 +1369,7 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data)
if (tag == DW_TAG_formal_parameter ||
tag == DW_TAG_variable) {
struct probe_trace_arg ta;
+ struct probe_trace_arg_ref *ref;
memset(&ta, 0, sizeof(struct probe_trace_arg));
ret = convert_variable_location(die_mem, af->pf.addr,
@@ -1401,6 +1402,10 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data)
die_mem, &buf);
}
+ strbuf_addf(&buf, "\t%s", ta.value);
+ for (ref = ta.ref; ref; ref = ref->next)
+ strbuf_addf(&buf, " off %ld", ref->offset);
+
pr_debug("Add new var: %s\n", buf.buf);
if (ret2 == 0) {
struct str_node *sn;
--
2.13.6