Search in sources :

Example 6 with ClassSegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator in project openj9 by eclipse.

the class RamClassSummaryCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSummaryHelper classSummaryHelper = new ClassSummaryHelper(preferredOrder);
        ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
            numberOfClasses++;
            ClassWalker classWalker = new RamClassWalker(classPointer, context);
            LinearDumper linearDumper = new LinearDumper();
            J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
            classSummaryHelper.addRegionsForClass(allRegionsNode);
        }
        classSummaryHelper.printStatistics(out);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) J9ClassRegionNode(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) ClassSummaryHelper(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassSummaryHelper) 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 7 with ClassSegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator in project openj9 by eclipse.

the class AllClassesCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    init();
    if (args != null) {
        if (!parseArgs(out, args)) {
            return;
        }
    }
    boolean useRange = (rangeStart != null && rangeEnd != null);
    /* If none of "rom" or "ram" is specified, then list both type of classes */
    if (!dumpROMClasses && !dumpRAMClasses) {
        dumpROMClasses = dumpRAMClasses = true;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (dumpRAMClasses) {
            out.append("RAM classes (ram size loader rom replacement name)" + nl);
            out.append("Class addr\tsize\t\tClassLoader\tROM class addr\tArray\tClass name" + nl);
            out.append(nl);
            ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
            while (classSegmentIterator.hasNext()) {
                J9ClassPointer classPointer = J9ClassPointer.NULL;
                try {
                    classPointer = (J9ClassPointer) classSegmentIterator.next();
                    if (useRange) {
                        if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
                            /* J9Class is outside of specified range; skip it. */
                            continue;
                        }
                    }
                    // 0x02713400 0x00000148 0x001210cc 0x02da2f20 0x00000000
                    // java/util/regex/Pattern$Begin
                    out.append(classPointer.getHexAddress());
                    out.append('\t');
                    out.append(J9ClassHelper.size(classPointer, vm).getHexValue());
                    out.append('\t');
                    out.append(classPointer.classLoader().getHexAddress());
                    out.append('\t');
                    out.append(classPointer.romClass().getHexAddress());
                    out.append('\t');
                    if (J9ClassHelper.isSwappedOut(classPointer)) {
                        out.append(classPointer.arrayClass().getHexAddress());
                    } else {
                        out.append('0');
                    }
                    out.append('\t');
                    out.append(J9ClassHelper.getJavaName(classPointer));
                    out.append(nl);
                } catch (CorruptDataException e) {
                    if (useRange) {
                        if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
                            /* J9Class that caused CorruptDataException is outside of specified range; skip it. */
                            continue;
                        }
                    }
                }
            }
        }
        if (dumpROMClasses) {
            ROMClassesIterator iterator = null;
            out.append(nl);
            if (useRange) {
                iterator = new ROMClassesRangeIterator(out, rangeStart, rangeEnd);
                /* Classloader is not available when using ROMClassesRangeIterator */
                out.append("ROM classes (rom size modifiers name)" + nl);
                out.append("Class addr\tROM size\tModifiers\tExtra\t\tClass name" + nl);
            } else {
                iterator = new ROMClassesIterator(out, vm.classMemorySegments());
                out.append("ROM classes (rom size loader modifiers name)" + nl);
                out.append("Class addr\tROM size\tClassLoader\tModifiers\tExtra\t\tClass name" + nl);
            }
            out.append(nl);
            while (iterator.hasNext()) {
                J9ROMClassPointer classPointer = iterator.next();
                out.append(classPointer.getHexAddress());
                out.append('\t');
                out.append(classPointer.romSize().getHexValue());
                /* MemorySegment is not available when using ROMClassesRangeIterator */
                if (iterator.getMemorySegmentPointer() != J9MemorySegmentPointer.NULL) {
                    out.append('\t');
                    out.append(iterator.getMemorySegmentPointer().classLoader().getHexAddress());
                }
                out.append('\t');
                out.append(classPointer.modifiers().getHexValue());
                out.append('\t');
                out.append(classPointer.extraModifiers().getHexValue());
                out.append('\t');
                out.append(J9UTF8Helper.stringValue(classPointer.className()));
                out.append(nl);
            }
            out.append(nl);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) ROMClassesRangeIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesRangeIterator) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) 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)

Example 8 with ClassSegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator in project openj9 by eclipse.

the class AnalyseRomClassUTF8Command method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        boolean printUTF8WeightList = false;
        int maxDistributionPercent = 85;
        if ((args.length >= 1) && (args[0].equals("UTF8WeightList"))) {
            printUTF8WeightList = true;
        }
        for (int i = 0; i < args.length; i++) {
            if (args[i].endsWith("%")) {
                try {
                    // Parses the maxDistribution string such as 85%
                    maxDistributionPercent = DecimalFormat.getInstance().parse(args[i]).intValue();
                } catch (ParseException e) {
                    out.println("Usage: !analyseromClassutf8 [UTF8WeightList] [maxDistribution%]		maxDistribution defaults to 85%");
                }
            }
        }
        Statistics statistics = new Statistics();
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ROMClassesIterator classSegmentIterator = new ROMClassesIterator(out, vm.classMemorySegments());
        J9ObjectPointer bootstraploader = vm.systemClassLoader().classLoaderObject();
        while (classSegmentIterator.hasNext()) {
            J9ROMClassPointer classPointer = (J9ROMClassPointer) classSegmentIterator.next();
            ClassWalker classWalker = new RomClassWalker(classPointer, context);
            LinearDumper linearDumper = new LinearDumper();
            J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
            statistics.add(allRegionsNode, classSegmentIterator, bootstraploader);
        }
        statistics.getResult(printUTF8WeightList, maxDistributionPercent, out);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) J9ClassRegionNode(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) ParseException(java.text.ParseException)

Example 9 with ClassSegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator in project openj9 by eclipse.

the class ClassForNameCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0) {
        printUsage(out);
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
        int hitCount = 0;
        String searchClassName = args[0];
        PatternString pattern = new PatternString(searchClassName);
        out.println(String.format("Searching for classes named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
        while (iterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
            String javaName = J9ClassHelper.getJavaName(classPointer);
            if (pattern.isMatch(javaName)) {
                hitCount++;
                String hexString = classPointer.getHexAddress();
                out.println(String.format("!j9class %1$s named %2$s", hexString, javaName));
            }
        }
        out.println(String.format("Found %1$d class(es) named %2$s", hitCount, searchClassName));
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 10 with ClassSegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator in project openj9 by eclipse.

the class ITableSizeCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    long currentSize = 0;
    long duplicatedSize = 0;
    long extendedSize = 0;
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ClassPointer clazz = (J9ClassPointer) classSegmentIterator.next();
            int classDepth = clazz.classDepthAndFlags().bitAnd(J9_JAVA_CLASS_DEPTH_MASK).intValue();
            J9ITablePointer superITable = J9ITablePointer.NULL;
            J9ITablePointer startITable = J9ITablePointer.cast(clazz.iTable());
            if (0 != classDepth) {
                PointerPointer superclasses = clazz.superclasses();
                J9ClassPointer superclazz = J9ClassPointer.cast(superclasses.at(classDepth - 1));
                superITable = J9ITablePointer.cast(superclazz.iTable());
            }
            currentSize += iTableChainSize(startITable, superITable);
            duplicatedSize += iTableChainSize(superITable, J9ITablePointer.NULL);
            extendedSize += iTableExtendedSize(startITable, superITable);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    long totalSize = duplicatedSize + currentSize;
    double percent = (double) totalSize / (double) currentSize;
    out.append("iTable duplication" + nl);
    out.append("------------------" + nl);
    out.append("current    iTable size : " + currentSize + nl);
    out.append("additional iTable size : " + duplicatedSize + nl);
    out.append("total      iTable size : " + totalSize + nl);
    out.append("growth factor          : " + percent + nl);
    out.append(nl);
    percent = (double) extendedSize / (double) currentSize;
    out.append("iTable contains extends" + nl);
    out.append("-----------------------" + nl);
    out.append("current    iTable size : " + currentSize + nl);
    out.append("new        iTable size : " + extendedSize + nl);
    out.append("growth factor          : " + percent + nl);
    out.append(nl);
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)9 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)9 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)9 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)8 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)8 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)4 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)4 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)4 PatternString (com.ibm.j9ddr.util.PatternString)3 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)3 J9ClassRegionNode (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode)3 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)2 ClassSummaryHelper (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassSummaryHelper)2 RamClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RamClassWalker)2 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)2 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)1 ROMClassesRangeIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesRangeIterator)1 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)1 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)1 J9ITablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer)1