why can't I set up a breakpoint in eclipse? - eclipse

For some odd reason, I can't use breakpoints in my eclipse project. All breakpoints that I set have a diagonal line on them, above the dot in the respective line (on the left margin of the window), as if they are blocked. When I run in debug mode, the breakpoints are ignored. Any ideas?

You've probably just pressed "Skip All Breakpoints" in the Breakpoint view - simply press it again.
Default key bindings are: Ctrl + Alt + B.

This doesn't exactly answer the OPs question, but when trying to double click to add break points, I was getting messages stating "this feature is not enabled".
I had to right click on the break point bar and select "Breakpoint Types" -> "C/C++ Breakpoints" instead of "Default". Then it worked fine.

in python, I had to go to:
windows->perspective->Open Perspective->Debug
then select the Breakpoints tab and make sure the zero with the slash (skip all breakpoints) is not selected (you can also use Ctrl-Alt-B to toggle it).

Open Debug View
Open Breakpoint Perspective
Right-click all breakpoints there
Press Enable

My "toggle breakpoint" and other menu options were disabled. I restarted Eclipse (Kepler SR1) and they came back enabled. I could set breakpoints again!

In my case, I'd edited my code during debugging, adding a null-check so I could place a breakpoint to stop execution only when a certain value was null. I couldn't add a breakpoint because the line of code in question was not present in the running application.
In Java, certain code changes can be woven in as soon as the file is saved, so in my case, remembering to save the changes was enough to enable placing a breakpoint.
For changes that can't be woven in, the application must be restarted before the new lines of code will be present.

In my case, I opened up the Breakpoints view, clicked 'remove all breakpoints' and then toggled the 'skip all breakpoints' option off, then on. This allowed me to set breakpoints again. This was after a restart of eclipse failed to help.

I was having a simular issue, for me the standard code-editor changed after installing a new plugin from Marketplace. Apparently the Plugin thought to change the default-editor for a lot of file-types, not only the one I installed it for. The new editor did not allow setting breakpoints but I hadn't known it changed at the time. When I right-clicked my source-file in the Project-explorer I saw under open-with the new editor listed on top. When I opened with the previous editor, everything went back to normal.

Related

is there a way to toggle search window results in eclipse

I am not sure if this is a bug, I tried uninstalling and reinstalling eclipse but seems like the problem has been saved in cache somewhere. Whenever I do a file search or C/C++ search with eclipse (either by clicking on the icon, or by typing ctrl+H), I do not see a search window pop up with results.
Same thing when I right click on a term and look for references or declarations in the workspace/project. I only see the occurrences Highlighted in the files, but that means I would need to manually check each file, which is just not doable. I also tried resetting the perspective, no luck!
Results in highlights, but no result window on the right side like there normally is:
I do not understand why this happens, I wonder if I disabled the search windows with a shortcut, this already happened with disabling the breakpoints and it took me a while to figure it out. Is there a way to toggle the appearance of the window? And if it really is a bug, how can I destroy all of the program's cache, because uninstalling by itself didn't work, there was a few settings that remained with the fresh installation.
Thanks!
There is a setting in the Search Preferences:
Window->Preferences --> General->Search
Then the search view should open up after starting the search.

How to remove "Debug Current Instruction Pointer"

I tried to use the debugger in Eclipse, but when I hit my
breakpoints, the Eclipse "Debug Current Instruction Pointer" is often
pointing at the wrong source line.I really want to remove "Debug Current Instruction Pointer". "Project -> Clean..." doesn't seem to help, nor does
restarting Eclipse, nor does rebooting.
The "Debug Current Instruction Pointer" is the position where you paused debugging last time. You can simply resolve it by following the below two steps
Go to the "Debug" preference/panel
Then click on the red square button to terminate the debugging you were executing last time or press Ctrl+F2 (Windows)
Now, just debug the program again. The execution will be starting from the "Toggle Breakpoint".
Note: You can delete the Toggle Breakpoint by double click on the line number and redefine the new according to your requirements by right click on targeted line number and select "Toggle BreakPoint" or press Ctrl+Shift+B (Windows)
Go to the debug view (as your current debug session is running) and complete or terminate current debugging session. this way you will get rid of "Debug Current Instruction Pointer"
What helped me was remove all breakpoints - right-click, RemoveAll.
sometimes breakpoints remain in eclipse list even after we remove them by clicking over them, to remove
Show Breakpoints view by navigating menu
Window>>Show View>>Other>> Select Debug>>Breakpoints
In Breakpoints view, uncheck unnecessary breakpoints
To prevent this pointer from ever being displayed in the first place, go to
Preferences -> General -> Editors -> Text Editors -> Annotations ->
select Debug Current Instruction Pointer -> uncheck "Vertical ruler"
box
"Debug Current Insturction Pointer" isn't something you would want to remove since it is not something that is set in any way, ist just a pointer to the current instruction where the debugger has paused your application. You can see that easily if you just step through your application and see how the "Debug Current Insturction Pointer" is moving along.
If you think it is pointing at the wrong source-line there are two reasons I can think of right now:
There are some "old" breakpoints left from earlier debug-sessions. You should see the breakpoint-marker and be able to remove it. If you want to get rid of all existing breakpoints just go to the breakpoints-view and remove them all using the double-X-icon.
The source-file shown in the debug-window doesn't match the class file that is currently running. This is most likely to happen in some imported libraries and not in your own project's code, but if it still does happen a clean/rebuild should take care of the problem.
You need to get out of the current debug session. Go to the debug console and end the current session by hitting the red square button.
This should remove all the debug current instruction pointers.
Check the arguments written in Run Configuration, because they can be wrong.
To reach Run Configuration, right click the project's main class -> Run As -> Run Configurations -> Java Application on menu -> Arguments. In the text Area write your arguments and try to debug again.

Is it possible to save a set of breakpoints?

I have a set of breakpoints which I used for debugging one issue. When I want to debug something else, these breakpoints are annoying, so I need to disable/delete them. However, I feel that I might want to be able to recreate the first set of breakpoints later.
Is it possible to save all currently active breakpoints so that you can switch between different sets of breakpoints with just one operation?
If I have 30 breakpoints, it would be very tedious to recreate/reenable them all manually.
In Eclipse (debug perspective -> breakpoints) select all the breakpoints, right click, export breakpoints!
You can use breakpoint working sets - see eclipse help.
If you can't find the Breakpoints tab, open it on: Window > Show View > Breakpoints.
Then, as said before: Ctrl+A to select all breakpoints > right click > Export Breakpoints....

Not working - Hover on variable to see value in debug prespective in Eclipse

I am using classic Eclipse 3.6.1.
I have a Java project which is throwing an exception because of a stack overflow.
Unlike other editors, when I hover my mouse pointer on a variable it does not show me the value of that variable.
Here are the settings in
Window->Preferences->Java->Editor->Hovers
Combined Hover - Shift
Variable Values - Ctrl
Source - Shift+Ctrl
But this doesn't seem to be working. I have seen threads by others about this same problem but could not find a solution. Is this a bug that hasn't been fixed yet?
Thanks!
Go to Window - Preferences - Java - Editor - Hovers.
Is "Combined Hover" selected? Uncheck it; apply; close the window; restart debugging session; go back; check it again; apply.
If the above doesn't help, you can check "Variable Values" option and specify a modifier key for it. Not as convenient as "combined", but should work.
The problem gets "fixed" by renaming the package.
For whatever reason, this refactoring triggers something in Eclipse, and immediately I was able to view variable values during debugging. Also, when I go back into Preferences under Hovers, I can now see the "Variable Values" option.
In my case Preferences under Hovers were checked and enabled. Even after that it was not showing values when I move the mouse on the variable. Problem has been fixed by simply closing and reopening the Eclipse (I was using Eclipse with Python).

How to change back the perspective after terminating the debugged process in Eclipse?

Eclipse by default automatically switches to the Debug perspective when you hit a breakpoint.
However, it is annoying me that it doesn't automatically switch back to the previous perspective (say, Java) when terminating the process.
It just stays in the debug perspective even though there is nothing to debug because nothing is running.
To complete mark's answer, that option tells Eclipse when to switch to the associated perspective upon program suspension - meaning when a breakpoint is hit, it will switch to Debug perspective.
Switching back to another perspective after you're done debugging has to be:
manual (mouse click)
manual ("Switch Perspective" shortcut CTRL F8)
automatic: Debug Perspective Auto Closer, which supplements bug 46336. (initially reported by zim)
Debug Perspective Auto Closer
Automatically opens previous perspective when debugging ends.
Behaviors: (configurable: Preferences -> Debug Perspective Auto Closer)
[default] when all debug launches have terminated, changes to perspective active on first launch
when any debug launch has terminated, changes to perspective active on that launch
If you want to avoid it switching to Debug in the first place, you can choose "Never" as the option (introduced in Eclipse 3.2 at the time).
(You can find the given Preferences page in Run/Debug > Perspective)
If you want to switch back in the situation where the debugged program terminates normally (Not when you want to stop debugging it yourself), you may hope Eclipse figures out that your program terminates normally and switch to a "default" perspective at that time...
However, there is no notion of "default" perspective, so how would Eclipse knows which one to switch to ? (the "Preferences/Perspectives/Make default" is only for the "Open Perspective" dialog, but that may not be the same perspective than the one you actually want to switch back to after a debug)
Also, should Eclipse closes the Debug perspective or just changes to a different one ?
What if there is more than one program running -- when one terminates, you might still be interested in debugging the other one, or maybe not.
The point is, the decision about when to change perspective (and what perspective to change to) is not reasonable for the machine to make -- it requires a person knowing what he wants to do next.
Ctrl + F8, the default shortcut to change views, reduces the pain a bit.
I filed a bug for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327983
I do not think it's possible to have eclipse switch back automatically but you can do it with the click of a button in the top-right of your window
you would need to write eclipse plugin
here i found example how in plugin switch perspective
As of 2015, this very basix UI woe is not addressed in Eclipse: the official bug report is assigned (but not fixed).
Fortunately, Sven Ramuschkat and Dirk Eismann wrote a plugin for that: the Perspective Switcher Plugin for Eclipse / Flash Builder
the Plugin will now automatically switch back from a Debug perspective to the previous non-Debug perspective as soon as the Debug session is terminated
It works on Eclipse Luna (and above)
Installation
Download the zip file , uncompress and copy the jar file in your eclipse/plugins folder.
Once it's done, you will see a new Preference pane.
Everything is configured for Eclipse to switch back to Java perspective if you have a java or properties file opened when the debugging session ends.