I am trying to learn assembly and I am using Ubuntu, I want to see the value of a label using GDB. Issue is that the label is one byte big and I cant cast it as just "p (byte)'label_name' ". And GDB does not seem to work if i dont tell it what the label size is.
CodePudding user response:
p (char)label_name
works for me. GDB commands use C type names. (Showing it as a number and the ASCII character it represents for char
. C doesn't have a separate type for 8-bit integer).
C doesn't have a type called byte
, so (byte)foo
is an error.
As Jester says, x /b &label_name
might be what you want to eXamine memory, especially if you want to see multiple bytes starting from a certain point.
Within GDB, help x
and help p
will show details on how to use it.
Related:
- GDB shows error message when trying to print a variable in an Assembly program
- Address of an ASM label in GDB - how GDB gets symbol type info for debugging C programs. Older GDB used to default to
int
or something, now it prints'x' has unknown type; cast it to its declared type
like you were getting. - How to print <incomplete type> variable in gdb