Search in sources :

Example 41 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class VmCheckCommand method checkJ9MethodSanity.

/*
	 *  Based on vmchk/checkmethods.c r1.5
	 * 
	 *	J9Method sanity:
	 *		Bytecode check:
	 *			Ensure (bytecodes - sizeof(J9ROMMethod) is in the right "area" to be a ROM Method.
	 *			Use ROMClass to determine where ROM methods for that class begin.
	 *		Constant pool check:
	 *			Ensure method's constant pool is the same as that of its J9Class.
	 *			Useful to validate that HCR doesn't violate this invariant.
	 *		VTable check:
	 *			If method of a non-interface class has modifier J9AccMethodVTable,
	 *			ensure it exists in the VTable of its J9Class.
	 *			Useful to validate that HCR doesn't violate this invariant.
	 */
private void checkJ9MethodSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
    reportMessage(out, "Checking methods");
    // Stolen from RootScaner.scanClasses()
    // GCClassLoaderIterator gcClassLoaderIterator =
    // GCClassLoaderIterator.from();
    GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    int count = 0;
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer segment = segmentIterator.next();
        GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
        while (classHeapIterator.hasNext()) {
            J9ClassPointer clazz = classHeapIterator.next();
            if (!J9ClassHelper.isObsolete(clazz)) {
                count += verifyClassMethods(vm, out, clazz);
            }
        }
    }
    reportMessage(out, "Checking %d methods done", count);
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) GCClassHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator) GCSegmentIterator(com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)

Example 42 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class ShowDumpAgentsCommand method seekDumpAgent.

private J9RASdumpAgentPointer seekDumpAgent(J9JavaVMPointer vm, J9RASdumpAgentPointer agentPtr, J9RASdumpFunctionsPointer dumpFn) throws CorruptDataException {
    J9RASdumpFunctionsPointer func = vm.j9rasDumpFunctions();
    J9RASdumpQueuePointer queue = J9RASdumpQueuePointer.cast(func);
    // Windows 64 bit returns a key of 0xFFFFFFFFFACADEDC
    // Other 64 bit platforms return 0x00000000FACADEDC.
    // Mask off the top bits since the key is 32 bits anyway.
    UDATA reserved = UDATA.roundToSizeofU32(UDATA.cast(queue.facade().reserved()));
    reserved = reserved.bitAnd(0x00000000FFFFFFFFl);
    if (!DUMP_FACADE_KEY.equals(reserved)) {
        // Dump functions have not been configured. (-Xdump:none was probably specified.)#
        return null;
    }
    /*
		 * Sanity check
		 */
    if (!queue.isNull()) {
        J9RASdumpAgentPointer node = agentPtr;
        /* Start from next agent, else start from the beginning */
        node = (node != null && !node.isNull()) ? node.nextPtr() : queue.agents();
        /* Agents with same dumpFn will be found in priority order */
        while (node != null && !node.isNull() && dumpFn != null && !dumpFn.isNull() && node.dumpFn().getAddress() != dumpFn.getAddress()) {
            node = node.nextPtr();
        }
        /* Update the current position */
        agentPtr = node;
        return node;
    }
    /* Blank current position */
    agentPtr = J9RASdumpAgentPointer.NULL;
    return agentPtr;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9RASdumpAgentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RASdumpAgentPointer) J9RASdumpFunctionsPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RASdumpFunctionsPointer) J9RASdumpQueuePointer(com.ibm.j9ddr.vm29.pointer.generated.J9RASdumpQueuePointer)

Example 43 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class ShowDumpAgentsCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9RASdumpAgentPointer agent = J9RASdumpAgentPointer.NULL;
        out.println("Registered dump agents\n----------------------");
        while (((agent = seekDumpAgent(vm, agent, null)) != null) && !agent.isNull()) {
            printDumpAgent(vm, agent, context, out);
            out.println("----------------------");
        }
        out.println();
    } catch (CorruptDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : J9RASdumpAgentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RASdumpAgentPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 44 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class StackmapCommand method run.

/**
 *  Java representation of j9dbgext.c#dbgext_stackmap function.
 *
 *  @param  command DDR extension command of stackmap.
 *                  It is supposed to be "stackmap" if this method is being called.
 *  @param  args    Arguments passed to !stackmap DDR extension.
 *                  Only one argument is expected since !stackmap expects only the address.
 *  @param  context Current context that DDR is running on.
 *  @param  out     Print stream to write the output.
 *
 *  @return void
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 1) {
        printUsage(out);
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (null == vm) {
            out.println("vm can not be found.");
        }
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        U8Pointer pc = U8Pointer.cast(address);
        CommandUtils.dbgPrint(out, "Searching for PC=%d in VM=%s...\n", pc.longValue(), vm.getHexAddress());
        J9MethodPointer remoteMethod = J9JavaVMHelper.getMethodFromPC(vm, pc);
        if (remoteMethod.notNull()) {
            int[] stackMap = new int[MAX_STACKSLOTS_COUNT / INT_SIZE_IN_BITS];
            int leftMostBitIntMask = 1 << (INT_SIZE_IN_BITS - 1);
            CommandUtils.dbgPrint(out, "Found method %s !j9method %s\n", J9MethodHelper.getName(remoteMethod), remoteMethod.getHexAddress());
            UDATA offsetPC = new UDATA(pc.sub(U8Pointer.cast(remoteMethod.bytecodes())));
            CommandUtils.dbgPrint(out, "Relative PC = %d\n", offsetPC.longValue());
            J9ClassPointer localClass = J9_CLASS_FROM_CP(remoteMethod.constantPool());
            long methodIndex = new UDATA(remoteMethod.sub(localClass.ramMethods())).longValue();
            CommandUtils.dbgPrint(out, "Method index is %d\n", methodIndex);
            J9ROMMethodPointer localROMMethod = J9ROMCLASS_ROMMETHODS(localClass.romClass());
            while (methodIndex != 0) {
                localROMMethod = ROMHelp.nextROMMethod(localROMMethod);
                --methodIndex;
            }
            CommandUtils.dbgPrint(out, "Using ROM method %s\n", localROMMethod.getHexAddress());
            /*
				 * This call will return the depth of the stack or errorcode in case of a failure.
				 */
            int errorCode = StackMap.j9stackmap_StackBitsForPC(offsetPC, localClass.romClass(), localROMMethod, null, 0);
            if (0 > errorCode) {
                CommandUtils.dbgPrint(out, "Stack map failed, error code = %d\n", errorCode);
            } else {
                int stackMapIndex = 0;
                if (0 != errorCode) {
                    /* This call to j9stackmap_StackBitsForPC will fill the stackMap */
                    errorCode = StackMap.j9stackmap_StackBitsForPC(offsetPC, localClass.romClass(), localROMMethod, stackMap, errorCode);
                    int currentDescription = stackMap[stackMapIndex];
                    int descriptionInt = 0;
                    CommandUtils.dbgPrint(out, "Stack map (%d slots mapped): ", errorCode);
                    long bitsRemaining = errorCode % INT_SIZE_IN_BITS;
                    if (bitsRemaining != 0) {
                        descriptionInt = currentDescription << (INT_SIZE_IN_BITS - bitsRemaining);
                        currentDescription++;
                    }
                    while (errorCode != 0) {
                        if (bitsRemaining == 0) {
                            descriptionInt = currentDescription;
                            currentDescription = stackMap[++stackMapIndex];
                            bitsRemaining = INT_SIZE_IN_BITS;
                        }
                        CommandUtils.dbgPrint(out, "%d", (descriptionInt & (leftMostBitIntMask)) != 0 ? 1 : 0);
                        descriptionInt = descriptionInt << 1;
                        --bitsRemaining;
                        --errorCode;
                    }
                    CommandUtils.dbgPrint(out, "\n");
                } else {
                    CommandUtils.dbgPrint(out, "Stack is empty\n");
                }
            }
        } else {
            CommandUtils.dbgPrint(out, "Not found\n");
        }
    } catch (CorruptDataException e) {
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 45 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class WalkInternTableCommand method getRomClassBuilderPtr.

/**
 * This method is used to get the pointer to the RomClassBuilder
 * @param out	PrintStream
 * @return void
 * @throws CorruptDataException
 */
private J9DbgStringInternTablePointer getRomClassBuilderPtr(PrintStream out) throws CorruptDataException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (vm.isNull()) {
            out.append("VM can not be found " + nl);
            return null;
        }
        J9TranslationBufferSetPointer translationBufferSetPtr = vm.dynamicLoadBuffers();
        if (translationBufferSetPtr.isNull()) {
            out.append("J9TranslationBufferSet can not be found " + nl);
            return null;
        }
        J9DbgROMClassBuilderPointer romClassBuilderPtr = J9DbgROMClassBuilderPointer.cast(translationBufferSetPtr.romClassBuilder());
        if (romClassBuilderPtr.isNull()) {
            out.append("romClassBuilderPtr can not be found " + nl);
            return null;
        }
        return romClassBuilderPtr.stringInternTable();
    } catch (CorruptDataException e) {
        throw e;
    }
}
Also used : J9TranslationBufferSetPointer(com.ibm.j9ddr.vm29.pointer.generated.J9TranslationBufferSetPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9DbgROMClassBuilderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9DbgROMClassBuilderPointer)

Aggregations

J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)57 CorruptDataException (com.ibm.j9ddr.CorruptDataException)49 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)39 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)23 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)17 UDATA (com.ibm.j9ddr.vm29.types.UDATA)13 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)10 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)8 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)8 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)6 PatternString (com.ibm.j9ddr.util.PatternString)5 MonitorIterator (com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator)5 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)5 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)5 MM_HeapRegionManagerPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionManagerPointer)5 Table (com.ibm.j9ddr.tools.ddrinteractive.Table)4 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)4 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)4 J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)4