| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 used by debugger wire protocol tests (standalone VM debugging). | 5 // Library used by debugger wire protocol tests (standalone VM debugging). |
| 6 | 6 |
| 7 library DartDebugger; | 7 library DartDebugger; |
| 8 | 8 |
| 9 import "dart:async"; | 9 import "dart:async"; |
| 10 import "dart:convert"; |
| 10 import "dart:io"; | 11 import "dart:io"; |
| 11 import "dart:math"; | 12 import "dart:math"; |
| 12 import "dart:utf"; | 13 import "dart:utf"; |
| 13 import "dart:json" as JSON; | 14 import "dart:json" as JSON; |
| 14 | 15 |
| 15 // Whether or not to print the debugger wire messages on the console. | 16 // Whether or not to print the debugger wire messages on the console. |
| 16 var verboseWire = false; | 17 var verboseWire = false; |
| 17 | 18 |
| 18 // Class to buffer wire protocol data from debug target and | 19 // Class to buffer wire protocol data from debug target and |
| 19 // break it down to individual json messages. | 20 // break it down to individual json messages. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // Data collected from debug target. | 387 // Data collected from debug target. |
| 387 Map currentMessage = null; // Currently handled message sent by target. | 388 Map currentMessage = null; // Currently handled message sent by target. |
| 388 String scriptUrl = null; | 389 String scriptUrl = null; |
| 389 bool shutdownEventSeen = false; | 390 bool shutdownEventSeen = false; |
| 390 int isolateId = 0; | 391 int isolateId = 0; |
| 391 bool isPaused = false; | 392 bool isPaused = false; |
| 392 | 393 |
| 393 Debugger(this.targetProcess, this.script) { | 394 Debugger(this.targetProcess, this.script) { |
| 394 var stdoutStringStream = targetProcess.stdout | 395 var stdoutStringStream = targetProcess.stdout |
| 395 .transform(new StringDecoder()) | 396 .transform(new StringDecoder()) |
| 396 .transform(new LineTransformer()); | 397 .transform(new LineSplitter()); |
| 397 stdoutStringStream.listen((line) { | 398 stdoutStringStream.listen((line) { |
| 398 print("TARG: $line"); | 399 print("TARG: $line"); |
| 399 if (line.startsWith("Debugger listening")) { | 400 if (line.startsWith("Debugger listening")) { |
| 400 RegExp portExpr = new RegExp(r"\d+"); | 401 RegExp portExpr = new RegExp(r"\d+"); |
| 401 var port = portExpr.stringMatch(line); | 402 var port = portExpr.stringMatch(line); |
| 402 print("Debug target found listening at port '$port'"); | 403 print("Debug target found listening at port '$port'"); |
| 403 openConnection(int.parse(port)); | 404 openConnection(int.parse(port)); |
| 404 } | 405 } |
| 405 }); | 406 }); |
| 406 | 407 |
| 407 var stderrStringStream = targetProcess.stderr | 408 var stderrStringStream = targetProcess.stderr |
| 408 .transform(new StringDecoder()) | 409 .transform(new StringDecoder()) |
| 409 .transform(new LineTransformer()); | 410 .transform(new LineSplitter()); |
| 410 stderrStringStream.listen((line) { | 411 stderrStringStream.listen((line) { |
| 411 print("TARG: $line"); | 412 print("TARG: $line"); |
| 412 }); | 413 }); |
| 413 } | 414 } |
| 414 | 415 |
| 415 // Handle debugger events, updating the debugger state. | 416 // Handle debugger events, updating the debugger state. |
| 416 void handleEvent(Map<String,dynamic> msg) { | 417 void handleEvent(Map<String,dynamic> msg) { |
| 417 events.add(new Event(msg)); | 418 events.add(new Event(msg)); |
| 418 | 419 |
| 419 if (msg["event"] == "isolate") { | 420 if (msg["event"] == "isolate") { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 targetOpts.add("--debuggee"); | 616 targetOpts.add("--debuggee"); |
| 616 print('args: ${targetOpts.join(" ")}'); | 617 print('args: ${targetOpts.join(" ")}'); |
| 617 | 618 |
| 618 Process.start(Platform.executable, targetOpts).then((Process process) { | 619 Process.start(Platform.executable, targetOpts).then((Process process) { |
| 619 print("Debug target process started, pid ${process.pid}."); | 620 print("Debug target process started, pid ${process.pid}."); |
| 620 process.stdin.close(); | 621 process.stdin.close(); |
| 621 var debugger = new Debugger(process, new DebugScript(script)); | 622 var debugger = new Debugger(process, new DebugScript(script)); |
| 622 }); | 623 }); |
| 623 return true; | 624 return true; |
| 624 } | 625 } |
| OLD | NEW |