[fuchsia_remote_debug_protocol] Adds the fuchsia remote debug protocol package.
Adds a package that will support connecting to and debugging devices with multiple instances of the Dart VM, and operate on multiple Isolates and Flutter Views. Currently supports connecting to all existing Dart VMs and extracting information about all Flutter Views running across each VM.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
// Copyright 2018 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:fuchsia_remote_debug_protocol/fuchsia_remote_debug_protocol.dart';
|
||||
import 'package:fuchsia_remote_debug_protocol/logging.dart';
|
||||
|
||||
/// Runs through a simple usage of the fuchsia_remote_debug_protocol library:
|
||||
/// connects to a remote machine at the address in argument 1 (interface
|
||||
/// optional for argument 2) to list all active flutter views and Dart VMs
|
||||
/// running on said device. This uses an SSH config file (optional, depending
|
||||
/// on your setup).
|
||||
///
|
||||
/// Example usage:
|
||||
///
|
||||
/// $ dart examples/list_vms_and_flutter_views.dart \
|
||||
/// fe80::8eae:4cff:fef4:9247 eno1
|
||||
Future<Null> main(List<String> args) async {
|
||||
// Log only at info level within the library. If issues arise, this can be
|
||||
// changed to [LoggingLevel.all] or [LoggingLevel.fine] to see more
|
||||
// information.
|
||||
Logger.globalLevel = LoggingLevel.info;
|
||||
if (args.isEmpty) {
|
||||
print('Expects an IP address and/or network interface');
|
||||
return;
|
||||
}
|
||||
final String address = args[0];
|
||||
final String interface = args.length > 1 ? args[1] : '';
|
||||
// Example ssh config path for the Fuchsia device after having made a local
|
||||
// build.
|
||||
const String sshConfigPath = '../../out/release-x86-64/ssh-keys/ssh_config';
|
||||
final FuchsiaRemoteConnection connection =
|
||||
await FuchsiaRemoteConnection.connect(address, interface, sshConfigPath);
|
||||
print('On $address, the following Dart VM ports are running:');
|
||||
for (int port in await connection.getDeviceServicePorts()) {
|
||||
print('\t$port');
|
||||
}
|
||||
print('');
|
||||
|
||||
print('The following Flutter views are running:');
|
||||
for (FlutterView view in await connection.getFlutterViews()) {
|
||||
print('\t${view.name ?? view.id}');
|
||||
}
|
||||
await connection.stop();
|
||||
}
|
||||
Reference in New Issue
Block a user