Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Siva Chandra <sivachandra@google.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb@sourceware.org
Subject: Re: Invoking methods on gdb.Value objects and other ideas
Date: Tue, 17 Dec 2013 00:55:00 -0000	[thread overview]
Message-ID: <CAGyQ6gyGWCN6y46CtwrvyDpQEX-g2pSvXBiP=j3mOwP9efG31g@mail.gmail.com> (raw)
In-Reply-To: <87bo0gpg4f.fsf@fleche.redhat.com>

Siva> 5. Method invocation via [] operator - One should be able to invoke
Siva> methods on a gdb.Value object like this:
Siva>   value_obj[method](arg1, arg2, ...)
Siva> METHOD can be a gdb.TypeMethod, or a gdb.ValueMethod object.

Siva> 6. Unresolved methods - Value and type objects should have Python
Siva> method "get_method".
Siva>   m = value_obj.get_method(method)
Siva> METHOD is a string value name of the method. M is a yet unresolved
Siva> method (due to overloading) but can used to invoke the method like in
Siva> 4 and 5 above. The method is resolved based on the args.

Tom> It seems to me that #5 and #6 are just two different ways to write the
Tom> same thing.  More or less.

Yes, more or less :-)
But, note that the method "get_method" takes a string arg, whereas the
operand to '[]' is _not_ a string.  It is a gdb.TypeMethod or
gdb.ValueMethod object.

Tom> Note that a danger of using strings and overloading [] is that in Java
Tom> (and maybe other languages, I don't know) a method and an ordinary field
Tom> can have the same name.  I think this would make the syntax ambiguous
Tom> there -- is value['name'] a reference to a field or to a bound method?

As I mentioned above, we do not use a string operand with '[]' to get methods.

Tom> Perhaps having just get_method is better for this reason.

But, do you think we should not have support for '[]' as described above?

Tom> The above seem to be found methods, but it seems that to be complete
Tom> you'd also want a way to create a C++ pointer-to-member.  I guess this
Tom> is more cleanly done via the Type API, or perhaps a method on your
Tom> proposed TypeMethod object.

I think you mean "bound" methods. I refrained from using that term as
they could be yet unresolved, and they are not gdb.TypeMethod or
gdb.ValueMethod objects. But, I do not have any real reason to not
call them bound methods.

About C++ pointer-to-member values, I think they are in a way methods
already, and hence could just be invoked by '(...)' method invocation?

Siva> 8. Debug method caching in the underlying "struct type" [3] - If a
Siva> particular debug matches for a type, then cache it in the type. Future
Siva> similar invocations need go through all debug methods for a match
Siva> (unless of course new debug methods are registered in the meanwhile).

Tom> I wasn't sure about this but I think the idea must be that the internals
Tom> cache the result of some other lookup; so that having multiple structs
Tom> representing the same type can't cause a problem.  So, it is a
Tom> performance optimization rather than an integral part of the lookup
Tom> machinery.

Siva> 9. Caching debug methods matches to disk - This is for a use case
Siva> wherein a GDB user does not write his own debug methods but ends up
Siva> implicitly using debug methods defined for a library not written by
Siva> him. For such cases, one could cache the debug method matches to disk
Siva> so that future GDB sessions save on debug method search.

Tom> I don't understand this one.

I think you should ignore #7, #8 and #9.  My mistake to have mixed
them up here with the discussion on method invocation.


  reply	other threads:[~2013-12-17  0:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13 17:46 Siva Chandra
2013-12-16 22:48 ` Tom Tromey
2013-12-17  0:55   ` Siva Chandra [this message]
2013-12-17 22:08     ` Siva Chandra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGyQ6gyGWCN6y46CtwrvyDpQEX-g2pSvXBiP=j3mOwP9efG31g@mail.gmail.com' \
    --to=sivachandra@google.com \
    --cc=gdb@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox