Update TraceManager to use the new callstree

pull/7/head
yann300 8 years ago
parent 858f17d264
commit 3df99cd319
  1. 32
      src/trace/traceManager.js
  2. 17
      src/trace/traceStepManager.js

@ -101,14 +101,7 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address
}
TraceManager.prototype.getAddresses = function (callback) {
var addresses = [ this.tx.to ]
for (var k in this.traceCache.calls) {
var address = this.traceCache.calls[k].address
if (address && addresses.join('').indexOf(address) === -1) {
addresses.push(address)
}
}
callback(null, addresses)
callback(null, this.traceCache.addresses)
}
TraceManager.prototype.getCallDataAt = function (stepIndex, callback) {
@ -126,9 +119,9 @@ TraceManager.prototype.getCallStackAt = function (stepIndex, callback) {
if (check) {
return callback(check, null)
}
var callStackChange = util.findLowerBoundValue(stepIndex, this.traceCache.callChanges)
if (callStackChange === null) return callback('no callstack found', null)
callback(null, this.traceCache.calls[callStackChange].callStack)
var call = util.findCall(stepIndex, this.traceCache.callsTree.call)
if (call === null) return callback('no callstack found', null)
callback(null, call.callStack)
}
TraceManager.prototype.getStackAt = function (stepIndex, callback) {
@ -151,7 +144,7 @@ TraceManager.prototype.getLastCallChangeSince = function (stepIndex, callback) {
if (check) {
return callback(check, null)
}
var callChange = util.findLowerBoundValue(stepIndex, this.traceCache.callChanges)
var callChange = util.findCall(stepIndex, this.traceCache.callsTree.call)
if (callChange === null) {
callback(null, 0)
} else {
@ -164,21 +157,14 @@ TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex, callback
if (check) {
return callback(check, null)
}
var self = this
this.getLastCallChangeSince(stepIndex, function (error, addressIndex) {
this.getLastCallChangeSince(stepIndex, function (error, resp) {
if (error) {
callback(error, null)
} else {
if (addressIndex === 0) {
callback(null, self.tx.to)
if (resp) {
callback(null, resp.address)
} else {
var callStack = self.traceCache.calls[addressIndex].callStack
var calledAddress = callStack[callStack.length - 1]
if (calledAddress) {
callback(null, calledAddress)
} else {
callback('unable to get current called address. ' + stepIndex + ' does not match with a CALL', null)
}
callback('unable to get current called address. ' + stepIndex + ' does not match with a CALL')
}
}
})

@ -33,25 +33,18 @@ TraceStepManager.prototype.findStepOverForward = function (currentStep) {
}
TraceStepManager.prototype.findNextCall = function (currentStep) {
var callChanges = this.traceAnalyser.traceCache.callChanges
var stepIndex = util.findLowerBound(currentStep, callChanges)
var callchange = callChanges[stepIndex + 1]
if (callchange && this.isCallInstruction(callchange - 1)) {
return callchange - 1
var call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
var subCalls = Object.keys(call.calls)
if (subCalls.length) {
return call.calls[subCalls[0]].start - 1
} else {
return currentStep
}
}
TraceStepManager.prototype.findStepOut = function (currentStep) {
var callChanges = this.traceAnalyser.traceCache.callChanges
var stepIndex = util.findLowerBound(currentStep, callChanges)
var call = this.traceAnalyser.traceCache.calls[callChanges[stepIndex]]
if (call && call.return) {
var call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
return call.return
} else {
return currentStep
}
}
module.exports = TraceStepManager

Loading…
Cancel
Save