use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class InfoProcCommand method printThreads.
private void printThreads() {
ImageProcess ip = ctx.getProcess();
out.print("\t Native thread IDs:");
out.print("\n\t ");
// normal tab plus 2 spaces
int lineLength = 10;
// FIXME: should output architecture (32/64-bit), endianness before threads
Iterator<?> itThread = ip.getThreads();
while (itThread.hasNext()) {
Object next = itThread.next();
if (next instanceof CorruptData) {
out.print("\n\t <corrupt data>");
continue;
}
ImageThread it = (ImageThread) next;
try {
String threadID = it.getID();
if (threadID != null) {
if (lineLength + threadID.length() > 80) {
out.print("\n\t ");
lineLength = 10;
}
out.print(it.getID() + " ");
lineLength += threadID.length() + 1;
}
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
}
}
out.print("\n");
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class XJCommand method printObjectsFromName.
private void printObjectsFromName(JavaHeap jh, String objName, PrintStream out, boolean supers, JavaRuntime jr) {
if (objName != null) {
JavaClass[] classes = Utils.getClassGivenName(objName, jr, out);
// still be an array type or it might not exist
if (classes == null || classes.length == 0) {
out.print("\t could not find class with name \"" + objName + "\"\n\n");
return;
}
for (int i = 0; i < classes.length; i++) {
boolean foundInstance = false;
JavaClass objClass = classes[i];
if (classes.length > 1) {
ClassOutput.printRuntimeClassAndLoader(objClass, out);
}
ClassOutput.printStaticFields(objClass, out);
Iterator<?> itObject = jh.getObjects();
int corruptObjectCount = 0;
while (itObject.hasNext()) {
Object obj = itObject.next();
if (obj instanceof CorruptData) {
// skip the corrupt object
corruptObjectCount++;
continue;
}
JavaObject jo = (JavaObject) obj;
String hierarchy = "";
JavaClass jc;
try {
jc = jo.getJavaClass();
} catch (CorruptDataException e) {
out.print("\t <error getting class while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
jc = null;
}
boolean foundSuperclass = false;
while (jc != null && !foundSuperclass) {
String className;
try {
className = jc.getName();
} catch (CorruptDataException e) {
out.print("\t <error getting class name while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
jc = null;
continue;
}
if (hierarchy.equals("")) {
hierarchy = className;
} else {
hierarchy = className + " => " + hierarchy;
}
if (jc.equals(objClass)) {
foundInstance = true;
foundSuperclass = true;
out.print("\t ");
out.print(hierarchy);
out.print(" @ ");
out.print(Utils.toHex(jo.getID().getAddress()));
out.print("\n");
ClassOutput.printFields(jo, jc, jr, out);
printReferences(jo, out);
} else {
if (supers) {
try {
jc = jc.getSuperclass();
} catch (CorruptDataException e) {
out.print("\t <error getting superclass while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
jc = null;
}
} else {
jc = null;
}
}
}
}
if (!foundInstance) {
out.print("\t <no object of class \"");
out.print(objName);
out.print("\" exists>\n\n");
}
if (corruptObjectCount != 0) {
out.println("\t Warning : " + corruptObjectCount + " corrupt objects were skipped\n");
}
}
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class XJCommand method printObjectsFromAddress.
private void printObjectsFromAddress(JavaHeap jh, Long objAddress, PrintStream out, JavaRuntime jr) {
JavaObject jo;
Iterator<?> itObject = jh.getObjects();
boolean found = false;
boolean done = false;
int corruptObjectCount = 0;
while (itObject.hasNext() && !done) {
Object obj = itObject.next();
if (obj instanceof CorruptData) {
// skip the corrupt object
corruptObjectCount++;
continue;
}
jo = (JavaObject) obj;
if (jo.getID().getAddress() == objAddress.longValue()) {
JavaClass jc;
found = true;
out.print("\t ");
try {
jc = jo.getJavaClass();
} catch (CorruptDataException e) {
out.print("\t <error getting class while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">");
jc = null;
}
if (null != jc) {
try {
out.print(jc.getName());
} catch (CorruptDataException e) {
out.print("\t <error getting class name while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">");
}
out.print(" @ ");
out.print(Utils.toHex(objAddress.longValue()));
out.print("\n");
ClassOutput.printFields(jo, jc, jr, out);
printReferences(jo, out);
// assumes only one object can exist at a specific memory address
done = true;
}
}
}
if (!found) {
out.print("\t <no object found at address ");
out.print(Utils.toHex(objAddress.longValue()));
out.print(">\n\n");
}
if (corruptObjectCount != 0) {
out.println("\t Warning : " + corruptObjectCount + " corrupt objects were skipped\n");
}
}
Aggregations