Displaying Data
print can be used to display variables and the result of function calls. You can control the format of the displayed data by adding a format flag after the command:
(gdb) print i$1 = 17263812 (gdb) print/x i$2 = 0x1076cc4 (gdb) print /o i$3 = 0101666304 (gdb) print/t i$4 = 1000001110110110011000100
Here are some of the format flags:
/x | Hexadecimal |
/d | Signed decimal |
/u | Unsigned decimal |
/o | Octal |
/t | Binary (t for "two") |
/c | Print as a character constant |
/f | Floating point |
You can use these in ad-hoc expressions too:
(gdb) print/o 0xfeedface $5 = 037673375316 ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access