Bug 30320 - [gdb/cli] lines_per_page not reset on "set height 0"
Summary: [gdb/cli] lines_per_page not reset on "set height 0"
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: cli (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-06 07:50 UTC by Tom de Vries
Modified: 2023-04-06 11:35 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments
tentative patch (1.18 KB, patch)
2023-04-06 08:07 UTC, Tom de Vries
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2023-04-06 07:50:08 UTC
I tested the following change:
...
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index bb4bd656471..a29fde6a7f4 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -216,8 +216,8 @@ if ![info exists INTERNAL_GDBFLAGS] {
        [join [list \
                   "-nw" \
                   "-nx" \
-                  {-iex "set height 0"} \
-                  {-iex "set width 0"}]]
+                  {-eiex "set height 0"} \
+                  {-eiex "set width 0"}]]
 
     # If DEBUGINFOD_URLS is set, gdb will try to download sources and
     # debug info for f.i. system libraries.  Prevent this.
...
and I ran into only one regression:
...
FAIL: gdb.base/paginate-execution-startup.exp: return: send \n to GDB
...

The passing case looks like this:
...
builtin_spawn /data/vries/gdb/leap-15-4/build/gdb/testsuite/../../gdb/gdb -nw -nx -iex set height 0 -iex set width 0 -data-directory /data/vries/gdb/leap-15-4/build/gdb/data-directory -ex set height 2 -ex start --args /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.base/paginate-execution-startup/paginate-execution-startup^M
GNU gdb (GDB) 14.0.50.20230405-git^M
Copyright (C) 2023 Free Software Foundation, Inc.^M
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>^M
This is free software: you are free to change and redistribute it.^M
There is NO WARRANTY, to the extent permitted by law.^M
Type "show copying" and "show warranty" for details.^M
This GDB was configured as "x86_64-pc-linux-gnu".^M
Type "show configuration" for configuration details.^M
For bug reporting instructions, please see:^M
<https://www.gnu.org/software/gdb/bugs/>.^M
Find the GDB manual and other documentation resources online at:^M
    <http://www.gnu.org/software/gdb/documentation/>.^M
^M
For help, type "help".^M
Type "apropos word" to search for commands related to "word"...^M
Reading symbols from /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.base/paginate-execution-startup/paginate-execution-startup...^M
--Type <RET> for more, q to quit, c to continue without paging--PASS: gdb.base/paginate-execution-startup.exp: return: run to pagination
^M
Temporary breakpoint 1 at 0x400512: file /data/vries/gdb/src/gdb/testsuite/gdb.base/paginate-execution-startup.c, line 29.^M
--Type <RET> for more, q to quit, c to continue without paging--^M
Starting program: /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.base/paginate-execution-startup/paginate-execution-startup ^M
^M
Temporary breakpoint 1, main () at /data/vries/gdb/src/gdb/testsuite/gdb.base/paginate-execution-startup.c:29^M
29        sleep (3);^M
(gdb) PASS: gdb.base/paginate-execution-startup.exp: return: send \n to GDB
...

And the failing case looks like this:
...
builtin_spawn /data/vries/gdb/leap-15-4/build/gdb/testsuite/../../gdb/gdb -nw -nx -eiex set height 0 -eiex set width 0 -data-directory /data/vries/gdb/leap-15-4/build/gdb/data-directory -ex set height 2 -ex start --args /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.base/paginate-execution-startup/paginate-execution-startup^M
GNU gdb (GDB) 14.0.50.20230405-git^M
Copyright (C) 2023 Free Software Foundation, Inc.^M
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>^M
This is free software: you are free to change and redistribute it.^M
There is NO WARRANTY, to the extent permitted by law.^M
Type "show copying" and "show warranty" for details.^M
This GDB was configured as "x86_64-pc-linux-gnu".^M
Type "show configuration" for configuration details.^M
For bug reporting instructions, please see:^M
<https://www.gnu.org/software/gdb/bugs/>.^M
Find the GDB manual and other documentation resources online at:^M
    <http://www.gnu.org/software/gdb/documentation/>.^M
^M
For help, type "help".^M
Type "apropos word" to search for commands related to "word"...^M
Reading symbols from /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.base/paginate-execution-startup/paginate-execution-startup...^M
Temporary breakpoint 1 at 0x400512: file /data/vries/gdb/src/gdb/testsuite/gdb.base/paginate-execution-startup.c, line 29.^M
--Type <RET> for more, q to quit, c to continue without paging--PASS: gdb.base/paginate-execution-startup.exp: return: run to pagination
^M
Starting program: /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.base/paginate-execution-startup/paginate-execution-startup ^M
^M
Temporary breakpoint 1, main () at /data/vries/gdb/src/gdb/testsuite/gdb.base/paginate-execution-startup.c:29^M
29        sleep (3);^M
(gdb) FAIL: gdb.base/paginate-execution-startup.exp: return: send \n to GDB
...

On obvious difference is in the amount of pagination prompts: 2 vs 1.

Looking in more detail, the first pagination prompt is in different locations.

Let's track pagination in both scenarios using watch lines_per_page and printed_lines.

First (passing, 2 pagination prompts):
- lines_per_page 0 -> 21
- lines_printed 0 -> 1 -> ... -> 15
- lines_per_page 21 -> 4294967295
- lines_per_page 4294967295 -> 2
- lines_printed 15 -> 0 (due to subsequent pagination prompt)
- pagination prompt, press enter
- lines_printed 0 -> 1
- lines_printed 1 -> 0 (due to subsequent pagination prompt)
- pagination prompt, press enter
- lines_printed 0 -> 1 -> 2 -> 3 -> 4

Second (failing, 1 pagination prompt):
- lines_per_page 0 -> 21
- lines_per_page 21 -> 4294967295
- lines_per_page 4294967295 -> 2
- lines_printed 0 -> 1
- lines_printed 1 -> 0 (due to subsequent pagination prompt)
- pagination prompt, press enter
- lines_printed 0 -> 1 -> 2 -> 3 -> 4

It seems odd to me that we don't reset lines_printed to 0 when doing "set height 0", in other words, setting pagination to "off".

In other words, I wonder if the failing scenario shows the correct behaviour.
Comment 1 Tom de Vries 2023-04-06 08:07:52 UTC
Created attachment 14805 [details]
tentative patch
Comment 2 Tom de Vries 2023-04-06 08:12:19 UTC
(In reply to Tom de Vries from comment #0)
> - lines_printed 0 -> 1 -> 2 -> 3 -> 4

FTR, I also investigated why we're not getting a pagination prompt here, despite lines_per_page being set to 2, but that's due to this code in fetch_inferior_event:
...
 /* Temporarily disable pagination.  Otherwise, the user would be                                             
     given an option to press 'q' to quit, which would cause an early                                          
     exit and could leave GDB in a half-baked state.  */
  scoped_restore save_pagination
    = make_scoped_restore (&pagination_enabled, false);
...