This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

>>>>> ">" == Hui Zhu <> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]