diff options
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index b3b6fe3eca..0dec961f3f 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -125,6 +125,8 @@ static char* dbg_listmessage_getname(int item, void * data, char *buffer) | |||
125 | #endif | 125 | #endif |
126 | 126 | ||
127 | struct action_callback_info; | 127 | struct action_callback_info; |
128 | #define DBGLIST_SHOW_SELECTION 0x1 | ||
129 | |||
128 | struct action_callback_info | 130 | struct action_callback_info |
129 | { | 131 | { |
130 | char *title; | 132 | char *title; |
@@ -137,6 +139,7 @@ struct action_callback_info | |||
137 | }; | 139 | }; |
138 | 140 | ||
139 | static char* dbg_menu_getname(int item, void * data, char *buffer); | 141 | static char* dbg_menu_getname(int item, void * data, char *buffer); |
142 | static char* threads_getname(int selected_item, void * data, char *buffer); | ||
140 | static bool dbg_list(struct action_callback_info *info) | 143 | static bool dbg_list(struct action_callback_info *info) |
141 | { | 144 | { |
142 | struct gui_synclist lists; | 145 | struct gui_synclist lists; |
@@ -149,8 +152,7 @@ static bool dbg_list(struct action_callback_info *info) | |||
149 | gui_synclist_set_title(&lists, info->title, NOICON); | 152 | gui_synclist_set_title(&lists, info->title, NOICON); |
150 | gui_synclist_set_icon_callback(&lists, NULL); | 153 | gui_synclist_set_icon_callback(&lists, NULL); |
151 | gui_synclist_set_nb_items(&lists, info->count*info->selection_size); | 154 | gui_synclist_set_nb_items(&lists, info->count*info->selection_size); |
152 | if (info->dbg_getname != dbg_menu_getname) | 155 | gui_synclist_hide_selection_marker(&lists, true); |
153 | gui_synclist_hide_selection_marker(&lists, true); | ||
154 | 156 | ||
155 | if (info->action_callback) | 157 | if (info->action_callback) |
156 | info->action_callback(ACTION_REDRAW, info); | 158 | info->action_callback(ACTION_REDRAW, info); |
@@ -179,17 +181,28 @@ static bool dbg_list(struct action_callback_info *info) | |||
179 | /*---------------------------------------------------*/ | 181 | /*---------------------------------------------------*/ |
180 | extern struct thread_entry threads[MAXTHREADS]; | 182 | extern struct thread_entry threads[MAXTHREADS]; |
181 | 183 | ||
182 | static char thread_status_char(int status) | 184 | static char thread_status_char(unsigned status) |
183 | { | 185 | { |
184 | switch (status) | 186 | static const char thread_status_chars[THREAD_NUM_STATES+1] = |
185 | { | 187 | { |
186 | case STATE_RUNNING : return 'R'; | 188 | [0 ... THREAD_NUM_STATES] = '?', |
187 | case STATE_BLOCKED : return 'B'; | 189 | [STATE_RUNNING] = 'R', |
188 | case STATE_SLEEPING : return 'S'; | 190 | [STATE_BLOCKED] = 'B', |
189 | case STATE_BLOCKED_W_TMO: return 'T'; | 191 | [STATE_SLEEPING] = 'S', |
190 | } | 192 | [STATE_BLOCKED_W_TMO] = 'T', |
193 | [STATE_FROZEN] = 'F', | ||
194 | [STATE_KILLED] = 'K', | ||
195 | }; | ||
191 | 196 | ||
192 | return '?'; | 197 | #if NUM_CORES > 1 |
198 | if (status == STATE_BUSY) /* Not a state index */ | ||
199 | return '.'; | ||
200 | #endif | ||
201 | |||
202 | if (status > THREAD_NUM_STATES) | ||
203 | status = THREAD_NUM_STATES; | ||
204 | |||
205 | return thread_status_chars[status]; | ||
193 | } | 206 | } |
194 | 207 | ||
195 | static char* threads_getname(int selected_item, void * data, char *buffer) | 208 | static char* threads_getname(int selected_item, void * data, char *buffer) |
@@ -214,7 +227,7 @@ static char* threads_getname(int selected_item, void * data, char *buffer) | |||
214 | thread = &threads[selected_item]; | 227 | thread = &threads[selected_item]; |
215 | status = thread_get_status(thread); | 228 | status = thread_get_status(thread); |
216 | 229 | ||
217 | if (thread->name == NULL) | 230 | if (status == STATE_KILLED) |
218 | { | 231 | { |
219 | snprintf(buffer, MAX_PATH, "%2d: ---", selected_item); | 232 | snprintf(buffer, MAX_PATH, "%2d: ---", selected_item); |
220 | return buffer; | 233 | return buffer; |
@@ -222,7 +235,6 @@ static char* threads_getname(int selected_item, void * data, char *buffer) | |||
222 | 235 | ||
223 | thread_get_name(name, 32, thread); | 236 | thread_get_name(name, 32, thread); |
224 | usage = thread_stack_usage(thread); | 237 | usage = thread_stack_usage(thread); |
225 | status = thread_get_status(thread); | ||
226 | 238 | ||
227 | snprintf(buffer, MAX_PATH, | 239 | snprintf(buffer, MAX_PATH, |
228 | "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s", | 240 | "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s", |
@@ -2329,6 +2341,7 @@ static const struct the_menu_item menuitems[] = { | |||
2329 | }; | 2341 | }; |
2330 | static int menu_action_callback(int btn, struct action_callback_info *info) | 2342 | static int menu_action_callback(int btn, struct action_callback_info *info) |
2331 | { | 2343 | { |
2344 | gui_synclist_hide_selection_marker(info->lists, false); | ||
2332 | if (btn == ACTION_STD_OK) | 2345 | if (btn == ACTION_STD_OK) |
2333 | { | 2346 | { |
2334 | menuitems[gui_synclist_get_sel_pos(info->lists)].function(); | 2347 | menuitems[gui_synclist_get_sel_pos(info->lists)].function(); |