This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: simlpe patch implements eval command (with printf-like format and args)
On Fri, Feb 22, 2008 at 12:11 AM, Michael Snyder <msnyder@specifix.com> wrote:
>
> On Thu, 2008-02-21 at 11:20 +0200, Yakov Lerner wrote:
> > This simple patch implements eval command with printf-like syntax:
> >
> > eval "printf-like-format", comma-separated args
> >
> > The patch is against cvs-checkedout source. Suggestions are welcome.
> > Implementation is very simple.
>
> Not bad at all, for a first contribution. But I suggest
> you try to limit the scope a little bit and make it still
> simpler -- maybe have it accept only strings, floats and ints
> to start -- and see if you can't implement it less intrusively
You mean here, to replicate (with cuts) the code of existing
printf_command(), and leave existing printf_command()
unchanged, correct ?
> eg. without taking over the function for another command and
> introducing new cross-module infrastructure. Then we can
> maybe iteratively improve on it.
>
> I'll give you some style and structure feedback on this one:
> >
> > +/* Grow allocated buffer and appens to it, without causing quadratic
> > slowdown */
>
> "append", of course -- and comments must be punctuated (in this case,
> period followed by two spaces". Plus indentation -- consult the GNU
> coding standard.
ok
> > +/* Grow allocated buffer and appens to it, without causing quadratic
> > slowdown */
>
> as above.
ok
> > +static void
> > +eval_command (char *arg, int from_tty)
> > +{
> > + struct cleanup *old_cleanups;
> > + char *str = gdb_own_xasprintf (arg);
> > +
> > + old_cleanups = make_cleanup (free_current_contents, &str);
> > + execute_command (str, from_tty);
> > + do_cleanups (old_chain);
> > +}
>
> old_chain is undefined. Probably should be "old_cleanups"?
ok
Thanks
Yakov