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

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

Issue 2488733003: [inspector] Add exception caught/uncaught status to protocol (Closed)
Patch Set: Use Maybe version of BooleanValue Created 4 years, 1 month 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
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/protocol/Protocol.h" 8 #include "src/inspector/protocol/Protocol.h"
9 #include "src/inspector/script-breakpoint.h" 9 #include "src/inspector/script-breakpoint.h"
10 #include "src/inspector/string-util.h" 10 #include "src/inspector/string-util.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 v8::Local<v8::Array> hitBreakpoints; 479 v8::Local<v8::Array> hitBreakpoints;
480 thisPtr->handleProgramBreak(pausedContext, 480 thisPtr->handleProgramBreak(pausedContext,
481 v8::Local<v8::Object>::Cast(info[0]), exception, 481 v8::Local<v8::Object>::Cast(info[0]), exception,
482 hitBreakpoints); 482 hitBreakpoints);
483 } 483 }
484 484
485 void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, 485 void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
486 v8::Local<v8::Object> executionState, 486 v8::Local<v8::Object> executionState,
487 v8::Local<v8::Value> exception, 487 v8::Local<v8::Value> exception,
488 v8::Local<v8::Array> hitBreakpointNumbers, 488 v8::Local<v8::Array> hitBreakpointNumbers,
489 bool isPromiseRejection) { 489 bool isPromiseRejection, bool isUncaught) {
490 // Don't allow nested breaks. 490 // Don't allow nested breaks.
491 if (m_runningNestedMessageLoop) return; 491 if (m_runningNestedMessageLoop) return;
492 492
493 V8DebuggerAgentImpl* agent = 493 V8DebuggerAgentImpl* agent =
494 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); 494 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext));
495 if (!agent) return; 495 if (!agent) return;
496 496
497 std::vector<String16> breakpointIds; 497 std::vector<String16> breakpointIds;
498 if (!hitBreakpointNumbers.IsEmpty()) { 498 if (!hitBreakpointNumbers.IsEmpty()) {
499 breakpointIds.reserve(hitBreakpointNumbers->Length()); 499 breakpointIds.reserve(hitBreakpointNumbers->Length());
500 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { 500 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
501 v8::Local<v8::Value> hitBreakpointNumber = 501 v8::Local<v8::Value> hitBreakpointNumber =
502 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); 502 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked();
503 DCHECK(hitBreakpointNumber->IsInt32()); 503 DCHECK(hitBreakpointNumber->IsInt32());
504 breakpointIds.push_back(String16::fromInteger( 504 breakpointIds.push_back(String16::fromInteger(
505 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); 505 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust()));
506 } 506 }
507 } 507 }
508 508
509 m_pausedContext = pausedContext; 509 m_pausedContext = pausedContext;
510 m_executionState = executionState; 510 m_executionState = executionState;
511 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause( 511 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(
512 pausedContext, exception, breakpointIds, isPromiseRejection); 512 pausedContext, exception, breakpointIds, isPromiseRejection, isUncaught);
513 if (result == V8DebuggerAgentImpl::RequestNoSkip) { 513 if (result == V8DebuggerAgentImpl::RequestNoSkip) {
514 m_runningNestedMessageLoop = true; 514 m_runningNestedMessageLoop = true;
515 int groupId = getGroupId(pausedContext); 515 int groupId = getGroupId(pausedContext);
516 DCHECK(groupId); 516 DCHECK(groupId);
517 m_inspector->client()->runMessageLoopOnPause(groupId); 517 m_inspector->client()->runMessageLoopOnPause(groupId);
518 // The agent may have been removed in the nested loop. 518 // The agent may have been removed in the nested loop.
519 agent = 519 agent =
520 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); 520 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext));
521 if (agent) agent->didContinue(); 521 if (agent) agent->didContinue();
522 m_runningNestedMessageLoop = false; 522 m_runningNestedMessageLoop = false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 DCHECK(value->IsObject()); 588 DCHECK(value->IsObject());
589 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(value); 589 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(value);
590 v8::Local<v8::DebugInterface::Script> script; 590 v8::Local<v8::DebugInterface::Script> script;
591 if (!v8::DebugInterface::Script::Wrap(m_isolate, scriptObject) 591 if (!v8::DebugInterface::Script::Wrap(m_isolate, scriptObject)
592 .ToLocal(&script)) 592 .ToLocal(&script))
593 return; 593 return;
594 agent->didParseSource( 594 agent->didParseSource(
595 wrapUnique(new V8DebuggerScript(m_isolate, script, inLiveEditScope)), 595 wrapUnique(new V8DebuggerScript(m_isolate, script, inLiveEditScope)),
596 event == v8::AfterCompile); 596 event == v8::AfterCompile);
597 } else if (event == v8::Exception) { 597 } else if (event == v8::Exception) {
598 v8::Local<v8::Context> context = debuggerContext();
598 v8::Local<v8::Object> eventData = eventDetails.GetEventData(); 599 v8::Local<v8::Object> eventData = eventDetails.GetEventData();
599 v8::Local<v8::Value> exception = 600 v8::Local<v8::Value> exception =
600 callInternalGetterFunction(eventData, "exception"); 601 callInternalGetterFunction(eventData, "exception");
601 v8::Local<v8::Value> promise = 602 v8::Local<v8::Value> promise =
602 callInternalGetterFunction(eventData, "promise"); 603 callInternalGetterFunction(eventData, "promise");
603 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject(); 604 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject();
605 v8::Local<v8::Value> uncaught =
606 callInternalGetterFunction(eventData, "uncaught");
607 bool isUncaught = uncaught->BooleanValue(context).FromJust();
604 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), 608 handleProgramBreak(eventContext, eventDetails.GetExecutionState(),
605 exception, v8::Local<v8::Array>(), isPromiseRejection); 609 exception, v8::Local<v8::Array>(), isPromiseRejection,
610 isUncaught);
606 } else if (event == v8::Break) { 611 } else if (event == v8::Break) {
607 v8::Local<v8::Value> argv[] = {eventDetails.GetEventData()}; 612 v8::Local<v8::Value> argv[] = {eventDetails.GetEventData()};
608 v8::Local<v8::Value> hitBreakpoints = 613 v8::Local<v8::Value> hitBreakpoints =
609 callDebuggerMethod("getBreakpointNumbers", 1, argv).ToLocalChecked(); 614 callDebuggerMethod("getBreakpointNumbers", 1, argv).ToLocalChecked();
610 DCHECK(hitBreakpoints->IsArray()); 615 DCHECK(hitBreakpoints->IsArray());
611 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), 616 handleProgramBreak(eventContext, eventDetails.GetExecutionState(),
612 v8::Local<v8::Value>(), 617 v8::Local<v8::Value>(),
613 hitBreakpoints.As<v8::Array>()); 618 hitBreakpoints.As<v8::Array>());
614 } 619 }
615 } 620 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 978
974 size_t stackSize = 979 size_t stackSize =
975 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; 980 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1;
976 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) 981 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId))
977 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; 982 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture;
978 983
979 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); 984 return V8StackTraceImpl::capture(this, contextGroupId, stackSize);
980 } 985 }
981 986
982 } // namespace v8_inspector 987 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698