From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1918 invoked by alias); 14 Dec 2006 04:58:01 -0000 Received: (qmail 1909 invoked by uid 22791); 14 Dec 2006 04:57:59 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 14 Dec 2006 04:57:53 +0000 Received: from kahikatea.snap.net.nz (p202-124-120-95.snap.net.nz [202.124.120.95]) by viper.snap.net.nz (Postfix) with ESMTP id 387C93D82EE for ; Thu, 14 Dec 2006 17:59:10 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 500) id 22840BE38A; Thu, 14 Dec 2006 17:53:22 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17792.55489.274138.854508@kahikatea.snap.net.nz> Date: Thu, 14 Dec 2006 04:58:00 -0000 To: gdb-patches@sources.redhat.com Subject: [PATCH] Fix variable objects for references to pointers X-Mailer: VM 7.19 under Emacs 22.0.91.17 X-IsSubscribed: yes 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 X-SW-Source: 2006-12/txt/msg00187.txt.bz2 This is a RFA for the patch below to fix variable objects for references to pointers as previously discussed. I've moved the changes into get_type_deref, as suggested by Vladimir, so that they appear in one rather than four places. Currently get_type_deref dereferences once for a reference or a pointer. All this patch does is dereference twice in the case of a references to a pointer. -- Nick http://www.inet.net.nz/~nickrob 2006-12-14 Nick Roberts * varobj.c (get_type_deref): Fix variable objects for references to pointers. *** varobj.c 09 Dec 2006 10:59:12 +1300 1.65 --- varobj.c 14 Dec 2006 17:51:46 +1300 *************** get_type (struct varobj *var) *** 1535,1541 **** return type; } ! /* This returns the type of the variable, dereferencing pointers, too. */ static struct type * get_type_deref (struct varobj *var) { --- 1535,1542 ---- return type; } ! /* This returns the type of the variable, dereferencing references, pointers ! and references to pointers, too. */ static struct type * get_type_deref (struct varobj *var) { *************** get_type_deref (struct varobj *var) *** 1543,1551 **** type = get_type (var); ! if (type != NULL && (TYPE_CODE (type) == TYPE_CODE_PTR ! || TYPE_CODE (type) == TYPE_CODE_REF)) ! type = get_target_type (type); return type; } --- 1544,1556 ---- type = get_type (var); ! if (type) ! { ! if (TYPE_CODE (type) == TYPE_CODE_REF) ! type = get_target_type (type); ! if (TYPE_CODE (type) == TYPE_CODE_PTR) ! type = get_target_type (type); ! } return type; } *************** c_number_of_children (struct varobj *var *** 1848,1856 **** break; case TYPE_CODE_PTR: ! /* This is where things get compilcated. All pointers have one child. Except, of course, for struct and union ptr, which we automagically ! dereference for the user and function ptrs, which have no children. We also don't dereference void* as we don't know what to show. We can show char* so we allow it to be dereferenced. If you decide to test for it, please mind that a little magic is necessary to --- 1853,1861 ---- break; case TYPE_CODE_PTR: ! /* This is where things get complicated. All pointers have one child. Except, of course, for struct and union ptr, which we automagically ! dereference for the user, and function ptrs, which have no children. We also don't dereference void* as we don't know what to show. We can show char* so we allow it to be dereferenced. If you decide to test for it, please mind that a little magic is necessary to