diff options
author | Tom Tromey <tom@tromey.com> | 2020-09-29 18:49:08 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-09-29 20:29:06 -0600 |
commit | 1bc397c561f55c1cf67a5e02f5c9305a54155a2e (patch) | |
tree | ac62792e3d25ef7c9429aebd4168d1dcc3aa72e0 /gdb/dwarf2 | |
parent | 630ed6b975d2d2f950523dd2ad9ac77614f5222c (diff) | |
download | gdb-1bc397c561f55c1cf67a5e02f5c9305a54155a2e.zip gdb-1bc397c561f55c1cf67a5e02f5c9305a54155a2e.tar.gz gdb-1bc397c561f55c1cf67a5e02f5c9305a54155a2e.tar.bz2 |
Remove DW_SND
This removes DW_SND in favor of accessors on struct attribute.
These accessors check that the form is appropriate.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (get_alignment, read_array_order)
(read_attribute_value, dwarf2_const_value_attr)
(dump_die_shallow, dwarf2_fetch_constant_bytes): Update.
* dwarf2/attribute.h (struct attribute) <as_signed, set_signed>:
New methods.
(DW_SND): Remove.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/attribute.h | 16 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 20 |
2 files changed, 27 insertions, 9 deletions
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 800ea8d..9178276 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -65,6 +65,14 @@ struct attribute return u.signature; } + /* Return the signed value. The attribute must have the appropriate + form. */ + LONGEST as_signed () const + { + gdb_assert (form == DW_FORM_sdata || form == DW_FORM_implicit_const); + return u.snd; + } + /* Return non-zero if ATTR's value is a section offset --- classes lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise. You may use DW_UNSND (attr) to retrieve such offsets. @@ -175,6 +183,13 @@ struct attribute u.signature = signature; } + /* Set this attribute to a signed integer. */ + void set_signed (LONGEST snd) + { + gdb_assert (form == DW_FORM_sdata || form == DW_FORM_implicit_const); + u.snd = snd; + } + ENUM_BITFIELD(dwarf_attribute) name : 16; ENUM_BITFIELD(dwarf_form) form : 15; @@ -205,7 +220,6 @@ private: /* Get at parts of an attribute structure. */ #define DW_UNSND(attr) ((attr)->u.unsnd) -#define DW_SND(attr) ((attr)->u.snd) #define DW_ADDR(attr) ((attr)->u.addr) #endif /* GDB_DWARF2_ATTRIBUTE_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e8170eb..190d38e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15872,7 +15872,7 @@ get_alignment (struct dwarf2_cu *cu, struct die_info *die) ULONGEST align; if (attr->form == DW_FORM_sdata) { - LONGEST val = DW_SND (attr); + LONGEST val = attr->as_signed (); if (val < 0) { complaint (_("DW_AT_alignment value must not be negative" @@ -16871,7 +16871,11 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_ordering, cu); if (attr != nullptr) - return (enum dwarf_array_dim_ordering) DW_SND (attr); + { + LONGEST val = attr->constant_value (-1); + if (val == DW_ORD_row_major || val == DW_ORD_col_major) + return (enum dwarf_array_dim_ordering) val; + } /* GNU F77 is a special case, as at 08/2004 array type info is the opposite order to the dwarf2 specification, but data is still @@ -19819,7 +19823,7 @@ read_attribute_value (const struct die_reader_specs *reader, DW_UNSND (attr) = 1; break; case DW_FORM_sdata: - DW_SND (attr) = read_signed_leb128 (abfd, info_ptr, &bytes_read); + attr->set_signed (read_signed_leb128 (abfd, info_ptr, &bytes_read)); info_ptr += bytes_read; break; case DW_FORM_rnglistx: @@ -19870,7 +19874,7 @@ read_attribute_value (const struct die_reader_specs *reader, info_ptr, need_reprocess); break; case DW_FORM_implicit_const: - DW_SND (attr) = implicit_const; + attr->set_signed (implicit_const); break; case DW_FORM_addrx: case DW_FORM_GNU_addr_index: @@ -21911,7 +21915,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, case DW_FORM_sdata: case DW_FORM_implicit_const: - *value = DW_SND (attr); + *value = attr->as_signed (); break; case DW_FORM_udata: @@ -22772,7 +22776,6 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) case DW_FORM_data4: case DW_FORM_data8: case DW_FORM_udata: - case DW_FORM_sdata: fprintf_unfiltered (f, "constant: %s", pulongest (DW_UNSND (&die->attrs[i]))); break; @@ -22810,9 +22813,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) fprintf_unfiltered (f, "unexpected attribute form: DW_FORM_indirect"); break; + case DW_FORM_sdata: case DW_FORM_implicit_const: fprintf_unfiltered (f, "constant: %s", - plongest (DW_SND (&die->attrs[i]))); + plongest (die->attrs[i].as_signed ())); break; default: fprintf_unfiltered (f, "unsupported attribute form: %d.", @@ -23247,7 +23251,7 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off, case DW_FORM_implicit_const: type = die_type (die, cu); result = write_constant_as_bytes (obstack, byte_order, - type, DW_SND (attr), len); + type, attr->as_signed (), len); break; case DW_FORM_udata: |