static void store_in_ref_table (struct die_info *,
struct dwarf2_cu *);
-static sect_offset dwarf2_get_ref_die_offset (const struct attribute *);
-
-static LONGEST dwarf2_get_attr_constant_value (const struct attribute *, int);
-
static struct die_info *follow_die_ref_or_sig (struct die_info *,
const struct attribute *,
struct dwarf2_cu **);
complaint (_("ignoring absolute DW_AT_sibling"));
else
{
- sect_offset off = dwarf2_get_ref_die_offset (&attr);
+ sect_offset off = attr.get_ref_die_offset ();
const gdb_byte *sibling_ptr = buffer + to_underlying (off);
if (sibling_ptr < info_ptr)
attr = dwarf2_attr (die, DW_AT_import, cu);
if (attr != NULL)
{
- sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
+ sect_offset sect_off = attr->get_ref_die_offset ();
bool is_dwz = (attr->form == DW_FORM_GNU_ref_alt || cu->per_cu->is_dwz);
dwarf2_per_cu_data *per_cu
= dwarf2_find_containing_comp_unit (sect_off, is_dwz,
if (attr != NULL)
{
struct type *type;
- sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
+ sect_offset sect_off = attr->get_ref_die_offset ();
type = get_die_type_at_offset (sect_off, cu->per_cu);
if (type != NULL && TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
{
parameter->kind = CALL_SITE_PARAMETER_PARAM_OFFSET;
- sect_offset sect_off
- = (sect_offset) dwarf2_get_ref_die_offset (origin);
+ sect_offset sect_off = origin->get_ref_die_offset ();
if (!cu->header.offset_in_cu_p (sect_off))
{
/* As DW_OP_GNU_parameter_ref uses CU-relative offset this
so if we see it, we can assume that a constant form is really
a constant and not a section offset. */
if (attr->form_is_constant ())
- *offset = dwarf2_get_attr_constant_value (attr, 0);
+ *offset = attr->constant_value (0);
else if (attr->form_is_section_offset ())
dwarf2_complex_location_expr_complaint ();
else if (attr->form_is_block ())
attr = dwarf2_attr (die, DW_AT_data_bit_offset, cu);
if (attr != NULL)
SET_FIELD_BITPOS (*fp, (FIELD_BITPOS (*fp)
- + dwarf2_get_attr_constant_value (attr, 0)));
+ + attr->constant_value (0)));
/* Get name of field. */
fieldname = dwarf2_name (die, cu);
if (member_loc->form_is_constant ())
{
- offset = dwarf2_get_attr_constant_value (member_loc, 0);
+ offset = member_loc->constant_value (0);
baton->size += 1 /* DW_OP_addr */ + cu->header.addr_size;
}
else
{
/* Pass 0 as the default as we know this attribute is constant
and the default value will not be returned. */
- LONGEST sz = dwarf2_get_attr_constant_value (len, 0);
+ LONGEST sz = len->constant_value (0);
prop_type = cu->per_cu->int_type (sz, true);
}
else
indirection. There's no need to create a dynamic property in this
case. Pass 0 for the default value as we know it will not be
returned in this case. */
- length = dwarf2_get_attr_constant_value (attr, 0);
+ length = attr->constant_value (0);
}
else if ((attr = dwarf2_attr (die, DW_AT_byte_size, cu)) != nullptr)
{
/* We don't currently support non-constant byte sizes for strings. */
- length = dwarf2_get_attr_constant_value (attr, 1);
+ length = attr->constant_value (1);
}
else
{
}
else if (attr->form_is_constant ())
{
- prop->data.const_val = dwarf2_get_attr_constant_value (attr, 0);
+ prop->data.const_val = attr->constant_value (0);
prop->kind = PROP_CONST;
}
else
LONGEST bias = 0;
struct attribute *bias_attr = dwarf2_attr (die, DW_AT_GNU_bias, cu);
if (bias_attr != nullptr && bias_attr->form_is_constant ())
- bias = dwarf2_get_attr_constant_value (bias_attr, 0);
+ bias = bias_attr->constant_value (0);
/* Normally, the DWARF producers are expected to use a signed
constant form (Eg. DW_FORM_sdata) to express negative bounds.
case DW_AT_specification:
case DW_AT_extension:
has_specification = 1;
- spec_offset = dwarf2_get_ref_die_offset (&attr);
+ spec_offset = attr.get_ref_die_offset ();
spec_is_dwz = (attr.form == DW_FORM_GNU_ref_alt
|| cu->per_cu->is_dwz);
break;
else
{
const gdb_byte *buffer = reader->buffer;
- sect_offset off = dwarf2_get_ref_die_offset (&attr);
+ sect_offset off = attr.get_ref_die_offset ();
const gdb_byte *sibling_ptr = buffer + to_underlying (off);
if (sibling_ptr < info_ptr)
case DW_AT_import:
if (tag == DW_TAG_imported_unit)
{
- d.sect_off = dwarf2_get_ref_die_offset (&attr);
+ d.sect_off = attr.get_ref_die_offset ();
is_dwz = (attr.form == DW_FORM_GNU_ref_alt
|| cu->per_cu->is_dwz);
}
if (attr->form == DW_FORM_GNU_ref_alt)
{
struct dwarf2_per_cu_data *per_cu;
- sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
+ sect_offset sect_off = attr->get_ref_die_offset ();
per_cu = dwarf2_find_containing_comp_unit (sect_off, 1,
dwarf2_per_objfile);
}
else if (attr->form_is_ref ())
{
- sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
+ sect_offset sect_off = attr->get_ref_die_offset ();
this_type = get_die_type_at_offset (sect_off, cu->per_cu);
}
*slot = die;
}
-/* Return DIE offset of ATTR. Return 0 with complaint if ATTR is not of the
- required kind. */
-
-static sect_offset
-dwarf2_get_ref_die_offset (const struct attribute *attr)
-{
- if (attr->form_is_ref ())
- return (sect_offset) DW_UNSND (attr);
-
- complaint (_("unsupported die ref attribute form: '%s'"),
- dwarf_form_name (attr->form));
- return {};
-}
-
-/* Return the constant value held by ATTR. Return DEFAULT_VALUE if
- * the value held by the attribute is not constant. */
-
-static LONGEST
-dwarf2_get_attr_constant_value (const struct attribute *attr, int default_value)
-{
- if (attr->form == DW_FORM_sdata || attr->form == DW_FORM_implicit_const)
- return DW_SND (attr);
- else if (attr->form == DW_FORM_udata
- || attr->form == DW_FORM_data1
- || attr->form == DW_FORM_data2
- || attr->form == DW_FORM_data4
- || attr->form == DW_FORM_data8)
- return DW_UNSND (attr);
- else
- {
- /* For DW_FORM_data16 see attribute::form_is_constant. */
- complaint (_("Attribute value is not a constant (%s)"),
- dwarf_form_name (attr->form));
- return default_value;
- }
-}
-
/* Follow reference or signature attribute ATTR of SRC_DIE.
On entry *REF_CU is the CU of SRC_DIE.
On exit *REF_CU is the CU of the result. */
follow_die_ref (struct die_info *src_die, const struct attribute *attr,
struct dwarf2_cu **ref_cu)
{
- sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
+ sect_offset sect_off = attr->get_ref_die_offset ();
struct dwarf2_cu *cu = *ref_cu;
struct die_info *die;