From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0707E3858D33; Wed, 12 Apr 2023 11:15:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0707E3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681298127; bh=zMkEqDoNca3e34tvSXFIV6h6xZuKkztZczdRbV3cRRk=; h=From:To:Subject:Date:From; b=uC3WjnDRYiiGBQB8A2yXaAUI5JTK2a9MRLjmwTdafrePddiBjAG/jUFRHXhDnT96i n0WuoE8nZovDLYkkNG5AFEhDYPcHMSKm60x0c17HO9tsX+3gepDAfs4ct0lATbaiG0 a0aZxpQPLjm1SnQVKluRbxdlYInvqkvcCMy1oL+U= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug tui/30337] New: [gdb/tui] TUI in ansi terminal has one off width problem Date: Wed, 12 Apr 2023 11:15:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: tui X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30337 Bug ID: 30337 Summary: [gdb/tui] TUI in ansi terminal has one off width problem Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: tui Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- I. Terminal used I open a terminal, and can easily switch between maximized: ... $ echo $COLUMNS=20 118 $ echo $LINES 31 ... and non-maximized: .. $ echo $COLUMNS=20 78 $ echo $LINES 20 ... II. TERM=3Dxterm Now let's start gdb in TUI mode in maximized mode: ... $ gdb \ -ex "set tui border-kind ascii" \ -ex "maint set tui-resize-message on" \ -ex "tui enable" ... That looks as expected (not posting, rather big). Now let's resize to non-maximized: ... +--------------------------------------------------------------------------= --+ | = | | = | | = | | = | | = | | [ No Source Available ] = | | = | | = | | = | | = | +--------------------------------------------------------------------------= --+ None No process In: L?? PC: = ??=20 @@ resize done 0, size =3D 78x20 (gdb)=20 ... OK, that looks good as well. III. TERM=3Dansi Now, let's repeat this, but with TERM set to ansi, as we do in the testsuit= e. That looks ok, with the exception of "gdb)" appearing at the start of the l= ine, with the missing "(" glued to the end of the previous line. Now, let's resize again to non-maximized: ... +--------------------------------------------------------------------------= -|| [ No Source Available ]=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 |+-------------------------------------------------------------------------= --+No ne No process In: L?? PC: ?? | | | | | @@ resize done 0, size =3D 77x20 (gdb) ---------------------------------------------------------------------= -- ... Well, the result looks a bit garbled, and the resize reports 77 instead of = 78. I tracked this down to readline underreporting the screen size, due to _rl_term_autowrap =3D=3D 0. With this demonstrator patch: ... diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 008189eb99b..995355e9ecc 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -528,6 +528,8 @@ tui_resize_all (void) int screenheight, screenwidth; rl_get_screen_size (&screenheight, &screenwidth); + screenwidth++; + width_diff =3D screenwidth - tui_term_width (); height_diff =3D screenheight - tui_term_height (); if (height_diff || width_diff) ... we get instead the expected and non-garbled: ... +--------------------------------------------------------------------------= --+ | = | | = | | = | | = | | = | | [ No Source Available ] = | | = | | = | | = | | = | +--------------------------------------------------------------------------= --+ None No process In: L?? PC: ?? = @@ resize done 0, size =3D 78x20 (gdb)=20 ... The problem seems to be related to this comment in Term::resize: ... # Somehow the number of columns transmitted to gdb is one less=20= =20=20=20=20=20=20=20=20=20 # than what we request from expect. We hide this weird=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20 # details from the caller.=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 _do_resize $_rows $cols stty columns [expr {$_cols + 1}] < $::gdb_tty_name ... and indeed, after dropping the +1 in {$_cols + 1} the test passes (and ... without timeouts). --=20 You are receiving this mail because: You are on the CC list for the bug.=