Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Breakpoints



It is possible to add a breakpoint by DebugSession.addBreakpoint(int). The method will return:
  • null if there is no step defined on the specified line
  • A breakpoint by default
  • A step if there was previously a breakpoint at this line number
It is possible to edit each breakpoint to add conditions for stopping on this breakpoint.

The script will pause at each breakpoint:
  • If there is no expression set for this breakpoint
  • Or if there is an expression set for this breakpoint, but the result of the expression is true

Editing a breakpoint

To edit a breakpoint, call the Breakpoint.setExpression(String). The expression can use any variables available for the breakpoint line. For example, for the following script:
      public String compute(String name, Object o, int value) {
        String result = name + value;
        result = result + ".groovy" + o.toString(); 
        return result;
      }
Suppose that we want to edit a breakpoint for the yellow line. We could use for example one of these expressions:
  • name.length() == 3
  • name.substring(1) == "toto"
  • (result + name).length() > 10
  • o.getClass() == String.class
  • value == 3

Breakpoint properties expressions

The following expressions are allowed:
  • Comparisons or equality expressions, for example: value < 3 or value == 3 or value <= 3[1]
    In this case value would be a variable
  • Boolean expressions, for example: b1 || b2 or b1 && b2 or b1 ^ b2[2]
    In this case b1 and b2 would be variables
  • Numeric expressions, for example: (value + 1) < 3 or (value * 2) > 10[3]
    In this case value would be a variable
  • Using methods, for example name.length() == 3 or name.substring(1) == "toto" or name.substring(index) == "toto"[4]
    In this case name and index would be variables

Incorrect properties expressions

If an expression is incorrect, the returned value will be false regardless of the reasons. Note that no exception will be thrown, but if you edit again the expression in the SwingDebugScriptWindow, you will see the expression in red:
breakpointincorrect

Notes

  1. ^ In this case value would be a variable
  2. ^ In this case b1 and b2 would be variables
  3. ^ In this case value would be a variable
  4. ^ In this case name and index would be variables

Categories: api | debugging

Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence