How do I view variables values in nsight eclipse edition - c++

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.

Related

Qt invisible combo box in release build (but not in debug build)

I have an application which worked well so far.
Today I have updated my ubuntu to 18.04 and therefore reinstalled all software components, including Qt.
Now I experience a pretty wired behavior.
When I compile my application in debug build, everything is correct. When I switch to release build some combo boxes become invisible.
What is strange is, that events still work, the comboboxes are still there (but invisible).
I know this because I use an installEventFilter()
with if(event->type() == QEvent::Enter) which changes some other widgets if I hover the combo box with the mouse. Although the combo boxes are invisible the events still work when I hover the area where the combo box would be located.
Unfortunately, I do not know what makes this issue, so I cannot reproduce it in a minimal example.
My question is: Did anybody experience something like this before?
And: Where should I start to look for the error?
(I cannot debug it because everything is correct for debug builds)
By the way: I do not know if this is related but when I first tried to run the application I got an error that gl/gl.h was missing. After asking my friend google for help I found out that OpenGL was missing, so I installed it.
I would go and look for uninitalized variables when setting the properties of the combobox. Usually in debug even unitialized variables are set to some fixed value.
Or maybe you are setting properties in an assert that is not compiled in the release build? E.g. like this
Q_ASSERT(...)
that code in between the () will just be skipped during a release build.

Visual Studio 2013 - Variable Value Window In Debugging

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

Debugging techniques c++ in Visual Studio 2013

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

How to view contents of an array while debugging in Code Blocks?

This is probably a silly question and i am posting this Post-Googling,
The question is,
How do i view the contents of an array while debugging, Provided the Breakpoint is in function not Main?
I am using code::blocks 13.12 version and i set a break point in my sample simple c++ code,
and i want to observe how the contents of the array change with the code but all i see is the the address of the array under watch window,
It is however displaying the values of other integer variables correctly,
a is an array
I forgot to mention that i am tracking the array in a function and not in main,and i am aware that main passes the address of the array to the function being called(by reference i meant)
I am relatively new to codeblocks, Am i missing some setting or something?
Right click on the cell, then select "Properties", there you can tell it to "watch as array", and tell it the index range to watch.
i am using 12.11. I select the array variable suppose a, choose "watch a" in the right button down menu, and I can see the values in the array a.
Another thing that I use is watching under cursor.
If you go Settings -> Debugger... -> GDB/CDB debugger -> Default and you enable selection "Evaluate expressions under cursor", every time you leave mouse pointer above a variable in the code, it will be watched.
It's not the same with having it in Watches toolbar, but strangely it will show array's fields.
Debug -> Debugging windows -> Watches
you may watch the variables in this way
in convenience, you can find button "Debugging Windows" near to the debug toolbar, choose "watch", hope you can find it!

Xcode 4: why "Continue to current line" is grayed out?

When I am debugging my program, I often want to make it run from where it is paused to a specific line.
In Xcode 3, I was able to do that by clicking on the button appearing next to the line number when hovering it.
In Xcode 4, it seems to be possible to do that either by right clicking on the line number and select Continue to here, either by using the Debug menu and choose Continue To Current Line item.
However these options are always grayed out when I want to use them.
Note, I don't know if this is relevant but I am using c++
Is there something I am doing wrong?
Thanks in advance,
Kevin
It seems that this is because you are using the LLDB debugger. As the same thing happens to me, whilst using the LLDB debugger and debugging C++ code, as you can see here:
I tested this with Objective-C code, and this feature works perfectly fine whilst debugging Objective-C.
The green button you mentioned, for Xcode 3, also pops-up with Objective-C code (using Xcode 4). As you can see here:
Perhaps it's a bug in Xcode, or Apple just wants you to program in Objective-C. It seems to be only an issue whilst using LLDB, and debugging C++ code (I am unsure of C code). On the other hand, debugging with GDB works fine with both: C++ and Obj-C code.
The only real options you have at the current time is:
Option 1:
Use the GDB debugger instead, as the GDB debugger with Xcode supports this.
To change the debugger:
Step 1:
Click your project name under the Scheme Menu, in the top left.
Step 2:
Click "Edit Scheme..."
Step 3:
Once the Edit Scheme menu comes up, click the pop-up menu next to the "Debugger" option.
Step 4:
Click the option "GDB" to use the GDB debugger.
NOTE:
Once you click GDB, the "Debug Process As" option will be greyed out.
Step 5:
Click OK.
NOTE:
I'm not sure about the limitations whilst using the GDB debugger, over LLDB (I think Xcode does not support any recent versions of GDB, as they have switched to LLDB and clang).
Option 2:
Create a breakpoint to where you wish to continue, and then continue to it. It really isn't that hard compared to right clicking and pressing "Continue Here" or the green button. This also provides the same functionality. With the use of keyboard shortcuts it could be just as fast (see below).
For example:
Say you want to continue until you hit line 39.
Set a breakpoint at line 39.
Click "Continue program execution" button, which is the button that likes some-what like a media-play button. Alternatively you can continue using the keyboard shortcut: Command + Ctrl + Y, or use the Menu (Product->Debug->Continue)
NOTE:
You need the Debug area shown (Shift-Command-Y), in order to see the "Continue program execution" button.