Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Clear per-objfile data upon rereading a symbol file
@ 2003-10-26 21:12 Mark Kettenis
  2003-10-27 16:14 ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2003-10-26 21:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Peter.Schauer

Peter Schrauer pointed out to me that upon re-reading a symbolf file,
we don't clear the per-objfile data pointers, whereas we clear almost
everything else in the symbol file related `struct objfile'.  This
currently leaves us with dangling pointers into freed obstacks.  The
attached patch fixes this.

I'll check this in on both branches in a few days unless somebody
objects, since this fixes a bug where GDB crashes.  We can't have that
:-(.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* objfiles.h (clear_objfile_data): New prototype.
	* objfiles.c (clear_objfile_data): New function.
	* symfile.c (reread_symbols): Clear per-objfile data.

Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.109
diff -u -p -r1.109 symfile.c
--- symfile.c 21 Sep 2003 01:26:45 -0000 1.109
+++ symfile.c 26 Oct 2003 21:05:52 -0000
@@ -1969,6 +1969,7 @@ reread_symbols (void)
 	      memset (&objfile->msymbol_demangled_hash, 0,
 		      sizeof (objfile->msymbol_demangled_hash));
 	      objfile->fundamental_types = NULL;
+	      clear_objfile_data (objfile);
 	      if (objfile->sf != NULL)
 		{
 		  (*objfile->sf->sym_finish) (objfile);
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.38
diff -u -p -r1.38 objfiles.c
--- objfiles.c 20 Oct 2003 14:38:42 -0000 1.38
+++ objfiles.c 26 Oct 2003 21:05:55 -0000
@@ -1166,6 +1166,13 @@ objfile_free_data (struct objfile *objfi
 }
 
 void
+clear_objfile_data (struct objfile *objfile)
+{
+  gdb_assert (objfile->data != NULL);
+  memset (objfile->data, 0, objfile->num_data * sizeof (void *));
+}
+
+void
 set_objfile_data (struct objfile *objfile, const struct objfile_data *data,
 		  void *value)
 {
Index: objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.26
diff -u -p -r1.26 objfiles.h
--- objfiles.h 14 Sep 2003 02:04:44 -0000 1.26
+++ objfiles.h 26 Oct 2003 21:06:00 -0000
@@ -599,6 +599,7 @@ extern int is_in_import_list (char *, st
    modules.  */
 
 extern const struct objfile_data *register_objfile_data (void);
+extern void clear_objfile_data (struct objfile *objfile);
 extern void set_objfile_data (struct objfile *objfile,
 			      const struct objfile_data *data, void *value);
 extern void *objfile_data (struct objfile *objfile,


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-29 18:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-26 21:12 [PATCH] Clear per-objfile data upon rereading a symbol file Mark Kettenis
2003-10-27 16:14 ` Andrew Cagney
2003-10-27 20:57   ` Mark Kettenis
2003-10-28 16:05     ` Elena Zannoni
2003-10-29 18:43       ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox