Any way to stop Eclipse CDT build? - eclipse

I'm attempting to build a project in Eclipse CDT and the build process fails early on, but then takes minutes to finish computing and finally quit.
How, through the Eclipse IDE, can I stop the build process.
I know there must be some way because I can delete any random file from the Project Explorer and a box pops up with the processes and I can click the red box next to build and it quits. But I shouldn't be required to delete a random file to get that box to pop up. Where is it?

There is a "progress view" found at Windows->Show View->other->General->Progress. That has the little red square I need to stop any particular task.

FYI - there's also a setting in the Properties sheet to "Stop on first build error".
Under the C/C++ Build item in the Properties page, click on the configuration you wish to modify, choose the Behavior tab, and click the checkbox under "Build Settings" ("Stop on first build error").
You can still use John's method to stop the build at any time, but if you're looking to have the build stop when you first encounter an error instead of continuing on, this setting might be helpful.

I use -Wfatal-errors flag in Makefile in Eclipse to prevent polluting my console
-Wfatal-errors
This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further
error messages.
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Warning-Options.html

You can disable the console's annoying focus-stealing behavior both for the build messages (so you can get the progress dialog to stay open) and for your program's console output (when debugging multiple threads). Go to window->preferences->C/C++/Build/Console and you'll find an option "Bring console to top when building (if present)". Uncheck that and you then can pause the build as you wish. To keep your program output chilled you can go here: http://georgik.sinusgear.com/2011/12/22/how-to-disable-stealing-of-focus-by-console-in-eclipse/

Related

How can I stick a process to a specific console while having more that one console open?

I am using Eclipse Mars to write test applications. Sometimes I need to run two apps at the same time so I open two consoles on my Eclipse. I can change the process being viewed on one of the consoles, but as soon as the other process prints something, it switches both consoles to show that. How can I stick a process to a specific console?
As far as I know you can't assign a process to a console. BUT you can make a process appear on a specific console none the less. To reach that you must click 'Pin Console' for the program you don't want to be changed on startup. Then in the console of the other program uncheck 'Pin Console'. The next program you start will show up in the unpinned console. So you will have to pin and unpin before each start of either one of your programs.
Maybe someone else is interested in the other steps besides the pinning and unpinning:
In the console view uncheck the buttons for
Show console view when standard out changes
and
Show console view when standard error changes
then go to the drop down menu of the console view and click
new console view
then start your first part of the application and assign one of the available consoles to that process and then start the next part and assign that to the other console. You can position both consoles as you are used to with eclipse and watch both of them simultaneously.
I tested this for eclipse luna and neon (so mars (which is in between) should have the same feature).

Running my program from PyDev with one click?

I am developing using the PyDev plugin in Eclipse. My program uses several classes in several files. I usually run the program using the green "play" icon or using Control+F11. The only problem is that it will run the file, which is currently in "focus". Usually this is not the one containing the starting point of my application. As I run my program something like 200 times a day, this means that I need 200 extra click on the mouse and often forget about this.
Is there any way of setting the default file to launch?
Yes, change the launching to rerun the last launched, so Ctrl+F11 will launch the last one -- and use F9 to launch the one with focus -- See instructions and details at: http://pydev.org/manual_101_run.html
For me, the shortcut is Ctrl+Shift+F9. I don't think I've changed any keybindings, so its strange that it would be different from the official documentation.
Go to Run->Run History, and select the run that is your 'main' run. Now you should be able to use Ctrl-Shift+F9 from any other file to rerun your main. If it isn't Ctrl+Shift+F9 for you, look on the console window that should be at the bottom of your screen showing the stdout after every run. There is an icon on the top of it that has the green start arrow with a yellow arrow underneath it pointing to the right. That is the command to relaunch with the same configuration. If you hover over that, it should tell you the keyboard shortcut you need.

Debug in Eclipse - ClassNotFoundException

when i debug in Eclipse a simple console application, I get a lot of ClassNotFoundException lines in the debug Window. It is not an error, somewhat lower in another pane I get "Source not found.". I understand that it is because the source code of the required class is not available, buI would like to skip over these lines... I have to press a lot of times the "step over" or "step out" button to get out of these states.
What can I do in order to avoid these useless lines at all?
Thanks
I've been having this problem for a few months now. I'd be debugging a java app and every time I'd hit a constructor, eclipse would try to find matching java core library ClassNotFoundException's source code.
I solved this problem by right-clicking in Debug window on the ClassNotFoundException when I hit it, and clicking on Filter Type. I would then right-click in the debug window again and choose Edit Step Filters.... In the Edit Step Filters window I checked everything in the Defined Step Filters section and unchecked everything in the bottom of the window (Filter synthetic methods, Filter static initializers, etc).
Hope this helps others in the future.
After Launching Debug Mode.
Go to Window → Show View → Break Points.
Now you would be able to see Break Point tab in Debugging mode.
Uncheck the option "ClassNotFoundException: caught and uncaught".
While debugging try Step Return (F7 as shortcut) to get one level up at a time and thus out of the libs you don't have the source attached for.
In a normal application your own code (your java files) is mixed together with code of others (class files in libraries, runtime environment, etc.).
Each time you step into a class file you will get this "Source not found"-Warning. (as you already mentioned in your question)
At first you could try to get the source codes for the libraries and link them to your libraries (for example in "project setup => Preferences.../Java Build Path/Libraries => unfold a jar-libraries => Source attachment").
If no source code is available you have to use the debugger-comands to avoid jumping into that class files. "Step Out/Return" might help, but the "Debug View" (which can be found in the top left corner in your "Debug Perspective") could be even more helpful.
In the "Debug View" you can see each thread of your application. If you are currently debugging a thread you can there see the current stacktrace. Instead of clicking F6 and F7 all the time you can also navigate by clicking on an stacktrace-item there.
Tipp: I am using - (Rightclick->"run to line") a lot - this is quite helpful to run over loops, etc.
An occurence of ClassNotFoundException is most common in debugging in order to avoid these exceptions, In breakpoints window(Windows>Show View>BreakPoints) uncheck the "ClassNotFoundException: caught and uncaught" to continue with the normal debugging.

Eclipse doesn't stop at breakpoints

Eclipse 3.5.2 is not stopping in breakpoints. It's as if the debugger is using an older version of the source file.
Tried the usual refresh, clean all projects, build all, with no change.
Already in debug mode and the break point is checked.
*ok ended up deleting the whole project and checking it out again. but still curious what the issue was.
Perhaps you have pushed the Skip all Breakpoints button in the Breakpoints view.
Thanks guys, this really saved my day too.
I antecedently pressed on skip break points, if you did the same this will result on break point appearing with a backslash icon on them.
To bring it back to normal:
Switch to Debug perspective.
press on the breakpoints view tap -->> upper right hand corner of the screen, you also can go there by Window->show view-> breakpoints.
5th icon from the left you will see break point with backslash. press on that one.
To confirm, try putting break point on any line, and it should appear normally.
Press Ctrl + Alt + B
OR go through below steps
Clearing all Breakpoints fixed the issue
(within debugger perspective: Window -> Remove All Breakpoints).
Rebuilding the project did not work for me.
Sometimes you do start the debug mode but the debugger doesn't actually get attached/gets detached. I've also had this issue a few times when my laptop was reacting really slowly.
A reboot always solved it for me.
Also try doing a clean all (works miracles in Eclipse).
Please un check this from the Eclipse Menu.
Run->Skip all breakpoints.
I think this will be enabled permanently once You select the Remove all Break points option in the Debug/Breakpoints window.
Performing a "Clean All" worked for me.
Click on "Project" tab --> "Clean" menu-item.
In the "Clean" dialogue-box select "Clean all projects" radio-button. Leave the remaining values as default. Click "OK" button.
BINGO!!!The remote-debugging started working for me as beautiful as before.
It has also happened to me, in my case it was due to the GDB launcher, which I needed to turn to "Legacy Create Process Launcher". To do so,
either change the default launchers to the "Legacy Create Process Launcher", in Windows>Preferences>Run/Debug>Launching>Default Launchers.
or choose this launcher in the debug configuration of your application (Run>Debug configurations>choose your debug configuration). Under the "main" tab at the bottom, click on "Select other...", check the box "Use configuration specific settings" and choose "Legacy Create Process Launcher".
I had a conditional break point wrongly put on the method entry point. Removed that breakpoint and it worked.
Note: Tried Skip all Breakpoints, Clean all projects, Refresh, close Eclipse with no luck before nailing it.
In my case, somehow the breakpoints got automatically disabled because of this switch turned on, skip breakpoints.
Breakpoints have seemed to work and not-work on the versions of Eclipse I've used the last couple years. Currently I'm using Juno and just experienced breakpoints-not-working again. The solutions above, although good ones, didn't work in my case.
Here's what worked in my case:
deleted the project
check it back out from svn
import it into Eclipse again
run "mvn eclipse:eclipse"
Since the project is also a Groovy/Http-bulder/junit-test project, I had to:
convert the project from Java to Groovy
add /src/test/groovy to the Java Build Path (Source folders on build path)
include "**/*.groovy" on the Java Build Path for /src/test/groovy
I had all breakpoints enabled and configured as I should. But whenever I clicked "debug" it would only step through the program (press f5/f6) Turns out there was a rogue setting
Right Click project > debug configurations > "Debugger" tab > uncheck "Stop on startup at:" box
One reason for this situation can be, that you have pressed 'skip all breakpoints', when play- and another pictures are smaller than those normally are (because of higher resolution screen). Another thing can be, that break points are stopped only under VM threads, not under normal threads!
Go to (eclipse-workspace)\.metadata\.plugins\org.eclipse.wst.server.core and delete all tmp folders.
Clean and Restart server.
In my case I had to enable then disable an option in the Preferences.
I don't prefer the debug view to keep jumping when a breakpoint is hit so I disabled this option, but caused the issue in question.
The solution was to enable it again, start a debug session, the breakpoint is hit and shown in the UI, then disable again the option.
Looks like a bug in Eclipse 4.17
UPDATE
There is also another simpler way that will make Eclipse show the debugging highlight at the breakpoint or rather refresh the debugging UI to work as it should. After the breakpoint is reached, Eclipse will ask you to switch to debugging mode if you are not already in, click switch button, then activate the debug tab/view, you will notice that the stepping buttons are activated and the breakpoint line is highlighted.
First remove all 'toggle breakpoints' from the class file.
Then Eclipse requires a restart.
Then make sure 'Skip All breakpoints' is NOT enabled. If it is, make it disabled.
Then, add toggle breakpoint to the lines in your file and run on Debug mode.
A pop-up window must appear to confirm if you really want to Switch to debug mode. Say Yes and proceed.
I suddenly experienced the skipping of breakpoints as well in Eclipse Juno CDT. For me the issue was that I had set optimization levels up. Once I set it back to none it was working fine. To set optimization levels go to Project Properties -> C/C++ Build -> Settings -> Tool Settings pan depending on which compiler you are using go to -> Optimization and set Optimization Level to: None (-O0).
Hope this helps! Best
I had the same problem, and I found the real cause.
I had written some concurrent / multi-threads code, while I added some breakpoints inside the code running in a new thread. So, when JUnit tests ran over, and stopped soon, the code will not reach and stop at the breakpoints.
For this situation, we have to click and select "Keep JUnit running after a test run when debugging" check box at "Debug Configurations..."
switching workspace worked for me.
Go to File > Switch Workspace and choose different folder (workspace)
That's it and BINGO! Debugging started working for me as beautiful as before.
go breatpoint and click on 5th to eclipse->window>->show view->other->debug->breakpoint and click on 5th option (Skip All Breakpoints)
Make sure, that you are using the correct JRE version to debug your project. Especially if it's a third party project.
Also make sure, that there is no trigger point set for any breakpoint.
I had the same problem when I was using Eclipse Juno.. I installed Eclipse Indigo and it works fine. Try to reinstall eclipse.
A different solution worked for me. I also faced the same problem - debug points were not being updated, though they are shown correctly in the IDE editor and in Break Points tab.
My problem and solution are: While creating the project, the 'Default Output Folder' points to different location. At a later stage, I have mavenized the project, selecting "Project Right Click - Configure - Convert to Maven Project". So there are two sets of output folders exist in my project file system. Cleaning the project multiple times did not solve my problem. In the background it was pointing to different binary files. Finally, when I removed the Maven Feature and cleaned the project, this time everything worked fine. Env: Eclipse Juno and JRE is J2SDK 1.5.
I get all breakpoints skipped and marked as warnings when using -O2 in the compiler flags. Switched to -O0 -g in my makefile and breakpoints now work. Hope this helps.
If it doesn't stop even after unchecking SKIP ALL BREAKPOINTS, you can add this android.os.debug.waitfordebugger just before your breakpoint.
If you do this,your app will definitely wait for debugger at that point everytime,even if you are just running your app,which it will only find when your device is connected to eclipse.
After debugging you must remove this line for app to run properly or else android will just keep waiting for the debugger.
Try to restart eclipse, that works sometimes. I guess there is some kind of cache there.
In my case the debugged code in JBoss was older than the code in the Eclipse project. Rebuilding the .war solved the problem.
Facing same problem with Eclipse Luna.
Project clean didn't work.
Rebuild didn't work.
What makes it work is uninstall the app on the device before each debugging.
I use the Eclipse FileSync plugin for live remote debugging. Make sure you tick Allow different target folders & edit the Target folder file setting in the tree view.
Setting the Default target folder by the Browse... button without Allow different target folders will set all folders to the same target (I had both libs & classes set to the default for libs so my breakpoints did not update).
Since Eclipse 4.7/Oxygen released in June 2017, there is a new concept of "Triggers for breakpoints", which is displayed as a small "T" next to the breakpoint "blue bullet" icon.
All the other breakpoints that are initially suppressed by triggers
will be hit only after any of the trigger points has been hit. All the
triggers are disabled after a trigger point is hit and will be
re-enabled after the run.
In order to reset all the "trigger" flags, you need to do the following steps :
Switch to Debug perspective.
Right-click in the "Breakpoints" view
Select "Remove All Triggers".
Note : this step does not delete all your breakpoints, which occurs when selecting "Remove All" in the same contextual menu.
Note : the keyboard shortcut to enable the triggers is "Alt-R", which takes precedence on the shortcut to open the "Run" menu with its mnemonics, when the "Breakpoints" view is selected.

Restarting an app in Eclipse

Is there any way to restart a program in Eclipse? (preferably 1-click)
I really wish the console view had something like a restart button that would kill the app and restart it with the latest changes.
This always takes me at least three clicks. I click the down arrow next to the green circle with white triangle (play button) to open the dropdown menu, then I click to choose the Java main that I want to run, and then to stop I click the red square terminate button in the console view. Is there any easier way to do this that requires fewer clicks?
In Eclipse 4.1
open:
windows->Preferences->keys
in the filter text type: terminate and relaunch
In the binding add your binding (i use shift-F5)
For "when" select "In Windows"
This will do it in single shorcut for you.
Or install relaunch plugin:
https://bitbucket.org/mantis78/relaunch-plugin/wiki/Home
which will enable you to restart anywhere
If you use "build automatically", there is a good chance that your changes are applied on the running program, on the fly. As such, most changes will be effective directly without a need to restart.
If there is a structural difference and Eclipse can't inject the new code (for example if you change anonymous classes, or inheritance patterns), then you will be prompted with a dialog inviting you to restart the application in one click:
Exceptions are when you change the value of a static variable (or of the initialization of a class that won't be executed again until you restart the application). In this case indeed, you will need to restart explicitly with another method.
the console view has a terminate button (a red square) which stops the execution. then another click on the Run button (the green circle with triangle) begins execution again.
thats what i do - 2 clicks :)
If you're using Eclipse with Spring you could download the "Spring Tools X" plugin.
This will automatically add a start and relaunch button to the top bar menu.
It should be available on any perspective.
I haven't found an elegant solution for this problem, but if your program is short running and you can live with a few instances here and there, you can just use the run command. Its default shortcut is Ctrl+F11. Every time you press this, your application will restart. BUT! If you press this while your application is still running, another instance will be run because the "old" instance won't be automatically terminated.
There are ways to really terminate your application using shortcut keys, but that requires setting breakpoints and then using the "terminate" command, and that isn't very elegant.
When developing my own network application, I have added a code to check if the older instance is running, and if so, then send an agreed command over network socket for graceful shutdown. While this approach may not be the best as universal solution, it allows clean shutdown of the previous instance, rather than just killing it.
Easy way without plugin, every Eclipse !
Click the project from of this icon at this time hold the shift Button, Project will restart (Terminate and relaunch) with server port also.