aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2011-03-07 16:17:29 +0000
committerTom Tromey <tromey@redhat.com>2011-03-07 16:17:29 +0000
commitb11896a5276900e7fda0bb6b7cd9d2b31a4945b3 (patch)
tree733433e09eb05de160b4549265cf1134e1b2dce3 /gdb
parentfda326dd1d341f03a75a36c8331b8cc8d1f637fa (diff)
downloadgdb-b11896a5276900e7fda0bb6b7cd9d2b31a4945b3.zip
gdb-b11896a5276900e7fda0bb6b7cd9d2b31a4945b3.tar.gz
gdb-b11896a5276900e7fda0bb6b7cd9d2b31a4945b3.tar.bz2
* xcoffread.c (xcoff_sym_fns): Update.
* symfile.h (struct sym_fns) <sym_read_psymbols>: New field. (enum symfile_add_flags) <SYMFILE_NO_READ>: New constant. * symfile.c (syms_from_objfile): Handle SYMFILE_NO_READ. (symbol_file_add_with_addrs_or_offsets): Likewise. (reread_symbols): Handle OBJF_PSYMTABS_READ. * somread.c (som_sym_fns): Update. * psymtab.h (require_partial_symbols): Declare. * psymtab.c (require_partial_symbols): New function. (ALL_OBJFILE_PSYMTABS_REQUIRED): New macro. (ALL_OBJFILE_PSYMTABS): Undef. (ALL_PSYMTABS): Move from psympriv.h. (lookup_partial_symtab, find_pc_sect_psymtab) (lookup_symbol_aux_psymtabs, relocate_psymtabs) (find_last_source_symtab_from_partial) (forget_cached_source_info_partial) (print_psymtab_stats_for_objfile, read_symtabs_for_function) (expand_partial_symbol_tables, read_psymtabs_with_filename) (map_symbol_names_psymtab, map_symbol_filenames_psymtab) (find_symbol_file_from_partial, map_matching_symbols_psymtab) (expand_symtabs_matching_via_partial, maintenance_info_psymtabs): Use ALL_OBJFILE_PSYMTABS_REQUIRED. * psympriv.h (ALL_PSYMTABS): Move to psymtab.c. * objfiles.h (OBJF_PSYMTABS_READ): New macro. * objfiles.c (objfile_has_partial_symbols): Handle lazily-read psymtabs. * mipsread.c (ecoff_sym_fns): Update. * machoread.c (macho_sym_fns): Update. * elfread.c (elf_symfile_read): Set up for lazy psymtab reading. (read_psyms): New function. (elf_sym_fns, elf_sym_fns_gdb_index): Update. (elf_sym_fns_lazy_psyms): New global. * dwarf2read.c (dwarf2_initialize_objfile): Don't call dwarf2_build_psymtabs. * dbxread.c (aout_sym_fns): Update. * coffread.c (coff_sym_fns): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog39
-rw-r--r--gdb/coffread.c1
-rw-r--r--gdb/dbxread.c1
-rw-r--r--gdb/dwarf2read.c1
-rw-r--r--gdb/elfread.c50
-rw-r--r--gdb/machoread.c1
-rw-r--r--gdb/mipsread.c1
-rw-r--r--gdb/objfiles.c9
-rw-r--r--gdb/objfiles.h5
-rw-r--r--gdb/psympriv.h6
-rw-r--r--gdb/psymtab.c88
-rw-r--r--gdb/psymtab.h8
-rw-r--r--gdb/somread.c1
-rw-r--r--gdb/symfile.c26
-rw-r--r--gdb/symfile.h13
-rw-r--r--gdb/xcoffread.c1
16 files changed, 214 insertions, 37 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9b2637a..7149bbf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,44 @@
2011-03-07 Tom Tromey <tromey@redhat.com>
+ * xcoffread.c (xcoff_sym_fns): Update.
+ * symfile.h (struct sym_fns) <sym_read_psymbols>: New field.
+ (enum symfile_add_flags) <SYMFILE_NO_READ>: New constant.
+ * symfile.c (syms_from_objfile): Handle SYMFILE_NO_READ.
+ (symbol_file_add_with_addrs_or_offsets): Likewise.
+ (reread_symbols): Handle OBJF_PSYMTABS_READ.
+ * somread.c (som_sym_fns): Update.
+ * psymtab.h (require_partial_symbols): Declare.
+ * psymtab.c (require_partial_symbols): New function.
+ (ALL_OBJFILE_PSYMTABS_REQUIRED): New macro.
+ (ALL_OBJFILE_PSYMTABS): Undef.
+ (ALL_PSYMTABS): Move from psympriv.h.
+ (lookup_partial_symtab, find_pc_sect_psymtab)
+ (lookup_symbol_aux_psymtabs, relocate_psymtabs)
+ (find_last_source_symtab_from_partial)
+ (forget_cached_source_info_partial)
+ (print_psymtab_stats_for_objfile, read_symtabs_for_function)
+ (expand_partial_symbol_tables, read_psymtabs_with_filename)
+ (map_symbol_names_psymtab, map_symbol_filenames_psymtab)
+ (find_symbol_file_from_partial, map_matching_symbols_psymtab)
+ (expand_symtabs_matching_via_partial, maintenance_info_psymtabs):
+ Use ALL_OBJFILE_PSYMTABS_REQUIRED.
+ * psympriv.h (ALL_PSYMTABS): Move to psymtab.c.
+ * objfiles.h (OBJF_PSYMTABS_READ): New macro.
+ * objfiles.c (objfile_has_partial_symbols): Handle lazily-read
+ psymtabs.
+ * mipsread.c (ecoff_sym_fns): Update.
+ * machoread.c (macho_sym_fns): Update.
+ * elfread.c (elf_symfile_read): Set up for lazy psymtab reading.
+ (read_psyms): New function.
+ (elf_sym_fns, elf_sym_fns_gdb_index): Update.
+ (elf_sym_fns_lazy_psyms): New global.
+ * dwarf2read.c (dwarf2_initialize_objfile): Don't call
+ dwarf2_build_psymtabs.
+ * dbxread.c (aout_sym_fns): Update.
+ * coffread.c (coff_sym_fns): Update.
+
+2011-03-07 Tom Tromey <tromey@redhat.com>
+
* infrun.c (print_exited_reason): Include inferior id and pid in
message.
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 9df775d..85a5553 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -2191,6 +2191,7 @@ static const struct sym_fns coff_sym_fns =
for sym_read() */
coff_symfile_read, /* sym_read: read a symbol file into
symtab */
+ NULL, /* sym_read_psymbols */
coff_symfile_finish, /* sym_finish: finished with file,
cleanup */
default_symfile_offsets, /* sym_offsets: xlate external to
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index b68aa80..2e32f38 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -3587,6 +3587,7 @@ static const struct sym_fns aout_sym_fns =
dbx_new_init, /* init anything gbl to entire symtab */
dbx_symfile_init, /* read initial info, setup for sym_read() */
dbx_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
dbx_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* parse user's offsets to internal form */
default_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d12028f..2a47c7d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2767,7 +2767,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
if (dwarf2_read_index (objfile))
return 1;
- dwarf2_build_psymtabs (objfile);
return 0;
}
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 54c7fa3..59a1f7c 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -40,8 +40,9 @@
extern void _initialize_elfread (void);
-/* Forward declaration. */
+/* Forward declarations. */
static const struct sym_fns elf_sym_fns_gdb_index;
+static const struct sym_fns elf_sym_fns_lazy_psyms;
/* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the completion of psymtab-reading.
@@ -887,14 +888,24 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
bfd_section_size (abfd, str_sect));
}
- if (dwarf2_has_info (objfile) && dwarf2_initialize_objfile (objfile))
- objfile->sf = &elf_sym_fns_gdb_index;
-
+ if (dwarf2_has_info (objfile))
+ {
+ if (dwarf2_initialize_objfile (objfile))
+ objfile->sf = &elf_sym_fns_gdb_index;
+ else
+ {
+ /* It is ok to do this even if the stabs reader made some
+ partial symbols, because OBJF_PSYMTABS_READ has not been
+ set, and so our lazy reader function will still be called
+ when needed. */
+ objfile->sf = &elf_sym_fns_lazy_psyms;
+ }
+ }
/* 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. `.gnu_debuglink' may no longer be present with
`.note.gnu.build-id'. */
- if (!objfile_has_partial_symbols (objfile))
+ else if (!objfile_has_partial_symbols (objfile))
{
char *debugfile;
@@ -913,6 +924,15 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
}
}
+/* Callback to lazily read psymtabs. */
+
+static void
+read_psyms (struct objfile *objfile)
+{
+ if (dwarf2_has_info (objfile))
+ dwarf2_build_psymtabs (objfile);
+}
+
/* This cleans up the objfile's deprecated_sym_stab_info pointer, and
the chain of stab_section_info's, that might be dangling from
it. */
@@ -1057,6 +1077,25 @@ static const struct sym_fns elf_sym_fns =
elf_new_init, /* init anything gbl to entire symtab */
elf_symfile_init, /* read initial info, setup for sym_read() */
elf_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
+ elf_symfile_finish, /* finished with file, cleanup */
+ default_symfile_offsets, /* Translate ext. to int. relocation */
+ elf_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
+ &psym_functions
+};
+
+/* The same as elf_sym_fns, but not registered and lazily reads
+ psymbols. */
+
+static const struct sym_fns elf_sym_fns_lazy_psyms =
+{
+ bfd_target_elf_flavour,
+ elf_new_init, /* init anything gbl to entire symtab */
+ elf_symfile_init, /* read initial info, setup for sym_read() */
+ elf_symfile_read, /* read a symbol file into symtab */
+ read_psyms, /* sym_read_psymbols */
elf_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* Translate ext. to int. relocation */
elf_symfile_segments, /* Get segment information from a file. */
@@ -1073,6 +1112,7 @@ static const struct sym_fns elf_sym_fns_gdb_index =
elf_new_init, /* init anything gbl to entire symab */
elf_symfile_init, /* read initial info, setup for sym_red() */
elf_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
elf_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* Translate ext. to int. relocatin */
elf_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/machoread.c b/gdb/machoread.c
index ad33f63..dbf9ae4 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -843,6 +843,7 @@ static const struct sym_fns macho_sym_fns = {
macho_new_init, /* init anything gbl to entire symtab */
macho_symfile_init, /* read initial info, setup for sym_read() */
macho_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
macho_symfile_finish, /* finished with file, cleanup */
macho_symfile_offsets, /* xlate external to internal form */
default_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 697f784..74d795d 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -396,6 +396,7 @@ static const struct sym_fns ecoff_sym_fns =
mipscoff_new_init, /* init anything gbl to entire symtab */
mipscoff_symfile_init, /* read initial info, setup for sym_read() */
mipscoff_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
mipscoff_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* dummy FIXME til implem sym reloc */
default_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 2223038..f3259dd 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -907,7 +907,14 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
int
objfile_has_partial_symbols (struct objfile *objfile)
{
- return objfile->sf ? objfile->sf->qf->has_symbols (objfile) : 0;
+ if (!objfile->sf)
+ return 0;
+ /* If we have not read psymbols, but we have a function capable of
+ reading them, then that is an indication that they are in fact
+ available. */
+ if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
+ return objfile->sf->sym_read_psymbols != NULL;
+ return objfile->sf->qf->has_symbols (objfile);
}
/* Return non-zero if OBJFILE has full symbols. */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 759c2f9..275c2ac 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -436,6 +436,11 @@ struct objfile
#define OBJF_USERLOADED (1 << 3) /* User loaded */
+/* Set if we have tried to read partial symtabs for this objfile.
+ This is used to allow lazy reading of partial symtabs. */
+
+#define OBJF_PSYMTABS_READ (1 << 4)
+
/* The object file that contains the runtime common minimal symbols
for SunOS4. Note that this objfile has no associated BFD. */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 8e8e15c..95d7676 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -183,10 +183,4 @@ extern void discard_psymtab (struct partial_symtab *);
#define ALL_OBJFILE_PSYMTABS(objfile, p) \
for ((p) = (objfile) -> psymtabs; (p) != NULL; (p) = (p) -> next)
-/* Traverse all psymtabs in all objfiles. */
-
-#define ALL_PSYMTABS(objfile, p) \
- ALL_OBJFILES (objfile) \
- ALL_OBJFILE_PSYMTABS (objfile, p)
-
#endif /* PSYMPRIV_H */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 6a0c563..eeae03b 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -69,6 +69,60 @@ static struct partial_symbol *fixup_psymbol_section (struct partial_symbol
static struct symtab *psymtab_to_symtab (struct partial_symtab *pst);
+/* Ensure that the partial symbols for OBJFILE have been loaded. This
+ function always returns its argument, as a convenience. */
+
+struct objfile *
+require_partial_symbols (struct objfile *objfile, int verbose)
+{
+ if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
+ {
+ objfile->flags |= OBJF_PSYMTABS_READ;
+
+ if (objfile->sf->sym_read_psymbols)
+ {
+ if (verbose)
+ {
+ printf_unfiltered (_("Reading symbols from %s..."),
+ objfile->name);
+ gdb_flush (gdb_stdout);
+ }
+ (*objfile->sf->sym_read_psymbols) (objfile);
+ if (verbose)
+ {
+ if (!objfile_has_symbols (objfile))
+ {
+ wrap_here ("");
+ printf_unfiltered (_("(no debugging symbols found)..."));
+ wrap_here ("");
+ }
+
+ printf_unfiltered (_("done.\n"));
+ }
+ }
+ }
+
+ return objfile;
+}
+
+/* Traverse all psymtabs in one objfile, requiring that the psymtabs
+ be read in. */
+
+#define ALL_OBJFILE_PSYMTABS_REQUIRED(objfile, p) \
+ for ((p) = require_partial_symbols (objfile, 1)->psymtabs; \
+ (p) != NULL; \
+ (p) = (p)->next)
+
+/* We want to make sure this file always requires psymtabs. */
+
+#undef ALL_OBJFILE_PSYMTABS
+
+/* Traverse all psymtabs in all objfiles. */
+
+#define ALL_PSYMTABS(objfile, p) \
+ ALL_OBJFILES (objfile) \
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
+
/* Lookup the partial symbol table of a source file named NAME.
*If* there is no '/' in the name, a match after a '/'
in the psymtab filename will also work. */
@@ -79,7 +133,7 @@ lookup_partial_symtab (struct objfile *objfile, const char *name,
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (FILENAME_CMP (name, pst->filename) == 0)
{
@@ -117,7 +171,7 @@ lookup_partial_symtab (struct objfile *objfile, const char *name,
/* Now, search for a matching tail (only if name doesn't have any dirs). */
if (lbasename (name) == name)
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (FILENAME_CMP (lbasename (pst->filename), name) == 0)
return (pst);
@@ -280,7 +334,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
its CUs may be missing in PSYMTABS_ADDRMAP as they may be varying
debug info type in single OBJFILE. */
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
if (pc >= pst->textlow && pc < pst->texthigh)
{
struct partial_symtab *best_pst;
@@ -423,7 +477,7 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
struct partial_symtab *ps;
const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain))
return PSYMTAB_TO_SYMTAB (ps);
@@ -635,7 +689,7 @@ relocate_psymtabs (struct objfile *objfile,
struct partial_symbol **psym;
struct partial_symtab *p;
- ALL_OBJFILE_PSYMTABS (objfile, p)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
{
p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
@@ -667,7 +721,7 @@ find_last_source_symtab_from_partial (struct objfile *ofp)
struct partial_symtab *ps;
struct partial_symtab *cs_pst = 0;
- ALL_OBJFILE_PSYMTABS (ofp, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (ofp, ps)
{
const char *name = ps->filename;
int len = strlen (name);
@@ -696,7 +750,7 @@ forget_cached_source_info_partial (struct objfile *objfile)
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (pst->fullname != NULL)
{
@@ -873,7 +927,7 @@ print_psymtab_stats_for_objfile (struct objfile *objfile)
struct partial_symtab *ps;
i = 0;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (ps->readin == 0)
i++;
@@ -915,7 +969,7 @@ read_symtabs_for_function (struct objfile *objfile, const char *func_name)
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (ps->readin)
continue;
@@ -933,7 +987,7 @@ expand_partial_symbol_tables (struct objfile *objfile)
{
struct partial_symtab *psymtab;
- ALL_OBJFILE_PSYMTABS (objfile, psymtab)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab)
{
psymtab_to_symtab (psymtab);
}
@@ -944,7 +998,7 @@ read_psymtabs_with_filename (struct objfile *objfile, const char *filename)
{
struct partial_symtab *p;
- ALL_OBJFILE_PSYMTABS (objfile, p)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
{
if (strcmp (filename, p->filename) == 0)
PSYMTAB_TO_SYMTAB (p);
@@ -957,7 +1011,7 @@ map_symbol_names_psymtab (struct objfile *objfile,
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
struct partial_symbol **psym;
@@ -995,7 +1049,7 @@ map_symbol_filenames_psymtab (struct objfile *objfile,
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
const char *fullname;
@@ -1044,7 +1098,7 @@ find_symbol_file_from_partial (struct objfile *objfile, const char *name)
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (lookup_partial_symbol (pst, name, 1, VAR_DOMAIN))
return pst->filename;
@@ -1095,7 +1149,7 @@ map_matching_symbols_psymtab (const char *name, domain_enum namespace,
const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
QUIT;
if (ps->readin
@@ -1128,7 +1182,7 @@ expand_symtabs_matching_via_partial (struct objfile *objfile,
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
struct partial_symbol **psym;
struct partial_symbol **bound, **gbound, **sbound;
@@ -1640,7 +1694,7 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
actually find a symtab whose name matches. */
int printed_objfile_start = 0;
- ALL_OBJFILE_PSYMTABS (objfile, psymtab)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab)
{
QUIT;
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 4a1e8e4..73e0a81 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -38,4 +38,12 @@ extern const struct quick_symbol_functions psym_functions;
extern const struct quick_symbol_functions dwarf2_gdb_index_functions;
+/* Ensure that the partial symbols for OBJFILE have been loaded. If
+ VERBOSE is non-zero, then this will print a message when symbols
+ are loaded. This function always returns its argument, as a
+ convenience. */
+
+extern struct objfile *require_partial_symbols (struct objfile *objfile,
+ int verbose);
+
#endif /* PSYMTAB_H */
diff --git a/gdb/somread.c b/gdb/somread.c
index fbbe356..70831a0 100644
--- a/gdb/somread.c
+++ b/gdb/somread.c
@@ -433,6 +433,7 @@ static const struct sym_fns som_sym_fns =
som_new_init, /* init anything gbl to entire symtab */
som_symfile_init, /* read initial info, setup for sym_read() */
som_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
som_symfile_finish, /* finished with file, cleanup */
som_symfile_offsets, /* Translate ext. to int. relocation */
default_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index de0b369..06b5dec 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1019,6 +1019,9 @@ syms_from_objfile (struct objfile *objfile,
(*objfile->sf->sym_read) (objfile, add_flags);
+ if ((add_flags & SYMFILE_NO_READ) == 0)
+ require_partial_symbols (objfile, 0);
+
/* Discard cleanups as symbol reading was successful. */
discard_cleanups (old_chain);
@@ -1079,9 +1082,15 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
struct cleanup *my_cleanups;
const char *name = bfd_get_filename (abfd);
const int from_tty = add_flags & SYMFILE_VERBOSE;
+ const int should_print = ((from_tty || info_verbose)
+ && (readnow_symbol_files
+ || (add_flags & SYMFILE_NO_READ) == 0));
if (readnow_symbol_files)
- flags |= OBJF_READNOW;
+ {
+ flags |= OBJF_READNOW;
+ add_flags &= ~SYMFILE_NO_READ;
+ }
my_cleanups = make_cleanup_bfd_close (abfd);
@@ -1100,7 +1109,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
/* We either created a new mapped symbol table, mapped an existing
symbol table file which has not had initial symbol reading
performed, or need to read an unmapped symbol table. */
- if (from_tty || info_verbose)
+ if (should_print)
{
if (deprecated_pre_add_symbol_hook)
deprecated_pre_add_symbol_hook (name);
@@ -1121,7 +1130,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
if ((flags & OBJF_READNOW))
{
- if (from_tty || info_verbose)
+ if (should_print)
{
printf_unfiltered (_("expanding to full symbols..."));
wrap_here ("");
@@ -1132,15 +1141,14 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
objfile->sf->qf->expand_all_symtabs (objfile);
}
- if ((from_tty || info_verbose)
- && !objfile_has_symbols (objfile))
+ if (should_print && !objfile_has_symbols (objfile))
{
wrap_here ("");
printf_unfiltered (_("(no debugging symbols found)..."));
wrap_here ("");
}
- if (from_tty || info_verbose)
+ if (should_print)
{
if (deprecated_post_add_symbol_hook)
deprecated_post_add_symbol_hook ();
@@ -2497,6 +2505,12 @@ reread_symbols (void)
/* Do not set flags as this is safe and we don't want to be
verbose. */
(*objfile->sf->sym_read) (objfile, 0);
+ if ((objfile->flags & OBJF_PSYMTABS_READ) != 0)
+ {
+ objfile->flags &= ~OBJF_PSYMTABS_READ;
+ require_partial_symbols (objfile, 0);
+ }
+
if (!objfile_has_symbols (objfile))
{
wrap_here ("");
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 4d56341..a0151ea 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -326,6 +326,13 @@ struct sym_fns
void (*sym_read) (struct objfile *, int);
+ /* Read the partial symbols for an objfile. This may be NULL, in
+ which case gdb assumes that sym_read already read the partial
+ symbols. This may only be non-NULL if the objfile actually does
+ have debuginfo available. */
+
+ void (*sym_read_psymbols) (struct objfile *);
+
/* Called when we are finished with an objfile. Should do all
cleanup that is specific to the object file format for the
particular objfile. */
@@ -408,7 +415,11 @@ enum symfile_add_flags
SYMFILE_MAINLINE = 1 << 2,
/* Do not call breakpoint_re_set when adding this symbol file. */
- SYMFILE_DEFER_BP_RESET = 1 << 3
+ SYMFILE_DEFER_BP_RESET = 1 << 3,
+
+ /* Do not immediately read symbols for this file. By default,
+ symbols are read when the objfile is created. */
+ SYMFILE_NO_READ = 1 << 4
};
extern void syms_from_objfile (struct objfile *,
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index a794f61..081080c 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -3084,6 +3084,7 @@ static const struct sym_fns xcoff_sym_fns =
xcoff_new_init, /* init anything gbl to entire symtab */
xcoff_symfile_init, /* read initial info, setup for sym_read() */
xcoff_initial_scan, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
xcoff_symfile_finish, /* finished with file, cleanup */
xcoff_symfile_offsets, /* xlate offsets ext->int form */
default_symfile_segments, /* Get segment information from a file. */