fix step over back, step over forward

pull/7/head
yann300 8 years ago
parent e6fea60b0c
commit def9a9ee67
  1. 10
      src/trace/traceStepManager.js
  2. 14
      test-browser/vmdebugger.js

@ -8,7 +8,7 @@ function TraceStepManager (_traceAnalyser) {
TraceStepManager.prototype.isCallInstruction = function (index) { TraceStepManager.prototype.isCallInstruction = function (index) {
var state = this.traceAnalyser.trace[index] var state = this.traceAnalyser.trace[index]
return traceHelper.isCallInstruction(state) return traceHelper.isCallInstruction(state) && !traceHelper.isCallToPrecompiledContract(index, this.traceAnalyser.trace)
} }
TraceStepManager.prototype.isReturnInstruction = function (index) { TraceStepManager.prototype.isReturnInstruction = function (index) {
@ -17,8 +17,9 @@ TraceStepManager.prototype.isReturnInstruction = function (index) {
} }
TraceStepManager.prototype.findStepOverBack = function (currentStep) { TraceStepManager.prototype.findStepOverBack = function (currentStep) {
if (this.isReturnInstruction(currentStep - 1)) { if (this.isReturnInstruction(currentStep)) {
return this.traceAnalyser.traceCache.calls[currentStep].call - 1 var call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
return call.start > 0 ? call.start - 1 : 0
} else { } else {
return currentStep > 0 ? currentStep - 1 : 0 return currentStep > 0 ? currentStep - 1 : 0
} }
@ -26,7 +27,8 @@ TraceStepManager.prototype.findStepOverBack = function (currentStep) {
TraceStepManager.prototype.findStepOverForward = function (currentStep) { TraceStepManager.prototype.findStepOverForward = function (currentStep) {
if (this.isCallInstruction(currentStep)) { if (this.isCallInstruction(currentStep)) {
return this.traceAnalyser.traceCache.calls[currentStep + 1].return var call = util.findCall(currentStep + 1, this.traceAnalyser.traceCache.callsTree.call)
return call.return + 1 < this.traceAnalyser.trace.length ? call.return + 1 : this.traceAnalyser.trace.length - 1
} else { } else {
return this.traceAnalyser.trace.length >= currentStep + 1 ? currentStep + 1 : currentStep return this.traceAnalyser.trace.length >= currentStep + 1 ? currentStep + 1 : currentStep
} }

@ -130,15 +130,19 @@ function stepping (browser) {
.click('#intoforward') .click('#intoforward')
.click('#overforward') .click('#overforward')
.assertCurrentSelectedItem('007 MLOAD') .assertCurrentSelectedItem('007 MLOAD')
.click('#overback') .click('#intoback')
.click('#overback') .click('#intoback')
.click('#overback') .click('#intoback')
.click('#overback') .click('#intoback')
.click('#overback') .click('#intoback')
.click('#overforward') .click('#overforward')
.assertCurrentSelectedItem('182 PUSH1 01') .assertCurrentSelectedItem('182 PUSH1 01')
.click('#overforward') .click('#overforward')
.assertCurrentSelectedItem('184 PUSH1 00') .assertCurrentSelectedItem('184 PUSH1 00')
.click('#intoback')
.click('#intoback')
.click('#overback')
.assertCurrentSelectedItem('181 CREATE')
return browser return browser
} }

Loading…
Cancel
Save