On 8/5/21 12:10 AM, Alan Bateman wrote:
On 05/08/2021 05:11, Jakob Cornell wrote:
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
The gdb behavior is context dependent and not clear to me that it's
worth trying to add it to jdb. If it is added then I think Chris is
right that is might have to be disabled by default as it could
otherwise break existing scripts/tests with empty lines. One place for
configuration ~/.jdbrc and it might be that it can only be enabled for
interactive sessions.
If usability is an issue then maybe it would be better to look at
jshell (the REPL that has been included since JDK 9). It makes us of
jline so you get better input navigation, history navigation, and tab
completion. I suspect there is an interesting project there.
-Alan
Yes, it would be an "interesting project", but I'm not so sure we want
to put that level of effort into jdb. It's just not that widely used,
and is mainly there to demonstrate JDI use and to help test JDI, and on
occasion for very basic java debugging when the user doesn't care to
config an IDE to do such.
Chris