Remove DW_SIGNATURE

This removes DW_SIGNATURE in favor of methods on struct attribute.  As
usual, the methods check the form, which DW_SIGNATURE did not do.

gdb/ChangeLog
2020-09-29  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (read_attribute_value, lookup_die_type)
	(dump_die_shallow, follow_die_sig, get_DW_AT_signature_type):
	Update.
	* dwarf2/attribute.h (struct attribute) <as_signature,
	set_signature>: New methods.
	(DW_SIGNATURE): Remove.
This commit is contained in:
Tom Tromey 2020-09-29 18:49:08 -06:00
parent 9d2246fce0
commit 630ed6b975
3 changed files with 29 additions and 6 deletions

View file

@ -1,3 +1,12 @@
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_attribute_value, lookup_die_type)
(dump_die_shallow, follow_die_sig, get_DW_AT_signature_type):
Update.
* dwarf2/attribute.h (struct attribute) <as_signature,
set_signature>: New methods.
(DW_SIGNATURE): Remove.
2020-09-29 Tom Tromey <tom@tromey.com> 2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_call_site_scope) * dwarf2/read.c (read_call_site_scope)

View file

@ -57,6 +57,14 @@ struct attribute
return u.blk; return u.blk;
} }
/* Return the signature. The attribute must have signature
form. */
ULONGEST as_signature () const
{
gdb_assert (form == DW_FORM_ref_sig8);
return u.signature;
}
/* Return non-zero if ATTR's value is a section offset --- classes /* Return non-zero if ATTR's value is a section offset --- classes
lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise. lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
You may use DW_UNSND (attr) to retrieve such offsets. You may use DW_UNSND (attr) to retrieve such offsets.
@ -160,6 +168,13 @@ struct attribute
u.blk = blk; u.blk = blk;
} }
/* Set the signature value for this attribute. */
void set_signature (ULONGEST signature)
{
gdb_assert (form == DW_FORM_ref_sig8);
u.signature = signature;
}
ENUM_BITFIELD(dwarf_attribute) name : 16; ENUM_BITFIELD(dwarf_attribute) name : 16;
ENUM_BITFIELD(dwarf_form) form : 15; ENUM_BITFIELD(dwarf_form) form : 15;
@ -192,6 +207,5 @@ private:
#define DW_UNSND(attr) ((attr)->u.unsnd) #define DW_UNSND(attr) ((attr)->u.unsnd)
#define DW_SND(attr) ((attr)->u.snd) #define DW_SND(attr) ((attr)->u.snd)
#define DW_ADDR(attr) ((attr)->u.addr) #define DW_ADDR(attr) ((attr)->u.addr)
#define DW_SIGNATURE(attr) ((attr)->u.signature)
#endif /* GDB_DWARF2_ATTRIBUTE_H */ #endif /* GDB_DWARF2_ATTRIBUTE_H */

View file

@ -19850,7 +19850,7 @@ read_attribute_value (const struct die_reader_specs *reader,
info_ptr += 8; info_ptr += 8;
break; break;
case DW_FORM_ref_sig8: case DW_FORM_ref_sig8:
DW_SIGNATURE (attr) = read_8_bytes (abfd, info_ptr); attr->set_signature (read_8_bytes (abfd, info_ptr));
info_ptr += 8; info_ptr += 8;
break; break;
case DW_FORM_ref_udata: case DW_FORM_ref_udata:
@ -22093,7 +22093,7 @@ lookup_die_type (struct die_info *die, const struct attribute *attr,
} }
else if (attr->form == DW_FORM_ref_sig8) else if (attr->form == DW_FORM_ref_sig8)
{ {
ULONGEST signature = DW_SIGNATURE (attr); ULONGEST signature = attr->as_signature ();
return get_signatured_type (die, signature, cu); return get_signatured_type (die, signature, cu);
} }
@ -22782,7 +22782,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
break; break;
case DW_FORM_ref_sig8: case DW_FORM_ref_sig8:
fprintf_unfiltered (f, "signature: %s", fprintf_unfiltered (f, "signature: %s",
hex_string (DW_SIGNATURE (&die->attrs[i]))); hex_string (die->attrs[i].as_signature ()));
break; break;
case DW_FORM_string: case DW_FORM_string:
case DW_FORM_strp: case DW_FORM_strp:
@ -23360,7 +23360,7 @@ static struct die_info *
follow_die_sig (struct die_info *src_die, const struct attribute *attr, follow_die_sig (struct die_info *src_die, const struct attribute *attr,
struct dwarf2_cu **ref_cu) struct dwarf2_cu **ref_cu)
{ {
ULONGEST signature = DW_SIGNATURE (attr); ULONGEST signature = attr->as_signature ();
struct signatured_type *sig_type; struct signatured_type *sig_type;
struct die_info *die; struct die_info *die;
@ -23468,7 +23468,7 @@ get_DW_AT_signature_type (struct die_info *die, const struct attribute *attr,
} }
else if (attr->form == DW_FORM_ref_sig8) else if (attr->form == DW_FORM_ref_sig8)
{ {
return get_signatured_type (die, DW_SIGNATURE (attr), cu); return get_signatured_type (die, attr->as_signature (), cu);
} }
else else
{ {