use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaObject method getSections.
public Iterator getSections() {
try {
fetchDeferredData();
LinkedList<ImageSection> sections = new LinkedList<ImageSection>();
long mainSectionSize = ObjectModel.getConsumedSizeInBytesWithHeader(object).longValue();
String name = getSectionName(mainSectionSize);
J9DDRImageSection section = DTFJContext.getImageSection(object.getAddress(), name);
section.setSize(mainSectionSize);
sections.add(section);
return sections.iterator();
} catch (CorruptDataException e) {
return corruptIterator(e.getCorruptData());
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
return corruptIterator(cd);
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaObject method getReferences.
@SuppressWarnings("rawtypes")
public Iterator getReferences() {
boolean isClass = false;
boolean isClassLoader = false;
boolean isWeakReference = false;
boolean isSoftReference = false;
boolean isPhantomReference = false;
if (null == references) {
references = new LinkedList<Object>();
try {
// find this object's class
JavaClass jClass = getJavaClass();
// add a reference to the object's class
if (null != jClass) {
JavaReference ref = new DTFJJavaReference(this, jClass, "Class", JavaReference.REFERENCE_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
references.add(ref);
}
if (isArray()) {
if (isObjectArray()) {
addObjectArrayReferences();
}
} else {
isClass = (jClass != null) && jClass.getName().equals("java/lang/Class");
List<JavaClass> superClasses = new LinkedList<JavaClass>();
// Do superclass walk
while (jClass != null) {
String className = jClass.getName();
isClassLoader |= className.equals("java/lang/ClassLoader");
isWeakReference |= className.equals("java/lang/ref/WeakReference");
isSoftReference |= className.equals("java/lang/ref/SoftReference");
isPhantomReference |= className.equals("java/lang/ref/PhantomReference");
superClasses.add(jClass);
jClass = jClass.getSuperclass();
}
int reachability = isWeakReference ? JavaReference.REACHABILITY_WEAK : isSoftReference ? JavaReference.REACHABILITY_SOFT : isPhantomReference ? JavaReference.REACHABILITY_PHANTOM : JavaReference.REACHABILITY_STRONG;
for (JavaClass clazz : superClasses) {
addFieldReferences(clazz, reachability);
}
}
} catch (CorruptDataException e) {
// Corrupt data, so add it to the container.
references.add(e.getCorruptData());
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
references.add(cd);
}
// Now add association-specific references
if (isClassLoader) {
try {
JavaClassLoader associatedClassLoader = getAssociatedClassLoader();
if (associatedClassLoader != null) {
for (Iterator classes = associatedClassLoader.getDefinedClasses(); classes.hasNext(); ) {
Object potentialClass = classes.next();
if (potentialClass instanceof JavaClass) {
JavaClass currentClass = (JavaClass) potentialClass;
JavaReference ref = new DTFJJavaReference(this, currentClass, "Loaded class", JavaReference.REFERENCE_LOADED_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
references.add(ref);
}
}
} else {
references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Couldn't find associated JavaClassLoader for classloader object " + this));
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
references.add(cd);
}
}
if (isClass) {
try {
JavaClass associatedClass = getAssociatedClass();
if (associatedClass != null) {
JavaReference ref = new DTFJJavaReference(this, associatedClass, "Associated class", JavaReference.REFERENCE_ASSOCIATED_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
references.add(ref);
} else {
// No associated class found. For anonymous classes this is expected, the class is not defined in a classloader.
J9ClassPointer j9Class = ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object);
if (!J9ClassHelper.isAnonymousClass(j9Class)) {
// Not an anonymous class, so something is wrong/damaged, add a corrupt data object to the references list
references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Couldn't find associated JavaClass for Class object " + this));
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
references.add(cd);
}
}
}
return references.iterator();
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaMethod method getCompiledSections.
@SuppressWarnings("rawtypes")
public Iterator getCompiledSections() {
if (compiledSections == null) {
compiledSections = new ArrayList<Object>();
List<J9JITExceptionTablePointer> metaDatas = DTFJContext.getJITMetaData(j9ramMethod);
if (metaDatas != null) {
for (J9JITExceptionTablePointer metaData : metaDatas) {
// There is always a warm region
try {
long start = metaData.startPC().longValue();
long size = metaData.endWarmPC().longValue() - start;
String name = String.format("jit section (%s) at %s", metaData.getAddress(), start);
J9DDRImageSection is = DTFJContext.getImageSection(start, name);
is.setSize(size);
compiledSections.add(is);
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
compiledSections.add(cd);
}
// JEXTRACT never considered the cold region. Leading to results where JEXTRACT could report 1 section and DTFJ will report 2.
try {
long start = metaData.startColdPC().longValue();
if (start != 0) {
long size = metaData.endPC().longValue() - start;
String name = String.format("cold jit section (%s) at %s", metaData.getAddress(), start);
J9DDRImageSection is = DTFJContext.getImageSection(start, name);
is.setSize(size);
compiledSections.add(is);
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
compiledSections.add(cd);
}
}
}
}
return compiledSections.iterator();
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaThread method walkSections.
private void walkSections() {
sections = new ArrayList<Object>();
J9JavaStackIterator stacks;
try {
stacks = J9JavaStackIterator.fromJ9JavaStack(thread.stackObject());
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
sections.add(cd);
return;
}
// JEXTRACT seems to be hard coded to only return 1 stack section ... walking the stack finds more than one.
int count = 0;
while (stacks.hasNext() && count < 1) {
J9JavaStackPointer stack = stacks.next();
try {
long size = stack.size().longValue();
long baseAddress = stack.end().longValue() - size;
J9DDRImageSection newSection = DTFJContext.getImageSection(baseAddress, getSectionName());
newSection.setSize(size);
sections.add(newSection);
count++;
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
sections.add(cd);
}
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaRuntime method getThreads.
@SuppressWarnings("rawtypes")
public Iterator getThreads() {
GCVMThreadListIterator threadIterator;
try {
threadIterator = GCVMThreadListIterator.from();
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
return corruptIterator(cd);
}
List<Object> toIterate = new LinkedList<Object>();
AddCorruptionToListListener listener = new AddCorruptionToListListener(toIterate);
register(listener);
try {
while (threadIterator.hasNext() && !listener.fatalCorruption()) {
J9VMThreadPointer next = threadIterator.next();
if (next != null) {
toIterate.add(new DTFJJavaThread(next));
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
toIterate.add(cd);
}
unregister(listener);
return toIterate.iterator();
}
Aggregations