Search in sources :

Example 6 with J9ClassLoaderPointer

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

the class VmCheckCommand method verifyJ9ROMClass.

private void verifyJ9ROMClass(PrintStream out, J9JavaVMPointer vm, J9ClassPointer clazz) throws CorruptDataException {
    J9ROMClassPointer romClass = clazz.romClass();
    J9ClassLoaderPointer classLoader = clazz.classLoader();
    J9MemorySegmentPointer segment = findSegmentInClassLoaderForAddress(classLoader, romClass);
    if (!segment.isNull()) {
        long address;
        if (romClass.interfaceCount().longValue() != 0) {
            address = romClass.interfaces().getAddress();
            verifyAddressInSegment(out, vm, segment, address, "romClass->interfaces");
        }
        if (romClass.romMethodCount().longValue() != 0) {
            address = romClass.romMethods().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->romMethods");
        }
        if (romClass.romFieldCount().longValue() != 0) {
            address = romClass.romFields().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->romFields");
        }
        if (romClass.innerClassCount().longValue() != 0) {
            address = romClass.innerClasses().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->innerClasses");
        }
        U32Pointer cpShapeDescription = romClass.cpShapeDescription();
        /* TODO: is !isNull() check required or not? */
        if (!cpShapeDescription.isNull()) {
            address = cpShapeDescription.getAddress();
            verifyAddressInSegment(out, vm, segment, address, "romClass->cpShapeDescription");
        }
    }
    {
        J9UTF8Pointer className = romClass.className();
        J9UTF8Pointer superclassName = romClass.superclassName();
        J9UTF8Pointer outerClassName = romClass.outerClassName();
        if (className.isNull() || !verifyUTF8(className)) {
            reportError(out, "invalid className=0x%s utf8 for romClass=0x%s", Long.toHexString(className.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!superclassName.isNull() && !verifyUTF8(superclassName)) {
            reportError(out, "invalid superclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(superclassName.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!outerClassName.isNull() && !verifyUTF8(outerClassName)) {
            reportError(out, "invalid outerclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(outerClassName.getAddress()), Long.toHexString(romClass.getAddress()));
        }
    }
    U32 ramConstantPoolCount = romClass.ramConstantPoolCount();
    U32 romConstantPoolCount = romClass.romConstantPoolCount();
    if (ramConstantPoolCount.gt(romConstantPoolCount)) {
        reportError(out, "ramConstantPoolCount=%d > romConstantPoolCount=%d for romClass=0x%s", ramConstantPoolCount.longValue(), romConstantPoolCount.longValue(), Long.toHexString(romClass.getAddress()));
    }
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 7 with J9ClassLoaderPointer

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

the class VmCheckCommand method checkLocalInternTableSanity.

/*
	 *  Based on vmchk/checkinterntable.c r1.3
	 * 
	 *	J9LocalInternTableSanity sanity:
	 *		if J9JavaVM->dynamicLoadBuffers != NULL
	 *			invariantInternTree check:
	 *				For each J9InternHashTableEntry
	 *					Ensure J9InternHashTableEntry->utf8 is valid
	 *					Ensure J9InternHashTableEntry->classLoader is valid
	 */
private void checkLocalInternTableSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
    int count = 0;
    reportMessage(out, "Checking ROM intern string nodes");
    J9TranslationBufferSetPointer dynamicLoadBuffers = vm.dynamicLoadBuffers();
    if (!dynamicLoadBuffers.isNull()) {
        J9DbgROMClassBuilderPointer romClassBuilder = J9DbgROMClassBuilderPointer.cast(dynamicLoadBuffers.romClassBuilder());
        J9DbgStringInternTablePointer stringInternTable = romClassBuilder.stringInternTable();
        J9InternHashTableEntryPointer node = stringInternTable.headNode();
        while (!node.isNull()) {
            J9UTF8Pointer utf8 = node.utf8();
            J9ClassLoaderPointer classLoader = node.classLoader();
            if (!verifyUTF8(utf8)) {
                reportError(out, "invalid utf8=0x%s for node=0x%s", Long.toHexString(utf8.getAddress()), Long.toHexString(node.getAddress()));
            }
            if (!verifyJ9ClassLoader(vm, classLoader)) {
                reportError(out, "invalid classLoader=0x%s for node=0x%s", Long.toHexString(classLoader.getAddress()), Long.toHexString(node.getAddress()));
            }
            count++;
            node = node.nextNode();
        }
    }
    reportMessage(out, "Checking %d ROM intern string nodes done", count);
}
Also used : J9TranslationBufferSetPointer(com.ibm.j9ddr.vm29.pointer.generated.J9TranslationBufferSetPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) J9DbgStringInternTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9DbgStringInternTablePointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) J9DbgROMClassBuilderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9DbgROMClassBuilderPointer) J9InternHashTableEntryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9InternHashTableEntryPointer)

Example 8 with J9ClassLoaderPointer

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

the class DTFJJavaRuntime method getJavaClassLoaders.

@SuppressWarnings("rawtypes")
public Iterator getJavaClassLoaders() {
    if (classLoaders != null) {
        // return cached set of class loaders
        return classLoaders.iterator();
    }
    classLoaders = new LinkedList<Object>();
    GCClassLoaderIterator classLoaderIterator;
    try {
        classLoaderIterator = GCClassLoaderIterator.from();
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        classLoaders.add(cd);
        return classLoaders.iterator();
    }
    AddCorruptionToListListener corruptionListener = new AddCorruptionToListListener(classLoaders);
    register(corruptionListener);
    try {
        while (!corruptionListener.fatalCorruption() && classLoaderIterator.hasNext()) {
            J9ClassLoaderPointer next = classLoaderIterator.next();
            if (next != null) {
                classLoaders.add(new DTFJJavaClassloader(next));
            }
        }
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        classLoaders.add(cd);
    }
    unregister(corruptionListener);
    return classLoaders.iterator();
}
Also used : GCClassLoaderIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) AddCorruptionToListListener(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.AddCorruptionToListListener)

Example 9 with J9ClassLoaderPointer

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

the class RootScanner method scanClassLoaders.

protected void scanClassLoaders() throws CorruptDataException {
    J9ClassLoaderPointer sysClassLoader = _vm.systemClassLoader();
    J9ClassLoaderPointer appClassLoader = J9ClassLoaderPointer.cast(_vm.applicationClassLoader());
    GCClassLoaderIterator classLoaderIterator = GCClassLoaderIterator.from();
    while (classLoaderIterator.hasNext()) {
        J9ClassLoaderPointer loader = classLoaderIterator.next();
        Reachability reachability;
        if (J9BuildFlags.gc_dynamicClassUnloading) {
            long dynamicClassUnloadingFlag = _extensions.dynamicClassUnloading();
            if (MM_GCExtensions$DynamicClassUnloading.DYNAMIC_CLASS_UNLOADING_NEVER == dynamicClassUnloadingFlag) {
                reachability = Reachability.STRONG;
            } else {
                if (loader.eq(sysClassLoader) || loader.eq(appClassLoader)) {
                    reachability = Reachability.STRONG;
                } else {
                    reachability = Reachability.WEAK;
                }
            }
        } else {
            reachability = Reachability.STRONG;
        }
        setReachability(reachability);
        doClassLoader(loader);
    }
}
Also used : J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) GCClassLoaderIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)

Example 10 with J9ClassLoaderPointer

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

the class RootScanner method scanClasses.

protected void scanClasses() throws CorruptDataException {
    J9ClassLoaderPointer sysClassLoader = _vm.systemClassLoader();
    J9ClassLoaderPointer appClassLoader = J9ClassLoaderPointer.cast(_vm.applicationClassLoader());
    GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(_vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer segment = segmentIterator.next();
        GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
        while (classHeapIterator.hasNext()) {
            J9ClassPointer clazz = classHeapIterator.next();
            Reachability reachability;
            if (J9BuildFlags.gc_dynamicClassUnloading) {
                long dynamicClassUnloadingFlag = _extensions.dynamicClassUnloading();
                if (MM_GCExtensions$DynamicClassUnloading.DYNAMIC_CLASS_UNLOADING_NEVER == dynamicClassUnloadingFlag) {
                    reachability = Reachability.STRONG;
                } else {
                    if (clazz.classLoader().eq(sysClassLoader) || clazz.classLoader().eq(appClassLoader)) {
                        reachability = Reachability.STRONG;
                    } else {
                        reachability = Reachability.WEAK;
                    }
                }
            } else {
                reachability = Reachability.STRONG;
            }
            setReachability(reachability);
            doClass(clazz);
        }
    }
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) GCClassHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator) GCSegmentIterator(com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)

Aggregations

J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)12 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)8 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)7 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)5 CorruptDataException (com.ibm.j9ddr.CorruptDataException)4 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)3 UDATA (com.ibm.j9ddr.vm29.types.UDATA)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 GCClassHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator)2 GCSegmentIterator (com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)2 J9HashTablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer)2 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)2 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)2 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)2 U32 (com.ibm.j9ddr.vm29.types.U32)2 CorruptData (com.ibm.dtfj.image.CorruptData)1 JavaObject (com.ibm.dtfj.java.JavaObject)1 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)1 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)1 ClassIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassIterator)1