Search in sources :

Example 26 with ImageSection

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

the class InfoHeapCommand method printSectionInfo.

private void printSectionInfo(JavaHeap theHeap, PrintStream out) {
    Iterator itSections = theHeap.getSections();
    int countSections = 1;
    while (itSections.hasNext()) {
        ImageSection theSection = (ImageSection) itSections.next();
        out.print("\t  Section #" + countSections + ":  " + theSection.getName() + "\n");
        out.print("\t   Size:        " + theSection.getSize() + " bytes\n");
        try {
            out.print("\t   Shared:      " + theSection.isShared() + "\n");
            out.print("\t   Executable:  " + theSection.isExecutable() + "\n");
            out.print("\t   Read Only:   " + theSection.isReadOnly() + "\n");
        } catch (DataUnavailable e) {
            out.print("\t   Shared:      <unknown>\n");
            out.print("\t   Executable:  <unknown>\n");
            out.print("\t   Read Only:   <unknown>\n");
        }
        countSections++;
    }
}
Also used : Iterator(java.util.Iterator) ImageSection(com.ibm.dtfj.image.ImageSection) DataUnavailable(com.ibm.dtfj.image.DataUnavailable)

Example 27 with ImageSection

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

the class InfoHeapCommand method printOccupancyInfo.

private void printOccupancyInfo(JavaHeap theHeap, PrintStream out) {
    /*
		 * This method takes a lot of time and hence this information is only included 
		 * when using "info heap <heapname>". If this method was run for every heap 
		 * when using "info heap *" the amount of time it would take would be astronomical.
		 */
    long size = 0;
    long totalObjectSize = 0;
    // total number of objects on the heap
    long totalObjects = 0;
    // total number of corrupt objects
    long totalCorruptObjects = 0;
    Iterator itSections = theHeap.getSections();
    // object returned from various iterators
    Object obj = null;
    // corrupt data
    CorruptData cdata = null;
    while (itSections.hasNext()) {
        obj = itSections.next();
        if (obj instanceof CorruptData) {
            // returned section is corrupt
            cdata = (CorruptData) obj;
            out.print("\t\t Warning - corrupt image section found");
            if (cdata.getAddress() != null) {
                out.print(" at 0x" + cdata.getAddress().toString());
            }
            out.print("\n");
        } else {
            // returned section is valid, so process it
            ImageSection theSection = (ImageSection) obj;
            size = size + theSection.getSize();
        }
    }
    out.print("\t  Size of heap: " + size + " bytes\n");
    Iterator itObjects = theHeap.getObjects();
    try {
        while (itObjects.hasNext()) {
            obj = itObjects.next();
            totalObjects++;
            if (obj instanceof CorruptData) {
                totalCorruptObjects++;
                cdata = (CorruptData) obj;
                out.print("\t\t Warning - corrupt heap object found at position " + totalObjects);
                if (cdata.getAddress() != null) {
                    out.print(" address 0x" + cdata.getAddress().toString());
                }
                out.print("\n");
            } else {
                JavaObject theObject = (JavaObject) obj;
                totalObjectSize = totalObjectSize + theObject.getSize();
            }
        }
        float percentage = ((float) totalObjectSize / (float) size) * 10000;
        // Sending this float through an int gets it down to 2 decimal places.
        int trimmedPercent = ((int) percentage);
        percentage = ((float) trimmedPercent) / 100;
        out.print("\t  Occupancy               :   " + totalObjectSize + " bytes  (" + percentage + "%)\n");
        out.print("\t  Total objects           :   " + totalObjects + "\n");
        out.print("\t  Total corrupted objects :   " + totalCorruptObjects + "\n");
    } catch (CorruptDataException e) {
        out.print("\t  Occupancy :   <unknown>\n");
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) ImageSection(com.ibm.dtfj.image.ImageSection) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 28 with ImageSection

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

the class WhatisCommand method isWithinImageSections.

private boolean isWithinImageSections(Iterator heapImageSections, Object memType, boolean isMethodCompiled, long address) {
    while (heapImageSections.hasNext()) {
        ImageSection imageSection = (ImageSection) heapImageSections.next();
        long baseAddress = imageSection.getBaseAddress().getAddress();
        long size = imageSection.getSize();
        long endAddress = baseAddress + size;
        if (address <= endAddress && address >= baseAddress) {
            if (null == memType) {
                out.print("\t\t0x" + Long.toHexString(address) + " is within heap segment: " + Long.toHexString(baseAddress) + " -- " + Long.toHexString(endAddress) + "\n");
                return true;
            }
            if (memType instanceof JavaMethod) {
                String methodName = "N/A", methodSig = "N/A", className = "N/A";
                try {
                    methodName = ((JavaMethod) memType).getName();
                    methodSig = ((JavaMethod) memType).getSignature();
                    className = ((JavaMethod) memType).getDeclaringClass().getName();
                } catch (CorruptDataException cde) {
                } catch (DataUnavailable du) {
                }
                String codeType = isMethodCompiled ? "compiled code" : "byte code";
                out.print("\t0x" + Long.toHexString(address) + " is within the " + codeType + " range: " + Long.toHexString(baseAddress) + " -- " + Long.toHexString(endAddress) + "\n\t" + "...of method " + methodName + " with signature " + methodSig + "\n\t" + "...in class " + className + "\n");
                return true;
            }
        }
    }
    return false;
}
Also used : ImageSection(com.ibm.dtfj.image.ImageSection) JavaMethod(com.ibm.dtfj.java.JavaMethod) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 29 with ImageSection

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

the class InfoSymCommand method printModule.

private void printModule(ImageModule imageModule, boolean printSymbols) {
    try {
        out.print("\t  " + imageModule.getName());
    } catch (CorruptDataException cde) {
        out.print("\t  " + Exceptions.getCorruptDataExceptionString());
    }
    try {
        String addressInHex = String.format("0x%x", imageModule.getLoadAddress());
        out.print(" @ " + addressInHex);
    } catch (DataUnavailable e) {
    // if we do not have the load address, simply omit it
    } catch (CorruptDataException e) {
    // if we do not have the load address, simply omit it
    }
    Iterator itSection = imageModule.getSections();
    if (itSection.hasNext()) {
        out.print(", sections:\n");
    } else {
        out.print(", <no section information>\n");
    }
    // iterate through the library sections
    while (itSection.hasNext()) {
        Object next = itSection.next();
        if (next instanceof ImageSection) {
            ImageSection is = (ImageSection) next;
            out.print("\t   0x" + Long.toHexString(is.getBaseAddress().getAddress()) + " - 0x" + Long.toHexString(is.getBaseAddress().getAddress() + is.getSize()));
            out.print(", name: \"");
            out.print(is.getName());
            out.print("\", size: 0x");
            out.print(Long.toHexString(is.getSize()));
            out.print("\n");
        } else if (next instanceof CorruptData) {
            // warn the user that this image section is corrupt
            out.print("\t   <corrupt section encountered>\n");
        } else {
            // unexpected type in iterator
            out.print("\t   <corrupt section encountered>\n");
        }
    }
    if (printSymbols) {
        out.print("\t  " + "symbols:\n");
        Iterator itSymbols = imageModule.getSymbols();
        while (itSymbols.hasNext()) {
            Object next = itSymbols.next();
            if (next instanceof ImageSymbol) {
                ImageSymbol is = (ImageSymbol) next;
                out.print("\t   0x" + Long.toHexString(is.getAddress().getAddress()));
                out.print(", name: \"");
                out.print(is.getName());
                out.print("\"\n");
            } else if (next instanceof CorruptData) {
                // warn the user that this image section is corrupt
                out.print("\t   <corrupt symbol encountered>\n");
            } else {
                // unexpected type in iterator
                out.print("\t   <corrupt symbol encountered>\n");
            }
        }
    }
    out.print("\n");
}
Also used : ImageSymbol(com.ibm.dtfj.image.ImageSymbol) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) ImageSection(com.ibm.dtfj.image.ImageSection) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 30 with ImageSection

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

the class InfoJitmCommand method showJITdMethods.

private void showJITdMethods() {
    JavaRuntime jr = ctx.getRuntime();
    Iterator itJavaClassLoader = jr.getJavaClassLoaders();
    while (itJavaClassLoader.hasNext()) {
        JavaClassLoader jcl = (JavaClassLoader) itJavaClassLoader.next();
        Iterator itJavaClass = jcl.getDefinedClasses();
        while (itJavaClass.hasNext()) {
            JavaClass jc = (JavaClass) itJavaClass.next();
            Iterator itJavaMethod = jc.getDeclaredMethods();
            String jcName;
            try {
                jcName = jc.getName();
            } catch (CorruptDataException e) {
                jcName = Exceptions.getCorruptDataExceptionString();
            }
            while (itJavaMethod.hasNext()) {
                JavaMethod jm = (JavaMethod) itJavaMethod.next();
                String name;
                String sig;
                try {
                    name = jm.getName();
                } catch (CorruptDataException e) {
                    name = Exceptions.getCorruptDataExceptionString();
                }
                try {
                    sig = jm.getSignature();
                } catch (CorruptDataException e) {
                    sig = Exceptions.getCorruptDataExceptionString();
                }
                if (jm.getCompiledSections().hasNext()) {
                    Iterator itImageSection = jm.getCompiledSections();
                    while (itImageSection.hasNext()) {
                        ImageSection is = (ImageSection) itImageSection.next();
                        long startAddr = is.getBaseAddress().getAddress();
                        long size = is.getSize();
                        long endAddr = startAddr + size;
                        out.print("\n\t" + "start=" + Utils.toHex(startAddr) + "  " + "end=" + Utils.toHex(endAddr) + "   " + jcName + "::" + name + sig);
                    }
                }
            }
        }
    }
    out.print("\n");
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) JavaMethod(com.ibm.dtfj.java.JavaMethod) ImageSection(com.ibm.dtfj.image.ImageSection) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Aggregations

ImageSection (com.ibm.dtfj.image.ImageSection)30 Iterator (java.util.Iterator)18 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)11 ArrayList (java.util.ArrayList)7 CorruptData (com.ibm.dtfj.image.CorruptData)6 LinkedList (java.util.LinkedList)5 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)4 J9DDRImageSection (com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)4 ImagePointer (com.ibm.dtfj.image.ImagePointer)3 JavaMethod (com.ibm.dtfj.java.JavaMethod)3 JavaObject (com.ibm.dtfj.java.JavaObject)3 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)3 ImageProcess (com.ibm.dtfj.image.ImageProcess)2 ImageSymbol (com.ibm.dtfj.image.ImageSymbol)2 ImageThread (com.ibm.dtfj.image.ImageThread)2 JavaClass (com.ibm.dtfj.java.JavaClass)2 JavaHeap (com.ibm.dtfj.java.JavaHeap)2 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)2 J9DDRDTFJUtils.corruptIterator (com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator)2 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)2