This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[multiprocess] prettier "info inferior" output
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 24 Nov 2008 18:11:51 -0700
- Subject: [multiprocess] prettier "info inferior" output
- Reply-to: Tom Tromey <tromey at redhat dot com>
This is for the multiprocess branch.
This patch changes "info inferior" to emit table headers.
I was playing around and realized I didn't know what the various
columns meant.
Currently the code emits more fields than there are columns; I think
breakpoint.c does this too but I am not sure whether this is correct.
I don't even know how to get the fields after "exec" not to be empty
(I really have not played much yet...), so I send this merely as a
suggested direction, not as a real patch.
Tom
2008-11-24 Tom Tromey <tromey@redhat.com>
* inferior.c (print_inferior): Make a table, not a list. Emit
table headers.
diff --git a/gdb/inferior.c b/gdb/inferior.c
index b2a8bf6..439f7fa 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -332,8 +332,28 @@ print_inferior (struct ui_out *uiout, int requested_inferior)
struct inferior *inf;
char *extra_info;
struct cleanup *old_chain;
+ int inf_count = 0;
- old_chain = make_cleanup_ui_out_list_begin_end (uiout, "inferiors");
+ /* Compute number of inferiors we will print. */
+ for (inf = inferior_list; inf; inf = inf->next)
+ {
+ struct cleanup *chain2;
+
+ if (requested_inferior != -1 && inf->num != requested_inferior)
+ continue;
+
+ ++inf_count;
+ }
+
+ old_chain = make_cleanup_ui_out_table_begin_end (uiout, 5, inf_count,
+ "inferiors");
+
+ ui_out_table_header (uiout, 3, ui_right, "current", "Cur");
+ ui_out_table_header (uiout, 4, ui_right, "id", "Id");
+ ui_out_table_header (uiout, 7, ui_right, "target-id", "PID");
+ ui_out_table_header (uiout, 20, ui_left, "name", "Name");
+ ui_out_table_header (uiout, 20, ui_left, "exec", "Exec");
+ ui_out_table_body (uiout);
for (inf = inferior_list; inf; inf = inf->next)
{
@@ -345,22 +365,18 @@ print_inferior (struct ui_out *uiout, int requested_inferior)
chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
if (inf->pid > 0 && inf->pid == PIDGET (inferior_ptid))
- ui_out_text (uiout, "* ");
+ ui_out_field_string (uiout, "current", "*");
else
- ui_out_text (uiout, " ");
+ ui_out_field_skip (uiout, "current");
ui_out_field_int (uiout, "id", inf->num);
- ui_out_text (uiout, " ");
ui_out_field_int (uiout, "target-id", inf->pid);
if (inf->name)
- {
- ui_out_text (uiout, " #");
- ui_out_field_string (uiout, "name", inf->name);
- ui_out_text (uiout, "#");
- }
+ ui_out_field_string (uiout, "name", inf->name);
+ else
+ ui_out_field_skip (uiout, "name");
if (inf->exec)
{
- ui_out_text (uiout, " ");
/* Use short names for execs, except for exec's own
inferior. */
ui_out_field_string (uiout, "exec",
@@ -369,20 +385,22 @@ print_inferior (struct ui_out *uiout, int requested_inferior)
: inf->exec->shortname));
if (inf->args)
{
- ui_out_text (uiout, " ");
+ ui_out_text (uiout, "\n ");
ui_out_field_string (uiout, "args", inf->args);
}
if (inf->inf_environ)
{
- ui_out_text (uiout, " ");
+ ui_out_text (uiout, "\n ");
ui_out_field_string (uiout, "environ", "env=X");
}
if (inf->io_terminal)
{
- ui_out_text (uiout, " ");
+ ui_out_text (uiout, "\n ");
ui_out_field_string (uiout, "io_terminal", "term=Y");
}
}
+ else
+ ui_out_field_skip (uiout, "exec");
#if 0
extra_info = target_extra_inferior_info (inf);
if (extra_info)