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

Side by Side Diff: runtime/vm/debugger.cc

Issue 10827288: - Support for patching of class methods and fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 63
64 void SourceBreakpoint::Disable() { 64 void SourceBreakpoint::Disable() {
65 is_enabled_ = false; 65 is_enabled_ = false;
66 Isolate::Current()->debugger()->SyncBreakpoint(this); 66 Isolate::Current()->debugger()->SyncBreakpoint(this);
67 } 67 }
68 68
69 69
70 RawScript* SourceBreakpoint::SourceCode() { 70 RawScript* SourceBreakpoint::SourceCode() {
71 const Function& func = Function::Handle(function_); 71 const Function& func = Function::Handle(function_);
72 const Class& cls = Class::Handle(func.owner()); 72 return func.script();
73 return cls.script();
74 } 73 }
75 74
76 75
77 RawString* SourceBreakpoint::SourceUrl() { 76 RawString* SourceBreakpoint::SourceUrl() {
78 const Script& script = Script::Handle(SourceCode()); 77 const Script& script = Script::Handle(SourceCode());
79 return script.url(); 78 return script.url();
80 } 79 }
81 80
82 81
83 intptr_t SourceBreakpoint::LineNumber() { 82 intptr_t SourceBreakpoint::LineNumber() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ASSERT(isolate != NULL); 128 ASSERT(isolate != NULL);
130 const Code& code = Code::Handle(Code::LookupCode(pc_)); 129 const Code& code = Code::Handle(Code::LookupCode(pc_));
131 function_ = code.function(); 130 function_ = code.function();
132 } 131 }
133 return function_; 132 return function_;
134 } 133 }
135 134
136 135
137 const char* Debugger::QualifiedFunctionName(const Function& func) { 136 const char* Debugger::QualifiedFunctionName(const Function& func) {
138 const String& func_name = String::Handle(func.name()); 137 const String& func_name = String::Handle(func.name());
139 Class& func_class = Class::Handle(func.owner()); 138 Class& func_class = Class::Handle(func.Owner());
140 String& class_name = String::Handle(func_class.Name()); 139 String& class_name = String::Handle(func_class.Name());
141 140
142 const char* kFormat = "%s%s%s"; 141 const char* kFormat = "%s%s%s";
143 intptr_t len = OS::SNPrint(NULL, 0, kFormat, 142 intptr_t len = OS::SNPrint(NULL, 0, kFormat,
144 func_class.IsTopLevel() ? "" : class_name.ToCString(), 143 func_class.IsTopLevel() ? "" : class_name.ToCString(),
145 func_class.IsTopLevel() ? "" : ".", 144 func_class.IsTopLevel() ? "" : ".",
146 func_name.ToCString()); 145 func_name.ToCString());
147 len++; // String terminator. 146 len++; // String terminator.
148 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 147 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
149 OS::SNPrint(chars, len, kFormat, 148 OS::SNPrint(chars, len, kFormat,
(...skipping 11 matching lines...) Expand all
161 160
162 161
163 RawString* ActivationFrame::SourceUrl() { 162 RawString* ActivationFrame::SourceUrl() {
164 const Script& script = Script::Handle(SourceScript()); 163 const Script& script = Script::Handle(SourceScript());
165 return script.url(); 164 return script.url();
166 } 165 }
167 166
168 167
169 RawScript* ActivationFrame::SourceScript() { 168 RawScript* ActivationFrame::SourceScript() {
170 const Function& func = DartFunction(); 169 const Function& func = DartFunction();
171 const Class& cls = Class::Handle(func.owner()); 170 return func.script();
172 return cls.script();
173 } 171 }
174 172
175 173
176 RawLibrary* ActivationFrame::Library() { 174 RawLibrary* ActivationFrame::Library() {
177 const Function& func = DartFunction(); 175 const Function& func = DartFunction();
178 const Class& cls = Class::Handle(func.owner()); 176 const Class& cls = Class::Handle(func.Owner());
179 return cls.library(); 177 return cls.library();
180 } 178 }
181 179
182 180
183 void ActivationFrame::GetPcDescriptors() { 181 void ActivationFrame::GetPcDescriptors() {
184 if (pc_desc_.IsNull()) { 182 if (pc_desc_.IsNull()) {
185 const Function& func = DartFunction(); 183 const Function& func = DartFunction();
186 ASSERT(!func.HasOptimizedCode()); 184 ASSERT(!func.HasOptimizedCode());
187 Code& code = Code::Handle(func.unoptimized_code()); 185 Code& code = Code::Handle(func.unoptimized_code());
188 ASSERT(!code.IsNull()); 186 ASSERT(!code.IsNull());
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 pc_ = 0ul; 479 pc_ = 0ul;
482 src_bpt_ = NULL; 480 src_bpt_ = NULL;
483 next_ = NULL; 481 next_ = NULL;
484 breakpoint_kind_ = PcDescriptors::kOther; 482 breakpoint_kind_ = PcDescriptors::kOther;
485 #endif 483 #endif
486 } 484 }
487 485
488 486
489 RawScript* CodeBreakpoint::SourceCode() { 487 RawScript* CodeBreakpoint::SourceCode() {
490 const Function& func = Function::Handle(function_); 488 const Function& func = Function::Handle(function_);
491 const Class& cls = Class::Handle(func.owner()); 489 return func.script();
492 return cls.script();
493 } 490 }
494 491
495 492
496 RawString* CodeBreakpoint::SourceUrl() { 493 RawString* CodeBreakpoint::SourceUrl() {
497 const Script& script = Script::Handle(SourceCode()); 494 const Script& script = Script::Handle(SourceCode());
498 return script.url(); 495 return script.url();
499 } 496 }
500 497
501 498
502 intptr_t CodeBreakpoint::LineNumber() { 499 intptr_t CodeBreakpoint::LineNumber() {
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } 1265 }
1269 1266
1270 1267
1271 bool Debugger::IsDebuggable(const Function& func) { 1268 bool Debugger::IsDebuggable(const Function& func) {
1272 RawFunction::Kind fkind = func.kind(); 1269 RawFunction::Kind fkind = func.kind();
1273 if ((fkind == RawFunction::kImplicitGetter) || 1270 if ((fkind == RawFunction::kImplicitGetter) ||
1274 (fkind == RawFunction::kImplicitSetter) || 1271 (fkind == RawFunction::kImplicitSetter) ||
1275 (fkind == RawFunction::kConstImplicitGetter)) { 1272 (fkind == RawFunction::kConstImplicitGetter)) {
1276 return false; 1273 return false;
1277 } 1274 }
1278 const Class& cls = Class::Handle(func.owner()); 1275 const Class& cls = Class::Handle(func.Owner());
1279 const Library& lib = Library::Handle(cls.library()); 1276 const Library& lib = Library::Handle(cls.library());
1280 return lib.IsDebuggable(); 1277 return lib.IsDebuggable();
1281 } 1278 }
1282 1279
1283 1280
1284 void Debugger::SignalBpReached() { 1281 void Debugger::SignalBpReached() {
1285 if (ignore_breakpoints_) { 1282 if (ignore_breakpoints_) {
1286 return; 1283 return;
1287 } 1284 }
1288 DebuggerStackTrace* stack_trace = CollectStackTrace(); 1285 DebuggerStackTrace* stack_trace = CollectStackTrace();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 // there are any breakpoints. The parent function is the actual method on 1416 // there are any breakpoints. The parent function is the actual method on
1420 // which the user sets breakpoints. 1417 // which the user sets breakpoints.
1421 lookup_function = func.parent_function(); 1418 lookup_function = func.parent_function();
1422 ASSERT(!lookup_function.IsNull()); 1419 ASSERT(!lookup_function.IsNull());
1423 } 1420 }
1424 SourceBreakpoint* bpt = src_breakpoints_; 1421 SourceBreakpoint* bpt = src_breakpoints_;
1425 while (bpt != NULL) { 1422 while (bpt != NULL) {
1426 if (lookup_function.raw() == bpt->function()) { 1423 if (lookup_function.raw() == bpt->function()) {
1427 // Check if the breakpoint is inside a closure or local function 1424 // Check if the breakpoint is inside a closure or local function
1428 // within the newly compiled function. 1425 // within the newly compiled function.
1429 Class& owner = Class::Handle(lookup_function.owner()); 1426 Class& owner = Class::Handle(lookup_function.Owner());
1430 Function& closure = 1427 Function& closure =
1431 Function::Handle(owner.LookupClosureFunction(bpt->token_pos())); 1428 Function::Handle(owner.LookupClosureFunction(bpt->token_pos()));
1432 if (!closure.IsNull() && (closure.raw() != lookup_function.raw())) { 1429 if (!closure.IsNull() && (closure.raw() != lookup_function.raw())) {
1433 if (verbose) { 1430 if (verbose) {
1434 OS::Print("Resetting pending breakpoint to function %s\n", 1431 OS::Print("Resetting pending breakpoint to function %s\n",
1435 closure.ToFullyQualifiedCString()); 1432 closure.ToFullyQualifiedCString());
1436 } 1433 }
1437 bpt->set_function(closure); 1434 bpt->set_function(closure);
1438 } else { 1435 } else {
1439 if (verbose) { 1436 if (verbose) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 } 1565 }
1569 1566
1570 1567
1571 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1568 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1572 ASSERT(bpt->next() == NULL); 1569 ASSERT(bpt->next() == NULL);
1573 bpt->set_next(code_breakpoints_); 1570 bpt->set_next(code_breakpoints_);
1574 code_breakpoints_ = bpt; 1571 code_breakpoints_ = bpt;
1575 } 1572 }
1576 1573
1577 } // namespace dart 1574 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/exceptions.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698