| 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 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 // This port will be used as a unique ID to represet the isolate in the | 1954 // This port will be used as a unique ID to represet the isolate in the |
| 1955 // debugger wire protocol messages. | 1955 // debugger wire protocol messages. |
| 1956 isolate_id_ = isolate->main_port(); | 1956 isolate_id_ = isolate->main_port(); |
| 1957 initialized_ = true; | 1957 initialized_ = true; |
| 1958 | 1958 |
| 1959 // Signal isolate creation event. | 1959 // Signal isolate creation event. |
| 1960 SignalIsolateEvent(Debugger::kIsolateCreated); | 1960 SignalIsolateEvent(Debugger::kIsolateCreated); |
| 1961 } | 1961 } |
| 1962 | 1962 |
| 1963 | 1963 |
| 1964 static RawFunction* GetOriginalFunction(const Function& func) { |
| 1965 const Class& origin_class = Class::Handle(func.origin()); |
| 1966 if (origin_class.is_patch()) { |
| 1967 // Patched functions from patch classes are removed from the |
| 1968 // function array of the patch class, so we will not find an |
| 1969 // original function object. |
| 1970 return func.raw(); |
| 1971 } |
| 1972 const Array& functions = Array::Handle(origin_class.functions()); |
| 1973 Object& orig_func = Object::Handle(); |
| 1974 for (intptr_t i = 0; i < functions.Length(); i++) { |
| 1975 orig_func = functions.At(i); |
| 1976 // Function names are symbols, so we can compare the raw pointers. |
| 1977 if (func.name() == Function::Cast(orig_func).name()) { |
| 1978 return Function::Cast(orig_func).raw(); |
| 1979 } |
| 1980 } |
| 1981 // Uncommon case: not a mixin function. |
| 1982 ASSERT(!Class::Handle(func.Owner()).IsMixinApplication()); |
| 1983 return func.raw(); |
| 1984 } |
| 1985 |
| 1986 |
| 1964 void Debugger::NotifyCompilation(const Function& func) { | 1987 void Debugger::NotifyCompilation(const Function& func) { |
| 1965 if (src_breakpoints_ == NULL) { | 1988 if (src_breakpoints_ == NULL) { |
| 1966 // Return with minimal overhead if there are no breakpoints. | 1989 // Return with minimal overhead if there are no breakpoints. |
| 1967 return; | 1990 return; |
| 1968 } | 1991 } |
| 1969 Function& lookup_function = Function::Handle(func.raw()); | 1992 Function& lookup_function = Function::Handle(func.raw()); |
| 1970 if (func.IsImplicitClosureFunction()) { | 1993 if (func.IsImplicitClosureFunction()) { |
| 1971 // If the newly compiled function is a an implicit closure (a closure that | 1994 // If the newly compiled function is a an implicit closure (a closure that |
| 1972 // was formed by assigning a static or instance method to a function | 1995 // was formed by assigning a static or instance method to a function |
| 1973 // object), we need to use the closure's parent function to see whether | 1996 // object), we need to use the closure's parent function to see whether |
| 1974 // there are any breakpoints. The parent function is the actual method on | 1997 // there are any breakpoints. The parent function is the actual method on |
| 1975 // which the user sets breakpoints. | 1998 // which the user sets breakpoints. |
| 1976 lookup_function = func.parent_function(); | 1999 lookup_function = func.parent_function(); |
| 1977 ASSERT(!lookup_function.IsNull()); | 2000 ASSERT(!lookup_function.IsNull()); |
| 1978 } | 2001 } |
| 2002 if (lookup_function.Owner() != lookup_function.origin()) { |
| 2003 // This is a cloned function from a mixin class. If a breakpoint |
| 2004 // was set in this function, it is registered using the function |
| 2005 // of the origin class. |
| 2006 lookup_function = GetOriginalFunction(lookup_function); |
| 2007 } |
| 1979 SourceBreakpoint* bpt = src_breakpoints_; | 2008 SourceBreakpoint* bpt = src_breakpoints_; |
| 1980 while (bpt != NULL) { | 2009 while (bpt != NULL) { |
| 1981 if (lookup_function.raw() == bpt->function()) { | 2010 if (lookup_function.raw() == bpt->function()) { |
| 1982 // Check if the breakpoint is inside a closure or local function | 2011 // Check if the breakpoint is inside a closure or local function |
| 1983 // within the newly compiled function. | 2012 // within the newly compiled function. |
| 1984 Class& owner = Class::Handle(lookup_function.Owner()); | 2013 Class& owner = Class::Handle(lookup_function.Owner()); |
| 1985 Function& closure = | 2014 Function& closure = |
| 1986 Function::Handle(owner.LookupClosureFunction(bpt->token_pos())); | 2015 Function::Handle(owner.LookupClosureFunction(bpt->token_pos())); |
| 1987 if (!closure.IsNull() && (closure.raw() != lookup_function.raw())) { | 2016 if (!closure.IsNull() && (closure.raw() != lookup_function.raw())) { |
| 1988 if (FLAG_verbose_debug) { | 2017 if (FLAG_verbose_debug) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 } | 2162 } |
| 2134 | 2163 |
| 2135 | 2164 |
| 2136 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2165 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 2137 ASSERT(bpt->next() == NULL); | 2166 ASSERT(bpt->next() == NULL); |
| 2138 bpt->set_next(code_breakpoints_); | 2167 bpt->set_next(code_breakpoints_); |
| 2139 code_breakpoints_ = bpt; | 2168 code_breakpoints_ = bpt; |
| 2140 } | 2169 } |
| 2141 | 2170 |
| 2142 } // namespace dart | 2171 } // namespace dart |
| OLD | NEW |