1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

call "info remote-process" to guess state.

This commit is contained in:
Alain Magloire 2003-01-17 18:33:44 +00:00
parent 97d28868c4
commit 6f480d7d32

View file

@ -8,8 +8,8 @@ import java.io.IOException;
import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.mi.core.cdi.CSession; import org.eclipse.cdt.debug.mi.core.cdi.CSession;
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.MIGDBSet;
import org.eclipse.cdt.debug.mi.core.command.MITargetAttach; import org.eclipse.cdt.debug.mi.core.command.MITargetAttach;
import org.eclipse.cdt.debug.mi.core.command.MITargetSelect; import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.cdt.debug.mi.core.output.MIInfo;
@ -113,19 +113,20 @@ public class MIPlugin extends Plugin {
Process pgdb = ProcessFactory.getFactory().exec(args); Process pgdb = ProcessFactory.getFactory().exec(args);
MISession session = createMISession(pgdb, pty, MISession.PROGRAM); MISession session = createMISession(pgdb, pty, MISession.PROGRAM);
// For windows we need to start the inferior in a new console window // Try to detect if we have been attach via "target remote localhost:port"
// to separate the Inferior std{in,out,err} from gdb std{in,out,err} // and set the state to be suspended.
try { try {
CommandFactory factory = session.getCommandFactory(); CLICommand cmd = new CLICommand("info remote-process");
MIGDBSet set = factory.createMIGDBSet(new String[]{"new-console"}); session.postCommand(cmd);
session.postCommand(set); MIInfo info = cmd.getMIInfo();
MIInfo info = set.getMIInfo();
if (info == null) { if (info == null) {
throw new MIException("No answer"); throw new MIException("No answer");
} }
//@@@ We have to manually set the suspended state when we attach
session.getMIInferior().setSuspended();
} catch (MIException e) { } catch (MIException e) {
// We ignore this exception, for example // If an exception is thrown that means ok
// on GNU/Linux the new-console is an error. // we did not attach to any target.
} }
return new CSession(session, false); return new CSession(session, false);
} }