使用qemu和kgdb调试内核源码

kgdb文档:http://kernel.org/doc/htmldocs/kgdb.html

修改.config

  • # CONFIG_DEBUG_RODATA is not set

  • CONFIG_FRAME_POINTER=y

  • CONFIG_KGDB=y

  • CONFIG_KGDB_SERIAL_CONSOLE=y

  • CONFIG_KGDB_KDB=y

  • CONFIG_KDB_KEYBOARD=y

#! /bin/sh

#qemu-system-x86_64 -kernel kernel/bzImage -append "root=/dev/sda" -boot c -hda busybox.img -k en-us -s -S 

qemu-system-x86_64 -kernel kernel/bzImage -append "root=/dev/sda kgdboc=kms,kbd,ttyS0,115200 kgdbwait kgdbcon" -boot c -hda busybox.img -k en-us -serial tcp::1234,server


gdb设置

gdb vmlinux

set debug remote 1 开启远程调试

set architecture i386:x86-64:intel 

set remotebaud 115200

target remote 127.0.0.1:1234

你可能感兴趣的:(使用qemu和kgdb调试内核源码)