This is the mail archive of the gdb-patches@sourceware.org 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 09/11] Delete varobj's children on traceframe is changed.


Hi,
The memory availability varies on trace frames.  When
--available-children-only is used, the varobj tree structure changes
when trace frame is changed.  GDB has to remove varobj's children if
it is marked as 'available_children_only'.  For example, in traceframe
1, foo.a and foo.c is collected, and in traceframe 2, foo.b is
collected,

struct foo
{
  int a; /* Collected in traceframe 1 */
  int b; /* Collected in traceframe 2 */
  int c; /* Collected in traceframe 1 */
};

When available-children-only is used, the expected result is that in
traceframe 1, foo has two children (a and c), and foo has one child
(b) in traceframe 2.  Without this patch, foo has a, b, and c in
traceframe 2, which is wrong.

In this patch, we install a traceframe_changed observer to clear
varobjs marked as 'available_children_only'.

gdb:

2013-11-24  Yao Qi  <yao@codesourcery.com>

	* varobj.c: Include "observer.h".
	(varobj_delete_if_available_children_only): New function.
	(varobj_traceframe_changed): New function.
	(_initialize_varobj): Install varobj_traceframe_changed to
	traceframe_changed observer.
---
 gdb/varobj.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/gdb/varobj.c b/gdb/varobj.c
index ba93eb5..4b201df 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -24,6 +24,7 @@
 #include "gdbcmd.h"
 #include "block.h"
 #include "valprint.h"
+#include "observer.h"
 
 #include "gdb_assert.h"
 #include <string.h>
@@ -2749,6 +2750,32 @@ all_root_varobjs (void (*func) (struct varobj *var, void *data), void *data)
       (*func) (var_root->rootvar, data);
     }
 }
+
+/* Delete VAR's children if it is marked as 'available_children_only'.  */
+
+static void
+varobj_delete_if_available_children_only (struct varobj *var, void *data)
+{
+  if (var->dynamic->available_children_only)
+    {
+      varobj_delete (var, NULL, /* children only */ 1);
+      var->num_children = -1;
+
+      /* We're starting over, so get rid of any iterator.  */
+      varobj_iter_delete (var->dynamic->child_iter);
+      var->dynamic->child_iter = NULL;
+      varobj_clear_saved_item (var->dynamic);
+    }
+}
+
+/* Installed on traceframe_changed observer.  */
+
+static void
+varobj_traceframe_changed (int tfnum, int tpnum)
+{
+  all_root_varobjs (varobj_delete_if_available_children_only , NULL);
+}
+
 
 extern void _initialize_varobj (void);
 void
@@ -2766,6 +2793,8 @@ _initialize_varobj (void)
 			     _("When non-zero, varobj debugging is enabled."),
 			     NULL, show_varobjdebug,
 			     &setlist, &showlist);
+
+  observer_attach_traceframe_changed (varobj_traceframe_changed);
 }
 
 /* Invalidate varobj VAR if it is tied to locals and re-create it if it is
-- 
1.7.7.6


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