mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
new function update() to search for the pid of the inferior.
This commit is contained in:
parent
db78b5ea0e
commit
009549f216
1 changed files with 31 additions and 1 deletions
|
@ -14,8 +14,10 @@ import org.eclipse.cdt.debug.mi.core.command.CLICommand;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIExecAbort;
|
import org.eclipse.cdt.debug.mi.core.command.MIExecAbort;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode;
|
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIInfoProgram;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowExitCodeInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowExitCodeInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfoProgramInfo;
|
||||||
import org.eclipse.cdt.utils.pty.PTY;
|
import org.eclipse.cdt.utils.pty.PTY;
|
||||||
import org.eclipse.cdt.utils.spawner.Spawner;
|
import org.eclipse.cdt.utils.spawner.Spawner;
|
||||||
|
|
||||||
|
@ -43,6 +45,9 @@ public class MIInferior extends Process {
|
||||||
PipedOutputStream errPiped;
|
PipedOutputStream errPiped;
|
||||||
PTY pty;
|
PTY pty;
|
||||||
|
|
||||||
|
int inferiorPid;
|
||||||
|
|
||||||
|
|
||||||
MIInferior(MISession mi, PTY p) {
|
MIInferior(MISession mi, PTY p) {
|
||||||
session = mi;
|
session = mi;
|
||||||
pty = p;
|
pty = p;
|
||||||
|
@ -182,7 +187,17 @@ public class MIInferior extends Process {
|
||||||
// Allow (5 secs) for the interrupt to propagate.
|
// Allow (5 secs) for the interrupt to propagate.
|
||||||
for (int i = 0; isRunning() && i < 5; i++) {
|
for (int i = 0; isRunning() && i < 5; i++) {
|
||||||
try {
|
try {
|
||||||
java.lang.Thread.sleep(2000);
|
java.lang.Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isRunning() && inferiorPid != 0) {
|
||||||
|
// lets try something else.
|
||||||
|
gdbSpawner.raise(inferiorPid, gdbSpawner.INT);
|
||||||
|
}
|
||||||
|
for (int i = 0; isRunning() && i < 5; i++) {
|
||||||
|
try {
|
||||||
|
java.lang.Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,4 +307,19 @@ public class MIInferior extends Process {
|
||||||
public PTY getPTY() {
|
public PTY getPTY() {
|
||||||
return pty;
|
return pty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if (inferiorPid == 0) {
|
||||||
|
// Try to discover the pid
|
||||||
|
CommandFactory factory = session.getCommandFactory();
|
||||||
|
MIInfoProgram prog = factory.createMIInfoProgram();
|
||||||
|
try {
|
||||||
|
session.postCommand(prog);
|
||||||
|
MIInfoProgramInfo info = prog.getMIInfoProgramInfo();
|
||||||
|
inferiorPid = info.getPID();
|
||||||
|
} catch (MIException e) {
|
||||||
|
// no rethrown.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue