[Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation
Yann E. MORIN
yann.morin.1998 at free.fr
Sat Dec 9 18:47:52 UTC 2023
Michael, All,
On 2023-12-09 11:10 +0100, Michael Trimarchi spake thusly:
> In order to use all the features of KGDB it's nice to have
> the possibility to source the vmlinux-gdb.py file. The
> generation of this file it's a target of linux kernel.
It is automatically generated when the kernel is configured with
CONFIG_GDB_SCRIPTS, so I think the best approach would be something
along the lines of:
package/gdb/gdb.mk:
define HOST_GDB_LINUX_CONFIG_FIXUPS
$(call KCONFIG_ENABLE_OPT,CONFIG_GDB_SCRIPTS)
endef
See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n1748
and:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n1752
Regards,
Yann E. MORIN.
> Add it
> in order to use gdb of vmlinux in output directory including
> tx-* linux script
>
> gdb-multiarch --tui output/build/<linux dir>/vmlinux
> add-auto-load-safe-path output/build/<linux dir>
> source output/build/<linux dir>/vmlinux-gdb.py
>
> Linux needs to be compiled with DEBUG_INFO (without restrict
> DEBUG_INFO) and kernel cmdline should be modified to wait
> of kgdb if needed. As example
>
> kgdboc_earlycon=ns16550a kgdboc=/dev/ttyS2 kgdbwait nokaslr
>
> The test was done on am62x board over serial line. In order
> to have it running properly we need to compile the agent-proxy
>
> ./output/host/bin/agent-proxy 4440 4441 0 /dev/ttyUSB0 115200
>
> gdb can now having the debugging uart available using:
>
> target remote localhost:4441
>
> the 4440 is used by the console and 4441 is used to debug
>
> Tested-by: Michael Trimarchi <michael at amarulasolutions.com>
> Signed-off-by: Michael Trimarchi <michael at amarulasolutions.com>
> ---
> linux/Config.in | 7 +++++++
> linux/linux.mk | 7 +++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/linux/Config.in b/linux/Config.in
> index ae734c49a0..71ab27bbcb 100644
> --- a/linux/Config.in
> +++ b/linux/Config.in
> @@ -486,6 +486,13 @@ config BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE
> such as "BTF: .tmp_vmlinux.btf: pahole (pahole) is not
> available".
>
> +config BR2_LINUX_KERNEL_ADD_HOST_GDB_SCRIPTS
> + bool "Need tools for debugging with kgdb"
> + help
> + Add helping script to be used with gdb and kgdb in order to
> + debug linux kernel. Those convinients scripts add some feature
> + command to gdb with specific python script
> +
> # Linux extensions
> source "linux/Config.ext.in"
>
> diff --git a/linux/linux.mk b/linux/linux.mk
> index 1db5c6046d..e8cdb26793 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -488,6 +488,12 @@ LINUX_APPEND_DTB += ; \
> endif
> endif
>
> +ifeq ($(BR2_LINUX_KERNEL_ADD_HOST_GDB_SCRIPTS),y)
> +define LINUX_BUILD_GDB_SCRIPTS
> + $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) scripts_gdb
> +endef
> +endif
> +
> # Compilation. We make sure the kernel gets rebuilt when the
> # configuration has changed. We call the 'all' and
> # '$(LINUX_TARGET_NAME)' targets separately because calling them in
> @@ -503,6 +509,7 @@ define LINUX_BUILD_CMDS
> $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all
> $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
> $(LINUX_BUILD_DTB)
> + $(LINUX_BUILD_GDB_SCRIPTS)
> $(LINUX_APPEND_DTB)
> endef
>
> --
> 2.40.1
>
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
More information about the buildroot
mailing list