Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87977 Details for
Bug 215437
[POG] Fail to attach to process launched with IBM JDK and JVMTI agent.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated patch.
patch_215437.txt (text/plain), 21.27 KB, created by
Asaf Yaffe
on 2008-01-27 14:40:16 EST
(
hide
)
Description:
Updated patch.
Filename:
MIME Type:
Creator:
Asaf Yaffe
Created:
2008-01-27 14:40:16 EST
Size:
21.27 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.jvmti.runtime.4.4.1 >Index: src-native/src/Martini/Infrastructure/CGAdaptor/CGAdaptor.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/CGAdaptor/CGAdaptor.cpp,v >retrieving revision 1.10 >diff -u -r1.10 CGAdaptor.cpp >--- src-native/src/Martini/Infrastructure/CGAdaptor/CGAdaptor.cpp 22 Apr 2007 14:32:32 -0000 1.10 >+++ src-native/src/Martini/Infrastructure/CGAdaptor/CGAdaptor.cpp 27 Jan 2008 19:16:20 -0000 >@@ -195,7 +195,7 @@ > res = DoCallGraphInstrumentation(pJavaClass, pCGContext->classInfo, m_bJVMInitDone); > if (MRTE_RESULT_OK == res) > { >- // write the instrumented class file to pInstrumentedClass >+ // Write the instrumented class file to pInstrumentedClass > SBuffer buffer; > res = pJavaClass->WriteBack(&buffer, funcAllocator); > if (MRTE_RESULT_OK == res) >@@ -292,10 +292,11 @@ > pJavaClass->RegisterRecorderCallback(wzCallbackClassName, > wzIsJVMInitName, wzIsJVMInitSig); > >- TResult res; >+ TResult res = MRTE_RESULT_OK; > IJavaMethod *pMethod; > TJavaMethodIterator *pMethIter = NULL; > SJavaMethodInfo *pJavaMethodInfo; >+ size_t instrMethodCount = 0; > > if (ILLEGAL_CP_ENTRY != cpEntryCallback > && ILLEGAL_CP_ENTRY != cpLeaveCallback >@@ -336,15 +337,19 @@ > cpEntryCallback, cpLeaveCallback, cpIsJVMInit, bJVMInitDone); > if (MRTE_RESULT_OK != res) > { >- //TODO: write an error to the Martini logger > DeallocateJavaMethodInfo(pJavaMethodInfo); > delete pJavaMethodInfo; >+ LOG_INFORMATIVE4("CGAdaptor", 0, false, >+ "Error instrumenting '%s.%s(%s)'. Reason: %x", >+ classInfo.szClassName, pMethodInstrumentationInfo->szName, >+ pMethodInstrumentationInfo->szSignature, res); > break; > } >+ instrMethodCount++; > LOG_INFORMATIVE3("CGAdaptor", 5, false, "Instrumented: %s.%s(%s)", > classInfo.szClassName, pMethodInstrumentationInfo->szName, > pMethodInstrumentationInfo->szSignature); >- } // if (method passed selelctivity criterion) >+ } // if (method passed selectivity criterion) > } > // deallocate the method information > DeallocateJavaMethodInfo(pJavaMethodInfo); >@@ -355,11 +360,12 @@ > else > { > // unable to add recorder callbacks to the constant pool >- //TODO: write an error to the Martini logger >+ LOG_INFORMATIVE1("CGAdaptor", 0, false, "Unable to add recorder callbacks to class %s", >+ classInfo.szClassName); > res = MRTE_ERROR_FAIL; > } > >- // clean-up >+ // Clean-up > CWideStringUtils::FreeWideString(wzCallbackClassName); > CWideStringUtils::FreeWideString(wzMethodEntryCallbackName); > CWideStringUtils::FreeWideString(wzMethodEntryCallbackSig); >@@ -368,6 +374,13 @@ > CWideStringUtils::FreeWideString(wzIsJVMInitName); > CWideStringUtils::FreeWideString(wzIsJVMInitSig); > >+ // If no methods were instrumented, modify the return code to indicate this >+ if (MRTE_SUCCEEDED(res) && instrMethodCount == 0) >+ { >+ LOG_INFORMATIVE1("CGAdaptor", 3, false, "Class %s was not instrumented because all its methods were excluded", >+ classInfo.szClassName); >+ res = MRTE_ERROR_INSTRUMENTATION_NOT_NEEDED; >+ } > return res; > } > >Index: src-native/src/Martini/Infrastructure/JPI/JVMTIInterface.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/JPI/JVMTIInterface.cpp,v >retrieving revision 1.28 >diff -u -r1.28 JVMTIInterface.cpp >--- src-native/src/Martini/Infrastructure/JPI/JVMTIInterface.cpp 23 Aug 2007 10:40:55 -0000 1.28 >+++ src-native/src/Martini/Infrastructure/JPI/JVMTIInterface.cpp 27 Jan 2008 19:16:33 -0000 >@@ -2686,7 +2686,22 @@ > err = m_pJvmtiEnv->AddCapabilities(&cap); > if (JVMTI_ERROR_NONE != err) > { >- return MRTE_ERROR_NOT_SUPPORTED; >+ // Try again without can_redefine_any_class (this capability is desired but not required) >+ cap.can_redefine_any_class = 0; >+ err = m_pJvmtiEnv->AddCapabilities(&cap); >+ if (JVMTI_ERROR_NONE != err) >+ { >+ MARTINI_INFORMATIVE("CJVMTIInterface", 0, false, >+ "[CTIEnableDisableBciGeneratedEventsCapability] Required JVMTI capability 'can_redefine_classes' is " >+ "not supported by the JVM"); >+ return MRTE_ERROR_NOT_SUPPORTED; >+ } >+ else >+ { >+ MARTINI_INFORMATIVE("CJVMTIInterface", 0, false, >+ "[CTIEnableDisableBciGeneratedEventsCapability] JVM does not support the JVMTI capability " >+ "'can_redefine_any_class'. This may cause problems with attach/detach operations"); >+ } > } > m_bEnabled = true; > return MRTE_RESULT_OK; >@@ -2702,8 +2717,7 @@ > { > return false; > } >- return (cap.can_redefine_any_class >- && cap.can_redefine_classes >+ return (cap.can_redefine_classes > && cap.can_suspend); > } > >@@ -2711,7 +2725,8 @@ > { > jvmtiCapabilities cap; > memset(&cap, 0, sizeof(jvmtiCapabilities)); >- cap.can_redefine_any_class = 1; >+ cap.can_redefine_any_class = 1; // Although the environment may not posses this capability, >+ // relinquishing it is OK according to the JVMTI specification > cap.can_redefine_classes = 1; > cap.can_suspend = 1; > jvmtiError err; >Index: src-native/src/Martini/Infrastructure/JPI/ObjectInfoManager.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/JPI/ObjectInfoManager.cpp,v >retrieving revision 1.9 >diff -u -r1.9 ObjectInfoManager.cpp >--- src-native/src/Martini/Infrastructure/JPI/ObjectInfoManager.cpp 1 Aug 2007 11:56:01 -0000 1.9 >+++ src-native/src/Martini/Infrastructure/JPI/ObjectInfoManager.cpp 27 Jan 2008 19:16:37 -0000 >@@ -85,9 +85,6 @@ > } > *pNewObjectId = m_objIdAllocator.AllocateId(); > GetTagInfo(tag)->jobjectInfo.objectId = *pNewObjectId; >- MARTINI_INFORMATIVE1("CObjectInfoManager", 5, false, >- "[NewObject] allocated new object id %u", (U32)*pNewObjectId); >- > return MRTE_RESULT_OK; > } > >Index: src-native/src/Martini/Infrastructure/JPI/DataManager.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/JPI/DataManager.h,v >retrieving revision 1.11 >diff -u -r1.11 DataManager.h >--- src-native/src/Martini/Infrastructure/JPI/DataManager.h 23 Aug 2007 10:40:55 -0000 1.11 >+++ src-native/src/Martini/Infrastructure/JPI/DataManager.h 27 Jan 2008 19:16:27 -0000 >@@ -213,6 +213,8 @@ > > TResult SetClassInstrumentationStatus(const MPI::TId classId, bool bEventsEnabled); > >+ bool AreEventsEnabledForClass(MPI::TId classId); >+ > TResult NewClass(const MPI::TId classId, > const char *szNativeClassName, > const MPI::TId loaderObjectId, >@@ -278,8 +280,6 @@ > > TResult GetThreadCurrentMonitor(MPI::TId *pMonId, jthread thread); > >- bool AreEventsEnabledForClass(MPI::TId classId); >- > void MakeUniqueClassName(RTUtil::MCString& strUniqueName, > const RTUtil::MCString& strClassName, > MPI::TId classLoaderId); >Index: src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.h,v >retrieving revision 1.9 >diff -u -r1.9 JavaInstrumentorManager.h >--- src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.h 23 Aug 2007 10:40:55 -0000 1.9 >+++ src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.h 27 Jan 2008 19:16:37 -0000 >@@ -266,12 +266,6 @@ > > TResult ApplyInstrForLoadedClasses(MPI::EEventGroup group, bool enabled); > >- TResult ApplyInstrForClass(Infrastructure::SClassFile *pInstrumentedClass, >- jclass *pClassJniGlobalRef, >- MPI::TId classId, >- MPI::EEventGroup group, >- bool bEnabled); >- > void InstrumentationLock() > { > m_csInstrumentation->Enter(); >@@ -312,6 +306,12 @@ > > private: > >+ TResult ApplyInstrForClass(Infrastructure::SClassFile *pInstrumentedClass, >+ jclass *pClassJniGlobalRef, >+ MPI::TId classId, >+ MPI::EEventGroup group, >+ bool bEnabled); >+ > TResult ApplyInstrForLoadedClassesImpl(MPI::EEventGroup group, bool enabled); > > TResult SetInstrumentationInfo(MPI::IEventObserver& even); >Index: src-native/src/Martini/Infrastructure/JPI/DataManager.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/JPI/DataManager.cpp,v >retrieving revision 1.25 >diff -u -r1.25 DataManager.cpp >--- src-native/src/Martini/Infrastructure/JPI/DataManager.cpp 23 Aug 2007 10:40:55 -0000 1.25 >+++ src-native/src/Martini/Infrastructure/JPI/DataManager.cpp 27 Jan 2008 19:16:27 -0000 >@@ -1696,6 +1696,14 @@ > m_pJavaInstrumentorManager->RedefineMultipleClasses( > vecClassesToRedefine, false /* isBlocking */); > } >+ else if (MRTE_ERROR_INSTRUMENTATION_NOT_NEEDED == iRes >+ || MRTE_ERROR_UNABLE_TO_INSTRUMENT == iRes) >+ { >+ MARTINI_INFORMATIVE1("CDataManager", 0, false, >+ "Class '%s' has wrong instrumentation, but will not be redefined due to user-defined " >+ "filters or an internal reason", >+ pClassInfo->szNativeName.Get()); >+ } > else > { > // Error instrumenting class. This is a fatal error. >Index: src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.cpp,v >retrieving revision 1.15 >diff -u -r1.15 JavaInstrumentorManager.cpp >--- src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.cpp 23 Aug 2007 10:40:55 -0000 1.15 >+++ src-native/src/Martini/Infrastructure/JPI/JavaInstrumentorManager.cpp 27 Jan 2008 19:16:36 -0000 >@@ -1064,35 +1064,62 @@ > } > > SClassFile *pClassWithBasicInstr = new SClassFile(); >+ SClassFile classToReturnToJVM; >+ memset(&classToReturnToJVM, 0, sizeof(SClassFile)); > > // Apply basic instrumentation to the class file. The memory for the resulting class file > // is allocated from the internal JPI heap (using malloc) >- iRetVal = m_pAdaptor->ModifyClass(classId, classToInstrument, LocalMemAlloc, >+ TResult modifyClassRes = m_pAdaptor->ModifyClass(classId, classToInstrument, LocalMemAlloc, > pClassWithBasicInstr); > > InstrumentationLock(); > >- if (MRTE_SUCCEEDED(iRetVal)) >+ if (MRTE_SUCCEEDED(modifyClassRes)) > { > // Store the instrumented class in the Data Manager. This image will be used > // for redefining the class in the future (if needed) > iRetVal = m_pDataManager->SetClassFileBuffer(classId, pClassWithBasicInstr); >+ if (MRTE_SUCCEEDED(iRetVal)) >+ { >+ // If the class was instrumented, check whether method-level BCI is also needed >+ // and prepare a class buffer for the JVM >+ TResult modifyByteCodesRes; >+ if (m_bInstrGeneratedEventsEnabled) >+ { >+ modifyByteCodesRes = m_pAdaptor->ModifyByteCodes(classId, *pClassWithBasicInstr, >+ pJVMEvent->u.classLoadHook.pfnAllocate, &classToReturnToJVM); >+ } >+ else >+ { >+ // Method-level BCI is not needed (events are not enabled) >+ modifyByteCodesRes = MRTE_ERROR_INSTRUMENTATION_NOT_NEEDED; >+ } > >- // If the class was instrumented, check whether method-level BCI is also needed >- // and prepare a class buffer for the JVM >- SClassFile classToReturnToJVM; >+ // If method-level BCI failed or not needed, use the "basic instrumentation" class image >+ if (MRTE_FAILED(modifyByteCodesRes)) >+ { >+ iRetVal = CopyClassFile(&classToReturnToJVM, *pClassWithBasicInstr, >+ pJVMEvent->u.classLoadHook.pfnAllocate); >+ MARTINI_INFORMATIVE2("CJavaInstrumentorManager", 5, false, >+ "Using basic instrumentation for class %u '%s'", >+ (U32)classId, pJVMEvent->u.classLoadHook.szClassName); >+ } >+ else >+ { >+ MARTINI_INFORMATIVE2("CJavaInstrumentorManager", 5, false, >+ "Using metod-level instrumentation for class %u '%s'", >+ (U32)classId, pJVMEvent->u.classLoadHook.szClassName); > >- if (m_bInstrGeneratedEventsEnabled) >- { >- iRetVal = m_pAdaptor->ModifyByteCodes(classId, *pClassWithBasicInstr, >- pJVMEvent->u.classLoadHook.pfnAllocate, &classToReturnToJVM); >+ } > } > else > { >- iRetVal = CopyClassFile(&classToReturnToJVM, *pClassWithBasicInstr, >- pJVMEvent->u.classLoadHook.pfnAllocate); >+ MARTINI_INFORMATIVE2("CJavaInstrumentorManager", 0, false, >+ "Unable to store basic image of class '%s' in Data Manager. Class id %u is invalid", >+ pJVMEvent->u.classLoadHook.szClassName, (U32)classId); > } > >+ > #ifdef DUMP_CLASS > char szDumpFileName[1000]; > sprintf(szDumpFileName, "%s@%p", pJVMEvent->u.classLoadHook.szClassName, >@@ -1113,6 +1140,9 @@ > // Return the instrumented class file to the JVM > *pJVMEvent->u.classLoadHook.ppucNewClassData = classToReturnToJVM.pClassFile; > *pJVMEvent->u.classLoadHook.pNewClassDataLen = classToReturnToJVM.uiSize; >+ MARTINI_INFORMATIVE2("CJavaInstrumentorManager", 5, false, >+ "Instrumented class %u '%s' will be returned to JVM", >+ (U32)classId, pJVMEvent->u.classLoadHook.szClassName); > } > else > { >@@ -1120,9 +1150,9 @@ > SetClassFileNotInstrumented(pJVMEvent); > if (MRTE_ERROR_FAIL == iRetVal) > { >- MARTINI_INFORMATIVE1("CJavaInstrumentorManager", 0, false, >- "Class '%s' was not instrumneted due to instrumentation errors", >- pJVMEvent->u.classLoadHook.szClassName); >+ MARTINI_INFORMATIVE2("CJavaInstrumentorManager", 0, false, >+ "Class %u '%s' was not instrumneted due to instrumentation errors", >+ (U32)classId, pJVMEvent->u.classLoadHook.szClassName); > } > } > } >@@ -1207,7 +1237,9 @@ > return iRes; > } > >- // Instrument classes >+ // Iterate the list of classes, instrument and queue for redefinition only classes >+ // that have valid JNI reference and basic instrumentation image >+ > TJvmtiClassDefVector vecClassesToRedefine; > vecClassesToRedefine.Reserve(pClassIdList->Count()); > >@@ -1231,7 +1263,13 @@ > MARTINI_INFORMATIVE1("CJavaInstrumentorManager", 5, false, > "Class '%s' added to redefinition list", > strNativeClassName.Get()); >- >+ } >+ else if (MRTE_ERROR_INSTRUMENTATION_NOT_NEEDED == iRes >+ || MRTE_ERROR_UNABLE_TO_INSTRUMENT == iRes) >+ { >+ MARTINI_INFORMATIVE1("CJavaInstrumentorManager", 5, false, >+ "Class '%s' will not be redefined due to user-defined filters or an internal reason", >+ strNativeClassName.Get()); > } > else > { >@@ -1316,6 +1354,16 @@ > // adaptor is always used, regardless of the specified group. > // This is OK since this version supports only one adaptor (either Heap or > // Call Graph) >+ >+ if (m_pDataManager->AreEventsEnabledForClass(classId) == bEnabled) >+ { >+ // No need to instrument this class as its events status matches the desired status >+ >+ // NOTE: this implementation assumes that different filters cannot be applied without >+ // disabling events and then enabling them again. >+ return MRTE_ERROR_INSTRUMENTATION_NOT_NEEDED; >+ } >+ > SClassFile classWithBasicInstr; > MCString strNativeClassName; > TMemoryAllocatorFunc funcAllocator = m_pJVM->GetMemoryAllocator(); >@@ -1329,7 +1377,7 @@ > } > if (bEnabled) > { >- // Apply call-graph instrumentation to the class >+ // Apply method-level instrumentation to the class > iRes = m_pAdaptor->ModifyByteCodes(classId, classWithBasicInstr, funcAllocator, > pInstrumentedClass); > } >@@ -1478,13 +1526,5 @@ > assert(classDef.class_bytes); > pClassRedefQueue->Push(classDef); > } >- else >- { >- if (MRTE_ERROR_INSTRUMENTATION_NOT_NEEDED != iRes >- && MRTE_ERROR_UNABLE_TO_INSTRUMENT != iRes) >- { >- iRes = MRTE_ERROR_FAIL; >- } >- } > return iRes; > } >Index: src-native/src/Martini/Infrastructure/Include/InstrumentationAdaptor.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/Include/InstrumentationAdaptor.h,v >retrieving revision 1.3 >diff -u -r1.3 InstrumentationAdaptor.h >--- src-native/src/Martini/Infrastructure/Include/InstrumentationAdaptor.h 20 Feb 2007 12:00:34 -0000 1.3 >+++ src-native/src/Martini/Infrastructure/Include/InstrumentationAdaptor.h 27 Jan 2008 19:16:22 -0000 >@@ -222,7 +222,8 @@ > * > * @retval MRTE_ERROR_INSTRUMENTATION_NOT_NEEDED The class was not instrumented > * at all. This value is returned >- * for interface classes. >+ * for interface classes or when all >+ * methods were filtered-out > * > * @retval MRTE_ERROR_UNABLE_TO_INSTRUMENT The class cannot be instrumented. > * This value is returned for classes >Index: src-native/src/Martini/Infrastructure/HeapAdaptor/HeapAdaptor.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/Martini/Infrastructure/HeapAdaptor/HeapAdaptor.cpp,v >retrieving revision 1.8 >diff -u -r1.8 HeapAdaptor.cpp >--- src-native/src/Martini/Infrastructure/HeapAdaptor/HeapAdaptor.cpp 29 Apr 2007 11:40:53 -0000 1.8 >+++ src-native/src/Martini/Infrastructure/HeapAdaptor/HeapAdaptor.cpp 27 Jan 2008 19:16:22 -0000 >@@ -440,6 +440,7 @@ > "sun/reflect/Generated", // Classes generated during runtime to > // support reflection > "com/Intel/VTune/VTuneAPI", // VTune API Proxy class >+ "java/lang/", // Patch to IBM redefinition problem > "org/eclipse/hyades/collection/profiler" // TPTP Profiler API Proxy class > }; > >@@ -747,7 +748,7 @@ > res = pMethod->AddLocalVariable(&(op.val.varID), VT_REFERENCE); > if (MRTE_FAILED(res)) > { >- LOG_ERROR3("CHeapAdaptor", "Failed to create a local varible for " >+ LOG_ERROR3("CHeapAdaptor", "Failed to create a local variable for " > "storing uninitialized object reference. Method %s.%s(%s)", > classInfo.szClassName, > pMethodInstrumentationInfo->szName,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 215437
:
87565
| 87977