This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch][python] Fix python/14513


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]