Cosmetic changes for "ps, heapinfo and stkmon" command output
authorpradeep.ns <pradeep.ns@samsung.com>
Mon, 29 May 2017 16:41:33 +0000 (22:11 +0530)
committerpradeep.ns <pradeep.ns@samsung.com>
Tue, 30 May 2017 15:24:21 +0000 (20:54 +0530)
New changes can be verified using TASH
1) with CONFIG_TASK_NAME_SIZE=0
TASH>>ps

  PID | PRIO | FLAG |  TYPE   | NP |  STATUS
------|------|------|---------|----|--------
    0 |    0 | FIFO | KTHREAD |    | READY
    1 |  224 | RR   | KTHREAD |    | WAITSIG
    3 |  125 | RR   | TASK    |    | RUNNING

2) with CONFIG_TASK_NAME_SIZE=31

TASH>>ps
PID | PRIO | FLAG |  TYPE   | NP |  STATUS  | NAME
----|------|------|---------|----|----------|----------
  0 |    0 | FIFO | KTHREAD |    | READY    | Idle Task
  1 |  224 | RR   | KTHREAD |    | WAITSIG  | hpwork
  3 |  125 | RR   | TASK    |    | RUNNING  | tash

heap output can be verified as follows

TASH>>heapinfo -a
TASH>>heapinfo -f
TASH>>heapinfo -p

stack monitor output can be verified as follows
TASH>>stkmon
TASH>>Stack Monitor: Running
=============================================================================
  PID |   STATUS |     SIZE | PEAK_STACK |  PEAK_HEAP |    TIME | THREAD NAME
------|----------|----------|------------|------------|---------|------------
   44 | INACTIVE |     2028 |        556 |          0 |    4390 | waiter
   46 | INACTIVE |     2044 |        500 |          0 |    6639 | <pthread>
   45 | INACTIVE |     2044 |        500 |          0 |    6639 | <pthread>
   58 | INACTIVE |     2044 |        452 |          0 |    6795 | <pthread>
   47 | INACTIVE |     2044 |        452 |          0 |    6795 | <pthread>
------|----------|----------|------------|------------|---------|------------
    0 |   ACTIVE |     1024 |       1024 |      59504 |   20740 | Idle Task
    1 |   ACTIVE |     2028 |        156 |          0 |   20742 | hpwork
    3 |   ACTIVE |     4076 |        876 |       3584 |   20742 | tash
   71 |   ACTIVE |     1020 |        524 |          0 |   20743 | StackMonitor

Signed-off-by: pradeep.ns <pradeep.ns@samsung.com>
apps/system/utils/kdbg_heapinfo.c
apps/system/utils/kdbg_ps.c
apps/system/utils/kdbg_stackmonitor.c
os/mm/mm_heap/mm_heapinfo.c

index 3b6954d..1ec6f48 100644 (file)
@@ -37,11 +37,11 @@ static void kdbg_heapinfo_task(FAR struct tcb_s *tcb, FAR void *arg)
        if (tcb->pid == 0) {
                tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE;
        }
-       printf("%3d  ", tcb->pid);
+       printf("%3d | ", tcb->pid);
 #if defined(CONFIG_SCHED_HAVE_PARENT) && !defined(HAVE_GROUP_MEMBERS)
-       printf("%4d  ", tcb->ppid);
+       printf("%5d | ", tcb->ppid);
 #endif
-       printf("%5d      %5d  %5d  ", tcb->adj_stack_size, tcb->curr_alloc_size, tcb->peak_alloc_size);
+       printf("%5d | %9d | %9d | ", tcb->adj_stack_size, tcb->curr_alloc_size, tcb->peak_alloc_size);
 
        /* Show task name and arguments */
 #if CONFIG_TASK_NAME_SIZE > 0
@@ -90,12 +90,16 @@ int kdbg_heapinfo(int argc, char **args)
        }
        heapinfo_parse(user_heap, mode, pid);
 
-       printf("\nPID  ");
+       printf("\n%3s | ", "PID");
 #if defined(CONFIG_SCHED_HAVE_PARENT) && !defined(HAVE_GROUP_MEMBERS)
-       printf("PPID  ");
+       printf("%5s | ", "PPID");
 #endif
-       printf("STACK  HEAP Curr  Peak  NAME\n");
-       printf("------------------------------------\n");
+       printf("%5s | %9s | %9s | %s\n", "STACK", "CURR_HEAP", "PEAK_HEAP", "NAME");
+       printf("----|");
+#if defined(CONFIG_SCHED_HAVE_PARENT) && !defined(HAVE_GROUP_MEMBERS)
+       printf("-------|");
+#endif
+       printf("-------|-----------|-----------|----------\n");
        sched_foreach(kdbg_heapinfo_task, NULL);
 
        return OK;
index 521899f..773a45f 100644 (file)
@@ -79,9 +79,9 @@ static const char *kdbg_ttypenames[4] = {
 
 static void kdbg_pseach(FAR struct tcb_s *tcb, FAR void *arg)
 {
-       printf("%5d %4d %4s %7s %c%c %8s", tcb->pid, tcb->sched_priority, tcb->flags & TCB_FLAG_ROUND_ROBIN ? "RR  " : "FIFO", kdbg_ttypenames[(tcb->flags & TCB_FLAG_TTYPE_MASK) >> TCB_FLAG_TTYPE_SHIFT], tcb->flags & TCB_FLAG_NONCANCELABLE ? 'N' : ' ', tcb->flags & TCB_FLAG_CANCEL_PENDING ? 'P' : ' ', kdbg_statenames[tcb->task_state]);
+       printf("%5d | %4d | %4s | %7s | %c%c | %8s", tcb->pid, tcb->sched_priority, tcb->flags & TCB_FLAG_ROUND_ROBIN ? "RR  " : "FIFO", kdbg_ttypenames[(tcb->flags & TCB_FLAG_TTYPE_MASK) >> TCB_FLAG_TTYPE_SHIFT], tcb->flags & TCB_FLAG_NONCANCELABLE ? 'N' : ' ', tcb->flags & TCB_FLAG_CANCEL_PENDING ? 'P' : ' ', kdbg_statenames[tcb->task_state]);
 #if CONFIG_TASK_NAME_SIZE > 0
-       printf(" %s", tcb->name);
+       printf(" %s", tcb->name);
 #endif
        printf("\n");
 }
@@ -89,11 +89,13 @@ static void kdbg_pseach(FAR struct tcb_s *tcb, FAR void *arg)
 int kdbg_ps(int argc, char **args)
 {
 #if CONFIG_TASK_NAME_SIZE > 0
-       printf("\n  PID PRIO FLAG    TYPE NP   STATUS             NAME\n");
-       printf("------------------------------------------------------\n");
+       printf("\n");
+       printf("  PID | PRIO | FLAG |  TYPE   | NP |  STATUS  | NAME\n");
+       printf("------|------|------|---------|----|----------|----------\n");
 #else
-       printf("\n  PID PRIO FLAG    TYPE NP   STATUS\n");
-       printf("-------------------------------------\n");
+       printf("\n");
+       printf("  PID | PRIO | FLAG |  TYPE   | NP |  STATUS\n");
+       printf("------|------|------|---------|----|--------\n");
 #endif
        sched_foreach(kdbg_pseach, NULL);
        return 0;
index 04ee1ff..e01e9ab 100644 (file)
@@ -111,9 +111,9 @@ static int stkmon_chk_idx;
 static void stkmon_title_print(void)
 {
 #ifdef CONFIG_DEBUG_MM_HEAPINFO
-       printf("%-5s %s %8s %5s %7s %7s ", "PID", "STATUS", "SIZE", "PEAK_STACK", "PEAK_HEAP", "TIME");
+       printf("%5s | %8s | %8s | %10s | %10s | %7s | ", "PID", "STATUS", "SIZE", "PEAK_STACK", "PEAK_HEAP", "TIME");
 #else
-       printf("%-5s %s %8s %5s %7s\n", "PID", "STATUS", "SIZE", "PEAK_STACK", "TIME");
+       printf("%5s | %8s | %8s | %10s | %10s | ", "PID", "STATUS", "SIZE", "PEAK_STACK", "TIME");
 #endif
 #if (CONFIG_TASK_NAME_SIZE > 0)
        printf("THREAD NAME\n");
@@ -128,9 +128,9 @@ static void stkmon_inactive_check(void)
        for (inactive_idx = 0; inactive_idx < CONFIG_MAX_TASKS * 2; inactive_idx++) {
                if (stkmon_arr[inactive_idx].timestamp != 0) {
 #ifdef CONFIG_DEBUG_MM_HEAPINFO
-                       printf("%5d %s %6d %9d %10d %7lld ", 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));
+                       printf("%5d | %8s | %8d | %10d | %10d | %7lld | ", 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 %9d %7lld ", 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 | %8s | %8d | %10d | %10lld | ", 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
 #if (CONFIG_TASK_NAME_SIZE > 0)
                        printf("%s\n", stkmon_arr[inactive_idx].chk_name);
@@ -148,9 +148,9 @@ static void stkmon_active_check(struct tcb_s *tcb, void *arg)
                tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE;
        }
 #ifdef CONFIG_DEBUG_MM_HEAPINFO
-       printf("%5d %s %9d %8d %10d %7lld ", tcb->pid, "ACTIVE", tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->peak_alloc_size, (uint64_t)((systime_t)clock_systimer()));
+       printf("%5d | %8s | %8d | %10d | %10d | %7lld | ", 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 %9d %8d %7lld", tcb->pid, "ACTIVE", tcb->adj_stack_size, up_check_tcbstack(tcb), (uint64_t)((systime_t)clock_systimer()));
+       printf("%5d | %8s | %8d | %10d | %10lld | ", tcb->pid, "ACTIVE", tcb->adj_stack_size, up_check_tcbstack(tcb), (uint64_t)((systime_t)clock_systimer()));
 #endif
 #if (CONFIG_TASK_NAME_SIZE > 0)
        printf("%s\n", tcb->name);
@@ -165,11 +165,19 @@ static void *stackmonitor_daemon(void *arg)
 
        /* Loop until we detect that there is a request to stop. */
        while (stkmon_started) {
-               printf("===============================================================\n");
+               printf("\n=============================================================================\n");
                stkmon_title_print();
-               printf("---------------------------------------------------------------\n");
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+               printf("------|----------|----------|------------|------------|---------|------------\n");
+#else
+               printf("------|----------|----------|------------|------------|------------\n");
+#endif
                stkmon_inactive_check();
-               printf("---------------------------------------------------------------\n");
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+               printf("------|----------|----------|------------|------------|---------|------------\n");
+#else
+               printf("------|----------|----------|------------|------------|------------\n");
+#endif
                sched_foreach(stkmon_active_check, NULL);
                sleep(CONFIG_STACKMONITOR_INTERVAL);
        }
index a8c665d..2511900 100644 (file)
@@ -102,7 +102,7 @@ void heapinfo_parse(FAR struct mm_heap_s *heap, int mode, int pid)
 
        if (mode != HEAPINFO_SIMPLE) {
                printf("****************************************************************\n");
-               printf("Heap Walker Output for Heap =0x%p\n", heap);
+               printf("Heap Walker Output for Heap = 0x%p\n", heap);
                printf("****************************************************************\n");
        }
 
@@ -122,7 +122,8 @@ void heapinfo_parse(FAR struct mm_heap_s *heap, int mode, int pid)
                        printf("****************************************************************\n");
                        printf("Heap Alloation Info- (Size in Bytes)\n");
                        printf("****************************************************************\n");
-                       printf("  MemAddr    Size      Owner    Pid \n");
+                       printf("  MemAddr |   Size   | Status |   Owner   | Pid |\n");
+                       printf("----------|----------|--------|-----------|-----|\n");
                }
 
                for (node = heap->mm_heapstart[region]; node < heap->mm_heapend[region]; node = (struct mm_allocnode_s *)((char *)node + node->size)) {
@@ -130,7 +131,7 @@ void heapinfo_parse(FAR struct mm_heap_s *heap, int mode, int pid)
                        /* Check if the node corresponds to an allocated memory chunk */
                        if ((pid == HEAPINFO_PID_NOTNEEDED || node->pid == pid) && (node->preceding & MM_ALLOC_BIT) != 0) {
                                if (mode == HEAPINFO_DETAIL_ALL || mode == HEAPINFO_DETAIL_PID) {
-                                       printf("0x%x %6d %c 0x%x %3d \n", node, node->size, 'A', node->alloc_call_addr, node->pid);
+                                       printf("0x%x | %8d |   %c    | 0x%x | %3d |\n", node, node->size, 'A', node->alloc_call_addr, node->pid);
                                }
 
 #if CONFIG_TASK_NAME_SIZE > 0
@@ -151,7 +152,7 @@ void heapinfo_parse(FAR struct mm_heap_s *heap, int mode, int pid)
                                        mxordblk = node->size;
                                }
                                if (mode == HEAPINFO_DETAIL_ALL || mode == HEAPINFO_DETAIL_FREE) {
-                                       printf("0x%x %6d %c\n", node, node->size, 'F');
+                                       printf("0x%x | %8d |   %c    |           |     |\n", node, node->size, 'F');
                                }
                        }
                }
@@ -172,11 +173,11 @@ void heapinfo_parse(FAR struct mm_heap_s *heap, int mode, int pid)
 
        printf("\nNon Scheduled Task Resources   : %d\n", nonsched_resource);
        if (mode != HEAPINFO_SIMPLE) {
-               printf("PID  SIZE\n");
-               printf("----------\n");
+               printf(" PID | SIZE \n");
+               printf("-----|------\n");
                for (nonsched_idx = 0; nonsched_idx < CONFIG_MAX_TASKS; nonsched_idx++) {
                        if (nonsched_list[nonsched_idx] != -1) {
-                               printf("%4d %5d\n", nonsched_list[nonsched_idx], nonsched_size[nonsched_idx]);
+                               printf("%4d %5d\n", nonsched_list[nonsched_idx], nonsched_size[nonsched_idx]);
                        }
                }
        }