Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/standalone/debugger/debug_lib.dart

Issue 12086080: Fix debugger test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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";
11 import "dart:json"; 11 import "dart:json" as JSON;
12 12
13 // TODO(hausner): need to select a different port number for each 13 // TODO(hausner): need to select a different port number for each
14 // test that runs in parallel. 14 // test that runs in parallel.
15 var debugPort = 5860; 15 var debugPort = 5860;
16 16
17 // Whether or not to print debug target process on the console. 17 // Whether or not to print debug target process on the console.
18 var showDebuggeeOutput = true; 18 var showDebuggeeOutput = true;
19 19
20 // Whether or not to print the debugger wire messages on the console. 20 // Whether or not to print the debugger wire messages on the console.
21 var verboseWire = false; 21 var verboseWire = false;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // message objects (maps). 423 // message objects (maps).
424 void handleMessages() { 424 void handleMessages() {
425 var msg = responses.getNextMessage(); 425 var msg = responses.getNextMessage();
426 while (msg != null) { 426 while (msg != null) {
427 if (verboseWire) print("RECV: $msg"); 427 if (verboseWire) print("RECV: $msg");
428 var msgObj = JSON.parse(msg); 428 var msgObj = JSON.parse(msg);
429 handleMessage(msgObj); 429 handleMessage(msgObj);
430 if (errorsDetected) { 430 if (errorsDetected) {
431 error("Error while handling script entry ${script.currentIndex}"); 431 error("Error while handling script entry ${script.currentIndex}");
432 error("Message received from debug target: $msg"); 432 error("Message received from debug target: $msg");
433 close(); 433 close(killDebugee: true);
Tom Ball 2013/01/31 14:59:26 Spelling: should be "debuggee", to match "debugger
434 return; 434 return;
435 } 435 }
436 if (shutdownEventSeen) { 436 if (shutdownEventSeen) {
437 close(); 437 close();
438 return; 438 return;
439 } 439 }
440 sendNextCommand(); 440 sendNextCommand();
441 msg = responses.getNextMessage(); 441 msg = responses.getNextMessage();
442 } 442 }
443 } 443 }
(...skipping 20 matching lines...) Expand all
464 void openConnection() { 464 void openConnection() {
465 socket = new Socket("127.0.0.1", portNumber); 465 socket = new Socket("127.0.0.1", portNumber);
466 to = socket.outputStream; 466 to = socket.outputStream;
467 from = new StringInputStream(socket.inputStream, Encoding.UTF_8); 467 from = new StringInputStream(socket.inputStream, Encoding.UTF_8);
468 from.onData = () { 468 from.onData = () {
469 try { 469 try {
470 responses.append(from.read()); 470 responses.append(from.read());
471 handleMessages(); 471 handleMessages();
472 } catch(e, trace) { 472 } catch(e, trace) {
473 print("Unexpected exception:\n$e\n$trace"); 473 print("Unexpected exception:\n$e\n$trace");
474 close(); 474 close(killDebugee: true);
475 } 475 }
476 }; 476 };
477 from.onClosed = () { 477 from.onClosed = () {
478 print("Connection closed by debug target"); 478 print("Connection closed by debug target");
479 close(); 479 close(killDebugee: true);
480 }; 480 };
481 from.onError = (e) { 481 from.onError = (e) {
482 print("Error '$e' detected in input stream from debug target"); 482 print("Error '$e' detected in input stream from debug target");
483 close(); 483 close(killDebugee: true);
484 }; 484 };
485 } 485 }
486 486
487 void close() { 487 void close({killDebugee: false}) {
488 if (errorsDetected) { 488 if (errorsDetected) {
489 for (int i = 0; i < errors.length; i++) print(errors[i]); 489 for (int i = 0; i < errors.length; i++) print(errors[i]);
490 } 490 }
491 to.close(); 491 to.close();
492 socket.close(); 492 socket.close();
493 targetProcess.kill(); 493 if (killDebugee) {
494 print("Target process killed"); 494 targetProcess.kill();
495 print("Target process killed");
496 }
495 Expect.isTrue(!errorsDetected); 497 Expect.isTrue(!errorsDetected);
496 stdin.close(); 498 stdin.close();
497 stdout.close(); 499 stdout.close();
498 stderr.close(); 500 stderr.close();
499 } 501 }
500 } 502 }
501 503
502 504
503 bool RunScript(List script) { 505 bool RunScript(List script) {
504 var options = new Options(); 506 var options = new Options();
505 if (options.arguments.contains("--debuggee")) { 507 if (options.arguments.contains("--debuggee")) {
506 return false; 508 return false;
507 } 509 }
508 showDebuggeeOutput = options.arguments.contains("--verbose"); 510 showDebuggeeOutput = options.arguments.contains("--verbose");
509 verboseWire = options.arguments.contains("--wire"); 511 verboseWire = options.arguments.contains("--wire");
510 512
511 var targetOpts = [ "--debug:$debugPort" ]; 513 var targetOpts = [ "--debug:$debugPort" ];
512 if (showDebuggeeOutput) targetOpts.add("--verbose_debug"); 514 if (showDebuggeeOutput) targetOpts.add("--verbose_debug");
513 targetOpts.add(options.script); 515 targetOpts.add(options.script);
514 targetOpts.add("--debuggee"); 516 targetOpts.add("--debuggee");
515 517
516 Process.start(options.executable, targetOpts).then((Process process) { 518 Process.start(options.executable, targetOpts).then((Process process) {
517 print("Debug target process started"); 519 print("Debug target process started");
518 process.stdin.close(); 520 process.stdin.close();
519 process.stdout.onData = process.stdout.read; 521 process.stdout.onData = process.stdout.read;
520 process.stderr.onData = process.stderr.read; 522 process.stderr.onData = process.stderr.read;
521 process.onExit = (int exitCode) { 523 process.onExit = (int exitCode) {
524 Expect.equals(0, exitCode);
522 print("Debug target process exited with exit code $exitCode"); 525 print("Debug target process exited with exit code $exitCode");
523 }; 526 };
524 var debugger = new Debugger(process, debugPort); 527 var debugger = new Debugger(process, debugPort);
525 stdin.onClosed = () => debugger.close(); 528 stdin.onClosed = () => debugger.close(killDebugee: true);
526 stdin.onError = (error) => debugger.close(); 529 stdin.onError = (error) => debugger.close(killDebugee: true);
527 debugger.runScript(script); 530 debugger.runScript(script);
528 }); 531 });
529 return true; 532 return true;
530 } 533 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698