2022-2023-1 20222814 《Linux内核原理与分析》第六周作业
实验五 分析 system_call 中断处理过程
1、打开QEMU
命令:
qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrdrootfs.img
2、进入menu,编辑 menu 中的 text.c 文件,给MenuOS增加 hello函数:
代码:
int hello(int argc,char *argv[]){
char m[] = {"20222814"};
int len = 9;
write(1,m,len);
return 0;
}
3、再次运行Menu不难发现命令中添加了hello:
4、设置断点
shell1中启动内核
cd ~/LinuxKernel
qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -S -s
用以下命令设置断点:
# shell2中使用gdb调试
cd ~/LinuxKernel
gdb
file linux-3.18.6/vmlinux
target remote:1234
b start_kernel
c
c
最后结果如下: