Search in sources :

Example 6 with JavaMethod

use of com.ibm.dtfj.java.JavaMethod in project openj9 by eclipse.

the class WhatisCommand method isWithinImageSections.

private boolean isWithinImageSections(Iterator heapImageSections, Object memType, boolean isMethodCompiled, long address) {
    while (heapImageSections.hasNext()) {
        ImageSection imageSection = (ImageSection) heapImageSections.next();
        long baseAddress = imageSection.getBaseAddress().getAddress();
        long size = imageSection.getSize();
        long endAddress = baseAddress + size;
        if (address <= endAddress && address >= baseAddress) {
            if (null == memType) {
                out.print("\t\t0x" + Long.toHexString(address) + " is within heap segment: " + Long.toHexString(baseAddress) + " -- " + Long.toHexString(endAddress) + "\n");
                return true;
            }
            if (memType instanceof JavaMethod) {
                String methodName = "N/A", methodSig = "N/A", className = "N/A";
                try {
                    methodName = ((JavaMethod) memType).getName();
                    methodSig = ((JavaMethod) memType).getSignature();
                    className = ((JavaMethod) memType).getDeclaringClass().getName();
                } catch (CorruptDataException cde) {
                } catch (DataUnavailable du) {
                }
                String codeType = isMethodCompiled ? "compiled code" : "byte code";
                out.print("\t0x" + Long.toHexString(address) + " is within the " + codeType + " range: " + Long.toHexString(baseAddress) + " -- " + Long.toHexString(endAddress) + "\n\t" + "...of method " + methodName + " with signature " + methodSig + "\n\t" + "...in class " + className + "\n");
                return true;
            }
        }
    }
    return false;
}
Also used : ImageSection(com.ibm.dtfj.image.ImageSection) JavaMethod(com.ibm.dtfj.java.JavaMethod) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 7 with JavaMethod

use of com.ibm.dtfj.java.JavaMethod in project openj9 by eclipse.

the class WhatisCommand method checkMethodInRange.

private void checkMethodInRange(Iterator objects, long address) {
    while (objects.hasNext()) {
        JavaObject jObject = (JavaObject) objects.next();
        JavaClass jClass;
        try {
            jClass = jObject.getJavaClass();
        } catch (CorruptDataException cde) {
            // go to the next iteration
            continue;
        }
        Iterator methods = jClass.getDeclaredMethods();
        while (methods.hasNext()) {
            JavaMethod jMethod = (JavaMethod) methods.next();
            Iterator bytecodeSections = jMethod.getBytecodeSections();
            Iterator compiledSections = jMethod.getCompiledSections();
            if (isWithinImageSections(bytecodeSections, jMethod, false, address)) {
                // found it, we are done
                return;
            }
            if (isWithinImageSections(compiledSections, jMethod, true, address)) {
                // found it, we are done
                return;
            }
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) JavaMethod(com.ibm.dtfj.java.JavaMethod) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 8 with JavaMethod

use of com.ibm.dtfj.java.JavaMethod in project openj9 by eclipse.

the class InfoJitmCommand method showJITdMethods.

private void showJITdMethods() {
    JavaRuntime jr = ctx.getRuntime();
    Iterator itJavaClassLoader = jr.getJavaClassLoaders();
    while (itJavaClassLoader.hasNext()) {
        JavaClassLoader jcl = (JavaClassLoader) itJavaClassLoader.next();
        Iterator itJavaClass = jcl.getDefinedClasses();
        while (itJavaClass.hasNext()) {
            JavaClass jc = (JavaClass) itJavaClass.next();
            Iterator itJavaMethod = jc.getDeclaredMethods();
            String jcName;
            try {
                jcName = jc.getName();
            } catch (CorruptDataException e) {
                jcName = Exceptions.getCorruptDataExceptionString();
            }
            while (itJavaMethod.hasNext()) {
                JavaMethod jm = (JavaMethod) itJavaMethod.next();
                String name;
                String sig;
                try {
                    name = jm.getName();
                } catch (CorruptDataException e) {
                    name = Exceptions.getCorruptDataExceptionString();
                }
                try {
                    sig = jm.getSignature();
                } catch (CorruptDataException e) {
                    sig = Exceptions.getCorruptDataExceptionString();
                }
                if (jm.getCompiledSections().hasNext()) {
                    Iterator itImageSection = jm.getCompiledSections();
                    while (itImageSection.hasNext()) {
                        ImageSection is = (ImageSection) itImageSection.next();
                        long startAddr = is.getBaseAddress().getAddress();
                        long size = is.getSize();
                        long endAddr = startAddr + size;
                        out.print("\n\t" + "start=" + Utils.toHex(startAddr) + "  " + "end=" + Utils.toHex(endAddr) + "   " + jcName + "::" + name + sig);
                    }
                }
            }
        }
    }
    out.print("\n");
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) JavaMethod(com.ibm.dtfj.java.JavaMethod) ImageSection(com.ibm.dtfj.image.ImageSection) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Aggregations

JavaMethod (com.ibm.dtfj.java.JavaMethod)8 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)6 ImageSection (com.ibm.dtfj.image.ImageSection)4 Iterator (java.util.Iterator)4 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)3 JavaClass (com.ibm.dtfj.java.JavaClass)3 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)2 JavaObject (com.ibm.dtfj.java.JavaObject)2 CorruptData (com.ibm.dtfj.image.CorruptData)1 ImagePointer (com.ibm.dtfj.image.ImagePointer)1 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)1 JavaReference (com.ibm.dtfj.java.JavaReference)1 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)1 PortableHeapDumpListener (com.ibm.dtfj.phd.parser.PortableHeapDumpListener)1 LongEnumeration (com.ibm.dtfj.phd.util.LongEnumeration)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Test (org.junit.Test)1