linux内核调试环境
作者:互联网
linux内核调试
我将linux调试环境整理成了makefile 文件。 在运行该批量命令时,需要先确认该命令是否能运行起来。
makefile 文件
env:
sudo apt-get install qemu libncurses5-dev gcc-arm-linux-gnueabi build-essential
tarFile:
tar -xvf busybox-1.24.0.tar.bz2
mv busybox-1.24.0 busybox
tar -xvf linux-4.0.tar.gz
fileSys:
echo "this can not run , you must do by hands"
cd busybox
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make menuconfig
echo "chose | Busybox Settings | buildOption | [*] Build BusyBox as a static binary (no shared libs)"
make install
cd _install
mkdir etc
mkdir dev
mkdir mnt
mkdir -p etc/init.d/
cd etc/init.d/
echo "create file named rcS, write content:"
cat rcS
chmod +x rcS
cat fstab
cat inittab
cd _install/dev
sudo mknod console c 5 1
sudo mknod null c 1 3
sudo cp _install ../linux-4.0/ -fr
buildKernel:
echo "this cammand not run "
cd linux-4.0
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make vexpress_defconfig
make menuconfig
echo " need condfig fileSystem | memery split"
make bzImage -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
make dtbs
runKernel:
echo "this cammand not run , run by hands "
cd /home/share/debug_kernel/linux-4.0
qemu-system-arm -M vexpress-a9 -smp 4 -m 1024M -kernel arch/arm/boot/zImage -dtb arch/arm/boot/dts/vexpress-v2p-ca9.dtb -nographic -append "rdinit=/linuxrc console=ttyAMA0 loglevel=8"
gdbKernel:
sudo apt-get install gdb-arm-none-eabi
echo "make menuconfig buid kernel has include debug imformation "
echo "the option has choiced "
qemu-system-arm -M vexpress-a9 -smp 4 -m 1024M -kernel arch/arm/boot/zImage -dtb arch/arm/boot/dts/vexpress-v2p-ca9.dtb -nographic --append "rdinit=/linuxrc console=ttyAMA0 loglevel=8" -nographic -S -s
echo "open anther terminal"
cd linux-4.0
arm-none-eabi-gdb --tui vmlinux
echo "target remote localhost:1234 b start_kernel c "
gdbKernelGUi:
sudo apt-get install eclipse-cdt
sudo cp debug_kernel debug_kernel_gui -fr
eclipse
echo "config eclipse option "
qemu-system-arm -M vexpress-a9 -smp 4 -m 1024M -kernel arch/arm/boot/zImage -dtb arch/arm/boot/dts/vexpress-v2p-ca9.dtb -nographic --append "rdinit=/linuxrc console=ttyAMA0 loglevel=8" -nographic -S -s
echo "enter gdbui"
file vmlinux
b do_fork
switchProcess:
echo "collect cpu information"
sudo trace-cmd record -e'sched_wakeup*' -e sched_switch -e 'sched_migrate*'
echo "记录sched_switch和sched_wakeup两个时间,每1s写入一次数据。"
sudo trace-cmd record -e sched_switch -e sched_wakeup -s 1000000
kernelshark trace.dat
rcS 文件
mkdir -p /proc
mkdir -p /tmp
mkdir -p /sys
mkdir -p /mnt
/bin/mount -a
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev>/proc/sys/kernel/hotplug
mdev -s
fstab 文件
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
debugfs /sys/kernel/debug debugfs defaults 0 0
inittab文件
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
总结
这个是以前搭建环境做得笔记
参考
标签:kernel,sudo,mkdir,echo,内核,linux,arm,调试 来源: https://blog.csdn.net/tan1666/article/details/122793668