use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException 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);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class FindStackValueCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (0 == args.length) {
out.println("Usage error: Missing stackvalue to search for. See usage.");
printUsage(out);
return;
} else if (1 < args.length) {
out.println("Usage error: Too many stackvalues to search for. See usage.");
printUsage(out);
return;
}
try {
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
UDATAPointer value = UDATAPointer.cast(address);
GCVMThreadListIterator gcvmThreadListIterator = GCVMThreadListIterator.from();
while (gcvmThreadListIterator.hasNext()) {
J9VMThreadPointer vmThreadPointer = gcvmThreadListIterator.next();
J9JavaStackPointer javaStackPointer = vmThreadPointer.stackObject();
J9JavaStackIterator javaStackIterator = J9JavaStackIterator.fromJ9JavaStack(javaStackPointer);
boolean found = false;
UDATA relativeSP = new UDATA(javaStackPointer.end().sub(vmThreadPointer.sp()));
while (javaStackIterator.hasNext()) {
J9JavaStackPointer stack = javaStackIterator.next();
UDATAPointer localEnd = stack.end().sub(1).add(1);
UDATAPointer search = localEnd.sub(relativeSP);
while (!search.eq(localEnd)) {
if (search.at(0).longValue() == value.longValue()) {
if (!found) {
out.append(String.format("!j9vmthread %s\n", Long.toHexString(vmThreadPointer.getAddress())));
found = true;
}
out.append(String.format("\tFound at %s\n", Long.toHexString(search.getAddress())));
}
search = search.add(1);
}
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class ClassForNameCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length == 0) {
printUsage(out);
return;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
int hitCount = 0;
String searchClassName = args[0];
PatternString pattern = new PatternString(searchClassName);
out.println(String.format("Searching for classes named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
while (iterator.hasNext()) {
J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
String javaName = J9ClassHelper.getJavaName(classPointer);
if (pattern.isMatch(javaName)) {
hitCount++;
String hexString = classPointer.getHexAddress();
out.println(String.format("!j9class %1$s named %2$s", hexString, javaName));
}
}
out.println(String.format("Found %1$d class(es) named %2$s", hitCount, searchClassName));
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class HashCodeCommand method run.
public void run(String command, String[] args, Context context, final PrintStream out) throws DDRInteractiveCommandException {
if (args.length != 1) {
throw new DDRInteractiveCommandException("This debug extension needs a single address argument: !hashcode <object addr>");
}
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
final J9ObjectPointer objectPointer = J9ObjectPointer.cast(address);
try {
J9ClassPointer clazz = J9ObjectHelper.clazz(objectPointer);
if (!J9ClassHelper.hasValidEyeCatcher(clazz)) {
throw new DDRInteractiveCommandException("object class is not valid (eyecatcher is not 0x99669966)");
}
} catch (CorruptDataException cde) {
throw new DDRInteractiveCommandException("memory fault de-referencing address argument", cde);
}
try {
out.println(ObjectModel.getObjectHashCode(objectPointer).getHexValue());
} catch (CorruptDataException cde) {
throw new DDRInteractiveCommandException("error calculating hashcode", cde);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class DumpRamClassLinearCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length == 0)
throw new DDRInteractiveCommandException("This debug extension needs an address argument !dumpramclasslinear <addr>[,n]");
String[] arguments = args[0].split(",");
long addr = Long.decode(arguments[0]);
long nestingThreshold;
if (arguments.length > 1) {
nestingThreshold = Long.decode(arguments[1]);
} else {
nestingThreshold = 1;
}
J9ClassPointer clazz = J9ClassPointer.cast(addr);
try {
out.println(String.format("RAM Class '%s' at %s", J9UTF8Helper.stringValue(clazz.romClass().className()), clazz.getHexAddress()));
ClassWalker classWalker = new RamClassWalker(clazz, context);
new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreshold);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations