From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 46F5C38515F6 for ; Mon, 9 May 2022 09:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46F5C38515F6 Received: by mail-wr1-x42a.google.com with SMTP id t6so18567567wra.4 for ; Mon, 09 May 2022 02:32:29 -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=0GWgMLb8LmZf02hxs7ERg+2yjUowa+RZzmw+23Dt1hI=; b=aKhLsMGXt8Cv0Ah3fK6k0Ul5KkuD+q9ZIDHE4tA2+a7liA1dqVVXPraZHN3LgSH10r ZRt7YohogM3a+RrpN8ldWpe9LITP+zmtA0FZhY2o+Kh3g66+19J4raCU8NGWMMDMq1Jp N5ow2K4DIN27ABTqQys2XjG3HXhiZJxxN3DaaeInh71qG265EDYitn5CWe8auZtWJafJ Ein9CztlruN+vePcFzUr0epEi0kEFkHyFQgBrB4QJ9LEF5/SYi85qXHCL26uWL5byt7z k6ik3KJbFpUCORPYpdBtJdD8/9muF+dx8zCVPpg9mHT4wj8zeVKECv4j3RPKZxkBG0Nt EZYw== X-Gm-Message-State: AOAM530ugY/+zglgcUItMk6e2r5QB2F2NqvlnoUYiYjV/wNV9hu3TBDW w7zjXJpac1xEsgMmocYBU85W44X1V7uZlXCgV7aezzxgn/A= X-Google-Smtp-Source: ABdhPJx4UYyhvy9ek4Fqi5X5TedkdTTS+HMiJUuaKlhG4uPwwlhz7ehPVvvfMfRttiXbdxVRjckLchzPI14df1ivgWY= X-Received: by 2002:adf:dc91:0:b0:20c:cb51:4160 with SMTP id r17-20020adfdc91000000b0020ccb514160mr2184518wrj.568.1652088748127; Mon, 09 May 2022 02:32:28 -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> <7c6d308fdbbcabf83dd5423c33ca851666beaae7.camel@mad-scientist.net> In-Reply-To: <7c6d308fdbbcabf83dd5423c33ca851666beaae7.camel@mad-scientist.net> From: Jonathan Wakely Date: Mon, 9 May 2022 10:32:17 +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=-1.0 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: Mon, 09 May 2022 09:32:30 -0000 On Sun, 8 May 2022 at 20:44, Paul Smith wrote: > > On Sun, 2022-05-08 at 09:16 +0100, Jonathan Wakely wrote: > > > 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') > > Unfortunately, this doesn't work :(. I can't do it from the GDB > command line or python (I have tried both with the same results). > Something about convenience variables doesn't play well with xmethods > (or maybe this xmethod implementation specifically?) You're right, sorry. It doesn't work for me with a convenience variable. But since what you want is something that works in arbitrary Python code, not just within GDB, doesn't pybind11 already do everything you want? https://github.com/pybind/pybind11