Java 类org.eclipse.debug.core.model.IThread 实例源码

项目:gemoc-studio-modeldebugging    文件:DSLDebugTargetAdapterTests.java   
/**
 * Test {@link DSLDebugTargetAdapter#getThreads()}.
 * 
 * @throws DebugException
 *             if fail
 */
@Test
public void getThreads() throws DebugException {
    DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget();
    eDebugTarget.setName("Debug target");
    final TestEventProcessor testEventProcessor = new TestEventProcessor();
    final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null,
            eDebugTarget, new ModelUpdater(), testEventProcessor);
    final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget();

    createThreads(eDebugTarget);

    final IThread[] threads = debugTarget.getThreads();

    assertEquals(0, testEventProcessor.getEvents().size());
    assertEquals(8, threads.length);
}
项目:ModelDebugging    文件:DSLDebugTargetAdapterTests.java   
/**
 * Test {@link DSLDebugTargetAdapter#getThreads()}.
 * 
 * @throws DebugException
 *             if fail
 */
@Test
public void getThreads() throws DebugException {
    DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget();
    eDebugTarget.setName("Debug target");
    final TestEventProcessor testEventProcessor = new TestEventProcessor();
    final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null,
            eDebugTarget, new ModelUpdater(), testEventProcessor);
    final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget();

    createThreads(eDebugTarget);

    final IThread[] threads = debugTarget.getThreads();

    assertEquals(0, testEventProcessor.getEvents().size());
    assertEquals(8, threads.length);
}
项目:vebugger    文件:VisualDetailPane.java   
/**
 * Render a selected variable.
 * 
 * @param selection
 *            the selection object
 * @param element
 *            the variable element
 * @throws DebugException
 */
private void displayVariable(IStructuredSelection selection, IDebugElement element) throws DebugException {
    IValue value = ((IVariable) element).getValue();

    if (value instanceof IJavaPrimitiveValue) {
        setBrowserTextToPrimitive((IJavaPrimitiveValue) value);
    } else {
        TreePath firstElementTreePath = ((TreeSelection) selection).getPaths()[0];
        String watchExpression = generateWatchExpression(firstElementTreePath);
        String messageExpression = generateMessageExpression(watchExpression);

        // Iterate all threads and run our rendering
        // expression in them in the hopes that we can find
        // the relevant selection in only one thread
        // FIXME find a better way to derive the correct thread!
        IWatchExpressionDelegate delegate = DebugPlugin.getDefault().getExpressionManager()
                .newWatchExpressionDelegate(element.getModelIdentifier());
        for (IThread thread : element.getDebugTarget().getThreads()) {
            delegate.evaluateExpression(messageExpression, thread, this);
        }
    }
}
项目:Pydev    文件:AbstractDebugTarget.java   
@Override
public IThread[] getThreads() throws DebugException {
    if (debugger == null) {
        return null;
    }

    if (threads == null) {
        ThreadListCommand cmd = new ThreadListCommand(this);
        this.postCommand(cmd);
        try {
            cmd.waitUntilDone(1000);
            threads = cmd.getThreads();
        } catch (InterruptedException e) {
            threads = new PyThread[0];
        }
    }
    return threads;
}
项目:Pydev    文件:DebuggerTestUtils.java   
/**
 * Waits until some thread is suspended.
 */
protected IThread waitForSuspendedThread(final PyDebugTarget target) throws Throwable {
    final IThread[] ret = new IThread[1];

    waitForCondition(new ICallback() {

        @Override
        public Object call(Object args) throws Exception {
            IThread[] threads = target.getThreads();
            for (IThread thread : threads) {
                if (thread.isSuspended()) {
                    ret[0] = thread;
                    return true;
                }
            }
            return false;
        }
    }, "waitForSuspendedThread");

    return ret[0];
}
项目:codehint    文件:EclipseUtils.java   
/**
 * Returns the current stack frame context, or <code>null</code> if none.
 * 
 * @return the current stack frame context, or <code>null</code> if none
 */
public static IJavaStackFrame getStackFrame() {
    IAdaptable adaptable = DebugUITools.getDebugContext();
    if (adaptable != null) {
        Object x = adaptable.getAdapter(IJavaStackFrame.class);
        if (x != null)
            return (IJavaStackFrame)x;
    }
    try {
        for (ILaunch launch: DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
            for (IThread thread: launch.getDebugTarget().getThreads()) {
                IStackFrame[] frames = thread.getStackFrames();
                if (frames.length > 0)
                    return (IJavaStackFrame)frames[0];
            }
        }
    } catch (DebugException e) {
        throw new RuntimeException(e);
    }
    return null;
}
项目:gemoc-studio-modeldebugging    文件:DSLEclipseDebugIntegration.java   
/**
 * Initializes {@link DSLEclipseDebugIntegration#SUPPORTED_TYPES}.
 * 
 * @return the {@link Set} of
 *         {@link org.eclipse.emf.common.notify.AdapterFactory#isFactoryForType(Object) supported
 *         types}.
 */
private static Set<Object> initSupportedTypes() {
final Set<Object> res = new HashSet<Object>();

res.add(IThread.class);
res.add(IDebugTarget.class);
res.add(IStackFrame.class);
res.add(IVariable.class);
res.add(IBreakpoint.class);

return res;
}
项目:gemoc-studio-modeldebugging    文件:DSLEclipseDebugIntegration.java   
/**
 * Gets an {@link IThread} form a {@link Thread}.
 * 
 * @param thread
 *            the {@link Thread}
 * @return the {@link IThread}
 */
public DSLThreadAdapter getThread(Thread thread) {
synchronized(thread) {
    final DSLThreadAdapter res = (DSLThreadAdapter)adapt(thread, IThread.class);
    if (res == null) {
    throw new IllegalStateException("can't addapt Thread to IThread.");
    }
    return res;
}
}
项目:gemoc-studio-modeldebugging    文件:DSLDebugTargetAdapter.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
 */
public IThread[] getThreads() throws DebugException {
    final List<IThread> res = new ArrayList<IThread>();

    for (Thread thread : getHost().getThreads()) {
        res.add(factory.getThread(thread));
    }

    return res.toArray(new IThread[res.size()]);
}
项目:pandionj    文件:Activator.java   
static void stepInto(ExecutionEvent event) {
    if(launch != null) {
        try {
            for(IThread t : launch.getDebugTarget().getThreads())
                if(t.canStepInto())
                    t.stepInto();
        } catch (DebugException e) {
            e.printStackTrace();
        }
    }
    //      showView(event);
}
项目:pandionj    文件:Activator.java   
static void stepOver(ExecutionEvent event) {
    if(launch != null) {
        try {
            for(IThread t : launch.getDebugTarget().getThreads())
                if(t.canStepOver())
                    t.stepOver();
        } catch (DebugException e) {
            e.printStackTrace();
        }
    }
    //      showView(event);
}
项目:pandionj    文件:Activator.java   
static void stepReturn(ExecutionEvent event) {
    if(launch != null) {
        try {
            for(IThread t : launch.getDebugTarget().getThreads())
                if(t.canStepReturn())
                    t.stepReturn();
        } catch (DebugException e) {
            e.printStackTrace();
        }
    }
    //      showView(event);
}
项目:cft    文件:ConnectToDebuggerListener.java   
public void handleDebugEvents(DebugEvent[] events) {
    if (events != null) {
        int size = events.length;
        for (int i = 0; i < size; i++) {

            if (events[i].getKind() == DebugEvent.TERMINATE) {

                Object source = events[i].getSource();

                // THe event source should be a thread as remote debugging
                // does not launch a separate local process
                // However, multiple threads may be associated with the
                // debug target, so to check if an app
                // is disconnected from the debugger, additional termination
                // checks need to be performed on the debug target
                // itself
                if (source instanceof IThread) {
                    IDebugTarget debugTarget = ((IThread) source).getDebugTarget();

                    // Be sure to only handle events from the debugger
                    // source that generated the termination event. Do not
                    // handle
                    // any other application that is currently connected to
                    // the debugger.
                    if (eventSource.equals(debugTarget) && debugTarget.isDisconnected()) {

                        DebugPlugin.getDefault().removeDebugEventListener(this);
                        ApplicationDebugLauncher.terminateLaunch(launchId);
                        return;
                    }
                }
            }
        }
    }
}
项目:dockerfoundry    文件:ConnectToDebuggerListener.java   
public void handleDebugEvents(DebugEvent[] events) {
    if (events != null) {
        int size = events.length;
        for (int i = 0; i < size; i++) {

            if (events[i].getKind() == DebugEvent.TERMINATE) {

                Object source = events[i].getSource();

                // THe event source should be a thread as remote debugging
                // does not launch a separate local process
                // However, multiple threads may be associated with the
                // debug target, so to check if an app
                // is disconnected from the debugger, additional termination
                // checks need to be performed on the debug target
                // itself
                if (source instanceof IThread) {
                    IDebugTarget debugTarget = ((IThread) source).getDebugTarget();

                    // Be sure to only handle events from the debugger
                    // source that generated the termination event. Do not
                    // handle
                    // any other application that is currently connected to
                    // the debugger.
                    if (eventSource.equals(debugTarget) && debugTarget.isDisconnected()) {

                        DebugPlugin.getDefault().removeDebugEventListener(this);
                        DebugOperations.terminateLaunch(launchId);
                        return;
                    }
                }
            }
        }
    }
}
项目:chromedevtools    文件:ConnectedTargetData.java   
private void fireEventForThread(int kind, int detail) {
  try {
    IThread[] threads = debugTargetState.getThreads();
    if (threads.length > 0) {
      DebugTargetImpl.fireDebugEvent(new DebugEvent(threads[0], kind, detail));
    }
  } catch (DebugException e) {
    // Actually, this is not thrown in our getThreads()
    return;
  }
}
项目:ModelDebugging    文件:DSLEclipseDebugIntegration.java   
/**
 * Initializes {@link DSLEclipseDebugIntegration#SUPPORTED_TYPES}.
 * 
 * @return the {@link Set} of
 *         {@link org.eclipse.emf.common.notify.AdapterFactory#isFactoryForType(Object) supported
 *         types}.
 */
private static Set<Object> initSupportedTypes() {
final Set<Object> res = new HashSet<Object>();

res.add(IThread.class);
res.add(IDebugTarget.class);
res.add(IStackFrame.class);
res.add(IVariable.class);
res.add(IBreakpoint.class);

return res;
}
项目:ModelDebugging    文件:DSLEclipseDebugIntegration.java   
/**
 * Gets an {@link IThread} form a {@link Thread}.
 * 
 * @param thread
 *            the {@link Thread}
 * @return the {@link IThread}
 */
public DSLThreadAdapter getThread(Thread thread) {
synchronized(thread) {
    final DSLThreadAdapter res = (DSLThreadAdapter)adapt(thread, IThread.class);
    if (res == null) {
    throw new IllegalStateException("can't addapt Thread to IThread.");
    }
    return res;
}
}
项目:ModelDebugging    文件:DSLDebugTargetAdapter.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
 */
public IThread[] getThreads() throws DebugException {
    final List<IThread> res = new ArrayList<IThread>();

    for (Thread thread : getHost().getThreads()) {
        res.add(factory.getThread(thread));
    }

    return res.toArray(new IThread[res.size()]);
}
项目:jive    文件:JiveDebugTarget.java   
protected void createRequests()
{
  for (final IThread thread : this.getThreads())
  {
    if (thread instanceof JiveThread)
    {
      ((JiveThread) thread).createRequests();
    }
  }
  eventHandlerFactory.createRequests();
}
项目:jive    文件:JiveDebugTarget.java   
protected void removeRequests()
{
  for (final IThread thread : this.getThreads())
  {
    if (thread instanceof JiveThread)
    {
      ((JiveThread) thread).removeRequests();
    }
  }
  eventHandlerFactory.removeRequests();
}
项目:jive    文件:SourceLookupFacility.java   
private IStackFrame createStackFrame(final IJiveDebugTarget target, final IJiveEvent event)
{
  try
  {
    final IThread thread = new MockThread(target, event);
    return thread.getTopStackFrame();
  }
  catch (final DebugException e)
  {
    throw new IllegalStateException("This should never occur since a mock object is returned.");
  }
}
项目:jive    文件:SourceLookupFacility.java   
public MockStackFrame(final IJiveDebugTarget target, final IJiveEvent event,
    final IThread thread)
{
  super(target);
  this.event = event;
  this.thread = thread;
}
项目:jive    文件:JiveLaunchNotifier.java   
@Override
public void selectionChanged(final IWorkbenchPart part, final ISelection selection)
{
  // allow views to be selectively enabled/disabled
  if (part instanceof IDebugView && selection instanceof IStructuredSelection)
  {
    Object object = ((IStructuredSelection) selection).getFirstElement();
    if (!selection.isEmpty())
    {
      // Determine if an IJiveDebugTarget is associated with the selection
      if (object instanceof IStackFrame)
      {
        object = ((IStackFrame) object).getThread();
      }
      if (object instanceof IThread)
      {
        object = ((IThread) object).getDebugTarget();
      }
      if (object instanceof IProcess)
      {
        object = ((IProcess) object).getLaunch();
      }
      if (object instanceof ILaunch)
      {
        object = ((ILaunch) object).getDebugTarget();
      }
    }
    // Display the debug target
    if (object instanceof IJiveDebugTarget)
    {
      JiveLaunchManager.INSTANCE.targetSelected((IJiveDebugTarget) object);
    }
  }
}
项目:Pydev    文件:AbstractDebugTarget.java   
/**
 * @return an existing thread with a given id (null if none)
 */
protected PyThread findThreadByID(String thread_id) {
    for (IThread thread : threads) {
        if (thread_id.equals(((PyThread) thread).getId())) {
            return (PyThread) thread;
        }
    }
    return null;
}
项目:Pydev    文件:PyDebugTargetConsole.java   
public PyDebugTargetConsole(PydevConsoleCommunication scriptConsoleCommunication, ILaunch launch, IProcess process,
        RemoteDebuggerConsole debugger) {
    super(launch, process, null, debugger, null);

    virtualConsoleThread = new PyThreadConsole(this);
    virtualConsoleThreads = new IThread[] { virtualConsoleThread };
}
项目:Pydev    文件:PyDebugTargetConsole.java   
@Override
public IThread[] getThreads() throws DebugException {
    if (isTerminated()) {
        return new IThread[0];
    }
    IThread[] realThreads = super.getThreads();
    if (realThreads != null) {
        return ArrayUtils.concatArrays(virtualConsoleThreads, realThreads);
    } else {
        return virtualConsoleThreads;
    }
}
项目:gemoc-studio-modeldebugging    文件:DSLThreadAdapter.java   
@Override
public boolean isAdapterForType(Object type) {
    return super.isAdapterForType(type) || type == IThread.class;
}
项目:gemoc-studio-modeldebugging    文件:DSLDebugModelPresentation.java   
@Override
public void removeAnnotations(IEditorPart editorPart, IThread thread) {
    // nothing to do here
}
项目:dsp4e    文件:DSPStackFrame.java   
@Override
public IThread getThread() {
    return thread;
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
@Override
public IThread[] getThreads() throws DebugException {
  return new IThread[0];
}
项目:statecharts    文件:SCTDebugTarget.java   
public synchronized IThread[] getThreads() throws DebugException {
    return new IThread[] {};
}
项目:monto-eclipse    文件:MontoDebugTarget.java   
@Override
public IThread[] getThreads() throws DebugException {
  return threads.stream().toArray(MontoThread[]::new);
}
项目:monto-eclipse    文件:MontoStackFrame.java   
@Override
public IThread getThread() {
  return thread;
}
项目:brainfuck    文件:BfDebugModelPresentation.java   
@Override
public void removeAnnotations(IEditorPart editorPart, IThread thread) {
}
项目:brainfuck    文件:BfDebugTarget.java   
@Override
public IThread[] getThreads() throws DebugException {
    return new IThread[] {this.thread};
}
项目:brainfuck    文件:BfStackFrame.java   
@Override
public IThread getThread() {
    return this.ownerThread;
}
项目:chromedevtools    文件:ConnectedTargetData.java   
@Override
IThread[] getThreads() throws DebugException {
  return disconnectAspect.isDisconnected()
      ? DebugTargetImpl.EMPTY_THREADS
      : threadArray;
}
项目:chromedevtools    文件:DebugTargetImpl.java   
@Override
public IThread[] getThreads() throws DebugException {
  return currentState.getThreads();
}
项目:chromedevtools    文件:TargetInitializeState.java   
@Override
IThread[] getThreads() throws DebugException {
  return DebugTargetImpl.EMPTY_THREADS;
}
项目:ModelDebugging    文件:DSLThreadAdapter.java   
@Override
public boolean isAdapterForType(Object type) {
    return super.isAdapterForType(type) || type == IThread.class;
}