14-checkpoint: Program received signal SIGTRAP, Trace/breakpoint trap
When I set a breakpoint and continue, I get an error like the following,can anyone help me?

Having the exact same issue.
Are you using WSL2 on Windows? The problem only exists when trying to add breakpoint...
The test environment I use is ubuntu20.04
In my case, I solved the problem by using the new GDB.
-
Issue Description: My setup: WSL2 Ubuntu on Windows 11, with GUI support The kernel itself can run and print 'X'. But when adding breakpoint
b mainusing i386-system-gdb, it will stop at SIGTRAP and showing0x00000000 in ?? (), as shown by the previous image. My i386-system-gdb is a patched version trying to solve theRemote 'g' packet reply is too longissue. It is built different from the one provided in this repo; https://wiki.osdev.org/QEMU_and_GDB_in_long_mode I used solution 2. -
Analysis: This problem only occurs when adding breakpoint. Dumped memory shows memory data are correct. However GDB's registers
info regare not showing helpful values when having the SIGTRAP (and I cannot even change them using gdb). I assume this is because the GDB is broken ( or broken by the OSDev patch). -
Solution: Using Ubuntu's default gdb
sudo apt install gdbinstead of thei386-system-gdbin the makefile.
❯ gdb --version
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
And change make debug in Makefile:
# Open the connection to qemu and load our kernel-object file with symbols
debug: os-image.bin kernel.elf
qemu-system-i386 -s -fda os-image.bin -S &
# ${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
gdb -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
which replaced ${GDB} with the new default gdb. Also added -S to halt the QEMU before booting. You can also change gdb=gdb, it's the same.
Thanks, @aea5, for your answer. I have the same problem on ubuntu 22.04 as @MyCodeMyMoney has. Add '-S' it is enough to resolve that