Search in sources :

Example 46 with CorruptData

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;
}
Also used : J9VMInitArgsPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMInitArgsPointer) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JavaVMOptionPointer(com.ibm.j9ddr.vm29.pointer.generated.JavaVMOptionPointer)

Example 47 with CorruptData

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()));
        }
    }
}
Also used : JavaField(com.ibm.dtfj.java.JavaField) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Example 48 with CorruptData

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);
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) MM_MemorySpacePointer(com.ibm.j9ddr.vm29.pointer.generated.MM_MemorySpacePointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) LinkedList(java.util.LinkedList) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Example 49 with CorruptData

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());
    }
}
Also used : CorruptData(com.ibm.dtfj.image.CorruptData)

Example 50 with CorruptData

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");
}
Also used : ImageFactory(com.ibm.dtfj.image.ImageFactory) ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) JavaRuntime(com.ibm.dtfj.java.JavaRuntime) ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) Image(com.ibm.dtfj.image.Image)

Aggregations

CorruptData (com.ibm.dtfj.image.CorruptData)68 JavaObject (com.ibm.dtfj.java.JavaObject)43 Iterator (java.util.Iterator)36 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)29 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)19 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)15 JavaClass (com.ibm.dtfj.java.JavaClass)11 JavaReference (com.ibm.dtfj.java.JavaReference)10 ImageProcess (com.ibm.dtfj.image.ImageProcess)9 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)7 LongListReferenceIterator (com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator)7 ReferenceIterator (com.ibm.jvm.dtfjview.heapdump.ReferenceIterator)7 ImageSection (com.ibm.dtfj.image.ImageSection)6 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)6 JavaHeap (com.ibm.dtfj.java.JavaHeap)6 J9Object (com.ibm.j9ddr.vm29.structure.J9Object)6 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)5 ImageThread (com.ibm.dtfj.image.ImageThread)5 JavaThread (com.ibm.dtfj.java.JavaThread)5 J9DDRImageSection (com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)5