use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer 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.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.
the class CheckMonitorTable method check.
@Override
public void check() {
try {
GCMonitorReferenceIterator monitorReferenceIterator = GCMonitorReferenceIterator.from();
while (monitorReferenceIterator.hasNext()) {
J9ObjectMonitorPointer objectMonitor = monitorReferenceIterator.next();
J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(objectMonitor.monitor());
PointerPointer slot = PointerPointer.cast(monitor.userDataEA());
if (_engine.checkSlotPool(slot, VoidPointer.cast(monitorReferenceIterator.currentMonitorTable().getJ9HashTablePointer())) != J9MODRON_SLOT_ITERATOR_OK) {
return;
}
}
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.
the class SimpleRootScanner method doMonitorReference.
@Override
protected void doMonitorReference(J9ObjectMonitorPointer slot, VoidPointer address) {
try {
J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(slot.monitor());
doSlot(J9ObjectPointer.cast(monitor.userData()), VoidPointer.cast(monitor.userDataEA()));
} catch (CorruptDataException e) {
EventManager.raiseCorruptDataEvent("Errror accessing object slot from J9ObjectMonitorPointer: " + slot.getHexAddress(), e, false);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.
the class MonitorsCommand method writeObjectMonitorToBuffer.
/**
* Helper to write details for an object monitor to a buffer.
*
* @param objectMonitor
* @param out
* @throws CorruptDataException
*/
private void writeObjectMonitorToBuffer(FilterOptions filter, ObjectMonitor objMon, StringBuilder out) throws CorruptDataException {
if (filter.shouldPrint(objMon)) {
out.append(String.format("Object monitor for %s\t\n", objMon.getObject().formatShortInteractive()));
if (objMon.isInflated()) {
out.append("\tInflated\n");
} else {
if (objMon.isContended()) {
out.append("\tContended Flatlocked\n");
} else if (objMon.getLockword().isNull()) {
out.append("\tDeflated\n");
} else {
out.append("\tFlatlocked\n");
}
}
J9ObjectMonitorPointer j9ObjMonPtr = objMon.getJ9ObjectMonitorPointer();
if (j9ObjMonPtr.notNull()) {
out.append(String.format("\t%s %s\n", j9ObjMonPtr.formatShortInteractive(), j9ObjMonPtr.monitor().formatShortInteractive()));
}
J9VMThreadPointer ownerThreadPointer = objMon.getOwner();
if (ownerThreadPointer.notNull()) {
out.append(String.format("\tOwner:\t%s\t%s\n", ownerThreadPointer.formatShortInteractive(), J9VMThreadHelper.getName(ownerThreadPointer)));
}
if (!objMon.getBlockedThreads().isEmpty()) {
out.append(String.format("\t%s\t\n", "Blocking (Enter Waiter):"));
for (J9VMThreadPointer threadPtr : objMon.getBlockedThreads()) {
out.append(String.format("\t\t%s\t%s\n", threadPtr.formatShortInteractive(), J9VMThreadHelper.getName(threadPtr)));
}
}
if (!objMon.getWaitingThreads().isEmpty()) {
out.append(String.format("\t%s\t\n", "Waiting (Notify Waiter):"));
for (J9VMThreadPointer threadPtr : objMon.getWaitingThreads()) {
out.append(String.format("\t\t%s\t%s\n", threadPtr.formatShortInteractive(), J9VMThreadHelper.getName(threadPtr)));
}
}
out.append(nl);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer 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