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
Related
I am quite new to Microsoft Visual Studio. I am using VS Community 2019. I want to enable all suggestions in intellisense all the time, how can I do that?
For example, I have a vector variable v2qPenLine which is a QVector<QVector<QPen>>. The vector variable is named in such a way so that I have easy access to it through intellisense. When I try to use it inside setPen() method (which is expecting a QPen but not a vector of QPen I guess) the intellisense does not suggest this vector:
To have it suggested, I need to click on the + button at the bottom and then it suggests the correct variable immediately:
This behaviour is not convenient at all. How can I change this behaviour of the intellisense so that it suggests only based on the name and do it all the time so that I don't have to click the + button at the bottom of the suggestion list? I think there should be a setting for this and so I tried to look up the settings of intellisense but I was unable to change this behaviour. I also couldn't find any reference to this on the internet.
I think it is a problem of your VS IDE Intellisense. And you can see that the Intellisense of your environment does have any info about variables, functions, classes ....on the first time. It should show all types on the first time. In your side, it only has the type of methods, quite strange.
Try the following suggestions:
1) disable any third party extensions under Extensions--> Manage Extensions-->Installed to check if there is an extension which caused that.
2) close VS, delete all files under C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\16.0_xxx\ComponentModelCache
3) reset all vs settings under Tools-->Import and Export Settings-->Reset all settings
4) close Vs, delete .vs hidden folder under the solution folder and then restart your project to test again.
5) repair vs or update it if there is a new release version
I am using Visual Studio Community 2017 and am frequently switching between several class files. The way I am having to do this is by pressing Ctrl+Tab (or Ctrl+Shift+Tab) repeatedly until I reach the desired tab.
It would be more convenient if there was a way to switch between tabs by pressing Ctrl+(tab's index) similar to how browser tabs are navigated. e.g. pressing Ctrl+1 opens the first/leftmost tab on your browser, Ctrl+2 opens the second one, etc.
Looking in Tools > Options > Environment > Keyboard, there are commands that use View.NavigateBackward and View.NavigateForward (The Ctrl+Tab and Ctrl+Shift+Tab functionality) that can be re-mapped - however nothing for the functionality I described above.
There are threads solving this issue for Visual Studio Code, however (and I'm really surprised/must be really dumb that) there are no threads that I could find for just Visual Studio.
Threads for Visual Studio Code:
Is there a quick change tabs function in Visual Studio Code?
https://github.com/Microsoft/vscode/issues/24753
You can switch to a specific tab with a keyboard shortcut with my Tabs Studio extension:
And you can additionally enable the Show tab numbers option to simplify usage of NavigateToTabXX commands:
So... After doing a more sensible search on StackOverflow instead of Google, I've found this thread;
https://stackoverflow.com/search?q=CTRL+Number+Visual+Studio
Which suggested to download a Visual Studio tool called "Hot Tabs". I have done so and it's working well for my purposes at the moment.
Hot Tabs
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
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.
I'm using nsight eclipse edition, and I cant figure out how to view variables values in debug mode for now (meaning usual variables in host memory, debugging usual c++ code so far).
"Variables" tab does not contain anything useful for me (nothing I can use now at least), and Memory tab, which should be able to display variables by their addresses and also monitor expressions does not work for me either.
Any suggestions?
The following steps seemed to work for me:
open nsight
create a new project, select CUDA C/C++ project, and select CUDA Runtime project
the project will be populated with a simple "bitreverse" code. The initial configuration will be the debug configuration. Select Project...Build Project to build the sample code (debug version).
Now on the right hand side of the toolbar, press the "Debug" button, to switch to the Debug perspective.
on the left of the first CUDA_CHECK_RETURN(...) line of code, right click and select "Toggle Breakpoint" to set a breakpoint at that line of code.
select Run...Debug The program will then be started in debug mode, stopped at the first line of code, and the host variables will be filled in in the upper right hand corner "Variables" pane.
To the left of the idata variable, select the triangle to expand the sub-menu. The submenu is populated with the values of idata at each index. The data will be garbage, as it has not been initialized yet.
Select Run...Resume to continue program execution. Program execution will halted at the breakpoint previously set.
If we inspect the idata variable in the "Variables" pane, we see that the values have been changed (initialized) to 0, 1, 2, ... etc.
If you attempt to debug a project for which you have built the "Release" configuration instead of "Debug" configuration, you will have a variety of issues, and will get a message "no source available" and there will be no variables displayed in the "Variables" pane.
I was using gcc 4.8, which caused problems.
Now I downgraded to gcc 4.6 and it solved problem.
Robert Crovella, thanks for your effort.