Search in sources :

Example 66 with CorruptData

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

the class InfoProcCommand method printThreads.

private void printThreads() {
    ImageProcess ip = ctx.getProcess();
    out.print("\t Native thread IDs:");
    out.print("\n\t  ");
    // normal tab plus 2 spaces
    int lineLength = 10;
    // FIXME: should output architecture (32/64-bit), endianness before threads
    Iterator<?> itThread = ip.getThreads();
    while (itThread.hasNext()) {
        Object next = itThread.next();
        if (next instanceof CorruptData) {
            out.print("\n\t  <corrupt data>");
            continue;
        }
        ImageThread it = (ImageThread) next;
        try {
            String threadID = it.getID();
            if (threadID != null) {
                if (lineLength + threadID.length() > 80) {
                    out.print("\n\t  ");
                    lineLength = 10;
                }
                out.print(it.getID() + " ");
                lineLength += threadID.length() + 1;
            }
        } catch (CorruptDataException e) {
            out.print(Exceptions.getCorruptDataExceptionString());
        }
    }
    out.print("\n");
}
Also used : ImageProcess(com.ibm.dtfj.image.ImageProcess) CorruptData(com.ibm.dtfj.image.CorruptData) ImageThread(com.ibm.dtfj.image.ImageThread) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 67 with CorruptData

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

the class XJCommand method printObjectsFromName.

private void printObjectsFromName(JavaHeap jh, String objName, PrintStream out, boolean supers, JavaRuntime jr) {
    if (objName != null) {
        JavaClass[] classes = Utils.getClassGivenName(objName, jr, out);
        // still be an array type or it might not exist
        if (classes == null || classes.length == 0) {
            out.print("\t  could not find class with name \"" + objName + "\"\n\n");
            return;
        }
        for (int i = 0; i < classes.length; i++) {
            boolean foundInstance = false;
            JavaClass objClass = classes[i];
            if (classes.length > 1) {
                ClassOutput.printRuntimeClassAndLoader(objClass, out);
            }
            ClassOutput.printStaticFields(objClass, out);
            Iterator<?> itObject = jh.getObjects();
            int corruptObjectCount = 0;
            while (itObject.hasNext()) {
                Object obj = itObject.next();
                if (obj instanceof CorruptData) {
                    // skip the corrupt object
                    corruptObjectCount++;
                    continue;
                }
                JavaObject jo = (JavaObject) obj;
                String hierarchy = "";
                JavaClass jc;
                try {
                    jc = jo.getJavaClass();
                } catch (CorruptDataException e) {
                    out.print("\t  <error getting class while traversing objects: ");
                    out.print(Exceptions.getCorruptDataExceptionString());
                    out.print(">\n");
                    jc = null;
                }
                boolean foundSuperclass = false;
                while (jc != null && !foundSuperclass) {
                    String className;
                    try {
                        className = jc.getName();
                    } catch (CorruptDataException e) {
                        out.print("\t  <error getting class name while traversing objects: ");
                        out.print(Exceptions.getCorruptDataExceptionString());
                        out.print(">\n");
                        jc = null;
                        continue;
                    }
                    if (hierarchy.equals("")) {
                        hierarchy = className;
                    } else {
                        hierarchy = className + " => " + hierarchy;
                    }
                    if (jc.equals(objClass)) {
                        foundInstance = true;
                        foundSuperclass = true;
                        out.print("\t  ");
                        out.print(hierarchy);
                        out.print(" @ ");
                        out.print(Utils.toHex(jo.getID().getAddress()));
                        out.print("\n");
                        ClassOutput.printFields(jo, jc, jr, out);
                        printReferences(jo, out);
                    } else {
                        if (supers) {
                            try {
                                jc = jc.getSuperclass();
                            } catch (CorruptDataException e) {
                                out.print("\t  <error getting superclass while traversing objects: ");
                                out.print(Exceptions.getCorruptDataExceptionString());
                                out.print(">\n");
                                jc = null;
                            }
                        } else {
                            jc = null;
                        }
                    }
                }
            }
            if (!foundInstance) {
                out.print("\t  <no object of class \"");
                out.print(objName);
                out.print("\" exists>\n\n");
            }
            if (corruptObjectCount != 0) {
                out.println("\t Warning : " + corruptObjectCount + " corrupt objects were skipped\n");
            }
        }
    }
}
Also used : JavaClass(com.ibm.dtfj.java.JavaClass) JavaObject(com.ibm.dtfj.java.JavaObject) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 68 with CorruptData

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

the class XJCommand method printObjectsFromAddress.

private void printObjectsFromAddress(JavaHeap jh, Long objAddress, PrintStream out, JavaRuntime jr) {
    JavaObject jo;
    Iterator<?> itObject = jh.getObjects();
    boolean found = false;
    boolean done = false;
    int corruptObjectCount = 0;
    while (itObject.hasNext() && !done) {
        Object obj = itObject.next();
        if (obj instanceof CorruptData) {
            // skip the corrupt object
            corruptObjectCount++;
            continue;
        }
        jo = (JavaObject) obj;
        if (jo.getID().getAddress() == objAddress.longValue()) {
            JavaClass jc;
            found = true;
            out.print("\t  ");
            try {
                jc = jo.getJavaClass();
            } catch (CorruptDataException e) {
                out.print("\t  <error getting class while traversing objects: ");
                out.print(Exceptions.getCorruptDataExceptionString());
                out.print(">");
                jc = null;
            }
            if (null != jc) {
                try {
                    out.print(jc.getName());
                } catch (CorruptDataException e) {
                    out.print("\t  <error getting class name while traversing objects: ");
                    out.print(Exceptions.getCorruptDataExceptionString());
                    out.print(">");
                }
                out.print(" @ ");
                out.print(Utils.toHex(objAddress.longValue()));
                out.print("\n");
                ClassOutput.printFields(jo, jc, jr, out);
                printReferences(jo, out);
                // assumes only one object can exist at a specific memory address
                done = true;
            }
        }
    }
    if (!found) {
        out.print("\t  <no object found at address ");
        out.print(Utils.toHex(objAddress.longValue()));
        out.print(">\n\n");
    }
    if (corruptObjectCount != 0) {
        out.println("\t Warning : " + corruptObjectCount + " corrupt objects were skipped\n");
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

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