[PATCH v6 4/8] GDB/Python: Make `None' stand for `unlimited' in setting integer parameters

Maciej W. Rozycki macro@embecosm.com
Fri Oct 21 08:03:05 GMT 2022


On Mon, 17 Oct 2022, Simon Marchi wrote:

> > Similarly to booleans and following the fix for PR python/29217 make 
> > `gdb.parameter' accept `None' for `unlimited' with parameters of the 
> > PARAM_UINTEGER, PARAM_INTEGER, and PARAM_ZUINTEGER_UNLIMITED types, as 
> > `None' is already returned by parameters of the two former types, so 
> > one might expect to be able to feed it back.  It also makes it possible 
> > to avoid the need to know what the internal integer representation is 
> > for the special setting of `unlimited'.
> 
> If I understand correctly, assigning None used to just raise an
> exception, and now it will be accepted for those kinds of parameters.

 Yes, we currently have:

(gdb) python gdb.set_parameter('listsize', None)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File ".../gdb/data-directory/python/gdb/__init__.py", line 245, in set_parameter
    execute("set " + name + " " + str(value), to_string=True)
gdb.error: No symbol table is loaded.  Use the "file" command.
Error while executing Python code.
(gdb) python test_param_PARAM_UINTEGER.value = None
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: The value must be integer.
Error while executing Python code.
(gdb) 

etc.  With my change in place these commands silently succeed.

 The only concern I can think of might be where there is an actual symbol 
called `None' in the debuggee.  I guess it can be handled by assigning its 
value to a convenience variable outside Python.

> So, I don't think there are backwards compatibility concerns here.  If
> so:
> 
> Approved-By: Simon Marchi <simon.marchi@polymtl.ca>

 I have also committed this change then, thanks!

  Maciej


More information about the Gdb-patches mailing list