help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Tracer tool


From: Gwenael Casaccio
Subject: Re: [Help-smalltalk] Tracer tool
Date: Mon, 20 Apr 2009 11:58:43 +0200

On Monday 20 April 2009 11:42:31 you wrote:
> > I'm working on a tool that trace the excecution of the block (I need to
> > know all the objects and methods touched by the block and the methodes
> > inside these methods). With something like this :
> >
> > [ blablabla ] trace.
> >
> > So I want to mark the context with a flag to know if the current context
> > is traced or not and in the method send_message I simply look at the flag
> > in the current context and store the result or not.
> >
> > I've looked at the VM code and it seems that the contexts are allocated
> > with the method  alloc_stack_context. So in this method I initialise the
> > trace variable with 0.
>
> Have you checked that using DebugTools is too slow?
>
> Initialization of the new context is done in activate_new_context,
> that's probably a better place.
>
> Also, alternatively you can use the checks that are already in place for
> the profiler, so that you don't introduce more ifs on a very hpt path.
>
> Alternatively, what about instrumenting the methods and replacing them
> dynamically?  That is, rewrite something like:
>
>    self abc.
>    self def: 3.
> to
>
>    Tracer current on: self perform: #abc.
>    Tracer current on: self perform: #def: with: 3.
>
> Inside the tracer object, you keep a mapping between untraced methods
> and traced methods, and do something like:
>
>    on: receiver perform: aSymbol
>
>        | method |
>
>        "Make this a primitive if it is too slow."
>        method := receiver class lookupSelector: aSymbol.
>        method isNil ifTrue: [ ... handle doesNotUnderstand ... ].
>        self on: receiver trace: method.
>        ^receiver perform: (self tracingMethodAt: method)
>
> Right now there is no instruction stream class (it's all in STCompiler
> in the Parser package), but maybe you have already written one? :-)

I've one ;)

>
> Paolo

Thanks for your answser :)

This is strange in the activate_new_context method I've done this :

  newContext = alloc_stack_context (size);

  newContext->traced = 0;
  fprintf (stderr, "traced value : %d\n", newContext->traced);
  fprintf (stderr, "parent value : %d\n", ((gst_method_context) OOP_TO_OBJ 
(_gst_this_context_oop))->traced);

And if the traced value for the parent context is not nil any idea of the 
problem ?

Gwenael





reply via email to

[Prev in Thread] Current Thread [Next in Thread]