linux: Add helping kernel gdb functions compilation
PATCH 1/1 linux: Add helping kernel gdb functions compilation
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
--- linux/Config.in | 7 +++++++ linux/linux.mk | 7 +++++++ 2 files changed, 14 insertions(+)
linux/Config.in +7 -0
@@ -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"
linux/linux.mk +7 -0
@@ -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
Signature · 6 lines
2.40.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Michael, All,
On 2023-12-09 11:10 +0100, Michael Trimarchi spake thusly:
Quoted 3 lines
In order to use all the features of KGDB it's nice to have the possibility to source the
vmlinux-gdb.pyfile. 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)
endefSee:
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.
Quoted 82 lines
Add it
in order to use gdb of vmlinux in output directory including tx-* linux scriptgdb-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 restrictDEBUG_INFO) and kernel cmdline should be modified to wait of kgdb if needed. As examplekgdboc_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/ttyUSB0115200gdb 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 <[email protected]>Signed-off-by Michael Trimarchi <[email protected]>--- linux/Config.in | 7 +++++++ linux/linux.mk | 7 +++++++ 2 files changed, 14 insertions(+)linux/Config.in +7
-0@@ -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"linux/linux.mk +7
-0@@ -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) endefSignature · 6 lines
2.40.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | 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 [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Yann
Quoted 18 lines · Yann E. MORIN
Michael, All,
On 2023-12-09 11:10 +0100, Michael Trimarchi spake thusly:
Quoted 3 lines
In order to use all the features of KGDB it's nice to have the possibility to source the
vmlinux-gdb.pyfile. 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
Quoted 5 lines
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
Quoted 93 lines
Regards,
Yann E. MORIN.Quoted 78 lines
Add it
in order to use gdb of vmlinux in output directory including tx-* linux scriptgdb-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 restrictDEBUG_INFO) and kernel cmdline should be modified to wait of kgdb if needed. As examplekgdboc_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/ttyUSB0115200gdb 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 <[email protected]>Signed-off-by Michael Trimarchi <[email protected]>--- linux/Config.in | 7 +++++++ linux/linux.mk | 7 +++++++ 2 files changed, 14 insertions(+)linux/Config.in +7
-0@@ -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"linux/linux.mk +7
-1@@ -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
Quoted 4 lines
_______________________________________________
buildroot mailing list
[email protected]
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. |'------------------------------^-------^------------------^--------------------'
Signature · 15 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot