* breakpoint.c (save_cmdlist): No longer static.
	* gdbcmd.h (save_cmdlist): Declare.
	* symfile.c (symbol_file_add_with_addrs_or_offsets): Set
	OBJF_READNOW on objfile if readnow_symbol_files.
	* elfread.c (elf_symfile_read): Use dwarf2_initialize_objfile.
	(elf_sym_fns_gdb_index): New global.
	* dwarf2read.c: Include exceptions.h.
	(offset_type): New.
	(struct mapped_index): New.
	(dwarf2_per_cu_data_ptr): New typedef.
	(struct dwarf2_per_objfile) <using_index, index_table, gdb_index>:
	New fields.
	(GDB_INDEX_SECTION): New define.
	(struct dwarf2_per_cu_quick_data): New.
	(struct dwarf2_per_cu_data) <objfile>: New field.
	<psymtab>: Removed.
	<v>: New field.
	(byte_swap): New function.
	(MAYBE_SWAP): New macro.
	(INDEX_SUFFIX): New macro.
	(dw2_do_instantiate_symtab): New function.
	(dw2_instantiate_symtab): Likewise.
	(create_cus_from_index): Likewise.
	(create_addrmap_from_index): Likewise.
	(mapped_index_string_hash): Likewise.
	(find_slot_in_mapped_hash): Likewise.
	(dwarf2_read_index): Likewise.
	(dw2_setup): Likewise.
	(dw2_require_line_header): Likewise.
	(dw2_require_full_path): Likewise.
	(dw2_find_last_source_symtab): Likewise.
	(dw2_forget_cached_source_info): Likewise.
	(dw2_lookup_symtab): Likewise.
	(dw2_lookup_symbol): Likewise.
	(dw2_do_expand_symtabs_matching): Likewise.
	(dw2_pre_expand_symtabs_matching): Likewise.
	(dw2_print_stats): Likewise.
	(dw2_dump): Likewise.
	(dw2_relocate): Likewise.
	(dw2_expand_symtabs_for_function): Likewise.
	(dw2_expand_all_symtabs): Likewise.
	(dw2_expand_symtabs_with_filename): Likewise.
	(dw2_find_symbol_file): Likewise.
	(dw2_map_ada_symtabs): Likewise.
	(dw2_expand_symtabs_matching): Likewise.
	(dw2_find_pc_sect_symtab): Likewise.
	(dw2_map_symbol_names): Likewise.
	(dw2_map_symbol_filenames): Likewise.
	(dw2_has_symbols): Likewise.
	(dwarf2_gdb_index_functions): New global.
	(dwarf2_initialize_objfile): New function.
	(process_psymtab_comp_unit): Update.
	(add_partial_subprogram): Likewise.
	(dwarf2_psymtab_to_symtab): Likewise.
	(psymtab_to_symtab_1): Use dw2_do_instantiate_symtab.
	(process_full_comp_unit): Update.
	(find_file_and_directory): New function.
	(read_file_scope): Use find_file_and_directory.
	(dwarf2_per_cu_objfile): Update.
	(dwarf2_per_cu_addr_size): Update.
	(dwarf2_per_cu_offset_size): Update.
	(dwarf2_free_objfile): Free the index, if needed.
	(dwarf2_per_objfile_free): Unmap the index, if needed.
	(struct strtab_entry): New.
	(hash_strtab_entry): New function.
	(eq_strtab_entry): Likewise.
	(create_strtab): Likewise.
	(add_string): Likewise.
	(struct symtab_index_entry): New.
	(struct mapped_symtab): New.
	(hash_symtab_entry): New function.
	(eq_symtab_entry): Likewise.
	(delete_symtab_entry): Likewise.
	(create_index_table): Likewise.
	(create_mapped_symtab): Likewise.
	(cleanup_mapped_symtab): Likewise.
	(find_slot): Likewise.
	(hash_expand): Likewise.
	(add_index_entry): Likewise.
	(add_indices_to_cpool): Likewise.
	(write_hash_table): Likewise.
	(add_address_entry): Likewise.
	(write_psymbols): Likewise.
	(write_obstack): Likewise.
	(unlink_if_set): Likewise.
	(write_psymtabs_to_index): Likewise.
	(save_gdb_index_command): Likewise.
	(_initialize_dwarf2_read): Install "save gdb-index"
	command.
	(create_all_comp_units): Initialize 'objfile' field of CU.
	(dwarf2_locate_sections): Check for .gdb_index.
	* psymtab.h (dwarf2_gdb_index_functions): Declare.
	* symfile.h (dwarf2_initialize_objfile): Declare.
gdb/doc
	* gdb.texinfo (Index Files): New node.
This commit is contained in:
Tom Tromey 2010-07-13 20:51:34 +00:00
parent 58b6ab1339
commit 9291a0cd80
10 changed files with 1813 additions and 68 deletions

View file

@ -1,3 +1,99 @@
2010-07-13 Tom Tromey <tromey@redhat.com>
* breakpoint.c (save_cmdlist): No longer static.
* gdbcmd.h (save_cmdlist): Declare.
* symfile.c (symbol_file_add_with_addrs_or_offsets): Set
OBJF_READNOW on objfile if readnow_symbol_files.
* elfread.c (elf_symfile_read): Use dwarf2_initialize_objfile.
(elf_sym_fns_gdb_index): New global.
* dwarf2read.c: Include exceptions.h.
(offset_type): New.
(struct mapped_index): New.
(dwarf2_per_cu_data_ptr): New typedef.
(struct dwarf2_per_objfile) <using_index, index_table, gdb_index>:
New fields.
(GDB_INDEX_SECTION): New define.
(struct dwarf2_per_cu_quick_data): New.
(struct dwarf2_per_cu_data) <objfile>: New field.
<psymtab>: Removed.
<v>: New field.
(byte_swap): New function.
(MAYBE_SWAP): New macro.
(INDEX_SUFFIX): New macro.
(dw2_do_instantiate_symtab): New function.
(dw2_instantiate_symtab): Likewise.
(create_cus_from_index): Likewise.
(create_addrmap_from_index): Likewise.
(mapped_index_string_hash): Likewise.
(find_slot_in_mapped_hash): Likewise.
(dwarf2_read_index): Likewise.
(dw2_setup): Likewise.
(dw2_require_line_header): Likewise.
(dw2_require_full_path): Likewise.
(dw2_find_last_source_symtab): Likewise.
(dw2_forget_cached_source_info): Likewise.
(dw2_lookup_symtab): Likewise.
(dw2_lookup_symbol): Likewise.
(dw2_do_expand_symtabs_matching): Likewise.
(dw2_pre_expand_symtabs_matching): Likewise.
(dw2_print_stats): Likewise.
(dw2_dump): Likewise.
(dw2_relocate): Likewise.
(dw2_expand_symtabs_for_function): Likewise.
(dw2_expand_all_symtabs): Likewise.
(dw2_expand_symtabs_with_filename): Likewise.
(dw2_find_symbol_file): Likewise.
(dw2_map_ada_symtabs): Likewise.
(dw2_expand_symtabs_matching): Likewise.
(dw2_find_pc_sect_symtab): Likewise.
(dw2_map_symbol_names): Likewise.
(dw2_map_symbol_filenames): Likewise.
(dw2_has_symbols): Likewise.
(dwarf2_gdb_index_functions): New global.
(dwarf2_initialize_objfile): New function.
(process_psymtab_comp_unit): Update.
(add_partial_subprogram): Likewise.
(dwarf2_psymtab_to_symtab): Likewise.
(psymtab_to_symtab_1): Use dw2_do_instantiate_symtab.
(process_full_comp_unit): Update.
(find_file_and_directory): New function.
(read_file_scope): Use find_file_and_directory.
(dwarf2_per_cu_objfile): Update.
(dwarf2_per_cu_addr_size): Update.
(dwarf2_per_cu_offset_size): Update.
(dwarf2_free_objfile): Free the index, if needed.
(dwarf2_per_objfile_free): Unmap the index, if needed.
(struct strtab_entry): New.
(hash_strtab_entry): New function.
(eq_strtab_entry): Likewise.
(create_strtab): Likewise.
(add_string): Likewise.
(struct symtab_index_entry): New.
(struct mapped_symtab): New.
(hash_symtab_entry): New function.
(eq_symtab_entry): Likewise.
(delete_symtab_entry): Likewise.
(create_index_table): Likewise.
(create_mapped_symtab): Likewise.
(cleanup_mapped_symtab): Likewise.
(find_slot): Likewise.
(hash_expand): Likewise.
(add_index_entry): Likewise.
(add_indices_to_cpool): Likewise.
(write_hash_table): Likewise.
(add_address_entry): Likewise.
(write_psymbols): Likewise.
(write_obstack): Likewise.
(unlink_if_set): Likewise.
(write_psymtabs_to_index): Likewise.
(save_gdb_index_command): Likewise.
(_initialize_dwarf2_read): Install "save gdb-index"
command.
(create_all_comp_units): Initialize 'objfile' field of CU.
(dwarf2_locate_sections): Check for .gdb_index.
* psymtab.h (dwarf2_gdb_index_functions): Declare.
* symfile.h (dwarf2_initialize_objfile): Declare.
2010-07-13 Tom Tromey <tromey@redhat.com> 2010-07-13 Tom Tromey <tromey@redhat.com>
* symtab.c (lookup_symbol_aux_symtabs): Call pre-expand hook. * symtab.c (lookup_symbol_aux_symtabs): Call pre-expand hook.

View file

@ -430,7 +430,7 @@ static int tracepoint_count;
static struct cmd_list_element *breakpoint_set_cmdlist; static struct cmd_list_element *breakpoint_set_cmdlist;
static struct cmd_list_element *breakpoint_show_cmdlist; static struct cmd_list_element *breakpoint_show_cmdlist;
static struct cmd_list_element *save_cmdlist; struct cmd_list_element *save_cmdlist;
/* Return whether a breakpoint is an active enabled breakpoint. */ /* Return whether a breakpoint is an active enabled breakpoint. */
static int static int

View file

@ -1,3 +1,7 @@
2010-07-13 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Index Files): New node.
2010-07-13 Tom Tromey <tromey@redhat.com> 2010-07-13 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (GDB/MI Variable Objects): Remove extra 'for'. * gdb.texinfo (GDB/MI Variable Objects): Remove extra 'for'.

View file

@ -14289,6 +14289,7 @@ program. To debug a core dump of a previous run, you must also tell
@menu @menu
* Files:: Commands to specify files * Files:: Commands to specify files
* Separate Debug Files:: Debugging information in separate files * Separate Debug Files:: Debugging information in separate files
* Index Files:: Index files speed up GDB
* Symbol Errors:: Errors reading symbol files * Symbol Errors:: Errors reading symbol files
* Data Files:: GDB data files * Data Files:: GDB data files
@end menu @end menu
@ -15178,6 +15179,46 @@ gnu_debuglink_crc32 (unsigned long crc,
This computation does not apply to the ``build ID'' method. This computation does not apply to the ``build ID'' method.
@node Index Files
@section Index Files Speed Up @value{GDBN}
@cindex index files
@cindex @samp{.gdb_index} section
When @value{GDBN} finds a symbol file, it scans the symbols in the
file in order to construct an internal symbol table. This lets most
@value{GDBN} operations work quickly---at the cost of a delay early
on. For large programs, this delay can be quite lengthy, so
@value{GDBN} provides a way to build an index, which speeds up
startup.
The index is stored as a section in the symbol file. @value{GDBN} can
write the index to a file, then you can put it into the symbol file
using @command{objcopy}.
To create an index file, use the @code{save gdb-index} command:
@table @code
@item save gdb-index @var{directory}
@kindex save gdb-index
Create an index file for each symbol file currently known by
@value{GDBN}. Each file is named after its corresponding symbol file,
with @samp{.gdb-index} appended, and is written into the given
@var{directory}.
@end table
Once you have created an index file you can merge it into your symbol
file, here named @file{symfile}, using @command{objcopy}:
@smallexample
$ objcopy --add-section .gdb_index=symfile.gdb-index \
--set-section-flags .gdb_index=readonly symfile symfile
@end smallexample
There are currently some limitation on indices. They only work when
for DWARF debugging information, not stabs. And, they do not
currently work for programs using Ada.
@node Symbol Errors @node Symbol Errors
@section Errors Reading Symbol Files @section Errors Reading Symbol Files

File diff suppressed because it is too large Load diff

View file

@ -40,6 +40,9 @@
extern void _initialize_elfread (void); extern void _initialize_elfread (void);
/* Forward declaration. */
static struct sym_fns elf_sym_fns_gdb_index;
/* The struct elfinfo is available only during ELF symbol table and /* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the completion of psymtab-reading. psymtab reading. It is destroyed at the completion of psymtab-reading.
It's local to elf_symfile_read. */ It's local to elf_symfile_read. */
@ -869,11 +872,9 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
str_sect->filepos, str_sect->filepos,
bfd_section_size (abfd, str_sect)); bfd_section_size (abfd, str_sect));
} }
if (dwarf2_has_info (objfile))
{ if (dwarf2_has_info (objfile) && dwarf2_initialize_objfile (objfile))
/* DWARF 2 sections */ objfile->sf = &elf_sym_fns_gdb_index;
dwarf2_build_psymtabs (objfile);
}
/* If the file has its own symbol tables it has no separate debug info. /* If the file has its own symbol tables it has no separate debug info.
`.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS.
@ -1049,6 +1050,24 @@ static struct sym_fns elf_sym_fns =
NULL /* next: pointer to next struct sym_fns */ NULL /* next: pointer to next struct sym_fns */
}; };
/* The same as elf_sym_fns, but not registered and uses the
DWARF-specific GNU index rather than psymtab. */
static struct sym_fns elf_sym_fns_gdb_index =
{
bfd_target_elf_flavour,
elf_new_init, /* sym_new_init: init anything gbl to entire symab */
elf_symfile_init, /* sym_init: read initial info, setup for sym_red() */
elf_symfile_read, /* sym_read: read a symbol file into symtab */
elf_symfile_finish, /* sym_finish: finished with file, cleanup */
default_symfile_offsets, /* sym_offsets: Translate ext. to int. relocatin */
elf_symfile_segments, /* sym_segments: Get segment information from
a file. */
NULL, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
&dwarf2_gdb_index_functions,
NULL /* next: pointer to next struct sym_fns */
};
void void
_initialize_elfread (void) _initialize_elfread (void)
{ {

View file

@ -124,6 +124,10 @@ extern struct cmd_list_element *setchecklist;
extern struct cmd_list_element *showchecklist; extern struct cmd_list_element *showchecklist;
/* Chain containing all defined "save" subcommands. */
extern struct cmd_list_element *save_cmdlist;
extern void execute_command (char *, int); extern void execute_command (char *, int);
enum command_control_type execute_control_command (struct command_line *); enum command_control_type execute_control_command (struct command_line *);

View file

@ -1,6 +1,6 @@
/* Public partial symbol table definitions. /* Public partial symbol table definitions.
Copyright (C) 2009 Free Software Foundation, Inc. Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This file is part of GDB. This file is part of GDB.
@ -28,4 +28,6 @@ void map_partial_symbol_filenames (void (*) (const char *, const char *,
extern const struct quick_symbol_functions psym_functions; extern const struct quick_symbol_functions psym_functions;
extern const struct quick_symbol_functions dwarf2_gdb_index_functions;
#endif /* PSYMTAB_H */ #endif /* PSYMTAB_H */

View file

@ -1059,6 +1059,9 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
const char *name = bfd_get_filename (abfd); const char *name = bfd_get_filename (abfd);
const int from_tty = add_flags & SYMFILE_VERBOSE; const int from_tty = add_flags & SYMFILE_VERBOSE;
if (readnow_symbol_files)
flags |= OBJF_READNOW;
my_cleanups = make_cleanup_bfd_close (abfd); my_cleanups = make_cleanup_bfd_close (abfd);
/* Give user a chance to burp if we'd be /* Give user a chance to burp if we'd be
@ -1095,7 +1098,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
the gdb startup command line or on a per symbol file basis. Expand the gdb startup command line or on a per symbol file basis. Expand
all partial symbol tables for this objfile if so. */ all partial symbol tables for this objfile if so. */
if ((flags & OBJF_READNOW) || readnow_symbol_files) if ((flags & OBJF_READNOW))
{ {
if (from_tty || info_verbose) if (from_tty || info_verbose)
{ {

View file

@ -575,6 +575,7 @@ extern struct cleanup *increment_reading_symtab (void);
extern int dwarf2_has_info (struct objfile *); extern int dwarf2_has_info (struct objfile *);
extern int dwarf2_initialize_objfile (struct objfile *);
extern void dwarf2_build_psymtabs (struct objfile *); extern void dwarf2_build_psymtabs (struct objfile *);
extern void dwarf2_build_frame_info (struct objfile *); extern void dwarf2_build_frame_info (struct objfile *);