Skip to content

Commit 7fa45ea

Browse files
authored
Log all output of ios-deploy (#127222)
Log all output of `ios-deploy` to try and determine if the issue of flutter/flutter#121231 is with stream or with `ios-deploy`. Note: This will cause some duplicate logs like example below but only in verbose mode ``` (lldb) 2023-05-19 13:48:19.107935-0500 Runner[2521:390363] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend. (lldb) 2023-05-19 13:48:19.107935-0500 Runner[2521:390363] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend. 2023-05-19 13:48:19.156866-0500 Runner[2521:390612] flutter: The Dart VM service is listening on http://127.0.0.1:63508/IsFnhXJykCM=/ VM Service URL on device: http://127.0.0.1:63508/IsFnhXJykCM=/ ```
1 parent f86c529 commit 7fa45ea

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

packages/flutter_tools/lib/src/ios/ios_deploy.dart

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ class IOSDeployDebugger {
348348
.transform<String>(utf8.decoder)
349349
.transform<String>(const LineSplitter())
350350
.listen((String line) {
351+
352+
// TODO(vashworth): Revert after https://github.com/flutter/flutter/issues/121231 is resolved.
353+
if (line.isNotEmpty) {
354+
_logger.printTrace(line);
355+
}
356+
351357
_monitorIOSDeployFailure(line, _logger);
352358

353359
// (lldb) platform select remote-'ios' --sysroot
@@ -365,7 +371,6 @@ class IOSDeployDebugger {
365371
}
366372
final String prompt = line.substring(0, promptEndIndex);
367373
lldbRun = RegExp(RegExp.escape(prompt) + r'\s*run');
368-
_logger.printTrace(line);
369374
return;
370375
}
371376

@@ -384,7 +389,6 @@ class IOSDeployDebugger {
384389
// success
385390
// 2020-09-15 13:42:25.185474-0700 Runner[477:181141] flutter: The Dart VM service is listening on http://127.0.0.1:57782/
386391
if (lldbRun.hasMatch(line)) {
387-
_logger.printTrace(line);
388392
_debuggerState = _IOSDeployDebuggerState.launching;
389393
// TODO(vashworth): Remove all debugger state comments when https://github.com/flutter/flutter/issues/126412 is resolved.
390394
_logger.printTrace('Debugger state set to launching.');
@@ -393,7 +397,6 @@ class IOSDeployDebugger {
393397
// Next line after "run" must be "success", or the attach failed.
394398
// Example: "error: process launch failed"
395399
if (_debuggerState == _IOSDeployDebuggerState.launching) {
396-
_logger.printTrace(line);
397400
final bool attachSuccess = line == 'success';
398401
_debuggerState = attachSuccess ? _IOSDeployDebuggerState.attached : _IOSDeployDebuggerState.detached;
399402
_logger.printTrace('Debugger state set to ${attachSuccess ? 'attached' : 'detached'}.');
@@ -408,7 +411,6 @@ class IOSDeployDebugger {
408411
// process signal SIGSTOP
409412
if (line.contains(_signalStop)) {
410413
// The app is about to be stopped. Only show in verbose mode.
411-
_logger.printTrace(line);
412414
return;
413415
}
414416

@@ -421,7 +423,6 @@ class IOSDeployDebugger {
421423

422424
if (line == _backTraceAll) {
423425
// The app is stopped and the backtrace for all threads will be printed.
424-
_logger.printTrace(line);
425426
// Even though we're not "detached", just stopped, mark as detached so the backtrace
426427
// is only show in verbose.
427428
_debuggerState = _IOSDeployDebuggerState.detached;
@@ -438,7 +439,6 @@ class IOSDeployDebugger {
438439

439440
if (line.contains('PROCESS_STOPPED') || _lldbProcessStopped.hasMatch(line)) {
440441
// The app has been stopped. Dump the backtrace, and detach.
441-
_logger.printTrace(line);
442442
_iosDeployProcess?.stdin.writeln(_backTraceAll);
443443
if (_processResumeCompleter == null) {
444444
detach();
@@ -449,28 +449,24 @@ class IOSDeployDebugger {
449449
if (line.contains('PROCESS_EXITED') || _lldbProcessExit.hasMatch(line)) {
450450
// The app exited or crashed, so exit. Continue passing debugging
451451
// messages to the log reader until it exits to capture crash dumps.
452-
_logger.printTrace(line);
453452
exit();
454453
return;
455454
}
456455
if (_lldbProcessDetached.hasMatch(line)) {
457456
// The debugger has detached from the app, and there will be no more debugging messages.
458457
// Kill the ios-deploy process.
459-
_logger.printTrace(line);
460458
exit();
461459
return;
462460
}
463461

464462
if (_lldbProcessResuming.hasMatch(line)) {
465-
_logger.printTrace(line);
466463
// we marked this detached when we received [_backTraceAll]
467464
_debuggerState = _IOSDeployDebuggerState.attached;
468465
_logger.printTrace('Debugger state set to attached.');
469466
return;
470467
}
471468

472469
if (_debuggerState != _IOSDeployDebuggerState.attached) {
473-
_logger.printTrace(line);
474470
return;
475471
}
476472
if (lastLineFromDebugger != null && lastLineFromDebugger!.isNotEmpty && line.isEmpty) {
@@ -488,7 +484,7 @@ class IOSDeployDebugger {
488484
.transform<String>(const LineSplitter())
489485
.listen((String line) {
490486
_monitorIOSDeployFailure(line, _logger);
491-
_logger.printTrace(line);
487+
_logger.printTrace('error: $line');
492488
});
493489
unawaited(_iosDeployProcess!.exitCode.then((int status) async {
494490
_logger.printTrace('ios-deploy exited with code $exitCode');

packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ void main () {
9494
logger = BufferLogger.test();
9595
});
9696

97+
testWithoutContext('print all lines', () async {
98+
final StreamController<List<int>> stdin = StreamController<List<int>>();
99+
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
100+
FakeCommand(
101+
command: const <String>['ios-deploy'],
102+
stdout: "(mylldb) platform select remote-'ios' --sysroot\r\n(mylldb) run\r\nsuccess\r\nrandom string\r\n",
103+
stdin: IOSink(stdin.sink),
104+
),
105+
]);
106+
final IOSDeployDebugger iosDeployDebugger = IOSDeployDebugger.test(
107+
processManager: processManager,
108+
logger: logger,
109+
);
110+
expect(await iosDeployDebugger.launchAndAttach(), isTrue);
111+
expect(logger.traceText, contains("(mylldb) platform select remote-'ios' --sysroot"));
112+
expect(logger.traceText, contains('(mylldb) run'));
113+
expect(logger.traceText, contains('success'));
114+
expect(logger.traceText, contains('random string'));
115+
});
116+
97117
testWithoutContext('custom lldb prompt', () async {
98118
final StreamController<List<int>> stdin = StreamController<List<int>>();
99119
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[

0 commit comments

Comments
 (0)