Class BreakpointManager
- java.lang.Object
-
- com.tonic.analysis.execution.debug.BreakpointManager
-
public final class BreakpointManager extends Object
Thread-safe registry of breakpoints indexed by key and by owning method for fast location checks.
-
-
Constructor Summary
Constructors Constructor Description BreakpointManager()Creates an empty manager backed by concurrent maps.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBreakpoint(Breakpoint bp)Registers a breakpoint, indexing it by key and by owning method.BreakpointcheckBreakpoint(StackFrame frame)Finds an enabled breakpoint matching the frame's current location.BreakpointcheckBreakpoint(String className, String methodName, String methodDesc, int pc)Finds an enabled breakpoint matching the given location.voiddisableAll()Disables every registered breakpoint.voiddisableBreakpoint(String key)Disables the breakpoint with the given key, if present.voidenableAll()Enables every registered breakpoint.voidenableBreakpoint(String key)Enables the breakpoint with the given key, if present.List<Breakpoint>getAllBreakpoints()BreakpointgetBreakpoint(String key)Looks up a breakpoint by key.intgetBreakpointCount()List<Breakpoint>getBreakpointsForMethod(String className, String methodName, String methodDesc)Lists the breakpoints registered for one method.booleanhasBreakpoints()static StringmethodKey(String className, String methodName, String methodDesc)Builds the per-method index key.voidremoveAllBreakpoints()Removes every registered breakpoint.booleanremoveBreakpoint(Breakpoint bp)Removes the given breakpoint.booleanremoveBreakpoint(String key)Removes the breakpoint with the given key, cleaning up the per-method index.
-
-
-
Method Detail
-
addBreakpoint
public void addBreakpoint(Breakpoint bp)
Registers a breakpoint, indexing it by key and by owning method.- Parameters:
bp- the breakpoint to add- Throws:
IllegalArgumentException- if bp is null
-
removeBreakpoint
public boolean removeBreakpoint(Breakpoint bp)
Removes the given breakpoint.- Parameters:
bp- the breakpoint to remove- Returns:
- true if it was registered and removed
-
removeBreakpoint
public boolean removeBreakpoint(String key)
Removes the breakpoint with the given key, cleaning up the per-method index.- Parameters:
key- the breakpoint key- Returns:
- true if a breakpoint was removed
-
removeAllBreakpoints
public void removeAllBreakpoints()
Removes every registered breakpoint.
-
enableBreakpoint
public void enableBreakpoint(String key)
Enables the breakpoint with the given key, if present.- Parameters:
key- the breakpoint key
-
disableBreakpoint
public void disableBreakpoint(String key)
Disables the breakpoint with the given key, if present.- Parameters:
key- the breakpoint key
-
enableAll
public void enableAll()
Enables every registered breakpoint.
-
disableAll
public void disableAll()
Disables every registered breakpoint.
-
getBreakpoint
public Breakpoint getBreakpoint(String key)
Looks up a breakpoint by key.- Parameters:
key- the breakpoint key- Returns:
- the breakpoint, or null if absent
-
getAllBreakpoints
public List<Breakpoint> getAllBreakpoints()
- Returns:
- a copy of all registered breakpoints
-
getBreakpointsForMethod
public List<Breakpoint> getBreakpointsForMethod(String className, String methodName, String methodDesc)
Lists the breakpoints registered for one method.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptor- Returns:
- a copy of the method's breakpoints, empty if none
-
hasBreakpoints
public boolean hasBreakpoints()
- Returns:
- true if any breakpoints are registered
-
getBreakpointCount
public int getBreakpointCount()
- Returns:
- the number of registered breakpoints
-
checkBreakpoint
public Breakpoint checkBreakpoint(StackFrame frame)
Finds an enabled breakpoint matching the frame's current location.- Parameters:
frame- the frame to test, may be null- Returns:
- the matching breakpoint, or null
-
checkBreakpoint
public Breakpoint checkBreakpoint(String className, String methodName, String methodDesc, int pc)
Finds an enabled breakpoint matching the given location.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptorpc- the current program counter- Returns:
- the matching breakpoint, or null
-
methodKey
public static String methodKey(String className, String methodName, String methodDesc)
Builds the per-method index key.- Parameters:
className- the class internal namemethodName- the method namemethodDesc- the method descriptor- Returns:
- the combined method key
- Throws:
IllegalArgumentException- if any component is null
-
-