addr2line: Always prefer linkage_name over plain names
Signed-off-by: Josh Stone <jistone@redhat.com>
diff --git a/src/ChangeLog b/src/ChangeLog
index 413a6bf..12b7e7f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
2014-12-10 Josh Stone <jistone@redhat.com>
+ * addr2line.c (get_diename): New, get linkage_name or name.
+ * addr2line.c (print_dwarf_function): Use get_diename.
+ * addr2line.c (handle_address): Likewise.
+ * addr2line.c (print_diesym): Removed.
+
+2014-12-10 Josh Stone <jistone@redhat.com>
+
* addr2line.c (handle_address): Find the proper inline parents.
2014-12-07 Mark Wielaard <mjw@redhat.com>
diff --git a/src/addr2line.c b/src/addr2line.c
index e8ffbc6..de80294 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -258,6 +258,23 @@
}
+static const char *
+get_diename (Dwarf_Die *die)
+{
+ Dwarf_Attribute attr;
+ const char *name;
+
+ name = dwarf_formstring (dwarf_attr_integrate (die, DW_AT_MIPS_linkage_name,
+ &attr)
+ ?: dwarf_attr_integrate (die, DW_AT_linkage_name,
+ &attr));
+
+ if (name == NULL)
+ name = dwarf_diename (die) ?: "??";
+
+ return name;
+}
+
static bool
print_dwarf_function (Dwfl_Module *mod, Dwarf_Addr addr)
{
@@ -274,7 +291,7 @@
{
case DW_TAG_subprogram:
{
- const char *name = dwarf_diename (&scopes[i]);
+ const char *name = get_diename (&scopes[i]);
if (name == NULL)
return false;
puts (name);
@@ -283,7 +300,7 @@
case DW_TAG_inlined_subroutine:
{
- const char *name = dwarf_diename (&scopes[i]);
+ const char *name = get_diename (&scopes[i]);
if (name == NULL)
return false;
printf ("%s inlined", name);
@@ -395,23 +412,6 @@
}
}
-static void
-print_diesym (Dwarf_Die *die)
-{
- Dwarf_Attribute attr;
- const char *name;
-
- name = dwarf_formstring (dwarf_attr_integrate (die, DW_AT_MIPS_linkage_name,
- &attr)
- ?: dwarf_attr_integrate (die, DW_AT_linkage_name,
- &attr));
-
- if (name == NULL)
- name = dwarf_diename (die) ?: "??";
-
- puts (name);
-}
-
static int
see_one_module (Dwfl_Module *mod,
void **userdata __attribute__ ((unused)),
@@ -684,7 +684,7 @@
|| tag == DW_TAG_entry_point
|| tag == DW_TAG_subprogram)
{
- print_diesym (parent);
+ puts (get_diename (parent));
break;
}
}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index c22ed8a..9d229c9 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-10 Josh Stone <jistone@redhat.com>
+
+ * run-addr2line-i-test.sh: Test 0x5f0 to make sure linkage_name is
+ preferred over the plain die name.
+
2014-12-02 Petr Machata <pmachata@redhat.com>
* dwarf-getmacros.c (mac): Skip over DW_MACINFO_undef,
diff --git a/tests/run-addr2line-i-test.sh b/tests/run-addr2line-i-test.sh
index e98adda..183916c 100755
--- a/tests/run-addr2line-i-test.sh
+++ b/tests/run-addr2line-i-test.sh
@@ -103,7 +103,7 @@
EOF
# All together now (plus function names).
-testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f1 0x00000000000005f2 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
foobar
/tmp/x.cpp:5
foobar
@@ -132,6 +132,8 @@
/tmp/x.cpp:20
_Z3foov
/tmp/x.cpp:26
+_Z2fuv
+/tmp/x.cpp:31
fubar inlined at /tmp/x.cpp:32 in _Z2fuv
/tmp/x.cpp:10
_Z2fuv