linux内核调试gdb + KGDB
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
·
Linux内核开发者使用最普遍的调试方法是printk方法,但是这种方法每次添加一些调试信息后还要重新编译烧写,效率不高,Kgdb调试方法是一种源码级的Linux内核调试器。使用Kgdb调试内核时,需要结合gdb一起使用,使用他们可以对内核进行单步调试,设置断点,观察变量、寄存器的值等。使用kgdb调试需要两台机器,即主机和目标机(一般为开发板),主机上使用gdb通过串口或者网络来调试目标机,目标机上需要内核配置支持kgdb。
kgdboc
kgdb的调试是通过串口
一、内核配置
Kernel hacking --->
-*- Kernel debugging
[*] Compile the kernel with debug info
[*] KGDB: kernel debugger --->
<*> KGDB: use kgdb over the serial console
二、修改uboot启动参数 console=ttyS1,57600 kgdboc=ttyS1,57600 kgdbwait
kgdboc后面跟的是调试用的串口,如果需要调试内核的启动过程,需要在kgdboc后加入kgdbwait
三、pc上启动gdb调试
启动后Linux内核会停在如下地方
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
serial8250.0: ttyS0 at MMIO 0x4806a000 (irq = 72) is a ST16654
console [ttyS0] enabled #by guoingbo
serial8250.1: ttyS1 at MMIO 0x4806c000 (irq = 73) is a ST16654
serial8250.2: ttyS2 at MMIO 0x49020000 (irq = 74) is a ST16654
kgdb: Registered I/O driver kgdboc.
kgdb: Waiting for connection from remote gdb...
这时在pc上开始启动gdb调试,
rsdk-linux-gdb ./vmlinux.img
set serial baud 57600
target remote /dev/ttyUSB0
注,这里填的是ttyUSB0,因为pc上的串口接到开发板上的用的就是这个串口,而在uboot中填的是ttyS1,是因为在开发板上的这个串口对应是ttyS1
kgdboe
kgdb的调试是通过网络
参考文章
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 5 年前
5def40a3
Add host customization support for the NodeJS version 5 年前
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐



所有评论(0)