1# GDB Support 2 3This feature allows remote guest debugging using GDB. Note that this feature is only supported on x86_64/KVM. 4 5To enable debugging with GDB, build with the `gdb` feature enabled: 6 7```bash 8cargo build --features gdb 9``` 10 11To use the `--gdb` option, specify the Unix Domain Socket with `--path` that Cloud Hypervisor will use to communicate with the host's GDB: 12 13```bash 14./cloud-hypervisor \ 15 --kernel hypervisor-fw \ 16 --disk path=bionic-server-cloudimg-amd64.raw \ 17 --cpus boot=1 \ 18 --memory size=1024M \ 19 --net "tap=,mac=,ip=,mask=" \ 20 --console off \ 21 --serial tty \ 22 --gdb path=/tmp/ch-gdb-sock 23``` 24 25Cloud Hypervisor will listen for GDB on the host side before starting the guest. 26On the host side, connect to the GDB remote server as follows: 27 28```bash 29gdb -q 30(gdb) target remote /tmp/ch-gdb-sock 31Remote debugging using /tmp/ch-gdb-sock 32warning: No executable has been specified, and target does not support 33determining executable automatically. Try using the "file" command. 340x000000000011217e in ?? () 35``` 36 37You can set up to four hardware breakpoints using the x86 debug register: 38 39```bash 40(gdb) hb *0x1121b7 41Hardware assisted breakpoint 1 at 0x1121b7 42(gdb) c 43Continuing. 44 45Breakpoint 1, 0x00000000001121b7 in ?? () 46(gdb) 47```