From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6258 invoked by alias); 18 Sep 2013 20:34:27 -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 6249 invoked by uid 89); 18 Sep 2013 20:34:26 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Sep 2013 20:34:26 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8IKYOgk025262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 18 Sep 2013 16:34:24 -0400 Received: from localhost.localdomain (ovpn-112-31.ams2.redhat.com [10.36.112.31]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r8IKYNxf017826; Wed, 18 Sep 2013 16:34:23 -0400 Message-ID: <523A0E4E.3090105@redhat.com> Date: Wed, 18 Sep 2013 20:34:00 -0000 From: Phil Muldoon MIME-Version: 1.0 To: Tom Tromey CC: "gdb-patches@sourceware.org" Subject: Re: [patch][python] Fix python/14513 References: <5239A7E9.8010202@redhat.com> <877gedub9p.fsf@fleche.redhat.com> In-Reply-To: <877gedub9p.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-09/txt/msg00630.txt.bz2 On 18/09/13 21:26, Tom Tromey wrote: >>>>>> "Phil" == Phil Muldoon writes: > > Phil> Parameters normally report what the value has been set too: > Phil> (gdb) set foobar 5 > Phil> foobar has been set to 5. > > Phil> This patch just checks the string length of the output string before > Phil> printing it. > > Phil> OK? > > Built-in parameters don't seem to do this printing: > > (gdb) set print elements 500 > (gdb) > > I think the Python layer should follow this precedent. > Maybe get_set_string can be entirely removed. If you look at the testsuite for py-param, they do have this option. I have no opinion about this, but if we remove it I think we will we be breaking our API promise? This functionality has been in there for awhile. Here is an example from the testsuite: class TestParam (gdb.Parameter): """When enabled, test param does something useful. When disabled, does nothing.""" show_doc = "Show the state of the boolean test-param" set_doc = "Set the state of the boolean test-param" def get_show_string (self, pvalue):" ""\ return "The state of the Test Parameter is " + pvalue def get_set_string (self): val = "on" if (self.value == False): val = "off" return "Test Parameter has been set to " + val def __init__ (self, name): super (TestParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_BOOLEAN) self.value = True test_param = TestParam ('print test-param') Notice that get_set_string, a callback, has a return value. I felt it best in these circumstances to maintain API compatibility and do the empty string check. What do you think? Cheers, Phil