use of com.ibm.dtfj.image.CorruptData 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();
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class HeapdumpCommand method dumpHeap.
/**
* Walks the supplied heap and passes the artifacts through the formatter
*/
private void dumpHeap(HeapDumpFormatter formatter, JavaHeap thisHeap) throws IOException {
Iterator objectIterator = thisHeap.getObjects();
while (objectIterator.hasNext()) {
Object next = objectIterator.next();
_numberOfObjects++;
if (next instanceof CorruptData) {
_numberOfErrors++;
reportError("Corrupt object data found at " + ((CorruptData) next).getAddress() + " while walking heap " + thisHeap.getName(), null);
continue;
}
try {
JavaObject thisObject = (JavaObject) next;
if (thisObject.getJavaClass().getName().equals("java/lang/Class")) {
// heap classes are handled separately, in dumpClasses()
continue;
}
JavaClass thisClass = thisObject.getJavaClass();
JavaObject thisClassObject = thisClass.getObject();
int hashcode = 0;
if (_is32BitHash) {
// JVMs from 2.6 on, optional 32-bit hashcodes, if object was hashed
try {
hashcode = (int) thisObject.getPersistentHashcode();
} 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
try {
hashcode = (int) thisObject.getHashcode();
} catch (DataUnavailable ex) {
_numberOfErrors++;
reportError("Failed to get hashcode for object: " + thisObject.getID(), ex);
}
}
if (thisObject.isArray()) {
if (isPrimitive(thisClass.getComponentType())) {
formatter.addPrimitiveArray(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), getPrimitiveTypeCode(thisClass.getComponentType()), thisObject.getSize(), hashcode, thisObject.getArraySize());
} else {
formatter.addObjectArray(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), thisClass.getName(), thisClass.getComponentType().getObject().getID().getAddress(), thisClass.getComponentType().getName(), thisObject.getSize(), thisObject.getArraySize(), hashcode, getObjectReferences(thisObject));
}
} else {
formatter.addObject(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), thisClass.getName(), (int) thisObject.getSize(), hashcode, getObjectReferences(thisObject));
}
} catch (CorruptDataException ex) {
_numberOfErrors++;
reportError(null, ex);
continue;
}
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class OpenCommand method createContexts.
private void createContexts(Image loadedImage, String coreFilePath) {
if (loadedImage == null) {
// cannot create any contexts as an image has not been obtained
return;
}
boolean hasContexts = false;
Iterator<?> spaces = loadedImage.getAddressSpaces();
while (spaces.hasNext()) {
Object o = spaces.next();
if (o instanceof ImageAddressSpace) {
ImageAddressSpace space = (ImageAddressSpace) o;
Iterator<?> procs = space.getProcesses();
if (procs.hasNext()) {
while (procs.hasNext()) {
o = procs.next();
if (o instanceof ImageProcess) {
ImageProcess proc = (ImageProcess) o;
Iterator<?> runtimes = proc.getRuntimes();
if (runtimes.hasNext()) {
while (runtimes.hasNext()) {
o = runtimes.next();
if (o instanceof JavaRuntime) {
createCombinedContext(loadedImage, apiLevelMajor, apiLevelMinor, space, proc, (JavaRuntime) o, coreFilePath);
hasContexts = true;
} else if (o instanceof CorruptData) {
logger.fine("CorruptData encountered in ImageProcess.getRuntimes(): " + ((CorruptData) o).toString());
createCombinedContext(loadedImage, apiLevelMajor, apiLevelMinor, space, proc, null, coreFilePath);
hasContexts = true;
} else {
logger.fine("Unexpected class encountered in ImageProcess.getRuntimes()");
createCombinedContext(loadedImage, apiLevelMajor, apiLevelMinor, space, proc, null, coreFilePath);
hasContexts = true;
}
}
} else {
// there are no runtimes so create a context for this process
createCombinedContext(loadedImage, apiLevelMajor, apiLevelMinor, space, proc, null, coreFilePath);
hasContexts = true;
}
}
}
} else {
// context with only an address space
createCombinedContext(loadedImage, apiLevelMajor, apiLevelMinor, space, null, null, coreFilePath);
hasContexts = true;
}
} else {
// need a representation of a corrupt context
logger.fine("Skipping corrupt ImageAddress space");
}
}
if (!hasContexts) {
if (ctx.hasPropertyBeenSet(VERBOSE_MODE_PROPERTY)) {
out.println("Warning : no contexts were found, is this a valid core file ?");
}
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class WhatisCommand method isStartOfObj.
private boolean isStartOfObj(Iterator objects, long address) {
String className;
long corruptObjectCount = 0;
while (objects.hasNext()) {
Object obj = objects.next();
if (obj instanceof CorruptData) {
corruptObjectCount++;
continue;
}
JavaObject jObject = (JavaObject) obj;
if (address == jObject.getID().getAddress()) {
try {
className = jObject.getJavaClass().getName();
} catch (CorruptDataException cde) {
className = "<corrupt class name>";
}
out.print("\t\t0x" + Long.toHexString(address) + " is the start of an object of type " + className);
return true;
}
}
if (corruptObjectCount > 0) {
out.println("\t\t[skipped " + corruptObjectCount + " corrupt object(s) in heap]");
}
return false;
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class HeapdumpCommand method addStaticReferences.
/**
* Extracts static references from class
* @param thisClass Class being examined
* @param references List to add references to
*/
private void addStaticReferences(JavaClass thisClass, List references) throws CorruptDataException, MemoryAccessException {
Iterator fieldsIt = thisClass.getDeclaredFields();
while (fieldsIt.hasNext()) {
Object potential = fieldsIt.next();
if (potential instanceof CorruptData) {
reportError("Corrupt field found in class " + thisClass.getName() + "(" + thisClass.getID() + ") at " + ((CorruptData) potential).getAddress(), null);
_numberOfErrors++;
continue;
}
JavaField field = (JavaField) potential;
if (!Modifier.isStatic(field.getModifiers())) {
continue;
}
Object referent = field.get(thisClass.getObject());
if (referent instanceof CorruptData) {
_numberOfErrors++;
reportError("Corrupt referent found in class " + thisClass.getName() + "(" + thisClass.getID() + ") from field " + field.getName() + " at address " + ((CorruptData) potential).getAddress(), null);
} else if (referent instanceof JavaObject) {
JavaObject referredObject = (JavaObject) referent;
references.add(new Long(referredObject.getID().getAddress()));
} else if (referent == null) {
references.add(new Long(0));
} else if (referent instanceof Number || referent instanceof Boolean || referent instanceof Character) {
// Ignore
} else {
reportError("Unexpected type: " + referent.getClass().getName() + " returned from field " + field.getName() + " from class " + thisClass.getName() + "(" + thisClass.getID() + ")", null);
_numberOfErrors++;
}
}
}
Aggregations