[Openmcl-devel] extended trace facility

alex crain alexcrain at mail.widgetworks.com
Mon Feb 7 02:11:01 UTC 2005


On Feb 4, 2005, at 6:59 PM, Brent Fulgham wrote:

>
> So, I'm interested in writing applications for OS X in
> Lisp, but I'm not sure what resources are out there
> for picking this up.  The Bosco framework looks
> promising, but perhaps there are better choices.

This might help.

These patches extend the trace facility so that you can trace ObjC 
callbacks.

The first change was to help me debug COCOA. You can now do:

     (trace |-[HemlockTextView mouseDown:]|)

with useful results. The other change was to add a :backtrace option, 
which
simply dumps a quick stack dump when the function is called - useful 
for tracking
who is calling who.

Anyway, I've been using it in my version of the code for several weeks 
and it seems to
work well enough, although I can't vouch for the stepper since I 
haven't used it. I did apply
the patches to the lastest bleeding edge sources and it was fine, 
although you have
to force macro.lisp to compile twice because I changed the signature 
for DEFCALLBACK-BODY.

I also included text format documentation. I'll be happy to code it 
into HTML but I wasn't sure
what the source format should be and what I should do to hook it into 
the documentation tree.

The one part that is missing from the patches is the code that allows 
pretty printing of
ObjC structures (strets). My own copy of objc-clos.lisp is very 
different from the one in
the examples area so diffs arn't really suitable, but if you add this 
bit:

     (defun %print-ns-range (stream s v)
       (when s
	  (format stream "~A = " s))
       (format stream "[:<NSR>ange location=~A length=~A]~%" (pref v 
:<NSR>ange.location) (pref v :<NSR>ange.length)))

     (def-trace-print-function :<NSR>ange #'%print-ns-range)

     (defun %print-ns-point (stream s v)
       (when s
	  (format stream "~A = " s))
       (format stream "[:<NSP>oint x=~A y=~A]~%" (pref v :<NSP>oint.x) 
(pref v :<NSP>oint.y)))

     (def-trace-print-function :<NSP>oint #'%print-ns-point)

     (defun %print-ns-size (stream s v)
       (when s
	  (format stream "~A = " s))
       (format stream "[:<NSS>size width=~A height=~A]~%" (pref v 
:<NSS>ize.width) (pref v :<NSS>ize.height)))

     (def-trace-print-function :<NSS>ize #'%print-ns-size)

     (defun %print-ns-rect (stream s v)
       (when s
	  (format stream "~A = " s))
       (format stream "[:<NSR>ect x=~A y=~A width=~A height=~A]~%" (pref 
v :<NSR>ect.origin.x) (pref v :<NSR>ect.origin.y) (pref v 
:<NSR>ect.size.width) (pref v :<NSR>ect.size.height)))

     (def-trace-print-function :<NSR>ect #'%print-ns-rect)

Then you get pretty printing for NSRange, NSPoint, NSSize and NSRect, 
respectively.

I should probably document that.

:alex

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFFS
Type: application/octet-stream
Size: 24564 bytes
Desc: not available
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20050206/2a730a99/attachment.obj>
-------------- next part --------------
  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trace.doc
Type: application/msword
Size: 4830 bytes
Desc: not available
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20050206/2a730a99/attachment.doc>
-------------- next part --------------




More information about the Openmcl-devel mailing list