Re: [PATCH v8 3/6] gdb, cli: pass the argument of a set command to its callback.

Andrew Burgess <[email protected]> Thu, 23 Jul 2026 10:06:56 +0100
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Andrew Burgess <[email protected]> writes:

> Klaus Gerlicher <[email protected]> writes:
>
>> From: Natalia Saiapova <[email protected]>
>>
>> This might be useful, if some commands need to have a special case if
>> run w/o arguments.
>
> The body of a commit message should ideally not run-on from the title
> line.  This first sentence only makes sense after reading the title.
>
> Anyway, I think there's a bug in this commit.  For the setting types:
> var_uinteger, var_integer, and var_pinteger we call
> parse_cli_var_integer which can modify ARG.  This means you'll not be
> passing through the actual argument of the set command in these cases.
>
> I think the fix is easy enough, just capture the original ARG near the
> start of do_set_command.
>
> I think all the setting types are fine, but if you just capture the
> original ARG value and use that in the 'c->func' call you'll be covered.

It occurred to me that we can easily add some tests for this new
feature. If you checkout gdb/maint-test-settings.c and look for the
"test-settings" you'll see a bunch of dummy maintenance settings.  These
are used by a number of tests, like gdb.base/settings.exp.

Could we not add a set callback to each of these settings that just
prints the value that you're now passing through?  Then the tests, like
settings.exp can be updated to check that we print back the expected
string.

Thanks,
Andrew