enum dwarf_form form;
};
+/* Attributes have a name and a value */
+struct attribute
+ {
+ enum dwarf_attribute name;
+ enum dwarf_form form;
+ union
+ {
+ char *str;
+ struct dwarf_block *blk;
+ unsigned long unsnd;
+ long int snd;
+ CORE_ADDR addr;
+ }
+ u;
+ };
+
/* This data structure holds a complete die structure. */
struct die_info
{
unsigned int abbrev; /* Abbrev number */
unsigned int offset; /* Offset in .debug_info section */
unsigned int num_attrs; /* Number of attributes */
- struct attribute *attrs; /* An array of attributes */
/* The dies in a compilation unit form an n-ary tree. PARENT
points to this die's parent; CHILD points to the first child of
struct die_info *child; /* Its first child, if any. */
struct die_info *sibling; /* Its next sibling, if any. */
struct die_info *parent; /* Its parent, if any. */
- };
-/* Attributes have a name and a value */
-struct attribute
- {
- enum dwarf_attribute name;
- enum dwarf_form form;
- union
- {
- char *str;
- struct dwarf_block *blk;
- unsigned long unsnd;
- long int snd;
- CORE_ADDR addr;
- }
- u;
+ /* An array of attributes, with NUM_ATTRS elements. There may be
+ zero, but it's not common and zero-sized arrays are not
+ sufficiently portable C. */
+ struct attribute attrs[1];
};
struct function_range
static struct abbrev_info *dwarf_alloc_abbrev (struct dwarf2_cu *);
-static struct die_info *dwarf_alloc_die (struct dwarf2_cu *);
+static struct die_info *dwarf_alloc_die (struct dwarf2_cu *, int);
static void initialize_cu_func_list (struct dwarf2_cu *);
abbrev_number,
bfd_get_filename (abfd));
}
- die = dwarf_alloc_die (cu);
+ die = dwarf_alloc_die (cu, abbrev->num_attrs);
die->offset = offset;
die->tag = abbrev->tag;
die->abbrev = abbrev_number;
die->num_attrs = abbrev->num_attrs;
- die->attrs = (struct attribute *)
- obstack_alloc (&cu->comp_unit_obstack,
- die->num_attrs * sizeof (struct attribute));
for (i = 0; i < abbrev->num_attrs; ++i)
{
}
static struct die_info *
-dwarf_alloc_die (struct dwarf2_cu *cu)
+dwarf_alloc_die (struct dwarf2_cu *cu, int num_attrs)
{
struct die_info *die;
+ size_t size = sizeof (struct die_info);
+
+ if (num_attrs > 1)
+ size += (num_attrs - 1) * sizeof (struct attribute);
- die = (struct die_info *)
- obstack_alloc (&cu->comp_unit_obstack, sizeof (struct die_info));
+ die = (struct die_info *) obstack_alloc (&cu->comp_unit_obstack, size);
memset (die, 0, sizeof (struct die_info));
return (die);
}