use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer 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.pointer.generated.J9ThreadMonitorPointer in project openj9 by eclipse.
the class MonitorsCommand method tablePrintHelper.
/**
* Helper to print monitor tables.
*
* @param filter
* @param builder
* @param objectMonitorPointer
* @return
* @throws DDRInteractiveCommandException
*/
private ObjectMonitor tablePrintHelper(FilterOptions filter, StringBuilder builder, J9ObjectMonitorPointer objectMonitorPointer) throws DDRInteractiveCommandException {
try {
J9ThreadMonitorPointer threadMonitorPointer = objectMonitorPointer.monitor();
J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(threadMonitorPointer);
if (lock.flags().allBitsIn(J9ThreadAbstractMonitor.J9THREAD_MONITOR_OBJECT)) {
if (!lock.userData().eq(0)) {
// this is an object monitor in the system monitor table
J9ObjectPointer obj = J9ObjectPointer.cast(lock.userData());
ObjectMonitor objMon = ObjectAccessBarrier.getMonitor(obj);
if (null != objMon) {
writeObjectMonitorToBuffer(filter, objMon, builder);
return objMon;
}
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
return null;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer 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.pointer.generated.J9ThreadMonitorPointer in project openj9 by eclipse.
the class MonitorIterator method threadPoolHasNext.
private boolean threadPoolHasNext() throws CorruptDataException {
while ((current == null) && pool.notNull()) {
while (index < poolSize) {
J9ThreadMonitorPointer monitor = J9ThreadMonitorPointer.cast(poolEntries.add(index));
index++;
if (freeTag != monitor.count().longValue()) {
J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(monitor);
if (lock.flags().allBitsIn(J9ThreadAbstractMonitor.J9THREAD_MONITOR_OBJECT)) {
if (!lock.userData().eq(0)) {
// this is an object monitor in the system monitor table
J9ObjectPointer obj = J9ObjectPointer.cast(lock.userData());
ObjectMonitor objmon = ObjectAccessBarrier.getMonitor(obj);
// This check is to exclude flat object monitors. Flat object monitors are accounted for during the heap walk
if ((objmon == null) || !objmon.isInflated()) {
continue;
}
// return an object monitor
current = objmon;
}
} else {
// return a system monitor
current = monitor;
}
if (log.isLoggable(Level.FINE)) {
log.fine(String.format("Found monitor @ 0x%016x : %s", monitor.getAddress(), monitor.name().getCStringAtOffset(0)));
}
return true;
}
}
pool = pool.next();
if (pool.notNull()) {
index = 0;
poolEntries = pool.entriesEA();
}
}
return pool.notNull();
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer 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);
}
}
Aggregations