Mercurial > hg > release > heapstats-1.1
changeset 8:d000aea96245
Bug 1587: Refactor to improve the messaging and gathering the symbols.
reviewed-by: yasuenag
author | KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> |
---|---|
date | Tue, 19 Nov 2013 21:24:52 +0900 |
parents | edef0dd8472c |
children | d0cc4c3be1eb |
files | agent/ChangeLog agent/src/oopUtil.cpp agent/src/snapShotMain.cpp agent/src/symbolFinder.cpp agent/src/symbolFinder.hpp |
diffstat | 5 files changed, 57 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/ChangeLog Mon Nov 18 20:03:04 2013 +0900 +++ b/agent/ChangeLog Tue Nov 19 21:24:52 2013 +0900 @@ -1,3 +1,7 @@ +2013-11-19 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> + + * Bug 1587: Refactor to improve the messaging and gathering the symbols. + 2013-11-18 Yasumasa Suenaga <suenaga.yasumasa@lab.ntt.co.jp> * Bug 1605: Cannot build HeapStats 1.1 agent on RHEL5
--- a/agent/src/oopUtil.cpp Mon Nov 18 20:03:04 2013 +0900 +++ b/agent/src/oopUtil.cpp Tue Nov 19 21:24:52 2013 +0900 @@ -2225,8 +2225,9 @@ /*! * \brief Search common flag. + * \return Process result. */ -void searchCommonFlags(void) { +bool searchCommonFlags(void) { /* Search flag symbols. */ struct { @@ -2250,13 +2251,11 @@ /* Search symbol. */ tempPtr = (bool*)symFinder->findSymbol(flagList[i].symbolStr); - /* If not found symbol. */ + /* If symbol not found. */ if (unlikely(tempPtr == NULL)) { - PRINT_WARN_MSG_HEADER << "Not found java symbol." + PRINT_WARN_MSG_HEADER << "Java symbol not found." << " symbol:\"" << flagList[i].symbolStr << "\"" << NEWLINE; - - /* Set dummy flag. */ - tempPtr = &dummyFalseFlag; + return false; } (*flagList[i].flagPtr) = tempPtr; @@ -2272,7 +2271,7 @@ /* Search symbol. */ tempPtr = (bool*)symFinder->findSymbol(target_sym); - /* If not found symbol. */ + /* If symbol not found. */ if (unlikely(tempPtr == NULL)) { PRINT_WARN_MSG_HEADER << target_sym << " not found." << NEWLINE; } @@ -2322,21 +2321,22 @@ int *intPos = NULL; intPos = (int*)symFinder->findSymbol(intSymList[i].symbol); - /* If not found integer symbol. */ + /* If integer symbol not found, search sub-symbol. */ if (unlikely(intPos == NULL)) { intPos = (int*)symFinder->findSymbol(intSymList[i].subSymbol); } - /* If not found integer symbol. */ + /* If integer symbol and sub-symbol not found. */ if (unlikely(intPos == NULL)) { - PRINT_WARN_MSG_HEADER - << "Not found java symbol. Use default value." + PRINT_DEBUG_MSG_HEADER + << "Java symbol not found, using default value instead." << " symbol:\"" << intSymList[i].symbol << "\"" << NEWLINE; } else { (*intSymList[i].pointer) = (*intPos); } } + return true; } /*! @@ -2361,7 +2361,7 @@ } /* If not found "is_in_permanent" function symbol. */ if (unlikely(is_in_permanent == NULL)) { - PRINT_WARN_MSG("Not found java symbol. symbol:\"is_in_permanent\""); + PRINT_WARN_MSG("Java symbol not found. symbol:\"is_in_permanent\""); return false; } @@ -2370,7 +2370,7 @@ SYMBOL_GETOBJCTSIZE); /* If not found "GetObjectSize" function symbol. */ if (unlikely(getObjectSize == NULL)) { - PRINT_WARN_MSG("Not found java symbol. symbol:\"GetObjectSize\""); + PRINT_WARN_MSG("Java symbol not found. symbol:\"GetObjectSize\""); return false; } @@ -2379,7 +2379,7 @@ (enableCR6964458) ? AS_KLASS_SYMBOL : AS_KLASSOOP_SYMBOL); /* If not found "as_klassOop" function symbol. */ if (unlikely(asKlassOop == NULL)) { - PRINT_WARN_MSG("Not found java symbol. symbol:\"as_klassOop\""); + PRINT_WARN_MSG("Java symbol not found. symbol:\"as_klassOop\""); return false; } @@ -2387,7 +2387,7 @@ safePointState = (int*)symFinder->findSymbol(SAFEPOINT_STATE_SYMBOL); /* If not found "_state" variable symbol. */ if (unlikely(safePointState == NULL)) { - PRINT_WARN_MSG("Not found java symbol. symbol:\"safepoint_state\""); + PRINT_WARN_MSG("Java symbol not found. symbol:\"safepoint_state\""); return false; } @@ -2409,7 +2409,7 @@ if (unlikely(getClassLoaderForInstanceKlass == NULL || getClassLoaderForObjArrayKlass == NULL)) { - PRINT_WARN_MSG("Not found java symbol. symbol:\"get_classloader\""); + PRINT_WARN_MSG("Java symbol not found. symbol:\"get_classloader\""); return false; } @@ -2431,7 +2431,7 @@ /* Search class(vtable) symbol. */ arr->vtable = (void**)symFinder->findSymbol(arr->vtableSymbol); if (unlikely(arr->vtable == NULL)) { - PRINT_WARN_MSG_HEADER << "Not found java symbol." + PRINT_WARN_MSG_HEADER << "Java symbol not found." << " symbol:\"" << arr->vtableSymbol << "\"" << NEWLINE; return false; } @@ -2439,7 +2439,7 @@ /* Search function symbol. */ arr->originalFunc = symFinder->findSymbol(arr->funcSymbol); if (unlikely(arr->originalFunc == NULL)) { - PRINT_WARN_MSG_HEADER << "Not found java symbol." + PRINT_WARN_MSG_HEADER << "Java symbol not found." << " symbol:\"" << arr->funcSymbol << "\"" << NEWLINE; return false; } @@ -2572,21 +2572,21 @@ "_ZN12CMSCollector15_collectorStateE"); /* If not found "CMS_collectorState" function symbol. */ if (unlikely(CMS_collectorState == NULL)) { - PRINT_WARN_MSG("Not found java symbol. symbol:\"CollectorState\""); + PRINT_WARN_MSG("Java symbol not found. symbol:\"CollectorState\""); return false; } /* If failure getting function information. */ if (unlikely(!setupOverrideFunction(cms_new_hook))) { - PRINT_WARN_MSG("Failure function overriding. func:CMS_new"); + PRINT_WARN_MSG("Can't override function. func:CMS_new"); return false; } /* If failure getting function information. */ if (unlikely(!setupOverrideFunction(cms_sweep_hook))) { - PRINT_WARN_MSG("Failure function overriding. func:CMS_sweep"); + PRINT_WARN_MSG("Can't override function. func:CMS_sweep"); return false; } BitsPerWordMask = BitsPerWord - 1; @@ -2772,7 +2772,7 @@ /* Cretae VMStruct scanner instance. */ vmScanner = new TVMStructScanner(symFinder); } catch(...) { - PRINT_WARN_MSG("Failure getting symbol information."); + PRINT_CRIT_MSG("Failure getting symbol information."); jvmti->Deallocate((unsigned char *)libPath); delete symFinder; symFinder = NULL; @@ -2787,7 +2787,7 @@ if (unlikely(isError(jvmti, jvmti->GetSystemProperty("java.vm.version", &versionStr)))) { - PRINT_WARN_MSG("Failure getting JVM version."); + PRINT_CRIT_MSG("Failure getting JVM version."); throw 1; } else { unsigned char major = 0; @@ -2801,7 +2801,7 @@ /* If failure parse version string. */ if (unlikely(result != 3)) { - PRINT_WARN_MSG("Failure getting symbol information."); + PRINT_CRIT_MSG("Unsupported JVM version."); throw 1; } hotSpotVersion = major << 24 | minor << 16 | build; @@ -2850,8 +2850,11 @@ enableCR8015107 = (hotSpotVersion >= afterCR8015107); /* Search flag symbol in libjvm. */ - searchCommonFlags(); - + if (unlikely(!searchCommonFlags())) { + PRINT_CRIT_MSG("Failure getting java symbol information."); + throw 1; + } + /* * See 7046558: G1: concurrent marking optimizations. * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7046558 @@ -2863,13 +2866,15 @@ if (unlikely(hotSpotVersion < afterCR7046558)) { /* Heapstats agent is unsupported G1GC on JDK6. */ - PRINT_WARN_MSG("Sorry, G1GC isn't supported in this version."); + PRINT_CRIT_MSG("Sorry, G1GC isn't supported in this version."); + PRINT_CRIT_MSG("You should use >= 22.0-b03"); throw 1; } } /* Search common function symbol in libjvm. */ if (unlikely(!searchCommonFunction())) { + PRINT_CRIT_MSG("Failure getting java symbol information."); throw 1; } @@ -2877,7 +2882,7 @@ if (unlikely(pthread_key_create(&oldKlassOopKey, pThreadKeyDestructor) != 0)) { - PRINT_WARN_MSG("Failure create pthread key."); + PRINT_CRIT_MSG("Failure create pthread key."); throw 1; } } catch(...) {
--- a/agent/src/snapShotMain.cpp Mon Nov 18 20:03:04 2013 +0900 +++ b/agent/src/snapShotMain.cpp Tue Nov 19 21:24:52 2013 +0900 @@ -895,7 +895,7 @@ /* Initialize oop util. */ if (unlikely(!oopUtilInitialize(*jvmti))) { - PRINT_CRIT_MSG("Getting low level information failed!"); + PRINT_CRIT_MSG("Please check installation and version of java and debuginfo packages."); return GET_LOW_LEVEL_INFO_FAILED; }
--- a/agent/src/symbolFinder.cpp Mon Nov 18 20:03:04 2013 +0900 +++ b/agent/src/symbolFinder.cpp Tue Nov 19 21:24:52 2013 +0900 @@ -31,6 +31,7 @@ #include <link.h> #include <bfd.h> #include <errno.h> +#include <sys/stat.h> #include "symbolFinder.hpp" #include "util.hpp" @@ -146,6 +147,11 @@ /* Load library with bfd record. */ loadLibraryInfo(targetLibInfo.libname, &libBfdInfo); + /* If bfd record has the symbols, no need to search debuginfo */ + if (libBfdInfo.hasSymtab && libBfdInfo.staticSymCnt > 0 && libBfdInfo.dynSymCnt > 0) { + return true; + } + char dbgInfoPath[PATH_MAX]; dbgInfoPath[0] = '\0'; @@ -189,9 +195,16 @@ if(dbgInfoPath[0] != '\0'){ /* Load library's debuginfo with bfd record. */ - PRINT_DEBUG_MSG_HEADER << "Try to read debuginfo from " + struct stat st = {0}; + if (unlikely(stat(&(dbgInfoPath[0]), &st) != 0)) { + PRINT_WARN_MSG_HEADER << "Cannot read debuginfo from " << dbgInfoPath << NEWLINE; - loadLibraryInfo(dbgInfoPath, &debugBfdInfo); + } else { + PRINT_DEBUG_MSG_HEADER << "Try to read debuginfo from " + << dbgInfoPath << NEWLINE; + loadLibraryInfo(dbgInfoPath, &debugBfdInfo); + } + } else{ PRINT_DEBUG_MSG_HEADER << "The same version of debuginfo not found: " @@ -307,6 +320,9 @@ /* Load dynamic symbols. */ libInfo->dynSymCnt = bfd_read_minisymbols(bfdDesc, 1, (void **)&libInfo->dynSyms, &libInfo->dynSymSize); + /* Check .symtab section. If there are no symbols in the BFD, + * below function returns the size of terminal Null pointer or 0 */ + libInfo->hasSymtab = (bfd_get_symtab_upper_bound(bfdDesc) > sizeof(NULL)); libInfo->workSym = syms; }
--- a/agent/src/symbolFinder.hpp Mon Nov 18 20:03:04 2013 +0900 +++ b/agent/src/symbolFinder.hpp Tue Nov 19 21:24:52 2013 +0900 @@ -63,6 +63,7 @@ char *dynSyms; /*!< List stored dynamic symbol. */ int dynSymCnt; /*!< Count of dynamic symbols. */ unsigned int dynSymSize; /*!< Size of single dynamic symbols. */ + bool hasSymtab; /*!< Flag of BFD has .symtab section. */ asymbol *workSym; /*!< Empty symbol for working temporary. */ } TLibBFDInfo;