[RFC] Let "gcore" command accept a suffix argument
Hui Zhu
teawater@gmail.com
Sun Jan 10 14:16:00 GMT 2010
You are good on it.
Make a new patch is more easy than make me clear with this idea. :)
Thanks,
Hui
On Sun, Jan 10, 2010 at 22:00, Joel Brobecker <brobecker@adacore.com> wrote:
>> But I think we have know the type of the val that we want output, the
>> string we want it as string, the number we want it to be number.
>> Are you sure we need point out the type of val to be output?
>>
>> And this idea is out of my ability. Sorry about it.
>
> If you could have a look at how the "printf" command is implemented,
> you might be surprised as to how easy this task might be. For someone
> who tackled the really complex project of grafting process record onto
> GDB, I sincerely think that this should nearly be a no-brainer for you:
>
> 1. Extract out the entire contents of the printf_command implementation
> into a separate function. Let's call it ui_printf:
>
> void
> ui_printf (char *args, ui_file *stream)
>
> 2. Adjust the body so that all the printf/puts, etc, basically anything
> printing on stdout, are replace by equivalent calls that print in
> the given ui_file *stream;
>
> 3. Implement the body of printf_command by simply calling this new
> function with gdb_stdout as the ui_file;
>
> printf_command (char *args, int from_tty)
> {
> ui_printf (args, gdb_stout);
> }
>
> 4. Implement the eval function roughly like so:
>
> eval_command (char *args, int from_tty)
> {
> struct ui_file *ui_out = mem_fileopen ();
> char *expanded;
> struct cleanup *old_chain;
>
> ui_printf (args, ui_out); // That's the new function extracted
> // from printf_command, which prints
> // in a ui_file instead of stdout.
> expanded = ui_file_xstrdup (ui_out, NULL);
> old_chain = make_cleanup (xfree, expanded);
> execute_command (expanded, from_tty);
> do_cleanups (old_chain);
> }
>
> --
> Joel
>
More information about the Gdb-patches
mailing list