This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC/Patch] Call overloaded operators to perform valid Python operations on struct/class values.
- From: Doug Evans <xdje42 at gmail dot com>
- To: Siva Chandra <sivachandra at google dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Thu, 19 Dec 2013 06:11:09 -0800
- Subject: Re: [RFC/Patch] Call overloaded operators to perform valid Python operations on struct/class values.
- Authentication-results: sourceware.org; auth=none
- References: <CAGyQ6gxk9zcLKQ1Ef2XhgUMCyB8MB1v=6tA4jsfPyEFgxR8bNw at mail dot gmail dot com> <m31u1q1oq0 dot fsf at sspiff dot org> <871u1j2ldi dot fsf at fleche dot redhat dot com> <CAP9bCMSPpz8px2ZFvRroHcNP8PWWQV39P7GmXCmj+fdSR7NT2Q at mail dot gmail dot com> <CAGyQ6gzYE_NthBxc17VPxjgtYSqTW3HGhPVp8qvk=Nye27G8hg at mail dot gmail dot com> <CAP9bCMTthY1oJN-res0Cegd_YrMqW77ZehMjnzK+Y9681Of5bQ at mail dot gmail dot com> <CAGyQ6gy9E3J8mbG0xKTTwH8=MYG2naeBhMtwmNb5f=m9Xsmufg at mail dot gmail dot com>
On Wed, Dec 18, 2013 at 3:15 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Wed, Dec 18, 2013 at 8:37 AM, Doug Evans <xdje42@gmail.com> wrote:
>> Not that this could work, but for illustration's sake:
>> smart_ptr = gdb.parse_and_eval ("my_smart_ptr");
>> dereferenced_smart_ptr = gdb.parse_and_eval("*%V" % smart_ptr)
>
> Should work. May be the '%' syntax would not (I am not sure). But, we
> could consider other alternatives [Replace occurrences of $1, $2, etc
> for example].
>
> Is this an exhaustive solution or a cool fallback option when no other
> Pythonic way works
Both?
[Not sure I understand the question.]
> [Side topic: Should smart_ptr.dereference() invoke 'operator*'? The
> documentation says this: "... behavior of Value.dereference is
> identical to applying the C unary operator * on a given value." And, I
> remember writing this myself :-)]
Dunno.