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

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

Issue 2979163002: Allow setting breakpoints in function literal field initializers under --dfe. (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
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
11 #include "vm/code_patcher.h" 11 #include "vm/code_patcher.h"
12 #include "vm/compiler.h" 12 #include "vm/compiler.h"
13 #include "vm/dart_entry.h" 13 #include "vm/dart_entry.h"
14 #include "vm/deopt_instructions.h" 14 #include "vm/deopt_instructions.h"
15 #include "vm/disassembler.h" 15 #include "vm/disassembler.h"
16 #include "vm/flags.h" 16 #include "vm/flags.h"
17 #include "vm/globals.h" 17 #include "vm/globals.h"
18 #include "vm/json_stream.h" 18 #include "vm/json_stream.h"
19 #include "vm/kernel_binary.h"
20 #include "vm/kernel_binary_flowgraph.h"
21 #include "vm/kernel_to_il.h"
19 #include "vm/longjump.h" 22 #include "vm/longjump.h"
20 #include "vm/message_handler.h" 23 #include "vm/message_handler.h"
21 #include "vm/object.h" 24 #include "vm/object.h"
22 #include "vm/object_store.h" 25 #include "vm/object_store.h"
23 #include "vm/os.h" 26 #include "vm/os.h"
24 #include "vm/parser.h" 27 #include "vm/parser.h"
25 #include "vm/port.h" 28 #include "vm/port.h"
26 #include "vm/runtime_entry.h" 29 #include "vm/runtime_entry.h"
27 #include "vm/service.h" 30 #include "vm/service.h"
28 #include "vm/service_event.h" 31 #include "vm/service_event.h"
(...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 *best_fit = function.raw(); 2645 *best_fit = function.raw();
2643 return true; 2646 return true;
2644 } 2647 }
2645 } 2648 }
2646 } 2649 }
2647 // If none of the functions in the class contain token_pos, then we 2650 // If none of the functions in the class contain token_pos, then we
2648 // check if it falls within a function literal initializer of a field 2651 // check if it falls within a function literal initializer of a field
2649 // that has not been initialized yet. If the field (and hence the 2652 // that has not been initialized yet. If the field (and hence the
2650 // function literal initializer) has already been initialized, then 2653 // function literal initializer) has already been initialized, then
2651 // it would have been found above in the object store as a closure. 2654 // it would have been found above in the object store as a closure.
2655 const uint8_t* kernel_data = script.kernel_data();
2652 fields = cls.fields(); 2656 fields = cls.fields();
2653 if (!fields.IsNull()) { 2657 if (!fields.IsNull()) {
2654 const intptr_t num_fields = fields.Length(); 2658 const intptr_t num_fields = fields.Length();
2655 for (intptr_t pos = 0; pos < num_fields; pos++) { 2659 for (intptr_t pos = 0; pos < num_fields; pos++) {
2656 TokenPosition start; 2660 TokenPosition start;
2657 TokenPosition end; 2661 TokenPosition end;
2658 field ^= fields.At(pos); 2662 field ^= fields.At(pos);
2659 ASSERT(!field.IsNull()); 2663 ASSERT(!field.IsNull());
2660 if (field.Script() != script.raw()) { 2664 if (field.Script() != script.raw()) {
2661 // The field should be defined in the script we want to set 2665 // The field should be defined in the script we want to set
2662 // the breakpoint in. 2666 // the breakpoint in.
2663 continue; 2667 continue;
2664 } 2668 }
2665 if (Parser::FieldHasFunctionLiteralInitializer(field, &start, &end)) { 2669 bool has_func_literal_initializer = false;
2670 if (kernel_data != NULL) {
2671 #ifndef DART_PRECOMPILED_RUNTIME
2672 // If we have the kernel program, use it.
2673 kernel::TranslationHelper translation_helper(
2674 Thread::Current(), script.kernel_string_offsets(),
2675 script.kernel_string_data(), script.kernel_canonical_names());
2676 kernel::StreamingFlowGraphBuilder* builder =
2677 new kernel::StreamingFlowGraphBuilder(&translation_helper, zone,
2678 kernel_data,
2679 script.kernel_data_size());
2680 kernel::FieldHelper field_helper(builder, field.kernel_offset());
2681 field_helper.ReadUntilExcluding(kernel::FieldHelper::kEnd, true);
2682 has_func_literal_initializer =
2683 field_helper.FieldHasFunctionLiteralInitializer(&start, &end);
2684 delete builder;
2685 #endif // !DART_PRECOMPILED_RUNTIME
siva 2017/07/17 22:39:23 Is it possible to abstract this out as a function
sivachandra 2017/07/17 23:49:36 Done.
2686 } else {
2687 has_func_literal_initializer =
2688 Parser::FieldHasFunctionLiteralInitializer(field, &start, &end);
2689 }
2690 if (has_func_literal_initializer) {
2666 if ((start <= token_pos && token_pos <= end) || 2691 if ((start <= token_pos && token_pos <= end) ||
2667 (token_pos <= start && start <= last_token_pos)) { 2692 (token_pos <= start && start <= last_token_pos)) {
2668 return true; 2693 return true;
2669 } 2694 }
2670 } 2695 }
2671 } 2696 }
2672 } 2697 }
2673 } 2698 }
2674 return false; 2699 return false;
2675 } 2700 }
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
4340 4365
4341 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 4366 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
4342 ASSERT(bpt->next() == NULL); 4367 ASSERT(bpt->next() == NULL);
4343 bpt->set_next(code_breakpoints_); 4368 bpt->set_next(code_breakpoints_);
4344 code_breakpoints_ = bpt; 4369 code_breakpoints_ = bpt;
4345 } 4370 }
4346 4371
4347 #endif // !PRODUCT 4372 #endif // !PRODUCT
4348 4373
4349 } // namespace dart 4374 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698