OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 debugger_page_element; | 5 library debugger_page_element; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
10 import 'package:observatory/app.dart'; | 10 import 'package:observatory/app.dart'; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 String helpLong = | 311 String helpLong = |
312 'Continue running the isolate.\n' | 312 'Continue running the isolate.\n' |
313 '\n' | 313 '\n' |
314 'Hotkey: [F7]\n' | 314 'Hotkey: [F7]\n' |
315 '\n' | 315 '\n' |
316 'Syntax: continue\n' | 316 'Syntax: continue\n' |
317 ' c\n'; | 317 ' c\n'; |
318 } | 318 } |
319 | 319 |
320 class NextCommand extends DebuggerCommand { | 320 class SmartNextCommand extends DebuggerCommand { |
321 NextCommand(Debugger debugger) : super(debugger, 'next', []); | 321 SmartNextCommand(Debugger debugger) : super(debugger, 'next', []) { |
| 322 alias = 'n'; |
| 323 } |
322 | 324 |
323 Future run(List<String> args) { | 325 Future run(List<String> args) async { |
324 return debugger.next(); | 326 return debugger.smartNext(); |
325 } | 327 } |
326 | 328 |
327 String helpShort = | 329 String helpShort = |
328 'Continue running the isolate until it reaches the next source location ' | 330 'Continue running the isolate until it reaches the next source location ' |
329 'in the current function (hotkey: [F9])'; | 331 'in the current function (hotkey: [F9])'; |
330 | 332 |
331 String helpLong = | 333 String helpLong = |
332 'Continue running the isolate until it reaches the next source location ' | 334 'Continue running the isolate until it reaches the next source location ' |
333 'in the current function.\n' | 335 'in the current function.\n' |
334 '\n' | 336 '\n' |
335 'Hotkey: [F9]\n' | 337 'Hotkey: [F9]\n' |
336 '\n' | 338 '\n' |
337 'Syntax: next\n'; | 339 'Syntax: next\n'; |
338 } | 340 } |
339 | 341 |
| 342 class SyncNextCommand extends DebuggerCommand { |
| 343 SyncNextCommand(Debugger debugger) : super(debugger, 'next-sync', []); |
| 344 |
| 345 Future run(List<String> args) { |
| 346 return debugger.syncNext(); |
| 347 } |
| 348 |
| 349 String helpShort = |
| 350 'Run until return/unwind to current activation.'; |
| 351 |
| 352 String helpLong = |
| 353 'Continue running the isolate until control returns to the current ' |
| 354 'activation or one of its callers.\n' |
| 355 '\n' |
| 356 'Syntax: next-sync\n'; |
| 357 } |
| 358 |
| 359 class AsyncNextCommand extends DebuggerCommand { |
| 360 AsyncNextCommand(Debugger debugger) : super(debugger, 'next-async', []); |
| 361 |
| 362 Future run(List<String> args) { |
| 363 return debugger.asyncNext(); |
| 364 } |
| 365 |
| 366 String helpShort = |
| 367 'Step over await or yield'; |
| 368 |
| 369 String helpLong = |
| 370 'Continue running the isolate until control returns to the current ' |
| 371 'activation of an async or async* function.\n' |
| 372 '\n' |
| 373 'Syntax: next-async\n'; |
| 374 } |
| 375 |
340 class StepCommand extends DebuggerCommand { | 376 class StepCommand extends DebuggerCommand { |
341 StepCommand(Debugger debugger) : super(debugger, 'step', []) { | 377 StepCommand(Debugger debugger) : super(debugger, 'step', []) { |
342 alias = 's'; | 378 alias = 's'; |
343 } | 379 } |
344 | 380 |
345 Future run(List<String> args) { | 381 Future run(List<String> args) { |
346 return debugger.step(); | 382 return debugger.step(); |
347 } | 383 } |
348 | 384 |
349 String helpShort = | 385 String helpShort = |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 'Syntax: log ' | 474 'Syntax: log ' |
439 '# Display the current minimum log level.\n' | 475 '# Display the current minimum log level.\n' |
440 ' log <level> ' | 476 ' log <level> ' |
441 '# Set the minimum log level to <level>.\n' | 477 '# Set the minimum log level to <level>.\n' |
442 ' log OFF ' | 478 ' log OFF ' |
443 '# Display no log messages.\n' | 479 '# Display no log messages.\n' |
444 ' log ALL ' | 480 ' log ALL ' |
445 '# Display all log messages.\n'; | 481 '# Display all log messages.\n'; |
446 } | 482 } |
447 | 483 |
448 class AsyncNextCommand extends DebuggerCommand { | |
449 AsyncNextCommand(Debugger debugger) : super(debugger, 'anext', []) { | |
450 } | |
451 | |
452 Future run(List<String> args) async { | |
453 if (debugger.isolatePaused()) { | |
454 var event = debugger.isolate.pauseEvent; | |
455 if (event.asyncContinuation == null) { | |
456 debugger.console.print("No async continuation at this location"); | |
457 } else { | |
458 return debugger.isolate.asyncStepOver()[Isolate.kFirstResume]; | |
459 } | |
460 } else { | |
461 debugger.console.print('The program is already running'); | |
462 } | |
463 } | |
464 | |
465 String helpShort = | |
466 'Step over await or yield'; | |
467 | |
468 String helpLong = | |
469 'Continue running the isolate until control returns to the current ' | |
470 'activation of an async or async* function.\n' | |
471 '\n' | |
472 'Syntax: anext\n'; | |
473 } | |
474 | |
475 class FinishCommand extends DebuggerCommand { | 484 class FinishCommand extends DebuggerCommand { |
476 FinishCommand(Debugger debugger) : super(debugger, 'finish', []); | 485 FinishCommand(Debugger debugger) : super(debugger, 'finish', []); |
477 | 486 |
478 Future run(List<String> args) { | 487 Future run(List<String> args) { |
479 if (debugger.isolatePaused()) { | 488 if (debugger.isolatePaused()) { |
480 var event = debugger.isolate.pauseEvent; | 489 var event = debugger.isolate.pauseEvent; |
481 if (event.kind == ServiceEvent.kPauseStart) { | 490 if (event.kind == ServiceEvent.kPauseStart) { |
482 debugger.console.print( | 491 debugger.console.print( |
483 "Type 'continue' [F7] or 'step' [F10] to start the isolate"); | 492 "Type 'continue' [F7] or 'step' [F10] to start the isolate"); |
484 return new Future.value(null); | 493 return new Future.value(null); |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 } else { | 1207 } else { |
1199 currentFrame += count; | 1208 currentFrame += count; |
1200 } | 1209 } |
1201 } | 1210 } |
1202 | 1211 |
1203 int get stackDepth => stack['frames'].length; | 1212 int get stackDepth => stack['frames'].length; |
1204 | 1213 |
1205 ObservatoryDebugger() { | 1214 ObservatoryDebugger() { |
1206 _loadSettings(); | 1215 _loadSettings(); |
1207 cmd = new RootCommand([ | 1216 cmd = new RootCommand([ |
| 1217 new AsyncNextCommand(this), |
| 1218 new BreakCommand(this), |
| 1219 new ClearCommand(this), |
| 1220 new ClsCommand(this), |
| 1221 new ContinueCommand(this), |
| 1222 new DeleteCommand(this), |
| 1223 new DownCommand(this), |
| 1224 new FinishCommand(this), |
| 1225 new FrameCommand(this), |
1208 new HelpCommand(this), | 1226 new HelpCommand(this), |
1209 new PrintCommand(this), | |
1210 new DownCommand(this), | |
1211 new UpCommand(this), | |
1212 new FrameCommand(this), | |
1213 new PauseCommand(this), | |
1214 new ContinueCommand(this), | |
1215 new NextCommand(this), | |
1216 new StepCommand(this), | |
1217 new AsyncNextCommand(this), | |
1218 new FinishCommand(this), | |
1219 new BreakCommand(this), | |
1220 new SetCommand(this), | |
1221 new ClearCommand(this), | |
1222 new DeleteCommand(this), | |
1223 new InfoCommand(this), | 1227 new InfoCommand(this), |
1224 new IsolateCommand(this), | 1228 new IsolateCommand(this), |
| 1229 new LogCommand(this), |
| 1230 new PauseCommand(this), |
| 1231 new PrintCommand(this), |
1225 new RefreshCommand(this), | 1232 new RefreshCommand(this), |
1226 new LogCommand(this), | 1233 new SetCommand(this), |
1227 new ClsCommand(this), | 1234 new SmartNextCommand(this), |
| 1235 new StepCommand(this), |
| 1236 new SyncNextCommand(this), |
| 1237 new UpCommand(this), |
1228 ]); | 1238 ]); |
1229 _consolePrinter = new _ConsoleStreamPrinter(this); | 1239 _consolePrinter = new _ConsoleStreamPrinter(this); |
1230 } | 1240 } |
1231 | 1241 |
1232 void _loadSettings() { | 1242 void _loadSettings() { |
1233 _upIsDown = settings.get('up-is-down'); | 1243 _upIsDown = settings.get('up-is-down'); |
1234 } | 1244 } |
1235 | 1245 |
1236 VM get vm => page.app.vm; | 1246 VM get vm => page.app.vm; |
1237 | 1247 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 } else if (event.exception != null) { | 1377 } else if (event.exception != null) { |
1368 console.print('Paused due to exception at ' | 1378 console.print('Paused due to exception at ' |
1369 '${script.name}:${line}:${col}'); | 1379 '${script.name}:${line}:${col}'); |
1370 // This seems to be missing if we are paused-at-exception after | 1380 // This seems to be missing if we are paused-at-exception after |
1371 // paused-at-isolate-exit. Maybe we shutdown part of the debugger too | 1381 // paused-at-isolate-exit. Maybe we shutdown part of the debugger too |
1372 // soon? | 1382 // soon? |
1373 console.printRef(event.exception); | 1383 console.printRef(event.exception); |
1374 } else { | 1384 } else { |
1375 console.print('Paused at ${script.name}:${line}:${col}'); | 1385 console.print('Paused at ${script.name}:${line}:${col}'); |
1376 } | 1386 } |
1377 if (event.asyncContinuation != null) { | |
1378 console.print("Paused in async function: 'anext' available"); | |
1379 } | |
1380 }); | 1387 }); |
1381 } | 1388 } |
1382 } | 1389 } |
1383 | 1390 |
1384 Future _reportBreakpointEvent(ServiceEvent event) { | 1391 Future _reportBreakpointEvent(ServiceEvent event) { |
1385 var bpt = event.breakpoint; | 1392 var bpt = event.breakpoint; |
1386 var verb = null; | 1393 var verb = null; |
1387 switch (event.kind) { | 1394 switch (event.kind) { |
1388 case ServiceEvent.kBreakpointAdded: | 1395 case ServiceEvent.kBreakpointAdded: |
1389 verb = 'added'; | 1396 verb = 'added'; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 var pending = []; | 1618 var pending = []; |
1612 for (var bpt in bpts) { | 1619 for (var bpt in bpts) { |
1613 pending.add(isolate.removeBreakpoint(bpt)); | 1620 pending.add(isolate.removeBreakpoint(bpt)); |
1614 } | 1621 } |
1615 await Future.wait(pending); | 1622 await Future.wait(pending); |
1616 } | 1623 } |
1617 } | 1624 } |
1618 return new Future.value(null); | 1625 return new Future.value(null); |
1619 } | 1626 } |
1620 | 1627 |
1621 Future next() { | 1628 |
| 1629 Future smartNext() async { |
| 1630 if (isolatePaused()) { |
| 1631 var event = isolate.pauseEvent; |
| 1632 if (event.atAsyncJump) { |
| 1633 return asyncNext(); |
| 1634 } else { |
| 1635 return syncNext(); |
| 1636 } |
| 1637 } else { |
| 1638 console.print('The program is already running'); |
| 1639 } |
| 1640 } |
| 1641 |
| 1642 Future asyncNext() async { |
| 1643 if (isolatePaused()) { |
| 1644 var event = isolate.pauseEvent; |
| 1645 if (event.asyncContinuation == null) { |
| 1646 console.print("No async continuation at this location"); |
| 1647 } else { |
| 1648 return isolate.asyncStepOver()[Isolate.kFirstResume]; |
| 1649 } |
| 1650 } else { |
| 1651 console.print('The program is already running'); |
| 1652 } |
| 1653 } |
| 1654 |
| 1655 Future syncNext() async { |
1622 if (isolatePaused()) { | 1656 if (isolatePaused()) { |
1623 var event = isolate.pauseEvent; | 1657 var event = isolate.pauseEvent; |
1624 if (event.kind == ServiceEvent.kPauseStart) { | 1658 if (event.kind == ServiceEvent.kPauseStart) { |
1625 console.print("Type 'continue' [F7] or 'step' [F10] to start the isolate
"); | 1659 console.print("Type 'continue' [F7] or 'step' [F10] to start the isolate
"); |
1626 return new Future.value(null); | 1660 return; |
1627 } | 1661 } |
1628 if (event.kind == ServiceEvent.kPauseExit) { | 1662 if (event.kind == ServiceEvent.kPauseExit) { |
1629 console.print("Type 'continue' [F7] to exit the isolate"); | 1663 console.print("Type 'continue' [F7] to exit the isolate"); |
1630 return new Future.value(null); | 1664 return; |
1631 } | 1665 } |
1632 return isolate.stepOver(); | 1666 return isolate.stepOver(); |
1633 } else { | 1667 } else { |
1634 console.print('The program is already running'); | 1668 console.print('The program is already running'); |
1635 return new Future.value(null); | 1669 return; |
1636 } | 1670 } |
1637 } | 1671 } |
1638 | 1672 |
1639 Future step() { | 1673 Future step() { |
1640 if (isolatePaused()) { | 1674 if (isolatePaused()) { |
1641 var event = isolate.pauseEvent; | 1675 var event = isolate.pauseEvent; |
1642 if (event.kind == ServiceEvent.kPauseExit) { | 1676 if (event.kind == ServiceEvent.kPauseExit) { |
1643 console.print("Type 'continue' [F7] to exit the isolate"); | 1677 console.print("Type 'continue' [F7] to exit the isolate"); |
1644 return new Future.value(null); | 1678 return new Future.value(null); |
1645 } | 1679 } |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 | 2314 |
2281 case KeyCode.F8: | 2315 case KeyCode.F8: |
2282 e.preventDefault(); | 2316 e.preventDefault(); |
2283 debugger.toggleBreakpoint().whenComplete(() { | 2317 debugger.toggleBreakpoint().whenComplete(() { |
2284 busy = false; | 2318 busy = false; |
2285 }); | 2319 }); |
2286 break; | 2320 break; |
2287 | 2321 |
2288 case KeyCode.F9: | 2322 case KeyCode.F9: |
2289 e.preventDefault(); | 2323 e.preventDefault(); |
2290 debugger.next().whenComplete(() { | 2324 debugger.smartNext().whenComplete(() { |
2291 busy = false; | 2325 busy = false; |
2292 }); | 2326 }); |
2293 break; | 2327 break; |
2294 | 2328 |
2295 case KeyCode.F10: | 2329 case KeyCode.F10: |
2296 e.preventDefault(); | 2330 e.preventDefault(); |
2297 debugger.step().whenComplete(() { | 2331 debugger.step().whenComplete(() { |
2298 busy = false; | 2332 busy = false; |
2299 }); | 2333 }); |
2300 break; | 2334 break; |
(...skipping 16 matching lines...) Expand all Loading... |
2317 } | 2351 } |
2318 }); | 2352 }); |
2319 } | 2353 } |
2320 | 2354 |
2321 void focus() { | 2355 void focus() { |
2322 $['textBox'].focus(); | 2356 $['textBox'].focus(); |
2323 } | 2357 } |
2324 | 2358 |
2325 DebuggerInputElement.created() : super.created(); | 2359 DebuggerInputElement.created() : super.created(); |
2326 } | 2360 } |
OLD | NEW |