unable to place breakpoints in eclipse

南笙酒味 提交于 2019-12-18 16:29:12

问题


I am using eclipse europa (3.5) on windows vista home premium 64-bit using JDK 1.6.0_18 (32 BIT).

Normally, I am able to put breakpoints just fine; However, for a particular class which is NOT part of the project (this class is inside a .JAR file (.JAR file is part of the project) ), although I have attached a source directory to this .JAR file, I am unable to place a breakpoint in this class.

If I double-click on the breakpoint pane(left border), I notice that a class breakpoint is placed. I was wondering if there was NO debug info; However, found that this particular class was compiled using ant/javac task using debug="true" and debuglevel="lines,vars,source". I even ran jad on this class to confirm that it indeed contained the debug info.

So, why is eclipse preventing me from placing a breakpoint ?

EDIT : Just so everyone understands the context, this is a webapp running under tomcat 6.0. I am remote debugging the application from eclipse after having started tomcat outside. The application is working just fine. I am trying to understand the behavior of the above class which I'm unable to do since eclipse is not letting me set a BP.

P.S : I saw a few threads here talking about BPs not being hit but in my case, I am unable to place the BP!

P.P.S : I tried JDK 1.6.0_16 before trying out 1.6.0_18.

Thanks for any pointers.


回答1:


Try to take a look at your configuration Java->debug->Step filtering sometime its enabled and you cannot stop inside a filtered package




回答2:


It sounds like Eclipse cannot find the jar file on the classpath, although you did say that the jar file is part of the project. What happens if you run the application normally? Do you get a ClassDefNotFoundException or something similar?

If you check the tabs on the Run/Debug configuration you should be able to see what paths and jar files are on the classpath at runtime. You can also add jar files that are not needed to build the application but are needed to run it.




回答3:


When trying at add breakpoints for a .jsp page it turned out the page was not opened with a JSP editor, which prevented the setting of breakpoints.




回答4:


although I have attached a source directory to this .JAR file, I am unable to place a breakpoint in this class.

You say "a source directory". Are you sure, it's the same version that was used to compile the jar? If you're attaching a different source code version, the line numbers may not match, and your break point won't hit.




回答5:


I m aware of a bug in eclipse where break points dont work with a specific version of jdk 1.6.x For more info look at here




回答6:


Use a plugin called Jadclipse to decompile the jar in runtime, place the breakpoint at the point where the JAR method is invoked, then press F6 and you should be able to go into your JAR method.




回答7:


Just a simple refresh of the .jar file did the trick for me.

I was able to place breakpoints in all the other class files of the same package except one. What I observed is that, when I opened this class file in editor and selected "Link with Editor", eclipse did not take me to this class file itself, but only to the package of this class file.

After the refresh,"Link with Editor" worked and I was able to place the breakpoint.

If someone could explain this behavior,it will be helpful.




回答8:


Step1: Toggle/Enable breakpoint Set the breakpoint at the line of code or point of method entry from where you would like to start debugging the code. Right click on the left margin of the editor next to the line of code and a context menu pops up. Select toggle breakpoint in the context menu

Step2: Configure the breakpoint to stop execution To start debugging, the execution should stop at the breakpoint specified. For this click on breakpoint properties and do the following:

1. Check Hit count
2. Specify value as 1
3. Select “Suspend thread” option

This will stop the execution when the program hits the breakpoint.

Step3: Switch to debug perspective

In Eclipse, select Window –>Open Perspective –> Debug

Step4: Run in debug mode

Now run the program in debug mode. Select Run –> Debug

Now the program starts running in debug mode and you would see the state of the thread as “running”

When the program hits the breakpoint the state of the thread changes from “running” to “suspended”

Step5: Debugging the code with Expressions \Watch variables \ Inspect

Now the code stops at the breakpoint. You could use the watch variables / expression to monitor the current value of the debug variable. Suppose you set the breakpoint at the variable named “counter” and the program stopped at counter variable Add the expression with the variable name “counter” which allows you to monitor the value of the variable as you execute the program You could also right click on the counter variable and select “Inspect” from the context menu If it is a method then, select the method name and click on “Step Into Selection“. This will allow you to monitor or debug the method execution line by line.

Step6: Use F6 key to step into the method

To “step into” the next executable line of code in the current method, press the “F6 Key”. This will pass the program control from the current line to the next executable line of code.



来源:https://stackoverflow.com/questions/2415655/unable-to-place-breakpoints-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!