This is a fork of Dica-Developer/vim-jdb so checkout the main branch as well.
Its a JAVA debugger frontend plugin for VIM. It allows to debug a JAVA program via the JDB debugger. It allows remote debugging via attach parameter. It marks by vim-jdb setted breakpoints and shows the current file and line the debugger stays in.
It requires VIM >= 8.0 and VIM compiled with channel, signs and job support.
- start JAVA process with the following debug agent option, e.g.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005' - attach to the JAVA process from your VIM with VIM-JDB like
:JDBAttachor by explicitly specifying host and port:JDBAttach localhost:5005 - now the JDB shell buffer should open and signal that it connected to the JAVA process
- open a JAVA file and go to the line in it where you want to set a breakpoint
- set a breakpoint on the current line in the current file by using the command
:JDBBreakpointOnLine - breakpoints are marked depending on your terminals and VIMs capabilities with a
⛔orx - if your programm stops at the breakpoint this is marked with a
-> - use the command
:JDBStepOverto execute to the next line - with
:JDBCommandyou can send any JDB command to the JDB JAVA process, e.g. you want to see all locals do:JDBCommands locals - with
:JDBContinueyou can resume the execution until the next breakpoint is hits - with
:JDBDebugProcesswill (currently) pick the function name you are currently in if it is annontated with "@Test". It will then construct the the path to the class from the class name and package name in the file. finally it will start jdb like this e.g.: jdb -Dtest.single=functionmane org.junit.runner.JUnitCore yourpackage.classname for this to work properly you need to set the env var CLASSPATH with your projects dependencies. For me I use gradle for dev so have a task named "classpath" and can do this from with in gradle before starting. :let $CLASSPATH=system("gradle -q classpath") . ":build/classes/main:build/classes/test"
| Command | Description |
|---|---|
| JDBAttach | attach to a running JVM with a debug listener on localhost:5005, can be overwritten by given host:port as an argument |
| JDBDetach | detach the debugger UI from the application that is currently debugged |
| JDBBreakpointOnLine | set a breakpoint on the current line |
| JDBClearBreakpointOnLine | clear the breakpoint on the current line |
| JDBContinue | continues the execution until the next breakpoint |
| JDBStepOver | steps to the next line |
| JDBStepIn | steps a level down the stack |
| JDBStepUp | steps a level up in the stack |
| JDBStepI | steps to the next instruction |
| JDBCommand | send any JDB command to the application under debug |
| JDBDebugProcess | While in a JUnit test this will start a debug process using junit -Dtest.single |
To specify the JDB command to use you can overwrite the following variable g:vimjdb_jdb_command. The default is jdb.
For starting debug process for Unit tests you can override the following variables.
g:vimjdb_unit_test_class by default it is set tp 'org.junit.runnint.JUnitCore'