Search in sources :

Example 6 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJWalker method iterate.

private void iterate(Object object, Method iterator, int maxItems) {
    int count = 0;
    path.push(getNameFromMethod(iterator));
    iterator.setAccessible(true);
    try {
        Object result = iterator.invoke(object, (Object[]) null);
        if (result instanceof Iterator<?>) {
            Iterator<?> list = (Iterator<?>) result;
            while (list.hasNext() && (count < maxItems)) {
                Object data = list.next();
                if (data instanceof CorruptData) {
                    results.add(new InvocationResult(getCurrentPath(), (CorruptData) data));
                } else {
                    Method[] methods = data.getClass().getMethods();
                    for (Method method : methods) {
                        if (method.getReturnType().getSimpleName().equals("Iterator")) {
                            path.push("[" + count + "]/");
                            iterate(data, method, maxItems);
                            path.pop();
                        }
                    }
                }
                count++;
            }
        }
        if (result instanceof CorruptData) {
            results.add(new InvocationResult(getCurrentPath(), (CorruptData) result));
        }
    } catch (Exception e) {
        System.err.println("Exception thrown by iterator : " + e.getMessage());
        logger.log(Level.WARNING, "Exception thrown by iterator", e);
        results.add(new InvocationResult(getCurrentPath(), e.getCause()));
    // fall through and exit the invocation of this iterator
    }
    path.pop();
}
Also used : Iterator(java.util.Iterator) CorruptData(com.ibm.dtfj.image.CorruptData) Method(java.lang.reflect.Method) IOException(java.io.IOException)

Example 7 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class J9DDRDTFJUtils method handleAsCorruptDataException.

/**
 * Convert the supplied error condition into a corrupt data exception
 * or re-throw it if it is an instance of Error that we do not want to
 * intercept.
 *
 * @param p the process from the DTFJ context
 * @param t error condition to convert
 * @return CorruptDataException
 */
public static com.ibm.dtfj.image.CorruptDataException handleAsCorruptDataException(IProcess p, Throwable t) {
    if (t instanceof com.ibm.dtfj.image.CorruptDataException) {
        // prevent repeated logging of this error by ignoring DTFJ CorruptDataExceptions
        return (com.ibm.dtfj.image.CorruptDataException) t;
    }
    if (isErrorNotToBeIntercepted(t)) {
        if (t instanceof Error) {
            // re-throw unhandled errors
            throw (Error) t;
        }
        // should not hit this as we handle run time exceptions
        throw new RuntimeException(t);
    }
    if (t instanceof com.ibm.j9ddr.CorruptDataException) {
        com.ibm.j9ddr.CorruptDataException cde = (com.ibm.j9ddr.CorruptDataException) t;
        logger.log(Level.FINE, "Corrupt data encountered", t);
        return newCorruptDataException(p, cde);
    }
    String message = logError(t);
    CorruptData cd = newCorruptData(p, message);
    return new DTFJCorruptDataException(cd, t);
}
Also used : J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.j9ddr.CorruptDataException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 8 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaClass method getInterfaces.

@SuppressWarnings("rawtypes")
public Iterator getInterfaces() {
    ArrayList<Object> interfaceNames;
    int interfaceCount;
    SelfRelativePointer interfaceName;
    try {
        // a failure in the following calls mean that we cannot find any interfaces
        interfaceCount = j9class.romClass().interfaceCount().intValue();
        if (interfaceCount > 0xFFFF) {
            // class file format limits the number of interfaces to U2 (unsigned 2 bytes)
            String msg = String.format("Invalid number of interfaces for class@0x%s", Long.toHexString(j9class.getAddress()));
            throw new com.ibm.j9ddr.CorruptDataException(msg);
        }
        interfaceNames = new ArrayList<Object>(interfaceCount);
        interfaceName = j9class.romClass().interfaces();
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        return corruptIterator(cd);
    }
    // a failure in the loop should return what we've found so far + a corrupt data
    try {
        for (int i = 0; i < interfaceCount; i++) {
            VoidPointer namePointer = interfaceName.add(i).get();
            // a failure to get the name means we can still move to the next iface
            try {
                interfaceNames.add(J9UTF8Helper.stringValue(J9UTF8Pointer.cast(namePointer)));
            } catch (Throwable t) {
                CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                interfaceNames.add(cd);
            }
        }
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        interfaceNames.add(cd);
    }
    return interfaceNames.iterator();
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) SelfRelativePointer(com.ibm.j9ddr.vm29.pointer.SelfRelativePointer) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 9 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaClass method addClassLoaderReference.

private void addClassLoaderReference(List<Object> coll) {
    JavaReference jRef = null;
    try {
        JavaClassLoader classLoader = this.getClassLoader();
        if (null != classLoader) {
            JavaObject classLoaderObject = classLoader.getObject();
            if (null != classLoaderObject) {
                jRef = new DTFJJavaReference(this, classLoaderObject, "Classloader", JavaReference.REFERENCE_CLASS_LOADER, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                coll.add(jRef);
            }
        }
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        coll.add(cd);
    }
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Example 10 with CorruptData

use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.

the class DTFJJavaHeap method getSections.

@SuppressWarnings({ "rawtypes", "unchecked" })
public Iterator getSections() {
    try {
        if (null == sections) {
            List sectionList = new ArrayList<ImageSection>();
            Iterator<GCHeapRegionDescriptor> it = regions.iterator();
            while (it.hasNext()) {
                try {
                    GCHeapRegionDescriptor region = it.next();
                    long base = region.getLowAddress().getAddress();
                    long size = region.getHighAddress().getAddress() - base;
                    String name = String.format("Heap extent at 0x%x (0x%x bytes)", base, size);
                    sectionList.add(new J9DDRImageSection(MM_HeapRegionDescriptorPointer.getProcess(), base, size, name));
                } catch (Throwable t) {
                    CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                    sectionList.add(cd);
                }
            }
            sections = sectionList;
        }
        return sections.iterator();
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        return corruptIterator(cd);
    }
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRImageSection(com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)

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