Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

nathanchance
Copy link
Member

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.

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.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Copy link
Member

@nickdesaulniers nickdesaulniers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to:

  1. print a helpful message like "starting qemu debugging on port XYX\nUse:\ntarget remote :XYZ\nto connect`
  2. 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!

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
@nathanchance
Copy link
Member Author

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
Copy link

tpimh commented Apr 23, 2020

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
Copy link
Member Author

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!

Copy link
Member

@nickdesaulniers nickdesaulniers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@nathanchance nathanchance merged commit 991a6d3 into ClangBuiltLinux:master Apr 23, 2020
@nickdesaulniers
Copy link
Member

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.

@nathanchance nathanchance deleted the gdb branch April 23, 2020 05:52
echo "to connect"
echo
printf '\033[0m'
QEMU=( "${QEMU[@]}" -s -S )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm playing with this now; does this just fallthrough and execute qemu below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see, it sets the arg, then executes below. got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants