Changeset 48dcc69 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2010-06-11T10:52:57Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be06914
Parents:
c0f13d2
Message:

better printouts for threads

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/thread.c

    rc0f13d2 r48dcc69  
    605605static bool thread_walker(avltree_node_t *node, void *arg)
    606606{
     607        bool *additional = (bool *) arg;
    607608        thread_t *thread = avltree_get_instance(node, thread_t, threads_tree_node);
    608609       
     
    613614       
    614615#ifdef __32_BITS__
    615         printf("%-6" PRIu64" %-10s %10p %-8s %10p %-3" PRIu32 " %10p %10p %9"
    616                 PRIu64 "%c %9" PRIu64 "%c ", thread->tid, thread->name, thread,
    617                 thread_states[thread->state], thread->task, thread->task->context,
    618                 thread->thread_code, thread->kstack, ucycles, usuffix, kcycles, ksuffix);
     616        if (*additional)
     617                printf("%-8" PRIu64" %10p %9" PRIu64 "%c %9" PRIu64 "%c ",
     618                    thread->tid, thread->kstack, ucycles, usuffix,
     619                    kcycles, ksuffix);
     620        else
     621                printf("%-8" PRIu64" %-14s %10p %-8s %10p %-5" PRIu32 " %10p\n",
     622                    thread->tid, thread->name, thread, thread_states[thread->state],
     623                    thread->task, thread->task->context, thread->thread_code);
    619624#endif
    620625       
    621626#ifdef __64_BITS__
    622         printf("%-6" PRIu64" %-10s %18p %-8s %18p %-3" PRIu32 " %18p %18p %9"
    623                 PRIu64 "%c %9" PRIu64 "%c ", thread->tid, thread->name, thread,
    624                 thread_states[thread->state], thread->task, thread->task->context,
    625                 thread->thread_code, thread->kstack, ucycles, usuffix, kcycles, ksuffix);
    626 #endif
    627        
    628         if (thread->cpu)
    629                 printf("%-4u", thread->cpu->id);
     627        if (*additional)
     628                printf("%-8" PRIu64" %18p %18p\n"
     629                    "         %9" PRIu64 "%c %9" PRIu64 "%c ",
     630                    thread->tid, thread->thread_code, thread->kstack,
     631                    ucycles, usuffix, kcycles, ksuffix);
    630632        else
    631                 printf("none");
    632        
    633         if (thread->state == Sleeping) {
     633                printf("%-8" PRIu64" %-14s %18p %-8s %18p %-5" PRIu32 "\n",
     634                    thread->tid, thread->name, thread, thread_states[thread->state],
     635                    thread->task, thread->task->context);
     636#endif
     637       
     638        if (*additional) {
     639                if (thread->cpu)
     640                        printf("%-5u", thread->cpu->id);
     641                else
     642                        printf("none ");
     643               
     644                if (thread->state == Sleeping) {
    634645#ifdef __32_BITS__
    635                 printf(" %10p", thread->sleep_queue);
    636 #endif
     646                        printf(" %10p", thread->sleep_queue);
     647#endif
     648                       
     649#ifdef __64_BITS__
     650                        printf(" %18p", thread->sleep_queue);
     651#endif
     652                }
    637653               
    638 #ifdef __64_BITS__
    639                 printf(" %18p", thread->sleep_queue);
    640 #endif
     654                printf("\n");
    641655        }
    642656       
    643         printf("\n");
    644        
    645657        return true;
    646658}
     
    648660/** Print list of threads debug info
    649661 *
    650  */
    651 void thread_print_list(void)
     662 * @param additional Print additional information.
     663 *
     664 */
     665void thread_print_list(bool additional)
    652666{
    653667        /* Messing with thread structures, avoid deadlock */
     
    655669       
    656670#ifdef __32_BITS__
    657         printf("tid    name       address    state    task       "
    658                 "ctx code       stack      ucycles    kcycles    cpu  "
    659                 "waitqueue\n");
    660         printf("------ ---------- ---------- -------- ---------- "
    661                 "--- ---------- ---------- ---------- ---------- ---- "
    662                 "----------\n");
     671        if (additional)
     672                printf("[id    ] [stack   ] [ucycles ] [kcycles ] [cpu]"
     673                    " [waitqueue]\n");
     674        else
     675                printf("[id    ] [name        ] [address ] [state ] [task    ]"
     676                    " [ctx] [code    ]\n");
    663677#endif
    664678       
    665679#ifdef __64_BITS__
    666         printf("tid    name       address            state    task               "
    667                 "ctx code               stack              ucycles    kcycles    cpu  "
    668                 "waitqueue\n");
    669         printf("------ ---------- ------------------ -------- ------------------ "
    670                 "--- ------------------ ------------------ ---------- ---------- ---- "
    671                 "------------------\n");
    672 #endif
    673        
    674         avltree_walk(&threads_tree, thread_walker, NULL);
     680        if (additional) {
     681                printf("[id    ] [code            ] [stack           ]\n"
     682                    "         [ucycles ] [kcycles ] [cpu] [waitqueue       ]\n");
     683        } else
     684                printf("[id    ] [name        ] [address         ] [state ]"
     685                    " [task            ] [ctx]\n");
     686#endif
     687       
     688        avltree_walk(&threads_tree, thread_walker, &additional);
    675689       
    676690        irq_spinlock_unlock(&threads_lock, true);
Note: See TracChangeset for help on using the changeset viewer.