Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: runtime/vm/debugger.cc

Issue 1568353002: Don't test directly against Scanner::kNoSourcePos instead use >= 0. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 ASSERT(!code.IsNull()); 1733 ASSERT(!code.IsNull());
1734 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); 1734 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
1735 1735
1736 // First pass: find the safe point which is closest to the beginning 1736 // First pass: find the safe point which is closest to the beginning
1737 // of the given token range. 1737 // of the given token range.
1738 intptr_t best_fit_pos = INT_MAX; 1738 intptr_t best_fit_pos = INT_MAX;
1739 intptr_t best_column = INT_MAX; 1739 intptr_t best_column = INT_MAX;
1740 PcDescriptors::Iterator iter(desc, kSafepointKind); 1740 PcDescriptors::Iterator iter(desc, kSafepointKind);
1741 while (iter.MoveNext()) { 1741 while (iter.MoveNext()) {
1742 const intptr_t pos = iter.TokenPos(); 1742 const intptr_t pos = iter.TokenPos();
1743 if ((pos == Scanner::kNoSourcePos) || 1743 if ((pos < 0) ||
1744 (pos < requested_token_pos) || 1744 (pos < requested_token_pos) ||
1745 (pos > last_token_pos)) { 1745 (pos > last_token_pos)) {
1746 // Token is not in the target range. 1746 // Token is not in the target range.
1747 continue; 1747 continue;
1748 } 1748 }
1749 1749
1750 intptr_t token_start_column = -1; 1750 intptr_t token_start_column = -1;
1751 if (requested_column >= 0) { 1751 if (requested_column >= 0) {
1752 intptr_t ignored = -1; 1752 intptr_t ignored = -1;
1753 intptr_t token_len = -1; 1753 intptr_t token_len = -1;
(...skipping 25 matching lines...) Expand all
1779 // was specified) and has the lowest code address. 1779 // was specified) and has the lowest code address.
1780 if (best_fit_pos != INT_MAX) { 1780 if (best_fit_pos != INT_MAX) {
1781 const Script& script = Script::Handle(func.script()); 1781 const Script& script = Script::Handle(func.script());
1782 const TokenStream& tokens = TokenStream::Handle(script.tokens()); 1782 const TokenStream& tokens = TokenStream::Handle(script.tokens());
1783 const intptr_t begin_pos = best_fit_pos; 1783 const intptr_t begin_pos = best_fit_pos;
1784 const intptr_t end_of_line_pos = LastTokenOnLine(tokens, begin_pos); 1784 const intptr_t end_of_line_pos = LastTokenOnLine(tokens, begin_pos);
1785 uword lowest_pc_offset = kUwordMax; 1785 uword lowest_pc_offset = kUwordMax;
1786 PcDescriptors::Iterator iter(desc, kSafepointKind); 1786 PcDescriptors::Iterator iter(desc, kSafepointKind);
1787 while (iter.MoveNext()) { 1787 while (iter.MoveNext()) {
1788 const intptr_t pos = iter.TokenPos(); 1788 const intptr_t pos = iter.TokenPos();
1789 if ((pos == Scanner::kNoSourcePos) || 1789 if ((pos < 0) ||
1790 (pos < begin_pos) || 1790 (pos < begin_pos) ||
1791 (pos > end_of_line_pos)) { 1791 (pos > end_of_line_pos)) {
1792 // Token is not on same line as best fit. 1792 // Token is not on same line as best fit.
1793 continue; 1793 continue;
1794 } 1794 }
1795 1795
1796 if (requested_column >= 0) { 1796 if (requested_column >= 0) {
1797 intptr_t ignored = -1; 1797 intptr_t ignored = -1;
1798 intptr_t token_start_column = -1; 1798 intptr_t token_start_column = -1;
1799 // We look for other tokens at the best column in case there 1799 // We look for other tokens at the best column in case there
(...skipping 20 matching lines...) Expand all
1820 if (last_token_pos < func.end_token_pos()) { 1820 if (last_token_pos < func.end_token_pos()) {
1821 return ResolveBreakpointPos(func, last_token_pos, func.end_token_pos(), 1821 return ResolveBreakpointPos(func, last_token_pos, func.end_token_pos(),
1822 -1 /* no column */); 1822 -1 /* no column */);
1823 } 1823 }
1824 return -1; 1824 return -1;
1825 } 1825 }
1826 1826
1827 1827
1828 void Debugger::MakeCodeBreakpointAt(const Function& func, 1828 void Debugger::MakeCodeBreakpointAt(const Function& func,
1829 BreakpointLocation* loc) { 1829 BreakpointLocation* loc) {
1830 ASSERT(loc->token_pos_ != Scanner::kNoSourcePos); 1830 ASSERT(loc->token_pos_ >= 0);
1831 ASSERT((loc != NULL) && loc->IsResolved()); 1831 ASSERT((loc != NULL) && loc->IsResolved());
1832 ASSERT(!func.HasOptimizedCode()); 1832 ASSERT(!func.HasOptimizedCode());
1833 Code& code = Code::Handle(func.unoptimized_code()); 1833 Code& code = Code::Handle(func.unoptimized_code());
1834 ASSERT(!code.IsNull()); 1834 ASSERT(!code.IsNull());
1835 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); 1835 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
1836 uword lowest_pc_offset = kUwordMax; 1836 uword lowest_pc_offset = kUwordMax;
1837 RawPcDescriptors::Kind lowest_kind = RawPcDescriptors::kAnyKind; 1837 RawPcDescriptors::Kind lowest_kind = RawPcDescriptors::kAnyKind;
1838 // Find the safe point with the lowest compiled code address 1838 // Find the safe point with the lowest compiled code address
1839 // that maps to the token position of the source breakpoint. 1839 // that maps to the token position of the source breakpoint.
1840 PcDescriptors::Iterator iter(desc, kSafepointKind); 1840 PcDescriptors::Iterator iter(desc, kSafepointKind);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 // We returned from the "interesting frame", there can be no more 2634 // We returned from the "interesting frame", there can be no more
2635 // stepping breaks for it. Pause at the next appropriate location 2635 // stepping breaks for it. Pause at the next appropriate location
2636 // and let the user set the "interesting" frame again. 2636 // and let the user set the "interesting" frame again.
2637 stepping_fp_ = 0; 2637 stepping_fp_ = 0;
2638 } 2638 }
2639 } 2639 }
2640 2640
2641 if (!frame->IsDebuggable()) { 2641 if (!frame->IsDebuggable()) {
2642 return Error::null(); 2642 return Error::null();
2643 } 2643 }
2644 if (frame->TokenPos() == Scanner::kNoSourcePos) { 2644 if (frame->TokenPos() < 0) {
2645 return Error::null(); 2645 return Error::null();
2646 } 2646 }
2647 2647
2648 // Don't pause for a single step if there is a breakpoint set 2648 // Don't pause for a single step if there is a breakpoint set
2649 // at this location. 2649 // at this location.
2650 if (HasActiveBreakpoint(frame->pc())) { 2650 if (HasActiveBreakpoint(frame->pc())) {
2651 return Error::null(); 2651 return Error::null();
2652 } 2652 }
2653 2653
2654 if (FLAG_verbose_debug) { 2654 if (FLAG_verbose_debug) {
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
3243 } 3243 }
3244 3244
3245 3245
3246 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 3246 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
3247 ASSERT(bpt->next() == NULL); 3247 ASSERT(bpt->next() == NULL);
3248 bpt->set_next(code_breakpoints_); 3248 bpt->set_next(code_breakpoints_);
3249 code_breakpoints_ = bpt; 3249 code_breakpoints_ = bpt;
3250 } 3250 }
3251 3251
3252 } // namespace dart 3252 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698