Commit 1e5e4e8f authored by yann300's avatar yann300

add findCall

parent 92666bf9
...@@ -83,5 +83,27 @@ module.exports = { ...@@ -83,5 +83,27 @@ module.exports = {
findLowerBoundValue: function (target, array) { findLowerBoundValue: function (target, array) {
var index = this.findLowerBound(target, array) var index = this.findLowerBound(target, array)
return index >= 0 ? array[index] : null 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
} }
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