Search in sources :

Example 6 with GCVMThreadListIterator

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

the class CheckVMThreadStacks method print.

@Override
public void print() {
    try {
        GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
        final ScanFormatter formatter = new ScanFormatter(this, "thread stacks");
        while (vmThreadListIterator.hasNext()) {
            J9VMThreadPointer walkThread = vmThreadListIterator.next();
            formatter.section("thread slots", walkThread);
            WalkState walkState = new WalkState();
            walkState.walkThread = walkThread;
            walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK | J9_STACKWALK_SKIP_INLINES;
            walkState.callBacks = new BaseStackWalkerCallbacks() {

                public void objectSlotWalkFunction(J9VMThreadPointer walkThread, WalkState walkState, PointerPointer objectSlot, VoidPointer stackAddress) {
                    try {
                        formatter.entry(objectSlot.at(0));
                    } catch (CorruptDataException e) {
                    }
                }
            };
            StackWalker.walkStackFrames(walkState);
            formatter.endSection();
            formatter.section("thread stack", walkThread);
            dumpStackTrace(walkThread);
            formatter.endSection();
        }
        formatter.end("thread stacks");
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) BaseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 7 with GCVMThreadListIterator

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

the class CheckVMThreads method check.

@Override
public void check() {
    try {
        GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
        while (vmThreadListIterator.hasNext()) {
            J9VMThreadPointer walkThread = vmThreadListIterator.next();
            GCVMThreadIterator vmthreadIterator = GCVMThreadIterator.fromJ9VMThread(walkThread);
            while (vmthreadIterator.hasNext()) {
                PointerPointer slot = PointerPointer.cast(vmthreadIterator.nextAddress());
                if (_engine.checkSlotVMThread(slot, VoidPointer.cast(walkThread), CheckError.check_type_other, vmthreadIterator.getState()) != J9MODRON_SLOT_ITERATOR_OK) {
                    continue;
                }
            }
        }
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) GCVMThreadIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadIterator)

Example 8 with GCVMThreadListIterator

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

the class RootScanner method scanThreads.

protected void scanThreads() throws CorruptDataException {
    setReachability(Reachability.STRONG);
    GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
    while (vmThreadListIterator.hasNext()) {
        J9VMThreadPointer walkThread = vmThreadListIterator.next();
        /* "Inline" the behaviour of GC_VMThreadIterator to distinguish between the types of roots */
        GCVMThreadSlotIterator threadSlotIterator = GCVMThreadSlotIterator.fromJ9VMThread(walkThread);
        GCVMThreadSlotIterator threadSlotAddressIterator = GCVMThreadSlotIterator.fromJ9VMThread(walkThread);
        while (threadSlotIterator.hasNext()) {
            doVMThreadSlot(threadSlotIterator.next(), threadSlotAddressIterator.nextAddress());
        }
        GCVMThreadJNISlotIterator jniSlotIterator = GCVMThreadJNISlotIterator.fromJ9VMThread(walkThread);
        GCVMThreadJNISlotIterator jniSlotAddressIterator = GCVMThreadJNISlotIterator.fromJ9VMThread(walkThread);
        while (jniSlotIterator.hasNext()) {
            doVMThreadJNISlot(jniSlotIterator.next(), jniSlotAddressIterator.nextAddress());
        }
        if (J9BuildFlags.interp_hotCodeReplacement) {
            GCVMThreadMonitorRecordSlotIterator monitorRecordSlotIterator = GCVMThreadMonitorRecordSlotIterator.fromJ9VMThread(walkThread);
            GCVMThreadMonitorRecordSlotIterator addressIterator = GCVMThreadMonitorRecordSlotIterator.fromJ9VMThread(walkThread);
            while (monitorRecordSlotIterator.hasNext()) {
                doVMThreadMonitorRecordSlot(monitorRecordSlotIterator.next(), addressIterator.nextAddress());
            }
        }
        if (_scanStackSlots) {
            GCVMThreadStackSlotIterator.scanSlots(walkThread, _stackWalkerCallbacks, _includeStackFrameClassReferences, _trackVisibleStackFrameDepth);
        }
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) GCVMThreadJNISlotIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadJNISlotIterator) GCVMThreadSlotIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadSlotIterator) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) GCVMThreadMonitorRecordSlotIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadMonitorRecordSlotIterator)

Example 9 with GCVMThreadListIterator

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

the class FindStackValueCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (0 == args.length) {
        out.println("Usage error: Missing stackvalue to search for. See usage.");
        printUsage(out);
        return;
    } else if (1 < args.length) {
        out.println("Usage error: Too many stackvalues to search for. See usage.");
        printUsage(out);
        return;
    }
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        UDATAPointer value = UDATAPointer.cast(address);
        GCVMThreadListIterator gcvmThreadListIterator = GCVMThreadListIterator.from();
        while (gcvmThreadListIterator.hasNext()) {
            J9VMThreadPointer vmThreadPointer = gcvmThreadListIterator.next();
            J9JavaStackPointer javaStackPointer = vmThreadPointer.stackObject();
            J9JavaStackIterator javaStackIterator = J9JavaStackIterator.fromJ9JavaStack(javaStackPointer);
            boolean found = false;
            UDATA relativeSP = new UDATA(javaStackPointer.end().sub(vmThreadPointer.sp()));
            while (javaStackIterator.hasNext()) {
                J9JavaStackPointer stack = javaStackIterator.next();
                UDATAPointer localEnd = stack.end().sub(1).add(1);
                UDATAPointer search = localEnd.sub(relativeSP);
                while (!search.eq(localEnd)) {
                    if (search.at(0).longValue() == value.longValue()) {
                        if (!found) {
                            out.append(String.format("!j9vmthread %s\n", Long.toHexString(vmThreadPointer.getAddress())));
                            found = true;
                        }
                        out.append(String.format("\tFound at %s\n", Long.toHexString(search.getAddress())));
                    }
                    search = search.add(1);
                }
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) J9JavaStackIterator(com.ibm.j9ddr.vm29.j9.J9JavaStackIterator) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 10 with GCVMThreadListIterator

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

the class MonitorsCommand method j9vmthreadCommand.

/**
 * See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
 * function documentation
 *
 * @param args
 *            command args
 * @param out
 *            the output stream
 * @throws DDRInteractiveCommandException
 */
private void j9vmthreadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length < 2) {
        out.println("This command takes one address argument: \"!monitors j9vmthread <address>\"");
        return;
    }
    try {
        long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
        VoidPointer ptr = VoidPointer.cast(address);
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9VMThreadPointer thread = null;
        GCVMThreadListIterator threadIterator = GCVMThreadListIterator.from();
        while (threadIterator.hasNext()) {
            if (ptr.equals(threadIterator.next())) {
                thread = J9VMThreadPointer.cast(ptr);
            }
        }
        if (null == thread) {
            throw new DDRInteractiveCommandException(String.format("Could not find any j9vmthread at address %s\n", ptr.getHexAddress()));
        }
        // Step 1: Print the general info for the VM and native threads:
        out.println(String.format("!j9vmthread 0x%08x\t!j9thread 0x%08x\t// %s", thread.getAddress(), thread.osThread().getAddress(), J9VMThreadHelper.getName(thread)));
        printMonitorsForJ9VMThread(out, vm, thread);
        printMonitorsForJ9Thread(out, vm, thread.osThread());
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

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