Search in sources :

Example 6 with J9JavaVMPointer

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

the class ThreadsCommand method debugEventData.

private void debugEventData(PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9VMThreadPointer mainThread = vm.mainThread();
        if (mainThread.notNull()) {
            J9VMThreadPointer threadCursor = vm.mainThread();
            do {
                // 
                out.append(String.format("    !j9vmthread 0x%s %s %s %s %s %s %s %s %s", Long.toHexString(threadCursor.getAddress()), Long.toHexString(threadCursor.debugEventData1().longValue()), Long.toHexString(threadCursor.debugEventData2().longValue()), Long.toHexString(threadCursor.debugEventData3().longValue()), Long.toHexString(threadCursor.debugEventData4().longValue()), Long.toHexString(threadCursor.debugEventData5().longValue()), Long.toHexString(threadCursor.debugEventData6().longValue()), Long.toHexString(threadCursor.debugEventData7().longValue()), Long.toHexString(threadCursor.debugEventData8().longValue())));
                out.append(nl);
                threadCursor = threadCursor.linkNext();
            } while (!threadCursor.eq(mainThread));
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 7 with J9JavaVMPointer

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

the class RamClassWalker method allSlotsInJitVTablesDo.

private void allSlotsInJitVTablesDo() throws CorruptDataException {
    J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
    if (!vm.jitConfig().isNull()) {
        final long jitvTableSlots = J9ClassHelper.vTable(ramClass).at(0).longValue();
        final long jitvTableSlotsLength = jitvTableSlots * UDATA.SIZEOF;
        for (int i = 0; i < jitvTableSlots; i++) {
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, UDATAPointer.cast(ramClass.subOffset(jitvTableSlotsLength)).add(i), "send target", "");
        }
        /*
			 * The vTable is before the RAMClass, to get the starting address,
			 * the length of the vTable is subtracted from the pointer of the
			 * class
			 */
        classWalkerCallback.addSection(clazz, ramClass.subOffset(jitvTableSlotsLength), jitvTableSlotsLength, "jitVTables", true);
    }
}
Also used : J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)

Example 8 with J9JavaVMPointer

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

the class CoreInfoCommand method run.

/**
 * Run method for !coreinfo extension.
 *
 * @param command  !coreinfo
 * @param args	args passed by !coreinfo 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("!coreinfo expects no args. Usage :");
        printUsage(out);
        return;
    }
    J9JavaVMPointer vm;
    try {
        J9RASPointer ras = DataType.getJ9RASPointer();
        vm = J9RASHelper.getVM(ras);
        IProcess process = vm.getProcess();
        J9DDRImageProcess ddrProcess = new J9DDRImageProcess(process);
        try {
            /* Print the command line of a running program that generated core file */
            out.println("COMMANDLINE\n" + ddrProcess.getCommandLine() + "\n");
        } catch (DataUnavailable e) {
            /*For Zos core files, commandline 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");
        }
        Properties properties = J9JavaVMHelper.getSystemProperties(vm);
        /* Print VM service level info */
        out.println("JAVA SERVICE LEVEL INFO\n" + ras.serviceLevel().getCStringAtOffset(0));
        /* Print Java Version Info */
        out.println("JAVA VERSION INFO\n" + properties.get("java.fullversion"));
        /* Print Java VM Version Info */
        out.println("JAVA VM VERSION\t- " + properties.get("java.vm.version") + "\n");
        /* Print Platform Info */
        boolean is64BitPlatform = (process.bytesPerPointer() == 8) ? true : false;
        ICore core = vm.getProcess().getAddressSpace().getCore();
        Platform platform = core.getPlatform();
        out.println("PLATFORM INFO");
        out.print("Platform Name :\t" + platform.name());
        if (is64BitPlatform) {
            out.println(" 64Bit");
        } else {
            out.println(" 32Bit");
        }
        out.println("OS Level\t: " + ras.osnameEA().getCStringAtOffset(0) + " " + ras.osversionEA().getCStringAtOffset(0));
        out.println("Processors -");
        out.println("  Architecture\t: " + ras.osarchEA().getCStringAtOffset(0));
        out.println("  How Many\t: " + ras.cpus().longValue());
        try {
            properties = ddrProcess.getEnvironment();
            Enumeration processPropEnum = properties.keys();
            out.println("\nENVIRONMENT VARIABLES");
            while (processPropEnum.hasMoreElements()) {
                String key = (String) processPropEnum.nextElement();
                out.println(key + "=" + properties.get(key));
            }
        } catch (com.ibm.dtfj.image.CorruptDataException e) {
            throw new DDRInteractiveCommandException("CorruptDataException occured while getting the environment variables from process");
        } catch (DataUnavailable e) {
            out.println("Environment variables are not available\n");
        }
    } catch (CorruptDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Enumeration(java.util.Enumeration) Platform(com.ibm.j9ddr.corereaders.Platform) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) Properties(java.util.Properties) ICore(com.ibm.j9ddr.corereaders.ICore) 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 9 with J9JavaVMPointer

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

the class DumpAllRamClassLinearCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    long nestingThreashold;
    if (args.length > 1) {
        throw new DDRInteractiveCommandException("This debug extension accepts none or one argument!");
    } else if (args.length == 1) {
        nestingThreashold = Long.valueOf(args[0]);
    } else {
        nestingThreashold = 1;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (null != vm) {
            out.println();
            out.println("!j9javavm " + vm.getHexAddress());
        } else {
            throw new DDRInteractiveCommandException("Unable to find the VM in core dump!");
        }
        out.println();
        ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
            out.println("!dumpramclasslinear " + classPointer.getHexAddress());
            // RAM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
            out.println(String.format("RAM Class '%s' at %s", J9ClassHelper.getJavaName(classPointer), classPointer.getHexAddress()));
            out.println();
            ClassWalker classWalker = new RamClassWalker(classPointer, context);
            new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreashold);
            out.println();
        }
    } catch (CorruptDataException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) RamClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RamClassWalker) RamClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RamClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 10 with J9JavaVMPointer

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

the class ClassloadersSummaryCommand method getStat.

public Collection<ClassloadersSummaryNode> getStat() throws CorruptDataException {
    Map<J9ClassLoaderPointer, Counter> classloadersCount = new HashMap<J9ClassLoaderPointer, Counter>();
    J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
    GCClassLoaderIterator iterator = GCClassLoaderIterator.from();
    while (iterator.hasNext()) {
        J9ClassLoaderPointer classLoader = iterator.next();
        classloadersCount.put(classLoader, new Counter(0));
    }
    /* Iterate through all classes and count how many were loaded by each classLoader */
    ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
    while (classSegmentIterator.hasNext()) {
        J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
        Counter counter = classloadersCount.get(classPointer.classLoader());
        if (counter != null) {
            counter.addOne();
        } else {
            classloadersCount.put(classPointer.classLoader(), new Counter(1));
        }
    }
    J9ObjectPointer sys = vm.systemClassLoader().classLoaderObject();
    final UDATA valueROM = new UDATA(J9MemorySegment.MEMORY_TYPE_ROM_CLASS);
    final UDATA valueRAM = new UDATA(J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    Map<String, ClassloadersSummaryNode> classloaders = new LinkedHashMap<String, ClassloadersSummaryNode>();
    for (Map.Entry<J9ClassLoaderPointer, Counter> entry : classloadersCount.entrySet()) {
        J9ObjectPointer classLoaderObject = entry.getKey().classLoaderObject();
        boolean isSystem = classLoaderObject.equals(sys);
        String loader = isSystem ? "*System*" : J9ObjectHelper.getClassName(classLoaderObject);
        /*	For each classloader, iterate through each associated memory segment and identify whether it is  
			 * 	a ROM or a RAM type memory segment  */
        long romSegmentCount = 0;
        long ramSegmentCount = 0;
        long romSegmentAllocatedMem = 0;
        long ramSegmentAllocatedMem = 0;
        J9MemorySegmentPointer segment = entry.getKey().classSegments();
        while (segment.notNull()) {
            if ((segment.type().bitAnd(valueROM)).equals(valueROM)) {
                romSegmentCount += 1;
                romSegmentAllocatedMem += segment.size().longValue();
            } else if ((segment.type().bitAnd(valueRAM)).equals(valueRAM)) {
                ramSegmentCount += 1;
                ramSegmentAllocatedMem += segment.size().longValue();
            }
            segment = segment.nextSegmentInClassLoader();
        }
        ClassloadersSummaryNode cpentry = classloaders.get(loader);
        if (cpentry == null) {
            // If the classLoader is not in the list, add it with "# Classloaders = 1" and "# Loaded Classes = classesLoaded"
            classloaders.put(loader, new ClassloadersSummaryNode(loader, 1L, entry.getValue().getCount(), ramSegmentCount, romSegmentCount, romSegmentAllocatedMem, ramSegmentAllocatedMem));
        } else {
            // If the classLoader is in the list, increment "# Classloaders" by 1 and increment "# Loaded Classes" by classesLoaded
            cpentry.numClassloaders += 1;
            cpentry.numLoadedClasses += entry.getValue().getCount();
            cpentry.ramSegmentCounter += ramSegmentCount;
            cpentry.romSegmentCounter += romSegmentCount;
            cpentry.totalROMSegmentAllocatedMemory += romSegmentAllocatedMem;
            cpentry.totalRAMSegmentAllocatedMemory += ramSegmentAllocatedMem;
        }
    }
    return classloaders.values();
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) GCClassLoaderIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) LinkedHashMap(java.util.LinkedHashMap) ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

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