From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27776 invoked by alias); 8 Dec 2009 10:57:51 -0000 Received: (qmail 27754 invoked by uid 22791); 8 Dec 2009 10:57:45 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Dec 2009 10:57:34 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1529729001C; Tue, 8 Dec 2009 11:57:32 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kg-G2Ma9hYF8; Tue, 8 Dec 2009 11:57:31 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 0C0B2290010; Tue, 8 Dec 2009 11:57:30 +0100 (CET) Subject: Re: [RFA] Make sym_read routines handle separate debug files Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: Tristan Gingold In-Reply-To: Date: Tue, 08 Dec 2009 10:57:00 -0000 Cc: gdb-patches@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20091204124838.GA5764@ulanbator.act-europe.fr> <2CC5EFB8-A1BC-4025-9136-E8FA344B2C04@adacore.com> To: Tom Tromey X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-12/txt/msg00117.txt.bz2 Hi, latest version of the patch. I have inserted a gdb_assert in symbol_file_a= dd_separate and fixed the comment in reread_symbols. No regression on x86 GNU/Linux. Tristan. 2009-12-08 Tristan Gingold * symfile.h (symbol_file_add_separate): New prototype. (find_separate_debug_file_by_buildid): Ditto. (find_separate_debug_file_by_debuglink): Ditto. * symfile.c (reread_separate_symbols): Remove. (find_separate_debug_file): Split into ... (find_separate_debug_file_by_buildid): ... this and ... (find_separate_debug_file_by_debuglink): ... this. (symbol_file_add_with_addrs_or_offsets): Do not save orig_addrs. Remove separate debug file handling. (symbol_file_add_separate): New function. (reread_symbols): Do not considere separate debug files, but free them while handling their parent. Reindent. * coffread.c (coff_symfile_read): Handle separate object file. * elfread.c (elf_symfile_read): Ditto. TBM. --- gdb/coffread.c | 15 ++ gdb/elfread.c | 20 ++ gdb/symfile.c | 540 +++++++++++++++++++++++++---------------------------= ---- gdb/symfile.h | 7 + 4 files changed, 283 insertions(+), 299 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 3f5ff96..58f5337 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -637,6 +637,21 @@ coff_symfile_read (struct objfile *objfile, int symfil= e_flags) =20 dwarf2_build_frame_info (objfile); =20 + /* Try to add separate debug file if no symbols table found. */ + if (!objfile_has_partial_symbols (objfile)) + { + char *debugfile; + + debugfile =3D find_separate_debug_file_by_debuglink (objfile); + + if (debugfile) + { + bfd *abfd =3D symfile_bfd_open (debugfile); + symbol_file_add_separate (abfd, symfile_flags, objfile); + xfree (debugfile); + } + } + do_cleanups (back_to); } =20 diff --git a/gdb/elfread.c b/gdb/elfread.c index dd844fc..a47e687 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -737,6 +737,26 @@ elf_symfile_read (struct objfile *objfile, int symfile= _flags) /* FIXME: kettenis/20030504: This still needs to be integrated with dwarf2read.c in a better way. */ dwarf2_build_frame_info (objfile); + + /* If the file has its own symbol tables it has no separate debug info. + `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSY= MTABS. + `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. = */ + if (!objfile_has_partial_symbols (objfile)) + { + char *debugfile; + + debugfile =3D find_separate_debug_file_by_buildid (objfile); + + if (debugfile =3D=3D NULL) + debugfile =3D find_separate_debug_file_by_debuglink (objfile); + + if (debugfile) + { + bfd *abfd =3D symfile_bfd_open (debugfile); + symbol_file_add_separate (abfd, symfile_flags, objfile); + xfree (debugfile); + } + } } =20 /* This cleans up the objfile's deprecated_sym_stab_info pointer, and diff --git a/gdb/symfile.c b/gdb/symfile.c index 6e1b915..10733d7 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -97,8 +97,6 @@ static void symbol_file_add_main_1 (char *args, int from_= tty, int flags); =20 static void add_symbol_file_command (char *, int); =20 -static void reread_separate_symbols (struct objfile *objfile); - static void cashier_psymtab (struct partial_symtab *); =20 bfd *symfile_bfd_open (char *); @@ -140,8 +138,6 @@ static void add_filename_language (char *ext, enum lang= uage lang); =20 static void info_ext_lang_command (char *args, int from_tty); =20 -static char *find_separate_debug_file (struct objfile *objfile); - static void init_filename_language_table (void); =20 static void symfile_find_segment_sections (struct objfile *objfile); @@ -947,8 +943,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, { struct objfile *objfile; struct partial_symtab *psymtab; - char *debugfile =3D NULL; - struct section_addr_info *orig_addrs =3D NULL; struct cleanup *my_cleanups; const char *name =3D bfd_get_filename (abfd); const int from_tty =3D add_flags & SYMFILE_VERBOSE; @@ -967,12 +961,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, objfile =3D allocate_objfile (abfd, flags); discard_cleanups (my_cleanups); =20 - if (addrs) - { - orig_addrs =3D copy_section_addr_info (addrs); - make_cleanup_free_section_addr_info (orig_addrs); - } - /* 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. */ @@ -1012,33 +1000,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, } } =20 - /* If the file has its own symbol tables it has no separate debug info. - `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSY= MTABS. - `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. = */ - if (objfile->psymtabs =3D=3D NULL) - debugfile =3D find_separate_debug_file (objfile); - if (debugfile) - { - if (addrs !=3D NULL) - { - objfile->separate_debug_objfile - =3D symbol_file_add (debugfile, add_flags, orig_addrs, flags); - } - else - { - objfile->separate_debug_objfile - =3D symbol_file_add (debugfile, add_flags, NULL, flags); - } - objfile->separate_debug_objfile->separate_debug_objfile_backlink - =3D objfile; - - /* Put the separate debug object before the normal one, this is so t= hat - usage of the ALL_OBJFILES_SAFE macro will stay safe. */ - put_objfile_before (objfile->separate_debug_objfile, objfile); - - xfree (debugfile); - } - if ((from_tty || info_verbose) && !objfile_has_symbols (objfile)) { @@ -1076,6 +1037,28 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, return (objfile); } =20 +/* Add BFD as a separate debug file for OBJFILE. */ + +void +symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *obj= file) +{ + /* Currently only one separate debug objfile is supported. */ + gdb_assert (objfile && objfile->separate_debug_objfile =3D=3D NULL); + + objfile->separate_debug_objfile =3D + symbol_file_add_with_addrs_or_offsets + (bfd, symfile_flags, + 0, /* No addr table. */ + objfile->section_offsets, objfile->num_sections, + objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW + | OBJF_USERLOADED)); + objfile->separate_debug_objfile->separate_debug_objfile_backlink + =3D objfile; + + /* Put the separate debug object before the normal one, this is so that + usage of the ALL_OBJFILES_SAFE macro will stay safe. */ + put_objfile_before (objfile->separate_debug_objfile, objfile); +} =20 /* Process the symbol file ABFD, as either the main file or as a dynamically loaded file. @@ -1383,8 +1366,8 @@ The directory where separate debug symbols are search= ed for is \"%s\".\n"), #define DEBUG_SUBDIRECTORY ".debug" #endif =20 -static char * -find_separate_debug_file (struct objfile *objfile) +char * +find_separate_debug_file_by_buildid (struct objfile *objfile) { asection *sect; char *basename, *name_copy, *debugdir; @@ -1413,6 +1396,20 @@ find_separate_debug_file (struct objfile *objfile) else if (build_id_name !=3D NULL) return build_id_name; } + return NULL; +} + +char * +find_separate_debug_file_by_debuglink (struct objfile *objfile) +{ + asection *sect; + char *basename, *name_copy, *debugdir; + char *dir =3D NULL; + char *debugfile =3D NULL; + char *canon_name =3D NULL; + bfd_size_type debuglink_size; + unsigned long crc32; + int i; =20 basename =3D get_debug_link_info (objfile, &crc32); =20 @@ -2320,204 +2317,216 @@ reread_symbols (void) =20 for (objfile =3D object_files; objfile; objfile =3D objfile->next) { - if (objfile->obfd) - { + /* solib-sunos.c creates one objfile with obfd. */ + if (objfile->obfd =3D=3D NULL) + continue; + + /* Separate debug objfiles are handled in the main objfile. */ + if (objfile->separate_debug_objfile_backlink) + continue; + #ifdef DEPRECATED_IBM6000_TARGET - /* If this object is from a shared library, then you should - stat on the library name, not member name. */ + /* If this object is from a shared library, then you should + stat on the library name, not member name. */ =20 - if (objfile->obfd->my_archive) - res =3D stat (objfile->obfd->my_archive->filename, &new_statbuf); - else + if (objfile->obfd->my_archive) + res =3D stat (objfile->obfd->my_archive->filename, &new_statbuf); + else #endif - res =3D stat (objfile->name, &new_statbuf); - if (res !=3D 0) + res =3D stat (objfile->name, &new_statbuf); + if (res !=3D 0) + { + /* FIXME, should use print_sys_errmsg but it's not filtered. */ + printf_unfiltered (_("`%s' has disappeared; keeping its symbols.\n"), + objfile->name); + continue; + } + new_modtime =3D new_statbuf.st_mtime; + if (new_modtime !=3D objfile->mtime) + { + struct cleanup *old_cleanups; + struct section_offsets *offsets; + int num_offsets; + char *obfd_filename; + + printf_unfiltered (_("`%s' has changed; re-reading symbols.\n"), + objfile->name); + + /* There are various functions like symbol_file_add, + symfile_bfd_open, syms_from_objfile, etc., which might + appear to do what we want. But they have various other + effects which we *don't* want. So we just do stuff + ourselves. We don't worry about mapped files (for one thing, + any mapped file will be out of date). */ + + /* If we get an error, blow away this objfile (not sure if + that is the correct response for things like shared + libraries). */ + old_cleanups =3D make_cleanup_free_objfile (objfile); + /* We need to do this whenever any symbols go away. */ + make_cleanup (clear_symtab_users_cleanup, 0 /*ignore*/); + + if (exec_bfd !=3D NULL && strcmp (bfd_get_filename (objfile->obfd), + bfd_get_filename (exec_bfd)) =3D=3D 0) { - /* FIXME, should use print_sys_errmsg but it's not filtered. */ - printf_unfiltered (_("`%s' has disappeared; keeping its symbols.\n"= ), - objfile->name); - continue; + /* Reload EXEC_BFD without asking anything. */ + + exec_file_attach (bfd_get_filename (objfile->obfd), 0); } - new_modtime =3D new_statbuf.st_mtime; - if (new_modtime !=3D objfile->mtime) + + /* Clean up any state BFD has sitting around. We don't need + to close the descriptor but BFD lacks a way of closing the + BFD without closing the descriptor. */ + obfd_filename =3D bfd_get_filename (objfile->obfd); + if (!bfd_close (objfile->obfd)) + error (_("Can't close BFD for %s: %s"), objfile->name, + bfd_errmsg (bfd_get_error ())); + if (remote_filename_p (obfd_filename)) + objfile->obfd =3D remote_bfd_open (obfd_filename, gnutarget); + else + objfile->obfd =3D bfd_openr (obfd_filename, gnutarget); + if (objfile->obfd =3D=3D NULL) + error (_("Can't open %s to read symbols."), objfile->name); + else + objfile->obfd =3D gdb_bfd_ref (objfile->obfd); + /* bfd_openr sets cacheable to true, which is what we want. */ + if (!bfd_check_format (objfile->obfd, bfd_object)) + error (_("Can't read symbols from %s: %s."), objfile->name, + bfd_errmsg (bfd_get_error ())); + + /* Save the offsets, we will nuke them with the rest of the + objfile_obstack. */ + num_offsets =3D objfile->num_sections; + offsets =3D ((struct section_offsets *) + alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets))); + memcpy (offsets, objfile->section_offsets, + SIZEOF_N_SECTION_OFFSETS (num_offsets)); + + /* Remove any references to this objfile in the global + value lists. */ + preserve_values (objfile); + + /* Nuke all the state that we will re-read. Much of the following + code which sets things to NULL really is necessary to tell + other parts of GDB that there is nothing currently there. + + Try to keep the freeing order compatible with free_objfile. */ + + if (objfile->sf !=3D NULL) { - struct cleanup *old_cleanups; - struct section_offsets *offsets; - int num_offsets; - char *obfd_filename; - - printf_unfiltered (_("`%s' has changed; re-reading symbols.\n"), - objfile->name); - - /* There are various functions like symbol_file_add, - symfile_bfd_open, syms_from_objfile, etc., which might - appear to do what we want. But they have various other - effects which we *don't* want. So we just do stuff - ourselves. We don't worry about mapped files (for one thing, - any mapped file will be out of date). */ - - /* If we get an error, blow away this objfile (not sure if - that is the correct response for things like shared - libraries). */ - old_cleanups =3D make_cleanup_free_objfile (objfile); - /* We need to do this whenever any symbols go away. */ - make_cleanup (clear_symtab_users_cleanup, 0 /*ignore*/); - - if (exec_bfd !=3D NULL && strcmp (bfd_get_filename (objfile->obfd), - bfd_get_filename (exec_bfd)) =3D=3D 0) - { - /* Reload EXEC_BFD without asking anything. */ + (*objfile->sf->sym_finish) (objfile); + } =20 - exec_file_attach (bfd_get_filename (objfile->obfd), 0); - } + clear_objfile_data (objfile); =20 - /* Clean up any state BFD has sitting around. We don't need - to close the descriptor but BFD lacks a way of closing the - BFD without closing the descriptor. */ - obfd_filename =3D bfd_get_filename (objfile->obfd); - if (!bfd_close (objfile->obfd)) - error (_("Can't close BFD for %s: %s"), objfile->name, - bfd_errmsg (bfd_get_error ())); - if (remote_filename_p (obfd_filename)) - objfile->obfd =3D remote_bfd_open (obfd_filename, gnutarget); - else - objfile->obfd =3D bfd_openr (obfd_filename, gnutarget); - if (objfile->obfd =3D=3D NULL) - error (_("Can't open %s to read symbols."), objfile->name); - else - objfile->obfd =3D gdb_bfd_ref (objfile->obfd); - /* bfd_openr sets cacheable to true, which is what we want. */ - if (!bfd_check_format (objfile->obfd, bfd_object)) - error (_("Can't read symbols from %s: %s."), objfile->name, - bfd_errmsg (bfd_get_error ())); - - /* Save the offsets, we will nuke them with the rest of the - objfile_obstack. */ - num_offsets =3D objfile->num_sections; - offsets =3D ((struct section_offsets *) - alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets))); - memcpy (offsets, objfile->section_offsets, - SIZEOF_N_SECTION_OFFSETS (num_offsets)); - - /* Remove any references to this objfile in the global - value lists. */ - preserve_values (objfile); - - /* Nuke all the state that we will re-read. Much of the following - code which sets things to NULL really is necessary to tell - other parts of GDB that there is nothing currently there. -=09=09=20 - Try to keep the freeing order compatible with free_objfile. */ - - if (objfile->sf !=3D NULL) - { - (*objfile->sf->sym_finish) (objfile); - } + /* Free the separate debug objfile if there is one. It will be + automatically recreated by sym_read. */ + if (objfile->separate_debug_objfile) + { + /* Note: no need to clear separate_debug_objfile field as it is + done by free_objfile. */ + free_objfile (objfile->separate_debug_objfile); + } =20 - clear_objfile_data (objfile); - - /* FIXME: Do we have to free a whole linked list, or is this - enough? */ - if (objfile->global_psymbols.list) - xfree (objfile->global_psymbols.list); - memset (&objfile->global_psymbols, 0, - sizeof (objfile->global_psymbols)); - if (objfile->static_psymbols.list) - xfree (objfile->static_psymbols.list); - memset (&objfile->static_psymbols, 0, - sizeof (objfile->static_psymbols)); - - /* Free the obstacks for non-reusable objfiles */ - bcache_xfree (objfile->psymbol_cache); - objfile->psymbol_cache =3D bcache_xmalloc (); - bcache_xfree (objfile->macro_cache); - objfile->macro_cache =3D bcache_xmalloc (); - bcache_xfree (objfile->filename_cache); - objfile->filename_cache =3D bcache_xmalloc (); - if (objfile->demangled_names_hash !=3D NULL) - { - htab_delete (objfile->demangled_names_hash); - objfile->demangled_names_hash =3D NULL; - } - obstack_free (&objfile->objfile_obstack, 0); - objfile->sections =3D NULL; - objfile->symtabs =3D NULL; - objfile->psymtabs =3D NULL; - objfile->psymtabs_addrmap =3D NULL; - objfile->free_psymtabs =3D NULL; - objfile->cp_namespace_symtab =3D NULL; - objfile->msymbols =3D NULL; - objfile->deprecated_sym_private =3D NULL; - objfile->minimal_symbol_count =3D 0; - memset (&objfile->msymbol_hash, 0, - sizeof (objfile->msymbol_hash)); - memset (&objfile->msymbol_demangled_hash, 0, - sizeof (objfile->msymbol_demangled_hash)); - - objfile->psymbol_cache =3D bcache_xmalloc (); - objfile->macro_cache =3D bcache_xmalloc (); - objfile->filename_cache =3D bcache_xmalloc (); - /* obstack_init also initializes the obstack so it is - empty. We could use obstack_specify_allocation but - gdb_obstack.h specifies the alloc/dealloc - functions. */ - obstack_init (&objfile->objfile_obstack); - if (build_objfile_section_table (objfile)) - { - error (_("Can't find the file sections in `%s': %s"), - objfile->name, bfd_errmsg (bfd_get_error ())); - } - terminate_minimal_symbol_table (objfile); - - /* 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 =3D (struct section_offsets *) - obstack_alloc (&objfile->objfile_obstack, - SIZEOF_N_SECTION_OFFSETS (num_offsets)); - memcpy (objfile->section_offsets, offsets, - SIZEOF_N_SECTION_OFFSETS (num_offsets)); - objfile->num_sections =3D num_offsets; - - /* What the hell is sym_new_init for, anyway? The concept of - distinguishing between the main file and additional files - in this way seems rather dubious. */ - if (objfile =3D=3D symfile_objfile) - { - (*objfile->sf->sym_new_init) (objfile); - } + /* FIXME: Do we have to free a whole linked list, or is this + enough? */ + if (objfile->global_psymbols.list) + xfree (objfile->global_psymbols.list); + memset (&objfile->global_psymbols, 0, + sizeof (objfile->global_psymbols)); + if (objfile->static_psymbols.list) + xfree (objfile->static_psymbols.list); + memset (&objfile->static_psymbols, 0, + sizeof (objfile->static_psymbols)); + + /* Free the obstacks for non-reusable objfiles */ + bcache_xfree (objfile->psymbol_cache); + objfile->psymbol_cache =3D bcache_xmalloc (); + bcache_xfree (objfile->macro_cache); + objfile->macro_cache =3D bcache_xmalloc (); + bcache_xfree (objfile->filename_cache); + objfile->filename_cache =3D bcache_xmalloc (); + if (objfile->demangled_names_hash !=3D NULL) + { + htab_delete (objfile->demangled_names_hash); + objfile->demangled_names_hash =3D NULL; + } + obstack_free (&objfile->objfile_obstack, 0); + objfile->sections =3D NULL; + objfile->symtabs =3D NULL; + objfile->psymtabs =3D NULL; + objfile->psymtabs_addrmap =3D NULL; + objfile->free_psymtabs =3D NULL; + objfile->cp_namespace_symtab =3D NULL; + objfile->msymbols =3D NULL; + objfile->deprecated_sym_private =3D NULL; + objfile->minimal_symbol_count =3D 0; + memset (&objfile->msymbol_hash, 0, + sizeof (objfile->msymbol_hash)); + memset (&objfile->msymbol_demangled_hash, 0, + sizeof (objfile->msymbol_demangled_hash)); + + objfile->psymbol_cache =3D bcache_xmalloc (); + objfile->macro_cache =3D bcache_xmalloc (); + objfile->filename_cache =3D bcache_xmalloc (); + /* obstack_init also initializes the obstack so it is + empty. We could use obstack_specify_allocation but + gdb_obstack.h specifies the alloc/dealloc + functions. */ + obstack_init (&objfile->objfile_obstack); + if (build_objfile_section_table (objfile)) + { + error (_("Can't find the file sections in `%s': %s"), + objfile->name, bfd_errmsg (bfd_get_error ())); + } + terminate_minimal_symbol_table (objfile); + + /* 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 =3D (struct section_offsets *) + obstack_alloc (&objfile->objfile_obstack, + SIZEOF_N_SECTION_OFFSETS (num_offsets)); + memcpy (objfile->section_offsets, offsets, + SIZEOF_N_SECTION_OFFSETS (num_offsets)); + objfile->num_sections =3D num_offsets; + + /* What the hell is sym_new_init for, anyway? The concept of + distinguishing between the main file and additional files + in this way seems rather dubious. */ + if (objfile =3D=3D symfile_objfile) + { + (*objfile->sf->sym_new_init) (objfile); + } =20 - (*objfile->sf->sym_init) (objfile); - clear_complaints (&symfile_complaints, 1, 1); - /* The "mainline" parameter is a hideous hack; I think leaving it - zero is OK since dbxread.c also does what it needs to do if - objfile->global_psymbols.size is 0. */ - (*objfile->sf->sym_read) (objfile, 0); - if (!objfile_has_symbols (objfile)) - { - wrap_here (""); - printf_unfiltered (_("(no debugging symbols found)\n")); - wrap_here (""); - } + (*objfile->sf->sym_init) (objfile); + clear_complaints (&symfile_complaints, 1, 1); + /* Do not set flags as this is safe and we don't want to be + verbose. */ + (*objfile->sf->sym_read) (objfile, 0); + if (!objfile_has_symbols (objfile)) + { + wrap_here (""); + printf_unfiltered (_("(no debugging symbols found)\n")); + wrap_here (""); + } =20 - /* We're done reading the symbol file; finish off complaints. */ - clear_complaints (&symfile_complaints, 0, 1); + /* We're done reading the symbol file; finish off complaints. */ + clear_complaints (&symfile_complaints, 0, 1); =20 - /* Getting new symbols may change our opinion about what is - frameless. */ + /* Getting new symbols may change our opinion about what is + frameless. */ =20 - reinit_frame_cache (); + reinit_frame_cache (); =20 - /* Discard cleanups as symbol reading was successful. */ - discard_cleanups (old_cleanups); + /* Discard cleanups as symbol reading was successful. */ + discard_cleanups (old_cleanups); =20 - /* If the mtime has changed between the time we set new_modtime - and now, we *want* this to be out of date, so don't call stat - again now. */ - objfile->mtime =3D new_modtime; - reread_one =3D 1; - reread_separate_symbols (objfile); - init_entry_point_info (objfile); - } + /* If the mtime has changed between the time we set new_modtime + and now, we *want* this to be out of date, so don't call stat + again now. */ + objfile->mtime =3D new_modtime; + reread_one =3D 1; + init_entry_point_info (objfile); } } =20 @@ -2532,73 +2541,6 @@ reread_symbols (void) observer_notify_executable_changed (); } } - - -/* Handle separate debug info for OBJFILE, which has just been - re-read: - - If we had separate debug info before, but now we don't, get rid - of the separated objfile. - - If we didn't have separated debug info before, but now we do, - read in the new separated debug info file. - - If the debug link points to a different file, toss the old one - and read the new one. - This function does *not* handle the case where objfile is still - using the same separate debug info file, but that file's timestamp - has changed. That case should be handled by the loop in - reread_symbols already. */ -static void -reread_separate_symbols (struct objfile *objfile) -{ - char *debug_file; - unsigned long crc32; - - /* Does the updated objfile's debug info live in a - separate file? */ - debug_file =3D find_separate_debug_file (objfile); - - if (objfile->separate_debug_objfile) - { - /* There are two cases where we need to get rid of - the old separated debug info objfile: - - if the new primary objfile doesn't have - separated debug info, or - - if the new primary objfile has separate debug - info, but it's under a different filename. - - If the old and new objfiles both have separate - debug info, under the same filename, then we're - okay --- if the separated file's contents have - changed, we will have caught that when we - visited it in this function's outermost - loop. */ - if (! debug_file - || strcmp (debug_file, objfile->separate_debug_objfile->name) != =3D 0) - free_objfile (objfile->separate_debug_objfile); - } - - /* If the new objfile has separate debug info, and we - haven't loaded it already, do so now. */ - if (debug_file - && ! objfile->separate_debug_objfile) - { - /* Use the same section offset table as objfile itself. - Preserve the flags from objfile that make sense. */ - objfile->separate_debug_objfile - =3D (symbol_file_add_with_addrs_or_offsets - (symfile_bfd_open (debug_file), - info_verbose ? SYMFILE_VERBOSE : 0, - 0, /* No addr table. */ - objfile->section_offsets, objfile->num_sections, - objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW - | OBJF_USERLOADED))); - objfile->separate_debug_objfile->separate_debug_objfile_backlink - =3D objfile; - } - if (debug_file) - xfree (debug_file); -} - - =20 =20 =20 diff --git a/gdb/symfile.h b/gdb/symfile.h index 9061009..a9c5608 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -238,6 +238,13 @@ extern struct objfile *symbol_file_add_from_bfd (bfd *= , int, struct section_addr_info = *, int); =20 +extern void symbol_file_add_separate (bfd *bfd, int symfile_flags, + struct objfile *objfile); + +extern char *find_separate_debug_file_by_buildid (struct objfile *objfile); + +extern char *find_separate_debug_file_by_debuglink (struct objfile *objfil= e); + /* Create a new section_addr_info, with room for NUM_SECTIONS. */ =20 extern struct section_addr_info *alloc_section_addr_info (size_t