跳转到内容

Attach, hot swap and remote debugging

此内容尚不支持你的语言。

Attach to a running process and hot swap for Java are Works. Debugging on a remote host is Experimental: it is implemented and tested without the window.

  1. Run › Attach to Process… (⌥⇧F5). A list of your own processes opens with a field: “Attach to Process (filter, or host:port of a debug port)”.
  2. Type part of a name to filter, or type the address of a debug port.
  3. Choose the process with ↑ ↓ and press ↩.
Program Attach by
native (C, C++, Rust, Swift) process id, through lldb-dap; or a gdb-remote address
Python process id, through debugpy; or the port of debugpy --listen
Node.js process id, or the port of node --inspect
Java a JDWP port only, for example a JVM started with -agentlib:jdwp=transport=dt_socket,server=y,address=5005
Go process id, through Delve; or a headless Delve server on the loopback interface

The session then works as in Debug a program. Stop detaches; the console says “Detached; the program goes on running”.

There is no separate “remote JVM” configuration: type localhost:5005 into the attach field.

During a Java debug session:

  1. Change a method body and save the file. jdtls compiles the class.
  2. A bar shows “Code changed” with the changed files and Reload Changed Classes (⌃⌥⇧F9; also in the Debug toolbar’s ⋮ menu).
  3. Click it. The running program uses the new code from the next call on.

Reloading is refused while a changed file has errors. The JVM decides what it accepts: changes to method bodies are reloaded, new fields or methods usually are not. Hot swap is Java only; other adapters refuse it with a line in the debug console.

In a project opened on another machine over SSH, the debug adapters run on that host, next to the program. Debug Current File, debug configurations, Attach to Process (which then lists the host’s processes) and hot swap work as they do locally; a dropped connection shows “Reconnecting…”.

In a remote project the attach field also takes:

Address Target
host:port a debug port the remote host can reach
docker:<container>:<port> a debug port inside a Docker container
pod:[namespace/]<pod>:<port> a debug port in a Kubernetes pod

Add =<folder> to name the folder in the target that holds the project’s sources, for example docker:api:5005=/srv/api; Ferris IDEA then maps paths between the two. Debug ports are expected on the loopback interface; when you type another address, the console warns that the debug traffic to it is not protected.

Keyboard of
ActionShortcut
HotswapHotswap⌃⌥⇧F9CtrlAltShiftF9
Run › Attach to Process⌥⇧F5CtrlAltF5
Run › Stop⌘F2CtrlF2

debug_attach and debug_hot_swap need the right debug. The remote tools run the same session on the host of a remote project.

  • debug_attachchangesdry run by defaultdebugAttach a debugger to a running program: native (lldb-dap), python (debugpy), node (js-debug), java (JDWP) or go (Delve), by pid or debug port.
  • debug_hot_swapchangesdebugHot swap (Reload Changed Classes, SPEC-0091 v12): builds the changed workspace sources files for a Java debug session (java-debug in jdtls) and reloads the changed classes into the running program; returns their names.
  • debug_processesreadsLocal processes of this user that a debugger can attach to: id, name, command line, runtime (native, python, node, java) and the debug port its command line opens (JDWP agent, node --inspect, debugpy --listen); processes with a debug port first.
  • remote_debug_attachchangesdry run by defaultdebugAttach a debugger to a process, a debug port, a container or a pod of an open remote project's host (SPEC-0322, Experimental).
  • remote_debug_startchangesdry run by defaultdebugDebug a run configuration (or the run marker at doc+line) of an open remote project on its host (SPEC-0322, Experimental): the adapter runs on the host, nothing opens a port here.