Search in sources :

Example 6 with MonitorTable

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

Example 7 with MonitorTable

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

the class CheckMonitorTable method print.

@Override
public void print() {
    try {
        VoidPointer monitorTableList = VoidPointer.cast(getJavaVM().monitorTableList());
        GCMonitorReferenceIterator monitorReferenceIterator = GCMonitorReferenceIterator.from();
        MonitorTable previousMonitorTable = null;
        ScanFormatter formatter = new ScanFormatter(this, "MonitorTableList", monitorTableList);
        while (monitorReferenceIterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitor = monitorReferenceIterator.next();
            MonitorTable currentMonitorTable = monitorReferenceIterator.currentMonitorTable();
            if (!currentMonitorTable.equals(previousMonitorTable)) {
                if (null != previousMonitorTable) {
                    formatter.endSection();
                }
                formatter.section("MonitorTable", currentMonitorTable.getMonitorTableListEntryPointer());
            }
            J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(objectMonitor.monitor());
            formatter.entry(VoidPointer.cast(monitor.userData()));
            previousMonitorTable = currentMonitorTable;
        }
        if (null != previousMonitorTable) {
            formatter.endSection();
        }
        formatter.end("MonitorTableList", monitorTableList);
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) GCMonitorReferenceIterator(com.ibm.j9ddr.vm29.j9.gc.GCMonitorReferenceIterator) MonitorTable(com.ibm.j9ddr.vm29.j9.MonitorTable) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)

Aggregations

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