Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: runtime/bin/dbg_message.cc

Issue 23067006: Evaluate expression in context of an object (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dbg_message.h ('k') | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dbg_message.cc
===================================================================
--- runtime/bin/dbg_message.cc (revision 26326)
+++ runtime/bin/dbg_message.cc (working copy)
@@ -50,6 +50,14 @@
}
+bool MessageParser::HasParam(const char* name) const {
+ const char* params = Params();
+ ASSERT(params != NULL);
+ dart::JSONReader r(params);
+ return r.Seek(name);
+}
+
+
intptr_t MessageParser::GetIntParam(const char* name) const {
const char* params = Params();
ASSERT(params != NULL);
@@ -470,6 +478,7 @@
{ "getClassProperties", DbgMessage::HandleGetClassPropsCmd },
{ "getLibraryProperties", DbgMessage::HandleGetLibPropsCmd },
{ "setLibraryProperties", DbgMessage::HandleSetLibPropsCmd },
+ { "evaluateExpr", DbgMessage::HandleEvaluateExprCmd },
{ "getObjectProperties", DbgMessage::HandleGetObjPropsCmd },
{ "getListElements", DbgMessage::HandleGetListCmd },
{ "getGlobalVariables", DbgMessage::HandleGetGlobalsCmd },
@@ -633,6 +642,54 @@
}
+bool DbgMessage::HandleEvaluateExprCmd(DbgMessage* in_msg) {
+ ASSERT(in_msg != NULL);
+ MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
+ int msg_id = msg_parser.MessageId();
+ Dart_Handle target;
+
+ if (msg_parser.HasParam("libraryId")) {
+ in_msg->SendErrorReply(msg_id,
+ "libararyId evaluation target not supported");
+ return false;
+ } else if (msg_parser.HasParam("classId")) {
+ in_msg->SendErrorReply(msg_id,
+ "classId evaluation target not supported");
+ return false;
+ } else if (msg_parser.HasParam("objectId")) {
+ intptr_t obj_id = msg_parser.GetIntParam("objectId");
+ target = Dart_GetCachedObject(obj_id);
+ } else {
+ in_msg->SendErrorReply(msg_id, "illegal evaluation target");
+ return false;
+ }
+
+ if (Dart_IsError(target)) {
+ in_msg->SendErrorReply(msg_id, Dart_GetError(target));
+ return false;
+ }
+ char* expr_chars = msg_parser.GetStringParam("expression");
+ Dart_Handle expr = Dart_NewStringFromCString(expr_chars);
+ if (Dart_IsError(expr)) {
+ in_msg->SendErrorReply(msg_id, Dart_GetError(expr));
+ return false;
+ }
+
+ Dart_Handle value = Dart_EvaluateExpr(target, expr);
+ if (Dart_IsError(value)) {
+ in_msg->SendErrorReply(msg_id, Dart_GetError(value));
+ return false;
+ }
+
+ dart::TextBuffer msg(64);
+ msg.Printf("{\"id\":%d, \"result\":", msg_id);
+ FormatRemoteObj(&msg, value);
+ msg.Printf("}");
+ in_msg->SendReply(&msg);
+ return false;
+}
+
+
bool DbgMessage::HandleGetObjPropsCmd(DbgMessage* in_msg) {
ASSERT(in_msg != NULL);
MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
« no previous file with comments | « runtime/bin/dbg_message.h ('k') | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698