Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Setting environment variables in gdb process programattically

I need to set or modify an environment variable in the gdb process as part of the launch processing for my plugin. I was told I needed to do this by updating the build environment since gdb gets it's environment variables from the build environment, not the debug configuration.

I'm trying to do this in the launch method of my launch configuration delegate which extends GdbLaunchDelegate. I am able to update the C/C++ build variables in the project properties, but it seems like the update does not take effect until the next launch of the debug session. I can see the updates by looking in project properties in the first launch, so I'm wondering if I'm doing this too late or if there's more that I need to be doing.

The code that gets me access to the project properties looks like 


        IEnvironmentVariableManager envManager = CCorePlugin.getDefault()
                .getBuildEnvironmentManager();
        IContributedEnvironment env = envManager.getContributedEnvironment();
        ICProjectDescription projectDescription = CoreModel.getDefault()
                .getProjectDescription(project, false);
        IEnvironmentVariable pythonPath = null;
        ICConfigurationDescription configDescription = projectDescription
                .getActiveConfiguration();
        pythonPath= env.getVariable("PYTHONPATH", configDescription);
          // Update pythonPath
        env.addVariable("PYTHONPATH", pythonPath,
                    IEnvironmentVariable.ENVVAR_REPLACE, ":",
                    configDescription);

Once I do this I call super.launch() to launch the debug session

Any suggestions what I might be doing wrong?

Thanks.

Dave





Back to the top