Including debugging information for Clojure code

139 views
Skip to first unread message

James Norton

unread,
Mar 13, 2016, 3:01:06 PM3/13/16
to Clojure
I have been experimenting with using the Java Debug Interface (JDI) with Clojure, but I am confused about how to get Clojure to include debugging information when compiling to Java byte code. I have created NREPL middleware that is able to attach to the VM using com.sun.jdi.Bootstrap and listen for `set-breakpoint` operations, but it fails with a com.sun.jdi.AbsentInformationException when I try to call .sourceNames on a reference type (obtained by calling .allClasses on the VM). In the Java world this exception indicates that the -g option was not passed to javac - I don't know what the equivalent is in the Clojure world.

I hope the explanation of what I'm trying to do makes sense here. I'm out of my depth so I may be completely off on how things work, but I know there must be some way to get the debugging information included based on the fact that Cursive and CIDER seem to work. If anyone could explain or point me to an explanation I would be very grateful.

Thanks,

James

Jason Gilman

unread,
Mar 13, 2016, 10:13:46 PM3/13/16
to Clojure
I'd recommend asking on slack. There's a cider channel where they hang out and may be able to answer your question. You can join here https://clojurians.slack.com/

I'd really like to know this information for Proto REPL as well.

Colin Fleming

unread,
Mar 14, 2016, 2:26:11 AM3/14/16
to clo...@googlegroups.com
I don't have much time right now, but AFAIK Cursive is the only debugger using JDI - CIDER has a source manipulation debugger. I don't generally have to do anything special to debug, although I use an IntelliJ layer on top of JDI. I can try to check if it's doing anything with that flag. You can also check if your classes have debug info using Javap or a decompiler.

I have to run now, but if you have further questions or you can't get it working let me know and I can dig further.

On 14 March 2016 at 15:13, Jason Gilman <jason....@gmail.com> wrote:
I'd recommend asking on slack. There's a cider channel where they hang out and may be able to answer your question. You can join here https://clojurians.slack.com/

I'd really like to know this information for Proto REPL as well.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Norton

unread,
Mar 14, 2016, 7:43:26 PM3/14/16
to Clojure

Thanks for the reply. I was able to get it working when I looked at other classes. The first class I tried on the list resulted in the exception, but other classes (including those from my test project) worked. And thanks for the note about CIDER. I had looked at those sources briefly, but now I won't spend time on them.

-James 

Jason Gilman

unread,
Mar 14, 2016, 8:01:31 PM3/14/16
to Clojure
That's awesome that you got it working. If you could share any information you found that would be really helpful for others in the future.

Alex Miller

unread,
Mar 14, 2016, 8:17:56 PM3/14/16
to Clojure
FYI, I believe the Clojure compiler always emits classes with Java debug information (line numbers, source files, and local variables).

Colin Fleming

unread,
Mar 14, 2016, 10:49:03 PM3/14/16
to clo...@googlegroups.com
Hi Jason,

Things you might be interested in checking out:

George Jahad's CDT: https://github.com/georgejahad/cdt. It's kind of old, but the JDI hasn't changed much recently.

There's also Ritz: https://github.com/pallet/ritz. Again, I think it's a little bit-rotted these days but there's probably lots of good stuff there.

You might also be interested in my talk at Clojure/West last year: https://www.youtube.com/watch?v=ql77RwhcCK0. I don't talk much about the implementation, but I do talk a lot about what makes Clojure difficult to debug over JDI.

Cheers,
Colin

Jason Gilman

unread,
Mar 15, 2016, 6:41:18 AM3/15/16
to clo...@googlegroups.com
Thanks for the information. I'll check those out. For others trying to solve the same problem I also found what looks like the relevant code within Counter Clockwise https://github.com/laurentpetit/ccw/blob/fb3a5467087cbe76d6b4fafe36ba7b97f5564228/ccw.core/src/java/ccw/debug/ClojureLineBreakpointAdapter.java#L61

You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/KkhgttZ1wDw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages