use of com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator 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.walkers.MonitorIterator in project openj9 by eclipse.
the class MonitorsCommand method printMonitorsForJ9VMThread.
private void printMonitorsForJ9VMThread(PrintStream out, J9JavaVMPointer vm, J9VMThreadPointer thread) throws CorruptDataException {
FilterOptions defaultFilter = FilterOptions.defaultOption();
MonitorIterator iterator = new MonitorIterator(vm);
while (iterator.hasNext()) {
Object current = iterator.next();
if (current instanceof ObjectMonitor) {
ObjectMonitor objMon = (ObjectMonitor) current;
// Step 2: Print any monitors that the thread is the owner of:
if (thread.equals(objMon.getOwner())) {
out.print("Owns Object Monitor:\n\t");
writeObjectMonitor(defaultFilter, objMon, out);
}
// Step 3: Print any monitors that the thread is blocking on::
for (J9VMThreadPointer threadPtr : objMon.getBlockedThreads()) {
if (threadPtr.equals(thread)) {
out.print(String.format("Blocking on (Enter Waiter):\n\t"));
writeObjectMonitor(defaultFilter, objMon, out);
}
}
// Step 4: Print any monitors that the thread is waiting on:
for (J9VMThreadPointer threadPtr : objMon.getWaitingThreads()) {
if (threadPtr.equals(thread)) {
out.print(String.format("Waiting on (Notify Waiter):\n\t"));
writeObjectMonitor(defaultFilter, objMon, out);
}
}
}
}
}
use of com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator 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.walkers.MonitorIterator 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.walkers.MonitorIterator in project openj9 by eclipse.
the class DeadlockUtils method readObjectMonitors.
/**
* Returns a hash map of Object Pointers to their respective mutex (Object Monitor or System Monitor)
* @param vm
* @return
* @throws CorruptDataException
*/
public static HashMap<J9ObjectPointer, Object> readObjectMonitors(J9JavaVMPointer vm) throws CorruptDataException {
HashMap<J9ObjectPointer, Object> objectMonitorsMap = new HashMap<J9ObjectPointer, Object>();
MonitorIterator iterator = new MonitorIterator(vm);
while (iterator.hasNext()) {
Object current = iterator.next();
if (current instanceof ObjectMonitor) {
ObjectMonitor mon = (ObjectMonitor) current;
J9ObjectPointer object = mon.getObject();
objectMonitorsMap.put(object, mon);
} else if (current instanceof J9ThreadMonitorPointer) {
// System Monitor
J9ThreadMonitorPointer mon = (J9ThreadMonitorPointer) current;
J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(mon);
if (false == lock.userData().eq(0)) {
// this is an object monitor in the system monitor table
J9ObjectPointer object = J9ObjectPointer.cast(lock.userData());
objectMonitorsMap.put(object, mon);
}
}
}
return objectMonitorsMap;
}
Aggregations