Where can I see the return value of a function/methode that is called while debugging.
I step on each line with F7. I want to see each(!) return value. Where can I see it?
Here is an example (I know the code is wrong!):
wxString strSubDest = strDestination_ + dirname.Right(dirname.Find(wxFILE_SEP_PATH, true));
I want to see two values if I step over this line.
Return value of Right() and of Find().
by secretly creating a symbol.
You mean the MSVC compiler restruct code like this
to
long rc = functioncall();
?
And then the debugger can handle it?
Nice! Why does GCC and GDB does not allow this?
First, just ignore the fact of patching GDB.
This is what I did:
* Created a new console project.
* Created a main.cpp ('cause I created the project totally empty).
* Added this little test program:
#include <iostream>
long function(long n)
{
return n * 7 + 2;
}
int main()
{
long x;
std::cin >> x;
function(x);
std::cin >> x;
function(x);
}
* In the build options enabled debugging symbols [-g].
* In the debugger toolbar I enabled the "CPU Registers" window.
* Added a breakpoint at line 13 (first call to function).
* Started debugging.
It'll show you a console and will be waiting for a long value. I typed 8 just for fun. When I hit enter the program is interrupted by the debugger.
The current value of eax is before calling function, so I just click on "Next line" button (it's in the debugger toolbar). Now check eax's value: 58 (8 * 7 + 2).
"Next line". It'll ask for another number. I typed 3. "Next line". Once again it's eax's value before the function is called. "Next line". Now eax's value is 23 (3 * 7 + 2).
The plugin I was talking about is the debugger plugin, but I really wonder if Don Corleone would be interested in doing so, or anyone else in writing a patch.
Once again, it's kinda a hack, but works :P
Another trick, if someone is really feeling like creating a patch for the debugger plugin (sorry if no one is) :)
Howto when the return value is a struct
This is basically the same example, but now everything is evaluated as long and double, stored in a struct and returned.
#include <iostream>
struct longdouble
{
long l;
double d;
};
longdouble function(longdouble n)
{
longdouble r;
r.l = r.d = n.l * 7 + 2;
return r;
}
int main()
{
longdouble x;
std::cin >> x.l;
x.d = x.l;
function(x);
std::cin >> x.l;
x.d = x.l;
function(x);
}
The breakpoint goes now in line 24 (first call to function).
I just did the same: typed 8, the program was interrupted and clicked on "Next line". Because it's a struct, eax stores a pointer to a temporary struct where the result is saved. In my machine it's 0x22ff50 in hex (eax's value).
If you want the value of l (the long inside struct longdouble): Debug -> Send user command to debugger:
output ((struct longdouble *)0x22ff50)->l
The result will be shown in the Debugger thingy in the Messages pane.
I hope all of this be of any use, but once again: sorry.