-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return/throw callback support #37
Comments
I think it's also important to note that functionExit/invokeFun aren't sufficient for knowing what line of code returns. This is because try/finally blocks can execute code after an expression is returned. For example, the given analysis used on the given code makes it impossible to tell which line of code triggers the return.
// DO NOT INSTRUMENT
(function (sandbox) {
function MyAnalysis() {
/**
* These callbacks are called before and after a function, method, or constructor invocation.
**/
this.invokeFunPre = function (iid, f, base, args, isConstructor, isMethod, functionIid, functionSid) {
console.log("invokeFunPre");
};
this.invokeFun = function (iid, f, base, args, result, isConstructor, isMethod, functionIid, functionSid) {
console.log("invokeFun");
};
/**
* These callbacks are called before the execution of a function body starts and after it completes.
**/
this.functionEnter = function (iid, f, dis, args) {
console.log("functionEnter");
};
this.functionExit = function (iid, returnVal, wrappedExceptionVal) {
console.log("functionExit");
};
/**
* These callbacks are called after a variable is read or written.
**/
this.read = function (iid, name, val, isGlobal, isScriptLocal) {
console.log("read " + val);
};
this.write = function (iid, name, val, lhs, isGlobal, isScriptLocal) {
console.log("write " + name + " = " + val);
};
}
sandbox.analysis = new MyAnalysis();
})(J$);
let a = 0;
function example(arg1, arg2) {
try {
return arg1;
} finally {
a = 1;
arg2;
}
}
example(10, 20);
Ideally, listening to the return callback would give us:
|
Any update on this feature? |
The ThrowNode has a branch tag, which I can hook in NodeProf. However there is not yet any specific tag for the ReturnNode. @eleinadani is it possible to add a new |
couldn't you simply intercept all throw/return values via |
It is about the comment from @mwaldrich above
Existing value returned or thrown do not reveal the line of code which returns or throws. |
Instrumentation support for |
Thanks for the implementation! I'm starting to use this in my analysis now. I noticed this callback doesn't provide the function that the code is returning from. While it is possible for me to maintain a call stack in my analysis, it would be much more efficient to re-use the call stack in Graal. In addition, this change would make the |
@mwaldrich this is doable, I can add support for this. |
I would advise against this: executing a Consider this example:
The
|
Yes, it wouldn't make sense to model a callstack using the I wanted the function in the If I wanted to do this with the current callback, I would need to model a callstack in my analysis (using However, I could see how people might assume that |
Is there an ETA for implementation of these callbacks? My team would like to use these in our analysis.
The text was updated successfully, but these errors were encountered: