Debugging

44 views
Skip to first unread message

Adam Krieg

unread,
Jan 30, 2017, 9:04:35 PM1/30/17
to cur...@googlegroups.com
What’s the current status of the debugger in Cursive? I’ve always had some issues with running the REPL in the debugger, where, if I set a breakpoint, it would break at that breakpoint multiple times (3x or more). I don’t know if this is an issue with debugging an expression oriented language in a line oriented debugger.

Now, I’m trying to debug a Leiningen launched application and breakpoints aren’t working at all. Are there any other steps required to run an app in debug mode other than launching in Intellij Debug mode?

Thanks,

Adam

Colin Fleming

unread,
Jan 30, 2017, 9:07:02 PM1/30/17
to cur...@googlegroups.com
The debugger works, but with some limitations. Breaking multiple times at a single breakpoint is one of them - as you say, you can have multiple expressions on a single line, and things that look like a single expression may expand into many if the form is a macro. If you haven’t seen it I spoke about these and other limitations at Clojure West this year.

The lein launched application doesn’t work at all unfortunately - this is because of the way leiningen works. What happens is that Cursive runs lein with a command, but lein internally starts a new process with the actual application. So Cursive ends up debugging the lein shim process, not the actual app, which is almost never what you want. 

One thing that should work but that I haven’t tried would be to put the JVM args to start your app JVM in debug mode in your project.clj, and then connect to that with a remote debugger. Here’s how that would work:

  1. Create a “Remote” run configuration. The default config is probably fine. 
  2. Copy the command line arguments from the supplied field and put them in :jvm-opts in your project.clj. If you’d like your app to wait for the connection on startup, set suspend=y.
  3. Run your app, and then connect the debugger to it with your remote run config.

Adam Krieg

unread,
Jan 30, 2017, 9:07:38 PM1/30/17
to cur...@googlegroups.com
Thanks, Colin!  That is very helpful.  

I was looking for a section on debugging on cursiveclojure.com, but did not find one.  Perhaps you could use your answer and put it up on the website for future use.

Best,

Adam

Chris Price

unread,
Jan 30, 2017, 9:08:13 PM1/30/17
to cur...@googlegroups.com
On Tue, Sep 15, 2015 at 9:25 PM, Colin Fleming <cur...@cursiveclojure.com> wrote:
The debugger works, but with some limitations. Breaking multiple times at a single breakpoint is one of them - as you say, you can have multiple expressions on a single line, and things that look like a single expression may expand into many if the form is a macro. If you haven’t seen it I spoke about these and other limitations at Clojure West this year.

The lein launched application doesn’t work at all unfortunately - this is because of the way leiningen works. What happens is that Cursive runs lein with a command, but lein internally starts a new process with the actual application. So Cursive ends up debugging the lein shim process, not the actual app, which is almost never what you want. 

One thing that should work but that I haven’t tried would be to put the JVM args to start your app JVM in debug mode in your project.clj, and then connect to that with a remote debugger. Here’s how that would work:

  1. Create a “Remote” run configuration. The default config is probably fine. 
  2. Copy the command line arguments from the supplied field and put them in :jvm-opts in your project.clj. If you’d like your app to wait for the connection on startup, set suspend=y.
  3. Run your app, and then connect the debugger to it with your remote run config.

I've done this in the past (admittedly not recently) and it has worked fine.
Reply all
Reply to author
Forward
0 new messages