User forums > Using Code::Blocks
view function return value
roshi:
Hi,
is it possible to see the return value of a function?
Something better than register views.
Thanks
MortenMacFly:
--- Quote from: roshi on December 07, 2008, 07:18:33 pm ---is it possible to see the return value of a function?
--- End quote ---
What's wrong with:
myRetVal = MyFunc();
...and inspecting "myRetVal"?!
Guess you need to explain a little more. You did not even mention if you are debugging or not... Probably you can inspect the values in memory during runtime with certain tools.
roshi:
Hi,
I'm sorry for being ambiguous.
While debugging if I want to check the return value of a function what can I do?
For example the value will most likely be in the ebx if I remember well. (or was it eax), but this is not very useful if were talking about a class pointer...
Most of the time you can't reevaluate the function, so changing the code works only in a very strict number of situations.
In most cases, even if you don't use it, (I think) it would be really useful to have access to the return value.
This would be like the "Function Arguments" (in the watches) but it would be called "Return Value". If it was a pointer of a complex data type, one should be able to browse it's internal state just like in the case of "watch *this".
I think, for those who know and remember, visual studio 6 had this functionality.
I remember using it some 10 years ago. The return value would be shown in red, and you could browse it's state (if one existed) in a table view.
Cheers
Merry Christmas
thomas:
I don't think there is a better way than the one suggested by MortenMacFly (which should work just fine, and doesn't re-evaluate anything).
To my knowledge, there is no such thing under gdb, and I could only imagine it implemented if compiler and debugger agreed on a few rules, which they don't. Note that gdb debugs optimized code -- within some obvious technical limits -- just fine, however it can't do magic.
roshi:
hi
I googled once
http://www.google.com/search?hl=en&rlz=1C1GGLS_enJP305&q=gdb+watch+function+return+value&btnG=Search
and found this
http://www.unknownroad.com/rtfm/gdbtut/gdbstep.html#RETURN
2.8 How do I return from a function? [top] [toc]
Use the finish command to have a function finish executing and return to it's caller. This command also shows you what value the function returned.
(gdb) finish
Run till exit from #0 fun1 () at test.c:5
main (argc=1, argv=0xbffffaf4) at test.c:17
17 return 0;
Value returned is $1 = 1
which might be helpful implementing this functionality.
Actually I was wondering how could VC6 10 years ago have such functionality and not gdb in 2008.
Now is it possible to send commands to gdb from within C::B? (will google for it)
Cheers
Navigation
[0] Message Index
[#] Next page
Go to full version