Skip to contentSkip to conversation

kernel.bbclass: make scripts_gdb when CONFIG_GDB_SCRIPTS=y and target is available

RFC PATCH In review Olivier Dautricourt 2 participants 3 messages Oct 14, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 kernel.bbclass: make scripts_gdb when CONFIG_GDB_SCRIPTS=y and target is available

Since Commit 67274c083438340ad16c ("scripts/gdb: delay generation of gdb constants.py") in kernel source tree (>=V5.1), scripts_gdb target needs explicit run to build scripts/gdb. (vmlinux-gdb.py script is used by gdb for linux kernel integration).

As this step was previously not needed, this suggest newer kernels builds do not bundle it anymore, this change provides the same functionalities for kernels >=V5.1 .

---
 meta/classes-recipe/kernel.bbclass | 3 +++
 1 file changed, 3 insertions(+)
meta/classes-recipe/kernel.bbclass +3 -0
index 2ec9ea2091..5206b4f2a7 100644
@@ -394,6 +394,9 @@ kernel_do_compile() {
 	for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
 		oe_runmake ${PARALLEL_MAKE} ${typeformake} ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
 	done
+	if (grep -q -i -e '^CONFIG_GDB_SCRIPTS=y$' .config && grep -q -e "^PHONY +=.*scripts_gdb" "${S}/Makefile"); then
+		oe_runmake ${PARALLEL_MAKE} scripts_gdb
+	fi
 }
 
 kernel_do_transform_kernel() {
Signature · 1 line
2.42.0
#1 lore raw
Quoted 9 lines · Olivier Dautricourt

Since Commit 67274c083438340ad16c ("scripts/gdb: delay generation of gdb constants.py") in kernel source tree (>=V5.1), scripts_gdb target needs explicit run to build scripts/gdb. (vmlinux-gdb.py script is used by gdb for linux kernel integration).

As this step was previously not needed, this suggest newer kernels builds do not bundle it anymore, this change provides the same functionalities for kernels >=V5.1 .

It also suggests that very few people use the integration :)

Quoted 11 lines
---
 meta/classes-recipe/kernel.bbclass | 3 +++
 1 file changed, 3 insertions(+)
meta/classes-recipe/kernel.bbclass +0 -0
index 2ec9ea2091..5206b4f2a7 100644

meta/classes-recipe/kernel.bbclass kernel_do_compile() { · line 399

Quoted 6 lines
meta/classes-recipe/kernel.bbclass +3 -0
@@ -394,6 +394,9 @@ kernel_do_compile() {
        for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
                oe_runmake ${PARALLEL_MAKE} ${typeformake} ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
        done
+       if (grep -q -i -e '^CONFIG_GDB_SCRIPTS=y$' .config && grep -q -e "^PHONY +=.*scripts_gdb" "${S}/Makefile"); then
+               oe_runmake ${PARALLEL_MAKE} scripts_gdb
+       fi

We really try to avoid using any explicit checks for CONFIG_* in the kernel classes or using them to coordinate functionality. While I don't think that this is a significant issue here (since what is being built is small and it is isolated),
it is something that could be coordinated via a distro feature as the main "on off" switch. We already have some debug distro features, and I could see this being something that could trigger when they are enabled (and for kernel-yocto derived kernels, it could also ensure that gdb functionality is enabled via a fragment).

I'd also suggest that this could be placed into a separate task like we do for modules. Again, the build here is small, but it is something outside of the core kernel build which is the purpose of do_compile in the kernel classes. As a task, it also would be easy enough for other users to override if it causes them issues.

Cheers,

Bruce

Quoted 6 lines
meta/classes-recipe/kernel.bbclass +0 -1
 }
 
 kernel_do_transform_kernel() {
--

2.42.0

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#2 lore raw
Quoted 48 lines · Bruce Ashfield
Quoted 9 lines · Olivier Dautricourt

Since Commit 67274c083438340ad16c ("scripts/gdb: delay generation of gdb constants.py") in kernel source tree (>=V5.1), scripts_gdb target needs explicit run to build scripts/gdb. (vmlinux-gdb.py script is used by gdb for linux kernel integration).

As this step was previously not needed, this suggest newer kernels builds do not bundle it anymore, this change provides the same functionalities for kernels >=V5.1 .

It also suggests that very few people use the integration :)

Quoted 11 lines
---
 meta/classes-recipe/kernel.bbclass | 3 +++
 1 file changed, 3 insertions(+)
meta/classes-recipe/kernel.bbclass +0 -0
index 2ec9ea2091..5206b4f2a7 100644

meta/classes-recipe/kernel.bbclass kernel_do_compile() { · line 399

Quoted 6 lines
meta/classes-recipe/kernel.bbclass +3 -0
@@ -394,6 +394,9 @@ kernel_do_compile() {
        for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
                oe_runmake ${PARALLEL_MAKE} ${typeformake} ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
        done
+       if (grep -q -i -e '^CONFIG_GDB_SCRIPTS=y$' .config && grep -q -e "^PHONY +=.*scripts_gdb" "${S}/Makefile"); then
+               oe_runmake ${PARALLEL_MAKE} scripts_gdb
+       fi

We really try to avoid using any explicit checks for CONFIG_* in the kernel classes or using them to coordinate functionality. While I don't think that this is a significant issue here (since what is being built is small and it is isolated),
it is something that could be coordinated via a distro feature as the main "on off" switch. We already have some debug distro features, and I could see this being something that could trigger when they are enabled (and for kernel-yocto derived kernels, it could also ensure that gdb functionality is enabled via a fragment).

I'd also suggest that this could be placed into a separate task like we do for modules. Again, the build here is small, but it is something outside of the core kernel build which is the purpose of do_compile in the kernel classes. As a task, it also would be easy enough for other users to override if it causes them issues.

Quoted 3 lines

Cheers,

Bruce

Thanks for the quick reply. I understood your points and i will see how to better integrate this.

Kind Regards,

Olivier