Is it possible to inspect the return value of a function in gdb assuming the return value is not assigned to a variable?
Yes, just examine the EAX
register by typing print $eax
. For most functions, the return value is stored in that register, even if it's not used.
The exceptions to this are functions returning types larger than 32 bits, specifically 64-bit integers (long long
), double
s, and structs
or classes
.
The other exception is if you're not running on an Intel architecture. In that case, you'll have to figure out which register is used, if any.