* addr2line.c (fill_lines): compare the file names of object in which

symbols exist. [Bug #9654] [ruby-dev:48058]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-03-22 14:06:11 +00:00
Родитель af1da410ca
Коммит 14c9cf885c
2 изменённых файлов: 22 добавлений и 12 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sat Mar 22 22:56:45 2014 NARUSE, Yui <naruse@ruby-lang.org>
* addr2line.c (fill_lines): compare the file names of object in which
symbols exist. [Bug #9654] [ruby-dev:48058]
Sat Mar 22 06:46:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/cgi/util.rb (escape_html, unescape_html): make synonyms

Просмотреть файл

@ -436,11 +436,11 @@ parse_debug_line(int num_traces, void **traces,
/* read file and fill lines */
static void
fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
line_info_t *current_line, line_info_t *lines);
line_info_t *current_line, line_info_t *lines, int offset);
static void
follow_debuglink(char *debuglink, int num_traces, void **traces, char **syms,
line_info_t *current_line, line_info_t *lines)
line_info_t *current_line, line_info_t *lines, int offset)
{
/* Ideally we should check 4 paths to follow gnu_debuglink,
but we handle only one case for now as this format is used
@ -467,13 +467,13 @@ follow_debuglink(char *debuglink, int num_traces, void **traces, char **syms,
current_line->mapped2 = current_line->mapped;
current_line->mapped_size2 = current_line->mapped_size;
current_line->fd2 = current_line->fd;
fill_lines(num_traces, traces, syms, 0, current_line, lines);
fill_lines(num_traces, traces, syms, 0, current_line, lines, offset);
}
/* read file and fill lines */
static void
fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
line_info_t *current_line, line_info_t *lines)
line_info_t *current_line, line_info_t *lines, int offset)
{
int i, j;
char *shstr;
@ -574,13 +574,18 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
ElfW(Sym) *symtab = (ElfW(Sym) *)(file + symtab_shdr->sh_offset);
int symtab_count = (int)(symtab_shdr->sh_size / sizeof(ElfW(Sym)));
for (j = 0; j < symtab_count; j++) {
int type = ELF_ST_TYPE(symtab[j].st_info);
ElfW(Sym) *sym = &symtab[j];
int type = ELF_ST_TYPE(sym->st_info);
intptr_t saddr = (intptr_t)sym->st_value + lines[offset].base_addr;
if (type != STT_FUNC) continue;
for (i = 0; i < num_traces; i++) {
ElfW(Sym) *sym = &symtab[j];
intptr_t saddr = (intptr_t)sym->st_value + lines[i].base_addr;
ptrdiff_t d = (intptr_t)traces[i] - saddr;
if (d <= 0 || d > (ptrdiff_t)sym->st_size) continue;
for (i = offset; i < num_traces; i++) {
intptr_t d = (intptr_t)traces[i] - saddr;
const char *path = lines[i].path;
if (path && strcmp(lines[offset].path, path) != 0)
continue;
if (d <= 0 || d > (intptr_t)sym->st_size)
continue;
/* fill symbol name and addr from .symtab */
lines[i].sname = strtab + sym->st_name;
lines[i].saddr = saddr;
}
@ -594,7 +599,7 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
if (gnu_debuglink_shdr && check_debuglink) {
follow_debuglink(file + gnu_debuglink_shdr->sh_offset,
num_traces, traces, syms,
current_line, lines);
current_line, lines, offset);
}
return;
}
@ -651,7 +656,7 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces, char **syms)
binary_filename[len] = '\0';
curobj_baseaddr = lines[i].base_addr;
fill_lines(num_traces, traces, syms, 1, &lines[i], lines);
fill_lines(num_traces, traces, syms, 1, &lines[i], lines, i);
}
/* output */