I want to debug an application in Linux.
The application is created in C++. The GUI is created using QT.
The GUI is linked with a static library that can be treated as the back end of the application.
I want to debug the static library but am not sure how to do that.
I tried using gdb
gdb GUI
But how can I attach the library?
Has anyone had experience in debugging libraries in linux?
gdb will automatically debug functions in the library when they are called. just call it like
gdb ./foo
run
:) . Be sure you build foo with debugging flags (-g3 will enable all debugging stuffs for gcc :). You should not optimize when debugging (pass at most -O1 to gcc, do not optimize further). It can confuse the debugger.
If you want to debug the library code itself, you'll need to build the library with the -g compiler flag (as well as building the executable with -g as litb pointed out). Otherwise gdb will step through your code fine but will throw up its hands each time you make a library call.
You can Try KDbg, DDD - Data Display Debugger, Code::Blocks
Ulike DDD, others are IDE with debugger integrated but core debugger [gdb] remains same in those IDE. only thing is that you will get oragnized view of debugger view in GUI.
Also try Eclipse+CDT pluggin. it's also good.
A little-known alternative is gdbtui which uses a curses based interface.
You can also use Kdbg or ddd
Related
my Qt (QML/C++) application crashes and I can not find the reason why. I tried to output a lot of information but some signal/slot connection probably causes a crash. I spent many hours trying to find the reason but I failed.
The only good point is that I can reproduce the crash whenever I want.
Unfortunately I don't know hot to use the included GDB debugger. This is the output I got:
How do I find from this what happened and where? I need to find at least the function, in which my application crashed.
Or what else could I try? Unfortunately I can not disable the signal/slot connections or the associated functions, because then I can not get to the point, where it crashes.
Qt has detailed documentation on how to install a debugger found here: QtCreator Debugger
MingW does have a GDB that can be used to debug the application better. You can also use CDB to debug, just depends on your preference.
Once that is installed, you'll be able to set breakpoints and check variable information to see where your program is crashing using the Debugger view in QtCreator.
Tools->Options->Build & Run
If you have Qt version kit like this you need to check debuggers.
https://i.stack.imgur.com/LaY1p.png
https://i.stack.imgur.com/8kTG6.png
You need to install MinGW and after install you will be have debugger. After install press F5 to start debuging.
I'm making a wxWidget application for windows. I'm working with code:blocks 13.12 and MinGW 4.8 in windows 7.
I enable the -pg option in settings->compiler and after compiling try to open the plugins->code profiler and the result is this:
gprof:
file`C:\Users\josele\Documents\C_C++\DLL\SQLManager\bin\Release\SQLManager.exe'
has no symbols
Basicly I don't know how profiling works in code:block and also my general knowledge of profiling is quite reduced.
I'm looking for solve this or a tutorial of: how profiling works in code:blocks?.
If you need more information, only let me know. Thank you in advance.
PD. I also run the .exe before calling the plugins->code profiler with a positive exit of the program
I just solve that problem with this posts:
http://forums.codeblocks.org/index.php?topic=12237.0
http://forums.codeblocks.org/index.php?topic=14798.0
I went to Project->build options and there I turn off optimizations and enable the pofiler.
What solved it for me was turning off the "-s" compiler flag, which seems to be on by default in CB release flags.
On Linux, I have some C++ programs built with my own makefiles, and I'm looking for some GUI debuggers to debug them at source level.
Previously I use KDbg(2.5.2) on openSUSE(12.3). It works but with some very annoying limitation, e.g., I cannot set a breakpoint when the debugged program is not trapped by Kdbg -- I mean, in order to set a new breakpoint, I have to set it before the program is launched or the program pauses on hitting an already set breakpoint.
Now I try to use Eclipse CDT. I got eclipse-cpp-juno-SR2-linux-gtk.tar.gz but find that I don't know how to load my executable so to start debugging.
I googled with words like 『eclipse debug pre-built C binary』, but few seems to care about this feature.
Can Eclipse CDT really do that? If Eclipse CDT can't, is there any better alternatives to KDbg? Please help.
According to hint from this answer, https://stackoverflow.com/a/248119/151453 , I finally figure out how to do it.
The key point is: In the Eclipse CDT project, create/edit a Launch Configuration so to tell the debugger what executable to load.
Now I have to admit, Eclipse CDT does quite well in C++ code debugging far better than KDbg.
Some screen shot below, on openSUSE 12.3 .
Now we can Run -> Debug (F11)
Debugger automatically pauses the program at main()'s first statement.
The Stand-alone Debugger is an Eclipse application which packages the Eclipse plug-ins from the CDT (C/C++ Development Tools) project into an application that can be started from a command-line script:
bash /path/scripts/cdtdebug.sh -e executable [args]
I'm trying to use QtCreator as an IDE for Windows platform. So far I have managed to create a "kit" that uses cygwin's gcc compiler, and to build a non-qt "hello world" project. When I try to debug the project, I get
"The debugger could not load the debugging helper library."
error and can see only assembler code. I have installed QtCreator as a standalone application, so I don't have either qt lib or mingw. If anybody knows how to make QtCreator debug projects using cygwin's gdb, I would really appreciate it.
P.S: The reason why I want to use QtCreator as an IDE is that Eclipse's indexer fails on parsing boost sources, it eats up way too much memory and I have to turn it off to make the IDE operable. And neither autocomplete or navigation of the class hierarchy works without the indexer.
I’m porting a C++ sdk from Windows to Mac OSX 10.5. I have a problem in Xcode where my breakpoints in certain files will only be hit if I set them while debugging. If I stop debugging and then restart, the breakpoints no longer get hit. If I add them while not debugging, they don't get hit. This is only in certain files and my breakpoints are always dark blue. i.e. I can’t tell the difference between a breakpoint that will get hit and one that won’t.
Specifically, my sdk is made up of various dynamic libraries. These are built using Perforce jam, which calls the various compile and link executables depending on my OS and compiler version (such as Visual Studio’s cl.exe and link.exe). I have a simple (unit testing) command line application that links to these dynamic libraries and calls code in them. This application on Windows is a Visual Studio project, in which I set breakpoints on library code and expect them to be hit.
I’ve created the same C++ command line utility application in Xcode 3.1.2 that links to the sdk dylibs and calls code in them. Some of the breakpoints work fine. I can set breakpoints in code that’s called from the troublesome code, and step out to the troublesome code, which I can then step through fine. The troublesome code is compiled into the same dylib as code that works fine. It’s also long and complicated enough not to be a candidate for inlining.
I’ve tried the following:
Turn Load symbols lazily off.
Compile with both gcc 4.0 and gcc 4.2.
Do a full clean and shutdown.
Delete the user-specific files of the xcodeproj package.
Rename the files so they can’t clash with system files.
Clear everything out of the Breakpoints window.
Create a new Xcode project.
My application is compiled in debug with DWARF format and my libraries are built with the –g flag (along with –v, –arch i386 and –fvisibility-inlines-hidden).
Help would be much appreciated. Thanks.
Update: sorry for not updating this, my Mac port project was postponed. I never resolved this, but discovered that it actually only occurs in constructor bodies. I'll revisit this as and when I hit the problem again.
Have you tried these?
Why aren't my breakpoints working?
Not really an answer: You should make a bug report in the official Apple bugtracker. The chances are high that you get an answer sooner or later there - or perhaps it is really a bug.