Search in sources :

Example 1 with MonitorTableListIterator

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

the class ThreadsCommand method monitors.

/**
 * Prints all of the J9ObjectMonitors in the list of monitor tables.
 *
 * NOTE: It does not dump system monitors found in the thread lib monitor_pool
 *
 * @param out the PrintStream to write output to
 *
 * @see {@link MonitorsCommand}
 */
private void monitors(PrintStream out) throws DDRInteractiveCommandException {
    try {
        MonitorTableListIterator iterator = new MonitorTableListIterator();
        MonitorTable previousMonitorTable = null;
        while (iterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitorPointer = iterator.next();
            MonitorTable currentMonitorTable = iterator.currentMonitorTable();
            if (!currentMonitorTable.equals(previousMonitorTable)) {
                /* Print header for new monitor table */
                out.append("Table = " + currentMonitorTable.getTableName() + ", itemCount=" + currentMonitorTable.getCount());
                out.append(nl);
            }
            out.append(String.format("\n    !j9thread 0x%s    !j9threadmonitor 0x%s", Long.toHexString(objectMonitorPointer.monitor().owner().getAddress()), Long.toHexString(objectMonitorPointer.monitor().getAddress())));
            out.append(nl);
            previousMonitorTable = currentMonitorTable;
        }
    } 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)

Example 2 with MonitorTableListIterator

use of com.ibm.j9ddr.vm29.j9.MonitorTableListIterator 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 3 with MonitorTableListIterator

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

the class MonitorsCommand method tablesCommand.

/**
 * See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
 * function documentation
 *
 * @param args
 *            command args
 * @param out
 *            the output stream
 */
private void tablesCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
    try {
        MonitorTableListIterator iterator = new MonitorTableListIterator();
        MonitorTable previousMonitorTable = null;
        while (iterator.hasNext()) {
            MonitorTable currentMonitorTable = iterator.currentMonitorTable();
            if (!currentMonitorTable.equals(previousMonitorTable)) {
                /* Print header for new monitor table */
                out.println(iterator.currentMonitorTable().extraInfo());
            }
            previousMonitorTable = currentMonitorTable;
            iterator.next();
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) MonitorTableListIterator(com.ibm.j9ddr.vm29.j9.MonitorTableListIterator) MonitorTable(com.ibm.j9ddr.vm29.j9.MonitorTable)

Example 4 with MonitorTableListIterator

use of com.ibm.j9ddr.vm29.j9.MonitorTableListIterator 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)4 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)4 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)4 MonitorTableListIterator (com.ibm.j9ddr.vm29.j9.MonitorTableListIterator)4 J9ObjectMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)3 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)1 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)1 HashSet (java.util.HashSet)1