kernel debug(内核调试)
1.yum -y install ncurses-devel.x86_64 elfutils-libelf-devel.x86_64 elfutils-libelf-devel.x86_642.download kernel and busybox3. kernel compress: make ARCH=x86_64 CROSS_COMPILE=x86_64-none-linux-...
·
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 <<EOF
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s
ifconfig lo up
EOF
chmod +x $ROOTFS/etc/init.d/rcS
cat > $ROOTFS/etc/inittab <<EOF
# /etc/inittab
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
EOF
chmod +x $ROOTFS/etc/inittab
cp -rP ${BUSYBOX}/_install/* ${ROOTFS}
cp -rP ${DYNAMIC_LIB_PATH_64}/libc-${GLIBC_VERSION}.so ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/libc.so.6 ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/libm-${GLIBC_VERSION}.so ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/libm.so.6 ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/librt-${GLIBC_VERSION}.so ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/librt.so.1 ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/libpthread-${GLIBC_VERSION}.so ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/libpthread.so.0 ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/ld-${GLIBC_VERSION}.so ${ROOTFS}/lib64/
cp -rP ${DYNAMIC_LIB_PATH_64}/ld-linux-x86-64.so.2 ${ROOTFS}/lib64/
cd ${ROOTFS}
ln -sf bin/busybox init
find . | cpio -o --format=newc > ../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.
更多推荐
已为社区贡献1条内容
所有评论(0)