| 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 "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 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 // debugger wire protocol messages. | 2019 // debugger wire protocol messages. |
| 2020 isolate_id_ = isolate->main_port(); | 2020 isolate_id_ = isolate->main_port(); |
| 2021 initialized_ = true; | 2021 initialized_ = true; |
| 2022 | 2022 |
| 2023 // Signal isolate creation event. | 2023 // Signal isolate creation event. |
| 2024 SignalIsolateEvent(Debugger::kIsolateCreated); | 2024 SignalIsolateEvent(Debugger::kIsolateCreated); |
| 2025 } | 2025 } |
| 2026 | 2026 |
| 2027 | 2027 |
| 2028 static RawFunction* GetOriginalFunction(const Function& func) { | 2028 static RawFunction* GetOriginalFunction(const Function& func) { |
| 2029 if (func.IsClosureFunction()) { |
| 2030 // Local functions (closures) in mixin functions do not have |
| 2031 // an original function they were cloned from. |
| 2032 // Note: this is a problem when a breakpoint is set in a mixed-in |
| 2033 // closure. The breakpoint is linked to the closure attached to the |
| 2034 // mixin application class, not the mixin class. When the same |
| 2035 // closure is compiled for another mixin application class, we |
| 2036 // don't find the breakpoint since we'll be looking in the |
| 2037 // mixin class. |
| 2038 return func.raw(); |
| 2039 } |
| 2029 const Class& origin_class = Class::Handle(func.origin()); | 2040 const Class& origin_class = Class::Handle(func.origin()); |
| 2030 if (origin_class.is_patch()) { | 2041 if (origin_class.is_patch()) { |
| 2031 // Patched functions from patch classes are removed from the | 2042 // Patched functions from patch classes are removed from the |
| 2032 // function array of the patch class, so we will not find an | 2043 // function array of the patch class, so we will not find an |
| 2033 // original function object. | 2044 // original function object. |
| 2034 return func.raw(); | 2045 return func.raw(); |
| 2035 } | 2046 } |
| 2036 const Array& functions = Array::Handle(origin_class.functions()); | 2047 const Array& functions = Array::Handle(origin_class.functions()); |
| 2037 Object& orig_func = Object::Handle(); | 2048 Object& orig_func = Object::Handle(); |
| 2038 for (intptr_t i = 0; i < functions.Length(); i++) { | 2049 for (intptr_t i = 0; i < functions.Length(); i++) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2066 if (lookup_function.Owner() != lookup_function.origin()) { | 2077 if (lookup_function.Owner() != lookup_function.origin()) { |
| 2067 // This is a cloned function from a mixin class. If a breakpoint | 2078 // This is a cloned function from a mixin class. If a breakpoint |
| 2068 // was set in this function, it is registered using the function | 2079 // was set in this function, it is registered using the function |
| 2069 // of the origin class. | 2080 // of the origin class. |
| 2070 lookup_function = GetOriginalFunction(lookup_function); | 2081 lookup_function = GetOriginalFunction(lookup_function); |
| 2071 } | 2082 } |
| 2072 SourceBreakpoint* bpt = src_breakpoints_; | 2083 SourceBreakpoint* bpt = src_breakpoints_; |
| 2073 while (bpt != NULL) { | 2084 while (bpt != NULL) { |
| 2074 if (lookup_function.raw() == bpt->function()) { | 2085 if (lookup_function.raw() == bpt->function()) { |
| 2075 // Check if the breakpoint is inside a closure or local function | 2086 // Check if the breakpoint is inside a closure or local function |
| 2076 // within the newly compiled function. | 2087 // within the newly compiled function. Note that we must look |
| 2077 Class& owner = Class::Handle(lookup_function.Owner()); | 2088 // in the owner class of the function that just got compiled |
| 2089 // (i.e. func), not the owner class of the function we use to |
| 2090 // record the breakpoint (lookup_function). |
| 2091 Class& owner = Class::Handle(func.Owner()); |
| 2078 Function& closure = | 2092 Function& closure = |
| 2079 Function::Handle(owner.LookupClosureFunction(bpt->token_pos())); | 2093 Function::Handle(owner.LookupClosureFunction(bpt->token_pos())); |
| 2080 if (!closure.IsNull() && (closure.raw() != lookup_function.raw())) { | 2094 if (!closure.IsNull() && (closure.raw() != lookup_function.raw())) { |
| 2081 if (FLAG_verbose_debug) { | 2095 if (FLAG_verbose_debug) { |
| 2082 OS::Print("Resetting pending breakpoint to function %s\n", | 2096 OS::Print("Resetting pending breakpoint to function %s\n", |
| 2083 closure.ToFullyQualifiedCString()); | 2097 closure.ToFullyQualifiedCString()); |
| 2084 } | 2098 } |
| 2085 bpt->set_function(closure); | 2099 bpt->set_function(closure); |
| 2086 } else { | 2100 } else { |
| 2087 if (FLAG_verbose_debug) { | 2101 if (FLAG_verbose_debug) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 } | 2240 } |
| 2227 | 2241 |
| 2228 | 2242 |
| 2229 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2243 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 2230 ASSERT(bpt->next() == NULL); | 2244 ASSERT(bpt->next() == NULL); |
| 2231 bpt->set_next(code_breakpoints_); | 2245 bpt->set_next(code_breakpoints_); |
| 2232 code_breakpoints_ = bpt; | 2246 code_breakpoints_ = bpt; |
| 2233 } | 2247 } |
| 2234 | 2248 |
| 2235 } // namespace dart | 2249 } // namespace dart |
| OLD | NEW |