Specify number size in gdb for print commands?

0

To play around with various additions to registers that may be 8,4,2 or 1 bytes (rax, eax, ax, al) is there a way I can specify the number of bytes of the number I'm using? For example

# works for 4 bytes
>>> p/x -1
$30 = 0xffffffff
>>> p/x 1
$31 = 0x1
>>> p/d 0xffffffff
$34 = -1

# can I get it to work for one byte, signed char?
>>> p/d 0xff
$35 = 255
c
gdb
asked on Stack Overflow Sep 26, 2020 by samuelbrody1249

1 Answer

1

A simple way is to use casting to tell gdb the type of the value.

(gdb) p /d (char)0xff
$2 = -1
answered on Stack Overflow Sep 26, 2020 by kaylum

User contributions licensed under CC BY-SA 3.0