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("idNum", id()); | |
Cutch
2014/07/15 19:42:34
Is there a better name than "idNum" Also, it seems
turnidge
2014/07/15 23:37:24
Is redundant, but that lets us treat "id" as an op
| |
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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 } | 519 } |
521 | 520 |
522 | 521 |
523 void DebuggerEvent::PrintJSON(JSONStream* js) const { | 522 void DebuggerEvent::PrintJSON(JSONStream* js) const { |
524 JSONObject jsobj(js); | 523 JSONObject jsobj(js); |
525 jsobj.AddProperty("type", "ServiceEvent"); | 524 jsobj.AddProperty("type", "ServiceEvent"); |
526 // TODO(turnidge): Drop the 'id' for things like DebuggerEvent. | 525 // TODO(turnidge): Drop the 'id' for things like DebuggerEvent. |
527 jsobj.AddProperty("id", ""); | 526 jsobj.AddProperty("id", ""); |
528 jsobj.AddProperty("eventType", EventTypeToCString(type())); | 527 jsobj.AddProperty("eventType", EventTypeToCString(type())); |
529 jsobj.AddProperty("isolate", isolate()); | 528 jsobj.AddProperty("isolate", isolate()); |
530 if (type() == kBreakpointResolved || type() == kBreakpointReached) { | 529 if ((type() == kBreakpointResolved || type() == kBreakpointReached) && |
530 breakpoint() != NULL) { | |
531 jsobj.AddProperty("breakpoint", breakpoint()); | 531 jsobj.AddProperty("breakpoint", breakpoint()); |
532 } | 532 } |
533 if (type() == kExceptionThrown) { | 533 if (type() == kExceptionThrown) { |
534 jsobj.AddProperty("exception", *(exception())); | 534 jsobj.AddProperty("exception", *(exception())); |
535 } | 535 } |
536 } | 536 } |
537 | 537 |
538 | 538 |
539 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( | 539 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( |
540 const Instance& exc_obj) const { | 540 const Instance& exc_obj) const { |
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2208 } | 2208 } |
2209 } | 2209 } |
2210 } | 2210 } |
2211 | 2211 |
2212 | 2212 |
2213 // static | 2213 // static |
2214 bool Debugger::IsDebuggable(const Function& func) { | 2214 bool Debugger::IsDebuggable(const Function& func) { |
2215 if (!IsDebuggableFunctionKind(func)) { | 2215 if (!IsDebuggableFunctionKind(func)) { |
2216 return false; | 2216 return false; |
2217 } | 2217 } |
2218 if (Service::IsRunning()) { | |
2219 return true; | |
2220 } | |
2218 const Class& cls = Class::Handle(func.Owner()); | 2221 const Class& cls = Class::Handle(func.Owner()); |
2219 const Library& lib = Library::Handle(cls.library()); | 2222 const Library& lib = Library::Handle(cls.library()); |
2220 return lib.IsDebuggable(); | 2223 return lib.IsDebuggable(); |
2221 } | 2224 } |
2222 | 2225 |
2223 | 2226 |
2224 void Debugger::SignalPausedEvent(ActivationFrame* top_frame, | 2227 void Debugger::SignalPausedEvent(ActivationFrame* top_frame, |
2225 SourceBreakpoint* bpt) { | 2228 SourceBreakpoint* bpt) { |
2226 resume_action_ = kContinue; | 2229 resume_action_ = kContinue; |
2227 stepping_fp_ = 0; | 2230 stepping_fp_ = 0; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2484 void Debugger::RemoveBreakpoint(intptr_t bp_id) { | 2487 void Debugger::RemoveBreakpoint(intptr_t bp_id) { |
2485 SourceBreakpoint* prev_bpt = NULL; | 2488 SourceBreakpoint* prev_bpt = NULL; |
2486 SourceBreakpoint* curr_bpt = src_breakpoints_; | 2489 SourceBreakpoint* curr_bpt = src_breakpoints_; |
2487 while (curr_bpt != NULL) { | 2490 while (curr_bpt != NULL) { |
2488 if (curr_bpt->id() == bp_id) { | 2491 if (curr_bpt->id() == bp_id) { |
2489 if (prev_bpt == NULL) { | 2492 if (prev_bpt == NULL) { |
2490 src_breakpoints_ = src_breakpoints_->next(); | 2493 src_breakpoints_ = src_breakpoints_->next(); |
2491 } else { | 2494 } else { |
2492 prev_bpt->set_next(curr_bpt->next()); | 2495 prev_bpt->set_next(curr_bpt->next()); |
2493 } | 2496 } |
2497 | |
2494 // Remove references from code breakpoints to this source breakpoint, | 2498 // Remove references from code breakpoints to this source breakpoint, |
2495 // and disable the code breakpoints. | 2499 // and disable the code breakpoints. |
2496 UnlinkCodeBreakpoints(curr_bpt); | 2500 UnlinkCodeBreakpoints(curr_bpt); |
2497 delete curr_bpt; | 2501 delete curr_bpt; |
2502 | |
2503 // Remove references from the current debugger pause event. | |
2504 if (pause_event_->type() == DebuggerEvent::kBreakpointReached && | |
2505 pause_event_->breakpoint() == curr_bpt) { | |
2506 pause_event_->set_breakpoint(NULL); | |
2507 } | |
2498 return; | 2508 return; |
2499 } | 2509 } |
2500 prev_bpt = curr_bpt; | 2510 prev_bpt = curr_bpt; |
2501 curr_bpt = curr_bpt->next(); | 2511 curr_bpt = curr_bpt->next(); |
2502 } | 2512 } |
2503 // bpt is not a registered breakpoint, nothing to do. | 2513 // bpt is not a registered breakpoint, nothing to do. |
2504 } | 2514 } |
2505 | 2515 |
2506 | 2516 |
2507 // Turn code breakpoints associated with the given source breakpoint into | 2517 // Turn code breakpoints associated with the given source breakpoint into |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2578 } | 2588 } |
2579 | 2589 |
2580 | 2590 |
2581 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2591 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2582 ASSERT(bpt->next() == NULL); | 2592 ASSERT(bpt->next() == NULL); |
2583 bpt->set_next(code_breakpoints_); | 2593 bpt->set_next(code_breakpoints_); |
2584 code_breakpoints_ = bpt; | 2594 code_breakpoints_ = bpt; |
2585 } | 2595 } |
2586 | 2596 |
2587 } // namespace dart | 2597 } // namespace dart |
OLD | NEW |