When my code is executing my trace_function set using set_trace_func how
do I get the return value for a ruby return event? Say for example I had
a function
def myFunc(arg1, arg2)
result = arg1 * arg2
end
and my trace function has been called for the return event for the
myFunc() function. The function always returns the last data item
evaluated, which in this case is result. Can I determine this value from
inside the trace function? If I can how do I do so?
I've spent all this afternoon trying to do this (and the other problem
in my other question), examining the Ruby source, but can't work it out.
Hope someone can help me, or tell me it can't be done
When my code is executing my trace_function set using set_trace_func how
do I get the return value for a ruby return event? Say for example I had
a function
def myFunc(arg1, arg2)
result = arg1 * arg2
end
and my trace function has been called for the return event for the
myFunc() function. The function always returns the last data item
evaluated, which in this case is result. Can I determine this value from
inside the trace function? If I can how do I do so?
I've spent all this afternoon trying to do this (and the other problem
in my other question), examining the Ruby source, but can't work it out.
Hope someone can help me, or tell me it can't be done
Stephen
Stephen,
This is a complete shot-in-the-dark from a noob but have you tried adding this as the last line of the function?
return result
I heard somewhere it negatively impacts performance to add an explicit return statement in functions. Maybe the cause of this performace hit will be the same thing that helps when tracing.
This is a complete shot-in-the-dark from a noob but have you tried adding this as the last line of the function?
return result
I heard somewhere it negatively impacts performance to add an explicit return statement in functions. Maybe the cause of this performace hit will be the same thing that helps when tracing.