Quantcast
Viewing all articles
Browse latest Browse all 5131

Raspberry Pi OS • What is correct option for building kernel with debug info

I have a Raspberry Pi zero 2 W. I am b uilding on an X86 Ubuntu 22.04 host. I was able to follow the steps to cross-compile the kernel from source located https://www.raspberrypi.com/documentati ... ernel.html. The build was successful and I booted off of it an all seems OK.

I want to enable KGDB in the kernel. When I run find on vmlinux it says "not stripped" but doesn't say "with debug_info".
I found this page about KGDB https://linuxlink.timesys.com/docs/how_to_use_kgdb. It seems to imply that menuconfig will just have an enable debug info option in kernel hacking.

Include Kernel Hacking -> Compile the Kernel with debug info

But that doesn't seem to be the case in my version of Kernel Hacking.
When I go into Kernel Hacking I see "Compile-time checks and compiler options", in there it says "Debug Information" and I get these options:

(X) Disable debug information
( ) Rely on the toolchain's implicit default DWARF version
( ) Generate DWARF Version 4 debuiginfo
( ) Generate DWARF Version 5 debuginfo.

I have picked the "Rely on the toolchain's implicit default DWARF version".

I was able to save that configuration and rebuild the image and modules and it succeeded. Now find shows:

$ file vmlinux
vmlinux: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=30973decdf1b9ea04d09d087839f4942e55c5cee, with debug_info, not stripped

So, I do get the debug information and gdb seems to be happy with it.

$ gdb -f vmlinux
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
<copyright stuff>
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from vmlinux...
(gdb)

which is better than before. I still need to figure out how to activate KGDB in the kernel when it is running and get gdb to connect to it. I'll start working on that.

I am wondering if I picked the correct DWARF option or if I should be selecting one of the others?

Thanks
Chris

Statistics: Posted by chriskot870 — Mon Aug 12, 2024 11:55 pm



Viewing all articles
Browse latest Browse all 5131

Trending Articles