From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1365 invoked by alias); 21 Feb 2020 18:16:57 -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 1354 invoked by uid 89); 21 Feb 2020 18:16:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:BDB5F1E, H*MI:sk:BDB5F1E, H*f:sk:BDB5F1E, Pending 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 18:16:55 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j5Cr5-0004wY-Gq; Fri, 21 Feb 2020 13:16:51 -0500 Received: from [65.112.16.22] (port=57412 helo=pdslaptop) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1j5Cr5-0003Sq-7e; Fri, 21 Feb 2020 13:16:51 -0500 Message-ID: <846069b1bb0bffa7188666f75077df00fa77a930.camel@gnu.org> Subject: Re: Types prefixed by "class" or "struct" string?? From: Paul Smith Reply-To: psmith@gnu.org To: Paul Koning Cc: gdb@sourceware.org Date: Fri, 21 Feb 2020 18:16:00 -0000 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" 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/msg00057.txt.bz2 On Fri, 2020-02-21 at 09:55 -0500, Paul Koning wrote: > > But, if I try to look up the type including the "class " it > > definitely fails: > > Well, sure. "class" is not part of the name of the type. Heh. Well, clearly :). I think I didn't make something clear in my initial message: it's not *ME* that's providing the "class " prefix: GDB is doing that itself. That's the problem: it's adding this prefix to the names of types, then when it tries to look them up it fails. However I've discovered the culprit, although I still can't understand why I never saw this before / what could have changed. Basically, if you evaluate a gdb.Type in a string context GDB adds the "class" or "struct" prefix; I guess that's part of the __str__ representation for the gdb.Type class? Example: (gdb) python > o = gdb.convenience_variable('o') > print o['pending'].type > ^D class std::__cxx11::list > But if I use the .name attribute, then I don't get the prefix: (gdb) python > o = gdb.convenience_variable('o') > print o['pending'].type.name > ^D std::__cxx11::list > Unfortunately the Python macros that come with GCC's STL use the string conversion in the pretty-printer code; for example: def find_type(orig, name): typ = orig.strip_typedefs() while True: # Strip cv-qualifiers. PR 67440. search = '%s::%s' % (typ.unqualified(), name) If this used type.unqualified().name instead it would probably be OK. But, this kind of thing is done EVERYWHERE in the GCC pretty-printers so it can't possibly have always been this way or nothing would work!! I simply don't understand how I could have not run into such a fundamental issue before: as I said I've been using all these same versions, built locally and checked into Git, for well over a year now. Has GDB always provided this "class" / "struct" prefix in the __str__ representation of gdb.Type?