Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View return value?

Say I have the following

int num = 40 + str2Int("30");

Is there anyway with visual studio 2008 to tell what Str2Int is returning without stepping into the function and going to the return?

like image 585
user230821 Avatar asked Jan 17 '10 04:01

user230821


People also ask

How do I see return value in Visual Studio?

View return values for functions If the window is closed, use Debug > Windows > Autos to open the Autos window. In addition, you can enter functions in the Immediate window to view return values. (Open it using Debug > Windows > Immediate.)

What is the return value $?

The return value of a command is stored in the $? variable. cmd; echo $?; The return value is called exit status. This value can be used to determine whether a command completed successfully or unsuccessfully.

What is return value C++?

In C++, a function which is defined as having a return type of void , or is a constructor or destructor, must not return a value. If a function is defined as having a return type other than void , it should return a value.

How do I view a variable in Intellij?

Right-click a variable or expression that you want to watch and choose Add Inline Watch in the context menu. An inline watch will be created for that variable or expression.


2 Answers

In the "auto" variable windows it will display the result of any operations you just stepped over.

Edit: Removed uncertainty over the location of this (thanks goes to Michael Burr)

like image 154
Grant Peters Avatar answered Oct 16 '22 05:10

Grant Peters


Since the return value is generally in the EAX register, you put the $eax 'variable' in the watch window. When you step over the function call, what's in EAX is what that function returned.

And if you also provide the hr format symbol the debugger will show you the HRESULT or Win32 error message (like "S_OK" or "Access is denied") instead of just the raw number. It can be handy to have each ($eax and $eax,hr) in separate watch entries.

Another useful entry is $err which shows whatever GetLastError() would return (and the hr format symbol can be applied to it - or anything - as well):

$eax
$eax,hr
$err
$err,hr

Note that older versions of the VS debugger might want you to use a @ instead of a $ to start these variables, but a member of the debugger team has stated that $ is preferred to keep things in line with the "Debugging Tools for Windows" toolset (I think that support for @ is deprecated and might be removed at some point).

like image 3
Michael Burr Avatar answered Oct 16 '22 05:10

Michael Burr