If I break in line 3:
1 int foo()
2 {
3 return func();
4 }
is there a way to examine the return value of func()?
Thanks.
If I break in line 3:
1 int foo()
2 {
3 return func();
4 }
is there a way to examine the return value of func()?
Thanks.
After line three the return value will be in EAX, so you can
print $eax
Hope this helps
In C, the return value of a function is returned in register %EAX, so you can get the return value of func() if you set a breakpoint for immediately after func()
returns and then call
print $eax
or
info registers
which gives you information about all of the registers, including %EAX.
In this case, if your break point is at line 3, you may need to use s
to step through to after func()
returns but before foo()
does.
I answered a simular question here, info frame is a platform independent way todo this.
If you step into "func()", and then say "finish", gdb will return to foo and print the return value of func.