From 18c5b349236ea4a3ae9b5eb31f764646e4b049f5 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Wed, 8 Feb 2023 20:22:54 +0000 Subject: [PATCH] build: create copy of kernel binary with debug symbols --- Makefile | 2 ++ tools/kernel-debug/debug_session.sh | 3 ++- tools/kernel-debug/gdb_session_init | 2 +- tools/kernel-debug/lldb_session_init | 2 +- tools/make/gcc-cross-compile.mk | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 30b5219..8c84485 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,8 @@ $(BUILD_DIR)/$(KERNEL_EXEC): $(ALL_KERNEL_OBJECT_FILES) @printf " \033[1;36mLD\033[0m \033[1mbuild/\033[35m$(KERNEL_EXEC)\033[0m\n" @mkdir -p $(@D) @$(LD) $^ -o $@ $(LDFLAGS) $(ARCH_LDFLAGS) + @cp $@ $@.dbg + @$(STRIP) $@ $(BUILD_DIR)/%.o: %.S @printf " \033[1;32mAS\033[0m \033[35m$(KERNEL_EXEC)\033[0m/$<\n" diff --git a/tools/kernel-debug/debug_session.sh b/tools/kernel-debug/debug_session.sh index cf4c9ad..5e2ec45 100755 --- a/tools/kernel-debug/debug_session.sh +++ b/tools/kernel-debug/debug_session.sh @@ -10,7 +10,8 @@ if command -v gdb &> /dev/null; then new-session -d -s hz-debug "sleep 0.3; gdb -tui -x $gdb_cfg" \; \ split-window -h -l 80 \; \ split-window -v -l 25 "$@"\; \ - select-pane -t 0 + select-pane -t 0 \; \ + resize-pane -R 20 elif command -v lldb &> /dev/null; then printf " \033[93;1mLLDB\033[0m boot/socks_kernel\n" tmux \ diff --git a/tools/kernel-debug/gdb_session_init b/tools/kernel-debug/gdb_session_init index 0481960..3a27743 100644 --- a/tools/kernel-debug/gdb_session_init +++ b/tools/kernel-debug/gdb_session_init @@ -1,4 +1,4 @@ set confirm off -symbol-file build/socks_kernel +symbol-file build/socks_kernel.dbg target remote localhost:1234 set confirm on diff --git a/tools/kernel-debug/lldb_session_init b/tools/kernel-debug/lldb_session_init index 0a275e8..c49964e 100644 --- a/tools/kernel-debug/lldb_session_init +++ b/tools/kernel-debug/lldb_session_init @@ -1,2 +1,2 @@ -file build/socks_kernel +file build/socks_kernel.dbg gdb-remote localhost:1234 diff --git a/tools/make/gcc-cross-compile.mk b/tools/make/gcc-cross-compile.mk index 9dc8b30..d24eba1 100644 --- a/tools/make/gcc-cross-compile.mk +++ b/tools/make/gcc-cross-compile.mk @@ -1,6 +1,8 @@ LD := $(ARCH)-elf-gcc CC := $(ARCH)-elf-gcc ASM := $(ARCH)-elf-gcc +OBJCOPY := $(ARCH)-elf-objcopy +STRIP := $(ARCH)-elf-strip CFLAGS := -ffreestanding -nostdlib ASMFLAGS := $(CFLAGS)