diff options
Diffstat (limited to 'libdw/dwarf_getsrclines.c')
-rw-r--r-- | libdw/dwarf_getsrclines.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c index fe0e67d6..efd0459f 100644 --- a/libdw/dwarf_getsrclines.c +++ b/libdw/dwarf_getsrclines.c @@ -135,20 +135,13 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines) /* Get the offset into the .debug_line section. NB: this call also checks whether the previous dwarf_attr call failed. */ - Dwarf_Word offset; - if (INTUSE(dwarf_formudata) (stmt_list, &offset) != 0) + const unsigned char *lineendp; + const unsigned char *linep + = __libdw_formptr (stmt_list, IDX_debug_line, DWARF_E_NO_DEBUG_LINE, + (unsigned char **) &lineendp, NULL); + if (linep == NULL) goto out; - Dwarf *dbg = cu->dbg; - if (dbg->sectiondata[IDX_debug_line] == NULL) - { - __libdw_seterrno (DWARF_E_NO_DEBUG_LINE); - goto out; - } - const uint8_t *linep = dbg->sectiondata[IDX_debug_line]->d_buf + offset; - const uint8_t *lineendp = (dbg->sectiondata[IDX_debug_line]->d_buf - + dbg->sectiondata[IDX_debug_line]->d_size); - /* Get the compilation directory. */ Dwarf_Attribute compdir_attr_mem; Dwarf_Attribute *compdir_attr = INTUSE(dwarf_attr) (cudie, @@ -162,6 +155,8 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines) __libdw_seterrno (DWARF_E_INVALID_DEBUG_LINE); goto out; } + + Dwarf *dbg = cu->dbg; Dwarf_Word unit_length = read_4ubyte_unaligned_inc (dbg, linep); unsigned int length = 4; if (unlikely (unit_length == DWARF3_LENGTH_64_BIT)) @@ -429,10 +424,10 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines) /* The value is an address. The size is defined as apporiate for the target machine. We use the address size field from the CU header. */ - if (cu->address_size == 4) - address = read_4ubyte_unaligned_inc (dbg, linep); - else - address = read_8ubyte_unaligned_inc (dbg, linep); + if (__libdw_read_address_inc (dbg, IDX_debug_line, + (unsigned char **)&linep, + cu->address_size, &address)) + goto out; break; case DW_LNE_define_file: |