From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id A60AB3858C27 for ; Sun, 8 May 2022 14:09:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A60AB3858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mad-scientist.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mad-scientist.net Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id A372510048354 for ; Sun, 8 May 2022 14:09:58 +0000 (UTC) Received: from box5922.bluehost.com ([162.241.30.80]) by cmsmtp with ESMTP id nhbin0i5e53CXnhbingHns; Sun, 08 May 2022 14:09:58 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=OPfiYQWB c=1 sm=1 tr=0 ts=6277cf36 a=u+82WREdhvUKZ7QTvcqjvQ==:117 a=u+82WREdhvUKZ7QTvcqjvQ==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=oZkIemNP1mAA:10:nop_rcvd_month_year a=3EOfIcITIxQA:10:endurance_base64_authed_username_1 a=fheT2PAwyxn40HLWXG4A:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mad-scientist.us; s=default; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:Reply-To:From:Subject: Message-ID:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OwJuelVj9flYQoD0I7SHdz8kGk3WMNukInUQjPjHTIk=; b=N8ZW0UNtOCHPJOuwrNIZhg83t5 1AJ2iJhYr0NwK/YR15evjhMHhMcEIpo9Qco+nshO9poX8RyogbPDZBMxTZgh4jubO8n8Fujlrz2+A nIukACZJetT/A2xX6nC334Wu0; Received: from static-11-191-147-69.axsne.net ([69.147.191.11]:10402 helo=[10.200.55.35]) by box5922.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nnhbh-0014SB-NF; Sun, 08 May 2022 08:09:57 -0600 Message-ID: <798b5f59f29de856858d0db2104ff21f626e42a0.camel@mad-scientist.net> Subject: Re: Help using the GDB C++ STL pretty-printers / xmethods From: Paul Smith Reply-To: paul@mad-scientist.net To: Jonathan Wakely Cc: gcc-help Date: Sun, 08 May 2022 10:09:56 -0400 In-Reply-To: References: <5568db74d0acb198a3e8121ee75e3cfa02ea0c6f.camel@mad-scientist.net> <453082091.802975.1651922375216@mail.yahoo.com> <222e7c9b9ac74aa886c1501792e677a0dfa1f268.camel@mad-scientist.net> <27202f68e59e9a17aaa96d39659ce73005325cd7.camel@mad-scientist.net> Organization: Please remain calm--I may be mad but I am a professional! Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1 (by Flathub.org)) MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5922.bluehost.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mad-scientist.net X-BWhitelist: no X-Source-IP: 69.147.191.11 X-Source-L: No X-Exim-ID: 1nnhbh-0014SB-NF X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: static-11-191-147-69.axsne.net ([10.200.55.35]) [69.147.191.11]:10402 X-Source-Auth: paul@mad-scientist.us X-Email-Count: 1 X-Source-Cap: bWFkc2NpZTE7bWFkc2NpZTE7Ym94NTkyMi5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=2.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 May 2022 14:10:01 -0000 On Sun, 2022-05-08 at 09:16 +0100, Jonathan Wakely wrote: > > > xmethods don't help me (IIUC) because I'm in the middle of some > > > Python function and the value I want to retrieve is in a Python > > > variable, not in a GDB variable, so I can't easily access it with > > > parse_and_eval(). > >=20 > > gdb.set_convenience_variable('mgr', val['mgr']) > > init =3D gdb.parse_and_eval('$mgr->initialized') > >=20 > > This will use the xmethod to evaluate the expression. >=20 > And then: >=20 > if init: > =C2=A0 =C2=A0 return gdb.parse_and_eval('*$mgr') Yes... this is why I qualified my statement with "easily" :). Also if I'm doing this as I search through a 700,000 element container, which is already not super-speedy, the performance is likely not going to be great. I imagine the cleanest solution is to have a Python API for STL that works with and returns gdb.Values, then have the pretty-printers call that API and format the result. Then others can use that API as well. I get that the current suite of Python functions are geared specifically towards using STL objects directly from the GDB UI: both pretty-printing and accessing them. As someone who's writing my own Python functions for a complex C++ program, however, an API as above would be more helpful; we have lots of methods that grovel through complex structures looking for specific elements, etc. And, I understand the answer "patches welcome" :). I'm just putting this out there for people to consider.