gdb: fix off-by-one error in quirk_rust_enum
[deliverable/binutils-gdb.git] / gdb / dwarf2 / die.h
index f8826a276e8b700b86f21a2074fcca11a778ecd7..5522ebdf3114f013b70184811c930db8d90be194 100644 (file)
 /* This data structure holds a complete die structure.  */
 struct die_info
 {
+  /* Return the named attribute or NULL if not there, but do not
+     follow DW_AT_specification, etc.  */
+  struct attribute *attr (dwarf_attribute name)
+  {
+    for (unsigned i = 0; i < num_attrs; ++i)
+      if (attrs[i].name == name)
+       return &attrs[i];
+    return NULL;
+  }
+
+  /* Return the address base of the compile unit, which, if exists, is
+     stored either at the attribute DW_AT_GNU_addr_base, or
+     DW_AT_addr_base.  */
+  gdb::optional<ULONGEST> addr_base ()
+  {
+    for (unsigned i = 0; i < num_attrs; ++i)
+      if (attrs[i].name == DW_AT_addr_base
+         || attrs[i].name == DW_AT_GNU_addr_base)
+       {
+         /* If both exist, just use the first one.  */
+         return DW_UNSND (&attrs[i]);
+       }
+    return gdb::optional<ULONGEST> ();
+  }
+
+  /* Return range lists base of the compile unit, which, if exists, is
+     stored either at the attribute DW_AT_rnglists_base or
+     DW_AT_GNU_ranges_base.  */
+  ULONGEST ranges_base ()
+  {
+    for (unsigned i = 0; i < num_attrs; ++i)
+      if (attrs[i].name == DW_AT_rnglists_base
+         || attrs[i].name == DW_AT_GNU_ranges_base)
+       {
+         /* If both exist, just use the first one.  */
+         return DW_UNSND (&attrs[i]);
+       }
+    return 0;
+  }
+
+
   /* DWARF-2 tag for this DIE.  */
   ENUM_BITFIELD(dwarf_tag) tag : 16;
 
This page took 0.031412 seconds and 4 git commands to generate.