use of com.ibm.j9ddr.vm29.j9.SystemMonitor in project openj9 by eclipse.
the class DumpContendedLoadTable method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (0 != args.length) {
String argument = args[0];
if (argument.equalsIgnoreCase("help")) {
help(out);
return;
}
}
try {
J9JavaVMPointer javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9HashTablePointer contTable = javaVM.contendedLoadTable();
J9PoolPointer poolPtr = contTable.listNodePool();
Pool<J9ContendedLoadTableEntryPointer> pool = Pool.fromJ9Pool(poolPtr, J9ContendedLoadTableEntryPointer.class);
SlotIterator<J9ContendedLoadTableEntryPointer> poolIterator = pool.iterator();
if (poolIterator.hasNext()) {
out.println("Active class loads:");
while (poolIterator.hasNext()) {
J9ContendedLoadTableEntryPointer entryPointer = poolIterator.next();
String ldStatus = loadingStatusValues.get(entryPointer.status().longValue());
if (null == ldStatus) {
ldStatus = "ILLEGAL VALUE: " + entryPointer.status();
}
J9VMThreadPointer loadingThread = entryPointer.thread();
out.print(String.format("\tClassname: %s;\n\t\tLoader: %s; Loading thread: %s %s\n\t\tStatus: %s; Table entry hash 0x%X\n", entryPointer.className().getCStringAtOffset(0, entryPointer.classNameLength().longValue()), entryPointer.classLoader().formatShortInteractive(), J9VMThreadHelper.getName(loadingThread), loadingThread.formatShortInteractive(), ldStatus, entryPointer.hashValue().longValue()));
}
MonitorIterator iterator = new MonitorIterator(javaVM);
while (iterator.hasNext()) {
Object current = iterator.next();
if (current instanceof J9ThreadMonitorPointer) {
// System Monitor
SystemMonitor monitor = SystemMonitor.fromJ9ThreadMonitor((J9ThreadMonitorPointer) current);
final String monitorName = monitor.getName();
if (monitorName.matches(".*VM class table.*")) {
List<J9ThreadPointer> waitingThreads = monitor.getWaitingThreads();
if (!waitingThreads.isEmpty()) {
out.print("Waiting threads:\n");
for (J9ThreadPointer tp : waitingThreads) {
J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(tp);
if (vmThread.notNull()) {
out.print(String.format("\t%s\t%s\n", vmThread.formatShortInteractive(), J9VMThreadHelper.getName(vmThread)));
} else {
out.print(String.format("\t%s\t%s\n", tp.formatShortInteractive(), "[osthread]"));
}
}
}
break;
}
}
}
} else {
out.println("No active class loads");
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.j9.SystemMonitor in project openj9 by eclipse.
the class MonitorsCommand method printMonitorsForJ9Thread.
private void printMonitorsForJ9Thread(PrintStream out, J9JavaVMPointer vm, J9ThreadPointer osThreadPtr) throws CorruptDataException {
FilterOptions defaultFilter = FilterOptions.defaultOption();
MonitorIterator iterator = new MonitorIterator(vm);
while (iterator.hasNext()) {
Object current = iterator.next();
if (current instanceof J9ThreadMonitorPointer) {
// System Monitor
SystemMonitor monitor = SystemMonitor.fromJ9ThreadMonitor((J9ThreadMonitorPointer) current);
List<J9ThreadPointer> threadList = null;
// Step 2: Print any monitors that the thread is the owner of:
J9ThreadPointer ownerPtr = monitor.getOwner();
if (ownerPtr.notNull() && ownerPtr.equals(osThreadPtr)) {
out.print("Owns System Monitor:\n\t");
writeSystemMonitor(defaultFilter, monitor, out);
}
// Step 3: Print any monitors that the thread is blocking on:
threadList = monitor.getBlockedThreads();
for (J9ThreadPointer thread : threadList) {
if (osThreadPtr.equals(thread)) {
out.print("Blocking on System Monitor (Enter Waiter):\n\t");
writeSystemMonitor(defaultFilter, monitor, out);
}
}
// Step 4: Print any monitors that the thread is waiting on:
threadList = monitor.getWaitingThreads();
for (J9ThreadPointer thread : threadList) {
if (osThreadPtr.equals(thread)) {
out.print("Waiting on System Monitor (Notify Waiter):\n\t");
writeSystemMonitor(defaultFilter, monitor, out);
}
}
}
}
}
use of com.ibm.j9ddr.vm29.j9.SystemMonitor in project openj9 by eclipse.
the class MonitorsCommand method systemCommand.
private void systemCommand(FilterOptions filter, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
MonitorIterator iterator = new MonitorIterator(vm);
while (iterator.hasNext()) {
Object current = iterator.next();
if (current instanceof J9ThreadMonitorPointer) {
// System Monitor
SystemMonitor monitor = SystemMonitor.fromJ9ThreadMonitor((J9ThreadMonitorPointer) current);
writeSystemMonitor(filter, monitor, out);
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.j9.SystemMonitor in project openj9 by eclipse.
the class MonitorsCommand method writeSystemMonitorToBuffer.
/**
* Helper to write details for a system monitor to a buffer.
*
* @param filter
* @param monitor
* @param out
* @throws CorruptDataException
*/
private void writeSystemMonitorToBuffer(FilterOptions filter, SystemMonitor monitor, StringBuilder out) throws CorruptDataException {
if (filter.shouldPrint(monitor)) {
out.append(String.format("%s\t%s\n", monitor.getRawMonitor().formatShortInteractive(), monitor.getName()));
// Step 1: Check for owner:
J9ThreadPointer ownerPtr = monitor.getOwner();
if (!ownerPtr.isNull()) {
out.append(String.format("\tOwner:\t%s\n", ownerPtr.formatShortInteractive()));
}
// Step 2: Check if there are blocked (enter waiters) threads:
List<String> blockedThreads = threadsListHelper(monitor.getBlockedThreads());
if (!blockedThreads.isEmpty()) {
out.append("\tBlocking (Enter Waiter):\n");
for (String aThread : blockedThreads) {
out.append(String.format("\t\t%s\n", aThread));
}
}
// Step 3: Check if there are waiting (notify waiters) threads:
List<String> notifyThreads = threadsListHelper(monitor.getWaitingThreads());
if (!notifyThreads.isEmpty()) {
out.append("\tWaiting (Notify Waiter):\n");
for (String aThread : notifyThreads) {
out.append(String.format("\t\t%s\n", aThread));
}
}
}
}
Aggregations