4

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?

3 Answers 3

12

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 
Sign up to request clarification or add additional context in comments.

Comments

1

Try casting the value:

(gdb) p/x (unsigned long long) 1024*1024*1024*4 $1 = 0x100000000 

2 Comments

I hadn't tried casting to long long since I was on a 64bit system I though it would default long to be 64bit. Thanks! +1
@Whome Actually, on my system, long does default to 64-bit. I guess the only guarantee that we get at least 64 bits is to use long long.
1

in my gdb script. I used a gdb-script file, in order to reproduce the debugging process by gdb bin -x gdb.txt, so printf is used:

printf "0x%llx\n", $rax 

works.

pwndbg> printf "0x%llx\n", $rax 0x7ffff77c0068 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.