Search in sources :

Example 21 with U32Pointer

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

the class J9BCUtil method dumpMethodAnnotations.

private static void dumpMethodAnnotations(PrintStream out, J9ROMMethodPointer romMethod) throws CorruptDataException {
    U32Pointer methodAnnotationData = ROMHelp.getMethodAnnotationsDataFromROMMethod(romMethod);
    U32Pointer parametersAnnotationData = ROMHelp.getParameterAnnotationsDataFromROMMethod(romMethod);
    U32Pointer defaultAnnotationData = ROMHelp.getDefaultAnnotationDataFromROMMethod(romMethod);
    U32Pointer methodTypeAnnotations = ROMHelp.getMethodTypeAnnotationDataFromROMMethod(romMethod);
    U32Pointer codeTypeAnnotations = ROMHelp.getCodeTypeAnnotationDataFromROMMethod(romMethod);
    if ((!methodAnnotationData.isNull()) || (!parametersAnnotationData.isNull()) || (!defaultAnnotationData.isNull())) {
        J9ROMNameAndSignaturePointer nameAndSignature = romMethod.nameAndSignature();
        J9UTF8Pointer name = nameAndSignature.name();
        J9UTF8Pointer signature = nameAndSignature.signature();
        out.append("      Name: " + J9UTF8Helper.stringValue(name) + nl);
        out.append("      Signature: " + J9UTF8Helper.stringValue(signature) + nl);
    }
    if (!methodAnnotationData.isNull()) {
        U32 length = methodAnnotationData.at(0);
        U32Pointer data = methodAnnotationData.add(1);
        out.append(String.format("      Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!parametersAnnotationData.isNull()) {
        U32 length = parametersAnnotationData.at(0);
        U32Pointer data = parametersAnnotationData.add(1);
        out.append(String.format("      Parameters Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!defaultAnnotationData.isNull()) {
        U32 length = defaultAnnotationData.at(0);
        U32Pointer data = defaultAnnotationData.add(1);
        out.append(String.format("      Default Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!methodTypeAnnotations.isNull()) {
        U32 length = methodTypeAnnotations.at(0);
        U32Pointer data = methodTypeAnnotations.add(1);
        out.append(String.format("      Method Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!codeTypeAnnotations.isNull()) {
        U32 length = codeTypeAnnotations.at(0);
        U32Pointer data = codeTypeAnnotations.add(1);
        out.append(String.format("      Code Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
}
Also used : J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) U32(com.ibm.j9ddr.vm29.types.U32) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 22 with U32Pointer

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

the class VMConstantPoolCommand method run.

/**
 * Run method for !vmconstantpool extension.
 *
 * @param command  !vmconstantpool
 * @param args	args passed by !vmconstantpool extension.
 * @param context Context
 * @param out PrintStream
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer javaVM;
        javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (args.length == 1) {
            long vmaddress = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
            if (vmaddress != javaVM.getAddress()) {
                out.println(args[0] + " is not a valid j9javavm address. Run !findvm to find out the j9javavm address of the current context");
                return;
            }
        } else if (args.length > 1) {
            printUsage(out);
        }
        J9ConstantPoolPointer jclConstantPool = J9ConstantPoolPointer.cast(javaVM.jclConstantPoolEA());
        J9ROMClassPointer romClass = jclConstantPool.ramClass().romClass();
        int index;
        U32Pointer cpShapeDescription;
        int constPoolCount;
        cpShapeDescription = romClass.cpShapeDescription();
        long cpDescription = cpShapeDescription.at(0).longValue();
        constPoolCount = romClass.romConstantPoolCount().intValue();
        PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
        long cpDescriptionIndex = 0;
        for (index = 0; index < constPoolCount; index++) {
            if (0 == cpDescriptionIndex) {
                // Load a new description word
                cpDescription = cpShapeDescription.at(0).longValue();
                cpShapeDescription = cpShapeDescription.add(1);
                cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
            }
            long shapeDesc = cpDescription & J9_CP_DESCRIPTION_MASK;
            AbstractPointer ref = PointerPointer.NULL;
            if (shapeDesc == J9CPTYPE_CLASS) {
                ref = J9ROMClassRefPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_STRING) {
                ref = J9ROMStringRefPointer.cast(cpEntry);
            } else if ((shapeDesc == J9CPTYPE_INT) || (shapeDesc == J9CPTYPE_FLOAT)) {
                ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_LONG) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Long at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.getHexValue() + "\n}");
            } else if (shapeDesc == J9CPTYPE_DOUBLE) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Double at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_FIELD)) {
                long classRefCPIndex;
                if (shapeDesc == J9CPTYPE_FIELD) {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    /* gets the classRefCPIndex to obtain a pointer to the j9romclassref */
                    classRefCPIndex = J9ROMFieldRefPointer.cast(ref).classRefCPIndex().longValue();
                } else {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    classRefCPIndex = J9ROMMethodRefPointer.cast(ref).classRefCPIndex().longValue();
                }
                PointerPointer classRefCPEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass)).addOffset(J9ROMConstantPoolItem.SIZEOF * classRefCPIndex);
                /* gets the DDR output of the item */
                String outString = ref.formatFullInteractive();
                String[] parts = outString.split(nl);
                /* add a debug extension(!j9romclassref) on the second line of the output */
                parts[1] += "(!j9romclassref " + classRefCPEntry.getHexAddress() + ")";
                out.print(join(nl, parts));
            } else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Unused at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if (ref.notNull()) {
                out.println(ref.formatFullInteractive());
            }
            cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
            cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
            cpDescriptionIndex -= 1;
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) U64Pointer(com.ibm.j9ddr.vm29.pointer.U64Pointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 23 with U32Pointer

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

the class CheckReporterTTY method reportObjectHeader.

@Override
public void reportObjectHeader(CheckError error, J9ObjectPointer object, String prefix) {
    String prefixString = prefix == null ? "" : prefix;
    if (!shouldReport(error)) {
        return;
    }
    boolean isValid = false;
    boolean isHole = false;
    boolean isIndexable = false;
    try {
        isHole = ObjectModel.isDeadObject(object);
        if (!isHole) {
            isIndexable = ObjectModel.isIndexable(object);
        }
        isValid = true;
    } catch (CorruptDataException cde) {
    }
    if (isValid) {
        if (isIndexable) {
            out.print(String.format("  <gc check (%d): %sIObject %x header:", error._errorNumber, prefixString, object.getAddress()));
        } else {
            String elementName = isHole ? "Hole" : "Object";
            out.print(String.format("  <gc check (%d): %s%s %x header:", error._errorNumber, prefixString, elementName, object.getAddress()));
        }
    } else {
        out.print(String.format("  <gc check (%d): %s%s %x header:", error._errorNumber, prefixString, "Corrupt", object.getAddress()));
    }
    int headerSize = (int) J9Object.SIZEOF;
    if (isHole) {
        headerSize = (int) MM_HeapLinkedFreeHeader.SIZEOF;
    } else {
        try {
            headerSize = ObjectModel.getHeaderSize(object).intValue();
        } catch (CorruptDataException cde) {
        }
    }
    try {
        U32Pointer data = U32Pointer.cast(object);
        for (int i = 0; i < headerSize / U32.SIZEOF; i++) {
            out.print(String.format(" %08X", data.at(i).longValue()));
        }
    } catch (CorruptDataException cde) {
    }
    out.println(">");
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Aggregations

U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)19 U32 (com.ibm.j9ddr.vm29.types.U32)7 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)4 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)4 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 AbstractPointer (com.ibm.j9ddr.vm29.pointer.AbstractPointer)2 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)2 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)2 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)2 J9RAMClassRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMClassRefPointer)2 J9RAMMethodHandleRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodHandleRefPointer)2 J9RAMMethodTypeRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodTypeRefPointer)2 J9RAMStringRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMStringRefPointer)2 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)2 J9ROMFieldRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldRefPointer)2 J9ROMMethodHandleRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodHandleRefPointer)2 J9ROMMethodRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodRefPointer)2 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1