mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Implement RuntimeOptions.
This commit is contained in:
parent
930ddb92fb
commit
9bfdedea05
2 changed files with 72 additions and 1 deletions
|
@ -172,7 +172,7 @@ public class CSession implements ICDISession, ICDISessionObject {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getRuntimeOptions()
|
||||
*/
|
||||
public ICDIRuntimeOptions getRuntimeOptions() {
|
||||
return new RuntimeOptions();
|
||||
return new RuntimeOptions(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,9 +5,17 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIExecArguments;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
|
||||
/**
|
||||
* @author alain
|
||||
|
@ -19,22 +27,85 @@ import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
|
|||
*/
|
||||
public class RuntimeOptions implements ICDIRuntimeOptions {
|
||||
|
||||
CSession session;
|
||||
|
||||
public RuntimeOptions(CSession s) {
|
||||
session = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions#setArguments(String)
|
||||
*/
|
||||
public void setArguments(String args) {
|
||||
if (args == null || args.length() == 0) {
|
||||
return;
|
||||
}
|
||||
MISession mi = session.getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIExecArguments arguments = factory.createMIExecArguments(args);
|
||||
try {
|
||||
mi.postCommand(arguments);
|
||||
MIInfo info = arguments.getMIInfo();
|
||||
if (info == null) {
|
||||
//throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
//throw new CDIException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions#setEnvironment(Properties)
|
||||
*/
|
||||
public void setEnvironment(Properties props) {
|
||||
if (props == null) {
|
||||
return;
|
||||
}
|
||||
MISession mi = session.getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
Iterator iterator = props.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String key = (String)iterator.next();
|
||||
String value = props.getProperty(key);
|
||||
String params[] = null;
|
||||
if (value == null || value.length() == 0) {
|
||||
params = new String[] {"environment", key};
|
||||
} else {
|
||||
String var = key + "=" + value;
|
||||
params = new String[] {"environment", var};
|
||||
}
|
||||
MIGDBSet set = factory.createMIGDBSet(params);
|
||||
try {
|
||||
mi.postCommand(set);
|
||||
MIInfo info = set.getMIInfo();
|
||||
if (info == null) {
|
||||
//throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
//throw new CDIException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions#setWorkingDirectory(String)
|
||||
*/
|
||||
public void setWorkingDirectory(String wd) {
|
||||
if (wd == null || wd.length() == 0) {
|
||||
return;
|
||||
}
|
||||
MISession mi = session.getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIEnvironmentCD cd = factory.createMIEnvironmentCD(wd);
|
||||
try {
|
||||
mi.postCommand(cd);
|
||||
MIInfo info = cd.getMIInfo();
|
||||
if (info == null) {
|
||||
//throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
//throw new CDIException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue