use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaVMInitArgs method loadData.
private void loadData() {
if (// cache has been populated
isCachePopulated || isCorrupt)
return;
// obtain the vm init args, logic copied from javadump.cpp so dtfj output
// matches javacore output.
J9VMInitArgsPointer args = null;
try {
args = DTFJContext.getVm().vmArgsArray();
ignoreFlag = !args.actualVMArgs().ignoreUnrecognized().eq(0);
version = args.actualVMArgs().version().intValue();
} catch (Throwable t) {
isCorrupt = true;
cdata = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
}
if (isCorrupt) {
// structure is fundamentally unusable
// prevent continual reloading
isCachePopulated = true;
return;
}
// now see if we can extract the options
try {
int optionCount = args.nOptions().intValue();
JavaVMOptionPointer option = args.actualVMArgs().options();
for (int i = 0; i < optionCount; i++) {
try {
DTFJJavaVMOption vmoption = new DTFJJavaVMOption(option);
options.add(vmoption);
if (log.isLoggable(Level.FINE)) {
try {
log.fine(String.format("Found VM option %s", vmoption.getOptionString()));
} catch (Exception e) {
log.warning(e.getMessage());
}
}
option = option.add(1);
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
options.add(cd);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
corruptCache = corruptIterator(cd);
}
// prevent continual reloading
isCachePopulated = true;
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaObject method addFieldReferences.
private void addFieldReferences(JavaClass jClass, int referentReachabilityType) throws CorruptDataException, MemoryAccessException {
Iterator<?> fieldIt = jClass.getDeclaredFields();
while (fieldIt.hasNext()) {
Object fieldObj = fieldIt.next();
if (fieldObj instanceof JavaField) {
JavaField thisField = (JavaField) fieldObj;
if ((thisField.getModifiers() & Modifier.STATIC) == 0) {
String signature = thisField.getSignature();
// From a reference point of view, only objects are interesting
if (signature.startsWith("L") || signature.startsWith("[")) {
Object targetObj = thisField.get(this);
if (targetObj == null) {
continue;
}
if (targetObj instanceof JavaObject) {
String fieldName = thisField.getName();
String declaringClassName = null;
try {
declaringClassName = thisField.getDeclaringClass().getName();
} catch (DataUnavailable e) {
// declaringClassName will be null, we will add this as a strong ref.
}
String description = "Object Reference [field name:" + fieldName + "]";
// (Not any referent field declared in subclasses.)
if (fieldName.equals("referent") && "java/lang/ref/Reference".equals(declaringClassName)) {
references.add(new DTFJJavaReference(this, targetObj, description, JavaReference.REFERENCE_FIELD, JavaReference.HEAP_ROOT_UNKNOWN, referentReachabilityType));
} else {
references.add(new DTFJJavaReference(this, targetObj, description, JavaReference.REFERENCE_FIELD, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG));
}
} else if (targetObj instanceof CorruptData) {
references.add(targetObj);
} else {
references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Unexpected type from field get: " + targetObj + ", class=" + targetObj.getClass().getName()));
}
}
}
} else if (fieldObj instanceof CorruptData) {
references.add(fieldObj);
} else {
references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Unexpected type from field iteration: " + fieldObj + ", class=" + fieldObj.getClass().getName()));
}
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaRuntime method getHeaps.
@SuppressWarnings("rawtypes")
public Iterator getHeaps() throws UnsupportedOperationException {
try {
LinkedList<Object> heaps = new LinkedList<Object>();
VoidPointer memorySpace = DTFJContext.getVm().defaultMemorySpace();
MM_MemorySpacePointer defaultMemorySpace = MM_MemorySpacePointer.cast(memorySpace);
U8Pointer namePtr = defaultMemorySpace._name();
// MEMORY_SPACE_NAME_UNDEFINED
String name = "No name";
if (namePtr != null && namePtr != U8Pointer.NULL) {
try {
name = namePtr.getCStringAtOffset(0);
} catch (com.ibm.j9ddr.CorruptDataException e) {
name = "<<corrupt heap name>>";
}
}
heaps.add(new DTFJJavaHeap(defaultMemorySpace, name, DTFJContext.getImagePointer(memorySpace.getAddress())));
return heaps.iterator();
} 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 CorruptDataComparator method testEquals.
/* (non-Javadoc)
* @see com.ibm.j9ddr.view.dtfj.test.DTFJComparator#testEquals(java.lang.Object, java.lang.Object, int)
*/
@Override
public void testEquals(Object ddrObject, Object jextractObject, int members) {
CorruptData ddrCorruptData = (CorruptData) ddrObject;
CorruptData jextractCorruptData = (CorruptData) jextractObject;
if ((members & ADDRESS) != 0) {
ImagePointerComparator comp = new ImagePointerComparator();
(new ImagePointerComparator()).testEquals(ddrCorruptData.getAddress(), jextractCorruptData.getAddress(), comp.getDefaultMask());
}
if ((members & TOSTRING) != 0) {
assertEquals(jextractCorruptData.toString(), ddrCorruptData.toString());
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJTest method getRuntime.
public JavaRuntime getRuntime(File core) throws Exception {
ImageFactory factory = getImageFactory();
Image image = factory.getImage(core);
log.finest("Image returned: " + image);
@SuppressWarnings("unchecked") Iterator addressSpaceIt = image.getAddressSpaces();
while (addressSpaceIt.hasNext()) {
Object asObj = addressSpaceIt.next();
if (asObj instanceof CorruptData) {
log.warning("Corrupt AddressSpace returned: " + asObj);
} else if (asObj instanceof ImageAddressSpace) {
ImageAddressSpace as = (ImageAddressSpace) asObj;
log.finest("Address Space: " + as + " found");
@SuppressWarnings("unchecked") Iterator processIterator = as.getProcesses();
while (processIterator.hasNext()) {
Object processObj = processIterator.next();
if (processObj instanceof CorruptData) {
log.warning("Corrupt ImageProcess returned: " + asObj);
} else if (processObj instanceof ImageProcess) {
ImageProcess process = (ImageProcess) processObj;
log.finest("ImageProcess: " + process + " found");
@SuppressWarnings("unchecked") Iterator runtimeIterator = process.getRuntimes();
while (runtimeIterator.hasNext()) {
Object runtimeObj = runtimeIterator.next();
if (runtimeObj instanceof CorruptData) {
log.warning("Corrupt ImageProcess returned: " + asObj);
} else if (runtimeObj instanceof JavaRuntime) {
JavaRuntime runtime = (JavaRuntime) runtimeObj;
log.finer("JavaRuntime found: " + runtime + ", was loaded by " + runtime.getClass().getClassLoader());
return runtime;
} else {
throw new ClassCastException("Unexpected type from Runtime iterator: " + runtimeObj.getClass() + ": " + runtimeObj);
}
}
} else {
throw new ClassCastException("Unexpected type from Process iterator: " + processObj.getClass() + ": " + processObj);
}
}
} else {
throw new ClassCastException("Unexpected type from AddressSpace iterator: " + asObj.getClass() + ": " + asObj);
}
}
throw new RuntimeException("Could not find a Java Runtime");
}
Aggregations