Search in sources :

Example 26 with CorruptData

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

the class InfoSymCommand method listModules.

private void listModules(String moduleName) {
    ImageProcess ip = ctx.getProcess();
    try {
        Object e = ip.getExecutable();
        if (e instanceof ImageModule) {
            ImageModule exe = (ImageModule) e;
            if (moduleName != null) {
                if (checkModuleName(exe.getName(), moduleName)) {
                    printModule(exe, true);
                }
            } else {
                printModule(exe, false);
            }
        } else if (e instanceof CorruptData) {
            CorruptData corruptObj = (CorruptData) e;
            // warn the user that this image library is corrupt
            out.print("\t  <corrupt executable encountered: " + corruptObj.toString() + ">\n\n");
        }
    } catch (DataUnavailable e) {
        out.println(Exceptions.getDataUnavailableString());
    } catch (CorruptDataException e) {
        out.println(Exceptions.getCorruptDataExceptionString());
    }
    Iterator iLibs;
    try {
        iLibs = ip.getLibraries();
    } catch (DataUnavailable du) {
        iLibs = null;
        out.println(Exceptions.getDataUnavailableString());
    } catch (CorruptDataException cde) {
        iLibs = null;
        out.println(Exceptions.getCorruptDataExceptionString());
    }
    // iterate through the libraries
    while (null != iLibs && iLibs.hasNext()) {
        Object next = iLibs.next();
        if (next instanceof ImageModule) {
            ImageModule mod = (ImageModule) next;
            String currentName = null;
            try {
                currentName = mod.getName();
            } catch (CorruptDataException e) {
                out.print("\t  <corrupt library name: " + mod.toString() + ">\n\n");
            }
            if (moduleName != null) {
                if (checkModuleName(currentName, moduleName)) {
                    printModule(mod, true);
                }
            } else {
                printModule(mod, false);
            }
        } else if (next instanceof CorruptData) {
            CorruptData corruptObj = (CorruptData) next;
            // warn the user that this image library is corrupt
            out.print("\t  <corrupt library encountered: " + corruptObj.toString() + ">\n\n");
        } else {
            // unexpected type in iterator
            out.print("\t  <corrupt library encountered>\n\n");
        }
    }
}
Also used : ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageModule(com.ibm.dtfj.image.ImageModule)

Example 27 with CorruptData

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

the class InfoClassCommand method countClassInstances.

private void countClassInstances() {
    JavaRuntime runtime = ctx.getRuntime();
    Map<JavaClass, ClassStatistics> thisRuntimeClasses = classInstanceCounts.get(runtime);
    final Collection<JavaClass> javaClasses = getRuntimeClasses(runtime);
    long corruptObjectCount = 0;
    long corruptClassCount = 0;
    long corruptClassNameCount = 0;
    Iterator itHeap = runtime.getHeaps();
    while (itHeap.hasNext()) {
        Object heap = itHeap.next();
        if (heap instanceof CorruptData) {
            out.println("[skipping corrupt heap]");
            continue;
        }
        JavaHeap jh = (JavaHeap) heap;
        Iterator itObject = jh.getObjects();
        // Walk through all objects in this heap, accumulating counts and total memory size by class
        while (itObject.hasNext()) {
            Object next = itObject.next();
            // JavaHeap, we don't attempt to count these as instances of known classes).
            if (next instanceof JavaObject) {
                JavaObject jo = (JavaObject) next;
                ClassStatistics stats = null;
                try {
                    // Check whether we found this class in the classloaders walk earlier
                    JavaClass jc = jo.getJavaClass();
                    if (javaClasses.contains(jc)) {
                        stats = thisRuntimeClasses.get(jc);
                    } else {
                        // Class not found in the classloaders, create a statistic for it now, and issue a warning message
                        stats = new ClassStatistics();
                        thisRuntimeClasses.put(jc, stats);
                        String classname;
                        try {
                            classname = jc.getName();
                            out.println("Warning, class: " + classname + " found when walking the heap was missing from classloader walk");
                        } catch (CorruptDataException cde) {
                            corruptClassNameCount++;
                        }
                    }
                    // Increment the statistic for objects of this class (accumulated count and size)
                    stats.incrementCount();
                    try {
                        stats.addToSize(jo.getSize());
                    } catch (CorruptDataException cde) {
                        // bad size, count object as corrupt
                        corruptObjectCount++;
                    }
                } catch (CorruptDataException cde) {
                    corruptClassCount++;
                }
            } else {
                corruptObjectCount++;
            }
        }
    }
    if (corruptObjectCount != 0) {
        out.println("Warning, found " + corruptObjectCount + " corrupt objects during heap walk");
    }
    if (corruptClassCount != 0) {
        out.println("Warning, found " + corruptClassCount + " corrupt class references during heap walk");
    }
    if (corruptClassNameCount != 0) {
        out.println("Warning, found " + corruptClassNameCount + " corrupt class names during heap walk");
    }
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaHeap(com.ibm.dtfj.java.JavaHeap) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JavaClass(com.ibm.dtfj.java.JavaClass) JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData)

Example 28 with CorruptData

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

the class InfoSystemCommand method doCommand.

public void doCommand() {
    try {
        out.println("\nMachine OS:\t" + ctx.getImage().getSystemType());
    } catch (DataUnavailable exc) {
        out.println("\nMachine OS:\t" + "data unavailable");
    } catch (CorruptDataException exc) {
        out.println("\nMachine OS:\t" + "data corrupted");
    }
    Properties imageProperties = ctx.getImage().getProperties();
    if (imageProperties.containsKey("Hypervisor")) {
        out.println("Hypervisor:\t" + imageProperties.getProperty("Hypervisor"));
    }
    try {
        out.println("Machine name:\t" + ctx.getImage().getHostName());
    } catch (DataUnavailable exc) {
        out.println("Machine name:\t" + "data unavailable");
    } catch (CorruptDataException exc) {
        out.println("Machine name:\t" + "data corrupted");
    }
    out.println("Machine IP address(es):");
    try {
        Iterator<?> itIPAddresses = ctx.getImage().getIPAddresses();
        while (itIPAddresses.hasNext()) {
            Object addr = itIPAddresses.next();
            if (addr instanceof InetAddress) {
                out.println("\t\t" + ((InetAddress) addr).getHostAddress());
            } else if (addr instanceof CorruptData) {
                out.println("\t\tdata corrupted");
            }
        }
    } catch (DataUnavailable du) {
        out.println("\t\tdata unavailable");
    }
    try {
        out.println("System memory:\t" + ctx.getImage().getInstalledMemory());
    } catch (DataUnavailable exc) {
        out.println("System memory:\t" + "data unavailable");
    }
    try {
        long createTimeMillis = ctx.getImage().getCreationTime();
        if (createTimeMillis != 0) {
            DateFormat fmt = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
            String createTimeStr = fmt.format(new Date(createTimeMillis));
            out.println("\nDump creation time: " + createTimeStr);
        } else {
            out.println("\nDump creation time: data unavailable");
        }
    } catch (DataUnavailable d) {
        out.println("\nDump creation time: data unavailable");
    }
    // Dump creation time - nanotime - added in DTFJ 1.12
    try {
        long createTimeNanos = ctx.getImage().getCreationTimeNanos();
        if (createTimeNanos != 0) {
            out.println("Dump creation time (nanoseconds): " + createTimeNanos);
        } else {
            out.println("Dump creation time (nanoseconds): data unavailable");
        }
    } catch (DataUnavailable du) {
        out.println("Dump creation time (nanoseconds): data unavailable");
    } catch (CorruptDataException cde) {
        out.println("Dump creation time (nanoseconds): data corrupted");
    }
    out.println("\nJava version:");
    if (ctx.getRuntime() != null) {
        try {
            out.println(ctx.getRuntime().getVersion());
        } catch (CorruptDataException e) {
            out.println("version data corrupted");
        }
    } else {
        out.println("\tmissing, unknown or unsupported JRE");
    }
    // JVM start time - millisecond wall clock - added in DTFJ 1.12
    try {
        long startTimeMillis = ctx.getRuntime().getStartTime();
        if (startTimeMillis != 0) {
            DateFormat fmt = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
            String createTimeStr = fmt.format(new Date(startTimeMillis));
            out.println("\nJVM start time: " + createTimeStr);
        } else {
            out.println("\nJVM start time: data unavailable");
        }
    } catch (DataUnavailable d) {
        out.println("\nJVM start time: data unavailable");
    } catch (CorruptDataException cde) {
        out.println("\nJVM start time (nanoseconds): data corrupted");
    }
    // JVM start time - nanotime - added in DTFJ 1.12
    try {
        long startTimeNanos = ctx.getRuntime().getStartTimeNanos();
        if (startTimeNanos != 0) {
            out.println("JVM start time (nanoseconds): " + startTimeNanos);
        } else {
            out.println("JVM start time (nanoseconds): data unavailable");
        }
    } catch (DataUnavailable du) {
        out.println("JVM start time (nanoseconds): data unavailable");
    } catch (CorruptDataException cde) {
        out.println("JVM start time (nanoseconds): data corrupted");
    }
    boolean kernelSettingPrinted = false;
    for (String name : new String[] { "/proc/sys/kernel/sched_compat_yield", "/proc/sys/kernel/core_pattern", "/proc/sys/kernel/core_uses_pid" }) {
        if (imageProperties.containsKey(name)) {
            if (!kernelSettingPrinted) {
                out.println("\nLinux Kernel Settings:");
            }
            out.println(name + " = " + imageProperties.getProperty(name));
            kernelSettingPrinted = true;
        }
    }
    out.println();
}
Also used : CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Properties(java.util.Properties) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptData(com.ibm.dtfj.image.CorruptData) InetAddress(java.net.InetAddress) SimpleDateFormat(java.text.SimpleDateFormat)

Example 29 with CorruptData

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

the class InfoHeapCommand method printHeapInfo.

private void printHeapInfo(String param, JavaRuntime runtime, PrintStream out) {
    Iterator itHeaps = runtime.getHeaps();
    int countheaps = 1;
    while (itHeaps.hasNext()) {
        Object heap = itHeaps.next();
        if (heap instanceof CorruptData) {
            out.println("[skipping corrupt heap");
            continue;
        }
        JavaHeap theHeap = (JavaHeap) heap;
        out.print("\t Heap #" + countheaps + ":  " + theHeap.getName() + "\n");
        if (param != null) {
            printSectionInfo(theHeap, out);
        }
        countheaps++;
    }
}
Also used : JavaHeap(com.ibm.dtfj.java.JavaHeap) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData)

Example 30 with CorruptData

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

the class PHDJavaRuntime method prepClassLoaders.

/**
 * Remember objects associated with class loaders
 * Performance optimization - we can then find these objects on a scan through the heap
 * and remember them, saving a fruitless search of the heap if they only exist in a javacore.
 */
private void prepClassLoaders() {
    if (metaJavaRuntime != null) {
        final PHDJavaClassLoader boot = loaders.get(null);
        for (Iterator it = metaJavaRuntime.getJavaClassLoaders(); it.hasNext(); ) {
            Object next = it.next();
            if (next instanceof CorruptData)
                continue;
            JavaClassLoader load = (JavaClassLoader) next;
            try {
                JavaObject jo = load.getObject();
                saveExtraObject(boot, jo);
            } catch (CorruptDataException e) {
            }
        }
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

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