From 691ae8c7ebab4fdd73866f452903e5adf46f3608 Mon Sep 17 00:00:00 2001 From: Erwin Waterlander Date: Tue, 19 Nov 2024 12:45:16 +0000 Subject: [PATCH] Core Build local debug use launch environment attributes. The Core Build local debug session uses the environment variables from the environment tab that was added in #901. --- .../launching/CoreBuildLocalDebugLaunchDelegate.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java index 24877b3c275..6744d1675ca 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/CoreBuildLocalDebugLaunchDelegate.java @@ -40,6 +40,7 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchManager; import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.launch.ITargetedLaunch; @@ -81,6 +82,14 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun envProps.putAll(buildEnv); gdbLaunch.setInitialEnvironment(envProps); + // Override initial environment by launch configuration attributes. + Map launchEnvironment = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, + new HashMap<>()); + if (!configuration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true)) { + envProps.clear(); + } + envProps.putAll(launchEnvironment); + IToolChain toolChain = buildConfig.getToolChain(); Path gdbPath = toolChain.getCommandPath(Paths.get("gdb")); //$NON-NLS-1$ gdbLaunch.setGDBPath(gdbPath != null ? gdbPath.toString() : "gdb"); //$NON-NLS-1$