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 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 Object::null_array(), 0); | 1264 Object::null_array(), 0); |
1265 return activation; | 1265 return activation; |
1266 } | 1266 } |
1267 | 1267 |
1268 | 1268 |
1269 DebuggerStackTrace* Debugger::StackTrace() { | 1269 DebuggerStackTrace* Debugger::StackTrace() { |
1270 return (stack_trace_ != NULL) ? stack_trace_ : CollectStackTrace(); | 1270 return (stack_trace_ != NULL) ? stack_trace_ : CollectStackTrace(); |
1271 } | 1271 } |
1272 | 1272 |
1273 | 1273 |
| 1274 ExceptionStackTrace* Debugger::BuildExceptionStackTrace() { |
| 1275 Isolate* isolate = Isolate::Current(); |
| 1276 ExceptionStackTrace* result = new ExceptionStackTrace(8); |
| 1277 StackFrameIterator iterator(false); |
| 1278 Function& function = Function::Handle(isolate); |
| 1279 Code& code = Code::Handle(isolate); |
| 1280 Code& inlined_code = Code::Handle(isolate); |
| 1281 |
| 1282 String& function_name = String::Handle(isolate); |
| 1283 String& script_uri = String::Handle(isolate); |
| 1284 Script& script = Script::Handle(isolate); |
| 1285 |
| 1286 for (StackFrame* frame = iterator.NextFrame(); |
| 1287 frame != NULL; |
| 1288 frame = iterator.NextFrame()) { |
| 1289 ASSERT(frame->IsValid()); |
| 1290 if (frame->IsEntryFrame()) { |
| 1291 } else if (frame->IsDartFrame()) { |
| 1292 code = frame->LookupDartCode(); |
| 1293 if (code.is_optimized()) { |
| 1294 for (InlinedFunctionsIterator it(code, frame->pc()); |
| 1295 !it.Done(); |
| 1296 it.Advance()) { |
| 1297 function = it.function(); |
| 1298 inlined_code = it.code(); |
| 1299 uword pc = it.pc(); |
| 1300 |
| 1301 if (!function.is_visible()) continue; |
| 1302 |
| 1303 function_name = function.QualifiedUserVisibleName(); |
| 1304 script = function.script(); |
| 1305 script_uri = script.url(); |
| 1306 const intptr_t token_pos = inlined_code.GetTokenIndexOfPC(pc); |
| 1307 intptr_t line = -1; |
| 1308 intptr_t column = -1; |
| 1309 if (token_pos >= 0) { |
| 1310 if (script.HasSource()) { |
| 1311 script.GetTokenLocation(token_pos, &line, &column); |
| 1312 } else { |
| 1313 script.GetTokenLocation(token_pos, &line, NULL); |
| 1314 } |
| 1315 } |
| 1316 result->AddFrame( |
| 1317 new ExceptionStackFrame(function_name, script_uri, line, column)); |
| 1318 } |
| 1319 } else { |
| 1320 function = frame->LookupDartFunction(); |
| 1321 uword pc = frame->pc(); |
| 1322 |
| 1323 if (!function.is_visible()) continue; |
| 1324 |
| 1325 function_name = function.QualifiedUserVisibleName(); |
| 1326 script = function.script(); |
| 1327 script_uri = script.url(); |
| 1328 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
| 1329 intptr_t line = -1; |
| 1330 intptr_t column = -1; |
| 1331 if (token_pos >= 0) { |
| 1332 if (script.HasSource()) { |
| 1333 script.GetTokenLocation(token_pos, &line, &column); |
| 1334 } else { |
| 1335 script.GetTokenLocation(token_pos, &line, NULL); |
| 1336 } |
| 1337 } |
| 1338 result->AddFrame( |
| 1339 new ExceptionStackFrame(function_name, script_uri, line, column)); |
| 1340 } |
| 1341 } |
| 1342 } |
| 1343 return result; |
| 1344 } |
| 1345 |
| 1346 |
1274 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { | 1347 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { |
1275 ASSERT((pause_info == kNoPauseOnExceptions) || | 1348 ASSERT((pause_info == kNoPauseOnExceptions) || |
1276 (pause_info == kPauseOnUnhandledExceptions) || | 1349 (pause_info == kPauseOnUnhandledExceptions) || |
1277 (pause_info == kPauseOnAllExceptions)); | 1350 (pause_info == kPauseOnAllExceptions)); |
1278 exc_pause_info_ = pause_info; | 1351 exc_pause_info_ = pause_info; |
1279 } | 1352 } |
1280 | 1353 |
1281 | 1354 |
1282 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() { | 1355 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() { |
1283 return exc_pause_info_; | 1356 return exc_pause_info_; |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 } | 2206 } |
2134 | 2207 |
2135 | 2208 |
2136 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2209 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2137 ASSERT(bpt->next() == NULL); | 2210 ASSERT(bpt->next() == NULL); |
2138 bpt->set_next(code_breakpoints_); | 2211 bpt->set_next(code_breakpoints_); |
2139 code_breakpoints_ = bpt; | 2212 code_breakpoints_ = bpt; |
2140 } | 2213 } |
2141 | 2214 |
2142 } // namespace dart | 2215 } // namespace dart |
OLD | NEW |