mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +02:00
set the serial baud
This commit is contained in:
parent
f0f94b3965
commit
a81bc230d8
2 changed files with 35 additions and 6 deletions
|
@ -22,9 +22,14 @@ import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
|
||||||
|
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.MITargetSelect;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
|
||||||
public class GDBServerDebugger implements ICDebugger {
|
public class GDBServerDebugger implements ICDebugger {
|
||||||
|
@ -54,17 +59,40 @@ public class GDBServerDebugger implements ICDebugger {
|
||||||
try {
|
try {
|
||||||
String gdb = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
|
String gdb = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
|
||||||
File cwd = exe.getProject().getLocation().toFile();
|
File cwd = exe.getProject().getLocation().toFile();
|
||||||
String remote;
|
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
|
||||||
|
Session session = null;
|
||||||
if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) {
|
if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) {
|
||||||
remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid");
|
String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid");
|
||||||
remote += ":";
|
remote += ":";
|
||||||
remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid");
|
remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid");
|
||||||
|
String[] args = new String[] {"remote", remote};
|
||||||
|
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit);
|
||||||
} else {
|
} else {
|
||||||
remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid");
|
MIPlugin plugin = MIPlugin.getDefault();
|
||||||
|
Preferences prefs = plugin.getPluginPreferences();
|
||||||
|
int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
|
||||||
|
|
||||||
|
String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid");
|
||||||
|
String remoteBaud = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid");
|
||||||
|
session = (Session)MIPlugin.getDefault().createCSession(gdb, (File)null, cwd, gdbinit);
|
||||||
|
MISession miSession = session.getMISession();
|
||||||
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
|
MIGDBSet setRemoteBaud = factory.createMIGDBSet(new String[]{"remotebaud", remoteBaud});
|
||||||
|
// Set serial line parameters
|
||||||
|
miSession.postCommand(setRemoteBaud, launchTimeout);
|
||||||
|
MIInfo info = setRemoteBaud.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
session.terminate();
|
||||||
|
throw new MIException ("Can not set Baud");
|
||||||
|
}
|
||||||
|
MITargetSelect select = factory.createMITargetSelect(new String[] {"remote", remote});
|
||||||
|
miSession.postCommand(select, launchTimeout);
|
||||||
|
select.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
session.terminate();
|
||||||
|
throw new MIException ("No answer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
|
|
||||||
String[] args = new String[] {"remote", remote};
|
|
||||||
Session session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit);
|
|
||||||
initializeLibraries(config, session);
|
initializeLibraries(config, session);
|
||||||
return session;
|
return session;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -21,4 +21,5 @@ public interface IGDBServerMILaunchConfigurationConstants extends IMILaunchConfi
|
||||||
public static final String ATTR_HOST = MIPlugin.getUniqueIdentifier() + ".HOST"; //$NON-NLS-1$
|
public static final String ATTR_HOST = MIPlugin.getUniqueIdentifier() + ".HOST"; //$NON-NLS-1$
|
||||||
public static final String ATTR_PORT = MIPlugin.getUniqueIdentifier() + ".PORT"; //$NON-NLS-1$
|
public static final String ATTR_PORT = MIPlugin.getUniqueIdentifier() + ".PORT"; //$NON-NLS-1$
|
||||||
public static final String ATTR_DEV = MIPlugin.getUniqueIdentifier() + ".DEV"; //$NON-NLS-1$
|
public static final String ATTR_DEV = MIPlugin.getUniqueIdentifier() + ".DEV"; //$NON-NLS-1$
|
||||||
|
public static final String ATTR_DEV_SPEED = MIPlugin.getUniqueIdentifier() + ".DEV_SPEED"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue