diff mbox series

[v2,13/18] devtool: ide-sdk: map Cargo workspace sources for LLDB

Message ID 20261109-devtool-ide-sdk-cargo-v2-13-d56134000561@savoirfairelinux.com
State New
Headers show
Series devtool: ide-sdk: add support for Rust recipes | expand

Commit Message

Enguerrand de Ribaucourt Nov. 9, 2026, 1:44 p.m. UTC
Cargo debug info remaps the modified source tree to TARGET_DBGSRC_DIR.
Include this reverse map in CodeLLDB launch configs even when rootfs-dbg
is disabled. Use the Cargo workspace as its source root while preserving
the existing rootfs-debug mappings for other recipes.

AI-Generated: Uses GitHub Copilot
Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>

---
Changes in v2:
- Move source-map verification to the LLDB configuration test.
---
 scripts/lib/devtool/ide_plugins/ide_code.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py b/scripts/lib/devtool/ide_plugins/ide_code.py
index a7bb3221e0..6312988db1 100644
--- a/scripts/lib/devtool/ide_plugins/ide_code.py
+++ b/scripts/lib/devtool/ide_plugins/ide_code.py
@@ -555,15 +555,22 @@  class IdeVSCode(IdeBase):
         source_map = {
             "/usr/include": os.path.join(modified_recipe.recipe_sysroot, "usr", "include")
         }
-        if lldb_config.image_recipe.rootfs_dbg:
+        rootfs_dbg = lldb_config.image_recipe.rootfs_dbg
+        is_cargo = modified_recipe.build_tool is BuildTool.CARGO
+        if is_cargo or rootfs_dbg:
+            source_root = (
+                modified_recipe.real_srctree
+                if is_cargo else "${workspaceFolder}")
             # Map build-time paths back to the workspace source tree.
             for target_path, host_path in modified_recipe.reverse_debug_prefix_map.items():
                 if host_path.startswith(modified_recipe.real_srctree):
                     source_map[target_path] = (
-                        "${workspaceFolder}"
+                        source_root
                         + host_path[len(modified_recipe.real_srctree):])
-                else:
+                elif rootfs_dbg:
                     source_map[target_path] = host_path
+
+        if rootfs_dbg:
             if "/usr/src/debug" in source_map:
                 logger.error(
                     'Key "/usr/src/debug" already exists in source_map. '