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

14-checkpoint: Program received signal SIGTRAP, Trace/breakpoint trap #246

Open
MyCodeMyMoney opened this issue May 23, 2022 · 4 comments
Open

Comments

@MyCodeMyMoney
Copy link

When I set a breakpoint and continue, I get an error like the following,can anyone help me?
image

@aea5
Copy link

aea5 commented Jun 20, 2022

Having the exact same issue.

Are you using WSL2 on Windows? The problem only exists when trying to add breakpoint...

@MyCodeMyMoney
Copy link
Author

The test environment I use is ubuntu20.04

@aea5
Copy link

aea5 commented Jun 21, 2022

In my case, I solved the problem by using the new GDB.

  1. 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 main using i386-system-gdb, it will stop at SIGTRAP and showing 0x00000000 in ?? (), as shown by the previous image.
    My i386-system-gdb is a patched version trying to solve the Remote 'g' packet reply is too long issue. 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.

  2. Analysis:
    This problem only occurs when adding breakpoint. Dumped memory shows memory data are correct. However GDB's registers info reg are 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).

  3. Solution:
    Using Ubuntu's default gdb sudo apt install gdb instead of the i386-system-gdb in 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.

@arashandishgar
Copy link

arashandishgar commented Nov 3, 2022

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

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

No branches or pull requests

3 participants