From: John Baldwin <jhb@FreeBSD.org>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb/cli] Add maint info screen
Date: Thu, 27 Apr 2023 13:49:48 -0700 [thread overview]
Message-ID: <c2c8fd76-733c-f7cf-c125-511ea88715f3@FreeBSD.org> (raw)
In-Reply-To: <20230417140906.25341-1-tdevries@suse.de>
On 4/17/23 7:09 AM, Tom de Vries via Gdb-patches wrote:
> While working on PRs tui/30337 and cli/30346 I came across various notions of
> width in gdb, as reported by gdb, readline, curses and the environment
> variables.
>
> As for gdb, readline and the environment variables, the way things work
> is:
> - Gdb asks readline to detect screen size,
> - readline sets the actual screen size in the environment variables
> COLUMNS and LINES,
> - readline reports back a screen size to gdb, which may have one column
> less than the actual screen size, to deal with lack of auto-wrap.
> This becomes gdb's notion of screen size (in other words the point where
> we can expect the gdb command line to wrap),
> - Gdb then explicitly sets readline's screen size, which readline itself may
> adjust to deal with lack of auto-wrap. This becomes readlines notion
> of screen size (well, internally the unadjusted one, but it'll report back
> the adjusted one).
>
> Add a command "maint info screen" that prints these notions, both for width
> and height.
>
> For TERM=xterm we have:
> ...
> $ TERM=xterm gdb -ex "maint info screen"
> Number of characters gdb thinks are in a line is 118.
> Number of characters readline reports are in a line is 118.
> Number of characters curses thinks are in a line is 118.
> Number of characters environment thinks are in a line is 118 (COLUMNS).
> Number of lines gdb thinks are in a page is 27.
> Number of lines readline reports are in a page is 27.
> Number of lines curses thinks are in a page is 27.
> Number of lines environment thinks are in a page is 27 (LINES).
> ...
>
> And for TERM=ansi:
> ...
> $ TERM=ansi gdb -ex "maint info screen"
> Number of characters gdb thinks are in a line is 117.
> Number of characters readline reports are in a line is 116.
> Number of characters curses thinks are in a line is 118.
> Number of characters environment thinks are in a line is 118 (COLUMNS).
> Number of lines gdb thinks are in a page is 27.
> Number of lines readline reports are in a page is 27.
> Number of lines curses thinks are in a page is 27.
> Number of lines environment thinks are in a page is 27 (LINES).
> ...
>
> [ The fact that we have "characters readline reports are in a line is 116" is
> is due to gdb making readline adjust twice for the lack of auto-wrap, this is
> PR cli/30346.
>
> Likewise we can detect tui/30337 by doing a resize in TUI mode and doing
> "maint info screen":
> ...
> Number of characters characters curses thinks are in a line is 110.
> Number of characters environment thinks are in a line is 111 (COLUMNS). ]
>
> And for TERM=ansi, with width and heigth set to 0:
> ...
> Number of characters gdb thinks are in a line is 4294967295 (unlimited).
> Number of characters readline reports are in a line is 32766 (unlimited - 1).
> Number of characters curses thinks are in a line is 118.
> Number of characters environment thinks are in a line is 118 (COLUMNS).
> Number of lines gdb thinks are in a page is 4294967295 (unlimited).
> Number of lines readline reports are in a page is 32767 (unlimited).
> Number of lines curses thinks are in a page is 27.
> Number of lines environment thinks are in a page is 27 (LINES).
> ...
>
> [ Note that when doing a resize by say maximizing or de-maximizing a terminal,
> all reported values are updated, except for curses when not in TUI mode.
>
> Maybe that means there's a bug. If not, then maybe we should not print
> the curses lines unless in TUI mode, or annotate those lines such that it's
> clear that the values may be not up-to-date. ]
>
> I'd like to use this command in the regression test for PR cli/30346.
>
> Tested on x86_64-linux.
I was building GDB in a Linux x86-64 VM that didn't have curses-dev installed and
this change causes GDB to no longer build:
CXX utils.o
/git/gdb/gdb/utils.c: In function ‘void maintenance_info_screen(const char*, int)’:
/git/gdb/gdb/utils.c:1310:14: error: ‘COLS’ was not declared in this scope
1310 | COLS);
| ^~~~
/git/gdb/gdb/utils.c:1331:15: error: ‘LINES’ was not declared in this scope; did you mean ‘LONGEST’?
1331 | LINES);
| ^~~~~
| LONGEST
make[2]: *** [Makefile:1920: utils.o] Error 1
--
John Baldwin
next prev parent reply other threads:[~2023-04-27 20:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 14:09 Tom de Vries
2023-04-17 17:19 ` Eli Zaretskii
2023-04-21 15:21 ` Tom de Vries
2023-04-21 13:54 ` Tom Tromey
2023-04-27 20:49 ` John Baldwin [this message]
2023-04-27 21:06 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2c8fd76-733c-f7cf-c125-511ea88715f3@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).