diff mbox series

[3/6] devtool: code: Add source mapping for debug source files

Message ID 20240215170422.659073-4-enguerrand.de-ribaucourt@savoirfairelinux.com
State New
Headers show
Series devtool: ide: Improve VSCode support | expand

Commit Message

Enguerrand de Ribaucourt Feb. 15, 2024, 5:04 p.m. UTC
When launching the debug configuration, the source files from the debug
rootfs were openened in the editor instead of the local workspace files.
We add an exception to properly map them to the file being developed and
compiled by the IDE integration. This also more closely matches what the
user would expect compared to native development.

This is also true for the devtool fallback mode.
---
 scripts/lib/devtool/ide_plugins/ide_code.py | 1 +
 scripts/lib/devtool/ide_sdk.py              | 1 +
 2 files changed, 2 insertions(+)

Comments

Adrian Freihofer Feb. 15, 2024, 11:21 p.m. UTC | #1
On Thu, 2024-02-15 at 18:04 +0100, Enguerrand de Ribaucourt wrote:
> When launching the debug configuration, the source files from the
> debug
> rootfs were openened in the editor instead of the local workspace
> files.
> We add an exception to properly map them to the file being developed
> and
> compiled by the IDE integration. This also more closely matches what
> the
> user would expect compared to native development.
> 
> This is also true for the devtool fallback mode.

This sounds a little bit unexpected to me. With devtool deploy-target
the binaries which are copied to the target device have still the
absolute rpath from the real build host. The are not packaged.

I would expect something like this when a packaged binary would be
debugged. But I'm not sure if that would make sense and should be
supported.

> ---
>  scripts/lib/devtool/ide_plugins/ide_code.py | 1 +
>  scripts/lib/devtool/ide_sdk.py              | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py
> b/scripts/lib/devtool/ide_plugins/ide_code.py
> index b2193130d2e..c063b7d0590 100644
> --- a/scripts/lib/devtool/ide_plugins/ide_code.py
> +++ b/scripts/lib/devtool/ide_plugins/ide_code.py
> @@ -234,6 +234,7 @@ class IdeVSCode(IdeBase):
>          if gdb_cross_config.image_recipe.rootfs_dbg:
>              launch_config['additionalSOLibSearchPath'] =
> modified_recipe.solib_search_path_str(
>                  gdb_cross_config.image_recipe)
> +            src_file_map[os.path.join("/usr/src/debug",
> modified_recipe.pn, modified_recipe.pv)] = "${workspaceFolder}"
>              src_file_map["/usr/src/debug"] = os.path.join(
>                  gdb_cross_config.image_recipe.rootfs_dbg, "usr",
> "src", "debug")
>          else:
> diff --git a/scripts/lib/devtool/ide_sdk.py
> b/scripts/lib/devtool/ide_sdk.py
> index a82ab572998..1e36f2b2093 100755
> --- a/scripts/lib/devtool/ide_sdk.py
> +++ b/scripts/lib/devtool/ide_sdk.py
> @@ -356,6 +356,7 @@ class RecipeModified:
>              'PACKAGE_DEBUG_SPLIT_STYLE')
>          self.path = recipe_d.getVar('PATH')
>          self.pn = recipe_d.getVar('PN')
> +        self.pv = recipe_d.getVar('PV')
>          self.recipe_sysroot = os.path.realpath(
>              recipe_d.getVar('RECIPE_SYSROOT'))
>          self.recipe_sysroot_native = os.path.realpath(
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 b2193130d2e..c063b7d0590 100644
--- a/scripts/lib/devtool/ide_plugins/ide_code.py
+++ b/scripts/lib/devtool/ide_plugins/ide_code.py
@@ -234,6 +234,7 @@  class IdeVSCode(IdeBase):
         if gdb_cross_config.image_recipe.rootfs_dbg:
             launch_config['additionalSOLibSearchPath'] = modified_recipe.solib_search_path_str(
                 gdb_cross_config.image_recipe)
+            src_file_map[os.path.join("/usr/src/debug", modified_recipe.pn, modified_recipe.pv)] = "${workspaceFolder}"
             src_file_map["/usr/src/debug"] = os.path.join(
                 gdb_cross_config.image_recipe.rootfs_dbg, "usr", "src", "debug")
         else:
diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index a82ab572998..1e36f2b2093 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -356,6 +356,7 @@  class RecipeModified:
             'PACKAGE_DEBUG_SPLIT_STYLE')
         self.path = recipe_d.getVar('PATH')
         self.pn = recipe_d.getVar('PN')
+        self.pv = recipe_d.getVar('PV')
         self.recipe_sysroot = os.path.realpath(
             recipe_d.getVar('RECIPE_SYSROOT'))
         self.recipe_sysroot_native = os.path.realpath(