This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Let "gcore" command accept a suffix argument
- From: Tom Tromey <tromey at redhat dot com>
- To: Hui Zhu <teawater at gmail dot com>
- Cc: Michael Snyder <msnyder at vmware dot com>, Joel Brobecker <brobecker at adacore dot com>, gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Thu, 10 Dec 2009 10:07:13 -0700
- Subject: Re: [RFC] Let "gcore" command accept a suffix argument
- References: <4B11DA3C.3000203@vmware.com> <daef60380911300437o4c616eb2v5ad7bfe99bd3c5e9@mail.gmail.com> <20091130162246.GE4034@adacore.com> <4B141157.3070709@vmware.com> <20091130185341.GI4034@adacore.com> <4B141469.5030402@vmware.com> <20091130190619.GJ4034@adacore.com> <4B1428F0.7090608@vmware.com> <daef60380912091827u6ff7127bp1d03998a40932914@mail.gmail.com> <daef60380912091832t5c443609he8a3fb46d1a4cd50@mail.gmail.com>
- Reply-to: tromey at redhat dot com
>>>>> ">" == 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