org.eclipse.debug.core.model.IThread Java Examples

The following examples show how to use org.eclipse.debug.core.model.IThread. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: DebuggerTestUtils.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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];
}
 
Example #3
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #4
Source File: PyDebugTargetConsole.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public PyDebugTargetConsole(PydevConsoleCommunication scriptConsoleCommunication, ILaunch launch, IProcess process,
        RemoteDebuggerConsole debugger) {
    super(launch, process, null, debugger, null);

    virtualConsoleThread = new PyThreadConsole(this);
    virtualConsoleThreads = new IThread[] { virtualConsoleThread };
}
 
Example #5
Source File: PyDebugTargetConsole.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@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;
    }
}
 
Example #6
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public IThread[] getThreads() throws DebugException {
  return new IThread[0];
}
 
Example #7
Source File: SCTDebugTarget.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public synchronized IThread[] getThreads() throws DebugException {
	return new IThread[] {};
}
 
Example #8
Source File: ScriptStackFrame.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IThread getThread( )
{
	return thread;
}
 
Example #9
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Contructor
 * 
 * @param launch
 * @param vm
 * @param name
 * @param process
 * @param listenPort
 * @param eventPort
 * @param tempFolder
 */
public ScriptDebugTarget( ILaunch launch, ReportVMClient vm, String name,
		IProcess process, int listenPort, String tempFolder )
{
	super( null );
	this.launch = launch;
	this.reportVM = vm;
	this.name = name;
	this.process = process;

	this.tempFolder = tempFolder;

	this.listenPort = listenPort;

	launch.addDebugTarget( this );
	vm.addVMListener( this );

	setTerminating( false );
	setTerminated( false );
	thread = new ScriptDebugThread( this );
	// There are only one thread
	threads = new IThread[]{
		thread
	};

	DebugPlugin.getDefault( )
			.getBreakpointManager( )
			.addBreakpointListener( this );
	
	DebugPlugin.getDefault().getBreakpointManager().addBreakpointManagerListener(this);

	// connect the server util the ReportLauncher run already
	while ( !isTerminated( ) )
	{
		try
		{
			vm.connect( listenPort );
			break;
		}
		catch ( VMException e )
		{
			try
			{
				Thread.sleep( 100 );
			}
			catch ( InterruptedException e1 )
			{
				//do nothing
			}
			continue;
		}
	}
}
 
Example #10
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IThread[] getThreads( ) throws DebugException
{
	return threads;
}
 
Example #11
Source File: PyStackFrame.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IThread getThread() {
    return thread;
}
 
Example #12
Source File: DebuggerTestWorkbench.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void run() {
    try {
        currentStep = "launchEditorInDebug";
        //make a launch for debugging 
        debuggerTestUtils.launchEditorInDebug();

        //switch to debug perspective, because otherwise, when we hit a breakpoint it'll ask if we want to show it.
        debuggerTestUtils.switchToPerspective("org.eclipse.debug.ui.DebugPerspective");
        PyBreakpointRulerAction createAddBreakPointAction = debuggerTestUtils.createAddBreakPointAction(
                1);
        createAddBreakPointAction.run();

        currentStep = "waitForLaunchAvailable";
        ILaunch launch = debuggerTestUtils.waitForLaunchAvailable();
        PyDebugTarget target = (PyDebugTarget) debuggerTestUtils.waitForDebugTargetAvailable(launch);

        currentStep = "waitForSuspendedThread";
        IThread suspendedThread = debuggerTestUtils.waitForSuspendedThread(target);
        assertTrue(suspendedThread.getName().startsWith("MainThread"));
        IStackFrame topStackFrame = suspendedThread.getTopStackFrame();
        assertTrue("Was not expecting: " + topStackFrame.getName(),
                topStackFrame.getName().indexOf("debug_file.py:2") != 0);
        IVariable[] variables = topStackFrame.getVariables();

        HashSet<String> varNames = new HashSet<String>();
        for (IVariable variable : variables) {
            PyVariable var = (PyVariable) variable;
            varNames.add(var.getName());
        }
        HashSet<String> expected = new HashSet<String>();
        expected.add("Globals");
        expected.add("__doc__");
        expected.add("__file__");
        expected.add("__name__");
        expected.add("mod1");
        assertEquals(expected, varNames);

        assertTrue(target.canTerminate());
        target.terminate();

        finished = true;
    } catch (Throwable e) {
        debuggerTestUtils.failException = e;
    }
}