From 10b8b85018a68155b9aab67a85779ba4d1cfcdd8 Mon Sep 17 00:00:00 2001 From: emaste Date: Tue, 22 Sep 2015 16:51:40 +0000 Subject: [PATCH] addr2line: skip CUs lacking debug info instead of bailing out Some binaries (such as the FreeBSD kernel) contain a mixture of CUs with and without debug information. Previously translate() exited upon encountering a CU without debug information. Instead, just move on to the next CU. Reported by: royger Reviewed by: royger Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3712 --- contrib/elftoolchain/addr2line/addr2line.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/elftoolchain/addr2line/addr2line.c b/contrib/elftoolchain/addr2line/addr2line.c index cfdcc745f9fb..86e728229075 100644 --- a/contrib/elftoolchain/addr2line/addr2line.c +++ b/contrib/elftoolchain/addr2line/addr2line.c @@ -248,7 +248,13 @@ translate(Dwarf_Debug dbg, const char* addrstr) continue; } - if (dwarf_srclines(die, &lbuf, &lcount, &de) != DW_DLV_OK) { + switch (dwarf_srclines(die, &lbuf, &lcount, &de)) { + case DW_DLV_OK: + break; + case DW_DLV_NO_ENTRY: + /* If one CU lacks debug info, just skip it. */ + continue; + default: warnx("dwarf_srclines: %s", dwarf_errmsg(de)); goto out; }