[RFA v2] Add "continue" response to pager

Pedro Alves palves@redhat.com
Wed May 9 19:51:00 GMT 2018


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



More information about the Gdb-patches mailing list