Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
76758ef9
Unverified
Commit
76758ef9
authored
Feb 25, 2022
by
Danny Tuppeny
Committed by
GitHub
Feb 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dap] Don't use --start-paused when running in Profile/Release mode (#98926)
parent
37a1aaf8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
212 additions
and
15 deletions
+212
-15
flutter_adapter.dart
...flutter_tools/lib/src/debug_adapters/flutter_adapter.dart
+37
-12
flutter_adapter_test.dart
...er_tools/test/general.shard/dap/flutter_adapter_test.dart
+158
-0
flutter_test_adapter_test.dart
...ols/test/general.shard/dap/flutter_test_adapter_test.dart
+9
-3
mocks.dart
packages/flutter_tools/test/general.shard/dap/mocks.dart
+8
-0
No files found.
packages/flutter_tools/lib/src/debug_adapters/flutter_adapter.dart
View file @
76758ef9
...
...
@@ -85,30 +85,55 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
/// Whether or not the user requested debugging be enabled.
///
/// debug/noDebug here refers to the DAP "debug" mode and not the Flutter
/// debug mode (vs Profile/Release). It is provided by the client editor based
/// on whether a user chooses to "Run" or "Debug" their app.
/// For debugging to be enabled, the user must have chosen "Debug" (and not
/// "Run") in the editor (which maps to the DAP `noDebug` field) _and_ must
/// not have requested to run in Profile or Release mode. Profile/Release
/// modes will always disable debugging.
///
/// This is always enabled for attach requests, but can be disabled for launch
/// requests via DAP's `noDebug` flag. If `noDebug` is not provided, will
/// default to debugging.
/// This is always `true` for attach requests.
///
/// When not debugging, we will not connect to the VM Service so some
/// functionality (breakpoints, evaluation, etc.) will not be available.
/// Functionality provided via the daemon (hot reload/restart) will still be
/// available.
bool
get
debug
{
bool
get
enableDebugger
{
final
DartCommonLaunchAttachRequestArguments
args
=
this
.
args
;
if
(
args
is
FlutterLaunchRequestArguments
)
{
// Invert DAP's noDebug flag, treating it as false (so _do_ debug) if not
// provided.
return
!(
args
.
noDebug
??
false
);
return
!(
args
.
noDebug
??
false
)
&&
!
profileMode
&&
!
releaseMode
;
}
// Otherwise (attach), always debug.
return
true
;
}
/// Whether the launch configuration arguments specify `--profile`.
///
/// Always `false` for attach requests.
bool
get
profileMode
{
final
DartCommonLaunchAttachRequestArguments
args
=
this
.
args
;
if
(
args
is
FlutterLaunchRequestArguments
)
{
return
args
.
toolArgs
?.
contains
(
'--profile'
)
??
false
;
}
// Otherwise (attach), always false.
return
false
;
}
/// Whether the launch configuration arguments specify `--release`.
///
/// Always `false` for attach requests.
bool
get
releaseMode
{
final
DartCommonLaunchAttachRequestArguments
args
=
this
.
args
;
if
(
args
is
FlutterLaunchRequestArguments
)
{
return
args
.
toolArgs
?.
contains
(
'--release'
)
??
false
;
}
// Otherwise (attach), always false.
return
false
;
}
/// Called by [attachRequest] to request that we actually connect to the app to be debugged.
@override
Future
<
void
>
attachImpl
()
async
{
...
...
@@ -214,7 +239,7 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
final
List
<
String
>
toolArgs
=
<
String
>[
'run'
,
'--machine'
,
if
(
debug
)
'--start-paused'
,
if
(
enableDebugger
)
'--start-paused'
,
];
await
_startProcess
(
...
...
@@ -258,7 +283,7 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
// Delay responding until the app is launched and (optionally) the debugger
// is connected.
await
appStartedCompleter
.
future
;
if
(
debug
)
{
if
(
enableDebugger
)
{
await
debuggerInitialized
;
}
}
...
...
@@ -363,7 +388,7 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
void
_handleDebugPort
(
Map
<
String
,
Object
?>
params
)
{
// When running in noDebug mode, Flutter may still provide us a VM Service
// URI, but we will not connect it because we don't want to do any debugging.
if
(!
debug
)
{
if
(!
enableDebugger
)
{
return
;
}
...
...
@@ -494,7 +519,7 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
await
sendFlutterRequest
(
'app.restart'
,
<
String
,
Object
?>{
'appId'
:
_appId
,
'fullRestart'
:
fullRestart
,
'pause'
:
debug
,
'pause'
:
enableDebugger
,
'reason'
:
reason
,
'debounce'
:
true
,
});
...
...
packages/flutter_tools/test/
src
/dap/flutter_adapter_test.dart
→
packages/flutter_tools/test/
general.shard
/dap/flutter_adapter_test.dart
View file @
76758ef9
...
...
@@ -13,8 +13,83 @@ import 'mocks.dart';
void
main
(
)
{
group
(
'flutter adapter'
,
()
{
final
String
expectedFlutterExecutable
=
globals
.
platform
.
isWindows
?
r'C:\fake\flutter\bin\flutter.bat'
:
'/fake/flutter/bin/flutter'
;
setUpAll
(()
{
Cache
.
flutterRoot
=
'/fake/flutter'
;
Cache
.
flutterRoot
=
globals
.
platform
.
isWindows
?
r'C:\fake\flutter'
:
'/fake/flutter'
;
});
group
(
'--start-paused'
,
()
{
test
(
'is passed for debug mode'
,
()
async
{
final
MockFlutterDebugAdapter
adapter
=
MockFlutterDebugAdapter
(
fileSystem:
globals
.
fs
,
platform:
globals
.
platform
);
final
Completer
<
void
>
responseCompleter
=
Completer
<
void
>();
final
FlutterLaunchRequestArguments
args
=
FlutterLaunchRequestArguments
(
cwd:
'/project'
,
program:
'foo.dart'
,
);
await
adapter
.
configurationDoneRequest
(
MockRequest
(),
null
,
()
{});
await
adapter
.
launchRequest
(
MockRequest
(),
args
,
responseCompleter
.
complete
);
await
responseCompleter
.
future
;
expect
(
adapter
.
processArgs
,
contains
(
'--start-paused'
));
});
test
(
'is not passed for noDebug mode'
,
()
async
{
final
MockFlutterDebugAdapter
adapter
=
MockFlutterDebugAdapter
(
fileSystem:
globals
.
fs
,
platform:
globals
.
platform
);
final
Completer
<
void
>
responseCompleter
=
Completer
<
void
>();
final
FlutterLaunchRequestArguments
args
=
FlutterLaunchRequestArguments
(
cwd:
'/project'
,
program:
'foo.dart'
,
noDebug:
true
,
);
await
adapter
.
configurationDoneRequest
(
MockRequest
(),
null
,
()
{});
await
adapter
.
launchRequest
(
MockRequest
(),
args
,
responseCompleter
.
complete
);
await
responseCompleter
.
future
;
expect
(
adapter
.
processArgs
,
isNot
(
contains
(
'--start-paused'
)));
});
test
(
'is not passed if toolArgs contains --profile'
,
()
async
{
final
MockFlutterDebugAdapter
adapter
=
MockFlutterDebugAdapter
(
fileSystem:
globals
.
fs
,
platform:
globals
.
platform
);
final
Completer
<
void
>
responseCompleter
=
Completer
<
void
>();
final
FlutterLaunchRequestArguments
args
=
FlutterLaunchRequestArguments
(
cwd:
'/project'
,
program:
'foo.dart'
,
toolArgs:
<
String
>[
'--profile'
],
);
await
adapter
.
configurationDoneRequest
(
MockRequest
(),
null
,
()
{});
await
adapter
.
launchRequest
(
MockRequest
(),
args
,
responseCompleter
.
complete
);
await
responseCompleter
.
future
;
expect
(
adapter
.
processArgs
,
isNot
(
contains
(
'--start-paused'
)));
});
test
(
'is not passed if toolArgs contains --release'
,
()
async
{
final
MockFlutterDebugAdapter
adapter
=
MockFlutterDebugAdapter
(
fileSystem:
globals
.
fs
,
platform:
globals
.
platform
);
final
Completer
<
void
>
responseCompleter
=
Completer
<
void
>();
final
FlutterLaunchRequestArguments
args
=
FlutterLaunchRequestArguments
(
cwd:
'/project'
,
program:
'foo.dart'
,
toolArgs:
<
String
>[
'--release'
],
);
await
adapter
.
configurationDoneRequest
(
MockRequest
(),
null
,
()
{});
await
adapter
.
launchRequest
(
MockRequest
(),
args
,
responseCompleter
.
complete
);
await
responseCompleter
.
future
;
expect
(
adapter
.
processArgs
,
isNot
(
contains
(
'--start-paused'
)));
});
});
test
(
'includes toolArgs'
,
()
async
{
...
...
@@ -32,7 +107,7 @@ void main() {
await
adapter
.
launchRequest
(
MockRequest
(),
args
,
responseCompleter
.
complete
);
await
responseCompleter
.
future
;
expect
(
adapter
.
executable
,
equals
(
'/fake/flutter/bin/flutter'
));
expect
(
adapter
.
executable
,
equals
(
expectedFlutterExecutable
));
expect
(
adapter
.
processArgs
,
contains
(
'tool_arg'
));
});
...
...
packages/flutter_tools/test/
src
/dap/flutter_test_adapter_test.dart
→
packages/flutter_tools/test/
general.shard
/dap/flutter_test_adapter_test.dart
View file @
76758ef9
...
...
@@ -13,8 +13,14 @@ import 'mocks.dart';
void
main
(
)
{
group
(
'flutter test adapter'
,
()
{
final
String
expectedFlutterExecutable
=
globals
.
platform
.
isWindows
?
r'C:\fake\flutter\bin\flutter.bat'
:
'/fake/flutter/bin/flutter'
;
setUpAll
(()
{
Cache
.
flutterRoot
=
'/fake/flutter'
;
Cache
.
flutterRoot
=
globals
.
platform
.
isWindows
?
r'C:\fake\flutter'
:
'/fake/flutter'
;
});
test
(
'includes toolArgs'
,
()
async
{
...
...
@@ -35,7 +41,7 @@ void main() {
await
adapter
.
launchRequest
(
request
,
args
,
responseCompleter
.
complete
);
await
responseCompleter
.
future
;
expect
(
adapter
.
executable
,
equals
(
'/fake/flutter/bin/flutter'
));
expect
(
adapter
.
executable
,
equals
(
expectedFlutterExecutable
));
expect
(
adapter
.
processArgs
,
contains
(
'tool_arg'
));
});
...
...
packages/flutter_tools/test/
src
/dap/mocks.dart
→
packages/flutter_tools/test/
general.shard
/dap/mocks.dart
View file @
76758ef9
...
...
@@ -52,6 +52,14 @@ class MockFlutterDebugAdapter extends FlutterDebugAdapter {
// launchRequest will complete.
appStartedCompleter
.
complete
();
}
@override
Future
<
void
>
get
debuggerInitialized
{
// If we were mocking debug mode, then simulate the debugger initializing.
return
enableDebugger
?
Future
<
void
>.
value
()
:
throw
StateError
(
'Invalid attempt to wait for debuggerInitialized when not debugging'
);
}
}
/// A [FlutterTestDebugAdapter] that captures what process/args will be launched.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment