| 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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 Debug.scripts = function() { | 851 Debug.scripts = function() { |
| 852 // Collect all scripts in the heap. | 852 // Collect all scripts in the heap. |
| 853 return %DebugGetLoadedScripts(); | 853 return %DebugGetLoadedScripts(); |
| 854 }; | 854 }; |
| 855 | 855 |
| 856 | 856 |
| 857 Debug.debuggerFlags = function() { | 857 Debug.debuggerFlags = function() { |
| 858 return debugger_flags; | 858 return debugger_flags; |
| 859 }; | 859 }; |
| 860 | 860 |
| 861 Debug.MakeMirror = MakeMirror; |
| 861 | 862 |
| 862 function MakeExecutionState(break_id) { | 863 function MakeExecutionState(break_id) { |
| 863 return new ExecutionState(break_id); | 864 return new ExecutionState(break_id); |
| 864 } | 865 } |
| 865 | 866 |
| 866 function ExecutionState(break_id) { | 867 function ExecutionState(break_id) { |
| 867 this.break_id = break_id; | 868 this.break_id = break_id; |
| 868 this.selected_frame = 0; | 869 this.selected_frame = 0; |
| 869 } | 870 } |
| 870 | 871 |
| 871 ExecutionState.prototype.prepareStep = function(opt_action, opt_count) { | 872 ExecutionState.prototype.prepareStep = function(opt_action, opt_count) { |
| 872 var action = Debug.StepAction.StepIn; | 873 var action = Debug.StepAction.StepIn; |
| 873 if (!IS_UNDEFINED(opt_action)) action = %ToNumber(opt_action); | 874 if (!IS_UNDEFINED(opt_action)) action = %ToNumber(opt_action); |
| 874 var count = opt_count ? %ToNumber(opt_count) : 1; | 875 var count = opt_count ? %ToNumber(opt_count) : 1; |
| 875 | 876 |
| 876 return %PrepareStep(this.break_id, action, count); | 877 return %PrepareStep(this.break_id, action, count); |
| 877 } | 878 } |
| 878 | 879 |
| 879 ExecutionState.prototype.evaluateGlobal = function(source, disable_break) { | 880 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, |
| 880 return MakeMirror( | 881 opt_additional_context) { |
| 881 %DebugEvaluateGlobal(this.break_id, source, Boolean(disable_break))); | 882 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source, |
| 883 Boolean(disable_break), |
| 884 opt_additional_context)); |
| 882 }; | 885 }; |
| 883 | 886 |
| 884 ExecutionState.prototype.frameCount = function() { | 887 ExecutionState.prototype.frameCount = function() { |
| 885 return %GetFrameCount(this.break_id); | 888 return %GetFrameCount(this.break_id); |
| 886 }; | 889 }; |
| 887 | 890 |
| 888 ExecutionState.prototype.threadCount = function() { | 891 ExecutionState.prototype.threadCount = function() { |
| 889 return %GetThreadCount(this.break_id); | 892 return %GetThreadCount(this.break_id); |
| 890 }; | 893 }; |
| 891 | 894 |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { | 1833 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { |
| 1831 if (!request.arguments) { | 1834 if (!request.arguments) { |
| 1832 return response.failed('Missing arguments'); | 1835 return response.failed('Missing arguments'); |
| 1833 } | 1836 } |
| 1834 | 1837 |
| 1835 // Pull out arguments. | 1838 // Pull out arguments. |
| 1836 var expression = request.arguments.expression; | 1839 var expression = request.arguments.expression; |
| 1837 var frame = request.arguments.frame; | 1840 var frame = request.arguments.frame; |
| 1838 var global = request.arguments.global; | 1841 var global = request.arguments.global; |
| 1839 var disable_break = request.arguments.disable_break; | 1842 var disable_break = request.arguments.disable_break; |
| 1843 var additional_context = request.arguments.additional_context; |
| 1840 | 1844 |
| 1841 // The expression argument could be an integer so we convert it to a | 1845 // The expression argument could be an integer so we convert it to a |
| 1842 // string. | 1846 // string. |
| 1843 try { | 1847 try { |
| 1844 expression = String(expression); | 1848 expression = String(expression); |
| 1845 } catch(e) { | 1849 } catch(e) { |
| 1846 return response.failed('Failed to convert expression argument to string'); | 1850 return response.failed('Failed to convert expression argument to string'); |
| 1847 } | 1851 } |
| 1848 | 1852 |
| 1849 // Check for legal arguments. | 1853 // Check for legal arguments. |
| 1850 if (!IS_UNDEFINED(frame) && global) { | 1854 if (!IS_UNDEFINED(frame) && global) { |
| 1851 return response.failed('Arguments "frame" and "global" are exclusive'); | 1855 return response.failed('Arguments "frame" and "global" are exclusive'); |
| 1852 } | 1856 } |
| 1857 |
| 1858 var additional_context_object; |
| 1859 if (additional_context) { |
| 1860 additional_context_object = {}; |
| 1861 for (var key in additional_context) { |
| 1862 var context_value_handle = additional_context[key]; |
| 1863 var context_value_mirror = LookupMirror(context_value_handle); |
| 1864 if (!context_value_mirror) { |
| 1865 return response.failed( |
| 1866 "Context object '" + key + "' #" + context_value_handle + |
| 1867 "# not found"); |
| 1868 } |
| 1869 additional_context_object[key] = context_value_mirror.value(); |
| 1870 } |
| 1871 } |
| 1853 | 1872 |
| 1854 // Global evaluate. | 1873 // Global evaluate. |
| 1855 if (global) { | 1874 if (global) { |
| 1856 // Evaluate in the global context. | 1875 // Evaluate in the global context. |
| 1857 response.body = | 1876 response.body = this.exec_state_.evaluateGlobal( |
| 1858 this.exec_state_.evaluateGlobal(expression, Boolean(disable_break)); | 1877 expression, Boolean(disable_break), additional_context_object); |
| 1859 return; | 1878 return; |
| 1860 } | 1879 } |
| 1861 | 1880 |
| 1862 // Default value for disable_break is true. | 1881 // Default value for disable_break is true. |
| 1863 if (IS_UNDEFINED(disable_break)) { | 1882 if (IS_UNDEFINED(disable_break)) { |
| 1864 disable_break = true; | 1883 disable_break = true; |
| 1865 } | 1884 } |
| 1866 | 1885 |
| 1867 // No frames no evaluate in frame. | 1886 // No frames no evaluate in frame. |
| 1868 if (this.exec_state_.frameCount() == 0) { | 1887 if (this.exec_state_.frameCount() == 0) { |
| 1869 return response.failed('No frames'); | 1888 return response.failed('No frames'); |
| 1870 } | 1889 } |
| 1871 | 1890 |
| 1872 // Check whether a frame was specified. | 1891 // Check whether a frame was specified. |
| 1873 if (!IS_UNDEFINED(frame)) { | 1892 if (!IS_UNDEFINED(frame)) { |
| 1874 var frame_number = %ToNumber(frame); | 1893 var frame_number = %ToNumber(frame); |
| 1875 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { | 1894 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { |
| 1876 return response.failed('Invalid frame "' + frame + '"'); | 1895 return response.failed('Invalid frame "' + frame + '"'); |
| 1877 } | 1896 } |
| 1878 // Evaluate in the specified frame. | 1897 // Evaluate in the specified frame. |
| 1879 response.body = this.exec_state_.frame(frame_number).evaluate( | 1898 response.body = this.exec_state_.frame(frame_number).evaluate( |
| 1880 expression, Boolean(disable_break)); | 1899 expression, Boolean(disable_break), additional_context_object); |
| 1881 return; | 1900 return; |
| 1882 } else { | 1901 } else { |
| 1883 // Evaluate in the selected frame. | 1902 // Evaluate in the selected frame. |
| 1884 response.body = this.exec_state_.frame().evaluate( | 1903 response.body = this.exec_state_.frame().evaluate( |
| 1885 expression, Boolean(disable_break)); | 1904 expression, Boolean(disable_break), additional_context_object); |
| 1886 return; | 1905 return; |
| 1887 } | 1906 } |
| 1888 }; | 1907 }; |
| 1889 | 1908 |
| 1890 | 1909 |
| 1891 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { | 1910 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { |
| 1892 if (!request.arguments) { | 1911 if (!request.arguments) { |
| 1893 return response.failed('Missing arguments'); | 1912 return response.failed('Missing arguments'); |
| 1894 } | 1913 } |
| 1895 | 1914 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 case 'string': | 2289 case 'string': |
| 2271 case 'number': | 2290 case 'number': |
| 2272 json = value; | 2291 json = value; |
| 2273 break | 2292 break |
| 2274 | 2293 |
| 2275 default: | 2294 default: |
| 2276 json = null; | 2295 json = null; |
| 2277 } | 2296 } |
| 2278 return json; | 2297 return json; |
| 2279 } | 2298 } |
| OLD | NEW |