attribute's form into account. */
CORE_ADDR value_as_address () const;
+ /* If the attribute has a string form, return the string value;
+ otherwise return NULL. */
+ const char *value_as_string () 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.
/* 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.
+ the constant_value method to it.
However, note that for some attributes you must check
attr_form_is_section_offset before using this test. DW_FORM_data4
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. */
+ DW_FORM_data16 is not considered as 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;
+ bool form_is_ref () const
+ {
+ return (form == DW_FORM_ref_addr
+ || form == DW_FORM_ref1
+ || form == DW_FORM_ref2
+ || form == DW_FORM_ref4
+ || form == DW_FORM_ref8
+ || form == DW_FORM_ref_udata
+ || form == DW_FORM_GNU_ref_alt);
+ }
/* Check if the attribute's form is a DW_FORM_block*
if so return true else false. */
/* Return DIE offset of this attribute. Return 0 with complaint if
the attribute is not of the required kind. */
- sect_offset get_ref_die_offset () const;
+ sect_offset get_ref_die_offset () const
+ {
+ if (form_is_ref ())
+ return (sect_offset) u.unsnd;
+ get_ref_die_offset_complaint ();
+ return {};
+ }
/* Return the constant value held by this attribute. Return
DEFAULT_VALUE if the value held by the attribute is not
ULONGEST signature;
}
u;
+
+private:
+
+ /* Used by get_ref_die_offset to issue a complaint. */
+
+ void get_ref_die_offset_complaint () const;
};
/* Get at parts of an attribute structure. */