/* Attributes have a name and a value. */
struct attribute
{
+ /* Read the given attribute value as an address, taking the
+ attribute's form into account. */
+ CORE_ADDR value_as_address () const;
+
+ /* 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.
+
+ Section 7.5.4, "Attribute Encodings", explains that no attribute
+ may have a value that belongs to more than one of these classes; it
+ would be ambiguous if we did, because we use the same forms for all
+ of them. */
+
+ bool form_is_section_offset () const;
+
+ /* Return non-zero if ATTR's value falls in the 'constant' class, or
+ zero otherwise. When this function returns true, you can apply
+ dwarf2_get_attr_constant_value to it.
+
+ However, note that for some attributes you must check
+ attr_form_is_section_offset before using this test. DW_FORM_data4
+ and DW_FORM_data8 are members of both the constant class, and of
+ the classes that contain offsets into other debug sections
+ (lineptr, loclistptr, macptr or rangelistptr). The DWARF spec says
+ that, if an attribute's can be either a constant or one of the
+ section offset classes, DW_FORM_data4 and DW_FORM_data8 should be
+ taken as section offsets, not constants.
+
+ DW_FORM_data16 is not considered as dwarf2_get_attr_constant_value
+ cannot handle that. */
+
+ bool form_is_constant () const;
+
+ /* DW_ADDR is always stored already as sect_offset; despite for the forms
+ besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */
+
+ bool form_is_ref () const;
+
+
ENUM_BITFIELD(dwarf_attribute) name : 16;
ENUM_BITFIELD(dwarf_form) form : 15;
#define DW_ADDR(attr) ((attr)->u.addr)
#define DW_SIGNATURE(attr) ((attr)->u.signature)
-/* Read the given attribute value as an address, taking the attribute's
- form into account. */
-
-extern CORE_ADDR attr_value_as_address (struct attribute *attr);
-
/* Check if the attribute's form is a DW_FORM_block*
if so return true else false. */
extern int attr_form_is_block (const struct attribute *attr);
-/* 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.
-
- Section 7.5.4, "Attribute Encodings", explains that no attribute
- may have a value that belongs to more than one of these classes; it
- would be ambiguous if we did, because we use the same forms for all
- of them. */
-
-extern int attr_form_is_section_offset (const struct attribute *attr);
-
-/* Return non-zero if ATTR's value falls in the 'constant' class, or
- zero otherwise. When this function returns true, you can apply
- dwarf2_get_attr_constant_value to it.
-
- However, note that for some attributes you must check
- attr_form_is_section_offset before using this test. DW_FORM_data4
- and DW_FORM_data8 are members of both the constant class, and of
- the classes that contain offsets into other debug sections
- (lineptr, loclistptr, macptr or rangelistptr). The DWARF spec says
- that, if an attribute's can be either a constant or one of the
- section offset classes, DW_FORM_data4 and DW_FORM_data8 should be
- taken as section offsets, not constants.
-
- DW_FORM_data16 is not considered as dwarf2_get_attr_constant_value
- cannot handle that. */
-
-extern int attr_form_is_constant (const struct attribute *attr);
-
-/* DW_ADDR is always stored already as sect_offset; despite for the forms
- besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */
-
-extern int attr_form_is_ref (const struct attribute *attr);
-
#endif /* GDB_DWARF2_ATTRIBUTE_H */
attr = dwarf2_attr (die, DW_AT_entry_pc, cu);
if (attr != nullptr)
{
- cu->base_address = attr_value_as_address (attr);
+ cu->base_address = attr->value_as_address ();
cu->base_known = 1;
}
else
attr = dwarf2_attr (die, DW_AT_low_pc, cu);
if (attr != nullptr)
{
- cu->base_address = attr_value_as_address (attr);
+ cu->base_address = attr->value_as_address ();
cu->base_known = 1;
}
}
sect_offset_str (die->sect_off), objfile_name (objfile));
return;
}
- pc = attr_value_as_address (attr) + baseaddr;
+ pc = attr->value_as_address () + baseaddr;
pc = gdbarch_adjust_dwarf2_addr (gdbarch, pc);
if (cu->call_site_htab == NULL)
SET_FIELD_DWARF_BLOCK (call_site->target, dlbaton);
}
- else if (attr_form_is_ref (attr))
+ else if (attr->form_is_ref ())
{
struct dwarf2_cu *target_cu = cu;
struct die_info *target_die;
for DW_AT_call_parameter. */
origin = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
}
- if (loc == NULL && origin != NULL && attr_form_is_ref (origin))
+ if (loc == NULL && origin != NULL && origin->form_is_ref ())
{
parameter->kind = CALL_SITE_PARAMETER_PARAM_OFFSET;
struct die_info *type_die = NULL;
struct dwarf2_cu *type_cu = cu;
- if (attr_form_is_ref (attr))
+ if (attr->form_is_ref ())
type_die = follow_die_ref (die, attr, &type_cu);
if (type_die == NULL)
return NULL;
attr = dwarf2_attr (die, DW_AT_low_pc, cu);
if (attr != nullptr)
{
- low = attr_value_as_address (attr);
- high = attr_value_as_address (attr_high);
- if (cu->header.version >= 4 && attr_form_is_constant (attr_high))
+ low = attr->value_as_address ();
+ high = attr_high->value_as_address ();
+ if (cu->header.version >= 4 && attr_high->form_is_constant ())
high += low;
}
else
attr = dwarf2_attr (die, DW_AT_low_pc, cu);
if (attr != nullptr)
{
- CORE_ADDR low = attr_value_as_address (attr);
- CORE_ADDR high = attr_value_as_address (attr_high);
+ CORE_ADDR low = attr->value_as_address ();
+ CORE_ADDR high = attr_high->value_as_address ();
- if (cu->header.version >= 4 && attr_form_is_constant (attr_high))
+ if (cu->header.version >= 4 && attr_high->form_is_constant ())
high += low;
low = gdbarch_adjust_dwarf2_addr (gdbarch, low + baseaddr);
This is because DW_AT_data_member_location is new in DWARF 4,
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 (attr))
+ if (attr->form_is_constant ())
*offset = dwarf2_get_attr_constant_value (attr, 0);
- else if (attr_form_is_section_offset (attr))
+ else if (attr->form_is_section_offset ())
dwarf2_complex_location_expr_complaint ();
else if (attr_form_is_block (attr))
*offset = decode_locdesc (DW_BLOCK (attr), cu);
}
}
}
- else if (attr_form_is_section_offset (attr))
+ else if (attr->form_is_section_offset ())
{
dwarf2_complex_location_expr_complaint ();
}
if (attr == nullptr)
return 0;
- if (!attr_form_is_constant (attr))
+ if (!attr->form_is_constant ())
{
complaint (_("DW_AT_alignment must have constant form"
" - DIE at %s [in module %s]"),
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr != nullptr)
{
- if (attr_form_is_constant (attr))
+ if (attr->form_is_constant ())
TYPE_LENGTH (type) = DW_UNSND (attr);
else
{
In this case arrange not to check the offset. */
is_variant_part = false;
}
- else if (attr_form_is_ref (discr))
+ else if (discr->form_is_ref ())
{
struct dwarf2_cu *target_cu = cu;
struct die_info *target_die = follow_die_ref (die, discr, &target_cu);
gdb_assert (common_loc && member_loc);
gdb_assert (attr_form_is_block (common_loc));
gdb_assert (attr_form_is_block (member_loc)
- || attr_form_is_constant (member_loc));
+ || member_loc->form_is_constant ());
baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
baton->per_cu = cu->per_cu;
baton->size = 5 /* DW_OP_call4 */ + 1 /* DW_OP_plus */;
- if (attr_form_is_constant (member_loc))
+ if (member_loc->form_is_constant ())
{
offset = dwarf2_get_attr_constant_value (member_loc, 0);
baton->size += 1 /* DW_OP_addr */ + cu->header.addr_size;
store_unsigned_integer (ptr, 4, byte_order, cu_off);
ptr += 4;
- if (attr_form_is_constant (member_loc))
+ if (member_loc->form_is_constant ())
{
*ptr++ = DW_OP_addr;
store_unsigned_integer (ptr, cu->header.addr_size, byte_order, offset);
{
/* Ok. */
}
- else if (attr_form_is_section_offset (attr))
+ else if (attr->form_is_section_offset ())
{
dwarf2_complex_location_expr_complaint ();
attr = NULL;
sect_offset_str (child_die->sect_off),
objfile_name (objfile));
- if (attr_form_is_section_offset (member_loc))
+ if (member_loc->form_is_section_offset ())
dwarf2_complex_location_expr_complaint ();
- else if (attr_form_is_constant (member_loc)
+ else if (member_loc->form_is_constant ()
|| attr_form_is_block (member_loc))
{
if (attr != nullptr)
}
attr = dwarf2_attr (die, DW_AT_string_length, cu);
- if (attr != nullptr && !attr_form_is_constant (attr))
+ if (attr != nullptr && !attr->form_is_constant ())
{
/* The string length describes the location at which the length of
the string can be found. The size of the length field can be
= dwarf2_attr (die, DW_AT_string_length_byte_size, cu);
if (len == nullptr)
len = dwarf2_attr (die, DW_AT_byte_size, cu);
- if (len != nullptr && attr_form_is_constant (len))
+ if (len != nullptr && len->form_is_constant ())
{
/* Pass 0 as the default as we know this attribute is constant
and the default value will not be returned. */
prop->kind = PROP_LOCEXPR;
gdb_assert (prop->data.baton != NULL);
}
- else if (attr_form_is_ref (attr))
+ else if (attr->form_is_ref ())
{
struct dwarf2_cu *target_cu = cu;
struct die_info *target_die;
switch (target_attr->name)
{
case DW_AT_location:
- if (attr_form_is_section_offset (target_attr))
+ if (target_attr->form_is_section_offset ())
{
baton = XOBNEW (obstack, struct dwarf2_property_baton);
baton->property_type = die_type (target_die, target_cu);
}
}
}
- else if (attr_form_is_constant (attr))
+ else if (attr->form_is_constant ())
{
prop->data.const_val = dwarf2_get_attr_constant_value (attr, 0);
prop->kind = PROP_CONST;
LONGEST bias = 0;
struct attribute *bias_attr = dwarf2_attr (die, DW_AT_GNU_bias, cu);
- if (bias_attr != nullptr && attr_form_is_constant (bias_attr))
+ if (bias_attr != nullptr && bias_attr->form_is_constant ())
bias = dwarf2_get_attr_constant_value (bias_attr, 0);
/* Normally, the DWARF producers are expected to use a signed
break;
case DW_AT_low_pc:
has_low_pc_attr = 1;
- lowpc = attr_value_as_address (&attr);
+ lowpc = attr.value_as_address ();
break;
case DW_AT_high_pc:
has_high_pc_attr = 1;
- highpc = attr_value_as_address (&attr);
- if (cu->header.version >= 4 && attr_form_is_constant (&attr))
+ highpc = attr.value_as_address ();
+ if (cu->header.version >= 4 && attr.form_is_constant ())
high_pc_relative = 1;
break;
case DW_AT_location:
{
d.locdesc = DW_BLOCK (&attr);
}
- else if (attr_form_is_section_offset (&attr))
+ else if (attr.form_is_section_offset ())
{
dwarf2_complex_location_expr_complaint ();
}
}
/* Super hack. */
- if (cu->per_cu->is_dwz && attr_form_is_ref (attr))
+ if (cu->per_cu->is_dwz && attr->form_is_ref ())
attr->form = DW_FORM_GNU_ref_alt;
/* We have seen instances where the compiler tried to emit a byte
{
CORE_ADDR addr;
- addr = attr_value_as_address (attr);
+ addr = attr->value_as_address ();
addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + baseaddr);
SET_SYMBOL_VALUE_ADDRESS (sym, addr);
}
dwarf2_per_objfile);
this_type = get_die_type_at_offset (sect_off, per_cu);
}
- else if (attr_form_is_ref (attr))
+ else if (attr->form_is_ref ())
{
sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
struct die_info *type_die = NULL;
struct dwarf2_cu *type_cu = cu;
- if (attr_form_is_ref (attr))
+ if (attr->form_is_ref ())
type_die = follow_die_ref (die, attr, &type_cu);
if (type_die == NULL)
return build_error_marker_type (cu, die);
static sect_offset
dwarf2_get_ref_die_offset (const struct attribute *attr)
{
- if (attr_form_is_ref (attr))
+ if (attr->form_is_ref ())
return (sect_offset) DW_UNSND (attr);
complaint (_("unsupported die ref attribute form: '%s'"),
return DW_UNSND (attr);
else
{
- /* For DW_FORM_data16 see attr_form_is_constant. */
+ /* 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;
{
struct die_info *die;
- if (attr_form_is_ref (attr))
+ if (attr->form_is_ref ())
die = follow_die_ref (src_die, attr, ref_cu);
else if (attr->form == DW_FORM_ref_sig8)
die = follow_die_sig (src_die, attr, ref_cu);
retval.data = NULL;
retval.size = 0;
}
- else if (attr_form_is_section_offset (attr))
+ else if (attr->form_is_section_offset ())
{
struct dwarf2_loclist_baton loclist_baton;
CORE_ADDR pc = (*get_frame_pc) (baton);
struct dwarf2_cu *cu) /* ARI: editCase function */
{
/* Yes, DW_AT_signature can use a non-ref_sig8 reference. */
- if (attr_form_is_ref (attr))
+ if (attr->form_is_ref ())
{
struct dwarf2_cu *type_cu = cu;
struct die_info *type_die = follow_die_ref (die, attr, &type_cu);
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_section_info *section = cu_debug_loc_section (cu);
- if (attr_form_is_section_offset (attr)
+ if (attr->form_is_section_offset ()
/* .debug_loc{,.dwo} may not exist at all, or the offset may be outside
the section. If so, fall through to the complaint in the
other branch. */