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

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

Issue 11446020: Set BP in closurized function if necessary (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')
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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 intptr_t first_token_pos, 949 intptr_t first_token_pos,
950 intptr_t last_token_pos) { 950 intptr_t last_token_pos) {
951 if ((last_token_pos < target_function.token_pos()) || 951 if ((last_token_pos < target_function.token_pos()) ||
952 (target_function.end_token_pos() < first_token_pos)) { 952 (target_function.end_token_pos() < first_token_pos)) {
953 // The given token position is not within the target function. 953 // The given token position is not within the target function.
954 return NULL; 954 return NULL;
955 } 955 }
956 EnsureFunctionIsDeoptimized(target_function); 956 EnsureFunctionIsDeoptimized(target_function);
957 957
958 CodeBreakpoint* cbpt = NULL; 958 CodeBreakpoint* cbpt = NULL;
959 SourceBreakpoint* bpt = NULL; 959 SourceBreakpoint* source_bpt = NULL;
960 if (target_function.HasCode()) { 960 if (target_function.HasCode()) {
961 cbpt = MakeCodeBreakpoint(target_function, first_token_pos, last_token_pos); 961 cbpt = MakeCodeBreakpoint(target_function, first_token_pos, last_token_pos);
962 if (cbpt != NULL) { 962 if (cbpt != NULL) {
963 if (cbpt->src_bpt() != NULL) { 963 if (cbpt->src_bpt() != NULL) {
964 // There is already a source breakpoint for the location. 964 // There is already a source breakpoint for the location.
965 ASSERT(cbpt->src_bpt() == 965 ASSERT(cbpt->src_bpt() ==
966 GetSourceBreakpoint(target_function, cbpt->token_pos())); 966 GetSourceBreakpoint(target_function, cbpt->token_pos()));
967 return cbpt->src_bpt(); 967 return cbpt->src_bpt();
968 } 968 }
969 // No source breakpoint exists yet that is associated with the code 969 // No source breakpoint exists yet that is associated with the code
970 // breakpoint we found. (This is an internal breakpoint.) Adjust 970 // breakpoint we found. (This is an internal breakpoint.) Adjust
971 // the breakpoint location to the actual position where breakpoint 971 // the breakpoint location to the actual position where breakpoint
972 // got set. 972 // got set.
973 first_token_pos = cbpt->token_pos(); 973 first_token_pos = cbpt->token_pos();
974 } 974 }
975 } else { 975 } else {
976 bpt = GetSourceBreakpoint(target_function, first_token_pos); 976 source_bpt = GetSourceBreakpoint(target_function, first_token_pos);
977 if (bpt != NULL) { 977 if (source_bpt != NULL) {
978 // A source breakpoint for this uncompiled location already 978 // A source breakpoint for this uncompiled location already
979 // exists. 979 // exists.
980 return bpt; 980 return source_bpt;
981 } 981 }
982 } 982 }
983 bpt = new SourceBreakpoint(nextId(), target_function, first_token_pos); 983 source_bpt = new SourceBreakpoint(nextId(), target_function, first_token_pos);
984 RegisterSourceBreakpoint(bpt); 984 RegisterSourceBreakpoint(source_bpt);
985 if (FLAG_verbose_debug && !target_function.HasCode()) { 985 if (FLAG_verbose_debug && !target_function.HasCode()) {
986 OS::Print("Registering breakpoint for " 986 OS::Print("Registering breakpoint for "
987 "uncompiled function '%s' at line %"Pd"\n", 987 "uncompiled function '%s' at line %"Pd"\n",
988 target_function.ToFullyQualifiedCString(), 988 target_function.ToFullyQualifiedCString(),
989 bpt->LineNumber()); 989 source_bpt->LineNumber());
990 } 990 }
991 991
992 if (cbpt != NULL) { 992 if (cbpt != NULL) {
993 ASSERT(cbpt->src_bpt() == NULL); 993 ASSERT(cbpt->src_bpt() == NULL);
994 cbpt->set_src_bpt(bpt); 994 cbpt->set_src_bpt(source_bpt);
995 SignalBpResolved(bpt); 995 SignalBpResolved(source_bpt);
996 } else { 996 } else {
997 if (FLAG_verbose_debug) { 997 if (FLAG_verbose_debug) {
998 OS::Print("Failed to set breakpoint at '%s' line %"Pd"\n", 998 OS::Print("Failed to set breakpoint at '%s' line %"Pd"\n",
999 String::Handle(bpt->SourceUrl()).ToCString(), 999 String::Handle(source_bpt->SourceUrl()).ToCString(),
1000 bpt->LineNumber()); 1000 source_bpt->LineNumber());
1001 } 1001 }
1002 } 1002 }
1003 bpt->Enable(); 1003
1004 return bpt; 1004 if (target_function.implicit_closure_function() != Function::null()) {
regis 2012/12/05 22:54:34 You use implicit_closure_function() and ImplicitCl
hausner 2012/12/05 23:04:13 Done.
1005 // There is a closureized version of this function. If the closure
regis 2012/12/05 22:54:34 closurized
hausner 2012/12/05 23:04:13 Done.
1006 // is already compiled, we need to set a code breakpoint in its
1007 // code.
1008 const Function& closure =
1009 Function::Handle(target_function.ImplicitClosureFunction());
1010 if (closure.HasCode()) {
1011 CodeBreakpoint* closure_bpt =
1012 MakeCodeBreakpoint(closure, first_token_pos, last_token_pos);
1013 if ((closure_bpt != NULL) && (closure_bpt->src_bpt() == NULL)) {
1014 closure_bpt->set_src_bpt(source_bpt);
1015 }
1016 }
1017 }
1018 source_bpt->Enable();
1019 return source_bpt;
1005 } 1020 }
1006 1021
1007 1022
1008 // Synchronize the enabled/disabled state of all code breakpoints 1023 // Synchronize the enabled/disabled state of all code breakpoints
1009 // associated with the source breakpoint bpt. 1024 // associated with the source breakpoint bpt.
1010 void Debugger::SyncBreakpoint(SourceBreakpoint* bpt) { 1025 void Debugger::SyncBreakpoint(SourceBreakpoint* bpt) {
1011 CodeBreakpoint* cbpt = code_breakpoints_; 1026 CodeBreakpoint* cbpt = code_breakpoints_;
1012 while (cbpt != NULL) { 1027 while (cbpt != NULL) {
1013 if (bpt == cbpt->src_bpt()) { 1028 if (bpt == cbpt->src_bpt()) {
1014 if (bpt->IsEnabled()) { 1029 if (bpt->IsEnabled()) {
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 } 1632 }
1618 1633
1619 1634
1620 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1635 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1621 ASSERT(bpt->next() == NULL); 1636 ASSERT(bpt->next() == NULL);
1622 bpt->set_next(code_breakpoints_); 1637 bpt->set_next(code_breakpoints_);
1623 code_breakpoints_ = bpt; 1638 code_breakpoints_ = bpt;
1624 } 1639 }
1625 1640
1626 } // namespace dart 1641 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698