Search in sources :

Example 31 with VoidPointer

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

the class CheckEngine method checkSlotVMThread.

public int checkSlotVMThread(PointerPointer objectIndirect, VoidPointer objectIndirectBase, int objectType, int iteratorState) {
    J9ObjectPointer object;
    try {
        object = J9ObjectPointer.cast(objectIndirect.at(0));
        int result = checkObjectIndirect(object);
        if ((GCVMThreadIterator.state_monitor_records == iteratorState) && (J9MODRON_GCCHK_RC_STACK_OBJECT == result)) {
            result = checkStackObject(object);
        }
        if (J9MODRON_GCCHK_RC_OK != result) {
            CheckError error = new CheckError(objectIndirectBase, objectIndirect, _cycle, _currentCheck, result, _cycle.nextErrorCount(), objectType);
            _reporter.report(error);
        }
    } catch (CorruptDataException e) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(objectIndirectBase, objectIndirect, _cycle, _currentCheck, J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount(), objectType);
        _reporter.report(error);
    }
    return J9MODRON_SLOT_ITERATOR_OK;
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 32 with VoidPointer

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

the class DTFJJavaClass method getInterfaces.

@SuppressWarnings("rawtypes")
public Iterator getInterfaces() {
    ArrayList<Object> interfaceNames;
    int interfaceCount;
    SelfRelativePointer interfaceName;
    try {
        // a failure in the following calls mean that we cannot find any interfaces
        interfaceCount = j9class.romClass().interfaceCount().intValue();
        if (interfaceCount > 0xFFFF) {
            // class file format limits the number of interfaces to U2 (unsigned 2 bytes)
            String msg = String.format("Invalid number of interfaces for class@0x%s", Long.toHexString(j9class.getAddress()));
            throw new com.ibm.j9ddr.CorruptDataException(msg);
        }
        interfaceNames = new ArrayList<Object>(interfaceCount);
        interfaceName = j9class.romClass().interfaces();
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        return corruptIterator(cd);
    }
    // a failure in the loop should return what we've found so far + a corrupt data
    try {
        for (int i = 0; i < interfaceCount; i++) {
            VoidPointer namePointer = interfaceName.add(i).get();
            // a failure to get the name means we can still move to the next iface
            try {
                interfaceNames.add(J9UTF8Helper.stringValue(J9UTF8Pointer.cast(namePointer)));
            } catch (Throwable t) {
                CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                interfaceNames.add(cd);
            }
        }
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        interfaceNames.add(cd);
    }
    return interfaceNames.iterator();
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) SelfRelativePointer(com.ibm.j9ddr.vm29.pointer.SelfRelativePointer) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 33 with VoidPointer

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

the class J9ObjectStructureFormatter method printSubArrayType.

void printSubArrayType(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, int begin, int end, J9IndexableObjectPointer array) throws CorruptDataException {
    U32 arraySize = J9IndexableObjectHelper.size(array);
    if (arraySize.anyBitsIn(0x80000000)) {
        arraySize = new U32(Integer.MAX_VALUE);
    }
    int finish = Math.min(arraySize.intValue(), end);
    if (begin < finish) {
        String className = J9IndexableObjectHelper.getClassName(array);
        char signature = className.charAt(1);
        switch(signature) {
            case 'B':
            case 'Z':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 1);
                    out.println(String.format("[%d] = %3d, 0x%02x", index, U8Pointer.cast(slot).at(0).longValue(), U8Pointer.cast(slot).at(0).longValue()));
                }
                break;
            case 'C':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
                    long value = U16Pointer.cast(slot).at(0).longValue();
                    out.println(String.format("[%d] = %5d, 0x%2$04x, '%c'", index, value, (char) value));
                }
                break;
            case 'S':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
                    out.println(String.format("[%d] = %6d, 0x%04x", index, I16Pointer.cast(slot).at(0).longValue(), U16Pointer.cast(slot).at(0).longValue()));
                }
                break;
            case 'I':
            case 'F':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 4);
                    out.println(String.format("[%d] = %10d, 0x%08x, %8.8fF", index, I32Pointer.cast(slot).at(0).longValue(), U32Pointer.cast(slot).at(0).longValue(), FloatPointer.cast(slot).floatAt(0)));
                }
                break;
            case 'J':
            case 'D':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 8);
                    out.println(String.format("[%d] = %2d, 0x%016x, %8.8fF", index, I64Pointer.cast(slot).at(0).longValue(), I64Pointer.cast(slot).at(0).longValue(), DoublePointer.cast(slot).doubleAt(0)));
                }
                break;
            case 'L':
            case '[':
                for (int index = begin; index < finish; index++) {
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, (int) ObjectReferencePointer.SIZEOF);
                    if (slot.notNull()) {
                        long compressedPtrValue;
                        if (J9BuildFlags.gc_compressedPointers) {
                            compressedPtrValue = I32Pointer.cast(slot).at(0).longValue();
                        } else {
                            compressedPtrValue = DataType.getProcess().getPointerAt(slot.getAddress());
                        }
                        padding(out, tabLevel);
                        out.println(String.format("[%d] = !fj9object 0x%x = !j9object 0x%x", index, compressedPtrValue, ObjectReferencePointer.cast(slot).at(0).longValue()));
                    } else {
                        padding(out, tabLevel);
                        out.println(String.format("[%d] = null", slot));
                    }
                }
                break;
        }
    }
    /* check if it just printed a range; if so, give cmd to see all data */
    arraySize = J9IndexableObjectHelper.size(array);
    if (begin > 0 || arraySize.longValue() > finish) {
        out.println(String.format("To print entire range: !j9indexableobject %s %d %d\n", array.getHexAddress(), 0, arraySize.longValue()));
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) U32(com.ibm.j9ddr.vm29.types.U32)

Example 34 with VoidPointer

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

the class LiveSetWalker method scanObject.

private static void scanObject(HashSet<J9ObjectPointer> visitedObjects, ObjectVisitor visitor, J9ObjectPointer object, VoidPointer address) {
    if (visitedObjects.contains(object)) {
        return;
    }
    if (!visitor.visit(object, address)) {
        return;
    }
    visitedObjects.add(object);
    try {
        GCObjectIterator objectIterator = GCObjectIterator.fromJ9Object(object, true);
        GCObjectIterator addressIterator = GCObjectIterator.fromJ9Object(object, true);
        while (objectIterator.hasNext()) {
            J9ObjectPointer slot = objectIterator.next();
            VoidPointer addr = addressIterator.nextAddress();
            if (slot.notNull()) {
                scanObject(visitedObjects, visitor, slot, addr);
            }
        }
        if (J9ObjectHelper.getClassName(object).equals("java/lang/Class")) {
            J9ClassPointer clazz = ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object);
            // Iterate the Object slots
            GCClassIterator classIterator = GCClassIterator.fromJ9Class(clazz);
            GCClassIterator classAddressIterator = GCClassIterator.fromJ9Class(clazz);
            while (classIterator.hasNext()) {
                J9ObjectPointer slot = classIterator.next();
                VoidPointer addr = classAddressIterator.nextAddress();
                if (slot.notNull()) {
                    scanObject(visitedObjects, visitor, slot, addr);
                }
            }
            // Iterate the Class slots
            GCClassIteratorClassSlots classSlotIterator = GCClassIteratorClassSlots.fromJ9Class(clazz);
            GCClassIteratorClassSlots classSlotAddressIterator = GCClassIteratorClassSlots.fromJ9Class(clazz);
            while (classSlotIterator.hasNext()) {
                J9ClassPointer slot = classSlotIterator.next();
                VoidPointer addr = classSlotAddressIterator.nextAddress();
                J9ObjectPointer classObject = ConstantPoolHelpers.J9VM_J9CLASS_TO_HEAPCLASS(slot);
                if (classObject.notNull()) {
                    scanObject(visitedObjects, visitor, classObject, addr);
                }
            }
        }
    } catch (CorruptDataException e) {
        EventManager.raiseCorruptDataEvent("Corruption found while walking the live set, object: " + object.getHexAddress(), e, false);
    }
    visitor.finishVisit(object, address);
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) GCClassIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassIterator) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) GCObjectIterator(com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) GCClassIteratorClassSlots(com.ibm.j9ddr.vm29.j9.gc.GCClassIteratorClassSlots)

Example 35 with VoidPointer

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

the class LiveSetWalker method walkLiveSet.

/*
	 * Walks the LiveSet in preorder, returns a HashSet of all walked objects.  The HashSet is generated as a byproduct of the walk.
	 * 
	 * @return a HashSet containing all visited objects 
	 */
public static void walkLiveSet(ObjectVisitor visitor, RootSetType rootSetType) throws CorruptDataException {
    /* TODO: lpnguyen, use something less stupid than a hashSet (markMap?) for this */
    HashSet<J9ObjectPointer> visitedObjects = new HashSet<J9ObjectPointer>();
    /* Not using a singleton because we want to allow users to catch corruptData events.  Not worrying about the perf loss taken
		 * by doing this as walking the live set will probably take an order of magnitude longer anyway
		 */
    RootSet rootSet = RootSet.from(rootSetType, false);
    GCIterator rootIterator = rootSet.gcIterator(rootSetType);
    GCIterator rootAddressIterator = rootSet.gcIterator(rootSetType);
    while (rootIterator.hasNext()) {
        J9ObjectPointer nextObject = (J9ObjectPointer) rootIterator.next();
        VoidPointer nextAddress = rootAddressIterator.nextAddress();
        if (nextObject.notNull()) {
            scanObject(visitedObjects, visitor, nextObject, nextAddress);
        }
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) GCIterator(com.ibm.j9ddr.vm29.j9.gc.GCIterator) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) HashSet(java.util.HashSet)

Aggregations

VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)48 CorruptDataException (com.ibm.j9ddr.CorruptDataException)37 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)15 NoSuchElementException (java.util.NoSuchElementException)13 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)9 UDATA (com.ibm.j9ddr.vm29.types.UDATA)9 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)5 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)5 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)5 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)4 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)3 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)3 CorruptData (com.ibm.dtfj.image.CorruptData)2 JavaObject (com.ibm.dtfj.java.JavaObject)2 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)2 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)2 GCJNIGlobalReferenceIterator (com.ibm.j9ddr.vm29.j9.gc.GCJNIGlobalReferenceIterator)2 GCJNIWeakGlobalReferenceIterator (com.ibm.j9ddr.vm29.j9.gc.GCJNIWeakGlobalReferenceIterator)2 GCObjectIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator)2 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)2