diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py @@ -23,7 +23,7 @@ self.assertFalse(not_expected_item in actual_list) @skipIfWindows - @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + #@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots def test_completions(self): """ Tests the completion request at different breakpoints diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile new file mode 100644 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py new file mode 100644 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py @@ -0,0 +1,43 @@ +""" +Test lldb-vscode completions request +""" + + +import lldbvscode_testcase +import unittest2 +import vscode +from lldbsuite.test import lldbutil +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +import os + + +class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + def verify_completions(self, actual_list, expected_list, not_expected_list=[]): + for expected_item in expected_list: + self.assertTrue(expected_item in actual_list) + + for not_expected_item in not_expected_list: + self.assertFalse(not_expected_item in actual_list) + + @skipIfWindows + #@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + def test_environment_variable(self): + """ + Tests the completion request at different breakpoints + """ + program = self.getBuildArtifact("a.out") + path_env_variable = 'PATH='+os.environ['PATH'] + self.build_and_launch(program, inheritEnvironment=False) + self.continue_to_exit() + output = self.get_stdout().encode('utf-8') + lines = output.splitlines() + found = False + for line in lines: + if line.startswith('PATH='): + found = True + self.assertTrue(path_env_variable == line, "PATH environment variable not the same") + self.assertTrue(found, 'PATH environment variable not found') \ No newline at end of file diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp new file mode 100644 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +extern char **environ; + +int main(int argc, char const *argv[], char const *envp[]) { + char** env_var_pointer = environ; + // std::vector vscode_env_variables; + int count = 0; + for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) { + printf("%s\n", env_variable); + count++; + } + return 0; // breakpoint 1 +} diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py @@ -265,7 +265,7 @@ disableSTDIO=False, shellExpandArguments=False, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None,sourcePath= None, - debuggerRoot=None, launchCommands=None): + debuggerRoot=None, launchCommands=None, inheritEnvironment=False): '''Sending launch request to vscode ''' @@ -296,7 +296,9 @@ exitCommands=exitCommands, sourcePath=sourcePath, debuggerRoot=debuggerRoot, - launchCommands=launchCommands) + launchCommands=launchCommands, + inheritEnvironment=inheritEnvironment + ) if not (response and response['success']): self.assertTrue(response['success'], 'launch failed (%s)' % (response['message'])) @@ -306,14 +308,13 @@ disableSTDIO=False, shellExpandArguments=False, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, - sourcePath=None, debuggerRoot=None): + sourcePath=None, debuggerRoot=None, inheritEnvironment=False): '''Build the default Makefile target, create the VSCode debug adaptor, and launch the process. ''' self.build_and_create_debug_adaptor() self.assertTrue(os.path.exists(program), 'executable must exist') - self.launch(program, args, cwd, env, stopOnEntry, disableASLR, disableSTDIO, shellExpandArguments, trace, initCommands, preRunCommands, stopCommands, exitCommands, - sourcePath, debuggerRoot) + sourcePath, debuggerRoot, inheritEnvironment=inheritEnvironment) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -562,7 +562,7 @@ disableSTDIO=False, shellExpandArguments=False, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, sourcePath=None, - debuggerRoot=None, launchCommands=None): + debuggerRoot=None, launchCommands=None, inheritEnvironment=False): args_dict = { 'program': program } @@ -597,6 +597,8 @@ args_dict['debuggerRoot'] = debuggerRoot if launchCommands: args_dict['launchCommands'] = launchCommands + if inheritEnvironment: + args_dict['inheritEnvironment'] = inheritEnvironment command_dict = { 'command': 'launch', 'type': 'request', @@ -891,6 +893,7 @@ stopCommands=options.stopCmds, exitCommands=options.exitCmds) else: + print('Options.Envs: ', options.envs) response = dbg.request_launch(options.program, args=args, env=options.envs, @@ -929,6 +932,7 @@ def main(): + print("Hello This Is Main") parser = optparse.OptionParser( description=('A testing framework for the Visual Studio Code Debug ' 'Adaptor protocol')) diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1402,10 +1402,11 @@ // if arguments has launchWithDebuggerEnvironment // then append current environment to g_vsc.launch_info if (launchWithDebuggerEnvironment) { + // if (true) { char** env_var_pointer = environ; std::vector vscode_env_variables; - for (char* c = *env_var_pointer; c; c=*++env_var_pointer){ - vscode_env_variables.push_back(c); + for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){ + vscode_env_variables.push_back(env_variable); } envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables)); }