@@ -36,12 +36,9 @@ public class DebugSession implements IDebugSession {
3636 private EventHub eventHub = new EventHub ();
3737 private List <EventRequest > eventRequests = new ArrayList <>();
3838 private List <Disposable > subscriptions = new ArrayList <>();
39- private final boolean suspendAllThreads ;
4039
4140 public DebugSession (VirtualMachine virtualMachine ) {
4241 vm = virtualMachine ;
43- // Capture suspend policy at session start - this persists for the session lifetime
44- this .suspendAllThreads = DebugSettings .getCurrent ().suspendAllThreads ;
4542 }
4643
4744 @ Override
@@ -130,32 +127,36 @@ public void terminate() {
130127 }
131128
132129 @ Override
133- public IBreakpoint createBreakpoint (JavaBreakpointLocation sourceLocation , int hitCount , String condition , String logMessage ) {
134- return new EvaluatableBreakpoint (vm , this .getEventHub (), sourceLocation , hitCount , condition , logMessage , suspendAllThreads );
130+ public IBreakpoint createBreakpoint (JavaBreakpointLocation sourceLocation , int hitCount , String condition , String logMessage , int suspendPolicy ) {
131+ EvaluatableBreakpoint breakpoint = new EvaluatableBreakpoint (vm , this .getEventHub (), sourceLocation , hitCount , condition , logMessage );
132+ breakpoint .setSuspendPolicy (suspendPolicy );
133+ return breakpoint ;
135134 }
136135
137136 @ Override
138- public IBreakpoint createBreakpoint (String className , int lineNumber , int hitCount , String condition , String logMessage ) {
139- return new EvaluatableBreakpoint (vm , this .getEventHub (), className , lineNumber , hitCount , condition , logMessage , suspendAllThreads );
137+ public IBreakpoint createBreakpoint (String className , int lineNumber , int hitCount , String condition , String logMessage , int suspendPolicy ) {
138+ EvaluatableBreakpoint breakpoint = new EvaluatableBreakpoint (vm , this .getEventHub (), className , lineNumber , hitCount , condition , logMessage );
139+ breakpoint .setSuspendPolicy (suspendPolicy );
140+ return breakpoint ;
140141 }
141142
142143 @ Override
143144 public IWatchpoint createWatchPoint (String className , String fieldName , String accessType , String condition , int hitCount ) {
144- return new Watchpoint (vm , this .getEventHub (), className , fieldName , accessType , condition , hitCount , suspendAllThreads );
145+ return new Watchpoint (vm , this .getEventHub (), className , fieldName , accessType , condition , hitCount );
145146 }
146147
147148 @ Override
148- public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught ) {
149- setExceptionBreakpoints (notifyCaught , notifyUncaught , null , null );
149+ public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught , int suspendModeOnCaught , int suspendModeOnUncaught ) {
150+ setExceptionBreakpoints (notifyCaught , notifyUncaught , suspendModeOnCaught , suspendModeOnUncaught , null , null );
150151 }
151152
152153 @ Override
153- public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught , String [] classFilters , String [] classExclusionFilters ) {
154- setExceptionBreakpoints (notifyCaught , notifyUncaught , null , classFilters , classExclusionFilters );
154+ public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught , int suspendModeOnCaught , int suspendModeOnUncaught , String [] classFilters , String [] classExclusionFilters ) {
155+ setExceptionBreakpoints (notifyCaught , notifyUncaught , suspendModeOnCaught , suspendModeOnUncaught , null , classFilters , classExclusionFilters );
155156 }
156157
157158 @ Override
158- public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught , String [] exceptionTypes ,
159+ public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught , int suspendModeOnCaught , int suspendModeOnUncaught , String [] exceptionTypes ,
159160 String [] classFilters , String [] classExclusionFilters ) {
160161 EventRequestManager manager = vm .eventRequestManager ();
161162
@@ -187,19 +188,7 @@ public void setExceptionBreakpoints(boolean notifyCaught, boolean notifyUncaught
187188 // See org.eclipse.debug.jdi.tests.AbstractJDITest for the example.
188189
189190 if (exceptionTypes == null || exceptionTypes .length == 0 ) {
190- ExceptionRequest request = manager .createExceptionRequest (null , notifyCaught , notifyUncaught );
191- request .setSuspendPolicy (suspendAllThreads ? EventRequest .SUSPEND_ALL : EventRequest .SUSPEND_EVENT_THREAD );
192- if (classFilters != null ) {
193- for (String classFilter : classFilters ) {
194- request .addClassFilter (classFilter );
195- }
196- }
197- if (classExclusionFilters != null ) {
198- for (String exclusionFilter : classExclusionFilters ) {
199- request .addClassExclusionFilter (exclusionFilter );
200- }
201- }
202- request .enable ();
191+ createExceptionBreakpoint (null , notifyCaught , notifyUncaught , suspendModeOnCaught , suspendModeOnUncaught , classFilters , classExclusionFilters );
203192 return ;
204193 }
205194
@@ -219,27 +208,27 @@ public void setExceptionBreakpoints(boolean notifyCaught, boolean notifyUncaught
219208 && eventRequests .contains (debugEvent .event .request ()))
220209 .subscribe (debugEvent -> {
221210 ClassPrepareEvent event = (ClassPrepareEvent ) debugEvent .event ;
222- createExceptionBreakpoint (event .referenceType (), notifyCaught , notifyUncaught , classFilters , classExclusionFilters );
211+ createExceptionBreakpoint (event .referenceType (), notifyCaught , notifyUncaught , suspendModeOnCaught , suspendModeOnUncaught , classFilters , classExclusionFilters );
223212 });
224213 subscriptions .add (subscription );
225214
226215 // register exception breakpoint in the loaded classes.
227216 for (ReferenceType refType : vm .classesByName (exceptionType )) {
228- createExceptionBreakpoint (refType , notifyCaught , notifyUncaught , classFilters , classExclusionFilters );
217+ createExceptionBreakpoint (refType , notifyCaught , notifyUncaught , suspendModeOnCaught , suspendModeOnUncaught , classFilters , classExclusionFilters );
229218 }
230219 }
231220 }
232221 }
233222
234223 @ Override
235- public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught , String [] exceptionTypes ,
224+ public void setExceptionBreakpoints (boolean notifyCaught , boolean notifyUncaught , int suspendModeOnCaught , int suspendModeOnUncaught , String [] exceptionTypes ,
236225 String [] classFilters , String [] classExclusionFilters , boolean async ) {
237226 if (async ) {
238227 AsyncJdwpUtils .runAsync (() -> {
239- setExceptionBreakpoints (notifyCaught , notifyUncaught , exceptionTypes , classFilters , classExclusionFilters );
228+ setExceptionBreakpoints (notifyCaught , notifyUncaught , suspendModeOnCaught , suspendModeOnUncaught , exceptionTypes , classFilters , classExclusionFilters );
240229 });
241230 } else {
242- setExceptionBreakpoints (notifyCaught , notifyUncaught , exceptionTypes , classFilters , classExclusionFilters );
231+ setExceptionBreakpoints (notifyCaught , notifyUncaught , suspendModeOnCaught , suspendModeOnUncaught , exceptionTypes , classFilters , classExclusionFilters );
243232 }
244233 }
245234
@@ -263,22 +252,27 @@ public VirtualMachine getVM() {
263252 return vm ;
264253 }
265254
266- @ Override
267- public boolean shouldSuspendAllThreads () {
268- return suspendAllThreads ;
269- }
270-
271255 @ Override
272256 public IMethodBreakpoint createFunctionBreakpoint (String className , String functionName , String condition ,
273257 int hitCount ) {
274- return new MethodBreakpoint (vm , this .getEventHub (), className , functionName , condition , hitCount , suspendAllThreads );
258+ return new MethodBreakpoint (vm , this .getEventHub (), className , functionName , condition , hitCount );
259+ }
260+
261+ private void createExceptionBreakpoint (ReferenceType refType , boolean notifyCaught , boolean notifyUncaught ,
262+ int suspendModeOnCaught , int suspendModeOnUncaught , String [] classFilters , String [] classExclusionFilters ) {
263+ if (suspendModeOnCaught == suspendModeOnUncaught ) {
264+ createExceptionBreakpoint (refType , notifyCaught , notifyUncaught , suspendModeOnCaught , classFilters , classExclusionFilters );
265+ } else {
266+ createExceptionBreakpoint (refType , notifyCaught , notifyUncaught , suspendModeOnCaught , classFilters , classExclusionFilters );
267+ createExceptionBreakpoint (refType , notifyCaught , notifyUncaught , suspendModeOnUncaught , classFilters , classExclusionFilters );
268+ }
275269 }
276270
277271 private void createExceptionBreakpoint (ReferenceType refType , boolean notifyCaught , boolean notifyUncaught ,
278- String [] classFilters , String [] classExclusionFilters ) {
272+ int suspendMode , String [] classFilters , String [] classExclusionFilters ) {
279273 EventRequestManager manager = vm .eventRequestManager ();
280274 ExceptionRequest request = manager .createExceptionRequest (refType , notifyCaught , notifyUncaught );
281- request .setSuspendPolicy (suspendAllThreads ? EventRequest . SUSPEND_ALL : EventRequest . SUSPEND_EVENT_THREAD );
275+ request .setSuspendPolicy (suspendMode );
282276 if (classFilters != null ) {
283277 for (String classFilter : classFilters ) {
284278 request .addClassFilter (classFilter );
@@ -291,4 +285,4 @@ private void createExceptionBreakpoint(ReferenceType refType, boolean notifyCaug
291285 }
292286 request .enable ();
293287 }
294- }
288+ }
0 commit comments