@@ -23,15 +23,33 @@ class IsolateManager {
23
23
final Map <int , ThreadInfo > _threadsByThreadId = {};
24
24
int _nextThreadNumber = 1 ;
25
25
26
- /// Whether debugging is enabled.
26
+ /// Whether debugging is enabled for this session .
27
27
///
28
28
/// This must be set before any isolates are spawned and controls whether
29
29
/// breakpoints or exception pause modes are sent to the VM.
30
30
///
31
+ /// If false, requests to send breakpoints or exception pause mode will be
32
+ /// dropped. Other functionality (handling pause events, resuming, etc.) will
33
+ /// all still function.
34
+ ///
31
35
/// This is used to support debug sessions that have VM Service connections
32
36
/// but were run with noDebug: true (for example we may need a VM Service
33
37
/// connection for a noDebug flutter app in order to support hot reload).
34
- bool _debug = false ;
38
+ bool debug = false ;
39
+
40
+ /// Whether SDK libraries should be marked as debuggable.
41
+ ///
42
+ /// Calling [sendLibraryDebuggables] is required after changing this value to
43
+ /// apply changes. This allows applying both [debugSdkLibraries] and
44
+ /// [debugExternalPackageLibraries] in one step.
45
+ bool debugSdkLibraries = true ;
46
+
47
+ /// Whether external package libraries should be marked as debuggable.
48
+ ///
49
+ /// Calling [sendLibraryDebuggables] is required after changing this value to
50
+ /// apply changes. This allows applying both [debugSdkLibraries] and
51
+ /// [debugExternalPackageLibraries] in one step.
52
+ bool debugExternalPackageLibraries = true ;
35
53
36
54
/// Tracks breakpoints last provided by the client so they can be sent to new
37
55
/// isolates that appear after initial breakpoints were sent.
@@ -72,6 +90,18 @@ class IsolateManager {
72
90
/// not exited between accessing this list and trying to use the results.
73
91
List <ThreadInfo > get threads => _threadsByIsolateId.values.toList ();
74
92
93
+ /// Re-applies debug options to all isolates/libraries.
94
+ ///
95
+ /// This is required if options like debugSdkLibraries are modified, but is a
96
+ /// separate step to batch together changes to multiple options.
97
+ Future <void > applyDebugOptions () async {
98
+ await Future .wait (_threadsByThreadId.values.map (
99
+ // debuggable libraries is the only thing currently affected by these
100
+ // changable options.
101
+ (isolate) => _sendLibraryDebuggables (isolate.isolate),
102
+ ));
103
+ }
104
+
75
105
Future <T > getObject< T extends vm.Response > (
76
106
vm.IsolateRef isolate, vm.ObjRef object) async {
77
107
final res = await _adapter.vmService? .getObject (isolate.id! , object.id! );
@@ -219,19 +249,6 @@ class IsolateManager {
219
249
.map ((isolate) => _sendBreakpoints (isolate.isolate, uri: uri)));
220
250
}
221
251
222
- /// Sets whether debugging is enabled for this session.
223
- ///
224
- /// If not, requests to send breakpoints or exception pause mode will be
225
- /// dropped. Other functionality (handling pause events, resuming, etc.) will
226
- /// all still function.
227
- ///
228
- /// This is used to support debug sessions that have VM Service connections
229
- /// but were run with noDebug: true (for example we may need a VM Service
230
- /// connection for a noDebug flutter app in order to support hot reload).
231
- void setDebugEnabled (bool debug) {
232
- _debug = debug;
233
- }
234
-
235
252
/// Records exception pause mode as one of 'None', 'Unhandled' or 'All'. All
236
253
/// existing isolates will be updated to reflect the new setting.
237
254
Future <void > setExceptionPauseMode (String mode) async {
@@ -371,13 +388,13 @@ class IsolateManager {
371
388
372
389
/// Checks whether a library should be considered debuggable.
373
390
///
374
- /// This usesthe settings from the launch arguments (debugSdkLibraries
375
- /// and debugExternalPackageLibraries) against the type of library given .
391
+ /// Initial values are provided in the launch arguments, but may be updated
392
+ /// by the `updateDebugOptions` custom request .
376
393
bool _libaryIsDebuggable (vm.LibraryRef library) {
377
394
if (_isSdkLibrary (library)) {
378
- return _adapter.args. debugSdkLibraries ?? false ;
395
+ return debugSdkLibraries;
379
396
} else if (_isExternalPackageLibrary (library)) {
380
- return _adapter.args. debugExternalPackageLibraries ?? false ;
397
+ return debugExternalPackageLibraries;
381
398
} else {
382
399
return true ;
383
400
}
@@ -391,7 +408,7 @@ class IsolateManager {
391
408
/// newly-created isolates).
392
409
Future <void > _sendBreakpoints (vm.IsolateRef isolate, {String ? uri}) async {
393
410
final service = _adapter.vmService;
394
- if (! _debug || service == null ) {
411
+ if (! debug || service == null ) {
395
412
return ;
396
413
}
397
414
@@ -425,7 +442,7 @@ class IsolateManager {
425
442
/// Sets the exception pause mode for an individual isolate.
426
443
Future <void > _sendExceptionPauseMode (vm.IsolateRef isolate) async {
427
444
final service = _adapter.vmService;
428
- if (! _debug || service == null ) {
445
+ if (! debug || service == null ) {
429
446
return ;
430
447
}
431
448
@@ -436,7 +453,7 @@ class IsolateManager {
436
453
/// on the debug settings.
437
454
Future <void > _sendLibraryDebuggables (vm.IsolateRef isolateRef) async {
438
455
final service = _adapter.vmService;
439
- if (! _debug || service == null ) {
456
+ if (! debug || service == null ) {
440
457
return ;
441
458
}
442
459
0 commit comments