[PR,symtab/17855] Fix.

Message ID m33876ary6.fsf@sspiff.org
State New, archived
Headers

Commit Message

Doug Evans Jan. 20, 2015, 6:26 a.m. UTC
  Hi.

This patch fixes symtab/17855.
Basically the issue is that breakpoint_re_set is currently being called
before observer_notify_new_objfile (NULL), and thus the ada symbol
cache (and the general symbol cache of a separate patch) aren't being
flushed first, so that when breakpoints are reset symbol lookup is being
done on a stale cache.

Regression tested on amd64-linux.

2015-01-19  Doug Evans  <xdje42@gmail.com>

	PR symtab/17855
	* symfile.c (clear_symtab_users): Notify observers of change before
	calling breakpoint_re_set.
  

Comments

Pedro Alves Jan. 22, 2015, 11:41 a.m. UTC | #1
On 01/20/2015 06:26 AM, Doug Evans wrote:
> Hi.
> 
> This patch fixes symtab/17855.
> Basically the issue is that breakpoint_re_set is currently being called
> before observer_notify_new_objfile (NULL), and thus the ada symbol
> cache (and the general symbol cache of a separate patch) aren't being
> flushed first, so that when breakpoints are reset symbol lookup is being
> done on a stale cache.
> 
> Regression tested on amd64-linux.
> 
> 2015-01-19  Doug Evans  <xdje42@gmail.com>
> 
> 	PR symtab/17855
> 	* symfile.c (clear_symtab_users): Notify observers of change before
> 	calling breakpoint_re_set.
> 
> 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);

Looking at the whole function, ISTM that the breakpoint_re_set
call should move further down.  I can imagine that breakpoint_re_set
could well hit a stale pc function cache, cleared only after by
clear_pc_function_cache.  breakpoint.c:parse_breakpoint_sals also
references the last displayed sal.  One would hope that breakpoint
re-set is independent of that, though the existing comment about
breakpoint_re_set accessing the current symtab leaves me
wondering.  WDYT?

Thanks,
Pedro Alves
  
Doug Evans Jan. 22, 2015, 3:37 p.m. UTC | #2
On Thu, Jan 22, 2015 at 3:41 AM, Pedro Alves <palves@redhat.com> wrote:
> Looking at the whole function, ISTM that the breakpoint_re_set
> call should move further down.  I can imagine that breakpoint_re_set
> could well hit a stale pc function cache, cleared only after by
> clear_pc_function_cache.  breakpoint.c:parse_breakpoint_sals also
> references the last displayed sal.  One would hope that breakpoint
> re-set is independent of that, though the existing comment about
> breakpoint_re_set accessing the current symtab leaves me
> wondering.  WDYT?

Fine by me.
  

Patch

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