public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Phil Muldoon <pmuldoon@redhat.com>
Cc: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [patch] Allow gdb.Values to become callable if appropriate.
Date: Tue, 20 Jul 2010 22:17:00 -0000	[thread overview]
Message-ID: <m31vaxajct.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4C442BAA.2020300@redhat.com> (Phil Muldoon's message of "Mon, 19	Jul 2010 11:40:42 +0100")

>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> Here is a little patch that allows gdb.Values to become "callable".
Phil> In this patch, I have limited the ability to call only values where
Phil> the type == TYPE_CODE_FUNC.  It is the responsibility of the user to
Phil> cast or dereference appropriately before attempting a call.  If the
Phil> type does not resolve to TYPE_CODE_FUNC, then the call will be
Phil> abandoned.  There's not too much checking I can do in the function
Phil> beyond what call_function_by_hand already does.  If any errors occur
Phil> in the conversion of the arguments, the call will be abandoned.

Phil> Comments?

Looks good.

Phil> +A @code{gdb.Value} that represents a function or a function pointer is a
Phil> +callable Python object.

From what I can see, your patch explicitly excludes function pointers.

This may be a bit too strict.  I think it would be reasonably safe and
easy to accept references (via coerce_ref) and also function pointers
(doing a single dereference inside the new function).

Alternatively, update the documentation.

Phil> +  args_count = PyTuple_Size (args);
Phil> +  if (args_count > 0)
Phil> +    {
Phil> +      int i;
Phil> +      
Phil> +      vargs =  alloca (sizeof (struct value *) * args_count);

Extra space after the "=".

Phil> -  0,				  /*tp_call*/
Phil> +  (ternaryfunc) valpy_call,	  /*tp_call*/

I don't think this cast is necessary.

Tom

  reply	other threads:[~2010-07-20 22:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-19 10:40 Phil Muldoon
2010-07-20 22:17 ` Tom Tromey [this message]
2010-07-26  9:17   ` Phil Muldoon
2010-07-26 17:07     ` Eli Zaretskii
2010-07-27 13:16       ` Phil Muldoon
2010-07-27 18:24         ` Tom Tromey
2010-07-28  9:47           ` Phil Muldoon
2010-07-30 21:39             ` Tom Tromey
2010-07-31  7:08               ` Eli Zaretskii
2010-08-03  9:55                 ` Phil Muldoon

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=m31vaxajct.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).