1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 12:55:40 +02:00

change create session for attach to take an

array of string that can serve to connect to
a remote host if need be:
-target-select remotehost 999
This commit is contained in:
Alain Magloire 2002-10-09 13:11:52 +00:00
parent 0926de5ab2
commit f5456b1ad1
2 changed files with 13 additions and 3 deletions

View file

@ -55,7 +55,7 @@ public class GDBDebugger implements ICDebugger {
public ICDISession createAttachSession(ILaunchConfiguration config, IFile exe, int pid) throws CDIException {
try {
String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
CSession session = (CSession)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toOSString(), pid);
CSession session = (CSession)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toOSString(), pid, null);
initializeLibraries(config, session);
return session;
} catch (IOException e) {

View file

@ -11,6 +11,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.CSession;
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.MITargetSelect;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
@ -135,18 +136,27 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
public ICDISession createCSession(String gdb, String program, int pid) throws IOException, MIException {
public ICDISession createCSession(String gdb, String program, int pid, String[] targetParams) throws IOException, MIException {
if (gdb == null || gdb.length() == 0) {
gdb = "gdb";
}
String[] args = new String[] {gdb, "--quiet", "-nw", "-i", "mi1", program};
Process pgdb = ProcessFactory.getFactory().exec(args);
MISession session = createMISession(pgdb, null, MISession.ATTACH);
MIInfo info = null;
try {
CommandFactory factory = session.getCommandFactory();
if (targetParams != null && targetParams.length > 0) {
MITargetSelect target = factory.createMITargetSelect(targetParams);
session.postCommand(target);
info = target.getMIInfo();
if (info == null) {
throw new IOException("No answer");
}
}
MITargetAttach attach = factory.createMITargetAttach(pid);
session.postCommand(attach);
MIInfo info = attach.getMIInfo();
info = attach.getMIInfo();
if (info == null) {
throw new IOException("No answer");
}