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 | c648120540c7a1550bd7e65e660fda419ecf23b3 (patch) | |
tree | 89ac85f4f1477aa22342aca569cf9aa38d79ed4c /gdb/dwarf2/attribute.h | |
parent | 3b64bf15bc96d83e49521048bfe3eacf25d3649d (diff) | |
download | gdb-c648120540c7a1550bd7e65e660fda419ecf23b3.zip gdb-c648120540c7a1550bd7e65e660fda419ecf23b3.tar.gz gdb-c648120540c7a1550bd7e65e660fda419ecf23b3.tar.bz2 |
Remove DW_STRING and DW_STRING_IS_CANONICAL
This removes DW_STRING and DW_STRING_IS_CANONICAL, replacing them with
accessor methods on struct attribute. The new code ensures that a
string value will only ever be used when the form allows it.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_cutu_die_from_dwo)
(read_attribute_reprocess, read_attribute_value, read_attribute)
(dwarf2_const_value_attr, dwarf2_name, dump_die_shallow)
(dwarf2_fetch_constant_bytes): Update.
* dwarf2/attribute.h (struct attribute) <form_is_string>: Declare.
<set_string_noncanonical, set_string_canonical>: New methods.
<string_is_canonical>: Update comment.
<canonical_string_p>: Add assert.
(DW_STRING, DW_STRING_IS_CANONICAL): Remove.
* dwarf2/attribute.c (attribute::form_is_string): New method.
(attribute::string): Use it.
Diffstat (limited to 'gdb/dwarf2/attribute.h')
-rw-r--r-- | gdb/dwarf2/attribute.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index a2c41f2..a9b77c1 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -98,6 +98,9 @@ struct attribute bool form_is_block () const; + /* Check if the attribute's form is a string form. */ + bool form_is_string () const; + /* Return DIE offset of this attribute. Return 0 with complaint if the attribute is not of the required kind. */ @@ -122,16 +125,34 @@ struct attribute flag indicates whether the value has been canonicalized. */ bool canonical_string_p () const { + gdb_assert (form_is_string ()); return string_is_canonical; } + /* Initialize this attribute to hold a non-canonical string + value. */ + void set_string_noncanonical (const char *str) + { + gdb_assert (form_is_string ()); + u.str = str; + string_is_canonical = 0; + } + + /* Set the canonical string value for this attribute. */ + void set_string_canonical (const char *str) + { + gdb_assert (form_is_string ()); + u.str = str; + string_is_canonical = 1; + } + ENUM_BITFIELD(dwarf_attribute) name : 16; ENUM_BITFIELD(dwarf_form) form : 15; - /* Has DW_STRING already been updated by dwarf2_canonicalize_name? This - field should be in u.str (existing only for DW_STRING) but it is kept - here for better struct attribute alignment. */ + /* Has u.str already been updated by dwarf2_canonicalize_name? This + field should be in u.str but it is kept here for better struct + attribute alignment. */ unsigned int string_is_canonical : 1; union @@ -154,8 +175,6 @@ private: /* Get at parts of an attribute structure. */ -#define DW_STRING(attr) ((attr)->u.str) -#define DW_STRING_IS_CANONICAL(attr) ((attr)->string_is_canonical) #define DW_UNSND(attr) ((attr)->u.unsnd) #define DW_BLOCK(attr) ((attr)->u.blk) #define DW_SND(attr) ((attr)->u.snd) |