On 23 Nov 2018, at 14:59, Marcus Denker <marcus.denker@inria.fr> wrote:
On 23 Nov 2018, at 13:40, Manuel Leuenberger <leuenberger@inf.unibe.ch> wrote:
Hi,
I stumbled upon another MetaLink scenario that I am unsure how to implement. I want to track method invocations, with receiver, arguments, selector, and return value (maybe even signaled exception). I can track the method input with a MetaLink installed on an RBMethodNode like this:
MetaLink new metaObject: [ :c | Transcript show: c receiver; show: c method selector; show: c arguments; cr ]; selector: #value:; arguments: #(context).
and for returns with a MetaLink on RBReturnNodes like this:
MetaLink new metaObject: [ :v | Transcript show: v; cr ]; selector: #value:; arguments: #(value)
The problem is though, that not all methods have explicit returns, and some mix explicit returns and self returns. I tried installed an #after MetaLink on a RBMethodNode, but this fails in many cases. Is there any way that I can instrument a method and track receiver, selector, arguments, and returned value (even if self) at the same time?
I am working now on making the #after work so that one can get with #value the return of the methodâ¦
I now have a version where it works for Message Sends correctly *and* were #after on Method works better (the compilation errors should be fixed).
But #value for #after on Method needs some more work⦠soon!
I will commit this intermediate step now.
Here is the first step: https://github.com/pharo-project/pharo/pull/2011 ⢠#operation for send after ⢠#operation and value for {} arrays ⢠#after hooks: preamble now executed before the operation ⢠#after hooks: added concept of postamble, executed just before hook Next I need to look into #value for #after on methods. This got broken because we wrap the whole method in an exception handler (as #after should be called even if an exception happens). But this adds too much complexity⦠especially how it is done now. I think I will simplify that in a next step. Marcus