-
Notifications
You must be signed in to change notification settings - Fork 99
Debug
To provide debugging support emacs-eclim uses jdb, gud and eclim.
For now support is very basic and it’s limited to debugging test files or attaching
debugger to already running process. For each debugging session eclim will set
sourcepath with all dependencies that are present in workspace. Stepping through code
will show on side buffer with code loaded in the corresponding line. While debugging you can use
standard jdb commands. For this consult help in console itself which
will yield all available options. In addition to jdb commands to control debug flow you can use gud commands as well. gud commands can be used from debug console or directly from sourcecode of the application. There are two additional advantages that gud commands have over standard jdb:
- you can use
gudcommands to control other debuggers as well e.g.gdb - you can bind keys to call
gudcommands
jdb is distributed with Oracle jdk so installation of jdb is the same as for jdk.
gud is distributed with emacs.
Right after debugger have started you can already interact with it without executing debugged
program. This is right moment to call help and see what options are available in jdb.
Basic commands that will get you started:
run- to run program
stop at fully.qualified.name.of.Class:line- to set breakpoint on line
stop in fully.qualified.name.of.Class.methodName- to set breakpoint for method
locals- to show local variables
next- step one line
cont- continue executing the program
list- print current place in sources
Additionally gud provides set of functions that can be called in standard emacs way
by M-x or from menu.
| Key Binding | Description |
|---|---|
C-c C-r |
Continue |
C-c C-n |
Next |
C-c C-s |
Step into |
C-c C-f |
Finish function |
C-c C-p |
Print expression |
C-c C-> |
Down stack |
C-c C-< |
Up stack |
C-c C-b |
Set breakpoint |
C-c C-d |
Remove breakpoint |
Currently there are just two different functions to start debug session.
eclim-debug-attach- will read project for current buffer and identify all present dependencies in workspace and attach debugger to currently running process on port defined by user.
eclim-debug-test- will try to recognize what kind of test framework is used and act accordingly. Currently best supported test framework is
junit.testngsupport is possible formavenprojects.
| Key Binding | Description |
|---|---|
C-c C-e p t |
Debug current test file |
C-c C-e p a |
Attach debugger to process |
Every command for gud can be called only after gud console have started. Commands
used here are the same as in gud console window the only difference is additional C-x as
a prefix.
| Key Binding | Description |
|---|---|
C-x C-c C-r |
Continue |
C-x C-c C-n |
Next |
C-x C-c C-s |
Step into |
C-x C-c C-f |
Finish function |
C-x C-c C-p |
Print expression |
C-x C-c C-> |
Down stack |
C-x C-c C-< |
Up stack |
C-x C-c C-b |
Set breakpoint |
C-x C-c C-d |
Remove breakpoint |