Search in sources :

Example 16 with J9MemorySegmentPointer

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

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

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

the class VmCheckCommand method verifyAddressInSegment.

private void verifyAddressInSegment(PrintStream out, J9JavaVMPointer vm, J9MemorySegmentPointer segment, long address, String description) throws CorruptDataException {
    U8Pointer heapBase = segment.heapBase();
    U8Pointer heapAlloc = segment.heapAlloc();
    if (address < heapBase.getAddress() || (address >= heapAlloc.getAddress())) {
        reportError(out, "address 0x%s (%s) not in segment [heapBase=0x%s, heapAlloc=0x%s]", address, description, Long.toHexString(heapBase.getAddress()), Long.toHexString(heapAlloc.getAddress()));
    }
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 19 with J9MemorySegmentPointer

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

the class SegmentsUtil method addSegmentsToArrayList.

private static void addSegmentsToArrayList(J9MemorySegmentListPointer segmentListPointer, ArrayList<J9MemorySegmentPointer> segmentArray, int segmentType) throws CorruptDataException {
    MemorySegmentIterator segmentIterator = new MemorySegmentIterator(segmentListPointer, segmentType, false);
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer seg = (J9MemorySegmentPointer) segmentIterator.next();
        segmentArray.add(seg);
    }
}
Also used : MemorySegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)

Example 20 with J9MemorySegmentPointer

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

the class CheckEngine method checkJ9ClassPointer.

public int checkJ9ClassPointer(J9ClassPointer clazz, boolean allowUndead) throws CorruptDataException {
    // Java-ism. Need to check this first before doing compares etc.
    if (clazz == null || clazz.isNull()) {
        return J9MODRON_GCCHK_RC_NULL_CLASS_POINTER;
    }
    // Short circuit if we've recently checked this class.
    int cacheIndex = (int) (clazz.longValue() % CLASS_CACHE_SIZE);
    if (allowUndead && clazz.eq(_checkedClassCacheAllowUndead[cacheIndex])) {
        return J9MODRON_GCCHK_RC_OK;
    } else if (clazz.eq(_checkedClassCache[cacheIndex])) {
        return J9MODRON_GCCHK_RC_OK;
    }
    if (UDATA.cast(clazz).anyBitsIn(J9MODRON_GCCHK_J9CLASS_ALIGNMENT_MASK)) {
        return J9MODRON_GCCHK_RC_CLASS_POINTER_UNALIGNED;
    }
    J9MemorySegmentPointer segment = findSegmentForClass(clazz);
    if (segment == null) {
        return J9MODRON_GCCHK_RC_CLASS_NOT_FOUND;
    }
    if (!allowUndead) {
        if ((segment.type().longValue() & MEMORY_TYPE_UNDEAD_CLASS) != 0) {
            return J9MODRON_GCCHK_RC_CLASS_IS_UNDEAD;
        }
    }
    /* Check to ensure J9Class header has the correct eyecatcher. */
    int result = checkJ9ClassHeader(clazz);
    if (J9MODRON_GCCHK_RC_OK != result) {
        return result;
    }
    /* Check to ensure J9Class is not unloaded */
    result = checkJ9ClassIsNotUnloaded(clazz);
    if (J9MODRON_GCCHK_RC_OK != result) {
        return result;
    }
    if ((_cycle.getCheckFlags() & J9MODRON_GCCHK_VERIFY_RANGE) != 0) {
        IDATA delta = segment.heapAlloc().sub(U8Pointer.cast(clazz));
        /* Basic check that there is enough room for the class header */
        if (delta.lt(J9Class.SIZEOF)) {
            return J9MODRON_GCCHK_RC_CLASS_INVALID_RANGE;
        }
    }
    /* class checked out. Record it in the cache so we don't need to check it again. */
    if (allowUndead) {
        _checkedClassCacheAllowUndead[cacheIndex] = clazz;
    } else {
        _checkedClassCache[cacheIndex] = clazz;
    }
    return J9MODRON_GCCHK_RC_OK;
}
Also used : IDATA(com.ibm.j9ddr.vm29.types.IDATA) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)

Aggregations

J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)17 CorruptDataException (com.ibm.j9ddr.CorruptDataException)7 GCSegmentIterator (com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)7 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)7 GCClassHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator)6 MemorySegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)4 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)4 UDATA (com.ibm.j9ddr.vm29.types.UDATA)4 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)2 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 ArrayList (java.util.ArrayList)2 NoSuchElementException (java.util.NoSuchElementException)2 GCClassIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassIterator)1 GCClassIteratorClassSlots (com.ibm.j9ddr.vm29.j9.gc.GCClassIteratorClassSlots)1 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)1 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)1 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)1 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 J9JITDataCacheHeaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JITDataCacheHeaderPointer)1