add findCall

pull/7/head
yann300 8 years ago
parent 92666bf9dd
commit 1e5e4e8f2c
  1. 22
      src/helpers/util.js

@ -83,5 +83,27 @@ module.exports = {
findLowerBoundValue: function (target, array) {
var index = this.findLowerBound(target, array)
return index >= 0 ? array[index] : null
},
findCall: findCall
}
/**
* Find the call from @args rootCall which contains @args index (recursive)
*
* @param {Int} index - index of the vmtrace
* @param {Object} rootCall - call tree, built by the trace analyser
* @return {Object} - return the call which include the @args index
*/
function findCall (index, rootCall) {
var calls = Object.keys(rootCall.calls)
var ret = rootCall
for (var k in calls) {
var subCall = rootCall.calls[calls[k]]
if (index >= subCall.start && index <= subCall.return) {
ret = findCall(index, subCall)
break
}
}
return ret
}

Loading…
Cancel
Save