OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 m_breakProgramCallbackTemplate.Reset(m_isolate, templ); | 266 m_breakProgramCallbackTemplate.Reset(m_isolate, templ); |
267 } | 267 } |
268 | 268 |
269 v8::Local<v8::Function> breakProgramFunction = v8::Local<v8::FunctionTemplat
e>::New(m_isolate, m_breakProgramCallbackTemplate)->GetFunction(); | 269 v8::Local<v8::Function> breakProgramFunction = v8::Local<v8::FunctionTemplat
e>::New(m_isolate, m_breakProgramCallbackTemplate)->GetFunction(); |
270 v8::Debug::Call(breakProgramFunction); | 270 v8::Debug::Call(breakProgramFunction); |
271 } | 271 } |
272 | 272 |
273 void ScriptDebugServer::continueProgram() | 273 void ScriptDebugServer::continueProgram() |
274 { | 274 { |
275 if (isPaused()) | 275 if (isPaused()) |
276 quitMessageLoopOnPause(); | 276 m_client->quitMessageLoopOnPause(); |
277 m_pausedScriptState.clear(); | 277 m_pausedScriptState.clear(); |
278 m_executionState.Clear(); | 278 m_executionState.Clear(); |
279 } | 279 } |
280 | 280 |
281 void ScriptDebugServer::stepIntoStatement() | 281 void ScriptDebugServer::stepIntoStatement() |
282 { | 282 { |
283 ASSERT(isPaused()); | 283 ASSERT(isPaused()); |
284 ASSERT(!m_executionState.IsEmpty()); | 284 ASSERT(!m_executionState.IsEmpty()); |
285 v8::HandleScope handleScope(m_isolate); | 285 v8::HandleScope handleScope(m_isolate); |
286 v8::Local<v8::Value> argv[] = { m_executionState }; | 286 v8::Local<v8::Value> argv[] = { m_executionState }; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 v8::Local<v8::Array> hitBreakpoints; | 516 v8::Local<v8::Array> hitBreakpoints; |
517 thisPtr->handleProgramBreak(pausedScriptState, v8::Local<v8::Object>::Cast(i
nfo[0]), exception, hitBreakpoints); | 517 thisPtr->handleProgramBreak(pausedScriptState, v8::Local<v8::Object>::Cast(i
nfo[0]), exception, hitBreakpoints); |
518 } | 518 } |
519 | 519 |
520 void ScriptDebugServer::handleProgramBreak(ScriptState* pausedScriptState, v8::L
ocal<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::A
rray> hitBreakpointNumbers, bool isPromiseRejection) | 520 void ScriptDebugServer::handleProgramBreak(ScriptState* pausedScriptState, v8::L
ocal<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::A
rray> hitBreakpointNumbers, bool isPromiseRejection) |
521 { | 521 { |
522 // Don't allow nested breaks. | 522 // Don't allow nested breaks. |
523 if (m_runningNestedMessageLoop) | 523 if (m_runningNestedMessageLoop) |
524 return; | 524 return; |
525 | 525 |
526 ScriptDebugListener* listener = getDebugListenerForContext(pausedScriptState
->context()); | 526 ScriptDebugListener* listener = m_client->getDebugListenerForContext(pausedS
criptState->context()); |
527 if (!listener) | 527 if (!listener) |
528 return; | 528 return; |
529 | 529 |
530 Vector<String> breakpointIds; | 530 Vector<String> breakpointIds; |
531 if (!hitBreakpointNumbers.IsEmpty()) { | 531 if (!hitBreakpointNumbers.IsEmpty()) { |
532 breakpointIds.resize(hitBreakpointNumbers->Length()); | 532 breakpointIds.resize(hitBreakpointNumbers->Length()); |
533 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 533 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
534 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); | 534 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); |
535 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); | 535 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); |
536 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value())
; | 536 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value())
; |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 m_pausedScriptState = pausedScriptState; | 540 m_pausedScriptState = pausedScriptState; |
541 m_executionState = executionState; | 541 m_executionState = executionState; |
542 ScriptDebugListener::SkipPauseRequest result = listener->didPause(pausedScri
ptState, currentCallFrames(), ScriptValue(pausedScriptState, exception), breakpo
intIds, isPromiseRejection); | 542 ScriptDebugListener::SkipPauseRequest result = listener->didPause(pausedScri
ptState, currentCallFrames(), ScriptValue(pausedScriptState, exception), breakpo
intIds, isPromiseRejection); |
543 if (result == ScriptDebugListener::NoSkip) { | 543 if (result == ScriptDebugListener::NoSkip) { |
544 m_runningNestedMessageLoop = true; | 544 m_runningNestedMessageLoop = true; |
545 runMessageLoopOnPause(pausedScriptState->context()); | 545 m_client->runMessageLoopOnPause(pausedScriptState->context()); |
546 m_runningNestedMessageLoop = false; | 546 m_runningNestedMessageLoop = false; |
547 } | 547 } |
548 m_pausedScriptState.clear(); | 548 m_pausedScriptState.clear(); |
549 m_executionState.Clear(); | 549 m_executionState.Clear(); |
550 | 550 |
551 if (result == ScriptDebugListener::StepFrame) { | 551 if (result == ScriptDebugListener::StepFrame) { |
552 v8::Local<v8::Value> argv[] = { executionState }; | 552 v8::Local<v8::Value> argv[] = { executionState }; |
553 callDebuggerMethod("stepFrameStatement", 1, argv); | 553 callDebuggerMethod("stepFrameStatement", 1, argv); |
554 } else if (result == ScriptDebugListener::StepInto) { | 554 } else if (result == ScriptDebugListener::StepInto) { |
555 v8::Local<v8::Value> argv[] = { executionState }; | 555 v8::Local<v8::Value> argv[] = { executionState }; |
(...skipping 27 matching lines...) Expand all Loading... |
583 { | 583 { |
584 if (!enabled()) | 584 if (!enabled()) |
585 return; | 585 return; |
586 v8::DebugEvent event = eventDetails.GetEvent(); | 586 v8::DebugEvent event = eventDetails.GetEvent(); |
587 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError && event != v8::PromiseEvent) | 587 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError && event != v8::PromiseEvent) |
588 return; | 588 return; |
589 | 589 |
590 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext(); | 590 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext(); |
591 ASSERT(!eventContext.IsEmpty()); | 591 ASSERT(!eventContext.IsEmpty()); |
592 | 592 |
593 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); | 593 ScriptDebugListener* listener = m_client->getDebugListenerForContext(eventCo
ntext); |
594 if (listener) { | 594 if (listener) { |
595 v8::HandleScope scope(m_isolate); | 595 v8::HandleScope scope(m_isolate); |
596 if (event == v8::AfterCompile || event == v8::CompileError) { | 596 if (event == v8::AfterCompile || event == v8::CompileError) { |
597 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 597 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
598 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; | 598 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; |
599 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri
pt", 1, argv).ToLocalChecked(); | 599 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri
pt", 1, argv).ToLocalChecked(); |
600 ASSERT(value->IsObject()); | 600 ASSERT(value->IsObject()); |
601 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); | 601 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); |
602 dispatchDidParseSource(listener, object, event != v8::AfterCompile ?
CompileError : CompileSuccess); | 602 dispatchDidParseSource(listener, object, event != v8::AfterCompile ?
CompileError : CompileSuccess); |
603 } else if (event == v8::Exception) { | 603 } else if (event == v8::Exception) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 742 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
743 } | 743 } |
744 | 744 |
745 | 745 |
746 bool ScriptDebugServer::isPaused() | 746 bool ScriptDebugServer::isPaused() |
747 { | 747 { |
748 return m_pausedScriptState; | 748 return m_pausedScriptState; |
749 } | 749 } |
750 | 750 |
751 } // namespace blink | 751 } // namespace blink |
OLD | NEW |