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 @@ -251,7 +251,7 @@ initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, attachCommands=None, coreFile=None, disconnectAutomatically=True, terminateCommands=None, - postRunCommands=None): + postRunCommands=None, sourceMap=None): '''Build the default Makefile target, create the VSCode debug adaptor, and attach to the process. ''' @@ -271,7 +271,8 @@ initCommands=initCommands, preRunCommands=preRunCommands, stopCommands=stopCommands, exitCommands=exitCommands, attachCommands=attachCommands, terminateCommands=terminateCommands, - coreFile=coreFile, postRunCommands=postRunCommands) + coreFile=coreFile, postRunCommands=postRunCommands, + sourceMap=sourceMap) if not (response and response['success']): self.assertTrue(response['success'], 'attach failed (%s)' % (response['message'])) 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 @@ -506,7 +506,8 @@ initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, attachCommands=None, terminateCommands=None, - coreFile=None, postRunCommands=None): + coreFile=None, postRunCommands=None, + sourceMap=None): args_dict = {} if pid is not None: args_dict['pid'] = pid @@ -533,6 +534,8 @@ args_dict['coreFile'] = coreFile if postRunCommands: args_dict['postRunCommands'] = postRunCommands + if sourceMap: + args_dict['sourceMap'] = sourceMap command_dict = { 'command': 'attach', 'type': 'request', diff --git a/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py b/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py --- a/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py +++ b/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py @@ -41,3 +41,18 @@ self.vscode.request_next(threadId=32259) self.assertEquals(self.get_stackFrames(), expected_frames) + + @skipIfWindows + @skipIfRemote + def test_core_file_source_mapping(self): + ''' Test that sourceMap property is correctly applied when loading a core ''' + current_dir = os.path.dirname(os.path.realpath(__file__)) + exe_file = os.path.join(current_dir, "linux-x86_64.out") + core_file = os.path.join(current_dir, "linux-x86_64.core") + + self.create_debug_adaptor() + + source_map = [["/home/labath/test", current_dir]] + self.attach(exe_file, coreFile=core_file, sourceMap=source_map) + + self.assertTrue(current_dir in self.get_stackFrames()[0]['source']['path']) diff --git a/lldb/test/API/tools/lldb-vscode/coreFile/main.c b/lldb/test/API/tools/lldb-vscode/coreFile/main.c new file mode 100644 --- /dev/null +++ b/lldb/test/API/tools/lldb-vscode/coreFile/main.c @@ -0,0 +1 @@ +/* Fake source file for core dump source mapping test */ 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 @@ -616,6 +616,8 @@ // Run any initialize LLDB commands the user specified in the launch.json g_vsc.RunInitCommands(); + SetSourceMapFromArguments(*arguments); + lldb::SBError status; g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status)); if (status.Fail()) { @@ -657,8 +659,6 @@ g_vsc.target = g_vsc.debugger.GetSelectedTarget(); } - SetSourceMapFromArguments(*arguments); - if (error.Success() && core_file.empty()) { auto attached_pid = g_vsc.target.GetProcess().GetProcessID(); if (attached_pid == LLDB_INVALID_PROCESS_ID) {