Bug 17855 - clear_symtab_users doesn't call observer_notify_new_objfile (NULL) early enough
Summary: clear_symtab_users doesn't call observer_notify_new_objfile (NULL) early enough
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-18 04:52 IST by Doug Evans
Modified: 2015-02-22 17:15 IST (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Evans 2015-01-18 04:52:44 IST
I ran into this with my symtab lookup cache patch, PR 17799.

I think the problem can also be seen from ada, which has its own symbol lookup cache, except one will need to fix PR 17854 first (assuming I'm not missing something).

diff --git a/gdb/symfile.c b/gdb/symfile.c                                                                                                                       
index d55e361..ad481de 100644                                                                                                                                    
--- a/gdb/symfile.c                                                                                                                                              
+++ b/gdb/symfile.c                                                                                                                                              
@@ -3023,6 +3023,12 @@ clear_symtab_users (int add_flags)
   /* Someday, we should do better than this, by only blowing away                                                                                               
      the things that really need to be blown.  */                                                                                                               
                                                                                                                                                                 
+  /* Notify anyone listening that the previous loaded symtab(s) are invalid.                                                                                    
+     It is important to do this before calling breakpoint_re_set as the latter                                                                                  
+     will try to look up symbols, and for example the symbol cache needs to                                                                                     
+     be flushed first.  */                                                                                                                                      
+  observer_notify_new_objfile (NULL);                                                                                                                           
+                                                                                                                                                                
   /* Clear the "current" symtab first, because it is no longer valid.                                                                                           
      breakpoint_re_set may try to access the current symtab.  */                                                                                                
   clear_current_source_symtab_and_line ();                                                                                                                      
@@ -3032,7 +3038,6 @@ clear_symtab_users (int add_flags)
     breakpoint_re_set ();                                                                                                                                       
   clear_last_displayed_sal ();                                                                                                                                  
   clear_pc_function_cache ();                                                                                                                                   
-  observer_notify_new_objfile (NULL);                                                                                                                           
                                                                                                                                                                 
   /* Clear globals which might have pointed into a removed objfile.                                                                                             
      FIXME: It's not clear which of these are supposed to persist
Comment 1 cvs-commit@gcc.gnu.org 2015-01-31 20:45:41 IST
The master branch has been updated by Doug Evans <devans@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e700d1b279b26d4b7d86cfae70d2e022ee748068

commit e700d1b279b26d4b7d86cfae70d2e022ee748068
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Sat Jan 31 12:43:02 2015 -0800

    PR symtab/17855
    
    gdb/ChangeLog:
    
    	PR symtab/17855
    	* symfile.c (clear_symtab_users): Move call to breakpoint_re_set
    	to end.
Comment 2 cvs-commit@gcc.gnu.org 2015-01-31 21:07:30 IST
The gdb-7.9-branch branch has been updated by Doug Evans <devans@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d4137b858a8b7916668f160a166ee375adcb601b

commit d4137b858a8b7916668f160a166ee375adcb601b
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Sat Jan 31 13:04:51 2015 -0800

    PR symtab/17855
    
    gdb/ChangeLog:
    
    	PR symtab/17855
    	* symfile.c (clear_symtab_users): Move call to breakpoint_re_set
    	to end.
Comment 3 Doug Evans 2015-02-04 15:55:13 IST
patches are in trunk and 7.9 branch
Comment 4 cvs-commit@gcc.gnu.org 2015-02-22 17:15:05 IST
The master branch has been updated by Doug Evans <devans@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=85c3a371b327377ba1014e8962ba41554599d3e6

commit 85c3a371b327377ba1014e8962ba41554599d3e6
Author: Doug Evans <xdje42@gmail.com>
Date:   Sun Feb 22 09:11:55 2015 -0800

    testcase for PR symtab/17855
    
    gdb/testsuite/ChangeLog:
    
    	PR symtab/17855
    	* gdb.ada/exec_changed.exp: Add second test where symbol lookup cache
    	is read after symbols have been re-read.
    	* gdb.ada/exec_changed/first.adb (First): New procedure Break_Me.
    	* gdb.ada/exec_changed/second.adb (Second): Ditto.