NodeProf supports most of the callbacks of Jalangi and can run existing Jalangi analysis using these callbacks without modification. NodeProf also supports several features not supported by Jalangi. Details can be found in the following sections.
evalPre and evalPost for the 'eval' operation in JavaScript.
/**
* str is the code to be executed by eval
*/
this.evalPre = function (iid, str) {
}
this.evalPost = function (iid, str) {
}
evalFunctionPre and evalFunctionPost callbacks for function defined using the new Function("XXX")
:
this.evalFunctionPre= function(iid, func, receiver, args){
}
/**
* ret will be the function object created
*/
this.evalFunctionPost= function(iid, func, receiver, args, ret){
}
An extra pair of callbacks for entering built-in functions:
/**
* for built-in functions, their `name` is passed instead of an `iid`.
*/
this.builtinEnter = function (name, f, dis, args) {
};
this.builtinExit = function (name, returnVal) {
return {returnVal: returnVal};
};
NodeProf supports selecting source files for instrumentation if their name is matched by a string in an inclusion (or exclusion) list provided when registering the analysis object:
sandbox.addAnalysis(new MyAnalysis(), {excludes: 'badSource.js'});
Details can be found in the tutorial.
Jalangi can change the return value of an event by returning a specific object, e.g., {result: XXX} in the callback. This is not yet supported in NodeProf.
-
this.forinObject = function (iid, val)
-
this.declare = function (iid, name, val, isArgument, argumentIndex, isCatchParam)
-
this._return = function (iid, val)
-
this._throw = function (iid, val)
-
this._with = function (iid, val)
-
this.endExpression = function (iid)
-
this.onReady = function (cb)
-
this.scriptEnter = function (iid, instrumentedFileName, originalFileName)
-
this.scriptExit = function (iid, wrappedExceptionVal)
-
this.instrumentCodePre
-
this.instrumentCode
-
this.runInstrumentedFunctionBody