aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1991-04-23 17:27:49 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1991-04-23 17:27:49 +0000
commit19b7c2a49e3062561ebe11f000dc236a1d659c53 (patch)
tree4d17dc0d0dbaf5918eabe088f599ae711e9ba1c9
parent9872a49c27a0cced505d4d94d543c7d0b647186e (diff)
downloadgdb-19b7c2a49e3062561ebe11f000dc236a1d659c53.zip
gdb-19b7c2a49e3062561ebe11f000dc236a1d659c53.tar.gz
gdb-19b7c2a49e3062561ebe11f000dc236a1d659c53.tar.bz2
* printcmd.c (print_scalar_formatted): Add 't' for binary.
-rw-r--r--gdb/printcmd.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index b8bc298..663bfcd 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -382,6 +382,51 @@ print_scalar_formatted (valaddr, type, format, size, stream)
case 0:
abort ();
+ case 't':
+ /* Binary; 't' stands for "two". */
+ {
+ char bits[8*(sizeof val_long) + 1];
+ char *cp = bits;
+ int width;
+
+ if (!size)
+ width = 8*(sizeof val_long);
+ else
+ switch (size)
+ {
+ case 'b':
+ width = 8;
+ break;
+ case 'h':
+ width = 16;
+ break;
+ case 'w':
+ width = 32;
+ break;
+ case 'g':
+ width = 64;
+ break;
+ default:
+ error ("Undefined output size \"%c\".", size);
+ }
+
+ bits[width] = '\0';
+ while (width-- > 0)
+ {
+ bits[width] = (val_long & 1) ? '1' : '0';
+ val_long >>= 1;
+ }
+ if (!size)
+ {
+ while (*cp && *cp == '0')
+ cp++;
+ if (*cp == '\0')
+ cp--;
+ }
+ fprintf_filtered (stream, cp);
+ }
+ break;
+
default:
error ("Undefined output format \"%c\".", format);
}