/
Linux Debug infrastructure (Kernel debugging using KGDB)
Linux Debug infrastructure (Kernel debugging using KGDB)
Enabling KGDB with Petalinux
- Pre-requisites
- Petalinux environment (set the required environment set for petalinux)
- Petalinux (source from Petalinux daily)
- Petalinux project (create). petalinux-create -t project -s <hardware_specific.bsp>
- $ petalinux-create -t kgdb -s /proj/petalinux/2018.3/petalinux-v2018.3_daily_latest/bsp/release/xilinx-zcu102-v2018.3-final.bsp
- Modifying Linux-kernel This step is to enable Kernel-configs for KGDB (module can be enabled by selecting that module and pressing ‘y’)
- To configure kernel use Petalinux-config. This will open kernel menu-config.
- $ petalinux-config -c kernel
check project-spec/meta-user/recipes-kernel/linux/linux-xlnx/user_xx.cfg for following configs-
- CONFIG_CONSOLE_POLL=y
- CONFIG_KGDB=y
- CONFIG_KGDB_SERIAL_CONSOLE=y
- Building Project the boot images. To build the project use petalinux-build
- $ petalinux-build
Working with ARM-DCC
- On development hardware-
- Boot the hardware
select the console for debugging. echo ttyPS0 > /sys/module/kgdboc/parameters/kgdboc. Following logs should show up-
- [ 60.352486] KGDB: Registered I/O driver kgdboc
- [ 60.372279] KGDB: Waiting for connection from remote gdb...
- On host PC-
- change to the images directory of the project. cd images/linux/. locate vmlinux binary
- launch gdb with vmlinux
- aarch64-linux-gnu-gdb -b 115200 ./vmlinux
- Once gdb prompt is up. select the host-remote tty interface.
- target remote /dev/ttyUSB0
- Once connection is established, carry on with debugging. Set breakpoints, run kernel etc..
root@xhdkperepu40:/work/dmaEXP/uartPs1/images/linux# aarch64-linux-gnu-gdb -b 115200 ./vmlinux GNU gdb (Linaro GDB 2018.04) 8.0.50.20171128-git Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./vmlinux...done. (gdb) (gdb) (gdb) target remote /dev/ttyUSB0 Remote debugging using /dev/ttyUSB0 arch_kgdb_breakpoint () at /work/dmaEXP/uartPs1/components/extSrc/linux-xlnx/arch/arm64/include/asm/kgdb.h:32 32 asm ("brk %0" : : "I" (KGDB_COMPILED_DBG_BRK_IMM)); (gdb) (gdb) (gdb) break addrconf_notify Breakpoint 1 at 0xffffff80088abb40: file /work/dmaEXP/uartPs1/components/extSrc/linux-xlnx/net/ipv6/addrconf.c, line 3352. (gdb) continue Continuing. [Switching to Thread 2376] Thread 86 "" hit Breakpoint 1, addrconf_notify (this=0xffffff8008e2f398, event=4, ptr=0xffffff800d543d30) at /work/dmaEXP/uartPs1/components/extSrc/linux-xlnx/net/ipv6/addrconf.c:3352 3352 { (gdb) Continuing. Thread 86 "" hit Breakpoint 1, addrconf_notify (this=0xffffff8008e2f398, event=4, ptr=0xffffff800d543d30) at /work/dmaEXP/uartPs1/components/extSrc/linux-xlnx/net/ipv6/addrconf.c:3352 3352 { (gdb) list 3347 write_unlock_bh(&idev->lock); 3348 } 3349 3350 static int addrconf_notify(struct notifier_block *this, unsigned long event, 3351 void *ptr) 3352 { 3353 struct net_device *dev = netdev_notifier_info_to_dev(ptr); 3354 struct netdev_notifier_changeupper_info *info; 3355 struct inet6_dev *idev = __in6_dev_get(dev); 3356 struct net *net = dev_net(dev); (gdb) bt #0 addrconf_notify (this=0xffffff8008e2f398, event=4, ptr=0xffffff800d543d30) at /work/dmaEXP/uartPs1/components/extSrc/linux-xlnx/net/ipv6/addrconf.c:3352 #1 0xffffff80080b9ab0 in notifier_call_chain (nl=<optimized out>, val=4, v=0xffffff800d543d30, nr_to_call=143309632, nr_calls=0x1043) at /work/dmaEXP/uartPs1/components/extSrc/linux-xlnx/kernel/notifier.c:93 #2 0xffffff80080b9c64 in __raw_notifier_call_chain (nr_calls=<optimized out>, nr_to_call=<optimized out>, v=<optimized out>, val=<optimized out>, nh=<optimized out>) at /work/dmaEXP/uartPs1/components/extSrc/linux-xlnx/kernel/notifier.c:394 #3 raw_notifier_call_chain (nh=<optimized out>, val=<optimized out>, v=<optimized out>) at /work/dmaEXP/uartPs1/components/extSrc/linux-xl