From 687e8ec101083b7d65f993abe2dddabb4d24024a Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Sat, 20 Jul 2024 18:18:35 +0000 Subject: [PATCH] adding debug symbols option --- Makefile | 5 ++++- build.zig | 6 ++++-- linker.ld | 15 --------------- sources/drivers/vga/vga.zig | 1 + 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 39934d2..c5c6ea6 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ all : @zig build +debug: + @zig build -Ddebug=true + run : fclean @zig build run run-debug : fclean - @zig build run-debug + @zig build run-debug -Ddebug=true clean: diff --git a/build.zig b/build.zig index b3d8217..aa4db96 100644 --- a/build.zig +++ b/build.zig @@ -2,16 +2,18 @@ const std = @import("std"); pub fn build(b: *std.Build) void { + const debug_symbols = b.option(bool, "debug", "Add debug symbols") orelse false; + const kernel = b.addExecutable(.{ .name = "kernel.elf", .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "sources/kernel/kmain.zig" } }, .target = b.resolveTargetQuery(.{ .cpu_arch = .x86, - .abi = .gnu, + .abi = .none, .os_tag = .freestanding, }), .optimize = .Debug, - //.strip = true, + .strip = !debug_symbols, .code_model = .kernel, .pic = false, }); diff --git a/linker.ld b/linker.ld index dba4aff..4e9e314 100644 --- a/linker.ld +++ b/linker.ld @@ -13,21 +13,6 @@ SECTIONS .rodata : ALIGN(4K) { *(.rodata) - __debug_info_start = .; - KEEP(*(.debug_info)) - __debug_info_end = .; - __debug_abbrev_start = .; - KEEP(*(.debug_abbrev)) - __debug_abbrev_end = .; - __debug_str_start = .; - KEEP(*(.debug_str)) - __debug_str_end = .; - __debug_line_start = .; - KEEP(*(.debug_line)) - __debug_line_end = .; - __debug_ranges_start = .; - KEEP(*(.debug_ranges)) - __debug_ranges_end = .; } .data : ALIGN(4K) diff --git a/sources/drivers/vga/vga.zig b/sources/drivers/vga/vga.zig index 97ae35c..fed98d5 100644 --- a/sources/drivers/vga/vga.zig +++ b/sources/drivers/vga/vga.zig @@ -153,6 +153,7 @@ pub fn init(title : []const u8, title_color : u8, navbar_color : u8, triggered_c updateCursor(); updateNavbar(); kernel.logs.klogln("[VGA Driver] loaded"); + kernel.stk.stackTrace(42); } fn putEntry(c: u8, color: u8, x: usize, y: usize) void