Oops! Retract last change. Didn't mean to pollute things with energize just
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 9b50d6f2d1ab6d99da7a91a9af883e14bf2b7c1d..740c4c10e52d01dd239cf0a2f66d65b04e3b431c 100644 (file)
@@ -37,6 +37,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <fcntl.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <ctype.h>
 
 /* Global variables owned by this file */
 
@@ -69,7 +70,7 @@ symfile_bfd_open PARAMS ((char *));
 static void
 find_sym_fns PARAMS ((struct objfile *));
 
-static void
+void
 clear_symtab_users_once PARAMS ((void));
 
 /* List of all available sym_fns.  On gdb startup, each object file reader
@@ -403,6 +404,22 @@ syms_from_objfile (objfile, addr, mainline, verbo)
   TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
   TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0;
 
+  /* Mark the objfile has having had initial symbol read attempted.  Note
+     that this does not mean we found any symbols... */
+
+  objfile -> flags |= OBJF_SYMS;
+}
+
+/* Perform required actions immediately after either reading in the initial
+   symbols for a new objfile, or mapping in the symbols from a reusable
+   objfile. */
+   
+void
+new_symfile_objfile (objfile, mainline, verbo)
+     struct objfile *objfile;
+     int mainline;
+     int verbo;
+{
   if (mainline)
     {
       /* OK, make it the "real" symbol file.  */
@@ -446,7 +463,6 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
   struct objfile *objfile;
   struct partial_symtab *psymtab;
   bfd *abfd;
-  int mapped_it;
 
   /* Open a bfd for the file and then check to see if the file has a
      symbol table.  There is a distinction between having no symbol table
@@ -492,6 +508,8 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
          wrap_here ("");
          fflush (stdout);
        }
+      init_entry_point_info (objfile);
+      find_sym_fns (objfile);
     }
   else
     {
@@ -505,9 +523,10 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
          fflush (stdout);
        }
       syms_from_objfile (objfile, addr, mainline, from_tty);
-      objfile -> flags |= OBJF_SYMS;
     }      
 
+  new_symfile_objfile (objfile, mainline, from_tty);
+
   /* We now have at least a partial symbol table.  Check to see if the
      user requested that all symbols be read on initial access via either
      the gdb startup command line or on a per symbol file basis.  Expand
@@ -526,7 +545,7 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
           psymtab != NULL;
           psymtab = psymtab -> next)
        {
-         (void) psymtab_to_symtab (psymtab);
+         psymtab_to_symtab (psymtab);
        }
     }
 
@@ -550,7 +569,6 @@ symbol_file_command (args, from_tty)
   char **argv;
   char *name = NULL;
   struct cleanup *cleanups;
-  struct objfile *objfile;
   int mapped = 0;
   int readnow = 0;
 
@@ -565,6 +583,10 @@ symbol_file_command (args, from_tty)
        error ("Not confirmed.");
       free_all_objfiles ();
       symfile_objfile = NULL;
+      if (from_tty)
+       {
+         printf ("No symbol file now.\n");
+       }
     }
   else
     {
@@ -603,8 +625,7 @@ symbol_file_command (args, from_tty)
          /* Getting new symbols may change our opinion about what is
             frameless.  */
          reinit_frame_cache ();
-         objfile = symbol_file_add (name, from_tty, (CORE_ADDR)0, 1,
-                                    mapped, readnow);
+         symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, mapped, readnow);
        }
       do_cleanups (cleanups);
     }
@@ -634,6 +655,7 @@ symfile_bfd_open (name)
     }
   free (name);                 /* Free 1st new malloc'd copy */
   name = absolute_name;                /* Keep 2nd malloc'd copy in bfd */
+                               /* It'll be freed in free_objfile(). */
 
   sym_bfd = bfd_fdopenr (name, NULL, desc);
   if (!sym_bfd)
@@ -678,7 +700,7 @@ static void
 find_sym_fns (objfile)
      struct objfile *objfile;
 {
-  struct sym_fns *sf, *sf2;
+  struct sym_fns *sf;
 
   for (sf = symtab_fns; sf != NULL; sf = sf -> next)
     {
@@ -715,8 +737,8 @@ add_symbol_file_command (args, from_tty)
   char *name = NULL;
   CORE_ADDR text_addr;
   char *arg;
-  int readnow;
-  int mapped;
+  int readnow = 0;
+  int mapped = 0;
   
   dont_repeat ();
 
@@ -781,7 +803,7 @@ add_symbol_file_command (args, from_tty)
 
   reinit_frame_cache ();
 
-  (void) symbol_file_add (name, 0, text_addr, 0, mapped, readnow);
+  symbol_file_add (name, 0, text_addr, 0, mapped, readnow);
 }
 \f
 /* Re-read symbols if a symbol-file has changed.  */
@@ -803,7 +825,7 @@ reread_symbols ()
 the_big_top:
   for (objfile = object_files; objfile; objfile = objfile->next) {
     if (objfile->obfd) {
-#ifdef IBM6000
+#ifdef IBM6000_TARGET
      /* If this object is from a shared library, then you should
         stat on the library name, not member name. */
 
@@ -969,7 +991,7 @@ allocate_symtab (filename, objfile)
 
   symtab = (struct symtab *)
     obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symtab));
-  (void) memset (symtab, 0, sizeof (*symtab));
+  memset (symtab, 0, sizeof (*symtab));
   symtab -> filename = obsavestring (filename, strlen (filename),
                                     &objfile -> symbol_obstack);
   symtab -> fullname = NULL;
@@ -1005,7 +1027,7 @@ allocate_psymtab (filename, objfile)
       obstack_alloc (&objfile -> psymbol_obstack,
                     sizeof (struct partial_symtab));
 
-  (void) memset (psymtab, 0, sizeof (struct partial_symtab));
+  memset (psymtab, 0, sizeof (struct partial_symtab));
   psymtab -> filename = obsavestring (filename, strlen (filename),
                                      &objfile -> psymbol_obstack);
   psymtab -> symtab = NULL;
@@ -1048,7 +1070,7 @@ allocate_psymtab (filename, objfile)
 static int clear_symtab_users_queued;
 static int clear_symtab_users_done;
 
-static void
+void
 clear_symtab_users_once ()
 {
   /* Enforce once-per-`do_cleanups'-semantics */
@@ -1127,18 +1149,21 @@ int
 free_named_symtabs (name)
      char *name;
 {
-  register struct symtab *s;
-  register struct symtab *prev;
-  register struct partial_symtab *ps;
-  struct blockvector *bv;
-  int blewit = 0;
-
 #if 0
   /* FIXME:  With the new method of each objfile having it's own
      psymtab list, this function needs serious rethinking.  In particular,
      why was it ever necessary to toss psymtabs with specific compilation
      unit filenames, as opposed to all psymtabs from a particular symbol
-     file. */
+     file?  -- fnf
+     Well, the answer is that some systems permit reloading of particular
+     compilation units.  We want to blow away any old info about these
+     compilation units, regardless of which objfiles they arrived in. --gnu.  */
+
+  register struct symtab *s;
+  register struct symtab *prev;
+  register struct partial_symtab *ps;
+  struct blockvector *bv;
+  int blewit = 0;
 
   /* We only wack things if the symbol-reload switch is set.  */
   if (!symbol_reloading)
@@ -1246,7 +1271,44 @@ start_psymtab_common (objfile, addr,
   psymtab -> statics_offset = static_syms - objfile -> static_psymbols.list;
   return (psymtab);
 }
+\f
+/* Debugging versions of functions that are usually inline macros
+   (see symfile.h).  */
+
+#if 0          /* Don't quite work nowadays... */
+
+/* Add a symbol with a long value to a psymtab.
+   Since one arg is a struct, we pass in a ptr and deref it (sigh).  */
+
+void
+add_psymbol_to_list (name, namelength, namespace, class, list, val)
+     char *name;
+     int namelength;
+     enum namespace namespace;
+     enum address_class class;
+     struct psymbol_allocation_list *list;
+     long val;
+{
+  ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, (*list), val,
+                         SYMBOL_VALUE);
+}
+
+/* Add a symbol with a CORE_ADDR value to a psymtab. */
+
+void
+add_psymbol_addr_to_list (name, namelength, namespace, class, list, val)
+     char *name;
+     int namelength;
+     enum namespace namespace;
+     enum address_class class;
+     struct psymbol_allocation_list *list;
+     CORE_ADDR val;
+{
+  ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, (*list), val,
+                         SYMBOL_VALUE_ADDRESS);
+}
 
+#endif /* 0 */
 \f
 void
 _initialize_symfile ()
This page took 0.026058 seconds and 4 git commands to generate.