* xcoffread.c (xcoff_sym_fns): Update.
authorTom Tromey <tromey@redhat.com>
Mon, 7 Mar 2011 16:17:29 +0000 (16:17 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 7 Mar 2011 16:17:29 +0000 (16:17 +0000)
* 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.

16 files changed:
gdb/ChangeLog
gdb/coffread.c
gdb/dbxread.c
gdb/dwarf2read.c
gdb/elfread.c
gdb/machoread.c
gdb/mipsread.c
gdb/objfiles.c
gdb/objfiles.h
gdb/psympriv.h
gdb/psymtab.c
gdb/psymtab.h
gdb/somread.c
gdb/symfile.c
gdb/symfile.h
gdb/xcoffread.c

index 9b2637a6ad2a213c131cd965f51422f185c89fdc..7149bbf32bb0b41c0a2645eebeaaa9f27fb37ca1 100644 (file)
@@ -1,3 +1,42 @@
+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
index 9df775d46b9421c6c1d2dea6a54568f04357d55f..85a55536f7e98f3f73151ce6f4f29af2c4a94f5a 100644 (file)
@@ -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
index b68aa80197d5296dfc7da546c4acaf151847af68..2e32f388e165eb771d6ea19ba159db65bc8610ec 100644 (file)
@@ -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.  */
index d12028f6175fc12c79c71a1f637df7f9f8f59990..2a47c7d19b08fc62a9ee2a5253cf8e635fed001c 100644 (file)
@@ -2767,7 +2767,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
   if (dwarf2_read_index (objfile))
     return 1;
 
-  dwarf2_build_psymtabs (objfile);
   return 0;
 }
 
index 54c7fa3359845eb27d55f5cef1641e90f61f4e33..59a1f7c6ad1d4f76b0d1aa5962bb0fa902faa504 100644 (file)
@@ -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.  */
index ad33f63a63820b6eda7c7ccc93e3a894163e1b5c..dbf9ae4c6e351e80188bc16d0d6c66f8db71adae 100644 (file)
@@ -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.  */
index 697f784ed567f3d9736286f71bf3dd5d06ed3f73..74d795d4a6f35b1bd1332db81b6f8da3b21bcd39 100644 (file)
@@ -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.  */
index 2223038b7cfec2ddc6f8e803bf08835d82605a88..f3259dd6b02b213a0035cf7cd731575e57aefaba 100644 (file)
@@ -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.  */
index 759c2f9fb8c11ae4c9ca230ce1d1607684a52da5..275c2ac39f3b474ec1709e70e6cb8b620e5f6d53 100644 (file)
@@ -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.  */
 
index 8e8e15c1305cdb2e4d3181d639bbe7e4989fe238..95d7676cbfad496fad0a8d0fa337c118f1ae9447 100644 (file)
@@ -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 */
index 6a0c563648d38711af6f131387a2be5866f8e502..eeae03bd37c7e7c89c2cdac2da7052671d7093c5 100644 (file)
@@ -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;
 
index 4a1e8e4db00eaf767df833fec10193a04b98ad7e..73e0a81a1294fe1dc3534b4106eadb664aa629b9 100644 (file)
@@ -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 */
index fbbe3564d003363a7c24bd7425b51b7dc1c0d51c..70831a08e6459971694ab1fb52f4d473c7f2fc30 100644 (file)
@@ -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.  */
index de0b369439031ab5d5ce698586b41ea33f01b538..06b5deccca15062a67f7c06820969aad61d7fd9c 100644 (file)
@@ -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 ("");
index 4d56341763a4d7fc015a68530dcc77e6d172d072..a0151eafadb952eed9cec87d7f776846b8dc7a2a 100644 (file)
@@ -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 *,
index a794f61643f7de265c4c623b2a9e663ea0729cd1..081080ccabae6217dd5d4febd18e157dfb713ee3 100644 (file)
@@ -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.  */
This page took 0.039523 seconds and 4 git commands to generate.