Search in sources :

Example 1 with Session

use of com.ibm.jvm.dtfjview.Session in project openj9 by eclipse.

the class CloseCommand 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;
    }
    Object obj = ctx.getProperties().get(SessionProperties.SESSION_PROPERTY);
    if (obj == null) {
        logger.fine("Could not close a new context as the session property has not been set");
        return;
    }
    if (!(obj instanceof Session)) {
        logger.fine("Could not close an existing context as the session type was not recognised [" + obj.getClass().getName() + "]");
        return;
    }
    ISessionContextManager mgr = ((ISession) obj).getContextManager();
    switch(args.length) {
        case // close all contexts
        0:
            out.println("Closing all contexts");
            mgr.removeAllContexts();
            out.println("All contexts have been closed");
            break;
        case // close all images shared with the specified context
        1:
            out.println("Closing all contexts sharing the same Image");
            int id = Integer.valueOf(args[0]);
            ICombinedContext toclose = mgr.getContext(id);
            if (toclose == null) {
                out.println("The specified context id " + args[0] + " was invalid");
                return;
            }
            mgr.removeContexts(toclose.getImage().getSource());
            out.println("Closed all contexts created from " + toclose.getImage().getSource());
            break;
        default:
            out.println("This command takes 0 or 1 parameters. Execute 'close help' for more information");
            return;
    }
}
Also used : ISession(com.ibm.jvm.dtfjview.spi.ISession) ISessionContextManager(com.ibm.jvm.dtfjview.spi.ISessionContextManager) ICombinedContext(com.ibm.jvm.dtfjview.spi.ICombinedContext) ISession(com.ibm.jvm.dtfjview.spi.ISession) Session(com.ibm.jvm.dtfjview.Session)

Example 2 with Session

use of com.ibm.jvm.dtfjview.Session in project openj9 by eclipse.

the class OpenCommand method createCombinedContext.

private void createCombinedContext(final Image loadedImage, final int major, final int minor, final ImageAddressSpace space, final ImageProcess proc, final JavaRuntime rt, String coreFilePath) {
    // take the DTFJ context and attempt to combine it with a DDR interactive one
    Object obj = ctx.getProperties().get(SessionProperties.SESSION_PROPERTY);
    if (obj == null) {
        logger.fine("Could not create a new context as the session property has not been set");
        return;
    }
    if (!(obj instanceof Session)) {
        logger.fine("Could not create a new context as the session type was not recognised [" + obj.getClass().getName() + "]");
        return;
    }
    JdmpviewContextManager mgr = (JdmpviewContextManager) ((ISession) obj).getContextManager();
    CombinedContext cc = (CombinedContext) mgr.createContext(loadedImage, major, minor, space, proc, rt);
    cc.startDDRInteractiveSession(loadedImage, out);
    cc.getProperties().put(CORE_FILE_PATH_PROPERTY, coreFilePath);
    cc.getProperties().put(IMAGE_FACTORY_PROPERTY, getFactory());
    if (ctx.hasPropertyBeenSet(VERBOSE_MODE_PROPERTY)) {
        cc.getProperties().put(VERBOSE_MODE_PROPERTY, "true");
    }
    try {
        // flag to indicate if native libs are required but not present
        boolean hasLibError = true;
        String os = cc.getImage().getSystemType().toLowerCase();
        if (os.contains("linux") || (os.contains("aix"))) {
            if (cc.getProcess() != null) {
                Iterator<?> modules = cc.getProcess().getLibraries();
                if (modules.hasNext()) {
                    obj = modules.next();
                    if (obj instanceof ImageModule) {
                        // there is at least one native lib available
                        hasLibError = false;
                    }
                }
            }
        } else {
            hasLibError = false;
        }
        if (hasLibError) {
            out.println("Warning : native libraries are not available for " + coreFilePath);
        }
    } catch (DataUnavailable e) {
        logger.log(Level.FINE, "Warning : native libraries are not available for " + coreFilePath);
    } catch (Exception e) {
        logger.log(Level.FINE, "Error determining if native libraries are required for " + coreFilePath, e);
    }
}
Also used : JdmpviewContextManager(com.ibm.jvm.dtfjview.JdmpviewContextManager) CombinedContext(com.ibm.jvm.dtfjview.CombinedContext) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) ImageModule(com.ibm.dtfj.image.ImageModule) CommandException(com.ibm.java.diagnostics.utils.commands.CommandException) IOException(java.io.IOException) ISession(com.ibm.jvm.dtfjview.spi.ISession) Session(com.ibm.jvm.dtfjview.Session)

Aggregations

Session (com.ibm.jvm.dtfjview.Session)2 ISession (com.ibm.jvm.dtfjview.spi.ISession)2 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)1 ImageModule (com.ibm.dtfj.image.ImageModule)1 CommandException (com.ibm.java.diagnostics.utils.commands.CommandException)1 CombinedContext (com.ibm.jvm.dtfjview.CombinedContext)1 JdmpviewContextManager (com.ibm.jvm.dtfjview.JdmpviewContextManager)1 ICombinedContext (com.ibm.jvm.dtfjview.spi.ICombinedContext)1 ISessionContextManager (com.ibm.jvm.dtfjview.spi.ISessionContextManager)1 IOException (java.io.IOException)1