| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 enabled ? "true" : "false"); | 683 enabled ? "true" : "false"); |
| 684 in_msg->SendReply(&msg); | 684 in_msg->SendReply(&msg); |
| 685 return false; | 685 return false; |
| 686 } | 686 } |
| 687 | 687 |
| 688 | 688 |
| 689 bool DbgMessage::HandleEvaluateExprCmd(DbgMessage* in_msg) { | 689 bool DbgMessage::HandleEvaluateExprCmd(DbgMessage* in_msg) { |
| 690 ASSERT(in_msg != NULL); | 690 ASSERT(in_msg != NULL); |
| 691 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); | 691 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
| 692 int msg_id = msg_parser.MessageId(); | 692 int msg_id = msg_parser.MessageId(); |
| 693 Dart_Handle target; | 693 Dart_Handle target = Dart_Null(); |
| 694 Dart_ActivationFrame frame = NULL; |
| 694 | 695 |
| 695 if (msg_parser.HasParam("libraryId")) { | 696 if (msg_parser.HasParam("libraryId")) { |
| 696 intptr_t lib_id = msg_parser.GetIntParam("libraryId"); | 697 intptr_t lib_id = msg_parser.GetIntParam("libraryId"); |
| 697 target = Dart_GetLibraryFromId(lib_id); | 698 target = Dart_GetLibraryFromId(lib_id); |
| 698 } else if (msg_parser.HasParam("classId")) { | 699 } else if (msg_parser.HasParam("classId")) { |
| 699 intptr_t cls_id = msg_parser.GetIntParam("classId"); | 700 intptr_t cls_id = msg_parser.GetIntParam("classId"); |
| 700 target = Dart_GetClassFromId(cls_id); | 701 target = Dart_GetClassFromId(cls_id); |
| 701 } else if (msg_parser.HasParam("objectId")) { | 702 } else if (msg_parser.HasParam("objectId")) { |
| 702 intptr_t obj_id = msg_parser.GetIntParam("objectId"); | 703 intptr_t obj_id = msg_parser.GetIntParam("objectId"); |
| 703 target = Dart_GetCachedObject(obj_id); | 704 target = Dart_GetCachedObject(obj_id); |
| 705 } else if (msg_parser.HasParam("frameId")) { |
| 706 intptr_t frame_index = msg_parser.GetIntParam("frameId"); |
| 707 Dart_Handle res; |
| 708 Dart_StackTrace stack_trace; |
| 709 res = Dart_GetStackTrace(&stack_trace); |
| 710 ASSERT_NOT_ERROR(res); |
| 711 intptr_t trace_length = 0; |
| 712 res = Dart_StackTraceLength(stack_trace, &trace_length); |
| 713 ASSERT_NOT_ERROR(res); |
| 714 if (frame_index >= trace_length) { |
| 715 in_msg->SendErrorReply(msg_id, "illegal frame index"); |
| 716 return false; |
| 717 } |
| 718 res = Dart_GetActivationFrame(stack_trace, frame_index, &frame); |
| 719 ASSERT_NOT_ERROR(res); |
| 704 } else { | 720 } else { |
| 705 in_msg->SendErrorReply(msg_id, "illegal evaluation target"); | 721 in_msg->SendErrorReply(msg_id, "illegal evaluation target"); |
| 706 return false; | 722 return false; |
| 707 } | 723 } |
| 708 | 724 |
| 709 if (Dart_IsError(target)) { | |
| 710 in_msg->SendErrorReply(msg_id, Dart_GetError(target)); | |
| 711 return false; | |
| 712 } | |
| 713 char* expr_chars = msg_parser.GetStringParam("expression"); | 725 char* expr_chars = msg_parser.GetStringParam("expression"); |
| 714 Dart_Handle expr = Dart_NewStringFromCString(expr_chars); | 726 Dart_Handle expr = Dart_NewStringFromCString(expr_chars); |
| 715 if (Dart_IsError(expr)) { | 727 if (Dart_IsError(expr)) { |
| 716 in_msg->SendErrorReply(msg_id, Dart_GetError(expr)); | 728 in_msg->SendErrorReply(msg_id, Dart_GetError(expr)); |
| 717 return false; | 729 return false; |
| 718 } | 730 } |
| 719 | 731 |
| 720 Dart_Handle value = Dart_EvaluateExpr(target, expr); | 732 Dart_Handle eval_result = Dart_Null(); |
| 721 if (Dart_IsError(value)) { | 733 if (frame != NULL) { |
| 722 in_msg->SendErrorReply(msg_id, Dart_GetError(value)); | 734 eval_result = Dart_ActivationFrameEvaluate(frame, expr); |
| 735 } else { |
| 736 if (Dart_IsError(target)) { |
| 737 in_msg->SendErrorReply(msg_id, Dart_GetError(target)); |
| 738 return false; |
| 739 } |
| 740 eval_result = Dart_EvaluateExpr(target, expr); |
| 741 } |
| 742 if (Dart_IsError(eval_result)) { |
| 743 in_msg->SendErrorReply(msg_id, Dart_GetError(eval_result)); |
| 723 return false; | 744 return false; |
| 724 } | 745 } |
| 725 | 746 |
| 726 dart::TextBuffer msg(64); | 747 dart::TextBuffer msg(64); |
| 727 msg.Printf("{\"id\":%d, \"result\":", msg_id); | 748 msg.Printf("{\"id\":%d, \"result\":", msg_id); |
| 728 FormatRemoteObj(&msg, value); | 749 FormatRemoteObj(&msg, eval_result); |
| 729 msg.Printf("}"); | 750 msg.Printf("}"); |
| 730 in_msg->SendReply(&msg); | 751 in_msg->SendReply(&msg); |
| 731 return false; | 752 return false; |
| 732 } | 753 } |
| 733 | 754 |
| 734 | 755 |
| 735 bool DbgMessage::HandleGetObjPropsCmd(DbgMessage* in_msg) { | 756 bool DbgMessage::HandleGetObjPropsCmd(DbgMessage* in_msg) { |
| 736 ASSERT(in_msg != NULL); | 757 ASSERT(in_msg != NULL); |
| 737 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); | 758 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
| 738 int msg_id = msg_parser.MessageId(); | 759 int msg_id = msg_parser.MessageId(); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 } else { | 1408 } else { |
| 1388 ASSERT(kind == kShutdown); | 1409 ASSERT(kind == kShutdown); |
| 1389 RemoveIsolateMsgQueue(isolate_id); | 1410 RemoveIsolateMsgQueue(isolate_id); |
| 1390 } | 1411 } |
| 1391 } | 1412 } |
| 1392 Dart_ExitScope(); | 1413 Dart_ExitScope(); |
| 1393 } | 1414 } |
| 1394 | 1415 |
| 1395 } // namespace bin | 1416 } // namespace bin |
| 1396 } // namespace dart | 1417 } // namespace dart |
| OLD | NEW |