This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Clear per-objfile data upon rereading a symbol file


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,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]