From: Ali Tamur Date: Thu, 25 Apr 2019 20:35:53 +0000 (-0700) Subject: Support DW_FORM_strx1, _strx2, _strx3, _strx4 forms. X-Git-Tag: binutils-2_33~1408 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15f18d1467aa08ff7a4793f21e02fd4c2ebc0a0b;p=external%2Fbinutils.git Support DW_FORM_strx1, _strx2, _strx3, _strx4 forms. Dwarf5 defines DW_FORM_strx1 and others, which are similar to DW_FORM_strx but uses 1-4 bytes unsigned integers. This is a small step towards supporting dwarf5 in gdb. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 126343c..fdbcb67 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-04-30 Ali Tamur + * gdb/dwarf2read.c (read_3_bytes): New declaration. + (read_attribute_value): Added DW_FORM_strx1-4 cases. + (read_3_bytes): New function. + 2019-04-30 Joel Brobecker * windows-nat.c (main_thread_id): Delete. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 751c59c3..b0bdecf 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1531,6 +1531,9 @@ static int read_1_signed_byte (bfd *, const gdb_byte *); static unsigned int read_2_bytes (bfd *, const gdb_byte *); +/* Read the next three bytes (little-endian order) as an unsigned integer. */ +static unsigned int read_3_bytes (bfd *, const gdb_byte *); + static unsigned int read_4_bytes (bfd *, const gdb_byte *); static ULONGEST read_8_bytes (bfd *, const gdb_byte *); @@ -19330,6 +19333,10 @@ read_attribute_value (const struct die_reader_specs *reader, info_ptr += bytes_read; break; case DW_FORM_strx: + case DW_FORM_strx1: + case DW_FORM_strx2: + case DW_FORM_strx3: + case DW_FORM_strx4: case DW_FORM_GNU_str_index: if (reader->dwo_file == NULL) { @@ -19340,12 +19347,34 @@ read_attribute_value (const struct die_reader_specs *reader, bfd_get_filename (abfd)); } { - ULONGEST str_index = - read_unsigned_leb128 (abfd, info_ptr, &bytes_read); - + ULONGEST str_index; + if (form == DW_FORM_strx1) + { + str_index = read_1_byte (abfd, info_ptr); + info_ptr += 1; + } + else if (form == DW_FORM_strx2) + { + str_index = read_2_bytes (abfd, info_ptr); + info_ptr += 2; + } + else if (form == DW_FORM_strx3) + { + str_index = read_3_bytes (abfd, info_ptr); + info_ptr += 3; + } + else if (form == DW_FORM_strx4) + { + str_index = read_4_bytes (abfd, info_ptr); + info_ptr += 4; + } + else + { + str_index = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); + info_ptr += bytes_read; + } DW_STRING (attr) = read_str_index (reader, str_index); DW_STRING_IS_CANONICAL (attr) = 0; - info_ptr += bytes_read; } break; default: @@ -19416,6 +19445,19 @@ read_2_signed_bytes (bfd *abfd, const gdb_byte *buf) } static unsigned int +read_3_bytes (bfd *abfd, const gdb_byte *buf) +{ + unsigned int result = 0; + for (int i = 0; i < 3; ++i) + { + unsigned char byte = bfd_get_8 (abfd, buf); + buf++; + result |= ((unsigned int) byte << (i * 8)); + } + return result; +} + +static unsigned int read_4_bytes (bfd *abfd, const gdb_byte *buf) { return bfd_get_32 (abfd, buf); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8d2601b..fa1f567 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-04-30 Ali Tamur + + * lib/dwarf.exp(): Added DW_FORM_strx1-4. + 2019-04-30 Tom Tromey * lib/ada.exp (find_ada_tool): New proc. diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index 3a430fc..3cc5928 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -528,6 +528,10 @@ namespace eval Dwarf { DW_FORM_exprloc - DW_FORM_strx - + DW_FORM_strx1 - + DW_FORM_strx2 - + DW_FORM_strx3 - + DW_FORM_strx4 - DW_FORM_GNU_addr_index - DW_FORM_GNU_str_index -