[PATCH 2/5] bootlinux: build kernel GDB helpers (scripts_gdb) into the build directory

Daniel Gomez <[email protected]> Fri, 12 Jun 2026 14:18:39 +0200
Newsgroups dev.linux.lists.kdevops
Message-ID <20260612-b4-bootlinux-direct-boot-followups-v1-2-c72537a65d08@samsung.com>
From: Daniel Gomez <[email protected]>

The kernel ships a Python helper set under scripts/gdb/ that an
attached gdb sources via vmlinux-gdb.py to call lx-dmesg, lx-ps,
lx-mounts and the rest. The helpers are materialized in the build
directory by `make scripts_gdb`, not by a normal kernel build.

Add a post-build task that runs the target with the same parameters
as the kernel build itself, gated by
CONFIG_BOOTLINUX_DIRECT_BOOT_SCRIPTS_GDB (default y). Independent of
CONFIG_GDB_SCRIPTS in the resolved .config; that knob only controls
distro packaging, not whether the build can produce the helpers.

Generated-by: Claude AI
Signed-off-by: Daniel Gomez <[email protected]>
---
 playbooks/roles/bootlinux/tasks/build/direct-boot.yml | 13 +++++++++++++
 workflows/linux/Kconfig                               | 16 ++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/playbooks/roles/bootlinux/tasks/build/direct-boot.yml b/playbooks/roles/bootlinux/tasks/build/direct-boot.yml
index eadcbfbf..104def13 100644
--- a/playbooks/roles/bootlinux/tasks/build/direct-boot.yml
+++ b/playbooks/roles/bootlinux/tasks/build/direct-boot.yml
@@ -163,6 +163,19 @@
   delegate_to: localhost
   tags: [build-linux]
 
+- name: Generate kernel GDB helpers (scripts_gdb) in the build directory
+  community.general.make:
+    chdir: "{{ bootlinux_direct_boot_tree_path }}"
+    target: scripts_gdb
+    jobs: "{{ bootlinux_direct_boot_nproc.stdout }}"
+    params: "{{ bootlinux_make_params | combine({'O': bootlinux_direct_boot_builddir}) }}"
+  environment: "{{ bootlinux_direct_boot_build_environment }}"
+  when:
+    - bootlinux_direct_boot_scripts_gdb | default(true) | bool
+  run_once: true
+  delegate_to: localhost
+  tags: [build-linux]
+
 # `make install` runs /sbin/installkernel against the controller's
 # /boot and may need root. Copy the image into the destdir by hand.
 - name: Resolve the built kernel image path
diff --git a/workflows/linux/Kconfig b/workflows/linux/Kconfig
index 117dd464..d5d322d0 100644
--- a/workflows/linux/Kconfig
+++ b/workflows/linux/Kconfig
@@ -177,6 +177,22 @@ config BOOTLINUX_DIRECT_BOOT_COMPILE_COMMANDS
 	  .cmd contents. Disable to skip (a few seconds on a large
 	  build).
 
+config BOOTLINUX_DIRECT_BOOT_SCRIPTS_GDB
+	bool "Build the kernel's GDB Python helpers (scripts_gdb)"
+	output yaml
+	default y
+	help
+	  After the kernel build, run `make scripts_gdb` against the
+	  out-of-tree build directory to materialize
+	  scripts/gdb/vmlinux-gdb.py and its helpers next to vmlinux.
+	  Lets a developer attach gdb to the running kernel (or a
+	  vmlinux core) and use lx-* commands (lx-dmesg, lx-ps,
+	  lx-mounts, ...) without a separate setup pass. The script
+	  collection is independent of CONFIG_GDB_SCRIPTS in the
+	  resolved .config; that knob only affects whether the
+	  scripts are installed into a distro package, not whether
+	  the build can produce them.
+
 endif # BOOTLINUX_DIRECT_BOOT
 
 if BOOTLINUX_9P

-- 
2.54.0