RFR: 8357828: Add a timestamp to jcmd diagnostic commands

Kevin Walls kevinw at openjdk.org
Mon Sep 22 11:53:31 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`

I think it should be clearer what the benefit is, who the users are.

In a remote support situation where the the user is gathering info, then timestamps are good.
Running "date; jcmd ... " is an alternative.


An optional global timestamp setting could be in the Jcmd launcher, which would mean it doesn't have to be implemented in each native diagnostic command impl.
i.e. a jcmd option before the PID.

jcmd -T PID command...  (or whatever option)
jcmd -T -f commands.txt  ... could that print a timestamp before every inidvidual command?

That might be straightforward, but then you can get double timestamps if the jcmd implementation already prints one (so do you remove the timestamp from Thread.print if the jcmd launcher starts printing it?)

Also complicated for some to commands enable a timestamp by default, the jcmd launcher does not know anything about command implementations.
So maybe it needs some common code on the native side.

Do we print a timestamp if the command is not recognised?

Lots of questions. 8-)

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

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


More information about the serviceability-dev mailing list