| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 handler.HandleNextMessage(); | 978 handler.HandleNextMessage(); |
| 979 handler.filterMsg("name"); | 979 handler.filterMsg("name"); |
| 980 EXPECT_STREQ( | 980 EXPECT_STREQ( |
| 981 "{\"type\":\"@Smi\"," | 981 "{\"type\":\"@Smi\"," |
| 982 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," | 982 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," |
| 983 "\"user_name\":\"_Smi\"}," | 983 "\"user_name\":\"_Smi\"}," |
| 984 "\"id\":\"objects\\/int-111235\"," | 984 "\"id\":\"objects\\/int-111235\"," |
| 985 "\"valueAsString\":\"111235\"}", | 985 "\"valueAsString\":\"111235\"}", |
| 986 handler.msg()); | 986 handler.msg()); |
| 987 | 987 |
| 988 // Request function 0 from class A. | 988 // Request function 'b' from class A. |
| 989 service_msg = EvalF(lib, | 989 service_msg = EvalF(lib, |
| 990 "[0, port, ['classes', '%" Pd "', 'functions', '0']," | 990 "[0, port, ['classes', '%" Pd "', 'functions', 'b']," |
| 991 "[], []]", cid); | 991 "[], []]", cid); |
| 992 Service::HandleIsolateMessage(isolate, service_msg); | 992 Service::HandleIsolateMessage(isolate, service_msg); |
| 993 handler.HandleNextMessage(); | 993 handler.HandleNextMessage(); |
| 994 EXPECT_SUBSTRING("\"type\":\"Function\"", handler.msg()); | 994 EXPECT_SUBSTRING("\"type\":\"Function\"", handler.msg()); |
| 995 ExpectSubstringF(handler.msg(), | 995 ExpectSubstringF(handler.msg(), |
| 996 "\"id\":\"classes\\/%" Pd "\\/functions\\/0\"," | 996 "\"id\":\"classes\\/%" Pd "\\/functions\\/b\"," |
| 997 "\"name\":\"get:a\",", cid); | 997 "\"name\":\"b\",", cid); |
| 998 | 998 |
| 999 // Request field 0 from class A. | 999 // Request field 0 from class A. |
| 1000 service_msg = EvalF(lib, "[0, port, ['classes', '%" Pd "', 'fields', '0']," | 1000 service_msg = EvalF(lib, "[0, port, ['classes', '%" Pd "', 'fields', '0']," |
| 1001 "[], []]", cid); | 1001 "[], []]", cid); |
| 1002 Service::HandleIsolateMessage(isolate, service_msg); | 1002 Service::HandleIsolateMessage(isolate, service_msg); |
| 1003 handler.HandleNextMessage(); | 1003 handler.HandleNextMessage(); |
| 1004 EXPECT_SUBSTRING("\"type\":\"Field\"", handler.msg()); | 1004 EXPECT_SUBSTRING("\"type\":\"Field\"", handler.msg()); |
| 1005 ExpectSubstringF(handler.msg(), | 1005 ExpectSubstringF(handler.msg(), |
| 1006 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\"," | 1006 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\"," |
| 1007 "\"name\":\"a\",", cid); | 1007 "\"name\":\"a\",", cid); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"]," | 1051 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"]," |
| 1052 "\"option_keys\":[],\"option_values\":[]}}", cid); | 1052 "\"option_keys\":[],\"option_values\":[]}}", cid); |
| 1053 | 1053 |
| 1054 // Invalid function command. | 1054 // Invalid function command. |
| 1055 service_msg = EvalF(lib, | 1055 service_msg = EvalF(lib, |
| 1056 "[0, port, ['classes', '%" Pd "', 'functions', '0'," | 1056 "[0, port, ['classes', '%" Pd "', 'functions', '0'," |
| 1057 "'x', 'y'], [], []]", cid); | 1057 "'x', 'y'], [], []]", cid); |
| 1058 Service::HandleIsolateMessage(isolate, service_msg); | 1058 Service::HandleIsolateMessage(isolate, service_msg); |
| 1059 handler.HandleNextMessage(); | 1059 handler.HandleNextMessage(); |
| 1060 ExpectSubstringF(handler.msg(), | 1060 ExpectSubstringF(handler.msg(), |
| 1061 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," | 1061 "{\"type\":\"Error\",\"id\":\"\"," |
| 1062 "\"message\":\"Command should have 4 or 5 arguments\"," |
| 1062 "\"request\":" | 1063 "\"request\":" |
| 1063 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"0\",\"x\",\"y\"]," | 1064 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"0\",\"x\",\"y\"]," |
| 1064 "\"option_keys\":[],\"option_values\":[]}}", cid); | 1065 "\"option_keys\":[],\"option_values\":[]}}", cid); |
| 1065 | 1066 |
| 1066 // Invalid function subcommand with valid function id. | 1067 // Invalid function subcommand with valid function id. |
| 1067 service_msg = EvalF(lib, | 1068 service_msg = EvalF(lib, |
| 1068 "[0, port, ['classes', '%" Pd "', 'functions', '0'," | 1069 "[0, port, ['classes', '%" Pd "', 'functions', 'b'," |
| 1069 "'x'], [], []]", cid); | 1070 "'x'], [], []]", cid); |
| 1070 Service::HandleIsolateMessage(isolate, service_msg); | 1071 Service::HandleIsolateMessage(isolate, service_msg); |
| 1071 handler.HandleNextMessage(); | 1072 handler.HandleNextMessage(); |
| 1072 ExpectSubstringF(handler.msg(), | 1073 ExpectSubstringF(handler.msg(), |
| 1073 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Invalid sub collection x\"," | 1074 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Invalid sub collection x\"," |
| 1074 "\"request\":" | 1075 "\"request\":" |
| 1075 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"0\",\"x\"]," | 1076 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"b\",\"x\"]," |
| 1076 "\"option_keys\":[],\"option_values\":[]}}", cid); | 1077 "\"option_keys\":[],\"option_values\":[]}}", cid); |
| 1077 | 1078 |
| 1078 // Retained size of all instances of class B. | 1079 // Retained size of all instances of class B. |
| 1079 const Class& class_b = Class::Handle(GetClass(vmlib, "B")); | 1080 const Class& class_b = Class::Handle(GetClass(vmlib, "B")); |
| 1080 EXPECT(!class_b.IsNull()); | 1081 EXPECT(!class_b.IsNull()); |
| 1081 const Instance& b0 = Instance::Handle(Instance::New(class_b)); | 1082 const Instance& b0 = Instance::Handle(Instance::New(class_b)); |
| 1082 const Instance& b1 = Instance::Handle(Instance::New(class_b)); | 1083 const Instance& b1 = Instance::Handle(Instance::New(class_b)); |
| 1083 service_msg = EvalF(lib, "[0, port, ['classes', '%" Pd "', 'retained']," | 1084 service_msg = EvalF(lib, "[0, port, ['classes', '%" Pd "', 'retained']," |
| 1084 "[], []]", class_b.id()); | 1085 "[], []]", class_b.id()); |
| 1085 Service::HandleIsolateMessage(isolate, service_msg); | 1086 Service::HandleIsolateMessage(isolate, service_msg); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 if (table->HasValidClassAt(i) && table->At(i) == cls.raw()) { | 1709 if (table->HasValidClassAt(i) && table->At(i) == cls.raw()) { |
| 1709 break; | 1710 break; |
| 1710 } | 1711 } |
| 1711 } | 1712 } |
| 1712 ASSERT(i != table->NumCids()); | 1713 ASSERT(i != table->NumCids()); |
| 1713 | 1714 |
| 1714 // Look up the service if of the function Foo.bar. | 1715 // Look up the service if of the function Foo.bar. |
| 1715 const Function& func = Function::Handle( | 1716 const Function& func = Function::Handle( |
| 1716 cls.LookupFunction(String::Handle(String::New("bar")))); | 1717 cls.LookupFunction(String::Handle(String::New("bar")))); |
| 1717 ASSERT(!func.IsNull()); | 1718 ASSERT(!func.IsNull()); |
| 1718 intptr_t function_id = -1; | |
| 1719 function_id = cls.FindFunctionIndex(func); | |
| 1720 ASSERT(function_id != -1); | |
| 1721 | 1719 |
| 1722 char buf[1024]; | 1720 char buf[1024]; |
| 1723 OS::SNPrint(buf, sizeof(buf), | 1721 OS::SNPrint(buf, sizeof(buf), |
| 1724 "[0, port, ['classes', '%" Pd "', 'functions'," | 1722 "[0, port, ['classes', '%" Pd "', 'functions'," |
| 1725 "'% " Pd "', 'coverage'], [], []]", i, function_id); | 1723 "'bar', 'coverage'], [], []]", i); |
| 1726 | 1724 |
| 1727 Array& service_msg = Array::Handle(); | 1725 Array& service_msg = Array::Handle(); |
| 1728 service_msg = Eval(lib, buf); | 1726 service_msg = Eval(lib, buf); |
| 1729 Service::HandleIsolateMessage(isolate, service_msg); | 1727 Service::HandleIsolateMessage(isolate, service_msg); |
| 1730 handler.HandleNextMessage(); | 1728 handler.HandleNextMessage(); |
| 1731 OS::SNPrint(buf, sizeof(buf), | 1729 OS::SNPrint(buf, sizeof(buf), |
| 1732 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" | 1730 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" |
| 1733 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," | 1731 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," |
| 1734 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," | 1732 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," |
| 1735 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1733 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 service_msg = Eval(lib, "[0, port, ['profile'], ['tags'], ['hidden']]"); | 2024 service_msg = Eval(lib, "[0, port, ['profile'], ['tags'], ['hidden']]"); |
| 2027 Service::HandleIsolateMessage(isolate, service_msg); | 2025 Service::HandleIsolateMessage(isolate, service_msg); |
| 2028 handler.HandleNextMessage(); | 2026 handler.HandleNextMessage(); |
| 2029 // Expect error. | 2027 // Expect error. |
| 2030 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 2028 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
| 2031 } | 2029 } |
| 2032 | 2030 |
| 2033 #endif // !defined(TARGET_ARCH_ARM64) | 2031 #endif // !defined(TARGET_ARCH_ARM64) |
| 2034 | 2032 |
| 2035 } // namespace dart | 2033 } // namespace dart |
| OLD | NEW |