public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA v2] Add "continue" response to pager
@ 2018-04-25 14:52 Tom Tromey
  2018-05-09 15:43 ` Tom Tromey
  2018-05-09 19:51 ` Pedro Alves
  0 siblings, 2 replies; 12+ messages in thread
From: Tom Tromey @ 2018-04-25 14:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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.

This is v2 of a patch originally sent here but never committed.

    https://sourceware.org/ml/gdb-patches/2014-06/msg00862.html

I think this version addresses all comments in that thread.

Tested by the buildbot.

gdb/ChangeLog
2018-04-25  Tom Tromey  <tom@tromey.com>

	PR cli/12326:
	* NEWS: Add entry about pager.
	* 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.

gdb/doc/ChangeLog
2018-04-25  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Screen Size): Document "c" response to pagination
	prompt.

gdb/testsuite/ChangeLog
2018-04-25  Tom Tromey  <tom@tromey.com>

	PR cli/12326:
	* gdb.cp/static-print-quit.exp: Update.
	* lib/gdb.exp (pagination_prompt): Update.
	* gdb.base/page.exp: Use pagination_prompt.  Add new tests.
	* gdb.python/python.exp: Use pagination_prompt.
---
 gdb/ChangeLog                              | 10 +++++++++
 gdb/NEWS                                   |  3 +++
 gdb/doc/ChangeLog                          |  5 +++++
 gdb/doc/gdb.texinfo                        |  5 +++--
 gdb/testsuite/ChangeLog                    |  8 ++++++++
 gdb/testsuite/gdb.base/page.exp            | 21 ++++++++++++++++++-
 gdb/testsuite/gdb.cp/static-print-quit.exp |  9 +-------
 gdb/testsuite/gdb.python/python.exp        | 33 +++++++++++-------------------
 gdb/testsuite/lib/gdb.exp                  |  3 ++-
 gdb/utils.c                                | 27 +++++++++++++++++++-----
 10 files changed, 86 insertions(+), 38 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 63fe30d175..f94e9dc778 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,9 @@
 
 *** Changes since GDB 8.1
 
+* The pager now allows a "c" response, meaning to disable the pager
+  for the rest of the current command.
+
 * The commands 'info variables/functions/types' now show the source line
   numbers of symbol definitions when available.
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 28f083f96e..b5f976d5fc 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -23874,8 +23874,9 @@ Print ten commands just after the commands last printed.
 Certain commands to @value{GDBN} may produce large amounts of
 information output to the screen.  To help you read all of it,
 @value{GDBN} pauses and asks you for input at the end of each page of
-output.  Type @key{RET} when you want to continue the output, or @kbd{q}
-to discard the remaining output.  Also, the screen width setting
+output.  Type @key{RET} when you want to continue the output, @kbd{q}
+to discard the remaining output, or @kbd{c} to disable paging for the
+rest of the current command.  Also, the screen width setting
 determines when to wrap lines of output.  Depending on what is being
 printed, @value{GDBN} tries to break the line at a readable place,
 rather than simply letting it overflow onto the following line.
diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp
index 47db79fb8e..f7557d3b94 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 <return> to continue, or q <return> to quit---" {
+	".*$pagination_prompt" {
     "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" \
+    ".*$pagination_prompt" {
+	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.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp
index ab60a0cba0..81ea61f7ce 100644
--- a/gdb/testsuite/gdb.cp/static-print-quit.exp
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -41,14 +41,7 @@ gdb_test_multiple "print c" $test {
 
 set test "print c - q <return>"
 gdb_test_multiple "" $test {
-    -re " to continue, or q <return>" {
-	pass $test
-    }
-}
-
-set test "print c - to quit"
-gdb_test_multiple "" $test {
-    -re " to quit---$" {
+    -re " continue without paging---$" {
 	pass $test
     }
 }
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index cee195f315..8b296582a9 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -139,33 +139,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 <return>" {
-	exp_continue
-    }
-    -re " to continue, or q <return>" {
-	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 \
+    ".*$pagination_prompt" \
+    $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 <return>" {
-	exp_continue
-    }
-    -re " to continue, or q <return>" {
-	exp_continue
-    }
-    -re " to quit---$" {
-	pass $test
-    }
-}
+send_gdb "python print (\"\\n\" * $lines)\n"
+gdb_expect_list $test \
+    ".*$pagination_prompt" \
+    $arglist
 gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q"
 
 gdb_test_no_output "set height 0"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 4d48f5e3ad..a4e0f4b9cd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -82,7 +82,8 @@ if ![info exists gdb_prompt] then {
 }
 
 # A regexp that matches the pagination prompt.
-set pagination_prompt [string_to_regexp "---Type <return> to continue, or q <return> to quit---"]
+set pagination_prompt \
+    "---Type <return> to continue, q <return> to quit, or c <return> to\r\n *continue without paging---"
 
 # The variable fullname_syntax_POSIX is a regexp which matches a POSIX 
 # absolute path ie. /foo/ 
diff --git a/gdb/utils.c b/gdb/utils.c
index b957b0dc5c..4478c52166 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1282,6 +1282,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
@@ -1466,12 +1470,14 @@ prompt_for_continue (void)
      prompt_for_continue_wait_time.  */
   using namespace std::chrono;
   steady_clock::time_point prompt_started = steady_clock::now ();
+  int disable_pagination = pagination_disabled_for_command;
 
   if (annotation_level > 1)
     printf_unfiltered (("\n\032\032pre-prompt-for-continue\n"));
 
   strcpy (cont_prompt,
-	  "---Type <return> to continue, or q <return> to quit---");
+	  "---Type <return> to continue, q <return> to quit, or c <return> to\n"
+	  "   continue without paging---");
   if (annotation_level > 1)
     strcat (cont_prompt, "\n\032\032prompt-for-continue\n");
 
@@ -1501,11 +1507,14 @@ prompt_for_continue (void)
       if (p[0] == 'q')
 	/* Do not call quit here; there is no possibility of SIGINT.  */
 	throw_quit ("Quit");
+      if (p[0] == 'c')
+	disable_pagination = 1;
     }
 
   /* Now we have to do this again, so that GDB will know that it doesn't
      need to save the ---Type <return>--- 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.  */
 }
@@ -1535,6 +1544,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,
@@ -1679,6 +1689,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
@@ -1695,8 +1706,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')
@@ -1736,8 +1750,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.  */
-- 
2.13.6

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-04-25 14:52 [RFA v2] Add "continue" response to pager Tom Tromey
@ 2018-05-09 15:43 ` Tom Tromey
  2018-05-09 19:51 ` Pedro Alves
  1 sibling, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2018-05-09 15:43 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This adds a "continue" response to the pager.  If the user types "c"
Tom> in response to the pager prompt, pagination will be disabled for the
Tom> duration of one command -- but re-enabled afterward.  This is handy if
Tom> you type a command that produces a lot of output, and you don't want
Tom> to baby-sit it by typing "return" each time the prompt comes up.

Ping.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-04-25 14:52 [RFA v2] Add "continue" response to pager Tom Tromey
  2018-05-09 15:43 ` Tom Tromey
@ 2018-05-09 19:51 ` Pedro Alves
  2018-05-09 21:28   ` Tom Tromey
  1 sibling, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2018-05-09 19:51 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 04/25/2018 03:52 PM, Tom Tromey wrote:
> 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.
> 
> This is v2 of a patch originally sent here but never committed.
> 
>     https://sourceware.org/ml/gdb-patches/2014-06/msg00862.html
> 
> I think this version addresses all comments in that thread.
> 
> Tested by the buildbot.

Thanks, cool feature.  I've wanted it before too.

I gave the patch a quick try, and I have to say that it looks a
bit odd to me that the pager prompt takes two lines:

---Type <return> to continue, q <return> to quit, or c <return> to
   continue without paging---

I'm wondering whether we can shorten that, to, say:

---Type <return> for more, q to quit, c to continue without paging---

That seems clear enough to me, and is still 69 cols.  I doubt
anyone would miss the indication to type enter after q or c.
We could shorten it more, like, say:

---Type <return> for more, q to quit, c to continue without paging---  # 69 cols
---Type <ret> for more, q to quit, c to continue without paging---     # 66 cols
--Type <return> for more, q to quit, c to continue without paging--    # 67 cols
--Type <ret> for more, q to quit, c to continue without paging--       # 64 cols

> diff --git a/gdb/testsuite/gdb.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp
> index ab60a0cba0..81ea61f7ce 100644
> --- a/gdb/testsuite/gdb.cp/static-print-quit.exp
> +++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
> @@ -41,14 +41,7 @@ gdb_test_multiple "print c" $test {
>  
>  set test "print c - q <return>"
>  gdb_test_multiple "" $test {
> -    -re " to continue, or q <return>" {
> -	pass $test
> -    }
> -}
> -
> -set test "print c - to quit"
> -gdb_test_multiple "" $test {
> -    -re " to quit---$" {
> +    -re " continue without paging---$" {
>  	pass $test
>      }
>  }

This looks like it was split in two for some reason:

commit 7db6f30f9d4707b04e7292d7d8bfa5d37eaff67f
Author:     Jan Kratochvil <jan.kratochvil@redhat.com>
AuthorDate: Fri May 6 13:38:35 2011 +0000

    gdb/testsuite/
            Fix a race.
            * gdb.cp/static-print-quit.exp (print c): Split to ...
            (print c - <return>, print c - q <return>, print c - to quit):
            ... these.  Make the testfile untested on gdb-7.1.


Did you look up the patch submission, see if it still makes sense?


> diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
> index cee195f315..8b296582a9 100644
> --- a/gdb/testsuite/gdb.python/python.exp
> +++ b/gdb/testsuite/gdb.python/python.exp
> @@ -139,33 +139,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 <return>" {
> -	exp_continue
> -    }
> -    -re " to continue, or q <return>" {
> -	exp_continue
> -    }
> -    -re " to quit---$" {
> -	pass $test
> -    }

So I'm wondering whether this was split for a
similar reason.  Likewise other testsuite spots in the patch.

> diff --git a/gdb/utils.c b/gdb/utils.c
> index b957b0dc5c..4478c52166 100644
> --- a/gdb/utils.c
> +++ b/gdb/utils.c
> @@ -1282,6 +1282,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;

Use bool?

> +
>  /* 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
> @@ -1466,12 +1470,14 @@ prompt_for_continue (void)
>       prompt_for_continue_wait_time.  */
>    using namespace std::chrono;
>    steady_clock::time_point prompt_started = steady_clock::now ();
> +  int disable_pagination = pagination_disabled_for_command;

Ditto.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-09 19:51 ` Pedro Alves
@ 2018-05-09 21:28   ` Tom Tromey
  2018-05-10  0:23     ` Pedro Alves
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2018-05-09 21:28 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> I gave the patch a quick try, and I have to say that it looks a
Pedro> bit odd to me that the pager prompt takes two lines:

Pedro> ---Type <return> to continue, q <return> to quit, or c <return> to
Pedro>    continue without paging---

Pedro> I'm wondering whether we can shorten that, to, say:

Pedro> ---Type <return> for more, q to quit, c to continue without paging---

Yeah, I think that would be better.

The Emacs docs write <RET> for return.  So maybe:

Pedro> --Type <ret> for more, q to quit, c to continue without paging--       # 64 cols

Though I guess I would tend to add a couple of spaces, so:

-- Type <RET> for more, q to quit, c to continue without paging --       # 66 cols


I would like to get the spelling worked out before updating the patch.

Pedro> Did you look up the patch submission, see if it still makes sense?

Nope, but if we shorten the text then perhaps the change won't be
needed.

>> +static int pagination_disabled_for_command;

Pedro> Use bool?

I made this change locally.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-09 21:28   ` Tom Tromey
@ 2018-05-10  0:23     ` Pedro Alves
  2018-05-27 15:20       ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2018-05-10  0:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 05/09/2018 10:28 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> I gave the patch a quick try, and I have to say that it looks a
> Pedro> bit odd to me that the pager prompt takes two lines:
> 
> Pedro> ---Type <return> to continue, q <return> to quit, or c <return> to
> Pedro>    continue without paging---
> 
> Pedro> I'm wondering whether we can shorten that, to, say:
> 
> Pedro> ---Type <return> for more, q to quit, c to continue without paging---
> 
> Yeah, I think that would be better.
> 
> The Emacs docs write <RET> for return.  So maybe:
> 
> Pedro> --Type <ret> for more, q to quit, c to continue without paging--       # 64 cols
> 
> Though I guess I would tend to add a couple of spaces, so:
> 
> -- Type <RET> for more, q to quit, c to continue without paging --       # 66 cols

That's fine with me.  I suspect that the "---" wrapping without
spaces might have been inspired by some Unix /usr/bin/more
implementation, because util-linux's 'more' prints "--More-- "
by default.

> I would like to get the spelling worked out before updating the patch.
> 
> Pedro> Did you look up the patch submission, see if it still makes sense?
> 
> Nope, but if we shorten the text then perhaps the change won't be
> needed.

A racy test won't usually be an issue with size of the text, but
about how the regexps might match differently depending
on how much the expect buffer happens to get filled with.

I found the original submission, here:

  https://sourceware.org/ml/gdb-patches/2011-05/msg00150.html

which points at:

 ~~~~~~~~~~~~
 However, when using read1(), the "<return>" part matches with
 this snippet from lib/gdb.exp:
 
          "<return>" {
             send_gdb "\n"
             perror "Window too small."
             fail "$message"
             ...
 ~~~~~~~~~~~~

However, someone *cough* changed that "<return>" to
$pagination_prompt instead:

	-re "$pagination_prompt" {
	    send_gdb "\n"
	    perror "Window too small."
	    fail "$message"

in:

commit c3f814a14336b9d395f3abad739592929e2faaa0
Author:     Pedro Alves <palves@redhat.com>
AuthorDate: Fri Jul 25 10:07:38 2014 +0100

    Fix paginate-*.exp races

so it looks like the split is really no longer necessary.

A brief passage about this in the commit log would be nice,
so that we have a history link in case we need to revisit.

Please confirm that the affected tests pass cleanly with
make check-read1, just to make sure.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-10  0:23     ` Pedro Alves
@ 2018-05-27 15:20       ` Tom Tromey
  2018-05-27 21:01         ` Eli Zaretskii
  2018-05-28 18:57         ` Pedro Alves
  0 siblings, 2 replies; 12+ messages in thread
From: Tom Tromey @ 2018-05-27 15:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> That's fine with me.  I suspect that the "---" wrapping without
Pedro> spaces might have been inspired by some Unix /usr/bin/more
Pedro> implementation, because util-linux's 'more' prints "--More-- "
Pedro> by default.

In the end I removed the spaces.

Pedro> commit c3f814a14336b9d395f3abad739592929e2faaa0
Pedro> Author:     Pedro Alves <palves@redhat.com>
Pedro> AuthorDate: Fri Jul 25 10:07:38 2014 +0100
Pedro>     Fix paginate-*.exp races

Pedro> so it looks like the split is really no longer necessary.

With the new text it was sufficient to just update what was expected in
this test.  So I didn't end up backing out the old race fix.  It seemed
pretty safe to just leave it alone.

Here's the latest version.

Tom

commit ccd0b974d93f5a87b33fdfb38eea7ed12b00fca0
Author: Tom Tromey <tom@tromey.com>
Date:   Wed Apr 25 08:52:00 2018 -0600

    Add "continue" response to pager
    
    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.
    
    I think this version addresses all review comments from versions 1-3.
    
    Tested by the buildbot.
    
    ChangeLog
    2018-05-26  Tom Tromey  <tom@tromey.com>
    
            PR cli/12326:
            * NEWS: Add entry about pager.
            * 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.
    
    doc/ChangeLog
    2018-05-26  Tom Tromey  <tom@tromey.com>
    
            PR cli/12326:
            * gdb.texinfo (Screen Size): Document "c" response to pagination
            prompt.
    
    testsuite/ChangeLog
    2018-05-26  Tom Tromey  <tom@tromey.com>
    
            PR cli/12326:
            * gdb.cp/static-print-quit.exp: Update.
            * lib/gdb.exp (pagination_prompt): Update.
            * gdb.base/page.exp: Use pagination_prompt.  Add new tests.
            * gdb.python/python.exp: Use pagination_prompt.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 33c6a712a8..8d2863524f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2018-05-26  Tom Tromey	<tom@tromey.com>
+
+	PR cli/12326:
+	* NEWS: Add entry about pager.
+	* 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.
+
 2018-05-25  Tom Tromey  <tom@tromey.com>
 
 	* value.c (value::location): Initialize.
diff --git a/gdb/NEWS b/gdb/NEWS
index cef558039e..265f52c748 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,9 @@
 
 *** Changes since GDB 8.1
 
+* The pager now allows a "c" response, meaning to disable the pager
+  for the rest of the current command.
+
 * The commands 'info variables/functions/types' now show the source line
   numbers of symbol definitions when available.
 
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 798ff3715e..511debe8ff 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-26  Tom Tromey	<tom@tromey.com>
+
+	PR cli/12326:
+	* gdb.texinfo (Screen Size): Document "c" response to pagination
+	prompt.
+
 2018-05-04  Tom Tromey  <tom@tromey.com>
 
 	PR python/22731:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 62ba1d25a4..f1c879098c 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -23877,8 +23877,9 @@ Print ten commands just after the commands last printed.
 Certain commands to @value{GDBN} may produce large amounts of
 information output to the screen.  To help you read all of it,
 @value{GDBN} pauses and asks you for input at the end of each page of
-output.  Type @key{RET} when you want to continue the output, or @kbd{q}
-to discard the remaining output.  Also, the screen width setting
+output.  Type @key{RET} when you want to continue the output, @kbd{q}
+to discard the remaining output, or @kbd{c} to disable paging for the
+rest of the current command.  Also, the screen width setting
 determines when to wrap lines of output.  Depending on what is being
 printed, @value{GDBN} tries to break the line at a readable place,
 rather than simply letting it overflow onto the following line.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b2938b1bf1..ef2cd6b53d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2018-05-26  Tom Tromey	<tom@tromey.com>
+
+	PR cli/12326:
+	* gdb.cp/static-print-quit.exp: Update.
+	* lib/gdb.exp (pagination_prompt): Update.
+	* gdb.base/page.exp: Use pagination_prompt.  Add new tests.
+	* gdb.python/python.exp: Use pagination_prompt.
+
 2018-05-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	PR gdb/23203
diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp
index 47db79fb8e..f7557d3b94 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 <return> to continue, or q <return> to quit---" {
+	".*$pagination_prompt" {
     "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" \
+    ".*$pagination_prompt" {
+	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.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp
index ab60a0cba0..f8c94a9028 100644
--- a/gdb/testsuite/gdb.cp/static-print-quit.exp
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -29,10 +29,10 @@ gdb_test_no_output "set height 2"
 
 set test "print c - <return>"
 gdb_test_multiple "print c" $test {
-    -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type <return>" {
+    -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n--Type <RET>" {
 	pass $test
     }
-    -re "\r\n---Type <return>" {
+    -re "\r\n--Type <RET>" {
 	# gdb-7.1 did not crash with this testcase but it had the same bug.
 	untested "bug does not reproduce"
 	return 0
@@ -41,14 +41,14 @@ gdb_test_multiple "print c" $test {
 
 set test "print c - q <return>"
 gdb_test_multiple "" $test {
-    -re " to continue, or q <return>" {
+    -re " to continue, q to quit, " {
 	pass $test
     }
 }
 
-set test "print c - to quit"
+set test "print c - remainder"
 gdb_test_multiple "" $test {
-    -re " to quit---$" {
+    -re "c to continue without paging--$" {
 	pass $test
     }
 }
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index f6bf93add0..b921b829fd 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -142,33 +142,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 <return>" {
-	exp_continue
-    }
-    -re " to continue, or q <return>" {
-	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 \
+    ".*$pagination_prompt" \
+    $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 <return>" {
-	exp_continue
-    }
-    -re " to continue, or q <return>" {
-	exp_continue
-    }
-    -re " to quit---$" {
-	pass $test
-    }
-}
+send_gdb "python print (\"\\n\" * $lines)\n"
+gdb_expect_list $test \
+    ".*$pagination_prompt" \
+    $arglist
 gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q"
 
 gdb_test_no_output "set height 0"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ee66a38e08..65dd1d5afd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -82,7 +82,8 @@ if ![info exists gdb_prompt] then {
 }
 
 # A regexp that matches the pagination prompt.
-set pagination_prompt [string_to_regexp "---Type <return> to continue, or q <return> to quit---"]
+set pagination_prompt \
+    "--Type <RET> to continue, q to quit, c to continue without paging--"
 
 # The variable fullname_syntax_POSIX is a regexp which matches a POSIX 
 # absolute path ie. /foo/ 
diff --git a/gdb/utils.c b/gdb/utils.c
index a2e933bc8d..9383eadd02 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1283,6 +1283,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 bool 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
@@ -1467,12 +1471,14 @@ prompt_for_continue (void)
      prompt_for_continue_wait_time.  */
   using namespace std::chrono;
   steady_clock::time_point prompt_started = steady_clock::now ();
+  bool disable_pagination = pagination_disabled_for_command;
 
   if (annotation_level > 1)
     printf_unfiltered (("\n\032\032pre-prompt-for-continue\n"));
 
   strcpy (cont_prompt,
-	  "---Type <return> to continue, or q <return> to quit---");
+	  "--Type <RET> to continue, q to quit, "
+	  "c to continue without paging--");
   if (annotation_level > 1)
     strcat (cont_prompt, "\n\032\032prompt-for-continue\n");
 
@@ -1502,11 +1508,14 @@ prompt_for_continue (void)
       if (p[0] == 'q')
 	/* Do not call quit here; there is no possibility of SIGINT.  */
 	throw_quit ("Quit");
+      if (p[0] == 'c')
+	disable_pagination = true;
     }
 
   /* Now we have to do this again, so that GDB will know that it doesn't
      need to save the ---Type <return>--- 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.  */
 }
@@ -1536,6 +1545,7 @@ reinitialize_more_filter (void)
 {
   lines_printed = 0;
   chars_printed = 0;
+  pagination_disabled_for_command = false;
 }
 
 /* Indicate that if the next sequence of characters overflows the line,
@@ -1680,6 +1690,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
@@ -1696,8 +1707,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')
@@ -1737,8 +1751,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.  */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-27 15:20       ` Tom Tromey
@ 2018-05-27 21:01         ` Eli Zaretskii
  2018-05-28 18:57         ` Pedro Alves
  1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2018-05-27 21:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: palves, gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Sat, 26 May 2018 23:14:14 -0600
> 
> commit ccd0b974d93f5a87b33fdfb38eea7ed12b00fca0
> Author: Tom Tromey <tom@tromey.com>
> Date:   Wed Apr 25 08:52:00 2018 -0600
> 
>     Add "continue" response to pager
>     
>     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.
>     
>     I think this version addresses all review comments from versions 1-3.
>     
>     Tested by the buildbot.
>     
>     ChangeLog
>     2018-05-26  Tom Tromey  <tom@tromey.com>
>     
>             PR cli/12326:
>             * NEWS: Add entry about pager.
>             * 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.
>     
>     doc/ChangeLog
>     2018-05-26  Tom Tromey  <tom@tromey.com>
>     
>             PR cli/12326:
>             * gdb.texinfo (Screen Size): Document "c" response to pagination
>             prompt.
>     
>     testsuite/ChangeLog
>     2018-05-26  Tom Tromey  <tom@tromey.com>
>     
>             PR cli/12326:
>             * gdb.cp/static-print-quit.exp: Update.
>             * lib/gdb.exp (pagination_prompt): Update.
>             * gdb.base/page.exp: Use pagination_prompt.  Add new tests.
>             * gdb.python/python.exp: Use pagination_prompt.

Thanks, this is okay for the documentation parts.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-27 15:20       ` Tom Tromey
  2018-05-27 21:01         ` Eli Zaretskii
@ 2018-05-28 18:57         ` Pedro Alves
  2018-05-29  9:03           ` Tom Tromey
  1 sibling, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2018-05-28 18:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 05/27/2018 06:14 AM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> That's fine with me.  I suspect that the "---" wrapping without
> Pedro> spaces might have been inspired by some Unix /usr/bin/more
> Pedro> implementation, because util-linux's 'more' prints "--More-- "
> Pedro> by default.
> 
> In the end I removed the spaces.
> 
> Pedro> commit c3f814a14336b9d395f3abad739592929e2faaa0
> Pedro> Author:     Pedro Alves <palves@redhat.com>
> Pedro> AuthorDate: Fri Jul 25 10:07:38 2014 +0100
> Pedro>     Fix paginate-*.exp races
> 
> Pedro> so it looks like the split is really no longer necessary.
> 
> With the new text it was sufficient to just update what was expected in
> this test.  So I didn't end up backing out the old race fix.  It seemed
> pretty safe to just leave it alone.

That's fine with me (though you're removing it in the
gdb.python/ tests AFAICT).

> commit ccd0b974d93f5a87b33fdfb38eea7ed12b00fca0
> Author: Tom Tromey <tom@tromey.com>
> Date:   Wed Apr 25 08:52:00 2018 -0600
> 
>     Add "continue" response to pager

...

>     
>     I think this version addresses all review comments from versions 1-3.

I'd suggest removing this sentence before pushing.

>     
>     Tested by the buildbot.

> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index ee66a38e08..65dd1d5afd 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -82,7 +82,8 @@ if ![info exists gdb_prompt] then {
>  }
>  
>  # A regexp that matches the pagination prompt.
> -set pagination_prompt [string_to_regexp "---Type <return> to continue, or q <return> to quit---"]
> +set pagination_prompt \
> +    "--Type <RET> to continue, q to quit, c to continue without paging--"

Hmm, I'm a little surprised at the reversion to say "to continue"
instead of "for more" as in the earlier suggestions:

   "--Type <RET> for more, q to quit, c to continue without paging--"
vs
   "--Type <RET> to continue, q to quit, c to continue without paging--"

I had suggested "for more" for two reasons:

 - it's shorter
 - avoids ambiguity in the saying "continue" twice

It's not a big deal, but since you didn't comment on that,
I can't be sure whether you changed it back on purpose
or by accident, hence I'm speaking up.  :-)

Otherwise it LGTM.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-28 18:57         ` Pedro Alves
@ 2018-05-29  9:03           ` Tom Tromey
  2018-05-29 17:04             ` Pedro Alves
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2018-05-29  9:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> With the new text it was sufficient to just update what was expected in
>> this test.  So I didn't end up backing out the old race fix.  It seemed
>> pretty safe to just leave it alone.

Pedro> That's fine with me (though you're removing it in the
Pedro> gdb.python/ tests AFAICT).

In this version I've reverted that as well.

Pedro> Hmm, I'm a little surprised at the reversion to say "to continue"
Pedro> instead of "for more" as in the earlier suggestions:
Pedro>    "--Type <RET> for more, q to quit, c to continue without paging--"
Pedro> vs
Pedro>    "--Type <RET> to continue, q to quit, c to continue without paging--"

Pedro> I had suggested "for more" for two reasons:
Pedro>  - it's shorter
Pedro>  - avoids ambiguity in the saying "continue" twice

Pedro> It's not a big deal, but since you didn't comment on that,
Pedro> I can't be sure whether you changed it back on purpose
Pedro> or by accident, hence I'm speaking up.  :-)

I think I just didn't notice that detail, or if I did, I forgot at some
point along the way.

Here's a new version.

Tom

commit 0510dda7a558fa3255d6768262b934c101ea526f
Author: Tom Tromey <tom@tromey.com>
Date:   Wed Apr 25 08:52:00 2018 -0600

    Add "continue" response to pager
    
    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.
    
    Tested by the buildbot.
    
    ChangeLog
    2018-05-28  Tom Tromey  <tom@tromey.com>
    
            PR cli/12326:
            * NEWS: Add entry about pager.
            * 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.
    
    doc/ChangeLog
    2018-05-28  Tom Tromey  <tom@tromey.com>
    
            PR cli/12326:
            * gdb.texinfo (Screen Size): Document "c" response to pagination
            prompt.
    
    testsuite/ChangeLog
    2018-05-28  Tom Tromey  <tom@tromey.com>
    
            PR cli/12326:
            * gdb.cp/static-print-quit.exp: Update.
            * lib/gdb.exp (pagination_prompt): Update.
            * gdb.base/page.exp: Use pagination_prompt.  Add new tests.
            * gdb.python/python.exp: Update.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 98fb9551269..73b5638b71e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2018-05-28  Tom Tromey	<tom@tromey.com>
+
+	PR cli/12326:
+	* NEWS: Add entry about pager.
+	* 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.
+
 2018-05-27  Tom Tromey  <tom@tromey.com>
 
 	* Makefile.in (DEPFILES): Don't reference REMOTE_OBS.
diff --git a/gdb/NEWS b/gdb/NEWS
index cef558039ed..265f52c748d 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,9 @@
 
 *** Changes since GDB 8.1
 
+* The pager now allows a "c" response, meaning to disable the pager
+  for the rest of the current command.
+
 * The commands 'info variables/functions/types' now show the source line
   numbers of symbol definitions when available.
 
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 798ff3715ed..f61c70f24c3 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-28  Tom Tromey	<tom@tromey.com>
+
+	PR cli/12326:
+	* gdb.texinfo (Screen Size): Document "c" response to pagination
+	prompt.
+
 2018-05-04  Tom Tromey  <tom@tromey.com>
 
 	PR python/22731:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 62ba1d25a4c..f1c879098cf 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -23877,8 +23877,9 @@ Print ten commands just after the commands last printed.
 Certain commands to @value{GDBN} may produce large amounts of
 information output to the screen.  To help you read all of it,
 @value{GDBN} pauses and asks you for input at the end of each page of
-output.  Type @key{RET} when you want to continue the output, or @kbd{q}
-to discard the remaining output.  Also, the screen width setting
+output.  Type @key{RET} when you want to continue the output, @kbd{q}
+to discard the remaining output, or @kbd{c} to disable paging for the
+rest of the current command.  Also, the screen width setting
 determines when to wrap lines of output.  Depending on what is being
 printed, @value{GDBN} tries to break the line at a readable place,
 rather than simply letting it overflow onto the following line.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b2938b1bf1d..aad72d0596e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2018-05-28  Tom Tromey	<tom@tromey.com>
+
+	PR cli/12326:
+	* gdb.cp/static-print-quit.exp: Update.
+	* lib/gdb.exp (pagination_prompt): Update.
+	* gdb.base/page.exp: Use pagination_prompt.  Add new tests.
+	* gdb.python/python.exp: Update.
+
 2018-05-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	PR gdb/23203
diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp
index 47db79fb8e4..f7557d3b94b 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 <return> to continue, or q <return> to quit---" {
+	".*$pagination_prompt" {
     "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" \
+    ".*$pagination_prompt" {
+	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.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp
index ab60a0cba0f..22b0cf6cb97 100644
--- a/gdb/testsuite/gdb.cp/static-print-quit.exp
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -29,10 +29,10 @@ gdb_test_no_output "set height 2"
 
 set test "print c - <return>"
 gdb_test_multiple "print c" $test {
-    -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type <return>" {
+    -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n--Type <RET>" {
 	pass $test
     }
-    -re "\r\n---Type <return>" {
+    -re "\r\n--Type <RET>" {
 	# gdb-7.1 did not crash with this testcase but it had the same bug.
 	untested "bug does not reproduce"
 	return 0
@@ -41,14 +41,14 @@ gdb_test_multiple "print c" $test {
 
 set test "print c - q <return>"
 gdb_test_multiple "" $test {
-    -re " to continue, or q <return>" {
+    -re " for more, q to quit, " {
 	pass $test
     }
 }
 
-set test "print c - to quit"
+set test "print c - remainder"
 gdb_test_multiple "" $test {
-    -re " to quit---$" {
+    -re "c to continue without paging--$" {
 	pass $test
     }
 }
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index f6bf93add0d..26c7b6320db 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -143,13 +143,13 @@ gdb_test_no_output "set height $lines"
 
 set test "verify pagination beforehand"
 gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
-    -re "---Type <return>" {
+    -re "--Type <RET>" {
 	exp_continue
     }
-    -re " to continue, or q <return>" {
+    -re " for more, q to quit" {
 	exp_continue
     }
-    -re " to quit---$" {
+    -re ", c to continue without paging--$" {
 	pass $test
     }
 }
@@ -159,13 +159,13 @@ gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=T
 
 set test "verify pagination afterwards"
 gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
-    -re "---Type <return>" {
+    -re "--Type <RET>" {
 	exp_continue
     }
-    -re " to continue, or q <return>" {
+    -re " for more, q to quit" {
 	exp_continue
     }
-    -re " to quit---$" {
+    -re ", c to continue without paging--$" {
 	pass $test
     }
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ee66a38e08f..aef580b04d3 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -82,7 +82,8 @@ if ![info exists gdb_prompt] then {
 }
 
 # A regexp that matches the pagination prompt.
-set pagination_prompt [string_to_regexp "---Type <return> to continue, or q <return> to quit---"]
+set pagination_prompt \
+    "--Type <RET> for more, q to quit, c to continue without paging--"
 
 # The variable fullname_syntax_POSIX is a regexp which matches a POSIX 
 # absolute path ie. /foo/ 
diff --git a/gdb/utils.c b/gdb/utils.c
index a2e933bc8dc..dd66d725fcb 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1283,6 +1283,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 bool 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
@@ -1467,12 +1471,14 @@ prompt_for_continue (void)
      prompt_for_continue_wait_time.  */
   using namespace std::chrono;
   steady_clock::time_point prompt_started = steady_clock::now ();
+  bool disable_pagination = pagination_disabled_for_command;
 
   if (annotation_level > 1)
     printf_unfiltered (("\n\032\032pre-prompt-for-continue\n"));
 
   strcpy (cont_prompt,
-	  "---Type <return> to continue, or q <return> to quit---");
+	  "--Type <RET> for more, q to quit, "
+	  "c to continue without paging--");
   if (annotation_level > 1)
     strcat (cont_prompt, "\n\032\032prompt-for-continue\n");
 
@@ -1502,11 +1508,14 @@ prompt_for_continue (void)
       if (p[0] == 'q')
 	/* Do not call quit here; there is no possibility of SIGINT.  */
 	throw_quit ("Quit");
+      if (p[0] == 'c')
+	disable_pagination = true;
     }
 
   /* Now we have to do this again, so that GDB will know that it doesn't
      need to save the ---Type <return>--- 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.  */
 }
@@ -1536,6 +1545,7 @@ reinitialize_more_filter (void)
 {
   lines_printed = 0;
   chars_printed = 0;
+  pagination_disabled_for_command = false;
 }
 
 /* Indicate that if the next sequence of characters overflows the line,
@@ -1680,6 +1690,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
@@ -1696,8 +1707,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')
@@ -1737,8 +1751,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.  */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-29  9:03           ` Tom Tromey
@ 2018-05-29 17:04             ` Pedro Alves
  2018-06-04 21:47               ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2018-05-29 17:04 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 05/29/2018 03:52 AM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
>>> With the new text it was sufficient to just update what was expected in
>>> this test.  So I didn't end up backing out the old race fix.  It seemed
>>> pretty safe to just leave it alone.
> 
> Pedro> That's fine with me (though you're removing it in the
> Pedro> gdb.python/ tests AFAICT).
> 
> In this version I've reverted that as well.

Thanks.

> Here's a new version.

LGTM.  One suggestion in the docs below.  Sorry about being picky...

> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 62ba1d25a4c..f1c879098cf 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -23877,8 +23877,9 @@ Print ten commands just after the commands last printed.
>  Certain commands to @value{GDBN} may produce large amounts of
>  information output to the screen.  To help you read all of it,
>  @value{GDBN} pauses and asks you for input at the end of each page of
> -output.  Type @key{RET} when you want to continue the output, or @kbd{q}
> -to discard the remaining output.  Also, the screen width setting
> +output.  Type @key{RET} when you want to continue the output, @kbd{q}
> +to discard the remaining output, or @kbd{c} to disable paging for the
> +rest of the current command.  Also, the screen width setting

I'd suggest saying something here closer to gdb's output.  For example,
above, "continue the output" doesn't suggest that it's only one more
page, and, using the verb "continue" for the "c" key I think makes it
easier to memorize / understand.  Like so:

 Type @key{RET} when you want to see one more page of output, @kbd{q}
 to discard the remaining output, or @kbd{c} to continue without paging
 for the rest of the current command.

No need to post a new patch for that, if Eli's OK with it.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-05-29 17:04             ` Pedro Alves
@ 2018-06-04 21:47               ` Tom Tromey
  2018-06-05 14:44                 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2018-06-04 21:47 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches, eliz

Hi Eli, not sure if you saw Pedro's question in this thread:

Pedro> I'd suggest saying something here closer to gdb's output.  For example,
Pedro> above, "continue the output" doesn't suggest that it's only one more
Pedro> page, and, using the verb "continue" for the "c" key I think makes it
Pedro> easier to memorize / understand.  Like so:

Pedro>  Type @key{RET} when you want to see one more page of output, @kbd{q}
Pedro>  to discard the remaining output, or @kbd{c} to continue without paging
Pedro>  for the rest of the current command.

Pedro> No need to post a new patch for that, if Eli's OK with it.

thanks,
Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFA v2] Add "continue" response to pager
  2018-06-04 21:47               ` Tom Tromey
@ 2018-06-05 14:44                 ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2018-06-05 14:44 UTC (permalink / raw)
  To: Tom Tromey; +Cc: palves, gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org, eliz@gnu.org
> Date: Mon, 04 Jun 2018 15:47:52 -0600
> 
> Hi Eli, not sure if you saw Pedro's question in this thread:
> 
> Pedro> I'd suggest saying something here closer to gdb's output.  For example,
> Pedro> above, "continue the output" doesn't suggest that it's only one more
> Pedro> page, and, using the verb "continue" for the "c" key I think makes it
> Pedro> easier to memorize / understand.  Like so:
> 
> Pedro>  Type @key{RET} when you want to see one more page of output, @kbd{q}
> Pedro>  to discard the remaining output, or @kbd{c} to continue without paging
> Pedro>  for the rest of the current command.
> 
> Pedro> No need to post a new patch for that, if Eli's OK with it.

I'm OK with that.  Sorry for missing the cue.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-06-05 14:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-25 14:52 [RFA v2] Add "continue" response to pager Tom Tromey
2018-05-09 15:43 ` Tom Tromey
2018-05-09 19:51 ` Pedro Alves
2018-05-09 21:28   ` Tom Tromey
2018-05-10  0:23     ` Pedro Alves
2018-05-27 15:20       ` Tom Tromey
2018-05-27 21:01         ` Eli Zaretskii
2018-05-28 18:57         ` Pedro Alves
2018-05-29  9:03           ` Tom Tromey
2018-05-29 17:04             ` Pedro Alves
2018-06-04 21:47               ` Tom Tromey
2018-06-05 14:44                 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).