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

Side by Side Diff: src/inspector/v8-debugger.cc

Issue 2916363002: [inspector] Make pausing on console.assert work with multiple sessions (Closed)
Patch Set: rebased Created 3 years, 6 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
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | src/inspector/v8-debugger-agent-impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/v8-debugger.h" 5 #include "src/inspector/v8-debugger.h"
6 6
7 #include "src/inspector/debugger-script.h" 7 #include "src/inspector/debugger-script.h"
8 #include "src/inspector/inspected-context.h" 8 #include "src/inspector/inspected-context.h"
9 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
10 #include "src/inspector/script-breakpoint.h" 10 #include "src/inspector/script-breakpoint.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 v8::debug::BreakRightNow(m_isolate); 356 v8::debug::BreakRightNow(m_isolate);
357 } 357 }
358 358
359 void V8Debugger::continueProgram(int targetContextGroupId) { 359 void V8Debugger::continueProgram(int targetContextGroupId) {
360 if (m_pausedContextGroupId != targetContextGroupId) return; 360 if (m_pausedContextGroupId != targetContextGroupId) return;
361 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); 361 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause();
362 m_pausedContext.Clear(); 362 m_pausedContext.Clear();
363 m_executionState.Clear(); 363 m_executionState.Clear();
364 } 364 }
365 365
366 void V8Debugger::breakProgramOnAssert(int targetContextGroupId) {
367 if (!enabled()) return;
368 if (m_pauseOnExceptionsState == v8::debug::NoBreakOnException) return;
369 // Don't allow nested breaks.
370 if (isPaused()) return;
371 if (!canBreakProgram()) return;
372 DCHECK(targetContextGroupId);
373 m_targetContextGroupId = targetContextGroupId;
374 m_scheduledAssertBreak = true;
375 v8::debug::BreakRightNow(m_isolate);
376 }
377
366 void V8Debugger::stepIntoStatement(int targetContextGroupId) { 378 void V8Debugger::stepIntoStatement(int targetContextGroupId) {
367 DCHECK(isPaused()); 379 DCHECK(isPaused());
368 DCHECK(!m_executionState.IsEmpty()); 380 DCHECK(!m_executionState.IsEmpty());
369 DCHECK(targetContextGroupId); 381 DCHECK(targetContextGroupId);
370 m_targetContextGroupId = targetContextGroupId; 382 m_targetContextGroupId = targetContextGroupId;
371 v8::debug::PrepareStep(m_isolate, v8::debug::StepIn); 383 v8::debug::PrepareStep(m_isolate, v8::debug::StepIn);
372 continueProgram(targetContextGroupId); 384 continueProgram(targetContextGroupId);
373 } 385 }
374 386
375 void V8Debugger::stepOverStatement(int targetContextGroupId) { 387 void V8Debugger::stepOverStatement(int targetContextGroupId) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 } 604 }
593 m_targetContextGroupId = 0; 605 m_targetContextGroupId = 0;
594 if (m_stepIntoAsyncCallback) { 606 if (m_stepIntoAsyncCallback) {
595 m_stepIntoAsyncCallback->sendFailure( 607 m_stepIntoAsyncCallback->sendFailure(
596 Response::Error("No async tasks were scheduled before pause.")); 608 Response::Error("No async tasks were scheduled before pause."));
597 m_stepIntoAsyncCallback.reset(); 609 m_stepIntoAsyncCallback.reset();
598 } 610 }
599 m_breakRequested = false; 611 m_breakRequested = false;
600 612
601 bool scheduledOOMBreak = m_scheduledOOMBreak; 613 bool scheduledOOMBreak = m_scheduledOOMBreak;
614 bool scheduledAssertBreak = m_scheduledAssertBreak;
602 auto agentCheck = [&scheduledOOMBreak](V8DebuggerAgentImpl* agent) { 615 auto agentCheck = [&scheduledOOMBreak](V8DebuggerAgentImpl* agent) {
603 return agent->enabled() && (scheduledOOMBreak || !agent->skipAllPauses()); 616 return agent->enabled() && (scheduledOOMBreak || !agent->skipAllPauses());
604 }; 617 };
605 618
606 bool hasAgents = false; 619 bool hasAgents = false;
607 m_inspector->forEachSession( 620 m_inspector->forEachSession(
608 contextGroupId, 621 contextGroupId,
609 [&agentCheck, &hasAgents](V8InspectorSessionImpl* session) { 622 [&agentCheck, &hasAgents](V8InspectorSessionImpl* session) {
610 if (agentCheck(session->debuggerAgent())) hasAgents = true; 623 if (agentCheck(session->debuggerAgent())) hasAgents = true;
611 }); 624 });
(...skipping 17 matching lines...) Expand all
629 } 642 }
630 clearContinueToLocation(); 643 clearContinueToLocation();
631 644
632 DCHECK(contextGroupId); 645 DCHECK(contextGroupId);
633 m_pausedContext = pausedContext; 646 m_pausedContext = pausedContext;
634 m_executionState = executionState; 647 m_executionState = executionState;
635 m_pausedContextGroupId = contextGroupId; 648 m_pausedContextGroupId = contextGroupId;
636 649
637 m_inspector->forEachSession( 650 m_inspector->forEachSession(
638 contextGroupId, [&agentCheck, &pausedContext, &exception, &breakpointIds, 651 contextGroupId, [&agentCheck, &pausedContext, &exception, &breakpointIds,
639 &isPromiseRejection, &isUncaught, 652 &isPromiseRejection, &isUncaught, &scheduledOOMBreak,
640 &scheduledOOMBreak](V8InspectorSessionImpl* session) { 653 &scheduledAssertBreak](V8InspectorSessionImpl* session) {
641 if (agentCheck(session->debuggerAgent())) { 654 if (agentCheck(session->debuggerAgent())) {
642 session->debuggerAgent()->didPause( 655 session->debuggerAgent()->didPause(
643 InspectedContext::contextId(pausedContext), exception, 656 InspectedContext::contextId(pausedContext), exception,
644 breakpointIds, isPromiseRejection, isUncaught, scheduledOOMBreak); 657 breakpointIds, isPromiseRejection, isUncaught, scheduledOOMBreak,
658 scheduledAssertBreak);
645 } 659 }
646 }); 660 });
647 { 661 {
648 v8::Context::Scope scope(pausedContext); 662 v8::Context::Scope scope(pausedContext);
649 v8::Local<v8::Context> context = m_isolate->GetCurrentContext(); 663 v8::Local<v8::Context> context = m_isolate->GetCurrentContext();
650 CHECK(!context.IsEmpty() && 664 CHECK(!context.IsEmpty() &&
651 context != v8::debug::GetDebugContext(m_isolate)); 665 context != v8::debug::GetDebugContext(m_isolate));
652 m_inspector->client()->runMessageLoopOnPause(contextGroupId); 666 m_inspector->client()->runMessageLoopOnPause(contextGroupId);
653 m_pausedContextGroupId = 0; 667 m_pausedContextGroupId = 0;
654 } 668 }
655 m_inspector->forEachSession(contextGroupId, 669 m_inspector->forEachSession(contextGroupId,
656 [](V8InspectorSessionImpl* session) { 670 [](V8InspectorSessionImpl* session) {
657 if (session->debuggerAgent()->enabled()) 671 if (session->debuggerAgent()->enabled())
658 session->debuggerAgent()->didContinue(); 672 session->debuggerAgent()->didContinue();
659 }); 673 });
660 674
661 if (m_scheduledOOMBreak) m_isolate->RestoreOriginalHeapLimit(); 675 if (m_scheduledOOMBreak) m_isolate->RestoreOriginalHeapLimit();
662 m_scheduledOOMBreak = false; 676 m_scheduledOOMBreak = false;
677 m_scheduledAssertBreak = false;
663 m_pausedContext.Clear(); 678 m_pausedContext.Clear();
664 m_executionState.Clear(); 679 m_executionState.Clear();
665 } 680 }
666 681
667 void V8Debugger::v8OOMCallback(void* data) { 682 void V8Debugger::v8OOMCallback(void* data) {
668 V8Debugger* thisPtr = static_cast<V8Debugger*>(data); 683 V8Debugger* thisPtr = static_cast<V8Debugger*>(data);
669 thisPtr->m_isolate->IncreaseHeapLimitForDebugging(); 684 thisPtr->m_isolate->IncreaseHeapLimitForDebugging();
670 thisPtr->m_scheduledOOMBreak = true; 685 thisPtr->m_scheduledOOMBreak = true;
671 v8::Local<v8::Context> context = thisPtr->m_isolate->GetEnteredContext(); 686 v8::Local<v8::Context> context = thisPtr->m_isolate->GetEnteredContext();
672 DCHECK(!context.IsEmpty()); 687 DCHECK(!context.IsEmpty());
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); 1208 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount);
1194 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); 1209 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size());
1195 fprintf(stdout, "Created async tasks: %zu\n", 1210 fprintf(stdout, "Created async tasks: %zu\n",
1196 m_asyncTaskCreationStacks.size()); 1211 m_asyncTaskCreationStacks.size());
1197 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); 1212 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size());
1198 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); 1213 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size());
1199 fprintf(stdout, "\n"); 1214 fprintf(stdout, "\n");
1200 } 1215 }
1201 1216
1202 } // namespace v8_inspector 1217 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | src/inspector/v8-debugger-agent-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698