From: Brendan Hansen Date: Mon, 6 Nov 2023 04:18:52 +0000 (-0600) Subject: added: `MEMDEBUG` configuration option X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=b4f7ca54892b32cdd608b2ca2d51736b1d5fd737;p=onyx.git added: `MEMDEBUG` configuration option --- diff --git a/core/alloc/memdebug.onyx b/core/alloc/memdebug.onyx index c700d5f3..fa64e967 100644 --- a/core/alloc/memdebug.onyx +++ b/core/alloc/memdebug.onyx @@ -23,6 +23,7 @@ MemDebugState :: struct { MemDebugMsg :: union { Start: struct { version: u32; + heap_base_address: u32; }; Action: struct { @@ -67,7 +68,7 @@ wait_for_connection :: (m: &MemDebugState) -> Result(void, io.Error) { m.socket = .{ Some = result.socket }; m.writer = .{ Some = io.writer_make(m.socket->unwrap_ptr(), 0) }; - memdebug_send_message(m, .{ Start = .{ version = VERSION } }); + memdebug_send_message(m, .{ Start = .{ version = VERSION, heap_base_address = cast(u32) __heap_start } }); } enable_in_scope :: macro (a: Allocator, port := DEFAULT_PORT) { diff --git a/core/runtime/platform/onyx/platform.onyx b/core/runtime/platform/onyx/platform.onyx index 4c50afa8..09d187eb 100644 --- a/core/runtime/platform/onyx/platform.onyx +++ b/core/runtime/platform/onyx/platform.onyx @@ -127,6 +127,10 @@ __start :: () { __runtime_initialize(); context.thread_id = 0; + #if #defined(runtime.vars.MEMDEBUG) { + use core.alloc.memdebug + memdebug.enable_in_scope(context.allocator); + } #if (typeof MAIN_FUNCTION) == #type () -> void { // An error on this line means no 'main.main' was found in your program. MAIN_FUNCTION();