Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: Source/bindings/dart/DartScriptDebugServer.cpp

Issue 466243002: Support merged Dart-JS callstacks (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/dartium
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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 return StackTrace(m_peer->currentCallFramesForVm(), currentCallFramesForVm() );
695 }
696
697 StackTrace DartScriptDebugServer::currentCallFramesForVm()
698 {
699 if (!m_executionState && Dart_CurrentIsolate()) {
700 ASSERT(!m_isPaused);
701 // We are not paused at a Dart breakpoint but there may be Dart frames
702 // on the call stack.
703 DartDOMData* dartDOMData = DartDOMData::current();
vsm 2014/08/13 14:26:45 Will this ever be NULL if Dart_CurrentIsolate is n
Jacob 2014/08/13 21:36:15 It won't be null. Removed that check. There are pl
704 if (!dartDOMData || dartDOMData->stackTraceTimestampTracker()->recursion Level() == 0)
705 return StackTrace();
706
707 Dart_Handle ALLOW_UNUSED result = Dart_GetStackTrace(&m_executionState);
708 ASSERT(!Dart_IsError(result));
709 if (!m_executionState)
710 return StackTrace();
711 intptr_t length = 0;
712 Dart_StackTraceLength(m_executionState, &length);
713 ASSERT(length);
vsm 2014/08/13 14:26:45 nit: you could drop an ASSERT_NOT_REACHED() into t
Jacob 2014/08/13 21:36:15 Done.
714 if (!length) {
715 m_executionState = 0;
716 return StackTrace();
717 }
718 }
719 return StackTrace(m_executionState, DartUtilities::currentScriptState());
693 } 720 }
694 721
695 StackTrace DartScriptDebugServer::currentCallFramesForAsyncStack() 722 StackTrace DartScriptDebugServer::currentCallFramesForAsyncStack()
696 { 723 {
697 // FIXMEDART: implement propertly. These are the regular not Async call fram es. 724 // FIXMEDART: implement propertly. These are the regular not Async call fram es.
698 return StackTrace(m_executionState); 725 return StackTrace(m_executionState, DartUtilities::currentScriptState());
699 } 726 }
700 727
701 bool DartScriptDebugServer::isPaused() 728 bool DartScriptDebugServer::isPaused()
702 { 729 {
703 return !!m_executionState; 730 return m_isPaused;
704 } 731 }
705 732
706 void DartScriptDebugServer::clearCompiledScripts() 733 void DartScriptDebugServer::clearCompiledScripts()
707 { 734 {
708 // FIXMEDART: is this meaningful for Dart? 735 // FIXMEDART: is this meaningful for Dart?
709 // Currently tracking what scripts have been compiled is handled by a 736 // Currently tracking what scripts have been compiled is handled by a
710 // different class. 737 // different class.
711 } 738 }
712 739
713 void DartScriptDebugServer::setPreprocessorSource(const String& preprocessorSour ce) 740 void DartScriptDebugServer::setPreprocessorSource(const String& preprocessorSour ce)
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 981
955 DartPageDebug* DartScriptDebugServer::lookupPageDebugForCurrentIsolate() 982 DartPageDebug* DartScriptDebugServer::lookupPageDebugForCurrentIsolate()
956 { 983 {
957 Page* page = DartUtilities::domWindowForCurrentIsolate()->document()->page() ; 984 Page* page = DartUtilities::domWindowForCurrentIsolate()->document()->page() ;
958 return lookupPageDebug(page); 985 return lookupPageDebug(page);
959 } 986 }
960 987
961 void DartScriptDebugServer::handleProgramBreak(Dart_Isolate isolate, Dart_StackT race stackTrace, intptr_t dartBreakpointId, Dart_Handle exception, const Dart_Co deLocation& location) 988 void DartScriptDebugServer::handleProgramBreak(Dart_Isolate isolate, Dart_StackT race stackTrace, intptr_t dartBreakpointId, Dart_Handle exception, const Dart_Co deLocation& location)
962 { 989 {
963 ASSERT(isolate == Dart_CurrentIsolate()); 990 ASSERT(isolate == Dart_CurrentIsolate());
991
964 // Don't allow nested breaks. 992 // Don't allow nested breaks.
965 if (isAnyScriptPaused()) 993 if (isAnyScriptPaused())
966 return; 994 return;
967 995
968 DartPageDebug* pageDebug = lookupPageDebugForCurrentIsolate(); 996 DartPageDebug* pageDebug = lookupPageDebugForCurrentIsolate();
969 if (!pageDebug) 997 if (!pageDebug)
970 return; 998 return;
971 ScriptDebugListener* listener = pageDebug->listener(); 999 ScriptDebugListener* listener = pageDebug->listener();
972 1000
973 if (!listener) 1001 if (!listener)
974 return; 1002 return;
975 1003
976 // Required as some Dart code executes outside of a valid V8 scope when 1004 // Required as some Dart code executes outside of a valid V8 scope when
977 // the program is paused due to interrupting a Dart isolate. 1005 // the program is paused due to interrupting a Dart isolate.
978 V8Scope v8Scope(DartDOMData::current()); 1006 V8Scope v8Scope(DartDOMData::current());
979 1007
980 Vector<String> breakpointIds; 1008 Vector<String> breakpointIds;
981 breakpointIds.append(pageDebug->lookupBreakpointId(dartBreakpointId)); 1009 breakpointIds.append(pageDebug->lookupBreakpointId(dartBreakpointId));
982 m_executionState = stackTrace; 1010 m_executionState = stackTrace;
1011 m_isPaused = true;
983 m_pausedIsolate = isolate; 1012 m_pausedIsolate = isolate;
984 DartScriptState* scriptState = DartUtilities::currentScriptState(); 1013 DartScriptState* scriptState = DartUtilities::currentScriptState();
985 ScriptDebugListener::SkipPauseRequest result = listener->didPause(scriptStat e, currentCallFrames(), exception ? DartUtilities::dartToScriptValue(exception) : ScriptValue(), breakpointIds); 1014 ScriptDebugListener::SkipPauseRequest result = listener->didPause(scriptStat e, currentCallFrames(), exception ? DartUtilities::dartToScriptValue(exception) : ScriptValue(), breakpointIds);
986 1015
987 if (result == ScriptDebugListener::NoSkip) { 1016 if (result == ScriptDebugListener::NoSkip) {
988 m_runningNestedMessageLoop = true; 1017 m_runningNestedMessageLoop = true;
989 runMessageLoopOnPause(isolate); 1018 runMessageLoopOnPause(isolate);
990 m_runningNestedMessageLoop = false; 1019 m_runningNestedMessageLoop = false;
991 } 1020 }
992 if (result == ScriptDebugListener::StepInto) { 1021 if (result == ScriptDebugListener::StepInto) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 } 1183 }
1155 1184
1156 void UnifiedScriptDebugServer::setPauseOnExceptionsState(ScriptDebugServer::Paus eOnExceptionsState pauseOnExceptionsState) 1185 void UnifiedScriptDebugServer::setPauseOnExceptionsState(ScriptDebugServer::Paus eOnExceptionsState pauseOnExceptionsState)
1157 { 1186 {
1158 m_dart->setPauseOnExceptionsState(pauseOnExceptionsState); 1187 m_dart->setPauseOnExceptionsState(pauseOnExceptionsState);
1159 m_v8->setPauseOnExceptionsState(pauseOnExceptionsState); 1188 m_v8->setPauseOnExceptionsState(pauseOnExceptionsState);
1160 } 1189 }
1161 1190
1162 void UnifiedScriptDebugServer::setPauseOnNextStatement(bool pause) 1191 void UnifiedScriptDebugServer::setPauseOnNextStatement(bool pause)
1163 { 1192 {
1164 if (isPaused()) { 1193 if (isPaused())
1165 return; 1194 return;
1166 }
1167 m_v8->setPauseOnNextStatement(pause); 1195 m_v8->setPauseOnNextStatement(pause);
1168 m_dart->setPauseOnNextStatement(pause); 1196 m_dart->setPauseOnNextStatement(pause);
1169 } 1197 }
1170 1198
1171 bool UnifiedScriptDebugServer::canBreakProgram() 1199 bool UnifiedScriptDebugServer::canBreakProgram()
1172 { 1200 {
1173 return m_v8->canBreakProgram() || m_dart->canBreakProgram(); 1201 return m_v8->canBreakProgram() || m_dart->canBreakProgram();
1174 } 1202 }
1175 1203
1176 void UnifiedScriptDebugServer::breakProgram() 1204 void UnifiedScriptDebugServer::breakProgram()
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 int UnifiedScriptDebugServer::frameCount() 1261 int UnifiedScriptDebugServer::frameCount()
1234 { 1262 {
1235 // FIXMEDART: Implement cases where both JS and Dart are paused correctly. 1263 // FIXMEDART: Implement cases where both JS and Dart are paused correctly.
1236 if (m_v8->isPaused()) { 1264 if (m_v8->isPaused()) {
1237 return m_v8->frameCount(); 1265 return m_v8->frameCount();
1238 } 1266 }
1239 return m_dart->frameCount(); 1267 return m_dart->frameCount();
1240 } 1268 }
1241 1269
1242 1270
1271 StackTrace UnifiedScriptDebugServer::currentCallFramesForVm()
1272 {
1273 return currentCallFrames();
1274 }
1275
1243 StackTrace UnifiedScriptDebugServer::currentCallFrames() 1276 StackTrace UnifiedScriptDebugServer::currentCallFrames()
1244 { 1277 {
1245 // FIXMEDART: we need to figure out how to interleave stack traces where pos sible. 1278 return StackTrace(m_v8->currentCallFramesForVm(), m_dart->currentCallFramesF orVm());
1246 StackTrace v8StackTrace = m_v8->currentCallFrames();
1247 if (!v8StackTrace.isNull())
1248 return v8StackTrace;
1249 return m_dart->currentCallFrames();
1250 } 1279 }
1251 1280
1252 StackTrace UnifiedScriptDebugServer::currentCallFramesForAsyncStack() 1281 StackTrace UnifiedScriptDebugServer::currentCallFramesForAsyncStack()
1253 { 1282 {
1254 // FIXMEDART: we need to figure out how to interleave stack traces where pos sible. 1283 // FIXMEDART: figure out how to interleave async stack traces once we
1284 // actually support async stack traces properly for Dart.
1255 StackTrace v8StackTrace = m_v8->currentCallFramesForAsyncStack(); 1285 StackTrace v8StackTrace = m_v8->currentCallFramesForAsyncStack();
1256 if (!v8StackTrace.isNull()) 1286 if (!v8StackTrace.isNull())
1257 return v8StackTrace; 1287 return v8StackTrace;
1258 return m_dart->currentCallFramesForAsyncStack(); 1288 return m_dart->currentCallFramesForAsyncStack();
1259 } 1289 }
1260 1290
1261 1291
1262 bool UnifiedScriptDebugServer::isPaused() 1292 bool UnifiedScriptDebugServer::isPaused()
1263 { 1293 {
1264 return m_v8->isPaused() || m_dart->isPaused(); 1294 return m_v8->isPaused() || m_dart->isPaused();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 MessageQueue<ScriptDebugServer::Task>& tasks = debugTaskQueue(); 1366 MessageQueue<ScriptDebugServer::Task>& tasks = debugTaskQueue();
1337 tasks.append(task); 1367 tasks.append(task);
1338 // The first VM interrupt method triggered will drain the task queue. 1368 // The first VM interrupt method triggered will drain the task queue.
1339 // FIXMEDART: refactor the V8 code to have an interruptAndRunAllTasks 1369 // FIXMEDART: refactor the V8 code to have an interruptAndRunAllTasks
1340 // method. 1370 // method.
1341 PageScriptDebugServer::interruptAndRun(adoptPtr(new DrainQueueTask(&tasks))) ; 1371 PageScriptDebugServer::interruptAndRun(adoptPtr(new DrainQueueTask(&tasks))) ;
1342 DartScriptDebugServer::interruptAndRunAllTasks(); 1372 DartScriptDebugServer::interruptAndRunAllTasks();
1343 } 1373 }
1344 1374
1345 } 1375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698