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 @@ -839,13 +839,19 @@ class DebugAdaptor(DebugCommunication): - def __init__(self, executable=None, port=None, init_commands=[]): + def __init__( + self, executable=None, port=None, init_commands=[], skip_init_files=True + ): self.process = None if executable is not None: + env = os.environ.copy() + if skip_init_files: + env['LLDBVSCODE_SKIP_INIT_FILES'] = "1" self.process = subprocess.Popen([executable], stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + env=env) DebugCommunication.__init__(self, self.process.stdout, self.process.stdin, init_commands) elif port is not None: 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 @@ -454,6 +454,11 @@ } } +const bool GetSkipInitFiles() { + static const bool skip_init_files = getenv("LLDBVSCODE_SKIP_INIT_FILES") != NULL; + return skip_init_files; +} + // "AttachRequest": { // "allOf": [ { "$ref": "#/definitions/Request" }, { // "type": "object", @@ -1194,7 +1199,9 @@ // }] // } void request_initialize(const llvm::json::Object &request) { - g_vsc.debugger = lldb::SBDebugger::Create(true /*source_init_files*/); + const bool skip_init_files = GetSkipInitFiles(); + g_vsc.debugger = + lldb::SBDebugger::Create(!skip_init_files /*source_init_files*/); // Create an empty target right away since we might get breakpoint requests // before we are given an executable to launch in a "launch" request, or a // executable when attaching to a process by process ID in a "attach"