How to inspect the return value of a function in GDB?

前端 未结 3 681
鱼传尺愫
鱼传尺愫 2020-11-29 17:00

Is it possible to inspect the return value of a function in gdb assuming the return value is not assigned to a variable?

3条回答
  •  [愿得一人]
    2020-11-29 17:29

    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), doubles, 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.

提交回复
热议问题