There's no longer a context menu option to set a breakpoint "in-line".
Example:
if (someBoolean) return CallToMyMethod();
With previous versions of VS I could simply right click "CallToMyMethod" and set a breakpoint there. There doesn't seem to be a way of doing this anymore?
Just highlight the method name or the part where you need the breakpoint and then press F9.
Related
I've just updated to Visual Studio 2017 (15.8.2) - after the update, intellisense when debugging isn't working. For example, if I hover over abc (screen shot) I get the same summary as shown in the Locals (abc count=7), however I can't expand the tooltip to show the property's of the object - as shown in the Locals.
Also when I hit a breakpoint and the scroll to another part of the file, I automatically get taken back to the breakpoint after a few seconds.
These could be settings that were turned on as part of the update, however I haven't been able to find any info on this. I've also reset all settings however I still experience the same issues.
Update:
After some further searching I came across this https://developercommunity.visualstudio.com/content/problem/321198/variable-datatips-dont-expand.html
Looks like an issue introduced in 15.8.1
I am using Visual Studio Code and when I debug (I am debugging C++ code compiled with Clang) I see only local variables.
I do not see any global variables list.
How can I see all variables?
In this case I am inside a loop and I see only all the variables defined inside the loop, not the one defined outside.
You will need to manually add global variables to a watch window.
Set a breakpoint
Start debugging (Debug -> Start Debugging or
F5)
Open a Watch window (Debug -> Windows -> Watch -> Watch 1)
Type in the name of the variable manually
In Visual Studio Code you can just go to the Watch pannel int the debug menu and click on + , then type the name of the variable you want to watch.
Hope it helps !
After you follow the stepes in Andrew L's answer you can modify the variable's value by the help of either:
1. Debug Console
2. Address-Of Operator
By prefixing the variable we want to watch with (&) we can now expand it and then right click on the dereferenced variable to set a value.
I am a newbie programmer, and have Visual Studio Update 3 on my computer. I cannot find the window that displays the values of variables as I am debugging.
I have looked under the pull-down tab at the top entitled "Debug" and "Window", and cannot find anything. I do not know exactly what the window is called either. Please help.
If you're looking for the scoped local variable values or Autos:
you must first have the debugger running, then goto:
DEBUG => Windows => Autos
and
DEBUG => Windows => Locals
to actually see those values, you need to have a debug stopper in place and it get hit by the program.
Alternatively you can - while debugging - highlight a variable name and use the 'Quick Watch'
In the default layout, the Locals window will typically be visible in the lower left pane, but only while debugging is active.
Here you can see the debugger windows on the bottom. The left side shows current breakpoints while the right side is showing watched variables in the pane labeled Watch 1. At the bottom you'll see other panes available to display in the lower left, specifically Call Stack, Command Window, etc. The one you want to see all in scope variables at a given breakpoint is Locals
If you have closed the locals window, or otherwise cannot find it, there is a way to re-open it through the Debug->Windows menu as pnm points out
I'm developing in visual studio 2013, and have a couple of questions regarding debugging:
Is it possible to have a group of breakpoints that I can enable/disable all together? Sometimes I may be working on feature 'a' and then need to work on feature 'b'. Being able to group breakpoints, and disable them all at once would be very handy!
Is it possible to have a variable with one value for the debug build, and another for the release build? Working with opencv, and when I'm in the debug mode, I like to see data on the image that isn't to be shown in the release, so I've set up one bool variable to control this that I have to keep changing when switching builds!
1 - Yes, as of VS 2010 you can label breakpoints into groups.
http://msdn.microsoft.com/en-us/library/vstudio/dd293674(v=vs.100).aspx
http://weblogs.asp.net/scottgu/vs-2010-debugger-improvements-breakpoints-datatips-import-export
Briefly, right click on a breakpoint, click Edit Labels..., then either Add a new one (Ex. parser), or select a previous one. To toggle groups by label, go to the Breakpoints window (Debug -> Windows -> Breakpoints), and change the criteria "In Column" to Labels, and type parser into Search. Then you can toggle the results.
2 - Use conditional compilation macros
#ifdef DEBUG
int verbose = 1;
#else
int verbose = 0;
#endif
For the second questions, you can use the pre-processor conditional features:
#ifdef DEBUG
// Building debug variant
#else
// Building something else
#endif
Windows 7 x64; MS Visual Studio 2010 SP1.
I press the F10 key step by step into DEBUG mode, and look the "Autos" window items. I see some variables (in the "Autos" window) sometime appears/disappears in their visibility area (and they are already initialized). Why it happen? Look the screens below.
The Autos window shows things the debugger thinks you may be interested in relation to where you are in the code. It's automagic, so it's impossible to explain exactly what the logic is. Use locals or watch windows if you need to have a more constant view.