From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124064 invoked by alias); 21 Feb 2020 14:48:58 -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 123985 invoked by uid 89); 21 Feb 2020 14:48:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=Git, H*r:142, H*r:sk:gdb@sou, 2331 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Feb 2020 14:48:50 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j59bj-000818-6Z for gdb@sourceware.org; Fri, 21 Feb 2020 09:48:47 -0500 Received: from pool-98-118-0-140.bstnma.fios.verizon.net ([98.118.0.140]:39472 helo=homebase.home) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1j59bi-0000gJ-UG for gdb@sourceware.org; Fri, 21 Feb 2020 09:48:47 -0500 Message-ID: Subject: Types prefixed by "class" or "struct" string?? From: Paul Smith Reply-To: psmith@gnu.org To: gdb@sourceware.org Date: Fri, 21 Feb 2020 14:48:00 -0000 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00055.txt.bz2 Something very odd is going on. I'm using GCC 8.1 and GDB 8.2.1 with Python support (GNU/Linux on x86_64), and I've been using them for quite a while (I've built them myself and put them into a Git repository, along with binutils 2.33.1 and a sysroot). I can't say for sure that this is different or has always happened but certainly I just started noticing it recently and I can't think of anything that's changed in my environment. What's happening is that when the GDB Python interface retrieves a type as a string the name of the type is prefixed by "class " (if it's a class) or "struct " if it's a struct. So for example if I try to print a std::list variable, I'm getting these exceptions from GDB: (gdb) p $o->pending $28 = empty std::__cxx11::listTraceback (most recent call last): File "/cc/python/libstdcxx/v6/printers.py", line 243, in children nodetype = find_type(self.val.type, '_Node') File "/cc/python/libstdcxx/v6/printers.py", line 99, in find_type raise ValueError("Cannot find type %s::%s" % (str(orig), name)) ValueError: Cannot find type class std::__cxx11::list >::_Node Look carefully at the message and you'll see that the value of self.val.type is not just the type, but the type prefixed by "class ". If I try to look up a type without the "class " prefix it works fine: (gdb) python >t = gdb.lookup_type('std::__cxx11::list >::_Node') >print str(t) >^D std::__cxx11::list >::_Node But, if I try to look up the type including the "class " it definitely fails: (gdb) python >t = gdb.lookup_type('class std::__cxx11::list >::_Node') >^D Traceback (most recent call last): File "", line 1, in gdb.error: No type named class std::__cxx11::list >::_Node. Error while executing Python code. Does anyone know what might be causing this or how to avoid it? For my own python macros I can strip out the prefix before I look up types, but obviously I can't do that for the stdcxx printer macros that come with GCC. And I don't remember needing to do that before. I'm very confused...