8000 Linux内核2 跟踪分析Linux内核的启动过程 · Issue #67 · holdyounger/ScopeBlog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Linux内核2 跟踪分析Linux内核的启动过程 #67
Open
@holdyounger

Description

@holdyounger

Linux内核2 跟踪分析Linux内核的启动过程

使用实验楼的虚拟机打开 shell

cd ~/LinuxKernel/
qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img

内核启动完成后进入 menu程序(《软件工程 C 编码实践篇》的课程项目),支持三个命令 help、version 和 quit,您也可以添加更多的命令,对选修过《软件工程 C 编码实践篇》的童鞋应该是 a piece of cake.

使用 gdb 跟踪调试内核

$ qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -s -S

# 关于-s和-S选项的说明:
# 1. -S
#   -S freeze CPU at startup (use ’c’ to start execution)
# 2. -s
#   -s shorthand for -gdb tcp::1234
# 若不想使用1234端口,则可以使用-gdb tcp:xxxx来取代-s选项

另开一个 shell 窗口

# 打开 GDB 调试器
$ gdb

# 在 GDB 中输入以下命令:

# 在gdb界面中targe remote之前加载符号表
(gdb)file linux-3.18.6/vmlinux

# 建立gdb和gdbserver之间的连接,按c 让qemu上的Linux继续运行
(gdb)target remote:1234

# 断点的设置可以在target remote之前,也可以在之后
(gdb)break start_kernel

blog link [Linux内核2 跟踪分析Linux内核的启动过程](https://holdyounger.github.io/OS/Linux/Linux内核分析配套实验/2 跟踪分析Linux内核的启动过程/)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0