From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6655 invoked by alias); 10 Oct 2012 20:05:05 -0000 Received: (qmail 6617 invoked by uid 22791); 10 Oct 2012 20:05:03 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Oct 2012 20:04:58 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1TM2WX-0005v7-ER from Luis_Gustavo@mentor.com for gdb-patches@sourceware.org; Wed, 10 Oct 2012 13:04:57 -0700 Received: from NA1-MAIL.mgc.mentorg.com ([147.34.98.181]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 10 Oct 2012 13:04:57 -0700 Received: from [0.0.0.0] ([172.16.63.104]) by NA1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 10 Oct 2012 13:04:56 -0700 Message-ID: <5075D4FD.9050900@mentor.com> Date: Wed, 10 Oct 2012 20:05:00 -0000 From: Luis Gustavo Reply-To: "Gustavo, Luis" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.28) Gecko/20120313 Lightning/1.0b2 Thunderbird/3.1.20 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] Fix mi "-var-create" regression Content-Type: multipart/mixed; boundary="------------010306080504070901060904" 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: 2012-10/txt/msg00163.txt.bz2 This is a multi-part message in MIME format. --------------010306080504070901060904 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1407 Hi, After the commit that fixed #13393 (http://sourceware.org/bugzilla/show_bug.cgi?id=13393), certain calls to -var-create with "set print object on" started failing with a dereferencing error, like so: (gdb) -var-create - * $sp ^error,msg="Attempt to dereference a generic pointer." (gdb) This happens because in value.c:value_actual_type we have this check: if (TYPE_CODE (result) == TYPE_CODE_PTR || TYPE_CODE (result) == TYPE_CODE_REF) { struct type *real_type; real_type = value_rtti_indirect_type (value, NULL, NULL, NULL); if (real_type) { if (real_type_found) *real_type_found = 1; result = real_type; } } If we reach this point with result being a pointer of reference, we execute the if block. This will eventually lead to a call to valops.c:get_value_at, where we throw an error in case the target type is void (pointers usually have such a target type) Anton does mention a particular problem with indirect pointers in #13393 comment #8, but it is not clear if a bug ticket has been filed for that. The following patch adds a check for target type void, and skips the problematic if block accordingly. This fixes the problem and does not seem to cause any regressions. With "set print object off", everything works as it should. Ok? --------------010306080504070901060904 Content-Type: text/x-patch; name="rtti-print-object.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rtti-print-object.diff" Content-length: 951 2012-10-10 Luis Machado * value.c (value_actual_type): Check for TYPE_CODE_VOID target types. Index: gdb/gdb/value.c =================================================================== --- gdb.orig/gdb/value.c 2012-10-10 16:38:21.872234906 -0300 +++ gdb/gdb/value.c 2012-10-10 16:42:49.560222099 -0300 @@ -850,8 +850,13 @@ value_actual_type (struct value *value, result = value_type (value); if (opts.objectprint) { - if (TYPE_CODE (result) == TYPE_CODE_PTR + /* If result's target type is TYPE_CODE_VOID, do not try fetching its rtti + type. GDB will try to dereference the void pointer and will throw an + error when trying to do so. */ + if ((TYPE_CODE (result) == TYPE_CODE_PTR || TYPE_CODE (result) == TYPE_CODE_REF) + && ((TYPE_TARGET_TYPE (result) != NULL) + && TYPE_CODE (TYPE_TARGET_TYPE (result)) != TYPE_CODE_VOID)) { struct type *real_type; --------------010306080504070901060904--