OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 | 647 |
648 // Create a JSON request for the break command. | 648 // Create a JSON request for the break command. |
649 DebugRequest.prototype.breakCommandToJSONRequest_ = function(args) { | 649 DebugRequest.prototype.breakCommandToJSONRequest_ = function(args) { |
650 // Build a evaluate request from the text command. | 650 // Build a evaluate request from the text command. |
651 var request = this.createRequest('setbreakpoint'); | 651 var request = this.createRequest('setbreakpoint'); |
652 | 652 |
653 // Process arguments if any. | 653 // Process arguments if any. |
654 if (args && args.length > 0) { | 654 if (args && args.length > 0) { |
655 var target = args; | 655 var target = args; |
| 656 var type = 'function'; |
| 657 var line; |
| 658 var column; |
656 var condition; | 659 var condition; |
| 660 var pos; |
657 | 661 |
658 var pos = args.indexOf(' '); | 662 // Check for breakpoint condition. |
| 663 pos = args.indexOf(' '); |
659 if (pos > 0) { | 664 if (pos > 0) { |
660 target = args.substring(0, pos); | 665 target = args.substring(0, pos); |
661 condition = args.substring(pos + 1, args.length); | 666 condition = args.substring(pos + 1, args.length); |
662 } | 667 } |
663 | 668 |
| 669 // Check for script breakpoint (name:line[:column]). If no ':' in break |
| 670 // specification it is considered a function break point. |
| 671 pos = target.indexOf(':'); |
| 672 if (pos > 0) { |
| 673 type = 'script'; |
| 674 var tmp = target.substring(pos + 1, target.length); |
| 675 target = target.substring(0, pos); |
| 676 |
| 677 // Check for both line and column. |
| 678 pos = tmp.indexOf(':'); |
| 679 if (pos > 0) { |
| 680 column = parseInt(tmp.substring(pos + 1, tmp.length)) - 1; |
| 681 line = parseInt(tmp.substring(0, pos)) - 1; |
| 682 } else { |
| 683 line = parseInt(tmp) - 1; |
| 684 } |
| 685 } else if (target[0] == '#' && target[target.length - 1] == '#') { |
| 686 type = 'handle'; |
| 687 target = target.substring(1, target.length - 1); |
| 688 } else { |
| 689 type = 'function'; |
| 690 } |
| 691 |
664 request.arguments = {}; | 692 request.arguments = {}; |
665 request.arguments.type = 'function'; | 693 request.arguments.type = type; |
666 request.arguments.target = target; | 694 request.arguments.target = target; |
| 695 request.arguments.line = line; |
| 696 request.arguments.column = column; |
667 request.arguments.condition = condition; | 697 request.arguments.condition = condition; |
668 } else { | 698 } else { |
669 throw new Error('Invalid break arguments.'); | 699 throw new Error('Invalid break arguments.'); |
670 } | 700 } |
671 | 701 |
672 return request.toJSONProtocol(); | 702 return request.toJSONProtocol(); |
673 }; | 703 }; |
674 | 704 |
675 | 705 |
676 // Create a JSON request for the clear command. | 706 // Create a JSON request for the clear command. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 } | 744 } |
715 | 745 |
716 // Handle the help command. | 746 // Handle the help command. |
717 DebugRequest.prototype.helpCommand_ = function(args) { | 747 DebugRequest.prototype.helpCommand_ = function(args) { |
718 // Help os quite simple. | 748 // Help os quite simple. |
719 if (args && args.length > 0) { | 749 if (args && args.length > 0) { |
720 print('warning: arguments to \'help\' are ignored'); | 750 print('warning: arguments to \'help\' are ignored'); |
721 } | 751 } |
722 | 752 |
723 print('break location [condition]'); | 753 print('break location [condition]'); |
| 754 print(' break on named function: location is a function name'); |
| 755 print(' break on function: location is #<id>#'); |
| 756 print(' break on script position: location is name:line[:column]'); |
724 print('clear <breakpoint #>'); | 757 print('clear <breakpoint #>'); |
725 print('backtrace [from frame #] [to frame #]]'); | 758 print('backtrace [from frame #] [to frame #]]'); |
726 print('frame <frame #>'); | 759 print('frame <frame #>'); |
727 print('step [in | next | out| min [step count]]'); | 760 print('step [in | next | out| min [step count]]'); |
728 print('print <expression>'); | 761 print('print <expression>'); |
729 print('source [from line [num lines]]'); | 762 print('source [from line [num lines]]'); |
730 print('scripts'); | 763 print('scripts'); |
731 print('continue'); | 764 print('continue'); |
732 print('trace compile'); | 765 print('trace compile'); |
733 print('help'); | 766 print('help'); |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 json += NumberToJSON_(elem); | 1458 json += NumberToJSON_(elem); |
1426 } else if (typeof(elem) === 'string') { | 1459 } else if (typeof(elem) === 'string') { |
1427 json += StringToJSON_(elem); | 1460 json += StringToJSON_(elem); |
1428 } else { | 1461 } else { |
1429 json += elem; | 1462 json += elem; |
1430 } | 1463 } |
1431 } | 1464 } |
1432 json += ']'; | 1465 json += ']'; |
1433 return json; | 1466 return json; |
1434 } | 1467 } |
OLD | NEW |