Search in sources :

Example 41 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaObject method getSections.

public Iterator getSections() {
    try {
        fetchDeferredData();
        LinkedList<ImageSection> sections = new LinkedList<ImageSection>();
        long mainSectionSize = ObjectModel.getConsumedSizeInBytesWithHeader(object).longValue();
        String name = getSectionName(mainSectionSize);
        J9DDRImageSection section = DTFJContext.getImageSection(object.getAddress(), name);
        section.setSize(mainSectionSize);
        sections.add(section);
        return sections.iterator();
    } catch (CorruptDataException e) {
        return corruptIterator(e.getCorruptData());
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        return corruptIterator(cd);
    }
}
Also used : J9DDRImageSection(com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection) ImageSection(com.ibm.dtfj.image.ImageSection) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) LinkedList(java.util.LinkedList) J9DDRImageSection(com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)

Example 42 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaObject method getReferences.

@SuppressWarnings("rawtypes")
public Iterator getReferences() {
    boolean isClass = false;
    boolean isClassLoader = false;
    boolean isWeakReference = false;
    boolean isSoftReference = false;
    boolean isPhantomReference = false;
    if (null == references) {
        references = new LinkedList<Object>();
        try {
            // find this object's class
            JavaClass jClass = getJavaClass();
            // add a reference to the object's class
            if (null != jClass) {
                JavaReference ref = new DTFJJavaReference(this, jClass, "Class", JavaReference.REFERENCE_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                references.add(ref);
            }
            if (isArray()) {
                if (isObjectArray()) {
                    addObjectArrayReferences();
                }
            } else {
                isClass = (jClass != null) && jClass.getName().equals("java/lang/Class");
                List<JavaClass> superClasses = new LinkedList<JavaClass>();
                // Do superclass walk
                while (jClass != null) {
                    String className = jClass.getName();
                    isClassLoader |= className.equals("java/lang/ClassLoader");
                    isWeakReference |= className.equals("java/lang/ref/WeakReference");
                    isSoftReference |= className.equals("java/lang/ref/SoftReference");
                    isPhantomReference |= className.equals("java/lang/ref/PhantomReference");
                    superClasses.add(jClass);
                    jClass = jClass.getSuperclass();
                }
                int reachability = isWeakReference ? JavaReference.REACHABILITY_WEAK : isSoftReference ? JavaReference.REACHABILITY_SOFT : isPhantomReference ? JavaReference.REACHABILITY_PHANTOM : JavaReference.REACHABILITY_STRONG;
                for (JavaClass clazz : superClasses) {
                    addFieldReferences(clazz, reachability);
                }
            }
        } catch (CorruptDataException e) {
            // Corrupt data, so add it to the container.
            references.add(e.getCorruptData());
        } catch (Throwable t) {
            CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
            references.add(cd);
        }
        // Now add association-specific references
        if (isClassLoader) {
            try {
                JavaClassLoader associatedClassLoader = getAssociatedClassLoader();
                if (associatedClassLoader != null) {
                    for (Iterator classes = associatedClassLoader.getDefinedClasses(); classes.hasNext(); ) {
                        Object potentialClass = classes.next();
                        if (potentialClass instanceof JavaClass) {
                            JavaClass currentClass = (JavaClass) potentialClass;
                            JavaReference ref = new DTFJJavaReference(this, currentClass, "Loaded class", JavaReference.REFERENCE_LOADED_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                            references.add(ref);
                        }
                    }
                } else {
                    references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Couldn't find associated JavaClassLoader for classloader object " + this));
                }
            } catch (Throwable t) {
                CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                references.add(cd);
            }
        }
        if (isClass) {
            try {
                JavaClass associatedClass = getAssociatedClass();
                if (associatedClass != null) {
                    JavaReference ref = new DTFJJavaReference(this, associatedClass, "Associated class", JavaReference.REFERENCE_ASSOCIATED_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                    references.add(ref);
                } else {
                    // No associated class found. For anonymous classes this is expected, the class is not defined in a classloader.
                    J9ClassPointer j9Class = ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object);
                    if (!J9ClassHelper.isAnonymousClass(j9Class)) {
                        // Not an anonymous class, so something is wrong/damaged, add a corrupt data object to the references list
                        references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Couldn't find associated JavaClass for Class object " + this));
                    }
                }
            } catch (Throwable t) {
                CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                references.add(cd);
            }
        }
    }
    return references.iterator();
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) LinkedList(java.util.LinkedList) JavaReference(com.ibm.dtfj.java.JavaReference) JavaClass(com.ibm.dtfj.java.JavaClass) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) J9DDRDTFJUtils.corruptIterator(com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Example 43 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaMethod method getCompiledSections.

@SuppressWarnings("rawtypes")
public Iterator getCompiledSections() {
    if (compiledSections == null) {
        compiledSections = new ArrayList<Object>();
        List<J9JITExceptionTablePointer> metaDatas = DTFJContext.getJITMetaData(j9ramMethod);
        if (metaDatas != null) {
            for (J9JITExceptionTablePointer metaData : metaDatas) {
                // There is always a warm region
                try {
                    long start = metaData.startPC().longValue();
                    long size = metaData.endWarmPC().longValue() - start;
                    String name = String.format("jit section (%s) at %s", metaData.getAddress(), start);
                    J9DDRImageSection is = DTFJContext.getImageSection(start, name);
                    is.setSize(size);
                    compiledSections.add(is);
                } catch (Throwable t) {
                    CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                    compiledSections.add(cd);
                }
                // JEXTRACT never considered the cold region.  Leading to results where JEXTRACT could report 1 section and DTFJ will report 2.
                try {
                    long start = metaData.startColdPC().longValue();
                    if (start != 0) {
                        long size = metaData.endPC().longValue() - start;
                        String name = String.format("cold jit section (%s) at %s", metaData.getAddress(), start);
                        J9DDRImageSection is = DTFJContext.getImageSection(start, name);
                        is.setSize(size);
                        compiledSections.add(is);
                    }
                } catch (Throwable t) {
                    CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                    compiledSections.add(cd);
                }
            }
        }
    }
    return compiledSections.iterator();
}
Also used : J9JITExceptionTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9JITExceptionTablePointer) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRImageSection(com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)

Example 44 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaThread method walkSections.

private void walkSections() {
    sections = new ArrayList<Object>();
    J9JavaStackIterator stacks;
    try {
        stacks = J9JavaStackIterator.fromJ9JavaStack(thread.stackObject());
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        sections.add(cd);
        return;
    }
    // JEXTRACT seems to be hard coded to only return 1 stack section ... walking the stack finds more than one.
    int count = 0;
    while (stacks.hasNext() && count < 1) {
        J9JavaStackPointer stack = stacks.next();
        try {
            long size = stack.size().longValue();
            long baseAddress = stack.end().longValue() - size;
            J9DDRImageSection newSection = DTFJContext.getImageSection(baseAddress, getSectionName());
            newSection.setSize(size);
            sections.add(newSection);
            count++;
        } catch (Throwable t) {
            CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
            sections.add(cd);
        }
    }
}
Also used : J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) J9JavaStackIterator(com.ibm.j9ddr.vm29.j9.J9JavaStackIterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) J9DDRImageSection(com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)

Example 45 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaRuntime method getThreads.

@SuppressWarnings("rawtypes")
public Iterator getThreads() {
    GCVMThreadListIterator threadIterator;
    try {
        threadIterator = GCVMThreadListIterator.from();
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        return corruptIterator(cd);
    }
    List<Object> toIterate = new LinkedList<Object>();
    AddCorruptionToListListener listener = new AddCorruptionToListListener(toIterate);
    register(listener);
    try {
        while (threadIterator.hasNext() && !listener.fatalCorruption()) {
            J9VMThreadPointer next = threadIterator.next();
            if (next != null) {
                toIterate.add(new DTFJJavaThread(next));
            }
        }
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        toIterate.add(cd);
    }
    unregister(listener);
    return toIterate.iterator();
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) JavaObject(com.ibm.dtfj.java.JavaObject) AddCorruptionToListListener(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.AddCorruptionToListListener) LinkedList(java.util.LinkedList)

Aggregations

CorruptData (com.ibm.dtfj.image.CorruptData)68 JavaObject (com.ibm.dtfj.java.JavaObject)43 Iterator (java.util.Iterator)36 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)29 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)19 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)15 JavaClass (com.ibm.dtfj.java.JavaClass)11 JavaReference (com.ibm.dtfj.java.JavaReference)10 ImageProcess (com.ibm.dtfj.image.ImageProcess)9 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)7 LongListReferenceIterator (com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator)7 ReferenceIterator (com.ibm.jvm.dtfjview.heapdump.ReferenceIterator)7 ImageSection (com.ibm.dtfj.image.ImageSection)6 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)6 JavaHeap (com.ibm.dtfj.java.JavaHeap)6 J9Object (com.ibm.j9ddr.vm29.structure.J9Object)6 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)5 ImageThread (com.ibm.dtfj.image.ImageThread)5 JavaThread (com.ibm.dtfj.java.JavaThread)5 J9DDRImageSection (com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)5