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

Tom Tromey tromey@redhat.com
Thu Dec 10 17:08:00 GMT 2009


>>>>> ">" == 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



More information about the Gdb-patches mailing list