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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 m_debuggerContext.Reset(m_isolate, v8::debug::GetDebugContext(m_isolate)); | 187 m_debuggerContext.Reset(m_isolate, v8::debug::GetDebugContext(m_isolate)); |
188 v8::debug::ChangeBreakOnException(m_isolate, v8::debug::NoBreakOnException); | 188 v8::debug::ChangeBreakOnException(m_isolate, v8::debug::NoBreakOnException); |
189 m_pauseOnExceptionsState = v8::debug::NoBreakOnException; | 189 m_pauseOnExceptionsState = v8::debug::NoBreakOnException; |
190 compileDebuggerScript(); | 190 compileDebuggerScript(); |
191 } | 191 } |
192 | 192 |
193 void V8Debugger::disable() { | 193 void V8Debugger::disable() { |
194 if (--m_enableCount) return; | 194 if (--m_enableCount) return; |
195 DCHECK(enabled()); | 195 DCHECK(enabled()); |
196 clearBreakpoints(); | 196 clearBreakpoints(); |
| 197 clearContinueToLocation(); |
197 m_debuggerScript.Reset(); | 198 m_debuggerScript.Reset(); |
198 m_debuggerContext.Reset(); | 199 m_debuggerContext.Reset(); |
199 allAsyncTasksCanceled(); | 200 allAsyncTasksCanceled(); |
200 m_taskWithScheduledBreak = nullptr; | 201 m_taskWithScheduledBreak = nullptr; |
201 m_wasmTranslation.Clear(); | 202 m_wasmTranslation.Clear(); |
202 v8::debug::SetDebugDelegate(m_isolate, nullptr); | 203 v8::debug::SetDebugDelegate(m_isolate, nullptr); |
203 v8::debug::SetOutOfMemoryCallback(m_isolate, nullptr, nullptr); | 204 v8::debug::SetOutOfMemoryCallback(m_isolate, nullptr, nullptr); |
204 m_isolate->RestoreOriginalHeapLimit(); | 205 m_isolate->RestoreOriginalHeapLimit(); |
205 } | 206 } |
206 | 207 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 DCHECK(!m_executionState.IsEmpty()); | 405 DCHECK(!m_executionState.IsEmpty()); |
405 DCHECK(targetContextGroupId); | 406 DCHECK(targetContextGroupId); |
406 if (m_stepIntoAsyncCallback) { | 407 if (m_stepIntoAsyncCallback) { |
407 m_stepIntoAsyncCallback->sendFailure(Response::Error( | 408 m_stepIntoAsyncCallback->sendFailure(Response::Error( |
408 "Current scheduled step into async was overriden with new one.")); | 409 "Current scheduled step into async was overriden with new one.")); |
409 } | 410 } |
410 m_targetContextGroupId = targetContextGroupId; | 411 m_targetContextGroupId = targetContextGroupId; |
411 m_stepIntoAsyncCallback = std::move(callback); | 412 m_stepIntoAsyncCallback = std::move(callback); |
412 } | 413 } |
413 | 414 |
| 415 Response V8Debugger::continueToLocation( |
| 416 int targetContextGroupId, |
| 417 std::unique_ptr<protocol::Debugger::Location> location) { |
| 418 DCHECK(isPaused()); |
| 419 DCHECK(!m_executionState.IsEmpty()); |
| 420 DCHECK(targetContextGroupId); |
| 421 m_targetContextGroupId = targetContextGroupId; |
| 422 ScriptBreakpoint breakpoint(location->getScriptId(), |
| 423 location->getLineNumber(), |
| 424 location->getColumnNumber(0), String16()); |
| 425 int lineNumber = 0; |
| 426 int columnNumber = 0; |
| 427 m_continueToLocationBreakpointId = |
| 428 setBreakpoint(breakpoint, &lineNumber, &columnNumber); |
| 429 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 430 continueProgram(targetContextGroupId); |
| 431 // TODO(kozyatinskiy): Return actual line and column number. |
| 432 return Response::OK(); |
| 433 } else { |
| 434 return Response::Error("Cannot continue to specified location"); |
| 435 } |
| 436 } |
| 437 |
| 438 void V8Debugger::clearContinueToLocation() { |
| 439 if (m_continueToLocationBreakpointId.length()) { |
| 440 removeBreakpoint(m_continueToLocationBreakpointId); |
| 441 m_continueToLocationBreakpointId = String16(); |
| 442 } |
| 443 } |
| 444 |
414 Response V8Debugger::setScriptSource( | 445 Response V8Debugger::setScriptSource( |
415 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, | 446 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, |
416 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, | 447 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, |
417 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged, | 448 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged, |
418 bool* compileError) { | 449 bool* compileError) { |
419 class EnableLiveEditScope { | 450 class EnableLiveEditScope { |
420 public: | 451 public: |
421 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { | 452 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { |
422 v8::debug::SetLiveEditEnabled(m_isolate, true); | 453 v8::debug::SetLiveEditEnabled(m_isolate, true); |
423 inLiveEditScope = true; | 454 inLiveEditScope = true; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 if (!hitBreakpointNumbers.IsEmpty()) { | 591 if (!hitBreakpointNumbers.IsEmpty()) { |
561 breakpointIds.reserve(hitBreakpointNumbers->Length()); | 592 breakpointIds.reserve(hitBreakpointNumbers->Length()); |
562 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 593 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
563 v8::Local<v8::Value> hitBreakpointNumber = | 594 v8::Local<v8::Value> hitBreakpointNumber = |
564 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); | 595 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); |
565 DCHECK(hitBreakpointNumber->IsInt32()); | 596 DCHECK(hitBreakpointNumber->IsInt32()); |
566 breakpointIds.push_back(String16::fromInteger( | 597 breakpointIds.push_back(String16::fromInteger( |
567 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); | 598 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); |
568 } | 599 } |
569 } | 600 } |
| 601 clearContinueToLocation(); |
570 | 602 |
571 m_pausedContext = pausedContext; | 603 m_pausedContext = pausedContext; |
572 m_executionState = executionState; | 604 m_executionState = executionState; |
573 m_pausedContextGroupId = contextGroupId; | 605 m_pausedContextGroupId = contextGroupId; |
574 agent->didPause(InspectedContext::contextId(pausedContext), exception, | 606 agent->didPause(InspectedContext::contextId(pausedContext), exception, |
575 breakpointIds, isPromiseRejection, isUncaught, | 607 breakpointIds, isPromiseRejection, isUncaught, |
576 m_scheduledOOMBreak); | 608 m_scheduledOOMBreak); |
577 int groupId = m_inspector->contextGroupId(pausedContext); | 609 int groupId = m_inspector->contextGroupId(pausedContext); |
578 DCHECK(groupId); | 610 DCHECK(groupId); |
579 { | 611 { |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); | 1124 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); |
1093 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); | 1125 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); |
1094 fprintf(stdout, "Created async tasks: %zu\n", | 1126 fprintf(stdout, "Created async tasks: %zu\n", |
1095 m_asyncTaskCreationStacks.size()); | 1127 m_asyncTaskCreationStacks.size()); |
1096 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); | 1128 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); |
1097 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); | 1129 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); |
1098 fprintf(stdout, "\n"); | 1130 fprintf(stdout, "\n"); |
1099 } | 1131 } |
1100 | 1132 |
1101 } // namespace v8_inspector | 1133 } // namespace v8_inspector |
OLD | NEW |