+2010-03-10 Tom Tromey <tromey@redhat.com>
+
+ * elfread.c (elf_symfile_read): Don't call
+ dwarf2_build_frame_info.
+ * dwarf2read.c (struct dwarf2_section_info) <readin>: New field.
+ (struct dwarf2_per_objfile) <objfile>: New field.
+ (dwarf2_has_info): Now idempotent. Set objfile field.
+ (dwarf2_read_section): Check and set readin field. Call
+ posix_madvise.
+ (dwarf2_build_psymtabs): Don't read all sections.
+ (read_type_comp_unit_head): Read types section.
+ (create_debug_types_hash_table): Likewise.
+ (init_cu_die_reader): Add asserts.
+ (process_type_comp_unit): Add assert.
+ (dwarf2_build_psymtabs_hard): Read info section.
+ (load_partial_comp_unit): Add assert.
+ (create_all_comp_units): Read info section.
+ (load_full_comp_unit): Likewise.
+ (dwarf2_ranges_read): Read ranges section.
+ (dwarf2_record_block_ranges): Add assert.
+ (dwarf2_read_abbrevs): Read abbrev section.
+ (read_indirect_string): Read str section.
+ (dwarf_decode_line_header): Read line section.
+ (read_signatured_type_at_offset): Read types section.
+ (dwarf_decode_macros): Read macinfo section.
+ (dwarf2_symbol_mark_computed): Read loc section.
+ * dwarf2-frame.c (dwarf2_frame_find_fde): Call
+ dwarf2_build_frame_info.
+ (dwarf2_build_frame_info): Unconditionally set
+ dwarf2_frame_objfile_data on the objfile.
+ * configure.ac: Check for posix_madvise.
+ * config.in, configure: Rebuild.
+
2010-03-10 Tom Tromey <tromey@redhat.com>
* xcoffread.c (xcoff_start_psymtab): Update.
* dbxread.c (start_psymtab): Update.
(end_psymtab): Likewise.
-2010-30-10 Tom Tromey <tromey@redhat.com>
+2010-03-10 Tom Tromey <tromey@redhat.com>
* xcoffread.c: Include psymtab.h.
(xcoff_sym_fns): Update.
fde_table = objfile_data (objfile, dwarf2_frame_objfile_data);
if (fde_table == NULL)
+ {
+ dwarf2_build_frame_info (objfile);
+ fde_table = objfile_data (objfile, dwarf2_frame_objfile_data);
+ }
+ gdb_assert (fde_table != NULL);
+
+ if (fde_table->num_entries == 0)
continue;
gdb_assert (objfile->section_offsets);
gdb_byte *frame_ptr;
struct dwarf2_cie_table cie_table;
struct dwarf2_fde_table fde_table;
+ struct dwarf2_fde_table *fde_table2;
cie_table.num_entries = 0;
cie_table.entries = NULL;
cie_table.num_entries = 0; /* Paranoia. */
}
- if (fde_table.num_entries != 0)
+ /* Copy fde_table to obstack: it is needed at runtime. */
+ fde_table2 = (struct dwarf2_fde_table *)
+ obstack_alloc (&objfile->objfile_obstack, sizeof (*fde_table2));
+
+ if (fde_table.num_entries == 0)
+ {
+ fde_table2->entries = NULL;
+ fde_table2->num_entries = 0;
+ }
+ else
{
- struct dwarf2_fde_table *fde_table2;
struct dwarf2_fde *fde_prev = NULL;
struct dwarf2_fde *first_non_zero_fde = NULL;
int i;
qsort (fde_table.entries, fde_table.num_entries,
sizeof (fde_table.entries[0]), qsort_fde_cmp);
- /* Copy fde_table to obstack: it is needed at runtime. */
- fde_table2 = (struct dwarf2_fde_table *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (*fde_table2));
- fde_table2->num_entries = 0;
-
/* Check for leftovers from --gc-sections. The GNU linker sets
the relevant symbols to zero, but doesn't zero the FDE *end*
ranges because there's no relocation there. It's (offset,
/* Since we'll be doing bsearch, squeeze out identical (except
for eh_frame_p) fde entries so bsearch result is predictable.
Also discard leftovers from --gc-sections. */
+ fde_table2->num_entries = 0;
for (i = 0; i < fde_table.num_entries; i++)
{
struct dwarf2_fde *fde = fde_table.entries[i];
fde_prev = fde;
}
fde_table2->entries = obstack_finish (&objfile->objfile_obstack);
- set_objfile_data (objfile, dwarf2_frame_objfile_data, fde_table2);
/* Discard the original fde_table. */
xfree (fde_table.entries);
}
+
+ set_objfile_data (objfile, dwarf2_frame_objfile_data, fde_table2);
}
/* Provide a prototype to silence -Wmissing-prototypes. */
gdb_byte *buffer;
bfd_size_type size;
int was_mmapped;
+ /* True if we have tried to read this section. */
+ int readin;
};
struct dwarf2_per_objfile
struct dwarf2_section_info frame;
struct dwarf2_section_info eh_frame;
+ /* Back link. */
+ struct objfile *objfile;
+
/* A list of all the compilation units. This is used to locate
the target compilation unit of a particular reference. */
struct dwarf2_per_cu_data **all_comp_units;
int
dwarf2_has_info (struct objfile *objfile)
{
- struct dwarf2_per_objfile *data;
-
- /* Initialize per-objfile state. */
- data = obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
- memset (data, 0, sizeof (*data));
- set_objfile_data (objfile, dwarf2_objfile_data_key, data);
- dwarf2_per_objfile = data;
+ dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
+ if (!dwarf2_per_objfile)
+ {
+ /* Initialize per-objfile state. */
+ struct dwarf2_per_objfile *data
+ = obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
+ memset (data, 0, sizeof (*data));
+ set_objfile_data (objfile, dwarf2_objfile_data_key, data);
+ dwarf2_per_objfile = data;
- bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
- return (data->info.asection != NULL && data->abbrev.asection != NULL);
+ bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
+ dwarf2_per_objfile->objfile = objfile;
+ }
+ return (dwarf2_per_objfile->info.asection != NULL
+ && dwarf2_per_objfile->abbrev.asection != NULL);
}
/* When loading sections, we can either look for ".<name>", or for
gdb_byte *buf, *retbuf;
unsigned char header[4];
+ if (info->readin)
+ return;
info->buffer = NULL;
info->was_mmapped = 0;
+ info->readin = 1;
if (info->asection == NULL || info->size == 0)
return;
{
info->was_mmapped = 1;
info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ;
+#if HAVE_POSIX_MADVISE
+ posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED);
+#endif
return;
}
}
void
dwarf2_build_psymtabs (struct objfile *objfile)
{
- dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->abbrev);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->line);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->str);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->macinfo);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->ranges);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->loc);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->eh_frame);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->frame);
-
if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)
{
init_psymbol_list (objfile, 1024);
unsigned int bytes_read;
gdb_byte *initial_types_ptr = types_ptr;
+ dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->types);
cu_header->offset = types_ptr - dwarf2_per_objfile->types.buffer;
types_ptr = read_comp_unit_head (cu_header, types_ptr, abfd);
static int
create_debug_types_hash_table (struct objfile *objfile)
{
- gdb_byte *info_ptr = dwarf2_per_objfile->types.buffer;
+ gdb_byte *info_ptr;
htab_t types_htab;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
+ info_ptr = dwarf2_per_objfile->types.buffer;
+
if (info_ptr == NULL)
{
dwarf2_per_objfile->signatured_types = NULL;
reader->abfd = cu->objfile->obfd;
reader->cu = cu;
if (cu->per_cu->from_debug_types)
- reader->buffer = dwarf2_per_objfile->types.buffer;
+ {
+ gdb_assert (dwarf2_per_objfile->types.readin);
+ reader->buffer = dwarf2_per_objfile->types.buffer;
+ }
else
- reader->buffer = dwarf2_per_objfile->info.buffer;
+ {
+ gdb_assert (dwarf2_per_objfile->info.readin);
+ reader->buffer = dwarf2_per_objfile->info.buffer;
+ }
}
/* Find the base address of the compilation unit for range lists and
this_cu = &entry->per_cu;
this_cu->from_debug_types = 1;
+ gdb_assert (dwarf2_per_objfile->types.readin);
process_psymtab_comp_unit (objfile, this_cu,
dwarf2_per_objfile->types.buffer,
dwarf2_per_objfile->types.buffer + entry->offset,
static void
dwarf2_build_psymtabs_hard (struct objfile *objfile)
{
- /* Instead of reading this into a big buffer, we should probably use
- mmap() on architectures that support it. (FIXME) */
bfd *abfd = objfile->obfd;
gdb_byte *info_ptr;
struct cleanup *back_to;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
info_ptr = dwarf2_per_objfile->info.buffer;
/* Any cached compilation units will be linked by the per-objfile
gdb_assert (! this_cu->from_debug_types);
+ gdb_assert (dwarf2_per_objfile->info.readin);
info_ptr = dwarf2_per_objfile->info.buffer + this_cu->offset;
beg_of_comp_unit = info_ptr;
int n_allocated;
int n_comp_units;
struct dwarf2_per_cu_data **all_comp_units;
- gdb_byte *info_ptr = dwarf2_per_objfile->info.buffer;
+ gdb_byte *info_ptr;
+
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
+ info_ptr = dwarf2_per_objfile->info.buffer;
n_comp_units = 0;
n_allocated = 10;
/* Set local variables from the partial symbol table info. */
offset = per_cu->offset;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
info_ptr = dwarf2_per_objfile->info.buffer + offset;
beg_of_comp_unit = info_ptr;
found_base = cu->base_known;
base = cu->base_address;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->ranges);
if (offset >= dwarf2_per_objfile->ranges.size)
{
complaint (&symfile_complaints,
CORE_ADDR base = cu->base_address;
int base_known = cu->base_known;
+ gdb_assert (dwarf2_per_objfile->ranges.readin);
if (offset >= dwarf2_per_objfile->ranges.size)
{
complaint (&symfile_complaints,
memset (cu->dwarf2_abbrevs, 0,
ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
+ &dwarf2_per_objfile->abbrev);
abbrev_ptr = dwarf2_per_objfile->abbrev.buffer + cu_header->abbrev_offset;
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
{
LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
+ dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->str);
if (dwarf2_per_objfile->str.buffer == NULL)
{
error (_("DW_FORM_strp used without .debug_str section [in module %s]"),
int i;
char *cur_dir, *cur_file;
+ dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->line);
if (dwarf2_per_objfile->line.buffer == NULL)
{
complaint (&symfile_complaints, _("missing .debug_line section"));
{
struct signatured_type *type_sig;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
+
/* We have the section offset, but we need the signature to do the
hash table lookup. */
type_sig = lookup_signatured_type_at_offset (objfile, offset);
enum dwarf_macinfo_record_type macinfo_type;
int at_commandline;
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
+ &dwarf2_per_objfile->macinfo);
if (dwarf2_per_objfile->macinfo.buffer == NULL)
{
complaint (&symfile_complaints, _("missing .debug_macinfo section"));
baton->per_cu = cu->per_cu;
gdb_assert (baton->per_cu);
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
+ &dwarf2_per_objfile->loc);
+
/* We don't know how long the location list is, but make sure we
don't run off the edge of the section. */
baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr);