RFR: 8357828: Add a timestamp to jcmd diagnostic commands

Ivan Bereziuk duke at openjdk.org
Tue Sep 23 09:00:13 UTC 2025


On Thu, 18 Sep 2025 14:57:44 GMT, Ivan Bereziuk <duke at openjdk.org> wrote:

> `jcmd` provides great diagnostics but many commands lack a timestamp in their output.
> Adding a timestamp to the output of some would add value for those debugging JVM data.
> 
> Some diagnostic commands already provide timestamps. For example `Thread.print` already prints one of "yyyy-MM-dd HH:mm:ss" format.
> 
> Adding timestamps to all diagnostic `jcmd` commands with a non-throw-away STDOUT.
> 
> The exceptions are:
> * `VM.uptime` - command run with `-date` argument will also print a timestamp;
> * `VM.system_properties` - already lists timestamp
> * `Thread.dump_to_file` - the content dumped to file already has a timestamp;
> * `VM.version`

Speaking of having "print a timestamp" as a global flag. Placing be the flag early for the launcher, before `pid | main class` gives some benefits:
* we can document the flag in the general documentation "jcmd -h"
* we could place the timestamp on the same line with PID printed by launcher.

$ jcmd -T ${PID} VM.info
12345: 2025-01-01 23:59:59
. . .

Is there any issues to that?

On the other hand, I see dcmd implements a special rule to handle "-h", "-help", and "--help" flags placed at the end of `jcmd` arguments list. We could allow the new "timestamp" flag to be passed past the `jcmd PID command`, Process the flag in `DCmdFactory` and pass the boolean down to a concrete `DCmd` instance.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27368#issuecomment-3323026694


More information about the serviceability-dev mailing list