diff mbox series

[UNSTABLE,v3] UBUNTU: [Packaging] Build and include GDB Python scripts into debug packages

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

Commit Message

Krzysztof Kozlowski May 19, 2021, 4:17 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/share/gdb/auto-load.

BugLink: https://bugs.launchpad.net/bugs/1928715
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

---

Changes since v2:
1. Put the scripts under /usr/share/gdb/auto-load.

Changes since v1 (RFC):
1. Add a comment inside .mk.
2. More tests.
---
 debian/rules.d/2-binary-arch.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Paolo Pisati June 4, 2021, 9:05 a.m. UTC | #1
On Wed, May 19, 2021 at 12:17:47PM -0400, Krzysztof Kozlowski wrote:
> 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/share/gdb/auto-load.
> 
> BugLink: https://bugs.launchpad.net/bugs/1928715
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
diff mbox series

Patch

diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 0b008df5a853..bd7fb7169b5c 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -49,6 +49,13 @@  $(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)
+	# The target scripts_gdb is part of "all", so we need to call it manually
+	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 =
@@ -295,6 +302,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/share/gdb/auto-load/boot/vmlinux-$(abi_release)-$*/vmlinuz-$(abi_release)-$*-gdb.py; \
+		install -m644 -D $(builddir)/build-$*/scripts/gdb/linux/* \
+			--target-directory=$(dbgpkgdir)/usr/share/gdb/auto-load/boot/vmlinux-$(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.