How to stop GDB from executing "break main" by default in Eclipse? - c

I'm working on a C project with Eclipse and MinGW. When running a debug build of this project, gdb always breaks on entering main(). I can see why this could be useful, but for my current project I don't want that to happen.
I've read that there is a command
(gdb) break main
which will accomplish the same behavior when running from the command line.
At the moment I do NOT have a .gdbinit file.
At the moment gdb doesn't stop on entering main when running from the command line, but it does when running from Eclipse.
How do I make GDB stop breaking on entering main by default within Eclipse?

Make sure you are in the c++ perspective, then go to menu Run -> Debug Configurations. Make sure your application is chosen in the left pane, press the Debugger tab, and uncheck Stop on startup at: checkbox.
EDIT: you can see a screen-shot here: Method/Function Breakpoints in Eclipse CDT

To set it for any new launch, On the menu Window->Preferences, Select C/C++->Debug->GDB item on the left, and then go to the Debug Configurations Defaults section and uncheck the "Stop at startup at:" checkbox on CDT 8.0 or later.
You can see the details here: How do I prevent the debugger from stopping on the first line?

Related

OSX Eclipse CDT stalls at the start of debugging: "Configuring GDB"

I have installed Eclipse CDT and GDB.
I created a simple "Hello World" C project.
When I try to debug the project, GDB starts to behave very chaotic: I am able to debug a few times, step through the code, etc., but then it starts stalling at the begining of the next debug session with the message "Configuring GDB".
After I restart Eclipse CDT sometimes I still cannot debug, and sometimes I can, but also just for a few times, and then again the same problem comes up: stalls with "Configuring GDB" message.
I have tried hard to find the pattern, but failed.
What could be the reason for such a chaotic behaviour?
p.s.
I forgot to mention that I did sign the /usr/local/bin/gdb executable (and verified it with codesign --verify --verbose gdb).
Edit:
The screenshot shows the 2 stuck sessions:

Console App using eclipse and mingw (not launching app in cms.exe)

I am putting together a Windows console app in Eclipse c/c++ Neon (Win 10) and Mingw.
When I run the program the output appears in the console window within Eclipse, but I need/want to be able to debug with the program running a a normal Windows console app (like it would in a vs studio console app).
I have tried adding -mwindows to the minGW in Command line pattern and in linker options. I tried a number of other things I found on the web.
I have spent hours searching and nothing seems to do the trick.
1) Create a file named .gdbinit (or it can be named whatever you want, but this one is the conventional)
2) Add a line set new-console on to the file. Save it.
3) Open "Debug Configurations" in the Eclipse, and select your project debug configuration.
4) Go to the "Debugger" tab.
5) Point the "GDB command file" to the file you have created.
Done! now run this debug configuration.

KDevelop not executing Hello World program

I am using KDevelop 4.6.0 on Ubuntu 14.04.
At one point I saw the output of my hello world program, but now I can build it, but not execute it. That is, if I press the Execute button I am presented with a Launch Configurations dialog which gives me a choice of either a Global configuration or a PlayingAround configuration (my project name). However, no matter which configuration is chosen, nothing happens. No error message, no output, nothing.
Click on that "Add New..." button at the left-top corner. This would allow you to create a launch for any targets created with add_executable from CMake as well as arbitrary executable target.

How can I set KDevelop to compile codes with gcc properly?

I just downloaded KDevelop from Ubuntu Software Center, and have gcc.
I want to see anything happens by pressing F9 but KDevelop says I need to configure a launcher first. And all I know about the setting window is I have to put 'gcc' in somewhere on the window, as well as path to the source code file and path to the executable file it will make.
I have no any knowledge about this window, no any syntax to use in it and can't find it anywhere on the web. Now I desperately require some help. I want to make KDevelop to compile and debug with already-installed gcc and gdb.
It asks you of which executable to debug. You, i suppose, don't want to debug gcc, so you should set this field to your executable. You can also select Project Target option, and choose CMake target that corresponds to your executable.
This step happens after the build step. Make sure your build process is working first (F8).
The window above lets you select which executable in your project should be run when the launch button is pressed.
If your project is created in KDevelop or otherwise uses CMake as the build system, this should be configured by default and use the "target" part of the dialog.
Otherwise the executable should point to the executable you created as part the build process that you want to test.

Debugging in Dev-C++ makes IDE crash and not respond

I'd love to ask someone to hint me what to do. I have installed Dev-C++ on my computer (the 5.11 ver.)
I don't know what happened to it, if it's Windows 8.1 problem or some other I really don't know, but when I start to debug, it simply stops working.
What exactly happens:
I open dev-c++, then I open my *.c file. I set a breakpoint in my source code, and when I hit debug, a pop-up windows shows:
You have not enabled debugging info (-g) and/or stripped it from executable (-s) in Compiler Options.
Do you want to correct this now?
And when I hit yes, it simply stops to respond, and crashes.
I have never occured such situation, because on every computer I have worked, I'd got no problem with debugging on Dev-C++. Even running it in compatibility mode didn't help.
I really don't know what to do. For any help, thanks in advance!
For me to fix by following as below
Go to Tools -> Compiler option
Change from TMD-GCC 4.9.2 64 bit Release to TMD-GCC 4.9.2 64 bit Debug
Put the option -g as in the picture
Then click OK and run again!
Hope it will help!
GO to Tools > Compiler Option >
On select Compiler Set to Configure >> TDM-GCC 4.9.2 64 bit Debug
Now in general tap space put -g
Most Important : Rebuild All (F12) **
Open File -> New -> Project -> Console Application or Empty project
Write a project_name and select OK button
write your code and Save as main.c in the same folder you saved you .dev file
add watcher any line you want and debug it.
Thats all. You don't need to add any parameter to anywhere.
You have to first set up your compiler property by adding -g to both commands fields. Here is a YouTube video shows you how to do that.
https://www.youtube.com/watch?v=EOnl-Ojd66Q
I'm also using window 8, and after following the video, I still got the same pop up widow with the same message. I found out if you click no for "Do you want to correct this now" the debugger will start working. I don't know why, but it works for me. Good luck!
Go to Tools => Compiler options.
Then select TDM-GCC 4.9.2 64-BIT DEBUG
Worked for me.
first you have to create a project; then copy your code into the project; set the following compiler option: settings tab -> code generation : disable all optimizations and finally settings tab -> linker: set to yes the generating debugging information and the strip executable choices. good luck
Follow these steps:
a) Tools -> Compiler Options.
b) Put -g in both boxes of the compiler tab.
c) Make sure both the boxes with "Add the following...." are checked and then hit ok.
adding the -g manually did not work for me.
This is what worked for me :
As other said, you have to create a new PROJECT, then paste your old code into it.
after that, just press the debugger button as you would, it will ask to put the -g for you, and this time when you say YES, it will not crash. It will work as a charm.
Watch this video to clarify :
https://www.youtube.com/watch?v=xFpShi0yAc4
I also got the same problem when I ran my Program without compiling.
That was only the reason for this crashes and errors for me.
Dev-C++ IDE requires compilation first then after it allows to run the program unlike other IDE like C-Free which automatically compiles first and run the program for you.
Use F11 shortcut key for compile and run the program for Dev-C++ IDE.
It works for me.

Resources