Skip to content

Commit

Permalink
Revert "[lldb-vscode] Add inheritEnvironment option"
Browse files Browse the repository at this point in the history
This reverts commit 4ec6eba.
  • Loading branch information
Walter Erquinigo committed Mar 21, 2020
1 parent 34c0759 commit c85bf7c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 156 deletions.
Expand Up @@ -267,7 +267,7 @@ def launch(self, program=None, args=None, cwd=None, env=None,
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None,sourcePath= None,
debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
debuggerRoot=None, launchCommands=None):
'''Sending launch request to vscode
'''

Expand Down Expand Up @@ -298,8 +298,7 @@ def cleanup():
exitCommands=exitCommands,
sourcePath=sourcePath,
debuggerRoot=debuggerRoot,
launchCommands=launchCommands,
inheritEnvironment=inheritEnvironment)
launchCommands=launchCommands)
if not (response and response['success']):
self.assertTrue(response['success'],
'launch failed (%s)' % (response['message']))
Expand All @@ -309,7 +308,7 @@ def build_and_launch(self, program, args=None, cwd=None, env=None,
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=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,
and launch the process.
'''
Expand All @@ -319,4 +318,4 @@ def build_and_launch(self, program, args=None, cwd=None, env=None,
self.launch(program, args, cwd, env, stopOnEntry, disableASLR,
disableSTDIO, shellExpandArguments, trace,
initCommands, preRunCommands, stopCommands, exitCommands,
sourcePath, debuggerRoot, inheritEnvironment=inheritEnvironment)
sourcePath, debuggerRoot)
Expand Up @@ -570,7 +570,7 @@ def request_launch(self, program, args=None, cwd=None, env=None,
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
debuggerRoot=None, launchCommands=None):
args_dict = {
'program': program
}
Expand Down Expand Up @@ -605,8 +605,6 @@ def request_launch(self, program, args=None, cwd=None, env=None,
args_dict['debuggerRoot'] = debuggerRoot
if launchCommands:
args_dict['launchCommands'] = launchCommands
if inheritEnvironment:
args_dict['inheritEnvironment'] = inheritEnvironment
command_dict = {
'command': 'launch',
'type': 'request',
Expand Down Expand Up @@ -914,8 +912,7 @@ def run_vscode(dbg, args, options):
initCommands=options.initCmds,
preRunCommands=options.preRunCmds,
stopCommands=options.stopCmds,
exitCommands=options.exitCmds,
inheritEnvironment=options.inheritEnvironment)
exitCommands=options.exitCmds)

if response['success']:
if options.sourceBreakpoints:
Expand Down
3 changes: 0 additions & 3 deletions lldb/test/API/tools/lldb-vscode/environmentVariables/Makefile

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp

This file was deleted.

20 changes: 4 additions & 16 deletions lldb/tools/lldb-vscode/lldb-vscode.cpp
Expand Up @@ -40,7 +40,6 @@
#include <sstream>
#include <thread>

#include "lldb/API/SBEnvironment.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
Expand Down Expand Up @@ -1356,8 +1355,6 @@ void request_launch(const llvm::json::Object &request) {
auto launchCommands = GetStrings(arguments, "launchCommands");
g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
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
// in the debug map of the main executable have relative paths which require
Expand All @@ -1374,13 +1371,6 @@ void request_launch(const llvm::json::Object &request) {
// the targets - preRunCommands are run with the target.
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;
g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
if (status.Fail()) {
Expand All @@ -1405,12 +1395,10 @@ void request_launch(const llvm::json::Object &request) {
if (!args.empty())
g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);

// This mimics what CommandObjectProcess does when launching a process
lldb::SBEnvironment env = g_vsc.target.GetEnvironment();
for (const auto &name_and_value : GetStrings(arguments, "env"))
env.PutEntry(name_and_value.c_str());

g_vsc.launch_info.SetEnvironment(env, true);
// Pass any environment variables along that the user specified.
auto envs = GetStrings(arguments, "env");
if (!envs.empty())
g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);

auto flags = g_vsc.launch_info.GetLaunchFlags();

Expand Down
5 changes: 0 additions & 5 deletions lldb/tools/lldb-vscode/package.json
Expand Up @@ -84,11 +84,6 @@
"description": "Additional environment variables.",
"default": []
},
"inheritEnvironment": {
"type": "boolean",
"description": "Inherit the debugger environment when launching a process. Only works for binaries launched directly by LLDB.",
"default": false
},
"stopOnEntry": {
"type": "boolean",
"description": "Automatically stop after launch.",
Expand Down

0 comments on commit c85bf7c

Please sign in to comment.