diff mbox series

[v3,14/14] devtool: ide-sdk: detect stale gcc python helpers in the recipe sysroot

Message ID 20260819220138.4095398-15-adrian.freihofer@siemens.com
State New
Headers show
Series devtool: ide-sdk: robust attach-mode debugging and test cleanup | expand

Commit Message

AdrianF Aug. 19, 2026, 10 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

RECIPE_SYSROOT can retain a gcc-<old-version>/python directory left
over from before a gcc version bump, since sysroot cleanup does not
always remove it. gdb_pretty_print_scripts globbed usr/share/gcc-*/python
and silently picked the first match, which could be the stale, no
longer matching version, breaking libstdc++ pretty-printing in gdb
(register_libstdcxx_printers) without an obvious cause.

Raise a DevtoolError when the glob matches more than one directory
instead of guessing, and tell the user to remove tmp/work and rebuild
the recipe.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 scripts/lib/devtool/ide_sdk.py | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index ab2bba5d39..4fdeeec24d 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -817,6 +817,11 @@  class RecipeModified:
             if self.toolchain == "gcc":
                 gcc_python_helpers_pattern = os.path.join(self.recipe_sysroot, "usr", "share", "gcc-*", "python")
                 gcc_python_helpers_dirs = glob.glob(gcc_python_helpers_pattern)
+                if len(gcc_python_helpers_dirs) > 1:
+                    raise DevtoolError(
+                        "Found multiple gcc python helpers directories matching %s: %s. "
+                        "The recipe sysroot likely has stale files from a previous gcc version, "
+                        "remove tmp/work and rebuild the recipe." % (gcc_python_helpers_pattern, gcc_python_helpers_dirs))
                 if gcc_python_helpers_dirs:
                     gcc_python_helpers = gcc_python_helpers_dirs[0]
                 else: