From: AdrianF <adrian.freihofer@siemens.com>
To: openembedded-core@lists.openembedded.org
Cc: Adrian Freihofer <adrian.freihofer@siemens.com>
Subject: [PATCH v3 13/13] devtool: ide-sdk: Support GDB pretty-printing for C++ STL types
Date: Mon, 26 Jan 2026 08:37:40 +0100 [thread overview]
Message-ID: <20260126073809.468495-14-adrian.freihofer@siemens.com> (raw)
In-Reply-To: <20260126073809.468495-1-adrian.freihofer@siemens.com>
From: Adrian Freihofer <adrian.freihofer@siemens.com>
GDB requires Python scripts provided by GCC to properly display C++ STL
types. This commit adds support for configuring GDB to use these
pretty-printers in the ide-sdk, covering both the ide_none and ide_code
plugins.
The implementation locates the GCC Python helper scripts in the sysroot
and injects the necessary commands into the GDB initialization files and
IDE debug configurations. This ensures that when debugging C++
applications, STL containers and other complex types are displayed in a
readable format.
Without this:
(gdb) print numbers
$1 = {<std::_Vector_base<int, std::allocator<int> >> = {
_M_impl = {<std::allocator<int>> = {<std::__new_allocator<int>> =
{<No data fields>}, <No data fields>}, <std::_Vector_base<int,
std::allocator<int> >::_Vector_impl_data> =
{_M_start = 0x55555556c370, _M_finish = 0x55555556c37c,
_M_end_of_storage = 0x55555556c37c}, <No data fields>}},
<No data fields>}
With this:
(gdb) print numbers
$1 = std::vector of length 3, capacity 3 = {1, 2, 3}
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
scripts/lib/devtool/ide_plugins/ide_code.py | 14 +++++++++++
scripts/lib/devtool/ide_plugins/ide_none.py | 8 +++++++
scripts/lib/devtool/ide_sdk.py | 26 +++++++++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py b/scripts/lib/devtool/ide_plugins/ide_code.py
index 647a5b8cc6..c2ee9b91c6 100644
--- a/scripts/lib/devtool/ide_plugins/ide_code.py
+++ b/scripts/lib/devtool/ide_plugins/ide_code.py
@@ -290,6 +290,20 @@ class IdeVSCode(IdeBase):
logger.warning(
"Cannot setup debug symbols configuration for GDB. IMAGE_GEN_DEBUGFS is not enabled.")
+ # Enable pretty-printing for gdb for resolving STL types with help of python scripts
+ pretty_printing_cmd = modified_recipe.gdb_pretty_print_scripts
+ if pretty_printing_cmd:
+ setup_commands += [
+ {
+ "description": "Enable pretty-printing for gdb",
+ "text": "python " +";".join(pretty_printing_cmd)
+ },
+ {
+ "description": "Enable pretty-printing for gdb",
+ "text": "-enable-pretty-printing"
+ }
+ ]
+
launch_config['sourceFileMap'] = src_file_map
launch_config['setupCommands'] = setup_commands
diff --git a/scripts/lib/devtool/ide_plugins/ide_none.py b/scripts/lib/devtool/ide_plugins/ide_none.py
index ba65f6f7da..ed96afa33c 100644
--- a/scripts/lib/devtool/ide_plugins/ide_none.py
+++ b/scripts/lib/devtool/ide_plugins/ide_none.py
@@ -102,6 +102,14 @@ class GdbCrossConfigNone(GdbCrossConfig):
"Cannot setup debug symbols configuration for GDB. IMAGE_GEN_DEBUGFS is not enabled.")
# Disable debuginfod for now, the IDE configuration uses rootfs-dbg from the image workdir.
gdbinit_lines.append('set debuginfod enabled off')
+
+ # Enable pretty-printing for gdb for resolving STL types with help of python scripts
+ pretty_printing_cmd = self.modified_recipe.gdb_pretty_print_scripts
+ if pretty_printing_cmd:
+ gdbinit_lines.append(os.linesep +"python")
+ gdbinit_lines += pretty_printing_cmd
+ gdbinit_lines.append("end" + os.linesep)
+
gdbinit_lines.append(
'%s %s:%d' % (remote_cmd, self.gdb_cross.host, self.gdbserver_port))
gdbinit_lines.append('set remote exec-file ' + self.binary.binary_path)
diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index 78d7ed78c6..ba225f20b9 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -15,6 +15,7 @@ import stat
import subprocess
import sys
import shlex
+import glob
from argparse import RawTextHelpFormatter
from enum import Enum
@@ -414,6 +415,7 @@ class RecipeModified:
self.staging_incdir = None
self.strip_cmd = None
self.target_arch = None
+ self.tcoverride = None
self.topdir = None
self.workdir = None
# Service management
@@ -437,6 +439,7 @@ class RecipeModified:
# Populated after bitbake built all the recipes
self._installed_binaries = None
+ self._gdb_pretty_print_scripts = None
def initialize(self, config, workspace, tinfoil):
recipe_d = parse_recipe(
@@ -488,6 +491,7 @@ class RecipeModified:
recipe_d.getVar('STAGING_INCDIR'))
self.strip_cmd = recipe_d.getVar('STRIP')
self.target_arch = recipe_d.getVar('TARGET_ARCH')
+ self.tcoverride = recipe_d.getVar('TCOVERRIDE')
self.topdir = recipe_d.getVar('TOPDIR')
self.workdir = os.path.realpath(recipe_d.getVar('WORKDIR'))
@@ -632,6 +636,28 @@ class RecipeModified:
return mappings
+ @property
+ def gdb_pretty_print_scripts(self):
+ if self._gdb_pretty_print_scripts is None:
+ if self.tcoverride == "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 gcc_python_helpers_dirs:
+ gcc_python_helpers = gcc_python_helpers_dirs[0]
+ else:
+ logger.warning("Could not find gcc python helpers directory matching: %s", gcc_python_helpers_pattern)
+ gcc_python_helpers = ""
+ pretty_print_scripts = [
+ "import sys",
+ "sys.path.insert(0, '" + gcc_python_helpers + "')",
+ "from libstdcxx.v6.printers import register_libstdcxx_printers",
+ "register_libstdcxx_printers(None)"
+ ]
+ self._gdb_pretty_print_scripts = pretty_print_scripts
+ else:
+ self._gdb_pretty_print_scripts = ""
+ return self._gdb_pretty_print_scripts
+
def __init_exported_variables(self, d):
"""Find all variables with export flag set.
--
2.52.0
prev parent reply other threads:[~2026-01-26 7:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 7:37 [PATCH v3 00/13] IDE SDK Improvements AdrianF
2026-01-26 7:37 ` [PATCH v3 01/13] useradd_base.bbclass: do not use awk AdrianF
2026-01-26 8:18 ` [OE-core] " ChenQi
2026-01-26 12:28 ` Alexander Kanavin
2026-01-26 14:01 ` adrian.freihofer
2026-01-26 20:18 ` Alexander Kanavin
2026-01-26 17:41 ` Peter Kjellerstedt
2026-01-30 14:01 ` Freihofer, Adrian
2026-01-26 7:37 ` [PATCH v3 02/13] devtool: ide-sdk find bitbake-setup init-build-env AdrianF
2026-01-26 7:37 ` [PATCH v3 03/13] oe-selftest: devtool: DevtoolIdeSdkTests debug logging AdrianF
2026-01-26 7:37 ` [PATCH v3 04/13] cpp-example: run as a service AdrianF
2026-01-26 7:37 ` [PATCH v3 05/13] oe-selftest: devtool: check example services are running AdrianF
2026-01-26 7:37 ` [PATCH v3 06/13] devtool: ide-sdk: add gdbserver attach mode support AdrianF
2026-01-26 7:37 ` [PATCH v3 07/13] devtool: ide-sdk: move code to ide_none AdrianF
2026-01-26 7:37 ` [PATCH v3 08/13] devtool: ide-sdk: make install_and_deploy script pass target arg AdrianF
2026-01-26 7:37 ` [PATCH v3 09/13] devtool: ide-sdk: vscode replace scripts AdrianF
2026-01-26 7:37 ` [PATCH v3 10/13] oe-selftest: devtool ide-sdk cover vscode remote debugging AdrianF
2026-01-26 7:37 ` [PATCH v3 11/13] devtool: ide-sdk: evaluate DEBUG_PREFIX_MAP AdrianF
2026-01-26 7:37 ` [PATCH v3 12/13] cpp-example: Add std::vector example AdrianF
2026-01-26 7:37 ` AdrianF [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260126073809.468495-14-adrian.freihofer@siemens.com \
--to=adrian.freihofer@siemens.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox