[Lldb-commits] [lldb] 1c05c52 - [lldb-vscode] Fix coredump load source mapping for first file
Ted Woodward via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 1 08:47:54 PDT 2021
Author: Ted Woodward
Date: 2021-11-01T10:47:42-05:00
New Revision: 1c05c52de2177a328b7d2d07b697af67eb9f8122
URL: https://github.com/llvm/llvm-project/commit/1c05c52de2177a328b7d2d07b697af67eb9f8122
DIFF: https://github.com/llvm/llvm-project/commit/1c05c52de2177a328b7d2d07b697af67eb9f8122.diff
LOG: [lldb-vscode] Fix coredump load source mapping for first file
SetSourceMapFromArguments is called after the core is loaded. This means
that the source file for the crashing code won't have the source map applied.
Move the call to SetSourceMapFromArguments in request_attach to just after
the call to RunInitCommands, matching request_launch behavior.
Reviewed By: clayborg, wallace
Differential Revision: https://reviews.llvm.org/D112834
Added:
lldb/test/API/tools/lldb-vscode/coreFile/main.c
Modified:
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
lldb/tools/lldb-vscode/lldb-vscode.cpp
Removed:
################################################################################
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
index 0a55fc0ead1e4..255a4805a9737 100644
--- 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 @@ def attach(self, program=None, pid=None, waitFor=None, trace=None,
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 @@ def cleanup():
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
index df057d5e63aa6..603b1545cd714 100644
--- 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 @@ def request_attach(self, program=None, pid=None, waitFor=None, trace=None,
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 @@ def request_attach(self, program=None, pid=None, waitFor=None, trace=None,
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
index 55efd91d827a6..56a93ccd6c8ab 100644
--- 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 @@ def test_core_file(self):
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
index 0000000000000..389bf7b51f4d6
--- /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
index 71bdcaef0dff4..445a06c9da702 100644
--- a/lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -616,6 +616,8 @@ void request_attach(const llvm::json::Object &request) {
// 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 @@ void request_attach(const llvm::json::Object &request) {
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) {
More information about the lldb-commits
mailing list