From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id B957E3858C27 for ; Sun, 8 May 2022 14:37:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B957E3858C27 Received: by mail-wr1-x434.google.com with SMTP id e24so16204989wrc.9 for ; Sun, 08 May 2022 07:37:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sPHuNvcuAtC454dIIof77ptapZi9dGZ8L0dAJE6f0U0=; b=YethoDI5PF5TW4zK8BFbJ0UAQ+DEQLLZ0ccg1DA/7lxU0x4g70kFckwT/E0+ZOMM6e HDcgXR0rZ9evgvOySTci0d05NbgMWfQCKO9L2SrAdzSY4M64n/r+ozk7niKVN1cInULg 31S64qgdJvLjIp57EJlgUVDfH2VaZuwp6ye58YiN315ue1t5CdfLXoHAAvIb4gEMdINl 2yoALhUBMhv/QhdR5awl22qZxFE+6/swraxM/GMrYDXGGwBlhxKcRARUnJCmu61tJc3Z WjF83Qa6eekql2IWiSJjYT2Y2t7veNt9aEVWBK81mLF3X93ui44P25kWeaYurzpsnKRL 0sxQ== X-Gm-Message-State: AOAM530A6uorypnt/aV67LGkvuIEwHONTiesMprqWj63dbsSNbP2qnOY E1nnt/mjaB0UmVOiwDruPowfYASM/YyvEPPzwq8= X-Google-Smtp-Source: ABdhPJxf841Kka00YibeRUebXqGkALOc+8Gi9NGHXqknfm2Y0EiRDF16m2c5zAdSnwFuH1Wrp0qhsJn+IYOu91/Eq1k= X-Received: by 2002:a05:6000:1889:b0:20c:617a:b087 with SMTP id a9-20020a056000188900b0020c617ab087mr10312261wri.102.1652020630730; Sun, 08 May 2022 07:37:10 -0700 (PDT) MIME-Version: 1.0 References: <5568db74d0acb198a3e8121ee75e3cfa02ea0c6f.camel@mad-scientist.net> <453082091.802975.1651922375216@mail.yahoo.com> <222e7c9b9ac74aa886c1501792e677a0dfa1f268.camel@mad-scientist.net> <27202f68e59e9a17aaa96d39659ce73005325cd7.camel@mad-scientist.net> <798b5f59f29de856858d0db2104ff21f626e42a0.camel@mad-scientist.net> In-Reply-To: <798b5f59f29de856858d0db2104ff21f626e42a0.camel@mad-scientist.net> From: Jonathan Wakely Date: Sun, 8 May 2022 15:36:59 +0100 Message-ID: Subject: Re: Help using the GDB C++ STL pretty-printers / xmethods To: Paul Smith Cc: gcc-help Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 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:37:16 -0000 On Sun, 8 May 2022 at 15:09, Paul Smith wrote: > > 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(). > > > > > > gdb.set_convenience_variable('mgr', val['mgr']) > > > init = gdb.parse_and_eval('$mgr->initialized') > > > > > > This will use the xmethod to evaluate the expression. > > > > And then: > > > > if init: > > 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. Then you are the perfect person to scratch this itch :-) > > And, I understand the answer "patches welcome" :). I'm just putting > this out there for people to consider.