| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Simple interactive debugger shell that connects to the Dart VM's debugger | 5 // Simple interactive debugger shell that connects to the Dart VM's debugger |
| 6 // connection port. | 6 // connection port. |
| 7 | 7 |
| 8 import "dart:convert"; | 8 import "dart:convert"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 import "dart:async"; | 10 import "dart:async"; |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 } | 959 } |
| 960 | 960 |
| 961 | 961 |
| 962 Future<TargetScript> getTargetScript(Map location) { | 962 Future<TargetScript> getTargetScript(Map location) { |
| 963 var isolate = targetIsolates[currentIsolate.id]; | 963 var isolate = targetIsolates[currentIsolate.id]; |
| 964 var url = location['url']; | 964 var url = location['url']; |
| 965 var script = isolate.scripts[url]; | 965 var script = isolate.scripts[url]; |
| 966 if (script != null) { | 966 if (script != null) { |
| 967 return new Future.value(script); | 967 return new Future.value(script); |
| 968 } | 968 } |
| 969 script = new TargetScript(); |
| 969 | 970 |
| 970 // Ask the vm for the source and line number table. | 971 // Ask the vm for the source and line number table. |
| 971 var sourceCmd = { | 972 var sourceCmd = { |
| 972 "id": seqNum++, | 973 "id": seqNum++, |
| 973 "command": "getScriptSource", | 974 "command": "getScriptSource", |
| 974 "params": { "isolateId": currentIsolate.id, | 975 "params": { "isolateId": currentIsolate.id, |
| 975 "libraryId": location['libraryId'], | 976 "libraryId": location['libraryId'], |
| 976 "url": url } }; | 977 "url": url } }; |
| 977 | 978 |
| 978 var lineNumberCmd = { | 979 var lineNumberCmd = { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 990 script.lineToSource = ['']; | 991 script.lineToSource = ['']; |
| 991 script.lineToSource.addAll(script.source.split('\n')); | 992 script.lineToSource.addAll(script.source.split('\n')); |
| 992 }); | 993 }); |
| 993 | 994 |
| 994 // Send the line numbers command | 995 // Send the line numbers command |
| 995 var lineNumberResponse = sendCmd(lineNumberCmd).then((response) { | 996 var lineNumberResponse = sendCmd(lineNumberCmd).then((response) { |
| 996 Map result = response["result"]; | 997 Map result = response["result"]; |
| 997 script.tokenToLine = parseLineNumberTable(result['lines']); | 998 script.tokenToLine = parseLineNumberTable(result['lines']); |
| 998 }); | 999 }); |
| 999 | 1000 |
| 1000 script = new TargetScript(); | |
| 1001 return Future.wait([sourceResponse, lineNumberResponse]).then((_) { | 1001 return Future.wait([sourceResponse, lineNumberResponse]).then((_) { |
| 1002 // When both commands complete, cache the result. | 1002 // When both commands complete, cache the result. |
| 1003 isolate.scripts[url] = script; | 1003 isolate.scripts[url] = script; |
| 1004 return script; | 1004 return script; |
| 1005 }); | 1005 }); |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 | 1008 |
| 1009 Future printLocation(String label, Map location) { | 1009 Future printLocation(String label, Map location) { |
| 1010 // Figure out the line number. | 1010 // Figure out the line number. |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 handleUncaughtError: debuggerError)); | 1409 handleUncaughtError: debuggerError)); |
| 1410 | 1410 |
| 1411 zone.run(() { | 1411 zone.run(() { |
| 1412 parseArgs(args); | 1412 parseArgs(args); |
| 1413 cmdo = new Commando(completer: debuggerCommandCompleter); | 1413 cmdo = new Commando(completer: debuggerCommandCompleter); |
| 1414 cmdSubscription = cmdo.commands.listen(processCommand, | 1414 cmdSubscription = cmdo.commands.listen(processCommand, |
| 1415 onError: processError, | 1415 onError: processError, |
| 1416 onDone: processDone); | 1416 onDone: processDone); |
| 1417 }); | 1417 }); |
| 1418 } | 1418 } |
| OLD | NEW |