RFR: 8357828: Add a timestamp to jcmd diagnostic commands

Larry Cable duke at openjdk.org
Wed Sep 24 22:27:28 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`

On 9/24/25 12:50 PM, Alex Menkov wrote:
> *alexmenkov* left a comment (openjdk/jdk#27368) 
> <https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/27368*issuecomment-3330432466__;Iw!!ACWV5N9M2RV99hQ!L8Ino0e59huBM_uRbUgs_2H_F9z8ErphlRCLbOg46qe85WuOwQe9PPmlOD1eOCuSVjCV2Xyj6sI_YJnNWYmYB9_KGw$>
>
>     My proposal would entail
>     * adding a new standard option to jcmd
>     * somehow funneling that option to the JVM
>     * the option should be optional, so that:
>     * old jcmd still works with new JVMs (and produces legacy jcmd output)
>     * new jcmd still works with old JVMs (and produces legacy jcmd output)
>     How complex would this be? There are two approaches to this. You
>     can either create a new attach listener protocol (we already have
>     ATTACH_API_V2 vs ATTACH_API_V1, so the precedence is there). Or,
>     you can expand the jcmd parsing (see |jcmd(AttachOperation* op,
>     attachStream* out)| in attachListener.cpp).
>
> ATTACH_API_V2 supports "options".
> Client (jcmd) detects options supported by the target VM ("getversion 
> options" command) and can set option values in attach command request.
> Currently the only supported option is "streaming" (it allows turn off 
> streaming output).
> The option is needed only for tests and needs to work for all attach 
> tools (jcmd, jstack, etc.), so it can be set by specifying java 
> property launching attach tool (like |jcmd 
> -J-Djdk.attach.allowStreamingOutput=false PID command|)
>

sounds like a plan!

>> Reply to this email directly, view it on GitHub 
> <https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/27368*issuecomment-3330432466__;Iw!!ACWV5N9M2RV99hQ!L8Ino0e59huBM_uRbUgs_2H_F9z8ErphlRCLbOg46qe85WuOwQe9PPmlOD1eOCuSVjCV2Xyj6sI_YJnNWYmYB9_KGw$>, 
> or unsubscribe 
> <https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ANTA67SGRSQRLDJZAM3LPRT3ULYW5AVCNFSM6AAAAACG4ANNIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMZQGQZTENBWGY__;!!ACWV5N9M2RV99hQ!L8Ino0e59huBM_uRbUgs_2H_F9z8ErphlRCLbOg46qe85WuOwQe9PPmlOD1eOCuSVjCV2Xyj6sI_YJnNWYk7VM8-7g$>.
> You are receiving this because you were mentioned.Message ID: 
> ***@***.***>
>

--------------oR0JTaz5Fop00jaWhAnzYKGf
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <br>
    <br>
    <div class="moz-cite-prefix">On 9/24/25 12:50 PM, Alex Menkov wrote:<br>
    </div>
    <blockquote type="cite" ***@***.***">
      
      <div style="display: flex; flex-wrap: wrap; white-space: pre-wrap; align-items: center; "><img height="20" width="20" style="border-radius:50%; margin-right: 4px;" decoding="async" src="https://avatars.githubusercontent.com/u/69548902?s=20&v=4" moz-do-not-send="true"><strong>alexmenkov</strong> left a comment <a href="https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/27368*issuecomment-3330432466__;Iw!!ACWV5N9M2RV99hQ!L8Ino0e59huBM_uRbUgs_2H_F9z8ErphlRCLbOg46qe85WuOwQe9PPmlOD1eOCuSVjCV2Xyj6sI_YJnNWYmYB9_KGw$" moz-do-not-send="true">(openjdk/jdk#27368)</a></div>
      <blockquote>
        <p dir="auto">My proposal would entail<br>
          * adding a new standard option to jcmd<br>
          * somehow funneling that option to the JVM<br>
          * the option should be optional, so that:<br>
          * old jcmd still works with new JVMs (and produces legacy jcmd
          output)<br>
          * new jcmd still works with old JVMs (and produces legacy jcmd
          output)<br>
          How complex would this be? There are two approaches to this.
          You can either create a new attach listener protocol (we
          already have ATTACH_API_V2 vs ATTACH_API_V1, so the precedence
          is there). Or, you can expand the jcmd parsing (see <code class="notranslate">jcmd(AttachOperation* op, attachStream*
            out)</code> in attachListener.cpp).</p>
      </blockquote>
      <p dir="auto">ATTACH_API_V2 supports "options".<br>
        Client (jcmd) detects options supported by the target VM
        ("getversion options" command) and can set option values in
        attach command request.<br>
        Currently the only supported option is "streaming" (it allows
        turn off streaming output).<br>
        The option is needed only for tests and needs to work for all
        attach tools (jcmd, jstack, etc.), so it can be set by
        specifying java property launching attach tool (like <code class="notranslate">jcmd
          -J-Djdk.attach.allowStreamingOutput=false PID command</code>)</p>
    </blockquote>
    <br>
    sounds like a plan!<br>
    <br>
    <blockquote type="cite" ***@***.***">
      <p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>
        Reply to this email directly, <a href="https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/27368*issuecomment-3330432466__;Iw!!ACWV5N9M2RV99hQ!L8Ino0e59huBM_uRbUgs_2H_F9z8ErphlRCLbOg46qe85WuOwQe9PPmlOD1eOCuSVjCV2Xyj6sI_YJnNWYmYB9_KGw$" moz-do-not-send="true">view it on GitHub</a>, or <a href="https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ANTA67SGRSQRLDJZAM3LPRT3ULYW5AVCNFSM6AAAAACG4ANNIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMZQGQZTENBWGY__;!!ACWV5N9M2RV99hQ!L8Ino0e59huBM_uRbUgs_2H_F9z8ErphlRCLbOg46qe85WuOwQe9PPmlOD1eOCuSVjCV2Xyj6sI_YJnNWYk7VM8-7g$" moz-do-not-send="true">unsubscribe</a>.<br>
        You are receiving this because you were mentioned.<img src="https://github.com/notifications/beacon/ANTA67WKNASEIPXUMLRQ5RD3ULYW5A5CNFSM6AAAAACG4ANNIKWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTWGQJO5E.gif" height="1" width="1" alt="" moz-do-not-send="true"><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message
          ID: <span><openjdk/jdk/pull/27368/c3330432466</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
      <script type="application/ld+json">[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "https://github.com/openjdk/jdk/pull/27368#issuecomment-3330432466",
"url": "https://github.com/openjdk/jdk/pull/27368#issuecomment-3330432466",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>
    </blockquote>
    <br>
  </body>
</html>

--------------oR0JTaz5Fop00jaWhAnzYKGf--

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

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


More information about the serviceability-dev mailing list