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

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

Issue 2842733002: [inspector] V8DebuggerAgent should not resume break in different group (Closed)
Patch Set: Created 3 years, 8 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.cc » ('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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return function->Call(context, debuggerScript, argc, argv); 165 return function->Call(context, debuggerScript, argc, argv);
166 } 166 }
167 return function->Call(context, debuggerScript, argc, argv); 167 return function->Call(context, debuggerScript, argc, argv);
168 } 168 }
169 169
170 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) 170 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector)
171 : m_isolate(isolate), 171 : m_isolate(isolate),
172 m_inspector(inspector), 172 m_inspector(inspector),
173 m_enableCount(0), 173 m_enableCount(0),
174 m_breakpointsActivated(true), 174 m_breakpointsActivated(true),
175 m_runningNestedMessageLoop(false),
176 m_ignoreScriptParsedEventsCounter(0), 175 m_ignoreScriptParsedEventsCounter(0),
177 m_maxAsyncCallStacks(kMaxAsyncTaskStacks), 176 m_maxAsyncCallStacks(kMaxAsyncTaskStacks),
178 m_maxAsyncCallStackDepth(0), 177 m_maxAsyncCallStackDepth(0),
179 m_pauseOnExceptionsState(v8::debug::NoBreakOnException), 178 m_pauseOnExceptionsState(v8::debug::NoBreakOnException),
180 m_wasmTranslation(isolate) {} 179 m_wasmTranslation(isolate) {}
181 180
182 V8Debugger::~V8Debugger() {} 181 V8Debugger::~V8Debugger() {}
183 182
184 void V8Debugger::enable() { 183 void V8Debugger::enable() {
185 if (m_enableCount++) return; 184 if (m_enableCount++) return;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return !v8::debug::AllFramesOnStackAreBlackboxed(m_isolate); 354 return !v8::debug::AllFramesOnStackAreBlackboxed(m_isolate);
356 } 355 }
357 356
358 void V8Debugger::breakProgram() { 357 void V8Debugger::breakProgram() {
359 // Don't allow nested breaks. 358 // Don't allow nested breaks.
360 if (isPaused()) return; 359 if (isPaused()) return;
361 if (!canBreakProgram()) return; 360 if (!canBreakProgram()) return;
362 v8::debug::BreakRightNow(m_isolate); 361 v8::debug::BreakRightNow(m_isolate);
363 } 362 }
364 363
365 void V8Debugger::continueProgram() { 364 void V8Debugger::continueProgram(int targetContextGroupId) {
365 if (m_pausedContextGroupId != targetContextGroupId) return;
366 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); 366 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause();
367 m_pausedContext.Clear(); 367 m_pausedContext.Clear();
368 m_executionState.Clear(); 368 m_executionState.Clear();
369 } 369 }
370 370
371 void V8Debugger::stepIntoStatement(int targetContextGroupId) { 371 void V8Debugger::stepIntoStatement(int targetContextGroupId) {
372 DCHECK(isPaused()); 372 DCHECK(isPaused());
373 DCHECK(!m_executionState.IsEmpty()); 373 DCHECK(!m_executionState.IsEmpty());
374 DCHECK(targetContextGroupId); 374 DCHECK(targetContextGroupId);
375 m_targetContextGroupId = targetContextGroupId; 375 m_targetContextGroupId = targetContextGroupId;
376 v8::debug::PrepareStep(m_isolate, v8::debug::StepIn); 376 v8::debug::PrepareStep(m_isolate, v8::debug::StepIn);
377 continueProgram(); 377 continueProgram(targetContextGroupId);
378 } 378 }
379 379
380 void V8Debugger::stepOverStatement(int targetContextGroupId) { 380 void V8Debugger::stepOverStatement(int targetContextGroupId) {
381 DCHECK(isPaused()); 381 DCHECK(isPaused());
382 DCHECK(!m_executionState.IsEmpty()); 382 DCHECK(!m_executionState.IsEmpty());
383 DCHECK(targetContextGroupId); 383 DCHECK(targetContextGroupId);
384 m_targetContextGroupId = targetContextGroupId; 384 m_targetContextGroupId = targetContextGroupId;
385 v8::debug::PrepareStep(m_isolate, v8::debug::StepNext); 385 v8::debug::PrepareStep(m_isolate, v8::debug::StepNext);
386 continueProgram(); 386 continueProgram(targetContextGroupId);
387 } 387 }
388 388
389 void V8Debugger::stepOutOfFunction(int targetContextGroupId) { 389 void V8Debugger::stepOutOfFunction(int targetContextGroupId) {
390 DCHECK(isPaused()); 390 DCHECK(isPaused());
391 DCHECK(!m_executionState.IsEmpty()); 391 DCHECK(!m_executionState.IsEmpty());
392 DCHECK(targetContextGroupId); 392 DCHECK(targetContextGroupId);
393 m_targetContextGroupId = targetContextGroupId; 393 m_targetContextGroupId = targetContextGroupId;
394 v8::debug::PrepareStep(m_isolate, v8::debug::StepOut); 394 v8::debug::PrepareStep(m_isolate, v8::debug::StepOut);
395 continueProgram(); 395 continueProgram(targetContextGroupId);
396 } 396 }
397 397
398 void V8Debugger::scheduleStepIntoAsync( 398 void V8Debugger::scheduleStepIntoAsync(
399 std::unique_ptr<ScheduleStepIntoAsyncCallback> callback, 399 std::unique_ptr<ScheduleStepIntoAsyncCallback> callback,
400 int targetContextGroupId) { 400 int targetContextGroupId) {
401 DCHECK(isPaused()); 401 DCHECK(isPaused());
402 DCHECK(!m_executionState.IsEmpty()); 402 DCHECK(!m_executionState.IsEmpty());
403 DCHECK(targetContextGroupId); 403 DCHECK(targetContextGroupId);
404 if (m_stepIntoAsyncCallback) { 404 if (m_stepIntoAsyncCallback) {
405 m_stepIntoAsyncCallback->sendFailure(Response::Error( 405 m_stepIntoAsyncCallback->sendFailure(Response::Error(
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 v8::Local<v8::Value> hitBreakpointNumber = 561 v8::Local<v8::Value> hitBreakpointNumber =
562 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); 562 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked();
563 DCHECK(hitBreakpointNumber->IsInt32()); 563 DCHECK(hitBreakpointNumber->IsInt32());
564 breakpointIds.push_back(String16::fromInteger( 564 breakpointIds.push_back(String16::fromInteger(
565 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); 565 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust()));
566 } 566 }
567 } 567 }
568 568
569 m_pausedContext = pausedContext; 569 m_pausedContext = pausedContext;
570 m_executionState = executionState; 570 m_executionState = executionState;
571 m_runningNestedMessageLoop = true; 571 m_pausedContextGroupId = contextGroupId;
572 agent->didPause(InspectedContext::contextId(pausedContext), exception, 572 agent->didPause(InspectedContext::contextId(pausedContext), exception,
573 breakpointIds, isPromiseRejection, isUncaught, 573 breakpointIds, isPromiseRejection, isUncaught,
574 m_scheduledOOMBreak); 574 m_scheduledOOMBreak);
575 int groupId = m_inspector->contextGroupId(pausedContext); 575 int groupId = m_inspector->contextGroupId(pausedContext);
576 DCHECK(groupId); 576 DCHECK(groupId);
577 { 577 {
578 v8::Context::Scope scope(pausedContext); 578 v8::Context::Scope scope(pausedContext);
579 v8::Local<v8::Context> context = m_isolate->GetCurrentContext(); 579 v8::Local<v8::Context> context = m_isolate->GetCurrentContext();
580 CHECK(!context.IsEmpty() && 580 CHECK(!context.IsEmpty() &&
581 context != v8::debug::GetDebugContext(m_isolate)); 581 context != v8::debug::GetDebugContext(m_isolate));
582 m_inspector->client()->runMessageLoopOnPause(groupId); 582 m_inspector->client()->runMessageLoopOnPause(groupId);
583 m_runningNestedMessageLoop = false; 583 m_pausedContextGroupId = 0;
584 } 584 }
585 // The agent may have been removed in the nested loop. 585 // The agent may have been removed in the nested loop.
586 agent = m_inspector->enabledDebuggerAgentForGroup(groupId); 586 agent = m_inspector->enabledDebuggerAgentForGroup(groupId);
587 if (agent) agent->didContinue(); 587 if (agent) agent->didContinue();
588 if (m_scheduledOOMBreak) m_isolate->RestoreOriginalHeapLimit(); 588 if (m_scheduledOOMBreak) m_isolate->RestoreOriginalHeapLimit();
589 m_scheduledOOMBreak = false; 589 m_scheduledOOMBreak = false;
590 m_pausedContext.Clear(); 590 m_pausedContext.Clear();
591 m_executionState.Clear(); 591 m_executionState.Clear();
592 } 592 }
593 593
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); 1077 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount);
1078 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); 1078 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size());
1079 fprintf(stdout, "Created async tasks: %zu\n", 1079 fprintf(stdout, "Created async tasks: %zu\n",
1080 m_asyncTaskCreationStacks.size()); 1080 m_asyncTaskCreationStacks.size());
1081 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); 1081 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size());
1082 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); 1082 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size());
1083 fprintf(stdout, "\n"); 1083 fprintf(stdout, "\n");
1084 } 1084 }
1085 1085
1086 } // namespace v8_inspector 1086 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | src/inspector/v8-debugger-agent-impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698