* [Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation
@ 2023-12-09 10:10 Michael Trimarchi
2023-12-09 18:47 ` Yann E. MORIN
0 siblings, 1 reply; 3+ messages in thread
From: Michael Trimarchi @ 2023-12-09 10:10 UTC (permalink / raw)
To: buildroot; +Cc: Dario Binacchi, linux-amarula, Michael Trimarchi
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. 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@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@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@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation
2023-12-09 10:10 [Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation Michael Trimarchi
@ 2023-12-09 18:47 ` Yann E. MORIN
2023-12-09 22:00 ` Michael Nazzareno Trimarchi
0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2023-12-09 18:47 UTC (permalink / raw)
To: Michael Trimarchi; +Cc: Dario Binacchi, linux-amarula, buildroot
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@amarulasolutions.com>
> Signed-off-by: Michael Trimarchi <michael@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@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. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation
2023-12-09 18:47 ` Yann E. MORIN
@ 2023-12-09 22:00 ` Michael Nazzareno Trimarchi
0 siblings, 0 replies; 3+ messages in thread
From: Michael Nazzareno Trimarchi @ 2023-12-09 22:00 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: Dario Binacchi, linux-amarula, buildroot
Hi Yann
On Sat, Dec 9, 2023 at 7:47 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> 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
>
I have done the change, the suggestion was really good. I re-submit,
add your contribution
on the commit message, including suggested by and resent v2
Michael
> 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@amarulasolutions.com>
> > Signed-off-by: Michael Trimarchi <michael@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@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. |
> '------------------------------^-------^------------------^--------------------'
--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________
Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-09 22:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-09 10:10 [Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation Michael Trimarchi
2023-12-09 18:47 ` Yann E. MORIN
2023-12-09 22:00 ` Michael Nazzareno Trimarchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox