| 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 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1885 // interested in. | 1885 // interested in. |
| 1886 ActivationFrame* frame = TopDartFrame(); | 1886 ActivationFrame* frame = TopDartFrame(); |
| 1887 ASSERT(frame != NULL); | 1887 ASSERT(frame != NULL); |
| 1888 const Function& func = frame->function(); | 1888 const Function& func = frame->function(); |
| 1889 if (!IsDebuggable(func)) { | 1889 if (!IsDebuggable(func)) { |
| 1890 return; | 1890 return; |
| 1891 } | 1891 } |
| 1892 if (frame->TokenPos() == Scanner::kDummyTokenIndex) { | 1892 if (frame->TokenPos() == Scanner::kDummyTokenIndex) { |
| 1893 return; | 1893 return; |
| 1894 } | 1894 } |
| 1895 // Don't pause for a single step if there is a breakpoint set |
| 1896 // at this location. |
| 1897 if (HasActiveBreakpoint(frame->pc())) { |
| 1898 return; |
| 1899 } |
| 1895 | 1900 |
| 1896 if (FLAG_verbose_debug) { | 1901 if (FLAG_verbose_debug) { |
| 1897 OS::Print(">>> single step break at %s:%" Pd " (func %s token %" Pd ")\n", | 1902 OS::Print(">>> single step break at %s:%" Pd " (func %s token %" Pd ")\n", |
| 1898 String::Handle(frame->SourceUrl()).ToCString(), | 1903 String::Handle(frame->SourceUrl()).ToCString(), |
| 1899 frame->LineNumber(), | 1904 frame->LineNumber(), |
| 1900 String::Handle(frame->QualifiedFunctionName()).ToCString(), | 1905 String::Handle(frame->QualifiedFunctionName()).ToCString(), |
| 1901 frame->TokenPos()); | 1906 frame->TokenPos()); |
| 1902 } | 1907 } |
| 1903 | 1908 |
| 1904 ASSERT(stack_trace_ == NULL); | 1909 ASSERT(stack_trace_ == NULL); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2094 bpt->LineNumber(), | 2099 bpt->LineNumber(), |
| 2095 func.IsClosureFunction() ? "closure" : "function", | 2100 func.IsClosureFunction() ? "closure" : "function", |
| 2096 String::Handle(func.name()).ToCString()); | 2101 String::Handle(func.name()).ToCString()); |
| 2097 } | 2102 } |
| 2098 MakeCodeBreakpointsAt(func, bpt); | 2103 MakeCodeBreakpointsAt(func, bpt); |
| 2099 } | 2104 } |
| 2100 } | 2105 } |
| 2101 } | 2106 } |
| 2102 | 2107 |
| 2103 | 2108 |
| 2109 // TODO(hausner): Could potentially make this faster by checking |
| 2110 // whether the call target at pc is a debugger stub. |
| 2111 bool Debugger::HasActiveBreakpoint(uword pc) { |
| 2112 CodeBreakpoint* bpt = GetCodeBreakpoint(pc); |
| 2113 return (bpt != NULL) && (bpt->IsEnabled()); |
| 2114 } |
| 2115 |
| 2116 |
| 2104 CodeBreakpoint* Debugger::GetCodeBreakpoint(uword breakpoint_address) { | 2117 CodeBreakpoint* Debugger::GetCodeBreakpoint(uword breakpoint_address) { |
| 2105 CodeBreakpoint* bpt = code_breakpoints_; | 2118 CodeBreakpoint* bpt = code_breakpoints_; |
| 2106 while (bpt != NULL) { | 2119 while (bpt != NULL) { |
| 2107 if (bpt->pc() == breakpoint_address) { | 2120 if (bpt->pc() == breakpoint_address) { |
| 2108 return bpt; | 2121 return bpt; |
| 2109 } | 2122 } |
| 2110 bpt = bpt->next(); | 2123 bpt = bpt->next(); |
| 2111 } | 2124 } |
| 2112 return NULL; | 2125 return NULL; |
| 2113 } | 2126 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 } | 2235 } |
| 2223 | 2236 |
| 2224 | 2237 |
| 2225 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2238 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 2226 ASSERT(bpt->next() == NULL); | 2239 ASSERT(bpt->next() == NULL); |
| 2227 bpt->set_next(code_breakpoints_); | 2240 bpt->set_next(code_breakpoints_); |
| 2228 code_breakpoints_ = bpt; | 2241 code_breakpoints_ = bpt; |
| 2229 } | 2242 } |
| 2230 | 2243 |
| 2231 } // namespace dart | 2244 } // namespace dart |
| OLD | NEW |