ClangBuiltLinux / boot-utils

Collection of files for booting Linux kernels
26 stars 7 forks source link

boot-qemu.sh: Add the ability to debug with GDB #5

Closed nathanchance closed 4 years ago

nathanchance commented 4 years ago

Adding '-s -S' stops the CPU and allows us to connect with GDB via 'target remote :1234'.

This implies '-i' so that the machine does not get killed in the middle of debugging.

nathanchance commented 4 years ago

Might be nice to:

  1. print a helpful message like "starting qemu debugging on port XYX\nUse:\ntarget remote :XYZ\nto connect`

Thanks for the suggestion, done! Let me know if it looks good to you before I merge it.

  1. move boot-qemu-help.txt to a README.md file, so that we show info in the github, too. All we do otherwise is cat it. Doesn't need to actually contain markdown.

thanks for the patch!

I will do this in a follow up PR once this has been merged since it is a good idea.

tpimh commented 4 years ago

print a helpful message like "starting qemu debugging on port XYX\nUse:\ntarget remote :XYZ\nto connect`

I wonder if it's good idea to actually start gdb from the script with appropriate commandline like gdb -ex "target remote :1234" vmlinux. This would mean that qemu would be running in the background which may not be what the user wants. Ideal solution would be to split the terminal with termux and run gdb and qemu side by side.

Doesn't need to actually contain markdown.

GitHub renders readme.txt just as well.

nathanchance commented 4 years ago

I wonder if it's good idea to actually start gdb from the script with appropriate commandline like gdb -ex "target remote :1234" vmlinux. This would mean that qemu would be running in the background which may not be what the user wants. Ideal solution would be to split the terminal with termux and run gdb and qemu side by side.

Yeah, as it currently stands the script will just "hang" after printing that message and the QEMU command via set -x so that the user can open up another tab or split their tmux window. That is what I have always done, I find sending QEMU to the background to be unreliable.

GitHub renders readme.txt just as well.

Good to know!

nickdesaulniers commented 4 years ago

I wonder if it's good idea to actually start gdb from the script with appropriate commandline like gdb -ex "target remote :1234" vmlinux

Oh! Yeah, that's great! I would love if it prompted me to restart if I quit gdb, too, since you can't restart a kernel image withing gdb AFAIK.