X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsymfile.c;h=30330afaabc6c6a53ef20821e5ef326213532b9d;hb=8b92e4d54f80aae37af6b0b2a23e114ae4b5d29d;hp=68352841dd002e3a5a52a888d7634a4997721c83;hpb=7b097ae3929cc0a113d185397fff442217b2365b;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/symfile.c b/gdb/symfile.c index 68352841dd..30330afaab 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -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; -/* 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) -{ - 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. */ @@ -499,7 +485,7 @@ default_symfile_offsets (struct objfile *objfile, objfile->num_sections = bfd_count_sections (objfile->obfd); objfile->section_offsets = (struct section_offsets *) - obstack_alloc (&objfile->psymbol_obstack, + obstack_alloc (&objfile->objfile_obstack, SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)); memset (objfile->section_offsets, 0, SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)); @@ -704,7 +690,7 @@ syms_from_objfile (struct objfile *objfile, objfile->num_sections = num_offsets; objfile->section_offsets = ((struct section_offsets *) - obstack_alloc (&objfile->psymbol_obstack, size)); + obstack_alloc (&objfile->objfile_obstack, size)); memcpy (objfile->section_offsets, offsets, size); init_objfile_sect_indices (objfile); @@ -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_unfiltered ("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_unfiltered ("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 @@ -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++; } @@ -1751,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 { @@ -1922,7 +1879,7 @@ reread_symbols (void) bfd_errmsg (bfd_get_error ())); /* Save the offsets, we will nuke them with the rest of the - psymbol_obstack. */ + objfile_obstack. */ num_offsets = objfile->num_sections; offsets = ((struct section_offsets *) alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets))); @@ -1954,13 +1911,13 @@ reread_symbols (void) htab_delete (objfile->demangled_names_hash); objfile->demangled_names_hash = NULL; } - obstack_free (&objfile->psymbol_obstack, 0); + obstack_free (&objfile->objfile_obstack, 0); obstack_free (&objfile->symbol_obstack, 0); - obstack_free (&objfile->type_obstack, 0); objfile->sections = NULL; 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; @@ -1981,12 +1938,10 @@ reread_symbols (void) it is empty. */ objfile->psymbol_cache = bcache_xmalloc (); objfile->macro_cache = bcache_xmalloc (); - obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, + obstack_specify_allocation (&objfile->objfile_obstack, 0, 0, xmalloc, xfree); obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc, xfree); - obstack_specify_allocation (&objfile->type_obstack, 0, 0, - xmalloc, xfree); if (build_objfile_section_table (objfile)) { error ("Can't find the file sections in `%s': %s", @@ -1997,7 +1952,7 @@ reread_symbols (void) /* We use the same section offsets as from last time. I'm not sure whether that is always correct for shared libraries. */ objfile->section_offsets = (struct section_offsets *) - obstack_alloc (&objfile->psymbol_obstack, + obstack_alloc (&objfile->objfile_obstack, SIZEOF_N_SECTION_OFFSETS (num_offsets)); memcpy (objfile->section_offsets, offsets, SIZEOF_N_SECTION_OFFSETS (num_offsets)); @@ -2110,8 +2065,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; @@ -2322,12 +2276,12 @@ allocate_psymtab (char *filename, struct objfile *objfile) } else psymtab = (struct partial_symtab *) - obstack_alloc (&objfile->psymbol_obstack, + obstack_alloc (&objfile->objfile_obstack, sizeof (struct partial_symtab)); memset (psymtab, 0, sizeof (struct partial_symtab)); psymtab->filename = obsavestring (filename, strlen (filename), - &objfile->psymbol_obstack); + &objfile->objfile_obstack); psymtab->symtab = NULL; /* Prepend it to the psymtab list for the objfile it belongs to. @@ -2476,7 +2430,7 @@ cashier_psymtab (struct partial_symtab *pst) partial_symbol lists (global_psymbols/static_psymbols) that this psymtab points to. These just take up space until all the psymtabs are reclaimed. Ditto the dependencies list and - filename, which are all in the psymbol_obstack. */ + filename, which are all in the objfile_obstack. */ /* We need to cashier any psymtab that has this one as a dependency... */ again: @@ -2539,7 +2493,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 +2504,7 @@ again2: for (s = symtab_list; s; s = s->next) { - if (STREQ (name, s->filename)) + if (strcmp (name, s->filename) == 0) break; prev = s; } @@ -2680,7 +2634,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) @@ -2717,7 +2672,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 +2684,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 +2705,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)