From 3fcdb85ebf83c3f871befd8e7f634f3155b2cfcb Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 22 May 2025 09:34:47 -0700 Subject: [PATCH] use tid/pid-specifying spall functions --- src/base/base_profile.c | 10 +++++++++- src/base/base_profile.h | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/base/base_profile.c b/src/base/base_profile.c index 03a8d523..b04daee5 100644 --- a/src/base/base_profile.c +++ b/src/base/base_profile.c @@ -5,11 +5,19 @@ internal inline void spall_begin(char *fmt, ...) { + if(spall_pid == 0) + { + spall_pid = os_get_process_info()->pid; + } + if(spall_tid == 0) + { + spall_tid = os_tid(); + } Temp scratch = scratch_begin(0, 0); va_list args; va_start(args, fmt); String8 string = push_str8fv(scratch.arena, fmt, args); - spall_buffer_begin(&spall_profile, &spall_buffer, string.str, string.size, os_now_microseconds()); + spall_buffer_begin_ex(&spall_profile, &spall_buffer, string.str, string.size, os_now_microseconds(), spall_tid, spall_pid); va_end(args); scratch_end(scratch); } diff --git a/src/base/base_profile.h b/src/base/base_profile.h index 3981e365..a0013659 100644 --- a/src/base/base_profile.h +++ b/src/base/base_profile.h @@ -73,10 +73,12 @@ scratch_end(scratch); \ global U64 spall_capturing = 1; global SpallProfile spall_profile = {0}; thread_static SpallBuffer spall_buffer = {0}; +thread_static U32 spall_tid = 0; +thread_static U32 spall_pid = 0; internal inline void spall_begin(char *fmt, ...); # define ProfBegin(...) (spall_capturing ? (spall_begin(__VA_ARGS__), 0) : 0) # define ProfBeginDynamic(...) (spall_capturing ? (spall_begin(__VA_ARGS__), 0) : 0) -# define ProfEnd(...) (spall_capturing ? (spall_buffer_end(&spall_profile, &spall_buffer, os_now_microseconds())), 0 : 0) +# define ProfEnd(...) (spall_capturing ? (spall_buffer_end_ex(&spall_profile, &spall_buffer, os_now_microseconds(), spall_tid, spall_pid)), 0 : 0) # define ProfTick(...) # define ProfIsCapturing(...) (!!spall_capturing) # define ProfBeginCapture(...) (spall_capturing = 1)