Jack Li's Blog

Debug xv6 with gdb

Preparation #

# Run xv6 with gdb
make qemu-gdb

# Change to another terminal and connect to xv6-gdb
gdb-multiarch -x .gdbinit

Basic Command #

# Set break point
b syscall
b module.c:67

# Print source code
layout src
layout asm

# Continue
c

# Step into
step

# Step over
next

# Print register or value
p /x $stvec
p /x $a7
p /x p->proc

# List value of register
info register

# List args
info args

# See who call it
backtrace

# Set value
set xxx

# Watching variable
watch a