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/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" |
11 #include "src/inspector/v8-debugger-agent-impl.h" | 11 #include "src/inspector/v8-debugger-agent-impl.h" |
12 #include "src/inspector/v8-inspector-impl.h" | 12 #include "src/inspector/v8-inspector-impl.h" |
13 #include "src/inspector/v8-internal-value-type.h" | 13 #include "src/inspector/v8-internal-value-type.h" |
14 #include "src/inspector/v8-stack-trace-impl.h" | 14 #include "src/inspector/v8-stack-trace-impl.h" |
15 #include "src/inspector/v8-value-copier.h" | 15 #include "src/inspector/v8-value-copier.h" |
16 | 16 |
17 namespace v8_inspector { | 17 namespace v8_inspector { |
18 | 18 |
19 namespace { | 19 namespace { |
20 const char stepIntoV8MethodName[] = "stepIntoStatement"; | |
21 const char stepOutV8MethodName[] = "stepOutOfFunction"; | |
22 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; | 20 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; |
23 static const char v8AsyncTaskEventEnqueueRecurring[] = "enqueueRecurring"; | 21 static const char v8AsyncTaskEventEnqueueRecurring[] = "enqueueRecurring"; |
24 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; | 22 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; |
25 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; | 23 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; |
26 static const char v8AsyncTaskEventCancel[] = "cancel"; | 24 static const char v8AsyncTaskEventCancel[] = "cancel"; |
27 | 25 |
28 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) { | 26 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) { |
29 return value ? v8::True(isolate) : v8::False(isolate); | 27 return value ? v8::True(isolate) : v8::False(isolate); |
30 } | 28 } |
31 | 29 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 306 |
309 void V8Debugger::continueProgram() { | 307 void V8Debugger::continueProgram() { |
310 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); | 308 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); |
311 m_pausedContext.Clear(); | 309 m_pausedContext.Clear(); |
312 m_executionState.Clear(); | 310 m_executionState.Clear(); |
313 } | 311 } |
314 | 312 |
315 void V8Debugger::stepIntoStatement() { | 313 void V8Debugger::stepIntoStatement() { |
316 DCHECK(isPaused()); | 314 DCHECK(isPaused()); |
317 DCHECK(!m_executionState.IsEmpty()); | 315 DCHECK(!m_executionState.IsEmpty()); |
318 v8::HandleScope handleScope(m_isolate); | 316 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn); |
319 v8::Local<v8::Value> argv[] = {m_executionState}; | |
320 callDebuggerMethod(stepIntoV8MethodName, 1, argv); | |
321 continueProgram(); | 317 continueProgram(); |
322 } | 318 } |
323 | 319 |
324 void V8Debugger::stepOverStatement() { | 320 void V8Debugger::stepOverStatement() { |
325 DCHECK(isPaused()); | 321 DCHECK(isPaused()); |
326 DCHECK(!m_executionState.IsEmpty()); | 322 DCHECK(!m_executionState.IsEmpty()); |
327 v8::HandleScope handleScope(m_isolate); | 323 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepNext); |
328 v8::Local<v8::Value> argv[] = {m_executionState}; | |
329 callDebuggerMethod("stepOverStatement", 1, argv); | |
330 continueProgram(); | 324 continueProgram(); |
331 } | 325 } |
332 | 326 |
333 void V8Debugger::stepOutOfFunction() { | 327 void V8Debugger::stepOutOfFunction() { |
334 DCHECK(isPaused()); | 328 DCHECK(isPaused()); |
335 DCHECK(!m_executionState.IsEmpty()); | 329 DCHECK(!m_executionState.IsEmpty()); |
336 v8::HandleScope handleScope(m_isolate); | 330 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut); |
337 v8::Local<v8::Value> argv[] = {m_executionState}; | |
338 callDebuggerMethod(stepOutV8MethodName, 1, argv); | |
339 continueProgram(); | 331 continueProgram(); |
340 } | 332 } |
341 | 333 |
342 void V8Debugger::clearStepping() { | 334 void V8Debugger::clearStepping() { |
343 DCHECK(enabled()); | 335 DCHECK(enabled()); |
344 v8::HandleScope scope(m_isolate); | 336 v8::DebugInterface::ClearStepping(m_isolate); |
345 v8::Context::Scope contextScope(debuggerContext()); | |
346 | |
347 v8::Local<v8::Value> argv[] = {v8::Undefined(m_isolate)}; | |
348 callDebuggerMethod("clearStepping", 0, argv); | |
349 } | 337 } |
350 | 338 |
351 bool V8Debugger::setScriptSource( | 339 bool V8Debugger::setScriptSource( |
352 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, | 340 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, |
353 ErrorString* error, | 341 ErrorString* error, |
354 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, | 342 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, |
355 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged) { | 343 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged) { |
356 class EnableLiveEditScope { | 344 class EnableLiveEditScope { |
357 public: | 345 public: |
358 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { | 346 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // The agent may have been removed in the nested loop. | 525 // The agent may have been removed in the nested loop. |
538 agent = | 526 agent = |
539 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); | 527 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); |
540 if (agent) agent->didContinue(); | 528 if (agent) agent->didContinue(); |
541 m_runningNestedMessageLoop = false; | 529 m_runningNestedMessageLoop = false; |
542 } | 530 } |
543 m_pausedContext.Clear(); | 531 m_pausedContext.Clear(); |
544 m_executionState.Clear(); | 532 m_executionState.Clear(); |
545 | 533 |
546 if (result == V8DebuggerAgentImpl::RequestStepFrame) { | 534 if (result == V8DebuggerAgentImpl::RequestStepFrame) { |
547 v8::Local<v8::Value> argv[] = {executionState}; | 535 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepFrame); |
548 callDebuggerMethod("stepFrameStatement", 1, argv); | |
549 } else if (result == V8DebuggerAgentImpl::RequestStepInto) { | 536 } else if (result == V8DebuggerAgentImpl::RequestStepInto) { |
550 v8::Local<v8::Value> argv[] = {executionState}; | 537 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn); |
551 callDebuggerMethod(stepIntoV8MethodName, 1, argv); | |
552 } else if (result == V8DebuggerAgentImpl::RequestStepOut) { | 538 } else if (result == V8DebuggerAgentImpl::RequestStepOut) { |
553 v8::Local<v8::Value> argv[] = {executionState}; | 539 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut); |
554 callDebuggerMethod(stepOutV8MethodName, 1, argv); | |
555 } | 540 } |
556 } | 541 } |
557 | 542 |
558 void V8Debugger::v8DebugEventCallback( | 543 void V8Debugger::v8DebugEventCallback( |
559 const v8::DebugInterface::EventDetails& eventDetails) { | 544 const v8::DebugInterface::EventDetails& eventDetails) { |
560 V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData()); | 545 V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData()); |
561 thisPtr->handleV8DebugEvent(eventDetails); | 546 thisPtr->handleV8DebugEvent(eventDetails); |
562 } | 547 } |
563 | 548 |
564 v8::Local<v8::Value> V8Debugger::callInternalGetterFunction( | 549 v8::Local<v8::Value> V8Debugger::callInternalGetterFunction( |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 | 976 |
992 size_t stackSize = | 977 size_t stackSize = |
993 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 978 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
994 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 979 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
995 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 980 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
996 | 981 |
997 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 982 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
998 } | 983 } |
999 | 984 |
1000 } // namespace v8_inspector | 985 } // namespace v8_inspector |
OLD | NEW |