debug symbols are expected in .debug file

This commit is contained in:
Mathieu Maret 2023-11-09 23:38:20 +01:00
parent 18ea283213
commit 4376201d32
2 changed files with 10 additions and 5 deletions

View File

@ -29,11 +29,11 @@ deps=$(csrc:%.c=%.d) $(gasmsrc:%.S=%.d)
docsrc=$(wildcard docs/*.md) docsrc=$(wildcard docs/*.md)
docobj=$(docsrc:%.md=%.html) docobj=$(docsrc:%.md=%.html)
kernel kernel.sym &: $(asmobj) $(gasmobj) $(cobj) linker.ld kernel kernel.debug &: $(asmobj) $(gasmobj) $(cobj) linker.ld
$(LD) $(LDFLAGS) $(asmobj) $(gasmobj) $(cobj) -o kernel -T linker.ld $(LIBGCC) -Map kernel.map $(LD) $(LDFLAGS) $(asmobj) $(gasmobj) $(cobj) -o kernel -T linker.ld $(LIBGCC) -Map kernel.map
objcopy --only-keep-debug kernel kernel.sym objcopy --only-keep-debug kernel kernel.debug
objcopy --strip-debug kernel objcopy --strip-debug kernel
objcopy --add-gnu-debuglink=kernel.sym kernel objcopy --add-gnu-debuglink=kernel.debug kernel
fd.iso: kernel fd.iso: kernel
mkdir -p isodir/boot/grub mkdir -p isodir/boot/grub
@ -90,7 +90,7 @@ run:kernel disk.img ## Run the OS on qemu
debug: CFLAGS += $(DEBUG_FLAGS) ## Run the OS on qemu and attach a debugger to it (may need a clean befor to have the debug symbols) debug: CFLAGS += $(DEBUG_FLAGS) ## Run the OS on qemu and attach a debugger to it (may need a clean befor to have the debug symbols)
debug: CXXFLAGS += $(DEBUG_FLAGS) debug: CXXFLAGS += $(DEBUG_FLAGS)
debug:kernel kernel.sym disk.img debug:kernel kernel.debug disk.img
gdb -q -x debug.gdb gdb -q -x debug.gdb
debug_test: CFLAGS += $(DEBUG_FLAGS) -DRUN_TEST debug_test: CFLAGS += $(DEBUG_FLAGS) -DRUN_TEST
@ -100,7 +100,7 @@ screenshot:
shutter --window=qemu -o screenshot_1.png -e && zopflipng screenshot_1.png screenshot_1.png shutter --window=qemu -o screenshot_1.png -e && zopflipng screenshot_1.png screenshot_1.png
clean: clean:
$(RM) kernel $(asmobj) $(gasmobj) $(cobj) $(deps) $(cinc) fd.iso kernel.sym kernel.map $(docobj) $(RM) kernel $(asmobj) $(gasmobj) $(cobj) $(deps) $(cinc) fd.iso kernel.debug kernel.map $(docobj)
$(RM) -r isodir $(RM) -r isodir
.PHONY: .PHONY:

View File

@ -1,4 +1,9 @@
add-symbol-file userspace/user add-symbol-file userspace/user
# Thx to add-gnu-debuglink gdb should know that symbols are in kernel.debug.
# And by default, it should be looking at executable.debug
# But we still have to give him the executable he is suppose to debug (See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Separate-Debug-Files.html)
#add-symbol-file kernel.debug
file kernel
source custom_gdb_extension.py source custom_gdb_extension.py
#For ASM sources #For ASM sources
directory arch/x86/:core directory arch/x86/:core