diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2017-02-20 20:53:21 +0100 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2017-02-20 20:59:56 +0100 |
commit | 43988095a5a4c53e6d5b00a6335454919c4fac55 (patch) | |
tree | 2e523badb62b5e3ad99bd49c4d1d6eaa9265a40e /gdb/dwarf2loc.c | |
parent | 22d2f3ab926890490deed2888f6f013031fa6a6e (diff) | |
download | gdb-43988095a5a4c53e6d5b00a6335454919c4fac55.zip gdb-43988095a5a4c53e6d5b00a6335454919c4fac55.tar.gz gdb-43988095a5a4c53e6d5b00a6335454919c4fac55.tar.bz2 |
DWARF-5 basic functionality
this is a kitchen-sink patch for everything that did not fit into its own
patch.
DWO is not yet implemented.
gdb/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* defs.h (read_unsigned_leb128): New declaration.
* dwarf2loc.c (decode_debug_loclists_addresses): New function.
(decode_debug_loc_dwo_addresses): Update DEBUG_LOC_* to DW_LLE_*.
(dwarf2_find_location_expression): Call also
decode_debug_loclists_addresses. Handle DWARF-5 ULEB128 length.
* dwarf2loc.h (dwarf2_version): New declaration.
* dwarf2read.c (struct dwarf2_per_objfile): Add loclists, line_str,
rnglists.
(dwarf2_elf_names): Add .debug_loclists, .debug_line_str,
.debug_rnglists.
(struct dwop_section_names): Add loclists_dwo.
(dwop_section_names): Add .debug_loclists.dwo.
(struct comp_unit_head): Add unit_type, signature, type_offset_in_tu.
(struct dwarf2_per_cu_data): Add dwarf_version.
(struct dwo_sections): Add loclists.
(struct attr_abbrev): Add implicit_const.
(read_indirect_line_string): New declaration.
(read_unsigned_leb128): Delete declaration.
(rcuh_kind): New definition.
(read_and_check_comp_unit_head): Change parameter
is_debug_types_section to section_kind.
(dwarf2_locate_sections): Handle loclists, line_str and rnglists.
(read_comp_unit_head): Change parameter abfd to section, add parameter
section_kind. Handle DWARF-5.
(error_check_comp_unit_head): Accept also DWARF version 5.
(read_and_check_comp_unit_head): Change parameter
is_debug_types_section to section_kind.
(read_and_check_type_unit_head): Delete function.
(read_abbrev_offset): Handle DWARF-5.
(create_debug_type_hash_table): Add parameter section_kind. Process
only DW_UT_type. Use signature and type_offset_in_tu from struct
comp_unit_head.
(create_debug_types_hash_table): Update create_debug_type_hash_table
caller.
(create_all_type_units): Call create_debug_type_hash_table.
(read_cutu_die_from_dwo, init_cutu_and_read_dies): Change
read_and_check_type_unit_head caller to read_and_check_comp_unit_head
caller.
(skip_one_die): Handle DW_FORM_implicit_const.
(dwarf2_rnglists_process): New function.
(dwarf2_ranges_process): Call dwarf2_rnglists_process for DWARF-5.
(abbrev_table_read_table): Handle DW_FORM_implicit_const.
(read_attribute_value): Handle DW_FORM_implicit_const,
DW_FORM_line_strp.
(read_attribute): Handle DW_FORM_implicit_const.
(read_indirect_string_at_offset_from): New function from
read_indirect_string_at_offset.
(read_indirect_string_at_offset): Call
read_indirect_string_at_offset_from.
(read_indirect_line_string_at_offset): New function.
(read_indirect_string): New function comment.
(read_indirect_line_string): New function.
(read_unsigned_leb128): Make it global.
(dwarf2_string_attr): Handle DWARF-5.
(add_include_dir_stub, read_formatted_entries): New functions.
(dwarf_decode_line_header, dump_die_shallow, cu_debug_loc_section):
Handle DWARF-5.
(per_cu_header_read_in): Update read_comp_unit_head caller.
(dwarf2_version): New function.
* symfile.h (struct dwarf2_debug_sections): Add loclists, line_str and
rnglists.
* xcoffread.c (dwarf2_xcoff_names): Update struct dwarf2_debug_sections
fields.
gdb/testsuite/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.dwarf2/dw2-error.exp (file $testfile): Update expected string.
Diffstat (limited to 'gdb/dwarf2loc.c')
-rw-r--r-- | gdb/dwarf2loc.c | 81 |
1 files changed, 74 insertions, 7 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index c1e02eb..8774af4 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -143,6 +143,57 @@ decode_debug_loc_addresses (const gdb_byte *loc_ptr, const gdb_byte *buf_end, return DEBUG_LOC_START_END; } +/* Decode the addresses in .debug_loclists entry. + A pointer to the next byte to examine is returned in *NEW_PTR. + The encoded low,high addresses are return in *LOW,*HIGH. + The result indicates the kind of entry found. */ + +static enum debug_loc_kind +decode_debug_loclists_addresses (struct dwarf2_per_cu_data *per_cu, + const gdb_byte *loc_ptr, + const gdb_byte *buf_end, + const gdb_byte **new_ptr, + CORE_ADDR *low, CORE_ADDR *high, + enum bfd_endian byte_order, + unsigned int addr_size, + int signed_addr_p) +{ + uint64_t u64; + + if (loc_ptr == buf_end) + return DEBUG_LOC_BUFFER_OVERFLOW; + + switch (*loc_ptr++) + { + case DW_LLE_end_of_list: + *new_ptr = loc_ptr; + return DEBUG_LOC_END_OF_LIST; + case DW_LLE_base_address: + if (loc_ptr + addr_size > buf_end) + return DEBUG_LOC_BUFFER_OVERFLOW; + if (signed_addr_p) + *high = extract_signed_integer (loc_ptr, addr_size, byte_order); + else + *high = extract_unsigned_integer (loc_ptr, addr_size, byte_order); + loc_ptr += addr_size; + *new_ptr = loc_ptr; + return DEBUG_LOC_BASE_ADDRESS; + case DW_LLE_offset_pair: + loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64); + if (loc_ptr == NULL) + return DEBUG_LOC_BUFFER_OVERFLOW; + *low = u64; + loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64); + if (loc_ptr == NULL) + return DEBUG_LOC_BUFFER_OVERFLOW; + *high = u64; + *new_ptr = loc_ptr; + return DEBUG_LOC_START_END; + default: + return DEBUG_LOC_INVALID_ENTRY; + } +} + /* Decode the addresses in .debug_loc.dwo entry. A pointer to the next byte to examine is returned in *NEW_PTR. The encoded low,high addresses are return in *LOW,*HIGH. @@ -163,10 +214,10 @@ decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu, switch (*loc_ptr++) { - case DEBUG_LOC_END_OF_LIST: + case DW_LLE_GNU_end_of_list_entry: *new_ptr = loc_ptr; return DEBUG_LOC_END_OF_LIST; - case DEBUG_LOC_BASE_ADDRESS: + case DW_LLE_GNU_base_address_selection_entry: *low = 0; loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &high_index); if (loc_ptr == NULL) @@ -174,7 +225,7 @@ decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu, *high = dwarf2_read_addr_index (per_cu, high_index); *new_ptr = loc_ptr; return DEBUG_LOC_BASE_ADDRESS; - case DEBUG_LOC_START_END: + case DW_LLE_GNU_start_end_entry: loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index); if (loc_ptr == NULL) return DEBUG_LOC_BUFFER_OVERFLOW; @@ -185,7 +236,7 @@ decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu, *high = dwarf2_read_addr_index (per_cu, high_index); *new_ptr = loc_ptr; return DEBUG_LOC_START_END; - case DEBUG_LOC_START_LENGTH: + case DW_LLE_GNU_start_length_entry: loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index); if (loc_ptr == NULL) return DEBUG_LOC_BUFFER_OVERFLOW; @@ -237,11 +288,17 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, kind = decode_debug_loc_dwo_addresses (baton->per_cu, loc_ptr, buf_end, &new_ptr, &low, &high, byte_order); - else + else if (dwarf2_version (baton->per_cu) < 5) kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr, &low, &high, byte_order, addr_size, signed_addr_p); + else + kind = decode_debug_loclists_addresses (baton->per_cu, + loc_ptr, buf_end, &new_ptr, + &low, &high, byte_order, + addr_size, signed_addr_p); + loc_ptr = new_ptr; switch (kind) { @@ -277,8 +334,18 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, high += base_address; } - length = extract_unsigned_integer (loc_ptr, 2, byte_order); - loc_ptr += 2; + if (dwarf2_version (baton->per_cu) < 5) + { + length = extract_unsigned_integer (loc_ptr, 2, byte_order); + loc_ptr += 2; + } + else + { + unsigned int bytes_read; + + length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read); + loc_ptr += bytes_read; + } if (low == high && pc == low) { |