Search in sources :

Example 11 with CorruptDataException

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

the class InfoThreadCommand method printThreadSummary.

private void printThreadSummary(ImageProcess ip) {
    // Prints a summary list of native thread IDs
    int count = 0;
    Iterator itThread = ip.getThreads();
    while (itThread.hasNext()) {
        Object next = itThread.next();
        if (next instanceof CorruptData)
            continue;
        ImageThread it = (ImageThread) next;
        if (count % 8 == 0) {
            if (0 == count)
                out.print("\n\nNative thread IDs for current process:");
            out.print("\n ");
        }
        try {
            out.print(Utils.padWithSpaces(it.getID(), 8));
        } catch (CorruptDataException e) {
            out.print(Exceptions.getCorruptDataExceptionString());
        }
        count++;
    }
    out.print("\n");
}
Also used : Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) ImageThread(com.ibm.dtfj.image.ImageThread) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 12 with CorruptDataException

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

the class XJCommand method printReferences.

/**
 * Print the references from the given object. Omit the first reference: this is always a reference to the
 * object's class.
 */
public static void printReferences(JavaObject jo, PrintStream out) {
    Iterator<?> references = jo.getReferences();
    if (references.hasNext()) {
        // reference to the class, ignore this one
        references.next();
    }
    if (!references.hasNext()) {
        out.print("\t    references: <none>\n ");
        out.print("\t     ");
    } else {
        out.print("\t    references:\n ");
        out.print("\t     ");
        while (references.hasNext()) {
            Object potential_reference = references.next();
            if (potential_reference instanceof JavaReference) {
                JavaReference reference = (JavaReference) potential_reference;
                try {
                    Object target = reference.getTarget();
                    if (target instanceof JavaObject) {
                        out.print(" 0x" + Long.toHexString(((JavaObject) target).getID().getAddress()));
                    } else if (target instanceof JavaClass) {
                        out.print(" 0x" + Long.toHexString(((JavaClass) target).getID().getAddress()));
                    }
                } catch (DataUnavailable e) {
                // don't print anything
                } catch (CorruptDataException e) {
                    out.print(Exceptions.getCorruptDataExceptionString());
                }
            }
        }
    }
    out.print("\n\n");
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 13 with CorruptDataException

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

the class XXCommand method doCommand.

public void doCommand(String[] args) {
    Long address;
    String param = args[0];
    address = Utils.longFromStringWithPrefix(param);
    if (null == address) {
        out.println("invalid hex address specify; 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(Utils.toFixedWidthHex(b));
                    break;
                case 2:
                    out.print(Utils.toFixedWidthHex(s));
                    break;
                case 4:
                    out.print(Utils.toFixedWidthHex(i));
                    break;
                case 8:
                    out.print(Utils.toFixedWidthHex(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 14 with CorruptDataException

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

the class J9DDRImageProcess method getThreadMap.

private Map<Long, Object> getThreadMap() {
    Map<Long, Object> dtfjThreadMap = null;
    if (cachedThreads != null) {
        dtfjThreadMap = (Map<Long, Object>) cachedThreads.get();
    }
    /* We did not find a cache of threads, build one. */
    if (dtfjThreadMap == null) {
        Collection<? extends IOSThread> threads = null;
        long corruptId = -1;
        try {
            threads = process.getThreads();
        } catch (com.ibm.j9ddr.CorruptDataException e) {
            return Collections.singletonMap(corruptId, (Object) new J9DDRCorruptData(process, e));
        }
        // On Linux, fork/abort system dumping means we only get one thread, with an altered TID. In this case we have logic in
        // getCurrentThread that renames the dump thread. Add this thread in addition to the native thread.
        boolean forkandabort = ((process.getPlatform() == Platform.LINUX) && (threads.size() == 1));
        dtfjThreadMap = new HashMap<Long, Object>();
        if (forkandabort) {
            try {
                J9DDRBaseImageThread currentThread = (J9DDRBaseImageThread) getCurrentThread();
                if (currentThread != null) {
                    dtfjThreadMap.put(currentThread.getThreadId(), currentThread);
                }
            } catch (CorruptDataException e) {
                // A corrupt thread won't have an id but we will still return the corrupt
                // data in the list of all threads.
                dtfjThreadMap.put(corruptId--, new J9DDRCorruptData(process, e.getMessage()));
            } catch (com.ibm.j9ddr.CorruptDataException e) {
                // A corrupt thread won't have an id but we will still return the corrupt
                // data in the list of all threads.
                dtfjThreadMap.put(corruptId--, new J9DDRCorruptData(process, e.getMessage()));
            }
        }
        for (IOSThread thread : threads) {
            try {
                dtfjThreadMap.put(thread.getThreadId(), new J9DDRImageThread(process, thread));
            } catch (com.ibm.j9ddr.CorruptDataException e) {
                // In the unlikely event that we can't get the thread id, store the thread
                // without the id.
                dtfjThreadMap.put(corruptId--, new J9DDRImageThread(process, thread));
            }
        }
        cachedThreads = new WeakReference<Map<Long, Object>>(dtfjThreadMap);
    }
    return dtfjThreadMap;
}
Also used : DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) IOSThread(com.ibm.j9ddr.corereaders.osthread.IOSThread) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with CorruptDataException

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

the class DTFJJavaObject method arraycopy.

public void arraycopy(int srcStart, Object dst, int dstStart, int length) throws CorruptDataException, MemoryAccessException {
    fetchDeferredData();
    if (!objectIsArray) {
        throw new IllegalArgumentException("Object is not an array");
    }
    J9IndexableObjectPointer array = J9IndexableObjectPointer.cast(object);
    try {
        validateArrayCopyParameters(array, srcStart, dst, dstStart, length);
        // CMVC 171150 : use helper object to correctly get the class name
        String className = J9IndexableObjectHelper.getClassName(array);
        if ((null == className) || (className.length() < 2)) {
            J9DDRCorruptData cd = new J9DDRCorruptData(DTFJContext.getProcess(), "The class name for this object could not be determined", object.getAddress());
            throw new CorruptDataException(cd);
        }
        if (className.charAt(1) == 'L' || className.charAt(1) == '[') {
            // JExtract/DTFJ can cope with dst of either Object[] or JavaObject[] - but we need to detect other things
            if (!dst.getClass().equals(Object[].class) && !(dst instanceof JavaObject[])) {
                throw new IllegalArgumentException("Type of dst object (" + dst.getClass().getName() + ") incompatible with Object array. Should be JavaObject[] or Object[]");
            }
            J9ObjectPointer[] intermediateArray = new J9ObjectPointer[length];
            Object[] castedDst = (Object[]) dst;
            if (dstStart + (long) length > castedDst.length) {
                throw new ArrayIndexOutOfBoundsException("Supplied destination array too small. Requires: " + (dstStart + (long) length) + ", was " + castedDst.length);
            }
            J9IndexableObjectHelper.getData(array, intermediateArray, srcStart, length, 0);
            for (int i = 0; i < length; i++) {
                if (intermediateArray[i].isNull()) {
                    castedDst[dstStart + i] = null;
                } else {
                    castedDst[dstStart + i] = new DTFJJavaObject(intermediateArray[i]);
                }
            }
        } else {
            // For primitives we can pass through the client object. The type verification will be done in J9IndexableObjectPointer
            J9IndexableObjectHelper.getData(array, dst, srcStart, length, dstStart);
        }
    } catch (Throwable t) {
        throw J9DDRDTFJUtils.handleAllButMemAccExAsCorruptDataException(DTFJContext.getProcess(), t, whitelist);
    }
}
Also used : J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) J9IndexableObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9IndexableObjectPointer) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject)

Aggregations

CorruptDataException (com.ibm.dtfj.image.CorruptDataException)124 JavaObject (com.ibm.dtfj.java.JavaObject)55 Iterator (java.util.Iterator)49 JavaClass (com.ibm.dtfj.java.JavaClass)41 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)39 CorruptData (com.ibm.dtfj.image.CorruptData)26 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)25 ImagePointer (com.ibm.dtfj.image.ImagePointer)19 CorruptData (com.ibm.dtfj.image.j9.CorruptData)17 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)14 ImageSection (com.ibm.dtfj.image.ImageSection)12 ImageThread (com.ibm.dtfj.image.ImageThread)12 JavaThread (com.ibm.dtfj.java.JavaThread)12 ArrayList (java.util.ArrayList)11 ImageProcess (com.ibm.dtfj.image.ImageProcess)9 JavaField (com.ibm.dtfj.java.JavaField)8 JavaReference (com.ibm.dtfj.java.JavaReference)8 LinkedList (java.util.LinkedList)8 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)7 JavaMethod (com.ibm.dtfj.java.JavaMethod)7