Search in sources :

Example 56 with DataUnavailable

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

the class InfoLockCommand method showSystemLocks.

private void showSystemLocks() {
    Vector vMonitorsWithLockedObjects = new Vector();
    JavaRuntime jRuntime = ctx.getRuntime();
    Iterator monitors = jRuntime.getMonitors();
    out.println("\nSystem locks...");
    while (monitors.hasNext()) {
        JavaMonitor jMonitor = (JavaMonitor) monitors.next();
        JavaObject jObject = jMonitor.getObject();
        try {
            String monitorName = jMonitor.getName().trim();
            if (monitorName.equalsIgnoreCase("")) {
                monitorName = "<un-named monitor>";
            }
            out.println("id: 0x" + jMonitor.getID() + " name: " + jMonitor.getName());
            JavaThread owner = jMonitor.getOwner();
            if (null != owner) {
                try {
                    out.println("\towner thread id: " + owner.getImageThread().getID() + " name: " + owner.getName());
                } catch (DataUnavailable e) {
                    out.println("\towner thread id: " + Exceptions.getDataUnavailableString());
                    logger.log(Level.FINE, Exceptions.getDataUnavailableString(), e);
                }
            }
            showWaiters(jMonitor);
        } catch (CorruptDataException cde) {
            out.println("\nwarning, corrupt data encountered during scan for system locks...");
        }
        if (null != jObject) {
            // Remember object monitors (flat or inflated) for later
            vMonitorsWithLockedObjects.add(jMonitor);
        }
    }
    showLockedObjects(vMonitorsWithLockedObjects);
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Vector(java.util.Vector) JavaMonitor(com.ibm.dtfj.java.JavaMonitor)

Example 57 with DataUnavailable

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

the class InfoLockCommand method showLockedObjects.

private void showLockedObjects(Vector vMonitorsWithLockedObjects) {
    out.println("\nObject Locks in use...");
    if (0 == vMonitorsWithLockedObjects.size()) {
        out.println("\t...None.");
        return;
    }
    Iterator lockedObjects = vMonitorsWithLockedObjects.iterator();
    while (lockedObjects.hasNext()) {
        JavaMonitor jMonitor = (JavaMonitor) lockedObjects.next();
        JavaObject jObject = jMonitor.getObject();
        try {
            JavaThread owner = jMonitor.getOwner();
            String className = "<unknown class>";
            JavaClass jClass = jObject.getJavaClass();
            if (null != jClass) {
                className = jClass.getName();
            }
            String jObjectID = Long.toHexString(jObject.getID().getAddress());
            if (null == owner) {
                out.println(className + "@0x" + jObjectID);
            } else {
                String owningThreadID = null;
                try {
                    owningThreadID = owner.getImageThread().getID();
                } catch (DataUnavailable e) {
                    owningThreadID = Exceptions.getDataUnavailableString();
                }
                out.println(className + "@0x" + jObjectID);
                out.println("\towner thread id: " + owningThreadID + " name: " + owner.getName());
            }
            showWaiters(jMonitor);
        } catch (CorruptDataException cde) {
            logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JavaMonitor(com.ibm.dtfj.java.JavaMonitor)

Example 58 with DataUnavailable

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

the class InfoMemoryCommand method printDbgmallocWarning.

private void printDbgmallocWarning(PrintStream out, JavaRuntime runtime) {
    try {
        boolean dbgmalloc = false;
        JavaVMInitArgs args = runtime.getJavaVMInitArgs();
        if (args != null) {
            Iterator<?> opts = args.getOptions();
            while (opts.hasNext()) {
                Object obj = opts.next();
                if (obj instanceof JavaVMOption) {
                    JavaVMOption opt = (JavaVMOption) obj;
                    if (COM_IBM_DBGMALLOC_PROPERTY.equals(opt.getOptionString())) {
                        dbgmalloc = true;
                    }
                }
            }
        }
        if (!dbgmalloc) {
            out.println();
            out.printf("Note: %s was not found in the Java VM init options.\nMemory allocated by some class library components will not have been recorded.\n", COM_IBM_DBGMALLOC_PROPERTY);
        }
    } catch (DataUnavailable du) {
        out.println("Java VM init options information unavailable.");
        logger.log(Level.FINE, Exceptions.getDataUnavailableString(), du);
    } catch (CorruptDataException cde) {
        out.println("Corrupt Data encountered walking Java VM init options");
        logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
    }
}
Also used : JavaVMOption(com.ibm.dtfj.java.JavaVMOption) JavaVMInitArgs(com.ibm.dtfj.java.JavaVMInitArgs) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 59 with DataUnavailable

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

the class InfoMemoryCommand method run.

public void run(String command, String[] args, IContext context, PrintStream out) throws CommandException {
    if (initCommand(command, args, context, out)) {
        // processing already handled by super class
        return;
    }
    JavaRuntime runtime = ctx.getRuntime();
    try {
        Iterator memoryCategories = runtime.getMemoryCategories();
        printAllMemoryCategories(out, memoryCategories);
        printDbgmallocWarning(out, runtime);
    } catch (DataUnavailable du) {
        out.println("Memory categories information unavailable.");
        logger.log(Level.FINE, Exceptions.getDataUnavailableString(), du);
    }
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable)

Example 60 with DataUnavailable

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

the class InfoThreadCommand method printStackFrameInfo.

private void printStackFrameInfo(ImageThread it) {
    Iterator itStackFrame;
    ImageStackFrame isf;
    try {
        itStackFrame = it.getStackFrames();
    } catch (DataUnavailable d) {
        out.print("   native stack frames: " + Exceptions.getDataUnavailableString() + "\n");
        return;
    }
    out.print("   native stack frames:");
    out.print("\n");
    while (itStackFrame.hasNext()) {
        Object o = itStackFrame.next();
        if (o instanceof CorruptData) {
            out.print("    <corrupt stack frame: " + ((CorruptData) o).toString() + ">\n");
            continue;
        }
        isf = (ImageStackFrame) o;
        out.print("    bp: ");
        try {
            out.print(toAdjustedHex(isf.getBasePointer().getAddress()));
        } catch (CorruptDataException e) {
            if (getArtifactType() == ArtifactType.javacore) {
                // javacore does not provide native stack base pointers, show as unavailable, not corrupt
                out.print(Exceptions.getDataUnavailableString());
            } else {
                out.print(Exceptions.getCorruptDataExceptionString());
            }
        }
        out.print(" pc: ");
        try {
            out.print(toAdjustedHex(isf.getProcedureAddress().getAddress()));
        } catch (CorruptDataException e) {
            out.print(Exceptions.getCorruptDataExceptionString());
        }
        out.print(" ");
        try {
            out.print(isf.getProcedureName());
        } catch (CorruptDataException e) {
            out.print(Exceptions.getCorruptDataExceptionString());
        }
        out.print("\n");
    }
}
Also used : Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageStackFrame(com.ibm.dtfj.image.ImageStackFrame)

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