View | Details | Raw Unified | Return to bug 215416
Collapse All | Expand All

(-)src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java (-18 / +21 lines)
Lines 29-34 Link Here
29
29
30
	Process fGDBProcess;
30
	Process fGDBProcess;
31
	private static final int ONE_SECOND = 1000;
31
	private static final int ONE_SECOND = 1000;
32
	private long commandTimeout;
32
33
33
	public MIProcessAdapter(String[] args, IProgressMonitor monitor) throws IOException {
34
	public MIProcessAdapter(String[] args, IProgressMonitor monitor) throws IOException {
34
		this(args, 0, monitor);
35
		this(args, 0, monitor);
Lines 36-41 Link Here
36
37
37
	public MIProcessAdapter(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
38
	public MIProcessAdapter(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
38
		fGDBProcess = getGDBProcess(args, launchTimeout, monitor);
39
		fGDBProcess = getGDBProcess(args, launchTimeout, monitor);
40
		commandTimeout = MIPlugin.getCommandTimeout();
39
	}
41
	}
40
42
41
	/**
43
	/**
Lines 112-127 Link Here
112
114
113
	public void interrupt(MIInferior inferior) {
115
	public void interrupt(MIInferior inferior) {
114
		if (fGDBProcess instanceof Spawner) {
116
		if (fGDBProcess instanceof Spawner) {
115
			Spawner gdbSpawner = (Spawner) fGDBProcess;
117
			if (inferior.isRunning()) {
116
			gdbSpawner.interrupt();
118
				Spawner gdbSpawner = (Spawner) fGDBProcess;
117
			synchronized (inferior) {
119
				gdbSpawner.interrupt();
118
				// Allow (5 secs) for the interrupt to propagate.
120
				waitForInterrupt(inferior);
119
				for (int i = 0; inferior.isRunning() && i < 5; i++) {
120
					try {
121
						inferior.wait(1000);
122
					} catch (InterruptedException e) {
123
					}
124
				}
125
			}
121
			}
126
			// If we are still running try to drop the sig to the PID
122
			// If we are still running try to drop the sig to the PID
127
			if (inferior.isRunning() && inferior.getInferiorPID() > 0) {
123
			if (inferior.isRunning() && inferior.getInferiorPID() > 0) {
Lines 132-137 Link Here
132
128
133
	}
129
	}
134
130
131
	protected boolean waitForInterrupt(MIInferior inferior) {
132
	    synchronized (inferior) {
133
	    	// Allow MI command timeout for the interrupt to propagate.
134
	    	long maxSec = commandTimeout / ONE_SECOND + 1;
135
	    	for (int i = 0; inferior.isRunning() && i < maxSec; i++) {
136
	    		try {
137
	    			inferior.wait(ONE_SECOND);
138
	    		} catch (InterruptedException e) {
139
	    		}
140
	    	}
141
	    	return inferior.isRunning();
142
	    }
143
    }
144
135
	/**
145
	/**
136
	 * Send an interrupt to the inferior process.
146
	 * Send an interrupt to the inferior process.
137
	 * 
147
	 * 
Lines 141-154 Link Here
141
		if (fGDBProcess instanceof Spawner) {
151
		if (fGDBProcess instanceof Spawner) {
142
			Spawner gdbSpawner = (Spawner) fGDBProcess;
152
			Spawner gdbSpawner = (Spawner) fGDBProcess;
143
			gdbSpawner.raise(inferior.getInferiorPID(), gdbSpawner.INT);
153
			gdbSpawner.raise(inferior.getInferiorPID(), gdbSpawner.INT);
144
			synchronized (inferior) {
154
			waitForInterrupt(inferior);
145
				for (int i = 0; inferior.isRunning() && i < 5; i++) {
146
					try {
147
						inferior.wait(1000);
148
					} catch (InterruptedException e) {
149
					}
150
				}
151
			}
152
		}
155
		}
153
	}
156
	}
154
	
157
	
(-)cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java (-2 / +2 lines)
Lines 36-42 Link Here
36
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
36
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
37
import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint;
37
import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint;
38
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
38
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
39
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
40
import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
39
import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
41
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
40
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
42
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
41
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
Lines 631-638 Link Here
631
		try {
630
		try {
632
			miSession.getMIInferior().interrupt();
631
			miSession.getMIInferior().interrupt();
633
			// Wait till the EventManager tell us the go ahead
632
			// Wait till the EventManager tell us the go ahead
633
			long maxSec = miSession.getCommandTimeout()/1000 + 1;
634
			synchronized (this) {
634
			synchronized (this) {
635
				for (int i = 0; !suspended && i < 6; i++) {
635
				for (int i = 0; !suspended && i < maxSec; i++) {
636
					try {
636
					try {
637
						wait(1000);
637
						wait(1000);
638
					} catch (InterruptedException e) {
638
					} catch (InterruptedException e) {
(-)mi/org/eclipse/cdt/debug/mi/core/MIInferior.java (-2 / +3 lines)
Lines 209-217 Link Here
209
				session.postCommand(interrupt);
209
				session.postCommand(interrupt);
210
				// call getMIInfo() even if we discard the value;
210
				// call getMIInfo() even if we discard the value;
211
				interrupt.getMIInfo();
211
				interrupt.getMIInfo();
212
				// Allow (5 secs) for the interrupt to propagate.
212
				// Allow MI command timeout for the interrupt to propagate.
213
				long maxSec = session.getCommandTimeout()/1000 + 1;
213
				synchronized(this) {
214
				synchronized(this) {
214
					for (int i = 0;(state == RUNNING) && i < 5; i++) {
215
					for (int i = 0;(state == RUNNING) && i < maxSec; i++) {
215
						try {
216
						try {
216
							wait(1000);
217
							wait(1000);
217
						} catch (InterruptedException e) {
218
						} catch (InterruptedException e) {

Return to bug 215416