Proposed changes to empty command handling in JDB

Jakob Cornell jakob at jcornell.net
Thu Aug 5 04:11:27 UTC 2021


Hi folks,

I've been looking to improve the usability of JDB a bit by imitating GDB's handling of empty commands.  If the most recent command is one that it makes sense to invoke repeatedly, GDB does so.  Also, when the `list' command is repeated (by either typing it out or issuing an empty command after a `list'), GDB shows the next chunk of source lines, resetting to the line being executed when the user moves up or down the stack or advances execution.

Here are the changes I propose, based on suggestions from Chris Plummer:

A new command line option (`-gdb' or `-repeat'?) is introduced which enables GDB-like behavior.  When this mode is selected, entering an empty command at the prompt reruns the previous command if it was one of the following forms: `up', `down', `step', `step up', `stepi', `next', `cont', `pop', `reenter', `!!', and `<n> <command>' (where any of the preceding commands is being repeated).

Currently JDB appears to use the current source line as the center of its listings even when invoked repeatedly.  I haven't included an auto-advance enhancement to that command here because it goes somewhat beyond the narrow scope of implementing command repetition, but I'm happy to implement that alongside these changes or in a separate change set if the community sees fit.  I find this auto-advance useful when using GDB and PDB.

Any feedback is appreciated, but in particular I'm hoping to get some input on these points:

- If the repetition is limited to commands that are likely to be repeated, is it necessary to have this feature off by default?
- Would folks like to see auto-advance `list' behavior along with these changes?

JBS ticket: https://bugs.openjdk.java.net/browse/JDK-8271356

Best,
Jakob


More information about the serviceability-dev mailing list