| 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 "vm/code_generator.h" | 7 #include "vm/code_generator.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 if (!target_function.HasCode()) { | 712 if (!target_function.HasCode()) { |
| 713 return; | 713 return; |
| 714 } | 714 } |
| 715 } | 715 } |
| 716 Code& code = Code::Handle(target_function.unoptimized_code()); | 716 Code& code = Code::Handle(target_function.unoptimized_code()); |
| 717 ASSERT(!code.IsNull()); | 717 ASSERT(!code.IsNull()); |
| 718 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); | 718 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); |
| 719 for (int i = 0; i < desc.Length(); i++) { | 719 for (int i = 0; i < desc.Length(); i++) { |
| 720 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(i)); | 720 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(i)); |
| 721 if (bpt != NULL) { | 721 if (bpt != NULL) { |
| 722 // There is already a breakpoint for this address. Leave it alone. | 722 // There is already a breakpoint for this address. Make sure |
| 723 // it is enabled. |
| 724 bpt->Enable(); |
| 723 continue; | 725 continue; |
| 724 } | 726 } |
| 725 PcDescriptors::Kind kind = desc.DescriptorKind(i); | 727 PcDescriptors::Kind kind = desc.DescriptorKind(i); |
| 726 if ((kind == PcDescriptors::kIcCall) || | 728 if ((kind == PcDescriptors::kIcCall) || |
| 727 (kind == PcDescriptors::kFuncCall) || | 729 (kind == PcDescriptors::kFuncCall) || |
| 728 (kind == PcDescriptors::kReturn)) { | 730 (kind == PcDescriptors::kReturn)) { |
| 729 bpt = new CodeBreakpoint(target_function, i); | 731 bpt = new CodeBreakpoint(target_function, i); |
| 730 RegisterCodeBreakpoint(bpt); | 732 RegisterCodeBreakpoint(bpt); |
| 731 bpt->Enable(); | 733 bpt->Enable(); |
| 732 } | 734 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 // We found the the pc descriptor within the given token range that | 864 // We found the the pc descriptor within the given token range that |
| 863 // has the lowest execution address. This is the first possible | 865 // has the lowest execution address. This is the first possible |
| 864 // breakpoint on the line. We use this instead of the nearest | 866 // breakpoint on the line. We use this instead of the nearest |
| 865 // PC descriptor measured in token index distance. | 867 // PC descriptor measured in token index distance. |
| 866 best_fit_index = lowest_pc_index; | 868 best_fit_index = lowest_pc_index; |
| 867 } | 869 } |
| 868 if (best_fit_index >= 0) { | 870 if (best_fit_index >= 0) { |
| 869 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(best_fit_index)); | 871 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(best_fit_index)); |
| 870 // We should only ever have one code breakpoint at the same address. | 872 // We should only ever have one code breakpoint at the same address. |
| 871 // If we find an existing breakpoint, it must be an internal one which | 873 // If we find an existing breakpoint, it must be an internal one which |
| 872 // is used for stepping. | 874 // is used for stepping, or one that was left over from previously |
| 875 // deleting a source breakpoint. Make sure it's enabled. |
| 873 if (bpt != NULL) { | 876 if (bpt != NULL) { |
| 874 ASSERT(bpt->src_bpt() == NULL); | 877 ASSERT(bpt->src_bpt() == NULL); |
| 878 bpt->Enable(); |
| 875 return bpt; | 879 return bpt; |
| 876 } | 880 } |
| 877 | 881 |
| 878 bpt = new CodeBreakpoint(func, best_fit_index); | 882 bpt = new CodeBreakpoint(func, best_fit_index); |
| 879 if (verbose) { | 883 if (verbose) { |
| 880 OS::Print("Setting breakpoint in function '%s' (%s:%d) (PC %p)\n", | 884 OS::Print("Setting breakpoint in function '%s' (%s:%d) (PC %p)\n", |
| 881 String::Handle(func.name()).ToCString(), | 885 String::Handle(func.name()).ToCString(), |
| 882 String::Handle(bpt->SourceUrl()).ToCString(), | 886 String::Handle(bpt->SourceUrl()).ToCString(), |
| 883 bpt->LineNumber(), | 887 bpt->LineNumber(), |
| 884 bpt->pc()); | 888 bpt->pc()); |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 } | 1553 } |
| 1550 | 1554 |
| 1551 | 1555 |
| 1552 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1556 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1553 ASSERT(bpt->next() == NULL); | 1557 ASSERT(bpt->next() == NULL); |
| 1554 bpt->set_next(code_breakpoints_); | 1558 bpt->set_next(code_breakpoints_); |
| 1555 code_breakpoints_ = bpt; | 1559 code_breakpoints_ = bpt; |
| 1556 } | 1560 } |
| 1557 | 1561 |
| 1558 } // namespace dart | 1562 } // namespace dart |
| OLD | NEW |