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 return Response::OK(); | |
432 } else { | |
433 return Response::Error("No breakpoint by passed location"); | |
dgozman
2017/05/16 18:51:04
Cannot continue to specified location
kozy
2017/05/16 19:01:16
Done.
| |
434 } | |
435 } | |
436 | |
437 void V8Debugger::clearContinueToLocation() { | |
438 if (m_continueToLocationBreakpointId.length()) { | |
439 removeBreakpoint(m_continueToLocationBreakpointId); | |
440 } | |
441 m_continueToLocationBreakpointId = String16(); | |
dgozman
2017/05/16 18:51:04
Move this under if?
kozy
2017/05/16 19:01:16
Done.
| |
442 } | |
443 | |
414 Response V8Debugger::setScriptSource( | 444 Response V8Debugger::setScriptSource( |
415 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, | 445 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, |
416 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, | 446 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, |
417 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged, | 447 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged, |
418 bool* compileError) { | 448 bool* compileError) { |
419 class EnableLiveEditScope { | 449 class EnableLiveEditScope { |
420 public: | 450 public: |
421 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { | 451 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { |
422 v8::debug::SetLiveEditEnabled(m_isolate, true); | 452 v8::debug::SetLiveEditEnabled(m_isolate, true); |
423 inLiveEditScope = true; | 453 inLiveEditScope = true; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 if (!hitBreakpointNumbers.IsEmpty()) { | 590 if (!hitBreakpointNumbers.IsEmpty()) { |
561 breakpointIds.reserve(hitBreakpointNumbers->Length()); | 591 breakpointIds.reserve(hitBreakpointNumbers->Length()); |
562 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 592 for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
563 v8::Local<v8::Value> hitBreakpointNumber = | 593 v8::Local<v8::Value> hitBreakpointNumber = |
564 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); | 594 hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); |
565 DCHECK(hitBreakpointNumber->IsInt32()); | 595 DCHECK(hitBreakpointNumber->IsInt32()); |
566 breakpointIds.push_back(String16::fromInteger( | 596 breakpointIds.push_back(String16::fromInteger( |
567 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); | 597 hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); |
568 } | 598 } |
569 } | 599 } |
600 clearContinueToLocation(); | |
570 | 601 |
571 m_pausedContext = pausedContext; | 602 m_pausedContext = pausedContext; |
572 m_executionState = executionState; | 603 m_executionState = executionState; |
573 m_pausedContextGroupId = contextGroupId; | 604 m_pausedContextGroupId = contextGroupId; |
574 agent->didPause(InspectedContext::contextId(pausedContext), exception, | 605 agent->didPause(InspectedContext::contextId(pausedContext), exception, |
575 breakpointIds, isPromiseRejection, isUncaught, | 606 breakpointIds, isPromiseRejection, isUncaught, |
576 m_scheduledOOMBreak); | 607 m_scheduledOOMBreak); |
577 int groupId = m_inspector->contextGroupId(pausedContext); | 608 int groupId = m_inspector->contextGroupId(pausedContext); |
578 DCHECK(groupId); | 609 DCHECK(groupId); |
579 { | 610 { |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1092 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); | 1123 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); |
1093 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); | 1124 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); |
1094 fprintf(stdout, "Created async tasks: %zu\n", | 1125 fprintf(stdout, "Created async tasks: %zu\n", |
1095 m_asyncTaskCreationStacks.size()); | 1126 m_asyncTaskCreationStacks.size()); |
1096 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); | 1127 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); |
1097 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); | 1128 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); |
1098 fprintf(stdout, "\n"); | 1129 fprintf(stdout, "\n"); |
1099 } | 1130 } |
1100 | 1131 |
1101 } // namespace v8_inspector | 1132 } // namespace v8_inspector |
OLD | NEW |