This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] When CLI, and an empty table suppress table output
- To: gdb-patches at sources dot redhat dot com
- Subject: [patch] When CLI, and an empty table suppress table output
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 19 Jun 2001 16:23:17 -0400
Hello,
(How do I explain this?) This change does to things:
o Tweek breakpoint.c, so that the ``no''
or ``missing'' breakpoint messages are
not part of the ui_out table.
(Because the message was being generated
while the ui-out table was still open, it
was being lost for the CLI since the CLI
(with the patch below) discards the table
when it is empty.
o for cli-out.c it adds code to look at
the number of rows in the table being
displayed and if that is zero supresses
the entire table (including headers).
This is at least the behavour of GDB when
outputting breakpoint tables - no breakpoints
then no headers.
This (and an MI) patch clear the way for
a tweek to breakpoint_1 so that it always
creates the breakpoint headers and then
leaves it to the output builder to decide
if they should or should not be displayed.
Andrew
2001-06-19 Andrew Cagney <ac131313@redhat.com>
* cli-out.c: Include "gdb_assert.h'.
(struct ui_out_data): Add field ``suppress_output.
(cli_table_begin): When NR_ROWS is zero, suppress_output.
(cli_table_end): Clear suppress_output.
(cli_table_body): Check suppress_output.
(cli_table_header, cli_begin): Ditto.
(cli_end, cli_field_int, cli_field_skip): Ditto.
(cli_field_string, cli_field_fmt, cli_spaces): Ditto.
(cli_text, cli_message, cli_wrap_hint): Ditto.
* breakpoint.c (breakpoint_1): Close the ui_out table before
printing the breakpoint not found message.
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.44
diff -p -r1.44 breakpoint.c
*** breakpoint.c 2001/06/19 16:19:15 1.44
--- breakpoint.c 2001/06/19 20:05:58
*************** breakpoint_1 (int bnum, int allflag)
*** 3657,3662 ****
--- 3657,3667 ----
print_one_breakpoint (b, &last_addr);
}
+
+ #ifdef UI_OUT
+ ui_out_table_end (uiout);
+ #endif /* UI_OUT */
+
if (nr_printable_breakpoints == 0)
{
#ifdef UI_OUT
*************** breakpoint_1 (int bnum, int allflag)
*** 3680,3688 ****
set_next_address (last_addr);
}
- #ifdef UI_OUT
- ui_out_table_end (uiout);
- #endif /* UI_OUT */
/* FIXME? Should this be moved up so that it is only called when
there have been breakpoints? */
annotate_breakpoints_table_end ();
--- 3685,3690 ----
Index: cli-out.c
===================================================================
RCS file: /cvs/src/src/gdb/cli-out.c,v
retrieving revision 1.9
diff -p -r1.9 cli-out.c
*** cli-out.c 2001/06/19 16:19:15 1.9
--- cli-out.c 2001/06/19 20:05:59
***************
*** 24,29 ****
--- 24,30 ----
#include "ui-out.h"
#include "cli-out.h"
#include "gdb_string.h"
+ #include "gdb_assert.h"
/* Convenience macro for allocting typesafe memory. */
***************
*** 34,39 ****
--- 35,41 ----
struct ui_out_data
{
struct ui_file *stream;
+ int suppress_output;
};
/* These are the CLI output functions */
*************** cli_table_begin (struct ui_out *uiout, i
*** 111,116 ****
--- 113,125 ----
int nr_rows,
const char *tblid)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (nr_rows == 0)
+ data->suppress_output = 1;
+ else
+ /* Only the table suppresses the output and, fortunatly, a table
+ is not a recursive data structure. */
+ gdb_assert (data->suppress_output == 0);
}
/* Mark beginning of a table body */
*************** cli_table_begin (struct ui_out *uiout, i
*** 118,123 ****
--- 127,135 ----
void
cli_table_body (struct ui_out *uiout)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
/* first, close the table header line */
cli_text (uiout, "\n");
}
*************** cli_table_body (struct ui_out *uiout)
*** 127,132 ****
--- 139,146 ----
void
cli_table_end (struct ui_out *uiout)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ data->suppress_output = 0;
}
/* Specify table header */
*************** void
*** 135,140 ****
--- 149,157 ----
cli_table_header (struct ui_out *uiout, int width, enum ui_align alignment,
const char *colhdr)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
cli_field_string (uiout, 0, width, alignment, 0, colhdr);
}
*************** cli_begin (struct ui_out *uiout,
*** 146,151 ****
--- 163,171 ----
int level,
const char *id)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
}
/* Mark end of a list */
*************** cli_end (struct ui_out *uiout,
*** 155,160 ****
--- 175,183 ----
enum ui_out_type type,
int level)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
}
/* output an int field */
*************** cli_field_int (struct ui_out *uiout, int
*** 166,171 ****
--- 189,197 ----
{
char buffer[20]; /* FIXME: how many chars long a %d can become? */
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
sprintf (buffer, "%d", value);
cli_field_string (uiout, fldno, width, alignment, fldname, buffer);
}
*************** cli_field_skip (struct ui_out *uiout, in
*** 177,182 ****
--- 203,211 ----
enum ui_align alignment,
const char *fldname)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
cli_field_string (uiout, fldno, width, alignment, fldname, "");
}
*************** cli_field_string (struct ui_out *uiout,
*** 194,199 ****
--- 223,232 ----
int before = 0;
int after = 0;
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+
if ((align != ui_noalign) && string)
{
before = width - strlen (string);
*************** cli_field_fmt (struct ui_out *uiout, int
*** 238,243 ****
--- 271,279 ----
va_list args)
{
struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+
vfprintf_filtered (data->stream, format, args);
if (align != ui_noalign)
*************** void
*** 248,253 ****
--- 284,291 ----
cli_spaces (struct ui_out *uiout, int numspaces)
{
struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
print_spaces_filtered (numspaces, data->stream);
}
*************** void
*** 255,260 ****
--- 293,300 ----
cli_text (struct ui_out *uiout, const char *string)
{
struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
fputs_filtered (string, data->stream);
}
*************** cli_message (struct ui_out *uiout, int v
*** 263,268 ****
--- 303,310 ----
const char *format, va_list args)
{
struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
if (ui_out_get_verblvl (uiout) >= verbosity)
vfprintf_unfiltered (data->stream, format, args);
}
*************** cli_message (struct ui_out *uiout, int v
*** 270,275 ****
--- 312,320 ----
void
cli_wrap_hint (struct ui_out *uiout, char *identstring)
{
+ struct ui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
wrap_here (identstring);
}