Search in sources :

Example 6 with ICombinedContext

use of com.ibm.jvm.dtfjview.spi.ICombinedContext 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 7 with ICombinedContext

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

the class JdmpviewContextManager method createContext.

/**
 * Create a new context from DTFJ.
 *
 * @param image the DTFJ Image
 * @param major the DTFJ API major number
 * @param minor the DTFJ API minor number
 * @param space DTFJ address space
 * @param proc DTFJ process
 * @param rt DTFJ JavaRuntime
 * @return the newly created context
 */
public ICombinedContext createContext(final Image image, final int major, final int minor, final ImageAddressSpace space, final ImageProcess proc, final JavaRuntime rt) {
    // get existing contexts for this source
    ArrayList<ICombinedContext> existingContexts = contextTracker.get(image.getSource());
    ICombinedContext combinedctx = new CombinedContext(major, minor, image, space, proc, rt, maxContextID);
    combinedctx.refresh();
    maxContextID++;
    if (existingContexts == null) {
        // this is the first context for this source
        existingContexts = new ArrayList<ICombinedContext>();
        contextTracker.put(image.getSource(), existingContexts);
    }
    existingContexts.add(combinedctx);
    hasChanged = true;
    return combinedctx;
}
Also used : ICombinedContext(com.ibm.jvm.dtfjview.spi.ICombinedContext) ICombinedContext(com.ibm.jvm.dtfjview.spi.ICombinedContext)

Aggregations

ICombinedContext (com.ibm.jvm.dtfjview.spi.ICombinedContext)7 CommandException (com.ibm.java.diagnostics.utils.commands.CommandException)2 ArrayList (java.util.ArrayList)2 Session (com.ibm.jvm.dtfjview.Session)1 ISession (com.ibm.jvm.dtfjview.spi.ISession)1 ISessionContextManager (com.ibm.jvm.dtfjview.spi.ISessionContextManager)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 URI (java.net.URI)1