Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8274167

Modify jdb to treat an empty command as a repeat of the previous command

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • core-svc
    • None
    • behavioral
    • minimal
    • Hide
      With regards to the "repeat" behavior changes, it only does so after issuing the new `repeat on` command, so users should not notice any difference in behavior unless they first issue `repeat on`.

      With regard changes to the `list` ==> marker, the ==> may now appear on a different line in some instances, but this highly unlikely to cause any compatibility issues.

      Show
      With regards to the "repeat" behavior changes, it only does so after issuing the new `repeat on` command, so users should not notice any difference in behavior unless they first issue `repeat on`. With regard changes to the `list` ==> marker, the ==> may now appear on a different line in some instances, but this highly unlikely to cause any compatibility issues.
    • Other
    • JDK

      Summary

      Add JDB support for automatic command repetition and list auto-advance, and make list command output more intuitive.

      Problem

      The overall problem is that JDB is not as ergonomic as other command line debuggers like GDB and PDB (the Python debugger). In particular:

      • In order to quickly step through a chunk of code in JDB, the user has to either step one line at a time, typing out the next command each time, or use a more intricate approach such as a temporary breakpoint or an next command after counting lines. In other debuggers this is accomplished by issuing a next command and then simply repeating it by pressing Enter as necessary.
      • In order to examine code more than 10 lines at a time, a JDB user has to invoke list repeatedly with a manually computed line number each time, and if the user doesn't bother to determine the precise line number at the center of the next chunk the listing duplicates or skips lines. In other debuggers, a large chunk of the source can be easily listed by repeatedly invoking list (or just pressing Enter) as needed.

      Solution

      A new command is added to make the new functionality available on an opt-in basis. The user may enter repeat on to enable or repeat off to disable the features described below. repeat may be used to query the current setting (off by default).

      • After issuing one of a certain set of "repeatable" commands [1], entering a blank line at the prompt will now cause the command to be re-executed, just as !! does but without first displaying the command. This only occurs if repeat is enabled. Previously, a blank line was always a no-op.

      • In some situations, list command output now starts where the previous list output left off. The situations are (1) an arbitrary list command is followed by a list command with no target (the commands need not be consecutive; only certain commands [2] reset the listing state), and (2) an arbitrary list command is repeated by entering a blank line at the prompt. This behavior only occurs if repeat is enabled, but the listing state survives changes to the repeat setting and is updated even when repeat is disabled. After reaching the end of the file, only "EOF" is printed until the state is reset.

      • Previously, the marker => was used in the output of list to indicate the listing "target"; the one specified in the command (usually a line number), or otherwise the current line of execution. Only the current line of execution is now so marked, regardless of whether a target is specified. This occurs irrespective of the repeat setting.

      An alternative way to address the usability concerns is to integrate Jline into JDB, for an experience similar to that of Jshell. While this is conceptually simpler, there was concern that the extent of the code changes necessary for this integration would be too large compared to the benefit [3].

      [1] The repeatable commands are: up, down, step, stepi, next, cont, list, pop, and reenter. A repeatable command preceded by a repeat number (e.g. 5 next) is also repeatable.

      [2] The listing reset commands are: run, suspend, resume, up, down, kill, interrupt, threadgroup, step, stepi, next, cont, pop, and reenter. A listing reset command preceded by a repeat number is also a listing reset command.

      [3] https://mail.openjdk.java.net/pipermail/serviceability-dev/2021-August/038889.html

      Specification

      To my knowledge the behavior of JDB is only specified to the extent of its help and usage messages, which are updated as appropriate in the accompanying pull request [4].

            cjplummer Chris Plummer
            cjplummer Chris Plummer
            Serguei Spitsyn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: