73

I tried b but seem not:

(gdb) p/b 0x0000000000400398
Size letters are meaningless in "print" command.

Is there such a switch?

compiler
  • 4,143
  • 9
  • 36
  • 40

2 Answers2

125

You need the /t switch which works with both p and x:

(gdb) p /t 0x0000000000400398
$1 = 10000000000001110011000

See help x for more info on the FMT (format) switches.

Paul R
  • 208,748
  • 37
  • 389
  • 560
  • 3
    @PaulR but the size letters are meaningless in "print" command, so it certainly ought to be the *b* ;) – Hi-Angel Jun 10 '14 at 09:53
  • 6
    As per manual, Print as integer in binary. The letter `t' stands for "two". (2) – Hoppo Feb 07 '17 at 22:46
  • 1
    The `t` switch isn't a `size` switch but a `format` switch. That's why gdb will not warn you about `size letters` being `meaningless`. ;-) – Alexandro de Oliveira Oct 17 '17 at 16:26
  • 4
    No space when using lldb: ```(lldb) p/t 0x0000000000400398 (int) $0 = 0b00000000010000000000001110011000``` – JAL Sep 09 '18 at 00:26
7

x/4tb 0x0000000000400398 will let you analyze the Memory Address with Binary Values.

Sandeep Singh
  • 4,941
  • 8
  • 36
  • 56