From: Fred Fish <fnf@specifix.com>
To: gdb-patches@sourceware.org
Cc: fnf@specifix.com
Subject: [PATCH] Clear current source symtab if belongs to objfile being freed
Date: Tue, 03 Jan 2006 17:42:00 -0000 [thread overview]
Message-ID: <200601031242.38425.fnf@specifix.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 452 bytes --]
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
[-- Attachment #2: symtab.patch --]
[-- Type: text/x-diff, Size: 2071 bytes --]
2006-01-03 Fred Fish <fnf@specifix.com>
* 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);
next reply other threads:[~2006-01-03 17:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-03 17:42 Fred Fish [this message]
2006-01-03 23:26 ` Jim Blandy
2006-01-04 20:57 ` Fred Fish
2006-01-05 22:08 ` Jim Blandy
2006-01-06 16:26 ` [commit] " Fred Fish
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200601031242.38425.fnf@specifix.com \
--to=fnf@specifix.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox