diff --git a/README.adoc b/README.adoc index ef997c9..38346d1 100644 --- a/README.adoc +++ b/README.adoc @@ -3326,11 +3326,11 @@ qemu-arm -g 1234 -L . bin/ls TODO: find source. Lazy now. -=== Debug QEMU +=== Debug the emulator -When you start interacting with QEMU hardware, it is useful to see what is going on inside of QEMU itself. +When you start hacking QEMU or gem5, it is useful to see what is going on inside the emulator themselves. -This is of course trivial since QEMU is just an userland program on the host, but we make it a bit easier with: +This is of course trivial since they are just regular userland programs on the host, but we make it a bit easier with: .... ./run -D @@ -3349,7 +3349,13 @@ And in QEMU: /pci.sh .... -Just make sure that you never click inside the QEMU window when doing that, otherwise you mouse gets captured forever, and the only solution I can find is to go to a TTY with `Ctrl-Alt-F1` and `kill` QEMU. +When in <>, using `-D` makes Ctrl-C not get passed to the QEMU guest anymore: it is instead captured by GDB itself, so allow breaking. So e.g. you won't be able to easily quit from a guest progra like: + +.... +sleep 10 +.... + +In graphic mode, make sure that you never click inside the QEMU graphic while debugging, otherwise you mouse gets captured forever, and the only solution I can find is to go to a TTY with `Ctrl-Alt-F1` and `kill` QEMU. You can still send key presses to QEMU however even without the mouse capture, just either click on the title bar, or alt tab to give it focus. diff --git a/run b/run index fde1a32..de9d406 100755 --- a/run +++ b/run @@ -195,6 +195,12 @@ ${extra_flags} \ " fi else + if [ -z "$debug_vm" ]; then + serial_monitor='-serial mon:stdio \ +' + else + serial_monitor= + fi if "$kvm"; then extra_flags="${extra_flags} -enable-kvm" fi @@ -205,9 +211,9 @@ ${debug_vm} \ -device rtl8139,netdev=net0 \\ -gdb tcp::1234 \\ -m '${memory}' \\ --serial mon:stdio \\ -monitor telnet::45454,server,nowait \\ -netdev user,hostfwd=tcp::45455-:45455,hostfwd=tcp::45456-:22,id=net0 \\ +${serial_monitor} \ -smp '${cpus}' \\ -trace 'enable=${trace_type},file=${qemu_out_dir}/trace.bin' \\ -virtfs 'local,path=${p9_dir},mount_tag=host_scratch,security_model=mapped,id=host_scratch' \\