Skip to content

Commit 8f0015e

Browse files
committed
Correctly break on exceptions
1 parent 81d8747 commit 8f0015e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

adapter/src/main/kotlin/org/javacs/ktda/jdi/JDIDebuggee.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,18 @@ class JDIDebuggee(
7474

7575
private fun setExceptionBreakpoints(breakpoints: Set<ExceptionBreakpoint>) = vm
7676
.eventRequestManager()
77-
.createExceptionRequest(
77+
.also { it.deleteEventRequests(it.exceptionRequests()) }
78+
.takeIf { breakpoints.isNotEmpty() }
79+
// Workaround: JDI will otherwise not enable the request correctly
80+
?.also { vm.allThreads() }
81+
?.createExceptionRequest(
7882
null,
7983
breakpoints.contains(ExceptionBreakpoint.CAUGHT),
8084
breakpoints.contains(ExceptionBreakpoint.UNCAUGHT)
8185
)
82-
.apply { setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD) }
83-
.enable()
86+
?.apply { setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD) }
87+
?.enable()
88+
?: Unit
8489

8590
/** Tries to set a breakpoint */
8691
private fun setBreakpoint(filePath: String, lineNumber: Long) {

adapter/src/main/kotlin/org/javacs/ktda/jdi/event/VMEventBus.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class VMEventBus(private val vm: VirtualMachine): DebuggeeEventBus {
8787
threadID = toThreadID(it.jdiEvent),
8888
exception = JDIException(it.jdiEvent.exception(), it.jdiEvent.thread())
8989
))
90+
it.resumeThreads = false
9091
}
9192
}
9293

0 commit comments

Comments
 (0)