xv6 调试技巧

url: https://pdos.csail.mit.edu/6.S081/2020/labs/guidance.html

参考链接详细讲了 xv6 调试技巧,认真研读

下面总结重点:

1.运行 debug 模式的方式:
窗口1执行 make qemu-gdb
窗口2执行 gdb-multiarch

如果你想观看内核文件的汇编版本,请查找 kernel.asm

If the kernel panics, it will print an error message listing the value of the program counter when it crashed; you can search kernel.asm to find out in which function the program counter was when it crashed, or you can run addr2line -e kernel/kernel pc-value (run man addr2line for details). If you want to get backtrace, restart using gdb: run ‘make qemu-gdb’ in one window, run gdb (or riscv64-linux-gnu-gdb) in another window, set breakpoint in panic (‘b panic’), followed by followed by ‘c’ (continue). When the kernel hits the break point, type ‘bt’ to get a backtrace.

If your kernel hangs (e.g., due to a deadlock) or cannot execute further (e.g., due to a page fault when executing a kernel instruction), you can use gdb to find out where it is hanging. Run run ‘make qemu-gdb’ in one window, run gdb (riscv64-linux-gnu-gdb) in another window, followed by followed by ‘c’ (continue). When the kernel appears to hang hit Ctrl-C in the qemu-gdb window and type ‘bt’ to get a backtrace.

qemu has a “monitor” that lets you query the state of the emulated machine. You can get at it by typing control-a c (the “c” is for console). A particularly useful monitor command is info mem to print the page table. You may need to use the cpu command to select which core info mem looks at, or you could start qemu with make CPUS=1 qemu to cause there to be just one core.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值