1
0
Fork 0
forked from len0rd/rockbox

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

View file

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

View file

@ -306,6 +306,11 @@ int thread_get_debug_info(unsigned int thread_id,
#endif #endif
#ifndef HAVE_SDL_THREADS #ifndef HAVE_SDL_THREADS
infop->stack_usage = stack_usage(thread->stack, thread->stack_size); 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 #endif
#if NUM_CORES > 1 #if NUM_CORES > 1
infop->core = thread->core; infop->core = thread->core;