From 4376201d32a2926251fa1bdf72253431dc43af5a Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Thu, 9 Nov 2023 23:38:20 +0100 Subject: [PATCH] debug symbols are expected in .debug file --- Makefile | 10 +++++----- debug.gdb | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3dbb44d..48215c5 100644 --- a/Makefile +++ b/Makefile @@ -29,11 +29,11 @@ deps=$(csrc:%.c=%.d) $(gasmsrc:%.S=%.d) docsrc=$(wildcard docs/*.md) 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 - objcopy --only-keep-debug kernel kernel.sym + objcopy --only-keep-debug kernel kernel.debug objcopy --strip-debug kernel - objcopy --add-gnu-debuglink=kernel.sym kernel + objcopy --add-gnu-debuglink=kernel.debug kernel fd.iso: kernel 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: CXXFLAGS += $(DEBUG_FLAGS) -debug:kernel kernel.sym disk.img +debug:kernel kernel.debug disk.img gdb -q -x debug.gdb 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 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 .PHONY: diff --git a/debug.gdb b/debug.gdb index c6e54ae..167a4e6 100644 --- a/debug.gdb +++ b/debug.gdb @@ -1,4 +1,9 @@ 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 #For ASM sources directory arch/x86/:core