bug 396527: [debugger] Unable to debug with local interpreter on OSX
diff --git a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineConfigurer.java b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineConfigurer.java
index 290af6b..16279d1 100644
--- a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineConfigurer.java
+++ b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineConfigurer.java
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
+import org.eclipse.dltk.launching.IInterpreterInstall;
import org.eclipse.dltk.launching.InterpreterConfig;
import org.eclipse.dltk.launching.debug.DbgpConnectionConfig;
import org.eclipse.koneki.ldt.debug.core.internal.Activator;
@@ -33,11 +34,12 @@
private InterpreterConfig initialConfig;
@Override
- public InterpreterConfig alterConfig(ILaunch launch, InterpreterConfig config) throws CoreException {
+ public InterpreterConfig alterConfig(final ILaunch launch, final InterpreterConfig config, final IInterpreterInstall interpreterinstall)
+ throws CoreException {
// In debug engine the config must not be alter, surely because it is used as key to retreive the DBGPConnectionConfig.
initialConfig = config;
InterpreterConfig interpreterConfig = (InterpreterConfig) config.clone();
- return super.alterConfig(launch, interpreterConfig);
+ return super.alterConfig(launch, interpreterConfig, interpreterinstall);
}
protected List<IPath> getLuaPath(ILaunch launch, InterpreterConfig config) throws CoreException {
diff --git a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineRunner.java b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineRunner.java
index 8f34810..aa15e30 100644
--- a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineRunner.java
+++ b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericDebuggingEngineRunner.java
@@ -32,7 +32,7 @@
@Override
protected InterpreterConfig addEngineConfig(InterpreterConfig config, PreferencesLookupDelegate delegate, ILaunch launch) throws CoreException {
LuaGenericDebuggingEngineConfigurer luaGenericDebuggingEngineConfigurer = new LuaGenericDebuggingEngineConfigurer();
- InterpreterConfig alteredConfig = luaGenericDebuggingEngineConfigurer.alterConfig(launch, config);
+ InterpreterConfig alteredConfig = luaGenericDebuggingEngineConfigurer.alterConfig(launch, config, getInstall());
return alteredConfig;
}
@@ -69,4 +69,15 @@
LuaGenericInterpreterCommandLineRenderer commandLineRenderer = new LuaGenericInterpreterCommandLineRenderer();
return commandLineRenderer.renderCommandLine(config, getInstall());
}
+
+ // TODO HACK ENV_VAR : make environment variable defined at interpreter
+ // level less priority
+ // ****************************************************************************
+ @Override
+ protected String[] getEnvironmentVariablesAsStrings(InterpreterConfig config) {
+ return config.getEnvironmentAsStrings();
+ }
+ // END HACK
+ // ****************************************************************************
+
}
diff --git a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterConfigurer.java b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterConfigurer.java
index 9754376..4dff1ef 100644
--- a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterConfigurer.java
+++ b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterConfigurer.java
@@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -22,7 +23,10 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.launching.EnvironmentVariable;
+import org.eclipse.dltk.launching.IInterpreterInstall;
import org.eclipse.dltk.launching.InterpreterConfig;
import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
import org.eclipse.koneki.ldt.core.IProjectSourceRootFolderVisitor;
@@ -35,7 +39,25 @@
private static final String LUA_INIT_PATTERN = LuaDebugConstants.WILDCARD_PATTERN + File.separator + LuaDebugConstants.LUA_INIT_PATTERN;
private static final String LUAC_INIT_PATTERN = LuaDebugConstants.WILDCARD_PATTERN + File.separator + LuaDebugConstants.LUAC_INIT_PATTERN;
- public InterpreterConfig alterConfig(final ILaunch launch, final InterpreterConfig config) throws CoreException {
+ public InterpreterConfig alterConfig(final ILaunch launch, final InterpreterConfig config, final IInterpreterInstall interpreterinstall)
+ throws CoreException {
+
+ // TODO HACK ENV_VAR : make environment variable defined at interpreter level less priority
+ // ****************************************************************************
+ // get launch conf env var
+ @SuppressWarnings("unchecked")
+ final Map<String, String> configEnvs = launch.getLaunchConfiguration().getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,
+ (Map<?, ?>) null);
+ EnvironmentVariable[] interEnvs = interpreterinstall.getEnvironmentVariables();
+ // add var defined at interpreter level only if it was not defined at launch conf level
+ if (interEnvs != null) {
+ for (EnvironmentVariable envVar : interEnvs) {
+ if (configEnvs == null || !configEnvs.containsKey(envVar.getName()))
+ config.addEnvVar(envVar.getName(), envVar.getValue());
+ }
+ }
+ // END HACK
+ // ****************************************************************************
// Append project path to $LUA_PATH
final String envLuaPath = config.getEnvVar(LuaDebugConstants.LUA_PATH);
diff --git a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterRunner.java b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterRunner.java
index f5b2f4f..6b7bfc4 100644
--- a/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterRunner.java
+++ b/plugins/org.eclipse.koneki.ldt.debug.core/src/org/eclipse/koneki/ldt/debug/core/internal/interpreter/generic/LuaGenericInterpreterRunner.java
@@ -28,7 +28,7 @@
LuaGenericInterpreterConfigurer luaGenericInterpreterConfigurer = new LuaGenericInterpreterConfigurer();
try {
- luaGenericInterpreterConfigurer.alterConfig(launch, config);
+ luaGenericInterpreterConfigurer.alterConfig(launch, config, getInstall());
} catch (CoreException e) {
// TODO we should be able to raise a core exception here (We should open a DLTK bug ?)
Activator.log(e.getStatus());
@@ -40,4 +40,15 @@
LuaGenericInterpreterCommandLineRenderer commandLineRenderer = new LuaGenericInterpreterCommandLineRenderer();
return commandLineRenderer.renderCommandLine(config, getInstall());
}
+
+ // TODO HACK ENV_VAR : make environment variable defined at interpreter
+ // level less priority
+ // ****************************************************************************
+ @Override
+ protected String[] getEnvironmentVariablesAsStrings(InterpreterConfig config) {
+ return config.getEnvironmentAsStrings();
+ }
+ // END HACK
+ // ****************************************************************************
+
}
diff --git a/plugins/org.eclipse.koneki.ldt.support.lua51/src/org/eclipse/koneki/ldt/support/lua51/internal/interpreter/JNLua51DebuggingEngineRunner.java b/plugins/org.eclipse.koneki.ldt.support.lua51/src/org/eclipse/koneki/ldt/support/lua51/internal/interpreter/JNLua51DebuggingEngineRunner.java
index 8ad226d..2bf8285 100644
--- a/plugins/org.eclipse.koneki.ldt.support.lua51/src/org/eclipse/koneki/ldt/support/lua51/internal/interpreter/JNLua51DebuggingEngineRunner.java
+++ b/plugins/org.eclipse.koneki.ldt.support.lua51/src/org/eclipse/koneki/ldt/support/lua51/internal/interpreter/JNLua51DebuggingEngineRunner.java
@@ -32,7 +32,7 @@
@Override
protected InterpreterConfig addEngineConfig(InterpreterConfig config, PreferencesLookupDelegate delegate, ILaunch launch) throws CoreException {
JNLua51DebuggingEngineConfigurer configurer = new JNLua51DebuggingEngineConfigurer();
- InterpreterConfig alteredConfig = configurer.alterConfig(launch, config);
+ InterpreterConfig alteredConfig = configurer.alterConfig(launch, config, getInstall());
return alteredConfig;
}
}