OLD | NEW |
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, | 468 void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, |
469 v8::Local<v8::Object> executionState, | 469 v8::Local<v8::Object> executionState, |
470 v8::Local<v8::Value> exception, | 470 v8::Local<v8::Value> exception, |
471 v8::Local<v8::Array> hitBreakpointNumbers, | 471 v8::Local<v8::Array> hitBreakpointNumbers, |
472 bool isPromiseRejection, bool isUncaught) { | 472 bool isPromiseRejection, bool isUncaught) { |
473 // Don't allow nested breaks. | 473 // Don't allow nested breaks. |
474 if (m_runningNestedMessageLoop) return; | 474 if (m_runningNestedMessageLoop) return; |
475 | 475 |
476 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup( | 476 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup( |
477 m_inspector->contextGroupId(pausedContext)); | 477 m_inspector->contextGroupId(pausedContext)); |
478 if (!agent) return; | 478 if (!agent || (agent->skipAllPauses() && !m_scheduledOOMBreak)) return; |
479 | 479 |
480 std::vector<String16> breakpointIds; | 480 std::vector<String16> breakpointIds; |
481 if (!hitBreakpointNumbers.IsEmpty()) { | 481 if (!hitBreakpointNumbers.IsEmpty()) { |
482 breakpointIds.reserve(hitBreakpointNumbers->Length()); | 482 breakpointIds.reserve(hitBreakpointNumbers->Length()); |
483 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 483 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
484 v8::Local<v8::Value> hitBreakpointNumber = | 484 v8::Local<v8::Value> hitBreakpointNumber = |
485 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); | 485 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); |
486 DCHECK(hitBreakpointNumber->IsInt32()); | 486 DCHECK(hitBreakpointNumber->IsInt32()); |
487 breakpointIds.push_back(String16::fromInteger( | 487 breakpointIds.push_back(String16::fromInteger( |
488 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); | 488 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 m_pausedContext = pausedContext; | 492 m_pausedContext = pausedContext; |
493 m_executionState = executionState; | 493 m_executionState = executionState; |
494 bool shouldPause = | 494 agent->didPause(InspectedContext::contextId(pausedContext), exception, |
495 agent->didPause(pausedContext, exception, breakpointIds, | 495 breakpointIds, isPromiseRejection, isUncaught, |
496 isPromiseRejection, isUncaught, m_scheduledOOMBreak); | 496 m_scheduledOOMBreak); |
497 if (shouldPause) { | 497 m_runningNestedMessageLoop = true; |
498 m_runningNestedMessageLoop = true; | 498 int groupId = m_inspector->contextGroupId(pausedContext); |
499 int groupId = m_inspector->contextGroupId(pausedContext); | 499 DCHECK(groupId); |
500 DCHECK(groupId); | 500 { |
501 v8::Context::Scope scope(pausedContext); | 501 v8::Context::Scope scope(pausedContext); |
502 v8::Local<v8::Context> context = m_isolate->GetCurrentContext(); | 502 v8::Local<v8::Context> context = m_isolate->GetCurrentContext(); |
503 CHECK(!context.IsEmpty() && | 503 CHECK(!context.IsEmpty() && |
504 context != v8::debug::GetDebugContext(m_isolate)); | 504 context != v8::debug::GetDebugContext(m_isolate)); |
505 m_inspector->client()->runMessageLoopOnPause(groupId); | 505 m_inspector->client()->runMessageLoopOnPause(groupId); |
506 // The agent may have been removed in the nested loop. | |
507 agent = m_inspector->enabledDebuggerAgentForGroup( | |
508 m_inspector->contextGroupId(pausedContext)); | |
509 if (agent) agent->didContinue(); | |
510 m_runningNestedMessageLoop = false; | |
511 } | 506 } |
| 507 m_runningNestedMessageLoop = false; |
| 508 // The agent may have been removed in the nested loop. |
| 509 agent = m_inspector->enabledDebuggerAgentForGroup(groupId); |
| 510 if (agent) agent->didContinue(); |
512 if (m_scheduledOOMBreak) m_isolate->RestoreOriginalHeapLimit(); | 511 if (m_scheduledOOMBreak) m_isolate->RestoreOriginalHeapLimit(); |
513 m_scheduledOOMBreak = false; | 512 m_scheduledOOMBreak = false; |
514 m_pausedContext.Clear(); | 513 m_pausedContext.Clear(); |
515 m_executionState.Clear(); | 514 m_executionState.Clear(); |
516 } | 515 } |
517 | 516 |
518 void V8Debugger::v8OOMCallback(void* data) { | 517 void V8Debugger::v8OOMCallback(void* data) { |
519 V8Debugger* thisPtr = static_cast<V8Debugger*>(data); | 518 V8Debugger* thisPtr = static_cast<V8Debugger*>(data); |
520 thisPtr->m_isolate->IncreaseHeapLimitForDebugging(); | 519 thisPtr->m_isolate->IncreaseHeapLimitForDebugging(); |
521 thisPtr->m_scheduledOOMBreak = true; | 520 thisPtr->m_scheduledOOMBreak = true; |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 994 |
996 size_t stackSize = | 995 size_t stackSize = |
997 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 996 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
998 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 997 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
999 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 998 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
1000 | 999 |
1001 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 1000 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
1002 } | 1001 } |
1003 | 1002 |
1004 } // namespace v8_inspector | 1003 } // namespace v8_inspector |
OLD | NEW |