| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library debugger_page_element; | 5 library debugger_page_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
| 10 import 'package:observatory/app.dart'; | 10 import 'package:observatory/app.dart'; |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 } | 962 } |
| 963 String helpShort = 'Switch the current isolate'; | 963 String helpShort = 'Switch the current isolate'; |
| 964 | 964 |
| 965 String helpLong = | 965 String helpLong = |
| 966 'Switch the current isolate.\n' | 966 'Switch the current isolate.\n' |
| 967 '\n' | 967 '\n' |
| 968 'Syntax: isolate <number>\n' | 968 'Syntax: isolate <number>\n' |
| 969 ' isolate <name>\n'; | 969 ' isolate <name>\n'; |
| 970 } | 970 } |
| 971 | 971 |
| 972 String _isolateRunState(Isolate isolate) { |
| 973 if (isolate.paused) { |
| 974 return 'paused'; |
| 975 } else if (isolate.running) { |
| 976 return 'running'; |
| 977 } else if (isolate.idle) { |
| 978 return 'idle'; |
| 979 } else { |
| 980 return 'unknown'; |
| 981 } |
| 982 } |
| 983 |
| 972 class IsolateListCommand extends DebuggerCommand { | 984 class IsolateListCommand extends DebuggerCommand { |
| 973 IsolateListCommand(Debugger debugger) : super(debugger, 'list', []); | 985 IsolateListCommand(Debugger debugger) : super(debugger, 'list', []); |
| 974 | 986 |
| 975 Future run(List<String> args) { | 987 Future run(List<String> args) async { |
| 976 if (debugger.vm == null) { | 988 if (debugger.vm == null) { |
| 977 debugger.console.print( | 989 debugger.console.print( |
| 978 "Internal error: vm has not been set"); | 990 "Internal error: vm has not been set"); |
| 979 return new Future.value(null); | 991 return; |
| 980 } | 992 } |
| 993 |
| 994 // Refresh all isolates first. |
| 995 var pending = []; |
| 981 for (var isolate in debugger.vm.isolates) { | 996 for (var isolate in debugger.vm.isolates) { |
| 982 String current = (isolate == debugger.isolate ? ' *' : ''); | 997 pending.add(isolate.reload()); |
| 998 } |
| 999 await Future.wait(pending); |
| 1000 |
| 1001 const maxIdLen = 9; |
| 1002 const maxRunStateLen = 7; |
| 1003 var maxNameLen = 0; |
| 1004 for (var isolate in debugger.vm.isolates) { |
| 1005 if (isolate.name.length > maxNameLen) { |
| 1006 maxNameLen = isolate.name.length; |
| 1007 } |
| 1008 } |
| 1009 |
| 1010 debugger.console.print("${'ID'.padLeft(maxIdLen, ' ')} " |
| 1011 "${'ORIGIN'.padLeft(maxIdLen, ' ')} " |
| 1012 "${'NAME'.padRight(maxNameLen, ' ')} " |
| 1013 "${'STATE'.padRight(maxRunStateLen, ' ')} " |
| 1014 "CURRENT"); |
| 1015 for (var isolate in debugger.vm.isolates) { |
| 1016 String current = (isolate == debugger.isolate ? '*' : ''); |
| 983 debugger.console.print( | 1017 debugger.console.print( |
| 984 "Isolate ${isolate.number} '${isolate.name}'${current}"); | 1018 "${isolate.number.toString().padLeft(maxIdLen, ' ')} " |
| 1019 "${isolate.originNumber.toString().padLeft(maxIdLen, ' ')} " |
| 1020 "${isolate.name.padRight(maxNameLen, ' ')} " |
| 1021 "${_isolateRunState(isolate).padRight(maxRunStateLen, ' ')} " |
| 1022 "${current}"); |
| 985 } | 1023 } |
| 986 return new Future.value(null); | 1024 debugger.console.newline(); |
| 987 } | 1025 } |
| 988 | 1026 |
| 989 String helpShort = 'List all isolates'; | 1027 String helpShort = 'List all isolates'; |
| 990 | 1028 |
| 991 String helpLong = | 1029 String helpLong = |
| 992 'List all isolates.\n' | 1030 'List all isolates.\n' |
| 993 '\n' | 1031 '\n' |
| 994 'Syntax: isolate list\n'; | 1032 'Syntax: isolate list\n'; |
| 995 } | 1033 } |
| 996 | 1034 |
| (...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 } | 2492 } |
| 2455 }); | 2493 }); |
| 2456 } | 2494 } |
| 2457 | 2495 |
| 2458 void focus() { | 2496 void focus() { |
| 2459 $['textBox'].focus(); | 2497 $['textBox'].focus(); |
| 2460 } | 2498 } |
| 2461 | 2499 |
| 2462 DebuggerInputElement.created() : super.created(); | 2500 DebuggerInputElement.created() : super.created(); |
| 2463 } | 2501 } |
| OLD | NEW |