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

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

Issue 2879923003: [inspector] added targetCallFrames for continueToLocation (Closed)
Patch Set: ac Created 3 years, 7 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (m_stepIntoAsyncCallback) { 407 if (m_stepIntoAsyncCallback) {
408 m_stepIntoAsyncCallback->sendFailure(Response::Error( 408 m_stepIntoAsyncCallback->sendFailure(Response::Error(
409 "Current scheduled step into async was overriden with new one.")); 409 "Current scheduled step into async was overriden with new one."));
410 } 410 }
411 m_targetContextGroupId = targetContextGroupId; 411 m_targetContextGroupId = targetContextGroupId;
412 m_stepIntoAsyncCallback = std::move(callback); 412 m_stepIntoAsyncCallback = std::move(callback);
413 } 413 }
414 414
415 Response V8Debugger::continueToLocation( 415 Response V8Debugger::continueToLocation(
416 int targetContextGroupId, 416 int targetContextGroupId,
417 std::unique_ptr<protocol::Debugger::Location> location) { 417 std::unique_ptr<protocol::Debugger::Location> location,
418 const String16& targetCallFrames) {
418 DCHECK(isPaused()); 419 DCHECK(isPaused());
419 DCHECK(!m_executionState.IsEmpty()); 420 DCHECK(!m_executionState.IsEmpty());
420 DCHECK(targetContextGroupId); 421 DCHECK(targetContextGroupId);
421 m_targetContextGroupId = targetContextGroupId; 422 m_targetContextGroupId = targetContextGroupId;
422 ScriptBreakpoint breakpoint(location->getScriptId(), 423 ScriptBreakpoint breakpoint(location->getScriptId(),
423 location->getLineNumber(), 424 location->getLineNumber(),
424 location->getColumnNumber(0), String16()); 425 location->getColumnNumber(0), String16());
425 int lineNumber = 0; 426 int lineNumber = 0;
426 int columnNumber = 0; 427 int columnNumber = 0;
427 m_continueToLocationBreakpointId = 428 m_continueToLocationBreakpointId =
428 setBreakpoint(breakpoint, &lineNumber, &columnNumber); 429 setBreakpoint(breakpoint, &lineNumber, &columnNumber);
429 if (!m_continueToLocationBreakpointId.isEmpty()) { 430 if (!m_continueToLocationBreakpointId.isEmpty()) {
431 m_continueToLocationTargetCallFrames = targetCallFrames;
432 if (m_continueToLocationTargetCallFrames !=
433 protocol::Debugger::ContinueToLocation::TargetCallFramesEnum::Any) {
434 m_continueToLocationStack = captureStackTrace(true);
435 DCHECK(m_continueToLocationStack);
436 }
430 continueProgram(targetContextGroupId); 437 continueProgram(targetContextGroupId);
431 // TODO(kozyatinskiy): Return actual line and column number. 438 // TODO(kozyatinskiy): Return actual line and column number.
432 return Response::OK(); 439 return Response::OK();
433 } else { 440 } else {
434 return Response::Error("Cannot continue to specified location"); 441 return Response::Error("Cannot continue to specified location");
435 } 442 }
436 } 443 }
437 444
445 bool V8Debugger::shouldContinueToCurrentLocation() {
446 if (m_continueToLocationTargetCallFrames ==
447 protocol::Debugger::ContinueToLocation::TargetCallFramesEnum::Any) {
448 return true;
449 }
450 std::unique_ptr<V8StackTraceImpl> currentStack = captureStackTrace(true);
451 if (m_continueToLocationTargetCallFrames ==
452 protocol::Debugger::ContinueToLocation::TargetCallFramesEnum::Current) {
453 return m_continueToLocationStack->isEqualIgnoringTopFrame(
454 currentStack.get());
455 }
456 return true;
457 }
458
438 void V8Debugger::clearContinueToLocation() { 459 void V8Debugger::clearContinueToLocation() {
439 if (m_continueToLocationBreakpointId.length()) { 460 if (m_continueToLocationBreakpointId.isEmpty()) return;
440 removeBreakpoint(m_continueToLocationBreakpointId); 461 removeBreakpoint(m_continueToLocationBreakpointId);
441 m_continueToLocationBreakpointId = String16(); 462 m_continueToLocationBreakpointId = String16();
442 } 463 m_continueToLocationTargetCallFrames = String16();
464 m_continueToLocationStack.reset();
443 } 465 }
444 466
445 Response V8Debugger::setScriptSource( 467 Response V8Debugger::setScriptSource(
446 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, 468 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun,
447 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, 469 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails,
448 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged, 470 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged,
449 bool* compileError) { 471 bool* compileError) {
450 class EnableLiveEditScope { 472 class EnableLiveEditScope {
451 public: 473 public:
452 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { 474 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 std::vector<String16> breakpointIds; 612 std::vector<String16> breakpointIds;
591 if (!hitBreakpointNumbers.IsEmpty()) { 613 if (!hitBreakpointNumbers.IsEmpty()) {
592 breakpointIds.reserve(hitBreakpointNumbers->Length()); 614 breakpointIds.reserve(hitBreakpointNumbers->Length());
593 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { 615 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
594 v8::Local<v8::Value> hitBreakpointNumber = 616 v8::Local<v8::Value> hitBreakpointNumber =
595 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); 617 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked();
596 DCHECK(hitBreakpointNumber->IsInt32()); 618 DCHECK(hitBreakpointNumber->IsInt32());
597 breakpointIds.push_back(String16::fromInteger( 619 breakpointIds.push_back(String16::fromInteger(
598 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); 620 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust()));
599 } 621 }
622 if (breakpointIds.size() == 1 &&
623 breakpointIds[0] == m_continueToLocationBreakpointId) {
624 v8::Context::Scope contextScope(pausedContext);
625 if (!shouldContinueToCurrentLocation()) return;
626 }
600 } 627 }
601 clearContinueToLocation(); 628 clearContinueToLocation();
602 629
603 m_pausedContext = pausedContext; 630 m_pausedContext = pausedContext;
604 m_executionState = executionState; 631 m_executionState = executionState;
605 m_pausedContextGroupId = contextGroupId; 632 m_pausedContextGroupId = contextGroupId;
606 agent->didPause(InspectedContext::contextId(pausedContext), exception, 633 agent->didPause(InspectedContext::contextId(pausedContext), exception,
607 breakpointIds, isPromiseRejection, isUncaught, 634 breakpointIds, isPromiseRejection, isUncaught,
608 m_scheduledOOMBreak); 635 m_scheduledOOMBreak);
609 int groupId = m_inspector->contextGroupId(pausedContext); 636 int groupId = m_inspector->contextGroupId(pausedContext);
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); 1151 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount);
1125 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); 1152 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size());
1126 fprintf(stdout, "Created async tasks: %zu\n", 1153 fprintf(stdout, "Created async tasks: %zu\n",
1127 m_asyncTaskCreationStacks.size()); 1154 m_asyncTaskCreationStacks.size());
1128 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); 1155 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size());
1129 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); 1156 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size());
1130 fprintf(stdout, "\n"); 1157 fprintf(stdout, "\n");
1131 } 1158 }
1132 1159
1133 } // namespace v8_inspector 1160 } // 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