summaryrefslogtreecommitdiff
path: root/addr2line.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-17 01:29:49 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-17 01:29:49 (GMT)
commit2a59b579fed2fd49973ca73890f182299262909f (patch)
tree4d849b542f3b88579ca9627ff8d032d3bf44bc9d /addr2line.c
parent0f92eba17f3fef786dd54e953df1db97835c2bb1 (diff)
Check the end of Compilation Unit by unit length instead of level of tree
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'addr2line.c')
-rw-r--r--addr2line.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/addr2line.c b/addr2line.c
index f05ff27..97e8b2a 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -741,6 +741,7 @@ typedef struct {
char *debug_line_files;
char *debug_line_directories;
char *p;
+ char *cu_end;
char *pend;
char *q0;
char *q;
@@ -1404,12 +1405,14 @@ di_read_cu(DebugInfoReader *reader)
reader->current_cu = reader->p;
if (hdr32->unit_length == 0xffffffff) {
DW_CompilationUnitHeader64 *hdr = (DW_CompilationUnitHeader64 *)hdr32;
+ reader->cu_end = reader->p + 12 + hdr->unit_length;
reader->p += 23;
reader->q0 = reader->obj->debug_abbrev.ptr + hdr->debug_abbrev_offset;
reader->address_size = hdr->address_size;
reader->format = 64;
} else {
DW_CompilationUnitHeader32 *hdr = hdr32;
+ reader->cu_end = reader->p + 4 + hdr->unit_length;
reader->p += 11;
reader->q0 = reader->obj->debug_abbrev.ptr + hdr->debug_abbrev_offset;
reader->address_size = hdr->address_size;
@@ -1478,13 +1481,13 @@ read_abstract_origin(DebugInfoReader *reader, uint64_t abstract_origin, line_inf
static void
debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
line_info_t *lines, int offset) {
- do {
+ while (reader->p < reader->cu_end) {
DIE die;
ranges_t ranges = {};
line_info_t line = {};
if (!di_read_die(reader, &die)) continue;
- //fprintf(stderr,"%d:%tx: <%d> Abbrev Number: %lu\n",__LINE__,diepos,reader->level,die.tag);
+ /* fprintf(stderr,"%d:%tx: <%d>\n",__LINE__,die.pos,reader->level,die.tag); */
if (die.tag != DW_TAG_subprogram && die.tag != DW_TAG_inlined_subroutine) {
skip_die:
@@ -1547,7 +1550,7 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
lines[i].saddr = reader->obj->base_addr + saddr;
}
}
- } while (reader->level > 0);
+ }
}
static unsigned long
@@ -1735,7 +1738,7 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
debug_info_reader_init(&reader, obj);
i = 0;
while (reader.p < reader.pend) {
- //fprintf(stderr, "%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info, i++);
+ /* fprintf(stderr, "%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info.ptr, i++); */
di_read_cu(&reader);
debug_info_read(&reader, num_traces, traces, lines, offset);
}