[inspector] migrate stepping related methods to debug-interface
* introduced DebugInterface::PrepareStep and DebugInterface::ClearStepping method. Inspector calls these methods only on pause and not interseted in calling this for not current break_id so we don't need to expose debug interface with break_id argument and can only check that current break_id is valid. BUG=chromium:652939,v8:5510 R=yangguo@chromium.org,dgozman@chromium.org Review-Url: https://chromiumcodereview.appspot.com/2423153002 Cr-Commit-Position: refs/heads/master@{#40450}
This commit is contained in:
parent
2cb9213e31
commit
859eddbdef
18
src/api.cc
18
src/api.cc
@ -8811,6 +8811,24 @@ void DebugInterface::ChangeBreakOnException(Isolate* isolate,
|
|||||||
type != NoBreakOnException);
|
type != NoBreakOnException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugInterface::PrepareStep(Isolate* v8_isolate, StepAction action) {
|
||||||
|
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||||
|
ENTER_V8(isolate);
|
||||||
|
CHECK(isolate->debug()->CheckExecutionState());
|
||||||
|
// Clear all current stepping setup.
|
||||||
|
isolate->debug()->ClearStepping();
|
||||||
|
// Prepare step.
|
||||||
|
isolate->debug()->PrepareStep(static_cast<i::StepAction>(action));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugInterface::ClearStepping(Isolate* v8_isolate) {
|
||||||
|
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||||
|
ENTER_V8(isolate);
|
||||||
|
CHECK(isolate->debug()->CheckExecutionState());
|
||||||
|
// Clear all current stepping setup.
|
||||||
|
isolate->debug()->ClearStepping();
|
||||||
|
}
|
||||||
|
|
||||||
Local<String> CpuProfileNode::GetFunctionName() const {
|
Local<String> CpuProfileNode::GetFunctionName() const {
|
||||||
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
|
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
|
||||||
i::Isolate* isolate = node->isolate();
|
i::Isolate* isolate = node->isolate();
|
||||||
|
@ -127,6 +127,17 @@ class DebugInterface {
|
|||||||
*/
|
*/
|
||||||
static void ChangeBreakOnException(Isolate* isolate,
|
static void ChangeBreakOnException(Isolate* isolate,
|
||||||
ExceptionBreakState state);
|
ExceptionBreakState state);
|
||||||
|
|
||||||
|
enum StepAction {
|
||||||
|
StepOut = 0, // Step out of the current function.
|
||||||
|
StepNext = 1, // Step to the next statement in the current function.
|
||||||
|
StepIn = 2, // Step into new functions invoked or the next statement
|
||||||
|
// in the current function.
|
||||||
|
StepFrame = 3 // Step into a new frame or return to previous frame.
|
||||||
|
};
|
||||||
|
|
||||||
|
static void PrepareStep(Isolate* isolate, StepAction action);
|
||||||
|
static void ClearStepping(Isolate* isolate);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
|
@ -501,8 +501,11 @@ class Debug {
|
|||||||
void Iterate(ObjectVisitor* v);
|
void Iterate(ObjectVisitor* v);
|
||||||
|
|
||||||
bool CheckExecutionState(int id) {
|
bool CheckExecutionState(int id) {
|
||||||
return is_active() && !debug_context().is_null() && break_id() != 0 &&
|
return CheckExecutionState() && break_id() == id;
|
||||||
break_id() == id;
|
}
|
||||||
|
|
||||||
|
bool CheckExecutionState() {
|
||||||
|
return is_active() && !debug_context().is_null() && break_id() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flags and states.
|
// Flags and states.
|
||||||
|
@ -253,43 +253,6 @@ DebuggerScript.currentCallFrames = function(execState, limit)
|
|||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {!ExecutionState} execState
|
|
||||||
*/
|
|
||||||
DebuggerScript.stepIntoStatement = function(execState)
|
|
||||||
{
|
|
||||||
execState.prepareStep(Debug.StepAction.StepIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {!ExecutionState} execState
|
|
||||||
*/
|
|
||||||
DebuggerScript.stepFrameStatement = function(execState)
|
|
||||||
{
|
|
||||||
execState.prepareStep(Debug.StepAction.StepFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {!ExecutionState} execState
|
|
||||||
*/
|
|
||||||
DebuggerScript.stepOverStatement = function(execState)
|
|
||||||
{
|
|
||||||
execState.prepareStep(Debug.StepAction.StepNext);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {!ExecutionState} execState
|
|
||||||
*/
|
|
||||||
DebuggerScript.stepOutOfFunction = function(execState)
|
|
||||||
{
|
|
||||||
execState.prepareStep(Debug.StepAction.StepOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerScript.clearStepping = function()
|
|
||||||
{
|
|
||||||
Debug.clearStepping();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns array in form:
|
// Returns array in form:
|
||||||
// [ 0, <v8_result_report> ] in case of success
|
// [ 0, <v8_result_report> ] in case of success
|
||||||
// or [ 1, <general_error_message>, <compiler_message>, <line_number>, <column_number> ] in case of compile error, numbers are 1-based.
|
// or [ 1, <general_error_message>, <compiler_message>, <line_number>, <column_number> ] in case of compile error, numbers are 1-based.
|
||||||
|
@ -61,8 +61,6 @@ var JavaScriptCallFrame;
|
|||||||
*/
|
*/
|
||||||
var Debug = {};
|
var Debug = {};
|
||||||
|
|
||||||
Debug.clearStepping = function() {}
|
|
||||||
|
|
||||||
Debug.clearAllBreakPoints = function() {}
|
Debug.clearAllBreakPoints = function() {}
|
||||||
|
|
||||||
/** @return {!Array<!Script>} */
|
/** @return {!Array<!Script>} */
|
||||||
@ -192,9 +190,6 @@ BreakEvent.prototype.breakPointsHit = function() {}
|
|||||||
/** @interface */
|
/** @interface */
|
||||||
function ExecutionState() {}
|
function ExecutionState() {}
|
||||||
|
|
||||||
/** @param {!Debug.StepAction} action */
|
|
||||||
ExecutionState.prototype.prepareStep = function(action) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} source
|
* @param {string} source
|
||||||
* @param {boolean} disableBreak
|
* @param {boolean} disableBreak
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
namespace v8_inspector {
|
namespace v8_inspector {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char stepIntoV8MethodName[] = "stepIntoStatement";
|
|
||||||
const char stepOutV8MethodName[] = "stepOutOfFunction";
|
|
||||||
static const char v8AsyncTaskEventEnqueue[] = "enqueue";
|
static const char v8AsyncTaskEventEnqueue[] = "enqueue";
|
||||||
static const char v8AsyncTaskEventEnqueueRecurring[] = "enqueueRecurring";
|
static const char v8AsyncTaskEventEnqueueRecurring[] = "enqueueRecurring";
|
||||||
static const char v8AsyncTaskEventWillHandle[] = "willHandle";
|
static const char v8AsyncTaskEventWillHandle[] = "willHandle";
|
||||||
@ -315,37 +313,27 @@ void V8Debugger::continueProgram() {
|
|||||||
void V8Debugger::stepIntoStatement() {
|
void V8Debugger::stepIntoStatement() {
|
||||||
DCHECK(isPaused());
|
DCHECK(isPaused());
|
||||||
DCHECK(!m_executionState.IsEmpty());
|
DCHECK(!m_executionState.IsEmpty());
|
||||||
v8::HandleScope handleScope(m_isolate);
|
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn);
|
||||||
v8::Local<v8::Value> argv[] = {m_executionState};
|
|
||||||
callDebuggerMethod(stepIntoV8MethodName, 1, argv);
|
|
||||||
continueProgram();
|
continueProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8Debugger::stepOverStatement() {
|
void V8Debugger::stepOverStatement() {
|
||||||
DCHECK(isPaused());
|
DCHECK(isPaused());
|
||||||
DCHECK(!m_executionState.IsEmpty());
|
DCHECK(!m_executionState.IsEmpty());
|
||||||
v8::HandleScope handleScope(m_isolate);
|
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepNext);
|
||||||
v8::Local<v8::Value> argv[] = {m_executionState};
|
|
||||||
callDebuggerMethod("stepOverStatement", 1, argv);
|
|
||||||
continueProgram();
|
continueProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8Debugger::stepOutOfFunction() {
|
void V8Debugger::stepOutOfFunction() {
|
||||||
DCHECK(isPaused());
|
DCHECK(isPaused());
|
||||||
DCHECK(!m_executionState.IsEmpty());
|
DCHECK(!m_executionState.IsEmpty());
|
||||||
v8::HandleScope handleScope(m_isolate);
|
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut);
|
||||||
v8::Local<v8::Value> argv[] = {m_executionState};
|
|
||||||
callDebuggerMethod(stepOutV8MethodName, 1, argv);
|
|
||||||
continueProgram();
|
continueProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8Debugger::clearStepping() {
|
void V8Debugger::clearStepping() {
|
||||||
DCHECK(enabled());
|
DCHECK(enabled());
|
||||||
v8::HandleScope scope(m_isolate);
|
v8::DebugInterface::ClearStepping(m_isolate);
|
||||||
v8::Context::Scope contextScope(debuggerContext());
|
|
||||||
|
|
||||||
v8::Local<v8::Value> argv[] = {v8::Undefined(m_isolate)};
|
|
||||||
callDebuggerMethod("clearStepping", 0, argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool V8Debugger::setScriptSource(
|
bool V8Debugger::setScriptSource(
|
||||||
@ -544,14 +532,11 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
|
|||||||
m_executionState.Clear();
|
m_executionState.Clear();
|
||||||
|
|
||||||
if (result == V8DebuggerAgentImpl::RequestStepFrame) {
|
if (result == V8DebuggerAgentImpl::RequestStepFrame) {
|
||||||
v8::Local<v8::Value> argv[] = {executionState};
|
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepFrame);
|
||||||
callDebuggerMethod("stepFrameStatement", 1, argv);
|
|
||||||
} else if (result == V8DebuggerAgentImpl::RequestStepInto) {
|
} else if (result == V8DebuggerAgentImpl::RequestStepInto) {
|
||||||
v8::Local<v8::Value> argv[] = {executionState};
|
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn);
|
||||||
callDebuggerMethod(stepIntoV8MethodName, 1, argv);
|
|
||||||
} else if (result == V8DebuggerAgentImpl::RequestStepOut) {
|
} else if (result == V8DebuggerAgentImpl::RequestStepOut) {
|
||||||
v8::Local<v8::Value> argv[] = {executionState};
|
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut);
|
||||||
callDebuggerMethod(stepOutV8MethodName, 1, argv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user