Chromium Code Reviews| 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:io"; | 9 import "dart:io"; |
| 10 import "dart:utf"; | 10 import "dart:utf"; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 int seqNr = 0; // Sequence number of next debugger command message. | 316 int seqNr = 0; // Sequence number of next debugger command message. |
| 317 Command lastCommand = null; // Most recent command sent to target. | 317 Command lastCommand = null; // Most recent command sent to target. |
| 318 List<String> errors = new List(); | 318 List<String> errors = new List(); |
| 319 | 319 |
| 320 // Data collected from debug target. | 320 // Data collected from debug target. |
| 321 Map currentMessage = null; // Currently handled message sent by target. | 321 Map currentMessage = null; // Currently handled message sent by target. |
| 322 String scriptUrl = null; | 322 String scriptUrl = null; |
| 323 bool shutdownEventSeen = false; | 323 bool shutdownEventSeen = false; |
| 324 int isolateId = 0; | 324 int isolateId = 0; |
| 325 | 325 |
| 326 // stdin subscription to allow terminating the test via command-line. | |
| 327 var stdinSubscription; | |
| 328 | |
| 329 Debugger(this.targetProcess, this.portNumber) { | 326 Debugger(this.targetProcess, this.portNumber) { |
| 330 stdinSubscription = | |
| 331 stdin.listen((d) {}, | |
| 332 onError: (error) => close(killDebugee: true), | |
| 333 onDone: () => close(killDebugee: true)); | |
| 334 | |
| 335 var stdoutStringStream = targetProcess.stdout | 327 var stdoutStringStream = targetProcess.stdout |
| 336 .transform(new StringDecoder()) | 328 .transform(new StringDecoder()) |
| 337 .transform(new LineTransformer()); | 329 .transform(new LineTransformer()); |
| 338 stdoutStringStream.listen((line) { | 330 stdoutStringStream.listen((line) { |
| 339 if (showDebuggeeOutput) { | 331 if (showDebuggeeOutput) { |
| 340 print("TARG: $line"); | 332 print("TARG: $line"); |
| 341 } | 333 } |
| 342 }); | 334 }); |
| 343 | 335 |
| 344 var stderrStringStream = targetProcess.stderr | 336 var stderrStringStream = targetProcess.stderr |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 close(killDebugee: true); | 485 close(killDebugee: true); |
| 494 }); | 486 }); |
| 495 }); | 487 }); |
| 496 } | 488 } |
| 497 | 489 |
| 498 void close({killDebugee: false}) { | 490 void close({killDebugee: false}) { |
| 499 if (errorsDetected) { | 491 if (errorsDetected) { |
| 500 for (int i = 0; i < errors.length; i++) print(errors[i]); | 492 for (int i = 0; i < errors.length; i++) print(errors[i]); |
| 501 } | 493 } |
| 502 socket.close(); | 494 socket.close(); |
| 503 stdinSubscription.cancel(); | |
| 504 if (killDebugee) { | 495 if (killDebugee) { |
| 505 targetProcess.kill(); | 496 targetProcess.kill(); |
| 506 print("Target process killed"); | 497 print("Target process killed"); |
| 507 } | 498 } |
| 508 Expect.isTrue(!errorsDetected); | 499 Expect.isTrue(!errorsDetected); |
| 509 stdin.close(); | 500 stdin.close(); |
| 510 stdout.close(); | 501 stdout.close(); |
| 511 stderr.close(); | 502 stderr.close(); |
| 512 } | 503 } |
| 513 } | 504 } |
| 514 | 505 |
| 515 | 506 |
| 516 bool RunScript(List script) { | 507 bool RunScript(List script) { |
| 517 var options = new Options(); | 508 var options = new Options(); |
| 518 if (options.arguments.contains("--debuggee")) { | 509 if (options.arguments.contains("--debuggee")) { |
| 519 return false; | 510 return false; |
| 520 } | 511 } |
| 521 showDebuggeeOutput = options.arguments.contains("--verbose"); | 512 // The default is to show debugging output. |
| 513 showDebuggeeOutput = !options.arguments.contains("--non-verbose"); | |
|
Ivan Posva
2013/03/26 15:58:38
--no-verbose
| |
| 522 verboseWire = options.arguments.contains("--wire"); | 514 verboseWire = options.arguments.contains("--wire"); |
| 523 | 515 |
| 524 var targetOpts = [ "--debug:$debugPort" ]; | 516 var targetOpts = [ "--debug:$debugPort" ]; |
| 525 if (showDebuggeeOutput) targetOpts.add("--verbose_debug"); | 517 if (showDebuggeeOutput) targetOpts.add("--verbose_debug"); |
| 526 targetOpts.add(options.script); | 518 targetOpts.add(options.script); |
| 527 targetOpts.add("--debuggee"); | 519 targetOpts.add("--debuggee"); |
| 528 | 520 |
| 529 Process.start(options.executable, targetOpts).then((Process process) { | 521 Process.start(options.executable, targetOpts).then((Process process) { |
| 530 print("Debug target process started"); | 522 print("Debug target process started"); |
| 531 process.stdin.close(); | 523 process.stdin.close(); |
| 532 process.exitCode.then((int exitCode) { | 524 process.exitCode.then((int exitCode) { |
| 533 Expect.equals(0, exitCode); | 525 Expect.equals(0, exitCode); |
| 534 Expect.equals(0, exitCode); | |
| 535 print("Debug target process exited with exit code $exitCode"); | 526 print("Debug target process exited with exit code $exitCode"); |
| 536 }); | 527 }); |
| 537 var debugger = new Debugger(process, debugPort); | 528 var debugger = new Debugger(process, debugPort); |
| 538 debugger.runScript(script); | 529 debugger.runScript(script); |
| 539 }); | 530 }); |
| 540 return true; | 531 return true; |
| 541 } | 532 } |
| OLD | NEW |