Search in sources :

Example 21 with DataUnavailable

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

the class InfoThreadCommand method printThreadBlocker.

private void printThreadBlocker(JavaThread jt) {
    try {
        if ((jt.getState() & JavaThread.STATE_PARKED) != 0) {
            out.print("      parked on: ");
            // java.util.concurrent locks
            if (jt.getBlockingObject() == null) {
                out.print("<unknown>");
            } else {
                JavaObject jo = jt.getBlockingObject();
                String lockID = Long.toHexString(jo.getID().getAddress());
                out.print(jo.getJavaClass().getName() + "@0x" + lockID);
                String ownerThreadName = "<unknown>";
                String ownerThreadID = "<null>";
                out.print(" owner name: ");
                JavaThread lockOwnerThread = Utils.getParkBlockerOwner(jo, ctx.getRuntime());
                if (lockOwnerThread != null) {
                    ownerThreadName = lockOwnerThread.getName();
                    if (lockOwnerThread.getImageThread() != null) {
                        ownerThreadID = lockOwnerThread.getImageThread().getID();
                    }
                } else {
                    // If the owning thread has ended we won't find the JavaThread
                    // We can still get the owning thread name from the java.lang.Thread object itself.
                    // We won't get a thread id.
                    JavaObject lockOwnerObj = Utils.getParkBlockerOwnerObject(jo, ctx.getRuntime());
                    if (lockOwnerObj != null) {
                        ownerThreadName = Utils.getThreadNameFromObject(lockOwnerObj, ctx.getRuntime(), out);
                    }
                }
                out.print("\"" + ownerThreadName + "\"");
                out.print(" owner id: " + ownerThreadID);
            }
            out.print("\n");
        } else if ((jt.getState() & JavaThread.STATE_IN_OBJECT_WAIT) != 0) {
            out.print("      waiting to be notified on: ");
        } else if ((jt.getState() & JavaThread.STATE_BLOCKED_ON_MONITOR_ENTER) != 0) {
            out.print("      waiting to enter: ");
        }
        if ((jt.getState() & JavaThread.STATE_IN_OBJECT_WAIT) != 0 || (jt.getState() & JavaThread.STATE_BLOCKED_ON_MONITOR_ENTER) != 0) {
            // java monitors
            MonitorState ms = (MonitorState) monitors.get(jt);
            if (ms == null) {
                out.println("<monitor information not available>");
            } else {
                JavaObject jo = ms.getMonitor().getObject();
                if (null == jo) {
                    // working with a raw monitor
                    String name = ms.getMonitor().getName();
                    if (name.equals("")) {
                        name = "<unnamed>";
                    }
                    out.print("\"" + name + "\"");
                    out.print(" with ID ");
                    out.print(Utils.toHex(ms.getMonitor().getID().getAddress()));
                } else {
                    // working with a Java monitor
                    String lockID = Long.toHexString(jo.getID().getAddress());
                    out.print(jo.getJavaClass().getName() + "@0x" + lockID);
                }
                out.print(" owner name: ");
                if (ms.getMonitor().getOwner() != null) {
                    out.print("\"" + ms.getMonitor().getOwner().getName() + "\"");
                    if (ms.getMonitor().getOwner().getImageThread() != null) {
                        out.print(" owner id: " + ms.getMonitor().getOwner().getImageThread().getID());
                    }
                } else {
                    out.print("<unowned>");
                }
                out.print("\n");
            }
        }
    } catch (CorruptDataException cde) {
        out.print(Exceptions.getCorruptDataExceptionString());
        logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), cde);
    } catch (DataUnavailable e) {
        out.print(Exceptions.getDataUnavailableString());
        logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), e);
    } catch (MemoryAccessException e) {
        out.print(Exceptions.getMemoryAccessExceptionString());
        logger.log(Level.FINEST, Exceptions.getMemoryAccessExceptionString(), e);
    }
}
Also used : MonitorState(com.ibm.jvm.dtfjview.commands.helpers.MonitorState) JavaObject(com.ibm.dtfj.java.JavaObject) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) StateToString(com.ibm.jvm.dtfjview.commands.helpers.StateToString) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 22 with DataUnavailable

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

the class InfoProcCommand method printJITOptions.

private void printJITOptions() {
    try {
        if (ctx.getRuntime().isJITEnabled()) {
            out.println("\t JIT was enabled for this runtime");
            Properties props = ctx.getRuntime().getJITProperties();
            StringBuilder options = new StringBuilder("\t ");
            for (Object key : props.keySet()) {
                options.append(" " + key + " " + props.get(key) + ",");
            }
            out.println(options.substring(0, options.length() - 1));
        } else {
            out.println("\t JIT was disabled for this runtime");
        }
    } catch (CorruptDataException e) {
        out.println("\t JIT options\n");
    } catch (DataUnavailable e) {
        out.println("\t JIT options not supported by this implementation of DTFJ");
    }
}
Also used : DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Properties(java.util.Properties)

Example 23 with DataUnavailable

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

the class InfoProcCommand method printEnvironmentVariables.

private void printEnvironmentVariables() {
    ImageProcess ip = ctx.getProcess();
    out.print("\t Environment variables:");
    out.print("\n");
    Properties variables;
    try {
        variables = ip.getEnvironment();
    } catch (CorruptDataException e) {
        out.print("\t  " + Exceptions.getCorruptDataExceptionString() + "\n");
        return;
    } catch (DataUnavailable e) {
        out.print("\t  " + Exceptions.getDataUnavailableString() + "\n");
        return;
    }
    Enumeration<?> keys = variables.propertyNames();
    while (keys.hasMoreElements()) {
        String key = (String) keys.nextElement();
        printVariableInfo(key, variables.getProperty(key));
    }
}
Also used : ImageProcess(com.ibm.dtfj.image.ImageProcess) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Properties(java.util.Properties)

Example 24 with DataUnavailable

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

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

the class InfoLockCommand method showWaiters.

private void showWaiters(JavaMonitor jMonitor) throws CorruptDataException {
    // List any threads waiting on enter or notify for this monitor
    Iterator itEnterWaiter = jMonitor.getEnterWaiters();
    while (itEnterWaiter.hasNext()) {
        Object t = itEnterWaiter.next();
        if (!(t instanceof JavaThread)) {
            continue;
        }
        JavaThread jThread = (JavaThread) t;
        try {
            out.println("\twaiting thread id: " + jThread.getImageThread().getID() + " name: " + jThread.getName());
        } catch (DataUnavailable dae) {
            out.println("\twaiting thread id: <unknown>");
            logger.log(Level.FINE, Exceptions.getDataUnavailableString(), dae);
        }
    }
    Iterator itNotifyWaiter = jMonitor.getNotifyWaiters();
    while (itNotifyWaiter.hasNext()) {
        Object t = itNotifyWaiter.next();
        if (!(t instanceof JavaThread)) {
            continue;
        }
        JavaThread jThread = (JavaThread) t;
        try {
            out.println("\twaiting thread id: " + jThread.getImageThread().getID() + " name: " + jThread.getName());
        } catch (DataUnavailable dae) {
            out.println("\twaiting thread id: <unknown>");
            logger.log(Level.FINE, Exceptions.getDataUnavailableString(), dae);
        }
    }
}
Also used : Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject)

Aggregations

DataUnavailable (com.ibm.dtfj.image.DataUnavailable)62 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)39 Iterator (java.util.Iterator)25 JavaObject (com.ibm.dtfj.java.JavaObject)20 CorruptData (com.ibm.dtfj.image.CorruptData)15 Properties (java.util.Properties)13 JavaClass (com.ibm.dtfj.java.JavaClass)9 JavaThread (com.ibm.dtfj.java.JavaThread)9 ImageProcess (com.ibm.dtfj.image.ImageProcess)8 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)8 ImageThread (com.ibm.dtfj.image.ImageThread)7 ImageModule (com.ibm.dtfj.image.ImageModule)6 JavaReference (com.ibm.dtfj.java.JavaReference)6 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)5 ImageSection (com.ibm.dtfj.image.ImageSection)4 DTFJCorruptDataException (com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException)4 ImagePointer (com.ibm.dtfj.image.ImagePointer)3 JavaMethod (com.ibm.dtfj.java.JavaMethod)3 JavaMonitor (com.ibm.dtfj.java.JavaMonitor)3 StateToString (com.ibm.jvm.dtfjview.commands.helpers.StateToString)3