diff options
author | Enze Li <enze.li@hotmail.com> | 2022-06-12 13:22:25 +0800 |
---|---|---|
committer | Enze Li <enze.li@hotmail.com> | 2022-06-18 11:23:06 +0800 |
commit | 21a527dfc85d62c9e90c65ac4076f517a6b76a48 (patch) | |
tree | ead0bfa6f75933bf50a82b62d692d08504ab5e2a /gdb/testsuite/gdb.base/printcmds.exp | |
parent | 40d4cb8bccb0f46f34826564ea3502717ca8f0ce (diff) | |
download | gdb-21a527dfc85d62c9e90c65ac4076f517a6b76a48.zip gdb-21a527dfc85d62c9e90c65ac4076f517a6b76a48.tar.gz gdb-21a527dfc85d62c9e90c65ac4076f517a6b76a48.tar.bz2 |
gdb: Add new 'print nibbles' feature
Make an introduction of a new print setting that can be set by 'set
print nibbles [on|off]'. The default value if OFF, which can be changed
by user manually. Of course, 'show print nibbles' is also included in
the patch.
The new feature displays binary values by group, with four bits per
group. The motivation for this work is to enhance the readability of
binary values.
Here's a GDB session before this patch is applied.
(gdb) print var_a
$1 = 1230
(gdb) print/t var_a
$2 = 10011001110
With this patch applied, we can use the new print setting to display the
new form of the binary values.
(gdb) print var_a
$1 = 1230
(gdb) print/t var_a
$2 = 10011001110
(gdb) set print nibbles on
(gdb) print/t var_a
$3 = 0100 1100 1110
Tested on x86_64 openSUSE Tumbleweed.
Diffstat (limited to 'gdb/testsuite/gdb.base/printcmds.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/printcmds.exp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 3260c8a..04d390d 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -709,6 +709,48 @@ proc test_print_char_arrays {} { gdb_test_no_output "set print address off" "address off char arrays" } +proc test_print_nibbles {} { + gdb_test_no_output "set print nibbles on" + foreach lang_line { + {"ada" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"asm" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"c" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"c++" "0" "0" "0011'0000" "1111'1111" "1111" "0001" "1111'0000'1111"} + {"d" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"fortran" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"go" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"minimal" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"objective-c" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"opencl" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"pascal" "0" "0" "0011 0000" "1111 1111" "1111" "0001" "1111 0000 1111"} + {"rust" "0" "0" "0011_0000" "1111_1111" "1111" "0001" "1111_0000_1111"} + } { + set lang [lindex $lang_line 0] + set val1 [lindex $lang_line 1] + set val2 [lindex $lang_line 2] + set val3 [lindex $lang_line 3] + set val4 [lindex $lang_line 4] + set val5 [lindex $lang_line 5] + set val6 [lindex $lang_line 6] + set val7 [lindex $lang_line 7] + set val8 [lindex $lang_line 8] + + with_test_prefix "$lang" { + gdb_test_no_output "set language $lang" + gdb_test "p/t 0" $val1 + gdb_test "p/t 0x0" $val2 + gdb_test "p/t 0x30" $val3 + gdb_test "p/t 0xff" $val4 + gdb_test "p/t 0x0f" $val5 + gdb_test "p/t 0x01" $val6 + gdb_test "p/t 0xf0f" $val7 + gdb_test "p/t 0x70f" $val8 + gdb_test_no_output "set language auto" + } + } + gdb_test_no_output "set print nibbles off" +} + proc test_print_string_constants {} { global gdb_prompt @@ -1086,6 +1128,7 @@ test_print_int_arrays test_print_typedef_arrays test_artificial_arrays test_print_char_arrays +test_print_nibbles # We used to do the runto main here. test_print_string_constants test_print_array_constants |