[comp.sys.ti.explorer] tracing all accesses to an instance

snicoud@ATC.BOEING.COM (Stephen Nicoud) (02/21/90)

    Date: Sun, 4 Feb 90 17:16:19 EST
    From: fsr@bubba.att.com
    Subject: tracing all accesses to an instance

    oh flavor gurus,

    i have a question.

    yesterday i created a flavor and began using it in my application.
    the 8 or so methods that i wrote for it defined the interface
    to the rest of my "world".  but then i began using it, and things didn't
    work right, and because i couldn't be sure the rest of my "world"
    was making calls to my instance in the proper order, and with the
    proper arguments, i set about trying to "trace" all accesses to it.

    unfortunately the function TRACE expects some kind of valid function
    object...fair enough.  then i remembered that the function APPLY and
    hence FUNCALL allow flavor instances to be used in place of other
    valid function objects.  so it tried

    (eval `(trace ,*instance*))

    but to no eval.

    i still assume this can be accomplished somehow.  can anybody help?

    thanks,
    frank

Hmm, if you want to trace each access to only a particular instance, an
"obvious" solution doesn't immediately come to mind.

I suppose that, in general, you might be able to trace all method calls
of a flavor "class" by setting up a loop to trace each method.  You
know, something like,

	(loop for method in (send (make-instance 'your-flavor) :which-operations)
	      do (eval `(trace (:function (:method your-flavor ,method)))))

I don't know, maybe you can set up a conditional for a particular
instance like,

	(loop for method in (send your-instance :which-operations)
	      do (eval `(trace (:function (:method your-instance ,method) :cond (eq (car arglist) your-instance)))))

I haven't tried these code bits, so there's probably something
"obviously" wrong with them. :-) Maybe someone else with more time on
their hands than me can tell us if these are even reasonable.

Anyway, it might give you a couple of ideas on ways to try.

Good Luck and let us know what you come up with,

Steve