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 

1 Answer 1

1

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

(gdb) p /d (char)0xff $2 = -1 
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, could you please link to a part in the docs that explains that a bit if it's there? I tried help x and help p but wasn't finding too much of help.
It's not really documented very explicitly as far as I know. The commands to examine data work on expressions. An expression is in the context of the language being debugged. In this case, the default type for C is int and casting is the way to change the type of any expression.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.