[PATCH RFC 2/3] dwarf_loader: Add name to inline expansion

Thierry Treyer via B4 Relay
2025-04-16T19:21:07Z

From: Thierry Treyer <ttreyer@meta.com>

Add the name field to inline expansion. It contains the name of the
abstract origin. The name can be used to locate the origin function in
the BTF.

Surely there's a better way to find the btf_id of the original function?

Signed-off-by: Thierry Treyer <ttreyer@meta.com>
---
dwarf_loader.c | 9 +++++++++
dwarves.h | 1 +
2 files changed, 10 insertions(+)

diff --git a/dwarf_loader.c b/dwarf_loader.c
index 24ac9afceb3793c165d3e92cfdfaf27ab67fd4d6..d7a130d138a65bad71a563cf3d629bdd7b9e6c6f 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -1376,6 +1376,15 @@ static struct inline_expansion *inline_expansion__new(Dwarf_Die *die, struct cu
dtag->decl_file = attr_string(die, DW_AT_call_file, conf);
dtag->decl_line = attr_numeric(die, DW_AT_call_line);
dwarf_tag__set_attr_type(dtag, type, die, DW_AT_abstract_origin);
+
+ Dwarf_Attribute attr_orig;
+ if (dwarf_attr(die, DW_AT_abstract_origin, &attr_orig)) {
+ Dwarf_Die die_orig;
+ if (dwarf_formref_die(&attr_orig, &die_orig)) {
+ exp->name = attr_string(&die_orig, DW_AT_name, conf);
+ }
+ }
+
exp->ip.addr = 0;
exp->high_pc = 0;
exp->nr_parms = 0;
diff --git a/dwarves.h b/dwarves.h
index 38efd6a6e2b0b0e5a571a8d12bbec33502509d8b..13b19433fe4aa7cd54ec0160c7008a33cbc17e24 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -809,6 +809,7 @@ struct ip_tag {

struct inline_expansion {
struct ip_tag ip;
+ const char *name;
size_t size;
uint64_t high_pc;
struct list_head parms;

--
2.47.1