What is the deployment method of kernel debug environment
What is the deployment method of the kernel debug environment, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
I. compiling ramfs
Here you can simply use mkinitramfs or mkinitrd to create a ramfs file. But this way the system boots into the initramfs system and there is no real root file system mounted.
Mkinitramfs-o ramdisk.img
two。 Using buildroot to build an automatic root file system
2.1 download buildroot code
Download source files from buildroot
2.2 decompress and execute make menuconfig
2.3 configure System configuration-> Root password
Filesystem images-> cpio root filesystem
2.4 make
2.5 after compilation, a rootfs.cpio file is generated in the output/images directory.
II. Compile the kernel
Download the kernel source code
Download the kernel source code from https://www.kernel.org/
two。 Configure the kernel
To execute make menuconfig to configure the kernel, you need to enable the kernel debug function. It is enabled by default. Confirm CONFIG_DEBUG_INFO=y in the .config file.
3. Compile
Execute make-j8 to compile. It takes a long time to compile and generates a vmlinux file. A bzImage file is generated in the arch/x86_64/boot directory
Third, start the virtual machine
Start the virtual machine
Qemu-kvm-kernel $kernel_path/arch/x86_64/boot/bzImage\-nographic-append "console=ttyS0 nokaslr"\-initrd $buildroot/output/images/rootfs.cpio\-m 1024\-- enable-kvm\-cpu host\-s-S4, debug kernel
1. Start gdb
Gdb. / vmlinux
two。 Connect the virtual machine
Target remote: 1234
Debug kernel
Hbreak start_ Kernel v. Automated deployment scripts
Here is an automatic deployment script that can be modified to adapt to the use of
Is it helpful for wget https://github.com/Max-bazinga/kernel_debug/blob/main/auto_deploy_kernel_debug_env.sh to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.