* serial.h: Fix prototye for serial_raw().
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 8ef5ed90e2ffcde7b8260ff68f2e4f0f87fe6059..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.  */
@@ -491,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
     {
@@ -504,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
@@ -525,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);
        }
     }
 
@@ -563,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
     {
@@ -601,8 +625,7 @@ symbol_file_command (args, from_tty)
          /* Getting new symbols may change our opinion about what is
             frameless.  */
          reinit_frame_cache ();
-         (void) 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);
     }
@@ -632,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)
@@ -779,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.  */
@@ -967,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;
@@ -1003,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;
@@ -1046,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 */
@@ -1247,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.026247 seconds and 4 git commands to generate.