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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 ' set <option> # Get current value for option\n' | 630 ' set <option> # Get current value for option\n' |
631 ' set <option> <value> # Set value for option'; | 631 ' set <option> <value> # Set value for option'; |
632 } | 632 } |
633 | 633 |
634 class BreakCommand extends DebuggerCommand { | 634 class BreakCommand extends DebuggerCommand { |
635 BreakCommand(Debugger debugger) : super(debugger, 'break', []); | 635 BreakCommand(Debugger debugger) : super(debugger, 'break', []); |
636 | 636 |
637 Future run(List<String> args) async { | 637 Future run(List<String> args) async { |
638 if (args.length > 1) { | 638 if (args.length > 1) { |
639 debugger.console.print('not implemented'); | 639 debugger.console.print('not implemented'); |
640 return new Future.value(null); | 640 return; |
641 } | 641 } |
642 var arg = (args.length == 0 ? '' : args[0]); | 642 var arg = (args.length == 0 ? '' : args[0]); |
643 var loc = await DebuggerLocation.parse(debugger, arg); | 643 var loc = await DebuggerLocation.parse(debugger, arg); |
644 if (loc.valid) { | 644 if (loc.valid) { |
645 if (loc.function != null) { | 645 if (loc.function != null) { |
646 try { | 646 try { |
647 await debugger.isolate.addBreakpointAtEntry(loc.function); | 647 await debugger.isolate.addBreakpointAtEntry(loc.function); |
648 } on ServerRpcException catch(e) { | 648 } on ServerRpcException catch(e) { |
649 if (e.code == ServerRpcException.kCannotAddBreakpoint) { | 649 if (e.code == ServerRpcException.kCannotAddBreakpoint) { |
650 debugger.console.print('Unable to set breakpoint at ${loc}'); | 650 debugger.console.print('Unable to set breakpoint at ${loc}'); |
651 } else { | 651 } else { |
652 rethrow; | 652 rethrow; |
653 } | 653 } |
654 } | 654 } |
655 } else { | 655 } else { |
656 assert(loc.script != null); | 656 assert(loc.script != null); |
657 if (loc.col != null) { | 657 var script = loc.script; |
658 // TODO(turnidge): Add tokenPos breakpoint support. | 658 if (loc.line < 1 || loc.line > script.lines.length) { |
659 debugger.console.print( | 659 debugger.console.print( |
660 'Ignoring column: ' | 660 'line number must be in range [1,${script.lines.length}]'); |
661 'adding breakpoint at a specific column not yet implemented'); | 661 return; |
662 } | 662 } |
663 try { | 663 try { |
664 await debugger.isolate.addBreakpoint(loc.script, loc.line); | 664 await debugger.isolate.addBreakpoint(script, loc.line, loc.col); |
665 } on ServerRpcException catch(e) { | 665 } on ServerRpcException catch(e) { |
666 if (e.code == ServerRpcException.kCannotAddBreakpoint) { | 666 if (e.code == ServerRpcException.kCannotAddBreakpoint) { |
667 debugger.console.print('Unable to set breakpoint at ${loc}'); | 667 debugger.console.print('Unable to set breakpoint at ${loc}'); |
668 } else { | 668 } else { |
669 rethrow; | 669 rethrow; |
670 } | 670 } |
671 } | 671 } |
672 } | 672 } |
673 } else { | 673 } else { |
674 debugger.console.print(loc.errorMessage); | 674 debugger.console.print(loc.errorMessage); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 ' (e.g \'break test.dart:11:8\')\n' | 711 ' (e.g \'break test.dart:11:8\')\n' |
712 ' break <function> ' | 712 ' break <function> ' |
713 '# Break at the named function\n' | 713 '# Break at the named function\n' |
714 ' ' | 714 ' ' |
715 ' (e.g \'break main\' or \'break Class.someFunction\')\n'; | 715 ' (e.g \'break main\' or \'break Class.someFunction\')\n'; |
716 } | 716 } |
717 | 717 |
718 class ClearCommand extends DebuggerCommand { | 718 class ClearCommand extends DebuggerCommand { |
719 ClearCommand(Debugger debugger) : super(debugger, 'clear', []); | 719 ClearCommand(Debugger debugger) : super(debugger, 'clear', []); |
720 | 720 |
721 Future run(List<String> args) { | 721 Future run(List<String> args) async { |
722 if (args.length > 1) { | 722 if (args.length > 1) { |
723 debugger.console.print('not implemented'); | 723 debugger.console.print('not implemented'); |
724 return new Future.value(null); | 724 return; |
725 } | 725 } |
726 var arg = (args.length == 0 ? '' : args[0]); | 726 var arg = (args.length == 0 ? '' : args[0]); |
727 return DebuggerLocation.parse(debugger, arg).then((loc) { | 727 var loc = await DebuggerLocation.parse(debugger, arg); |
728 if (loc.valid) { | 728 if (!loc.valid) { |
729 if (loc.function != null) { | 729 debugger.console.print(loc.errorMessage); |
730 debugger.console.print( | 730 return; |
731 'Ignoring breakpoint at $loc: ' | 731 } |
732 'Function entry breakpoints not yet implemented'); | 732 if (loc.function != null) { |
733 return null; | 733 debugger.console.print( |
734 } | 734 'Ignoring breakpoint at $loc: ' |
735 if (loc.col != null) { | 735 'Clearing function breakpoints not yet implemented'); |
736 // TODO(turnidge): Add tokenPos clear support. | 736 return; |
737 debugger.console.print( | 737 } |
738 'Ignoring column: ' | |
739 'clearing breakpoint at a specific column not yet implemented'); | |
740 } | |
741 | 738 |
742 for (var bpt in debugger.isolate.breakpoints.values) { | 739 var script = loc.script; |
743 var script = bpt.location.script; | 740 if (loc.line < 1 || loc.line > script.lines.length) { |
744 if (script.id == loc.script.id) { | 741 debugger.console.print( |
745 assert(script.loaded); | 742 'line number must be in range [1,${script.lines.length}]'); |
746 var line = script.tokenToLine(bpt.location.tokenPos); | 743 return; |
747 if (line == loc.line) { | 744 } |
748 return debugger.isolate.removeBreakpoint(bpt).then((result) { | 745 var lineInfo = script.getLine(loc.line); |
749 if (result is DartError) { | 746 var bpts = lineInfo.breakpoints; |
750 debugger.console.print( | 747 int bptFound = 0; |
rmacnak
2015/09/03 00:55:19
btpsFound = 0 or bptFound = false
turnidge
2015/09/04 18:05:29
Done.
var foundBreakpoint = false;
| |
751 'Unable to clear breakpoint at ${loc}: ${result.message}') ; | 748 if (bpts != null) { |
752 return; | 749 var bptList = bpts.toList(); |
753 } | 750 for (var bpt in bptList) { |
754 }); | 751 if (loc.col == null || |
755 } | 752 loc.col == script.tokenToCol(bpt.location.tokenPos)) { |
753 bptFound++; | |
754 var result = await debugger.isolate.removeBreakpoint(bpt); | |
755 if (result is DartError) { | |
756 debugger.console.print( | |
757 'Error clearing breakpoint ${bpt.number}: ${result.message}'); | |
756 } | 758 } |
757 } | 759 } |
758 debugger.console.print('No breakpoint found at ${loc}'); | |
759 } else { | |
760 debugger.console.print(loc.errorMessage); | |
761 } | 760 } |
762 }); | 761 } |
762 if (bptFound == 0) { | |
763 debugger.console.print('No breakpoint found at ${loc}'); | |
764 } | |
763 } | 765 } |
764 | 766 |
765 Future<List<String>> complete(List<String> args) { | 767 Future<List<String>> complete(List<String> args) { |
766 if (args.length != 1) { | 768 if (args.length != 1) { |
767 return new Future.value([args.join('')]); | 769 return new Future.value([args.join('')]); |
768 } | 770 } |
769 return new Future.value(DebuggerLocation.complete(debugger, args[0])); | 771 return new Future.value(DebuggerLocation.complete(debugger, args[0])); |
770 } | 772 } |
771 | 773 |
772 String helpShort = 'Remove a breakpoint by source location or function name' | 774 String helpShort = 'Remove a breakpoint by source location or function name' |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2359 } | 2361 } |
2360 }); | 2362 }); |
2361 } | 2363 } |
2362 | 2364 |
2363 void focus() { | 2365 void focus() { |
2364 $['textBox'].focus(); | 2366 $['textBox'].focus(); |
2365 } | 2367 } |
2366 | 2368 |
2367 DebuggerInputElement.created() : super.created(); | 2369 DebuggerInputElement.created() : super.created(); |
2368 } | 2370 } |
OLD | NEW |