Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Michael Trimarchi <michael@amarulasolutions.com>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	linux-amarula@amarulasolutions.com, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation
Date: Sat, 9 Dec 2023 19:47:52 +0100	[thread overview]
Message-ID: <ZXS2WPiQ2xRVnpKz@landeda> (raw)
In-Reply-To: <20231209101043.1839458-1-michael@amarulasolutions.com>

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

  reply	other threads:[~2023-12-09 18:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-09 10:10 [Buildroot] [PATCH] linux: Add helping kernel gdb functions compilation Michael Trimarchi
2023-12-09 18:47 ` Yann E. MORIN [this message]
2023-12-09 22:00   ` Michael Nazzareno Trimarchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZXS2WPiQ2xRVnpKz@landeda \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=michael@amarulasolutions.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox