<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Thanks Coleen -<br>
      <br>
      Here's an update, the constants are good, here's an attempt to use
      constants and keep it not too verbose:<br>
      <br>
      <a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~kevinw/8026334/webrev.01/">http://cr.openjdk.java.net/~kevinw/8026334/webrev.01/</a><br>
      <br>
      Thanks<br>
      Kevin & Masato<br>
      <br>
      <br>
      On 26/03/14 23:44, Coleen Phillimore wrote:<br>
    </div>
    <blockquote cite="mid:53336666.2060909@oracle.com" type="cite">
      <meta content="text/html; charset=windows-1252"
        http-equiv="Content-Type">
      <br>
      Can you make these expressions into a variable for the
      calculations?  IE.
      <meta charset="utf-8">
      <pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="new" style="color: blue; font-weight: normal;">86400 = seconds_in_a_day
</span><meta charset="utf-8"><span class="new" style="color: blue; font-weight: normal;">3600 = seconds_in_an_hour</span>
<meta charset="utf-8"><span class="new" style="color: blue; font-weight: normal;">60 = seconds_in_a_minute

and then have
eldays * 86400 be something like day_seconds

</span><span class="new" style="color: blue; font-weight: normal;"></span></pre>
      Thanks - it would be nice if these numbers only appear once each.<br>
      Coleen<br>
      <pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="new" style="color: blue; font-weight: normal;"></span></pre>
      <div class="moz-cite-prefix">On 3/26/14 7:08 PM, Kevin Walls
        wrote:<br>
      </div>
      <blockquote cite="mid:53335DEE.3080805@oracle.com" type="cite"> <br>
        Hi, <br>
        <br>
        I'd like to get a review of this change: <br>
        <br>
        It's adding a human-readable breakdown of the elapsed time,
        which is currently printed in raw seconds in the hs_err file
        (it's the last item printed). <br>
        <br>
        This is on behalf of Masato Yoshido who has worked on it.
        Further details below, including a method that was used for
        manual testing. <br>
        <br>
        bug: <br>
        <a moz-do-not-send="true" class="moz-txt-link-freetext"
          href="https://bugs.openjdk.java.net/browse/JDK-8026334">https://bugs.openjdk.java.net/browse/JDK-8026334</a>
        <br>
        <br>
        webrev: <br>
        <a moz-do-not-send="true" class="moz-txt-link-freetext"
          href="http://cr.openjdk.java.net/%7Ekevinw/8026334/webrev.00/">http://cr.openjdk.java.net/~kevinw/8026334/webrev.00/</a>
        <br>
        <br>
        Many thanks, <br>
        Kevin <br>
        Masato <br>
        <br>
        <br>
        [Change details] <br>
        <br>
        - Time format will change as follows: <br>
        <br>
          (from) <br>
          elapsed time: %d seconds <br>
        <br>
          (to) <br>
          elapsed time: %d seconds (%dd %dh %dm %ds) <br>
        <br>
        - The reason why I leave the original elapsed time format is: <br>
          -- We don’t need to remove the original format. If we remove
        it, ones <br>
             who want time information in seconds need to calculate from
        day-, <br>
             hour-, minute- and second-parts. <br>
        <br>
        - There is no code doing exactly the same thing. Another code to
        which <br>
          we might be able to apply calculation similar to this
        conversion is <br>
          the GC log with -XX:+PrintGCTimeStamps. However, the elapsed
        time <br>
          in GC log is a floating point number, while the time in hs_err
        log <br>
          is an integer since there is a problem when %f is used in
        printf <br>
          on Linux platform (See comments in os::print_date_and_time
        function). <br>
          Therefore, the same code as this cannot simply be share with
        GC log. <br>
        <br>
        <br>
        [Test] <br>
        <br>
        (1) Tested only part of code of elapsed time calculation and
        printing. <br>
        <br>
        --- test_print_time.cpp --- <br>
        #include <stdio.h> <br>
        #include <stdlib.h> <br>
        #include <limits.h> <br>
        <br>
        void print_date_and_time(double t) { <br>
          int eltime = (int)t;  // elapsed time in seconds <br>
          int eldays, elhours, elminutes, elseconds;  // for printing
        elapsed time in a humanly readable format <br>
          eldays = eltime / 86400; <br>
          elhours = (eltime - eldays * 86400) / 3600; <br>
          elminutes = (eltime - eldays * 86400 - elhours * 3600) / 60; <br>
          elseconds = (eltime - eldays * 86400 - elhours * 3600 -
        elminutes * 60); <br>
          printf("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime,
        eldays, elhours, elminutes, elseconds); <br>
          printf("\n"); <br>
        } <br>
        <br>
        int main(int argc, char *argv[]) { <br>
          print_date_and_time((double)86399); <br>
          print_date_and_time((double)86400); <br>
          print_date_and_time((double)86401); <br>
          printf("\n"); <br>
        <br>
          print_date_and_time((double)86399.999); <br>
          print_date_and_time((double)86400.999); <br>
          print_date_and_time((double)86401.999); <br>
          printf("\n"); <br>
        <br>
          print_date_and_time((double)(-86399)); <br>
          print_date_and_time((double)(-86400)); <br>
          print_date_and_time((double)(-86401)); <br>
          printf("\n"); <br>
        <br>
          print_date_and_time((double)INT_MAX); <br>
          print_date_and_time((double)(INT_MAX+1)); <br>
          print_date_and_time((double)UINT_MAX); <br>
        } <br>
        --- <br>
        <br>
        --- Run the test program <br>
        $ ./test_print_time <br>
        elapsed time: 86399 seconds (0d 23h 59m 59s) <br>
        elapsed time: 86400 seconds (1d 0h 0m 0s) <br>
        elapsed time: 86401 seconds (1d 0h 0m 1s) <br>
        <br>
        elapsed time: 86399 seconds (0d 23h 59m 59s) <br>
        elapsed time: 86400 seconds (1d 0h 0m 0s) <br>
        elapsed time: 86401 seconds (1d 0h 0m 1s) <br>
        <br>
        elapsed time: -86399 seconds (0d -23h -59m -59s) <br>
        elapsed time: -86400 seconds (-1d 0h 0m 0s) <br>
        elapsed time: -86401 seconds (-1d 0h 0m -1s) <br>
        <br>
        elapsed time: 2147483647 seconds (24855d 3h 14m 7s) <br>
        elapsed time: -2147483648 seconds (-24855d -3h -14m -8s) <br>
        elapsed time: -2147483648 seconds (-24855d -3h -14m -8s) <br>
        --- <br>
        <br>
        <br>
        (2) Tested using a JNI program causing Segmentation Violation. <br>
            Tested on the following platforms: <br>
              solaris sparcv9 <br>
              solaris x64 <br>
              linux x86 <br>
              linux x64 <br>
              windows x86 <br>
              windows x64 <br>
              macosx x64 <br>
            hs_err_pid<pid>.log file was successfully generated
        with expected <br>
            “elapsed time” line on each platform. <br>
        <br>
        <br>
        --- TestCrash.java --- <br>
        public class TestCrash { <br>
          static { <br>
            System.loadLibrary("testcrash"); <br>
          } <br>
        <br>
          public static native void crash(); <br>
        <br>
          public static void main(String[] args) { <br>
            try { <br>
              Thread.sleep(61000); <br>
            } catch (InterruptedException e) { <br>
              e.printStackTrace(); <br>
            } <br>
            crash(); <br>
          } <br>
        } <br>
        --- <br>
        <br>
        --- TestCrash.c --- <br>
        #include <jni.h> <br>
        <br>
        #ifdef __cplusplus <br>
        extern "C" { <br>
        #endif <br>
        /* <br>
         * Class:     TestCrash <br>
         * Method:    crash <br>
         * Signature: ()V <br>
         */ <br>
        JNIEXPORT void JNICALL Java_TestCrash_crash(JNIEnv *env, jclass
        cls) { <br>
          const char *p = "Hello, world!"; <br>
          *(char *)p = 'a'; <br>
        } <br>
        <br>
        #ifdef __cplusplus <br>
        } <br>
        #endif <br>
        --- <br>
        <br>
        <br>
        Thanks and best regards, <br>
        Masato <br>
        <br>
        <br>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>