|
|
@ -2,7 +2,6 @@ |
|
|
|
//statesList => ListView
|
|
|
|
|
|
|
|
var currentSelectedState = null; |
|
|
|
var jumpStartingPoint = null; |
|
|
|
var debugData = null; |
|
|
|
var codeMap = null; |
|
|
|
|
|
|
@ -12,13 +11,14 @@ function init(data) |
|
|
|
jumpIntoBackAction.enabled(false); |
|
|
|
jumpIntoForwardAction.enabled(false); |
|
|
|
jumpOutForwardAction.enabled(false); |
|
|
|
jumpOverBackAction.enabled(false); |
|
|
|
jumpOverForwardAction.enabled(false); |
|
|
|
|
|
|
|
if (data === null) { |
|
|
|
statesList.model.clear(); |
|
|
|
statesSlider.maximumValue = 0; |
|
|
|
statesSlider.value = 0; |
|
|
|
currentSelectedState = null; |
|
|
|
jumpStartingPoint = null; |
|
|
|
debugData = null; |
|
|
|
return; |
|
|
|
} |
|
|
@ -40,6 +40,7 @@ function setupInstructions(stateIndex) { |
|
|
|
statesList.model.append(instructions[i]); |
|
|
|
codeMap[instructions[i].processIndex] = i; |
|
|
|
} |
|
|
|
callDataDump.listModel = debugData.states[stateIndex].callData.items; |
|
|
|
} |
|
|
|
|
|
|
|
function moveSelection(incr) |
|
|
@ -49,12 +50,15 @@ function moveSelection(incr) |
|
|
|
{ |
|
|
|
if (currentSelectedState + incr < debugData.states.length) |
|
|
|
select(currentSelectedState + incr); |
|
|
|
statesSlider.value = currentSelectedState; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function select(stateIndex) |
|
|
|
{ |
|
|
|
if (stateIndex < 0) |
|
|
|
stateIndex = 0; |
|
|
|
if (stateIndex >= debugData.states.length) |
|
|
|
stateIndex = debugData.state.length - 1; |
|
|
|
if (debugData.states[stateIndex].codeIndex !== debugData.states[currentSelectedState].codeIndex) |
|
|
|
setupInstructions(stateIndex); |
|
|
|
currentSelectedState = stateIndex; |
|
|
@ -63,15 +67,13 @@ function select(stateIndex) |
|
|
|
highlightSelection(codeLine); |
|
|
|
completeCtxInformation(state); |
|
|
|
|
|
|
|
if (state.instruction === "CALL" || state.instruction === "CREATE") |
|
|
|
jumpIntoForwardAction.enabled(true); |
|
|
|
else |
|
|
|
jumpIntoForwardAction.enabled(false); |
|
|
|
|
|
|
|
if (state.instruction === "JUMPDEST") |
|
|
|
jumpIntoBackAction.enabled(true); |
|
|
|
else |
|
|
|
jumpIntoBackAction.enabled(false); |
|
|
|
statesSlider.value = currentSelectedState; |
|
|
|
jumpIntoForwardAction.enabled(stateIndex < debugData.states.length - 1) |
|
|
|
jumpIntoBackAction.enabled(stateIndex > 0); |
|
|
|
jumpOverForwardAction.enabled(stateIndex < debugData.states.length - 1); |
|
|
|
jumpOverBackAction.enabled(stateIndex > 0); |
|
|
|
jumpOutBackAction.enabled(state.levels.length > 1); |
|
|
|
jumpOutForwardAction.enabled(state.levels.length > 1); |
|
|
|
} |
|
|
|
|
|
|
|
function codeStr(stateIndex) |
|
|
@ -83,6 +85,7 @@ function codeStr(stateIndex) |
|
|
|
function highlightSelection(index) |
|
|
|
{ |
|
|
|
statesList.currentIndex = index; |
|
|
|
statesList.positionViewAtIndex(index, ListView.Center); |
|
|
|
} |
|
|
|
|
|
|
|
function completeCtxInformation(state) |
|
|
@ -95,18 +98,18 @@ function completeCtxInformation(state) |
|
|
|
stack.listModel = state.debugStack; |
|
|
|
storage.listModel = state.debugStorage; |
|
|
|
memoryDump.listModel = state.debugMemory; |
|
|
|
callDataDump.listModel = state.debugCallData; |
|
|
|
} |
|
|
|
|
|
|
|
function stepOutBack() |
|
|
|
function isCallInstruction(index) |
|
|
|
{ |
|
|
|
if (jumpStartingPoint != null) |
|
|
|
{ |
|
|
|
select(jumpStartingPoint); |
|
|
|
jumpStartingPoint = null; |
|
|
|
jumpOutBackAction.enabled(false); |
|
|
|
jumpOutForwardAction.enabled(false); |
|
|
|
} |
|
|
|
var state = debugData.states[index]; |
|
|
|
return state.instruction === "CALL" || state.instruction === "CREATE"; |
|
|
|
} |
|
|
|
|
|
|
|
function isReturnInstruction(index) |
|
|
|
{ |
|
|
|
var state = debugData.states[index]; |
|
|
|
return state.instruction === "RETURN" |
|
|
|
} |
|
|
|
|
|
|
|
function stepIntoBack() |
|
|
@ -116,63 +119,52 @@ function stepIntoBack() |
|
|
|
|
|
|
|
function stepOverBack() |
|
|
|
{ |
|
|
|
var state = debugData.states[currentSelectedState]; |
|
|
|
if (state.instruction === "CALL" || state.instruction === "CREATE") |
|
|
|
{ |
|
|
|
for (var k = currentSelectedState; k > 0; k--) |
|
|
|
{ |
|
|
|
var line = codeMap[debugData.states[k].curPC]; |
|
|
|
if (line === statesList.currentIndex - 2) |
|
|
|
{ |
|
|
|
select(k); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (currentSelectedState > 0 && isReturnInstruction(currentSelectedState - 1)) |
|
|
|
stepOutBack(); |
|
|
|
else |
|
|
|
moveSelection(-1); |
|
|
|
} |
|
|
|
|
|
|
|
function stepOverForward() |
|
|
|
{ |
|
|
|
var state = debugData.states[currentSelectedState]; |
|
|
|
if (state.instruction === "CALL" || state.instruction === "CREATE") |
|
|
|
{ |
|
|
|
for (var k = currentSelectedState; k < debugData.states.length; k++) |
|
|
|
{ |
|
|
|
var line = codeMap[debugData.states[k].curPC]; |
|
|
|
if (line === statesList.currentIndex + 2) |
|
|
|
{ |
|
|
|
select(k); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (isCallInstruction(currentSelectedState)) |
|
|
|
stepOutForward(); |
|
|
|
else |
|
|
|
moveSelection(1); |
|
|
|
} |
|
|
|
|
|
|
|
function stepIntoForward() |
|
|
|
{ |
|
|
|
var state = debugData.states[currentSelectedState]; |
|
|
|
if (state.instruction === "CALL" || state.instruction === "CREATE") |
|
|
|
{ |
|
|
|
jumpStartingPoint = currentSelectedState; |
|
|
|
moveSelection(1); |
|
|
|
jumpOutBackAction.enabled(true); |
|
|
|
jumpOutForwardAction.enabled(true); |
|
|
|
} |
|
|
|
moveSelection(1); |
|
|
|
} |
|
|
|
|
|
|
|
function stepOutBack() |
|
|
|
{ |
|
|
|
var i = currentSelectedState - 1; |
|
|
|
var depth = 0; |
|
|
|
while (--i >= 0) |
|
|
|
if (isCallInstruction(i)) |
|
|
|
if (depth == 0) |
|
|
|
break; |
|
|
|
else depth--; |
|
|
|
else if (isReturnInstruction(i)) |
|
|
|
depth++; |
|
|
|
select(i); |
|
|
|
} |
|
|
|
|
|
|
|
function stepOutForward() |
|
|
|
{ |
|
|
|
if (jumpStartingPoint != null) |
|
|
|
{ |
|
|
|
stepOutBack(); |
|
|
|
stepOverForward(); |
|
|
|
jumpOutBackAction.enabled(false); |
|
|
|
jumpOutForwardAction.enabled(false); |
|
|
|
} |
|
|
|
var i = currentSelectedState; |
|
|
|
var depth = 0; |
|
|
|
while (++i < debugData.states.length) |
|
|
|
if (isReturnInstruction(i)) |
|
|
|
if (depth == 0) |
|
|
|
break; |
|
|
|
else |
|
|
|
depth--; |
|
|
|
else if (isCallInstruction(i)) |
|
|
|
depth++; |
|
|
|
select(i + 1); |
|
|
|
} |
|
|
|
|
|
|
|
function jumpTo(value) |
|
|
|