Search in sources :

Example 26 with J9ROMMethodPointer

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

the class J9BCUtil method dumpNative.

private static void dumpNative(PrintStream out, J9ROMMethodPointer romMethod, long flags) throws CorruptDataException {
    U8Pointer bytecodes = J9ROMMethodHelper.bytecodes(romMethod);
    long argCount = bytecodes.at(0).longValue();
    U8 returnType = bytecodes.at(1);
    U8Pointer currentDescription = bytecodes.add(2);
    String[] descriptions = new String[] { "void", "boolean", "byte", "char", "short", "float", "int", "double", "long", "object" };
    out.append(String.format("  Argument Count: %d", romMethod.argCount().longValue()));
    out.append(nl);
    out.append(String.format("  Temp Count: %d", romMethod.tempCount().longValue()));
    out.append(nl);
    out.append(String.format("  Native Argument Count: %d, types: (", argCount));
    for (long i = argCount; i > 0; i--) {
        out.append(descriptions[currentDescription.at(0).intValue()]);
        currentDescription = currentDescription.add(1);
        if (i != 1) {
            out.append(",");
        }
    }
    out.append(String.format(") %s ", descriptions[returnType.intValue()]));
    out.append(nl);
}
Also used : U8(com.ibm.j9ddr.vm29.types.U8) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 27 with J9ROMMethodPointer

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

the class J9BCUtil method dumpMethodDebugInfo.

private static void dumpMethodDebugInfo(PrintStream out, J9ROMClassPointer romClass, J9ROMMethodPointer romMethod, long flags) throws CorruptDataException {
    J9MethodDebugInfoPointer methodInfo;
    if ((flags & J9BCTranslationData.BCT_StripDebugAttributes) == 0) {
        methodInfo = getMethodDebugInfoFromROMMethod(romMethod);
        if (!methodInfo.isNull()) {
            out.append(nl);
            out.append("  Debug Info:");
            out.append(nl);
            out.append(String.format("    Line Number Table (%d):", J9MethodDebugInfoHelper.getLineNumberCount(methodInfo).intValue()));
            out.append(nl);
            LineNumberIterator lineNumberIterator = LineNumberIterator.lineNumberIteratorFor(methodInfo);
            while (lineNumberIterator.hasNext()) {
                LineNumber lineNumber = lineNumberIterator.next();
                if (null == lineNumber) {
                    out.append("      Bad compressed data \n");
                    U8Pointer currentLineNumberPtr = lineNumberIterator.getLineNumberTablePtr();
                    int sizeLeft = J9MethodDebugInfoHelper.getLineNumberCompressedSize(methodInfo).sub((currentLineNumberPtr.sub(J9MethodDebugInfoHelper.getLineNumberTableForROMClass(methodInfo)))).intValue();
                    while (0 < sizeLeft--) {
                        out.append("      " + currentLineNumberPtr.at(0));
                        out.append(nl);
                        currentLineNumberPtr = currentLineNumberPtr.add(1);
                    }
                    break;
                } else {
                    out.append(String.format("      Line: %5d PC: %5d", lineNumber.getLineNumber().longValue(), lineNumber.getLocation().longValue()));
                    out.append(nl);
                }
            }
            out.append(nl);
            out.append(String.format("    Variables (%d):", methodInfo.varInfoCount().longValue()));
            out.append(nl);
            LocalVariableTableIterator variableInfoValuesIterator = LocalVariableTableIterator.localVariableTableIteratorFor(methodInfo);
            while (variableInfoValuesIterator.hasNext()) {
                LocalVariableTable values = variableInfoValuesIterator.next();
                out.append(String.format("      Slot: %d", values.getSlotNumber().intValue()));
                out.append(nl);
                out.append(String.format("      Visibility Start: %d", values.getStartVisibility().intValue()));
                out.append(nl);
                out.append(String.format("      Visibility End: %d", values.getStartVisibility().intValue() + values.getVisibilityLength().intValue()));
                out.append(nl);
                out.append(String.format("      Visibility Length: %d", values.getVisibilityLength().intValue()));
                out.append(nl);
                out.append("      Name: ");
                if ((null != values.getName()) && (!values.getName().isNull())) {
                    out.append(String.format("%s", J9UTF8Helper.stringValue(values.getName())));
                } else {
                    out.append("None");
                }
                out.append(nl);
                out.append("      Signature: ");
                if ((null != values.getSignature()) && (!values.getSignature().isNull())) {
                    out.append(String.format("%s", J9UTF8Helper.stringValue(values.getSignature())));
                } else {
                    out.append("None");
                }
                out.append(nl);
                out.append("      Generic Signature: ");
                if ((null != values.getGenericSignature()) && (!values.getGenericSignature().isNull())) {
                    out.append(String.format("%s", J9UTF8Helper.stringValue(values.getGenericSignature())));
                } else {
                    out.append("None");
                }
                out.append(nl);
            }
        }
    }
}
Also used : LocalVariableTable(com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTable) J9MethodDebugInfoPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodDebugInfoPointer) LineNumberIterator(com.ibm.j9ddr.vm29.j9.walkers.LineNumberIterator) LocalVariableTableIterator(com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTableIterator) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) LineNumber(com.ibm.j9ddr.vm29.j9.walkers.LineNumber)

Example 28 with J9ROMMethodPointer

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

the class J9BCUtil method j9bcutil_dumpRomMethod.

/*
	 * Dump a printed representation of the specified @romMethod.
	 */
/* note that methodIndex was not used and was removed */
public static void j9bcutil_dumpRomMethod(PrintStream out, J9ROMMethodPointer romMethod, J9ROMClassPointer romClass, long flags, int options) throws CorruptDataException {
    J9ROMNameAndSignaturePointer nameAndSignature = romMethod.nameAndSignature();
    J9UTF8Pointer name = nameAndSignature.name();
    J9UTF8Pointer signature = nameAndSignature.signature();
    J9ROMConstantPoolItemPointer constantPool = J9ROMClassHelper.constantPool(romClass);
    out.append("  Name: " + J9UTF8Helper.stringValue(name) + nl);
    out.append("  Signature: " + J9UTF8Helper.stringValue(signature) + nl);
    out.append(String.format("  Access Flags (%s): ", Long.toHexString(romMethod.modifiers().longValue())));
    dumpModifiers(out, romMethod.modifiers().longValue(), MODIFIERSOURCE_METHOD, INCLUDE_INTERNAL_MODIFIERS);
    out.append(nl);
    out.append("  Max Stack: " + romMethod.maxStack().longValue() + nl);
    if (J9ROMMethodHelper.hasExceptionInfo(romMethod)) {
        J9ExceptionInfoPointer exceptionData = ROMHelp.J9_EXCEPTION_DATA_FROM_ROM_METHOD(romMethod);
        long catchCount = exceptionData.catchCount().longValue();
        if (catchCount > 0) {
            J9ExceptionHandlerPointer handler = ROMHelp.J9EXCEPTIONINFO_HANDLERS(exceptionData);
            out.append(String.format("  Caught Exceptions (%d):", catchCount));
            out.append(nl);
            out.append("     start   end   handler   catch type" + nl);
            out.append("     -----   ---   -------   ----------" + nl);
            for (int i = 0; i < catchCount; i++) {
                out.append(String.format("     %d  %d  %d   ", handler.startPC().longValue(), handler.endPC().longValue(), handler.handlerPC().longValue()));
                long exceptionClassIndex = handler.exceptionClassIndex().longValue();
                if (exceptionClassIndex != 0) {
                    J9ROMConstantPoolItemPointer addOffset = constantPool.add(exceptionClassIndex);
                    J9ROMStringRefPointer romStringRefPointer = J9ROMStringRefPointer.cast(addOffset.longValue());
                    out.append(J9UTF8Helper.stringValue(romStringRefPointer.utf8Data()));
                } else {
                    out.append("(any)");
                }
                out.append(nl);
                handler = handler.add(1);
            }
        }
        long throwCount = exceptionData.throwCount().longValue();
        if (throwCount > 0) {
            out.append(String.format("  Thrown Exceptions (%d):", throwCount));
            out.append(nl);
            SelfRelativePointer currentThrowName = ROMHelp.J9EXCEPTIONINFO_THROWNAMES(exceptionData);
            for (long i = 0; i < throwCount; i++) {
                J9UTF8Pointer currentName = J9UTF8Pointer.cast(currentThrowName.get());
                out.append(J9UTF8Helper.stringValue(currentName));
            }
        }
    }
    if (romMethod.modifiers().anyBitsIn(J9CfrClassFile.CFR_ACC_NATIVE)) {
        dumpNative(out, romMethod, flags);
    } else {
        dumpBytecodes(out, romClass, romMethod, flags);
    }
    dumpMethodDebugInfo(out, romClass, romMethod, flags);
    dumpStackMapTable(out, romClass, romMethod, flags);
    dumpMethodParameters(out, romClass, romMethod, flags);
    if (0 != (BCUtil_DumpAnnotations & options)) {
        dumpMethodAnnotations(out, romMethod);
    }
    out.append(nl);
}
Also used : J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) J9ROMConstantPoolItemPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer) SelfRelativePointer(com.ibm.j9ddr.vm29.pointer.SelfRelativePointer) J9ROMStringRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) J9ExceptionHandlerPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ExceptionHandlerPointer) J9ExceptionInfoPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ExceptionInfoPointer)

Example 29 with J9ROMMethodPointer

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

the class J9BCUtil method dumpMethodParameters.

private static void dumpMethodParameters(PrintStream out, J9ROMClassPointer romclass, J9ROMMethodPointer romMethod, long flags) throws CorruptDataException {
    J9MethodParametersDataPointer methodParameters = ROMHelp.getMethodParametersFromROMMethod(romMethod);
    if (methodParameters != J9MethodParametersDataPointer.NULL) {
        J9MethodParameterPointer parameters = methodParameters.parameters();
        out.println(String.format("  Method Parameters (%d):\n", methodParameters.parameterCount().longValue()));
        for (int i = 0; i < methodParameters.parameterCount().longValue(); i++) {
            J9UTF8Pointer name = J9UTF8Pointer.cast(parameters.nameEA().get());
            long parameterFlags = parameters.flags().longValue();
            if (name.isNull()) {
                out.print("    <no name>");
            } else {
                out.print("    " + J9UTF8Helper.stringValue(name));
            }
            out.print(String.format("    0x%x ( ", parameterFlags));
            dumpModifiers(out, parameterFlags, ONLY_SPEC_MODIFIERS, MODIFIERSOURCE_METHODPARAMETER);
            out.println(" )\n");
        }
        out.println("\n");
    }
}
Also used : J9MethodParametersDataPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodParametersDataPointer) J9MethodParameterPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodParameterPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)

Example 30 with J9ROMMethodPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer 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)

Aggregations

J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)22 CorruptDataException (com.ibm.j9ddr.CorruptDataException)10 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)10 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)9 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)7 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)7 U32 (com.ibm.j9ddr.vm29.types.U32)6 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)5 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)5 UDATA (com.ibm.j9ddr.vm29.types.UDATA)5 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)4 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)4 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)3 J9ROMClassAndMethod (com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)3 U16 (com.ibm.j9ddr.vm29.types.U16)3 U8 (com.ibm.j9ddr.vm29.types.U8)3 J9ROMFieldShapeIterator (com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator)2 J9ExceptionInfoPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ExceptionInfoPointer)2 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)2 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)2