CS110: Programming and Problem Solving

advertisement
CS491-001: Operating Systems Programming
Winter 2014 (201410)
Running xv6 with make
The Makefile provided with xv6 has several phony targets for running the system:
1. make qemu
Build everything and run xv6 with QEMU, with a VGA console in a new window
and the serial console in the terminal where you typed this command. Close the
VGA window or press Ctrl-C or Ctrl-A X to stop.
2. make qemu-nox
Run xv6 without the VGA console.
3. make qemu-gdb
Run xv6 with GDB port open. Refer to the GDB section.
4. make qemu-nox-gdb
Run xv6 with GDB port open, without the VGA console.
GDB debug instructions
QEMU supports debugging with GDB. To debug with GDB:
1. Run xv6 with GDB port open
make qemu-gdb
or
make qemu-nox-gdb
depending on whether you want the VGA console.
2. Run GDB with the kernel binary
gdb kernel
and GDB will automatically connect to the GDB port.
Refer to the GDB Manual for a complete instruction of GDB. Some commands are
proved to be useful.

Ctrl-C (when in execution)
Halt the execution and break into GDB at the current instruction.

c
Continue execution to the next breakpoint, or till the next Ctrl-C.

si
Step in, execute one instruction and halt.

b *addr
Set a breakpoint at eip address addr (eip addresses can be found in .asm files).

b func
Set a breakpoint at function of name func.

b file:N
Set a breakpoint at line N of source code file.

info registers
Print the general purpose registers, eip, eflags, and the segment selectors. For
more detailed result, use info registers in the QEMU monitor.

x/Nx addr
Dump in hex N words starting at virtual address addr.

x/Ni addr
Display N assembly instructions starting at virtual address addr.

symbol-file file
Switch to symbol file file.

set print pretty
Print arrays and structs in a pretty easy-to-read format.
QEMU monitor
QEMU itself has a built-in monitor available to inspect and modify the machine state.
Press Ctrl-A C in the terminal running QEMU to get into the monitor. Refer to the
QEMU Manual for a complete instruction of QEMU monitor.
Some commands are particularly useful:

xp/Nx paddr
Dump in hex N words starting at physical address paddr.

info registers
Display a full detailed dump of registers.

info mem
Display the page table in a compact form.

info pg (This is an MIT extension to QEMU)
Display the current page table structure. Different from info mem, this
command distinguishes between PDE and PTE. Unbroken sequences of PDE's or
PTE's with identical permissions are compressed into a single line.
Download