How to Use Conditional Breakpoint in Eclipse

How to use conditional breakpoint in Eclipse?

Put your breakpoint.
Right-click the breakpoint image on the margin and choose Breakpoint Properties:

Sample Image

Configure condition as you see fit:

Sample Image

Java/Eclipse - Conditional breakpoint and counter?

To activate the breakpoint after the condition is met a certain number of times:

  1. Open breakpoints dialog: Ctrl+double-click breakpoint
  2. Check Conditional checkbox
  3. Use following as condition:

    if (i == j) {
    int n = Integer.parseInt(System.getProperty("breakpoint.n", "0"));
    n++;
    System.setProperty("breakpoint.n", "" + n);
    if (n > 400) return true;
    }
    return false;

Java exception breakpoint with condition in Eclipse

There is no option to add a condition for an exception breakpoint similar to normal breakpoints. The closest thing you can do is use the Filtering properties page to add a filter on the breakpoint such as the class and/or the package which throws the exception. Or you can filter on a specific thread while debugging.

See http://help.eclipse.org/juno/topic/org.eclipse.jdt.doc.user/tasks/tasks-create-exception-filter-expression.htm for more info.

Eclipse conditional breakpoint, break at any string equals

This trick works as long as the string that you want to find isn't hard-coded in any way. If the string was getting passed to the compiler, then this trick may not work.

  1. Ensure you have installed the source-code alongside the JDK.
  2. Open java.lang.String class file. Your IDE should be automatically show the source-code for this class.
  3. Put a breakpoint in the char[] field variable. The variable name may vary for each JDK. On my machine it is private final char value[];.
  4. Put a condition on this breakpoint, e.g.:

    value!=null && value.length==6 && value[0]=='f' && value[1]=='o' && value[2]=='o' ....

Please note that the performance will be slower due to this breakpoint.

I have tested this on a simple application that read the string from a file, and the breakpoint is being hit properly when the file is being read into a string.

conditional break point in eclipse not working for a local variable?

Conditional line break point expression is evaluated before the code reaches the line. Since recipient is defined in line 65, you can't use this variable name in break point for line 65.

To fix it you can rewrite the line break point expression as:

"1".equals(list.get(0))

or move the break point to line 66.

How can I move a conditional breakpoint in Eclipse?

It is not possible nowadays. Many people wants it (including me) since 2002 as it is a feature request since then. Try asking again for it.



Related Topics



Leave a reply



Submit