diff options
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 40c0fcc9b0..15c2c93d62 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -180,7 +180,6 @@ static bool dbg_list(struct action_callback_info *info) | |||
180 | /*---------------------------------------------------*/ | 180 | /*---------------------------------------------------*/ |
181 | extern struct thread_entry threads[MAXTHREADS]; | 181 | extern struct thread_entry threads[MAXTHREADS]; |
182 | 182 | ||
183 | |||
184 | static char thread_status_char(int status) | 183 | static char thread_status_char(int status) |
185 | { | 184 | { |
186 | switch (status) | 185 | switch (status) |
@@ -193,42 +192,48 @@ static char thread_status_char(int status) | |||
193 | 192 | ||
194 | return '?'; | 193 | return '?'; |
195 | } | 194 | } |
196 | #if NUM_CORES > 1 | 195 | |
197 | #define IF_COP2(...) __VA_ARGS__ | ||
198 | #else | ||
199 | #define IF_COP2(...) | ||
200 | #endif | ||
201 | static char* threads_getname(int selected_item, void * data, char *buffer) | 196 | static char* threads_getname(int selected_item, void * data, char *buffer) |
202 | { | 197 | { |
203 | (void)data; | 198 | (void)data; |
199 | char name[32]; | ||
204 | struct thread_entry *thread = NULL; | 200 | struct thread_entry *thread = NULL; |
205 | int status, usage; | 201 | unsigned status; |
202 | int usage; | ||
203 | |||
204 | #if NUM_CORES > 1 | ||
205 | if (selected_item < (int)NUM_CORES) | ||
206 | { | ||
207 | usage = idle_stack_usage(selected_item); | ||
208 | snprintf(buffer, MAX_PATH, "Idle (%d): %2d%%", selected_item, usage); | ||
209 | return buffer; | ||
210 | } | ||
211 | |||
212 | selected_item -= NUM_CORES; | ||
213 | #endif | ||
214 | |||
206 | thread = &threads[selected_item]; | 215 | thread = &threads[selected_item]; |
216 | status = thread_get_status(thread); | ||
207 | 217 | ||
208 | if (thread->name == NULL) | 218 | if (thread->name == NULL) |
209 | { | 219 | { |
210 | snprintf(buffer, MAX_PATH, "%2d: ---", selected_item); | 220 | snprintf(buffer, MAX_PATH, "%2d: ---", selected_item); |
211 | return buffer; | 221 | return buffer; |
212 | } | 222 | } |
213 | 223 | ||
224 | thread_get_name(name, 32, thread); | ||
214 | usage = thread_stack_usage(thread); | 225 | usage = thread_stack_usage(thread); |
215 | status = thread_get_status(thread); | 226 | status = thread_get_status(thread); |
216 | #ifdef HAVE_PRIORITY_SCHEDULING | 227 | |
217 | snprintf(buffer, MAX_PATH, "%2d: " IF_COP2("(%d) ") "%c%c %d %2d%% %s", | 228 | snprintf(buffer, MAX_PATH, |
218 | selected_item, | 229 | "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s", |
219 | IF_COP2(thread->core,) | ||
220 | (status == STATE_RUNNING) ? '*' : ' ', | ||
221 | thread_status_char(status), | ||
222 | thread->priority, | ||
223 | usage, thread->name); | ||
224 | #else | ||
225 | snprintf(buffer, MAX_PATH, "%2d: " IF_COP2("(%d) ") "%c%c %2d%% %s", | ||
226 | selected_item, | 230 | selected_item, |
227 | IF_COP2(thread->core,) | 231 | IF_COP(thread->core,) |
228 | (status == STATE_RUNNING) ? '*' : ' ', | 232 | (status == STATE_RUNNING) ? '*' : ' ', |
229 | thread_status_char(status), | 233 | thread_status_char(status), |
230 | usage, thread->name); | 234 | IF_PRIO(thread->priority,) |
231 | #endif | 235 | usage, name); |
236 | |||
232 | return buffer; | 237 | return buffer; |
233 | } | 238 | } |
234 | static int dbg_threads_action_callback(int action, struct action_callback_info *info) | 239 | static int dbg_threads_action_callback(int action, struct action_callback_info *info) |
@@ -236,11 +241,16 @@ static int dbg_threads_action_callback(int action, struct action_callback_info * | |||
236 | #ifdef ROCKBOX_HAS_LOGF | 241 | #ifdef ROCKBOX_HAS_LOGF |
237 | if (action == ACTION_STD_OK) | 242 | if (action == ACTION_STD_OK) |
238 | { | 243 | { |
239 | struct thread_entry *thread = &threads[gui_synclist_get_sel_pos(info->lists)]; | 244 | int selpos = gui_synclist_get_sel_pos(info->lists); |
240 | if (thread->name != NULL) | 245 | #if NUM_CORES > 1 |
241 | remove_thread(thread); | 246 | if (selpos >= NUM_CORES) |
242 | } | 247 | remove_thread(&threads[selpos - NUM_CORES]); |
248 | #else | ||
249 | remove_thread(&threads[selpos]); | ||
243 | #endif | 250 | #endif |
251 | } | ||
252 | gui_synclist_hide_selection_marker(info->lists, false); | ||
253 | #endif /* ROCKBOX_HAS_LOGF */ | ||
244 | gui_synclist_draw(info->lists); | 254 | gui_synclist_draw(info->lists); |
245 | return action; | 255 | return action; |
246 | } | 256 | } |
@@ -248,8 +258,12 @@ static int dbg_threads_action_callback(int action, struct action_callback_info * | |||
248 | static bool dbg_os(void) | 258 | static bool dbg_os(void) |
249 | { | 259 | { |
250 | struct action_callback_info info; | 260 | struct action_callback_info info; |
251 | info.title = IF_COP2("Core and ") "Stack usage:"; | 261 | info.title = IF_COP("Core and ") "Stack usage:"; |
262 | #if NUM_CORES == 1 | ||
252 | info.count = MAXTHREADS; | 263 | info.count = MAXTHREADS; |
264 | #else | ||
265 | info.count = MAXTHREADS+NUM_CORES; | ||
266 | #endif | ||
253 | info.selection_size = 1; | 267 | info.selection_size = 1; |
254 | info.action_callback = dbg_threads_action_callback; | 268 | info.action_callback = dbg_threads_action_callback; |
255 | info.dbg_getname = threads_getname; | 269 | info.dbg_getname = threads_getname; |