[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
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://chromiumcodereview.appspot.com/2423153002
Cr-Commit-Position: refs/heads/master@{#40483}
This commit is contained in:
kozyatinskiy 2016-10-20 11:51:34 -07:00 committed by Commit bot
parent 209e57e98d
commit 24e5dfb546
6 changed files with 40 additions and 66 deletions

View File

@ -8814,6 +8814,23 @@ void DebugInterface::ChangeBreakOnException(Isolate* isolate,
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);
// Clear all current stepping setup.
isolate->debug()->ClearStepping();
}
Local<String> CpuProfileNode::GetFunctionName() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
i::Isolate* isolate = node->isolate();

View File

@ -127,6 +127,17 @@ class DebugInterface {
*/
static void ChangeBreakOnException(Isolate* isolate,
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

View File

@ -501,8 +501,11 @@ class Debug {
void Iterate(ObjectVisitor* v);
bool CheckExecutionState(int id) {
return is_active() && !debug_context().is_null() && break_id() != 0 &&
break_id() == id;
return CheckExecutionState() && break_id() == id;
}
bool CheckExecutionState() {
return is_active() && !debug_context().is_null() && break_id() != 0;
}
// Flags and states.

View File

@ -253,43 +253,6 @@ DebuggerScript.currentCallFrames = function(execState, limit)
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:
// [ 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.

View File

@ -61,8 +61,6 @@ var JavaScriptCallFrame;
*/
var Debug = {};
Debug.clearStepping = function() {}
Debug.clearAllBreakPoints = function() {}
/** @return {!Array<!Script>} */
@ -192,9 +190,6 @@ BreakEvent.prototype.breakPointsHit = function() {}
/** @interface */
function ExecutionState() {}
/** @param {!Debug.StepAction} action */
ExecutionState.prototype.prepareStep = function(action) {}
/**
* @param {string} source
* @param {boolean} disableBreak

View File

@ -17,8 +17,6 @@
namespace v8_inspector {
namespace {
const char stepIntoV8MethodName[] = "stepIntoStatement";
const char stepOutV8MethodName[] = "stepOutOfFunction";
static const char v8AsyncTaskEventEnqueue[] = "enqueue";
static const char v8AsyncTaskEventEnqueueRecurring[] = "enqueueRecurring";
static const char v8AsyncTaskEventWillHandle[] = "willHandle";
@ -315,37 +313,27 @@ void V8Debugger::continueProgram() {
void V8Debugger::stepIntoStatement() {
DCHECK(isPaused());
DCHECK(!m_executionState.IsEmpty());
v8::HandleScope handleScope(m_isolate);
v8::Local<v8::Value> argv[] = {m_executionState};
callDebuggerMethod(stepIntoV8MethodName, 1, argv);
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn);
continueProgram();
}
void V8Debugger::stepOverStatement() {
DCHECK(isPaused());
DCHECK(!m_executionState.IsEmpty());
v8::HandleScope handleScope(m_isolate);
v8::Local<v8::Value> argv[] = {m_executionState};
callDebuggerMethod("stepOverStatement", 1, argv);
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepNext);
continueProgram();
}
void V8Debugger::stepOutOfFunction() {
DCHECK(isPaused());
DCHECK(!m_executionState.IsEmpty());
v8::HandleScope handleScope(m_isolate);
v8::Local<v8::Value> argv[] = {m_executionState};
callDebuggerMethod(stepOutV8MethodName, 1, argv);
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut);
continueProgram();
}
void V8Debugger::clearStepping() {
DCHECK(enabled());
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(debuggerContext());
v8::Local<v8::Value> argv[] = {v8::Undefined(m_isolate)};
callDebuggerMethod("clearStepping", 0, argv);
v8::DebugInterface::ClearStepping(m_isolate);
}
bool V8Debugger::setScriptSource(
@ -544,14 +532,11 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
m_executionState.Clear();
if (result == V8DebuggerAgentImpl::RequestStepFrame) {
v8::Local<v8::Value> argv[] = {executionState};
callDebuggerMethod("stepFrameStatement", 1, argv);
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepFrame);
} else if (result == V8DebuggerAgentImpl::RequestStepInto) {
v8::Local<v8::Value> argv[] = {executionState};
callDebuggerMethod(stepIntoV8MethodName, 1, argv);
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn);
} else if (result == V8DebuggerAgentImpl::RequestStepOut) {
v8::Local<v8::Value> argv[] = {executionState};
callDebuggerMethod(stepOutV8MethodName, 1, argv);
v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut);
}
}