| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 (function (global, utils) { | 5 (function (global, utils) { |
| 6 "use strict"; | 6 "use strict"; |
| 7 | 7 |
| 8 // ---------------------------------------------------------------------------- | 8 // ---------------------------------------------------------------------------- |
| 9 // Imports | 9 // Imports |
| 10 | 10 |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 ExecutionState.prototype.prepareStep = function(action) { | 831 ExecutionState.prototype.prepareStep = function(action) { |
| 832 if (action === Debug.StepAction.StepIn || | 832 if (action === Debug.StepAction.StepIn || |
| 833 action === Debug.StepAction.StepOut || | 833 action === Debug.StepAction.StepOut || |
| 834 action === Debug.StepAction.StepNext || | 834 action === Debug.StepAction.StepNext || |
| 835 action === Debug.StepAction.StepFrame) { | 835 action === Debug.StepAction.StepFrame) { |
| 836 return %PrepareStep(this.break_id, action); | 836 return %PrepareStep(this.break_id, action); |
| 837 } | 837 } |
| 838 throw %make_type_error(kDebuggerType); | 838 throw %make_type_error(kDebuggerType); |
| 839 }; | 839 }; |
| 840 | 840 |
| 841 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, | 841 ExecutionState.prototype.evaluateGlobal = function(source) { |
| 842 opt_additional_context) { | 842 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source)); |
| 843 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source, | |
| 844 TO_BOOLEAN(disable_break), | |
| 845 opt_additional_context)); | |
| 846 }; | 843 }; |
| 847 | 844 |
| 848 ExecutionState.prototype.frameCount = function() { | 845 ExecutionState.prototype.frameCount = function() { |
| 849 return %GetFrameCount(this.break_id); | 846 return %GetFrameCount(this.break_id); |
| 850 }; | 847 }; |
| 851 | 848 |
| 852 ExecutionState.prototype.frame = function(opt_index) { | 849 ExecutionState.prototype.frame = function(opt_index) { |
| 853 // If no index supplied return the selected frame. | 850 // If no index supplied return the selected frame. |
| 854 if (opt_index == null) opt_index = this.selected_frame; | 851 if (opt_index == null) opt_index = this.selected_frame; |
| 855 if (opt_index < 0 || opt_index >= this.frameCount()) { | 852 if (opt_index < 0 || opt_index >= this.frameCount()) { |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 | 1864 |
| 1868 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { | 1865 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { |
| 1869 if (!request.arguments) { | 1866 if (!request.arguments) { |
| 1870 return response.failed('Missing arguments'); | 1867 return response.failed('Missing arguments'); |
| 1871 } | 1868 } |
| 1872 | 1869 |
| 1873 // Pull out arguments. | 1870 // Pull out arguments. |
| 1874 var expression = request.arguments.expression; | 1871 var expression = request.arguments.expression; |
| 1875 var frame = request.arguments.frame; | 1872 var frame = request.arguments.frame; |
| 1876 var global = request.arguments.global; | 1873 var global = request.arguments.global; |
| 1877 var disable_break = request.arguments.disable_break; | |
| 1878 var additional_context = request.arguments.additional_context; | |
| 1879 | 1874 |
| 1880 // The expression argument could be an integer so we convert it to a | 1875 // The expression argument could be an integer so we convert it to a |
| 1881 // string. | 1876 // string. |
| 1882 try { | 1877 try { |
| 1883 expression = TO_STRING(expression); | 1878 expression = TO_STRING(expression); |
| 1884 } catch(e) { | 1879 } catch(e) { |
| 1885 return response.failed('Failed to convert expression argument to string'); | 1880 return response.failed('Failed to convert expression argument to string'); |
| 1886 } | 1881 } |
| 1887 | 1882 |
| 1888 // Check for legal arguments. | 1883 // Check for legal arguments. |
| 1889 if (!IS_UNDEFINED(frame) && global) { | 1884 if (!IS_UNDEFINED(frame) && global) { |
| 1890 return response.failed('Arguments "frame" and "global" are exclusive'); | 1885 return response.failed('Arguments "frame" and "global" are exclusive'); |
| 1891 } | 1886 } |
| 1892 | 1887 |
| 1893 var additional_context_object; | |
| 1894 if (additional_context) { | |
| 1895 additional_context_object = {}; | |
| 1896 for (var i = 0; i < additional_context.length; i++) { | |
| 1897 var mapping = additional_context[i]; | |
| 1898 | |
| 1899 if (!IS_STRING(mapping.name)) { | |
| 1900 return response.failed("Context element #" + i + | |
| 1901 " doesn't contain name:string property"); | |
| 1902 } | |
| 1903 | |
| 1904 var raw_value = DebugCommandProcessor.resolveValue_(mapping); | |
| 1905 additional_context_object[mapping.name] = raw_value; | |
| 1906 } | |
| 1907 } | |
| 1908 | |
| 1909 // Global evaluate. | 1888 // Global evaluate. |
| 1910 if (global) { | 1889 if (global) { |
| 1911 // Evaluate in the native context. | 1890 // Evaluate in the native context. |
| 1912 response.body = this.exec_state_.evaluateGlobal( | 1891 response.body = this.exec_state_.evaluateGlobal(expression); |
| 1913 expression, TO_BOOLEAN(disable_break), additional_context_object); | |
| 1914 return; | 1892 return; |
| 1915 } | 1893 } |
| 1916 | 1894 |
| 1917 // Default value for disable_break is true. | |
| 1918 if (IS_UNDEFINED(disable_break)) { | |
| 1919 disable_break = true; | |
| 1920 } | |
| 1921 | |
| 1922 // No frames no evaluate in frame. | 1895 // No frames no evaluate in frame. |
| 1923 if (this.exec_state_.frameCount() == 0) { | 1896 if (this.exec_state_.frameCount() == 0) { |
| 1924 return response.failed('No frames'); | 1897 return response.failed('No frames'); |
| 1925 } | 1898 } |
| 1926 | 1899 |
| 1927 // Check whether a frame was specified. | 1900 // Check whether a frame was specified. |
| 1928 if (!IS_UNDEFINED(frame)) { | 1901 if (!IS_UNDEFINED(frame)) { |
| 1929 var frame_number = TO_NUMBER(frame); | 1902 var frame_number = TO_NUMBER(frame); |
| 1930 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { | 1903 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { |
| 1931 return response.failed('Invalid frame "' + frame + '"'); | 1904 return response.failed('Invalid frame "' + frame + '"'); |
| 1932 } | 1905 } |
| 1933 // Evaluate in the specified frame. | 1906 // Evaluate in the specified frame. |
| 1934 response.body = this.exec_state_.frame(frame_number).evaluate( | 1907 response.body = this.exec_state_.frame(frame_number).evaluate(expression); |
| 1935 expression, TO_BOOLEAN(disable_break), additional_context_object); | |
| 1936 return; | 1908 return; |
| 1937 } else { | 1909 } else { |
| 1938 // Evaluate in the selected frame. | 1910 // Evaluate in the selected frame. |
| 1939 response.body = this.exec_state_.frame().evaluate( | 1911 response.body = this.exec_state_.frame().evaluate(expression); |
| 1940 expression, TO_BOOLEAN(disable_break), additional_context_object); | |
| 1941 return; | 1912 return; |
| 1942 } | 1913 } |
| 1943 }; | 1914 }; |
| 1944 | 1915 |
| 1945 | 1916 |
| 1946 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { | 1917 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { |
| 1947 if (!request.arguments) { | 1918 if (!request.arguments) { |
| 1948 return response.failed('Missing arguments'); | 1919 return response.failed('Missing arguments'); |
| 1949 } | 1920 } |
| 1950 | 1921 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2419 utils.InstallFunctions(utils, DONT_ENUM, [ | 2390 utils.InstallFunctions(utils, DONT_ENUM, [ |
| 2420 "MakeExecutionState", MakeExecutionState, | 2391 "MakeExecutionState", MakeExecutionState, |
| 2421 "MakeExceptionEvent", MakeExceptionEvent, | 2392 "MakeExceptionEvent", MakeExceptionEvent, |
| 2422 "MakeBreakEvent", MakeBreakEvent, | 2393 "MakeBreakEvent", MakeBreakEvent, |
| 2423 "MakeCompileEvent", MakeCompileEvent, | 2394 "MakeCompileEvent", MakeCompileEvent, |
| 2424 "MakeAsyncTaskEvent", MakeAsyncTaskEvent, | 2395 "MakeAsyncTaskEvent", MakeAsyncTaskEvent, |
| 2425 "IsBreakPointTriggered", IsBreakPointTriggered, | 2396 "IsBreakPointTriggered", IsBreakPointTriggered, |
| 2426 ]); | 2397 ]); |
| 2427 | 2398 |
| 2428 }) | 2399 }) |
| OLD | NEW |