OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 745 |
746 ExecutionState.prototype.evaluateGlobal = function(source, disable_break) { | 746 ExecutionState.prototype.evaluateGlobal = function(source, disable_break) { |
747 return MakeMirror( | 747 return MakeMirror( |
748 %DebugEvaluateGlobal(this.break_id, source, Boolean(disable_break))); | 748 %DebugEvaluateGlobal(this.break_id, source, Boolean(disable_break))); |
749 }; | 749 }; |
750 | 750 |
751 ExecutionState.prototype.frameCount = function() { | 751 ExecutionState.prototype.frameCount = function() { |
752 return %GetFrameCount(this.break_id); | 752 return %GetFrameCount(this.break_id); |
753 }; | 753 }; |
754 | 754 |
| 755 ExecutionState.prototype.threadCount = function() { |
| 756 return %GetThreadCount(this.break_id); |
| 757 }; |
| 758 |
755 ExecutionState.prototype.frame = function(opt_index) { | 759 ExecutionState.prototype.frame = function(opt_index) { |
756 // If no index supplied return the selected frame. | 760 // If no index supplied return the selected frame. |
757 if (opt_index == null) opt_index = this.selected_frame; | 761 if (opt_index == null) opt_index = this.selected_frame; |
758 return new FrameMirror(this.break_id, opt_index); | 762 return new FrameMirror(this.break_id, opt_index); |
759 }; | 763 }; |
760 | 764 |
761 ExecutionState.prototype.cframesValue = function(opt_from_index, opt_to_index) { | 765 ExecutionState.prototype.cframesValue = function(opt_from_index, opt_to_index) { |
762 return %GetCFrames(this.break_id); | 766 return %GetCFrames(this.break_id); |
763 }; | 767 }; |
764 | 768 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 } else if (request.command == 'evaluate') { | 1164 } else if (request.command == 'evaluate') { |
1161 this.evaluateRequest_(request, response); | 1165 this.evaluateRequest_(request, response); |
1162 } else if (request.command == 'lookup') { | 1166 } else if (request.command == 'lookup') { |
1163 this.lookupRequest_(request, response); | 1167 this.lookupRequest_(request, response); |
1164 } else if (request.command == 'references') { | 1168 } else if (request.command == 'references') { |
1165 this.referencesRequest_(request, response); | 1169 this.referencesRequest_(request, response); |
1166 } else if (request.command == 'source') { | 1170 } else if (request.command == 'source') { |
1167 this.sourceRequest_(request, response); | 1171 this.sourceRequest_(request, response); |
1168 } else if (request.command == 'scripts') { | 1172 } else if (request.command == 'scripts') { |
1169 this.scriptsRequest_(request, response); | 1173 this.scriptsRequest_(request, response); |
| 1174 } else if (request.command == 'threads') { |
| 1175 this.threadsRequest_(request, response); |
1170 } else { | 1176 } else { |
1171 throw new Error('Unknown command "' + request.command + '" in request'); | 1177 throw new Error('Unknown command "' + request.command + '" in request'); |
1172 } | 1178 } |
1173 } catch (e) { | 1179 } catch (e) { |
1174 // If there is no response object created one (without command). | 1180 // If there is no response object created one (without command). |
1175 if (!response) { | 1181 if (!response) { |
1176 response = this.createResponse(); | 1182 response = this.createResponse(); |
1177 } | 1183 } |
1178 response.success = false; | 1184 response.success = false; |
1179 response.message = %ToString(e); | 1185 response.message = %ToString(e); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 script.lineCount = scripts[i].lineCount(); | 1672 script.lineCount = scripts[i].lineCount(); |
1667 script.sourceStart = scripts[i].source.substring(0, 80); | 1673 script.sourceStart = scripts[i].source.substring(0, 80); |
1668 script.sourceLength = scripts[i].source.length; | 1674 script.sourceLength = scripts[i].source.length; |
1669 script.type = scripts[i].type; | 1675 script.type = scripts[i].type; |
1670 response.body.push(script); | 1676 response.body.push(script); |
1671 } | 1677 } |
1672 } | 1678 } |
1673 }; | 1679 }; |
1674 | 1680 |
1675 | 1681 |
| 1682 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { |
| 1683 // Get the number of threads. |
| 1684 var total_threads = this.exec_state_.threadCount(); |
| 1685 |
| 1686 // Get information for all threads. |
| 1687 var threads = []; |
| 1688 for (var i = 0; i < total_threads; i++) { |
| 1689 var details = %GetThreadDetails(this.exec_state_.break_id, i); |
| 1690 var thread_info = { current: details[0], |
| 1691 id: details[1] |
| 1692 } |
| 1693 threads.push(thread_info); |
| 1694 } |
| 1695 |
| 1696 // Create the response body. |
| 1697 response.body = { |
| 1698 totalThreads: total_threads, |
| 1699 threads: threads |
| 1700 } |
| 1701 }; |
| 1702 |
| 1703 |
1676 // Check whether the previously processed command caused the VM to become | 1704 // Check whether the previously processed command caused the VM to become |
1677 // running. | 1705 // running. |
1678 DebugCommandProcessor.prototype.isRunning = function() { | 1706 DebugCommandProcessor.prototype.isRunning = function() { |
1679 return this.running_; | 1707 return this.running_; |
1680 } | 1708 } |
1681 | 1709 |
1682 | 1710 |
1683 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 1711 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { |
1684 return %SystemBreak(); | 1712 return %SystemBreak(); |
1685 }; | 1713 }; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 json += NumberToJSON_(elem); | 1835 json += NumberToJSON_(elem); |
1808 } else if (IS_STRING(elem)) { | 1836 } else if (IS_STRING(elem)) { |
1809 json += StringToJSON_(elem); | 1837 json += StringToJSON_(elem); |
1810 } else { | 1838 } else { |
1811 json += elem; | 1839 json += elem; |
1812 } | 1840 } |
1813 } | 1841 } |
1814 json += ']'; | 1842 json += ']'; |
1815 return json; | 1843 return json; |
1816 } | 1844 } |
OLD | NEW |