Search in sources :

Example 76 with J9JavaVMPointer

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

the class VmCheckCommand method checkJ9ROMClassSanity.

/*
	 *  Based on vmchk/checkromclasses.c r1.5
	 * 
	 *	J9ROMClass sanity:
	 *		SRP check:
	 *			Ensure J9ROMClass->interfaces SRP is in the same segment if J9ROMClass->interfaceCount != 0.
	 *			Ensure J9ROMClass->romMethods SRP is in the same segment if J9ROMClass->romMethodCount != 0.
	 *			Ensure J9ROMClass->romFields SRP is in the same segment if J9ROMClass->romFieldCount != 0.
	 *			Ensure J9ROMClass->innerClasses SRP is in the same segment if J9ROMClass->innerClasseCount != 0.
	 *			Ensure cpShapeDescription in the same segment.
	 *			Ensure all SRPs are in range on 64 bit platforms (including className, superclassName, and outerClassName).
	 *
	 *		ConstantPool count check:
	 *			Ensure ramConstantPoolCount <= romConstantPoolCount
	 */
private void checkJ9ROMClassSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
    reportMessage(out, "Checking ROM classes");
    // 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();
            verifyJ9ROMClass(out, vm, clazz);
            count++;
        }
    }
    reportMessage(out, "Checking %d ROM classes 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 77 with J9JavaVMPointer

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

the class VmCheckCommand method verifyJ9ClassSubclassHierarchy.

private boolean verifyJ9ClassSubclassHierarchy(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
    int index = 0;
    UDATA rootDepth = J9ClassHelper.classDepth(classPointer);
    J9ClassPointer currentClass = classPointer;
    boolean done = false;
    while (!done) {
        J9ClassPointer nextSubclass = currentClass.subclassTraversalLink();
        if (nextSubclass.isNull()) {
            reportError(out, "class=0x%s had NULL entry in subclassTraversalLink list at index=%d following class=0x%s", Long.toHexString(classPointer.getAddress()), index, Long.toHexString(currentClass.getAddress()));
            return false;
        }
        /* Sanity check the nextSubclass. */
        if (!verifyJ9ClassHeader(javaVM, out, nextSubclass)) {
            return false;
        }
        if (J9ClassHelper.classDepth(nextSubclass).lte(rootDepth)) {
            done = true;
        } else {
            currentClass = nextSubclass;
            index++;
        }
    }
    return true;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)

Example 78 with J9JavaVMPointer

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

the class VmCheckCommand method verifyClassMethods.

private int verifyClassMethods(J9JavaVMPointer vm, PrintStream out, J9ClassPointer clazz) throws CorruptDataException {
    int count = 0;
    J9ROMClassPointer romClass = clazz.romClass();
    int methodCount = romClass.romMethodCount().intValue();
    J9MethodPointer methods = clazz.ramMethods();
    boolean isInterfaceClass = J9ROMClassHelper.isInterface(romClass);
    J9ConstantPoolPointer ramConstantPool = J9ConstantPoolPointer.cast(clazz.ramConstantPool());
    for (int i = 0; i < methodCount; i++) {
        J9MethodPointer method = methods.add(i);
        J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(method);
        boolean methodInVTable = J9ROMMethodHelper.hasVTable(romMethod);
        if (!findROMMethodInClass(vm, romClass, romMethod, methodCount)) {
            reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in romClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!isInterfaceClass && methodInVTable) {
            if (!findMethodInVTable(method, clazz)) {
                reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in vTable of ramClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(clazz.getAddress()));
            }
        }
        if (!ramConstantPool.eq(ConstantPoolHelpers.J9_CP_FROM_METHOD(method))) {
            reportError(out, "ramConstantPool=0x%s on ramMethod=0x%s not equal to ramConstantPool=0x%s on ramClass=0x%s", Long.toHexString(ConstantPoolHelpers.J9_CP_FROM_METHOD(method).getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(ramConstantPool.getAddress()), Long.toHexString(clazz.getAddress()));
        }
        count++;
    }
    return count;
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)

Example 79 with J9JavaVMPointer

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

the class VMConstantPoolCommand method run.

/**
 * Run method for !vmconstantpool extension.
 *
 * @param command  !vmconstantpool
 * @param args	args passed by !vmconstantpool extension.
 * @param context Context
 * @param out PrintStream
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer javaVM;
        javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (args.length == 1) {
            long vmaddress = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
            if (vmaddress != javaVM.getAddress()) {
                out.println(args[0] + " is not a valid j9javavm address. Run !findvm to find out the j9javavm address of the current context");
                return;
            }
        } else if (args.length > 1) {
            printUsage(out);
        }
        J9ConstantPoolPointer jclConstantPool = J9ConstantPoolPointer.cast(javaVM.jclConstantPoolEA());
        J9ROMClassPointer romClass = jclConstantPool.ramClass().romClass();
        int index;
        U32Pointer cpShapeDescription;
        int constPoolCount;
        cpShapeDescription = romClass.cpShapeDescription();
        long cpDescription = cpShapeDescription.at(0).longValue();
        constPoolCount = romClass.romConstantPoolCount().intValue();
        PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
        long cpDescriptionIndex = 0;
        for (index = 0; index < constPoolCount; index++) {
            if (0 == cpDescriptionIndex) {
                // Load a new description word
                cpDescription = cpShapeDescription.at(0).longValue();
                cpShapeDescription = cpShapeDescription.add(1);
                cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
            }
            long shapeDesc = cpDescription & J9_CP_DESCRIPTION_MASK;
            AbstractPointer ref = PointerPointer.NULL;
            if (shapeDesc == J9CPTYPE_CLASS) {
                ref = J9ROMClassRefPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_STRING) {
                ref = J9ROMStringRefPointer.cast(cpEntry);
            } else if ((shapeDesc == J9CPTYPE_INT) || (shapeDesc == J9CPTYPE_FLOAT)) {
                ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_LONG) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Long at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.getHexValue() + "\n}");
            } else if (shapeDesc == J9CPTYPE_DOUBLE) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Double at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_FIELD)) {
                long classRefCPIndex;
                if (shapeDesc == J9CPTYPE_FIELD) {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    /* gets the classRefCPIndex to obtain a pointer to the j9romclassref */
                    classRefCPIndex = J9ROMFieldRefPointer.cast(ref).classRefCPIndex().longValue();
                } else {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    classRefCPIndex = J9ROMMethodRefPointer.cast(ref).classRefCPIndex().longValue();
                }
                PointerPointer classRefCPEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass)).addOffset(J9ROMConstantPoolItem.SIZEOF * classRefCPIndex);
                /* gets the DDR output of the item */
                String outString = ref.formatFullInteractive();
                String[] parts = outString.split(nl);
                /* add a debug extension(!j9romclassref) on the second line of the output */
                parts[1] += "(!j9romclassref " + classRefCPEntry.getHexAddress() + ")";
                out.print(join(nl, parts));
            } else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Unused at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if (ref.notNull()) {
                out.println(ref.formatFullInteractive());
            }
            cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
            cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
            cpDescriptionIndex -= 1;
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) U64Pointer(com.ibm.j9ddr.vm29.pointer.U64Pointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 80 with J9JavaVMPointer

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

the class TraceConfigCommand method run.

public void run(String command, String[] args, Context context, final PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        // !RasGlobalStorage
        RasGlobalStoragePointer rasGlobal = RasGlobalStoragePointer.cast(vm.j9rasGlobalStorage());
        // !UtGlobalData
        UtGlobalDataPointer utGlobal = UtGlobalDataPointer.cast(rasGlobal.utGlobalData());
        // !UtComponentList componentList
        UtComponentListPointer componentList = utGlobal.componentList();
        // !UtComponentData head
        UtComponentDataPointer head = componentList.head();
        if (args.length == 0) {
            walkTraceComponents(new ModuleVisitor() {

                public void visit(UtModuleInfoPointer modInfo) throws CorruptDataException {
                    out.println(moduleName(modInfo));
                }
            }, head, context, out);
        } else if ("all".equals(args[0])) {
            walkTraceComponents(new ModuleVisitor() {

                public void visit(UtModuleInfoPointer modInfo) throws CorruptDataException {
                    printActiveTracePoints(modInfo, out);
                }
            }, head, context, out);
        } else {
            for (int i = 0; i < args.length; i++) {
                final String componentName = args[i];
                walkTraceComponents(new ModuleVisitor() {

                    public void visit(UtModuleInfoPointer modInfo) throws CorruptDataException {
                        if (componentName.equals(moduleName(modInfo))) {
                            printActiveTracePoints(modInfo, out);
                        }
                    }
                }, head, context, out);
            }
        }
    } catch (CorruptDataException e) {
        e.printStackTrace();
    }
}
Also used : UtModuleInfoPointer(com.ibm.j9ddr.vm29.pointer.generated.UtModuleInfoPointer) UtComponentListPointer(com.ibm.j9ddr.vm29.pointer.generated.UtComponentListPointer) UtGlobalDataPointer(com.ibm.j9ddr.vm29.pointer.generated.UtGlobalDataPointer) UtComponentDataPointer(com.ibm.j9ddr.vm29.pointer.generated.UtComponentDataPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) RasGlobalStoragePointer(com.ibm.j9ddr.vm29.pointer.generated.RasGlobalStoragePointer)

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