2004-01-25 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 02b2c36e7f1de341a58e1774d3f5b79c74228746..076fc456d184cde1a3d51c26fe9f87672e488832 100644 (file)
@@ -1,7 +1,7 @@
 /* Generic symbol file reading for the GNU debugger, GDB.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
@@ -199,20 +199,6 @@ int auto_solib_add = 1;
 int auto_solib_limit;
 \f
 
-/* Since this function is called from within qsort, in an ANSI environment
-   it must conform to the prototype for qsort, which specifies that the
-   comparison function takes two "void *" pointers. */
-
-static int
-compare_symbols (const void *s1p, const void *s2p)
-{
-  register struct symbol **s1, **s2;
-
-  s1 = (struct symbol **) s1p;
-  s2 = (struct symbol **) s2p;
-  return (strcmp (SYMBOL_NATURAL_NAME (*s1), SYMBOL_NATURAL_NAME (*s2)));
-}
-
 /* This compares two partial symbols by names, using strcmp_iw_ordered
    for the comparison.  */
 
@@ -244,13 +230,13 @@ sort_pst_symbols (struct partial_symtab *pst)
 char *
 obsavestring (const char *ptr, int size, struct obstack *obstackp)
 {
-  register char *p = (char *) obstack_alloc (obstackp, size + 1);
+  char *p = (char *) obstack_alloc (obstackp, size + 1);
   /* Open-coded memcpy--saves function call time.  These strings are usually
      short.  FIXME: Is this really still true with a compiler that can
      inline memcpy? */
   {
-    register const char *p1 = ptr;
-    register char *p2 = p;
+    const char *p1 = ptr;
+    char *p2 = p;
     const char *end = ptr + size;
     while (p1 != end)
       *p2++ = *p1++;
@@ -266,8 +252,8 @@ char *
 obconcat (struct obstack *obstackp, const char *s1, const char *s2,
          const char *s3)
 {
-  register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1;
-  register char *val = (char *) obstack_alloc (obstackp, len);
+  int len = strlen (s1) + strlen (s2) + strlen (s3) + 1;
+  char *val = (char *) obstack_alloc (obstackp, len);
   strcpy (val, s1);
   strcat (val, s2);
   strcat (val, s3);
@@ -290,7 +276,7 @@ decrement_reading_symtab (void *dummy)
    case inline.  */
 
 struct symtab *
-psymtab_to_symtab (register struct partial_symtab *pst)
+psymtab_to_symtab (struct partial_symtab *pst)
 {
   /* If it's been looked up before, return it. */
   if (pst->symtab)
@@ -327,8 +313,8 @@ init_entry_point_info (struct objfile *objfile)
       /* Examination of non-executable.o files.  Short-circuit this stuff.  */
       objfile->ei.entry_point = INVALID_ENTRY_POINT;
     }
-  objfile->ei.entry_file_lowpc = INVALID_ENTRY_LOWPC;
-  objfile->ei.entry_file_highpc = INVALID_ENTRY_HIGHPC;
+  objfile->ei.deprecated_entry_file_lowpc = INVALID_ENTRY_LOWPC;
+  objfile->ei.deprecated_entry_file_highpc = INVALID_ENTRY_HIGHPC;
   objfile->ei.entry_func_lowpc = INVALID_ENTRY_LOWPC;
   objfile->ei.entry_func_highpc = INVALID_ENTRY_HIGHPC;
   objfile->ei.main_func_lowpc = INVALID_ENTRY_LOWPC;
@@ -861,43 +847,22 @@ symbol_file_add_with_addrs_or_offsets (char *name, int from_tty,
        orig_addrs->other[i] = addrs->other[i];
     }
 
-  /* If the objfile uses a mapped symbol file, and we have a psymtab for
-     it, then skip reading any symbols at this time. */
-
-  if ((objfile->flags & OBJF_MAPPED) && (objfile->flags & OBJF_SYMS))
+  /* 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)
     {
-      /* We mapped in an existing symbol table file that already has had
-         initial symbol reading performed, so we can skip that part.  Notify
-         the user that instead of reading the symbols, they have been mapped.
-       */
-      if (from_tty || info_verbose)
+      if (pre_add_symbol_hook)
+       pre_add_symbol_hook (name);
+      else
        {
-         printf_filtered ("Mapped symbols for %s...", name);
+         printf_unfiltered ("Reading symbols from %s...", name);
          wrap_here ("");
          gdb_flush (gdb_stdout);
        }
-      init_entry_point_info (objfile);
-      find_sym_fns (objfile);
-    }
-  else
-    {
-      /* 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 (pre_add_symbol_hook)
-           pre_add_symbol_hook (name);
-         else
-           {
-             printf_filtered ("Reading symbols from %s...", name);
-             wrap_here ("");
-             gdb_flush (gdb_stdout);
-           }
-       }
-      syms_from_objfile (objfile, addrs, offsets, num_offsets,
-                         mainline, from_tty);
     }
+  syms_from_objfile (objfile, addrs, offsets, num_offsets,
+                    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
@@ -908,7 +873,7 @@ symbol_file_add_with_addrs_or_offsets (char *name, int from_tty,
     {
       if (from_tty || info_verbose)
        {
-         printf_filtered ("expanding to full symbols...");
+         printf_unfiltered ("expanding to full symbols...");
          wrap_here ("");
          gdb_flush (gdb_stdout);
        }
@@ -947,7 +912,7 @@ symbol_file_add_with_addrs_or_offsets (char *name, int from_tty,
   if (!have_partial_symbols () && !have_full_symbols ())
     {
       wrap_here ("");
-      printf_filtered ("(no debugging symbols found)...");
+      printf_unfiltered ("(no debugging symbols found)...");
       wrap_here ("");
     }
 
@@ -957,7 +922,7 @@ symbol_file_add_with_addrs_or_offsets (char *name, int from_tty,
        post_add_symbol_hook ();
       else
        {
-         printf_filtered ("done.\n");
+         printf_unfiltered ("done.\n");
        }
     }
 
@@ -1223,20 +1188,16 @@ symbol_file_command (char *args, int from_tty)
       cleanups = make_cleanup_freeargv (argv);
       while (*argv != NULL)
        {
-         if (STREQ (*argv, "-mapped"))
-           flags |= OBJF_MAPPED;
-         else 
-           if (STREQ (*argv, "-readnow"))
-             flags |= OBJF_READNOW;
-           else 
-             if (**argv == '-')
-               error ("unknown option `%s'", *argv);
-             else
-               {
-                  name = *argv;
-
-                 symbol_file_add_main_1 (name, from_tty, flags);
-               }
+         if (strcmp (*argv, "-readnow") == 0)
+           flags |= OBJF_READNOW;
+         else if (**argv == '-')
+           error ("unknown option `%s'", *argv);
+         else
+           {
+             name = *argv;
+             
+             symbol_file_add_main_1 (name, from_tty, flags);
+           }
          argv++;
        }
 
@@ -1666,7 +1627,6 @@ print_transfer_performance (struct ui_file *stream,
    instead a call to target_link() (in target.c) would supply the
    value to use. We are now discontinuing this type of ad hoc syntax. */
 
-/* ARGSUSED */
 static void
 add_symbol_file_command (char *args, int from_tty)
 {
@@ -1752,17 +1712,13 @@ add_symbol_file_command (char *args, int from_tty)
 
            if (*arg == '-')
              {
-               if (strcmp (arg, "-mapped") == 0)
-                 flags |= OBJF_MAPPED;
-               else 
-                 if (strcmp (arg, "-readnow") == 0)
-                   flags |= OBJF_READNOW;
-                 else 
-                   if (strcmp (arg, "-s") == 0)
-                     {
-                       expecting_sec_name = 1;
-                       expecting_sec_addr = 1;
-                     }
+               if (strcmp (arg, "-readnow") == 0)
+                 flags |= OBJF_READNOW;
+               else if (strcmp (arg, "-s") == 0)
+                 {
+                   expecting_sec_name = 1;
+                   expecting_sec_addr = 1;
+                 }
              }
            else
              {
@@ -1798,7 +1754,7 @@ add_symbol_file_command (char *args, int from_tty)
      statements because local_hex_string returns a local static
      string. */
  
-  printf_filtered ("add symbol table from file \"%s\" at\n", filename);
+  printf_unfiltered ("add symbol table from file \"%s\" at\n", filename);
   section_addrs = alloc_section_addr_info (section_index);
   make_cleanup (xfree, section_addrs);
   for (i = 0; i < section_index; i++)
@@ -1813,7 +1769,7 @@ add_symbol_file_command (char *args, int from_tty)
          entered on the command line. */
       section_addrs->other[sec_num].name = sec;
       section_addrs->other[sec_num].addr = addr;
-      printf_filtered ("\t%s_addr = %s\n",
+      printf_unfiltered ("\t%s_addr = %s\n",
                       sec, 
                       local_hex_string ((unsigned long)addr));
       sec_num++;
@@ -1878,7 +1834,7 @@ reread_symbols (void)
          if (res != 0)
            {
              /* FIXME, should use print_sys_errmsg but it's not filtered. */
-             printf_filtered ("`%s' has disappeared; keeping its symbols.\n",
+             printf_unfiltered ("`%s' has disappeared; keeping its symbols.\n",
                               objfile->name);
              continue;
            }
@@ -1890,7 +1846,7 @@ reread_symbols (void)
              int num_offsets;
              char *obfd_filename;
 
-             printf_filtered ("`%s' has changed; re-reading symbols.\n",
+             printf_unfiltered ("`%s' has changed; re-reading symbols.\n",
                               objfile->name);
 
              /* There are various functions like symbol_file_add,
@@ -1962,6 +1918,7 @@ reread_symbols (void)
              objfile->symtabs = NULL;
              objfile->psymtabs = NULL;
              objfile->free_psymtabs = NULL;
+             objfile->cp_namespace_symtab = NULL;
              objfile->msymbols = NULL;
              objfile->sym_private = NULL;
              objfile->minimal_symbol_count = 0;
@@ -1970,6 +1927,7 @@ reread_symbols (void)
              memset (&objfile->msymbol_demangled_hash, 0,
                      sizeof (objfile->msymbol_demangled_hash));
              objfile->fundamental_types = NULL;
+             clear_objfile_data (objfile);
              if (objfile->sf != NULL)
                {
                  (*objfile->sf->sym_finish) (objfile);
@@ -2023,7 +1981,7 @@ reread_symbols (void)
              if (!have_partial_symbols () && !have_full_symbols ())
                {
                  wrap_here ("");
-                 printf_filtered ("(no debugging symbols found)\n");
+                 printf_unfiltered ("(no debugging symbols found)\n");
                  wrap_here ("");
                }
              objfile->flags |= OBJF_SYMS;
@@ -2110,8 +2068,7 @@ reread_separate_symbols (struct objfile *objfile)
             0, /* No addr table.  */
             objfile->section_offsets, objfile->num_sections,
             0, /* Not mainline.  See comments about this above.  */
-            objfile->flags & (OBJF_MAPPED | OBJF_REORDERED
-                              | OBJF_SHARED | OBJF_READNOW
+            objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
                               | OBJF_USERLOADED)));
       objfile->separate_debug_objfile->separate_debug_objfile_backlink
         = objfile;
@@ -2281,7 +2238,7 @@ deduce_language_from_filename (char *filename)
 struct symtab *
 allocate_symtab (char *filename, struct objfile *objfile)
 {
-  register struct symtab *symtab;
+  struct symtab *symtab;
 
   symtab = (struct symtab *)
     obstack_alloc (&objfile->symbol_obstack, sizeof (struct symtab));
@@ -2520,9 +2477,9 @@ free_named_symtabs (char *name)
      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 symtab *s;
+  struct symtab *prev;
+  struct partial_symtab *ps;
   struct blockvector *bv;
   int blewit = 0;
 
@@ -2539,7 +2496,7 @@ free_named_symtabs (char *name)
 again2:
   for (ps = partial_symtab_list; ps; ps = ps->next)
     {
-      if (STREQ (name, ps->filename))
+      if (strcmp (name, ps->filename) == 0)
        {
          cashier_psymtab (ps); /* Blow it away...and its little dog, too.  */
          goto again2;          /* Must restart, chain has been munged */
@@ -2550,7 +2507,7 @@ again2:
 
   for (s = symtab_list; s; s = s->next)
     {
-      if (STREQ (name, s->filename))
+      if (strcmp (name, s->filename) == 0)
        break;
       prev = s;
     }
@@ -2653,7 +2610,7 @@ add_psymbol_to_list (char *name, int namelength, domain_enum domain,
                     CORE_ADDR coreaddr,        /* Value as a CORE_ADDR */
                     enum language language, struct objfile *objfile)
 {
-  register struct partial_symbol *psym;
+  struct partial_symbol *psym;
   char *buf = alloca (namelength + 1);
   /* psymbol is static so that there will be no uninitialized gaps in the
      structure which might contain random data, causing cache misses in
@@ -2680,7 +2637,8 @@ add_psymbol_to_list (char *name, int namelength, domain_enum domain,
   SYMBOL_SET_NAMES (&psymbol, buf, namelength, objfile);
 
   /* Stash the partial symbol away in the cache */
-  psym = bcache (&psymbol, sizeof (struct partial_symbol), objfile->psymbol_cache);
+  psym = deprecated_bcache (&psymbol, sizeof (struct partial_symbol),
+                           objfile->psymbol_cache);
 
   /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
   if (list->next >= list->list + list->size)
@@ -2706,7 +2664,7 @@ add_psymbol_with_dem_name_to_list (char *name, int namelength, char *dem_name,
                                   enum language language,
                                   struct objfile *objfile)
 {
-  register struct partial_symbol *psym;
+  struct partial_symbol *psym;
   char *buf = alloca (namelength + 1);
   /* psymbol is static so that there will be no uninitialized gaps in the
      structure which might contain random data, causing cache misses in
@@ -2717,7 +2675,8 @@ add_psymbol_with_dem_name_to_list (char *name, int namelength, char *dem_name,
 
   memcpy (buf, name, namelength);
   buf[namelength] = '\0';
-  DEPRECATED_SYMBOL_NAME (&psymbol) = bcache (buf, namelength + 1, objfile->psymbol_cache);
+  DEPRECATED_SYMBOL_NAME (&psymbol) = deprecated_bcache (buf, namelength + 1,
+                                                        objfile->psymbol_cache);
 
   buf = alloca (dem_namelength + 1);
   memcpy (buf, dem_name, dem_namelength);
@@ -2728,7 +2687,7 @@ add_psymbol_with_dem_name_to_list (char *name, int namelength, char *dem_name,
     case language_c:
     case language_cplus:
       SYMBOL_CPLUS_DEMANGLED_NAME (&psymbol) =
-       bcache (buf, dem_namelength + 1, objfile->psymbol_cache);
+       deprecated_bcache (buf, dem_namelength + 1, objfile->psymbol_cache);
       break;
       /* FIXME What should be done for the default case? Ignoring for now. */
     }
@@ -2749,7 +2708,8 @@ add_psymbol_with_dem_name_to_list (char *name, int namelength, char *dem_name,
   SYMBOL_INIT_LANGUAGE_SPECIFIC (&psymbol, language);
 
   /* Stash the partial symbol away in the cache */
-  psym = bcache (&psymbol, sizeof (struct partial_symbol), objfile->psymbol_cache);
+  psym = deprecated_bcache (&psymbol, sizeof (struct partial_symbol),
+                           objfile->psymbol_cache);
 
   /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
   if (list->next >= list->list + list->size)
@@ -3191,7 +3151,7 @@ the 'overlay manual' command.");
                                  sec2->the_bfd_section))
        {
          if (info_verbose)
-           printf_filtered ("Note: section %s unmapped by overlap\n",
+           printf_unfiltered ("Note: section %s unmapped by overlap\n",
                             bfd_section_name (objfile->obfd,
                                               sec2->the_bfd_section));
          sec2->ovly_mapped = 0;        /* sec2 overlaps sec: unmap sec2 */
@@ -3241,7 +3201,7 @@ overlay_auto_command (char *args, int from_tty)
   overlay_debugging = ovly_auto;
   enable_overlay_breakpoints ();
   if (info_verbose)
-    printf_filtered ("Automatic overlay debugging enabled.");
+    printf_unfiltered ("Automatic overlay debugging enabled.");
 }
 
 /* Function: overlay_manual_command
@@ -3254,7 +3214,7 @@ overlay_manual_command (char *args, int from_tty)
   overlay_debugging = ovly_on;
   disable_overlay_breakpoints ();
   if (info_verbose)
-    printf_filtered ("Overlay debugging enabled.");
+    printf_unfiltered ("Overlay debugging enabled.");
 }
 
 /* Function: overlay_off_command
@@ -3267,7 +3227,7 @@ overlay_off_command (char *args, int from_tty)
   overlay_debugging = ovly_off;
   disable_overlay_breakpoints ();
   if (info_verbose)
-    printf_filtered ("Overlay debugging disabled.");
+    printf_unfiltered ("Overlay debugging disabled.");
 }
 
 static void
This page took 0.040106 seconds and 4 git commands to generate.