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 "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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 863 if (lowest_pc_index >= 0) { | 863 if (lowest_pc_index >= 0) { |
| 864 // 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 |
| 865 // has the lowest execution address. This is the first possible | 865 // has the lowest execution address. This is the first possible |
| 866 // breakpoint on the line. We use this instead of the nearest | 866 // breakpoint on the line. We use this instead of the nearest |
| 867 // PC descriptor measured in token index distance. | 867 // PC descriptor measured in token index distance. |
| 868 best_fit_index = lowest_pc_index; | 868 best_fit_index = lowest_pc_index; |
| 869 } | 869 } |
| 870 if (best_fit_index >= 0) { | 870 if (best_fit_index >= 0) { |
| 871 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(best_fit_index)); | 871 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(best_fit_index)); |
| 872 // 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. |
| 873 // If we find an existing breakpoint, it must be an internal one which | |
| 874 // is used for stepping, or one that was left over from previously | |
| 875 // deleting a source breakpoint. Make sure it's enabled. | |
| 876 if (bpt != NULL) { | 873 if (bpt != NULL) { |
|
siva
2012/07/30 22:17:15
Why is it not necessary to ensure that the breakpo
hausner
2012/07/30 22:36:57
Because the caller will make sure it gets enabled
| |
| 877 ASSERT(bpt->src_bpt() == NULL); | |
| 878 bpt->Enable(); | |
| 879 return bpt; | 874 return bpt; |
| 880 } | 875 } |
| 881 | 876 |
| 882 bpt = new CodeBreakpoint(func, best_fit_index); | 877 bpt = new CodeBreakpoint(func, best_fit_index); |
| 883 if (verbose) { | 878 if (verbose) { |
| 884 OS::Print("Setting breakpoint in function '%s' (%s:%d) (PC %p)\n", | 879 OS::Print("Setting breakpoint in function '%s' (%s:%d) (PC %p)\n", |
| 885 String::Handle(func.name()).ToCString(), | 880 String::Handle(func.name()).ToCString(), |
| 886 String::Handle(bpt->SourceUrl()).ToCString(), | 881 String::Handle(bpt->SourceUrl()).ToCString(), |
| 887 bpt->LineNumber(), | 882 bpt->LineNumber(), |
| 888 bpt->pc()); | 883 bpt->pc()); |
| 889 } | 884 } |
| 890 RegisterCodeBreakpoint(bpt); | 885 RegisterCodeBreakpoint(bpt); |
| 891 return bpt; | 886 return bpt; |
| 892 } | 887 } |
| 893 return NULL; | 888 return NULL; |
| 894 } | 889 } |
| 895 | 890 |
| 896 | 891 |
| 897 SourceBreakpoint* Debugger::SetBreakpoint(const Function& target_function, | 892 SourceBreakpoint* Debugger::SetBreakpoint(const Function& target_function, |
| 898 intptr_t first_token_pos, | 893 intptr_t first_token_pos, |
| 899 intptr_t last_token_pos) { | 894 intptr_t last_token_pos) { |
| 900 if ((last_token_pos < target_function.token_pos()) || | 895 if ((last_token_pos < target_function.token_pos()) || |
| 901 (target_function.end_token_pos() < first_token_pos)) { | 896 (target_function.end_token_pos() < first_token_pos)) { |
| 902 // The given token position is not within the target function. | 897 // The given token position is not within the target function. |
| 903 return NULL; | 898 return NULL; |
| 904 } | 899 } |
| 905 EnsureFunctionIsDeoptimized(target_function); | 900 EnsureFunctionIsDeoptimized(target_function); |
| 906 SourceBreakpoint* bpt = GetSourceBreakpoint(target_function, first_token_pos); | 901 |
| 907 if (bpt != NULL) { | 902 CodeBreakpoint* cbpt = NULL; |
| 908 // A breakpoint for this location already exists, return it. | 903 SourceBreakpoint* bpt = NULL; |
| 909 return bpt; | 904 if (target_function.HasCode()) { |
| 905 cbpt = MakeCodeBreakpoint(target_function, first_token_pos, last_token_pos); | |
| 906 if (cbpt != NULL) { | |
| 907 if (cbpt->src_bpt() != NULL) { | |
| 908 // There is already a source breakpoint for the location. | |
| 909 ASSERT(cbpt->src_bpt() == | |
| 910 GetSourceBreakpoint(target_function, cbpt->token_pos())); | |
| 911 return cbpt->src_bpt(); | |
| 912 } | |
| 913 // No source breakpoint exists yet that is associated with the code | |
| 914 // breakpoint we found. (This is an internal breakpoint.) Adjust | |
| 915 // the breakpoint location to the actual position where breakpoint | |
| 916 // got set. | |
| 917 first_token_pos = cbpt->token_pos(); | |
| 918 } | |
| 919 } else { | |
| 920 bpt = GetSourceBreakpoint(target_function, first_token_pos); | |
| 921 if (bpt != NULL) { | |
| 922 // A source breakpoint for this uncompiled location already | |
| 923 // exists. | |
| 924 return bpt; | |
| 925 } | |
| 910 } | 926 } |
| 911 bpt = new SourceBreakpoint(nextId(), target_function, first_token_pos); | 927 bpt = new SourceBreakpoint(nextId(), target_function, first_token_pos); |
| 912 RegisterSourceBreakpoint(bpt); | 928 RegisterSourceBreakpoint(bpt); |
| 913 if (verbose && !target_function.HasCode()) { | 929 if (verbose && !target_function.HasCode()) { |
| 914 OS::Print("Registering breakpoint for " | 930 OS::Print("Registering breakpoint for " |
| 915 "uncompiled function '%s' at line %d\n", | 931 "uncompiled function '%s' at line %d\n", |
| 916 target_function.ToFullyQualifiedCString(), | 932 target_function.ToFullyQualifiedCString(), |
| 917 bpt->LineNumber()); | 933 bpt->LineNumber()); |
| 918 } | 934 } |
| 919 | 935 |
| 920 if (target_function.HasCode()) { | 936 if (cbpt != NULL) { |
| 921 CodeBreakpoint* cbpt = | 937 ASSERT(cbpt->src_bpt() == NULL); |
| 922 MakeCodeBreakpoint(target_function, first_token_pos, last_token_pos); | 938 cbpt->set_src_bpt(bpt); |
| 923 if (cbpt != NULL) { | 939 SignalBpResolved(bpt); |
| 924 ASSERT(cbpt->src_bpt() == NULL); | 940 } else { |
| 925 cbpt->set_src_bpt(bpt); | 941 if (verbose) { |
| 926 SignalBpResolved(bpt); | 942 OS::Print("Failed to set breakpoint at '%s' line %d\n", |
| 927 } else { | 943 String::Handle(bpt->SourceUrl()).ToCString(), |
| 928 if (verbose) { | 944 bpt->LineNumber()); |
| 929 OS::Print("Failed to set breakpoint at '%s' line %d\n", | |
| 930 String::Handle(bpt->SourceUrl()).ToCString(), | |
| 931 bpt->LineNumber()); | |
| 932 } | |
| 933 } | 945 } |
| 934 } | 946 } |
| 935 bpt->Enable(); | 947 bpt->Enable(); |
| 936 return bpt; | 948 return bpt; |
| 937 } | 949 } |
| 938 | 950 |
| 939 | 951 |
| 940 // Synchronize the enabled/disabled state of all code breakpoints | 952 // Synchronize the enabled/disabled state of all code breakpoints |
| 941 // associated with the source breakpoint bpt. | 953 // associated with the source breakpoint bpt. |
| 942 void Debugger::SyncBreakpoint(SourceBreakpoint* bpt) { | 954 void Debugger::SyncBreakpoint(SourceBreakpoint* bpt) { |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1558 } | 1570 } |
| 1559 | 1571 |
| 1560 | 1572 |
| 1561 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1573 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1562 ASSERT(bpt->next() == NULL); | 1574 ASSERT(bpt->next() == NULL); |
| 1563 bpt->set_next(code_breakpoints_); | 1575 bpt->set_next(code_breakpoints_); |
| 1564 code_breakpoints_ = bpt; | 1576 code_breakpoints_ = bpt; |
| 1565 } | 1577 } |
| 1566 | 1578 |
| 1567 } // namespace dart | 1579 } // namespace dart |
| OLD | NEW |