Files
sdk/runtime/observatory/bin/shell.dart
T
Alexander Aprelev 6a6b9ac2bf [observatory] Migrate off dart:html to package:web.
Remove use of svg, use unicode characters instead.
Run dart format on observatory sources.
Sort import statements with import_sorter.

No functional changes.

TEST=ci, manual
Change-Id: I7e4f67be06a27c8ab510ae8e50ce30b162780d30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426683
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 10:03:10 -07:00

38 lines
1.2 KiB
Dart

// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library shell;
import 'dart:io';
import 'package:observatory/service_io.dart';
// Simple demo for service_io library. Connects to localhost on the default
// port, picks the first isolate, reads requests from stdin, and prints
// results to stdout. Example session:
// <<< isolate isolates/1071334835
// >>> /classes/40
// <<< {"type":"Class","id":"classes\/40","name":"num","user_name":"num",...
// >>> /objects/0
// >>> {"type":"Array","class":{"type":"@Class","id":"classes\/62",...
void repl(VM vm, Isolate isolate, String lastResult) {
print(lastResult);
Map params = {
'objectId': stdin.readLineSync(),
};
isolate.invokeRpcNoUpgrade('getObject', params).then((Map result) {
repl(vm, isolate, result.toString());
});
}
void main() {
String addr = 'ws://localhost:8181/ws';
new WebSocketVM(new WebSocketVMTarget(addr)).load().then((serviceObject) {
VM vm = serviceObject as VM;
Isolate isolate = vm.isolates.first;
repl(vm, isolate, 'isolate ${isolate.id}');
});
}