diff mbox series

[13/20] devtool: ide-sdk: parse Rust debug path remaps

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

Commit Message

Enguerrand de Ribaucourt Oct. 26, 2026, 8:55 a.m. UTC
Use Cargo RUSTFLAGS to populate reverse debug mappings and recognize Rust
--remap-path-prefix alongside the existing GCC prefix-map options. The
following LLDB source-map change depends on these normalized mappings.

AI-Generated: Uses GitHub Copilot
Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
---
 scripts/lib/devtool/ide_sdk.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index 44429e80b0..f22a98cedf 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -1140,6 +1140,9 @@  class RecipeModified:
         if self.build_tool is BuildTool.KERNEL_MODULE:
             self.reverse_debug_prefix_map = self._init_reverse_debug_prefix_map(
                 self.kernel_cc)
+        elif self.build_tool is BuildTool.CARGO:
+            self.reverse_debug_prefix_map = self._init_reverse_debug_prefix_map(
+                self.cargo_rustflags)
         else:
             self.reverse_debug_prefix_map = self._init_reverse_debug_prefix_map(
                 recipe_d.getVar('DEBUG_PREFIX_MAP'))
@@ -1292,15 +1295,20 @@  class RecipeModified:
         return ':'.join(self.solib_search_path(image))
 
     def _init_reverse_debug_prefix_map(self, debug_prefix_map):
-        """Parses GCC map options and returns a mapping of target to host paths.
+        """Parses compiler map options and returns a mapping of target to host paths.
 
-        This function scans a string containing GCC options such as -fdebug-prefix-map,
+        This function scans a string containing compiler options such as -fdebug-prefix-map,
         -fmacro-prefix-map, and -ffile-prefix-map (in both '--option value' and '--option=value'
         forms), extracting all mappings from target paths (used in debug info) to host source
         paths. If multiple mappings for the same target path are found, the most suitable
         host path is selected (preferring 'sources' over 'build' directories).
         """
-        prefixes = ("-fdebug-prefix-map", "-fmacro-prefix-map", "-ffile-prefix-map")
+        prefixes = (
+            "-fdebug-prefix-map",
+            "-fmacro-prefix-map",
+            "-ffile-prefix-map",
+            "--remap-path-prefix",
+        )
         all_mappings = {}
         args = shlex.split(debug_prefix_map)
         i = 0