use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class PHDJavaClass method referencesClass.
/**
* Is there a reference from one class to another?
* E.g. from an array class to the component type? This would be an indication that they
* are truly related.
* @param from
* @param to
* @return
*/
static boolean referencesClass(JavaClass from, JavaClass to) {
for (Iterator i1 = from.getReferences(); i1.hasNext(); ) {
Object o = i1.next();
if (o instanceof CorruptData)
continue;
JavaReference jr = (JavaReference) o;
try {
if (jr.isClassReference() && jr.getTarget().equals(to)) {
return true;
}
if (jr.isObjectReference() && jr.getTarget().equals(to.getObject())) {
return true;
}
} catch (DataUnavailable e) {
} catch (CorruptDataException e) {
}
}
return false;
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class PHDJavaRuntime method prepThreads.
/**
* Remember objects associated with threads.
* Performance optimization - we can then find these objects on a scan through the heap
* and remember them, saving a fruitless search of the heap if they only exist in a javacore.
*/
private void prepThreads() {
if (metaJavaRuntime != null) {
final PHDJavaClassLoader boot = loaders.get(null);
for (Iterator it = metaJavaRuntime.getThreads(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof CorruptData)
continue;
JavaThread thr = (JavaThread) next;
try {
JavaObject jo = thr.getObject();
saveExtraObject(boot, jo);
} catch (CorruptDataException e) {
}
}
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class HeapdumpCommand method dumpMultipleHeapsInSeparateFiles.
private void dumpMultipleHeapsInSeparateFiles(JavaRuntime runtime, String version, boolean is64Bit, boolean phdFormat, String baseFileName, Set heapsToDump) throws IOException {
Iterator heapIterator = runtime.getHeaps();
HeapDumpFormatter formatter = null;
while (heapIterator.hasNext()) {
Object thisHeapObj = heapIterator.next();
if (thisHeapObj instanceof CorruptData) {
out.println("Heap corrupted at: " + ((CorruptData) thisHeapObj).getAddress());
_numberOfErrors++;
continue;
}
JavaHeap thisHeap = (JavaHeap) thisHeapObj;
// Create a new heapdump formatter for every heap we find
if (formatter != null) {
formatter.close();
}
if (heapsToDump.size() > 0 && !heapsToDump.contains(thisHeap.getName())) {
continue;
}
String fileName = getFileNameForHeap(thisHeap, baseFileName);
out.print("Writing " + (phdFormat ? "PHD" : "Classic") + " format heapdump for heap " + thisHeap.getName() + " into " + fileName + "\n");
formatter = getFormatter(fileName, version, is64Bit, phdFormat);
// We have to dump classes in every heapdump
dumpClasses(formatter, runtime);
dumpHeap(formatter, thisHeap);
}
if (formatter != null) {
formatter.close();
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class HeapdumpCommand method dumpMultipleHeapsInOneFile.
private void dumpMultipleHeapsInOneFile(JavaRuntime runtime, String version, boolean is64Bit, boolean phdFormat, String filename, Set heapsToDump) throws IOException {
Iterator heapIterator = runtime.getHeaps();
HeapDumpFormatter formatter = getFormatter(filename, version, is64Bit, phdFormat);
out.println("Writing " + (phdFormat ? "PHD" : "Classic") + " format heapdump into " + filename);
while (heapIterator.hasNext()) {
Object thisHeapObj = heapIterator.next();
if (thisHeapObj instanceof CorruptData) {
out.println("Corrupt heap data found at: " + ((CorruptData) thisHeapObj).getAddress());
_numberOfErrors++;
continue;
}
JavaHeap thisHeap = (JavaHeap) thisHeapObj;
if (heapsToDump.size() > 0 && !heapsToDump.contains(thisHeap.getName())) {
continue;
}
dumpHeap(formatter, thisHeap);
}
dumpClasses(formatter, runtime);
formatter.close();
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class HeapdumpCommand method dumpClasses.
/**
* Walks the runtime classes and passes them through the formatter interface
*/
private void dumpClasses(HeapDumpFormatter formatter, JavaRuntime runtime) throws IOException {
Iterator classLoaderIt = runtime.getJavaClassLoaders();
int numberOfClasses = 0;
ITERATING_LOADERS: while (classLoaderIt.hasNext()) {
Object potential = classLoaderIt.next();
if (potential instanceof CorruptData) {
_numberOfErrors++;
reportError("CorruptData found in classloader list at address: " + ((CorruptData) potential).getAddress(), null);
continue ITERATING_LOADERS;
}
JavaClassLoader thisClassLoader = (JavaClassLoader) potential;
Iterator classesIt = thisClassLoader.getDefinedClasses();
ITERATING_CLASSES: while (classesIt.hasNext()) {
potential = classesIt.next();
numberOfClasses++;
try {
if (potential instanceof CorruptData) {
_numberOfErrors++;
reportError("CorruptData found in class list for classloader " + Long.toHexString(thisClassLoader.getObject().getID().getAddress()) + " at address: " + ((CorruptData) potential).getAddress(), null);
continue ITERATING_CLASSES;
}
JavaClass thisJavaClass = (JavaClass) potential;
JavaClass superClass = thisJavaClass.getSuperclass();
JavaObject classObject = thisJavaClass.getObject();
long instanceSize;
if (thisJavaClass.isArray()) {
instanceSize = 0;
} else {
instanceSize = thisJavaClass.getInstanceSize();
}
int hashcode = 0;
if (_is32BitHash) {
// JVMs from 2.6 on, optional 32-bit hashcodes, if object was hashed
try {
hashcode = classObject != null ? (int) classObject.getPersistentHashcode() : 0;
} catch (DataUnavailable ex) {
// no persistent hashcode for this object, pass hashcode=0 to the heapdump formatter
}
} else {
// JVMs prior to 2.6, all objects should have a 16-bit hashcode
hashcode = classObject != null ? (int) classObject.getHashcode() : 0;
}
formatter.addClass(classObject.getID().getAddress(), thisJavaClass.getName(), superClass != null ? superClass.getID().getAddress() : 0, classObject != null ? (int) classObject.getSize() : 0, instanceSize, hashcode, getClassReferences(thisJavaClass));
} catch (DTFJException ex) {
// Handle CorruptDataException and DataUnavailableException the same way
_numberOfErrors++;
reportError(null, ex);
continue ITERATING_CLASSES;
}
}
}
_numberOfClasses = numberOfClasses;
if ((pdSkipCount > 0) && _verbose) {
out.println("Warning : The protection domain information was not available for " + pdSkipCount + " classes");
}
}
Aggregations