| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/service.h" | 5 #include "vm/service.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
| 9 | 9 |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 | 773 |
| 774 | 774 |
| 775 static const MethodParameter* get_stack_params[] = { | 775 static const MethodParameter* get_stack_params[] = { |
| 776 ISOLATE_PARAMETER, | 776 ISOLATE_PARAMETER, |
| 777 new BoolParameter("_full", false), | 777 new BoolParameter("_full", false), |
| 778 NULL, | 778 NULL, |
| 779 }; | 779 }; |
| 780 | 780 |
| 781 | 781 |
| 782 static bool GetStack(Isolate* isolate, JSONStream* js) { | 782 static bool GetStack(Isolate* isolate, JSONStream* js) { |
| 783 ASSERT(isolate->debugger() != NULL); |
| 783 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 784 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
| 784 // Do we want the complete script object and complete local variable objects? | 785 // Do we want the complete script object and complete local variable objects? |
| 785 // This is true for dump requests. | 786 // This is true for dump requests. |
| 786 const bool full = BoolParameter::Parse(js->LookupParam("_full"), false); | 787 const bool full = BoolParameter::Parse(js->LookupParam("_full"), false); |
| 787 JSONObject jsobj(js); | 788 JSONObject jsobj(js); |
| 788 jsobj.AddProperty("type", "Stack"); | 789 jsobj.AddProperty("type", "Stack"); |
| 789 { | 790 { |
| 790 JSONArray jsarr(&jsobj, "frames"); | 791 JSONArray jsarr(&jsobj, "frames"); |
| 791 | 792 |
| 792 intptr_t num_frames = stack->Length(); | 793 intptr_t num_frames = stack->Length(); |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 jsobj.AddProperty("valueAsString", "<free>"); | 1249 jsobj.AddProperty("valueAsString", "<free>"); |
| 1249 break; | 1250 break; |
| 1250 default: | 1251 default: |
| 1251 UNIMPLEMENTED(); | 1252 UNIMPLEMENTED(); |
| 1252 break; | 1253 break; |
| 1253 } | 1254 } |
| 1254 } | 1255 } |
| 1255 | 1256 |
| 1256 | 1257 |
| 1257 static Breakpoint* LookupBreakpoint(Isolate* isolate, const char* id) { | 1258 static Breakpoint* LookupBreakpoint(Isolate* isolate, const char* id) { |
| 1259 ASSERT(isolate->debugger() != NULL); |
| 1258 size_t end_pos = strcspn(id, "/"); | 1260 size_t end_pos = strcspn(id, "/"); |
| 1259 if (end_pos == strlen(id)) { | 1261 if (end_pos == strlen(id)) { |
| 1260 return NULL; | 1262 return NULL; |
| 1261 } | 1263 } |
| 1262 const char* rest = id + end_pos + 1; // +1 for '/'. | 1264 const char* rest = id + end_pos + 1; // +1 for '/'. |
| 1263 if (strncmp("breakpoints", id, end_pos) == 0) { | 1265 if (strncmp("breakpoints", id, end_pos) == 0) { |
| 1264 intptr_t bpt_id = 0; | 1266 intptr_t bpt_id = 0; |
| 1265 Breakpoint* bpt = NULL; | 1267 Breakpoint* bpt = NULL; |
| 1266 if (GetIntegerId(rest, &bpt_id)) { | 1268 if (GetIntegerId(rest, &bpt_id)) { |
| 1267 bpt = isolate->debugger()->GetBreakpointById(bpt_id); | 1269 bpt = isolate->debugger()->GetBreakpointById(bpt_id); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 | 1616 |
| 1615 static const MethodParameter* evaluate_in_frame_params[] = { | 1617 static const MethodParameter* evaluate_in_frame_params[] = { |
| 1616 ISOLATE_PARAMETER, | 1618 ISOLATE_PARAMETER, |
| 1617 new UIntParameter("frameIndex", true), | 1619 new UIntParameter("frameIndex", true), |
| 1618 new MethodParameter("expression", true), | 1620 new MethodParameter("expression", true), |
| 1619 NULL, | 1621 NULL, |
| 1620 }; | 1622 }; |
| 1621 | 1623 |
| 1622 | 1624 |
| 1623 static bool EvaluateInFrame(Isolate* isolate, JSONStream* js) { | 1625 static bool EvaluateInFrame(Isolate* isolate, JSONStream* js) { |
| 1626 ASSERT(isolate->debugger() != NULL); |
| 1624 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 1627 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
| 1625 intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex")); | 1628 intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex")); |
| 1626 if (framePos > stack->Length()) { | 1629 if (framePos > stack->Length()) { |
| 1627 PrintInvalidParamError(js, "frameIndex"); | 1630 PrintInvalidParamError(js, "frameIndex"); |
| 1628 return true; | 1631 return true; |
| 1629 } | 1632 } |
| 1630 ActivationFrame* frame = stack->FrameAt(framePos); | 1633 ActivationFrame* frame = stack->FrameAt(framePos); |
| 1631 | 1634 |
| 1632 const char* expr = js->LookupParam("expression"); | 1635 const char* expr = js->LookupParam("expression"); |
| 1633 const String& expr_str = String::Handle(isolate, String::New(expr)); | 1636 const String& expr_str = String::Handle(isolate, String::New(expr)); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 | 1852 |
| 1850 static const MethodParameter* add_breakpoint_params[] = { | 1853 static const MethodParameter* add_breakpoint_params[] = { |
| 1851 ISOLATE_PARAMETER, | 1854 ISOLATE_PARAMETER, |
| 1852 new IdParameter("scriptId", true), | 1855 new IdParameter("scriptId", true), |
| 1853 new UIntParameter("line", true), | 1856 new UIntParameter("line", true), |
| 1854 NULL, | 1857 NULL, |
| 1855 }; | 1858 }; |
| 1856 | 1859 |
| 1857 | 1860 |
| 1858 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { | 1861 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { |
| 1862 ASSERT(isolate->debugger() != NULL); |
| 1859 const char* line_param = js->LookupParam("line"); | 1863 const char* line_param = js->LookupParam("line"); |
| 1860 intptr_t line = UIntParameter::Parse(line_param); | 1864 intptr_t line = UIntParameter::Parse(line_param); |
| 1861 const char* script_id = js->LookupParam("scriptId"); | 1865 const char* script_id = js->LookupParam("scriptId"); |
| 1862 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); | 1866 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); |
| 1863 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { | 1867 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { |
| 1864 PrintInvalidParamError(js, "scriptId"); | 1868 PrintInvalidParamError(js, "scriptId"); |
| 1865 return true; | 1869 return true; |
| 1866 } | 1870 } |
| 1867 const Script& script = Script::Cast(obj); | 1871 const Script& script = Script::Cast(obj); |
| 1868 const String& script_url = String::Handle(script.url()); | 1872 const String& script_url = String::Handle(script.url()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1880 | 1884 |
| 1881 | 1885 |
| 1882 static const MethodParameter* add_breakpoint_at_entry_params[] = { | 1886 static const MethodParameter* add_breakpoint_at_entry_params[] = { |
| 1883 ISOLATE_PARAMETER, | 1887 ISOLATE_PARAMETER, |
| 1884 new IdParameter("functionId", true), | 1888 new IdParameter("functionId", true), |
| 1885 NULL, | 1889 NULL, |
| 1886 }; | 1890 }; |
| 1887 | 1891 |
| 1888 | 1892 |
| 1889 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) { | 1893 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) { |
| 1894 ASSERT(isolate->debugger() != NULL); |
| 1890 const char* function_id = js->LookupParam("functionId"); | 1895 const char* function_id = js->LookupParam("functionId"); |
| 1891 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); | 1896 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); |
| 1892 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { | 1897 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { |
| 1893 PrintInvalidParamError(js, "functionId"); | 1898 PrintInvalidParamError(js, "functionId"); |
| 1894 return true; | 1899 return true; |
| 1895 } | 1900 } |
| 1896 const Function& function = Function::Cast(obj); | 1901 const Function& function = Function::Cast(obj); |
| 1897 Breakpoint* bpt = | 1902 Breakpoint* bpt = |
| 1898 isolate->debugger()->SetBreakpointAtEntry(function, false); | 1903 isolate->debugger()->SetBreakpointAtEntry(function, false); |
| 1899 if (bpt == NULL) { | 1904 if (bpt == NULL) { |
| 1900 js->PrintError(kCannotAddBreakpoint, | 1905 js->PrintError(kCannotAddBreakpoint, |
| 1901 "%s: Cannot add breakpoint at function '%s'", | 1906 "%s: Cannot add breakpoint at function '%s'", |
| 1902 js->method(), function.ToCString()); | 1907 js->method(), function.ToCString()); |
| 1903 return true; | 1908 return true; |
| 1904 } | 1909 } |
| 1905 bpt->PrintJSON(js); | 1910 bpt->PrintJSON(js); |
| 1906 return true; | 1911 return true; |
| 1907 } | 1912 } |
| 1908 | 1913 |
| 1909 | 1914 |
| 1910 static const MethodParameter* add_breakpoint_at_activation_params[] = { | 1915 static const MethodParameter* add_breakpoint_at_activation_params[] = { |
| 1911 ISOLATE_PARAMETER, | 1916 ISOLATE_PARAMETER, |
| 1912 new IdParameter("objectId", true), | 1917 new IdParameter("objectId", true), |
| 1913 NULL, | 1918 NULL, |
| 1914 }; | 1919 }; |
| 1915 | 1920 |
| 1916 | 1921 |
| 1917 static bool AddBreakpointAtActivation(Isolate* isolate, JSONStream* js) { | 1922 static bool AddBreakpointAtActivation(Isolate* isolate, JSONStream* js) { |
| 1923 ASSERT(isolate->debugger() != NULL); |
| 1918 const char* object_id = js->LookupParam("objectId"); | 1924 const char* object_id = js->LookupParam("objectId"); |
| 1919 Object& obj = Object::Handle(LookupHeapObject(isolate, object_id, NULL)); | 1925 Object& obj = Object::Handle(LookupHeapObject(isolate, object_id, NULL)); |
| 1920 if (obj.raw() == Object::sentinel().raw() || !obj.IsInstance()) { | 1926 if (obj.raw() == Object::sentinel().raw() || !obj.IsInstance()) { |
| 1921 PrintInvalidParamError(js, "objectId"); | 1927 PrintInvalidParamError(js, "objectId"); |
| 1922 return true; | 1928 return true; |
| 1923 } | 1929 } |
| 1924 const Instance& closure = Instance::Cast(obj); | 1930 const Instance& closure = Instance::Cast(obj); |
| 1925 Breakpoint* bpt = | 1931 Breakpoint* bpt = |
| 1926 isolate->debugger()->SetBreakpointAtActivation(closure); | 1932 isolate->debugger()->SetBreakpointAtActivation(closure); |
| 1927 if (bpt == NULL) { | 1933 if (bpt == NULL) { |
| 1928 js->PrintError(kCannotAddBreakpoint, | 1934 js->PrintError(kCannotAddBreakpoint, |
| 1929 "%s: Cannot add breakpoint at activation", | 1935 "%s: Cannot add breakpoint at activation", |
| 1930 js->method()); | 1936 js->method()); |
| 1931 return true; | 1937 return true; |
| 1932 } | 1938 } |
| 1933 bpt->PrintJSON(js); | 1939 bpt->PrintJSON(js); |
| 1934 return true; | 1940 return true; |
| 1935 } | 1941 } |
| 1936 | 1942 |
| 1937 | 1943 |
| 1938 static const MethodParameter* remove_breakpoint_params[] = { | 1944 static const MethodParameter* remove_breakpoint_params[] = { |
| 1939 ISOLATE_PARAMETER, | 1945 ISOLATE_PARAMETER, |
| 1940 NULL, | 1946 NULL, |
| 1941 }; | 1947 }; |
| 1942 | 1948 |
| 1943 | 1949 |
| 1944 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { | 1950 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { |
| 1951 ASSERT(isolate->debugger() != NULL); |
| 1945 if (!js->HasParam("breakpointId")) { | 1952 if (!js->HasParam("breakpointId")) { |
| 1946 PrintMissingParamError(js, "breakpointId"); | 1953 PrintMissingParamError(js, "breakpointId"); |
| 1947 return true; | 1954 return true; |
| 1948 } | 1955 } |
| 1949 const char* bpt_id = js->LookupParam("breakpointId"); | 1956 const char* bpt_id = js->LookupParam("breakpointId"); |
| 1950 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id); | 1957 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id); |
| 1951 if (bpt == NULL) { | 1958 if (bpt == NULL) { |
| 1952 PrintInvalidParamError(js, "breakpointId"); | 1959 PrintInvalidParamError(js, "breakpointId"); |
| 1953 return true; | 1960 return true; |
| 1954 } | 1961 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 } | 2147 } |
| 2141 | 2148 |
| 2142 | 2149 |
| 2143 static const MethodParameter* resume_params[] = { | 2150 static const MethodParameter* resume_params[] = { |
| 2144 ISOLATE_PARAMETER, | 2151 ISOLATE_PARAMETER, |
| 2145 NULL, | 2152 NULL, |
| 2146 }; | 2153 }; |
| 2147 | 2154 |
| 2148 | 2155 |
| 2149 static bool Resume(Isolate* isolate, JSONStream* js) { | 2156 static bool Resume(Isolate* isolate, JSONStream* js) { |
| 2157 ASSERT(isolate->debugger() != NULL); |
| 2150 const char* step_param = js->LookupParam("step"); | 2158 const char* step_param = js->LookupParam("step"); |
| 2151 if (isolate->message_handler()->paused_on_start()) { | 2159 if (isolate->message_handler()->paused_on_start()) { |
| 2152 isolate->message_handler()->set_pause_on_start(false); | 2160 isolate->message_handler()->set_pause_on_start(false); |
| 2153 if (Service::NeedsDebugEvents()) { | 2161 if (Service::NeedsDebugEvents()) { |
| 2154 ServiceEvent event(isolate, ServiceEvent::kResume); | 2162 ServiceEvent event(isolate, ServiceEvent::kResume); |
| 2155 Service::HandleEvent(&event); | 2163 Service::HandleEvent(&event); |
| 2156 } | 2164 } |
| 2157 PrintSuccess(js); | 2165 PrintSuccess(js); |
| 2158 return true; | 2166 return true; |
| 2159 } | 2167 } |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2798 ServiceMethodDescriptor& method = service_methods_[i]; | 2806 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2799 if (strcmp(method_name, method.name) == 0) { | 2807 if (strcmp(method_name, method.name) == 0) { |
| 2800 return &method; | 2808 return &method; |
| 2801 } | 2809 } |
| 2802 } | 2810 } |
| 2803 return NULL; | 2811 return NULL; |
| 2804 } | 2812 } |
| 2805 | 2813 |
| 2806 | 2814 |
| 2807 } // namespace dart | 2815 } // namespace dart |
| OLD | NEW |