Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Alexander Smundak <asmundak@google.com>
Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Add Frame.read_register to Python API
Date: Wed, 11 Jun 2014 19:11:00 -0000	[thread overview]
Message-ID: <87ioo7uuqm.fsf@fleche.redhat.com> (raw)
In-Reply-To: <CAHQ51u4ugn--HzUS0r8sMyv14LcasL5vY_EUdOyJ1wXaX+WLpw@mail.gmail.com>	(Alexander Smundak's message of "Mon, 9 Jun 2014 14:16:20 -0700")

>>>>> "Alexander" == Alexander Smundak <asmundak@google.com> writes:

Thanks for your patch.

There's a few nits but nothing very serious.

Alexander> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
Alexander> index 4688783..14564eb 100644
Alexander> --- a/gdb/doc/python.texi
Alexander> +++ b/gdb/doc/python.texi
Alexander> @@ -2046,9 +2046,10 @@ class InlinedFrameDecorator(FrameDecorator):
 
Alexander>      def __init__(self, fobj):
Alexander>          super(InlinedFrameDecorator, self).__init__(fobj)
Alexander> +        self.fobj = fobj
 
Alexander>      def function(self):
Alexander> -        frame = fobj.inferior_frame()
Alexander> +        frame = self.fobj.inferior_frame()
Alexander>          name = str(frame.name())

I think this is a nice fix but it seems unrelated to the patch at hand.

Alexander>  @defun Frame.find_sal ()
Alexander> -Return the frame's symtab and line object.
Alexander> +Return the frame's @code{gdb.Symtab_and_line} object.

Likewise.

Alexander> +/* Implementation of gdb.Frame.read_register (self, register) -> gdb.Value.
Alexander> +   Returns the value of a register in this frame.  */
Alexander> +static PyObject *
Alexander> +frapy_read_register (PyObject *self, PyObject *args)
Alexander> +{

The gdb style requests a blank line between the intro comment and the
function.

Alexander> +  struct frame_info *frame;
Alexander> +  volatile struct gdb_exception except;
Alexander> +  int regnum = -1;
Alexander> +  struct value *val = NULL;
Alexander> +  TRY_CATCH (except, RETURN_MASK_ALL)
Alexander> +    {

... and also a blank line between variable declarations and code
(wherever this occurs -- there's a case in the patch in a nested block).

Alexander> +      FRAPY_REQUIRE_VALID (self, frame);
Alexander> +      if (!PyArg_ParseTuple (args, "i", &regnum))
Alexander> +	{
Alexander> +	  const char *regnum_str;
Alexander> +	  PyErr_Clear();  /* Clear PyArg_ParseTuple failure above.  */
Alexander> +	  if (PyArg_ParseTuple (args, "s", &regnum_str))
Alexander> +	    {
Alexander> +	      regnum = user_reg_map_name_to_regnum (get_frame_arch (frame),
Alexander> +						    regnum_str,
Alexander> +						    strlen (regnum_str));
Alexander> +	    }
Alexander> +	}

I tend to think this would be clearer if the arguments were only parsed
once and then explicit type checks were applied to the resulting object.

Alexander> +  return val ? value_to_value_object (val) : NULL;

gdb style requests an explicit NULL check, like "return val != NULL ? ...".

Alexander> +# On x86-64, PC is register 16.
Alexander> +gdb_test "python print ('result = %s' % ((f0.architecture().name() != 'i386:x86-64') or f0.read_register('pc') == f0.read_register(16)))" \
Alexander> +  "True" \
Alexander> +  "test Frame.read_register(regnum)"

A test that is arch-specific needs to be conditionalized somehow.

Tom


  reply	other threads:[~2014-06-11 19:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-09 19:15 Alexander Smundak
2014-06-09 19:26 ` Eli Zaretskii
2014-06-09 21:16   ` Alexander Smundak
2014-06-11 19:11     ` Tom Tromey [this message]
2014-06-11 23:52       ` Alexander Smundak
2014-06-18 17:18         ` Alexander Smundak
2014-06-18 17:33           ` Eli Zaretskii
2014-06-23 22:46           ` Alexander Smundak
2014-06-30 16:22             ` Alexander Smundak
2014-07-07 20:59               ` Alexander Smundak
2014-07-14 16:24                 ` Alexander Smundak
2014-07-24 17:45                   ` Doug Evans
2014-07-31 18:53                     ` Doug Evans
2014-07-31 20:05                       ` Tom Tromey
2014-08-21 18:44         ` Doug Evans
2014-08-26 20:31           ` Alexander Smundak
2014-08-29 13:39             ` Doug Evans
2014-08-29 23:32               ` Sasha Smundak
2014-08-29 23:36                 ` Doug Evans
2014-09-03 23:46                   ` Doug Evans

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=87ioo7uuqm.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=asmundak@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /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