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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); | 137 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 void SourceBreakpoint::PrintJSON(JSONStream* stream) { | 141 void SourceBreakpoint::PrintJSON(JSONStream* stream) { |
142 Isolate* isolate = Isolate::Current(); | 142 Isolate* isolate = Isolate::Current(); |
143 | 143 |
144 JSONObject jsobj(stream); | 144 JSONObject jsobj(stream); |
145 jsobj.AddProperty("type", "Breakpoint"); | 145 jsobj.AddProperty("type", "Breakpoint"); |
146 | 146 |
147 jsobj.AddProperty("id", id()); | 147 jsobj.AddPropertyF("id", "debug/breakpoints/%" Pd "", id()); |
| 148 jsobj.AddProperty("breakpointNumber", id()); |
148 jsobj.AddProperty("enabled", IsEnabled()); | 149 jsobj.AddProperty("enabled", IsEnabled()); |
149 jsobj.AddProperty("resolved", IsResolved()); | 150 jsobj.AddProperty("resolved", IsResolved()); |
150 | 151 |
151 Library& library = Library::Handle(isolate); | 152 Library& library = Library::Handle(isolate); |
152 Script& script = Script::Handle(isolate); | 153 Script& script = Script::Handle(isolate); |
153 intptr_t token_pos; | 154 intptr_t token_pos; |
154 GetCodeLocation(&library, &script, &token_pos); | 155 GetCodeLocation(&library, &script, &token_pos); |
155 { | 156 { |
156 JSONObject location(&jsobj, "location"); | 157 JSONObject location(&jsobj, "location"); |
157 location.AddProperty("type", "Location"); | 158 location.AddProperty("type", "Location"); |
158 | 159 location.AddProperty("script", script); |
159 const String& url = String::Handle(script.url()); | |
160 location.AddProperty("script", url.ToCString()); | |
161 location.AddProperty("tokenPos", token_pos); | 160 location.AddProperty("tokenPos", token_pos); |
162 } | 161 } |
163 } | 162 } |
164 | 163 |
165 | 164 |
166 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 165 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
167 visitor->VisitPointer(reinterpret_cast<RawObject**>(&code_)); | 166 visitor->VisitPointer(reinterpret_cast<RawObject**>(&code_)); |
168 } | 167 } |
169 | 168 |
170 | 169 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 521 } |
523 | 522 |
524 | 523 |
525 void DebuggerEvent::PrintJSON(JSONStream* js) const { | 524 void DebuggerEvent::PrintJSON(JSONStream* js) const { |
526 JSONObject jsobj(js); | 525 JSONObject jsobj(js); |
527 jsobj.AddProperty("type", "ServiceEvent"); | 526 jsobj.AddProperty("type", "ServiceEvent"); |
528 // TODO(turnidge): Drop the 'id' for things like DebuggerEvent. | 527 // TODO(turnidge): Drop the 'id' for things like DebuggerEvent. |
529 jsobj.AddProperty("id", ""); | 528 jsobj.AddProperty("id", ""); |
530 jsobj.AddProperty("eventType", EventTypeToCString(type())); | 529 jsobj.AddProperty("eventType", EventTypeToCString(type())); |
531 jsobj.AddProperty("isolate", isolate()); | 530 jsobj.AddProperty("isolate", isolate()); |
532 if (type() == kBreakpointResolved || type() == kBreakpointReached) { | 531 if ((type() == kBreakpointResolved || type() == kBreakpointReached) && |
| 532 breakpoint() != NULL) { |
533 jsobj.AddProperty("breakpoint", breakpoint()); | 533 jsobj.AddProperty("breakpoint", breakpoint()); |
534 } | 534 } |
535 if (type() == kExceptionThrown) { | 535 if (type() == kExceptionThrown) { |
536 jsobj.AddProperty("exception", *(exception())); | 536 jsobj.AddProperty("exception", *(exception())); |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 | 540 |
541 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( | 541 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( |
542 const Instance& exc_obj) const { | 542 const Instance& exc_obj) const { |
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 } | 2198 } |
2199 } | 2199 } |
2200 } | 2200 } |
2201 | 2201 |
2202 | 2202 |
2203 // static | 2203 // static |
2204 bool Debugger::IsDebuggable(const Function& func) { | 2204 bool Debugger::IsDebuggable(const Function& func) { |
2205 if (!IsDebuggableFunctionKind(func)) { | 2205 if (!IsDebuggableFunctionKind(func)) { |
2206 return false; | 2206 return false; |
2207 } | 2207 } |
| 2208 if (Service::IsRunning()) { |
| 2209 return true; |
| 2210 } |
2208 const Class& cls = Class::Handle(func.Owner()); | 2211 const Class& cls = Class::Handle(func.Owner()); |
2209 const Library& lib = Library::Handle(cls.library()); | 2212 const Library& lib = Library::Handle(cls.library()); |
2210 return lib.IsDebuggable(); | 2213 return lib.IsDebuggable(); |
2211 } | 2214 } |
2212 | 2215 |
2213 | 2216 |
2214 void Debugger::SignalPausedEvent(ActivationFrame* top_frame, | 2217 void Debugger::SignalPausedEvent(ActivationFrame* top_frame, |
2215 SourceBreakpoint* bpt) { | 2218 SourceBreakpoint* bpt) { |
2216 resume_action_ = kContinue; | 2219 resume_action_ = kContinue; |
2217 stepping_fp_ = 0; | 2220 stepping_fp_ = 0; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 void Debugger::RemoveBreakpoint(intptr_t bp_id) { | 2477 void Debugger::RemoveBreakpoint(intptr_t bp_id) { |
2475 SourceBreakpoint* prev_bpt = NULL; | 2478 SourceBreakpoint* prev_bpt = NULL; |
2476 SourceBreakpoint* curr_bpt = src_breakpoints_; | 2479 SourceBreakpoint* curr_bpt = src_breakpoints_; |
2477 while (curr_bpt != NULL) { | 2480 while (curr_bpt != NULL) { |
2478 if (curr_bpt->id() == bp_id) { | 2481 if (curr_bpt->id() == bp_id) { |
2479 if (prev_bpt == NULL) { | 2482 if (prev_bpt == NULL) { |
2480 src_breakpoints_ = src_breakpoints_->next(); | 2483 src_breakpoints_ = src_breakpoints_->next(); |
2481 } else { | 2484 } else { |
2482 prev_bpt->set_next(curr_bpt->next()); | 2485 prev_bpt->set_next(curr_bpt->next()); |
2483 } | 2486 } |
| 2487 |
2484 // Remove references from code breakpoints to this source breakpoint, | 2488 // Remove references from code breakpoints to this source breakpoint, |
2485 // and disable the code breakpoints. | 2489 // and disable the code breakpoints. |
2486 UnlinkCodeBreakpoints(curr_bpt); | 2490 UnlinkCodeBreakpoints(curr_bpt); |
2487 delete curr_bpt; | 2491 delete curr_bpt; |
| 2492 |
| 2493 // Remove references from the current debugger pause event. |
| 2494 if (pause_event_ != NULL && |
| 2495 pause_event_->type() == DebuggerEvent::kBreakpointReached && |
| 2496 pause_event_->breakpoint() == curr_bpt) { |
| 2497 pause_event_->set_breakpoint(NULL); |
| 2498 } |
2488 return; | 2499 return; |
2489 } | 2500 } |
2490 prev_bpt = curr_bpt; | 2501 prev_bpt = curr_bpt; |
2491 curr_bpt = curr_bpt->next(); | 2502 curr_bpt = curr_bpt->next(); |
2492 } | 2503 } |
2493 // bpt is not a registered breakpoint, nothing to do. | 2504 // bpt is not a registered breakpoint, nothing to do. |
2494 } | 2505 } |
2495 | 2506 |
2496 | 2507 |
2497 // Turn code breakpoints associated with the given source breakpoint into | 2508 // Turn code breakpoints associated with the given source breakpoint into |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 } | 2579 } |
2569 | 2580 |
2570 | 2581 |
2571 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2582 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2572 ASSERT(bpt->next() == NULL); | 2583 ASSERT(bpt->next() == NULL); |
2573 bpt->set_next(code_breakpoints_); | 2584 bpt->set_next(code_breakpoints_); |
2574 code_breakpoints_ = bpt; | 2585 code_breakpoints_ = bpt; |
2575 } | 2586 } |
2576 | 2587 |
2577 } // namespace dart | 2588 } // namespace dart |
OLD | NEW |