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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
6 #include "vm/dart_api_impl.h" | 6 #include "vm/dart_api_impl.h" |
7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/message_handler.h" | 10 #include "vm/message_handler.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 va_list args2; | 105 va_list args2; |
106 va_start(args2, fmt); | 106 va_start(args2, fmt); |
107 OS::VSNPrint(buffer, (len + 1), fmt, args2); | 107 OS::VSNPrint(buffer, (len + 1), fmt, args2); |
108 va_end(args2); | 108 va_end(args2); |
109 | 109 |
110 return Eval(lib, buffer); | 110 return Eval(lib, buffer); |
111 } | 111 } |
112 | 112 |
113 | 113 |
114 // Search for the formatted string in buff. | 114 // Search for the formatted string in buff. |
| 115 // |
| 116 // TODO(turnidge): This function obscures the line number of failing |
| 117 // EXPECTs. Rework this. |
115 static void ExpectSubstringF(const char* buff, const char* fmt, ...) { | 118 static void ExpectSubstringF(const char* buff, const char* fmt, ...) { |
116 Isolate* isolate = Isolate::Current(); | 119 Isolate* isolate = Isolate::Current(); |
117 | 120 |
118 va_list args; | 121 va_list args; |
119 va_start(args, fmt); | 122 va_start(args, fmt); |
120 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args); | 123 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args); |
121 va_end(args); | 124 va_end(args); |
122 | 125 |
123 char* buffer = isolate->current_zone()->Alloc<char>(len + 1); | 126 char* buffer = isolate->current_zone()->Alloc<char>(len + 1); |
124 va_list args2; | 127 va_list args2; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 "\"user_name\":\"int\"},\"preview\":\"123\"}", | 452 "\"user_name\":\"int\"},\"preview\":\"123\"}", |
450 handler.msg()); | 453 handler.msg()); |
451 | 454 |
452 // object id ring / valid | 455 // object id ring / valid |
453 service_msg = Eval(lib, "[port, ['objects', '$validId'], [], []]"); | 456 service_msg = Eval(lib, "[port, ['objects', '$validId'], [], []]"); |
454 Service::HandleIsolateMessage(isolate, service_msg); | 457 Service::HandleIsolateMessage(isolate, service_msg); |
455 handler.HandleNextMessage(); | 458 handler.HandleNextMessage(); |
456 handler.filterMsg("name"); | 459 handler.filterMsg("name"); |
457 handler.filterMsg("size"); | 460 handler.filterMsg("size"); |
458 EXPECT_STREQ( | 461 EXPECT_STREQ( |
459 "{\"type\":\"String\",\"id\":\"objects\\/1\"," | 462 "{\"type\":\"String\"," |
460 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/60\"," | 463 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/60\"," |
461 "\"user_name\":\"String\"},\"preview\":\"\\\"value\\\"\"," | 464 "\"user_name\":\"String\"},\"fields\":[]," |
462 "\"fields\":[],}", | 465 "\"id\":\"objects\\/1\",\"preview\":\"\\\"value\\\"\"}", |
463 handler.msg()); | 466 handler.msg()); |
464 | 467 |
465 // object id ring / invalid => expired | 468 // object id ring / invalid => expired |
466 service_msg = Eval(lib, "[port, ['objects', '99999999'], [], []]"); | 469 service_msg = Eval(lib, "[port, ['objects', '99999999'], [], []]"); |
467 Service::HandleIsolateMessage(isolate, service_msg); | 470 Service::HandleIsolateMessage(isolate, service_msg); |
468 handler.HandleNextMessage(); | 471 handler.HandleNextMessage(); |
469 handler.filterMsg("name"); | 472 handler.filterMsg("name"); |
470 EXPECT_STREQ( | 473 EXPECT_STREQ( |
471 "{\"type\":\"Null\",\"id\":\"objects\\/expired\"," | 474 "{\"type\":\"Null\",\"id\":\"objects\\/expired\"," |
472 "\"preview\":\"<expired>\"}", | 475 "\"preview\":\"<expired>\"}", |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 EXPECT_VALID(port); | 777 EXPECT_VALID(port); |
775 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 778 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
776 | 779 |
777 Instance& service_msg = Instance::Handle(); | 780 Instance& service_msg = Instance::Handle(); |
778 | 781 |
779 // Request the class A over the service. | 782 // Request the class A over the service. |
780 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); | 783 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); |
781 Service::HandleIsolateMessage(isolate, service_msg); | 784 Service::HandleIsolateMessage(isolate, service_msg); |
782 handler.HandleNextMessage(); | 785 handler.HandleNextMessage(); |
783 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); | 786 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); |
| 787 EXPECT_SUBSTRING("\"name\":\"A\"", handler.msg()); |
784 ExpectSubstringF(handler.msg(), | 788 ExpectSubstringF(handler.msg(), |
785 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid); | 789 "\"id\":\"classes\\/%" Pd "\"", cid); |
786 | 790 |
787 // Request canonical type 0 from class A. | 791 // Request canonical type 0 from class A. |
788 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '0']," | 792 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '0']," |
789 "[], []]", cid); | 793 "[], []]", cid); |
790 Service::HandleIsolateMessage(isolate, service_msg); | 794 Service::HandleIsolateMessage(isolate, service_msg); |
791 handler.HandleNextMessage(); | 795 handler.HandleNextMessage(); |
792 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); | 796 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); |
| 797 EXPECT_SUBSTRING("\"name\":\"A<bool>\"", handler.msg()); |
793 ExpectSubstringF(handler.msg(), | 798 ExpectSubstringF(handler.msg(), |
794 "\"id\":\"classes\\/%" Pd "\\/types\\/0\"," | 799 "\"id\":\"classes\\/%" Pd "\\/types\\/0\"", cid); |
795 "\"name\":\"A<bool>\",", cid); | |
796 | 800 |
797 // Request canonical type 1 from class A. | 801 // Request canonical type 1 from class A. |
798 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '1']," | 802 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '1']," |
799 "[], []]", cid); | 803 "[], []]", cid); |
800 Service::HandleIsolateMessage(isolate, service_msg); | 804 Service::HandleIsolateMessage(isolate, service_msg); |
801 handler.HandleNextMessage(); | 805 handler.HandleNextMessage(); |
802 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); | 806 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); |
| 807 EXPECT_SUBSTRING("\"name\":\"A<A<bool>>\"", handler.msg()); |
803 ExpectSubstringF(handler.msg(), | 808 ExpectSubstringF(handler.msg(), |
804 "\"id\":\"classes\\/%" Pd "\\/types\\/1\"," | 809 "\"id\":\"classes\\/%" Pd "\\/types\\/1\"", cid); |
805 "\"name\":\"A<A<bool>>\",", cid); | |
806 | 810 |
807 // Request for non-existent canonical type from class A. | 811 // Request for non-existent canonical type from class A. |
808 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '42']," | 812 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '42']," |
809 "[], []]", cid); | 813 "[], []]", cid); |
810 Service::HandleIsolateMessage(isolate, service_msg); | 814 Service::HandleIsolateMessage(isolate, service_msg); |
811 handler.HandleNextMessage(); | 815 handler.HandleNextMessage(); |
812 ExpectSubstringF(handler.msg(), | 816 ExpectSubstringF(handler.msg(), |
813 "{\"type\":\"Error\",\"id\":\"\"," | 817 "{\"type\":\"Error\",\"id\":\"\"," |
814 "\"message\":\"Canonical type 42 not found\"" | 818 "\"message\":\"Canonical type 42 not found\"" |
815 ",\"request\":" | 819 ",\"request\":" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); | 1287 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
1284 | 1288 |
1285 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); | 1289 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); |
1286 Service::HandleIsolateMessage(isolate, service_msg); | 1290 Service::HandleIsolateMessage(isolate, service_msg); |
1287 handler.HandleNextMessage(); | 1291 handler.HandleNextMessage(); |
1288 // Expect error. | 1292 // Expect error. |
1289 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1293 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1290 } | 1294 } |
1291 | 1295 |
1292 } // namespace dart | 1296 } // namespace dart |
OLD | NEW |