Search in sources :

Example 56 with CorruptData

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

the class PHDJavaClass method referencesClass.

/**
 * Is there a reference from one class to another?
 * E.g. from an array class to the component type? This would be an indication that they
 * are truly related.
 * @param from
 * @param to
 * @return
 */
static boolean referencesClass(JavaClass from, JavaClass to) {
    for (Iterator i1 = from.getReferences(); i1.hasNext(); ) {
        Object o = i1.next();
        if (o instanceof CorruptData)
            continue;
        JavaReference jr = (JavaReference) o;
        try {
            if (jr.isClassReference() && jr.getTarget().equals(to)) {
                return true;
            }
            if (jr.isObjectReference() && jr.getTarget().equals(to.getObject())) {
                return true;
            }
        } catch (DataUnavailable e) {
        } catch (CorruptDataException e) {
        }
    }
    return false;
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 57 with CorruptData

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

the class PHDJavaRuntime method prepThreads.

/**
 * Remember objects associated with threads.
 * Performance optimization - we can then find these objects on a scan through the heap
 * and remember them, saving a fruitless search of the heap if they only exist in a javacore.
 */
private void prepThreads() {
    if (metaJavaRuntime != null) {
        final PHDJavaClassLoader boot = loaders.get(null);
        for (Iterator it = metaJavaRuntime.getThreads(); it.hasNext(); ) {
            Object next = it.next();
            if (next instanceof CorruptData)
                continue;
            JavaThread thr = (JavaThread) next;
            try {
                JavaObject jo = thr.getObject();
                saveExtraObject(boot, jo);
            } catch (CorruptDataException e) {
            }
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 58 with CorruptData

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

the class HeapdumpCommand method dumpMultipleHeapsInSeparateFiles.

private void dumpMultipleHeapsInSeparateFiles(JavaRuntime runtime, String version, boolean is64Bit, boolean phdFormat, String baseFileName, Set heapsToDump) throws IOException {
    Iterator heapIterator = runtime.getHeaps();
    HeapDumpFormatter formatter = null;
    while (heapIterator.hasNext()) {
        Object thisHeapObj = heapIterator.next();
        if (thisHeapObj instanceof CorruptData) {
            out.println("Heap corrupted at: " + ((CorruptData) thisHeapObj).getAddress());
            _numberOfErrors++;
            continue;
        }
        JavaHeap thisHeap = (JavaHeap) thisHeapObj;
        // Create a new heapdump formatter for every heap we find
        if (formatter != null) {
            formatter.close();
        }
        if (heapsToDump.size() > 0 && !heapsToDump.contains(thisHeap.getName())) {
            continue;
        }
        String fileName = getFileNameForHeap(thisHeap, baseFileName);
        out.print("Writing " + (phdFormat ? "PHD" : "Classic") + " format heapdump for heap " + thisHeap.getName() + " into " + fileName + "\n");
        formatter = getFormatter(fileName, version, is64Bit, phdFormat);
        // We have to dump classes in every heapdump
        dumpClasses(formatter, runtime);
        dumpHeap(formatter, thisHeap);
    }
    if (formatter != null) {
        formatter.close();
    }
}
Also used : PortableHeapDumpFormatter(com.ibm.jvm.dtfjview.heapdump.portable.PortableHeapDumpFormatter) ClassicHeapDumpFormatter(com.ibm.jvm.dtfjview.heapdump.classic.ClassicHeapDumpFormatter) HeapDumpFormatter(com.ibm.jvm.dtfjview.heapdump.HeapDumpFormatter) JavaHeap(com.ibm.dtfj.java.JavaHeap) ReferenceIterator(com.ibm.jvm.dtfjview.heapdump.ReferenceIterator) Iterator(java.util.Iterator) LongListReferenceIterator(com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData)

Example 59 with CorruptData

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

the class HeapdumpCommand method dumpMultipleHeapsInOneFile.

private void dumpMultipleHeapsInOneFile(JavaRuntime runtime, String version, boolean is64Bit, boolean phdFormat, String filename, Set heapsToDump) throws IOException {
    Iterator heapIterator = runtime.getHeaps();
    HeapDumpFormatter formatter = getFormatter(filename, version, is64Bit, phdFormat);
    out.println("Writing " + (phdFormat ? "PHD" : "Classic") + " format heapdump into " + filename);
    while (heapIterator.hasNext()) {
        Object thisHeapObj = heapIterator.next();
        if (thisHeapObj instanceof CorruptData) {
            out.println("Corrupt heap data found at: " + ((CorruptData) thisHeapObj).getAddress());
            _numberOfErrors++;
            continue;
        }
        JavaHeap thisHeap = (JavaHeap) thisHeapObj;
        if (heapsToDump.size() > 0 && !heapsToDump.contains(thisHeap.getName())) {
            continue;
        }
        dumpHeap(formatter, thisHeap);
    }
    dumpClasses(formatter, runtime);
    formatter.close();
}
Also used : PortableHeapDumpFormatter(com.ibm.jvm.dtfjview.heapdump.portable.PortableHeapDumpFormatter) ClassicHeapDumpFormatter(com.ibm.jvm.dtfjview.heapdump.classic.ClassicHeapDumpFormatter) HeapDumpFormatter(com.ibm.jvm.dtfjview.heapdump.HeapDumpFormatter) JavaHeap(com.ibm.dtfj.java.JavaHeap) ReferenceIterator(com.ibm.jvm.dtfjview.heapdump.ReferenceIterator) Iterator(java.util.Iterator) LongListReferenceIterator(com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData)

Example 60 with CorruptData

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

the class HeapdumpCommand method dumpClasses.

/**
 * Walks the runtime classes and passes them through the formatter interface
 */
private void dumpClasses(HeapDumpFormatter formatter, JavaRuntime runtime) throws IOException {
    Iterator classLoaderIt = runtime.getJavaClassLoaders();
    int numberOfClasses = 0;
    ITERATING_LOADERS: while (classLoaderIt.hasNext()) {
        Object potential = classLoaderIt.next();
        if (potential instanceof CorruptData) {
            _numberOfErrors++;
            reportError("CorruptData found in classloader list at address: " + ((CorruptData) potential).getAddress(), null);
            continue ITERATING_LOADERS;
        }
        JavaClassLoader thisClassLoader = (JavaClassLoader) potential;
        Iterator classesIt = thisClassLoader.getDefinedClasses();
        ITERATING_CLASSES: while (classesIt.hasNext()) {
            potential = classesIt.next();
            numberOfClasses++;
            try {
                if (potential instanceof CorruptData) {
                    _numberOfErrors++;
                    reportError("CorruptData found in class list for classloader " + Long.toHexString(thisClassLoader.getObject().getID().getAddress()) + " at address: " + ((CorruptData) potential).getAddress(), null);
                    continue ITERATING_CLASSES;
                }
                JavaClass thisJavaClass = (JavaClass) potential;
                JavaClass superClass = thisJavaClass.getSuperclass();
                JavaObject classObject = thisJavaClass.getObject();
                long instanceSize;
                if (thisJavaClass.isArray()) {
                    instanceSize = 0;
                } else {
                    instanceSize = thisJavaClass.getInstanceSize();
                }
                int hashcode = 0;
                if (_is32BitHash) {
                    // JVMs from 2.6 on, optional 32-bit hashcodes, if object was hashed
                    try {
                        hashcode = classObject != null ? (int) classObject.getPersistentHashcode() : 0;
                    } catch (DataUnavailable ex) {
                    // no persistent hashcode for this object, pass hashcode=0 to the heapdump formatter
                    }
                } else {
                    // JVMs prior to 2.6, all objects should have a 16-bit hashcode
                    hashcode = classObject != null ? (int) classObject.getHashcode() : 0;
                }
                formatter.addClass(classObject.getID().getAddress(), thisJavaClass.getName(), superClass != null ? superClass.getID().getAddress() : 0, classObject != null ? (int) classObject.getSize() : 0, instanceSize, hashcode, getClassReferences(thisJavaClass));
            } catch (DTFJException ex) {
                // Handle CorruptDataException and DataUnavailableException the same way
                _numberOfErrors++;
                reportError(null, ex);
                continue ITERATING_CLASSES;
            }
        }
    }
    _numberOfClasses = numberOfClasses;
    if ((pdSkipCount > 0) && _verbose) {
        out.println("Warning : The protection domain information was not available for " + pdSkipCount + " classes");
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) JavaObject(com.ibm.dtfj.java.JavaObject) DTFJException(com.ibm.dtfj.image.DTFJException) ReferenceIterator(com.ibm.jvm.dtfjview.heapdump.ReferenceIterator) Iterator(java.util.Iterator) LongListReferenceIterator(com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData)

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