This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] varobj deletion after the binary has changed
- From: Denis PILAT <denis dot pilat at st dot com>
- To: gdb-patches <gdb-patches at sourceware dot org>
- Date: Tue, 23 Jan 2007 13:32:22 +0100
- Subject: [RFC] varobj deletion after the binary has changed
Hi,
We have a bug in one of our gdb target, when the binary changed while
beeing debugged it appears that some of our varobj refers to invalid
symbols or type.
I propose a patch that delete all varobj when symbols are reloaded. May
be there is a better place to do that but I think we must do that
somewhere, don't you ?
Daniel: There is no regression in the testsuite on linux native target
with this patch :)
--
Denis Pilat
STMicroelectronics
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.180
diff -u -p -r1.180 symfile.c
--- symfile.c 21 Jan 2007 01:02:03 -0000 1.180
+++ symfile.c 23 Jan 2007 10:00:36 -0000
@@ -52,6 +52,7 @@
#include "observer.h"
#include "exec.h"
#include "parser-defs.h"
+#include "varobj.h"
#include <sys/types.h>
#include <fcntl.h>
@@ -2602,6 +2603,10 @@ clear_symtab_users (void)
between expressions and which ought to be reset each time. */
expression_context_block = NULL;
innermost_block = NULL;
+
+ /* Varobj may refer to symbols, delete all of them. */
+ varobj_delete_all ();
+
}
static void
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.79
diff -u -p -r1.79 varobj.c
--- varobj.c 16 Jan 2007 02:12:49 -0000 1.79
+++ varobj.c 23 Jan 2007 10:00:46 -0000
@@ -2545,3 +2545,23 @@ When non-zero, varobj debugging is enabl
show_varobjdebug,
&setlist, &showlist);
}
+
+int
+varobj_delete_all (void)
+{
+ struct varobj **allvarobj;
+ struct varobj **var;
+ int nv;
+ nv = varobj_list (&allvarobj);
+ if (nv > 0)
+ {
+ var = allvarobj;
+ while (*var != NULL)
+ {
+ varobj_delete (*var, NULL, 0);
+ var++;
+ }
+ xfree (allvarobj);
+ }
+ return nv;
+}
Index: varobj.h
===================================================================
RCS file: /cvs/src/src/gdb/varobj.h,v
retrieving revision 1.7
diff -u -p -r1.7 varobj.h
--- varobj.h 9 Jan 2007 17:58:59 -0000 1.7
+++ varobj.h 23 Jan 2007 10:00:46 -0000
@@ -99,4 +99,6 @@ extern int varobj_list (struct varobj **
extern int varobj_update (struct varobj **varp, struct varobj ***changelist);
+extern int varobj_delete_all (void);
+
#endif /* VAROBJ_H */