Skip to content

Commit 05778fa

Browse files
committed
Include system environment when debugging core build
When doing a local launch, the only environment passed to the debuggee was the modified variables, typically just PATH. This meant all the other environment was lost. This change does the same thing as all the other calls to setBuildEnvironment and passes in the initial system environment. I added a small note to the API of setBuildEnvironment to try to avoid this error in the future.
1 parent 5135c9f commit 05778fa

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ default IBinary[] getBuildOutput() throws CoreException {
151151
* @param env
152152
* build environment
153153
* @since 6.1
154+
* @implNote Ensure you pass a new non-empty map containing the base environment
155+
* as this method modifies the passed in map adding the ICBuildConfiguration specific
156+
* overrides, such as applying the project's build environment.
154157
*/
155158
default void setBuildEnvironment(Map<String, String> env) {
156159
}

dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory;
3535
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
3636
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
37+
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
3738
import org.eclipse.core.runtime.CoreException;
3839
import org.eclipse.core.runtime.IProgressMonitor;
3940
import org.eclipse.core.runtime.IStatus;
@@ -77,6 +78,11 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
7778
ICBuildConfiguration buildConfig = getBuildConfiguration(configuration, mode, target, monitor);
7879

7980
Map<String, String> buildEnv = new HashMap<>();
81+
Properties environmentVariables = EnvironmentReader.getEnvVars();
82+
for (String key : environmentVariables.stringPropertyNames()) {
83+
String value = environmentVariables.getProperty(key);
84+
buildEnv.put(key, value);
85+
}
8086
buildConfig.setBuildEnvironment(buildEnv);
8187
Properties envProps = new Properties();
8288
envProps.putAll(buildEnv);

0 commit comments

Comments
 (0)