public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 09/11] Delete varobj's children on traceframe is changed.
Date: Sun, 24 Nov 2013 02:12:00 -0000	[thread overview]
Message-ID: <1385258996-26047-10-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1385258996-26047-1-git-send-email-yao@codesourcery.com>

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);
+}
+
 \f
 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

  parent reply	other threads:[~2013-11-24  2:12 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-24  5:04 [RCF 00/11] Visit varobj available children only in MI Yao Qi
2013-11-24  2:12 ` [PATCH 08/11] Iterator varobj_items by their availability Yao Qi
2014-01-21 20:46   ` Keith Seitz
2013-11-24  2:12 ` [PATCH 01/11] Use 'struct varobj_item' to represent name and value pair Yao Qi
2014-01-21 20:43   ` Keith Seitz
2014-01-22  1:00     ` Doug Evans
2014-01-23  4:08       ` Yao Qi
2014-01-23 16:08         ` Doug Evans
2013-11-24  2:12 ` [PATCH 02/11] Generalize varobj iterator Yao Qi
2014-01-21 20:44   ` Keith Seitz
2014-01-22  1:07     ` Doug Evans
2013-11-24  2:12 ` [PATCH 06/11] Use varobj_is_dynamic_p more widely Yao Qi
2014-01-21 20:44   ` Keith Seitz
2013-11-24  2:12 ` [PATCH 11/11] Test case Yao Qi
2014-01-21 20:49   ` Keith Seitz
2013-11-24  2:12 ` [PATCH 05/11] Rename varobj_pretty_printed_p to varobj_is_dynamic_p Yao Qi
2014-01-21 20:44   ` Keith Seitz
2013-11-24  2:12 ` Yao Qi [this message]
2014-01-21 20:47   ` [PATCH 09/11] Delete varobj's children on traceframe is changed Keith Seitz
2013-11-24  2:12 ` [PATCH 04/11] Remove #if HAVE_PYTHON Yao Qi
2014-01-21 20:44   ` Keith Seitz
2013-11-24  2:12 ` [PATCH 03/11] Iterate over 'struct varobj_item' instead of PyObject Yao Qi
2014-01-21 20:44   ` Keith Seitz
2013-11-24  2:12 ` [PATCH 07/11] MI option --available-children-only Yao Qi
2014-01-21 20:45   ` Keith Seitz
2013-11-24  2:12 ` [PATCH 10/11] Match dynamic="1" in the output of -var-list-children Yao Qi
2014-01-21 20:47   ` Keith Seitz
2013-12-02  9:09 ` [RCF 00/11] Visit varobj available children only in MI Yao Qi
2013-12-17 12:54 ` Yao Qi
2014-01-07 18:22 ` Keith Seitz
2014-01-08 11:41   ` Joel Brobecker
2014-01-08 14:27   ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1385258996-26047-10-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).