apps/system/utils : Change to allocate array which saved terminated info
terminated_infos can be affected with another configs, like CONFIG_MAX_TASKS.
So that it can also affect the stack size of stack monitor.
Changing that array to be allocated can avoid the problem.
@@ -132,15 +132,22 @@ static void stkmon_print_title(void)
static void stkmon_print_inactive_list(void)
{
int inactive_idx;
- struct stkmon_save_s terminated_infos[STKMON_MAX_LOGS];
+ int ret;
+ struct stkmon_save_s *terminated_infos;
- /* Initialize the terminated_infos array. */
- for (inactive_idx = 0; inactive_idx < (STKMON_MAX_LOGS); inactive_idx++) {
- terminated_infos[inactive_idx].timestamp = 0;
+ terminated_infos = (struct stkmon_save_s *)zalloc(sizeof(struct stkmon_save_s) * STKMON_MAX_LOGS);
+ if (terminated_infos == NULL) {
+ printf("Failed to allocate the information array.\n");
+ return;
}
/* Copy the terminated task/pthread information from kernel. */
- prctl((int)PR_GET_STKLOG, (struct stkmon_save_s *)terminated_infos);
+ ret = prctl((int)PR_GET_STKLOG, terminated_infos);
+ if (ret != OK) {
+ free(terminated_infos);
+ printf("Failed to read terminated threads information.\n");
+ return;
+ }
for (inactive_idx = 0; inactive_idx < STKMON_MAX_LOGS; inactive_idx++) {
if (terminated_infos[inactive_idx].timestamp != 0) {
@@ -156,9 +163,10 @@ static void stkmon_print_inactive_list(void)
printf(" | %s", terminated_infos[inactive_idx].chk_name);
#endif
printf("\n");
- terminated_infos[inactive_idx].timestamp = 0;
}
}
+
+ free(terminated_infos);
}
static void stkmon_print_active_values(char *buf)
