Search in sources :

Example 71 with J9ClassPointer

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

the class RootPathCommand method objectToString.

public static String objectToString(J9ObjectPointer object) throws CorruptDataException {
    J9ClassPointer clazz = J9ObjectHelper.clazz(object);
    StringWriter buf = new StringWriter();
    String className;
    className = J9ClassHelper.getJavaName(clazz);
    if (className.equals("java/lang/Class")) {
        buf.write("class ");
        buf.write(J9ClassHelper.getJavaName(ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object)));
        buf.write('@');
        buf.write(object.getHexAddress());
    } else if (className.equals("java/lang/String")) {
        buf.write('"');
        buf.write(J9ObjectHelper.stringValue(object));
        buf.write("\"@");
        buf.write(object.getHexAddress());
    } else {
        buf.write(className);
        buf.write('@');
        buf.write(object.getHexAddress());
        if (ObjectModel.isIndexable(object)) {
            buf.write(" = ");
            buf.write(J9IndexableObjectHelper.getDataAsString(J9IndexableObjectPointer.cast(object)));
        }
    }
    return buf.toString();
}
Also used : StringWriter(java.io.StringWriter) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)

Example 72 with J9ClassPointer

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

the class VmCheckCommand method verifyJ9Class.

private boolean verifyJ9Class(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
    boolean passed = verifyJ9ClassHeader(javaVM, out, classPointer);
    if (!classPointer.classLoader().isNull()) {
        J9MemorySegmentPointer segment = classPointer.classLoader().classSegments();
        segment = findSegmentInClassLoaderForAddress(classPointer, segment);
        if (segment.isNull()) {
            reportError(out, "class=0x%s not found in classLoader=0x%s", Long.toHexString(classPointer.getAddress()), Long.toHexString(classPointer.classLoader().getAddress()));
            passed = false;
        }
    }
    if (!verifyJ9ClassSubclassHierarchy(javaVM, out, classPointer)) {
        passed = false;
    }
    return passed;
}
Also used : J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)

Example 73 with J9ClassPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer 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 74 with J9ClassPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer 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 75 with J9ClassPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer 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)

Aggregations

J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)67 CorruptDataException (com.ibm.j9ddr.CorruptDataException)34 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)16 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)13 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)13 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)12 UDATA (com.ibm.j9ddr.vm29.types.UDATA)12 U32 (com.ibm.j9ddr.vm29.types.U32)11 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)8 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)8 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)7 NoSuchElementException (java.util.NoSuchElementException)7 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)6 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)6 GCClassHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator)5 GCSegmentIterator (com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)5 J9ITablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer)5