Class Breakpoint
- java.lang.Object
-
- com.tonic.analysis.execution.debug.Breakpoint
-
public final class Breakpoint extends Object
Breakpoint location keyed by class, method, and pc, with mutable enablement, condition, and hit tracking.
-
-
Constructor Summary
Constructors Constructor Description Breakpoint(String className, String methodName, String methodDesc, int pc)Creates an enabled breakpoint at the given location with no line number.Breakpoint(String className, String methodName, String methodDesc, int pc, int lineNumber)Creates an enabled breakpoint at the given location.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BreakpointatLine(String className, String methodName, String methodDesc, int line)Creates a breakpoint carrying a source line number; matching still uses pc -1, i.e.static BreakpointatPC(String className, String methodName, String methodDesc, int pc)Creates a breakpoint at a specific bytecode offset.booleanequals(Object o)StringgetClassName()StringgetCondition()intgetHitCount()StringgetKey()intgetLineNumber()StringgetMethodDesc()StringgetMethodName()intgetPC()inthashCode()voidincrementHitCount()Records one more hit of this breakpoint.booleanisEnabled()booleanmatches(StackFrame frame)Tests whether this breakpoint matches the frame's current location.booleanmatches(String className, String methodName, String methodDesc, int pc)Tests whether this breakpoint matches the given location, treating a -1 pc as method entry (pc 0).static BreakpointmethodEntry(String className, String methodName, String methodDesc)Creates a breakpoint that triggers on method entry.voidresetHitCount()Resets the hit counter to zero.voidsetCondition(String condition)Sets an optional condition expression attached to this breakpoint.voidsetEnabled(boolean enabled)Enables or disables this breakpoint.StringtoString()
-
-
-
Constructor Detail
-
Breakpoint
public Breakpoint(String className, String methodName, String methodDesc, int pc)
Creates an enabled breakpoint at the given location with no line number.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptorpc- the bytecode offset, or -1 for method entry- Throws:
IllegalArgumentException- if className, methodName, or methodDesc is null or empty
-
Breakpoint
public Breakpoint(String className, String methodName, String methodDesc, int pc, int lineNumber)
Creates an enabled breakpoint at the given location.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptorpc- the bytecode offset, or -1 for method entrylineNumber- the source line, or -1 if unknown- Throws:
IllegalArgumentException- if className, methodName, or methodDesc is null or empty
-
-
Method Detail
-
methodEntry
public static Breakpoint methodEntry(String className, String methodName, String methodDesc)
Creates a breakpoint that triggers on method entry.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptor- Returns:
- the breakpoint
-
atLine
public static Breakpoint atLine(String className, String methodName, String methodDesc, int line)
Creates a breakpoint carrying a source line number; matching still uses pc -1, i.e. method entry.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptorline- the source line number- Returns:
- the breakpoint
- Throws:
IllegalArgumentException- if line is negative
-
atPC
public static Breakpoint atPC(String className, String methodName, String methodDesc, int pc)
Creates a breakpoint at a specific bytecode offset.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptorpc- the bytecode offset, or -1 for method entry- Returns:
- the breakpoint
- Throws:
IllegalArgumentException- if pc is less than -1
-
getClassName
public String getClassName()
- Returns:
- the class name
-
getMethodName
public String getMethodName()
- Returns:
- the method name
-
getMethodDesc
public String getMethodDesc()
- Returns:
- the method desc
-
getPC
public int getPC()
- Returns:
- the target bytecode offset, or -1 for method entry
-
getLineNumber
public int getLineNumber()
- Returns:
- the line number
-
isEnabled
public boolean isEnabled()
- Returns:
- whether enabled
-
setEnabled
public void setEnabled(boolean enabled)
Enables or disables this breakpoint.- Parameters:
enabled- true to enable
-
getCondition
public String getCondition()
- Returns:
- the condition
-
setCondition
public void setCondition(String condition)
Sets an optional condition expression attached to this breakpoint.- Parameters:
condition- the condition, or null to clear
-
getHitCount
public int getHitCount()
- Returns:
- the hit count
-
incrementHitCount
public void incrementHitCount()
Records one more hit of this breakpoint.
-
resetHitCount
public void resetHitCount()
Resets the hit counter to zero.
-
matches
public boolean matches(StackFrame frame)
Tests whether this breakpoint matches the frame's current location.- Parameters:
frame- the frame to test, may be null- Returns:
- true if the frame location matches
-
matches
public boolean matches(String className, String methodName, String methodDesc, int pc)
Tests whether this breakpoint matches the given location, treating a -1 pc as method entry (pc 0).- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptorpc- the current program counter- Returns:
- true if the location matches
-
getKey
public String getKey()
- Returns:
- a unique map key combining class, method, descriptor, and pc
-
-