This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Always disable pagination with MI?
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 3 Mar 2010 21:38:54 +0000
- Subject: Always disable pagination with MI?
A customer noted that sometimes, when GDB failed to evaluate
a watchpoint's condition, GDB would leave the inferior
stopped, but would forget to output a *stopped notification.
Something like this:
gdb -i=mi ...
...
(gdb)
&"Error in testing breakpoint condition:\n"
&"Cannot access memory at address 0x0\n"
~"Hardware watchpoint 2: global2\n"
~"\n"
~"Old value = 1\n"
~"New value = 2\n"
And nothing else came out. What was really happening, is
that pagination kicked in at this point, because no pagination
prompt is visible. If one presses enter when this happens,
the rest of the expected output, along with *stopped actually
comes out:
gdb -i=mi ...
...
(gdb)
&"Error in testing breakpoint condition:\n"
&"Cannot access memory at address 0x0\n"
~"Hardware watchpoint 2: global2\n"
~"\n"
~"Old value = 1\n"
~"New value = 2\n"
<ENTER>
~"main () at ../../../src/gdb/testsuite/gdb.base/watch-cond.c:42\n"
~"42\t func(&q);\n"
*stopped,frame={addr="0x000000000040058e",func="main",args=[],file="../../../src/gdb/testsuite/gdb.base/watch- cond.c",fullname="/home/pedro/gdb/baseline/src/gdb/testsuite/gdb.base/watch-cond.c",line="42"},thread-id="1",stopped-threads="all",core="1"
(gdb)
Pagination kicks in because that output is going to
gdb_stdout.
Obviously, this is lame. You can actually reproduce this
MI + pagination badness simply by issuing enough CLI
commands to fill a page, like this for example:
$ ./gdb -i=mi ./gdb
=thread-group-added,id="i1"
(gdb)
ib
&"ib\n"
~"Num Type Disp Enb Address What\n"
~"1 breakpoint keep y 0x00000000004645e4 in internal_error at ../../src/gdb/utils.c:1048\n"
~"2 breakpoint keep y 0x00000000004d7895 in info_command at ../../src/gdb/cli/cli-cmds.c:223\n"
~" silent\n"
~" return\n"
^done
<repeat "info break" a few times, and then:>
(gdb)
ib
&"ib\n"
~"Num Type Disp Enb Address What\n"
~"1 breakpoint keep y 0x00000000004645e4 in internal_error at ../../src/gdb/utils.c:1048\n"
<ENTER>
$ Segmentation fault
Whoops. I tried this on 6.8 and 7.0 and they behave
the same. This was probably never right, and I gather that
most frontends must be disabling pagination
already: either by explicit "set height 0"/"set pagination off",
or implicitly by running GDB from a non-tty, and, those that
want pagination handle it themselves.
Any objections to this?
--
Pedro Alves
2010-03-03 Pedro Alves <pedro@codesourcery.com>
gdb/
* utils.c (fputs_maybe_filtered): Always disable pagination if the
top level interpreter is MI.
---
gdb/utils.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Index: src/gdb/utils.c
===================================================================
--- src.orig/gdb/utils.c 2010-03-03 20:55:57.000000000 +0000
+++ src/gdb/utils.c 2010-03-03 20:56:49.000000000 +0000
@@ -71,6 +71,7 @@
#include <time.h>
#include "gdb_usleep.h"
+#include "interps.h"
#if !HAVE_DECL_MALLOC
extern PTR malloc (); /* ARI: PTR */
@@ -2209,8 +2210,10 @@ fputs_maybe_filtered (const char *linebu
return;
/* Don't do any filtering if it is disabled. */
- if ((stream != gdb_stdout) || !pagination_enabled
- || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX))
+ if (stream != gdb_stdout
+ || !pagination_enabled
+ || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
+ || ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ())))
{
fputs_unfiltered (linebuffer, stream);
return;