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

Unified Diff: runtime/vm/debugger.cc

Issue 8992020: First part of inspecting local variables (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 2587)
+++ runtime/vm/debugger.cc (working copy)
@@ -72,7 +72,8 @@
: pc_(pc),
function_(Function::null()),
token_index_(-1),
- line_number_(-1) {
+ line_number_(-1),
+ locals_(NULL) {
}
@@ -156,9 +157,12 @@
}
-RawArray* ActivationFrame::Variables() {
- UNIMPLEMENTED();
- return NULL;
+ActiveVariables* ActivationFrame::LocalVariables() {
+ if (locals_ == NULL) {
+ const Function& func = Function::Handle(DartFunction());
+ locals_ = new ActiveVariables(func, TokenIndex());
+ }
+ return locals_;
}
@@ -191,6 +195,39 @@
}
+ActiveVariables::ActiveVariables(const Function& function, intptr_t token_pos)
+ : descriptors_(NULL),
+ desc_indices_(8) {
+ const Code& code = Code::Handle(function.code());
+ LocalVarDescriptors& var_descs =
+ LocalVarDescriptors::ZoneHandle(code.var_descriptors());
+ descriptors_ = &var_descs;
+ intptr_t desc_len = var_descs.Length();
+ for (int i = 0; i < desc_len; i++) {
+ intptr_t begin_pos, end_pos;
+ var_descs.GetRange(i, &begin_pos, &end_pos);
+ if ((begin_pos <= token_pos) && (token_pos <= end_pos)) {
+ desc_indices_.Add(i);
+ }
+ }
+}
+
+
+void ActiveVariables::VariableAt(intptr_t i,
+ String* name,
+ intptr_t* token_pos,
+ intptr_t* end_pos,
+ Instance* value) const {
+ ASSERT(i < Length());
+ ASSERT(name != NULL);
+ intptr_t desc_index = desc_indices_[i];
+ *name ^= descriptors_->GetName(desc_index);
+ descriptors_->GetRange(i, token_pos, end_pos);
+ ASSERT(value != NULL);
+ *value = Instance::null();
siva 2011/12/20 19:11:26 Do you need a TODO here stating that getting of lo
hausner 2011/12/20 21:43:55 Done. It's what I'll do in the next change.
+}
+
+
Debugger::Debugger()
: initialized_(false),
bp_handler_(NULL),
@@ -258,7 +295,7 @@
desc.PC(i), StubCode::BreakpointDynamicEntryPoint());
bpt = new Breakpoint(target_function, i);
} else if (kind == PcDescriptors::kOther) {
- if (CodePatcher::IsDartCall(desc.PC(i))) {
+ if ((desc.TokenIndex(i) > 0) && CodePatcher::IsDartCall(desc.PC(i))) {
CodePatcher::PatchStaticCallAt(
desc.PC(i), StubCode::BreakpointStaticEntryPoint());
bpt = new Breakpoint(target_function, i);
@@ -290,9 +327,20 @@
static void DefaultBreakpointHandler(Breakpoint* bpt, StackTrace* stack) {
+ String& var_name = String::Handle();
+ Instance& value = Instance::Handle();
for (intptr_t i = 0; i < stack->Length(); i++) {
+ ActivationFrame* frame = stack->ActivationFrameAt(i);
OS::Print(" %d. %s\n",
- i + 1, stack->ActivationFrameAt(i)->ToCString());
+ i + 1, frame->ToCString());
+ ActiveVariables* locals = frame->LocalVariables();
+ intptr_t num_locals = locals->Length();
+ for (intptr_t i = 0; i < num_locals; i++) {
+ intptr_t token_pos, end_pos;
+ locals->VariableAt(i, &var_name, &token_pos, &end_pos, &value);
+ OS::Print(" var %s (pos %d) = %s\n",
+ var_name.ToCString(), token_pos, value.ToCString());
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698