Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I discover the return value at the end of a function when debugging in VS2008?

Using C# in Visual Studio 2008 and stepping through a function in the debugger I get to the end of a function and am on the final curly brace } and about to return. Is there a way to find out what value the function is about to return?

This is necessary if the return value is calculated such as:

return (x.Func() > y.Func());
like image 933
Guy Avatar asked Dec 17 '22 10:12

Guy


2 Answers

It's a little low level, but if you switch to disassembly then you can single step through the instructions and see what the return value is being set to. It is typically set in the @eax register.

You can place a breakpoint on the ret instructions and inspect the register at that point if you don't want to single step through it.

like image 146
Rob Walker Avatar answered Dec 24 '22 03:12

Rob Walker


You can put

(x.Func() > y.Func())

in a watch window to evaluate it, and see the result. Unless the statement is

return ValueChangesAfterEveryCall();

you should be fine.

like image 30
MagicKat Avatar answered Dec 24 '22 03:12

MagicKat