| 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:svg'; | 8 import 'dart:svg'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 import 'dart:math'; | 10 import 'dart:math'; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return new Future.value(null); | 202 return new Future.value(null); |
| 203 } | 203 } |
| 204 if (debugger.currentFrame == null) { | 204 if (debugger.currentFrame == null) { |
| 205 debugger.console.print('No stack'); | 205 debugger.console.print('No stack'); |
| 206 return new Future.value(null); | 206 return new Future.value(null); |
| 207 } | 207 } |
| 208 try { | 208 try { |
| 209 debugger.downFrame(count); | 209 debugger.downFrame(count); |
| 210 debugger.console.print('frame = ${debugger.currentFrame}'); | 210 debugger.console.print('frame = ${debugger.currentFrame}'); |
| 211 } catch (e) { | 211 } catch (e) { |
| 212 debugger.console.print( | 212 debugger.console.print('frame must be in range [${e.start},${e.end-1}]'); |
| 213 'frame must be in range [${e.start}..${e.end-1}]'); | |
| 214 } | 213 } |
| 215 return new Future.value(null); | 214 return new Future.value(null); |
| 216 } | 215 } |
| 217 | 216 |
| 218 String helpShort = 'Move down one or more frames (hotkey: [Page Down])'; | 217 String helpShort = 'Move down one or more frames (hotkey: [Page Down])'; |
| 219 | 218 |
| 220 String helpLong = 'Move down one or more frames.\n' | 219 String helpLong = 'Move down one or more frames.\n' |
| 221 '\n' | 220 '\n' |
| 222 'Hotkey: [Page Down]\n' | 221 'Hotkey: [Page Down]\n' |
| 223 '\n' | 222 '\n' |
| (...skipping 13 matching lines...) Expand all Loading... |
| 237 return new Future.value(null); | 236 return new Future.value(null); |
| 238 } | 237 } |
| 239 if (debugger.currentFrame == null) { | 238 if (debugger.currentFrame == null) { |
| 240 debugger.console.print('No stack'); | 239 debugger.console.print('No stack'); |
| 241 return new Future.value(null); | 240 return new Future.value(null); |
| 242 } | 241 } |
| 243 try { | 242 try { |
| 244 debugger.upFrame(count); | 243 debugger.upFrame(count); |
| 245 debugger.console.print('frame = ${debugger.currentFrame}'); | 244 debugger.console.print('frame = ${debugger.currentFrame}'); |
| 246 } on RangeError catch (e) { | 245 } on RangeError catch (e) { |
| 247 debugger.console.print( | 246 debugger.console.print('frame must be in range [${e.start},${e.end-1}]'); |
| 248 'frame must be in range [${e.start}..${e.end-1}]'); | |
| 249 } | 247 } |
| 250 return new Future.value(null); | 248 return new Future.value(null); |
| 251 } | 249 } |
| 252 | 250 |
| 253 String helpShort = 'Move up one or more frames (hotkey: [Page Up])'; | 251 String helpShort = 'Move up one or more frames (hotkey: [Page Up])'; |
| 254 | 252 |
| 255 String helpLong = 'Move up one or more frames.\n' | 253 String helpLong = 'Move up one or more frames.\n' |
| 256 '\n' | 254 '\n' |
| 257 'Hotkey: [Page Up]\n' | 255 'Hotkey: [Page Up]\n' |
| 258 '\n' | 256 '\n' |
| (...skipping 15 matching lines...) Expand all Loading... |
| 274 return new Future.value(null); | 272 return new Future.value(null); |
| 275 } | 273 } |
| 276 if (debugger.currentFrame == null) { | 274 if (debugger.currentFrame == null) { |
| 277 debugger.console.print('No stack'); | 275 debugger.console.print('No stack'); |
| 278 return new Future.value(null); | 276 return new Future.value(null); |
| 279 } | 277 } |
| 280 try { | 278 try { |
| 281 debugger.currentFrame = frame; | 279 debugger.currentFrame = frame; |
| 282 debugger.console.print('frame = ${debugger.currentFrame}'); | 280 debugger.console.print('frame = ${debugger.currentFrame}'); |
| 283 } on RangeError catch (e) { | 281 } on RangeError catch (e) { |
| 284 debugger.console.print( | 282 debugger.console.print('frame must be in range [${e.start},${e.end-1}]'); |
| 285 'frame must be in range [${e.start}..${e.end-1}]'); | |
| 286 } | 283 } |
| 287 return new Future.value(null); | 284 return new Future.value(null); |
| 288 } | 285 } |
| 289 | 286 |
| 290 String helpShort = 'Set the current frame'; | 287 String helpShort = 'Set the current frame'; |
| 291 | 288 |
| 292 String helpLong = 'Set the current frame.\n' | 289 String helpLong = 'Set the current frame.\n' |
| 293 '\n' | 290 '\n' |
| 294 'Syntax: frame <number>\n' | 291 'Syntax: frame <number>\n' |
| 295 ' f <count>\n'; | 292 ' f <count>\n'; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 396 |
| 400 String helpLong = | 397 String helpLong = |
| 401 'Continue running the isolate until it reaches the next source ' | 398 'Continue running the isolate until it reaches the next source ' |
| 402 'location.\n' | 399 'location.\n' |
| 403 '\n' | 400 '\n' |
| 404 'Hotkey: [F10]\n' | 401 'Hotkey: [F10]\n' |
| 405 '\n' | 402 '\n' |
| 406 'Syntax: step\n'; | 403 'Syntax: step\n'; |
| 407 } | 404 } |
| 408 | 405 |
| 409 class RewindCommand extends DebuggerCommand { | |
| 410 RewindCommand(Debugger debugger) : super(debugger, 'rewind', []); | |
| 411 | |
| 412 Future run(List<String> args) async { | |
| 413 try { | |
| 414 int count = 1; | |
| 415 if (args.length == 1) { | |
| 416 count = int.parse(args[0]); | |
| 417 } else if (args.length > 1) { | |
| 418 debugger.console.print('rewind expects 0 or 1 argument'); | |
| 419 return; | |
| 420 } else if (count < 1 || count > debugger.stackDepth) { | |
| 421 debugger.console.print( | |
| 422 'frame must be in range [1..${debugger.stackDepth - 1}]'); | |
| 423 return; | |
| 424 } | |
| 425 await debugger.rewind(count); | |
| 426 } on S.ServerRpcException catch(e) { | |
| 427 if (e.code == S.ServerRpcException.kCannotResume) { | |
| 428 debugger.console.printRed(e.data['details']); | |
| 429 } else { | |
| 430 rethrow; | |
| 431 } | |
| 432 } | |
| 433 } | |
| 434 | |
| 435 String helpShort = 'Rewind the stack to a previous frame'; | |
| 436 | |
| 437 String helpLong = | |
| 438 'Rewind the stack to a previous frame.\n' | |
| 439 '\n' | |
| 440 'Syntax: rewind\n' | |
| 441 ' rewind <count>\n'; | |
| 442 } | |
| 443 | |
| 444 class ReloadCommand extends DebuggerCommand { | |
| 445 ReloadCommand(Debugger debugger) : super(debugger, 'reload', []); | |
| 446 | |
| 447 Future run(List<String> args) async { | |
| 448 try { | |
| 449 int count = 1; | |
| 450 if (args.length > 0) { | |
| 451 debugger.console.print('reload expects no arguments'); | |
| 452 return; | |
| 453 } | |
| 454 await debugger.isolate.reloadSources(); | |
| 455 debugger.console.print('reload complete'); | |
| 456 await debugger.refreshStack(); | |
| 457 } on S.ServerRpcException catch(e) { | |
| 458 if (e.code == S.ServerRpcException.kIsolateReloadBarred || | |
| 459 e.code == S.ServerRpcException.kIsolateReloadFailed || | |
| 460 e.code == S.ServerRpcException.kIsolateIsReloading) { | |
| 461 debugger.console.printRed(e.data['details']); | |
| 462 } else { | |
| 463 rethrow; | |
| 464 } | |
| 465 } | |
| 466 } | |
| 467 | |
| 468 String helpShort = 'Reload the sources for the current isolate'; | |
| 469 | |
| 470 String helpLong = | |
| 471 'Reload the sources for the current isolate.\n' | |
| 472 '\n' | |
| 473 'Syntax: reload\n'; | |
| 474 } | |
| 475 | |
| 476 class ClsCommand extends DebuggerCommand { | 406 class ClsCommand extends DebuggerCommand { |
| 477 ClsCommand(Debugger debugger) : super(debugger, 'cls', []) {} | 407 ClsCommand(Debugger debugger) : super(debugger, 'cls', []) {} |
| 478 | 408 |
| 479 Future run(List<String> args) { | 409 Future run(List<String> args) { |
| 480 debugger.console.clear(); | 410 debugger.console.clear(); |
| 481 debugger.console.newline(); | 411 debugger.console.newline(); |
| 482 return new Future.value(null); | 412 return new Future.value(null); |
| 483 } | 413 } |
| 484 | 414 |
| 485 String helpShort = 'Clear the console'; | 415 String helpShort = 'Clear the console'; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 debugger.console.print('Unable to set breakpoint at ${loc}'); | 656 debugger.console.print('Unable to set breakpoint at ${loc}'); |
| 727 } else { | 657 } else { |
| 728 rethrow; | 658 rethrow; |
| 729 } | 659 } |
| 730 } | 660 } |
| 731 } else { | 661 } else { |
| 732 assert(loc.script != null); | 662 assert(loc.script != null); |
| 733 var script = loc.script; | 663 var script = loc.script; |
| 734 await script.load(); | 664 await script.load(); |
| 735 if (loc.line < 1 || loc.line > script.lines.length) { | 665 if (loc.line < 1 || loc.line > script.lines.length) { |
| 736 debugger.console.print( | 666 debugger.console |
| 737 'line number must be in range [1..${script.lines.length}]'); | 667 .print('line number must be in range [1,${script.lines.length}]'); |
| 738 return; | 668 return; |
| 739 } | 669 } |
| 740 try { | 670 try { |
| 741 await debugger.isolate.addBreakpoint(script, loc.line, loc.col); | 671 await debugger.isolate.addBreakpoint(script, loc.line, loc.col); |
| 742 } on S.ServerRpcException catch (e) { | 672 } on S.ServerRpcException catch (e) { |
| 743 if (e.code == S.ServerRpcException.kCannotAddBreakpoint) { | 673 if (e.code == S.ServerRpcException.kCannotAddBreakpoint) { |
| 744 debugger.console.print('Unable to set breakpoint at ${loc}'); | 674 debugger.console.print('Unable to set breakpoint at ${loc}'); |
| 745 } else { | 675 } else { |
| 746 rethrow; | 676 rethrow; |
| 747 } | 677 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } | 737 } |
| 808 if (loc.function != null) { | 738 if (loc.function != null) { |
| 809 debugger.console.print('Ignoring breakpoint at $loc: ' | 739 debugger.console.print('Ignoring breakpoint at $loc: ' |
| 810 'Clearing function breakpoints not yet implemented'); | 740 'Clearing function breakpoints not yet implemented'); |
| 811 return; | 741 return; |
| 812 } | 742 } |
| 813 | 743 |
| 814 var script = loc.script; | 744 var script = loc.script; |
| 815 if (loc.line < 1 || loc.line > script.lines.length) { | 745 if (loc.line < 1 || loc.line > script.lines.length) { |
| 816 debugger.console | 746 debugger.console |
| 817 .print('line number must be in range [1..${script.lines.length}]'); | 747 .print('line number must be in range [1,${script.lines.length}]'); |
| 818 return; | 748 return; |
| 819 } | 749 } |
| 820 var lineInfo = script.getLine(loc.line); | 750 var lineInfo = script.getLine(loc.line); |
| 821 var bpts = lineInfo.breakpoints; | 751 var bpts = lineInfo.breakpoints; |
| 822 var foundBreakpoint = false; | 752 var foundBreakpoint = false; |
| 823 if (bpts != null) { | 753 if (bpts != null) { |
| 824 var bptList = bpts.toList(); | 754 var bptList = bpts.toList(); |
| 825 for (var bpt in bptList) { | 755 for (var bpt in bptList) { |
| 826 if (loc.col == null || | 756 if (loc.col == null || |
| 827 loc.col == script.tokenToCol(bpt.location.tokenPos)) { | 757 loc.col == script.tokenToCol(bpt.location.tokenPos)) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 String helpLong = 'Show current frame.\n' | 892 String helpLong = 'Show current frame.\n' |
| 963 '\n' | 893 '\n' |
| 964 'Syntax: info frame\n'; | 894 'Syntax: info frame\n'; |
| 965 } | 895 } |
| 966 | 896 |
| 967 class IsolateCommand extends DebuggerCommand { | 897 class IsolateCommand extends DebuggerCommand { |
| 968 IsolateCommand(Debugger debugger) | 898 IsolateCommand(Debugger debugger) |
| 969 : super(debugger, 'isolate', [ | 899 : super(debugger, 'isolate', [ |
| 970 new IsolateListCommand(debugger), | 900 new IsolateListCommand(debugger), |
| 971 new IsolateNameCommand(debugger), | 901 new IsolateNameCommand(debugger), |
| 902 new IsolateReloadCommand(debugger), |
| 972 ]) { | 903 ]) { |
| 973 alias = 'i'; | 904 alias = 'i'; |
| 974 } | 905 } |
| 975 | 906 |
| 976 Future run(List<String> args) { | 907 Future run(List<String> args) { |
| 977 if (args.length != 1) { | 908 if (args.length != 1) { |
| 978 debugger.console.print('isolate expects one argument'); | 909 debugger.console.print('isolate expects one argument'); |
| 979 return new Future.value(null); | 910 return new Future.value(null); |
| 980 } | 911 } |
| 981 var arg = args[0].trim(); | 912 var arg = args[0].trim(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 return debugger.isolate.setName(args[0]); | 1035 return debugger.isolate.setName(args[0]); |
| 1105 } | 1036 } |
| 1106 | 1037 |
| 1107 String helpShort = 'Rename the current isolate'; | 1038 String helpShort = 'Rename the current isolate'; |
| 1108 | 1039 |
| 1109 String helpLong = 'Rename the current isolate.\n' | 1040 String helpLong = 'Rename the current isolate.\n' |
| 1110 '\n' | 1041 '\n' |
| 1111 'Syntax: isolate name <name>\n'; | 1042 'Syntax: isolate name <name>\n'; |
| 1112 } | 1043 } |
| 1113 | 1044 |
| 1045 class IsolateReloadCommand extends DebuggerCommand { |
| 1046 IsolateReloadCommand(Debugger debugger) : super(debugger, 'reload', []); |
| 1047 |
| 1048 Future run(List<String> args) async { |
| 1049 if (debugger.isolate == null) { |
| 1050 debugger.console.print('There is no current vm'); |
| 1051 return; |
| 1052 } |
| 1053 |
| 1054 await debugger.isolate.reloadSources(); |
| 1055 |
| 1056 debugger.console.print('Isolate reloading....'); |
| 1057 } |
| 1058 |
| 1059 String helpShort = 'Reload the sources for the current isolate.'; |
| 1060 |
| 1061 String helpLong = 'Reload the sources for the current isolate.\n' |
| 1062 '\n' |
| 1063 'Syntax: reload\n'; |
| 1064 } |
| 1065 |
| 1114 class InfoCommand extends DebuggerCommand { | 1066 class InfoCommand extends DebuggerCommand { |
| 1115 InfoCommand(Debugger debugger) | 1067 InfoCommand(Debugger debugger) |
| 1116 : super(debugger, 'info', [ | 1068 : super(debugger, 'info', [ |
| 1117 new InfoBreakpointsCommand(debugger), | 1069 new InfoBreakpointsCommand(debugger), |
| 1118 new InfoFrameCommand(debugger) | 1070 new InfoFrameCommand(debugger) |
| 1119 ]); | 1071 ]); |
| 1120 | 1072 |
| 1121 Future run(List<String> args) { | 1073 Future run(List<String> args) { |
| 1122 debugger.console.print("'info' expects a subcommand (see 'help info')"); | 1074 debugger.console.print("'info' expects a subcommand (see 'help info')"); |
| 1123 return new Future.value(null); | 1075 return new Future.value(null); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 new DeleteCommand(this), | 1364 new DeleteCommand(this), |
| 1413 new DownCommand(this), | 1365 new DownCommand(this), |
| 1414 new FinishCommand(this), | 1366 new FinishCommand(this), |
| 1415 new FrameCommand(this), | 1367 new FrameCommand(this), |
| 1416 new HelpCommand(this), | 1368 new HelpCommand(this), |
| 1417 new InfoCommand(this), | 1369 new InfoCommand(this), |
| 1418 new IsolateCommand(this), | 1370 new IsolateCommand(this), |
| 1419 new LogCommand(this), | 1371 new LogCommand(this), |
| 1420 new PauseCommand(this), | 1372 new PauseCommand(this), |
| 1421 new PrintCommand(this), | 1373 new PrintCommand(this), |
| 1422 new ReloadCommand(this), | |
| 1423 new RefreshCommand(this), | 1374 new RefreshCommand(this), |
| 1424 new RewindCommand(this), | |
| 1425 new SetCommand(this), | 1375 new SetCommand(this), |
| 1426 new SmartNextCommand(this), | 1376 new SmartNextCommand(this), |
| 1427 new StepCommand(this), | 1377 new StepCommand(this), |
| 1428 new SyncNextCommand(this), | 1378 new SyncNextCommand(this), |
| 1429 new UpCommand(this), | 1379 new UpCommand(this), |
| 1430 new VmCommand(this), | 1380 new VmCommand(this), |
| 1431 ], _history); | 1381 ], _history); |
| 1432 _consolePrinter = new _ConsoleStreamPrinter(this); | 1382 _consolePrinter = new _ConsoleStreamPrinter(this); |
| 1433 } | 1383 } |
| 1434 | 1384 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 if (event is M.PauseExitEvent) { | 1872 if (event is M.PauseExitEvent) { |
| 1923 console.print("Type 'continue' [F7] to exit the isolate"); | 1873 console.print("Type 'continue' [F7] to exit the isolate"); |
| 1924 return new Future.value(null); | 1874 return new Future.value(null); |
| 1925 } | 1875 } |
| 1926 return isolate.stepInto(); | 1876 return isolate.stepInto(); |
| 1927 } else { | 1877 } else { |
| 1928 console.print('The program is already running'); | 1878 console.print('The program is already running'); |
| 1929 return new Future.value(null); | 1879 return new Future.value(null); |
| 1930 } | 1880 } |
| 1931 } | 1881 } |
| 1932 | |
| 1933 Future rewind(int count) { | |
| 1934 if (isolatePaused()) { | |
| 1935 var event = isolate.pauseEvent; | |
| 1936 if (event is M.PauseExitEvent) { | |
| 1937 console.print("Type 'continue' [F7] to exit the isolate"); | |
| 1938 return new Future.value(null); | |
| 1939 } | |
| 1940 return isolate.rewind(count); | |
| 1941 } else { | |
| 1942 console.print('The program must be paused'); | |
| 1943 return new Future.value(null); | |
| 1944 } | |
| 1945 } | |
| 1946 } | 1882 } |
| 1947 | 1883 |
| 1948 class DebuggerPageElement extends HtmlElement implements Renderable { | 1884 class DebuggerPageElement extends HtmlElement implements Renderable { |
| 1949 static const tag = | 1885 static const tag = |
| 1950 const Tag<DebuggerPageElement>('debugger-page', dependencies: const [ | 1886 const Tag<DebuggerPageElement>('debugger-page', dependencies: const [ |
| 1951 NavTopMenuElement.tag, | 1887 NavTopMenuElement.tag, |
| 1952 NavVMMenuElement.tag, | 1888 NavVMMenuElement.tag, |
| 1953 NavIsolateMenuElement.tag, | 1889 NavIsolateMenuElement.tag, |
| 1954 NavNotifyElement.tag, | 1890 NavNotifyElement.tag, |
| 1955 ]); | 1891 ]); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 ..classes = ['frameSummary'] | 2506 ..classes = ['frameSummary'] |
| 2571 ..children = content | 2507 ..children = content |
| 2572 ]; | 2508 ]; |
| 2573 } | 2509 } |
| 2574 | 2510 |
| 2575 String makeExpandKey(String key) { | 2511 String makeExpandKey(String key) { |
| 2576 return '${_frame.function.qualifiedName}/${key}'; | 2512 return '${_frame.function.qualifiedName}/${key}'; |
| 2577 } | 2513 } |
| 2578 | 2514 |
| 2579 bool matchFrame(S.Frame newFrame) { | 2515 bool matchFrame(S.Frame newFrame) { |
| 2580 return (newFrame.function.id == _frame.function.id && | 2516 return newFrame.function.id == _frame.function.id; |
| 2581 newFrame.location.script.id == | |
| 2582 frame.location.script.id); | |
| 2583 } | 2517 } |
| 2584 | 2518 |
| 2585 void updateFrame(S.Frame newFrame) { | 2519 void updateFrame(S.Frame newFrame) { |
| 2586 assert(matchFrame(newFrame)); | 2520 assert(matchFrame(newFrame)); |
| 2587 _frame = newFrame; | 2521 _frame = newFrame; |
| 2588 } | 2522 } |
| 2589 | 2523 |
| 2590 S.Script get script => _frame.location.script; | 2524 S.Script get script => _frame.location.script; |
| 2591 | 2525 |
| 2592 int _varsTop(varsDiv) { | 2526 int _varsTop(varsDiv) { |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3256 ..setAttribute('height', '24') | 3190 ..setAttribute('height', '24') |
| 3257 ..children = [ | 3191 ..children = [ |
| 3258 new PathElement() | 3192 new PathElement() |
| 3259 ..setAttribute( | 3193 ..setAttribute( |
| 3260 'd', | 3194 'd', |
| 3261 'M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 ' | 3195 'M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 ' |
| 3262 '10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 ' | 3196 '10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 ' |
| 3263 '0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 ' | 3197 '0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 ' |
| 3264 '9h2V7h-2v2z') | 3198 '9h2V7h-2v2z') |
| 3265 ]; | 3199 ]; |
| OLD | NEW |