Search in sources :

Example 16 with DataUnavailable

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

the class DTFJComparator method invokeMethod.

@SuppressWarnings("unchecked")
private InvokeResult invokeMethod(Object ddrObject, Object jextractObject, String methodName, Class[] paramTypes, Object[] args) {
    if (assertEqualsIfBothObjectsCorrupt(jextractObject, ddrObject)) {
        return new InvokeResult(null, null, false);
    }
    boolean ddrDataUnavailable = false;
    boolean jextractDataUnavailable = false;
    boolean ddrCorruptData = false;
    boolean jextractCorruptData = false;
    boolean ddrUnsupportedOperation = false;
    @SuppressWarnings("unused") boolean jextractUnsupportedOperation = false;
    Object ddrResult = false;
    Object jextractResult = false;
    Method method;
    Throwable ddrException = null;
    Throwable jextractException = null;
    try {
        method = ddrObject.getClass().getMethod(methodName, paramTypes);
        method.setAccessible(true);
        ddrResult = method.invoke(ddrObject, args);
    } catch (SecurityException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", ddrObject.getClass().getName(), methodName));
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", ddrObject.getClass().getName(), methodName));
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", ddrObject.getClass().getName(), methodName));
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", ddrObject.getClass().getName(), methodName));
    } catch (InvocationTargetException e) {
        if (e.getCause() instanceof DataUnavailable) {
            // e.getCause().printStackTrace();
            ddrException = e.getCause();
            ddrDataUnavailable = true;
        } else if (e.getCause() instanceof CorruptDataException) {
            // e.getCause().printStackTrace();
            ddrException = e.getCause();
            ddrCorruptData = true;
        } else {
            fail(String.format("Unexpected exception %s from method %s.%s()", e.getCause(), ddrObject.getClass().getName(), methodName));
        }
    }
    try {
        method = jextractObject.getClass().getMethod(methodName, paramTypes);
        method.setAccessible(true);
        jextractResult = method.invoke(jextractObject, args);
    } catch (SecurityException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", jextractObject.getClass().getName(), methodName));
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", jextractObject.getClass().getName(), methodName));
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", jextractObject.getClass().getName(), methodName));
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        fail(String.format("Could not find method %s.%s()", jextractObject.getClass().getName(), methodName));
    } catch (InvocationTargetException e) {
        if (e.getCause() instanceof DataUnavailable) {
            jextractException = e.getCause();
            jextractDataUnavailable = true;
        } else if (e.getCause() instanceof CorruptDataException) {
            jextractException = e.getCause();
            jextractCorruptData = true;
        } else {
            fail(String.format("Unexpected exception %s from method %s.%s()", e.getCause(), ddrObject.getClass().getName(), methodName));
        }
    }
    if (ddrDataUnavailable && !jextractDataUnavailable) {
        if (ddrException != null) {
            ddrException.printStackTrace();
        }
        if (jextractException != null) {
            jextractException.printStackTrace();
        }
        fail(String.format("%s.%s returned DataUnavailable. JExtract did not.", ddrObject.getClass().getSimpleName(), methodName));
    }
    if (jextractCorruptData && !ddrCorruptData) {
        // in this case DDR found data and jextract threw a corrupt data exception, so mark it as do not test
        return new InvokeResult(ddrResult, jextractResult, false);
    } else {
        assertEquals(String.format("%s.%s() returned CorruptData for %s", ddrObject.getClass().getSimpleName(), methodName, ddrCorruptData ? "DDR" : "JEXTRACT"), jextractCorruptData, ddrCorruptData);
        return new InvokeResult(ddrResult, jextractResult, !jextractDataUnavailable && !ddrDataUnavailable && !ddrCorruptData && !ddrUnsupportedOperation);
    }
}
Also used : Method(java.lang.reflect.Method) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataUnavailable(com.ibm.dtfj.image.DataUnavailable)

Example 17 with DataUnavailable

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

the class Builder method setExecutableUnavailable.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.corereaders.Builder#setExecutableUnavailable(java.lang.String)
	 */
public void setExecutableUnavailable(String description) {
    _executableException = new DataUnavailable(description);
    // note that we usually can't look for libraries if we don't have an executable so set this here, as well
    _libraryException = _executableException;
// /XXX: this might not be safe!  It depends on the actual use of this component in the core readers
}
Also used : DataUnavailable(com.ibm.dtfj.image.DataUnavailable)

Example 18 with DataUnavailable

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

the class PHDJavaRuntime method findLoaders.

/**
 * Helper method to try to allocate classes to the correct class loader
 * There isn't an explicit mention of the loader, but an outbound reference might be to the loader.
 * First find all the objects which are class loaders.
 * The look at each file, see if it has a reference to a loader object and if so allocate it to
 * that loader.
 * @param file
 * @throws IOException
 */
private void findLoaders(HeapdumpReader newreader) throws IOException {
    // Where all the classes orginally have been put
    final PHDJavaClassLoader boot = loaders.get(null);
    // Might fail to find a class with a very corrupt dump
    final JavaClass jlc = findClass("java/lang/Class");
    final long jlcAddress = jlc == null || jlc.getID() == null ? 0 : jlc.getID().getAddress();
    // Find all the class loader classes
    final JavaClass jcl = findClass("java/lang/ClassLoader");
    final HashMap<Long, JavaClass> classLoaderClasses = new HashMap<Long, JavaClass>();
    for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
        JavaClass cls = it.next();
        if (cls instanceof CorruptData)
            continue;
        try {
            // Avoid bug with superclass loops by remembering superclasses
            // PHD Version 4 bug - bad superclass: J2RE 5.0 IBM J9 2.3 AIX ppc64-64 build 20080314_17962_BHdSMr
            HashSet<JavaClass> supers = new HashSet<JavaClass>();
            for (JavaClass j1 = cls; j1 != null && supers.add(j1); j1 = j1.getSuperclass()) {
                /* 
					 * See if either a superclass is java.lang.ClassLoader
					 * or if no superclass information is available (old Java 5)
					 * whether the name ends with "ClassLoader"
					 */
                if (j1.equals(jcl) || cls.getSuperclass() == null && !j1.isArray() && j1.getName().endsWith("ClassLoader")) {
                    ImagePointer ip = cls.getID();
                    if (ip != null) {
                        classLoaderClasses.put(ip.getAddress(), cls);
                    }
                }
            }
        } catch (CorruptDataException e) {
        // Ignore
        }
    }
    // Number of class objects not found at class addresses
    final int[] onHeapClasses = new int[1];
    // Find all the objects which are class loaders
    final PHDJavaHeap heap = heaps.get(0);
    final HashMap<Long, JavaObject> classObjects = new HashMap<Long, JavaObject>();
    // HeapdumpReader newreader = new HeapdumpReader(file, parentImage);
    final int adjustLen = newreader.version() == 4 && newreader.isJ9() ? 1 : 0;
    try {
        newreader.parse(new PortableHeapDumpListener() {

            public void classDump(long address, long superAddress, String name, int size, int flags, int hashCode, LongEnumeration refs) throws Exception {
            }

            public void objectArrayDump(long address, long classAddress, int flags, int hashCode, LongEnumeration refs, int length, long instanceSize) throws Exception {
                if (extraObjectsCache.containsKey(address)) {
                    // Don't bother saving reference information - we can get it later
                    JavaObject jo = new PHDJavaObject.Builder(heap, address, arrayOf(classAddress, refs, adjustLen), flags, hashCode).length(length - adjustLen).instanceSize(instanceSize).build();
                    extraObjectsCache.put(address, jo);
                }
            }

            public void objectDump(long address, long classAddress, int flags, int hashCode, LongEnumeration refs, long instanceSize) throws Exception {
                JavaClass cls = classLoaderClasses.get(classAddress);
                JavaObject jo;
                if (cls != null) {
                    // Object of type java.lang.ClassLoader, so create the object and the class loader
                    jo = new PHDJavaObject.Builder(heap, address, cls, flags, hashCode).refs(refs, 0).length(PHDJavaObject.SIMPLE_OBJECT).instanceSize(instanceSize).build();
                    PHDJavaClassLoader load = new PHDJavaClassLoader(jo);
                    loaders.put(jo, load);
                } else if (classAddress == jlcAddress) {
                    if (boot.findClass(address) == null) {
                        ++onHeapClasses[0];
                    }
                    jo = new PHDJavaObject.Builder(heap, address, jlc, flags, hashCode).refs(refs, 0).length(PHDJavaObject.SIMPLE_OBJECT).instanceSize(instanceSize).build();
                    classObjects.put(address, jo);
                } else {
                    jo = null;
                }
                if (extraObjectsCache.containsKey(address)) {
                    if (jo == null) {
                        jo = new PHDJavaObject.Builder(heap, address, findClass(classAddress), flags, hashCode).refs(refs, 0).length(PHDJavaObject.SIMPLE_OBJECT).build();
                    }
                    extraObjectsCache.put(address, jo);
                }
            }

            public void primitiveArrayDump(long address, int type, int length, int flags, int hashCode, long instanceSize) throws Exception {
                if (extraObjectsCache.containsKey(address)) {
                    // Create a full object as we have the data
                    JavaObject jo = new PHDJavaObject.Builder(heap, address, findArrayOfType(type), flags, hashCode).refsAsArray(NOREFS, 0).length(length).instanceSize(instanceSize).build();
                    extraObjectsCache.put(address, jo);
                }
            }
        });
    } catch (Exception e) {
    // Ignore the exception - we will have seen it elsewhere
    // e.printStackTrace();
    } finally {
        newreader.close();
        newreader = null;
    }
    // Assign classes to the correct loaders
    // Also try to set up on/off-heap class addresses
    PHDJavaClassLoader boot2 = null;
    int foundLoader = 0;
    int notFoundLoader = 0;
    // How many java/lang classes the possible boot loader has loaded
    int loaderJavaLangCount = 0;
    boolean useFirstObjectRefAsLoader = onHeapClasses[0] == 0;
    for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
        JavaClass j1 = it.next();
        PHDJavaClassLoader bestLoader = null;
        for (Iterator<JavaReference> it2 = j1.getReferences(); it2.hasNext(); ) {
            JavaReference jr = it2.next();
            try {
                // Is the first outbound object reference to a class loader?
                if (jr.isObjectReference()) {
                    JavaObject jo = (JavaObject) jr.getTarget();
                    PHDJavaClassLoader newLoader = loaders.get(jo);
                    if (newLoader != null) {
                        if (bestLoader == null || !useFirstObjectRefAsLoader) {
                            bestLoader = newLoader;
                        }
                    } else if (onHeapClasses[0] > 0) {
                        long addr = jo.getID().getAddress();
                        JavaObject jo2 = classObjects.get(addr);
                        if (jo2 != null) {
                            // For Java 6 jdmpview PHD files the on-heap class object is the last ref
                            // retrieve the full JavaObject from walking the heap earlier
                            ((PHDJavaClass) j1).setJavaObject(jo2);
                        }
                    }
                    // unless using off-heap classes when it is the last reference.
                    if (!j1.isArray() && useFirstObjectRefAsLoader && onHeapClasses[0] == 0)
                        break;
                }
            } catch (CorruptDataException e) {
            // e.printStackTrace();
            } catch (DataUnavailable e) {
            // e.printStackTrace();
            }
        }
        if (bestLoader != null) {
            ++foundLoader;
            // Don't remove the classes from the original loader, nor change the loader
            // as otherwise finding the array type fails
            bestLoader.prepareToMove(boot, j1);
            // Is the class by any chance the type of the class loader?
            try {
                if (boot2 == null && (j1.equals(jlc) || j1.equals(bestLoader.getObject().getJavaClass()))) {
                    // We have found the new bootstrap class loader
                    // Beware java 1.4.2 com/ibm/rmi/util/ClassInfo$NULL_CL_CLASS passes this test!
                    boot2 = bestLoader;
                }
                if (boot2 == bestLoader && j1.getName().startsWith("java/lang/"))
                    ++loaderJavaLangCount;
            } catch (CorruptDataException e) {
            }
        } else {
            ++notFoundLoader;
        }
        // Try retrieving the full JavaObject for the JavaClass
        try {
            JavaObject jo = j1.getObject();
            if (jo != null) {
                long addr = jo.getID().getAddress();
                JavaObject jo2 = classObjects.get(addr);
                if (jo2 != null) {
                    ((PHDJavaClass) j1).setJavaObject(jo2);
                }
            }
        } catch (CorruptDataException e) {
        }
    }
    // Ignore a bootstrap loader which hasn't loaded 5 java/lang classes
    if (loaderJavaLangCount < 5)
        boot2 = null;
    // Haven't found any loaders, but have a javacore file with loader information
    if (metaJavaRuntime != null) {
        for (Iterator i = metaJavaRuntime.getJavaClassLoaders(); i.hasNext(); ) {
            Object next = i.next();
            if (next instanceof CorruptData)
                continue;
            JavaClassLoader jcl2 = (JavaClassLoader) next;
            try {
                JavaObject lo = jcl2.getObject();
                if (lo != null) {
                    ImagePointer addr = lo.getID();
                    if (addr != null) {
                        ImagePointer ip = space.getPointer(addr.getAddress());
                        JavaObject jo = getObjectAtAddress(ip);
                        PHDJavaClassLoader newLoader = loaders.get(jo);
                        JavaClass loaderClass;
                        if (newLoader == null) {
                            try {
                                // Should be safe to find the class of 'jo' without rereading the PHD file
                                // as at least a dummy object should be in the extra objects cache.
                                // It could be that the object is still a dummy one with no proper class.
                                loaderClass = jo.getJavaClass();
                            } catch (CorruptDataException e) {
                                loaderClass = null;
                            }
                            JavaClass javacoreLoaderClass;
                            try {
                                javacoreLoaderClass = lo.getJavaClass();
                            } catch (CorruptDataException e) {
                                javacoreLoaderClass = null;
                            }
                            // Mismatch occurs with J2RE 5.0 IBM J9 2.3 Linux amd64-64 build j9vmxa6423-20091104
                            if (loaderClass != null && javacoreLoaderClass != null && (loaderClass.isArray() || loaderClass.getID() != null && javacoreLoaderClass.getID() != null && loaderClass.getID().getAddress() != javacoreLoaderClass.getID().getAddress())) {
                            // System.out.println("Skipping loader "+newLoader+" "+jo+" "+jo.getJavaClass()+" "+lo+" "+lo.getJavaClass()+" "+Long.toHexString(addr.getAddress())+" "+ip);
                            } else {
                                // The object should have been listed in the extra objects, so may now be the proper object
                                newLoader = new PHDJavaClassLoader(jo);
                                loaders.put(jo, newLoader);
                            }
                        } else {
                            // Replace with the offical object
                            jo = newLoader.getObject();
                            loaderClass = jo.getJavaClass();
                        }
                        if (newLoader != null) {
                            for (Iterator i2 = jcl2.getDefinedClasses(); i2.hasNext(); ) {
                                Object next2 = i2.next();
                                if (next2 instanceof CorruptData)
                                    continue;
                                JavaClass jc2 = (JavaClass) next2;
                                ImagePointer ip2 = jc2.getID();
                                JavaClass j1;
                                if (ip2 != null) {
                                    long claddr = ip2.getAddress();
                                    j1 = boot.findClass(claddr);
                                    // Not found by address, so try by name.
                                    if (j1 == null) {
                                        // But only if it is the only class of that name
                                        j1 = boot.findClassUnique(jc2.getName());
                                    } else {
                                        // Found by address
                                        try {
                                            j1.getName();
                                        } catch (CorruptDataException e) {
                                            // Our class doesn't have a name, so perhaps the javacore has the name
                                            try {
                                                String actualName = jc2.getName();
                                                PHDJavaClass pj1 = (PHDJavaClass) j1;
                                                // We will need to reindex the classloader as the name as changed
                                                pj1.setName(actualName);
                                            } catch (CorruptDataException e2) {
                                            }
                                        }
                                    }
                                } else {
                                    // But only if it is the only class of that name
                                    j1 = boot.findClassUnique(jc2.getName());
                                }
                                if (j1 != null) {
                                    newLoader.prepareToMove(boot, j1);
                                    // listed in javacore causes problems as byte etc. aren't listed
                                    if (j1.equals(loaderClass) || j1.equals(jlc)) {
                                        // We have found the new bootstrap class loader
                                        boot2 = newLoader;
                                    }
                                    for (Iterator i3 = jc2.getDeclaredMethods(); i3.hasNext(); ) {
                                        Object next3 = i3.next();
                                        if (next3 instanceof CorruptData)
                                            continue;
                                        JavaMethod jm = (JavaMethod) next3;
                                        PHDJavaClass pj1 = (PHDJavaClass) j1;
                                        pj1.addMethod(new PHDJavaMethod(space, pj1, jm));
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (CorruptDataException e) {
            } catch (DataUnavailable e) {
            } catch (MemoryAccessException e) {
            }
        }
    }
    // Move the classes to the correct class loaders
    for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
        JavaClass j1 = it.next();
        try {
            JavaClassLoader jcl2 = j1.getClassLoader();
            if (!boot.equals(jcl2) && jcl2 instanceof PHDJavaClassLoader) {
                transferClass(boot, (PHDJavaClassLoader) jcl2, j1);
            }
        } catch (CorruptDataException e) {
        }
    }
    // Reindex the loaders to account for the removed classes
    for (PHDJavaClassLoader loader : loaders.values()) {
        loader.initCache();
    }
    if (boot2 != null) {
        // Move remaining classes to new boot loader
        for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
            JavaClass j1 = it.next();
            boot2.prepareToMove(boot, j1);
            transferClass(boot, boot2, j1);
        }
        // index the new boot loader to account for the added files
        boot2.initCache();
        // Remove the original boot class loader as it has no classes
        loaders.remove(null);
    } else {
        // There may be duplicate array classes in the boot loader
        for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
            JavaClass j1 = it.next();
            JavaClass j2 = boot.setArrayType(this, boot, j1);
        }
        // index the boot loader to account for the added files
        boot.initCache();
    }
}
Also used : PortableHeapDumpListener(com.ibm.dtfj.phd.parser.PortableHeapDumpListener) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImagePointer(com.ibm.dtfj.image.ImagePointer) JavaReference(com.ibm.dtfj.java.JavaReference) LongEnumeration(com.ibm.dtfj.phd.util.LongEnumeration) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaMethod(com.ibm.dtfj.java.JavaMethod) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException) HashSet(java.util.HashSet) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException) IOException(java.io.IOException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JavaClass(com.ibm.dtfj.java.JavaClass) JavaObject(com.ibm.dtfj.java.JavaObject) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) CorruptData(com.ibm.dtfj.image.CorruptData) JavaObject(com.ibm.dtfj.java.JavaObject)

Example 19 with DataUnavailable

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

the class PHDImageProcess method processData.

private void processData(ImageAddressSpace space) {
    // }
    if (metaImageProcess != null) {
        try {
            for (Iterator it = metaImageProcess.getLibraries(); it.hasNext(); ) {
                Object next = it.next();
                if (next instanceof CorruptData) {
                    modules.add(new PHDCorruptImageModule(space, (CorruptData) next));
                } else {
                    try {
                        ImageModule mod = (ImageModule) next;
                        modules.add(new PHDImageModule(mod.getName()));
                    } catch (CorruptDataException e) {
                        modules.add(new PHDCorruptImageModule(space, e));
                    }
                }
            }
        } catch (CorruptDataException e) {
            modules_cd = new PHDCorruptData(space, e);
        } catch (DataUnavailable e) {
        // Ignore
        }
        /*
			 * Set up the image threads
			 */
        ImageThread current;
        try {
            current = metaImageProcess.getCurrentThread();
        } catch (CorruptDataException e) {
            currentThread = new PHDCorruptImageThread(space, e.getCorruptData());
            current = null;
        }
        for (Iterator it = metaImageProcess.getThreads(); it.hasNext(); ) {
            Object next = it.next();
            if (next instanceof CorruptData) {
                threads.put(next, new PHDCorruptImageThread(space, (CorruptData) next));
            } else {
                ImageThread thrd = (ImageThread) next;
                ImageThread imageThread = getThread(space, thrd);
                if (thrd.equals(current)) {
                    currentThread = imageThread;
                }
            }
        }
    }
// pid = getPID(file);
// runtimes = new ArrayList<JavaRuntime>();
// runtimes.add(new PHDJavaRuntime(file, parentImage, space,this,metaRuntime));
}
Also used : Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageThread(com.ibm.dtfj.image.ImageThread) ImageModule(com.ibm.dtfj.image.ImageModule)

Example 20 with DataUnavailable

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

the class InfoThreadCommand method printJavaThreadInfo.

private void printJavaThreadInfo(JavaThread jt, boolean idPrinted) {
    out.print("    name:          ");
    try {
        out.print(jt.getName());
    } catch (CorruptDataException e) {
        out.print(Exceptions.getCorruptDataExceptionString());
        logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
    }
    out.print("\n");
    if (!idPrinted) {
        try {
            if (jt.getImageThread() != null) {
                out.print("    id:            ");
                out.print(jt.getImageThread().getID());
            }
        } catch (CorruptDataException e) {
            out.print(Exceptions.getCorruptDataExceptionString());
            logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
        } catch (DataUnavailable e) {
            out.print(Exceptions.getDataUnavailableString());
            logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), e);
        } finally {
            out.print("\n");
        }
    }
    out.print("    Thread object: ");
    try {
        JavaObject threadObj = jt.getObject();
        if (null == threadObj) {
            out.print("<no associated Thread object>");
        } else {
            String threadClassName = null;
            try {
                JavaClass threadClass = threadObj.getJavaClass();
                threadClassName = threadClass.getName();
                if (threadClassName != null) {
                    out.print(threadClassName + " @ ");
                }
                out.print(Utils.toHex(threadObj.getID().getAddress()));
                // Navigate to the parent java/lang.Thread class to get the 'tid' and 'isDaemon' fields
                while (!JAVA_LANG_THREAD_CLASS.equals(threadClass.getName()) && threadClass != null) {
                    threadClass = threadClass.getSuperclass();
                }
                if (threadClass != null) {
                    Iterator itField = threadClass.getDeclaredFields();
                    boolean foundThreadId = false;
                    while (itField.hasNext()) {
                        JavaField jf = (JavaField) itField.next();
                        /* "uniqueId" field in java.lang.Thread is renamed to "tid". The old field name is
							 * checked to preserve functionality of DDR command with old core files that reference
							 * the "uniqueId" field.
							 */
                        if (!foundThreadId && (jf.getName().equals("uniqueId") || jf.getName().equals("tid"))) {
                            foundThreadId = true;
                            out.print("\n    ID:            " + Utils.getVal(threadObj, jf));
                        } else if (jf.getName().equals("isDaemon")) {
                            out.print("\n    Daemon:        " + Utils.getVal(threadObj, jf));
                        }
                    }
                }
            } catch (CorruptDataException cde) {
                out.print(" <in-flight or corrupt data encountered>");
                logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), cde);
            }
        }
    } catch (CorruptDataException cde) {
        out.print(Exceptions.getCorruptDataExceptionString());
        logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), cde);
    }
    out.print("\n");
    out.print("    Priority:      ");
    try {
        Integer pri = new Integer(jt.getPriority());
        out.print(pri.toString());
    } catch (CorruptDataException e) {
        out.print(Exceptions.getCorruptDataExceptionString());
        logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
    }
    out.print("\n");
    out.print("    Thread.State:  ");
    try {
        out.print(StateToString.getThreadStateString(jt.getState()));
    } catch (CorruptDataException cde) {
        out.print(Exceptions.getCorruptDataExceptionString());
        logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), cde);
    }
    out.print("\n");
    out.print("    JVMTI state:   ");
    try {
        out.print(StateToString.getJVMTIStateString(jt.getState()));
    } catch (CorruptDataException cde) {
        out.print(Exceptions.getCorruptDataExceptionString());
        logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), cde);
    }
    out.print("\n");
    printThreadBlocker(jt);
    out.print("    Java stack frames: ");
    printJavaStackFrameInfo(jt);
    out.print("\n");
}
Also used : JavaField(com.ibm.dtfj.java.JavaField) JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) StateToString(com.ibm.jvm.dtfjview.commands.helpers.StateToString)

Aggregations

DataUnavailable (com.ibm.dtfj.image.DataUnavailable)62 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)39 Iterator (java.util.Iterator)25 JavaObject (com.ibm.dtfj.java.JavaObject)20 CorruptData (com.ibm.dtfj.image.CorruptData)15 Properties (java.util.Properties)13 JavaClass (com.ibm.dtfj.java.JavaClass)9 JavaThread (com.ibm.dtfj.java.JavaThread)9 ImageProcess (com.ibm.dtfj.image.ImageProcess)8 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)8 ImageThread (com.ibm.dtfj.image.ImageThread)7 ImageModule (com.ibm.dtfj.image.ImageModule)6 JavaReference (com.ibm.dtfj.java.JavaReference)6 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)5 ImageSection (com.ibm.dtfj.image.ImageSection)4 DTFJCorruptDataException (com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException)4 ImagePointer (com.ibm.dtfj.image.ImagePointer)3 JavaMethod (com.ibm.dtfj.java.JavaMethod)3 JavaMonitor (com.ibm.dtfj.java.JavaMonitor)3 StateToString (com.ibm.jvm.dtfjview.commands.helpers.StateToString)3