Linux Kernel Analysis Sixth experiment

Source: Internet
Author: User

Using GDB to track the process of creating a new process

rm menu -rf git clone https://github.com/mengning/menu.git 

mv test_fork.c test.c  
执行fork,可以看到父进程子进程都输出了信息。

Using GDB for debugging

Qemu-kernel linux-3.18.6/arch/x86/boot/bzimage-initrd rootfs.img -s-s

Gdb
File Linux-3.18.6/vmlinux
Target remote:1234

Start setting breakpoints

Where does the new process start? Why does it go smoothly? That is, the execution starting point is consistent with how the kernel stack is guaranteed.

Ret_ From_ Fork determines the first instruction address of the new process. The child process starts at the ret_ From_ Fork. Because before ret_ From_ Fork, that is, in the copy_ thread () function * childregs = * Current_ pt_ regs (), this sentence assigns the regs parameter of the parent process to the kernel stack of the child process. * The Childregs type is Pt_ regs, which stores the parameters of the Save_ all in the stack, so it can be executed smoothly in the subsequent restore all.

Linux Kernel Analysis Sixth experiment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.