I have Kubuntu 14.10 and 15.04 installed on my four computers, all having different hardware (the oldest machine was assembbled in 2007 and the newest just a month ago. I have both 32- and 64-bit OSs installed. The amount of RAM varies from 4 to 32 GB). I have been using Code::Blocks on them for a few months, and I experience the same problem on all 4 machines: integrated debugger is painfully slow when debugging a C++ program.
After the debugger stops at a breakpoint, it takes 10 seconds to 5 minutes to step through a single line of code. And while the debugger is performing a step, one core of my CPU is loaded by GDB by 100%. And often trying to step through a line of code hangs forever. After that I have to kill GDB and the process that has been debugged.
Some time ago I updated GDB to version 7.9 (from 7.8) but this did not fix the problem. And I have no slowdown when debugging with GDB from command line, so I suspect that the problem is in the Code::Blocks debugger plugin.
I saw many complaints regarding similar problems, some of which were allegedly caused by outdated libc6-dbg (more exactly, by the fact that debug symbols were not shipped with Ubuntu and other Debian-based distributions), but reinstalling libc6-dbg did not help either.
I am afraid that after a day or two of trying to fix this problem I will give up and will switch to Eclipse or some other IDE. It looks like Code::Blocks and its debugger plugin have not been updated for a couple of years (at least, their Linux versions). So maybe I should not use Code::Blocks at all because its future is not clear (while Eclipse is likely to be in service for long time).
I wonder if anybody else experiences this problem and whether there are solutions. Overall Code::Blocks IDE looks decent and rather convenient, but this debugger problem prevents from using it for purposes other than writing code and compiling.
An update:
I ended up installing Eclipse for C++ (Luna release). It took some time to learn how to use it. It is slow, buggy, glitchy and uses a lot of RAM, but it at least allows me to debug my applications in IDE. Now I am 100% sure that the problem is in Code::Blocks debugger plugin.
I also tried NetBeans, and seems to work fine, but it is even slower than Eclipse and looks really ugly. So I am going to stick with Eclipse for now because no one seems to be willing to fix the debugger plugin in Code::Blocks.
The problem turned out to be with stepping through lines that declare uninitialized std::string objects. A similar (or the same) problem is described here:
https://sourceware.org/bugzilla/show_bug.cgi?id=12555
The probleb with debugging in Code::Blocks was suddenly fixed when I followed these instructions:
http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_inspect_the_contents_of_STL_containers.3F
on how to enable pretty-printing in Eclipse CDT.
I still need to follow these instructions on my other machines to make sure they fix the problem.
You can try and turn off CodeBlock pretty-printing: Settings->Debugger->Default->Enable Watch Scripts = Unchecked
(Source)
Related
I recently noticed that running a program inside gdb in windows makes it a lot slower, and I want to know why.
Here's an example:
It is a pure C++03 project, compiled with mingw32 (gcc 4.8.1, 32 bits).
It is statically linked against libstdc++ and libgcc, no other lib is used.
It is a cpu and memory intensive non-parallel process (a mesh edition operation, lots of news and deletes and queries to data structures involved).
The problem is not start-up time, the whole process is painfully slow.
Debug build (-O0 -g2) runs in 8 secs outside gdb, but in 140 secs within gdb.
Tested from command line, just launching gdb and just typing "run" (no breakpoints defined).
I also tested a release build (optimized, and without debugging information), and it is still much slower inside gdb (3 secs vs 140 secs; yes, it takes the same time as the not optimized version inside gdb).
Tested with gdb 7.5 and 7.6 from mingw32 project, and with a gdb 7.8 compiled by me (all of them without python support).
I usually develop on a GNU/Linux box, and there I can't notice speed differences between running with or withoud gdb.
I want to know what is gdb doing that is making it run so slowly. I have some basic understanding of how a debugger works, but I cannot figure out what is it doing here, and googling didn't helped me this time.
I've finally found the problem, thanks to greatwolf for asking me to test other debuggers. Ollydbg takes the same time as gdb, so it's not a gdb problem, its a Windows problem. This tip changed my search criteria and then I've found this article* that explains the problem very well and gives a really simple solution: define an environment varible _NO_DEBUG_HEAP to 1. This will disable the use of a special heap system windows provides and c++ programs use.
* Here's the link: http://preshing.com/20110717/the-windows-heap-is-slow-when-launched-from-the-debugger/
I once had issues with gdb being incredibly slow and I remember disabling nls (native language support, i.e. the translations of all the messages) would remedy this.
The configure time option is --disable-nls. I might have just been mistaken as to what is the true cause, but it's worth a shot for you anyways.
My bug report from back then is here, although the conclusion there would be that I was mistaken. If you can provide further insight into this, that would be great!
I have downloaded and installed the Qt 5.1.0 for Windows 32-bit (MinGW 4.8) from the qt-project downloads page. I have run the installer, and am able to compile and run applications using these libraries and the minGW 4.8 32-bit toolhchain.
However, I have a large application, and when I try to debug it (using the gdb bundled with the minGW toolchain), it takes an insane amount of time to start running, and any interaction with the application takes a long time to complete. Not an annoying amount of time, but an unusable amount of time. Has anyone else had this problem and are there any solutions?
In case this helps, I get lots of output when debugging like this:
Temporarily disabling breakpoints for unloaded shared library "C:\Qt\Qt5.1.0\5.1.0\mingw48_32\plugins\somefolder\somelib.dll"
There is a gdb bug that was introduced at some point between 7.4 and 7.5, which makes it much slower. When debugging QObject classes, the slower becomes awfully slow.
By disabling debugging helper, you improve it, but then you miss a lot of precious information in the Local Variables and Expressions. For instance, you cannot display nicely the contents of QLists, etc...
It seems that either:
buidling gdb from the CVS or
using an older gdb (7.4.1)
solves the issue.
Qt creator has "attempt quick start" in its gdb options. It helps a LOT.
Or you can switch to using MSVC compiler on Windows. That also switches your debugging to CDB instead of GDB and bypasses the problem entirely. You can just install MSVC compiler and plug it into QtCreator instead of mingw if you don't like MS IDE.
P.S. This also gives you readable core dumps which is a godsend.
See the comments on Zeks' answer. There he explains that switching from the MinGW toolchain to the Microsoft toolchain (compiler, debugger) solves the problem completely. Fortunately, Qt Creator supports the Microsoft toolchain so you don't need to switch IDEs.
After I did that, debugger launch time is now 4sec, and on app crash it there is zero delay. It also sped up builds a lot.
For reference, I've described how I've set up my system here.
I have managed to improve the debugging speed significantly after changing several settings:
Made sure the compiler is gcc.exe and not g++.exe in the Qt5.1.0\Tools\mingw48_32\bin folder
Unchecked Use Debugging Helper in the Tools->Options->Debugger->Locals & Expressions menu
Unchecked Stop when qWarning() is called and Stop when qFatal() is called
I have been developing a C++ application to run on a 64 bit Ubuntu 12.04. I develop the code on my 32 bit 12.04 Ubuntu laptop, then upload it to a git repository, pull it on the server and build the pulled source natively.
Until recently things worked well and I had no problems but today g++ 4.6.3 crashed when I tried to compile on the 64 bit server and I got an output telling me to submit a crash report (g++ 4.6.3 is the same version I have on my development machine also). The identical code did not cause a crash on my dev machine.
I am not asking why it crashed, but I would like to know what the problem was if possible. Does g++ produce any file logs when it encounters problems?
As far as I can tell my code is doing nothing controversial, I am not creating templates, I simply use a couple of boost libraries, mysql++, openssl and some static libraries I have written myself.
I really need to run this application every day so I want to fix this as soon as I can. I can think of the following ways to deal with things
Try and find out what aspect of my code caused the compiler to crash and rewrite my code accordingly.
Rent another server.
Upgrade (or downgrade) g++ or create an additional g++ on the server and try that. I am reluctant to do this as I have read that you can ruin your system when upgrading g++ on Ubuntu.
I use Eclipse to build everything on my dev machine and simply build code on my server using the Eclipse generated makefile that I have made part of the git project - I could write my own makefile in case something in there is causing the crash on the 64 bit server.
I would really welcome advice on how to proceed. I am not an expert on how compilers work internally and this is the first time I have encountered this kind of error so I am not quite sure what to do next.
I would really welcome advice on how to proceed
One reason for a crash might be hardware problem (faulty disk, disk controller, memory, or something else). This is hard to detect.
Another reason might be a compiler bug, but very unlikely.
What you can do is :
check the hardware of the server (run all possible checks you can think of). Try to compile many times on a different machine
make sure your system is not running out of virtual memory
upgrade or change the compiler, and see if it happens
There are various article explaining that g++ can crash because of HW problems :
crash during compiling - Most likely there is nothing wrong with your installation, your compiler or kernel. It very likely has something to do with your hardware. There are two exceptions to this "rule". You could be running low on virtual memory, or you could be installing Red Hat 5.x, 6.x or 7.x
crash during optimization
I wanted to shift from Visual Studio 2008 to Eclipse Helios for C++ dev. I tried in mac and found a lot of unstabilities while debugging. Then I tried on Linux and similar. This is the last problem I found:
http://www.eclipse.org/forums/index.php?t=msg&th=205832&start=0&S=0b23d01871ba30eea27e36afdf03712d
At the moment I am going to give up eclipse. I would just like to know how many of you succeeded using Eclipse Helios CDT for debugging C++ programs or if I am just a dammned, isolated case, before I give up or continue trying to go forward.
I use Eclipse Helios as my C++ IDE. Os is Ubuntu 10.04. I use it regularly for debugging and can't remember to have ever had any serious problems. I had never problems with "unstabilities" while working with projects of significant size including Qt applications.
I would suspect you are an isolated case. If you are more specific, we might be able to help. If you want to abandon Eclipse though, I have heard good things about Qt Creator but still consider Eclipse superior.
The only thing that bugs me while debugging is that the debugger doesn't respect breakpoints inside of template functions and source code is not shown for template functions. If I recall correctly, this is different for Qt Creator but am not sure right now.
I use Helios as well on Ubuntu 10.04, and Windows XP to debug my Qt projects built with mingw.
I've never had a problem.
I've never tried on a Mac though.
I've finally managed to run the QtCreator debugger on Windows after struggling with the Comodo Firewall incompatibilities.
I was hoping to switch from an older version of Qt and Visual C++ to the newest version of Qt and QtCreator, but the debugger performance is atrocious.
I have created a simple GUI with one window that does nothing else but display the window. After starting up QtCreator takes ~60MB RAM (Private bytes in Sysinternals process explorer).
When I start debugging, GDB is using 180MB. I start examining the main window pointer and it jumps to 313. Every time I try to inspect something, one of the cores jumps to 100% use and I have to wait for a few seconds for the information to show. This is just a toy program and I'm afraid that the real program that I want to switch will be much worse.
Is this kind of performance normal for MinGW? Would changing to the latest MinGW release improve things?
Visual C++ IDE + debugger + real-world program takes just close to 100MB of RAM and examining local variables is instantaneous.
Yesterday I built a copy of the Qt 4.5.2 libraries using MSVC 2008 and am using the QtCreator 1.2 MS CDB (Microsoft Console Debugger) support. It seems much faster than gdb. Building Qt for MSVC takes a few hours, but it might be worth trying.
Also, that means smaller Qt DLLs and EXEs as the MS compiler/linker is much better at removing unused code. Some of the Qt DLLs are less than half the size of their MinGW equivalents. Rumour has it that the C++ code the MS compiler generates is faster too.
I had to work with QtCreator a month ago. It's performance is awful, after 30 minutes of working with him, it will start to respond very slowly to everything. Maybe it's because it's still at the beginning.