aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/perf/util/dwarf-aux.h
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2023-11-09 15:59:26 -0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-11-10 09:04:12 -0300
commit3f5928e461e394d27bc1ed7d0785b1e63c43d6a1 (patch)
tree4eea36c6b045a2cf6b64bc4feb962eae9dd47d37 /tools/perf/util/dwarf-aux.h
parentperf dwarf-aux: Add die_get_scopes() alternative to dwarf_getscopes() (diff)
downloadwireguard-linux-3f5928e461e394d27bc1ed7d0785b1e63c43d6a1.tar.xz
wireguard-linux-3f5928e461e394d27bc1ed7d0785b1e63c43d6a1.zip
perf dwarf-aux: Add die_find_variable_by_reg() helper
The die_find_variable_by_reg() will search for a variable or a parameter sub-DIE in the given scope DIE where the location matches to the given register. For the simplest and most common case, memory access usually happens with a base register and an offset to the field so the register holds a pointer in a variable or function parameter. Then we can find one if it has a location expression at the (instruction) address. This function only handles such a simple case for now. In this case, the expression has a DW_OP_regN operation where N < 32. If the register index (N) is greater than or equal to 32, DW_OP_regx operation with an operand which saves the value for the N would be used. It rejects expressions with more operations. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: linux-toolchains@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Link: https://lore.kernel.org/r/20231110000012.3538610-8-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/dwarf-aux.h')
-rw-r--r--tools/perf/util/dwarf-aux.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/perf/util/dwarf-aux.h b/tools/perf/util/dwarf-aux.h
index f9d765f80fb0..b6f430730bd1 100644
--- a/tools/perf/util/dwarf-aux.h
+++ b/tools/perf/util/dwarf-aux.h
@@ -137,6 +137,10 @@ int die_get_scopes(Dwarf_Die *cu_die, Dwarf_Addr pc, Dwarf_Die **scopes);
/* Get byte offset range of given variable DIE */
int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf);
+/* Find a variable saved in the 'reg' at given address */
+Dwarf_Die *die_find_variable_by_reg(Dwarf_Die *sc_die, Dwarf_Addr pc, int reg,
+ Dwarf_Die *die_mem);
+
#else /* HAVE_DWARF_GETLOCATIONS_SUPPORT */
static inline int die_get_var_range(Dwarf_Die *sp_die __maybe_unused,
@@ -146,6 +150,14 @@ static inline int die_get_var_range(Dwarf_Die *sp_die __maybe_unused,
return -ENOTSUP;
}
+static inline Dwarf_Die *die_find_variable_by_reg(Dwarf_Die *sc_die __maybe_unused,
+ Dwarf_Addr pc __maybe_unused,
+ int reg __maybe_unused,
+ Dwarf_Die *die_mem __maybe_unused)
+{
+ return NULL;
+}
+
#endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT */
#endif /* _DWARF_AUX_H */