| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 EXPECT_STREQ( | 228 EXPECT_STREQ( |
| 229 "{\"type\":\"Error\",\"text\":\"999999 is not a valid class id.\"," | 229 "{\"type\":\"Error\",\"text\":\"999999 is not a valid class id.\"," |
| 230 "\"message\":{\"arguments\":[\"classes\",\"999999\"]," | 230 "\"message\":{\"arguments\":[\"classes\",\"999999\"]," |
| 231 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); | 231 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); |
| 232 | 232 |
| 233 // Request the class A over the service. | 233 // Request the class A over the service. |
| 234 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); | 234 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); |
| 235 Service::HandleServiceMessage(isolate, service_msg); | 235 Service::HandleServiceMessage(isolate, service_msg); |
| 236 handler.HandleNextMessage(); | 236 handler.HandleNextMessage(); |
| 237 EXPECT_STREQ( | 237 EXPECT_STREQ( |
| 238 "{\"type\":\"Class\",\"id\":\"classes\\/1009\",\"name\":\"A\"," | 238 "{\"type\":\"Class\",\"id\":\"classes\\/1010\",\"name\":\"A\"," |
| 239 "\"user_name\":\"A\",\"implemented\":false,\"abstract\":false," | 239 "\"user_name\":\"A\",\"implemented\":false,\"abstract\":false," |
| 240 "\"patch\":false,\"finalized\":true,\"const\":false,\"super\":" | 240 "\"patch\":false,\"finalized\":true,\"const\":false,\"super\":" |
| 241 "{\"type\":\"@Class\",\"id\":\"classes\\/35\",\"name\":\"Object\"," | 241 "{\"type\":\"@Class\",\"id\":\"classes\\/35\",\"name\":\"Object\"," |
| 242 "\"user_name\":\"Object\"},\"library\":{\"type\":\"@Library\",\"id\":" | 242 "\"user_name\":\"Object\"},\"library\":{\"type\":\"@Library\",\"id\":" |
| 243 "\"libraries\\/12\",\"name\":\"\",\"user_name\":\"dart:test-lib\"}," | 243 "\"libraries\\/12\",\"name\":\"\",\"user_name\":\"dart:test-lib\"}," |
| 244 "\"fields\":[{\"type\":\"@Field\",\"id\":\"classes\\/1009\\/fields\\/0\"," | 244 "\"fields\":[{\"type\":\"@Field\",\"id\":\"classes\\/1010\\/fields\\/0\"," |
| 245 "\"name\":\"a\",\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\"," | 245 "\"name\":\"a\",\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\"," |
| 246 "\"id\":\"classes\\/1009\",\"name\":\"A\",\"user_name\":\"A\"}," | 246 "\"id\":\"classes\\/1010\",\"name\":\"A\",\"user_name\":\"A\"}," |
| 247 "\"declared_type\":{\"type\":\"@Class\",\"id\":\"classes\\/106\"," | 247 "\"declared_type\":{\"type\":\"@Class\",\"id\":\"classes\\/106\"," |
| 248 "\"name\":\"dynamic\",\"user_name\":\"dynamic\"},\"static\":false," | 248 "\"name\":\"dynamic\",\"user_name\":\"dynamic\"},\"static\":false," |
| 249 "\"final\":false,\"const\":false}],\"functions\":[" | 249 "\"final\":false,\"const\":false}],\"functions\":[" |
| 250 "{\"type\":\"@Function\",\"id\":\"classes\\/1009\\/functions\\/0\"," | 250 "{\"type\":\"@Function\",\"id\":\"classes\\/1010\\/functions\\/0\"," |
| 251 "\"name\":\"get:a\",\"user_name\":\"A.a\"},{\"type\":\"@Function\"," | 251 "\"name\":\"get:a\",\"user_name\":\"A.a\"},{\"type\":\"@Function\"," |
| 252 "\"id\":\"classes\\/1009\\/functions\\/1\",\"name\":\"set:a\"," | 252 "\"id\":\"classes\\/1010\\/functions\\/1\",\"name\":\"set:a\"," |
| 253 "\"user_name\":\"A.a=\"},{\"type\":\"@Function\",\"id\":" | 253 "\"user_name\":\"A.a=\"},{\"type\":\"@Function\",\"id\":" |
| 254 "\"classes\\/1009\\/functions\\/2\",\"name\":\"b\",\"user_name\":\"A.b\"}" | 254 "\"classes\\/1010\\/functions\\/2\",\"name\":\"b\",\"user_name\":\"A.b\"}" |
| 255 ",{\"type\":\"@Function\",\"id\":\"classes\\/1009\\/functions\\/3\"," | 255 ",{\"type\":\"@Function\",\"id\":\"classes\\/1010\\/functions\\/3\"," |
| 256 "\"name\":\"c\",\"user_name\":\"A.c\"},{\"type\":\"@Function\",\"id\":" | 256 "\"name\":\"c\",\"user_name\":\"A.c\"},{\"type\":\"@Function\",\"id\":" |
| 257 "\"classes\\/1009\\/functions\\/4\",\"name\":\"A.\",\"user_name\":" | 257 "\"classes\\/1010\\/functions\\/4\",\"name\":\"A.\",\"user_name\":" |
| 258 "\"A.A\"}]}", | 258 "\"A.A\"}]}", |
| 259 handler.msg()); | 259 handler.msg()); |
| 260 | 260 |
| 261 // Request function 0 from class A. | 261 // Request function 0 from class A. |
| 262 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '0']," | 262 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '0']," |
| 263 "[], []]", cid); | 263 "[], []]", cid); |
| 264 Service::HandleServiceMessage(isolate, service_msg); | 264 Service::HandleServiceMessage(isolate, service_msg); |
| 265 handler.HandleNextMessage(); | 265 handler.HandleNextMessage(); |
| 266 EXPECT_STREQ( | 266 EXPECT_STREQ( |
| 267 "{\"type\":\"Function\",\"id\":\"classes\\/1009\\/functions\\/0\",\"name\":" | 267 "{\"type\":\"Function\",\"id\":\"classes\\/1010\\/functions\\/0\",\"name\":" |
| 268 "\"get:a\",\"user_name\":\"A.a\",\"is_static\":false,\"is_const\":false," | 268 "\"get:a\",\"user_name\":\"A.a\",\"is_static\":false,\"is_const\":false," |
| 269 "\"is_optimizable\":true,\"is_inlinable\":false,\"kind\":" | 269 "\"is_optimizable\":true,\"is_inlinable\":false,\"kind\":" |
| 270 "\"kImplicitGetter\",\"unoptimized_code\":{\"type\":\"null\"}," | 270 "\"kImplicitGetter\",\"unoptimized_code\":{\"type\":\"null\"}," |
| 271 "\"usage_counter\":0,\"optimized_call_site_count\":0,\"code\":" | 271 "\"usage_counter\":0,\"optimized_call_site_count\":0,\"code\":" |
| 272 "{\"type\":\"null\"},\"deoptimizations\":0}", handler.msg()); | 272 "{\"type\":\"null\"},\"deoptimizations\":0}", handler.msg()); |
| 273 | 273 |
| 274 // Request field 0 from class A. | 274 // Request field 0 from class A. |
| 275 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '0']," | 275 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '0']," |
| 276 "[], []]", cid); | 276 "[], []]", cid); |
| 277 Service::HandleServiceMessage(isolate, service_msg); | 277 Service::HandleServiceMessage(isolate, service_msg); |
| 278 handler.HandleNextMessage(); | 278 handler.HandleNextMessage(); |
| 279 EXPECT_STREQ( | 279 EXPECT_STREQ( |
| 280 "{\"type\":\"Field\",\"id\":\"classes\\/1009\\/fields\\/0\",\"name\":\"a\"," | 280 "{\"type\":\"Field\",\"id\":\"classes\\/1010\\/fields\\/0\",\"name\":\"a\"," |
| 281 "\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\",\"id\":" | 281 "\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\",\"id\":" |
| 282 "\"classes\\/1009\",\"name\":\"A\",\"user_name\":\"A\"},\"declared_type\":" | 282 "\"classes\\/1010\",\"name\":\"A\",\"user_name\":\"A\"},\"declared_type\":" |
| 283 "{\"type\":\"@Class\",\"id\":\"classes\\/106\",\"name\":\"dynamic\"," | 283 "{\"type\":\"@Class\",\"id\":\"classes\\/106\",\"name\":\"dynamic\"," |
| 284 "\"user_name\":\"dynamic\"},\"static\":false,\"final\":false,\"const\":" | 284 "\"user_name\":\"dynamic\"},\"static\":false,\"final\":false,\"const\":" |
| 285 "false,\"guard_nullable\":true,\"guard_class\":{\"type\":\"@Class\"," | 285 "false,\"guard_nullable\":true,\"guard_class\":{\"type\":\"@Class\"," |
| 286 "\"id\":\"classes\\/105\",\"name\":\"Null\",\"user_name\":\"Null\"}," | 286 "\"id\":\"classes\\/105\",\"name\":\"Null\",\"user_name\":\"Null\"}," |
| 287 "\"guard_length\":\"variable\"}", handler.msg()); | 287 "\"guard_length\":\"variable\"}", handler.msg()); |
| 288 | 288 |
| 289 // Invalid sub command. | 289 // Invalid sub command. |
| 290 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'huh', '0']," | 290 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'huh', '0']," |
| 291 "[], []]", cid); | 291 "[], []]", cid); |
| 292 Service::HandleServiceMessage(isolate, service_msg); | 292 Service::HandleServiceMessage(isolate, service_msg); |
| 293 handler.HandleNextMessage(); | 293 handler.HandleNextMessage(); |
| 294 EXPECT_STREQ( | 294 EXPECT_STREQ( |
| 295 "{\"type\":\"Error\",\"text\":\"Invalid sub collection huh\",\"message\":" | 295 "{\"type\":\"Error\",\"text\":\"Invalid sub collection huh\",\"message\":" |
| 296 "{\"arguments\":[\"classes\",\"1009\",\"huh\",\"0\"],\"option_keys\":[]," | 296 "{\"arguments\":[\"classes\",\"1010\",\"huh\",\"0\"],\"option_keys\":[]," |
| 297 "\"option_values\":[]}}", handler.msg()); | 297 "\"option_values\":[]}}", handler.msg()); |
| 298 | 298 |
| 299 // Invalid field request. | 299 // Invalid field request. |
| 300 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9']," | 300 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9']," |
| 301 "[], []]", cid); | 301 "[], []]", cid); |
| 302 Service::HandleServiceMessage(isolate, service_msg); | 302 Service::HandleServiceMessage(isolate, service_msg); |
| 303 handler.HandleNextMessage(); | 303 handler.HandleNextMessage(); |
| 304 EXPECT_STREQ( | 304 EXPECT_STREQ( |
| 305 "{\"type\":\"Error\",\"text\":\"Field 9 not found\"," | 305 "{\"type\":\"Error\",\"text\":\"Field 9 not found\"," |
| 306 "\"message\":{\"arguments\":[\"classes\",\"1009\",\"fields\",\"9\"]," | 306 "\"message\":{\"arguments\":[\"classes\",\"1010\",\"fields\",\"9\"]," |
| 307 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); | 307 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); |
| 308 | 308 |
| 309 // Invalid function request. | 309 // Invalid function request. |
| 310 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9']," | 310 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9']," |
| 311 "[], []]", cid); | 311 "[], []]", cid); |
| 312 Service::HandleServiceMessage(isolate, service_msg); | 312 Service::HandleServiceMessage(isolate, service_msg); |
| 313 handler.HandleNextMessage(); | 313 handler.HandleNextMessage(); |
| 314 EXPECT_STREQ( | 314 EXPECT_STREQ( |
| 315 "{\"type\":\"Error\",\"text\":\"Function 9 not found\"," | 315 "{\"type\":\"Error\",\"text\":\"Function 9 not found\"," |
| 316 "\"message\":{\"arguments\":[\"classes\",\"1009\",\"functions\",\"9\"]," | 316 "\"message\":{\"arguments\":[\"classes\",\"1010\",\"functions\",\"9\"]," |
| 317 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); | 317 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); |
| 318 | 318 |
| 319 | 319 |
| 320 // Invalid field subcommand. | 320 // Invalid field subcommand. |
| 321 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9', 'x']" | 321 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9', 'x']" |
| 322 ",[], []]", cid); | 322 ",[], []]", cid); |
| 323 Service::HandleServiceMessage(isolate, service_msg); | 323 Service::HandleServiceMessage(isolate, service_msg); |
| 324 handler.HandleNextMessage(); | 324 handler.HandleNextMessage(); |
| 325 EXPECT_STREQ( | 325 EXPECT_STREQ( |
| 326 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" | 326 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" |
| 327 "{\"arguments\":[\"classes\",\"1009\",\"fields\",\"9\",\"x\"]," | 327 "{\"arguments\":[\"classes\",\"1010\",\"fields\",\"9\",\"x\"]," |
| 328 "\"option_keys\":[],\"option_values\":[]}}", | 328 "\"option_keys\":[],\"option_values\":[]}}", |
| 329 handler.msg()); | 329 handler.msg()); |
| 330 | 330 |
| 331 // Invalid function request. | 331 // Invalid function request. |
| 332 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9'," | 332 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9'," |
| 333 "'x'], [], []]", cid); | 333 "'x'], [], []]", cid); |
| 334 Service::HandleServiceMessage(isolate, service_msg); | 334 Service::HandleServiceMessage(isolate, service_msg); |
| 335 handler.HandleNextMessage(); | 335 handler.HandleNextMessage(); |
| 336 EXPECT_STREQ( | 336 EXPECT_STREQ( |
| 337 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" | 337 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" |
| 338 "{\"arguments\":[\"classes\",\"1009\",\"functions\",\"9\",\"x\"]," | 338 "{\"arguments\":[\"classes\",\"1010\",\"functions\",\"9\",\"x\"]," |
| 339 "\"option_keys\":[],\"option_values\":[]}}", | 339 "\"option_keys\":[],\"option_values\":[]}}", |
| 340 handler.msg()); | 340 handler.msg()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 | 343 |
| 344 TEST_CASE(Service_Code) { | 344 TEST_CASE(Service_Code) { |
| 345 const char* kScript = | 345 const char* kScript = |
| 346 "var port;\n" // Set to our mock port by C++. | 346 "var port;\n" // Set to our mock port by C++. |
| 347 "\n" | 347 "\n" |
| 348 "class A {\n" | 348 "class A {\n" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 char buffer[kBufferSize]; | 454 char buffer[kBufferSize]; |
| 455 OS::SNPrint(buffer, kBufferSize-1, | 455 OS::SNPrint(buffer, kBufferSize-1, |
| 456 "{\"type\":\"Error\",\"text\":\"Could not find code at %" Px "\"," | 456 "{\"type\":\"Error\",\"text\":\"Could not find code at %" Px "\"," |
| 457 "\"message\":{\"arguments\":[\"code\",\"%" Px "\"]," | 457 "\"message\":{\"arguments\":[\"code\",\"%" Px "\"]," |
| 458 "\"option_keys\":[],\"option_values\":[]}}", address, address); | 458 "\"option_keys\":[],\"option_values\":[]}}", address, address); |
| 459 EXPECT_STREQ(buffer, handler.msg()); | 459 EXPECT_STREQ(buffer, handler.msg()); |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 } // namespace dart | 463 } // namespace dart |
| OLD | NEW |