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 "platform/address_sanitizer.h" | 9 #include "platform/address_sanitizer.h" |
10 | 10 |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 if (code.raw() == cbpt->code_) { | 525 if (code.raw() == cbpt->code_) { |
526 return true; | 526 return true; |
527 } | 527 } |
528 cbpt = cbpt->next_; | 528 cbpt = cbpt->next_; |
529 } | 529 } |
530 return false; | 530 return false; |
531 } | 531 } |
532 | 532 |
533 | 533 |
534 void Debugger::PrintBreakpointsToJSONArray(JSONArray* jsarr) const { | 534 void Debugger::PrintBreakpointsToJSONArray(JSONArray* jsarr) const { |
535 BreakpointLocation* sbpt = breakpoint_locations_; | 535 PrintBreakpointsListToJSONArray(breakpoint_locations_, jsarr); |
| 536 PrintBreakpointsListToJSONArray(latent_locations_, jsarr); |
| 537 } |
| 538 |
| 539 |
| 540 void Debugger::PrintBreakpointsListToJSONArray(BreakpointLocation* sbpt, |
| 541 JSONArray* jsarr) const { |
536 while (sbpt != NULL) { | 542 while (sbpt != NULL) { |
537 Breakpoint* bpt = sbpt->breakpoints(); | 543 Breakpoint* bpt = sbpt->breakpoints(); |
538 while (bpt != NULL) { | 544 while (bpt != NULL) { |
539 jsarr->AddValue(bpt); | 545 jsarr->AddValue(bpt); |
540 bpt = bpt->next(); | 546 bpt = bpt->next(); |
541 } | 547 } |
542 sbpt = sbpt->next_; | 548 sbpt = sbpt->next_; |
543 } | 549 } |
544 } | 550 } |
545 | 551 |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 bpt->Disable(); | 1654 bpt->Disable(); |
1649 delete bpt; | 1655 delete bpt; |
1650 } | 1656 } |
1651 if (NeedsIsolateEvents()) { | 1657 if (NeedsIsolateEvents()) { |
1652 ServiceEvent event(isolate_, ServiceEvent::kIsolateExit); | 1658 ServiceEvent event(isolate_, ServiceEvent::kIsolateExit); |
1653 InvokeEventHandler(&event); | 1659 InvokeEventHandler(&event); |
1654 } | 1660 } |
1655 } | 1661 } |
1656 | 1662 |
1657 | 1663 |
1658 void Debugger::OnIsolateRunnable() { | 1664 void Debugger::OnIsolateRunnable() {} |
1659 } | |
1660 | 1665 |
1661 | 1666 |
1662 static RawFunction* ResolveLibraryFunction(const Library& library, | 1667 static RawFunction* ResolveLibraryFunction(const Library& library, |
1663 const String& fname) { | 1668 const String& fname) { |
1664 ASSERT(!library.IsNull()); | 1669 ASSERT(!library.IsNull()); |
1665 const Object& object = Object::Handle(library.ResolveName(fname)); | 1670 const Object& object = Object::Handle(library.ResolveName(fname)); |
1666 if (!object.IsNull() && object.IsFunction()) { | 1671 if (!object.IsNull() && object.IsFunction()) { |
1667 return Function::Cast(object).raw(); | 1672 return Function::Cast(object).raw(); |
1668 } | 1673 } |
1669 return Function::null(); | 1674 return Function::null(); |
(...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4190 return bpt->OrigStubAddress(); | 4195 return bpt->OrigStubAddress(); |
4191 } | 4196 } |
4192 UNREACHABLE(); | 4197 UNREACHABLE(); |
4193 return Code::null(); | 4198 return Code::null(); |
4194 } | 4199 } |
4195 | 4200 |
4196 | 4201 |
4197 // Remove and delete the source breakpoint bpt and its associated | 4202 // Remove and delete the source breakpoint bpt and its associated |
4198 // code breakpoints. | 4203 // code breakpoints. |
4199 void Debugger::RemoveBreakpoint(intptr_t bp_id) { | 4204 void Debugger::RemoveBreakpoint(intptr_t bp_id) { |
| 4205 if (RemoveBreakpointFromTheList(bp_id, &breakpoint_locations_)) { |
| 4206 return; |
| 4207 } |
| 4208 RemoveBreakpointFromTheList(bp_id, &latent_locations_); |
| 4209 } |
| 4210 |
| 4211 |
| 4212 // Remove and delete the source breakpoint bpt and its associated |
| 4213 // code breakpoints. Returns true, if breakpoint was found and removed, |
| 4214 // returns false, if breakpoint was not found. |
| 4215 bool Debugger::RemoveBreakpointFromTheList(intptr_t bp_id, |
| 4216 BreakpointLocation** list) { |
4200 BreakpointLocation* prev_loc = NULL; | 4217 BreakpointLocation* prev_loc = NULL; |
4201 BreakpointLocation* curr_loc = breakpoint_locations_; | 4218 BreakpointLocation* curr_loc = *list; |
4202 while (curr_loc != NULL) { | 4219 while (curr_loc != NULL) { |
4203 Breakpoint* prev_bpt = NULL; | 4220 Breakpoint* prev_bpt = NULL; |
4204 Breakpoint* curr_bpt = curr_loc->breakpoints(); | 4221 Breakpoint* curr_bpt = curr_loc->breakpoints(); |
4205 while (curr_bpt != NULL) { | 4222 while (curr_bpt != NULL) { |
4206 if (curr_bpt->id() == bp_id) { | 4223 if (curr_bpt->id() == bp_id) { |
4207 if (prev_bpt == NULL) { | 4224 if (prev_bpt == NULL) { |
4208 curr_loc->set_breakpoints(curr_bpt->next()); | 4225 curr_loc->set_breakpoints(curr_bpt->next()); |
4209 } else { | 4226 } else { |
4210 prev_bpt->set_next(curr_bpt->next()); | 4227 prev_bpt->set_next(curr_bpt->next()); |
4211 } | 4228 } |
(...skipping 11 matching lines...) Expand all Loading... |
4223 if (synthetic_async_breakpoint_ == curr_bpt) { | 4240 if (synthetic_async_breakpoint_ == curr_bpt) { |
4224 synthetic_async_breakpoint_ = NULL; | 4241 synthetic_async_breakpoint_ = NULL; |
4225 } | 4242 } |
4226 delete curr_bpt; | 4243 delete curr_bpt; |
4227 curr_bpt = NULL; | 4244 curr_bpt = NULL; |
4228 | 4245 |
4229 // Delete the breakpoint location object if there are no more | 4246 // Delete the breakpoint location object if there are no more |
4230 // breakpoints at that location. | 4247 // breakpoints at that location. |
4231 if (curr_loc->breakpoints() == NULL) { | 4248 if (curr_loc->breakpoints() == NULL) { |
4232 if (prev_loc == NULL) { | 4249 if (prev_loc == NULL) { |
4233 breakpoint_locations_ = curr_loc->next(); | 4250 *list = curr_loc->next(); |
4234 } else { | 4251 } else { |
4235 prev_loc->set_next(curr_loc->next()); | 4252 prev_loc->set_next(curr_loc->next()); |
4236 } | 4253 } |
4237 | 4254 |
4238 // Remove references from code breakpoints to this breakpoint | 4255 if (!curr_loc->IsLatent()) { |
4239 // location and disable them. | 4256 // Remove references from code breakpoints to this breakpoint |
4240 UnlinkCodeBreakpoints(curr_loc); | 4257 // location and disable them. |
| 4258 // Latent breakpoint locations won't have code breakpoints. |
| 4259 UnlinkCodeBreakpoints(curr_loc); |
| 4260 } |
4241 BreakpointLocation* next_loc = curr_loc->next(); | 4261 BreakpointLocation* next_loc = curr_loc->next(); |
4242 delete curr_loc; | 4262 delete curr_loc; |
4243 curr_loc = next_loc; | 4263 curr_loc = next_loc; |
4244 } | 4264 } |
4245 | 4265 |
4246 // The code breakpoints will be deleted when the VM resumes | 4266 // The code breakpoints will be deleted when the VM resumes |
4247 // after the pause event. | 4267 // after the pause event. |
4248 return; | 4268 return true; |
4249 } | 4269 } |
4250 | 4270 |
4251 prev_bpt = curr_bpt; | 4271 prev_bpt = curr_bpt; |
4252 curr_bpt = curr_bpt->next(); | 4272 curr_bpt = curr_bpt->next(); |
4253 } | 4273 } |
4254 prev_loc = curr_loc; | 4274 prev_loc = curr_loc; |
4255 curr_loc = curr_loc->next(); | 4275 curr_loc = curr_loc->next(); |
4256 } | 4276 } |
4257 // breakpoint with bp_id does not exist, nothing to do. | 4277 // breakpoint with bp_id does not exist, nothing to do. |
| 4278 return false; |
4258 } | 4279 } |
4259 | 4280 |
4260 | 4281 |
4261 // Unlink code breakpoints from the given breakpoint location. | 4282 // Unlink code breakpoints from the given breakpoint location. |
4262 // They will later be deleted when control returns from the pause event | 4283 // They will later be deleted when control returns from the pause event |
4263 // callback. Also, disable the breakpoint so it no longer fires if it | 4284 // callback. Also, disable the breakpoint so it no longer fires if it |
4264 // should be hit before it gets deleted. | 4285 // should be hit before it gets deleted. |
4265 void Debugger::UnlinkCodeBreakpoints(BreakpointLocation* bpt_location) { | 4286 void Debugger::UnlinkCodeBreakpoints(BreakpointLocation* bpt_location) { |
4266 ASSERT(bpt_location != NULL); | 4287 ASSERT(bpt_location != NULL); |
4267 CodeBreakpoint* curr_bpt = code_breakpoints_; | 4288 CodeBreakpoint* curr_bpt = code_breakpoints_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4310 (bpt->requested_column_number_ == requested_column)) { | 4331 (bpt->requested_column_number_ == requested_column)) { |
4311 return bpt; | 4332 return bpt; |
4312 } | 4333 } |
4313 bpt = bpt->next(); | 4334 bpt = bpt->next(); |
4314 } | 4335 } |
4315 return NULL; | 4336 return NULL; |
4316 } | 4337 } |
4317 | 4338 |
4318 | 4339 |
4319 Breakpoint* Debugger::GetBreakpointById(intptr_t id) { | 4340 Breakpoint* Debugger::GetBreakpointById(intptr_t id) { |
4320 BreakpointLocation* loc = breakpoint_locations_; | 4341 Breakpoint* bpt = GetBreakpointByIdInTheList(id, breakpoint_locations_); |
| 4342 if (bpt != NULL) { |
| 4343 return bpt; |
| 4344 } |
| 4345 return GetBreakpointByIdInTheList(id, latent_locations_); |
| 4346 } |
| 4347 |
| 4348 |
| 4349 Breakpoint* Debugger::GetBreakpointByIdInTheList(intptr_t id, |
| 4350 BreakpointLocation* list) { |
| 4351 BreakpointLocation* loc = list; |
4321 while (loc != NULL) { | 4352 while (loc != NULL) { |
4322 Breakpoint* bpt = loc->breakpoints(); | 4353 Breakpoint* bpt = loc->breakpoints(); |
4323 while (bpt != NULL) { | 4354 while (bpt != NULL) { |
4324 if (bpt->id() == id) { | 4355 if (bpt->id() == id) { |
4325 return bpt; | 4356 return bpt; |
4326 } | 4357 } |
4327 bpt = bpt->next(); | 4358 bpt = bpt->next(); |
4328 } | 4359 } |
4329 loc = loc->next(); | 4360 loc = loc->next(); |
4330 } | 4361 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4385 | 4416 |
4386 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4417 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
4387 ASSERT(bpt->next() == NULL); | 4418 ASSERT(bpt->next() == NULL); |
4388 bpt->set_next(code_breakpoints_); | 4419 bpt->set_next(code_breakpoints_); |
4389 code_breakpoints_ = bpt; | 4420 code_breakpoints_ = bpt; |
4390 } | 4421 } |
4391 | 4422 |
4392 #endif // !PRODUCT | 4423 #endif // !PRODUCT |
4393 | 4424 |
4394 } // namespace dart | 4425 } // namespace dart |
OLD | NEW |