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 |
|