From 981d028c09d10ed867f2f955f58d60b753c64f29 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 8 Aug 2014 01:39:29 -0400 Subject: Do some kernel cleanup * Seal away private thread and kernel definitions and declarations into the internal headers in order to better hide internal structure. * Add a thread-common.c file that keeps shared functions together. List functions aren't messed with since that's about to be changed to different ones. * It is necessary to modify some ARM/PP stuff since GCC was complaining about constant pool distance and I would rather not force dump it. Just bl the cache calls in the startup and exit code and let it use veneers if it must. * Clean up redundant #includes in relevant areas and reorganize them. * Expunge useless and dangerous stuff like remove_thread(). Change-Id: I6e22932fad61a9fac30fd1363c071074ee7ab382 --- apps/debug_menu.c | 68 ++++++++++++------------------------------------------- 1 file changed, 15 insertions(+), 53 deletions(-) (limited to 'apps/debug_menu.c') diff --git a/apps/debug_menu.c b/apps/debug_menu.c index bc2a73fc9c..a11cff9350 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -133,69 +133,44 @@ #include "talk.h" -/*---------------------------------------------------*/ -/* SPECIAL DEBUG STUFF */ -/*---------------------------------------------------*/ -extern struct thread_entry threads[MAXTHREADS]; - -static char thread_status_char(unsigned status) -{ - static const char thread_status_chars[THREAD_NUM_STATES+1] = - { - [0 ... THREAD_NUM_STATES] = '?', - [STATE_RUNNING] = 'R', - [STATE_BLOCKED] = 'B', - [STATE_SLEEPING] = 'S', - [STATE_BLOCKED_W_TMO] = 'T', - [STATE_FROZEN] = 'F', - [STATE_KILLED] = 'K', - }; - - if (status > THREAD_NUM_STATES) - status = THREAD_NUM_STATES; - - return thread_status_chars[status]; -} - static const char* threads_getname(int selected_item, void *data, char *buffer, size_t buffer_len) { (void)data; - struct thread_entry *thread; - char name[32]; #if NUM_CORES > 1 if (selected_item < (int)NUM_CORES) { + struct core_debug_info coreinfo; + core_get_debug_info(selected_item, &coreinfo); snprintf(buffer, buffer_len, "Idle (%d): %2d%%", selected_item, - idle_stack_usage(selected_item)); + coreinfo.idle_stack_usage); return buffer; } selected_item -= NUM_CORES; #endif - thread = &threads[selected_item]; - - if (thread->state == STATE_KILLED) + struct thread_debug_info threadinfo; + if (thread_get_debug_info(selected_item, &threadinfo) <= 0) { snprintf(buffer, buffer_len, "%2d: ---", selected_item); return buffer; } - thread_get_name(name, 32, thread); - snprintf(buffer, buffer_len, - "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s", + "%2d: " IF_COP("(%d) ") "%s " IF_PRIO("%d %d ") "%2d%% %s", selected_item, - IF_COP(thread->core,) -#ifdef HAVE_SCHEDULER_BOOSTCTRL - (thread->cpu_boost) ? '+' : +#if NUM_CORES > 1 + threadinfo.core, +#endif + threadinfo.statusstr, +#ifdef HAVE_PRIORITY_SCHEDULING + threadinfo.base_priority, + threadinfo.current_priority, #endif - ((thread->state == STATE_RUNNING) ? '*' : ' '), - thread_status_char(thread->state), - IF_PRIO(thread->base_priority, thread->priority, ) - thread_stack_usage(thread), name); + threadinfo.stack_usage, + threadinfo.name); return buffer; } @@ -203,19 +178,6 @@ static const char* threads_getname(int selected_item, void *data, static int dbg_threads_action_callback(int action, struct gui_synclist *lists) { (void)lists; -#ifdef ROCKBOX_HAS_LOGF - if (action == ACTION_STD_OK) - { - int selpos = gui_synclist_get_sel_pos(lists); -#if NUM_CORES > 1 - if (selpos >= NUM_CORES) - remove_thread(threads[selpos - NUM_CORES].id); -#else - remove_thread(threads[selpos].id); -#endif - return ACTION_REDRAW; - } -#endif /* ROCKBOX_HAS_LOGF */ if (action == ACTION_NONE) action = ACTION_REDRAW; return action; -- cgit v1.2.3