From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7736 invoked by alias); 3 Jan 2006 17:42:10 -0000 Received: (qmail 7728 invoked by uid 22791); 3 Jan 2006 17:42:10 -0000 X-Spam-Check-By: sourceware.org Received: from w099.z064220152.sjc-ca.dsl.cnc.net (HELO duck.specifix.com) (64.220.152.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 03 Jan 2006 17:42:08 +0000 Received: from [::1] (duck.specifix.com [64.220.152.99]) by duck.specifix.com (Postfix) with ESMTP id 1372DFC47; Tue, 3 Jan 2006 09:42:06 -0800 (PST) From: Fred Fish Reply-To: fnf@specifix.com To: gdb-patches@sourceware.org Subject: [PATCH] Clear current source symtab if belongs to objfile being freed Date: Tue, 03 Jan 2006 17:42:00 -0000 User-Agent: KMail/1.9.1 Cc: fnf@specifix.com MIME-Version: 1.0 Message-Id: <200601031242.38425.fnf@specifix.com> Content-Type: Multipart/Mixed; boundary="Boundary-00=_OeruDdsxOxwGIHO" 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-01/txt/msg00011.txt.bz2 --Boundary-00=_OeruDdsxOxwGIHO Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 452 I stumbled over this problem while chasing something else. If the current source symtab belongs to a loaded shared library, and the objfile for that library is freed in the process or rerunning the executable, the current source symtab can be left pointing to garbage. An alternative solution, though a little more heavy handed, would be to replace the previous clear_pc_function_cache() call with a call to clear_symtab_users(). Comments? -Fred --Boundary-00=_OeruDdsxOxwGIHO Content-Type: text/x-diff; charset="us-ascii"; name="symtab.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="symtab.patch" Content-length: 2071 2006-01-03 Fred Fish * objfiles.c (source.h): Include. (free_objfile): Update comment about clear_symtab_users(). (free_objfile): Check all symtabs of objfile being freed and if one of them is the current source symtab, call clear_current_source_symtab_and_line(). Index: objfiles.c =================================================================== RCS file: /cvsroots/latest/src/gdb/gdb/objfiles.c,v retrieving revision 1.1.1.2 diff -c -p -r1.1.1.2 objfiles.c *** objfiles.c 30 Dec 2005 18:53:15 -0000 1.1.1.2 --- objfiles.c 3 Jan 2006 15:57:05 -0000 *************** *** 45,50 **** --- 45,51 ---- #include "breakpoint.h" #include "block.h" #include "dictionary.h" + #include "source.h" /* Prototypes for local functions */ *************** free_objfile (struct objfile *objfile) *** 432,441 **** is unknown, but we play it safe for now and keep each action until it is shown to be no longer needed. */ ! /* I *think* all our callers call clear_symtab_users. If so, no need ! to call this here. */ clear_pc_function_cache (); /* The last thing we do is free the objfile struct itself. */ objfile_free_data (objfile); --- 433,457 ---- is unknown, but we play it safe for now and keep each action until it is shown to be no longer needed. */ ! /* I *think* all our callers call clear_symtab_users. If so, no ! need to call this here. Update: We are called via ! objfile_purge_solibs which doesn't call clear_symtab_users. */ clear_pc_function_cache (); + /* Check to see if the current_source_symtab belongs to this objfile, + and if so, call clear_current_source_symtab_and_line. */ + + { + struct symtab_and_line cursal = get_current_source_symtab_and_line (); + struct symtab *s; + + ALL_OBJFILE_SYMTABS (objfile, s) + { + if (s == cursal.symtab) + clear_current_source_symtab_and_line (); + } + } + /* The last thing we do is free the objfile struct itself. */ objfile_free_data (objfile); --Boundary-00=_OeruDdsxOxwGIHO--