Search in sources :

Example 41 with ImagePointer

use of com.ibm.dtfj.image.ImagePointer 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 42 with ImagePointer

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

the class PHDJavaRuntime method initClassCache.

private void initClassCache() {
    for (PHDJavaClassLoader ldr : loaders.values()) {
        for (Iterator<JavaClass> it = ldr.getDefinedClasses(); it.hasNext(); ) {
            JavaClass cls = it.next();
            ImagePointer ip = cls.getID();
            if (ip != null) {
                classIdCache.put(ip.getAddress(), cls);
            } else {
                // Some classes have pseudo ids
                for (long l = 1; l <= lastDummyClassAddr(); ++l) {
                    if (cls.equals(ldr.findClass(l))) {
                        classIdCache.put(l, cls);
                    }
                }
            }
        }
    }
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JavaClass(com.ibm.dtfj.java.JavaClass)

Example 43 with ImagePointer

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

the class FindCommand method scanRegion.

private boolean scanRegion(long start, long end, ImageSection imageSection) {
    ImagePointer imagePointer = imageSection.getBaseAddress();
    long i;
    if (0 != start % findAtt.boundary) {
        i = start - start % findAtt.boundary + findAtt.boundary;
    } else {
        i = start;
    }
    int patternLength = findAtt.length();
    byte[] bytes = findAtt.getBytes();
    for (; i <= end; i += findAtt.boundary) {
        int j;
        for (j = 0; j < patternLength; j++) {
            byte oneByte = bytes[j];
            try {
                if (getByteFromImage(imagePointer, i + j) == oneByte) {
                    continue;
                } else {
                    break;
                }
            } catch (MemoryAccessException mae) {
                return false;
            }
        }
        if (j >= patternLength) {
            matches.add(new Long(i));
            if (matches.size() == findAtt.numMatchesToDisplay)
                return true;
        }
    }
    return false;
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 44 with ImagePointer

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

the class XDCommand method doCommand.

public void doCommand(String[] args) {
    String param = args[0];
    Long address;
    address = Utils.longFromStringWithPrefix(param);
    if (null == address) {
        out.println("invalid hex address specified; address must be specified as " + "\"0x<hex_address>\"");
        return;
    }
    out.print("\n");
    boolean found = false;
    for (int index = 0; index < argUnitNumber; index++) {
        long currAddr = address.longValue() + (index * argUnitSize);
        out.print("\t");
        out.print(Utils.toHex(currAddr));
        out.print(": ");
        ImageAddressSpace ias = ctx.getAddressSpace();
        ImagePointer ip = ias.getPointer(currAddr);
        byte b = 0;
        short s = 0;
        int i = 0;
        long l = 0;
        try {
            switch(argUnitSize) {
                case 1:
                    b = ip.getByteAt(0);
                    break;
                case 2:
                    s = ip.getShortAt(0);
                    break;
                case 4:
                    i = ip.getIntAt(0);
                    break;
                case 8:
                    l = ip.getLongAt(0);
                    break;
            }
            found = true;
        } catch (CorruptDataException e) {
            found = false;
        } catch (MemoryAccessException e) {
            found = false;
        }
        if (found) {
            switch(argUnitSize) {
                case 1:
                    out.print(Byte.toString(b));
                    break;
                case 2:
                    out.print(Short.toString(s));
                    break;
                case 4:
                    out.print(Integer.toString(i));
                    break;
                case 8:
                    out.print(Long.toString(l));
                    break;
            }
        }
        out.print("\n");
    }
    if (!found) {
        out.print("<address not found in any address space>");
    }
    out.print("\n");
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) ImagePointer(com.ibm.dtfj.image.ImagePointer) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 45 with ImagePointer

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

the class XKCommand method doCommand.

public void doCommand(String[] args) {
    String param = args[0];
    Long address = Utils.longFromStringWithPrefix(param);
    if (null == address) {
        out.println("invalid hex address specified; address must be specified as " + "\"0x<hex_address>\"");
        return;
    }
    ImageAddressSpace ias = ctx.getAddressSpace();
    int pointerSize = getIASPointerSize(ias);
    int unitSize;
    if (pointerSize > 32)
        unitSize = 8;
    else
        unitSize = 4;
    out.print("\n");
    for (int index = 0; index < argUnitNumber; index++) {
        boolean found = false;
        long currAddr = address.longValue() + (index * unitSize);
        ImagePointer ip = ias.getPointer(currAddr);
        out.print("\t");
        out.print(Utils.toHex(currAddr));
        out.print("   ");
        long l = 0;
        try {
            l = ip.getPointerAt(0).getAddress();
            found = true;
        } catch (CorruptDataException e) {
            found = false;
        } catch (MemoryAccessException e) {
            found = false;
        }
        if (found) {
            long pointer = l;
            out.print(toAdjustedHex(l, pointerSize));
            out.print("   ");
            if (31 == pointerSize) {
                pointer = (int) (pointer & (((long) 1) << pointerSize) - 1);
            }
            if (printSymbol(pointer, l - currAddr, pointerSize)) {
            } else if (printStackPointer(pointer, l - currAddr, pointerSize, ias)) {
            }
            out.print("\n");
        } else {
            out.print("<address not found in any address space or exception occurred>\n");
        }
    }
    out.print("\n");
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) ImagePointer(com.ibm.dtfj.image.ImagePointer) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Aggregations

ImagePointer (com.ibm.dtfj.image.ImagePointer)45 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)19 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)12 JavaClass (com.ibm.dtfj.java.JavaClass)9 JCInvalidArgumentsException (com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)8 CorruptData (com.ibm.dtfj.image.j9.CorruptData)7 JavaObject (com.ibm.dtfj.java.JavaObject)7 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)7 Iterator (java.util.Iterator)7 JCJavaClass (com.ibm.dtfj.java.javacore.JCJavaClass)6 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)5 JCJavaObject (com.ibm.dtfj.java.javacore.JCJavaObject)4 ArrayList (java.util.ArrayList)4 Vector (java.util.Vector)4 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)3 ImageSection (com.ibm.dtfj.image.ImageSection)3 JCImageThread (com.ibm.dtfj.image.javacore.JCImageThread)3 JCJavaMonitor (com.ibm.dtfj.java.javacore.JCJavaMonitor)3 IOException (java.io.IOException)3 CorruptData (com.ibm.dtfj.image.CorruptData)2