union
{
/* If this is a real section, the bfd section. */
- asection *asection;
+ asection *section;
/* If this is a virtual section, pointer to the containing ("real")
section. */
struct dwarf2_section_info *containing_section;
/* True if we have tried to read this section. */
char readin;
/* True if this is a virtual section, False otherwise.
- This specifies which of s.asection and s.containing_section to use. */
+ This specifies which of s.section and s.containing_section to use. */
char is_virtual;
};
static void read_signatured_type (struct signatured_type *);
+static int attr_to_dynamic_prop (const struct attribute *attr,
+ struct die_info *die, struct dwarf2_cu *cu,
+ struct dynamic_prop *prop);
+
/* memory allocation interface */
static struct dwarf_block *dwarf_alloc_block (struct dwarf2_cu *);
{
/* Initialize per-objfile state. */
struct dwarf2_per_objfile *data
- = obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
+ = XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_objfile);
memset (data, 0, sizeof (*data));
set_objfile_data (objfile, dwarf2_objfile_data_key, data);
dwarf2_per_objfile->objfile = objfile;
}
return (!dwarf2_per_objfile->info.is_virtual
- && dwarf2_per_objfile->info.s.asection != NULL
+ && dwarf2_per_objfile->info.s.section != NULL
&& !dwarf2_per_objfile->abbrev.is_virtual
- && dwarf2_per_objfile->abbrev.s.asection != NULL);
+ && dwarf2_per_objfile->abbrev.s.section != NULL);
}
/* Return the containing section of virtual section SECTION. */
section = get_containing_section (section);
gdb_assert (!section->is_virtual);
}
- return section->s.asection->owner;
+ return section->s.section->owner;
}
/* Return the bfd section of SECTION.
section = get_containing_section (section);
gdb_assert (!section->is_virtual);
}
- return section->s.asection;
+ return section->s.section;
}
/* Return the name of SECTION. */
}
else if (section_is_p (sectp->name, &names->info))
{
- dwarf2_per_objfile->info.s.asection = sectp;
+ dwarf2_per_objfile->info.s.section = sectp;
dwarf2_per_objfile->info.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->abbrev))
{
- dwarf2_per_objfile->abbrev.s.asection = sectp;
+ dwarf2_per_objfile->abbrev.s.section = sectp;
dwarf2_per_objfile->abbrev.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->line))
{
- dwarf2_per_objfile->line.s.asection = sectp;
+ dwarf2_per_objfile->line.s.section = sectp;
dwarf2_per_objfile->line.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->loc))
{
- dwarf2_per_objfile->loc.s.asection = sectp;
+ dwarf2_per_objfile->loc.s.section = sectp;
dwarf2_per_objfile->loc.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macinfo))
{
- dwarf2_per_objfile->macinfo.s.asection = sectp;
+ dwarf2_per_objfile->macinfo.s.section = sectp;
dwarf2_per_objfile->macinfo.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macro))
{
- dwarf2_per_objfile->macro.s.asection = sectp;
+ dwarf2_per_objfile->macro.s.section = sectp;
dwarf2_per_objfile->macro.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str))
{
- dwarf2_per_objfile->str.s.asection = sectp;
+ dwarf2_per_objfile->str.s.section = sectp;
dwarf2_per_objfile->str.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->addr))
{
- dwarf2_per_objfile->addr.s.asection = sectp;
+ dwarf2_per_objfile->addr.s.section = sectp;
dwarf2_per_objfile->addr.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->frame))
{
- dwarf2_per_objfile->frame.s.asection = sectp;
+ dwarf2_per_objfile->frame.s.section = sectp;
dwarf2_per_objfile->frame.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->eh_frame))
{
- dwarf2_per_objfile->eh_frame.s.asection = sectp;
+ dwarf2_per_objfile->eh_frame.s.section = sectp;
dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->ranges))
{
- dwarf2_per_objfile->ranges.s.asection = sectp;
+ dwarf2_per_objfile->ranges.s.section = sectp;
dwarf2_per_objfile->ranges.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->types))
struct dwarf2_section_info type_section;
memset (&type_section, 0, sizeof (type_section));
- type_section.s.asection = sectp;
+ type_section.s.section = sectp;
type_section.size = bfd_get_section_size (sectp);
VEC_safe_push (dwarf2_section_info_def, dwarf2_per_objfile->types,
}
else if (section_is_p (sectp->name, &names->gdb_index))
{
- dwarf2_per_objfile->gdb_index.s.asection = sectp;
+ dwarf2_per_objfile->gdb_index.s.section = sectp;
dwarf2_per_objfile->gdb_index.size = bfd_get_section_size (sectp);
}
{
if (section->is_virtual)
return section->size == 0;
- return section->s.asection == NULL || section->size == 0;
+ return section->s.section == NULL || section->size == 0;
}
/* Read the contents of the section INFO.
is ELF-only (at the time of writing). */
if (section_is_p (sectp->name, &dwarf2_elf_names.abbrev))
{
- dwz_file->abbrev.s.asection = sectp;
+ dwz_file->abbrev.s.section = sectp;
dwz_file->abbrev.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.info))
{
- dwz_file->info.s.asection = sectp;
+ dwz_file->info.s.section = sectp;
dwz_file->info.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.str))
{
- dwz_file->str.s.asection = sectp;
+ dwz_file->str.s.section = sectp;
dwz_file->str.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.line))
{
- dwz_file->line.s.asection = sectp;
+ dwz_file->line.s.section = sectp;
dwz_file->line.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.macro))
{
- dwz_file->macro.s.asection = sectp;
+ dwz_file->macro.s.section = sectp;
dwz_file->macro.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.gdb_index))
{
- dwz_file->gdb_index.s.asection = sectp;
+ dwz_file->gdb_index.s.section = sectp;
dwz_file->gdb_index.size = bfd_get_section_size (sectp);
}
}
struct dwz_file *dwz;
dwarf2_per_objfile->n_comp_units = (cu_list_elements + dwz_elements) / 2;
- dwarf2_per_objfile->all_comp_units
- = obstack_alloc (&objfile->objfile_obstack,
- dwarf2_per_objfile->n_comp_units
- * sizeof (struct dwarf2_per_cu_data *));
+ dwarf2_per_objfile->all_comp_units =
+ XOBNEWVEC (&objfile->objfile_obstack, struct dwarf2_per_cu_data *,
+ dwarf2_per_objfile->n_comp_units);
create_cus_from_index_list (objfile, cu_list, cu_list_elements,
&dwarf2_per_objfile->info, 0, 0);
dwarf2_per_objfile->n_type_units
= dwarf2_per_objfile->n_allocated_type_units
= elements / 3;
- dwarf2_per_objfile->all_type_units
- = xmalloc (dwarf2_per_objfile->n_type_units
- * sizeof (struct signatured_type *));
+ dwarf2_per_objfile->all_type_units =
+ XNEWVEC (struct signatured_type *, dwarf2_per_objfile->n_type_units);
sig_types_hash = allocate_signatured_type_table (objfile);
create_addrmap_from_index (objfile, &local_map);
- map = obstack_alloc (&objfile->objfile_obstack, sizeof (struct mapped_index));
+ map = XOBNEW (&objfile->objfile_obstack, struct mapped_index);
*map = local_map;
dwarf2_per_objfile->index_table = map;
return;
}
- qfn = obstack_alloc (&objfile->objfile_obstack, sizeof (*qfn));
+ qfn = XOBNEW (&objfile->objfile_obstack, struct quick_file_names);
qfn->hash.dwo_unit = cu->dwo_unit;
qfn->hash.line_offset.sect_off = line_offset;
gdb_assert (slot != NULL);
find_file_and_directory (comp_unit_die, cu, &name, &comp_dir);
qfn->num_file_names = lh->num_file_names;
- qfn->file_names = obstack_alloc (&objfile->objfile_obstack,
- lh->num_file_names * sizeof (char *));
+ qfn->file_names =
+ XOBNEWVEC (&objfile->objfile_obstack, const char *, lh->num_file_names);
for (i = 0; i < lh->num_file_names; ++i)
qfn->file_names[i] = file_full_name (i + 1, lh, comp_dir);
qfn->real_names = NULL;
subpst->textlow = 0;
subpst->texthigh = 0;
- subpst->dependencies = (struct partial_symtab **)
- obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct partial_symtab *));
+ subpst->dependencies
+ = XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
dwarf2_per_objfile->n_type_units
= dwarf2_per_objfile->n_allocated_type_units
= htab_elements (types_htab);
- dwarf2_per_objfile->all_type_units
- = xmalloc (dwarf2_per_objfile->n_type_units
- * sizeof (struct signatured_type *));
+ dwarf2_per_objfile->all_type_units =
+ XNEWVEC (struct signatured_type *, dwarf2_per_objfile->n_type_units);
iter = &dwarf2_per_objfile->all_type_units[0];
htab_traverse_noresize (types_htab, add_signatured_type_cu_to_table, &iter);
gdb_assert (iter - &dwarf2_per_objfile->all_type_units[0]
else if (stub_comp_dir != NULL)
{
/* Reconstruct the comp_dir attribute to simplify the code below. */
- comp_dir = (struct attribute *)
- obstack_alloc (&cu->comp_unit_obstack, sizeof (*comp_dir));
+ comp_dir = XOBNEW (&cu->comp_unit_obstack, struct attribute);
comp_dir->name = DW_AT_comp_dir;
comp_dir->form = DW_FORM_string;
DW_STRING_IS_CANONICAL (comp_dir) = 0;
{
/* If !use_existing_cu, this_cu->cu must be NULL. */
gdb_assert (this_cu->cu == NULL);
- cu = xmalloc (sizeof (*cu));
+ cu = XNEW (struct dwarf2_cu);
init_one_comp_unit (cu, this_cu);
/* If an error occurs while loading, release our storage. */
free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
{
/* If !use_existing_cu, this_cu->cu must be NULL. */
gdb_assert (this_cu->cu == NULL);
- cu = xmalloc (sizeof (*cu));
+ cu = XNEW (struct dwarf2_cu);
init_one_comp_unit (cu, this_cu);
/* If an error occurs while loading, release our storage. */
free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
/* Fill in 'dependencies' here; we fill in 'users' in a
post-pass. */
pst->number_of_dependencies = len;
- pst->dependencies = obstack_alloc (&objfile->objfile_obstack,
- len * sizeof (struct symtab *));
+ pst->dependencies =
+ XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len);
for (i = 0;
VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
i, iter);
gdb_assert (IS_TYPE_UNIT_GROUP (per_cu));
pst->number_of_dependencies = len;
- pst->dependencies = obstack_alloc (&objfile->objfile_obstack,
- len * sizeof (struct psymtab *));
+ pst->dependencies =
+ XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len);
for (i = 0;
VEC_iterate (sig_type_ptr, tu_group->tus, i, iter);
++i)
length = read_initial_length (abfd, info_ptr, &initial_length_size);
/* Save the compilation unit for later lookup. */
- this_cu = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct dwarf2_per_cu_data));
+ this_cu = XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_cu_data);
memset (this_cu, 0, sizeof (*this_cu));
this_cu->offset = offset;
this_cu->length = length + initial_length_size;
n_comp_units = 0;
n_allocated = 10;
- all_comp_units = xmalloc (n_allocated
- * sizeof (struct dwarf2_per_cu_data *));
+ all_comp_units = XNEWVEC (struct dwarf2_per_cu_data *, n_allocated);
read_comp_units_from_section (objfile, &dwarf2_per_objfile->info, 0,
&n_allocated, &n_comp_units, &all_comp_units);
&n_allocated, &n_comp_units,
&all_comp_units);
- dwarf2_per_objfile->all_comp_units
- = obstack_alloc (&objfile->objfile_obstack,
- n_comp_units * sizeof (struct dwarf2_per_cu_data *));
+ dwarf2_per_objfile->all_comp_units = XOBNEWVEC (&objfile->objfile_obstack,
+ struct dwarf2_per_cu_data *,
+ n_comp_units);
memcpy (dwarf2_per_objfile->all_comp_units, all_comp_units,
n_comp_units * sizeof (struct dwarf2_per_cu_data *));
xfree (all_comp_units);
struct dwarf2_queue_item *item;
per_cu->queued = 1;
- item = xmalloc (sizeof (*item));
+ item = XNEW (struct dwarf2_queue_item);
item->per_cu = per_cu;
item->pretend_language = pretend_language;
item->next = NULL;
/* Now we have a transitive closure of all the included symtabs. */
len = VEC_length (compunit_symtab_ptr, result_symtabs);
cust->includes
- = obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
- (len + 1) * sizeof (struct compunit_symtab *));
+ = XOBNEWVEC (&dwarf2_per_objfile->objfile->objfile_obstack,
+ struct compunit_symtab *, len + 1);
for (ix = 0;
VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
compunit_symtab_iter);
compilation is from a C file generated by language preprocessors, do
not set the language if it was already deduced by start_subfile. */
if (!(cu->language == language_c
- && COMPUNIT_FILETABS (cust)->language != language_c))
+ && COMPUNIT_FILETABS (cust)->language != language_unknown))
COMPUNIT_FILETABS (cust)->language = cu->language;
/* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can
if (section_is_p (sectp->name, &names->abbrev_dwo))
{
/* There can be only one. */
- if (sections->abbrev.s.asection != NULL)
+ if (sections->abbrev.s.section != NULL)
return 0;
- sections->abbrev.s.asection = sectp;
+ sections->abbrev.s.section = sectp;
sections->abbrev.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->info_dwo)
|| section_is_p (sectp->name, &names->types_dwo))
{
/* There can be only one. */
- if (sections->info_or_types.s.asection != NULL)
+ if (sections->info_or_types.s.section != NULL)
return 0;
- sections->info_or_types.s.asection = sectp;
+ sections->info_or_types.s.section = sectp;
sections->info_or_types.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->line_dwo))
{
/* There can be only one. */
- if (sections->line.s.asection != NULL)
+ if (sections->line.s.section != NULL)
return 0;
- sections->line.s.asection = sectp;
+ sections->line.s.section = sectp;
sections->line.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->loc_dwo))
{
/* There can be only one. */
- if (sections->loc.s.asection != NULL)
+ if (sections->loc.s.section != NULL)
return 0;
- sections->loc.s.asection = sectp;
+ sections->loc.s.section = sectp;
sections->loc.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macinfo_dwo))
{
/* There can be only one. */
- if (sections->macinfo.s.asection != NULL)
+ if (sections->macinfo.s.section != NULL)
return 0;
- sections->macinfo.s.asection = sectp;
+ sections->macinfo.s.section = sectp;
sections->macinfo.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macro_dwo))
{
/* There can be only one. */
- if (sections->macro.s.asection != NULL)
+ if (sections->macro.s.section != NULL)
return 0;
- sections->macro.s.asection = sectp;
+ sections->macro.s.section = sectp;
sections->macro.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_offsets_dwo))
{
/* There can be only one. */
- if (sections->str_offsets.s.asection != NULL)
+ if (sections->str_offsets.s.section != NULL)
return 0;
- sections->str_offsets.s.asection = sectp;
+ sections->str_offsets.s.section = sectp;
sections->str_offsets.size = bfd_get_section_size (sectp);
}
else
dwo_unit = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwo_unit);
dwo_unit->dwo_file = dwo_file;
dwo_unit->signature = signature;
- dwo_unit->section = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct dwarf2_section_info));
+ dwo_unit->section =
+ XOBNEW (&objfile->objfile_obstack, struct dwarf2_section_info);
*dwo_unit->section = sections.info_or_types;
/* dwo_unit->{offset,length,type_offset_in_tu} are set later. */
dwo_unit = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwo_unit);
dwo_unit->dwo_file = dwo_file;
dwo_unit->signature = signature;
- dwo_unit->section = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct dwarf2_section_info));
+ dwo_unit->section =
+ XOBNEW (&objfile->objfile_obstack, struct dwarf2_section_info);
*dwo_unit->section = create_dwp_v2_section (is_debug_types
? &dwp_file->sections.types
: &dwp_file->sections.info,
if (section_is_p (sectp->name, &names->abbrev_dwo))
{
- dwo_sections->abbrev.s.asection = sectp;
+ dwo_sections->abbrev.s.section = sectp;
dwo_sections->abbrev.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->info_dwo))
{
- dwo_sections->info.s.asection = sectp;
+ dwo_sections->info.s.section = sectp;
dwo_sections->info.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->line_dwo))
{
- dwo_sections->line.s.asection = sectp;
+ dwo_sections->line.s.section = sectp;
dwo_sections->line.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->loc_dwo))
{
- dwo_sections->loc.s.asection = sectp;
+ dwo_sections->loc.s.section = sectp;
dwo_sections->loc.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macinfo_dwo))
{
- dwo_sections->macinfo.s.asection = sectp;
+ dwo_sections->macinfo.s.section = sectp;
dwo_sections->macinfo.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macro_dwo))
{
- dwo_sections->macro.s.asection = sectp;
+ dwo_sections->macro.s.section = sectp;
dwo_sections->macro.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_dwo))
{
- dwo_sections->str.s.asection = sectp;
+ dwo_sections->str.s.section = sectp;
dwo_sections->str.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_offsets_dwo))
{
- dwo_sections->str_offsets.s.asection = sectp;
+ dwo_sections->str_offsets.s.section = sectp;
dwo_sections->str_offsets.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->types_dwo))
struct dwarf2_section_info type_section;
memset (&type_section, 0, sizeof (type_section));
- type_section.s.asection = sectp;
+ type_section.s.section = sectp;
type_section.size = bfd_get_section_size (sectp);
VEC_safe_push (dwarf2_section_info_def, dwo_sections->types,
&type_section);
/* Look for specific sections that we need. */
if (section_is_p (sectp->name, &names->str_dwo))
{
- dwp_file->sections.str.s.asection = sectp;
+ dwp_file->sections.str.s.section = sectp;
dwp_file->sections.str.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->cu_index))
{
- dwp_file->sections.cu_index.s.asection = sectp;
+ dwp_file->sections.cu_index.s.section = sectp;
dwp_file->sections.cu_index.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->tu_index))
{
- dwp_file->sections.tu_index.s.asection = sectp;
+ dwp_file->sections.tu_index.s.section = sectp;
dwp_file->sections.tu_index.size = bfd_get_section_size (sectp);
}
}
/* Look for specific sections that we need. */
if (section_is_p (sectp->name, &names->abbrev_dwo))
{
- dwp_file->sections.abbrev.s.asection = sectp;
+ dwp_file->sections.abbrev.s.section = sectp;
dwp_file->sections.abbrev.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->info_dwo))
{
- dwp_file->sections.info.s.asection = sectp;
+ dwp_file->sections.info.s.section = sectp;
dwp_file->sections.info.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->line_dwo))
{
- dwp_file->sections.line.s.asection = sectp;
+ dwp_file->sections.line.s.section = sectp;
dwp_file->sections.line.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->loc_dwo))
{
- dwp_file->sections.loc.s.asection = sectp;
+ dwp_file->sections.loc.s.section = sectp;
dwp_file->sections.loc.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macinfo_dwo))
{
- dwp_file->sections.macinfo.s.asection = sectp;
+ dwp_file->sections.macinfo.s.section = sectp;
dwp_file->sections.macinfo.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macro_dwo))
{
- dwp_file->sections.macro.s.asection = sectp;
+ dwp_file->sections.macro.s.section = sectp;
dwp_file->sections.macro.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_offsets_dwo))
{
- dwp_file->sections.str_offsets.s.asection = sectp;
+ dwp_file->sections.str_offsets.s.section = sectp;
dwp_file->sections.str_offsets.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->types_dwo))
{
- dwp_file->sections.types.s.asection = sectp;
+ dwp_file->sections.types.s.section = sectp;
dwp_file->sections.types.size = bfd_get_section_size (sectp);
}
}
child_die = sibling_die (child_die);
die_children_count++;
}
- offsets = xmalloc (sizeof (*offsets) * die_children_count);
+ offsets = XNEWVEC (sect_offset, die_children_count);
cleanups = make_cleanup (xfree, offsets);
offsets_end = offsets;
if (attr)
dwarf2_symbol_mark_computed (attr, newobj->name, cu, 1);
+ /* If there is a location for the static link, record it. */
+ newobj->static_link = NULL;
+ attr = dwarf2_attr (die, DW_AT_static_link, cu);
+ if (attr)
+ {
+ newobj->static_link = obstack_alloc (&objfile->objfile_obstack,
+ sizeof (*newobj->static_link));
+ attr_to_dynamic_prop (attr, die, cu, newobj->static_link);
+ }
+
cu->list_in_scope = &local_symbols;
if (die->child != NULL)
newobj = pop_context ();
/* Make a block for the local symbols within. */
block = finish_block (newobj->name, &local_symbols, newobj->old_blocks,
- lowpc, highpc);
+ newobj->static_link, lowpc, highpc);
/* For C++, set the block's scope. */
if ((cu->language == language_cplus
templ_func->n_template_arguments = VEC_length (symbolp, template_args);
templ_func->template_arguments
- = obstack_alloc (&objfile->objfile_obstack,
- (templ_func->n_template_arguments
- * sizeof (struct symbol *)));
+ = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *,
+ templ_func->n_template_arguments);
memcpy (templ_func->template_arguments,
VEC_address (symbolp, template_args),
(templ_func->n_template_arguments * sizeof (struct symbol *)));
if (local_symbols != NULL || local_using_directives != NULL)
{
struct block *block
- = finish_block (0, &local_symbols, newobj->old_blocks,
+ = finish_block (0, &local_symbols, newobj->old_blocks, NULL,
newobj->start_addr, highpc);
/* Note that recording ranges after traversing children, as we
{
struct dwarf2_locexpr_baton *dlbaton;
- dlbaton = obstack_alloc (&objfile->objfile_obstack, sizeof (*dlbaton));
+ dlbaton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
dlbaton->data = DW_BLOCK (attr)->data;
dlbaton->size = DW_BLOCK (attr)->size;
dlbaton->per_cu = cu->per_cu;
const char *fieldname = "";
/* Allocate a new field list entry and link it in. */
- new_field = (struct nextfield *) xmalloc (sizeof (struct nextfield));
+ new_field = XNEW (struct nextfield);
make_cleanup (xfree, new_field);
memset (new_field, 0, sizeof (struct nextfield));
char *fieldname = "";
/* Allocate a new field list entry and link it in. */
- new_field = xzalloc (sizeof (*new_field));
+ new_field = XCNEW (struct typedef_field_list);
make_cleanup (xfree, new_field);
gdb_assert (die->tag == DW_TAG_typedef);
/* Create a new member function field and chain it to the field list
entry. */
- new_fnfield = (struct nextfnfield *) xmalloc (sizeof (struct nextfnfield));
+ new_fnfield = XNEW (struct nextfnfield);
make_cleanup (xfree, new_fnfield);
memset (new_fnfield, 0, sizeof (struct nextfnfield));
new_fnfield->next = flp->head;
TYPE_N_TEMPLATE_ARGUMENTS (type)
= VEC_length (symbolp, template_args);
TYPE_TEMPLATE_ARGUMENTS (type)
- = obstack_alloc (&objfile->objfile_obstack,
- (TYPE_N_TEMPLATE_ARGUMENTS (type)
- * sizeof (struct symbol *)));
+ = XOBNEWVEC (&objfile->objfile_obstack,
+ struct symbol *,
+ TYPE_N_TEMPLATE_ARGUMENTS (type));
memcpy (TYPE_TEMPLATE_ARGUMENTS (type),
VEC_address (symbolp, template_args),
(TYPE_N_TEMPLATE_ARGUMENTS (type)
gdb_assert (attr_form_is_block (member_loc)
|| attr_form_is_constant (member_loc));
- baton = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct dwarf2_locexpr_baton));
+ baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
baton->per_cu = cu->per_cu;
gdb_assert (baton->per_cu);
if (attr_form_is_block (attr))
{
- baton = obstack_alloc (obstack, sizeof (*baton));
+ baton = XOBNEW (obstack, struct dwarf2_property_baton);
baton->referenced_type = NULL;
baton->locexpr.per_cu = cu->per_cu;
baton->locexpr.size = DW_BLOCK (attr)->size;
case DW_AT_location:
if (attr_form_is_section_offset (target_attr))
{
- baton = obstack_alloc (obstack, sizeof (*baton));
+ baton = XOBNEW (obstack, struct dwarf2_property_baton);
baton->referenced_type = die_type (target_die, target_cu);
fill_in_loclist_baton (cu, &baton->loclist, target_attr);
prop->data.baton = baton;
}
else if (attr_form_is_block (target_attr))
{
- baton = obstack_alloc (obstack, sizeof (*baton));
+ baton = XOBNEW (obstack, struct dwarf2_property_baton);
baton->referenced_type = die_type (target_die, target_cu);
baton->locexpr.per_cu = cu->per_cu;
baton->locexpr.size = DW_BLOCK (target_attr)->size;
&offset))
return 0;
- baton = obstack_alloc (obstack, sizeof (*baton));
+ baton = XOBNEW (obstack, struct dwarf2_property_baton);
baton->referenced_type = read_type_die (target_die->parent,
target_cu);
baton->offset_info.offset = offset;
{
struct abbrev_info *abbrev;
- abbrev = (struct abbrev_info *)
- obstack_alloc (&abbrev_table->abbrev_obstack, sizeof (struct abbrev_info));
+ abbrev = XOBNEW (&abbrev_table->abbrev_obstack, struct abbrev_info);
memset (abbrev, 0, sizeof (struct abbrev_info));
+
return abbrev;
}
abbrev_table = XNEW (struct abbrev_table);
abbrev_table->offset = offset;
obstack_init (&abbrev_table->abbrev_obstack);
- abbrev_table->abbrevs = obstack_alloc (&abbrev_table->abbrev_obstack,
- (ABBREV_HASH_SIZE
- * sizeof (struct abbrev_info *)));
+ abbrev_table->abbrevs =
+ XOBNEWVEC (&abbrev_table->abbrev_obstack, struct abbrev_info *,
+ ABBREV_HASH_SIZE);
memset (abbrev_table->abbrevs, 0,
ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
abbrev_ptr += bytes_read;
allocated_attrs = ATTR_ALLOC_CHUNK;
- cur_attrs = xmalloc (allocated_attrs * sizeof (struct attr_abbrev));
+ cur_attrs = XNEWVEC (struct attr_abbrev, allocated_attrs);
/* Loop until we reach an abbrev number of 0. */
while (abbrev_number)
abbrev_ptr += bytes_read;
}
- cur_abbrev->attrs = obstack_alloc (&abbrev_table->abbrev_obstack,
- (cur_abbrev->num_attrs
- * sizeof (struct attr_abbrev)));
+ cur_abbrev->attrs =
+ XOBNEWVEC (&abbrev_table->abbrev_obstack, struct attr_abbrev,
+ cur_abbrev->num_attrs);
memcpy (cur_abbrev->attrs, cur_attrs,
cur_abbrev->num_attrs * sizeof (struct attr_abbrev));
hashtab_obstack_allocate,
dummy_obstack_deallocate);
- part_die = obstack_alloc (&cu->comp_unit_obstack,
- sizeof (struct partial_die_info));
+ part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info);
while (1)
{
*slot = part_die;
}
- part_die = obstack_alloc (&cu->comp_unit_obstack,
- sizeof (struct partial_die_info));
+ part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info);
/* For some DIEs we want to follow their children (if any). For C
we have no reason to follow the children of structures; for other
if (lh->include_dirs_size == 0)
{
lh->include_dirs_size = 1; /* for testing */
- lh->include_dirs = xmalloc (lh->include_dirs_size
- * sizeof (*lh->include_dirs));
+ lh->include_dirs = XNEWVEC (const char *, lh->include_dirs_size);
}
else if (lh->num_include_dirs >= lh->include_dirs_size)
{
lh->include_dirs_size *= 2;
- lh->include_dirs = xrealloc (lh->include_dirs,
- (lh->include_dirs_size
- * sizeof (*lh->include_dirs)));
+ lh->include_dirs = XRESIZEVEC (const char *, lh->include_dirs,
+ lh->include_dirs_size);
}
lh->include_dirs[lh->num_include_dirs++] = include_dir;
if (lh->file_names_size == 0)
{
lh->file_names_size = 1; /* for testing */
- lh->file_names = xmalloc (lh->file_names_size
- * sizeof (*lh->file_names));
+ lh->file_names = XNEWVEC (struct file_entry, lh->file_names_size);
}
else if (lh->num_file_names >= lh->file_names_size)
{
return 0;
}
- lh = xmalloc (sizeof (*lh));
+ lh = XNEW (struct line_header);
memset (lh, 0, sizeof (*lh));
back_to = make_cleanup ((make_cleanup_ftype *) free_line_header,
(void *) lh);
line_ptr += 1;
lh->opcode_base = read_1_byte (abfd, line_ptr);
line_ptr += 1;
- lh->standard_opcode_lengths
- = xmalloc (lh->opcode_base * sizeof (lh->standard_opcode_lengths[0]));
+ lh->standard_opcode_lengths = XNEWVEC (unsigned char, lh->opcode_base);
lh->standard_opcode_lengths[0] = 1; /* This should never be used anyway. */
for (i = 1; i < lh->opcode_base; ++i)
/* Symbols of this form are reasonably rare, so we just
piggyback on the existing location code rather than writing
a new implementation of symbol_computed_ops. */
- *baton = obstack_alloc (obstack, sizeof (struct dwarf2_locexpr_baton));
+ *baton = XOBNEW (obstack, struct dwarf2_locexpr_baton);
(*baton)->per_cu = cu->per_cu;
gdb_assert ((*baton)->per_cu);
static struct dwarf_block *
dwarf_alloc_block (struct dwarf2_cu *cu)
{
- struct dwarf_block *blk;
-
- blk = (struct dwarf_block *)
- obstack_alloc (&cu->comp_unit_obstack, sizeof (struct dwarf_block));
- return (blk);
+ return XOBNEW (&cu->comp_unit_obstack, struct dwarf_block);
}
static struct die_info *
char *name = copy_string (body, p - body);
int argc = 0;
int argv_size = 1;
- char **argv = xmalloc (argv_size * sizeof (*argv));
+ char **argv = XNEWVEC (char *, argv_size);
p++;
{
struct dwarf2_loclist_baton *baton;
- baton = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct dwarf2_loclist_baton));
+ baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_loclist_baton);
fill_in_loclist_baton (cu, baton, attr);
{
struct dwarf2_locexpr_baton *baton;
- baton = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct dwarf2_locexpr_baton));
+ baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
baton->per_cu = cu->per_cu;
gdb_assert (baton->per_cu);
complaint (&symfile_complaints,
_("A problem internal to GDB: DIE 0x%x has type already set"),
die->offset.sect_off);
- *slot = obstack_alloc (&objfile->objfile_obstack, sizeof (**slot));
+ *slot = XOBNEW (&objfile->objfile_obstack,
+ struct dwarf2_per_cu_offset_and_type);
**slot = ofs;
return type;
}
eq_psymtab_cu_index,
NULL, xcalloc, xfree);
make_cleanup_htab_delete (cu_index_htab);
- psymtab_cu_index_map = (struct psymtab_cu_index_map *)
- xmalloc (sizeof (struct psymtab_cu_index_map)
- * dwarf2_per_objfile->n_comp_units);
+ psymtab_cu_index_map = XNEWVEC (struct psymtab_cu_index_map,
+ dwarf2_per_objfile->n_comp_units);
make_cleanup (xfree, psymtab_cu_index_map);
/* The CU list is already sorted, so we don't need to do additional