gdb: 未定义的输出格式 "z"

gdb: Undefined output format "z"

我想在 BeagleBone Black Board 上使用 gdb 调试我的代码。我想在 gdb 中将我的变量打印为十六进制,为了做到这一点,我一直使用 p/z 作为 gdb 命令。但是当我在 BeagleBlack 的 gdb 中使用这个命令时,我得到了:

Undefined output format "z".

有什么方法可以让它工作吗?它与gdb版本有关吗?我的操作系统是 Debian,我的 gdb 版本是:7.4.1-debian,当我尝试安装新软件包时,它说:gdb is already the newest version

打印格式 z 是最近添加的(我认为是 7.6 或 7.7 - 基于 this patch)。由于您使用的是旧版本的 gdb,它无法识别 z 选项。您可以改用 p/x

差异between x and z is the leading zeros

z Like ‘x’ formatting, the value is treated as an integer and printed as hexadecimal, but leading zeros are printed to pad the value to the size of the integer type.

我系统上的 GDB 是 7.9 版,它可以识别 p/z。因此,您可以升级 GDB 或使用 p/x.