use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.
the class InfoThreadCommand method printJavaStackFrameInfo.
private void printJavaStackFrameInfo(JavaThread jt) {
Iterator itStackFrame;
JavaStackFrame jsf;
JavaLocation jl;
itStackFrame = jt.getStackFrames();
if (!itStackFrame.hasNext()) {
out.print("<no frames to print>\n");
return;
} else {
out.print("\n");
}
while (itStackFrame.hasNext()) {
// this iterator can contain JavaStackFrame or CorruptData objects
Object next = itStackFrame.next();
if (next instanceof CorruptData) {
out.print(" " + Exceptions.getCorruptDataExceptionString() + "\n");
return;
} else {
jsf = (JavaStackFrame) next;
}
try {
jl = jsf.getLocation();
} catch (CorruptDataException e) {
out.print(" " + Exceptions.getCorruptDataExceptionString() + "\n");
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
return;
}
out.print(" bp: ");
try {
out.print(toAdjustedHex(jsf.getBasePointer().getAddress()));
} catch (CorruptDataException e) {
// jsf.getBasePointer() can't throw DataUnavailable, so we don't know if this is really
// a corruption. Log the exception but revert to issuing a DataUnavailable message.
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
out.print(" method: ");
try {
String signature = null;
try {
signature = jl.getMethod().getSignature();
} catch (CorruptDataException e) {
// jl.getMethod() can't throw DataUnavailable, so we don't know if this is really a
// corruption. I don't think we need to be pedantic and insert 'not available' where
// the return type and the parameter types would be. Just print class name and method.
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
if (signature == null) {
out.print(jl.getMethod().getDeclaringClass().getName() + "." + jl.getMethod().getName());
} else {
out.print(Utils.getReturnValueName(signature) + " " + jl.getMethod().getDeclaringClass().getName() + "." + jl.getMethod().getName() + Utils.getMethodSignatureName(signature));
}
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
} catch (DataUnavailable e) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), e);
}
// Assume the method is a java method in case of corrupt data.
boolean isNative = false;
try {
isNative = Modifier.isNative(jl.getMethod().getModifiers());
} catch (CorruptDataException e) {
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
if (!isNative) {
out.print(" source: ");
try {
out.print(jl.getFilename());
} catch (DataUnavailable d) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), d);
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
out.print(":");
try {
out.print(Integer.toString(jl.getLineNumber()));
} catch (DataUnavailable d) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINE, Exceptions.getDataUnavailableString(), d);
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
} else {
out.print(" (Native Method)");
}
out.print("\n objects:");
Iterator itObjectRefs = jsf.getHeapRoots();
if (!itObjectRefs.hasNext()) {
out.print(" <no objects in this frame>");
}
while (itObjectRefs.hasNext()) {
Object nextRef = itObjectRefs.next();
if (nextRef instanceof CorruptData) {
out.print(Exceptions.getCorruptDataExceptionString() + "\n");
// give up on this frame
break;
} else {
JavaReference jr = (JavaReference) nextRef;
try {
if (jr.isObjectReference()) {
JavaObject target = (JavaObject) (jr.getTarget());
out.print(" " + Utils.toHex(target.getID().getAddress()));
}
} catch (DataUnavailable d) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), d);
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
} catch (NullPointerException n) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), n);
}
}
}
out.print("\n");
}
}
use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.
the class XJCommand method printReferences.
/**
* Print the references from the given object. Omit the first reference: this is always a reference to the
* object's class.
*/
public static void printReferences(JavaObject jo, PrintStream out) {
Iterator<?> references = jo.getReferences();
if (references.hasNext()) {
// reference to the class, ignore this one
references.next();
}
if (!references.hasNext()) {
out.print("\t references: <none>\n ");
out.print("\t ");
} else {
out.print("\t references:\n ");
out.print("\t ");
while (references.hasNext()) {
Object potential_reference = references.next();
if (potential_reference instanceof JavaReference) {
JavaReference reference = (JavaReference) potential_reference;
try {
Object target = reference.getTarget();
if (target instanceof JavaObject) {
out.print(" 0x" + Long.toHexString(((JavaObject) target).getID().getAddress()));
} else if (target instanceof JavaClass) {
out.print(" 0x" + Long.toHexString(((JavaClass) target).getID().getAddress()));
}
} catch (DataUnavailable e) {
// don't print anything
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
}
}
}
}
out.print("\n\n");
}
use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.
the class DTFJJavaClass method addClassLoaderReference.
private void addClassLoaderReference(List<Object> coll) {
JavaReference jRef = null;
try {
JavaClassLoader classLoader = this.getClassLoader();
if (null != classLoader) {
JavaObject classLoaderObject = classLoader.getObject();
if (null != classLoaderObject) {
jRef = new DTFJJavaReference(this, classLoaderObject, "Classloader", JavaReference.REFERENCE_CLASS_LOADER, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
coll.add(jRef);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
coll.add(cd);
}
}
use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.
the class DTFJJavaClass method addSuperclassReference.
private void addSuperclassReference(List<Object> coll) {
JavaReference jRef = null;
try {
JavaClass superClass = this.getSuperclass();
if (null != superClass) {
jRef = new DTFJJavaReference(this, superClass, "Superclass", JavaReference.REFERENCE_SUPERCLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
coll.add(jRef);
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
coll.add(cd);
}
}
use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.
the class DTFJJavaClass method addConstantPoolReferences.
@SuppressWarnings("rawtypes")
private JavaReference addConstantPoolReferences(List<Object> references) {
// get the Constant Pool references from this class.
JavaReference jRef = null;
Iterator constantPoolIt = getConstantPoolReferences();
try {
while (constantPoolIt.hasNext()) {
// get each reference in turn, note that the iterator can return JavaClass
// JavaObject and CorruptData. The CorruptData objects are ignored.
Object cpObject = constantPoolIt.next();
if (cpObject instanceof JavaObject) {
// add the reference to the container.
jRef = new DTFJJavaReference(this, cpObject, "Constant Pool Object", JavaReference.REFERENCE_CONSTANT_POOL, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
} else if (cpObject instanceof JavaClass) {
// add the reference to the container.
jRef = new DTFJJavaReference(this, cpObject, "Constant Pool Class", JavaReference.REFERENCE_CONSTANT_POOL, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
}
if (null != jRef) {
references.add(jRef);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
references.add(cd);
}
return jRef;
}
Aggregations