From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7639 invoked by alias); 3 Aug 2006 21:46:47 -0000 Received: (qmail 7631 invoked by uid 22791); 3 Aug 2006 21:46:47 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Thu, 03 Aug 2006 21:46:44 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1G8l1e-0001e6-CW; Thu, 03 Aug 2006 17:46:42 -0400 Date: Thu, 03 Aug 2006 21:46:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org, Mark Kettenis Subject: [rfc] Clear some global variables when reloading object files Message-ID: <20060803214642.GA6303@nevyn.them.org> Mail-Followup-To: gdb-patches@sourceware.org, Mark Kettenis MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.11+cvs20060403 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-08/txt/msg00030.txt.bz2 Mark, I encountered a problem today with expression_context_block that sounded exactly like what you encountered with innermost_block. I suspect the right thing to do would be to clean up the global variables entirely, but I agree that it would be a terrible mess to untangle, and this seems like the next best thing. What do you think? -- Daniel Jacobowitz CodeSourcery 2006-08-03 Daniel Jacobowitz * Makefile.in (objfiles.o, symfile.o): Update. * objfiles.c: Include "expression.h" and "parser-defs.h". (free_objfile): Clear global blocks. * symfile.c: Include "parser-defs.h". (clear_symtab_users): Clear global blocks. --- Makefile.in (revision 146239) +++ Makefile.in (local) @@ -2441,7 +2441,8 @@ objc-lang.o: objc-lang.c $(defs_h) $(sym objfiles.o: objfiles.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \ $(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(mdebugread_h) \ $(gdb_assert_h) $(gdb_stat_h) $(gdb_obstack_h) $(gdb_string_h) \ - $(hashtab_h) $(breakpoint_h) $(block_h) $(dictionary_h) $(source_h) + $(hashtab_h) $(breakpoint_h) $(block_h) $(dictionary_h) $(source_h) \ + $(parser_defs_h) $(expression_h) observer.o: observer.c $(defs_h) $(observer_h) $(command_h) $(gdbcmd_h) \ $(observer_inc) obsd-tdep.o: obsd-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(obsd_tdep_h) @@ -2764,7 +2765,8 @@ symfile.o: symfile.c $(defs_h) $(bfdlink $(complaints_h) $(demangle_h) $(inferior_h) $(filenames_h) \ $(gdb_stabs_h) $(gdb_obstack_h) $(completer_h) $(bcache_h) \ $(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \ - $(gdb_string_h) $(gdb_stat_h) $(observer_h) $(exec_h) + $(gdb_string_h) $(gdb_stat_h) $(observer_h) $(exec_h) \ + $(parser_defs_h) symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \ $(objfiles_h) $(exceptions_h) $(gdbcmd_h) $(target_h) $(value_h) \ $(symfile_h) $(observer_h) $(auxv_h) $(elf_common_h) --- objfiles.c (revision 146239) +++ objfiles.c (local) @@ -34,6 +34,9 @@ #include "target.h" #include "bcache.h" #include "mdebugread.h" +#include "expression.h" +#include "parser-defs.h" + #include "gdb_assert.h" #include #include "gdb_stat.h" @@ -441,6 +444,12 @@ free_objfile (struct objfile *objfile) for example), so we need to call this here. */ clear_pc_function_cache (); + /* Clear globals which might have pointed into a removed objfile. + FIXME: It's not clear which of these are supposed to persist + between expressions and which ought to be reset each time. */ + expression_context_block = NULL; + innermost_block = NULL; + /* Check to see if the current_source_symtab belongs to this objfile, and if so, call clear_current_source_symtab_and_line. */ --- symfile.c (revision 146239) +++ symfile.c (local) @@ -51,6 +51,7 @@ #include "block.h" #include "observer.h" #include "exec.h" +#include "parser-defs.h" #include #include @@ -2537,6 +2538,12 @@ clear_symtab_users (void) clear_pc_function_cache (); if (deprecated_target_new_objfile_hook) deprecated_target_new_objfile_hook (NULL); + + /* Clear globals which might have pointed into a removed objfile. + FIXME: It's not clear which of these are supposed to persist + between expressions and which ought to be reset each time. */ + expression_context_block = NULL; + innermost_block = NULL; } static void