Expand to show the peak size of heap and remove the printed task name in stack monitor
authorjc_.kim <jc_.kim@samsung.com>
Fri, 10 Mar 2017 05:11:46 +0000 (14:11 +0900)
committerjc_.kim <jc_.kim@samsung.com>
Fri, 10 Mar 2017 05:11:46 +0000 (14:11 +0900)
When enable CONFIG_DEBUG_MM_HEAPINFO, stackmonitor can show the peak size of heap per thread

apps/system/utils/kdbg_stackmonitor.c

index a926e89..f0d610a 100644 (file)
@@ -90,8 +90,8 @@ struct stkmon_save_s {
        pid_t chk_pid;
        size_t chk_stksize;
        size_t chk_peaksize;
-#if (CONFIG_TASK_NAME_SIZE > 0)
-       char chk_name[CONFIG_TASK_NAME_SIZE + 1];
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+       int chk_peakheap;
 #endif
 };
 
@@ -107,10 +107,10 @@ static int stkmon_chk_idx;
  ****************************************************************************/
 static void stkmon_title_print(void)
 {
-#if (CONFIG_TASK_NAME_SIZE > 0)
-       printf("%-5s %s %8s %5s %7s %s\n", "PID", "STATUS", "SIZE", "PEAK", "TIME", "THREAD NAME");
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+       printf("%-5s %s %8s %5s %7s %7s\n", "PID", "STATUS", "SIZE", "PEAK_STACK", "PEAK_HEAP", "TIME");
 #else
-       printf("%-5s %s %8s %5s %7s\n", "PID", "STATUS", "SIZE", "PEAK", "TIME");
+       printf("%-5s %s %8s %5s %7s\n", "PID", "STATUS", "SIZE", "PEAK_STACK", "TIME");
 #endif
 }
 
@@ -119,10 +119,10 @@ static void stkmon_inactive_check(void)
        int inactive_idx;
        for (inactive_idx = 0; inactive_idx < CONFIG_MAX_TASKS * 2; inactive_idx++) {
                if (stkmon_arr[inactive_idx].timestamp != 0) {
-#if (CONFIG_TASK_NAME_SIZE > 0)
-                       printf("%5d %s %6d %6d %7lld %s\n", stkmon_arr[inactive_idx].chk_pid, "INACTIVE", stkmon_arr[inactive_idx].chk_stksize, stkmon_arr[inactive_idx].chk_peaksize, (uint64_t)((systime_t)stkmon_arr[inactive_idx].timestamp), stkmon_arr[inactive_idx].chk_name);
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+                       printf("%5d %s %6d %9d %10d %7lld\n", stkmon_arr[inactive_idx].chk_pid, "INACTIVE", stkmon_arr[inactive_idx].chk_stksize, stkmon_arr[inactive_idx].chk_peaksize, stkmon_arr[inactive_idx].chk_peakheap, (uint64_t)((systime_t)stkmon_arr[inactive_idx].timestamp));
 #else
-                       printf("%5d %s %6d %6d %7lld\n", stkmon_arr[inactive_idx].chk_pid, "INACTIVE", stkmon_arr[inactive_idx].chk_stksize, stkmon_arr[inactive_idx].chk_peaksize, (uint64_t)((systime_t)stkmon_arr[inactive_idx].timestamp));
+                       printf("%5d %s %6d %9d %7lld\n", stkmon_arr[inactive_idx].chk_pid, "INACTIVE", stkmon_arr[inactive_idx].chk_stksize, stkmon_arr[inactive_idx].chk_peaksize, (uint64_t)((systime_t)stkmon_arr[inactive_idx].timestamp));
 #endif
                        stkmon_arr[inactive_idx].timestamp = 0;
                }
@@ -134,10 +134,10 @@ static void stkmon_active_check(struct tcb_s *tcb, void *arg)
        if (tcb->pid == 0) {
                tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE;
        }
-#if (CONFIG_TASK_NAME_SIZE > 0)
-       printf("%5d %s %8d %6d %7lld %s\n", tcb->pid, "ACTIVE", tcb->adj_stack_size, up_check_tcbstack(tcb), (uint64_t)((systime_t)clock_systimer()), tcb->name);
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+       printf("%5d %s %9d %8d %10d %7lld\n", tcb->pid, "ACTIVE", tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->peak_alloc_size, (uint64_t)((systime_t)clock_systimer()));
 #else
-       printf("%5d %s %8d %6d %7lld\n", tcb->pid, "ACTIVE", tcb->adj_stack_size, up_check_tcbstack(tcb), (uint64_t)((systime_t)clock_systimer()));
+       printf("%5d %s %9d %8d %7lld\n", tcb->pid, "ACTIVE", tcb->adj_stack_size, up_check_tcbstack(tcb), (uint64_t)((systime_t)clock_systimer()));
 #endif
 }
 
@@ -147,11 +147,11 @@ static void *stackmonitor_daemon(void *arg)
 
        /* Loop until we detect that there is a request to stop. */
        while (stkmon_started) {
-               printf("=====================================================\n");
+               printf("==================================================\n");
                stkmon_title_print();
-               printf("-----------------------------------------------------\n");
+               printf("--------------------------------------------------\n");
                stkmon_inactive_check();
-               printf("-----------------------------------------------------\n");
+               printf("--------------------------------------------------\n");
                sched_foreach(stkmon_active_check, NULL);
                sleep(CONFIG_STACKMONITOR_INTERVAL);
        }
@@ -181,17 +181,12 @@ static void stackmonitor_stop(void)
  ****************************************************************************/
 void stkmon_logging(struct tcb_s *tcb)
 {
-#if (CONFIG_TASK_NAME_SIZE > 0)
-       int name_idx;
-#endif
        stkmon_arr[stkmon_chk_idx % (CONFIG_MAX_TASKS * 2)].timestamp = clock_systimer();
        stkmon_arr[stkmon_chk_idx % (CONFIG_MAX_TASKS * 2)].chk_pid = tcb->pid;
        stkmon_arr[stkmon_chk_idx % (CONFIG_MAX_TASKS * 2)].chk_stksize = tcb->adj_stack_size;
        stkmon_arr[stkmon_chk_idx % (CONFIG_MAX_TASKS * 2)].chk_peaksize = up_check_tcbstack(tcb);
-#if (CONFIG_TASK_NAME_SIZE > 0)
-       for (name_idx = 0; name_idx < CONFIG_TASK_NAME_SIZE + 1; name_idx++) {
-               stkmon_arr[stkmon_chk_idx % (CONFIG_MAX_TASKS * 2)].chk_name[name_idx] = tcb->name[name_idx];
-       }
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+       stkmon_arr[stkmon_chk_idx % (CONFIG_MAX_TASKS * 2)].chk_peakheap = tcb->peak_alloc_size;
 #endif
        stkmon_chk_idx %= (CONFIG_MAX_TASKS * 2);
        stkmon_chk_idx++;