OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "bin/dbg_connection.h" | 5 #include "bin/dbg_connection.h" |
6 #include "bin/dbg_message.h" | 6 #include "bin/dbg_message.h" |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 dart::JSONReader r(buf_); | 43 dart::JSONReader r(buf_); |
44 r.Seek("params"); | 44 r.Seek("params"); |
45 if (r.Type() == dart::JSONReader::kObject) { | 45 if (r.Type() == dart::JSONReader::kObject) { |
46 return r.ValueChars(); | 46 return r.ValueChars(); |
47 } else { | 47 } else { |
48 return NULL; | 48 return NULL; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 | 52 |
| 53 bool MessageParser::HasParam(const char* name) const { |
| 54 const char* params = Params(); |
| 55 ASSERT(params != NULL); |
| 56 dart::JSONReader r(params); |
| 57 return r.Seek(name); |
| 58 } |
| 59 |
| 60 |
53 intptr_t MessageParser::GetIntParam(const char* name) const { | 61 intptr_t MessageParser::GetIntParam(const char* name) const { |
54 const char* params = Params(); | 62 const char* params = Params(); |
55 ASSERT(params != NULL); | 63 ASSERT(params != NULL); |
56 dart::JSONReader r(params); | 64 dart::JSONReader r(params); |
57 r.Seek(name); | 65 r.Seek(name); |
58 ASSERT(r.Type() == dart::JSONReader::kInteger); | 66 ASSERT(r.Type() == dart::JSONReader::kInteger); |
59 return strtol(r.ValueChars(), NULL, 10); | 67 return strtol(r.ValueChars(), NULL, 10); |
60 } | 68 } |
61 | 69 |
62 | 70 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 471 |
464 static JSONDebuggerCommand debugger_commands[] = { | 472 static JSONDebuggerCommand debugger_commands[] = { |
465 { "resume", DbgMessage::HandleResumeCmd }, | 473 { "resume", DbgMessage::HandleResumeCmd }, |
466 { "stepInto", DbgMessage::HandleStepIntoCmd }, | 474 { "stepInto", DbgMessage::HandleStepIntoCmd }, |
467 { "stepOut", DbgMessage::HandleStepOutCmd }, | 475 { "stepOut", DbgMessage::HandleStepOutCmd }, |
468 { "stepOver", DbgMessage::HandleStepOverCmd }, | 476 { "stepOver", DbgMessage::HandleStepOverCmd }, |
469 { "getLibraries", DbgMessage::HandleGetLibrariesCmd }, | 477 { "getLibraries", DbgMessage::HandleGetLibrariesCmd }, |
470 { "getClassProperties", DbgMessage::HandleGetClassPropsCmd }, | 478 { "getClassProperties", DbgMessage::HandleGetClassPropsCmd }, |
471 { "getLibraryProperties", DbgMessage::HandleGetLibPropsCmd }, | 479 { "getLibraryProperties", DbgMessage::HandleGetLibPropsCmd }, |
472 { "setLibraryProperties", DbgMessage::HandleSetLibPropsCmd }, | 480 { "setLibraryProperties", DbgMessage::HandleSetLibPropsCmd }, |
| 481 { "evaluateExpr", DbgMessage::HandleEvaluateExprCmd }, |
473 { "getObjectProperties", DbgMessage::HandleGetObjPropsCmd }, | 482 { "getObjectProperties", DbgMessage::HandleGetObjPropsCmd }, |
474 { "getListElements", DbgMessage::HandleGetListCmd }, | 483 { "getListElements", DbgMessage::HandleGetListCmd }, |
475 { "getGlobalVariables", DbgMessage::HandleGetGlobalsCmd }, | 484 { "getGlobalVariables", DbgMessage::HandleGetGlobalsCmd }, |
476 { "getScriptURLs", DbgMessage::HandleGetScriptURLsCmd }, | 485 { "getScriptURLs", DbgMessage::HandleGetScriptURLsCmd }, |
477 { "getScriptSource", DbgMessage::HandleGetSourceCmd }, | 486 { "getScriptSource", DbgMessage::HandleGetSourceCmd }, |
478 { "getLineNumberTable", DbgMessage::HandleGetLineNumbersCmd }, | 487 { "getLineNumberTable", DbgMessage::HandleGetLineNumbersCmd }, |
479 { "getStackTrace", DbgMessage::HandleGetStackTraceCmd }, | 488 { "getStackTrace", DbgMessage::HandleGetStackTraceCmd }, |
480 { "setBreakpoint", DbgMessage::HandleSetBpCmd }, | 489 { "setBreakpoint", DbgMessage::HandleSetBpCmd }, |
481 { "setPauseOnException", DbgMessage::HandlePauseOnExcCmd }, | 490 { "setPauseOnException", DbgMessage::HandlePauseOnExcCmd }, |
482 { "removeBreakpoint", DbgMessage::HandleRemBpCmd }, | 491 { "removeBreakpoint", DbgMessage::HandleRemBpCmd }, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 } | 635 } |
627 dart::TextBuffer msg(64); | 636 dart::TextBuffer msg(64); |
628 msg.Printf("{\"id\":%d, \"result\": {\"debuggingEnabled\": \"%s\"}}", | 637 msg.Printf("{\"id\":%d, \"result\": {\"debuggingEnabled\": \"%s\"}}", |
629 msg_id, | 638 msg_id, |
630 enabled ? "true" : "false"); | 639 enabled ? "true" : "false"); |
631 in_msg->SendReply(&msg); | 640 in_msg->SendReply(&msg); |
632 return false; | 641 return false; |
633 } | 642 } |
634 | 643 |
635 | 644 |
| 645 bool DbgMessage::HandleEvaluateExprCmd(DbgMessage* in_msg) { |
| 646 ASSERT(in_msg != NULL); |
| 647 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
| 648 int msg_id = msg_parser.MessageId(); |
| 649 Dart_Handle target; |
| 650 |
| 651 if (msg_parser.HasParam("libraryId")) { |
| 652 in_msg->SendErrorReply(msg_id, |
| 653 "libararyId evaluation target not supported"); |
| 654 return false; |
| 655 } else if (msg_parser.HasParam("classId")) { |
| 656 in_msg->SendErrorReply(msg_id, |
| 657 "classId evaluation target not supported"); |
| 658 return false; |
| 659 } else if (msg_parser.HasParam("objectId")) { |
| 660 intptr_t obj_id = msg_parser.GetIntParam("objectId"); |
| 661 target = Dart_GetCachedObject(obj_id); |
| 662 } else { |
| 663 in_msg->SendErrorReply(msg_id, "illegal evaluation target"); |
| 664 return false; |
| 665 } |
| 666 |
| 667 if (Dart_IsError(target)) { |
| 668 in_msg->SendErrorReply(msg_id, Dart_GetError(target)); |
| 669 return false; |
| 670 } |
| 671 char* expr_chars = msg_parser.GetStringParam("expression"); |
| 672 Dart_Handle expr = Dart_NewStringFromCString(expr_chars); |
| 673 if (Dart_IsError(expr)) { |
| 674 in_msg->SendErrorReply(msg_id, Dart_GetError(expr)); |
| 675 return false; |
| 676 } |
| 677 |
| 678 Dart_Handle value = Dart_EvaluateExpr(target, expr); |
| 679 if (Dart_IsError(value)) { |
| 680 in_msg->SendErrorReply(msg_id, Dart_GetError(value)); |
| 681 return false; |
| 682 } |
| 683 |
| 684 dart::TextBuffer msg(64); |
| 685 msg.Printf("{\"id\":%d, \"result\":", msg_id); |
| 686 FormatRemoteObj(&msg, value); |
| 687 msg.Printf("}"); |
| 688 in_msg->SendReply(&msg); |
| 689 return false; |
| 690 } |
| 691 |
| 692 |
636 bool DbgMessage::HandleGetObjPropsCmd(DbgMessage* in_msg) { | 693 bool DbgMessage::HandleGetObjPropsCmd(DbgMessage* in_msg) { |
637 ASSERT(in_msg != NULL); | 694 ASSERT(in_msg != NULL); |
638 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); | 695 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
639 int msg_id = msg_parser.MessageId(); | 696 int msg_id = msg_parser.MessageId(); |
640 intptr_t obj_id = msg_parser.GetIntParam("objectId"); | 697 intptr_t obj_id = msg_parser.GetIntParam("objectId"); |
641 Dart_Handle obj = Dart_GetCachedObject(obj_id); | 698 Dart_Handle obj = Dart_GetCachedObject(obj_id); |
642 if (Dart_IsError(obj)) { | 699 if (Dart_IsError(obj)) { |
643 in_msg->SendErrorReply(msg_id, Dart_GetError(obj)); | 700 in_msg->SendErrorReply(msg_id, Dart_GetError(obj)); |
644 return false; | 701 return false; |
645 } | 702 } |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 } else { | 1303 } else { |
1247 ASSERT(kind == kShutdown); | 1304 ASSERT(kind == kShutdown); |
1248 RemoveIsolateMsgQueue(isolate_id); | 1305 RemoveIsolateMsgQueue(isolate_id); |
1249 } | 1306 } |
1250 } | 1307 } |
1251 Dart_ExitScope(); | 1308 Dart_ExitScope(); |
1252 } | 1309 } |
1253 | 1310 |
1254 } // namespace bin | 1311 } // namespace bin |
1255 } // namespace dart | 1312 } // namespace dart |
OLD | NEW |