diff --git a/libs/remix-debug/src/debugger/VmDebugger.js b/libs/remix-debug/src/debugger/VmDebugger.js index f9dda12c3e..5b548b8a19 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.js +++ b/libs/remix-debug/src/debugger/VmDebugger.js @@ -111,7 +111,6 @@ class VmDebuggerLogic { } }) } catch (error) { - console.log(error) } this._traceManager.getCurrentStep(index, (error, step) => { diff --git a/libs/remix-debug/src/debugger/solidityLocals.js b/libs/remix-debug/src/debugger/solidityLocals.js index f88d74249b..4e04af9e79 100644 --- a/libs/remix-debug/src/debugger/solidityLocals.js +++ b/libs/remix-debug/src/debugger/solidityLocals.js @@ -34,7 +34,7 @@ class DebuggerSolidityLocals { this.traceManager.waterfall([ this.traceManager.getStackAt, this.traceManager.getMemoryAt, - (stepIndex, next) => { + function getCurrentCalledAddressAt (stepIndex, next) { try { const address = this.traceManager.getCurrentCalledAddressAt(stepIndex) next(null, address) diff --git a/libs/remix-debug/src/solidity-decoder/internalCallTree.js b/libs/remix-debug/src/solidity-decoder/internalCallTree.js index 7a14e0fc70..a1c9da1969 100644 --- a/libs/remix-debug/src/solidity-decoder/internalCallTree.js +++ b/libs/remix-debug/src/solidity-decoder/internalCallTree.js @@ -126,19 +126,18 @@ class InternalCallTree { extractSourceLocation (step) { return new Promise((resolve, reject) => { - this.traceManager.getCurrentCalledAddressAt(step, (error, address) => { - if (!error) { - try { - this.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, step, this.solidityProxy.contracts).then(resolve).catch((error) => { - return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step + ' ' + error) - }) - } catch (error) { - return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error) - } - } else { + try { + const address = this.traceManager.getCurrentCalledAddressAt(step) + try { + this.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, step, this.solidityProxy.contracts).then(resolve).catch((error) => { + return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step + ' ' + error) + }) + } catch (error) { return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error) } - }) + } catch (error) { + return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error) + } }) } diff --git a/libs/remix-lib/src/trace/traceManager.js b/libs/remix-lib/src/trace/traceManager.js index fa89a7c814..7065f76cf5 100644 --- a/libs/remix-lib/src/trace/traceManager.js +++ b/libs/remix-lib/src/trace/traceManager.js @@ -140,24 +140,10 @@ TraceManager.prototype.getStackAt = function (stepIndex, callback) { } } -// TraceManager.prototype.getLastCallChangeSince = function (stepIndex, callback) { -// const check = this.checkRequestedStep(stepIndex) -// if (check) { -// return callback(check, null) -// } -// const callChange = util.findCall(stepIndex, this.traceCache.callsTree.call) -// if (callChange === null) { -// callback(null, 0) -// } else { -// callback(null, callChange) -// } -// } - TraceManager.prototype.getLastCallChangeSince = function (stepIndex) { try { this.checkRequestedStep(stepIndex) } catch (check) { - // return callback(check, null) throw new Error(check) } @@ -168,59 +154,16 @@ TraceManager.prototype.getLastCallChangeSince = function (stepIndex) { return callChange } -// TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex, callback) { -// const check = this.checkRequestedStep(stepIndex) -// if (check) { -// return callback(check, null) -// } -// this.getLastCallChangeSince(stepIndex, function (error, resp) { -// if (error) { -// callback(error, null) -// } else { -// if (resp) { -// callback(null, resp.address) -// } else { -// callback('unable to get current called address. ' + stepIndex + ' does not match with a CALL') -// } -// } -// }) -// } - -// TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex) { -// const check = this.checkRequestedStep(stepIndex) -// if (check) { -// // return callback(check, null) -// throw new Error(check) -// } -// try { -// const resp = this.getLastCallChangeSince(stepIndex) -// if (!resp) { -// throw new Error('unable to get current called address. ' + stepIndex + ' does not match with a CALL') -// } -// return resp.address -// } catch (error) { -// throw new Error(error) -// } -// } - -TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex, callback) { +TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex) { try { this.checkRequestedStep(stepIndex) - } catch (check) { - return callback(check, null) - } - - try { const resp = this.getLastCallChangeSince(stepIndex) if (!resp) { - // throw new Error('unable to get current called address. ' + stepIndex + ' does not match with a CALL') - callback('unable to get current called address. ' + stepIndex + ' does not match with a CALL') + throw new Error('unable to get current called address. ' + stepIndex + ' does not match with a CALL') } - // return resp.address - return callback(null, resp.address) + return resp.address } catch (error) { - // throw new Error(error) - return callback(error) + throw new Error(error) } }