From patchwork Mon Mar 28 21:33:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Breazeal X-Patchwork-Id: 11543 Received: (qmail 108497 invoked by alias); 28 Mar 2016 21:34:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 108475 invoked by uid 89); 28 Mar 2016 21:34:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=eclipse, Eclipse, scenario, motion X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 28 Mar 2016 21:34:29 +0000 Received: from svr-orw-fem-06.mgc.mentorg.com ([147.34.97.120]) by relay1.mentorg.com with esmtp id 1akenr-0005nn-DZ from Don_Breazeal@mentor.com ; Mon, 28 Mar 2016 14:34:27 -0700 Received: from build4-lucid-cs (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.3.224.2; Mon, 28 Mar 2016 14:34:27 -0700 Received: by build4-lucid-cs (Postfix, from userid 1905) id D908C41294; Mon, 28 Mar 2016 14:34:26 -0700 (PDT) From: Don Breazeal To: , , Subject: [PATCH v2 2/2] Optzd-out ptr: Eliminate -var-create error Date: Mon, 28 Mar 2016 14:33:40 -0700 Message-ID: <1459200820-24735-3-git-send-email-donb@codesourcery.com> In-Reply-To: <1459200820-24735-1-git-send-email-donb@codesourcery.com> References: <56CEF1F5.7060307@redhat.com> <1459200820-24735-1-git-send-email-donb@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This version of the patch is unchanged from the previous version, except that the description has been revised to be more concise and the ChangeLog has been updated to note the formatting change made by the patch. Luis reviewed this patch, but it still needs to be OK'd by a maintainer. thanks --Don ---- This patch eliminates an error thrown when accessing the value of a pointer to a structure where the pointer has been optimized out and 'set print object' is 'on'. The error shows up as the rather ugly value of the pointer variable in Eclipse. If 'set print object' is 'on', GDB tries to determine the actual (derived) type of the object rather than the declared type, which requires dereferencing the pointer, which in this cases throws an error because the pointer has been optimized out. The fix is to simply ignore the 'print object on' setting for pointers or references to structures when they have been optimized out. This means we just get the declared type instead of the actual type, because in this case that's the best that we can do. I'm working on setting things in motion for a patch to Eclipse that recognizes optimized-out pointer-to-struct in this scenario and prevents any subsequent attempt to dereference it from that end. Tested on bare-metal powerpc board with Linux x86 host. OK? thanks --Don gdb/ChangeLog: 2016-03-28 Don Breazeal * gdb/value.c (value_actual_type): Ignore the 'print object on' setting if the object is a pointer to or reference to a structure. Fix a formatting issue. --- gdb/value.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 738b2b2..50e4f8a 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1203,9 +1203,10 @@ value_actual_type (struct value *value, int resolve_simple_types, /* If result's target type is TYPE_CODE_STRUCT, proceed to fetch its rtti type. */ if ((TYPE_CODE (result) == TYPE_CODE_PTR - || TYPE_CODE (result) == TYPE_CODE_REF) + || TYPE_CODE (result) == TYPE_CODE_REF) && TYPE_CODE (check_typedef (TYPE_TARGET_TYPE (result))) - == TYPE_CODE_STRUCT) + == TYPE_CODE_STRUCT + && !value_optimized_out (value)) { struct type *real_type;