gdb with hex values

Shlomi Fish shlomif at
Fri Jul 5 13:50:41 UTC 2013

Hi John,

On Thu, 4 Jul 2013 23:49:37 -0500
"John J. Boyer" <john.boyer at> wrote:

> Is it possible to tell gdb to show the values of variables in 
> hexadecimal rather than decimal? I can't find anything on the man page.

Use the /x option:

shlomif[fcs]:$trunk/fc-solve/source/B$ gdb ./fc-solve
GNU gdb (GDB) 7.6-4.mga4 (Mageia release 4)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-mageia-linux-gnu".
For bug reporting instructions, please see:
Reading symbols
from /home/shlomif/progs/freecell/git/fc-solve/fc-solve/source/B/fc-solve...done.
(gdb) p 100
$1 = 100
(gdb) p /x 100
$2 = 0x64
(gdb) help p
Print value of expression EXP.
Variables accessible are those of the lexical environment of the selected
stack frame, plus all those whose scope is global or an entire file.

$NUM gets previous value number NUM.  $ and $$ are the last two values.
$$NUM refers to NUM'th value back from the last one.
Names starting with $ refer to registers (with the values they would have
if the program were to return to the stack frame now selected, restoring
all registers saved by frames farther in) or else to debugger
"convenience" variables (any such name not a known register).
Use assignment expressions to give values to convenience variables.

{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.
@ is a binary operator for treating consecutive data objects
anywhere in memory as an array.  FOO at NUM gives an array whose first
element is FOO, whose second element is stored in the space following
where FOO is stored, etc.  FOO must be an expression whose value
resides in memory.

EXP may be preceded with /FMT, where FMT is a format letter
but no count or size letter (see "x" command).

You can find more information about using gdb from its online manual:

And from these resources:

* (search for the "Advanced GDB" row).

* (and )

Hope it helps.


	Shlomi Fish

Shlomi Fish
Understand what Open Source is -

<rindolf>  If you repeat a scene 50k times, then the movie will have less
entropy and will compress better. ( irc:// )

Please reply to list if it's a mailing list post - .

More information about the Blinux-list mailing list