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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations