[PATCH v4 8/9] gdb/testsuite: support passing inferior arguments with native-gdbserver board

Simon Marchi simark@simark.ca
Tue May 19 17:22:35 GMT 2020


On 2020-05-19 1:11 p.m., Simon Marchi wrote:
> On 2020-05-15 1:29 p.m., Tom de Vries wrote:
>> The curly braces are what you get when you directly convert a list of
>> strings into a string.
>>
>> If we do the conversion ourselves, we get the desired outcome:
>> ...
>> $ cat test.tcl
>> #!/usr/bin/tclsh
>>
>> set args [list hello "with spaces" world]
>>
>> proc string_list_to_string_with_quotes { args } {
>>     set s ""
>>     foreach arg $args {
>>         set s "$s \"$arg\""
>>     }
>>     return $s
>> }
>>
>> set args_str [string_list_to_string_with_quotes {*}$args]
>> puts "run $args_str"
>> $ ./test.tcl
>> run  "hello" "with spaces" "world"
>> ...
>>
>> And we can use the normal "args" rather than the inferior_args, as long
>> as we take care to pass the args from one varargs function to another
>> using '{*}$args'.
> 
> I'm fine with both ways, do you have a preference?
> 
> Simon
> 

In fact, I think I'd rather not use "args", because that would make it more
difficult to add other parameters in the future.  So I'd keep "inferior_args",
although we can make it accept a list instead of a string, and apply the
treatment you have shown above.

Or, I like the procedures that accept optional arguments using shell-like switches,
so we could do:

  set inferior_args [list a b c]
  gdb_run_cmd -inferior-args $inferior_args

This is untested, I always forget how tcl converts between strings and lists
exactly, but you should see the point.  That makes it easier to add other parameters
in the future.

Simon



More information about the Gdb-patches mailing list