Hello Ignorant-ga,
Hmm. The return value is available but the description of how to find
it is buried pretty deeply. The most simple way to get the return
value is to...
- stop execution within the function you want to check the return
value (e.g., breakpoint)
- if the function you want the return value is not the current
function, select the proper function (using the GUI or from the gdb
command line) using the frame command. For example, using the menu
Status -> Backtrace... will bring up a window showing the functions
called. Make sure the right function is selected before the next step.
- enter the "finish" command to gdb [using the GDB console window]
The program will continue execution until the selected function (stack
frame) is completed and the return value will be printed (if any). At
this point, you are stopped at the point after the return from the
function call.
From the gdb online help...
(gdb) help finish
Execute until selected stack frame returns.
Upon return, the value returned is printed and put in the value history.
I found this by entering:
apropos return
and checking the likely commands until I found the one that appears to
do what you are asking for.
This is also documented in the (huge) "Debugging with GDB" which
should be provided with your system. If you can't find a copy, check
out a version in HTML format at
http://www.eelab.usyd.edu.au/tornado/docs/gnugdb4.18/gdb.html
or more specifically:
http://www.eelab.usyd.edu.au/tornado/docs/gnugdb4.18/gdb.html#SEC37
and scroll down a little for the description of finish [basically the same text].
Most of the other methods are pretty advanced (e.g., reading the
assembly code / printing the appropriate memory location / register).
Let me know if you have any problems with the answer I've provided
with a request for question clarification. I'll be glad to expand on
the answer if needed.
Good luck with your work.
--Maniac |