Search in sources :

Example 31 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class MarkMapCommand method isMarked.

protected void isMarked(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
        J9ObjectPointer object = J9ObjectPointer.cast(address);
        MarkedObject result = markMap.queryObject(object);
        if (result != null) {
            if (result.wasRelocated()) {
                out.format("Object %s is marked and relocated to %s\n", result.object.getHexAddress(), result.relocatedObject.getHexAddress());
            } else {
                out.format("Object %s is marked\n", result.object.getHexAddress());
            }
        } else {
            out.format("Object %s is not marked\n", object.getHexAddress());
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) MarkedObject(com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 32 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class ObjectSizeInfo method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    this.out = out;
    fieldStats = new TreeMap<String, ClassFieldInfo>();
    Table summary = new Table("Object field size summary");
    summary.row(ClassFieldInfo.getTitleRow());
    HeapFieldInfo hfi = new HeapFieldInfo();
    if (args != null) {
        if (!parseArgs(out, args)) {
            return;
        }
    }
    try {
        scanHeap();
        for (FieldInfo cfi : fieldStats.values()) {
            summary.row(cfi.getResults());
            hfi.addClass(cfi);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    summary.row(FieldInfo.getTitleRow());
    try {
        summary.row(hfi.getResults());
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    summary.render(out);
}
Also used : Table(com.ibm.j9ddr.tools.ddrinteractive.Table) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) ObjectFieldInfo(com.ibm.j9ddr.vm29.j9.ObjectFieldInfo)

Example 33 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException 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 34 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException 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 35 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class MonitorsCommand method tablePrintHelper.

/**
 * Helper to print monitor tables.
 *
 * @param filter
 * @param builder
 * @param objectMonitorPointer
 * @return
 * @throws DDRInteractiveCommandException
 */
private ObjectMonitor tablePrintHelper(FilterOptions filter, StringBuilder builder, J9ObjectMonitorPointer objectMonitorPointer) throws DDRInteractiveCommandException {
    try {
        J9ThreadMonitorPointer threadMonitorPointer = objectMonitorPointer.monitor();
        J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(threadMonitorPointer);
        if (lock.flags().allBitsIn(J9ThreadAbstractMonitor.J9THREAD_MONITOR_OBJECT)) {
            if (!lock.userData().eq(0)) {
                // this is an object monitor in the system monitor table
                J9ObjectPointer obj = J9ObjectPointer.cast(lock.userData());
                ObjectMonitor objMon = ObjectAccessBarrier.getMonitor(obj);
                if (null != objMon) {
                    writeObjectMonitorToBuffer(filter, objMon, builder);
                    return objMon;
                }
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    return null;
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Aggregations

DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)86 CorruptDataException (com.ibm.j9ddr.CorruptDataException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)38 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)16 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)16 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)16 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)11 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)6 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)6 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)6 PatternString (com.ibm.j9ddr.util.PatternString)5 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)5 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)5 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)4 MonitorTableListIterator (com.ibm.j9ddr.vm29.j9.MonitorTableListIterator)4