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.文章来源:https://www.toymoban.com/news/detail-728263.html
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.文章来源地址https://www.toymoban.com/news/detail-728263.html
到了这里,关于xv6 调试技巧的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!