Eclipse conditional breakpoints broken?

I am trying to set a conditional breakpoint in decompiled code, but Eclipse continues to give me an error:

Conditional breakpoint has compilation error

Reason: Evaluations must contain either an expression or a block of well-formed statuses

My case is pretty simple, just trying to compare with a string value. I have tried all of the following and I am getting errors with each of them:

myObj.toString() == "abc123" myObj.toString().equals("abc123") if(myObj.toString() == "abc123"){ return true; } true == true 

I also tried every combination of the presence or absence of a semicolon at the end of the line (s) and every combination of intervals and lines of a new line and every combination of the presence or absence of {} surrounding my state. Basically, I have no idea why this is not working ...

The code I'm trying to debug is inside a jar that decompiles with JD-Eclipse. Normal breakpoints work fine in this code.

Does anyone know what is going on here?

+7
source share
6 answers

This Eclipse FAQ page contains the syntax for correctly defining CBP and the most common reasons why they do not work. In your case, I consider the following:

This can happen if you set a breakpoint in a class whose class file does not contain a table of local variables. For example, let's say you want to set a conditional breakpoint in Class.forName (String). If you have the original attachment for rt.jar, then content support will allow you to reference the argument by its variable name, class Name. However, during debugging, the variable name will be known only if the class file contains a local variable table. Depending on the parameters used during compilation, this information may be removed from the class file.

JD may have generated variable names when decompiling your jar, so using "myObj" in a conditional generates a compile-time error.

+2
source

Perhaps conditional breakpoints are less than overall work. Consider, for example:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=278146

+2
source

It could be a bug in eclipse. What eclipse does is a new method or some of them in the source for the file where you set the breakpoint, and compile it. If something goes wrong in this process, your conditional breakpoint will mysteriously fail.

You can follow the approach I used below, run eclipse in debugging to try to find the cause of the problem: -

https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232#c21

+1
source

In the case of the condition "true == true", you should simply add a return statement:

 return true == true; 

For other problems that are not in the table of local variables, there should be an explanation. +1 to Mazaneicha for this.

0
source

In the case of the condition "true == true", you should simply add a return statement:

 return true == true; 

For other problems that are not in the table of local variables, there should be an explanation. +1 to Mazaneicha for this.

If you are trying to pass a method argument by its name, just try changing the name to "arg0", "arg1", etc.

For example, you can do the following:

 arg0 == null 

Easy to guess the variable name. Just place a non-personal breakpoint and see the list of variables in the Variables view.

0
source

Just add something that might help others, as I just decided this after a while. I also use JD-Eclipse for debugging when I get this problem.

Make sure all the necessary jar files are in the Classpath. Your conditional statement can be very simple, for example, "return true"; but after the "conditional breakpoint" checkbox is checked, this may be so (I also can’t be sure). The Eclipse debugger will verify that the path to the Eclipse project class is greater, and not just the string "return true".

Since I use JD-Eclipse, I did not add all the necessary jar files. The problem was resolved after adding jar files to the project class path

If you use remote debugging, you can also try to configure your Eclipse JDK project to be compatible with the target JVM JRE.

0
source

All Articles