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

Unified Diff: runtime/vm/object.cc

Issue 240213004: Fixes a problem with the recovery of contexts in the debugger at closure calls. (Closed) Base URL: https://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 | « runtime/vm/object.h ('k') | runtime/vm/stack_frame.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index f81ec3dc50c8f44cb5f974af51abcae5e7e2122e..75ef075e900f3654ed98ef0effd4bfee352b8329 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -10157,6 +10157,9 @@ const char* LocalVarDescriptors::ToCString() const {
"%2" Pd " kind=%d scope=0x%04x begin=%" Pd " end=%" Pd " name=%s\n";
for (intptr_t i = 0; i < Length(); i++) {
String& var_name = String::Handle(GetName(i));
+ if (var_name.IsNull()) {
+ var_name = Symbols::Empty().raw();
+ }
RawLocalVarDescriptors::VarInfo info;
GetInfo(i, &info);
len += OS::SNPrint(NULL, 0, kFormat,
@@ -10171,6 +10174,9 @@ const char* LocalVarDescriptors::ToCString() const {
intptr_t num_chars = 0;
for (intptr_t i = 0; i < Length(); i++) {
String& var_name = String::Handle(GetName(i));
+ if (var_name.IsNull()) {
+ var_name = Symbols::Empty().raw();
+ }
RawLocalVarDescriptors::VarInfo info;
GetInfo(i, &info);
num_chars += OS::SNPrint((buffer + num_chars),
@@ -11168,22 +11174,49 @@ const char* Context::ToCString() const {
if (IsNull()) {
return "Context (Null)";
}
+ Zone* zone = Isolate::Current()->current_zone();
const Context& parent_ctx = Context::Handle(parent());
if (parent_ctx.IsNull()) {
- const char* kFormat = "Context num_variables:% " Pd "";
- intptr_t len = OS::SNPrint(NULL, 0, kFormat, num_variables()) + 1;
- char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
- OS::SNPrint(chars, len, kFormat, num_variables());
- return chars;
+ return zone->PrintToString("Context@%p num_variables:% " Pd "",
+ this->raw(), num_variables());
} else {
const char* parent_str = parent_ctx.ToCString();
- const char* kFormat = "Context num_variables:% " Pd " parent:{ %s }";
- intptr_t len = OS::SNPrint(NULL, 0, kFormat,
- num_variables(), parent_str) + 1;
- char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
- OS::SNPrint(chars, len, kFormat, num_variables(), parent_str);
- return chars;
+ return zone->PrintToString(
+ "Context@%p num_variables:% " Pd " parent:{ %s }",
+ this->raw(), num_variables(), parent_str);
+ }
+}
+
+
+static void IndentN(int count) {
+ for (int i = 0; i < count; i++) {
+ OS::PrintErr(" ");
+ }
+}
+
+
+void Context::Dump(int indent) const {
+ if (IsNull()) {
+ IndentN(indent);
+ OS::PrintErr("Context@null\n");
+ return;
+ }
+
+ IndentN(indent);
+ OS::PrintErr("Context@%p vars(%" Pd ") {\n", this->raw(), num_variables());
+ Object& obj = Object::Handle();
+ for (intptr_t i = 0; i < num_variables(); i++) {
+ IndentN(indent + 2);
+ obj = At(i);
+ OS::PrintErr("[%" Pd "] = %s\n", i, obj.ToCString());
+ }
+
+ const Context& parent_ctx = Context::Handle(parent());
+ if (!parent_ctx.IsNull()) {
+ parent_ctx.Dump(indent + 2);
}
+ IndentN(indent);
+ OS::PrintErr("}\n");
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/stack_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698