Visual 2015 + Qt 5.6: Program execution very slow in debug mode - c++

I noticed that program execution in Visual debug mode is very slow (both release and debug version of the program). The performance drop impacts also non-Qt code which is just called in the GUI. In comparison to an old version based on MFC, the same non-Qt code runs > 10 times slower. I know that I can just start the program without debugger and everything is fine. However, the debugger is practical for reason. Does someone have a tip what causes the debugger problems?

Related

Variable values not visable when Stepping through Release in VS 2013 C++

I've followed the following instructions on how to step through and debug an executable when compiled in release mode.
http://msdn.microsoft.com/en-us/library/fsk896zz.aspx
The problem I'm running into is that although I can step through the program, I can't view the value of variables, which making stepping fairly useless.
Any ideas as to what might cause the issue?

GLUI runtime error with release build

I'm developing my first application using GLUI and I'm having some problems. I'm using Visual Studio 2010 on a Windows 7 machine and using glui-2.35. My application runs fine when built in debug mode but crashes with a runtime error when built in release mode. From the debugger the error is from the last statement in this function from glui.cpp:
void GLUI_Master_Object::set_glutReshapeFunc(void (*f)(int width, int height))
{
glutReshapeFunc( glui_reshape_func );
add_cb_to_glut_window( glutGetWindow(), GLUI_GLUT_RESHAPE, (void*) f);
}
I'm not sure why the release build crashes; any suggestions would be greatly appreciated.
I'm not an expert in MSVC++ debug and release mode but I've been looking for some information, and in this website, some users talk about it.
One of them (#mcdeeiis), in this page, says:
...
In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account.
While in release build the symbolic debug info is not emitted and the code execution is optimized.
Also, because the symbolic info is not emitted in a release build, the size of the final executable is lesser than a debug executable.
One can expect to see funny errors in release builds due to compiler optimizations or differences in memory layout or initialization. These are usually referred to as Release...
Anyway, check sure the libraries that GLUI or your project depends on, have been compiled with release mode too. It might cause problems.

How to debug host code in mixed cuda C++ program?

My work platforms are VS2010 and Nsight 3.1.
With Nsight, breakpoints can be set in cuda kernel and the debugger works well. If the breakpoints are set in host code, Nsight just ignores them.
I don't know if it is possible to set breakpoints in host code and use the debugger provided by VS2010. I tried, but the program stops when it meets the first cudaMalloc function. Could someone please tell me how to debug host code in a mixed cuda and c++ program?
Thanks a lot.
I'm afraid you could not debug both CUDA and c++ program in on VS. Here is a workaround. Hope it could help you
Launch a Windows command line. Set NSIGHT_CUDA_DEBUGGER=1
In this command line, execute your CUDA application (Here I suppose it's a long-term execution).
Open a VS. Tools menu ->Attach to Process. Choose transport as Nsight CPU Debugger and attach to your application. Then you could debug CUDA code
Open another VS. Choose transport as Default. Attach to the application then you could debug C++ code
Please pay attention, if the application is suspended by a VS, it could not be debugged by the other VS. You must resume current one and then switch to the other.

My C++ executable runs way faster outside the Visual Studio 2008 IDE than inside, even in release

I build a C++ application that does some number crunching.
I'm running in Visual Studio 2008 PRO SP1, in release mode, Windows 7 64 bit.
If I run it inside the IDE, the application takes 4 minutes, if I run the same executable from windows explorer it takes 6 seconds!
I have no clue. I have checked that this does not depend on the processor and operating system. I don't think I have strange VS plugins that are doing something in the background.
Any hints?
Thank you in advance!
Marco
Presumably, the slow down is caused by the debugger being attached when you are starting the application in Visual Studio. This is the case even when you've built the program in "Release" mode.
To confirm that this is indeed the source of your problem, try running your application without the debugger, using the "Start Without Debugging" command or Ctrl+F5.
It's worth nothing that in C++ specifically, when you start without debugging, your program won't use the Windows debug heap. With the debugger attached, it will.
As Cody mentioned, one option is to simply not debug. But if you want to speed up your debugging sessions, here are a few things I've found can make a huge difference:
Remove debugging print statements that are no longer necessary. If you see your log filling up with text, that is likely slowing you down significantly.
Remove breakpoints (Ctrl+Shift+F5). A couple times I've noticed a huge drop in performance, and it turned out to be due to a breakpoint with a condition that was never met.

Dubugging a program not run within the debugger and without a crash

I left a program running last night, it worked fine for about 5 hours and then one of its built-in self-diagnostic tests detected a problem and brought up a dialog box telling me the issue. The program was built with debug information (/Zi). Is it possible to somehow get the debugger started so I can examine the value of some variables within the program? Or is it too late?
You can attach the debugger to the running process:
Debug > Attach to Process...
Just open up the program's solution first.
Assuming you've still got the error dialog on the screen you can break into the program and work back up the call stack examining variables etc.
For the future crashes ... if you have windbg or Visual Studio Professional, you can debug crash dumps, even when program isn't running. It is quite useful sometimes. See "MiniDumpWriteDump" on MSDN for more info.
Other than that it is "Attach to process".
Professional edition of Visual Studio have Just-in-Time debugger, that will kick in as soon as anything crashes, even if MSVC wasn't running. It will also locate source code (if debug info and source code are available) and open/create solution for you.
There is an option in the Debug menu to attach the debugger to a running process, IIRC.