Kernel config options for kgdb

Kernel config options for kgdb

To enable CONFIG_KGDB you should look under
:menuselection:Kernel hacking --> Kernel debugging and select
:menuselection:KGDB: kernel debugger.

While it is not a hard requirement that you have symbols in your vmlinux
file, gdb tends not to be very useful without the symbolic data, so you
will want to turn on CONFIG_DEBUG_INFO which is called
:menuselection:Compile the kernel with debug info in the config menu.

It is advised, but not required, that you turn on the
CONFIG_FRAME_POINTER kernel option which is called :menuselection:Compile the kernel with frame pointers in the config menu. This option inserts code
into the compiled executable which saves the frame information in registers
or on the stack at different points which allows a debugger such as gdb to
more accurately construct stack back traces while debugging the kernel.

If the architecture that you are using supports the kernel option
CONFIG_STRICT_KERNEL_RWX, you should consider turning it off. This
option will prevent the use of software breakpoints because it marks
certain regions of the kernel’s memory space as read-only. If kgdb
supports it for the architecture you are using, you can use hardware
breakpoints if you desire to run with the CONFIG_STRICT_KERNEL_RWX
option turned on, else you need to turn off this option.

Next you should choose one of more I/O drivers to interconnect debugging
host and debugged target. Early boot debugging requires a KGDB I/O
driver that supports early debugging and the driver must be built into
the kernel directly. Kgdb I/O driver configuration takes place via
kernel or module parameters which you can learn more about in the in the
section that describes the parameter kgdboc.

Here is an example set of .config symbols to enable or disable for kgdb::

  # CONFIG_STRICT_KERNEL_RWX=is not set
  CONFIG_FRAME_POINTER=y
  CONFIG_KGDB=y
  CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_KALLSYMS
root Makefile
ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
KBUILD_CFLAGS += -O1
else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
KBUILD_CFLAGS += -O3
else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += -Os
endif

不常用kgdbcon

kgdboc=ttyS0,115200 kgdbwait nokaslr kgdbcon 

指定串口

echo ttyS0,115200 > /sys/module/kgdboc/parameters/kgdboc

陷入gdb

echo g > /proc/sysrq-trigger
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值