Search in sources :

Example 1 with CorruptDataException

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

the class DTFJHeapUnitTest method generateXML.

@SuppressWarnings("unchecked")
public void generateXML(File path, JavaRuntime rt) throws Exception {
    createWriter(path);
    startTag("<heaps>\n");
    for (Iterator heaps = rt.getHeaps(); heaps.hasNext(); ) {
        JavaHeap heap = (JavaHeap) heaps.next();
        writeIndent();
        startTag("<heap name=\"" + heap.getName() + "\">\n");
        long count = 0;
        for (Iterator objects = heap.getObjects(); objects.hasNext(); count++) {
            try {
                JavaObject obj = (JavaObject) objects.next();
                if (((count % 100) == 0) || (obj.isArray())) {
                    writeObject(obj, count);
                }
            } catch (CorruptDataException e) {
                write("<!-- corrupt object @ " + e.getCorruptData().getAddress() + " -->");
            }
        }
        startTag("<objects count=\"" + count + "\">\n");
        endTag("</objects>\n");
        endTag("</heap>\n");
    }
    endTag("</heaps>\n");
    closeWriter();
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaHeap(com.ibm.dtfj.java.JavaHeap) Iterator(java.util.Iterator) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 2 with CorruptDataException

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

the class JavaThreadTest method getImageThreadTest.

@Test
public // JEXTRACT: only EVER throws DataUnavailableException with TCK core.  We do better.
void getImageThreadTest() {
    for (int i = 0; i < jextractTestObjects.size(); i++) {
        JavaThread t1 = (JavaThread) jextractTestObjects.get(i);
        ImageThread i1;
        try {
            i1 = (ImageThread) t1.getImageThread();
        // System.out.println(i1.getID());
        } catch (CorruptDataException e) {
            System.out.println("CDE on thread: " + i);
        } catch (DataUnavailable e) {
            System.out.println("DUA on thread: " + i);
        }
    }
    imageThreadComparator.testComparatorEquals(ddrTestObjects, jextractTestObjects, "getImageThread");
}
Also used : JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) ImageThread(com.ibm.dtfj.image.ImageThread) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Test(org.junit.Test)

Example 3 with CorruptDataException

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

the class JCImageProcess method getCurrentThread.

/**
 */
public ImageThread getCurrentThread() throws CorruptDataException {
    ImageThread currentThread = null;
    if (fCurrentThreadID != IBuilderData.NOT_AVAILABLE) {
        // Return the indicated thread
        ImagePointer ip = fImageAddressSpace.getPointer(fCurrentThreadID);
        currentThread = getImageThread(ip);
        if (currentThread == null) {
            throw new CorruptDataException(new JCCorruptData("Bad native thread ID", ip));
        }
    }
    return currentThread;
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) ImageThread(com.ibm.dtfj.image.ImageThread) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 4 with CorruptDataException

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

the class ImageProcess method getCurrentThread.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.image.ImageProcess#getCurrentThread()
	 */
public com.ibm.dtfj.image.ImageThread getCurrentThread() throws CorruptDataException {
    ImageThread current = _currentThread;
    if (0 != _faultingNativeID) {
        // look up this thread
        Iterator threads = getThreads();
        while (threads.hasNext()) {
            Object next = threads.next();
            if (next instanceof CorruptData)
                continue;
            ImageThread thread = (ImageThread) next;
            if (Long.decode(thread.getID()).longValue() == _faultingNativeID) {
                current = thread;
                break;
            }
        }
    }
    // ensure that this is sane
    if ((0 != _faultingNativeID) && (null == current)) {
        throw new CorruptDataException(new CorruptData("no current thread", null));
    }
    return current;
}
Also used : Iterator(java.util.Iterator) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 5 with CorruptDataException

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

the class JavaAbstractClass method addSuperclassReference.

protected void addSuperclassReference(Collection coll) {
    JavaReference jRef = null;
    try {
        com.ibm.dtfj.java.JavaClass superClass = this.getSuperclass();
        if (null != superClass) {
            jRef = new JavaReference(_javaVM, this, superClass, "Superclass", JavaReference.REFERENCE_SUPERCLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
            coll.add(jRef);
        }
    } catch (CorruptDataException e) {
        coll.add(e.getCorruptData());
    }
}
Also used : JavaClass(com.ibm.dtfj.java.JavaClass) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Aggregations

CorruptDataException (com.ibm.dtfj.image.CorruptDataException)124 JavaObject (com.ibm.dtfj.java.JavaObject)55 Iterator (java.util.Iterator)49 JavaClass (com.ibm.dtfj.java.JavaClass)41 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)39 CorruptData (com.ibm.dtfj.image.CorruptData)26 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)25 ImagePointer (com.ibm.dtfj.image.ImagePointer)19 CorruptData (com.ibm.dtfj.image.j9.CorruptData)17 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)14 ImageSection (com.ibm.dtfj.image.ImageSection)12 ImageThread (com.ibm.dtfj.image.ImageThread)12 JavaThread (com.ibm.dtfj.java.JavaThread)12 ArrayList (java.util.ArrayList)11 ImageProcess (com.ibm.dtfj.image.ImageProcess)9 JavaField (com.ibm.dtfj.java.JavaField)8 JavaReference (com.ibm.dtfj.java.JavaReference)8 LinkedList (java.util.LinkedList)8 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)7 JavaMethod (com.ibm.dtfj.java.JavaMethod)7