add error param in callback functions

pull/7/head
yann300 9 years ago
parent 28cb70ee12
commit 505d74365a
  1. 20
      src/asmCode.js
  2. 6
      src/calldataPanel.js
  3. 6
      src/callstackPanel.js
  4. 6
      src/memoryPanel.js
  5. 6
      src/stackPanel.js
  6. 8
      src/stepManager.js
  7. 48
      src/sticker.js
  8. 6
      src/storagePanel.js
  9. 44
      src/traceManager.js
  10. 6
      src/vmDebugger.js

@ -48,8 +48,12 @@ module.exports = React.createClass({
if (nextProps.currentStepIndex < 0) return
codeResolver.setWeb3(this.context.web3)
var self = this
this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (address) {
self.ensureCodeLoaded(address, nextProps.currentStepIndex)
this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (error, address) {
if (error) {
console.log(error)
} else {
self.ensureCodeLoaded(address, nextProps.currentStepIndex)
}
})
},
@ -77,10 +81,14 @@ module.exports = React.createClass({
setInstructionIndex: function (address, step) {
var self = this
this.context.traceManager.getCurrentPC(step, function (instIndex) {
self.setState({
selected: codeResolver.getInstructionIndex(address, instIndex)
})
this.context.traceManager.getCurrentPC(step, function (error, instIndex) {
if (error) {
console.log(error)
} else {
self.setState({
selected: codeResolver.getInstructionIndex(address, instIndex)
})
}
})
}
})

@ -30,8 +30,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this
this.context.traceManager.getCallDataAt(nextProps.currentStepIndex, function (calldata) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
this.context.traceManager.getCallDataAt(nextProps.currentStepIndex, function (error, calldata) {
if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({
data: calldata
})

@ -30,8 +30,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this
this.context.traceManager.getCallStackAt(nextProps.currentStepIndex, function (callstack) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
this.context.traceManager.getCallStackAt(nextProps.currentStepIndex, function (error, callstack) {
if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({
data: callstack
})

@ -31,8 +31,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this
this.context.traceManager.getMemoryAt(nextProps.currentStepIndex, function (memory) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
this.context.traceManager.getMemoryAt(nextProps.currentStepIndex, function (error, memory) {
if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({
data: self.formatMemory(memory, 16)
})

@ -30,8 +30,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this
this.context.traceManager.getStackAt(nextProps.currentStepIndex, function (stack) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
this.context.traceManager.getStackAt(nextProps.currentStepIndex, function (error, stack) {
if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({
data: stack
})

@ -54,8 +54,12 @@ module.exports = React.createClass({
newTraceAvailable: function () {
this.init()
var self = this
this.context.traceManager.getLength(function (length) {
self.setState({ traceLength: length })
this.context.traceManager.getLength(function (error, length) {
if (error) {
console.log(error)
} else {
self.setState({ traceLength: length })
}
})
},

@ -84,28 +84,44 @@ module.exports = React.createClass({
if (nextProps.currentStepIndex < 0) return
var self = this
this.context.traceManager.getCurrentStep(nextProps.currentStepIndex, function (step) {
self.setState({
step: step
})
this.context.traceManager.getCurrentStep(nextProps.currentStepIndex, function (error, step) {
if (error) {
console.log(error)
} else {
self.setState({
step: step
})
}
})
this.context.traceManager.getMemExpand(nextProps.currentStepIndex, function (addmem) {
self.setState({
addmemory: addmem
})
this.context.traceManager.getMemExpand(nextProps.currentStepIndex, function (error, addmem) {
if (error) {
console.log(error)
} else {
self.setState({
addmemory: addmem
})
}
})
this.context.traceManager.getStepCost(nextProps.currentStepIndex, function (gas) {
self.setState({
gas: gas
})
this.context.traceManager.getStepCost(nextProps.currentStepIndex, function (error, gas) {
if (error) {
console.log(error)
} else {
self.setState({
gas: gas
})
}
})
this.context.traceManager.getRemainingGas(nextProps.currentStepIndex, function (remaingas) {
self.setState({
remaininGas: remaingas
})
this.context.traceManager.getRemainingGas(nextProps.currentStepIndex, function (error, remaingas) {
if (error) {
console.log(error)
} else {
self.setState({
remaininGas: remaingas
})
}
})
}
})

@ -31,8 +31,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this
this.context.traceManager.getStorageAt(nextProps.currentStepIndex, this.context.tx.blockNumber.toString(), this.context.tx.transactionIndex, function (storage) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
this.context.traceManager.getStorageAt(nextProps.currentStepIndex, this.context.tx.blockNumber.toString(), this.context.tx.transactionIndex, function (error, storage) {
if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({
data: storage
})

@ -136,14 +136,14 @@ module.exports = {
// API section
getLength: function (callback) {
if (!this.trace) callback(0)
callback(this.trace.length)
if (!this.trace) callback('no trace available', null)
callback(null, this.trace.length)
},
getStorageAt: function (stepIndex, blockNumber, txIndex, callback) {
var stoChange = this.findLowerBound(stepIndex, this.vmTraceChangesRef)
if (!stoChange) {
return {}
callback('cannot rebuild storage', null)
}
var changeRefs = this.vmTraceIndexByStorageChange[stoChange]
@ -160,20 +160,20 @@ module.exports = {
}
}
}
callback(storage)
callback(null, storage)
})
},
getCallDataAt: function (stepIndex, callback) {
var callDataChange = this.findLowerBound(stepIndex, this.callDataChanges)
if (!callDataChange) return ['']
callback([this.trace[callDataChange].calldata])
if (!callDataChange) return callback('no calldata found', null)
callback(null, [this.trace[callDataChange].calldata])
},
getCallStackAt: function (stepIndex, callback) {
var callStackChange = this.findLowerBound(stepIndex, this.depthChanges)
if (!callStackChange) return ''
callback(this.callStack[callStackChange].stack)
if (!callStackChange) return callback('no callstack found', null)
callback(null, this.callStack[callStackChange].stack)
},
getStackAt: function (stepIndex, callback) {
@ -181,46 +181,52 @@ module.exports = {
if (this.trace[stepIndex].stack) { // there's always a stack
stack = this.trace[stepIndex].stack.slice(0)
stack.reverse()
callback(stack)
callback(null, stack)
} else {
callback('no stack found', null)
}
},
getLastDepthIndexChangeSince: function (stepIndex, callback) {
var depthIndex = this.findLowerBound(stepIndex, this.depthChanges)
callback(depthIndex)
callback(null, depthIndex)
},
getCurrentCalledAddressAt: function (stepIndex, callback) {
var self = this
this.getLastDepthIndexChangeSince(stepIndex, function (addressIndex) {
callback(self.resolveAddress(addressIndex))
this.getLastDepthIndexChangeSince(stepIndex, function (error, addressIndex) {
if (error) {
callback(error, null)
} else {
callback(null, self.resolveAddress(addressIndex))
}
})
},
getMemoryAt: function (stepIndex, callback) {
var lastChanges = this.findLowerBound(stepIndex, this.memoryChanges)
if (!lastChanges) return ''
callback(this.trace[lastChanges].memory)
if (!lastChanges) return callback('no memory found', null)
callback(null, this.trace[lastChanges].memory)
},
getCurrentPC: function (stepIndex, callback) {
callback(this.trace[stepIndex].pc)
callback(null, this.trace[stepIndex].pc)
},
getCurrentStep: function (stepIndex, callback) {
callback(this.trace[stepIndex].steps)
callback(null, this.trace[stepIndex].steps)
},
getMemExpand: function (stepIndex, callback) {
callback(this.trace[stepIndex].memexpand ? this.trace[stepIndex].memexpand : '')
callback(null, this.trace[stepIndex].memexpand ? this.trace[stepIndex].memexpand : '')
},
getStepCost: function (stepIndex, callback) {
callback(this.trace[stepIndex].gascost)
callback(null, this.trace[stepIndex].gascost)
},
getRemainingGas: function (stepIndex, callback) {
callback(this.trace[stepIndex].gas)
callback(null, this.trace[stepIndex].gas)
},
// step section

@ -73,8 +73,10 @@ module.exports = React.createClass({
if (nextProps.currentStepIndex < 0) return
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this
this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (address) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (error, address) {
if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({
currentAddress: address
})

Loading…
Cancel
Save