From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 8EF933857341; Fri, 15 Apr 2022 17:53:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EF933857341 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Handle "set height 1" X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 1f0f8b5d9d9053c4d164d01c6915c2e6b8c6ea48 X-Git-Newrev: 111d19818a4a7c96c87e330c6c143fa03bb86819 Message-Id: <20220415175359.8EF933857341@sourceware.org> Date: Fri, 15 Apr 2022 17:53:59 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2022 17:53:59 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D111d19818a4a= 7c96c87e330c6c143fa03bb86819 commit 111d19818a4a7c96c87e330c6c143fa03bb86819 Author: Tom Tromey Date: Sat Jan 8 19:37:38 2022 -0700 Handle "set height 1" =20 PR cli/17151 points out that "set height 1" has pathological behavior in gdb. What I see is that gdb will endlessly print the pagination prompt. This patch takes a simple and expedient approach to a fix: pretend that the height is really 2. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D17151 Diff: --- gdb/testsuite/gdb.base/page.exp | 7 ++++--- gdb/utils.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.= exp index a38f1dd0c94..268777f8acb 100644 --- a/gdb/testsuite/gdb.base/page.exp +++ b/gdb/testsuite/gdb.base/page.exp @@ -121,6 +121,7 @@ foreach_with_prefix size {"0" "0x80000000" "unlimited"}= { gdb_test "set width -1" "integer -1 out of range" gdb_test "set height -1" "integer -1 out of range" =20 -gdb_exit -return 0 - +# A height of 1 used to cause pathological behavior -- it would +# endlessly prompt for paging without printing anything. +gdb_test_no_output "set height 1" +gdb_test "print 23" " =3D 23" diff --git a/gdb/utils.c b/gdb/utils.c index b7d5859d6b3..2465bf3a3ed 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1601,6 +1601,12 @@ pager_file::puts (const char *linebuffer) m_wrap_indent =3D 0; }); =20 + /* If the user does "set height 1" then the pager will exhibit weird + behavior. This is pathological, though, so don't allow it. */ + const unsigned int lines_allowed =3D (lines_per_page > 1 + ? lines_per_page - 1 + : 1); + /* Go through and output each character. Show line extension when this is necessary; prompt user for new page when this is necessary. */ @@ -1613,7 +1619,7 @@ pager_file::puts (const char *linebuffer) it here. */ if (pagination_enabled && !pagination_disabled_for_command - && lines_printed >=3D lines_per_page - 1) + && lines_printed >=3D lines_allowed) prompt_for_continue (); =20 while (*lineptr && *lineptr !=3D '\n') @@ -1690,7 +1696,7 @@ pager_file::puts (const char *linebuffer) this loop, so we must continue to check it here. */ if (pagination_enabled && !pagination_disabled_for_command - && lines_printed >=3D lines_per_page - 1) + && lines_printed >=3D lines_allowed) { prompt_for_continue (); did_paginate =3D true;