From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4245 invoked by alias); 18 Jun 2014 17:18:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 4227 invoked by uid 89); 18 Jun 2014 17:18:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-oa0-f45.google.com Received: from mail-oa0-f45.google.com (HELO mail-oa0-f45.google.com) (209.85.219.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 18 Jun 2014 17:18:49 +0000 Received: by mail-oa0-f45.google.com with SMTP id o6so2555740oag.18 for ; Wed, 18 Jun 2014 10:18:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=cVYao5KDrCV4bFUIXHpYOOaU4D+zG+A82k8mAM3Jflc=; b=CNxjc6vGATQWmkTwUHq1Jy5fjIGjn9CKLyXlBIIT66YOfY9ob7HB+WHtvIhYTV3wVD BatYegdFkqGBC6B6j07G5Vid1hvEXi7KDZ5wWROH8o/qS1GtKyfNCQgE6Rk6NPv20LEX z9Vr8WzBfHg8a0PQ51p1uMYpNJjADUTDjzS/9IHdFfnLj/AFqhCDqIMo+0M9SQS2tYrM ie0Rce1ThGS+Se/0uFV0HLxqoI2BwpdnT9pXYocFUngYZalRVxMK2KHOJv4aomTNnvZm v8kpoxNyjfcNTEbj501Y2KWrOOgGVeUDbC7/SKpJi9pwxkgSbWFvOayDDi2y2OdnMdbR 11Ng== X-Gm-Message-State: ALoCoQkzuuDmLaPJ8xxAF3acQBtTeQXeN1qXKw43djeJKXpCK46Ve5o9Yx6QyS7xn3pjgKYc7bxm MIME-Version: 1.0 X-Received: by 10.60.35.104 with SMTP id g8mr3331071oej.41.1403111927817; Wed, 18 Jun 2014 10:18:47 -0700 (PDT) Received: by 10.182.144.133 with HTTP; Wed, 18 Jun 2014 10:18:47 -0700 (PDT) In-Reply-To: References: <83oay128ca.fsf@gnu.org> <87ioo7uuqm.fsf@fleche.redhat.com> Date: Wed, 18 Jun 2014 17:18:00 -0000 Message-ID: Subject: Re: [PATCH] Add Frame.read_register to Python API From: Alexander Smundak To: Tom Tromey Cc: Eli Zaretskii , gdb-patches Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2014-06/txt/msg00681.txt.bz2 Ping. On Wed, Jun 11, 2014 at 4:52 PM, Alexander Smundak 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 > > * python/py-frame.c (frapy_read_register): New function. > > 2014-06-11 Sasha Smundak > > * python.texi (Frames in Python): Add read_register description. > > 2014-06-11 Sasha Smundak > > * gdb.python/py-frame.exp: Test Frame.read_register.