kernel debug(内核调试)

1.yum -y install ncurses-devel.x86_64 elfutils-libelf-devel.x86_64 elfutils-libelf-devel.x86_64

2.download kernel and busybox

3. kernel compress:

   make ARCH=x86_64 CROSS_COMPILE=x86_64-none-linux- defconfig
   make ARCH=x86_64 CROSS_COMPILE=x86_64-none-linux- menuconfig
   make ARCH=x86_64 CROSS_COMPILE=x86_64-none-linux- -j8



4.Generate minimal initramfs

#!/usr/bin/bash
ROOTFS=rootfs
BUSYBOX=$(find busybox* -maxdepth 0 -type d)
SYSROOT=$(x86_64-linux-gnu-gcc --print-sysroot)
GLIBC_VERSION=$(${SYSROOT}/usr/bin/ldd --version | head -1 | cut -d' ' -f4)
DYNAMIC_LIB_PATH_32=${SYSROOT}/lib
DYNAMIC_LIB_PATH_64=${SYSROOT}/lib64

rm -rf $ROOTFS
mkdir -p ${ROOTFS}/{proc,sys,dev,etc,etc/init.d,lib,lib64,mnt,tmp,go}

cat > $ROOTFS/etc/init.d/rcS < $ROOTFS/etc/inittab < ../initramfs


 

$ cd ~/workspace 
$ gdb
 (gdb) file linux-3.10.107/vmlinux 
Reading symbols from /home/yeyuzhen/workspace/linux-3.10.107/vmlinux...done.
(gdb) target remote:4321 
Remote debugging using :4321 kgdb_breakpoint () at kernel/debug/debug_core.c:1014 1014 wmb(); /* Sync point after breakpoint */


(gdb) b sys_sendto Breakpoint 1 at 0xffffffff815b44d0: file net/socket.c, line 1754. 
(gdb) info b Num Type Disp Enb Address What 1 breakpoint keep y 0xffffffff815b44d0 in SyS_sendto at net/socket.c:1754 (gdb) c Continuing.

 

你可能感兴趣的:(kernel debug(内核调试))