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 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 response.body.fromLine = slice.from_line; | 1638 response.body.fromLine = slice.from_line; |
1639 response.body.toLine = slice.to_line; | 1639 response.body.toLine = slice.to_line; |
1640 response.body.fromPosition = slice.from_position; | 1640 response.body.fromPosition = slice.from_position; |
1641 response.body.toPosition = slice.to_position; | 1641 response.body.toPosition = slice.to_position; |
1642 response.body.totalLines = script.lineCount(); | 1642 response.body.totalLines = script.lineCount(); |
1643 }; | 1643 }; |
1644 | 1644 |
1645 | 1645 |
1646 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { | 1646 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { |
1647 var types = ScriptTypeFlag(Debug.ScriptType.Normal); | 1647 var types = ScriptTypeFlag(Debug.ScriptType.Normal); |
| 1648 var includeSource = false; |
1648 if (request.arguments) { | 1649 if (request.arguments) { |
1649 // Pull out arguments. | 1650 // Pull out arguments. |
1650 if (!IS_UNDEFINED(request.arguments.types)) { | 1651 if (!IS_UNDEFINED(request.arguments.types)) { |
1651 types = %ToNumber(request.arguments.types); | 1652 types = %ToNumber(request.arguments.types); |
1652 if (isNaN(types) || types < 0) { | 1653 if (isNaN(types) || types < 0) { |
1653 return response.failed('Invalid types "' + request.arguments.types + '"'
); | 1654 return response.failed('Invalid types "' + request.arguments.types + '"'
); |
1654 } | 1655 } |
1655 } | 1656 } |
| 1657 |
| 1658 if (!IS_UNDEFINED(request.arguments.includeSource)) { |
| 1659 includeSource = %ToBoolean(request.arguments.includeSource); |
| 1660 } |
1656 } | 1661 } |
1657 | 1662 |
1658 // Collect all scripts in the heap. | 1663 // Collect all scripts in the heap. |
1659 var scripts = %DebugGetLoadedScripts(); | 1664 var scripts = %DebugGetLoadedScripts(); |
1660 | 1665 |
1661 response.body = []; | 1666 response.body = []; |
1662 | 1667 |
1663 for (var i = 0; i < scripts.length; i++) { | 1668 for (var i = 0; i < scripts.length; i++) { |
1664 if (types & ScriptTypeFlag(scripts[i].type)) { | 1669 if (types & ScriptTypeFlag(scripts[i].type)) { |
1665 var script = {}; | 1670 var script = {}; |
1666 if (scripts[i].name) { | 1671 if (scripts[i].name) { |
1667 script.name = scripts[i].name; | 1672 script.name = scripts[i].name; |
1668 } | 1673 } |
1669 script.id = scripts[i].id; | 1674 script.id = scripts[i].id; |
1670 script.lineOffset = scripts[i].line_offset; | 1675 script.lineOffset = scripts[i].line_offset; |
1671 script.columnOffset = scripts[i].column_offset; | 1676 script.columnOffset = scripts[i].column_offset; |
1672 script.lineCount = scripts[i].lineCount(); | 1677 script.lineCount = scripts[i].lineCount(); |
1673 script.sourceStart = scripts[i].source.substring(0, 80); | 1678 if (includeSource) { |
| 1679 script.source = scripts[i].source; |
| 1680 } else { |
| 1681 script.sourceStart = scripts[i].source.substring(0, 80); |
| 1682 } |
1674 script.sourceLength = scripts[i].source.length; | 1683 script.sourceLength = scripts[i].source.length; |
1675 script.type = scripts[i].type; | 1684 script.type = scripts[i].type; |
1676 response.body.push(script); | 1685 response.body.push(script); |
1677 } | 1686 } |
1678 } | 1687 } |
1679 }; | 1688 }; |
1680 | 1689 |
1681 | 1690 |
1682 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { | 1691 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { |
1683 // Get the number of threads. | 1692 // Get the number of threads. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 json += NumberToJSON_(elem); | 1844 json += NumberToJSON_(elem); |
1836 } else if (IS_STRING(elem)) { | 1845 } else if (IS_STRING(elem)) { |
1837 json += StringToJSON_(elem); | 1846 json += StringToJSON_(elem); |
1838 } else { | 1847 } else { |
1839 json += elem; | 1848 json += elem; |
1840 } | 1849 } |
1841 } | 1850 } |
1842 json += ']'; | 1851 json += ']'; |
1843 return json; | 1852 return json; |
1844 } | 1853 } |
OLD | NEW |