@@ -279,6 +279,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
return launch_config
@@ -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)
@@ -15,6 +15,7 @@ import stat
import subprocess
import sys
import shlex
+import glob
from argparse import RawTextHelpFormatter
from enum import Enum
@@ -410,6 +411,7 @@ class RecipeModified:
self.staging_incdir = None
self.strip_cmd = None
self.target_arch = None
+ self.tcoverride = None
self.topdir = None
self.workdir = None
self.recipe_id = None
@@ -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(
@@ -487,6 +490,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'))
@@ -639,6 +643,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.