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