mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 05:16:06 +00:00
Prevent lldb-vscode tests from source lldbinit file
lldb-vscode is hard-coded to source .lldbinit file which causes some tests to fail on my machine. This patch adds a new option to control this: 1. vscode.py and lldb-vscode tests will not source .lldbinit by default 2. lldb-vscode will source .lldbinit in production if not specified otherwise Differential Revision: https://reviews.llvm.org/D135620
This commit is contained in:
parent
0f1a51e173
commit
ef25a21726
@ -253,7 +253,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
initCommands=None, preRunCommands=None, stopCommands=None,
|
initCommands=None, preRunCommands=None, stopCommands=None,
|
||||||
exitCommands=None, attachCommands=None, coreFile=None,
|
exitCommands=None, attachCommands=None, coreFile=None,
|
||||||
disconnectAutomatically=True, terminateCommands=None,
|
disconnectAutomatically=True, terminateCommands=None,
|
||||||
postRunCommands=None, sourceMap=None):
|
postRunCommands=None, sourceMap=None, sourceInitFile=False):
|
||||||
'''Build the default Makefile target, create the VSCode debug adaptor,
|
'''Build the default Makefile target, create the VSCode debug adaptor,
|
||||||
and attach to the process.
|
and attach to the process.
|
||||||
'''
|
'''
|
||||||
@ -267,7 +267,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
# Execute the cleanup function during test case tear down.
|
# Execute the cleanup function during test case tear down.
|
||||||
self.addTearDownHook(cleanup)
|
self.addTearDownHook(cleanup)
|
||||||
# Initialize and launch the program
|
# Initialize and launch the program
|
||||||
self.vscode.request_initialize()
|
self.vscode.request_initialize(sourceInitFile)
|
||||||
response = self.vscode.request_attach(
|
response = self.vscode.request_attach(
|
||||||
program=program, pid=pid, waitFor=waitFor, trace=trace,
|
program=program, pid=pid, waitFor=waitFor, trace=trace,
|
||||||
initCommands=initCommands, preRunCommands=preRunCommands,
|
initCommands=initCommands, preRunCommands=preRunCommands,
|
||||||
@ -284,7 +284,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, terminateCommands=None,
|
stopCommands=None, exitCommands=None, terminateCommands=None,
|
||||||
sourcePath=None, debuggerRoot=None, launchCommands=None,
|
sourcePath=None, debuggerRoot=None, sourceInitFile=False, launchCommands=None,
|
||||||
sourceMap=None, disconnectAutomatically=True, runInTerminal=False,
|
sourceMap=None, disconnectAutomatically=True, runInTerminal=False,
|
||||||
expectFailure=False, postRunCommands=None):
|
expectFailure=False, postRunCommands=None):
|
||||||
'''Sending launch request to vscode
|
'''Sending launch request to vscode
|
||||||
@ -301,7 +301,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
self.addTearDownHook(cleanup)
|
self.addTearDownHook(cleanup)
|
||||||
|
|
||||||
# Initialize and launch the program
|
# Initialize and launch the program
|
||||||
self.vscode.request_initialize()
|
self.vscode.request_initialize(sourceInitFile)
|
||||||
response = self.vscode.request_launch(
|
response = self.vscode.request_launch(
|
||||||
program,
|
program,
|
||||||
args=args,
|
args=args,
|
||||||
@ -344,7 +344,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
trace=False, initCommands=None, preRunCommands=None,
|
trace=False, initCommands=None, preRunCommands=None,
|
||||||
stopCommands=None, exitCommands=None,
|
stopCommands=None, exitCommands=None,
|
||||||
terminateCommands=None, sourcePath=None,
|
terminateCommands=None, sourcePath=None,
|
||||||
debuggerRoot=None, runInTerminal=False,
|
debuggerRoot=None, sourceInitFile=False, runInTerminal=False,
|
||||||
disconnectAutomatically=True, postRunCommands=None,
|
disconnectAutomatically=True, postRunCommands=None,
|
||||||
lldbVSCodeEnv=None):
|
lldbVSCodeEnv=None):
|
||||||
'''Build the default Makefile target, create the VSCode debug adaptor,
|
'''Build the default Makefile target, create the VSCode debug adaptor,
|
||||||
@ -356,6 +356,7 @@ class VSCodeTestCaseBase(TestBase):
|
|||||||
return self.launch(program, args, cwd, env, stopOnEntry, disableASLR,
|
return self.launch(program, args, cwd, env, stopOnEntry, disableASLR,
|
||||||
disableSTDIO, shellExpandArguments, trace,
|
disableSTDIO, shellExpandArguments, trace,
|
||||||
initCommands, preRunCommands, stopCommands, exitCommands,
|
initCommands, preRunCommands, stopCommands, exitCommands,
|
||||||
terminateCommands, sourcePath, debuggerRoot, runInTerminal=runInTerminal,
|
terminateCommands, sourcePath, debuggerRoot, sourceInitFile,
|
||||||
|
runInTerminal=runInTerminal,
|
||||||
disconnectAutomatically=disconnectAutomatically,
|
disconnectAutomatically=disconnectAutomatically,
|
||||||
postRunCommands=postRunCommands)
|
postRunCommands=postRunCommands)
|
||||||
|
@ -613,7 +613,7 @@ class DebugCommunication(object):
|
|||||||
}
|
}
|
||||||
return self.send_recv(command_dict)
|
return self.send_recv(command_dict)
|
||||||
|
|
||||||
def request_initialize(self):
|
def request_initialize(self, sourceInitFile):
|
||||||
command_dict = {
|
command_dict = {
|
||||||
'command': 'initialize',
|
'command': 'initialize',
|
||||||
'type': 'request',
|
'type': 'request',
|
||||||
@ -626,7 +626,8 @@ class DebugCommunication(object):
|
|||||||
'pathFormat': 'path',
|
'pathFormat': 'path',
|
||||||
'supportsRunInTerminalRequest': True,
|
'supportsRunInTerminalRequest': True,
|
||||||
'supportsVariablePaging': True,
|
'supportsVariablePaging': True,
|
||||||
'supportsVariableType': True
|
'supportsVariableType': True,
|
||||||
|
'sourceInitFile': sourceInitFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response = self.send_recv(command_dict)
|
response = self.send_recv(command_dict)
|
||||||
@ -1004,7 +1005,7 @@ def attach_options_specified(options):
|
|||||||
|
|
||||||
|
|
||||||
def run_vscode(dbg, args, options):
|
def run_vscode(dbg, args, options):
|
||||||
dbg.request_initialize()
|
dbg.request_initialize(options.sourceInitFile)
|
||||||
if attach_options_specified(options):
|
if attach_options_specified(options):
|
||||||
response = dbg.request_attach(program=options.program,
|
response = dbg.request_attach(program=options.program,
|
||||||
pid=options.pid,
|
pid=options.pid,
|
||||||
@ -1112,6 +1113,13 @@ def main():
|
|||||||
default=False,
|
default=False,
|
||||||
help='Pause waiting for a debugger to attach to the debug adaptor')
|
help='Pause waiting for a debugger to attach to the debug adaptor')
|
||||||
|
|
||||||
|
parser.add_option(
|
||||||
|
'--sourceInitFile',
|
||||||
|
action='store_true',
|
||||||
|
dest='sourceInitFile',
|
||||||
|
default=False,
|
||||||
|
help='Whether lldb-vscode should source .lldbinit file or not')
|
||||||
|
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
'--port',
|
'--port',
|
||||||
type='int',
|
type='int',
|
||||||
|
@ -1444,8 +1444,15 @@ void request_initialize(const llvm::json::Object &request) {
|
|||||||
auto log_cb = [](const char *buf, void *baton) -> void {
|
auto log_cb = [](const char *buf, void *baton) -> void {
|
||||||
g_vsc.SendOutput(OutputType::Console, llvm::StringRef{buf});
|
g_vsc.SendOutput(OutputType::Console, llvm::StringRef{buf});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto arguments = request.getObject("arguments");
|
||||||
|
// sourceInitFile option is not from formal DAP specification. It is only
|
||||||
|
// used by unit tests to prevent sourcing .lldbinit files from environment
|
||||||
|
// which may affect the outcome of tests.
|
||||||
|
bool source_init_file = GetBoolean(arguments, "sourceInitFile", true);
|
||||||
|
|
||||||
g_vsc.debugger =
|
g_vsc.debugger =
|
||||||
lldb::SBDebugger::Create(true /*source_init_files*/, log_cb, nullptr);
|
lldb::SBDebugger::Create(source_init_file, log_cb, nullptr);
|
||||||
g_vsc.progress_event_thread = std::thread(ProgressEventThreadFunction);
|
g_vsc.progress_event_thread = std::thread(ProgressEventThreadFunction);
|
||||||
|
|
||||||
// Start our event thread so we can receive events from the debugger, target,
|
// Start our event thread so we can receive events from the debugger, target,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user