Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Siva Chandra <sivachandra@google.com>
Cc: gdb@sourceware.org
Subject: Re: Invoking methods on gdb.Value objects and other ideas
Date: Mon, 16 Dec 2013 22:48:00 -0000	[thread overview]
Message-ID: <87bo0gpg4f.fsf@fleche.redhat.com> (raw)
In-Reply-To: <CAGyQ6gxs7NCTSdMvBMxTthvVb1zQD-uYfU2OmLpVUcDEhwNYOA@mail.gmail.com>	(Siva Chandra's message of "Fri, 13 Dec 2013 09:46:16 -0800")

>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:

Siva> I am sharing some of my ideas on how we could facilitate invoking
Siva> source language methods (and debug methods) on gdb.Value objects.

Thanks.

Siva> 1. Bring in a class hierarchy of gdb types. That is, have a base class
Siva> gdb.Type from which other classes gdb.TypeStruct, gdb.TypeMethod etc
Siva> are derived.

Sounds good.  We probably should have done it from the start.

Siva> 2. Do the same with gdb.Value class. That is, have a base class
Siva> gdb.Value from which other classes gdb.ValueStruct, gdb.ValueMethod
Siva> etc. are derived. I am not very sure if this is really required, but I
Siva> can think of atleast one reason why this can be cleaner.

Likewise.

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.

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

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

Perhaps having just get_method is better for this reason.

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

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).

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

I don't understand this one.

Tom


  reply	other threads:[~2013-12-16 22:48 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 [this message]
2013-12-17  0:55   ` Siva Chandra
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=87bo0gpg4f.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=sivachandra@google.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