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" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 RawScript* SourceBreakpoint::SourceCode() { | 80 RawScript* SourceBreakpoint::SourceCode() { |
81 const Function& func = Function::Handle(function_); | 81 const Function& func = Function::Handle(function_); |
82 return func.script(); | 82 return func.script(); |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 void SourceBreakpoint::GetCodeLocation( | 86 void SourceBreakpoint::GetCodeLocation( |
87 Library* lib, | 87 Library* lib, |
88 Script* script, | 88 Script* script, |
89 intptr_t* pos) { | 89 intptr_t* pos) const { |
90 const Function& func = Function::Handle(function_); | 90 const Function& func = Function::Handle(function_); |
91 const Class& cls = Class::Handle(func.origin()); | 91 const Class& cls = Class::Handle(func.origin()); |
92 *lib = cls.library(); | 92 *lib = cls.library(); |
93 *script = func.script(); | 93 *script = func.script(); |
94 *pos = token_pos(); | 94 *pos = token_pos(); |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 RawString* SourceBreakpoint::SourceUrl() { | 98 RawString* SourceBreakpoint::SourceUrl() { |
99 const Script& script = Script::Handle(SourceCode()); | 99 const Script& script = Script::Handle(SourceCode()); |
(...skipping 14 matching lines...) Expand all Loading... |
114 void SourceBreakpoint::set_function(const Function& func) { | 114 void SourceBreakpoint::set_function(const Function& func) { |
115 function_ = func.raw(); | 115 function_ = func.raw(); |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 void SourceBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 119 void SourceBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
120 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); | 120 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); |
121 } | 121 } |
122 | 122 |
123 | 123 |
| 124 void SourceBreakpoint::PrintToJSONStream(JSONStream* stream) const { |
| 125 Isolate* isolate = Isolate::Current(); |
| 126 |
| 127 JSONObject jsobj(stream); |
| 128 jsobj.AddProperty("type", "Breakpoint"); |
| 129 |
| 130 jsobj.AddProperty("id", id()); |
| 131 jsobj.AddProperty("enabled", IsEnabled()); |
| 132 |
| 133 const Function& func = Function::Handle(function()); |
| 134 jsobj.AddProperty("resolved", func.HasCode()); |
| 135 |
| 136 Library& library = Library::Handle(isolate); |
| 137 Script& script = Script::Handle(isolate); |
| 138 intptr_t token_pos; |
| 139 GetCodeLocation(&library, &script, &token_pos); |
| 140 { |
| 141 JSONObject location(&jsobj, "location"); |
| 142 location.AddProperty("type", "Location"); |
| 143 location.AddProperty("libId", library.index()); |
| 144 |
| 145 const String& url = String::Handle(script.url()); |
| 146 location.AddProperty("script", url.ToCString()); |
| 147 location.AddProperty("tokenPos", token_pos); |
| 148 } |
| 149 } |
| 150 |
124 | 151 |
125 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 152 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
126 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); | 153 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); |
127 } | 154 } |
128 | 155 |
| 156 |
129 ActivationFrame::ActivationFrame( | 157 ActivationFrame::ActivationFrame( |
130 uword pc, | 158 uword pc, |
131 uword fp, | 159 uword fp, |
132 uword sp, | 160 uword sp, |
133 const Code& code, | 161 const Code& code, |
134 const Array& deopt_frame, | 162 const Array& deopt_frame, |
135 intptr_t deopt_frame_offset) | 163 intptr_t deopt_frame_offset) |
136 : pc_(pc), fp_(fp), sp_(sp), | 164 : pc_(pc), fp_(fp), sp_(sp), |
137 ctx_(Context::ZoneHandle()), | 165 ctx_(Context::ZoneHandle()), |
138 code_(Code::ZoneHandle(code.raw())), | 166 code_(Code::ZoneHandle(code.raw())), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 while (cbpt != NULL) { | 242 while (cbpt != NULL) { |
215 if (func.raw() == cbpt->function()) { | 243 if (func.raw() == cbpt->function()) { |
216 return true; | 244 return true; |
217 } | 245 } |
218 cbpt = cbpt->next_; | 246 cbpt = cbpt->next_; |
219 } | 247 } |
220 return false; | 248 return false; |
221 } | 249 } |
222 | 250 |
223 | 251 |
| 252 void Debugger::PrintBreakpointsToJSONArray(JSONArray* jsarr) const { |
| 253 SourceBreakpoint* sbpt = src_breakpoints_; |
| 254 while (sbpt != NULL) { |
| 255 jsarr->AddValue(sbpt); |
| 256 sbpt = sbpt->next_; |
| 257 } |
| 258 } |
| 259 |
| 260 |
224 RawString* ActivationFrame::QualifiedFunctionName() { | 261 RawString* ActivationFrame::QualifiedFunctionName() { |
225 return String::New(Debugger::QualifiedFunctionName(function())); | 262 return String::New(Debugger::QualifiedFunctionName(function())); |
226 } | 263 } |
227 | 264 |
228 | 265 |
229 RawString* ActivationFrame::SourceUrl() { | 266 RawString* ActivationFrame::SourceUrl() { |
230 const Script& script = Script::Handle(SourceScript()); | 267 const Script& script = Script::Handle(SourceScript()); |
231 return script.url(); | 268 return script.url(); |
232 } | 269 } |
233 | 270 |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 SourceBreakpoint* Debugger::SetBreakpointAtEntry( | 1618 SourceBreakpoint* Debugger::SetBreakpointAtEntry( |
1582 const Function& target_function) { | 1619 const Function& target_function) { |
1583 ASSERT(!target_function.IsNull()); | 1620 ASSERT(!target_function.IsNull()); |
1584 return SetBreakpoint(target_function, | 1621 return SetBreakpoint(target_function, |
1585 target_function.token_pos(), | 1622 target_function.token_pos(), |
1586 target_function.end_token_pos()); | 1623 target_function.end_token_pos()); |
1587 } | 1624 } |
1588 | 1625 |
1589 | 1626 |
1590 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, | 1627 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, |
1591 intptr_t line_number) { | 1628 intptr_t line_number) { |
1592 Library& lib = Library::Handle(isolate_); | 1629 Library& lib = Library::Handle(isolate_); |
1593 Script& script = Script::Handle(isolate_); | 1630 Script& script = Script::Handle(isolate_); |
1594 const GrowableObjectArray& libs = | 1631 const GrowableObjectArray& libs = |
1595 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); | 1632 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); |
1596 for (intptr_t i = 0; i < libs.Length(); i++) { | 1633 for (intptr_t i = 0; i < libs.Length(); i++) { |
1597 lib ^= libs.At(i); | 1634 lib ^= libs.At(i); |
1598 script = lib.LookupScript(script_url); | 1635 script = lib.LookupScript(script_url); |
1599 if (!script.IsNull()) { | 1636 if (!script.IsNull()) { |
1600 break; | 1637 break; |
1601 } | 1638 } |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2238 } | 2275 } |
2239 | 2276 |
2240 | 2277 |
2241 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2278 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2242 ASSERT(bpt->next() == NULL); | 2279 ASSERT(bpt->next() == NULL); |
2243 bpt->set_next(code_breakpoints_); | 2280 bpt->set_next(code_breakpoints_); |
2244 code_breakpoints_ = bpt; | 2281 code_breakpoints_ = bpt; |
2245 } | 2282 } |
2246 | 2283 |
2247 } // namespace dart | 2284 } // namespace dart |
OLD | NEW |