Commit 3d9b2cdc authored by yann300's avatar yann300

add getSourceLocation from stepindex

parent ce1ab50a
......@@ -37,6 +37,36 @@ SourceLocationTracker.prototype.getSourceLocation = function (address, index, co
}
/**
* Return the source location associated with the given @arg pc
*
* @param {String} address - contract address from which the source location is retrieved
* @param {Int} vmtraceStepIndex - index of the current code in the vmtrace
* @param {Object} contractDetails - AST of compiled contracts
* @param {Function} cb - callback function
*/
SourceLocationTracker.prototype.getSourceLocation = function (address, vmtraceStepIndex, contractsDetails, cb) {
var self = this
this.codeManager.getCode(address, function (error, result) {
if (!error) {
var sourceMap = getSourceMap(address, result.bytecode, contractsDetails)
if (sourceMap) {
self.codeManager.getInstructionIndex(address, vmtraceStepIndex, function (error, index) {
if (error) {
cb(error)
} else {
cb(null, self.sourceMappingDecoder.atIndex(index, sourceMap))
}
})
} else {
cb('no srcmap associated with the code ' + address)
}
} else {
cb(error)
}
})
}
/**
* backwards compatibility - attribute name will certainly be changed
*/
function srcmapRuntime (contract) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment