Search in sources :

Example 11 with JavaHeap

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

the class JavaObjectTest method loadTestObjects.

protected void loadTestObjects(JavaRuntime ddrRuntime, List<Object> ddrObjects, JavaRuntime jextractRuntime, List<Object> jextractObjects) {
    List<Object> ddrHeaps = new ArrayList<Object>();
    List<Object> jextractHeaps = new ArrayList<Object>();
    gcpolicy = getVMoption(ddrRuntime, "-Xgcpolicy:");
    if (gcpolicy.equals("gencon")) {
        ddrHeaps.add(ddrRuntime.getHeaps().next());
        jextractHeaps.add(jextractRuntime.getHeaps().next());
    } else {
        fillLists(ddrHeaps, ddrRuntime.getHeaps(), jextractHeaps, jextractRuntime.getHeaps(), null);
    }
    for (int i = 0; i < ddrHeaps.size(); i++) {
        JavaHeap ddrHeap = (JavaHeap) ddrHeaps.get(i);
        JavaHeap jextractHeap = (JavaHeap) jextractHeaps.get(i);
        // this is a very simple grab of the first 10 objects off the heap which are not arrays and comparing them
        fillObjectList(ddrObjects, ddrHeap.getObjects(), jextractObjects, jextractHeap.getObjects(), null, 10, false);
    }
}
Also used : JavaHeap(com.ibm.dtfj.java.JavaHeap) ArrayList(java.util.ArrayList) JavaObject(com.ibm.dtfj.java.JavaObject)

Example 12 with JavaHeap

use of com.ibm.dtfj.java.JavaHeap 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 13 with JavaHeap

use of com.ibm.dtfj.java.JavaHeap 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 14 with JavaHeap

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

the class HeapdumpCommand method heapArgumentsAreValid.

/**
 * Checks the list of heaps to dump as specified by the user.
 * @param runtime Current java runtime
 * @param heapsToDump Set of strings the user passed as heaps to dump
 * @return True if all the names are valid heaps, false otherwise
 */
private boolean heapArgumentsAreValid(JavaRuntime runtime, Set heapsToDump) {
    if (heapsToDump.size() == 0) {
        return true;
    }
    Set workingSet = new HashSet();
    workingSet.addAll(heapsToDump);
    Iterator heapIt = runtime.getHeaps();
    while (heapIt.hasNext()) {
        Object potential = heapIt.next();
        if (potential instanceof JavaHeap) {
            JavaHeap thisHeap = (JavaHeap) potential;
            workingSet.remove(thisHeap.getName());
        } else if (potential instanceof CorruptData) {
            reportError("Corrupt heap found. Address = " + ((CorruptData) potential).getAddress(), null);
            _numberOfErrors++;
        } else {
            _numberOfErrors++;
            reportError("Unexpected type " + potential.getClass().getName() + " found in heap iterator", null);
        }
    }
    if (workingSet.isEmpty()) {
        return true;
    } else {
        StringBuffer buffer = new StringBuffer();
        buffer.append("These specified heaps do not exist:\n");
        Iterator nameIterator = workingSet.iterator();
        while (nameIterator.hasNext()) {
            buffer.append("\t\t" + nameIterator.next() + "\n");
        }
        buffer.append("\tUse \"info heap\" to see list of heap names");
        out.println(buffer.toString());
        return false;
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) 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) HashSet(java.util.HashSet)

Example 15 with JavaHeap

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

the class XJCommand method printHeapObjects.

private void printHeapObjects(Long objAddress, String objName, PrintStream out, boolean supers) {
    JavaRuntime jr = ctx.getRuntime();
    JavaHeap jh;
    Iterator<?> itHeap = jr.getHeaps();
    int count = 1;
    while (itHeap.hasNext()) {
        Object obj = itHeap.next();
        if (obj instanceof JavaHeap) {
            jh = (JavaHeap) obj;
            out.print("\t heap #" + count + " - name: ");
            out.print(jh.getName());
            out.print("\n\n");
            printObjects(jh, objAddress, objName, out, supers, jr);
            count++;
        } else {
            out.println("\t\tWarning : skipping corrupt heap");
        }
    }
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaHeap(com.ibm.dtfj.java.JavaHeap) JavaObject(com.ibm.dtfj.java.JavaObject)

Aggregations

JavaHeap (com.ibm.dtfj.java.JavaHeap)15 Iterator (java.util.Iterator)11 JavaObject (com.ibm.dtfj.java.JavaObject)10 CorruptData (com.ibm.dtfj.image.CorruptData)6 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)4 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)3 ImageSection (com.ibm.dtfj.image.ImageSection)3 LongListReferenceIterator (com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator)3 ReferenceIterator (com.ibm.jvm.dtfjview.heapdump.ReferenceIterator)3 HeapDumpFormatter (com.ibm.jvm.dtfjview.heapdump.HeapDumpFormatter)2 ClassicHeapDumpFormatter (com.ibm.jvm.dtfjview.heapdump.classic.ClassicHeapDumpFormatter)2 PortableHeapDumpFormatter (com.ibm.jvm.dtfjview.heapdump.portable.PortableHeapDumpFormatter)2 ArrayList (java.util.ArrayList)2 ImageProcess (com.ibm.dtfj.image.ImageProcess)1 JavaClass (com.ibm.dtfj.java.JavaClass)1 ManagedRuntime (com.ibm.dtfj.runtime.ManagedRuntime)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Test (org.junit.Test)1