Search in sources :

Example 11 with GCVMThreadListIterator

use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator in project openj9 by eclipse.

the class VmCheckCommand method checkJ9VMThreadSanity.

/*
	 *  Based on vmchk/checkthreads.c r1.5
	 *
	 *	J9VMThread sanity:
	 *		Valid VM check:
	 *			J9VMThread->javaVM->javaVM == J9VMThread->javaVM.
	 *
	 *		Exclusive access check:
	 *			If any J9VMThread has exclusive access, ensure no other thread has exclusive or vm access.
	 */
private void checkJ9VMThreadSanity(J9JavaVMPointer javaVM, PrintStream out) throws CorruptDataException {
    GCVMThreadListIterator gcvmThreadListIterator = GCVMThreadListIterator.from();
    int count = 0;
    int numberOfThreadsWithVMAccess = 0;
    boolean exclusiveVMAccess = javaVM.exclusiveAccessState().eq(J9_XACCESS_EXCLUSIVE);
    reportMessage(out, "Checking threads");
    while (gcvmThreadListIterator.hasNext()) {
        J9VMThreadPointer thread = gcvmThreadListIterator.next();
        verifyJ9VMThread(out, thread, javaVM);
        if (thread.publicFlags().allBitsIn(J9Consts.J9_PUBLIC_FLAGS_VM_ACCESS)) {
            numberOfThreadsWithVMAccess++;
        }
        count++;
    }
    if (exclusiveVMAccess && numberOfThreadsWithVMAccess > 1) {
        reportError(out, "numberOfThreadsWithVMAccess (%d) > 1 with vm->exclusiveAccessState == J9_XACCESS_EXCLUSIVE", numberOfThreadsWithVMAccess);
    }
    reportMessage(out, "Checking %d threads done", count);
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)

Example 12 with GCVMThreadListIterator

use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator in project openj9 by eclipse.

the class CheckVMThreads method print.

@Override
public void print() {
    try {
        GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
        ScanFormatter formatter = new ScanFormatter(this, "VMThread Slots");
        while (vmThreadListIterator.hasNext()) {
            J9VMThreadPointer walkThread = vmThreadListIterator.next();
            formatter.section("thread", walkThread);
            GCVMThreadIterator vmthreadIterator = GCVMThreadIterator.fromJ9VMThread(walkThread);
            while (vmthreadIterator.hasNext()) {
                formatter.entry(vmthreadIterator.next());
            }
            formatter.endSection();
        }
        formatter.end("VMThread Slots");
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) GCVMThreadIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadIterator)

Example 13 with GCVMThreadListIterator

use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator 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

GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)13 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)13 CorruptDataException (com.ibm.j9ddr.CorruptDataException)7 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)4 WalkState (com.ibm.j9ddr.vm29.j9.stackwalker.WalkState)3 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 GCVMThreadIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadIterator)2 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)2 UDATA (com.ibm.j9ddr.vm29.types.UDATA)2 CorruptData (com.ibm.dtfj.image.CorruptData)1 JavaObject (com.ibm.dtfj.java.JavaObject)1 InvalidDataTypeException (com.ibm.j9ddr.InvalidDataTypeException)1 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)1 J9JavaStackIterator (com.ibm.j9ddr.vm29.j9.J9JavaStackIterator)1 GCScavengerForwardedHeader (com.ibm.j9ddr.vm29.j9.gc.GCScavengerForwardedHeader)1 GCVMThreadJNISlotIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadJNISlotIterator)1 GCVMThreadMonitorRecordSlotIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadMonitorRecordSlotIterator)1 GCVMThreadSlotIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadSlotIterator)1 IStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.IStackWalkerCallbacks)1