sometimes when I debug in Eclipse, I found some thing wrong so I want come back and debug again, but I want to do that just for couple statements.
I saw
How to step back in Eclipse debugger?
is it possible to "go back" in java eclipse debugger like dragging the arrow in VS
and I know about Drop to frame but I can't use this to step back any line I want. I need some thing else. For example if you use debug in Visual Studio, you can drag and drop the debug arrow anywhere you want. You can bring the debugger to previous statement and debug it again. I need something like this in Eclipse but Drop to frame doesn't do that.
Thanks.
The linked answers suggest to use a third-party product to provide exactly this feature. If you don't want to do that and are not satisfied with drop to frame, there is one more option. You can set a breakpoint before the interesting place (or just drop to that frame), and then evaluate arbitrary code in this context (see Eclipse Help or this blog post).
Related
First of all, I know my question is not a good question, I should say sorry for my this question, but this question confused me for a long time.
.Net/Visual Studio: I am coming from a .Net background. When I develop a project, I and my team are using the Visual Studio. When I debug the server side code (C# class code), it is very convenient since I use Visual Studio. I set the breakpoint, then I hover my mouse above the code, I can see what is the value of a variable or array values of a variable, so I can quickly know what is the value of a variable.
Java/Eclipse/Spring Tool Suite: When I was a student, all my courses are using Java with Eclipse, including course assignment and projects, and I found it was not convenient for debugging. Because I need to go to a debug mode, then I need to see a separate Windows within Eclipse, which shows the value of a variable in each row, this is not very efficient way to debug compared to debug in Visual Studio.
Now, I am going to develop the project using Java. This project is based on Spring framework. Then I found many people are using Spring Tool Suite, so I am going to use this IDE to develop my project.
My question is: Can we debug Java in an IDE like we debug in Visual Studio? What about debug code in Spring framework using Spring Tool Suite? Thanks.
Update:
All right, . I am testing this easy java program in Eclipse. I set the breakpoint, then I click "Run" -> "Debug", then I open a debug perspective. In the past, I only can see what is the value for variable a and b in Red Circle 2, but now, look like recently, when I put my mouse on variable a and b in Red Circle 1, I can see its value immediately? If yes, when this feature added to Eclipse? I am quite sure we cannot do so in Eclipse in the past.
Once you are actually debugging an application, you can hover over a variable in an open editor for the selected stack frame in the Debug view and see the variable's value. This is a long available feature.
You can also drag a view, using its title bar, out of the main window to create a new window if you want. I don't think this is heavily used, and may not work correctly with multiple screens, but it's there.
You're drawing a line based on IDE settings. Most likely, you're running in debug mode in VS even though you don't explicitly say it. That being said, your question is basic; of course, you can debug Java like C#.
Yes, of course, you can debug java code in Eclipse. Set a break point to the line you want to debug and select an object/variable/whichever and inspect it or add to watch.
Im trying to get the code flow of an open source platform. I have got the source code and ran the program from eclipse. The program has an option called "Run job" and I want to know where the control goes when that option is clicked. How can achieve this?
First, try to identify the control with the label "Run job".
You could do this by searching the source code in Eclipse with Search > File and then setting "Containing Text" to "Run job" and "File name patterns" to "*.java".
Probably in the same file, there is an ActionListener (or similar) added to the control that calls a method, when the control is clicked. This is the method you're looking for. (Add a breakpoint to see the flow in the debugger or try to understand it from the code.)
Apart from searching for the appropriate handlers and buttons in the source code (if you know the names), you can also enable tracing.
In your run configuration, there should be a tab for tracing. There, you'll want to enable some of the options under org.eclipse.ui that start with trace/.
You will get a lot of debug output, and there might be no trace option for the event you'd like to see. However it works well for things like keybindings (trace/keyBindings) and knowing which UI element got an event (trace/graphics). Note that some also take arguments, e.g. a commandId (something like org.eclipse.ui.edit.copy, will depend on your application).
You can find a small help text for each option here.
I started developing a game in Java with Eclipse. As you all know you have to debug a lot while coding. But I have the following issue:
My game is full-screen. If I run into a breakpoint it stops (like it should) and for some reason I can't switch window anymore (I am using Windows 7). I have to press Ctrl + Alt + Delete" and start the "Task manager" to be able to switch to Eclipse window and continue debugging.
So I tried to use window mode instead of full screen. Now if I run into a breakpoint the Eclipse window gets the focus (automatically) and I can debug easily.
So I thought it would be great to be in window mode, if and only if I am in debug mode, else it should be full screen.
For this I need to know if I am in debug mode or not. After reading this and this it seems like you can't check that easily, cause it depends on the VM you are using. Also it seems like the best solution is to use the Eclipse Debug/Run-Configuration and set a VM or program argument.
But how can I tell Eclipse to use this configuration only for debug mode? Or is there even a better way to determine, if debug is on or off?
It seems like the best way is to use arguments and pass them by using a Debug-Configuration and a Run-Configuration with the right values.
In Eclipse you have the possibility to add a Configuration to the Run list and the Debug list.
This can be done by going to the common tab inside the configurations and check the Debug and/or Run checkbox inside the "Display in favorite menu" section.
You can also edit the favorite list (add/remove/move entries) by clicking "Organize Favorites".
Note, that it does not prevent you from runing the Debug-Configuration or debuging the Run-Configuration.
The discussion here describes the "display view" in eclipse which allows one to to quickly evaluate java expressions. The thing is, when I open the display view the icons remain greyed out and I can't execute anything. The only icon that isn't is "clear console". The odd thing is, alot of the screenshots on the web show the same behaviour but the people posting about the feature don't mentioned it. There aren't any options in the context sensitive menu either. I'm trying it on a java project. I've tried it in the debug view and I get the same issue.
I'll provide a screenshot once my hosting is sorted.
I'm using eclipse 3.4.
To be able to use it, you're supposed to be in debug mode (set a breakpoint to freeze execution). That gives you a context, a stack frame to work in.
Once you're there, you select expressions in the display view and only then can you execute them, evaluate etc. If no text in the view is selected, none of the actions will be available.
As I understand, the purpose of the 'Display' view is to allow to evaluate expression during debug sessions. Are you trying to evaluate some expressions statically (i.e. with no running application in debug mode)?
Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable's value. Instead, hover behaves as if I were in normal Java perspective:
alt text http://michaelzanussi.com/wp-content/uploads/2009/11/debug_hover.png
I've tried cleaning the project, re-importing it, etc., all to no avail. Anything I'm missing here?
I went to Window - Preferences - Java - Editor - Hovers, hit "Restore Defaults" and "Apply" and that fixed it for me, even though nothing actually changed in the settings...
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.
I had this problem too once, I "just" had to restart eclipse, after that the hover mechanism worked again.
The problem was "fixed" by renaming the package.
For whatever reason, this refactoring triggered 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.
I had a similar issue and when I came across this question. My problem was that windows hover time was set to 20s or so (you can test if this is your problem by putting the mouse on a mistake and waiting for a min or so). The registry key "MouseHoverTime" was set to a large value of 200000 ms (normally 400). Fix it by going to start -> run -> "regedit" -> HKEY_CURRENT_USER\Control Panel\Mouse double click "MouseHoverTime" and setting it back to 400.
I think this had been done on my computer a while back to prevent hover popups in another program. Anyway, sorry that my answer doesn't directly apply to this question, but I'm hoping it'll help somebody like me that comes across this thread with a similar issue.
For C++ project, please add -ggdb -0g to the compiler option. Hope this solution can help eveyry C++ programer face with the same issue.