changeset 39:c1b7b75d1930

Bug 1844: Agent should be adapted new HotSpot versioning: JDK-8030011 reviewed-by: ykubota
author Yasumasa Suenaga <yasuenag@gmail.com>
date Tue, 17 Jun 2014 23:20:20 +0900
parents 2d49f99d0a36
children b1930d079140
files agent/ChangeLog agent/src/jvmInfo.hpp agent/src/oopUtil.cpp
diffstat 3 files changed, 46 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/agent/ChangeLog	Mon Apr 14 22:23:05 2014 +0900
+++ b/agent/ChangeLog	Tue Jun 17 23:20:20 2014 +0900
@@ -1,3 +1,7 @@
+2014-06-17  Yasumasa Suenaga  <yasuenag@gmail.com>
+
+	* Bug 1844: Agent should be adapted new HotSpot versioning: JDK-8030011
+
 2014-04-19  Yasumasa Suenaga  <yasuenag@gmail.com>
 
 	* Bug 1735: REGRESSION: Cannot collect files from procfs
--- a/agent/src/jvmInfo.hpp	Mon Apr 14 22:23:05 2014 +0900
+++ b/agent/src/jvmInfo.hpp	Tue Jun 17 23:20:20 2014 +0900
@@ -1,7 +1,7 @@
 /*!
  * \file jvmInfo.hpp
  * \brief This file is used to get JVM performance information.
- * Copyright (C) 2011-2013 Nippon Telegraph and Telephone Corporation
+ * Copyright (C) 2011-2014 Nippon Telegraph and Telephone Corporation
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -34,8 +34,8 @@
 /*!
  * \brief Make HotSpot version
  */
-#define MAKE_HS_VERSION(major, minor, build) \
-                   (((major) << 24) | ((minor) << 16) | (build))
+#define MAKE_HS_VERSION(major, minor, micro, build) \
+               (((major) << 24) | ((minor) << 16) | ((micro) << 8) | (build))
 
 /*!
  * \brief JVM performance header info.
@@ -369,7 +369,7 @@
      */
     inline bool isAfterCR7046558(void){
       // hs22.0-b03
-      return (this->_hsVersion >= MAKE_HS_VERSION(22, 0, 3));
+      return (this->_hsVersion >= MAKE_HS_VERSION(22, 0, 0, 3));
     }
 
     /*!
@@ -380,7 +380,7 @@
      */
     inline bool isAfterCR6964458(void){
       // hs25.0-b01
-      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 1));
+      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 0, 1));
     }
 
     /*!
@@ -390,7 +390,7 @@
      */
     inline bool isAfterCR8000213(void){
       // hs25.0-b04
-      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 4));
+      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 0, 4));
     }
 
     /*!
@@ -400,7 +400,7 @@
      */
     inline bool isAfterCR8003424(void){
       // hs25.0-b46
-      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 46));
+      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 0, 46));
     }
 
     /*!
@@ -409,7 +409,7 @@
      */
     inline bool isAfterCR8015107(void){
       // hs25.0-b51
-      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 51));
+      return (this->_hsVersion >= MAKE_HS_VERSION(25, 0, 0, 51));
     }
 
     /*!
--- a/agent/src/oopUtil.cpp	Mon Apr 14 22:23:05 2014 +0900
+++ b/agent/src/oopUtil.cpp	Tue Jun 17 23:20:20 2014 +0900
@@ -2229,19 +2229,45 @@
   else{
     unsigned char major  = 0;
     unsigned char minor  = 0;
-    unsigned short build = 0;
+    unsigned char micro = 0;
+    unsigned char build = 0;
     int result = 0;
     
     /* Parse version string. */
-    result = sscanf(versionStr, "%hhu.%hhu-b%hu", &major, &minor, &build);
-    jvmti->Deallocate((unsigned char *)versionStr);
+    result = sscanf(versionStr, "%hhu.%hhu-b%hhu", &major, &minor, &build);
     
-    /* If failure parse version string. */
-    if(unlikely(result != 3)){
-      PRINT_CRIT_MSG("Unsupported JVM version.");
-      return false;
+    /* We expect to get 3 values (major, minor, build) from sscanf() at first */
+    if(result != 3){
+      /* After JDK-8030011: Update Hotspot version string output */
+      unsigned char micro = 0;
+      result =  sscanf(versionStr, "%hhu.%hhu.%hhu", &major, &minor, &micro);
+      char *build_str = strrchr(versionStr, 'b');
+      if(likely(build_str != NULL)){
+        result += sscanf(build_str, "b%hhu", &build);
+      }
+
+      /*
+       * We expect to get 4 values (major, minor, micro, build) from sscanf().
+       * This versioning equals to JDK version.
+       */
+      if(unlikely(result != 4)){
+        PRINT_CRIT_MSG_HEADER << "Unsupported JVM version: "
+                              << versionStr
+                              << " (" << result << ")"
+                              << NEWLINE;
+        jvmti->Deallocate((unsigned char *)versionStr);
+        return false;
+      }
+
+      /*
+       * Latest HS version is "25".
+       * So I add 25 to major.
+       */
+      major += 25;
     }
-    jvmInfo->setHSVersion(MAKE_HS_VERSION(major, minor, build));
+
+    jvmti->Deallocate((unsigned char *)versionStr);
+    jvmInfo->setHSVersion(MAKE_HS_VERSION(major, minor, micro, build));
   }
   
   /* Search flag symbol in libjvm. */