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.
This commit is contained in:
parent
22d2f3ab92
commit
43988095a5
@ -1,3 +1,69 @@
|
||||
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.
|
||||
|
||||
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* dwarf2read.c (abbrev_table_read_table): Read the data only once.
|
||||
|
@ -648,6 +648,10 @@ extern void store_typed_address (gdb_byte *buf, struct type *type,
|
||||
|
||||
extern int watchdog;
|
||||
|
||||
/* From dwarf2read.c */
|
||||
|
||||
ULONGEST read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
|
||||
|
||||
/* Hooks for alternate command interfaces. */
|
||||
|
||||
/* * The name of the interpreter if specified on the command line. */
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -56,6 +56,8 @@ int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu);
|
||||
offset in the parent objfile. */
|
||||
CORE_ADDR dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *cu);
|
||||
|
||||
short dwarf2_version (struct dwarf2_per_cu_data *per_cu);
|
||||
|
||||
/* Find a particular location expression from a location list. */
|
||||
const gdb_byte *dwarf2_find_location_expression
|
||||
(struct dwarf2_loclist_baton *baton,
|
||||
|
780
gdb/dwarf2read.c
780
gdb/dwarf2read.c
File diff suppressed because it is too large
Load Diff
@ -600,10 +600,13 @@ struct dwarf2_debug_sections {
|
||||
struct dwarf2_section_names abbrev;
|
||||
struct dwarf2_section_names line;
|
||||
struct dwarf2_section_names loc;
|
||||
struct dwarf2_section_names loclists;
|
||||
struct dwarf2_section_names macinfo;
|
||||
struct dwarf2_section_names macro;
|
||||
struct dwarf2_section_names str;
|
||||
struct dwarf2_section_names line_str;
|
||||
struct dwarf2_section_names ranges;
|
||||
struct dwarf2_section_names rnglists;
|
||||
struct dwarf2_section_names types;
|
||||
struct dwarf2_section_names addr;
|
||||
struct dwarf2_section_names frame;
|
||||
|
@ -1,3 +1,7 @@
|
||||
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.dwarf2/dw2-error.exp (file $testfile): Update expected string.
|
||||
|
||||
2017-02-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
|
||||
PR gdb/21164
|
||||
|
@ -41,7 +41,7 @@ gdb_test_no_output "set breakpoint pending off"
|
||||
|
||||
# First test that reading symbols fails.
|
||||
gdb_test "file $binfile" \
|
||||
"Reading symbols.*Dwarf Error: wrong version in compilation unit header .is 153, should be 2, 3, or 4.*" \
|
||||
{Reading symbols.*Dwarf Error: wrong unit_type in compilation unit header \(is 0, should be 1 or 2\).*} \
|
||||
"file $testfile"
|
||||
|
||||
# Now check that we can still break given the minimal symbol.
|
||||
|
@ -159,13 +159,16 @@ static const struct dwarf2_debug_sections dwarf2_xcoff_names = {
|
||||
{ ".dwabrev", NULL },
|
||||
{ ".dwline", NULL },
|
||||
{ ".dwloc", NULL },
|
||||
{ NULL, NULL }, /* debug_loclists */
|
||||
/* AIX XCOFF defines one, named DWARF section for macro debug information.
|
||||
XLC does not generate debug_macinfo for DWARF4 and below.
|
||||
The section is assigned to debug_macro for DWARF5 and above. */
|
||||
{ NULL, NULL },
|
||||
{ ".dwmac", NULL },
|
||||
{ ".dwstr", NULL },
|
||||
{ NULL, NULL }, /* debug_line_str */
|
||||
{ ".dwrnges", NULL },
|
||||
{ NULL, NULL }, /* debug_rnglists */
|
||||
{ ".dwpbtyp", NULL },
|
||||
{ NULL, NULL }, /* debug_addr */
|
||||
{ ".dwframe", NULL },
|
||||
|
Loading…
Reference in New Issue
Block a user