[Openmcl-devel] Debugging Carbon applications
David Steuber
david at david-steuber.com
Thu Jan 27 12:04:40 PST 2005
I made a serendipitous discovery that I haven't found mentioned in the
documentation and haven't seen mentioned in this mailing list (which is
not to say that it hasn't been). People who remember my posts know
that I have been working on learning how to use OpenMCL to build a
Carbon application. In order to make my work easier, I created some
functions and a macro to do old fashioned printf (using format) style
debug logging to a file:
(defparameter *debug-log-file* nil)
(defun enable-debug-log (log-file-spec)
(when (member :debug *features*)
(when *debug-log-file*
(close *debug-log-file*))
(setf *debug-log-file*
(open log-file-spec :direction :output
:if-exists :supersede))))
(export 'enable-debug-log)
(defun disable-debug-log ()
(when *debug-log-file*
(close *debug-log-file*))
(setf *debug-log-file* nil))
(export 'disable-debug-log)
(defun enable-debugging ()
(pushnew :debug *features*))
(export 'enable-debugging)
(defun disable-debugging ()
(setf *features* (delete :debug *features*)))
(export 'disable-debugging)
(defun write-debug-log (cs &rest args)
(when *debug-log-file*
(format *debug-log-file* cs args)
(force-output *debug-log-file*)))
(defmacro debug-log (format-control-string &rest format-args)
(if (member :debug *features*)
`(carbon::write-debug-log ,format-control-string ,format-args)
(values)))
(export 'debug-log)
(enable-debugging)
Early on when the app bundle is started, this code is called:
(defmethod initialize-application ((app application))
(enable-debug-log "/Users/david/usr/src/OpenGL-Lisp/bin/debug.log")
(debug-log "Initializing Carbon application -- primary method
initialize-application called~%"))
The idea is that when I don't have debugging enabled, the DEBUG-LOG
form expands into nothing.
The discovery I made is when I opened debug.log in finder. An
application called console opened up. In it is not just the window for
debug.log but also a console window that of all things shows OpenMCL
output from when something I goofed calls up the debugger. There is
error information there! Also Carbon API calls that fail end up
spewing useful information there.
I'm still rather inexperienced with Lisp in general and OS X
development in particular. If anyone has any tips on how I can improve
my process or has other information I may have missed that would make
trouble shooting easier, I would love to hear about it.
More information about the Openmcl-devel
mailing list