I am using Eclipse IDE (Helios Version)
While debugging in Eclipse , is it possible to edit the source and continue debugging ??
For example i have this file
While debugging when i tried to modify the a4 value during debugging its not reflecting ??
public class Tes {
public static void main(String args[]) {
int a4 = 15;
for (int i = 0; i < a4; i++) {
System.out.println(i);
}
}
}
Yes it is possible to edit the source and continue debugging in Eclipse! You'll find extensive information here: Debugging with the Eclipse Platform (scroll down to the section Hotswap Bug Fixing: On-the-fly code fixing).
If you are running Java Virtual Machine (JVM) V1.4 or higher, Eclipse
supports a feature called Hotswap Bug Fixing (not available in JVM
V1.3 or lower). It allows the changing of source code during a
debugger session, which is better than exiting the application,
changing the code, recompiling, then starting another debugging
session. To use this function, simply change the code in the editor
and resume debugging.
There are some cases where the feature will not work. E.g. if you make changes to your main method's a4 variable, the JVM will not be able to remove all stack frames running old code from the call stack. The debugger data will be lost.
To see the Hotswap Bug Fixing JVM feature in action, just move the code from your main method in the Test class to some other class. Here's what I mean:
Now you can modify the code on the fly while debugging in the MyObject class. Have fun!
EDIT: Just found a similar question at superuser.com: Debugging in Eclipse, how to run until a breakpoint
If you happen to be running your application using a 1.3 JVM or higher versions, there's one final step with the debugger still running:
-> change the problem line - in your case "a4 value" and then Save the file, then press the Resume button to get the application running again.
This Saving of that particular java file that you have edited during debugging, will make the session to continue debugging from start(Constructor) of the file with new values.
This editing and saving can be done n number of times, and once you save it, the debugging session will automatically resume from the start of that particular file.
If you just want to change the value of a5 during debugging its alot easier than changing the source.
You can set a new value in the variables view you can see when in the debugging perspective in Eclipse.
See the manual here and here
Related
for some internal development I currently customize a Eclipse Plug in. The Plug in I use is deployed as .jar File. Now I extracted the Content and imported it as Eclipse Plug in project. Everything works fine until is start to add some Code.
For testing the new functionality I like to debug my code. Therefore I run the Eclipse Plug in project in Debug mode. I've got a Debugging connection but the line of code highlighted in the editor doesn't match with the code.
1 private void a(){
2 doSomething();
3 }
4
5 private void b(){
6 doSomethingElse();
7 }
For example the Debug view says I am in the Method b(). But the Highlighter, in the Text-Editor, point to line 3.
I tried several things like Cleaning and searched nearly everywhere in the Debug-Configurations but nothing helped me.
If the displayed code doesn't fit what the debugger tells you it is executing, then you are simply not debugging the code that you see in the editor (but probably still the version without your modifications).
There are a lot of potential reasons for this. For the most easy failure please check your debug configuration. On the plugins page of the debug configuration there are plugins shown as living in your workspace and being provided by the Eclipse installation. Make sure that for your plugin the checkbox is at the workspace version, like the first checkbox in this image:
The debugger highlights the code that is just about to be executed. When the debugger says you are in method b() it is simply telling you that it is about to debug method b()
For some reason, Eclipse is giving me ##$%.
First, some Basic info:
Currently I'm using Eclipse Kepler, on a Mac with OS 10.8.4, 4CPUs and 16GB RAM.
Additionally, I'm using the Spring 3.1.0-Release version.
All I'm doing is running an Integration Test using the SpringJUnit4ClassRunner class, this is a test to see the application context can be loaded:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(locations = { TestConfiguration.TestApplicationContextFile })
public class InitIT {
#Test
public void testInit() {
}
}
What happens when the application context has a problem (for instance, someone forgot to put a #Component annotation on a class and we get a "BeanCreationException"), eclipse simply freezes and refuses to do anything.
I can't even see the stacktrace, so I can't see what the problem is, and Eclipse just uses 100%+ of CPU and hangs, not even letting me press "Stop".
This doesn't happen every time, but when it does it's very consistent.
Also, needless to say, when the application context is loaded successfully, everything runs smoothly, so it's only a matter of when there's a problem.
Something I've discovered that may give a clue is that when I simply load the application context from a Main function instead of using SpringJUnit4ClassRunner, then it's a bit better, but it still takes Eclipse a few minutes to "cool down" and be nice enough to show me the stack trace.
Any ideas? Please let me know if I could send any more info that could help
:)
Thanks!
Ido
I am using Eclipse IDE for Java Developers
Version: Helios Service Release 1
Build id: 20100917-0705
In remote debugging Web app with tomcat 7.0.37, when I make some changes, even a line, the changes can not be made into the runtime, so I need to recompile and re-deploy the war application. Wast a lot of time. The message:
Hot code replace failed - Delete method not implemented
I do not understand the message.
Anyone know the secret on how to auto reflect the code change in debug mode? Thanks.
I've found that for hot code replacement to work the code being modified/replaced must be in the execution stack. So you can hot replace changes made to a method you've stopped in, but you can't hot replace changes to that method once you step out of that method... unless you first stop back in the method on a successive call to the method.
With the standard JVM (Oracle's), you can only modify existing methods. Both adding and deleting methods, and changing structure of class (moving methods, fields) are NOT supported. For that, go to JRebel!
One thing to notice is that changes to seemingly "normal code" inside some method will actually need for the java compiler to add or delete methods - and hence it will fail. This happens e.g. if you in an inner class accesses private fields in the outer class - the java compiler will need to add synthetic accessor-methods to the outer class to let the inner class access those fields - which hence will fail to Hot Code Replace. Also, if you remove some code accessing such fields, the java compiler wants to remove the corresponding synthetic accessor-method, which also will fail.
I think there is no way to reflect the code change in debug mode
Debug mode is to trace program flow and find if any issues or errors at particular piece of code....
it just points to line of code in eclipse, which is running in your tomcat, ie. code in eclipse is not used to run application the code u have installed or put in tomcat runs
hence your changes made in eclipse cant reflect in tomcat code
While trying to use GWT Super Dev Mode, I followed those guidelines :
GWT-2.5-Super-Dev-Mode
Introducing Super Dev Mode
How does GWT's Super Dev Mode work?
However, I am stuck at the step trying to turn on Super Dev Mode :
Once I fully compiled my project, I run the code server and the dev mode, go at http://127.0.0.1:8888/myapp.html (without the ?gwt.codesvr=127.0.0.1:9997) and then click on the bookmark Dev Mode On. It detects my module, asks me to recompile, a glass screen appears with a message Compiling MyApp ... and then nothing ... No error, no stack trace either in Chrome or Eclipse. Just nothing happens.
Debugging the js code from dev_mode_on.js file, the script is interrupted at line 324 :
...
function getBindingParameters(module_name, get_prop_map) {
var session_key = '__gwtDevModeSession:' + module_name;
--> var prop_map = get_prop_map(); <--
...
Once the function get_prop_map is called, a few more obfuscated functions run and the debugger returns.
I know it is still experimental, but do you have any idea of what I could have done wrong ?
PS: I am using GWT 2.5, GWT-maven-plugin 2.5 and Chrome 23.0.1271.64 m
We have found a similar issue and tracked down the cause, looks like a boundary case not handled in GWT.
More info can be found here: http://code.google.com/p/google-web-toolkit/issues/detail?id=7894
I don't have an answer, but I can give some general debugging tips for this sort of problem.
Super Dev Mode currently (as of 2.5) doesn't report any progress to the web browser while it's compiling. It won't update the dialog until the compile finishes. So it's possible that it's just very slow for your program for some reason, or the compile stopped and somehow didn't report an error like it normally does.
However, there are other ways you can monitor its progress. The compiler log is available as a web page by following links from the code server's front page; you will have to refresh the page to see updates. Or you could look at the log on disk in the code server's work directory. (You can set the work directory with the -workDir argument when you start it.)
Another way is to start the code server from the command line. Any stack traces from the code server will be printed there. You should also be able to look at the output in Eclipse or IntelliJ if you're running it from there.
From this you should be able to tell whether the compiler is slow, but still working (it's still printing output) or has actually stopped with a stack trace.
Being new to NetBeans 7 (this is running on Windows 7 64-bit Ultimate Edition) I found it extremely interesting that I can't get any POC (proof of concept applications) to be "viewable." Allow me to explain.
Going through the tutorials - about as simple as anything can ever be in software dev:
1) I create may NetBeans Development application ... but using a product location other than the default. NetBeans wants to use C:\Users{user_name}\Documents\NetBeanProjects as the root path to your projects, then create project folders underneath. Reasonable, but I have dedicated "development drives" where all my development happens, which is not where NetBeans wants to put it.
2) Create a Module for the application. Here I created an Installer and placed a System.out.println() in an overriden restored() method .... you never see this in the Output windows of the IDE. I also added a new Window with a button and textArea, and set the new Window's properties to be shown on application startup and in the Editor location .... you never see these either.
Long story short, I uninstalled NetBeans v7.0 from the computer, and reinstalled it again, but this time allowing the IDE to use the location it wants for project folders. Though, I still do not get the System.out.println() text in the Output window, I do get my new Windows with the button and TextArea.
I've added this post because I did a bunch of seaches trying to find an answer to all this to no avail. I certainly don't have the real answer, but if someone else is strugling with the same problem you'll at least have a "partial answer" if you've changed default project locations and your applications "don't seem to run or be visible."
If anyone knows the real answer to these questions PLEASE advise.
EDIT #1 ... thinking this might be a security or privilege issue I tried running the IDE "as Administrator" and this didn't make any difference. I do not see any prompts or anything in the OS' logs that indicate a problem either, so I'm assuming it's NetBeans.
EDIT #2 ... Found it. Finally discovered where all my System.out.println()'s are ending up. Not in the IDE's Output Window as I would have expected (pretty sure I'm not the only one) but in a "message.log" text file located at
C:\Users\{User_Name}\Documents\NetBeansProjects\{Project_Name}\build\testuserdir\var\log
That was fun - Not! I am assuming that this probably means the System.out is currently set to do this in a property somewhere. But at least I know it's not disappearing off into space somewhere now.
re. the System.out "Not in the IDE's Output Window", have you tried to instantiate a logger instead?
Directly after the class declaration, paste in the following field definition:
private static final Logger logger = Logger.getLogger("thePackageName.andYourClassNameHere");
import the import java.util.logging.Logger; library.
then simply log what ever you want to trace on the output console.
ie: logger.info(" ... " + ....);