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

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

Issue 12091067: Revert "Fix debugger test that broke with the change to the json library." (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" as JSON; 11 import "dart: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 20 matching lines...) Expand all
42 msg = buffer; 42 msg = buffer;
43 buffer = null; 43 buffer = null;
44 } else { 44 } else {
45 assert(msgLen < buffer.length); 45 assert(msgLen < buffer.length);
46 msg = buffer.substring(0, msgLen); 46 msg = buffer.substring(0, msgLen);
47 buffer = buffer.substring(msgLen); 47 buffer = buffer.substring(msgLen);
48 } 48 }
49 return msg; 49 return msg;
50 } 50 }
51 51
52 // Returns the character length of the newxt json message in the 52 // Returns the character length of the newxt json message in the
Bill Hesse 2013/01/30 16:04:09 typo newxt.
53 // buffer, or 0 if there is only a partial message in the buffer. 53 // buffer, or 0 if there is only a partial message in the buffer.
54 // The object value must start with '{' and continues to the 54 // The object value must start with '{' and continues to the
55 // matching '}'. No attempt is made to otherwise validate the contents 55 // matching '}'. No attempt is made to otherwise validate the contents
56 // as JSON. If it is invalid, a later JSON.parse() will fail. 56 // as JSON. If it is invalid, a later JSON.parse() will fail.
57 int objectLength() { 57 int objectLength() {
58 int skipWhitespace(int index) { 58 int skipWhitespace(int index) {
59 while (index < buffer.length) { 59 while (index < buffer.length) {
60 String char = buffer[index]; 60 String char = buffer[index];
61 if (char != " " && char != "\n" && char != "\r" && char != "\t") break; 61 if (char != " " && char != "\n" && char != "\r" && char != "\t") break;
62 index++; 62 index++;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 } 419 }
420 420
421 // Handle data received over the wire from the debug target 421 // Handle data received over the wire from the debug target
422 // process. Split input from JSON wire format into individual 422 // process. Split input from JSON wire format into individual
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);
Bill Hesse 2013/01/30 16:04:09 Shouldn't this JSON prefix be removed?
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();
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 }
444 444
445 runScript(List entries) { 445 runScript(List entries) {
446 script = new DebugScript(entries); 446 script = new DebugScript(entries);
447 openConnection(); 447 openConnection();
448 } 448 }
449 449
450 // Send a debugger command to the target VM. 450 // Send a debugger command to the target VM.
451 void sendMessage(Map<String,dynamic> msg) { 451 void sendMessage(Map<String,dynamic> msg) {
452 String jsonMsg = JSON.stringify(msg); 452 String jsonMsg = JSON.stringify(msg);
Bill Hesse 2013/01/30 16:04:09 Another JSON prefix.
453 if (verboseWire) print("SEND: $jsonMsg"); 453 if (verboseWire) print("SEND: $jsonMsg");
454 to.writeString(jsonMsg, Encoding.UTF_8); 454 to.writeString(jsonMsg, Encoding.UTF_8);
455 } 455 }
456 456
457 bool get errorsDetected => errors.length > 0; 457 bool get errorsDetected => errors.length > 0;
458 458
459 // Record error message. 459 // Record error message.
460 void error(String s) { 460 void error(String s) {
461 errors.add(s); 461 errors.add(s);
462 } 462 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 if (showDebuggeeOutput) targetOpts.add("--verbose_debug"); 512 if (showDebuggeeOutput) targetOpts.add("--verbose_debug");
513 targetOpts.add(options.script); 513 targetOpts.add(options.script);
514 targetOpts.add("--debuggee"); 514 targetOpts.add("--debuggee");
515 515
516 Process.start(options.executable, targetOpts).then((Process process) { 516 Process.start(options.executable, targetOpts).then((Process process) {
517 print("Debug target process started"); 517 print("Debug target process started");
518 process.stdin.close(); 518 process.stdin.close();
519 process.stdout.onData = process.stdout.read; 519 process.stdout.onData = process.stdout.read;
520 process.stderr.onData = process.stderr.read; 520 process.stderr.onData = process.stderr.read;
521 process.onExit = (int exitCode) { 521 process.onExit = (int exitCode) {
522 Expect.equals(0, exitCode);
523 print("Debug target process exited with exit code $exitCode"); 522 print("Debug target process exited with exit code $exitCode");
524 }; 523 };
525 var debugger = new Debugger(process, debugPort); 524 var debugger = new Debugger(process, debugPort);
526 stdin.onClosed = () => debugger.close(); 525 stdin.onClosed = () => debugger.close();
527 stdin.onError = (error) => debugger.close(); 526 stdin.onError = (error) => debugger.close();
528 debugger.runScript(script); 527 debugger.runScript(script);
529 }); 528 });
530 return true; 529 return true;
531 } 530 }
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