use of com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer 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.J9PoolPointer in project openj9 by eclipse.
the class MonitorsCommand method j9threadCommand.
/**
* See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
* function documentation
*
* @param args
* command args
* @param out
* the output stream
* @throws DDRInteractiveCommandException
*/
private void j9threadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
if (args.length < 2) {
out.println("This command takes one address argument: \"!monitors j9thread <address>\"");
return;
}
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
VoidPointer ptr = VoidPointer.cast(address);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMThreadPointer mainThread = vm.mainThread();
if (mainThread.isNull() || mainThread.osThread().isNull() || mainThread.osThread().library().isNull()) {
throw new CorruptDataException("Cannot locate thread library");
}
J9ThreadLibraryPointer lib = mainThread.osThread().library();
J9PoolPointer pool = lib.thread_pool();
Pool<J9ThreadPointer> threadPool = Pool.fromJ9Pool(pool, J9ThreadPointer.class);
SlotIterator<J9ThreadPointer> poolIterator = threadPool.iterator();
J9ThreadPointer osThreadPtr = null;
while (poolIterator.hasNext()) {
if (ptr.equals(poolIterator.next())) {
osThreadPtr = J9ThreadPointer.cast(ptr);
}
}
if (null == osThreadPtr) {
throw new DDRInteractiveCommandException(String.format("Could not find any j9thread at address %s\n", ptr.getHexAddress()));
}
// Is there an associated J9VMThread?
J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(osThreadPtr);
// Step 1: Print the general info for the VM and native threads:
out.println(String.format("%s\t%s\t// %s", osThreadPtr.formatShortInteractive(), vmThread.notNull() ? vmThread.formatShortInteractive() : "<none>", vmThread.notNull() ? J9VMThreadHelper.getName(vmThread) : "[osthread]"));
printMonitorsForJ9Thread(out, vm, osThreadPtr);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer in project openj9 by eclipse.
the class MonitorsCommand method threadCommand.
/**
* Dumps all monitors that are active for the specified J9Thread/J9VMThread/java.lang.Thread
* @param args
* @param out
* @throws DDRInteractiveCommandException
*/
private void threadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
if (args.length < 2) {
out.println("This command takes one address argument: \"!monitors thread <address>\"");
return;
}
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
VoidPointer ptr = VoidPointer.cast(address);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMThreadPointer mainThread = vm.mainThread();
J9ThreadLibraryPointer lib = mainThread.osThread().library();
J9PoolPointer pool = lib.thread_pool();
Pool<J9ThreadPointer> threadPool = Pool.fromJ9Pool(pool, J9ThreadPointer.class);
SlotIterator<J9ThreadPointer> poolIterator = threadPool.iterator();
J9ThreadPointer osThreadPtr = null;
while (poolIterator.hasNext()) {
osThreadPtr = poolIterator.next();
// Is there an associated J9VMThread?
J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(osThreadPtr);
J9ObjectPointer jlThread = null;
if (vmThread.notNull()) {
jlThread = vmThread.threadObject();
if ((null != jlThread) && jlThread.equals(ptr)) {
out.println("Found java/lang/Thread @ " + ptr.getHexAddress());
printMonitorsForJ9VMThread(out, vm, vmThread);
return;
} else if (vmThread.equals(ptr)) {
out.println("Found j9vmthread @ " + ptr.getHexAddress());
printMonitorsForJ9VMThread(out, vm, vmThread);
return;
}
}
if (osThreadPtr.equals(ptr)) {
out.println("Found j9thread @ " + ptr.getHexAddress());
if (vmThread.notNull()) {
printMonitorsForJ9VMThread(out, vm, vmThread);
}
printMonitorsForJ9Thread(out, vm, osThreadPtr);
return;
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer in project openj9 by eclipse.
the class GCVMThreadJNISlotIterator method hasNext.
public boolean hasNext() {
if (jniFrame.isNull()) {
// No more frames
return false;
}
if (null == poolIterator) {
// Haven't looked at the current frame yet
try {
J9PoolPointer poolPtr = J9PoolPointer.cast(jniFrame.references());
poolIterator = Pool.fromJ9Pool(poolPtr, PointerPointer.class).iterator();
} catch (CorruptDataException cde) {
// can try to recover from this
raiseCorruptDataEvent("Error looking at current frame", cde, false);
// Try moving to the previous frame
try {
jniFrame = jniFrame.previous();
poolIterator = null;
return hasNext();
} catch (CorruptDataException cde2) {
// cannot recover from this
raiseCorruptDataEvent("Error looking at previous frame", cde2, true);
return false;
}
}
}
if (poolIterator.hasNext()) {
return true;
} else {
// Move to the previous frame
try {
jniFrame = jniFrame.previous();
poolIterator = null;
return hasNext();
} catch (CorruptDataException e) {
// cannot recover from this
raiseCorruptDataEvent("Error moving to previous frame", e, true);
return false;
}
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer in project openj9 by eclipse.
the class DumpAllClassloadersCommand method run.
/**
* Run method for !dumpallclassloaders extension.
*
* @param command !dumpallclassloaders
* @param args !dumpallclassloaders extension accepts no args
* @param context Context
* @param out PrintStream
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length != 0) {
printUsage(out);
return;
}
try {
if (J9BuildFlags.env_data64) {
out.append("+------------------------------------------------------------------------- \n");
out.append("| ClassLoader | SharedLibraries | ClassHashTable | jniIDs Pool |\n");
out.append("| | Pool | | |\n");
out.append("| |-----------------+-----------------+-----------------| \n");
out.append("| Address | used | capacity | used | capacity | used | capacity |\n");
out.append("+-------------------+-----------------+-----------------+----------------- \n");
} else {
out.append("+----------------------------------------------------------------- \n");
out.append("|ClassLoader| SharedLibraries | ClassHashTable | jniIDs Pool |\n");
out.append("| | Pool | | |\n");
out.append("| |-----------------+-----------------+-----------------| \n");
out.append("| Address | used | capacity | used | capacity | used | capacity |\n");
out.append("+-----------+-----------------+-----------------+----------------- \n");
}
GCClassLoaderIterator iterator = GCClassLoaderIterator.from();
J9ClassLoaderPointer classLoaderPointer;
String classLoaderAddress;
long sharedLibPoolNumOfelements;
long sharedLibPoolCapacity;
long classHashTableNumOfelements;
long classHashTableCapacity;
long jniIDsPoolNumOfelements;
long jniIDsPoolCapacity;
while (iterator.hasNext()) {
classLoaderPointer = iterator.next();
classLoaderAddress = classLoaderPointer.getHexAddress();
J9PoolPointer sharedLibraries = classLoaderPointer.sharedLibraries();
if (!sharedLibraries.isNull()) {
Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(sharedLibraries, J9PoolPuddlePointer.class);
sharedLibPoolNumOfelements = pool.numElements();
sharedLibPoolCapacity = pool.capacity();
} else {
sharedLibPoolNumOfelements = 0;
sharedLibPoolCapacity = 0;
}
J9HashTablePointer classHashTable = classLoaderPointer.classHashTable();
if (!classHashTable.isNull()) {
if (!classHashTable.listNodePool().isNull()) {
J9PoolPointer listNodePool = classHashTable.listNodePool();
Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(listNodePool, J9PoolPuddlePointer.class);
classHashTableNumOfelements = pool.numElements();
classHashTableCapacity = pool.capacity();
} else {
classHashTableNumOfelements = classHashTable.numberOfNodes().longValue();
classHashTableCapacity = classHashTable.tableSize().longValue();
}
} else {
classHashTableNumOfelements = 0;
classHashTableCapacity = 0;
}
J9PoolPointer jniIDs = classLoaderPointer.jniIDs();
if (!jniIDs.isNull()) {
Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(jniIDs, J9PoolPuddlePointer.class);
jniIDsPoolNumOfelements = pool.numElements();
jniIDsPoolCapacity = pool.capacity();
} else {
jniIDsPoolNumOfelements = 0;
jniIDsPoolCapacity = 0;
}
String output = format(classLoaderAddress, sharedLibPoolNumOfelements, sharedLibPoolCapacity, classHashTableNumOfelements, classHashTableCapacity, jniIDsPoolNumOfelements, jniIDsPoolCapacity);
out.println(output);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations