OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return it->value; | 454 return it->value; |
455 } | 455 } |
456 return ""; | 456 return ""; |
457 } | 457 } |
458 | 458 |
459 DartScriptDebugServer::DartScriptDebugServer() | 459 DartScriptDebugServer::DartScriptDebugServer() |
460 : m_pauseOnExceptionState(DontPauseOnExceptions) | 460 : m_pauseOnExceptionState(DontPauseOnExceptions) |
461 , m_breakpointsActivated(true) | 461 , m_breakpointsActivated(true) |
462 , m_runningNestedMessageLoop(false) | 462 , m_runningNestedMessageLoop(false) |
463 , m_executionState(0) | 463 , m_executionState(0) |
| 464 , m_isPaused(false) |
464 , m_pausedIsolate(0) | 465 , m_pausedIsolate(0) |
465 , m_pausedPage(0) | 466 , m_pausedPage(0) |
466 , m_clientMessageLoop(0) | 467 , m_clientMessageLoop(0) |
467 , m_nextPageId(1) | 468 , m_nextPageId(1) |
468 { | 469 { |
469 } | 470 } |
470 | 471 |
471 DartScriptDebugServer::~DartScriptDebugServer() | 472 DartScriptDebugServer::~DartScriptDebugServer() |
472 { | 473 { |
473 for (DebugDataMap::iterator it = m_pageIdToDebugDataMap.begin(); it != m_pag
eIdToDebugDataMap.end(); ++it) | 474 for (DebugDataMap::iterator it = m_pageIdToDebugDataMap.begin(); it != m_pag
eIdToDebugDataMap.end(); ++it) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 return; | 627 return; |
627 | 628 |
628 // FIXME: determine if this method needs to be implemented for Dart. | 629 // FIXME: determine if this method needs to be implemented for Dart. |
629 } | 630 } |
630 | 631 |
631 void DartScriptDebugServer::continueProgram() | 632 void DartScriptDebugServer::continueProgram() |
632 { | 633 { |
633 if (isPaused()) | 634 if (isPaused()) |
634 quitMessageLoopOnPause(); | 635 quitMessageLoopOnPause(); |
635 m_executionState = 0; | 636 m_executionState = 0; |
| 637 m_isPaused = false; |
636 m_pausedIsolate = 0; | 638 m_pausedIsolate = 0; |
637 } | 639 } |
638 | 640 |
639 void DartScriptDebugServer::stepIntoStatement() | 641 void DartScriptDebugServer::stepIntoStatement() |
640 { | 642 { |
641 ASSERT(isPaused()); | 643 ASSERT(isPaused()); |
642 Dart_SetStepInto(); | 644 Dart_SetStepInto(); |
643 continueProgram(); | 645 continueProgram(); |
644 } | 646 } |
645 | 647 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 int DartScriptDebugServer::frameCount() | 684 int DartScriptDebugServer::frameCount() |
683 { | 685 { |
684 ASSERT(isPaused()); | 686 ASSERT(isPaused()); |
685 intptr_t length = 0; | 687 intptr_t length = 0; |
686 Dart_StackTraceLength(m_executionState, &length); | 688 Dart_StackTraceLength(m_executionState, &length); |
687 return length; | 689 return length; |
688 } | 690 } |
689 | 691 |
690 StackTrace DartScriptDebugServer::currentCallFrames() | 692 StackTrace DartScriptDebugServer::currentCallFrames() |
691 { | 693 { |
692 return StackTrace(m_executionState); | 694 if (!m_executionState) { |
| 695 if (!Dart_CurrentIsolate()) |
| 696 return StackTrace(); |
| 697 ASSERT(!m_isPaused); |
| 698 // We are not paused at a Dart breakpoint but there may be Dart frames |
| 699 // on the call stack. |
| 700 DartDOMData* dartDOMData = DartDOMData::current(); |
| 701 if (dartDOMData->stackTraceTimestampTracker()->recursionLevel() == 0) |
| 702 return StackTrace(); |
| 703 |
| 704 Dart_Handle ALLOW_UNUSED result = Dart_GetStackTrace(&m_executionState); |
| 705 ASSERT(!Dart_IsError(result)); |
| 706 if (!m_executionState) |
| 707 return StackTrace(); |
| 708 intptr_t length = 0; |
| 709 Dart_StackTraceLength(m_executionState, &length); |
| 710 if (!length) { |
| 711 ASSERT_NOT_REACHED(); |
| 712 m_executionState = 0; |
| 713 return StackTrace(); |
| 714 } |
| 715 } |
| 716 return StackTrace(m_executionState, DartUtilities::currentScriptState()); |
693 } | 717 } |
694 | 718 |
695 StackTrace DartScriptDebugServer::currentCallFramesForAsyncStack() | 719 StackTrace DartScriptDebugServer::currentCallFramesForAsyncStack() |
696 { | 720 { |
697 // FIXMEDART: implement propertly. These are the regular not Async call fram
es. | 721 // FIXMEDART: implement propertly. These are the regular not Async call fram
es. |
698 return StackTrace(m_executionState); | 722 return StackTrace(m_executionState, DartUtilities::currentScriptState()); |
699 } | 723 } |
700 | 724 |
701 bool DartScriptDebugServer::isPaused() | 725 bool DartScriptDebugServer::isPaused() |
702 { | 726 { |
703 return !!m_executionState; | 727 return m_isPaused; |
704 } | 728 } |
705 | 729 |
706 void DartScriptDebugServer::clearCompiledScripts() | 730 void DartScriptDebugServer::clearCompiledScripts() |
707 { | 731 { |
708 // FIXMEDART: is this meaningful for Dart? | 732 // FIXMEDART: is this meaningful for Dart? |
709 // Currently tracking what scripts have been compiled is handled by a | 733 // Currently tracking what scripts have been compiled is handled by a |
710 // different class. | 734 // different class. |
711 } | 735 } |
712 | 736 |
713 void DartScriptDebugServer::setPreprocessorSource(const String& preprocessorSour
ce) | 737 void DartScriptDebugServer::setPreprocessorSource(const String& preprocessorSour
ce) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 | 978 |
955 DartPageDebug* DartScriptDebugServer::lookupPageDebugForCurrentIsolate() | 979 DartPageDebug* DartScriptDebugServer::lookupPageDebugForCurrentIsolate() |
956 { | 980 { |
957 Page* page = DartUtilities::domWindowForCurrentIsolate()->document()->page()
; | 981 Page* page = DartUtilities::domWindowForCurrentIsolate()->document()->page()
; |
958 return lookupPageDebug(page); | 982 return lookupPageDebug(page); |
959 } | 983 } |
960 | 984 |
961 void DartScriptDebugServer::handleProgramBreak(Dart_Isolate isolate, Dart_StackT
race stackTrace, intptr_t dartBreakpointId, Dart_Handle exception, const Dart_Co
deLocation& location) | 985 void DartScriptDebugServer::handleProgramBreak(Dart_Isolate isolate, Dart_StackT
race stackTrace, intptr_t dartBreakpointId, Dart_Handle exception, const Dart_Co
deLocation& location) |
962 { | 986 { |
963 ASSERT(isolate == Dart_CurrentIsolate()); | 987 ASSERT(isolate == Dart_CurrentIsolate()); |
| 988 |
964 // Don't allow nested breaks. | 989 // Don't allow nested breaks. |
965 if (isAnyScriptPaused()) | 990 if (isAnyScriptPaused()) |
966 return; | 991 return; |
967 | 992 |
968 DartPageDebug* pageDebug = lookupPageDebugForCurrentIsolate(); | 993 DartPageDebug* pageDebug = lookupPageDebugForCurrentIsolate(); |
969 if (!pageDebug) | 994 if (!pageDebug) |
970 return; | 995 return; |
971 ScriptDebugListener* listener = pageDebug->listener(); | 996 ScriptDebugListener* listener = pageDebug->listener(); |
972 | 997 |
973 if (!listener) | 998 if (!listener) |
974 return; | 999 return; |
975 | 1000 |
976 // Required as some Dart code executes outside of a valid V8 scope when | 1001 // Required as some Dart code executes outside of a valid V8 scope when |
977 // the program is paused due to interrupting a Dart isolate. | 1002 // the program is paused due to interrupting a Dart isolate. |
978 V8Scope v8Scope(DartDOMData::current()); | 1003 V8Scope v8Scope(DartDOMData::current()); |
979 | 1004 |
980 Vector<String> breakpointIds; | 1005 Vector<String> breakpointIds; |
981 breakpointIds.append(pageDebug->lookupBreakpointId(dartBreakpointId)); | 1006 breakpointIds.append(pageDebug->lookupBreakpointId(dartBreakpointId)); |
982 m_executionState = stackTrace; | 1007 m_executionState = stackTrace; |
| 1008 m_isPaused = true; |
983 m_pausedIsolate = isolate; | 1009 m_pausedIsolate = isolate; |
984 DartScriptState* scriptState = DartUtilities::currentScriptState(); | 1010 DartScriptState* scriptState = DartUtilities::currentScriptState(); |
985 ScriptDebugListener::SkipPauseRequest result = listener->didPause(scriptStat
e, currentCallFrames(), exception ? DartUtilities::dartToScriptValue(exception)
: ScriptValue(), breakpointIds); | 1011 ScriptDebugListener::SkipPauseRequest result = listener->didPause(scriptStat
e, exception ? DartUtilities::dartToScriptValue(exception) : ScriptValue(), brea
kpointIds); |
986 | 1012 |
987 if (result == ScriptDebugListener::NoSkip) { | 1013 if (result == ScriptDebugListener::NoSkip) { |
988 m_runningNestedMessageLoop = true; | 1014 m_runningNestedMessageLoop = true; |
989 runMessageLoopOnPause(isolate); | 1015 runMessageLoopOnPause(isolate); |
990 m_runningNestedMessageLoop = false; | 1016 m_runningNestedMessageLoop = false; |
991 } | 1017 } |
992 if (result == ScriptDebugListener::StepInto) { | 1018 if (result == ScriptDebugListener::StepInto) { |
993 Dart_SetStepInto(); | 1019 Dart_SetStepInto(); |
994 } else if (result == ScriptDebugListener::StepOut) { | 1020 } else if (result == ScriptDebugListener::StepOut) { |
995 Dart_SetStepOut(); | 1021 Dart_SetStepOut(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 } | 1180 } |
1155 | 1181 |
1156 void UnifiedScriptDebugServer::setPauseOnExceptionsState(ScriptDebugServer::Paus
eOnExceptionsState pauseOnExceptionsState) | 1182 void UnifiedScriptDebugServer::setPauseOnExceptionsState(ScriptDebugServer::Paus
eOnExceptionsState pauseOnExceptionsState) |
1157 { | 1183 { |
1158 m_dart->setPauseOnExceptionsState(pauseOnExceptionsState); | 1184 m_dart->setPauseOnExceptionsState(pauseOnExceptionsState); |
1159 m_v8->setPauseOnExceptionsState(pauseOnExceptionsState); | 1185 m_v8->setPauseOnExceptionsState(pauseOnExceptionsState); |
1160 } | 1186 } |
1161 | 1187 |
1162 void UnifiedScriptDebugServer::setPauseOnNextStatement(bool pause) | 1188 void UnifiedScriptDebugServer::setPauseOnNextStatement(bool pause) |
1163 { | 1189 { |
1164 if (isPaused()) { | 1190 if (isPaused()) |
1165 return; | 1191 return; |
1166 } | |
1167 m_v8->setPauseOnNextStatement(pause); | 1192 m_v8->setPauseOnNextStatement(pause); |
1168 m_dart->setPauseOnNextStatement(pause); | 1193 m_dart->setPauseOnNextStatement(pause); |
1169 } | 1194 } |
1170 | 1195 |
1171 bool UnifiedScriptDebugServer::canBreakProgram() | 1196 bool UnifiedScriptDebugServer::canBreakProgram() |
1172 { | 1197 { |
1173 return m_v8->canBreakProgram() || m_dart->canBreakProgram(); | 1198 return m_v8->canBreakProgram() || m_dart->canBreakProgram(); |
1174 } | 1199 } |
1175 | 1200 |
1176 void UnifiedScriptDebugServer::breakProgram() | 1201 void UnifiedScriptDebugServer::breakProgram() |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 | 1257 |
1233 int UnifiedScriptDebugServer::frameCount() | 1258 int UnifiedScriptDebugServer::frameCount() |
1234 { | 1259 { |
1235 // FIXMEDART: Implement cases where both JS and Dart are paused correctly. | 1260 // FIXMEDART: Implement cases where both JS and Dart are paused correctly. |
1236 if (m_v8->isPaused()) { | 1261 if (m_v8->isPaused()) { |
1237 return m_v8->frameCount(); | 1262 return m_v8->frameCount(); |
1238 } | 1263 } |
1239 return m_dart->frameCount(); | 1264 return m_dart->frameCount(); |
1240 } | 1265 } |
1241 | 1266 |
1242 | |
1243 StackTrace UnifiedScriptDebugServer::currentCallFrames() | 1267 StackTrace UnifiedScriptDebugServer::currentCallFrames() |
1244 { | 1268 { |
1245 // FIXMEDART: we need to figure out how to interleave stack traces where pos
sible. | 1269 return StackTrace(m_v8->currentCallFrames(), m_dart->currentCallFrames()); |
1246 StackTrace v8StackTrace = m_v8->currentCallFrames(); | |
1247 if (!v8StackTrace.isNull()) | |
1248 return v8StackTrace; | |
1249 return m_dart->currentCallFrames(); | |
1250 } | 1270 } |
1251 | 1271 |
1252 StackTrace UnifiedScriptDebugServer::currentCallFramesForAsyncStack() | 1272 StackTrace UnifiedScriptDebugServer::currentCallFramesForAsyncStack() |
1253 { | 1273 { |
1254 // FIXMEDART: we need to figure out how to interleave stack traces where pos
sible. | 1274 // FIXMEDART: figure out how to interleave async stack traces once we |
| 1275 // actually support async stack traces properly for Dart. |
1255 StackTrace v8StackTrace = m_v8->currentCallFramesForAsyncStack(); | 1276 StackTrace v8StackTrace = m_v8->currentCallFramesForAsyncStack(); |
1256 if (!v8StackTrace.isNull()) | 1277 if (!v8StackTrace.isNull()) |
1257 return v8StackTrace; | 1278 return v8StackTrace; |
1258 return m_dart->currentCallFramesForAsyncStack(); | 1279 return m_dart->currentCallFramesForAsyncStack(); |
1259 } | 1280 } |
1260 | 1281 |
1261 | |
1262 bool UnifiedScriptDebugServer::isPaused() | 1282 bool UnifiedScriptDebugServer::isPaused() |
1263 { | 1283 { |
1264 return m_v8->isPaused() || m_dart->isPaused(); | 1284 return m_v8->isPaused() || m_dart->isPaused(); |
1265 } | 1285 } |
1266 | 1286 |
1267 bool UnifiedScriptDebugServer::runningNestedMessageLoop() | 1287 bool UnifiedScriptDebugServer::runningNestedMessageLoop() |
1268 { | 1288 { |
1269 return m_dart->runningNestedMessageLoop() || m_v8->runningNestedMessageLoop(
); | 1289 return m_dart->runningNestedMessageLoop() || m_v8->runningNestedMessageLoop(
); |
1270 } | 1290 } |
1271 | 1291 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 MessageQueue<ScriptDebugServer::Task>& tasks = debugTaskQueue(); | 1356 MessageQueue<ScriptDebugServer::Task>& tasks = debugTaskQueue(); |
1337 tasks.append(task); | 1357 tasks.append(task); |
1338 // The first VM interrupt method triggered will drain the task queue. | 1358 // The first VM interrupt method triggered will drain the task queue. |
1339 // FIXMEDART: refactor the V8 code to have an interruptAndRunAllTasks | 1359 // FIXMEDART: refactor the V8 code to have an interruptAndRunAllTasks |
1340 // method. | 1360 // method. |
1341 PageScriptDebugServer::interruptAndRun(adoptPtr(new DrainQueueTask(&tasks)))
; | 1361 PageScriptDebugServer::interruptAndRun(adoptPtr(new DrainQueueTask(&tasks)))
; |
1342 DartScriptDebugServer::interruptAndRunAllTasks(); | 1362 DartScriptDebugServer::interruptAndRunAllTasks(); |
1343 } | 1363 } |
1344 | 1364 |
1345 } | 1365 } |
OLD | NEW |