use of com.ibm.jvm.dtfjview.commands.helpers.ThreadData in project openj9 by eclipse.
the class InfoThreadCommand method getJavaThreads.
private Map getJavaThreads(String id) {
Map threads = new HashMap();
ManagedRuntime mr = ctx.getRuntime();
if (mr instanceof JavaRuntime) {
JavaRuntime jr = (JavaRuntime) mr;
Iterator itThread = jr.getThreads();
while (itThread.hasNext()) {
Object next = itThread.next();
// skip any corrupt threads
if (next instanceof CorruptData)
continue;
JavaThread jt = (JavaThread) next;
// Obtain the native thread ID for this thread, and for zOS also obtain the TCB
String currentTID = null;
String currentTCB = null;
try {
ImageThread it = jt.getImageThread();
currentTID = it.getID();
if (_is_zOS) {
currentTCB = it.getProperties().getProperty("TCB");
}
} catch (DTFJException e) {
// Continue with what we have obtained so far
}
if (null == id) {
// save all orphaned java threads in a list within the hashmap
if (null == currentTID) {
if (threads.containsKey(null)) {
ArrayList ta = (ArrayList) threads.get(null);
ta.add(new ThreadData(jt, jr));
} else {
ArrayList ta = new ArrayList(1);
ta.add(new ThreadData(jt, jr));
threads.put(null, ta);
}
} else {
threads.put(currentTID, new ThreadData(jt, jr));
}
} else if (id.equalsIgnoreCase(currentTID) || id.equalsIgnoreCase(currentTCB)) {
// We just want the specific Java thread that matches the native thread ID or zOS TCB
threads.put(currentTID, new ThreadData(jt, jr));
}
}
}
return threads;
}
use of com.ibm.jvm.dtfjview.commands.helpers.ThreadData in project openj9 by eclipse.
the class InfoThreadCommand method printThreadInfo.
private boolean printThreadInfo(String id, Map threads) {
Iterator itThread;
ImageThread it;
boolean found = false;
itThread = ctx.getProcess().getThreads();
while (itThread.hasNext()) {
Object next = itThread.next();
if (next instanceof CorruptData) {
out.print("\n <corrupt data>");
continue;
}
it = (ImageThread) next;
// Obtain the native thread ID for this thread, and for zOS also obtain the TCB
String currentTID = null;
String currentTCB = null;
try {
currentTID = it.getID();
if (_is_zOS) {
currentTCB = it.getProperties().getProperty("TCB");
}
} catch (CorruptDataException e) {
// Continue with what we have obtained so far
}
// the requested native thread ID or zOS TCB, then go ahead and print out this thread.
if (null == id || id.equalsIgnoreCase(currentTID) || id.equalsIgnoreCase(currentTCB)) {
out.print(" thread id: ");
out.print(currentTID);
out.print("\n");
printRegisters(it);
out.print(" native stack sections:");
out.print("\n");
Iterator itStackSection = it.getStackSections();
while (itStackSection.hasNext()) {
Object nextStackSection = itStackSection.next();
if (nextStackSection instanceof CorruptData) {
out.print(" " + Exceptions.getCorruptDataExceptionString() + "\n");
continue;
}
ImageSection is = (ImageSection) nextStackSection;
printStackSection(is);
}
printStackFrameInfo(it);
out.print(" properties:");
out.print("\n");
printProperties(it);
out.print(" associated Java thread: ");
ThreadData td = (ThreadData) threads.remove(currentTID);
if (null != td) {
out.print("\n");
printJavaThreadInfo(td.getThread(), true);
} else {
out.print("<no associated Java thread>\n");
}
out.print("\n");
found = true;
}
}
return found;
}
use of com.ibm.jvm.dtfjview.commands.helpers.ThreadData in project openj9 by eclipse.
the class InfoThreadCommand method printAddressSpaceInfo.
private void printAddressSpaceInfo(String id, Map threads) {
Iterator itAddressSpace;
ImageAddressSpace ias;
int asnum = 0;
if (id == null) {
// omit header line if we are only printing one thread
out.print("native threads for address space\n");
}
printProcessInfo(id, threads);
if (!threads.isEmpty()) {
out.print("\nJava threads not associated with known native threads:\n\n");
// retrieve any orphaned Java threads from the hashmap
ArrayList ta = (ArrayList) threads.remove(null);
if (ta != null) {
for (int i = 0; i < ta.size(); i++) {
ThreadData td = (ThreadData) ta.get(i);
printJavaThreadInfo(td.getThread(), false);
}
}
// If that still hasn't emptied the list we've managed to find id's for threads
if (!threads.isEmpty()) {
Iterator remainingThreads = threads.values().iterator();
while (remainingThreads.hasNext()) {
ThreadData td = (ThreadData) remainingThreads.next();
if (td == null) {
continue;
}
printJavaThreadInfo(td.getThread(), false);
}
}
}
}
Aggregations