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

Unified Diff: runtime/vm/debugger.cc

Issue 143263012: Ensure the debugger keeps a reference to code objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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/debugger.h ('k') | runtime/vm/debugger_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 31995)
+++ runtime/vm/debugger.cc (working copy)
@@ -156,7 +156,7 @@
void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) {
- visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_));
+ visitor->VisitPointer(reinterpret_cast<RawObject**>(&code_));
}
@@ -269,6 +269,18 @@
}
+bool Debugger::HasBreakpoint(const Code& code) {
+ CodeBreakpoint* cbpt = code_breakpoints_;
+ while (cbpt != NULL) {
+ if (code.raw() == cbpt->code_) {
+ return true;
+ }
+ cbpt = cbpt->next_;
+ }
+ return false;
+}
+
+
void Debugger::PrintBreakpointsToJSONArray(JSONArray* jsarr) const {
SourceBreakpoint* sbpt = src_breakpoints_;
while (sbpt != NULL) {
@@ -706,8 +718,8 @@
}
-CodeBreakpoint::CodeBreakpoint(const Function& func, intptr_t pc_desc_index)
- : function_(func.raw()),
+CodeBreakpoint::CodeBreakpoint(const Code& code, intptr_t pc_desc_index)
+ : code_(code.raw()),
pc_desc_index_(pc_desc_index),
pc_(0),
line_number_(-1),
@@ -715,9 +727,7 @@
src_bpt_(NULL),
next_(NULL) {
saved_value_ = 0;
- ASSERT(!func.HasOptimizedCode());
- Code& code = Code::Handle(func.unoptimized_code());
- ASSERT(!code.IsNull()); // Function must be compiled.
+ ASSERT(!code.IsNull());
PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
ASSERT(pc_desc_index < desc.Length());
token_pos_ = desc.TokenPos(pc_desc_index);
@@ -734,7 +744,7 @@
ASSERT(!IsEnabled());
// Poison the data so we catch use after free errors.
#ifdef DEBUG
- function_ = Function::null();
+ code_ = Code::null();
pc_ = 0ul;
src_bpt_ = NULL;
next_ = NULL;
@@ -743,8 +753,13 @@
}
+RawFunction* CodeBreakpoint::function() const {
+ return Code::Handle(code_).function();
+}
+
+
RawScript* CodeBreakpoint::SourceCode() {
- const Function& func = Function::Handle(function_);
+ const Function& func = Function::Handle(this->function());
return func.script();
}
@@ -964,10 +979,12 @@
return;
}
}
+ // Hang on to the code object before deoptimizing, in case deoptimization
+ // might cause the GC to run.
+ Code& code = Code::Handle(target_function.unoptimized_code());
+ ASSERT(!code.IsNull());
DeoptimizeWorld();
ASSERT(!target_function.HasOptimizedCode());
- Code& code = Code::Handle(target_function.unoptimized_code());
- ASSERT(!code.IsNull());
PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
for (intptr_t i = 0; i < desc.Length(); i++) {
if (IsSafePoint(desc, i)) {
@@ -978,7 +995,7 @@
bpt->Enable();
continue;
}
- bpt = new CodeBreakpoint(target_function, i);
+ bpt = new CodeBreakpoint(code, i);
RegisterCodeBreakpoint(bpt);
bpt->Enable();
}
@@ -1306,7 +1323,7 @@
CodeBreakpoint* code_bpt = GetCodeBreakpoint(desc.PC(i));
if (code_bpt == NULL) {
// No code breakpoint for this code exists; create one.
- code_bpt = new CodeBreakpoint(func, i);
+ code_bpt = new CodeBreakpoint(code, i);
RegisterCodeBreakpoint(code_bpt);
}
code_bpt->set_src_bpt(bpt);
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698