JDK-8224979 : SA tools not providing option to connect to debug server
  • Type: CSR
  • Component: hotspot
  • Sub-Component: svc-agent
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-05-29
  • Updated: 2019-08-29
  • Resolved: 2019-07-10
Related Reports
CSR :  
Description
Summary
-------

Add ability for connecting to debug server to a part of jhsdb commands (jstack, jmap, jinfo, jsnap).

Problem
-------

In JDK 8 or earlier, some tools (jstack, jmap, jinfo) can connect to debug server (jsadebugd). However it has not done so since JDK 9 because jhsdb cannot accept the attach request to debug server.

Solution
--------

Introduce `--connect` option to jhsdb to connect to remote debug server.

Specification
-------------

jstack, jmap, jinfo, jsnap in jhsdb can accept `--connect` option to connect to remote debug server. Other subcommands (hsdb, clhsdb, debugd, help) would not be changed.

The following help output is being added to each of the above jhsdb sub-commands:
```
--connect [<id>@]<host> To connect to a remote debug server (debugd).
...
The --connect option can be set to connect to a debug server (debugd).
--core, --pid, and --connect are mutually exclusive.
```


jstack:

```
$ jhsdb jstack --help
    --locks                 To print java.util.concurrent locks.
    --mixed                 To print both Java and native frames (mixed mode).
    --pid <pid>             To attach to and operate on the given live process.
    --core <corefile>       To operate on the given core file.
    --exe <executable for corefile>
    --connect [<id>@]<host> To connect to a remote debug server (debugd).

    The --core and --exe options must be set together to give the core
    file, and associated executable, to operate on. They can use
    absolute or relative paths.
    The --pid option can be set to operate on a live process.
    The --connect option can be set to connect to a debug server (debugd).
    --core, --pid, and --connect are mutually exclusive.

    Examples: jhsdb jstack --pid 1234
          or  jhsdb jstack --core ./core.1234 --exe ./myexe
          or  jhsdb jstack --connect debugserver
          or  jhsdb jstack --connect id@debugserver
```

jmap:

```
$ jhsdb jmap --help
    <no option>             To print same info as Solaris pmap.
    --heap                  To print java heap summary.
    --binaryheap            To dump java heap in hprof binary format.
    --dumpfile <name>       The name of the dump file.
    --histo                 To print histogram of java object heap.
    --clstats               To print class loader statistics.
    --finalizerinfo         To print information on objects awaiting finalization.
    --pid <pid>             To attach to and operate on the given live process.
    --core <corefile>       To operate on the given core file.
    --exe <executable for corefile>
    --connect [<id>@]<host> To connect to a remote debug server (debugd).

    The --core and --exe options must be set together to give the core
    file, and associated executable, to operate on. They can use
    absolute or relative paths.
    The --pid option can be set to operate on a live process.
    The --connect option can be set to connect to a debug server (debugd).
    --core, --pid, and --connect are mutually exclusive.

    Examples: jhsdb jmap --pid 1234
          or  jhsdb jmap --core ./core.1234 --exe ./myexe
          or  jhsdb jmap --connect debugserver
          or  jhsdb jmap --connect id@debugserver
```

jinfo:

```
$ jhsdb jinfo --help
    --flags                 To print VM flags.
    --sysprops              To print Java System properties.
    <no option>             To print both of the above.
    --pid <pid>             To attach to and operate on the given live process.
    --core <corefile>       To operate on the given core file.
    --exe <executable for corefile>
    --connect [<id>@]<host> To connect to a remote debug server (debugd).

    The --core and --exe options must be set together to give the core
    file, and associated executable, to operate on. They can use
    absolute or relative paths.
    The --pid option can be set to operate on a live process.
    The --connect option can be set to connect to a debug server (debugd).
    --core, --pid, and --connect are mutually exclusive.

    Examples: jhsdb jinfo --pid 1234
          or  jhsdb jinfo --core ./core.1234 --exe ./myexe
          or  jhsdb jinfo --connect debugserver
          or  jhsdb jinfo --connect id@debugserver 
```

jsnap:

```
$ jhsdb jsnap --help
    --all                   To print all performance counters.
    --pid <pid>             To attach to and operate on the given live process.
    --core <corefile>       To operate on the given core file.
    --exe <executable for corefile>
    --connect [<id>@]<host> To connect to a remote debug server (debugd).

    The --core and --exe options must be set together to give the core
    file, and associated executable, to operate on. They can use
    absolute or relative paths.
    The --pid option can be set to operate on a live process.
    The --connect option can be set to connect to a debug server (debugd).
    --core, --pid, and --connect are mutually exclusive.

    Examples: jhsdb jsnap --pid 1234
          or  jhsdb jsnap --core ./core.1234 --exe ./myexe
          or  jhsdb jsnap --connect debugserver
          or  jhsdb jsnap --connect id@debugserver
```
Comments
Voting to re-Approve revised request.
10-07-2019

[~ysuenaga] Looks good to me - thanks!
10-07-2019

What help message has been changed to what? * Description of `--connect` is replaced to "To connect to" from "To operate to". * Add "(debugd)" to "debug server" as an example. * "remote server IP or hostname" in an argument of `--connect` is replaced to "host". * Add angle brackets to `id`. (`[id@]<host>` to `[<id>@]<host>`) * "<--core --exe> and <--pid> and <--connect> are exclusive." is changed to " --core, --pid, and --connect are mutually exclusive."
10-07-2019

I updated the help messages in Specification section of this CSR. It is the change of webrev.07 which has been reviewed on serviceability-dev. http://cr.openjdk.java.net/~ysuenaga/JDK-8209790/webrev.07/
09-07-2019

On the discussion in serviceability-dev [1], we need to update the help message about this. So I reopened this CSR. [1] https://mail.openjdk.java.net/pipermail/serviceability-dev/2019-July/028624.html
09-07-2019

Moving to Approved for JDK 14.
24-06-2019

I've changed the fixVersion to 14 as JDK 13 is in RDP1.
23-06-2019

I updated description to `--connect`. I'm waiting for approving this CSR.
20-06-2019

[~ysuenaga] Yes, I'm fine with it. Please, go ahead and update the CSR description.
20-06-2019

This feature looks okay although `--remote` may not be the best name for the option. Maybe something like `--connect` would be better as it connects to a SA debug server.
18-06-2019

[~sspitsyn] Do you agree with [~alanb] ? This CSR has been reviewed by you, so I want to hear your opinion before the change.
18-06-2019

Move to Finalized. [~sspitsyn] As I said in JDK-8209790, debug server support is available the tools which extend sun.jvm.hotspot.tools.Tool . hsdb, clhsdb, debugd, help do not do that. * HSDB: it can connect to debug server, but the user can do it via GUI. * CLHSDB: not supported debug server on `attach` command, but user can use CLHSDB on debug server if open the console via HSDB. * debugd: does not support remote connection (this is remote server!) * help: not supported
15-06-2019

[~cjplummer] Thanks, Chris! I've also figured it out. I've updated the description with this. This CSR looks good, so I'm adding myself as a reviewer. One question though: > jstack, jmap, jinfo, jsnap in jhsdb can accept --remote option to connect to remote debug server. > Other subcommands (hsdb, clhsdb, debugd, help) would not be changed. What is the reason the new --remote option is not for the subcommands (hsdb, clhsdb, debugd, help)? Is it just have not been implemented yet, or there is some kind of a security concern?
14-06-2019

I think the following help output is being added to each of the above jhsdb sub-commands (plus of course the underlying changes to make it work): --remote <[id@]server> To operate on the remote debug server. ... The --remote option can be set to operate on a debug server. <--core --exe> and <--pid> and <--remote> are exclusive.
14-06-2019

[~ysuenaga] Hi Yasumasa, It is not clear from the CSR description what is updated with this CSR. Could you, please be more specific?
14-06-2019

Please have one or more servicabilty engineers review this request before it is Finalized for the second phase of CSR review. Moving to Provisional.
05-06-2019