diff options
author | Ali Tamur <tamur@google.com> | 2019-04-25 13:35:53 -0700 |
---|---|---|
committer | Ali Tamur <tamur@google.com> | 2019-04-30 16:18:52 -0700 |
commit | 15f18d1467aa08ff7a4793f21e02fd4c2ebc0a0b (patch) | |
tree | 7eecec663f0e4b5f15f095a552588393b1ffe7bb /gdb/dwarf2read.c | |
parent | ab4ee6147eb2e8fafd1fb96c945029c789182d3b (diff) | |
download | gdb-15f18d1467aa08ff7a4793f21e02fd4c2ebc0a0b.zip gdb-15f18d1467aa08ff7a4793f21e02fd4c2ebc0a0b.tar.gz gdb-15f18d1467aa08ff7a4793f21e02fd4c2ebc0a0b.tar.bz2 |
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.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 50 |
1 files changed, 46 insertions, 4 deletions
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); |