This is the mail archive of the 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] Introduce the "with" command

On 6/16/19 11:19 PM, Philippe Waroquiers wrote:
> I quickly read the patch, and played a little bit with it
> 2 minor comments below.
> Only one (minor) strange behaviour: 'out of range' encountered in
> the below 'nested' case:
>   (gdb) w print repeats unlimited -- w print repeats 1 -- p "1223334444"
>   $18 = "1", '2' <repeats 2 times>, '3' <repeats 3 times>, '4' <repeats 4 times>
>   integer 4294967295 out of range

Oh, thanks for catching that.  The reason is that a user can type
0 to mean "unlimited", but, "unlimited" is stored internally as -1,
which is 4294967295 in unsigned int.  The patch is currently passing
the internal "-1" directly to the set command.  We need to translate
the -1 back to "unlimited" or 0.

We already have code to do that in do_show_command, so I'll reuse it.

As for testing, I'm going to tweak the recently added
"maint test-settings set/show" commands, rename them to
"maint set/show test-settings", and then I'll add a
"maint with" command, which is just like "with", but
works with "maint set" settings.  This will allow 
testing all kind of different combinations similarly to
your example above, like:

 (gdb) maint with test-settings uinteger unlimited -- maint with test-settings uinteger 1
 (gdb) maint with test-settings uinteger 1 -- maint with test-settings uinteger unlimited

and it'll be easy to do the same thing for all types of settings
(var_uinteger, var_zuinteger, var_string, etc.).

> with set thank-you on -- echo It looks really nice :)

Cool. :-)

> Philippe
> On Fri, 2019-06-14 at 20:37 +0100, Pedro Alves wrote:
>> 	* printcmd.c: Include "top.h", "cli/cli-decode.h", and
>> 	"cli/cli-setshow.h".
>> 	(with_command, with_command_completer): New.
>> 	(_initialize_printcmd): Install the "with" command and its "w"
>> 	alias.
> It is slightly unexpected to have the with_command in the printcmd.c
> file, but I found no real good alternate place, as cli-setshow.c
> does not define any command, it just provides support to the "set"
> and "show" commands.

Yeah.  I put it here, because it's where the set_command is defined,
I guess because "set" has a double purpose of being a prefix command,
and implementing "set VAR = EXP".  See just above with_command.
show_command is in cli-cmds.c, I suppose we could put "with" there.

>> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> ....
> with_command_completer is not mentioned in valprint.h,
> and can be static I think.
>> +/* See valprint.h.  */
>> +
>> +void
>> +with_command_completer (struct cmd_list_element *ignore,
>> +			completion_tracker &tracker,
>> +			const char *text, const char * /*word*/)
Thanks, will fix, though I'll need to export a version of this
for "maint with" in the new version.

Pedro Alves

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