| OLD | NEW |
| 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 "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| 11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
| 12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
| 13 #include "vm/deopt_instructions.h" | 13 #include "vm/deopt_instructions.h" |
| 14 #include "vm/flags.h" | 14 #include "vm/flags.h" |
| 15 #include "vm/globals.h" | 15 #include "vm/globals.h" |
| 16 #include "vm/longjump.h" | 16 #include "vm/longjump.h" |
| 17 #include "vm/json_stream.h" |
| 17 #include "vm/object.h" | 18 #include "vm/object.h" |
| 18 #include "vm/object_store.h" | 19 #include "vm/object_store.h" |
| 19 #include "vm/os.h" | 20 #include "vm/os.h" |
| 20 #include "vm/port.h" | 21 #include "vm/port.h" |
| 21 #include "vm/stack_frame.h" | 22 #include "vm/stack_frame.h" |
| 22 #include "vm/stub_code.h" | 23 #include "vm/stub_code.h" |
| 23 #include "vm/symbols.h" | 24 #include "vm/symbols.h" |
| 24 #include "vm/visitor.h" | 25 #include "vm/visitor.h" |
| 25 | 26 |
| 26 | 27 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 78 |
| 78 RawScript* SourceBreakpoint::SourceCode() { | 79 RawScript* SourceBreakpoint::SourceCode() { |
| 79 const Function& func = Function::Handle(function_); | 80 const Function& func = Function::Handle(function_); |
| 80 return func.script(); | 81 return func.script(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 | 84 |
| 84 void SourceBreakpoint::GetCodeLocation( | 85 void SourceBreakpoint::GetCodeLocation( |
| 85 Library* lib, | 86 Library* lib, |
| 86 Script* script, | 87 Script* script, |
| 87 intptr_t* pos) { | 88 intptr_t* pos) const { |
| 88 const Function& func = Function::Handle(function_); | 89 const Function& func = Function::Handle(function_); |
| 89 const Class& cls = Class::Handle(func.origin()); | 90 const Class& cls = Class::Handle(func.origin()); |
| 90 *lib = cls.library(); | 91 *lib = cls.library(); |
| 91 *script = func.script(); | 92 *script = func.script(); |
| 92 *pos = token_pos(); | 93 *pos = token_pos(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 | 96 |
| 96 RawString* SourceBreakpoint::SourceUrl() { | 97 RawString* SourceBreakpoint::SourceUrl() { |
| 97 const Script& script = Script::Handle(SourceCode()); | 98 const Script& script = Script::Handle(SourceCode()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 112 void SourceBreakpoint::set_function(const Function& func) { | 113 void SourceBreakpoint::set_function(const Function& func) { |
| 113 function_ = func.raw(); | 114 function_ = func.raw(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 | 117 |
| 117 void SourceBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 118 void SourceBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 118 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); | 119 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); |
| 119 } | 120 } |
| 120 | 121 |
| 121 | 122 |
| 123 void SourceBreakpoint::PrintToJSONStream(JSONStream* stream) const { |
| 124 Isolate* isolate = Isolate::Current(); |
| 125 |
| 126 JSONObject jsobj(stream); |
| 127 jsobj.AddProperty("type", "Breakpoint"); |
| 128 |
| 129 jsobj.AddProperty("id", id()); |
| 130 jsobj.AddProperty("enabled", IsEnabled()); |
| 131 |
| 132 const Function& func = Function::Handle(function()); |
| 133 jsobj.AddProperty("resolved", func.HasCode()); |
| 134 |
| 135 Library& library = Library::Handle(isolate); |
| 136 Script& script = Script::Handle(isolate); |
| 137 intptr_t token_pos; |
| 138 GetCodeLocation(&library, &script, &token_pos); |
| 139 { |
| 140 JSONObject location(&jsobj, "location"); |
| 141 location.AddProperty("type", "Location"); |
| 142 location.AddProperty("libId", library.index()); |
| 143 |
| 144 const String& url = String::Handle(script.url()); |
| 145 location.AddProperty("script", url.ToCString()); |
| 146 location.AddProperty("tokenPos", token_pos); |
| 147 } |
| 148 } |
| 149 |
| 122 | 150 |
| 123 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 151 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 124 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); | 152 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); |
| 125 } | 153 } |
| 126 | 154 |
| 155 |
| 127 ActivationFrame::ActivationFrame( | 156 ActivationFrame::ActivationFrame( |
| 128 uword pc, | 157 uword pc, |
| 129 uword fp, | 158 uword fp, |
| 130 uword sp, | 159 uword sp, |
| 131 const Code& code, | 160 const Code& code, |
| 132 const Array& deopt_frame, | 161 const Array& deopt_frame, |
| 133 intptr_t deopt_frame_offset) | 162 intptr_t deopt_frame_offset) |
| 134 : pc_(pc), fp_(fp), sp_(sp), | 163 : pc_(pc), fp_(fp), sp_(sp), |
| 135 ctx_(Context::ZoneHandle()), | 164 ctx_(Context::ZoneHandle()), |
| 136 code_(Code::ZoneHandle(code.raw())), | 165 code_(Code::ZoneHandle(code.raw())), |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 while (cbpt != NULL) { | 241 while (cbpt != NULL) { |
| 213 if (func.raw() == cbpt->function()) { | 242 if (func.raw() == cbpt->function()) { |
| 214 return true; | 243 return true; |
| 215 } | 244 } |
| 216 cbpt = cbpt->next_; | 245 cbpt = cbpt->next_; |
| 217 } | 246 } |
| 218 return false; | 247 return false; |
| 219 } | 248 } |
| 220 | 249 |
| 221 | 250 |
| 251 void Debugger::PrintBreakpointsToJSONArray(JSONArray* jsarr) const { |
| 252 SourceBreakpoint* sbpt = src_breakpoints_; |
| 253 while (sbpt != NULL) { |
| 254 jsarr->AddValue(sbpt); |
| 255 sbpt = sbpt->next_; |
| 256 } |
| 257 } |
| 258 |
| 259 |
| 222 RawString* ActivationFrame::QualifiedFunctionName() { | 260 RawString* ActivationFrame::QualifiedFunctionName() { |
| 223 return String::New(Debugger::QualifiedFunctionName(function())); | 261 return String::New(Debugger::QualifiedFunctionName(function())); |
| 224 } | 262 } |
| 225 | 263 |
| 226 | 264 |
| 227 RawString* ActivationFrame::SourceUrl() { | 265 RawString* ActivationFrame::SourceUrl() { |
| 228 const Script& script = Script::Handle(SourceScript()); | 266 const Script& script = Script::Handle(SourceScript()); |
| 229 return script.url(); | 267 return script.url(); |
| 230 } | 268 } |
| 231 | 269 |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 SourceBreakpoint* Debugger::SetBreakpointAtEntry( | 1477 SourceBreakpoint* Debugger::SetBreakpointAtEntry( |
| 1440 const Function& target_function) { | 1478 const Function& target_function) { |
| 1441 ASSERT(!target_function.IsNull()); | 1479 ASSERT(!target_function.IsNull()); |
| 1442 return SetBreakpoint(target_function, | 1480 return SetBreakpoint(target_function, |
| 1443 target_function.token_pos(), | 1481 target_function.token_pos(), |
| 1444 target_function.end_token_pos()); | 1482 target_function.end_token_pos()); |
| 1445 } | 1483 } |
| 1446 | 1484 |
| 1447 | 1485 |
| 1448 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, | 1486 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, |
| 1449 intptr_t line_number) { | 1487 intptr_t line_number) { |
| 1450 Library& lib = Library::Handle(isolate_); | 1488 Library& lib = Library::Handle(isolate_); |
| 1451 Script& script = Script::Handle(isolate_); | 1489 Script& script = Script::Handle(isolate_); |
| 1452 const GrowableObjectArray& libs = | 1490 const GrowableObjectArray& libs = |
| 1453 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); | 1491 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); |
| 1454 for (intptr_t i = 0; i < libs.Length(); i++) { | 1492 for (intptr_t i = 0; i < libs.Length(); i++) { |
| 1455 lib ^= libs.At(i); | 1493 lib ^= libs.At(i); |
| 1456 script = lib.LookupScript(script_url); | 1494 script = lib.LookupScript(script_url); |
| 1457 if (!script.IsNull()) { | 1495 if (!script.IsNull()) { |
| 1458 break; | 1496 break; |
| 1459 } | 1497 } |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 } | 2134 } |
| 2097 | 2135 |
| 2098 | 2136 |
| 2099 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2137 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 2100 ASSERT(bpt->next() == NULL); | 2138 ASSERT(bpt->next() == NULL); |
| 2101 bpt->set_next(code_breakpoints_); | 2139 bpt->set_next(code_breakpoints_); |
| 2102 code_breakpoints_ = bpt; | 2140 code_breakpoints_ = bpt; |
| 2103 } | 2141 } |
| 2104 | 2142 |
| 2105 } // namespace dart | 2143 } // namespace dart |
| OLD | NEW |