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

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

Issue 2965673004: Fix setting breakpoints in parts of a library. (Closed)
Patch Set: Created 3 years, 5 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 | « runtime/tests/vm/vm.status ('k') | runtime/vm/debugger_test.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 "platform/address_sanitizer.h" 9 #include "platform/address_sanitizer.h"
10 10
(...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 // Returns true if a best fit is found. A best fit can either be a function 2703 // Returns true if a best fit is found. A best fit can either be a function
2704 // or a field. If it is a function, then the best fit function is returned 2704 // or a field. If it is a function, then the best fit function is returned
2705 // in |best_fit|. If a best fit is a field, it means that a latent 2705 // in |best_fit|. If a best fit is a field, it means that a latent
2706 // breakpoint can be set in the range |token_pos| to |last_token_pos|. 2706 // breakpoint can be set in the range |token_pos| to |last_token_pos|.
2707 bool Debugger::FindBestFit(const Script& script, 2707 bool Debugger::FindBestFit(const Script& script,
2708 TokenPosition token_pos, 2708 TokenPosition token_pos,
2709 TokenPosition last_token_pos, 2709 TokenPosition last_token_pos,
2710 Function* best_fit) { 2710 Function* best_fit) {
2711 Zone* zone = Thread::Current()->zone(); 2711 Zone* zone = Thread::Current()->zone();
2712 Class& cls = Class::Handle(zone); 2712 Class& cls = Class::Handle(zone);
2713 Library& lib = Library::Handle(zone, script.FindLibrary());
2714 ASSERT(!lib.IsNull());
2713 const GrowableObjectArray& closures = GrowableObjectArray::Handle( 2715 const GrowableObjectArray& closures = GrowableObjectArray::Handle(
2714 zone, isolate_->object_store()->closure_functions()); 2716 zone, isolate_->object_store()->closure_functions());
2715 Array& functions = Array::Handle(zone); 2717 Array& functions = Array::Handle(zone);
2716 Function& function = Function::Handle(zone); 2718 Function& function = Function::Handle(zone);
2717 Array& fields = Array::Handle(zone); 2719 Array& fields = Array::Handle(zone);
2718 Field& field = Field::Handle(zone); 2720 Field& field = Field::Handle(zone);
2719 Error& error = Error::Handle(zone); 2721 Error& error = Error::Handle(zone);
2720 2722
2721 const intptr_t num_closures = closures.Length(); 2723 const intptr_t num_closures = closures.Length();
2722 for (intptr_t i = 0; i < num_closures; i++) { 2724 for (intptr_t i = 0; i < num_closures; i++) {
(...skipping 10 matching lines...) Expand all
2733 return true; 2735 return true;
2734 } 2736 }
2735 2737
2736 const ClassTable& class_table = *isolate_->class_table(); 2738 const ClassTable& class_table = *isolate_->class_table();
2737 const intptr_t num_classes = class_table.NumCids(); 2739 const intptr_t num_classes = class_table.NumCids();
2738 for (intptr_t i = 1; i < num_classes; i++) { 2740 for (intptr_t i = 1; i < num_classes; i++) {
2739 if (!class_table.HasValidClassAt(i)) { 2741 if (!class_table.HasValidClassAt(i)) {
2740 continue; 2742 continue;
2741 } 2743 }
2742 cls = class_table.At(i); 2744 cls = class_table.At(i);
2743 if (cls.script() != script.raw()) { 2745 // This class is relevant to us only if it belongs to the
2746 // library to which |script| belongs.
2747 if (cls.library() != lib.raw()) {
2744 continue; 2748 continue;
2745 } 2749 }
2746 // Parse class definition if not done yet. 2750 // Parse class definition if not done yet.
2747 error = cls.EnsureIsFinalized(Thread::Current()); 2751 error = cls.EnsureIsFinalized(Thread::Current());
2748 if (!error.IsNull()) { 2752 if (!error.IsNull()) {
2749 // Ignore functions in this class. 2753 // Ignore functions in this class.
2750 // TODO(hausner): Should we propagate this error? How? 2754 // TODO(hausner): Should we propagate this error? How?
2751 // EnsureIsFinalized only returns an error object if there 2755 // EnsureIsFinalized only returns an error object if there
2752 // is no longjump base on the stack. 2756 // is no longjump base on the stack.
2753 continue; 2757 continue;
(...skipping 25 matching lines...) Expand all
2779 // function literal initializer) has already been initialized, then 2783 // function literal initializer) has already been initialized, then
2780 // it would have been found above in the object store as a closure. 2784 // it would have been found above in the object store as a closure.
2781 fields = cls.fields(); 2785 fields = cls.fields();
2782 if (!fields.IsNull()) { 2786 if (!fields.IsNull()) {
2783 const intptr_t num_fields = fields.Length(); 2787 const intptr_t num_fields = fields.Length();
2784 for (intptr_t pos = 0; pos < num_fields; pos++) { 2788 for (intptr_t pos = 0; pos < num_fields; pos++) {
2785 TokenPosition start; 2789 TokenPosition start;
2786 TokenPosition end; 2790 TokenPosition end;
2787 field ^= fields.At(pos); 2791 field ^= fields.At(pos);
2788 ASSERT(!field.IsNull()); 2792 ASSERT(!field.IsNull());
2793 if (field.Script() != script.raw()) {
2794 // The field should be defined in the script we want to set
2795 // the breakpoint in.
2796 continue;
2797 }
2789 if (Parser::FieldHasFunctionLiteralInitializer(field, &start, &end)) { 2798 if (Parser::FieldHasFunctionLiteralInitializer(field, &start, &end)) {
2790 if ((start <= token_pos && token_pos <= end) || 2799 if ((start <= token_pos && token_pos <= end) ||
2791 (token_pos <= start && start <= last_token_pos)) { 2800 (token_pos <= start && start <= last_token_pos)) {
2792 return true; 2801 return true;
2793 } 2802 }
2794 } 2803 }
2795 } 2804 }
2796 } 2805 }
2797 } 2806 }
2798 return false; 2807 return false;
(...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 4538
4530 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 4539 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
4531 ASSERT(bpt->next() == NULL); 4540 ASSERT(bpt->next() == NULL);
4532 bpt->set_next(code_breakpoints_); 4541 bpt->set_next(code_breakpoints_);
4533 code_breakpoints_ = bpt; 4542 code_breakpoints_ = bpt;
4534 } 4543 }
4535 4544
4536 #endif // !PRODUCT 4545 #endif // !PRODUCT
4537 4546
4538 } // namespace dart 4547 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | runtime/vm/debugger_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698