Search in sources :

Example 6 with J9UTF8Pointer

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

the class VmCheckCommand method verifyJ9ROMClass.

private void verifyJ9ROMClass(PrintStream out, J9JavaVMPointer vm, J9ClassPointer clazz) throws CorruptDataException {
    J9ROMClassPointer romClass = clazz.romClass();
    J9ClassLoaderPointer classLoader = clazz.classLoader();
    J9MemorySegmentPointer segment = findSegmentInClassLoaderForAddress(classLoader, romClass);
    if (!segment.isNull()) {
        long address;
        if (romClass.interfaceCount().longValue() != 0) {
            address = romClass.interfaces().getAddress();
            verifyAddressInSegment(out, vm, segment, address, "romClass->interfaces");
        }
        if (romClass.romMethodCount().longValue() != 0) {
            address = romClass.romMethods().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->romMethods");
        }
        if (romClass.romFieldCount().longValue() != 0) {
            address = romClass.romFields().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->romFields");
        }
        if (romClass.innerClassCount().longValue() != 0) {
            address = romClass.innerClasses().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->innerClasses");
        }
        U32Pointer cpShapeDescription = romClass.cpShapeDescription();
        /* TODO: is !isNull() check required or not? */
        if (!cpShapeDescription.isNull()) {
            address = cpShapeDescription.getAddress();
            verifyAddressInSegment(out, vm, segment, address, "romClass->cpShapeDescription");
        }
    }
    {
        J9UTF8Pointer className = romClass.className();
        J9UTF8Pointer superclassName = romClass.superclassName();
        J9UTF8Pointer outerClassName = romClass.outerClassName();
        if (className.isNull() || !verifyUTF8(className)) {
            reportError(out, "invalid className=0x%s utf8 for romClass=0x%s", Long.toHexString(className.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!superclassName.isNull() && !verifyUTF8(superclassName)) {
            reportError(out, "invalid superclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(superclassName.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!outerClassName.isNull() && !verifyUTF8(outerClassName)) {
            reportError(out, "invalid outerclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(outerClassName.getAddress()), Long.toHexString(romClass.getAddress()));
        }
    }
    U32 ramConstantPoolCount = romClass.ramConstantPoolCount();
    U32 romConstantPoolCount = romClass.romConstantPoolCount();
    if (ramConstantPoolCount.gt(romConstantPoolCount)) {
        reportError(out, "ramConstantPoolCount=%d > romConstantPoolCount=%d for romClass=0x%s", ramConstantPoolCount.longValue(), romConstantPoolCount.longValue(), Long.toHexString(romClass.getAddress()));
    }
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 7 with J9UTF8Pointer

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

the class VmCheckCommand method checkLocalInternTableSanity.

/*
	 *  Based on vmchk/checkinterntable.c r1.3
	 * 
	 *	J9LocalInternTableSanity sanity:
	 *		if J9JavaVM->dynamicLoadBuffers != NULL
	 *			invariantInternTree check:
	 *				For each J9InternHashTableEntry
	 *					Ensure J9InternHashTableEntry->utf8 is valid
	 *					Ensure J9InternHashTableEntry->classLoader is valid
	 */
private void checkLocalInternTableSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
    int count = 0;
    reportMessage(out, "Checking ROM intern string nodes");
    J9TranslationBufferSetPointer dynamicLoadBuffers = vm.dynamicLoadBuffers();
    if (!dynamicLoadBuffers.isNull()) {
        J9DbgROMClassBuilderPointer romClassBuilder = J9DbgROMClassBuilderPointer.cast(dynamicLoadBuffers.romClassBuilder());
        J9DbgStringInternTablePointer stringInternTable = romClassBuilder.stringInternTable();
        J9InternHashTableEntryPointer node = stringInternTable.headNode();
        while (!node.isNull()) {
            J9UTF8Pointer utf8 = node.utf8();
            J9ClassLoaderPointer classLoader = node.classLoader();
            if (!verifyUTF8(utf8)) {
                reportError(out, "invalid utf8=0x%s for node=0x%s", Long.toHexString(utf8.getAddress()), Long.toHexString(node.getAddress()));
            }
            if (!verifyJ9ClassLoader(vm, classLoader)) {
                reportError(out, "invalid classLoader=0x%s for node=0x%s", Long.toHexString(classLoader.getAddress()), Long.toHexString(node.getAddress()));
            }
            count++;
            node = node.nextNode();
        }
    }
    reportMessage(out, "Checking %d ROM intern string nodes done", count);
}
Also used : J9TranslationBufferSetPointer(com.ibm.j9ddr.vm29.pointer.generated.J9TranslationBufferSetPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) J9DbgStringInternTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9DbgStringInternTablePointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) J9DbgROMClassBuilderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9DbgROMClassBuilderPointer) J9InternHashTableEntryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9InternHashTableEntryPointer)

Example 8 with J9UTF8Pointer

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

the class SendSlot method getSendSlotsFromSignature.

public static UDATA getSendSlotsFromSignature(J9UTF8Pointer signature) throws CorruptDataException {
    UDATA sendArgs = new UDATA(0);
    int i = 1;
    for (; ; i++) {
        switch(J9UTF8Helper.stringValue(signature).charAt(i)) {
            case ')':
                return sendArgs;
            case '[':
                /* skip all '['s */
                for (i++; J9UTF8Helper.stringValue(signature).charAt(i) == '['; i++) ;
                if (J9UTF8Helper.stringValue(signature).charAt(i) == 'L') {
                /* FALL THRU */
                } else {
                    sendArgs = sendArgs.add(1);
                    break;
                }
            case 'L':
                for (i++; J9UTF8Helper.stringValue(signature).charAt(i) != ';'; i++) ;
                sendArgs = sendArgs.add(1);
                break;
            case 'D':
            case 'J':
                sendArgs = sendArgs.add(2);
                break;
            default:
                /* any other primitive type */
                sendArgs = sendArgs.add(1);
                break;
        }
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA)

Example 9 with J9UTF8Pointer

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

the class FilteredROMMethodsIterator method next.

public J9ROMClassAndMethod next() {
    J9ROMClassAndMethod result = nextMethod;
    /* hasNext may have already go the next method */
    nextMethod = null;
    /* destructive read */
    if (null == result) {
        do {
            try {
                if ((null != currentRomMethod) && (remainingMethods > 0)) {
                    J9ROMMethodPointer romMethod = currentRomMethod;
                    J9ROMNameAndSignaturePointer nameAndSignature = romMethod.nameAndSignature();
                    J9UTF8Pointer methNameUTF = nameAndSignature.name();
                    String methName = J9UTF8Helper.stringValue(methNameUTF);
                    if (methodPattern.isMatch(methName)) {
                        String methSig = J9UTF8Helper.stringValue(nameAndSignature.signature());
                        if (signaturePattern.isMatch(methSig)) {
                            result = new J9ROMClassAndMethod(romMethod, currentRomClass);
                        }
                    }
                    currentRomMethod = ROMHelp.nextROMMethod(currentRomMethod);
                    --remainingMethods;
                } else {
                    if (!goToNextClass()) {
                        break;
                    /* ran out of classes */
                    }
                }
            } catch (CorruptDataException e) {
                throw new NoSuchElementException();
            }
        } while (null == result);
    }
    return result;
}
Also used : J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException) NoSuchElementException(java.util.NoSuchElementException) J9ROMClassAndMethod(com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)

Example 10 with J9UTF8Pointer

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

Aggregations

J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)12 U32 (com.ibm.j9ddr.vm29.types.U32)6 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)4 CorruptDataException (com.ibm.j9ddr.CorruptDataException)3 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)3 UDATA (com.ibm.j9ddr.vm29.types.UDATA)3 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)2 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)2 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)2 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)2 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)2 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)2 J9ROMFieldShapePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)2 J9ROMStringRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer)2 U16 (com.ibm.j9ddr.vm29.types.U16)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 PatternString (com.ibm.j9ddr.util.PatternString)1 J9ROMFieldShapeIterator (com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator)1 J9ROMClassAndMethod (com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)1