Search in sources :

Example 11 with J9Object

use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.

the class J9ObjectStructureFormatter method format.

@Override
public FormatWalkResult format(String type, long address, PrintStream out, Context context, List<IFieldFormatter> fieldFormatters, String[] extraArgs) {
    if (type.equalsIgnoreCase("j9object") || type.equalsIgnoreCase("j9indexableobject")) {
        J9ClassPointer clazz = null;
        J9ObjectPointer object = null;
        try {
            boolean isArray;
            String className;
            object = J9ObjectPointer.cast(address);
            clazz = J9ObjectHelper.clazz(object);
            if (clazz.isNull()) {
                out.println("<can not read RAM class address>");
                return FormatWalkResult.STOP_WALKING;
            }
            isArray = J9ClassHelper.isArrayClass(clazz);
            className = J9UTF8Helper.stringValue(clazz.romClass().className());
            U8Pointer dataStart = U8Pointer.cast(object).add(ObjectModel.getHeaderSize(object));
            if (className.equals("java/lang/String")) {
                formatStringObject(out, 0, clazz, dataStart, object);
            } else if (isArray) {
                int begin = DEFAULT_ARRAY_FORMAT_BEGIN;
                int end = DEFAULT_ARRAY_FORMAT_END;
                if (extraArgs.length > 0) {
                    begin = Integer.parseInt(extraArgs[0]);
                }
                if (extraArgs.length > 1) {
                    end = Integer.parseInt(extraArgs[1]);
                }
                formatArrayObject(out, clazz, dataStart, J9IndexableObjectPointer.cast(object), begin, end);
            } else {
                formatObject(out, clazz, dataStart, object);
            }
        } catch (MemoryFault ex2) {
            out.println("Unable to read object clazz at " + object.getHexAddress() + " (clazz = " + clazz.getHexAddress() + ")");
        } catch (CorruptDataException ex) {
            out.println("Error for ");
            ex.printStackTrace(out);
        }
        return FormatWalkResult.STOP_WALKING;
    } else {
        return FormatWalkResult.KEEP_WALKING;
    }
}
Also used : MemoryFault(com.ibm.j9ddr.corereaders.memory.MemoryFault) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Aggregations

J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)6 CorruptDataException (com.ibm.j9ddr.CorruptDataException)4 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)4 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)3 U32 (com.ibm.j9ddr.vm29.types.U32)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 Table (com.ibm.j9ddr.tools.ddrinteractive.Table)2 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)2 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)2 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)2 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 J9ROMFieldShapePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)2 UDATA (com.ibm.j9ddr.vm29.types.UDATA)2 InvalidDataTypeException (com.ibm.j9ddr.InvalidDataTypeException)1 MemoryFault (com.ibm.j9ddr.corereaders.memory.MemoryFault)1 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)1 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)1 GCHeapRegionIterator (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator)1 GCHeapRegionManager (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionManager)1 GCObjectHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator)1