diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java index 3041cc66ad4..6eb35202b68 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDebugger.java @@ -38,6 +38,8 @@ import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.command.CLICommand; +import org.eclipse.cdt.debug.mi.core.command.MICommand; +import org.eclipse.cdt.debug.mi.core.command.Command; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIGDBSetNewConsole; import org.eclipse.cdt.debug.mi.core.output.MIInfo; @@ -59,6 +61,8 @@ import org.eclipse.debug.core.ILaunchConfiguration; */ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { + private String miVersion; + public ICDISession createSession(ILaunch launch, File executable, IProgressMonitor monitor) throws CoreException { return super.createSession(launch, executable, monitor); @@ -71,7 +75,7 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { protected CommandFactory getCommandFactory(ILaunchConfiguration config) throws CoreException { - String miVersion = MIPlugin.getMIVersion(config); + miVersion = MIPlugin.getMIVersion(config); return new GDBJtagCommandFactory(miVersion); } @@ -333,13 +337,18 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger { for (int j = 0; j < commands.length; ++j) { try { submonitor.subTask(Messages.getString("GDBJtagDebugger.21") + commands[j]); //$NON-NLS-1$ - CLICommand cli = new CLICommand(commands[j]); - miSession.postCommand(cli, MISession.FOREVER); + Command cmd = null; + if (commands[j].startsWith("-")) { + cmd = new MICommand(miVersion, commands[j]); + } else { + cmd = new CLICommand(commands[j]); + } + miSession.postCommand(cmd, MISession.FOREVER); submonitor.worked(1); if (submonitor.isCanceled()) { throw new OperationCanceledException(); } - MIInfo info = cli.getMIInfo(); + MIInfo info = cmd.getMIInfo(); if (info == null) { throw new MIException("Timeout"); //$NON-NLS-1$ } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagConnectionImpl.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagConnectionImpl.java index 76ce10c4b1b..4f2ad44a066 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagConnectionImpl.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagConnectionImpl.java @@ -37,7 +37,12 @@ public class DefaultGDBJtagConnectionImpl extends DefaultGDBJtagDeviceImpl imple public void doRemote(String connection, Collection commands) { String cmd = ""; //$NON-NLS-1$ if (connection != null) { - cmd = "target remote " + connection; //$NON-NLS-1$ + // The CLI version (target remote) does not let us know + // that we have properly connected. For older GDBs (<= 6.8) + // we need this information for a DSF session. + // The MI version does tell us, which is why we must use it + // Bug 348043 + cmd = "-target-select remote " + connection; //$NON-NLS-1$ addCmd(commands, cmd); } } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java index e570df8f394..37407a6f69b 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java @@ -52,7 +52,12 @@ public class DefaultGDBJtagDeviceImpl implements IGDBJtagDevice { * @see org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.IGDBJtagDevice#doRemote(java.lang.String, int, java.util.Collection) */ public void doRemote(String ip, int port, Collection commands) { - String cmd = "target remote " + ip + ":" + String.valueOf(port); //$NON-NLS-1$ //$NON-NLS-2$ + // The CLI version (target remote) does not let us know + // that we have properly connected. For older GDBs (<= 6.8) + // we need this information for a DSF session. + // The MI version does tell us, which is why we must use it + // Bug 348043 + String cmd = "-target-select remote " + ip + ":" + String.valueOf(port); //$NON-NLS-1$ //$NON-NLS-2$ addCmd(commands, cmd); }