Changeset b3b7e14a in mainline for uspace/app


Ignore:
Timestamp:
2010-06-11T15:31:03Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
214ec25c
Parents:
be06914
Message:

distinguish between "hot" and "cold" exceptions
display only "hot" exceptions by default
add top to help

Location:
uspace/app/top
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/top/screen.c

    rbe06914 rb3b7e14a  
    259259}
    260260
    261 static inline void print_task_head(void)
     261static inline void print_tasks_head(void)
    262262{
    263263        screen_style_inverted();
     
    371371}
    372372
    373 static inline void print_exc_head(void)
     373static inline void print_excs_head(void)
    374374{
    375375        screen_style_inverted();
     
    379379}
    380380
    381 static inline void print_exc(data_t *data)
     381static inline void print_excs(data_t *data)
    382382{
    383383        ipcarg_t cols;
     
    390390       
    391391        size_t i;
    392         for (i = 0; (i < data->exceptions_count) && (row < rows); i++, row++) {
     392        for (i = 0; (i < data->exceptions_count) && (row < rows); i++) {
     393                /* Filter-out cold exceptions if not instructed otherwise */
     394                if ((!excs_all) && (!data->exceptions[i].hot))
     395                        continue;
     396               
    393397                uint64_t count;
    394398                uint64_t cycles;
     
    409413               
    410414                screen_newline();
    411         }
     415                row++;
     416        }
     417       
     418        while (row < rows) {
     419                screen_newline();
     420                row++;
     421        }
     422}
     423
     424static void print_help(void)
     425{
     426        ipcarg_t cols;
     427        ipcarg_t rows;
     428        screen_get_size(&cols, &rows);
     429       
     430        ipcarg_t col;
     431        ipcarg_t row;
     432        screen_get_pos(&col, &row);
     433       
     434        screen_newline();
     435       
     436        printf("Operation modes:");
     437        screen_newline();
     438       
     439        printf(" t .. tasks statistics");
     440        screen_newline();
     441       
     442        printf(" i .. IPC statistics");
     443        screen_newline();
     444       
     445        printf(" e .. exceptions statistics");
     446        screen_newline();
     447       
     448        printf("      a .. toggle display of all/hot exceptions");
     449        screen_newline();
     450       
     451        row += 6;
    412452       
    413453        while (row < rows) {
     
    430470        screen_newline();
    431471       
    432         switch (operation_type) {
     472        switch (op_mode) {
    433473        case OP_TASKS:
    434                 print_task_head();
     474                print_tasks_head();
    435475                print_tasks(data);
    436476                break;
     
    439479                print_ipc(data);
    440480                break;
    441         case OP_EXC:
    442                 print_exc_head();
    443                 print_exc(data);
     481        case OP_EXCS:
     482                print_excs_head();
     483                print_excs(data);
    444484                break;
     485        case OP_HELP:
     486                print_tasks_head();
     487                print_help();
    445488        }
    446489       
  • uspace/app/top/top.c

    rbe06914 rb3b7e14a  
    5656#define MINUTE  60
    5757
    58 int operation_type;
     58op_mode_t op_mode = OP_TASKS;
     59bool excs_all = false;
    5960
    6061static const char *read_data(data_t *target)
     
    338339       
    339340        /* And paint screen until death */
    340         operation_type = OP_TASKS;
    341341        while (true) {
    342342                int c = tgetchar(UPDATE_INTERVAL);
     
    360360               
    361361                switch (c) {
     362                        case 't':
     363                                print_warning("Showing task statistics");
     364                                op_mode = OP_TASKS;
     365                                break;
     366                        case 'i':
     367                                print_warning("Showing IPC statistics");
     368                                op_mode = OP_IPC;
     369                                break;
     370                        case 'e':
     371                                print_warning("Showing exception statistics");
     372                                op_mode = OP_EXCS;
     373                                break;
     374                        case 'h':
     375                                print_warning("Showing help");
     376                                op_mode = OP_HELP;
     377                                break;
    362378                        case 'q':
    363379                                goto out;
    364                         case 'i':
    365                                 print_warning("Showing IPC statistics");
    366                                 operation_type = OP_IPC;
    367                                 break;
    368                         case 't':
    369                                 print_warning("Showing task statistics");
    370                                 operation_type = OP_TASKS;
    371                                 break;
    372                         case 'e':
    373                                 print_warning("Showing exception statistics");
    374                                 operation_type = OP_EXC;
    375                                 break;
     380                        case 'a':
     381                                if (op_mode == OP_EXCS) {
     382                                        excs_all = !excs_all;
     383                                        if (excs_all)
     384                                                print_warning("Showing all exceptions");
     385                                        else
     386                                                print_warning("Showing only hot exceptions");
     387                                        break;
     388                                }
    376389                        default:
    377                                 print_warning("Unknown command: %c", c);
     390                                print_warning("Unknown command \"%c\", use \"h\" for help", c);
    378391                                break;
    379392                }
  • uspace/app/top/top.h

    rbe06914 rb3b7e14a  
    4040
    4141#define FRACTION_TO_FLOAT(float, a, b) \
    42         { \
     42        do { \
    4343                if ((b) != 0) { \
    4444                        (float).upper = (a); \
     
    4848                        (float).lower = 1; \
    4949                } \
    50         }
     50        } while (0)
    5151
    52 #define OP_TASKS  1
    53 #define OP_IPC    2
    54 #define OP_EXC    3
     52typedef enum {
     53        OP_TASKS,
     54        OP_IPC,
     55        OP_EXCS,
     56        OP_HELP
     57} op_mode_t;
    5558
    56 extern int operation_type;
     59extern op_mode_t op_mode;
     60extern bool excs_all;
    5761
    5862typedef struct {
Note: See TracChangeset for help on using the changeset viewer.