Tracing Method Calls

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Tracing Method Calls

Arturo Zambrano
Hi all,
   I have a piece of undocumented software that I  need  understand ... One thing I would like to do is to have a complete trace of method calls (receivers, parameters)  for certain scenarios.
  As an "aspects"guy, my first idea was to use Phantom, but it seems not active anymore.
 
 Could someone please point me to some tools that I could use for this? (using Pharo 6, 6.1 or  7) 

 Thanks in advance

 Cheers
Arturo
 
  
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Tracing Method Calls

Steven Costiou-2

Hi,

it may not be actively maintained but Phantom has recently been ported to Pharo 6/6.1 https://github.com/InesSosa95/PHANtom

 

You could also use Reflectivity (look for MetaLink class), which should not be hard to understand if you are familiar with aspects (although that is not aspects).

 

For example, if you wanted to trace the receivers and parameters of a method named #mWithArg1:withArg2:withArg3: in class C, you could do :

|link|

link := MetaLink new.

link control: #before.

link arguments: #(#receiver #arguments).

link metaObject: YourMetaObject.

link selector: #yourMethodWithArg1:andArg:.

(C lookupSelector: #mWithArg1:withArg2:withArg3:) ast link: link

 

YourMetaObject is here an object which will receive the yourMethodWithArg1:andArg: with as arguments the receiver of the method #mWithArg1:withArg2:withArg3: and its arguments as an array.

It could be a block with 2 arguments, or any other object that you would use to implement your trace behavior. You have a number of reifications available that you can pass as arguments from the context, look for subclasses of RFReification.

Steven.

 

 

Le 2018-07-27 17:25, Arturo Zambrano a écrit :

Hi all,
   I have a piece of undocumented software that I  need  understand ... One thing I would like to do is to have a complete trace of method calls (receivers, parameters)  for certain scenarios.
  As an "aspects"guy, my first idea was to use Phantom, but it seems not active anymore.
 
 Could someone please point me to some tools that I could use for this? (using Pharo 6, 6.1 or  7) 
 
 Thanks in advance
 
 Cheers
Arturo
 
  
 
 

 

Reply | Threaded
Open this post in threaded view
|

Re: Tracing Method Calls

Arturo Zambrano
Hi Steven

On Fri, Jul 27, 2018 at 3:53 PM Steven Costiou <[hidden email]> wrote:

Hi,

it may not be actively maintained but Phantom has recently been ported to Pharo 6/6.1 https://github.com/InesSosa95/PHANtom


that's a good news :)  

 

You could also use Reflectivity (look for MetaLink class), which should not be hard to understand if you are familiar with aspects (although that is not aspects).

 

For example, if you wanted to trace the receivers and parameters of a method named #mWithArg1:withArg2:withArg3: in class C, you could do :

|link|

link := MetaLink new.

link control: #before.

link arguments: #(#receiver #arguments).

link metaObject: YourMetaObject.

link selector: #yourMethodWithArg1:andArg:.

(C lookupSelector: #mWithArg1:withArg2:withArg3:) ast link: link

 

YourMetaObject is here an object which will receive the yourMethodWithArg1:andArg: with as arguments the receiver of the method #mWithArg1:withArg2:withArg3: and its arguments as an array.

It could be a block with 2 arguments, or any other object that you would use to implement your trace behavior. You have a number of reifications available that you can pass as arguments from the context, look for subclasses of RFReification.


I was not aware of MetaLink. Thank you!


 

Steven.

 

 

Le 2018-07-27 17:25, Arturo Zambrano a écrit :

Hi all,
   I have a piece of undocumented software that I  need  understand ... One thing I would like to do is to have a complete trace of method calls (receivers, parameters)  for certain scenarios.
  As an "aspects"guy, my first idea was to use Phantom, but it seems not active anymore.
 
 Could someone please point me to some tools that I could use for this? (using Pharo 6, 6.1 or  7) 
 
 Thanks in advance
 
 Cheers
Arturo
 
  
 
 

 

Reply | Threaded
Open this post in threaded view
|

Re: Tracing Method Calls

Peter Uhnák
If you want some projects using metalinks for inspiration:


(the second one also has a link to PDF explaining it in more detail)


Peter

On Wed, Aug 1, 2018 at 2:21 PM, Arturo Zambrano <[hidden email]> wrote:
Hi Steven

On Fri, Jul 27, 2018 at 3:53 PM Steven Costiou <[hidden email]> wrote:

Hi,

it may not be actively maintained but Phantom has recently been ported to Pharo 6/6.1 https://github.com/InesSosa95/PHANtom


that's a good news :)  

 

You could also use Reflectivity (look for MetaLink class), which should not be hard to understand if you are familiar with aspects (although that is not aspects).

 

For example, if you wanted to trace the receivers and parameters of a method named #mWithArg1:withArg2:withArg3: in class C, you could do :

|link|

link := MetaLink new.

link control: #before.

link arguments: #(#receiver #arguments).

link metaObject: YourMetaObject.

link selector: #yourMethodWithArg1:andArg:.

(C lookupSelector: #mWithArg1:withArg2:withArg3:) ast link: link

 

YourMetaObject is here an object which will receive the yourMethodWithArg1:andArg: with as arguments the receiver of the method #mWithArg1:withArg2:withArg3: and its arguments as an array.

It could be a block with 2 arguments, or any other object that you would use to implement your trace behavior. You have a number of reifications available that you can pass as arguments from the context, look for subclasses of RFReification.


I was not aware of MetaLink. Thank you!


 

Steven.

 

 

Le 2018-07-27 17:25, Arturo Zambrano a écrit :

Hi all,
   I have a piece of undocumented software that I  need  understand ... One thing I would like to do is to have a complete trace of method calls (receivers, parameters)  for certain scenarios.
  As an "aspects"guy, my first idea was to use Phantom, but it seems not active anymore.
 
 Could someone please point me to some tools that I could use for this? (using Pharo 6, 6.1 or  7) 
 
 Thanks in advance
 
 Cheers
Arturo