This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Make 'show width/height' display "unlimited" when capped for readline
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 27 Feb 2019 18:49:14 -0000
- Subject: [binutils-gdb] Make 'show width/height' display "unlimited" when capped for readline
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8ed252144a29fb6370b828d84419d5c59d23dae2
commit 8ed252144a29fb6370b828d84419d5c59d23dae2
Author: Pedro Alves <palves@redhat.com>
Date: Wed Feb 27 18:48:36 2019 +0000
Make 'show width/height' display "unlimited" when capped for readline
When we cap the height/width sizes before passing to readline, tweak
the corresponding command variable to show "unlimited":
(gdb) set height 0x8000
(gdb) show height
Number of lines gdb thinks are in a page is unlimited.
Instead of the current output:
(gdb) set height 0x8000
(gdb) show height
Number of lines gdb thinks are in a page is 32768.
gdb/ChangeLog:
2019-02-27 Pedro Alves <palves@redhat.com>
* utils.c (set_screen_size): When we cap the height/width sizes,
tweak the corresponding command variable to show "unlimited":
gdb/testsuite/ChangeLog:
2019-02-27 Pedro Alves <palves@redhat.com>
* gdb.base/page.exp: Add tests for "set/show width/height" with
"infinite" values.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.base/page.exp | 24 ++++++++++++++++++++++++
gdb/utils.c | 10 ++++++++--
4 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 02602b2..1dc6356 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-27 Pedro Alves <palves@redhat.com>
+
+ * utils.c (set_screen_size): When we cap the height/width sizes,
+ tweak the corresponding command variable to show "unlimited":
+
2019-02-27 Saagar Jha <saagar@saagarjha.com>
Pedro Alves <palves@redhat.com>
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 477165a..b5177c7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-27 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/page.exp: Add tests for "set/show width/height" with
+ "infinite" values.
+
2019-02-27 Tom Tromey <tromey@adacore.com>
* lib/gdb.exp (skip_python_tests_prompt): Don't check for Python
diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp
index 10ebf0d..8f1698c 100644
--- a/gdb/testsuite/gdb.base/page.exp
+++ b/gdb/testsuite/gdb.base/page.exp
@@ -94,6 +94,30 @@ gdb_expect_list "paged count for interrupt" \
gdb_test "q" "Quit" "quit while paging"
+# Check that width/height of sqrt(INT_MAX) is treated as unlimited, as
+# well as "0" and explicit "unlimited".
+foreach_with_prefix size {"0" "0x80000000" "unlimited"} {
+
+ # Alternate between "non-unlimited" values and "unlimited" values,
+ # to make sure we're not seeing stale internal state.
+
+ gdb_test "set width 200"
+ gdb_test "show width" \
+ "Number of characters gdb thinks are in a line is 200\\."
+
+ gdb_test "set height 200"
+ gdb_test "show height" \
+ "Number of lines gdb thinks are in a page is 200\\."
+
+ gdb_test "set width $size"
+ gdb_test "show width unlimited" \
+ "Number of characters gdb thinks are in a line is unlimited\\."
+
+ gdb_test "set height $size"
+ gdb_test "show height unlimited" \
+ "Number of lines gdb thinks are in a page is unlimited\\."
+}
+
gdb_exit
return 0
diff --git a/gdb/utils.c b/gdb/utils.c
index 069da23..60af31f 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1394,10 +1394,16 @@ set_screen_size (void)
const int sqrt_int_max = INT_MAX >> (sizeof (int) * 8 / 2);
if (rows <= 0 || rows > sqrt_int_max)
- rows = sqrt_int_max;
+ {
+ rows = sqrt_int_max;
+ lines_per_page = UINT_MAX;
+ }
if (cols <= 0 || cols > sqrt_int_max)
- cols = sqrt_int_max;
+ {
+ cols = sqrt_int_max;
+ chars_per_line = UINT_MAX;
+ }
/* Update Readline's idea of the terminal size. */
rl_set_screen_size (rows, cols);