Search in sources :

Example 1 with ROMClassesIterator

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

the class DumpAllRomClassLinearCommand 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();
        ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
        while (iterator.hasNext()) {
            J9ROMClassPointer classPointer = iterator.next();
            out.println("!dumpromclasslinear " + classPointer.getHexAddress());
            // ROM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
            out.println(String.format("ROM Class '%s' at %s", J9UTF8Helper.stringValue(classPointer.className()), classPointer.getHexAddress()));
            out.println();
            ClassWalker classWalker = new RomClassWalker(classPointer, context);
            new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreashold);
            out.println();
        }
    } catch (CorruptDataException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}
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) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 2 with ROMClassesIterator

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

the class RomClassForNameCommand 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());
        ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
        int hitCount = 0;
        String searchClassName = args[0];
        PatternString pattern = new PatternString(searchClassName);
        out.println(String.format("Searching for ROMClasses named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
        while (iterator.hasNext()) {
            J9ROMClassPointer romClassPointer = iterator.next();
            String javaName = J9UTF8Helper.stringValue(romClassPointer.className());
            if (pattern.isMatch(javaName)) {
                hitCount++;
                String hexString = romClassPointer.getHexAddress();
                out.println(String.format("!j9romclass %1$s named %2$s", hexString, javaName));
            }
        }
        out.println(String.format("Found %1$d ROMClass(es) named %2$s", hitCount, searchClassName));
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) 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 3 with ROMClassesIterator

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

the class RomClassSummaryCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        boolean requiredLocal = false;
        boolean requiredShared = false;
        boolean required16bitnas = false;
        J9SharedClassConfigPointer sc = J9SharedClassConfigPointer.NULL;
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        long startAddress = 0, endAddress = 0;
        if ((args != null) && (args.length >= 1)) {
            if (args[0].equals("shared")) {
                requiredShared = true;
            } else if (args[0].equals("local")) {
                requiredLocal = true;
            } else if (args[0].equals("16bitnas")) {
                required16bitnas = true;
            } else {
                out.println("USAGE: !romclasssummary [local|shared] [16bitnas]");
                return;
            }
            if ((args.length >= 2) && (args[1].equals("16bitnas"))) {
                required16bitnas = true;
            }
            if (requiredShared || requiredLocal) {
                sc = vm.sharedClassConfig();
                if (requiredShared && sc.isNull()) {
                    out.println("The request for '" + args[0] + " classes' failed, because " + "shared classes were not enabled on that dump file.");
                    return;
                }
                if (sc.notNull()) {
                    startAddress = UDATA.cast(sc.cacheDescriptorList().romclassStartAddress()).longValue();
                    J9SharedCacheHeaderPointer header = sc.cacheDescriptorList().cacheStartAddress();
                    endAddress = UDATA.cast(header).add(header.segmentSRP()).longValue();
                }
            }
        }
        ClassSummaryHelper classSummaryHelper = new ClassSummaryHelper(preferredOrder);
        Statistics statistics = new Statistics();
        ROMClassesIterator classSegmentIterator = new ROMClassesIterator(out, vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ROMClassPointer classPointer = (J9ROMClassPointer) classSegmentIterator.next();
            if (requiredShared || requiredLocal) {
                boolean isShared;
                if (sc.notNull()) {
                    long classAddress = classPointer.getAddress();
                    isShared = classAddress >= startAddress && classAddress < endAddress;
                } else {
                    isShared = false;
                }
                if (requiredShared && !isShared)
                    continue;
                if (requiredLocal && isShared)
                    continue;
            }
            ClassWalker classWalker = new RomClassWalker(classPointer, context);
            LinearDumper linearDumper = new LinearDumper();
            J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
            classSummaryHelper.addRegionsForClass(allRegionsNode);
            if (required16bitnas) {
                statistics.add(allRegionsNode);
            }
        }
        classSummaryHelper.printStatistics(out);
        if (statistics.nameAndSignatureSRP16bitSize != -1) {
            out.println();
            out.println("<Total 16bit nameAndSignatureSRPs Size>");
            out.println(statistics.nameAndSignatureSRP16bitSize);
        }
        if (statistics.nameAndSignatureSRPCount != -1 && statistics.cpFieldNASCount != -1) {
            out.println();
            out.println("<Shared nameAndSignatureSRPs>");
            // nameAndSignatureSRPCount is divided by 2, because there is a name and a signature per NAS field
            out.println(statistics.cpFieldNASCount - statistics.nameAndSignatureSRPCount / 2);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9SharedClassConfigPointer(com.ibm.j9ddr.vm29.pointer.generated.J9SharedClassConfigPointer) ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9SharedCacheHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9SharedCacheHeaderPointer) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException) 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) ClassSummaryHelper(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassSummaryHelper) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)

Example 4 with ROMClassesIterator

use of com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator 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 5 with ROMClassesIterator

use of com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator 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)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)5 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)5 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)5 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)5 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)3 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)3 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)3 J9ClassRegionNode (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode)2 PatternString (com.ibm.j9ddr.util.PatternString)1 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)1 ROMClassesRangeIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesRangeIterator)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)1 J9SharedCacheHeaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9SharedCacheHeaderPointer)1 J9SharedClassConfigPointer (com.ibm.j9ddr.vm29.pointer.generated.J9SharedClassConfigPointer)1 ClassSummaryHelper (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassSummaryHelper)1 ParseException (java.text.ParseException)1