This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Add Frame.read_register to Python API
- From: Alexander Smundak <asmundak at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Mon, 7 Jul 2014 13:59:45 -0700
- Subject: Re: [PATCH] Add Frame.read_register to Python API
- Authentication-results: sourceware.org; auth=none
- References: <CAHQ51u4gJRVFXNnUykc6EmCCFGd4O3+LJmpjFGMZ9AeQSvQCuQ at mail dot gmail dot com> <83oay128ca dot fsf at gnu dot org> <CAHQ51u4ugn--HzUS0r8sMyv14LcasL5vY_EUdOyJ1wXaX+WLpw at mail dot gmail dot com> <87ioo7uuqm dot fsf at fleche dot redhat dot com> <CAHQ51u71A-sBCW_em68nHsFTXmHZCsYudKYtZm8MfC=rTGGAOg at mail dot gmail dot com> <CAHQ51u59HNGwF3VDGWoffRA5PmN5hReVo+-r_sx1ALfnQXCgvQ at mail dot gmail dot com> <CAHQ51u4Tib_v=-WoaE3KuHXtw-kMvB=hUkhNhDexVEwTUJDFEg at mail dot gmail dot com> <CAHQ51u7z_a70GgboK6MM1J3dVO_ajYJ4C5K1jw29_KAr=3kx1w at mail dot gmail dot com>
Ping.
On Mon, Jun 30, 2014 at 9:22 AM, Alexander Smundak <asmundak@google.com> wrote:
> Ping
>
> On Mon, Jun 23, 2014 at 3:46 PM, Alexander Smundak <asmundak@google.com> wrote:
>> Ping
>>
>> On Wed, Jun 18, 2014 at 10:18 AM, Alexander Smundak <asmundak@google.com> wrote:
>>> Ping.
>>>
>>> On Wed, Jun 11, 2014 at 4:52 PM, Alexander Smundak <asmundak@google.com> wrote:
>>>>> 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.
>>>>
>>>> Should I mail these two as a single patch or as two separate patches?
>>>>
>>>>> Alexander> + FRAPY_REQUIRE_VALID (self, frame);
>>>>> Alexander> + if (!PyArg_ParseTuple (args, "i", ®num))
>>>>> Alexander> + {
>>>>> Alexander> + const char *regnum_str;
>>>>> Alexander> + PyErr_Clear(); /* Clear PyArg_ParseTuple failure above. */
>>>>> Alexander> + if (PyArg_ParseTuple (args, "s", ®num_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.
>>>>
>>>> Did that, and then started doubting whether it is really necessary to read
>>>> a register by its (very arch-specific) number. The new version supports
>>>> reading the register by the name. Another change is that it now throws
>>>> an exception if the name is wrong.
>>>>
>>>>> 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.
>>>> IMHO it's borderline arch-specific -- it is runnable on any platform,
>>>> although it will not be testing much on any but x86-64. There hasn't
>>>> been any arch-specific tests for Python so far, so I am not sure what to do.
>>>>
>>>> Here's the new version (style violations have been addressed, too):
>>>>
>>>> The ability to read registers is needed to use Frame Filter API to
>>>> display the frames created by JIT compilers.
>>>>
>>>> gdb/Changelog
>>>> 2014-06-11 Sasha Smundak <asmundak@google.com>
>>>>
>>>> * python/py-frame.c (frapy_read_register): New function.
>>>>
>>>> 2014-06-11 Sasha Smundak <asmundak@google.com>
>>>>
>>>> * python.texi (Frames in Python): Add read_register description.
>>>>
>>>> 2014-06-11 Sasha Smundak <asmundak@google.com>
>>>>
>>>> * gdb.python/py-frame.exp: Test Frame.read_register.