Search in sources :

Example 36 with J9ClassPointer

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

the class CheckEngine method checkClassHeap.

public int checkClassHeap(J9ClassPointer clazz, J9MemorySegmentPointer segment) {
    int result;
    /*
		 * Verify that this is, in fact, a class
		 */
    try {
        result = checkJ9Class(clazz, segment, _cycle.getCheckFlags());
        if (J9MODRON_GCCHK_RC_OK != result) {
            CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
            _reporter.report(error);
        }
        /*
			 * Process object slots in the class
			 */
        GCClassIterator classIterator = GCClassIterator.fromJ9Class(clazz);
        while (classIterator.hasNext()) {
            PointerPointer slotPtr = PointerPointer.cast(classIterator.nextAddress());
            J9ObjectPointer object = J9ObjectPointer.cast(slotPtr.at(0));
            result = checkObjectIndirect(object);
            if (J9MODRON_GCCHK_RC_OK != result) {
                String elementName = "";
                switch(classIterator.getState()) {
                    case GCClassIterator.state_statics:
                        elementName = "static ";
                        break;
                    case GCClassIterator.state_constant_pool:
                        elementName = "constant ";
                        break;
                    case GCClassIterator.state_slots:
                        elementName = "slots ";
                        break;
                }
                CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
            if (GCExtensions.isStandardGC()) {
                /* If the slot has its old bit OFF, the class's remembered bit should be ON */
                if (object.notNull() && !ObjectModel.isOld(object)) {
                    if (!ObjectModel.isRemembered(clazz.classObject())) {
                        CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REMEMBERED_SET_OLD_OBJECT, _cycle.nextErrorCount());
                        _reporter.report(error);
                        return J9MODRON_SLOT_ITERATOR_OK;
                    }
                }
            }
        }
        if (J9MODRON_GCCHK_RC_OK != checkClassStatics(clazz)) {
            return J9MODRON_SLOT_ITERATOR_OK;
        }
        J9ClassPointer replaced = clazz.replacedClass();
        if (replaced.notNull()) {
            if (!J9ClassHelper.isSwappedOut(replaced)) {
                CheckError error = new CheckError(clazz, clazz.replacedClassEA(), _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REPLACED_CLASS_HAS_NO_HOTSWAP_FLAG, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
        }
        /*
			 * Process class slots in the class
			 */
        GCClassIteratorClassSlots classIteratorClassSlots = GCClassIteratorClassSlots.fromJ9Class(clazz);
        while (classIteratorClassSlots.hasNext()) {
            PointerPointer classSlotPtr = PointerPointer.cast(classIteratorClassSlots.nextAddress());
            J9ClassPointer classSlot = J9ClassPointer.cast(classSlotPtr.at(0));
            String elementName = "";
            result = J9MODRON_GCCHK_RC_OK;
            switch(classIteratorClassSlots.getState()) {
                case GCClassIteratorClassSlots.state_constant_pool:
                    /* may be NULL */
                    if (classSlot.notNull()) {
                        result = checkJ9ClassPointer(classSlot);
                    }
                    elementName = "constant ";
                    break;
                case GCClassIteratorClassSlots.state_superclasses:
                    /* must not be NULL */
                    result = checkJ9ClassPointer(classSlot);
                    elementName = "superclass ";
                    break;
                case GCClassIteratorClassSlots.state_interfaces:
                    /* must not be NULL */
                    result = checkJ9ClassPointer(classSlot);
                    elementName = "interface ";
                    break;
                case GCClassIteratorClassSlots.state_array_class_slots:
                    /* may be NULL */
                    if (classSlot.notNull()) {
                        result = checkJ9ClassPointer(classSlot);
                    }
                    elementName = "array class ";
            }
            if (J9MODRON_GCCHK_RC_OK != result) {
                CheckError error = new CheckError(clazz, classSlotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
        }
    } catch (CorruptDataException e) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
        _reporter.report(error);
    }
    return J9MODRON_SLOT_ITERATOR_OK;
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) GCClassIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassIterator) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) GCClassIteratorClassSlots(com.ibm.j9ddr.vm29.j9.gc.GCClassIteratorClassSlots)

Example 37 with J9ClassPointer

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

the class J9MethodFieldFormatter method postFormat.

/* (non-Javadoc)
	 * @see com.ibm.j9ddr.tools.ddrinteractive.IFieldFormatter#postFormat(java.lang.String, java.lang.String, int, long, java.io.PrintStream, com.ibm.j9ddr.tools.ddrinteractive.Context, com.ibm.j9ddr.tools.ddrinteractive.IStructureFormatter)
	 */
@Override
public FormatWalkResult postFormat(String name, String type, String declaredType, int typeCode, long address, PrintStream out, Context context, IStructureFormatter structureFormatter) throws CorruptDataException {
    if (typeCode == TYPE_STRUCTURE_POINTER && StructureCommandUtil.typeToCommand(type).equals("!j9method")) {
        PointerPointer slotPtr = PointerPointer.cast(address);
        J9MethodPointer method = J9MethodPointer.cast(slotPtr.at(0));
        if (method.isNull()) {
            return FormatWalkResult.KEEP_WALKING;
        }
        out.print(" // ");
        J9ROMMethodPointer j9romMethod = J9MethodHelper.romMethod(method);
        J9ClassPointer clazz = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(method);
        out.print(J9ClassHelper.getName(clazz));
        out.print(".");
        out.print(J9ROMMethodHelper.getName(j9romMethod));
        out.print(J9ROMMethodHelper.getSignature(j9romMethod));
    }
    return FormatWalkResult.KEEP_WALKING;
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)

Example 38 with J9ClassPointer

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

the class J9MethodStructureFormatter method writeMethodName.

private static void writeMethodName(J9MethodPointer method, PrintStream out) {
    out.print("Signature: ");
    try {
        J9ROMMethodPointer j9romMethod = J9MethodHelper.romMethod(method);
        J9ClassPointer clazz = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(method);
        out.print(J9ClassHelper.getName(clazz));
        out.print(".");
        out.print(J9ROMMethodHelper.getName(j9romMethod));
        out.print(J9ROMMethodHelper.getSignature(j9romMethod));
        out.print(" !bytecodes ");
        out.print(method.getHexAddress());
    } catch (CorruptDataException ex) {
        out.print("<FAULT>");
    } finally {
        out.println();
    }
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 39 with J9ClassPointer

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

the class J9ObjectFieldFormatter method postFormat.

@Override
public FormatWalkResult postFormat(String name, String type, String declaredType, int typeCode, long address, PrintStream out, Context context, IStructureFormatter structureFormatter) throws CorruptDataException {
    if (typeCode == TYPE_STRUCTURE_POINTER && StructureCommandUtil.typeToCommand(type).equals("!j9object")) {
        PointerPointer slotPtr = PointerPointer.cast(address);
        J9ObjectPointer object = J9ObjectPointer.cast(slotPtr.at(0));
        if (object.isNull()) {
            return FormatWalkResult.KEEP_WALKING;
        }
        J9ClassPointer clazz = J9ObjectHelper.clazz(object);
        out.print(" // ");
        if (J9ClassHelper.isArrayClass(clazz)) {
            out.print(J9ClassHelper.getArrayName(clazz));
        } else {
            out.print(J9ClassHelper.getName(clazz));
        }
    }
    return FormatWalkResult.KEEP_WALKING;
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 40 with J9ClassPointer

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

the class DTFJJavaClass method getDeclaredFields.

@SuppressWarnings("rawtypes")
public Iterator getDeclaredFields() {
    List<Object> list = declaredFieldsCache.get(j9class);
    if (list == null) {
        list = new LinkedList<Object>();
        final List<Object> fieldList = list;
        IEventListener corruptDataListener = new IEventListener() {

            public void corruptData(String message, com.ibm.j9ddr.CorruptDataException e, boolean fatal) {
                J9DDRCorruptData cd = J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), e);
                fieldList.add(cd);
            }
        };
        try {
            register(corruptDataListener);
            J9ClassPointer superclass = J9ClassPointer.NULL;
            try {
                superclass = getSuperClassPointer();
            } catch (com.ibm.j9ddr.CorruptDataException e1) {
                // pass null for the superclass to just list this classes fields as cannot determine superclass
                fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Unable to determine superclass"));
            }
            U32 flags = new U32(J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC | J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE);
            long fieldCount = j9class.romClass().romFieldCount().longValue();
            Iterator<J9ObjectFieldOffset> fields = null;
            if (fieldCount > MAX_CLASS_FIELDS) {
                fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Corrupt field count"));
            } else {
                fields = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(j9class, superclass, flags);
            }
            while (fields != null && fields.hasNext()) {
                try {
                    J9ObjectFieldOffset field = fields.next();
                    log.fine(String.format("Declared field : %s", field.getName()));
                    if (field.isStatic()) {
                        fieldList.add(new DTFJJavaFieldStatic(this, field));
                    } else {
                        fieldList.add(new DTFJJavaFieldInstance(this, field));
                    }
                } catch (com.ibm.j9ddr.CorruptDataException e) {
                    // add the corrupted field to the iterator
                    fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), e));
                }
                if (fieldList.size() > fieldCount) {
                    // The class has returned more fields than it said it contained, it is corrupt.
                    // add the corrupted field to the iterator
                    fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Corrupt class returned more fields than it declared"));
                    break;
                }
            }
            /* Large lists of fields are likely to be corrupt data so
				 * don't cache them.
				 */
            if (fieldList.size() < 1024) {
                declaredFieldsCache.put(j9class, fieldList);
            }
        } catch (Throwable t) {
            fieldList.add(J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t));
        } finally {
            unregister(corruptDataListener);
        }
    }
    return list.iterator();
}
Also used : J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) IEventListener(com.ibm.j9ddr.events.IEventListener) U32(com.ibm.j9ddr.vm29.types.U32) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object)

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