Search in sources :

Example 31 with J9ROMClassPointer

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

the class ROMClassesRangeIterator method getNextClass.

private J9ROMClassPointer getNextClass() {
    long newHeapPtr = 0;
    J9ROMClassPointer newNextClass = J9ROMClassPointer.NULL;
    if (nextClass == J9ROMClassPointer.NULL) {
        newHeapPtr = startAddr;
    } else {
        try {
            newHeapPtr = nextClass.getAddress() + nextClass.romSize().longValue();
        } catch (CorruptDataException e) {
            /* This shouldn't happen, but if it does then it's likely an internal error */
            out.append("Unabled to read size of ROMClass at " + nextClass.getHexAddress() + ".\n");
            newNextClass = J9ROMClassPointer.NULL;
        }
    }
    if ((newHeapPtr != 0) && (newHeapPtr < endAddr)) {
        /* test if the next ROMClass is valid */
        newNextClass = J9ROMClassPointer.cast(newHeapPtr);
        try {
            if (newNextClass.romSize().eq(0)) {
                out.append("Size of ROMClass at " + newNextClass.getHexAddress() + "is invalid.\n");
                newNextClass = J9ROMClassPointer.NULL;
            }
        } catch (CorruptDataException e) {
            out.append("Unable to read size of ROMClass at " + newNextClass.getHexAddress() + ".\n");
            newNextClass = J9ROMClassPointer.NULL;
        }
    }
    return newNextClass;
}
Also used : J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 32 with J9ROMClassPointer

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

the class FilteredROMMethodsIterator method goToNextClass.

private boolean goToNextClass() throws CorruptDataException {
    resetMethodIterationState();
    boolean classAvailable = false;
    while (null == currentRomMethod) {
        if (classIterator.hasNext()) {
            J9ROMClassPointer tempRomClass = classIterator.next();
            String className = J9UTF8Helper.stringValue(tempRomClass.className());
            if (classPattern.isMatch(className)) {
                if (tempRomClass.romMethodCount().longValue() > 0) {
                    currentRomClass = tempRomClass;
                    currentRomMethod = currentRomClass.romMethods();
                    remainingMethods = currentRomClass.romMethodCount().intValue();
                    classAvailable = true;
                }
            }
        } else {
            break;
        /* no more classes or classloaders */
        }
    }
    return classAvailable;
}
Also used : J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) PatternString(com.ibm.j9ddr.util.PatternString)

Example 33 with J9ROMClassPointer

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

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

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

the class ByteCodeDumper method dumpBytecodes.

public static IDATA dumpBytecodes(PrintStream out, J9ROMClassPointer romClass, J9ROMMethodPointer romMethod, U32 flags) throws Exception {
    U16 temp;
    UDATA length;
    out.append(String.format("  Argument Count: %d", romMethod.argCount().intValue()));
    out.append(nl);
    temp = romMethod.tempCount();
    out.append(String.format("  Temp Count: %d", temp.intValue()));
    out.append(nl);
    out.append(nl);
    length = ROMHelp.J9_BYTECODE_SIZE_FROM_ROM_METHOD(romMethod);
    if (length.eq(0)) {
        return new IDATA(BCT_ERR_NO_ERROR);
    /* catch abstract methods */
    }
    return j9bcutil_dumpBytecodes(out, romClass, ROMHelp.J9_BYTECODE_START_FROM_ROM_METHOD(romMethod), new UDATA(0), length.sub(1), flags, "");
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) IDATA(com.ibm.j9ddr.vm29.types.IDATA) U16(com.ibm.j9ddr.vm29.types.U16)

Aggregations

J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)27 CorruptDataException (com.ibm.j9ddr.CorruptDataException)16 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)11 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)8 U32 (com.ibm.j9ddr.vm29.types.U32)8 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)7 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)7 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)6 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)6 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)5 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)5 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)5 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)5 PatternString (com.ibm.j9ddr.util.PatternString)4 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)4 U16Pointer (com.ibm.j9ddr.vm29.pointer.U16Pointer)4 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)4 J9ClassRegionNode (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode)4