This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch][python] Fix python/14513
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 18 Sep 2013 21:34:22 +0100
- Subject: Re: [patch][python] Fix python/14513
- Authentication-results: sourceware.org; auth=none
- References: <5239A7E9 dot 8010202 at redhat dot com> <877gedub9p dot fsf at fleche dot redhat dot com>
On 18/09/13 21:26, Tom Tromey wrote:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> 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