Debug - OS stacks - show current stack usage too

Change-Id: I41f895786e409c3f4ea500f99eb74cbd6cdbe5b6
This commit is contained in:
William Wilgus 2025-02-27 12:34:30 -05:00 committed by Solomon Peachy
parent c5d3468be6
commit 856da7f366
3 changed files with 10 additions and 4 deletions

View file

@ -152,7 +152,7 @@ static const char* threads_getname(int selected_item, void *data,
{
struct core_debug_info coreinfo;
core_get_debug_info(selected_item, &coreinfo);
snprintf(buffer, buffer_len, "Idle (%d): %2d%%", selected_item,
snprintf(buffer, buffer_len, "Idle (%2d): %2d%%", selected_item,
coreinfo.idle_stack_usage);
return buffer;
}
@ -165,8 +165,8 @@ static const char* threads_getname(int selected_item, void *data,
struct thread_debug_info threadinfo;
if (thread_get_debug_info(selected_item, &threadinfo) > 0)
{
fmtstr = "%2d:" IF_COP(" (%d)") " %s%n" IF_PRIO(" %d %d")
IFN_SDL(" %2d%%") " %s";
fmtstr = "%2d:" IF_COP(" (%d)") " %s%n" IF_PRIO(" %2d %2d")
IFN_SDL(" %2d%% %2d%%") " %s";
}
int status_len;
size_t len = snprintf(buffer, buffer_len, fmtstr,
@ -175,7 +175,7 @@ static const char* threads_getname(int selected_item, void *data,
threadinfo.statusstr,
&status_len,
IF_PRIO(threadinfo.base_priority, threadinfo.current_priority,)
IFN_SDL(threadinfo.stack_usage,)
IFN_SDL(threadinfo.stack_usage_cur, threadinfo.stack_usage,)
threadinfo.name);
int start = 0;

View file

@ -196,6 +196,7 @@ struct thread_debug_info
char statusstr[4];
char name[32];
#ifndef HAVE_SDL_THREADS
unsigned int stack_usage_cur;
unsigned int stack_usage;
#endif
#if NUM_CORES > 1

View file

@ -306,6 +306,11 @@ int thread_get_debug_info(unsigned int thread_id,
#endif
#ifndef HAVE_SDL_THREADS
infop->stack_usage = stack_usage(thread->stack, thread->stack_size);
size_t stack_used_current =
thread->stack_size - (thread->context.sp - (uintptr_t)thread->stack);
infop->stack_usage_cur = stack_used_current * 100 / thread->stack_size;
#endif
#if NUM_CORES > 1
infop->core = thread->core;