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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const Code& code, | 133 const Code& code, |
134 const Array& deopt_frame, | 134 const Array& deopt_frame, |
135 intptr_t deopt_frame_offset) | 135 intptr_t deopt_frame_offset) |
136 : pc_(pc), fp_(fp), sp_(sp), | 136 : pc_(pc), fp_(fp), sp_(sp), |
137 ctx_(Context::ZoneHandle()), | 137 ctx_(Context::ZoneHandle()), |
138 code_(Code::ZoneHandle(code.raw())), | 138 code_(Code::ZoneHandle(code.raw())), |
139 function_(Function::ZoneHandle(code.function())), | 139 function_(Function::ZoneHandle(code.function())), |
140 token_pos_(-1), | 140 token_pos_(-1), |
141 pc_desc_index_(-1), | 141 pc_desc_index_(-1), |
142 line_number_(-1), | 142 line_number_(-1), |
| 143 column_number_(-1), |
143 context_level_(-1), | 144 context_level_(-1), |
144 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())), | 145 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())), |
145 deopt_frame_offset_(deopt_frame_offset), | 146 deopt_frame_offset_(deopt_frame_offset), |
146 vars_initialized_(false), | 147 vars_initialized_(false), |
147 var_descriptors_(LocalVarDescriptors::ZoneHandle()), | 148 var_descriptors_(LocalVarDescriptors::ZoneHandle()), |
148 desc_indices_(8), | 149 desc_indices_(8), |
149 pc_desc_(PcDescriptors::ZoneHandle()) { | 150 pc_desc_(PcDescriptors::ZoneHandle()) { |
150 } | 151 } |
151 | 152 |
152 | 153 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 intptr_t ActivationFrame::LineNumber() { | 289 intptr_t ActivationFrame::LineNumber() { |
289 // Compute line number lazily since it causes scanning of the script. | 290 // Compute line number lazily since it causes scanning of the script. |
290 if ((line_number_ < 0) && (TokenPos() >= 0)) { | 291 if ((line_number_ < 0) && (TokenPos() >= 0)) { |
291 const Script& script = Script::Handle(SourceScript()); | 292 const Script& script = Script::Handle(SourceScript()); |
292 script.GetTokenLocation(TokenPos(), &line_number_, NULL); | 293 script.GetTokenLocation(TokenPos(), &line_number_, NULL); |
293 } | 294 } |
294 return line_number_; | 295 return line_number_; |
295 } | 296 } |
296 | 297 |
297 | 298 |
| 299 intptr_t ActivationFrame::ColumnNumber() { |
| 300 // Compute column number lazily since it causes scanning of the script. |
| 301 if ((column_number_ < 0) && (TokenPos() >= 0)) { |
| 302 const Script& script = Script::Handle(SourceScript()); |
| 303 if (script.HasSource()) { |
| 304 script.GetTokenLocation(TokenPos(), &line_number_, &column_number_); |
| 305 } else { |
| 306 column_number_ = -1; |
| 307 } |
| 308 } |
| 309 return column_number_; |
| 310 } |
| 311 |
| 312 |
298 void ActivationFrame::GetVarDescriptors() { | 313 void ActivationFrame::GetVarDescriptors() { |
299 if (var_descriptors_.IsNull()) { | 314 if (var_descriptors_.IsNull()) { |
300 var_descriptors_ = code().var_descriptors(); | 315 var_descriptors_ = code().var_descriptors(); |
301 ASSERT(!var_descriptors_.IsNull()); | 316 ASSERT(!var_descriptors_.IsNull()); |
302 } | 317 } |
303 } | 318 } |
304 | 319 |
305 | 320 |
306 bool ActivationFrame::IsDebuggable() const { | 321 bool ActivationFrame::IsDebuggable() const { |
307 return Debugger::IsDebuggable(function()); | 322 return Debugger::IsDebuggable(function()); |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code, | 1278 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code, |
1264 Object::null_array(), 0); | 1279 Object::null_array(), 0); |
1265 return activation; | 1280 return activation; |
1266 } | 1281 } |
1267 | 1282 |
1268 | 1283 |
1269 DebuggerStackTrace* Debugger::StackTrace() { | 1284 DebuggerStackTrace* Debugger::StackTrace() { |
1270 return (stack_trace_ != NULL) ? stack_trace_ : CollectStackTrace(); | 1285 return (stack_trace_ != NULL) ? stack_trace_ : CollectStackTrace(); |
1271 } | 1286 } |
1272 | 1287 |
| 1288 DebuggerStackTrace* Debugger::CurrentStackTrace() { |
| 1289 return CollectStackTraceNew(); |
| 1290 } |
| 1291 |
| 1292 DebuggerStackTrace* Debugger::StackTraceFrom(const Stacktrace& ex_trace) { |
| 1293 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
| 1294 Function& function = Function::Handle(); |
| 1295 Code& code = Code::Handle(); |
| 1296 |
| 1297 const uword fp = 0; |
| 1298 const uword sp = 0; |
| 1299 const Array& deopt_frame = Array::Handle(); |
| 1300 const intptr_t deopt_frame_offset = -1; |
| 1301 |
| 1302 for (intptr_t i = 0; i < ex_trace.Length(); i++) { |
| 1303 function = ex_trace.FunctionAtFrame(i); |
| 1304 if (function.IsNull()) { |
| 1305 // Check if null function object indicates a stack trace overflow. |
| 1306 // Preallocated stacktraces like StackOverflow or OutOfMemory make skip |
| 1307 // frames. |
| 1308 ASSERT((i < (ex_trace.Length() - 1)) && |
| 1309 (ex_trace.FunctionAtFrame(i + 1) != Function::null())); |
| 1310 } else if (function.is_visible()) { |
| 1311 code = ex_trace.CodeAtFrame(i); |
| 1312 ASSERT(function.raw() == code.function()); |
| 1313 uword pc = code.EntryPoint() + Smi::Value(ex_trace.PcOffsetAtFrame(i)); |
| 1314 if (code.is_optimized() && ex_trace.expand_inlined()) { |
| 1315 // Traverse inlined frames. |
| 1316 for (InlinedFunctionsIterator it(code, pc); !it.Done(); it.Advance()) { |
| 1317 function = it.function(); |
| 1318 code = it.code(); |
| 1319 ASSERT(function.raw() == code.function()); |
| 1320 uword pc = it.pc(); |
| 1321 ASSERT(pc != 0); |
| 1322 ASSERT(code.EntryPoint() <= pc); |
| 1323 ASSERT(pc < (code.EntryPoint() + code.Size())); |
| 1324 |
| 1325 ActivationFrame* activation = new ActivationFrame( |
| 1326 pc, fp, sp, code, deopt_frame, deopt_frame_offset); |
| 1327 stack_trace->AddActivation(activation); |
| 1328 } |
| 1329 } else { |
| 1330 ActivationFrame* activation = new ActivationFrame( |
| 1331 pc, fp, sp, code, deopt_frame, deopt_frame_offset); |
| 1332 stack_trace->AddActivation(activation); |
| 1333 } |
| 1334 } |
| 1335 } |
| 1336 return stack_trace; |
| 1337 } |
| 1338 |
1273 | 1339 |
1274 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { | 1340 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { |
1275 ASSERT((pause_info == kNoPauseOnExceptions) || | 1341 ASSERT((pause_info == kNoPauseOnExceptions) || |
1276 (pause_info == kPauseOnUnhandledExceptions) || | 1342 (pause_info == kPauseOnUnhandledExceptions) || |
1277 (pause_info == kPauseOnAllExceptions)); | 1343 (pause_info == kPauseOnAllExceptions)); |
1278 exc_pause_info_ = pause_info; | 1344 exc_pause_info_ = pause_info; |
1279 } | 1345 } |
1280 | 1346 |
1281 | 1347 |
1282 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() { | 1348 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() { |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 } | 2228 } |
2163 | 2229 |
2164 | 2230 |
2165 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2231 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2166 ASSERT(bpt->next() == NULL); | 2232 ASSERT(bpt->next() == NULL); |
2167 bpt->set_next(code_breakpoints_); | 2233 bpt->set_next(code_breakpoints_); |
2168 code_breakpoints_ = bpt; | 2234 code_breakpoints_ = bpt; |
2169 } | 2235 } |
2170 | 2236 |
2171 } // namespace dart | 2237 } // namespace dart |
OLD | NEW |