gdb: remove FIELD_TYPE macro
[deliverable/binutils-gdb.git] / gdb / dwarf2 / attribute.h
index c2602310715c26ccd72aae36070436ffcadce1d5..ffb91e878f108216f823bf1afdb9c2f746bce39e 100644 (file)
@@ -28,6 +28,7 @@
 #define GDB_DWARF2_ATTRIBUTE_H
 
 #include "dwarf2.h"
+#include "gdbtypes.h"
 
 /* Blocks are a bunch of untyped bytes.  */
 struct dwarf_block
@@ -45,6 +46,10 @@ struct attribute
      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.
@@ -58,7 +63,7 @@ struct attribute
 
   /* 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
@@ -69,21 +74,47 @@ struct attribute
      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.  */
 
   bool form_is_block () const;
 
+  /* 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
+  {
+    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
+     constant.  */
+
+  LONGEST constant_value (int default_value) const;
+
 
   ENUM_BITFIELD(dwarf_attribute) name : 16;
   ENUM_BITFIELD(dwarf_form) form : 15;
@@ -103,6 +134,12 @@ struct attribute
       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.  */
This page took 0.024061 seconds and 4 git commands to generate.