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: Joel Brobecker <brobecker at adacore dot com>, Stan Shebs <stanshebs at earthlink dot net>, Stan Shebs <stan at codesourcery dot com>, Michael Snyder <msnyder at vmware dot com>, gdb-patches ml <gdb-patches at sourceware dot org>, Eli Zaretskii <eliz at gnu dot org>
- Date: Mon, 21 Jun 2010 15:39:16 -0600
- Subject: Re: [RFC] Let "gcore" command accept a suffix argument
- References: <m31vioaxv0.fsf@fleche.redhat.com> <4B3BEDCC.9040103@earthlink.net> <daef60381001040642h2e8b3919u221f61d43b23d395@mail.gmail.com> <daef60381001052257q2068a8fbmaacd026b8d5cef49@mail.gmail.com> <20100106075757.GF24777@adacore.com> <daef60381001090154m36f5cf15x9f76b7073e4d126@mail.gmail.com> <20100109105557.GA2007@adacore.com> <daef60381001090717j4a658548g114950986df6279b@mail.gmail.com> <20100110054328.GD2007@adacore.com> <daef60381001100530k39fe9727s355cad73a47a2989@mail.gmail.com> <20100110140029.GF2007@adacore.com> <AANLkTinVPdwg6HuAp08wknw8DYe80LcR33tbEaRkMDXz@mail.gmail.com>
- Reply-to: tromey at redhat dot com
>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:
>> static void
>> -printf_command (char *arg, int from_tty)
>> +ui_printf_maybe_filtered (char *arg, struct ui_file *stream, int filter)
I don't think you really need the 'filter' argument.
fprintf_filtered will actually work unfiltered unless printing to
gdb_stdout. (One of several bad things about this API -- but we already
rely on it.)
I think this argument uglifies the code quite a bit.
>> +static void
>> +eval_command (char *arg, int from_tty)
>> +{
>> + struct ui_file *ui_out = mem_fileopen ();
>> + char *expanded;
>> + struct cleanup *old_chain;
>> +
>> + ui_printf_maybe_filtered (arg, ui_out, 0);
>> + expanded = ui_file_xstrdup (ui_out, NULL);
>> + old_chain = make_cleanup (xfree, expanded);
>> + execute_command (expanded, from_tty);
>> + do_cleanups (old_chain);
You need a cleanup in there to destroy the new ui_out.
>> + add_com ("eval", no_class, eval_command, _("\
>> +Call command with variable."));
>> }
This needs a better doc string.
I think this approach is good overall. It needs a documentation patch,
a NEWS entry, and some tests.
Tom