use of com.ibm.dtfj.runtime.ManagedRuntime 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.dtfj.runtime.ManagedRuntime in project openj9 by eclipse.
the class ManagedRuntimeComparator method testEquals.
/* (non-Javadoc)
* @see com.ibm.j9ddr.view.dtfj.test.DTFJComparator#testEquals(java.lang.Object, java.lang.Object, int)
*/
@Override
public void testEquals(Object ddrObject, Object jextractObject, int members) {
ManagedRuntime ddrRuntime = (ManagedRuntime) ddrObject;
ManagedRuntime jextractRuntime = (ManagedRuntime) jextractObject;
// getVersion()
if ((VERSION & members) != 0) {
testJavaEquals(ddrRuntime, jextractRuntime, "getVersion");
}
// getFullVersion
if ((FULL_VERSION & members) != 0) {
testJavaEquals(ddrRuntime, jextractRuntime, "getFullVersion");
}
}
use of com.ibm.dtfj.runtime.ManagedRuntime in project openj9 by eclipse.
the class PHDImageAddressSpace method getImageSections.
public Iterator<ImageSection> getImageSections() {
List<ImageSection> list = new ArrayList<ImageSection>();
for (Iterator<ImageProcess> ip = getProcesses(); ip.hasNext(); ) {
ImageProcess p = ip.next();
if (p instanceof CorruptData)
continue;
for (Iterator<ManagedRuntime> jr = p.getRuntimes(); jr.hasNext(); ) {
ManagedRuntime mr = jr.next();
if (mr instanceof CorruptData)
continue;
if (mr instanceof JavaRuntime) {
for (Iterator<JavaHeap> jh = ((JavaRuntime) mr).getHeaps(); jh.hasNext(); ) {
JavaHeap hp = jh.next();
if (hp instanceof CorruptData)
continue;
for (Iterator<ImageSection> is = hp.getSections(); is.hasNext(); ) {
// Add the corrupt sections too
list.add(is.next());
}
}
}
}
}
if (metaImageAddressSpace != null) {
for (Iterator it = metaImageAddressSpace.getImageSections(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof ImageSection) {
ImageSection section = (ImageSection) next;
ImageSection newSection = new PHDImageSection(section.getName(), getPointer(section.getBaseAddress().getAddress()), section.getSize());
list.add(newSection);
}
}
}
return list.iterator();
}
use of com.ibm.dtfj.runtime.ManagedRuntime in project openj9 by eclipse.
the class Utils method getRuntimes.
public static Iterator getRuntimes(Image loadedImage) {
Vector runtimes = new Vector();
Iterator itAddressSpace;
Iterator itProcess;
Iterator itRuntime;
ManagedRuntime mr;
ImageAddressSpace ias;
ImageProcess ip;
itAddressSpace = loadedImage.getAddressSpaces();
while (itAddressSpace.hasNext()) {
ias = (ImageAddressSpace) itAddressSpace.next();
itProcess = ias.getProcesses();
while (itProcess.hasNext()) {
ip = (ImageProcess) itProcess.next();
itRuntime = ip.getRuntimes();
while (itRuntime.hasNext()) {
// this iterator can contain ManagedRuntime or CorruptData objects
Object next = itRuntime.next();
if (next instanceof CorruptData) {
// skip any CorruptData objects
continue;
} else {
mr = (ManagedRuntime) next;
if (!runtimes.contains(mr))
runtimes.add(mr);
}
}
}
}
return runtimes.iterator();
}
Aggregations