Skip to content

Debugging Clojure source

dmiller edited this page Sep 13, 2010 · 2 revisions

Debugging information has been added to the assemblies generated by AOT-compilation. This means that stack traces include file and line number information on stack frames coming from Clojure source files (*.clj). When the DLL has been loaded, you can use Visual Studio to set breakpoints in Clojure source files. Locals will show properly.

The expressions that have source information attached are function invocations such as (f x y z) and host expressions such as (.method x arg). Inlined methods preserve source information. Macros are not, though you can certainly set breakpoints on the methods that are called by a macro expansion.

All the core bootstrap files such as core.clj are compiled with this info, so you can set breakpoints in them, too.

At the moment, this is only supported for AOT-compiled files, due to a limitation in the CLR regarding debug info and dynamic methods. That means you must compile and then load:

(compile 'whatever.namespace)
(load "whatever/namespace")

Possible enhancements

We should add a flag to turn off PDB and debug info generation during compilation.

We should think about making distributions of the core DLLs both with and without debugging info.

We should extend this capability to non-AOT-compiled methods. It is only necessary to load from a source file. This is fairly easy to do, but it will slow down file loading a little. Hence, this needs to be switchable.

Clone this wiki locally