From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9829 invoked by alias); 3 Mar 2010 21:39:06 -0000 Received: (qmail 9815 invoked by uid 22791); 3 Mar 2010 21:39:04 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Mar 2010 21:38:59 +0000 Received: (qmail 29873 invoked from network); 3 Mar 2010 21:38:58 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Mar 2010 21:38:58 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Always disable pagination with MI? Date: Wed, 03 Mar 2010 21:39:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-19-generic; KDE/4.3.2; x86_64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201003032138.54319.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00129.txt.bz2 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" ~"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 (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" $ 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 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 #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;