Chromium Code Reviews| 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 // This test forks a second vm process that runs this dart script as | 5 // This test forks a second vm process that runs this dart script as |
| 6 // a debug target. | 6 // a debug target. |
| 7 // Run this test with option --wire to see the json messages sent | 7 // Run this test with option --wire to see the json messages sent |
| 8 // between the processes. | 8 // between the processes. |
| 9 // Run this test with option --verbose to see the stdout and stderr output | 9 // Run this test with option --verbose to see the stdout and stderr output |
| 10 // of the debug target process. | 10 // of the debug target process. |
| 11 | 11 |
| 12 import "debug_lib.dart"; | 12 import "debug_lib.dart"; |
| 13 import "dart:io"; | |
| 14 import "dart:math"; | |
| 15 | |
| 16 var debugPort; | |
| 17 var retries = 0; | |
| 18 var random = new Random(); | |
|
hausner
2013/03/28 00:31:21
Does this generate a different random number each
Tom Ball
2013/03/28 18:19:43
Updated to use current time in milliseconds as see
| |
| 13 | 19 |
| 14 bar(x) { | 20 bar(x) { |
| 15 print(x); | 21 print(x); |
| 16 } | 22 } |
| 17 | 23 |
| 18 foo(i) { | 24 foo(i) { |
| 19 bar("baz"); | 25 bar("baz"); |
| 20 print(i); | 26 print(i); |
| 21 } | 27 } |
| 22 | 28 |
| 23 main() { | 29 void runTest() { |
| 24 if (RunScript(testScript)) return; | 30 if (RunScript(testScript, debugPort)) return; |
| 25 print("Hello from debuggee"); | 31 print("Hello from debuggee"); |
| 26 foo(42); | 32 foo(42); |
| 27 print("Hello again"); | 33 print("Hello again"); |
| 28 } | 34 } |
| 29 | 35 |
| 36 void main() { | |
|
hausner
2013/03/28 00:31:21
It might be more convenient to put this functional
Tom Ball
2013/03/28 18:19:43
Done -- this reverted all changes to this specific
| |
| 37 var options = new Options(); | |
| 38 if (options.arguments.contains("--debuggee")) { | |
| 39 runTest(); | |
| 40 } else { | |
| 41 // Pick a port in the upper half of the port number range. | |
| 42 debugPort = random.nextInt(32000) + 32000; | |
| 43 print('using debug port $debugPort ...'); | |
| 44 ServerSocket.bind('127.0.0.1', debugPort).then((ServerSocket s) { | |
| 45 s.close(); | |
| 46 runTest(); | |
| 47 }, | |
| 48 onError: (e) { | |
| 49 if (++retries >= 3) { | |
| 50 print('unable to find unused port: $e'); | |
| 51 return -1; | |
| 52 } else { | |
| 53 // Retry with another random port. | |
| 54 main(); | |
| 55 } | |
| 56 }); | |
| 57 } | |
| 58 } | |
| 30 | 59 |
| 31 // Expected debugger events and commands. | 60 // Expected debugger events and commands. |
| 32 var testScript = [ | 61 var testScript = [ |
| 33 Breakpoint(), // Expect a breakpoint event. | 62 Breakpoint(), // Expect a breakpoint event. |
| 34 MatchFrame(0, "main"), // Top frame in trace is function "main". | 63 MatchFrame(0, "main"), // Top frame in trace is function "main". |
| 35 Step(), | 64 Step(), |
| 36 Breakpoint(function: "main"), | 65 Breakpoint(function: "main"), |
| 37 SetBreakpoint(15), // Set breakpoint a line 15, in function bar. | 66 SetBreakpoint(21), // Set breakpoint a line 21, in function bar. |
| 38 Resume(), | 67 Resume(), |
| 39 Breakpoint(function: "bar"), | 68 Breakpoint(function: "bar"), |
| 40 MatchFrames(["bar", "foo", "main"]), | 69 MatchFrames(["bar", "foo", "runTest", "main"]), |
| 41 MatchFrame(1, "foo"), | 70 MatchFrame(1, "foo"), |
| 42 Resume(), | 71 Resume(), |
| 43 ]; | 72 ]; |
| OLD | NEW |