From d9141a8a93d29e27e64817973973e25482af002a Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 18 Dec 2003 23:23:03 +0000 Subject: [PATCH] The -gdb-set environment is not describe properly in the doc ... finally discover at it works by looking at the command line, first attempt to rectify --- debug/org.eclipse.cdt.debug.mi.core/ChangeLog | 13 ++++++ .../cdt/debug/mi/core/cdi/RuntimeOptions.java | 9 ++-- .../debug/mi/core/command/CommandFactory.java | 8 ++++ .../mi/core/command/MIGDBSetEnvironment.java | 46 +++++++++++++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIGDBSetEnvironment.java diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 9335ed2b604..50002d89afb 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,16 @@ +2003-12-18 Alain Magloire + Set environment variable value to give the program. + Arguments are VAR VALUE where VAR is variable name and VALUE is value. + VALUES of environment variables are uninterpreted strings. + This does not affect the program until the next "run" command. + + So pass the string raw. + + * src/org/eclipse/cdt/debug/mi/core/command/MIGDBSetEnvironment.java + * src/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java + * src/org/eclipse/cdt/debug/mi/core/CommandFactory.java + + 2003-12-17 Mikhail Khodjaiants Fix for bug 49061: Different values are used as default for the "Load shared library symbols automatically" option. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java index 38419382c57..46250887caa 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java @@ -15,7 +15,7 @@ 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.command.MIGDBSetEnvironment; import org.eclipse.cdt.debug.mi.core.output.MIInfo; /** @@ -64,12 +64,11 @@ public class RuntimeOptions implements ICDIRuntimeOptions { String value = props.getProperty(key); String params[] = null; if (value == null || value.length() == 0) { - params = new String[] {"environment", key}; + params = new String[] {key}; } else { - String var = key + "=" + value; - params = new String[] {"environment", var}; + params = new String[] {key, value}; } - MIGDBSet set = factory.createMIGDBSet(params); + MIGDBSetEnvironment set = factory.createMIGDBSetEnvironment(params); try { mi.postCommand(set); MIInfo info = set.getMIInfo(); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java index 2ef3145589c..5d9b5f330f1 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java @@ -109,6 +109,14 @@ public class CommandFactory { return new MIEnvironmentPWD(); } + /** + * @param params + * @return + */ + public MIGDBSetEnvironment createMIGDBSetEnvironment(String[] params) { + return new MIGDBSetEnvironment(params); + } + public MIExecAbort createMIExecAbort() { return new MIExecAbort(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIGDBSetEnvironment.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIGDBSetEnvironment.java new file mode 100644 index 00000000000..f2612ad4406 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIGDBSetEnvironment.java @@ -0,0 +1,46 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.mi.core.command; + +/** + * + * -gdb-set + * + * Set an internal GDB variable. + * + */ +public class MIGDBSetEnvironment extends MIGDBSet { + + public MIGDBSetEnvironment(String[] paths) { + super(paths); + // Overload the parameter + String[] newPaths = new String[paths.length + 1]; + newPaths[0] = "environment"; + System.arraycopy(paths, 0, newPaths, 1, paths.length); + setParameters(newPaths); + } + + /** + * According to the help.: + * Set environment variable value to give the program. + * Arguments are VAR VALUE where VAR is variable name and VALUE is value. + * VALUES of environment variables are uninterpreted strings. + * This does not affect the program until the next "run" command. + * + * So pass the strings raw without interpretation. + */ + protected String parametersToString() { + StringBuffer buffer = new StringBuffer(); + if (parameters != null) { + for (int i = 0; i < parameters.length; i++) { + buffer.append(' ').append(parameters[i]); + } + } + return buffer.toString().trim(); + } + +}