Re: [RFC] Let "gcore" command accept a suffix argument

Tom Tromey
2009-12-10T17:08:38Z

>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:

>> I make a patch to make gdb support "eval gcore foo.$a" command.

Thanks!

>> +{
>> +#define CMDSIZE 1024
>> + char cmd[CMDSIZE + 1];

Don't use a fixed-size buffer. Allocate on the heap and use a cleanup.

>> + value = parse_and_eval (eval_begin);

This is going to give an error if anything appears after "$foo".
Try something like:

eval echo $foo $bar

You have multiple choices here.

You could make it only support convenience variables. Then you would
just have to extract the name and then look up the value.

Or you could try to introduce syntax allowing arbitrary expressions.
One idea that comes to mind is to reuse some code and make eval work
like printf:

eval "echo %s %d", $foo, $bar + 87

Now that I write it that seems weird :-)

>> + add_com ("eval", no_class, eval_command, _("\
>> +Call command with variable."));

Exactly what to write depends on how it is implemented.

This also needs a documentation change, a NEWS entry, and test cases.

Tom