github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/debug/debug.md (about) 1 # Debugging status 2 3 ## VMware 4 VMware offers a gdb stub that you can use for live gdb debugging, but it is hard to debug on boot, as there is no way to wait for the debugger. 5 6 ## VirtuaBox 7 The have their own debugger. I did not find a working gdb stub for 64 bit guests. I only use it when i have to. 8 9 ## QEMU 10 Best debugging support, gdb stub and suspends boot. 11 12 # Debugging tips 13 14 In general whenever I had a problem, I tried to emulate the conditions of the problem in Qemu, as it offers the best debugging experience: 15 - You can use QEMU to source level debugging. 16 - Can use different qemu configurations to simulate different hypervisors (this is usefull to test that various drivers work as expected). 17 - Can wait for debugger to debug boot problems 18 - Easy command line workflow 19 20 # To run QEMU similar to VirtualBox: 21 22 Use a scsi driver for disks and two network cards (unik uses two network cards in virtualbox): 23 24 qemu-system-x86_64 -device virtio-scsi-pci,id=scsi \ 25 -device scsi-hd,drive=hd1 \ 26 -drive file=disk.raw,format=raw,if=none,id=hd1 \ 27 -device virtio-net-pci,netdev=mynet0,mac=54:54:00:55:55:55 \ 28 -netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,dns=8.8.8.8 29 30 To see the output of qemu in the console screen, add "-nographic -vga none" 31 32 # To run QEMU similar to VMware: 33 34 On vmware the network card is behind PCI bridge: 35 36 qemu-system-x86_64 -drive file=root.img,format=raw,if=virtio \ 37 -device pci-bridge,chassis_nr=2 \ 38 -device e1000,netdev=mynet0,mac=54:54:00:55:55:55,bus=pci.1,addr=1 \ 39 -netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9 40 41 ``` 42 qemu-system-x86_64 -device virtio-scsi-pci,id=scsi \ 43 -device scsi-hd,drive=hd1 \ 44 -drive file=/Users/pivotal/.unik/virtualbox/instances/VboxUnikInstanceListener/boot.vmdk,format=vmdk,if=none,id=hd1 \ 45 -device scsi-hd,drive=hd2 \ 46 -drive file=/Users/pivotal/.unik/virtualbox/volumes/InstanceListenerData/data.vmdk,format=vmdk,if=none,id=hd2 \ 47 -device virtio-net-pci,netdev=mynet0,mac=54:54:00:55:55:55 \ 48 -netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9 \ 49 -device virtio-net-pci,netdev=mynet1,mac=54:54:00:55:55:51 \ 50 -netdev user,id=mynet1,net=192.168.76.0/24,dhcpstart=192.168.76.9 \ 51 -m 512 52 ``` 53 54 qemu-system-x86_64 -device virtio-scsi-pci,id=scsi \ 55 -device scsi-hd,drive=hd1 \ 56 -drive file=/Users/pivotal/.unik/virtualbox/instances/warvbox/boot.vmdk,format=vmdk,if=none,id=hd1 \ 57 -device virtio-net-pci,netdev=mynet0,mac=54:54:00:55:55:55 \ 58 -netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9 \ 59 -device virtio-net-pci,netdev=mynet1,mac=54:54:00:55:55:51 \ 60 -netdev user,id=mynet1,net=192.168.76.0/24,dhcpstart=192.168.76.9 \ 61 -m 1024 62 63 64 For hard drivers, use the scsi drive like in the virtualbox example. 65 66 # To debug using gdb 67 68 add "-s -S" to qemu cmdline to enabled debugging. 69 70 Use our debugging container: 71 72 docker run --rm -ti --net="host" -v $PWD/:/opt/code:ro projectunik/debuggers-rump-base-hw 73 74 and then from inside the container: 75 76 /opt/gdb-7.11/gdb/gdb -ex 'target remote 192.168.99.1:1234' /opt/code/program.bin 77 78 qemu-system-x86_64 -m 512 -net nic,model=virtio,netdev=mynet0 -netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,hostfwd=tcp:127.0.0.1:8081-:8080 -device virtio-blk-pci,id=blk0,drive=hd0 -drive file=/Users/pivotal/.unik/qemu/images/rump-go-website/boot.img,format=qcow2,if=none,id=hd0 -kernel /Users/pivotal/.unik/qemu/images/rump-go-website/program.bin -append '{"rc":[{"bin":"program",,"argv":[]}],,"net":{"if":"vioif0",,"type":"inet",,"method":"dhcp"},,"blk": {"source":"dev",,"path":"/dev/ld0e",,"fstype":"blk",,"mountpoint":"/bootpart",,}}' 79 80 qemu-system-x86_64 -m 1712 -net nic,model=virtio,netdev=mynet0 -netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,hostfwd=tcp:127.0.0.1:8081-:8080 -device virtio-blk-pci,id=blk0,drive=hd0 -drive file=~/.unik/tmp/gcloud.raw.image.dir.277863076/disk.raw,format=raw,if=none,id=hd0 81 82 sudo qemu-system-x86_64 -nographic -vga none -m 1700 -net nic,model=virtio,netdev=mynet0 -netdev tap,id=mynet0,script=ifup,downscript=ifdown -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd0 -drive file=~/.unik/tmp/gcloud.raw.image.dir.277863076/disk.raw,format=raw,if=none,id=hd0 83