diff mbox series

[SRU,F,RFC,1/1] UBUNTU: [Packaging] Build and include GDB Python scripts into debug packages

Message ID 20210514215805.249031-1-krzysztof.kozlowski@canonical.com
State New
Headers show
Series [SRU,F,RFC,1/1] UBUNTU: [Packaging] Build and include GDB Python scripts into debug packages | expand

Commit Message

Krzysztof Kozlowski May 14, 2021, 9:58 p.m. UTC
The kernel comes with useful GDB debugging scripts/commands (enabled
with CONFIG_GDB_SCRIPTS), however these are built either with "all" make
target or with "scripts_gdb".  Build these in
"$(stampdir)/stamp-build-%" target and package in "install-%" under
/usr/lib/debug/share.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

---

Work in progress, not extensively tested. I am sending to gather early
comments and hints. I will prepare proper SRU once
this looks good and is tested.

See https://www.kernel.org/doc/html/latest/dev-tools/gdb-kernel-debugging.html


---
 debian/rules.d/2-binary-arch.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 0542c12a708b..74577c14b5a6 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -52,6 +52,12 @@  $(stampdir)/stamp-build-%: $(stampdir)/stamp-prepare-%
 	@echo Debug: $@ build_image $(build_image) bldimg $(bldimg)
 	$(build_cd) $(kmake) $(build_O) $(conc_level) $(bldimg) modules $(if $(filter true,$(do_dtbs)),dtbs)
 
+ifneq ($(skipdbg),true)
+	if grep -q CONFIG_GDB_SCRIPTS=y $(builddir)/build-$*/.config; then \
+		$(build_cd) $(kmake) $(build_O) $(conc_level) scripts_gdb ; \
+	fi
+endif
+
 	@touch $@
 
 define build_dkms_sign =
@@ -294,6 +300,12 @@  ifneq ($(skipdbg),true)
 	# Debug image is simple
 	install -m644 -D $(builddir)/build-$*/vmlinux \
 		$(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
+	if [ -d $(builddir)/build-$*/scripts/gdb/linux ]; then \
+		install -m644 -D $(builddir)/build-$*/vmlinux-gdb.py \
+			$(dbgpkgdir)/usr/lib/debug/share/$(abi_release)-$*/vmlinux-gdb.py; \
+		install -m644 -D $(builddir)/build-$*/scripts/gdb/linux/* \
+			--target-directory=$(dbgpkgdir)/usr/lib/debug/share/$(abi_release)-$*/scripts/gdb/linux; \
+	fi
 	$(build_cd) $(kmake) $(build_O) modules_install $(vdso) \
 		INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
 	# Add .gnu_debuglink sections only after all/DKMS modules are built.