Search in sources :

Example 1 with ROMClassesRangeIterator

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

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)1 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)1 ROMClassesRangeIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesRangeIterator)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)1