Search in sources :

Example 6 with J9ObjectMonitorPointer

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

the class MonitorsCommand method tableCommand.

/**
 * See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
 * function documentation
 *
 * @param args
 *            command args
 * @param out
 *            the output stream
 * @throws DDRInteractiveCommandException
 */
private void tableCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
    FilterOptions filter = FilterOptions.defaultOption();
    if (args.length > 2) {
        filter = FilterOptions.parseOption(args[2]);
    } else if (args.length == 2) {
        out.println("No filter specified, defaulting to 'active' monitors.");
    } else if (args.length < 2) {
        out.println("This command takes one address argument: \"!monitors table <address>\"");
        return;
    }
    try {
        StringBuilder builder = new StringBuilder();
        long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
        VoidPointer ptr = VoidPointer.cast(address);
        MonitorTableListIterator iterator = new MonitorTableListIterator();
        boolean foundTable = false;
        while (iterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitorPointer = iterator.next();
            MonitorTable currentMonitorTable = iterator.currentMonitorTable();
            if (currentMonitorTable.getMonitorTableListEntryPointer().equals(ptr)) {
                tablePrintHelper(filter, builder, objectMonitorPointer);
                foundTable = true;
            }
        }
        out.append(builder);
        if (false == foundTable) {
            out.append(String.format("Could not find any J9MonitorTableListEntryPointer at address %s\n", ptr.getHexAddress()));
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) MonitorTableListIterator(com.ibm.j9ddr.vm29.j9.MonitorTableListIterator) MonitorTable(com.ibm.j9ddr.vm29.j9.MonitorTable)

Example 7 with J9ObjectMonitorPointer

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

the class CheckMonitorTable method check.

@Override
public void check() {
    try {
        GCMonitorReferenceIterator monitorReferenceIterator = GCMonitorReferenceIterator.from();
        while (monitorReferenceIterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitor = monitorReferenceIterator.next();
            J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(objectMonitor.monitor());
            PointerPointer slot = PointerPointer.cast(monitor.userDataEA());
            if (_engine.checkSlotPool(slot, VoidPointer.cast(monitorReferenceIterator.currentMonitorTable().getJ9HashTablePointer())) != J9MODRON_SLOT_ITERATOR_OK) {
                return;
            }
        }
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) GCMonitorReferenceIterator(com.ibm.j9ddr.vm29.j9.gc.GCMonitorReferenceIterator) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)

Example 8 with J9ObjectMonitorPointer

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

the class SimpleRootScanner method doMonitorReference.

@Override
protected void doMonitorReference(J9ObjectMonitorPointer slot, VoidPointer address) {
    try {
        J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(slot.monitor());
        doSlot(J9ObjectPointer.cast(monitor.userData()), VoidPointer.cast(monitor.userDataEA()));
    } catch (CorruptDataException e) {
        EventManager.raiseCorruptDataEvent("Errror accessing object slot from J9ObjectMonitorPointer: " + slot.getHexAddress(), e, false);
    }
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)

Example 9 with J9ObjectMonitorPointer

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

the class MonitorsCommand method writeObjectMonitorToBuffer.

/**
 * Helper to write details for an object monitor to a buffer.
 *
 * @param objectMonitor
 * @param out
 * @throws CorruptDataException
 */
private void writeObjectMonitorToBuffer(FilterOptions filter, ObjectMonitor objMon, StringBuilder out) throws CorruptDataException {
    if (filter.shouldPrint(objMon)) {
        out.append(String.format("Object monitor for %s\t\n", objMon.getObject().formatShortInteractive()));
        if (objMon.isInflated()) {
            out.append("\tInflated\n");
        } else {
            if (objMon.isContended()) {
                out.append("\tContended Flatlocked\n");
            } else if (objMon.getLockword().isNull()) {
                out.append("\tDeflated\n");
            } else {
                out.append("\tFlatlocked\n");
            }
        }
        J9ObjectMonitorPointer j9ObjMonPtr = objMon.getJ9ObjectMonitorPointer();
        if (j9ObjMonPtr.notNull()) {
            out.append(String.format("\t%s   %s\n", j9ObjMonPtr.formatShortInteractive(), j9ObjMonPtr.monitor().formatShortInteractive()));
        }
        J9VMThreadPointer ownerThreadPointer = objMon.getOwner();
        if (ownerThreadPointer.notNull()) {
            out.append(String.format("\tOwner:\t%s\t%s\n", ownerThreadPointer.formatShortInteractive(), J9VMThreadHelper.getName(ownerThreadPointer)));
        }
        if (!objMon.getBlockedThreads().isEmpty()) {
            out.append(String.format("\t%s\t\n", "Blocking (Enter Waiter):"));
            for (J9VMThreadPointer threadPtr : objMon.getBlockedThreads()) {
                out.append(String.format("\t\t%s\t%s\n", threadPtr.formatShortInteractive(), J9VMThreadHelper.getName(threadPtr)));
            }
        }
        if (!objMon.getWaitingThreads().isEmpty()) {
            out.append(String.format("\t%s\t\n", "Waiting (Notify Waiter):"));
            for (J9VMThreadPointer threadPtr : objMon.getWaitingThreads()) {
                out.append(String.format("\t\t%s\t%s\n", threadPtr.formatShortInteractive(), J9VMThreadHelper.getName(threadPtr)));
            }
        }
        out.append(nl);
    }
}
Also used : J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)

Example 10 with J9ObjectMonitorPointer

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

the class MonitorsCommand method objectsCommand.

private void objectsCommand(FilterOptions filter, PrintStream out) throws DDRInteractiveCommandException {
    try {
        HashSet<ObjectMonitor> monitors = new HashSet<ObjectMonitor>();
        MonitorTableListIterator iterator = new MonitorTableListIterator();
        MonitorTable previousMonitorTable = null;
        StringBuilder builder = new StringBuilder();
        while (iterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitorPointer = iterator.next();
            MonitorTable currentMonitorTable = iterator.currentMonitorTable();
            ObjectMonitor found = tablePrintHelper(filter, builder, objectMonitorPointer);
            if (null != found) {
                monitors.add(found);
            }
            if (!currentMonitorTable.equals(previousMonitorTable) && (builder.length() > 0)) {
                /* Print header for new monitor table */
                if (null != previousMonitorTable) {
                    out.println();
                }
                out.println(iterator.currentMonitorTable().extraInfo());
                previousMonitorTable = currentMonitorTable;
            }
            out.append(builder);
            builder.setLength(0);
        }
        // Don't forget leftover flatlocked monitors on heap, these have no associated table:
        Iterator<ObjectMonitor> flatMonitorIterator = HeapWalker.getFlatLockedMonitors().iterator();
        while (flatMonitorIterator.hasNext()) {
            ObjectMonitor objMon = flatMonitorIterator.next();
            if (!monitors.contains(objMon)) {
                writeObjectMonitorToBuffer(filter, objMon, builder);
            }
        }
        if (builder.length() > 0) {
            out.append("<Flatlocked Monitors on Heap>\n");
            out.append(builder);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) MonitorTableListIterator(com.ibm.j9ddr.vm29.j9.MonitorTableListIterator) MonitorTable(com.ibm.j9ddr.vm29.j9.MonitorTable) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor) HashSet(java.util.HashSet)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)9 J9ObjectMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)8 J9ThreadAbstractMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)5 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)4 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)4 MonitorTableListIterator (com.ibm.j9ddr.vm29.j9.MonitorTableListIterator)3 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)2 GCMonitorReferenceIterator (com.ibm.j9ddr.vm29.j9.gc.GCMonitorReferenceIterator)2 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)2 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)2 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)1 J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)1 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)1 U32 (com.ibm.j9ddr.vm29.types.U32)1 HashSet (java.util.HashSet)1