From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Always disable pagination with MI?
Date: Wed, 03 Mar 2010 21:39:00 -0000 [thread overview]
Message-ID: <201003032138.54319.pedro@codesourcery.com> (raw)
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;
next reply other threads:[~2010-03-03 21:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 21:39 Pedro Alves [this message]
2010-03-03 21:40 ` Pedro Alves
2010-03-03 21:53 ` Tom Tromey
2010-03-04 5:19 ` Joel Brobecker
2010-03-03 22:09 ` Vladimir Prus
2010-03-04 17:15 ` Marc Khouzam
2010-03-04 17:33 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201003032138.54319.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox