inpyjama / c-ninja-listings

Lower level assembly and C baremetal programming on RISC-V CPUs. Source code listings from the C-Ninja, in Pyjama! book.
https://inpyjama.com
96 stars 481 forks source link

Issue in make debug #8

Closed gnaneshraj14 closed 1 year ago

gnaneshraj14 commented 1 year ago
issue_exit_debug

may be I failed to exit debug or don't understand what happend not able to make debug now.

gnaneshraj14 commented 1 year ago

BTW I am on windows platform. The first time is entered make debug it was connected to port. Then as usual I opened new terminal and used the gdb and then quit it from the same terminal. But on the previous one where it was connected to port did exit. any suggestions on how to exit it on windows?

gnaneshraj14 commented 1 year ago

There is a big problem related to using GDB on windows machine. When we do make debug on Terminal1 and then make gdb on Terminal 2, after using GDB in terminal 2 we execute quit command. Then the debug process should be terminated and then in terminal 1 with the command ctrl+c should work to terminate make debug but it doesn’t happen so. If we try to kill the process of qemu by other processes it will crash and with next instance of opening Docker fails it reports error. And now Docker should be uninstalled and reinstalled to run all the process again. This certainly not good way to do. Can you please suggest what can be done here to end the make debug on Terminal 1 without any issues.

streetdogg commented 1 year ago

@ gnaneshraj14: Thank you for reporting the issue! Can I request you to try the following?

Then the debug process should be terminated and then in terminal 1 with the command ctrl+c should work to terminate make debug but it doesn’t happen so.

Use ctrl+a followed by x key to exit the qemu gracefully. You should the prints as below:

c-ninja@c-ninja-linux ~/Documents/test
 % make debug
qemu-system-riscv32 -S -M virt -nographic -bios none -kernel main.elf -gdb tcp::1234
QEMU: Terminated

Exiting QEMU correctly will ensure that the 1234 port is freed up to be used in the follow-up launches. Once we are in the docker container environment the underlying platform (mac, windows, linux etc) should not be a problem.

Please let me know if this helped :)

gnaneshraj14 commented 1 year ago

@streetdogg It did work thank you for your suggestions.