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]

Re: [PATCH 09/11] Delete varobj's children on traceframe is changed.


On 11/23/2013 06:09 PM, Yao Qi wrote:
In this patch, we install a traceframe_changed observer to clear
varobjs marked as 'available_children_only'.


Once again, only some minor comments.

Keith

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.  */

This comment doesn't really make sense here. Best to just get rid of it.
[cut-n-paste-o?]

+      varobj_iter_delete (var->dynamic->child_iter);
+      var->dynamic->child_iter = NULL;
+      varobj_clear_saved_item (var->dynamic);
+    }
+}
+

The above code looks like it is duplicated in varobj_set_available_children_only. That suggests that a common function could be introduced to do this.

+/* Installed on traceframe_changed observer.  */

"The callback installed for traceframe_changed events."

+
+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



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