From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89005 invoked by alias); 13 Jul 2018 20:19:16 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 88989 invoked by uid 89); 13 Jul 2018 20:19:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=solved, 9057, HContent-Transfer-Encoding:8bit X-HELO: mailout01.webmailer.hosteurope.de Received: from mailout01.webmailer.hosteurope.de (HELO mailout01.webmailer.hosteurope.de) (80.237.138.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jul 2018 20:19:13 +0000 Received: from server03.webmailer.hosteurope.de ([10.9.0.182])AUTHED by mailout.webmailer.hosteurope.de (mailout01.webmailer.hosteurope.de) running EXperimental Internet Mailer with esmtps (TLSv1:AES256-SHA:256) id 1fe4X1-0004Qj-Ps for gdb@sourceware.org; Fri, 13 Jul 2018 22:19:11 +0200 Received: from nobody by server03.webmailer.hosteurope.de with local (Exim 4.72) (envelope-from ) id 1fe4X1-0002Bd-NS for gdb@sourceware.org; Fri, 13 Jul 2018 22:19:11 +0200 X-Squirrel-UserHash: EhVcX1dJRwNeRwQRAQsKVxc= X-Squirrel-FromHash: XAdeV10STVc= Message-ID: <8d8b95e9218d09f8d808936b4a9f163e-EhVcX1dJRwNeRwQRAQsKVxcwfgFLV15YQUBGAEFbWkA3VF0NQVpwH1FRQ15bQyoDWllYRVlWWQ1e-webmailer1@server03.webmailer.hosteurope.de> Date: Fri, 13 Jul 2018 20:19:00 -0000 Subject: MI: -var-create does not resolve typedefs From: "Martin Richtarsky" To: gdb@sourceware.org User-Agent: Host Europe Webmailer/1.0 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Status: not scanned, license restriction X-KLMS-AntiPhishing: not scanned, license restriction X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.721, bases: 2018/07/13 13:08:00 #8555885; khse: 2015-01-01 01:01:01 X-KLMS-AntiVirus-Status: Clean, skipped X-HE-Access: Yes X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00030.txt.bz2 Hi, the result of the -var-create command is documented here [1] as follows: ‘type’ The varobj’s type. This is a string representation of the type, as would be printed by the GDB CLI. However, for a typedef this does not seem to hold: $ cat mi.cpp #include #include typedef std::vector StringVec; typedef int MyInt; int main() { size_t a = 0; StringVec sv; MyInt i; return 0; } $ g++ -g2 mi.cpp $ gdb --interpreter=mi a.out ... 1-var-create - * "a" 1^done,name="var1",numchild="0",value="4195792",type="size_t",thread-id="1",has_more="0" (gdb) 2-var-create - * "sv" 2^done,name="var2",numchild="1",value="{...}",type="StringVec",thread-id="1",has_more="0" (gdb) ptype(a) &"ptype(a)\n" ~"type = unsigned long\n" ^done (gdb) ptype(sv) &"ptype(sv)\n" ~"type = class std::vector, std::allocator >, std::allocator, std::allocator > > > [with _Tp = std::basic_string, std::allocator >, _Alloc = std::allocator, std::allocator > >] : protected std::_Vector_base<_Tp, _Alloc> {\n" ~" public:\n" Note how ptype resolves the typedef, but -var-create just shows the alias. The issue can be solved by a simple patch: --- a/gdb/varobj-orig.c +++ b/gdb/varobj.c @@ -905,7 +905,7 @@ varobj_get_type (struct varobj *var) if (CPLUS_FAKE_CHILD (var) || !var->root->is_valid) return std::string (); - return type_to_string (var->type); + return type_to_string (check_typedef(var->type)); } /* Obtain the type of an object variable. */ This would also solve the issue I'm having when using MI with a split dwarf build and a gold index [2] Is this a bug or is the typedef intentionally not resolved? [1] https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html [2] https://sourceware.org/bugzilla/show_bug.cgi?id=23042 Best regards, Martin -- http://www.productive-cpp.com/