From patchwork Tue Jun 24 16:17:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1698 Received: (qmail 1459 invoked by alias); 24 Jun 2014 16:17:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 1446 invoked by uid 89); 24 Jun 2014 16:17:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 24 Jun 2014 16:17:35 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5OGHXdc032615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 24 Jun 2014 12:17:34 -0400 Received: from barimba.redhat.com (ovpn-113-138.phx2.redhat.com [10.3.113.138]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5OGHXVp009776; Tue, 24 Jun 2014 12:17:33 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] add "continue" response to pager Date: Tue, 24 Jun 2014 10:17:30 -0600 Message-Id: <1403626650-26313-1-git-send-email-tromey@redhat.com> This adds a "continue" response to the pager. If the user types "c" in response to the pager prompt, pagination will be disabled for the duration of one command -- but re-enabled afterward. This is handy if you type a command that produces a lot of output, and you don't want to baby-sit it by typing "return" each time the prompt comes up. Built and regtested on x86-64 Fedora 20. This required a couple of minor tweaks to existing tests. 2014-06-24 Tom Tromey PR cli/12326: * utils.c (pagination_disabled_for_command): New global. (prompt_for_continue): Allow "c" response to prompt. (reinitialize_more_filter): Clear pagination_disabled_for_command. (fputs_maybe_filtered): Check pagination_disabled_for_command. 2014-06-24 Tom Tromey * gdb.base/page.exp: Update expected output. Add new tests. * gdb.python/python.exp: Update expected output. --- gdb/ChangeLog | 9 +++++++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/page.exp | 21 ++++++++++++++++++++- gdb/testsuite/gdb.python/python.exp | 33 ++++++++++++--------------------- gdb/utils.c | 27 ++++++++++++++++++++++----- 5 files changed, 68 insertions(+), 27 deletions(-) diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp index a21563b..05b3a64 100644 --- a/gdb/testsuite/gdb.base/page.exp +++ b/gdb/testsuite/gdb.base/page.exp @@ -47,7 +47,7 @@ gdb_test "show pagination" "State of pagination is on.*" "pagination is on" gdb_test_no_output "set height 10" send_gdb "help\n" gdb_expect_list "paged help" \ - ".*---Type to continue, or q to quit---" { + ".*---Type to continue, q to quit, or c to\r\n *continue without paging---" { "List of classes of commands:" "" "aliases -- Aliases of other commands" @@ -60,6 +60,25 @@ gdb_expect_list "paged help" \ } gdb_test "q" +gdb_test_no_output "set height 5" +send_gdb "printf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n11\"\n" +gdb_expect_list "paged count" \ + ".*---Type to continue, q to quit, or c to\r\n *continue without paging---" { + 1 + 2 + 3 + 4 +} +send_gdb "c\n" +gdb_expect_list "paged count remainder" "${gdb_prompt} " { + 5 + 6 + 7 + 8 + 9 + 10 + 11 +} gdb_exit return 0 diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index c03c284..bc4241b 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -107,33 +107,24 @@ set lines 10 gdb_test_no_output "set height $lines" set test "verify pagination beforehand" -gdb_test_multiple "python print (\"\\n\" * $lines)" $test { - -re "---Type " { - exp_continue - } - -re " to continue, or q " { - exp_continue - } - -re " to quit---$" { - pass $test - } +set arglist {} +for {set i 0} {$i < $lines} {incr i} { + lappend arglist "" } +lappend arglist "" +send_gdb "python print (\"\\n\" * $lines)\n" +gdb_expect_list $test \ + ".*---Type to continue, q to quit, or c to\r\n *continue without paging---" \ + $arglist gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination beforehand: q" gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gdb.execute does not page" set test "verify pagination afterwards" -gdb_test_multiple "python print (\"\\n\" * $lines)" $test { - -re "---Type " { - exp_continue - } - -re " to continue, or q " { - exp_continue - } - -re " to quit---$" { - pass $test - } -} +send_gdb "python print (\"\\n\" * $lines)\n" +gdb_expect_list $test \ + ".*---Type to continue, q to quit, or c to\r\n *continue without paging---" \ + $arglist gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q" gdb_test_no_output "set height 0" diff --git a/gdb/utils.c b/gdb/utils.c index 6f47cb0..6416bac 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1681,6 +1681,10 @@ show_chars_per_line (struct ui_file *file, int from_tty, /* Current count of lines printed on this page, chars on this line. */ static unsigned int lines_printed, chars_printed; +/* True if pagination is disabled for just one command. */ + +static int pagination_disabled_for_command; + /* Buffer and start column of buffered text, for doing smarter word- wrapping. When someone calls wrap_here(), we start buffering output that comes through fputs_filtered(). If we see a newline, we just @@ -1859,6 +1863,7 @@ prompt_for_continue (void) /* Used to add duration we waited for user to respond to prompt_for_continue_wait_time. */ struct timeval prompt_started, prompt_ended, prompt_delta; + int disable_pagination = pagination_disabled_for_command; gettimeofday (&prompt_started, NULL); @@ -1866,7 +1871,8 @@ prompt_for_continue (void) printf_unfiltered (("\n\032\032pre-prompt-for-continue\n")); strcpy (cont_prompt, - "---Type to continue, or q to quit---"); + "---Type to continue, q to quit, or c to\n" + " continue without paging---"); if (annotation_level > 1) strcat (cont_prompt, "\n\032\032prompt-for-continue\n"); @@ -1906,6 +1912,8 @@ prompt_for_continue (void) ++p; if (p[0] == 'q') quit (); + if (p[0] == 'c') + disable_pagination = 1; xfree (ignore); } immediate_quit--; @@ -1913,6 +1921,7 @@ prompt_for_continue (void) /* Now we have to do this again, so that GDB will know that it doesn't need to save the ---Type --- line at the top of the screen. */ reinitialize_more_filter (); + pagination_disabled_for_command = disable_pagination; dont_repeat (); /* Forget prev cmd -- CR won't repeat it. */ } @@ -1942,6 +1951,7 @@ reinitialize_more_filter (void) { lines_printed = 0; chars_printed = 0; + pagination_disabled_for_command = 0; } /* Indicate that if the next sequence of characters overflows the line, @@ -2086,6 +2096,7 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream, /* Don't do any filtering if it is disabled. */ if (stream != gdb_stdout || !pagination_enabled + || pagination_disabled_for_command || batch_flag || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX) || top_level_interpreter () == NULL @@ -2102,8 +2113,11 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream, lineptr = linebuffer; while (*lineptr) { - /* Possible new page. */ - if (filter && (lines_printed >= lines_per_page - 1)) + /* Possible new page. Note that PAGINATION_DISABLED_FOR_COMMAND + might be set during this loop, so we must continue to check + it here. */ + if (filter && (lines_printed >= lines_per_page - 1) + && !pagination_disabled_for_command) prompt_for_continue (); while (*lineptr && *lineptr != '\n') @@ -2143,8 +2157,11 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream, if (wrap_column) fputc_unfiltered ('\n', stream); - /* Possible new page. */ - if (lines_printed >= lines_per_page - 1) + /* Possible new page. Note that + PAGINATION_DISABLED_FOR_COMMAND might be set during + this loop, so we must continue to check it here. */ + if (lines_printed >= lines_per_page - 1 + && !pagination_disabled_for_command) prompt_for_continue (); /* Now output indentation and wrapped string. */