forked from OSchip/llvm-project
Revert "[lldb-vscode] Add inheritEnvironment option"
This reverts commit 4ec6ebabfc
.
This commit is contained in:
parent
34c0759f84
commit
c85bf7cfa8
|
@ -267,7 +267,7 @@ class VSCodeTestCaseBase(TestBase):
|
||||||
disableSTDIO=False, shellExpandArguments=False,
|
disableSTDIO=False, shellExpandArguments=False,
|
||||||
trace=False, initCommands=None, preRunCommands=None,
|
trace=False, initCommands=None, preRunCommands=None,
|
||||||
stopCommands=None, exitCommands=None,sourcePath= None,
|
stopCommands=None, exitCommands=None,sourcePath= None,
|
||||||
debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
|
debuggerRoot=None, launchCommands=None):
|
||||||
'''Sending launch request to vscode
|
'''Sending launch request to vscode
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -298,8 +298,7 @@ class VSCodeTestCaseBase(TestBase):
|
||||||
exitCommands=exitCommands,
|
exitCommands=exitCommands,
|
||||||
sourcePath=sourcePath,
|
sourcePath=sourcePath,
|
||||||
debuggerRoot=debuggerRoot,
|
debuggerRoot=debuggerRoot,
|
||||||
launchCommands=launchCommands,
|
launchCommands=launchCommands)
|
||||||
inheritEnvironment=inheritEnvironment)
|
|
||||||
if not (response and response['success']):
|
if not (response and response['success']):
|
||||||
self.assertTrue(response['success'],
|
self.assertTrue(response['success'],
|
||||||
'launch failed (%s)' % (response['message']))
|
'launch failed (%s)' % (response['message']))
|
||||||
|
@ -309,7 +308,7 @@ class VSCodeTestCaseBase(TestBase):
|
||||||
disableSTDIO=False, shellExpandArguments=False,
|
disableSTDIO=False, shellExpandArguments=False,
|
||||||
trace=False, initCommands=None, preRunCommands=None,
|
trace=False, initCommands=None, preRunCommands=None,
|
||||||
stopCommands=None, exitCommands=None,
|
stopCommands=None, exitCommands=None,
|
||||||
sourcePath=None, debuggerRoot=None, inheritEnvironment=False):
|
sourcePath=None, debuggerRoot=None):
|
||||||
'''Build the default Makefile target, create the VSCode debug adaptor,
|
'''Build the default Makefile target, create the VSCode debug adaptor,
|
||||||
and launch the process.
|
and launch the process.
|
||||||
'''
|
'''
|
||||||
|
@ -319,4 +318,4 @@ class VSCodeTestCaseBase(TestBase):
|
||||||
self.launch(program, args, cwd, env, stopOnEntry, disableASLR,
|
self.launch(program, args, cwd, env, stopOnEntry, disableASLR,
|
||||||
disableSTDIO, shellExpandArguments, trace,
|
disableSTDIO, shellExpandArguments, trace,
|
||||||
initCommands, preRunCommands, stopCommands, exitCommands,
|
initCommands, preRunCommands, stopCommands, exitCommands,
|
||||||
sourcePath, debuggerRoot, inheritEnvironment=inheritEnvironment)
|
sourcePath, debuggerRoot)
|
||||||
|
|
|
@ -570,7 +570,7 @@ class DebugCommunication(object):
|
||||||
disableSTDIO=False, shellExpandArguments=False,
|
disableSTDIO=False, shellExpandArguments=False,
|
||||||
trace=False, initCommands=None, preRunCommands=None,
|
trace=False, initCommands=None, preRunCommands=None,
|
||||||
stopCommands=None, exitCommands=None, sourcePath=None,
|
stopCommands=None, exitCommands=None, sourcePath=None,
|
||||||
debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
|
debuggerRoot=None, launchCommands=None):
|
||||||
args_dict = {
|
args_dict = {
|
||||||
'program': program
|
'program': program
|
||||||
}
|
}
|
||||||
|
@ -605,8 +605,6 @@ class DebugCommunication(object):
|
||||||
args_dict['debuggerRoot'] = debuggerRoot
|
args_dict['debuggerRoot'] = debuggerRoot
|
||||||
if launchCommands:
|
if launchCommands:
|
||||||
args_dict['launchCommands'] = launchCommands
|
args_dict['launchCommands'] = launchCommands
|
||||||
if inheritEnvironment:
|
|
||||||
args_dict['inheritEnvironment'] = inheritEnvironment
|
|
||||||
command_dict = {
|
command_dict = {
|
||||||
'command': 'launch',
|
'command': 'launch',
|
||||||
'type': 'request',
|
'type': 'request',
|
||||||
|
@ -914,8 +912,7 @@ def run_vscode(dbg, args, options):
|
||||||
initCommands=options.initCmds,
|
initCommands=options.initCmds,
|
||||||
preRunCommands=options.preRunCmds,
|
preRunCommands=options.preRunCmds,
|
||||||
stopCommands=options.stopCmds,
|
stopCommands=options.stopCmds,
|
||||||
exitCommands=options.exitCmds,
|
exitCommands=options.exitCmds)
|
||||||
inheritEnvironment=options.inheritEnvironment)
|
|
||||||
|
|
||||||
if response['success']:
|
if response['success']:
|
||||||
if options.sourceBreakpoints:
|
if options.sourceBreakpoints:
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
CXX_SOURCES := main.cpp
|
|
||||||
|
|
||||||
include Makefile.rules
|
|
|
@ -1,107 +0,0 @@
|
||||||
"""
|
|
||||||
Test lldb-vscode environment variables
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
import lldbvscode_testcase
|
|
||||||
import unittest2
|
|
||||||
import vscode
|
|
||||||
import os
|
|
||||||
from lldbsuite.test import lldbutil
|
|
||||||
from lldbsuite.test.decorators import *
|
|
||||||
from lldbsuite.test.lldbtest import *
|
|
||||||
|
|
||||||
class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
|
|
||||||
|
|
||||||
mydir = TestBase.compute_mydir(__file__)
|
|
||||||
|
|
||||||
def getEnvOutputByProgram(self):
|
|
||||||
env = {}
|
|
||||||
for line in self.get_stdout().encode('utf-8').splitlines():
|
|
||||||
(name, value) = line.split("=")
|
|
||||||
env[name] = value
|
|
||||||
return env
|
|
||||||
|
|
||||||
@skipIfWindows
|
|
||||||
@skipIfRemote
|
|
||||||
def test_empty_environment(self):
|
|
||||||
"""
|
|
||||||
Tests running a process with an empty environment
|
|
||||||
"""
|
|
||||||
program = self.getBuildArtifact("a.out")
|
|
||||||
self.build_and_launch(program)
|
|
||||||
self.continue_to_exit()
|
|
||||||
env = self.getEnvOutputByProgram()
|
|
||||||
|
|
||||||
self.assertNotIn("PATH", env)
|
|
||||||
|
|
||||||
@skipIfWindows
|
|
||||||
@skipIfRemote
|
|
||||||
def test_inheriting_environment(self):
|
|
||||||
"""
|
|
||||||
Tests running a process inheriting the environment
|
|
||||||
"""
|
|
||||||
program = self.getBuildArtifact("a.out")
|
|
||||||
self.build_and_launch(program, inheritEnvironment=True, env=["FOO=bar"])
|
|
||||||
self.continue_to_exit()
|
|
||||||
env = self.getEnvOutputByProgram()
|
|
||||||
|
|
||||||
self.assertEqual(env["PATH"], os.environ['PATH'])
|
|
||||||
self.assertEqual(env["FOO"], "bar")
|
|
||||||
|
|
||||||
@skipIfWindows
|
|
||||||
@skipIfRemote
|
|
||||||
def test_override_when_inheriting_environment(self):
|
|
||||||
"""
|
|
||||||
Tests the environment variables priority.
|
|
||||||
The launch.json's environment has precedence.
|
|
||||||
"""
|
|
||||||
program = self.getBuildArtifact("a.out")
|
|
||||||
new_path_value = "#" + os.environ["PATH"]
|
|
||||||
|
|
||||||
self.build_and_launch(
|
|
||||||
program,
|
|
||||||
inheritEnvironment=True,
|
|
||||||
env=["PATH=" + new_path_value])
|
|
||||||
self.continue_to_exit()
|
|
||||||
env = self.getEnvOutputByProgram()
|
|
||||||
|
|
||||||
self.assertEqual(env["PATH"], new_path_value)
|
|
||||||
|
|
||||||
@skipIfWindows
|
|
||||||
@skipIfRemote
|
|
||||||
def test_empty_environment_custom_launcher(self):
|
|
||||||
"""
|
|
||||||
Tests running a process with an empty environment from a custom
|
|
||||||
launcher
|
|
||||||
"""
|
|
||||||
program = self.getBuildArtifact("a.out")
|
|
||||||
self.build_and_create_debug_adaptor()
|
|
||||||
|
|
||||||
launchCommands = [
|
|
||||||
'target create "%s"' % (program),
|
|
||||||
"run"
|
|
||||||
]
|
|
||||||
self.launch(launchCommands=launchCommands)
|
|
||||||
self.continue_to_exit()
|
|
||||||
env = self.getEnvOutputByProgram()
|
|
||||||
self.assertNotIn("PATH", env)
|
|
||||||
|
|
||||||
@skipIfWindows
|
|
||||||
@skipIfRemote
|
|
||||||
def test_inheriting_environment_custom_launcher(self):
|
|
||||||
"""
|
|
||||||
Tests running a process from a custom launcher inheriting the
|
|
||||||
environment
|
|
||||||
"""
|
|
||||||
program = self.getBuildArtifact("a.out")
|
|
||||||
self.build_and_create_debug_adaptor()
|
|
||||||
|
|
||||||
launchCommands = [
|
|
||||||
'target create "%s"' % (program),
|
|
||||||
"run"
|
|
||||||
]
|
|
||||||
self.launch(launchCommands=launchCommands, inheritEnvironment=True)
|
|
||||||
self.continue_to_exit()
|
|
||||||
env = self.getEnvOutputByProgram()
|
|
||||||
self.assertIn("PATH", env)
|
|
|
@ -1,15 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern char **environ;
|
|
||||||
|
|
||||||
int main(int argc, char const *argv[]) {
|
|
||||||
char **env_var_pointer = environ;
|
|
||||||
for (char *env_variable = *env_var_pointer; env_variable;
|
|
||||||
env_variable = *++env_var_pointer) {
|
|
||||||
printf("%s\n", env_variable);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "lldb/API/SBEnvironment.h"
|
|
||||||
#include "llvm/ADT/ArrayRef.h"
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
#include "llvm/Option/Arg.h"
|
#include "llvm/Option/Arg.h"
|
||||||
#include "llvm/Option/ArgList.h"
|
#include "llvm/Option/ArgList.h"
|
||||||
|
@ -1356,8 +1355,6 @@ void request_launch(const llvm::json::Object &request) {
|
||||||
auto launchCommands = GetStrings(arguments, "launchCommands");
|
auto launchCommands = GetStrings(arguments, "launchCommands");
|
||||||
g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
|
g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
|
||||||
const auto debuggerRoot = GetString(arguments, "debuggerRoot");
|
const auto debuggerRoot = GetString(arguments, "debuggerRoot");
|
||||||
bool launchWithDebuggerEnvironment =
|
|
||||||
GetBoolean(arguments, "inheritEnvironment", false);
|
|
||||||
|
|
||||||
// This is a hack for loading DWARF in .o files on Mac where the .o files
|
// This is a hack for loading DWARF in .o files on Mac where the .o files
|
||||||
// in the debug map of the main executable have relative paths which require
|
// in the debug map of the main executable have relative paths which require
|
||||||
|
@ -1374,13 +1371,6 @@ void request_launch(const llvm::json::Object &request) {
|
||||||
// the targets - preRunCommands are run with the target.
|
// the targets - preRunCommands are run with the target.
|
||||||
g_vsc.RunInitCommands();
|
g_vsc.RunInitCommands();
|
||||||
|
|
||||||
// Reset the default value of the inherit environment setting, so that the
|
|
||||||
// environment of programs launched by launchCommands is consistent with the
|
|
||||||
// "inheritEnvironment" argument.
|
|
||||||
if (!launchWithDebuggerEnvironment)
|
|
||||||
g_vsc.RunLLDBCommands(llvm::StringRef(),
|
|
||||||
{"settings set target.inherit-env false"});
|
|
||||||
|
|
||||||
lldb::SBError status;
|
lldb::SBError status;
|
||||||
g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
|
g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
|
||||||
if (status.Fail()) {
|
if (status.Fail()) {
|
||||||
|
@ -1405,12 +1395,10 @@ void request_launch(const llvm::json::Object &request) {
|
||||||
if (!args.empty())
|
if (!args.empty())
|
||||||
g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
|
g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
|
||||||
|
|
||||||
// This mimics what CommandObjectProcess does when launching a process
|
// Pass any environment variables along that the user specified.
|
||||||
lldb::SBEnvironment env = g_vsc.target.GetEnvironment();
|
auto envs = GetStrings(arguments, "env");
|
||||||
for (const auto &name_and_value : GetStrings(arguments, "env"))
|
if (!envs.empty())
|
||||||
env.PutEntry(name_and_value.c_str());
|
g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
|
||||||
|
|
||||||
g_vsc.launch_info.SetEnvironment(env, true);
|
|
||||||
|
|
||||||
auto flags = g_vsc.launch_info.GetLaunchFlags();
|
auto flags = g_vsc.launch_info.GetLaunchFlags();
|
||||||
|
|
||||||
|
|
|
@ -84,11 +84,6 @@
|
||||||
"description": "Additional environment variables.",
|
"description": "Additional environment variables.",
|
||||||
"default": []
|
"default": []
|
||||||
},
|
},
|
||||||
"inheritEnvironment": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Inherit the debugger environment when launching a process. Only works for binaries launched directly by LLDB.",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"stopOnEntry": {
|
"stopOnEntry": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Automatically stop after launch.",
|
"description": "Automatically stop after launch.",
|
||||||
|
|
Loading…
Reference in New Issue