Chromium Code Reviews| 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 // Remove references from code breakpoints to this breakpoint |
| 4239 // location and disable them. | 4256 // location and disable them. |
| 4240 UnlinkCodeBreakpoints(curr_loc); | 4257 UnlinkCodeBreakpoints(curr_loc); |
|
siva
2017/05/08 18:28:18
Not sure if this is an issue, latent breakpoints w
aam
2017/05/08 20:17:47
Okay, makes sense. Added a check here to UnlinkCod
| |
| 4241 BreakpointLocation* next_loc = curr_loc->next(); | 4258 BreakpointLocation* next_loc = curr_loc->next(); |
| 4242 delete curr_loc; | 4259 delete curr_loc; |
| 4243 curr_loc = next_loc; | 4260 curr_loc = next_loc; |
| 4244 } | 4261 } |
| 4245 | 4262 |
| 4246 // The code breakpoints will be deleted when the VM resumes | 4263 // The code breakpoints will be deleted when the VM resumes |
| 4247 // after the pause event. | 4264 // after the pause event. |
| 4248 return; | 4265 return true; |
| 4249 } | 4266 } |
| 4250 | 4267 |
| 4251 prev_bpt = curr_bpt; | 4268 prev_bpt = curr_bpt; |
| 4252 curr_bpt = curr_bpt->next(); | 4269 curr_bpt = curr_bpt->next(); |
| 4253 } | 4270 } |
| 4254 prev_loc = curr_loc; | 4271 prev_loc = curr_loc; |
| 4255 curr_loc = curr_loc->next(); | 4272 curr_loc = curr_loc->next(); |
| 4256 } | 4273 } |
| 4257 // breakpoint with bp_id does not exist, nothing to do. | 4274 // breakpoint with bp_id does not exist, nothing to do. |
| 4275 return false; | |
| 4258 } | 4276 } |
| 4259 | 4277 |
| 4260 | 4278 |
| 4261 // Unlink code breakpoints from the given breakpoint location. | 4279 // Unlink code breakpoints from the given breakpoint location. |
| 4262 // They will later be deleted when control returns from the pause event | 4280 // 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 | 4281 // callback. Also, disable the breakpoint so it no longer fires if it |
| 4264 // should be hit before it gets deleted. | 4282 // should be hit before it gets deleted. |
| 4265 void Debugger::UnlinkCodeBreakpoints(BreakpointLocation* bpt_location) { | 4283 void Debugger::UnlinkCodeBreakpoints(BreakpointLocation* bpt_location) { |
| 4266 ASSERT(bpt_location != NULL); | 4284 ASSERT(bpt_location != NULL); |
| 4267 CodeBreakpoint* curr_bpt = code_breakpoints_; | 4285 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)) { | 4328 (bpt->requested_column_number_ == requested_column)) { |
| 4311 return bpt; | 4329 return bpt; |
| 4312 } | 4330 } |
| 4313 bpt = bpt->next(); | 4331 bpt = bpt->next(); |
| 4314 } | 4332 } |
| 4315 return NULL; | 4333 return NULL; |
| 4316 } | 4334 } |
| 4317 | 4335 |
| 4318 | 4336 |
| 4319 Breakpoint* Debugger::GetBreakpointById(intptr_t id) { | 4337 Breakpoint* Debugger::GetBreakpointById(intptr_t id) { |
| 4320 BreakpointLocation* loc = breakpoint_locations_; | 4338 Breakpoint* bpt = GetBreakpointByIdInTheList(id, breakpoint_locations_); |
| 4339 if (bpt != NULL) { | |
| 4340 return bpt; | |
| 4341 } | |
| 4342 return GetBreakpointByIdInTheList(id, latent_locations_); | |
| 4343 } | |
| 4344 | |
| 4345 | |
| 4346 Breakpoint* Debugger::GetBreakpointByIdInTheList(intptr_t id, | |
| 4347 BreakpointLocation* list) { | |
| 4348 BreakpointLocation* loc = list; | |
| 4321 while (loc != NULL) { | 4349 while (loc != NULL) { |
| 4322 Breakpoint* bpt = loc->breakpoints(); | 4350 Breakpoint* bpt = loc->breakpoints(); |
| 4323 while (bpt != NULL) { | 4351 while (bpt != NULL) { |
| 4324 if (bpt->id() == id) { | 4352 if (bpt->id() == id) { |
| 4325 return bpt; | 4353 return bpt; |
| 4326 } | 4354 } |
| 4327 bpt = bpt->next(); | 4355 bpt = bpt->next(); |
| 4328 } | 4356 } |
| 4329 loc = loc->next(); | 4357 loc = loc->next(); |
| 4330 } | 4358 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4385 | 4413 |
| 4386 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4414 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 4387 ASSERT(bpt->next() == NULL); | 4415 ASSERT(bpt->next() == NULL); |
| 4388 bpt->set_next(code_breakpoints_); | 4416 bpt->set_next(code_breakpoints_); |
| 4389 code_breakpoints_ = bpt; | 4417 code_breakpoints_ = bpt; |
| 4390 } | 4418 } |
| 4391 | 4419 |
| 4392 #endif // !PRODUCT | 4420 #endif // !PRODUCT |
| 4393 | 4421 |
| 4394 } // namespace dart | 4422 } // namespace dart |
| OLD | NEW |