Trace through calls

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

Trace through calls

Rick Hedin
Hello.  I am trying to get a handle on how things are are called.  I might
like to make some changes to standard morphs for my own purposes.

I can put the cursor on a morph, and inspect it, or debug it.  Can I put the
cursor on it and say "I want this morph, and all of its submorphs, to make a
note on the Transcript each time a method is entered?"  

             Regards, Rick


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Trace through calls

Göran Krampe
On 04/04/2011 10:22 PM, Rick H. wrote:
> Hello.  I am trying to get a handle on how things are are called.  I might
> like to make some changes to standard morphs for my own purposes.
>
> I can put the cursor on a morph, and inspect it, or debug it.  Can I put the
> cursor on it and say "I want this morph, and all of its submorphs, to make a
> note on the Transcript each time a method is entered?"
>
>               Regards, Rick

Not typical beginner stuff, but here goes:

Anything is possible - and my first idea on how to do that was to "wrap"
the morph (and all its submorphs individually) in a so called "wrapper"
object that delegates all messages to its wrappee - but first prints
something of course.

Constructing such a wrapper that is properly "invisible" can be a bit
tricky but basically one can create a class inheriting from ProtoObject
(instead of Object) which means it will have NO inherited behavior, and
then implement doesNotUnderstand: to do the delegation. Such a class
will be "utterly stupid" and thus fairly invisible. Things making it
complicated are identity - you would need to do the "wrap" using the
magical become: message. And you would need to make sure the wrappee
doesn't "leak" itself out as an answer to a message - in unwrapped form.
As you realize it gets tricky.

Then I remembered that there is something called MethodWrappers that can
be used to do similar "augmentation", but on a method by method basis
instead of on the object level. I am pretty sure that is a much more
bullet proof approach. Haven't used that package myself though.

regards, Göran
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Trace through calls

Levente Uzonyi-2
On Mon, 4 Apr 2011, Göran Krampe wrote:

> On 04/04/2011 10:22 PM, Rick H. wrote:
>> Hello.  I am trying to get a handle on how things are are called.  I might
>> like to make some changes to standard morphs for my own purposes.
>>
>> I can put the cursor on a morph, and inspect it, or debug it.  Can I put
>> the
>> cursor on it and say "I want this morph, and all of its submorphs, to make
>> a
>> note on the Transcript each time a method is entered?"
>>
>>               Regards, Rick
>
> Not typical beginner stuff, but here goes:
>
> Anything is possible - and my first idea on how to do that was to "wrap" the
> morph (and all its submorphs individually) in a so called "wrapper" object
> that delegates all messages to its wrappee - but first prints something of
> course.
>
> Constructing such a wrapper that is properly "invisible" can be a bit tricky
> but basically one can create a class inheriting from ProtoObject (instead of
> Object) which means it will have NO inherited behavior, and then implement
> doesNotUnderstand: to do the delegation. Such a class will be "utterly
> stupid" and thus fairly invisible. Things making it complicated are identity
> - you would need to do the "wrap" using the magical become: message. And you
> would need to make sure the wrappee doesn't "leak" itself out as an answer to
> a message - in unwrapped form. As you realize it gets tricky.
I'm sure this method is sufficient for Rick's goal, but Squeak has a
better mechanism for proxies, which allows all real message sends to be
captured. Igor wrote some classes* which simplify proxy creation, by
implementing the boilerplate stuff. The problem with this method is that
older VMs don't fully support this mechanism, but this is definitely the
best solution for the future, so expect this to be added to the Trunk
soon.


Levente

*http://code.google.com/p/pharo/issues/detail?id=3648

>
> Then I remembered that there is something called MethodWrappers that can be
> used to do similar "augmentation", but on a method by method basis instead of
> on the object level. I am pretty sure that is a much more bullet proof
> approach. Haven't used that package myself though.
>
> regards, Göran
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Trace through calls

Rick Hedin
It sounds like I'm better off doing it manually.  Thanks for your help.



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Trace through calls

Bert Freudenberg
On 07.04.2011, at 04:26, Rick H. wrote:

> It sounds like I'm better off doing it manually.  Thanks for your help.

Yes. I tried your original idea using ObjectViewer (which provides a generic interceptor of all messages, almost fixed in latest trunk image). But there are just too many messages sent repeatedly to make much sense of it.

You are far better off using the implementors/senders shortcuts which allow you to browse the Squeak code base as a hyper-text system. And ask questions when you get stuck, of course :)

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners