Debugging in a remote REPL

329 views
Skip to first unread message

Jonathan Halterman

unread,
Jan 30, 2017, 7:46:27 PM1/30/17
to cur...@googlegroups.com
There was a previous discussion on remote debugging which I wanted to ask about:


You mention starting the remote JVM process via the args shown in the dialog, but I'm guessing this dialog no longer exists? I can connect to a remote REPL easy enough, but it's not clear how to connect to it in debug mode. FWIW, the "debug" button in the REPL window is disabled for remote repls. 

Any pointers?

- jonathan

Colin Fleming

unread,
Jan 30, 2017, 7:47:02 PM1/30/17
to cur...@googlegroups.com
Hi Jonathan.

That dialog definitely still exists - it’s one of the built in IntelliJ run configurations. Note that this is the configuration called “Remote”, not the Clojure remote REPL. The key is that you have two connections which are independent - the REPL and the debugger. It sounds like you have the remote REPL connecting ok, so you just need the remote debugging. 

In Edit Configurations, click + and then select Remote, which is usually the last item in the list. Set Transport to Socket, and Debugger mode to Attach. Then copy the field that says Command line arguments for running remote JVM, and ensure that your REPL process is started with those JVM args. This is why “debug” is disabled for remote REPLs - it requires modifying how the process is started, so this assumes that the process has already been started in debug mode and connects to it. And then you should be good to go! Note that you’ll have to run two run configs - first the one that starts the process to debug, and another to start the remote debugger.

Let me know how that works,
Colin

Jon

unread,
Jan 30, 2017, 7:47:39 PM1/30/17
to cur...@googlegroups.com
The whole subject's a bit confusing, and it's necessary to be really unambiguous when thinking about what's going on.

You can attach IntelliJ debugging to a remote Java process by (i) ensuring that remote process's JVM is accepting debug connections, (ii) creating an Intellij Run Configuration which is of type 'Remote' and pointing to the remote process's JVM.

To do (i), it depends what the process is.  If it's a NREPL session started by 'lein repl', you need to start it with JAVA_OPTS set something like this:

JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" lein repl
where 5005 is the Java debugger port you're going to use in the next step.

To do (ii), use 'IntelliJ/Run/Edit configurations.../Defaults/Remote' and adjust the Settings section accordingly, using port 5005.  The bits at the top of that dialogue are read-only hints as to the configuration you will have to give a remote process in order to attach to it.

Note that Cursive's facility 'IntelliJ/Run/Debug REPL for xxx' is a shortcut which launches a REPL as in (i) then attaches the debugger to it.

Jon

Jonathan Halterman

unread,
Jan 30, 2017, 7:47:49 PM1/30/17
to cur...@googlegroups.com
Seems to work great guys, thanks for the response!

@Colin - You should definitely promote this ability on the user guide's REPL page!

- jonathan

Colin Fleming

unread,
Jan 30, 2017, 7:48:24 PM1/30/17
to cur...@googlegroups.com
Definitely, I’m about to start on a doc update crusade, I’ll get this into the REPL doc.
Reply all
Reply to author
Forward
0 new messages