How to remove "Debug Current Instruction Pointer" - eclipse

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.

Related

Eclipse C++: How to skip to first breakpoint?

When I start Eclipse C++ debugger, it starts from the first line side main(), and I have to step line-by-line until the end. How can I have it skip until the first breakpoint like Visual Studio? What's the point of having breakpoints if it starts from the beginning like this?
I wish to debug an event-based program, what's the good practice for that? I want it to start debugging when the event is raised. Thank you so much.
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.

How to disable eclipse switching to debug view while debugging

First this is NOT a question about perspectives. I already have the debugging perspective disabled while I'm debugging. My question is about the Debug view (Window -> Show view -> Other -> Debug -> Debug). This view pops up giving you information about threads running and where they are suspended and the like. My problem is that often times I find myself in need of just watching console output while stepping through code for whatever reason. My Console window is anchored in the same region of the eclipse IDE as the Debug view. If I close the debug view down there, I lose the ability to step over / into while stopped on a break point (the hotkeys don't work either, but the application still suspends right where it was when you closed the view). If I have the debug view open, every time I step over / into a method, the screen switches focus from the console back to the debug view. This is exceedingly annoying. How can I disable this?
Edit - I just did some testing, and the Debug view receives focus over anything else that's anchored in the same region as it. Regardless of what the other tabs purpose may be. There might be some exceptions, but surely there is a way to disable this someplace...
I also noticed that it doesn't switch to debug view with every step, in my case it switches when something is written to SDT Out.
One last Edit - I found a work around, it doesn't answer the question I asked but does solve my particular situation. Under Window -> Preferences -> Run/Debug -> Console there are two check boxes for show when program writes to standard out / standard error. If I check those, eclipse will first switch to the Debug view, then immediately switch back to the console.
Eclipse's Preferences under Run/Debug? There are two useful options you can change;
Activate the workbench when a breakpoint is hit
Activate the debug view when a breakpoint is hit
hopefully it will solve your problem. goodlouck
You can't. Anchor the Console in a different part stack so you can see its output along with the Debug view and the editor pane.
The only reason the step actions know which thread to operate on is because it's selected in the Debug view and the Debug view has focus.

Is there a keyboard shortcut for stopping the current console in Eclipse?

I'm developping a Java application with a class containing main. I can start the application using Ctrl+Alt+X J subsequently the application can be re-run by hitting Alt+R T Enter to choose the menu option for the first item in the Run history.
But to stop the application, I have to click on the small red square in the console view. This is annoying, because it forces me to use the mouse, type Alt+R T Enter then re-focus the editor using the mouse again.
Eclipse being so configurable, there must be a keyboard shortcut to stop the application run in the current console I haven't found. There are an entry in Window > Preferences > Keys called Terminate and Terminate and Relaunch but no matter what binding I assign or what when conditions I set and no matter if I use the Debug perspective or not, they don't seem to fire.
Please help an Eclipse newbie avoiding the mouse :)
Go to Preferences -> General -> Keys
Find "Terminate" Set your binding to whatever you want.
Then change "When" from "Debugging" to "Editing Java Source".

why can't I set up a breakpoint in 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.

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.