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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } else { | 397 } else { |
398 // We might want to account columns here as well. | 398 // We might want to account columns here as well. |
399 if (!(script.line_offset <= this.line_ && | 399 if (!(script.line_offset <= this.line_ && |
400 this.line_ < script.line_offset + script.lineCount())) { | 400 this.line_ < script.line_offset + script.lineCount())) { |
401 return false; | 401 return false; |
402 } | 402 } |
403 if (this.type_ == Debug.ScriptBreakPointType.ScriptName) { | 403 if (this.type_ == Debug.ScriptBreakPointType.ScriptName) { |
404 return this.script_name_ == script.nameOrSourceURL(); | 404 return this.script_name_ == script.nameOrSourceURL(); |
405 } else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) { | 405 } else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) { |
406 return this.script_regexp_object_.test(script.nameOrSourceURL()); | 406 return this.script_regexp_object_.test(script.nameOrSourceURL()); |
407 } else { | 407 } else { |
408 throw new Error("Unexpected breakpoint type " + this.type_); | 408 throw new Error("Unexpected breakpoint type " + this.type_); |
409 } | 409 } |
410 } | 410 } |
411 }; | 411 }; |
412 | 412 |
413 | 413 |
414 // Set the script break point in a script. | 414 // Set the script break point in a script. |
415 ScriptBreakPoint.prototype.set = function (script) { | 415 ScriptBreakPoint.prototype.set = function (script) { |
416 var column = this.column(); | 416 var column = this.column(); |
417 var line = this.line(); | 417 var line = this.line(); |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 true : request.arguments.enabled; | 1572 true : request.arguments.enabled; |
1573 var condition = request.arguments.condition; | 1573 var condition = request.arguments.condition; |
1574 var ignoreCount = request.arguments.ignoreCount; | 1574 var ignoreCount = request.arguments.ignoreCount; |
1575 var groupId = request.arguments.groupId; | 1575 var groupId = request.arguments.groupId; |
1576 | 1576 |
1577 // Check for legal arguments. | 1577 // Check for legal arguments. |
1578 if (!type || IS_UNDEFINED(target)) { | 1578 if (!type || IS_UNDEFINED(target)) { |
1579 response.failed('Missing argument "type" or "target"'); | 1579 response.failed('Missing argument "type" or "target"'); |
1580 return; | 1580 return; |
1581 } | 1581 } |
1582 | 1582 |
1583 // Either function or script break point. | 1583 // Either function or script break point. |
1584 var break_point_number; | 1584 var break_point_number; |
1585 if (type == 'function') { | 1585 if (type == 'function') { |
1586 // Handle function break point. | 1586 // Handle function break point. |
1587 if (!IS_STRING(target)) { | 1587 if (!IS_STRING(target)) { |
1588 response.failed('Argument "target" is not a string value'); | 1588 response.failed('Argument "target" is not a string value'); |
1589 return; | 1589 return; |
1590 } | 1590 } |
1591 var f; | 1591 var f; |
1592 try { | 1592 try { |
(...skipping 23 matching lines...) Expand all Loading... |
1616 } | 1616 } |
1617 | 1617 |
1618 // Set function break point. | 1618 // Set function break point. |
1619 break_point_number = Debug.setBreakPoint(mirror.value(), | 1619 break_point_number = Debug.setBreakPoint(mirror.value(), |
1620 line, column, condition); | 1620 line, column, condition); |
1621 } else if (type == 'script') { | 1621 } else if (type == 'script') { |
1622 // set script break point. | 1622 // set script break point. |
1623 break_point_number = | 1623 break_point_number = |
1624 Debug.setScriptBreakPointByName(target, line, column, condition, | 1624 Debug.setScriptBreakPointByName(target, line, column, condition, |
1625 groupId); | 1625 groupId); |
1626 } else if (type == 'scriptId') { | 1626 } else if (type == 'scriptId') { |
1627 break_point_number = | 1627 break_point_number = |
1628 Debug.setScriptBreakPointById(target, line, column, condition, groupId); | 1628 Debug.setScriptBreakPointById(target, line, column, condition, groupId); |
1629 } else if (type == 'scriptRegExp') { | 1629 } else if (type == 'scriptRegExp') { |
1630 break_point_number = | 1630 break_point_number = |
1631 Debug.setScriptBreakPointByRegExp(target, line, column, condition, | 1631 Debug.setScriptBreakPointByRegExp(target, line, column, condition, |
1632 groupId); | 1632 groupId); |
1633 } else { | 1633 } else { |
1634 response.failed('Illegal type "' + type + '"'); | 1634 response.failed('Illegal type "' + type + '"'); |
1635 return; | 1635 return; |
1636 } | 1636 } |
1637 | 1637 |
1638 // Set additional break point properties. | 1638 // Set additional break point properties. |
1639 var break_point = Debug.findBreakPoint(break_point_number); | 1639 var break_point = Debug.findBreakPoint(break_point_number); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1790 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
1791 description.type = 'scriptId'; | 1791 description.type = 'scriptId'; |
1792 description.script_id = break_point.script_id(); | 1792 description.script_id = break_point.script_id(); |
1793 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { | 1793 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { |
1794 description.type = 'scriptName'; | 1794 description.type = 'scriptName'; |
1795 description.script_name = break_point.script_name(); | 1795 description.script_name = break_point.script_name(); |
1796 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { | 1796 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { |
1797 description.type = 'scriptRegExp'; | 1797 description.type = 'scriptRegExp'; |
1798 description.script_regexp = break_point.script_regexp_object().source; | 1798 description.script_regexp = break_point.script_regexp_object().source; |
1799 } else { | 1799 } else { |
1800 throw new Error("Internal error: Unexpected breakpoint type: " + break_poi
nt.type()); | 1800 throw new Error("Internal error: Unexpected breakpoint type: " + break_poi
nt.type()); |
1801 } | 1801 } |
1802 array.push(description); | 1802 array.push(description); |
1803 } | 1803 } |
1804 | 1804 |
1805 response.body = { | 1805 response.body = { |
1806 breakpoints: array, | 1806 breakpoints: array, |
1807 breakOnExceptions: Debug.isBreakOnException(), | 1807 breakOnExceptions: Debug.isBreakOnException(), |
1808 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException() | 1808 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException() |
1809 } | 1809 } |
1810 } | 1810 } |
(...skipping 20 matching lines...) Expand all Loading... |
1831 response.failed('Missing argument "type"'); | 1831 response.failed('Missing argument "type"'); |
1832 return; | 1832 return; |
1833 } | 1833 } |
1834 | 1834 |
1835 // Initialize the default value of enable: | 1835 // Initialize the default value of enable: |
1836 var enabled; | 1836 var enabled; |
1837 if (type == 'all') { | 1837 if (type == 'all') { |
1838 enabled = !Debug.isBreakOnException(); | 1838 enabled = !Debug.isBreakOnException(); |
1839 } else if (type == 'uncaught') { | 1839 } else if (type == 'uncaught') { |
1840 enabled = !Debug.isBreakOnUncaughtException(); | 1840 enabled = !Debug.isBreakOnUncaughtException(); |
1841 } | 1841 } |
1842 | 1842 |
1843 // Pull out and check the 'enabled' argument if present: | 1843 // Pull out and check the 'enabled' argument if present: |
1844 if (!IS_UNDEFINED(request.arguments.enabled)) { | 1844 if (!IS_UNDEFINED(request.arguments.enabled)) { |
1845 enabled = request.arguments.enabled; | 1845 enabled = request.arguments.enabled; |
1846 if ((enabled != true) && (enabled != false)) { | 1846 if ((enabled != true) && (enabled != false)) { |
1847 response.failed('Illegal value for "enabled":"' + enabled + '"'); | 1847 response.failed('Illegal value for "enabled":"' + enabled + '"'); |
1848 } | 1848 } |
1849 } | 1849 } |
1850 | 1850 |
1851 // Now set the exception break state: | 1851 // Now set the exception break state: |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 try { | 2015 try { |
2016 expression = String(expression); | 2016 expression = String(expression); |
2017 } catch(e) { | 2017 } catch(e) { |
2018 return response.failed('Failed to convert expression argument to string'); | 2018 return response.failed('Failed to convert expression argument to string'); |
2019 } | 2019 } |
2020 | 2020 |
2021 // Check for legal arguments. | 2021 // Check for legal arguments. |
2022 if (!IS_UNDEFINED(frame) && global) { | 2022 if (!IS_UNDEFINED(frame) && global) { |
2023 return response.failed('Arguments "frame" and "global" are exclusive'); | 2023 return response.failed('Arguments "frame" and "global" are exclusive'); |
2024 } | 2024 } |
2025 | 2025 |
2026 var additional_context_object; | 2026 var additional_context_object; |
2027 if (additional_context) { | 2027 if (additional_context) { |
2028 additional_context_object = {}; | 2028 additional_context_object = {}; |
2029 for (var i = 0; i < additional_context.length; i++) { | 2029 for (var i = 0; i < additional_context.length; i++) { |
2030 var mapping = additional_context[i]; | 2030 var mapping = additional_context[i]; |
2031 if (!IS_STRING(mapping.name) || !IS_NUMBER(mapping.handle)) { | 2031 if (!IS_STRING(mapping.name) || !IS_NUMBER(mapping.handle)) { |
2032 return response.failed("Context element #" + i + | 2032 return response.failed("Context element #" + i + |
2033 " must contain name:string and handle:number"); | 2033 " must contain name:string and handle:number"); |
2034 } | 2034 } |
2035 var context_value_mirror = LookupMirror(mapping.handle); | 2035 var context_value_mirror = LookupMirror(mapping.handle); |
2036 if (!context_value_mirror) { | 2036 if (!context_value_mirror) { |
2037 return response.failed("Context object '" + mapping.name + | 2037 return response.failed("Context object '" + mapping.name + |
2038 "' #" + mapping.handle + "# not found"); | 2038 "' #" + mapping.handle + "# not found"); |
2039 } | 2039 } |
2040 additional_context_object[mapping.name] = context_value_mirror.value(); | 2040 additional_context_object[mapping.name] = context_value_mirror.value(); |
2041 } | 2041 } |
2042 } | 2042 } |
2043 | 2043 |
2044 // Global evaluate. | 2044 // Global evaluate. |
2045 if (global) { | 2045 if (global) { |
2046 // Evaluate in the global context. | 2046 // Evaluate in the global context. |
2047 response.body = this.exec_state_.evaluateGlobal( | 2047 response.body = this.exec_state_.evaluateGlobal( |
2048 expression, Boolean(disable_break), additional_context_object); | 2048 expression, Boolean(disable_break), additional_context_object); |
2049 return; | 2049 return; |
2050 } | 2050 } |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 case 'string': | 2591 case 'string': |
2592 case 'number': | 2592 case 'number': |
2593 json = value; | 2593 json = value; |
2594 break | 2594 break |
2595 | 2595 |
2596 default: | 2596 default: |
2597 json = null; | 2597 json = null; |
2598 } | 2598 } |
2599 return json; | 2599 return json; |
2600 } | 2600 } |
OLD | NEW |