If I start a gdb session and type:
(gdb) p/x 1024*1024*1024*2 $2 = 0x80000000 But if I cross the 32 bit threshold I get:
(gdb) p/x 1024*1024*1024*4 $3 = 0x0 How does one display the entire 64 bit value in gdb?
In addition to Yaniv's answer, you can use the ll suffix on one of the numbers (just one l may work depending on your system):
(gdb) p/x 1024*1024*1024*4ll $2 = 0x100000000 If you need to do unsigned arithmetic, you can of course use ull.
If you want to print memory contents as 64-bit values with the x command instead, you can use the g size modifier:
(gdb) x/8xg 0x7fffffffe008: 0x0000000000400e44 0x00007ffff7fe3000 0x7fffffffe018: 0x0000000000000000 0x0000000000000000 0x7fffffffe028: 0x0000000000f0b5ff 0x00000000000000c2 0x7fffffffe038: 0x0000000000000100 0x0000000000000001 Try casting the value:
(gdb) p/x (unsigned long long) 1024*1024*1024*4 $1 = 0x100000000 long does default to 64-bit. I guess the only guarantee that we get at least 64 bits is to use long long.