简体   繁体   English

如何在 GDB 中打印 64 位值

[英]How to Print 64-bit Value in GDB

If I start a gdb session and type:如果我启动 gdb session 并键入:

(gdb) p/x 1024*1024*1024*2
$2 = 0x80000000

But if I cross the 32 bit threshold I get:但如果我超过 32 位阈值,我会得到:

(gdb) p/x 1024*1024*1024*4
$3 = 0x0

How does one display the entire 64 bit value in gdb?如何显示 gdb 中的整个 64 位值?

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):除了 Yaniv 的回答之外,您还可以在其中一个数字上使用ll后缀(根据您的系统,只有一个l可能有效):

(gdb) p/x 1024*1024*1024*4ll
$2 = 0x100000000

If you need to do unsigned arithmetic, you can of course use ull .如果您需要进行无符号算术,您当然可以使用ull

If you want to print memory contents as 64-bit values with the x command instead, you can use the g size modifier:如果要使用 x 命令将内存内容打印为 64 位值,则可以使用g大小修饰符:

(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

in my gdb script.在我的 gdb 脚本中。 I used a gdb-script file, in order to reproduce the debugging process by gdb bin -x gdb.txt , so printf is used:我使用了一个 gdb 脚本文件,为了通过gdb bin -x gdb.txt重现调试过程,所以使用printf

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

works.作品。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM