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
This commit is contained in:
naruse 2017-11-18 18:05:39 +00:00
parent 5fd6558502
commit 8752634a97

View File

@ -13,6 +13,7 @@
#include "addr2line.h" #include "addr2line.h"
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#include <errno.h> #include <errno.h>
#ifdef USE_ELF #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; ElfW(Shdr) *dynsym_shdr = NULL, *dynstr_shdr = NULL;
obj_info_t *obj = *objp; obj_info_t *obj = *objp;
uintptr_t dladdr_fbase = 0; uintptr_t dladdr_fbase = 0;
bool compressed_p = false;
fd = open(binary_filename, O_RDONLY); fd = open(binary_filename, O_RDONLY);
if (fd < 0) { if (fd < 0) {
@ -555,6 +557,9 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
break; break;
case SHT_PROGBITS: case SHT_PROGBITS:
if (!strcmp(section_name, ".debug_line")) { if (!strcmp(section_name, ".debug_line")) {
if (shdr[i].sh_flags & SHF_COMPRESSED) {
compressed_p = true;
}
debug_line_shdr = shdr + i; debug_line_shdr = shdr + i;
} }
else if (!strcmp(section_name, ".gnu_debuglink")) { else if (!strcmp(section_name, ".gnu_debuglink")) {
@ -632,7 +637,8 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
goto finish; goto finish;
} }
if (parse_debug_line(num_traces, traces, if (!compressed_p &&
parse_debug_line(num_traces, traces,
file + debug_line_shdr->sh_offset, file + debug_line_shdr->sh_offset,
debug_line_shdr->sh_size, debug_line_shdr->sh_size,
obj, lines, offset)) obj, lines, offset))
@ -748,7 +754,7 @@ next_line:
kprintf("[0x%lx]\n", addr); kprintf("[0x%lx]\n", addr);
} }
else if (!line->saddr || !line->sname) { 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) { else if (line->line <= 0) {
kprintf("%s(%s+0x%lx) [0x%lx]\n", line->path, line->sname, kprintf("%s(%s+0x%lx) [0x%lx]\n", line->path, line->sname,