Issue
I want to debug my code with gdb on BeagleBone Black Board. I want to print my variable as hex in gdb and in order to do that I have always used p/z
as gdb command. But when I use this command in gdb in BeagleBlack I've got:
Undefined output format "z".
Is there any way that I make it working? Does it relate to gdb version? my operating system is Debian and my gdb version is: 7.4.1-debian
and when I try to install new package it says: gdb is already the newest version
Solution
The print format z
was added relatively recently ( I think, it's 7.6 or 7.7 - based on this patch). Since you are using a older version of gdb, it doesn't recognize the z
option. You can use p/x
instead.
The difference 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.
The GDB on my system is release 7.9 and it does recognize p/z
. So either you can upgrade your GDB or use p/x
.
Answered By - P.P