From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22541 invoked by alias); 24 Nov 2013 02:12:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 22387 invoked by uid 89); 24 Nov 2013 02:12:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 24 Nov 2013 02:12:04 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VkPB4-0006qs-UT from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sat, 23 Nov 2013 18:12:02 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sat, 23 Nov 2013 18:12:02 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Sat, 23 Nov 2013 18:12:02 -0800 From: Yao Qi To: Subject: [PATCH 09/11] Delete varobj's children on traceframe is changed. Date: Sun, 24 Nov 2013 02:12:00 -0000 Message-ID: <1385258996-26047-10-git-send-email-yao@codesourcery.com> In-Reply-To: <1385258996-26047-1-git-send-email-yao@codesourcery.com> References: <1385258996-26047-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00731.txt.bz2 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 * 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 @@ -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