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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 // Get the breakpoint list. | 273 // Get the breakpoint list. |
274 service_msg = Eval(lib, "[port, ['debug', 'breakpoints'], [], []]"); | 274 service_msg = Eval(lib, "[port, ['debug', 'breakpoints'], [], []]"); |
275 Service::HandleIsolateMessage(isolate, service_msg); | 275 Service::HandleIsolateMessage(isolate, service_msg); |
276 handler.HandleNextMessage(); | 276 handler.HandleNextMessage(); |
277 EXPECT_STREQ( | 277 EXPECT_STREQ( |
278 "{\"type\":\"BreakpointList\",\"breakpoints\":[{" | 278 "{\"type\":\"BreakpointList\",\"breakpoints\":[{" |
279 "\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," | 279 "\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," |
280 "\"resolved\":false," | 280 "\"resolved\":false," |
281 "\"location\":{\"type\":\"Location\"," | 281 "\"location\":{\"type\":\"Location\"," |
282 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}]}", | 282 "\"script\":\"test-lib\",\"tokenPos\":5}}]}", |
283 handler.msg()); | 283 handler.msg()); |
284 | 284 |
285 // Individual breakpoint. | 285 // Individual breakpoint. |
286 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1'], [], []]"); | 286 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1'], [], []]"); |
287 Service::HandleIsolateMessage(isolate, service_msg); | 287 Service::HandleIsolateMessage(isolate, service_msg); |
288 handler.HandleNextMessage(); | 288 handler.HandleNextMessage(); |
289 EXPECT_STREQ( | 289 EXPECT_STREQ( |
290 "{\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," | 290 "{\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," |
291 "\"resolved\":false," | 291 "\"resolved\":false," |
292 "\"location\":{\"type\":\"Location\"," | 292 "\"location\":{\"type\":\"Location\"," |
293 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}", | 293 "\"script\":\"test-lib\",\"tokenPos\":5}}", |
294 handler.msg()); | 294 handler.msg()); |
295 | 295 |
296 // Missing sub-command. | 296 // Missing sub-command. |
297 service_msg = Eval(lib, "[port, ['debug'], [], []]"); | 297 service_msg = Eval(lib, "[port, ['debug'], [], []]"); |
298 Service::HandleIsolateMessage(isolate, service_msg); | 298 Service::HandleIsolateMessage(isolate, service_msg); |
299 handler.HandleNextMessage(); | 299 handler.HandleNextMessage(); |
300 EXPECT_STREQ( | 300 EXPECT_STREQ( |
301 "{\"type\":\"Error\",\"id\":\"\"," | 301 "{\"type\":\"Error\",\"id\":\"\"," |
302 "\"message\":\"Must specify a subcommand\"," | 302 "\"message\":\"Must specify a subcommand\"," |
303 "\"request\":{\"arguments\":[\"debug\"],\"option_keys\":[]," | 303 "\"request\":{\"arguments\":[\"debug\"],\"option_keys\":[]," |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 599 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
600 | 600 |
601 Instance& service_msg = Instance::Handle(); | 601 Instance& service_msg = Instance::Handle(); |
602 | 602 |
603 // Request library. | 603 // Request library. |
604 service_msg = EvalF(h_lib, | 604 service_msg = EvalF(h_lib, |
605 "[port, ['libraries', '%" Pd "'], [], []]", lib_id); | 605 "[port, ['libraries', '%" Pd "'], [], []]", lib_id); |
606 Service::HandleIsolateMessage(isolate, service_msg); | 606 Service::HandleIsolateMessage(isolate, service_msg); |
607 handler.HandleNextMessage(); | 607 handler.HandleNextMessage(); |
608 EXPECT_SUBSTRING("\"type\":\"Library\"", handler.msg()); | 608 EXPECT_SUBSTRING("\"type\":\"Library\"", handler.msg()); |
609 EXPECT_SUBSTRING("\"url\":\"dart:test-lib\"", handler.msg()); | 609 EXPECT_SUBSTRING("\"url\":\"test-lib\"", handler.msg()); |
610 | 610 |
611 // Evaluate an expression from a library. | 611 // Evaluate an expression from a library. |
612 service_msg = EvalF(h_lib, | 612 service_msg = EvalF(h_lib, |
613 "[port, ['libraries', '%" Pd "', 'eval'], " | 613 "[port, ['libraries', '%" Pd "', 'eval'], " |
614 "['expr'], ['libVar - 1']]", lib_id); | 614 "['expr'], ['libVar - 1']]", lib_id); |
615 Service::HandleIsolateMessage(isolate, service_msg); | 615 Service::HandleIsolateMessage(isolate, service_msg); |
616 handler.HandleNextMessage(); | 616 handler.HandleNextMessage(); |
617 handler.filterMsg("name"); | 617 handler.filterMsg("name"); |
618 EXPECT_STREQ( | 618 EXPECT_STREQ( |
619 "{\"type\":\"@Smi\"," | 619 "{\"type\":\"@Smi\"," |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 EXPECT_VALID(h_lib); | 1051 EXPECT_VALID(h_lib); |
1052 | 1052 |
1053 // Build a mock message handler and wrap it in a dart port. | 1053 // Build a mock message handler and wrap it in a dart port. |
1054 ServiceTestMessageHandler handler; | 1054 ServiceTestMessageHandler handler; |
1055 Dart_Port port_id = PortMap::CreatePort(&handler); | 1055 Dart_Port port_id = PortMap::CreatePort(&handler); |
1056 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1056 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1057 EXPECT_VALID(port); | 1057 EXPECT_VALID(port); |
1058 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1058 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1059 | 1059 |
1060 Instance& service_msg = Instance::Handle(); | 1060 Instance& service_msg = Instance::Handle(); |
1061 service_msg = Eval(h_lib, "[port, ['scripts', 'dart:test-lib'], [], []]"); | 1061 service_msg = Eval(h_lib, "[port, ['scripts', 'test-lib'], [], []]"); |
1062 Service::HandleIsolateMessage(isolate, service_msg); | 1062 Service::HandleIsolateMessage(isolate, service_msg); |
1063 handler.HandleNextMessage(); | 1063 handler.HandleNextMessage(); |
1064 EXPECT_STREQ( | 1064 EXPECT_STREQ( |
1065 "{\"type\":\"Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," | 1065 "{\"type\":\"Script\",\"id\":\"scripts\\/test-lib\"," |
1066 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\"," | 1066 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1067 "\"kind\":\"script\"," | 1067 "\"kind\":\"script\"," |
1068 "\"source\":\"var port;\\n\\nmain() {\\n}\"," | 1068 "\"source\":\"var port;\\n\\nmain() {\\n}\"," |
1069 "\"tokenPosTable\":[[1,0,1,1,5,2,9],[3,5,1,6,5,7,6,8,8],[4,10,1]]}", | 1069 "\"tokenPosTable\":[[1,0,1,1,5,2,9],[3,5,1,6,5,7,6,8,8],[4,10,1]]}", |
1070 handler.msg()); | 1070 handler.msg()); |
1071 } | 1071 } |
1072 | 1072 |
1073 | 1073 |
1074 // TODO(zra): Remove when tests are ready to enable. | 1074 // TODO(zra): Remove when tests are ready to enable. |
1075 #if !defined(TARGET_ARCH_ARM64) | 1075 #if !defined(TARGET_ARCH_ARM64) |
1076 | 1076 |
(...skipping 21 matching lines...) Expand all Loading... |
1098 Dart_Port port_id = PortMap::CreatePort(&handler); | 1098 Dart_Port port_id = PortMap::CreatePort(&handler); |
1099 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1099 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1100 EXPECT_VALID(port); | 1100 EXPECT_VALID(port); |
1101 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1101 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1102 | 1102 |
1103 Instance& service_msg = Instance::Handle(); | 1103 Instance& service_msg = Instance::Handle(); |
1104 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]"); | 1104 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]"); |
1105 Service::HandleIsolateMessage(isolate, service_msg); | 1105 Service::HandleIsolateMessage(isolate, service_msg); |
1106 handler.HandleNextMessage(); | 1106 handler.HandleNextMessage(); |
1107 EXPECT_SUBSTRING( | 1107 EXPECT_SUBSTRING( |
1108 "{\"source\":\"dart:test-lib\",\"script\":{" | 1108 "{\"source\":\"test-lib\",\"script\":{" |
1109 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," | 1109 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," |
1110 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\"," | 1110 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1111 "\"kind\":\"script\"},\"hits\":" | 1111 "\"kind\":\"script\"},\"hits\":" |
1112 "[5,1,6,1]}", handler.msg()); | 1112 "[5,1,6,1]}", handler.msg()); |
1113 } | 1113 } |
1114 | 1114 |
1115 #endif | 1115 #endif |
1116 | 1116 |
1117 | 1117 |
1118 TEST_CASE(Service_AllocationProfile) { | 1118 TEST_CASE(Service_AllocationProfile) { |
1119 const char* kScript = | 1119 const char* kScript = |
1120 "var port;\n" // Set to our mock port by C++. | 1120 "var port;\n" // Set to our mock port by C++. |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); | 1405 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); |
1406 Service::HandleIsolateMessage(isolate, service_msg); | 1406 Service::HandleIsolateMessage(isolate, service_msg); |
1407 handler.HandleNextMessage(); | 1407 handler.HandleNextMessage(); |
1408 // Expect error. | 1408 // Expect error. |
1409 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1409 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1410 } | 1410 } |
1411 | 1411 |
1412 #endif // !defined(TARGET_ARCH_ARM64) | 1412 #endif // !defined(TARGET_ARCH_ARM64) |
1413 | 1413 |
1414 } // namespace dart | 1414 } // namespace dart |
OLD | NEW |