From 21a527dfc85d62c9e90c65ac4076f517a6b76a48 Mon Sep 17 00:00:00 2001 From: Enze Li Date: Sun, 12 Jun 2022 13:22:25 +0800 Subject: 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. --- gdb/language.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gdb/language.h') diff --git a/gdb/language.h b/gdb/language.h index f288500..c6812c5 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -282,6 +282,13 @@ struct language_defn virtual const char *natural_name () const = 0; + /* Digit separator of the language. */ + + virtual const char *get_digit_separator () const + { + return " "; + } + /* Return a vector of file extensions for this language. The extension must include the ".", like ".c". If this language doesn't need to provide any filename extensions, this may be an empty vector (which is -- cgit v1.1