Changeset c0f13d2 in mainline


Ignore:
Timestamp:
2010-06-10T16:04:07Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
48dcc69
Parents:
8eec3c8
Message:

introduce more compact and more readable command output to kconsole (suitable even for 80-column screens)

Location:
kernel/generic
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/console/kconsole.h

    r8eec3c8 rc0f13d2  
    4747        ARG_TYPE_INT,
    4848        ARG_TYPE_STRING,
     49        /** Optional string */
     50        ARG_TYPE_STRING_OPTIONAL,
    4951        /** Variable type - either symbol or string. */
    5052        ARG_TYPE_VAR
  • kernel/generic/include/proc/task.h

    r8eec3c8 rc0f13d2  
    138138extern int task_kill(task_id_t);
    139139extern void task_get_accounting(task_t *, uint64_t *, uint64_t *);
    140 extern void task_print_list(void);
     140extern void task_print_list(bool);
    141141
    142142extern void cap_set(task_t *, cap_t);
  • kernel/generic/src/console/cmd.c

    r8eec3c8 rc0f13d2  
    207207};
    208208
    209 /* Data and methods for 'call0' command. */
     209/* Data and methods for 'call0' and 'mcall0' command. */
    210210static char call0_buf[MAX_CMDLINE + 1];
    211211static char carg1_buf[MAX_CMDLINE + 1];
     
    363363};
    364364
     365
    365366static int cmd_tasks(cmd_arg_t *argv);
     367static char tasks_buf[MAX_CMDLINE + 1];
     368
     369static cmd_arg_t tasks_argv = {
     370        .type = ARG_TYPE_STRING_OPTIONAL,
     371        .buffer = tasks_buf,
     372        .len = sizeof(tasks_buf)
     373};
    366374static cmd_info_t tasks_info = {
    367375        .name = "tasks",
    368         .description = "List all tasks.",
     376        .description = "List all tasks (use -a for additional information).",
    369377        .func = cmd_tasks,
    370         .argc = 0
     378        .argc = 1,
     379        .argv = &tasks_argv
    371380};
    372381
     
    930939 * @return Always 1
    931940 */
    932 int cmd_tasks(cmd_arg_t * argv)
    933 {
    934         task_print_list();
     941int cmd_tasks(cmd_arg_t *argv)
     942{
     943        if (str_cmp(tasks_buf, "-a") == 0)
     944                task_print_list(true);
     945        else if (str_cmp(tasks_buf, "") == 0)
     946                task_print_list(false);
     947        else
     948                printf("Unknown argument \"%s\".\n", tasks_buf);
     949       
    935950        return 1;
    936951}
  • kernel/generic/src/console/kconsole.c

    r8eec3c8 rc0f13d2  
    590590        size_t i;
    591591        for (i = 0; i < cmd->argc; i++) {
     592                char *buf;
     593               
    592594                start = end;
    593595                if (!parse_argument(cmdline, size, &start, &end)) {
     596                        if (cmd->argv[i].type == ARG_TYPE_STRING_OPTIONAL) {
     597                                buf = (char *) cmd->argv[i].buffer;
     598                                str_cpy(buf, cmd->argv[i].len, "");
     599                                continue;
     600                        }
     601                       
    594602                        printf("Too few arguments.\n");
    595603                        spinlock_unlock(&cmd->lock);
     
    597605                }
    598606               
    599                 char *buf;
    600607                switch (cmd->argv[i].type) {
    601608                case ARG_TYPE_STRING:
     609                case ARG_TYPE_STRING_OPTIONAL:
    602610                        buf = (char *) cmd->argv[i].buffer;
    603611                        str_ncpy(buf, cmd->argv[i].len, cmdline + start,
  • kernel/generic/src/proc/task.c

    r8eec3c8 rc0f13d2  
    465465static bool task_print_walker(avltree_node_t *node, void *arg)
    466466{
     467        bool *additional = (bool *) arg;
    467468        task_t *task = avltree_get_instance(node, task_t, tasks_tree_node);
    468469        irq_spinlock_lock(&task->lock, false);
     
    476477       
    477478#ifdef __32_BITS__
    478         printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %10p %10p %9" PRIu64 "%c %9"
    479             PRIu64 "%c %7ld %6ld", task->taskid, task->name, task->context,
    480             task, task->as, ucycles, usuffix, kcycles, ksuffix,
    481             atomic_get(&task->refcount), atomic_get(&task->active_calls));
     479        if (*additional)
     480                printf("%-8" PRIu64 " %9ld %7ld", task->taskid,
     481                    atomic_get(&task->refcount), atomic_get(&task->active_calls));
     482        else
     483                printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %10p %10p"
     484                    " %9" PRIu64 "%c %9" PRIu64 "%c\n", task->taskid,
     485                    task->name, task->context, task, task->as,
     486                    ucycles, usuffix, kcycles, ksuffix);
    482487#endif
    483488       
    484489#ifdef __64_BITS__
    485         printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %18p %18p %9" PRIu64 "%c %9"
    486             PRIu64 "%c %7ld %6ld", task->taskid, task->name, task->context,
    487             task, task->as, ucycles, usuffix, kcycles, ksuffix,
    488             atomic_get(&task->refcount), atomic_get(&task->active_calls));
    489 #endif
    490        
    491         size_t i;
    492         for (i = 0; i < IPC_MAX_PHONES; i++) {
    493                 if (task->phones[i].callee)
    494                         printf(" %" PRIs ":%p", i, task->phones[i].callee);
     490        if (*additional)
     491                printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c %9ld %7ld",
     492                    task->taskid, ucycles, usuffix, kcycles, ksuffix,
     493                    atomic_get(&task->refcount), atomic_get(&task->active_calls));
     494        else
     495                printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %18p %18p\n",
     496                    task->taskid, task->name, task->context, task, task->as);
     497#endif
     498       
     499        if (*additional) {
     500                size_t i;
     501                for (i = 0; i < IPC_MAX_PHONES; i++) {
     502                        if (task->phones[i].callee)
     503                                printf(" %" PRIs ":%p", i, task->phones[i].callee);
     504                }
     505                printf("\n");
    495506        }
    496         printf("\n");
    497507       
    498508        irq_spinlock_unlock(&task->lock, false);
     
    500510}
    501511
    502 /** Print task list */
    503 void task_print_list(void)
     512/** Print task list
     513 *
     514 * @param additional Print additional information.
     515 *
     516 */
     517void task_print_list(bool additional)
    504518{
    505519        /* Messing with task structures, avoid deadlock */
     
    507521       
    508522#ifdef __32_BITS__
    509         printf("taskid name         ctx address    as        "
    510             " ucycles    kcycles    threads calls  callee\n");
    511         printf("------ ------------ --- ---------- ----------"
    512             " ---------- ---------- ------- ------ ------>\n");
     523        if (additional)
     524                printf("[taskid] [threads] [calls] [callee\n");
     525        else
     526                printf("[taskid] [name        ] [ctx] [address ] [as      ]"
     527                    " [ucycles ] [kcycles ]\n");
    513528#endif
    514529       
    515530#ifdef __64_BITS__
    516         printf("taskid name         ctx address            as                "
    517             " ucycles    kcycles    threads calls  callee\n");
    518         printf("------ ------------ --- ------------------ ------------------"
    519             " ---------- ---------- ---------- ------- ------ ------>\n");
    520 #endif
    521        
    522         avltree_walk(&tasks_tree, task_print_walker, NULL);
     531        if (additional)
     532                printf("[taskid] [ucycles ] [kcycles ] [threads] [calls]"
     533                    " [callee\n");
     534        else
     535                printf("[taskid] [name        ] [ctx] [address         ]"
     536                    " [as              ]\n");
     537#endif
     538       
     539        avltree_walk(&tasks_tree, task_print_walker, &additional);
    523540       
    524541        irq_spinlock_unlock(&tasks_lock, true);
Note: See TracChangeset for help on using the changeset viewer.