Search in sources :

Example 16 with U8Pointer

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

the class CStringFieldFormatter 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 == StructureTypeManager.TYPE_POINTER) {
        CTypeParser parser = new CTypeParser(declaredType);
        if (parser.getCoreType().equals("char") && parser.getSuffix().equals("*")) {
            U8Pointer ptr = U8Pointer.cast(PointerPointer.cast(address).at(0));
            if (ptr.isNull()) {
                return FormatWalkResult.KEEP_WALKING;
            }
            String str = ptr.getCStringAtOffset(0, MAXIMUM_LENGTH);
            if (str.length() > 0) {
                out.print(" // \"");
                out.print(str);
                if (str.length() >= MAXIMUM_LENGTH) {
                    out.print("...");
                }
                out.print("\"");
            }
        }
    }
    return FormatWalkResult.KEEP_WALKING;
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) CTypeParser(com.ibm.j9ddr.CTypeParser)

Example 17 with U8Pointer

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

the class J9ObjectStructureFormatter method printObjectField.

public void printObjectField(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, J9ClassPointer fromClass, J9ObjectFieldOffset objectFieldOffset) throws CorruptDataException {
    J9ROMFieldShapePointer fieldShape = objectFieldOffset.getField();
    UDATA fieldOffset = objectFieldOffset.getOffsetOrAddress();
    boolean isHiddenField = objectFieldOffset.isHidden();
    String className = J9UTF8Helper.stringValue(fromClass.romClass().className());
    String fieldName = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().name());
    String fieldSignature = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().signature());
    U8Pointer valuePtr = dataStart;
    valuePtr = valuePtr.add(fieldOffset);
    padding(out, tabLevel);
    out.print(String.format("%s %s = ", fieldSignature, fieldName));
    if (fieldShape.modifiers().anyBitsIn(J9FieldSizeDouble)) {
        out.print(U64Pointer.cast(valuePtr).at(0).getHexValue());
    } else if (fieldShape.modifiers().anyBitsIn(J9FieldFlagObject)) {
        AbstractPointer ptr = J9BuildFlags.gc_compressedPointers ? U32Pointer.cast(valuePtr) : UDATAPointer.cast(valuePtr);
        out.print(String.format("!fj9object 0x%x", ptr.at(0).longValue()));
    } else {
        out.print(I32Pointer.cast(valuePtr).at(0).getHexValue());
    }
    out.print(String.format(" (offset=%d) (%s)", fieldOffset.longValue(), className));
    if (isHiddenField) {
        out.print(" <hidden>");
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 18 with U8Pointer

use of com.ibm.j9ddr.vm29.pointer.U8Pointer 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 19 with U8Pointer

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

the class J9ObjectStructureFormatter method formatArrayObject.

private void formatArrayObject(PrintStream out, J9ClassPointer localClazz, U8Pointer dataStart, J9IndexableObjectPointer localObject, int begin, int end) throws CorruptDataException {
    String className = J9IndexableObjectHelper.getClassName(localObject);
    out.print(String.format("!J9IndexableObject %s {", localObject.getHexAddress()));
    out.println();
    /* print individual fields */
    out.println(String.format("    struct J9Class* clazz = !j9arrayclass 0x%X   // %s", localClazz.getAddress(), className));
    out.println(String.format("    Object flags = %s;", J9IndexableObjectHelper.flags(localObject).getHexValue()));
    U32 size = J9IndexableObjectHelper.size(localObject);
    if (!J9BuildFlags.thr_lockNursery) {
        out.println(String.format("    j9objectmonitor_t monitor = %s;", J9IndexableObjectHelper.monitor(localObject).getHexValue()));
    }
    if (size.anyBitsIn(0x80000000)) {
        out.println(String.format("    U_32 size = %s; // Size exceeds Integer.MAX_VALUE!", size.getHexValue()));
    } else {
        out.println(String.format("    U_32 size = %s;", size.getHexValue()));
    }
    printSubArrayType(out, 1, localClazz, dataStart, begin, end, localObject);
    out.println("}");
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32)

Example 20 with U8Pointer

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

the class DTFJJavaMethod method getBytecodeSections.

@SuppressWarnings("rawtypes")
public Iterator getBytecodeSections() {
    if (byteCodeSections == null) {
        byteCodeSections = new ArrayList<Object>();
        try {
            J9ROMMethodPointer originalRomMethod = ROMHelp.getOriginalROMMethod(j9ramMethod);
            if (!originalRomMethod.modifiers().anyBitsIn(J9JavaAccessFlags.J9AccNative)) {
                U8Pointer bcStart = ROMHelp.J9_BYTECODE_START_FROM_ROM_METHOD(originalRomMethod);
                UDATA bcSize = ROMHelp.J9_BYTECODE_SIZE_FROM_ROM_METHOD(originalRomMethod);
                J9DDRImageSection is = DTFJContext.getImageSection(bcStart.getAddress(), "bytecode section at " + j9ramMethod.bytecodes().getAddress());
                is.setSize(bcSize.longValue());
                byteCodeSections.add(is);
                if (!j9romMethod.equals(originalRomMethod)) {
                    is = DTFJContext.getImageSection(j9ramMethod.bytecodes().getAddress(), "bytecode section at " + j9ramMethod.bytecodes().getAddress());
                    is.setSize(bcSize.longValue());
                    byteCodeSections.add(is);
                }
            }
        } catch (Throwable t) {
            CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
            byteCodeSections.add(cd);
        }
    }
    return byteCodeSections.iterator();
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRImageSection(com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)

Aggregations

U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)37 CorruptDataException (com.ibm.j9ddr.CorruptDataException)11 UDATA (com.ibm.j9ddr.vm29.types.UDATA)11 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)8 U32 (com.ibm.j9ddr.vm29.types.U32)8 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)7 U8 (com.ibm.j9ddr.vm29.types.U8)7 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)5 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)5 U16 (com.ibm.j9ddr.vm29.types.U16)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)4 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)4 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)3 WalkState (com.ibm.j9ddr.vm29.j9.stackwalker.WalkState)3 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)3 CorruptData (com.ibm.dtfj.image.CorruptData)2 StackWalkResult (com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)2 LocalVariableTable (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTable)2 LocalVariableTableIterator (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTableIterator)2 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)2