From 5dcfaa8aa10532d1ac0f1ceef6826345f2883fe6 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 1 Dec 2015 15:28:08 +0100 Subject: [PATCH] Use main ELF file path if there is no separate debugfile in error messages. * dwflpp.cxx (dwflpp::die_location_as_string): Use main ELF file if there is no debugfile to show the file path that the DIE came from. --- dwflpp.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dwflpp.cxx b/dwflpp.cxx index 7848083b9..93104245f 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -3110,16 +3110,22 @@ dwflpp::die_location_as_string(Dwarf_Addr pc, Dwarf_Die *die) locstr += lex_cast_hex(dwarf_dieoffset(die)); /* DWARF file */ - const char *debugfile; + const char *mainfile, *debugfile; locstr += _(" from "); - if (dwfl_module_info (module, NULL, NULL, NULL, NULL, NULL, NULL, - &debugfile) == NULL || debugfile == NULL) + if (dwfl_module_info (module, NULL, NULL, NULL, NULL, NULL, &mainfile, + &debugfile) == NULL + || (mainfile == NULL && debugfile == NULL)) { locstr += _("unknown debug file for "); locstr += module_name; } else - locstr += debugfile; + { + if (debugfile != NULL) + locstr += debugfile; + else + locstr += mainfile; + } return locstr; } -- 2.43.5