Breakpoints are deleted in Eclipse CDT and MinGW using Windows - c++

In a simple Hello World Project in Eclipse CDT (version: Kepler) on Windows 7, I tried to set breakpoints to debug the program.
However, when the program is launched, the debugger stops at the first line of main(), and when the Resume button is pressed, all the breakpoints are skipped and the program terminates with: expect signal SIGINT when the program is resumed.
A strange thing happened too: the same installation on a second computer in which the username does not include spaces works fine.
The console for gdb traces does not report anything strange. The breakpoints are set and the execution does not report other errors (but I don't assure this is the problem).
The same settings are used on MacOS X too, but here it works fine.
Any hints? Thank you.

Related

CLion run program in separate system terminal

I have an ncurses program that I'd like to interactively debug using CLion. The problem is that when I run the program in CLion to debug it, the inbuilt console where the program is run doesn't display the output of the ncurses program properly.
I'd like to have the program run in my systems terminal so I can see the output properly whilst debugging the program with CLions debugger.
Is there any way to do this?
The best way to accomplish this is to use GDB now it can be really frustrating to get started so Ill show you how I accomplished it in linux
open a terminal and go to your project debug file and type gdbserver localhost:1234 ./myFile
open clion to myFile project and in the upper right corner you should see a build all (or your projects name) click it and go to "edit configurations"
in the upper left corner you should see a plus sign, click it and press "GDB remote debug"
then in "target remote" type tcp:127.0.0.1:1234
Next in "path mappings" press the plus and type /location/to/file/myFile (same file as in 1.) in both Remote and Location
Press OK and in the upper right corner select the name of the configuration that you just made and press debug
you might need to try to restart the gdbserver one more time for this to work but if you did all the steps above you should see a debug prompt come up and on the terminal you should see your project running.
There are some limitations with this for example you always have to run gdbserver localhost:1234 ./myFile command on your terminal for it to work.
Some Video/documentation that helped me:
Debugging with GDB at 33:35 (Video by JetBrain)
GDB documentation on Jetbrain
I hope this helped :)
In other debuggers, you would do this by running the ncurses application in a terminal, and attaching the debugger to the process using ncurses.
Doing that avoids interference between ncurses (which changes the terminal I/O modes) and the debugger's command-line.
The attach feature is a recently released feature of the CLions debugger:
Further reading:
More power to debug: Attach to local process (January 20, 2016)
CLion 1.2 roadmap (August 31, 2015)
Debugging in CLion (May 8, 2015 )
CLion answers frequently asked questions (September 16, 2014)
Debugging ncurses application with gdb
Using GNU's GDB Debugger:
Debugging Ncurses Programs

Remote gdb stops at every event

I'm having remote ARM Linux box which I need to debug.
The server is started:
gdbserver :12345 ./my_app
The client:
./arm-am3354-linux-gnueabihf-gdb ~/
(gdb) target remote dev_r:12345
(gdb) continue
Then I'm trying to pause the app with Ctrl+C, but the gdb stops with:
[Inferior 1 (process 2766) exited with code 01]
And on server:
Child exited with status 1
GDBserver exiting
Story:
I was trying to use remote debugging in QtCreator, but when setting breakpoints in run-time the gdb was crashing in the same way. Also the breakpoints and pause is not working in QtCreator.
I was trying also another gdb like gdb-multiarch and the one from android-sdk.
Update:
Debugging small program aka Hello World works. Local Debugging (on x86) works too. The app itself has hundred thousand lines of code, shared and static libraries.
Partial solution:
Probably the sysroot for embedded platform that I've got was invalid. After copying /lib/ and /usr/ from the target device and setting it as
set sysroot /home/karel/sysroot
I'm able to set breakpoints and the app stops at them. The pause however is still stopping the remote app. The same for QtCreator: Tools->Options->Debugger->GDB->Additional Attach Commands
I had a similar (or even exactly the same?) issue with debugging my application running on the EGLFS platform. Debugging when built with Qt 5.4 was working perfectly fine, debugging with Qt 5.5 did behave as you describe.
After hours of searching, I found that my application on Qt 5.5 exited when receiving a SIGINT, whereas on Qt 5.4, the debugger could pause the application as expected. Since GDB sends SIGINT when trying to pause the application or setting / removing a breakpoint, this was where trouble started.
After some more research, I finally found the following commit to Qt 5.5: Fix up signal handling in QFbVtHandler. At the very end, you see that when receiving SIGINT or SIGTERM, the handleInt() handler is called where we finally run into _exit(1). Setting a breakpoint there confirmed that this is exactly what happens when trying to pause or set a breakpoint with GDB.
Solution that worked for me: I have created a patch to qfbvthandler.cpp, simply removing the #define VTH_ENABLED line.
GDB debugging is now again working like a charm.
Note: Even though qfbvthandler.cpp has been updated in Qt5.6 and upwards, I suspect the behaviour would still be the same. I however don't have a workspace set up in order to test this.

Eclipse will not stop at breakpoint and puts thread state into Running: User Request

Recently, Eclipse SDK decided to kill my brain cells.
Out of the blue, it just stopped pausing at breakpoints. I do see it hit the breakpoint, but right then window loses focus and in the thread/callstack window it shows
MyApp [C/C++ Application]
MyApp [18556][cores:1]
Thread [2] (Running : Container)
Thread [1] (Running : User Request)
gdb
I see when i hits my breakpoint and it takes a blink of an eye before it goes into above state. My app stops responding and working and i have to kill it.
My app is a non GUI application which runs in linux as a background task, it reads and writes files, performs communication through COM and TCP/UDP. No user input is ever requested or anything like that.
There are tons of people who have problems with eclipse having problems with breakpoints, however they all are about java projects and or windows version of eclipse and none of the provided solutions work for me.
So far i have:
Rebuilt index.
Cleaned and rebuild project.
Deleted all debug files, makefile, binary and built again.
Cleared all breakpoints.
Made sure it was not set to ignore breakpoints.
and probably more which i already forgot.
Eclipse version is 4.2.1
Linux: Arch linux which was not updated for like 2 years now.
Project is C++.
What other information do i need to provide?
How can i solve this problem. I can't debug my application :(
I resolved this problem in this way: "Run" -> "Debug Configuration" -> select you configuration -> Debugger.
Then check the checkbox which shows "Use external console for inferior (open a new console window for input/output)".

Stepping through the debbuger in qtcreator causes gdb crash after a couple seconds

After I step through any code in this file in particular in a static library, gdb crashes after a couple of seconds.
I can step through other parts of the static library and shared libs that I have loaded and it works fine. The program runs fine and does not crash after gdb crashes.
gdb version 7.5.91.20130417-cvs-ubuntu on linux mint 15
How do I stop gdb from crashing in qtcreator?
If GDB is crashing, that sounds like a bug in GDB, from their docs:
If the debugger gets a fatal signal, for any input whatever, that is a gdb bug.
Reliable debuggers never crash.
Which version are you running/does upgrading to a newer version help?
provided as a supplementation:
I also encounter this gdb crash with qtcreator 5.0,after upgrade to qtcreator 6.0.1 ,error still existed with
"gdb crashed unexpectedly exit"
run the qt project is ok,when debugging ,and the qtcreator hit a breakpoint ,gdb will crash in about 3 seconds.
how I fix it:
remove cached QtProject folder under current user.
find . -name QtProject
in current user directory.
and remove the folder.

Problems with debugging using gdb

I've got a problem with gdb debugger. My console app shows me incorrect action results (some trash instead of normal string which I've got from XML ater the parsing) if I run it under a debugger plus I get SIGINT ( I don't output eol character and don't hit ctrl+c). Running my app with no attached debugger (just double click on .exe or Run menu from IDE) shows me correct results. What is the problem?
Some Info:
Windows 7 Pro Sp1 x86
gdb 7.3.1 (MinGW) and gcc 4.6.2 (MinGW)
Eclipse 3.7.1
Here is a gdb trace.
At this screenshot you can see the settings
Probably you have some memory corruption in your application and and they become visible when you use the debugger. In order to solve the problem we need to take a look on your source code.