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

Unified Diff: runtime/bin/dbg_message.cc

Issue 249533003: Support evaluation of expressions in context of a stack frame (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | « no previous file | 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 35336)
+++ runtime/bin/dbg_message.cc (working copy)
@@ -690,7 +690,8 @@
ASSERT(in_msg != NULL);
MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
int msg_id = msg_parser.MessageId();
- Dart_Handle target;
+ Dart_Handle target = Dart_Null();
+ Dart_ActivationFrame frame = NULL;
if (msg_parser.HasParam("libraryId")) {
intptr_t lib_id = msg_parser.GetIntParam("libraryId");
@@ -701,15 +702,26 @@
} else if (msg_parser.HasParam("objectId")) {
intptr_t obj_id = msg_parser.GetIntParam("objectId");
target = Dart_GetCachedObject(obj_id);
+ } else if (msg_parser.HasParam("frameId")) {
+ intptr_t frame_index = msg_parser.GetIntParam("frameId");
+ Dart_Handle res;
+ Dart_StackTrace stack_trace;
+ res = Dart_GetStackTrace(&stack_trace);
+ ASSERT_NOT_ERROR(res);
+ intptr_t trace_length = 0;
+ res = Dart_StackTraceLength(stack_trace, &trace_length);
+ ASSERT_NOT_ERROR(res);
+ if (frame_index >= trace_length) {
+ in_msg->SendErrorReply(msg_id, "illegal frame index");
+ return false;
+ }
+ res = Dart_GetActivationFrame(stack_trace, frame_index, &frame);
+ ASSERT_NOT_ERROR(res);
} 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)) {
@@ -717,15 +729,24 @@
return false;
}
- Dart_Handle value = Dart_EvaluateExpr(target, expr);
- if (Dart_IsError(value)) {
- in_msg->SendErrorReply(msg_id, Dart_GetError(value));
+ Dart_Handle eval_result = Dart_Null();
+ if (frame != NULL) {
+ eval_result = Dart_ActivationFrameEvaluate(frame, expr);
+ } else {
+ if (Dart_IsError(target)) {
+ in_msg->SendErrorReply(msg_id, Dart_GetError(target));
+ return false;
+ }
+ eval_result = Dart_EvaluateExpr(target, expr);
+ }
+ if (Dart_IsError(eval_result)) {
+ in_msg->SendErrorReply(msg_id, Dart_GetError(eval_result));
return false;
}
dart::TextBuffer msg(64);
msg.Printf("{\"id\":%d, \"result\":", msg_id);
- FormatRemoteObj(&msg, value);
+ FormatRemoteObj(&msg, eval_result);
msg.Printf("}");
in_msg->SendReply(&msg);
return false;
« no previous file with comments | « no previous file | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698