summaryrefslogtreecommitdiffstats
path: root/dwarf_wrappers.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dwarf_wrappers.cxx')
-rw-r--r--dwarf_wrappers.cxx39
1 files changed, 35 insertions, 4 deletions
diff --git a/dwarf_wrappers.cxx b/dwarf_wrappers.cxx
index d7183dc3..0cb3cc0f 100644
--- a/dwarf_wrappers.cxx
+++ b/dwarf_wrappers.cxx
@@ -47,15 +47,46 @@ void dwfl_assert(const std::string& desc, bool condition)
}
-// Helper for dealing with selected portions of libdwfl in a more readable
-// fashion, and with specific cleanup / checking / logging options.
+#if !_ELFUTILS_PREREQ(0, 143)
+// Elfutils prior to 0.143 didn't use attr_integrate when looking up the
+// decl_file or decl_line, so the attributes would sometimes be missed. For
+// those old versions, we define custom implementations to do the integration.
const char *
-dwarf_diename_integrate (Dwarf_Die *die)
+dwarf_decl_file_integrate (Dwarf_Die *die)
{
Dwarf_Attribute attr_mem;
- return dwarf_formstring (dwarf_attr_integrate (die, DW_AT_name, &attr_mem));
+ Dwarf_Sword idx = 0;
+ if (dwarf_formsdata (dwarf_attr_integrate (die, DW_AT_decl_file, &attr_mem),
+ &idx) != 0
+ || idx == 0)
+ return NULL;
+
+ Dwarf_Die cudie;
+ Dwarf_Files *files = NULL;
+ if (dwarf_getsrcfiles (dwarf_diecu (die, &cudie, NULL, NULL),
+ &files, NULL) != 0)
+ return NULL;
+
+ return dwarf_filesrc(files, idx, NULL, NULL);
}
+int
+dwarf_decl_line_integrate (Dwarf_Die *die, int *linep)
+{
+ Dwarf_Attribute attr_mem;
+ Dwarf_Sword line;
+
+ int res = dwarf_formsdata (dwarf_attr_integrate
+ (die, DW_AT_decl_line, &attr_mem),
+ &line);
+ if (res == 0)
+ *linep = line;
+
+ return res;
+}
+
+#endif // !_ELFUTILS_PREREQ(0, 143)
+
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */