Search in sources :

Example 21 with ImageSection

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

the class ImageSectionComparator method testEquals.

// getBaseAddress()
// getName()
// getSize()
// isExecutable()
// isReadOnly()
// isShared()
public void testEquals(Object ddrObject, Object jextractObject, int members) {
    ImageSection ddrImageSection = (ImageSection) ddrObject;
    ImageSection jextractImageSection = (ImageSection) jextractObject;
    // getBaseAddress
    if ((BASE_ADDRESS & members) != 0)
        new ImagePointerComparator().testComparatorEquals(ddrImageSection, jextractImageSection, "getBaseAddress");
    // getName()
    if ((NAME & members) != 0)
        testJavaEquals(ddrImageSection, jextractImageSection, "getName");
    // getSize()
    if ((SIZE & members) != 0)
        testJavaEquals(ddrImageSection, jextractImageSection, "getSize");
    // isExecutable()
    if ((IS_EXECUTABLE & members) != 0)
        testJavaEquals(ddrImageSection, jextractImageSection, "isExecutable");
    // isShared()
    if ((IS_SHARED & members) != 0)
        testJavaEquals(ddrImageSection, jextractImageSection, "isShared");
    // isReadOnly()
    if ((IS_READONLY & members) != 0)
        testJavaEquals(ddrImageSection, jextractImageSection, "isReadOnly");
}
Also used : ImageSection(com.ibm.dtfj.image.ImageSection)

Example 22 with ImageSection

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

the class JavaHeap method setRegions.

public void setRegions(Vector regions) {
    // store the regions
    _heapRegions = regions;
    // now make the sorted index of the subsections within all the regions for faster look-up, later on
    Iterator outer = regions.iterator();
    Vector heapSubRegionSections = new Vector();
    while (outer.hasNext()) {
        JavaHeapRegion region = (JavaHeapRegion) outer.next();
        Iterator sections = region.getSections();
        while (sections.hasNext()) {
            ImageSection section = (ImageSection) sections.next();
            heapSubRegionSections.add(new HeapSubRegionSection(region, section));
        }
    }
    // now sort the sub-regions
    _allSortedRegionSections = (HeapSubRegionSection[]) heapSubRegionSections.toArray(new HeapSubRegionSection[heapSubRegionSections.size()]);
    Arrays.sort(_allSortedRegionSections, new Comparator() {

        public int compare(Object arg0, Object arg1) {
            HeapSubRegionSection one = (HeapSubRegionSection) arg0;
            HeapSubRegionSection two = (HeapSubRegionSection) arg1;
            long delta = one.base() - two.base();
            int result = 0;
            if (delta < 0) {
                result = -1;
            } else if (delta > 0) {
                result = 1;
            }
            return result;
        }
    });
}
Also used : Iterator(java.util.Iterator) ImageSection(com.ibm.dtfj.image.ImageSection) Vector(java.util.Vector) Comparator(java.util.Comparator)

Example 23 with ImageSection

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

the class ImageAddressSpaceBuilder method addImageSection.

public ImageSection addImageSection(String name, long base, long size) {
    ImagePointer basePointer = fImageAddressSpace.getPointer(base);
    ImageSection section = new JCImageSection(name, basePointer, size);
    fImageAddressSpace.addImageSection(section);
    return section;
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) ImageSection(com.ibm.dtfj.image.ImageSection) JCImageSection(com.ibm.dtfj.image.javacore.JCImageSection) JCImageSection(com.ibm.dtfj.image.javacore.JCImageSection)

Example 24 with ImageSection

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

the class PHDJavaHeap method getSections.

public Iterator<ImageSection> getSections() {
    List<ImageSection> c = new ArrayList<ImageSection>();
    // This is the start of the last object
    long last = runtime.maxAddress;
    if (runtime.minAddress <= runtime.maxAddress) {
        ImagePointer objPointer = space.getPointer(last);
        JavaObject lastObj = null;
        try {
            lastObj = getLastObject(objPointer, runtime.maxObjClass, runtime.maxObjLen);
        } catch (IOException e1) {
        // allow to fall through so that jo is null
        }
        try {
            // Find the end of the last object
            if (lastObj != null)
                last += lastObj.getSize();
            ImageSection s = new PHDImageSection(getName(), space.getPointer(runtime.minAddress), last - runtime.minAddress);
            c.add(s);
        } catch (CorruptDataException e) {
            ImageSection s = new PHDImageSection(getName(), space.getPointer(runtime.minAddress), last - runtime.minAddress);
            c.add(s);
            // The object will take some space
            s = new PHDCorruptImageSection("Corrupt " + getName(), objPointer, 8);
            c.add(s);
        }
    }
    if (runtime.minClassAddress <= runtime.maxClassAddress) {
        // Space in heap for class objects
        long last2 = runtime.maxClassAddress;
        ImagePointer objPointer = space.getPointer(last2);
        int insert = c.size();
        ImageSection s;
        try {
            JavaClass jc = runtime.findClass(last2);
            // Make sure the class takes up some room
            long size = 8;
            if (jc != null) {
                JavaObject lastObj = jc.getObject();
                if (lastObj != null && lastObj.getID().equals(jc.getID())) {
                    size = lastObj.getSize();
                }
            }
            last2 += size;
        } catch (CorruptDataException e) {
            s = new PHDCorruptImageSection("Corrupt " + getName(), objPointer, 8);
            c.add(s);
        }
        // Do the object and class object sections overlap, if so combine them
        if (last2 < runtime.minAddress || last < runtime.minClassAddress) {
            s = new PHDImageSection(getName(), space.getPointer(runtime.minClassAddress), last2 - runtime.minClassAddress);
            c.add(insert, s);
        } else {
            long minAddr = Math.min(runtime.minAddress, runtime.minClassAddress);
            long maxAddr = Math.max(last, last2);
            s = new PHDImageSection(getName(), space.getPointer(minAddr), maxAddr - minAddr);
            // Replace with a combined section
            c.set(0, s);
        }
    }
    return c.iterator();
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) ArrayList(java.util.ArrayList) ImageSection(com.ibm.dtfj.image.ImageSection) IOException(java.io.IOException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 25 with ImageSection

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

the class ClassOutput method printMethods.

public static void printMethods(Iterator methods, PrintStream out) {
    while (methods.hasNext()) {
        JavaMethod jMethod = (JavaMethod) methods.next();
        try {
            out.print("Bytecode range(s): ");
            Iterator imageSections = jMethod.getBytecodeSections();
            boolean firstSectionPassed = false;
            while (imageSections.hasNext()) {
                ImageSection is = (ImageSection) imageSections.next();
                long baseAddress = is.getBaseAddress().getAddress();
                long endAddress = baseAddress + is.getSize();
                if (firstSectionPassed) {
                    out.print(", ");
                }
                out.print(Long.toHexString(baseAddress) + " -- " + Long.toHexString(endAddress));
                firstSectionPassed = true;
            }
            out.print(":  ");
            String signature;
            try {
                out.print(Utils.getMethodModifierString(jMethod));
            } catch (CorruptDataException e) {
                out.print(Exceptions.getCorruptDataExceptionString());
            }
            try {
                signature = jMethod.getSignature();
            } catch (CorruptDataException e) {
                out.print(Exceptions.getCorruptDataExceptionString());
                signature = null;
            }
            if (null != signature) {
                String name = Utils.getReturnValueName(signature);
                if (null == name) {
                    out.print("<unknown>");
                } else {
                    out.print(name);
                }
            }
            out.print(" ");
            out.print(jMethod.getName());
            if (null != signature) {
                String name = Utils.getMethodSignatureName(signature);
                if (null == name) {
                    out.print("<unknown>");
                } else {
                    out.print(name);
                }
            }
            out.print("\n");
        } catch (CorruptDataException cde) {
            out.print("N/A (CorruptDataException occurred)");
        }
    }
}
Also used : 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