From 8752634a971265d54dfc29b112360633c2be5a76 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 18 Nov 2017 18:05:39 +0000 Subject: explictly skip compressed debug line To identify the line of backtrace with ease, show the offset address of library. You can just find the source filename and the line with `addr2line -e libruby.so.2.5.0 0xXXXX` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- addr2line.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addr2line.c') diff --git a/addr2line.c b/addr2line.c index b59623f5b3..13bf747655 100644 --- a/addr2line.c +++ b/addr2line.c @@ -13,6 +13,7 @@ #include "addr2line.h" #include +#include #include #ifdef USE_ELF @@ -486,6 +487,7 @@ fill_lines(int num_traces, void **traces, int check_debuglink, ElfW(Shdr) *dynsym_shdr = NULL, *dynstr_shdr = NULL; obj_info_t *obj = *objp; uintptr_t dladdr_fbase = 0; + bool compressed_p = false; fd = open(binary_filename, O_RDONLY); if (fd < 0) { @@ -555,6 +557,9 @@ fill_lines(int num_traces, void **traces, int check_debuglink, break; case SHT_PROGBITS: if (!strcmp(section_name, ".debug_line")) { + if (shdr[i].sh_flags & SHF_COMPRESSED) { + compressed_p = true; + } debug_line_shdr = shdr + i; } else if (!strcmp(section_name, ".gnu_debuglink")) { @@ -632,7 +637,8 @@ fill_lines(int num_traces, void **traces, int check_debuglink, goto finish; } - if (parse_debug_line(num_traces, traces, + if (!compressed_p && + parse_debug_line(num_traces, traces, file + debug_line_shdr->sh_offset, debug_line_shdr->sh_size, obj, lines, offset)) @@ -748,7 +754,7 @@ next_line: kprintf("[0x%lx]\n", addr); } else if (!line->saddr || !line->sname) { - kprintf("%s [0x%lx]\n", line->path, addr); + kprintf("%s(0x%lx) [0x%lx]\n", line->path, addr-line->base_addr, addr); } else if (line->line <= 0) { kprintf("%s(%s+0x%lx) [0x%lx]\n", line->path, line->sname, -- cgit v1.2.3