Search in sources :

Example 1 with MonitorTable

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

the class MonitorTableList method peek.

/**
 * Search all the monitor tables in the J9JavaVM->monitorTables for the inflated monitor corresponding to the specified object
 *
 * @throws CorruptDataException
 *
 * @param object the object
 *
 * @returns the J9ObjectMonitorPointer found in the table, or J9ObjectMonitorPointer.NULL if no entry was found
 *
 * @see util/thrinfo.c : monitorTablePeek
 */
public static J9ObjectMonitorPointer peek(J9ObjectPointer object) throws CorruptDataException {
    if ((null == object) || (object.isNull())) {
        return J9ObjectMonitorPointer.NULL;
    }
    MonitorTable table = null;
    if (!initialized) {
        initializeCaches();
    }
    J9ObjectMonitorPointer objectMonitor = J9ObjectMonitorPointer.NULL;
    long hashcode = new U32(ObjectModel.getObjectHashCode(object)).longValue();
    int index = (int) (hashcode % monitorTables.length);
    table = monitorTables[index];
    if (table == null) {
        return objectMonitor;
    }
    if (null != table) {
        objectMonitor = table.peek(object);
        if (null == objectMonitor) {
            return J9ObjectMonitorPointer.NULL;
        }
    }
    return objectMonitor;
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)

Example 2 with MonitorTable

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

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

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

the class MonitorTableList method initializeCaches.

private static synchronized void initializeCaches() throws CorruptDataException {
    if (!initialized) {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        PointerPointer cursor = vm.monitorTables();
        int count = vm.monitorTableCount().intValue();
        monitorTables = new MonitorTable[count];
        for (int i = 0; i < count; i++) {
            J9MonitorTableListEntryPointer entries = vm.monitorTableList();
            while (entries.notNull()) {
                if (entries.monitorTable().eq(cursor.at(i))) {
                    monitorTables[i] = MonitorTable.from(entries);
                    break;
                }
                entries = entries.next();
            }
        }
        initialized = true;
    }
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9MonitorTableListEntryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MonitorTableListEntryPointer)

Example 5 with MonitorTable

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

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