Search in sources :

Example 36 with J9JavaVMPointer

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

the class RuntimeSettingsCommand method run.

/**
 * Run method for !runtimesettings extension.
 *
 * @param command  !runtimesettings
 * @param args	args passed by !runtimesettings extension.
 * @param context Context of current core file.
 * @param out PrintStream to print the output to the console.
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (0 < args.length) {
        out.println("!runtimesettings expects no args. Usage :");
        printUsage(out);
        return;
    }
    try {
        Long currentSoftmx;
        String qualifiedCurrentSoftmx = "";
        String initialSoftmx = "not set";
        J9RASPointer ras = DataType.getJ9RASPointer();
        J9JavaVMPointer vm = J9RASHelper.getVM(ras);
        IProcess process = vm.getProcess();
        J9DDRImageProcess ddrProcess = new J9DDRImageProcess(process);
        String cmdline;
        /* Parse the command line of a running program that generated core
			 * file to get the original -Xsoftmx setting
			 */
        cmdline = ddrProcess.getCommandLine();
        int start = cmdline.indexOf("-Xsoftmx");
        int length = "-Xsoftmx".length();
        int end = cmdline.indexOf(" ", start);
        if (-1 != start) {
            /* extract the value from the end of the option */
            initialSoftmx = cmdline.substring(start + length, end);
            initialSoftmx = initialSoftmx.toUpperCase();
        }
        currentSoftmx = new Long(GCExtensions.softMx().longValue());
        qualifiedCurrentSoftmx = currentSoftmx.toString();
        Matcher m = p.matcher(initialSoftmx);
        /* if initial softmx value is set on the command line as qualified
			 * value, print current softmx value in qualified form, otherwise
			 * print current in byte value
			 */
        if (m.matches()) {
            /* User may add multiple letters after the number on the command
				 * line, currently GC parser accepts this and simply ignores
				 * extra letters, so we need to do the same, set initialSoftmx
				 * to the first match of the pattern
				 */
            initialSoftmx = m.group(1);
            /* convert size in bytes held in currentSoftmx to canonical form */
            qualifiedCurrentSoftmx = qualifiedSize(currentSoftmx);
            /* If qualifiedSize() returns size in bytes, it could not
				 * convert the value, so print the initialSoftmx variable in
				 * bytes
				 */
            m = p.matcher(qualifiedCurrentSoftmx);
            if (!m.matches()) {
                initialSoftmx = sizeInBytes(initialSoftmx);
            }
        } else {
            /* InitialSoftmx value has either not been set or is in byte
				 * form, so print current value as byte form
				 */
            qualifiedCurrentSoftmx = currentSoftmx.toString();
        }
        printTableOfEqualSpacedColumns(out, new String[] { "name", "initial value", "current value" }, new String[][] { { "-Xsoftmx", initialSoftmx, qualifiedCurrentSoftmx } });
    } catch (DataUnavailable e) {
        /* For Z/OS core files, command line is not available */
        out.println("COMMANDLINE is not available\n");
    } catch (com.ibm.dtfj.image.CorruptDataException e) {
        throw new DDRInteractiveCommandException("CorruptDataException occured while getting the commandline from process");
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : Matcher(java.util.regex.Matcher) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9RASPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RASPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Example 37 with J9JavaVMPointer

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

the class VmCheckCommand method verifyJ9ClassHeader.

private boolean verifyJ9ClassHeader(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
    boolean passed = true;
    J9ROMClassPointer romClass = classPointer.romClass();
    String rootClasses = "java.lang.Object";
    if (false == J9ClassHelper.hasValidEyeCatcher(classPointer)) {
        reportError(out, "0x99669966 != eyecatcher (0x%s) for class=0x%s", Long.toHexString(classPointer.eyecatcher().longValue()), Long.toHexString(classPointer.getAddress()));
        passed = false;
    }
    if (romClass.isNull()) {
        reportError(out, "NULL == romClass for class=0x%s", Long.toHexString(classPointer.getAddress()));
        passed = false;
    }
    if (classPointer.classLoader().isNull()) {
        reportError(out, "NULL == classLoader for class=0x%s", Long.toHexString(classPointer.getAddress()));
        passed = false;
    }
    long classDepth = J9ClassHelper.classDepth(classPointer).longValue();
    if (classDepth > 0) {
        if (classPointer.superclasses().isNull()) {
            reportError(out, "NULL == superclasses for non-" + rootClasses + " class=0x%s", Long.toHexString(classPointer.getAddress()));
            passed = false;
        } else {
            // Verify that all entries of superclasses[] are non-null.
            for (long i = 0; i < classDepth; i++) {
                if (classPointer.superclasses().at(i).isNull()) {
                    reportError(out, "superclasses[%d] is NULL for class=0x%s", Long.toHexString(classPointer.getAddress()));
                    passed = false;
                    break;
                }
            }
        }
    } else {
        if (classPointer.superclasses().at(-1).notNull()) {
            reportError(out, "superclasses[-1] should be NULL for class=0x%s", Long.toHexString(classPointer.getAddress()));
            passed = false;
        }
    }
    if (classPointer.initializeStatus().eq(J9ClassInitFlags.J9ClassInitSucceeded)) {
        if (classPointer.classObject().isNull()) {
            reportError(out, "NULL == class->classObject for initialized class=0x%s", Long.toHexString(classPointer.getAddress()));
            passed = false;
        }
    }
    if (J9ClassHelper.isObsolete(classPointer)) {
        reportError(out, "clazz=0x%s is obsolete", Long.toHexString(classPointer.getAddress()));
        passed = false;
    }
    if (!romClass.isNull() && !romClass.romConstantPoolCount().eq(0)) {
        J9ConstantPoolPointer constantPool = J9ConstantPoolPointer.cast(classPointer.ramConstantPool());
        J9ClassPointer cpClass = constantPool.ramClass();
        if (!classPointer.eq(cpClass)) {
            reportError(out, "clazz=0x%s not equal clazz->ramConstantPool->ramClass=0x%s", Long.toHexString(classPointer.getAddress()), Long.toHexString(cpClass.getAddress()));
            passed = false;
        }
    }
    return passed;
}
Also used : J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)

Example 38 with J9JavaVMPointer

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

the class VmCheckCommand method checkJ9ClassSanity.

/*
	 *  Based on vmchk/checkclasses.c r1.7
	 *
	 *	J9Class sanity:
	 *		Eyecatcher check:
	 *			Ensure J9Class->eyecatcher == 0x99669966.
	 *
	 *		Superclasses check:
	 *			Ensure J9Class->superclasses != null unless J9Class is Object.
	 *
	 *		ClassObject null check:
	 *			Ensure J9Class->classObject != null if (J9Class->initializeStatus == J9ClassInitSucceeded)
	 *
	 *		ClassLoader segment check:
	 *			Ensure J9Class->classLoader->classSegments contains J9Class.
	 *
	 *		ConstantPool check:
	 *			Ensure J9Class->ramConstantPool->ramClass is equal to the J9Class.
	 *
	 *		Subclass hierarchy check:
	 *			Ensure subclasses can be traversed per the J9Class classDepth.
	 *
	 *		Obsolete class check:
	 *			Ensure obsolete classes are found in the replacedClass linked list on the currentClass.
	 */
private void checkJ9ClassSanity(J9JavaVMPointer javaVM, PrintStream out) throws CorruptDataException {
    reportMessage(out, "Checking classes");
    // Stolen from RootScaner.scanClasses()
    // GCClassLoaderIterator gcClassLoaderIterator =
    // GCClassLoaderIterator.from();
    GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(javaVM.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    int count = 0;
    int obsoleteCount = 0;
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer segment = segmentIterator.next();
        GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
        while (classHeapIterator.hasNext()) {
            J9ClassPointer clazz = classHeapIterator.next();
            if (!J9ClassHelper.isObsolete(clazz)) {
                verifyJ9Class(javaVM, out, clazz);
            } else {
                verifyObsoleteJ9Class(javaVM, out, clazz);
                obsoleteCount++;
            }
            count++;
        }
    }
    reportMessage(out, "Checking %d classes (%d obsolete) done", count, obsoleteCount);
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) GCClassHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator) GCSegmentIterator(com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)

Example 39 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer 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 40 with J9JavaVMPointer

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

Aggregations

J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)57 CorruptDataException (com.ibm.j9ddr.CorruptDataException)49 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)39 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)23 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)17 UDATA (com.ibm.j9ddr.vm29.types.UDATA)13 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)10 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)8 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)8 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)6 PatternString (com.ibm.j9ddr.util.PatternString)5 MonitorIterator (com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator)5 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)5 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)5 MM_HeapRegionManagerPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionManagerPointer)5 Table (com.ibm.j9ddr.tools.ddrinteractive.Table)4 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)4 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)4 J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)4