# HG changeset patch # User Yasumasa Suenaga # Date 1403014820 -32400 # Node ID c1b7b75d1930d865246cc5ae18c86bb6561f3ebe # Parent 2d49f99d0a36854949fe002be68cd5e8966d2a87 Bug 1844: Agent should be adapted new HotSpot versioning: JDK-8030011 reviewed-by: ykubota diff -r 2d49f99d0a36 -r c1b7b75d1930 agent/ChangeLog --- 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 + + * Bug 1844: Agent should be adapted new HotSpot versioning: JDK-8030011 + 2014-04-19 Yasumasa Suenaga * Bug 1735: REGRESSION: Cannot collect files from procfs diff -r 2d49f99d0a36 -r c1b7b75d1930 agent/src/jvmInfo.hpp --- 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)); } /*! diff -r 2d49f99d0a36 -r c1b7b75d1930 agent/src/oopUtil.cpp --- 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, µ); + 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. */