Changeset f682f5a in mainline for uspace/app/top/screen.c
- Timestamp:
- 2012-04-15T07:42:52Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b8d6783
- Parents:
- 94f6df7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/top/screen.c
r94f6df7 rf682f5a 290 290 } 291 291 292 static inline void print_ tasks_head(void)292 static inline void print_help_head(void) 293 293 { 294 294 screen_style_inverted(); 295 printf("[taskid] [thrds] [resident] [%%resi] [virtual] [%%virt]" 296 " [%%user] [%%kern] [name"); 295 printf("Help"); 297 296 screen_newline(); 298 297 screen_style_normal(); 299 298 } 300 299 301 static inline void print_ tasks(data_t *data)300 static inline void print_help(void) 302 301 { 303 302 sysarg_t cols; … … 305 304 screen_get_size(&cols, &rows); 306 305 306 screen_newline(); 307 308 printf("Operation modes:"); 309 screen_newline(); 310 311 printf(" t .. tasks statistics"); 312 screen_newline(); 313 314 printf(" i .. IPC statistics"); 315 screen_newline(); 316 317 printf(" e .. exceptions statistics"); 318 screen_newline(); 319 320 printf(" a .. toggle display of all/hot exceptions"); 321 screen_newline(); 322 323 printf(" h .. toggle this help screen"); 324 screen_newline(); 325 326 screen_newline(); 327 328 printf("Other keys:"); 329 screen_newline(); 330 331 printf(" q .. quit"); 332 screen_newline(); 333 307 334 sysarg_t col; 308 335 sysarg_t row; 309 336 screen_get_pos(&col, &row); 310 337 311 size_t i;312 for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) {313 stats_task_t *task = data->tasks + data->tasks_map[i];314 perc_task_t *perc = data->tasks_perc + data->tasks_map[i];315 316 uint64_t resmem;317 const char *resmem_suffix;318 bin_order_suffix(task->resmem, &resmem, &resmem_suffix, true);319 320 uint64_t virtmem;321 const char *virtmem_suffix;322 bin_order_suffix(task->virtmem, &virtmem, &virtmem_suffix, true);323 324 printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s ",325 task->task_id, task->threads, resmem, resmem_suffix);326 print_percent(perc->resmem, 2);327 printf(" %6" PRIu64 "%s ", virtmem, virtmem_suffix);328 print_percent(perc->virtmem, 2);329 puts(" ");330 print_percent(perc->ucycles, 2);331 puts(" ");332 print_percent(perc->kcycles, 2);333 puts(" ");334 print_string(task->name);335 336 screen_newline();337 }338 339 338 while (row < rows) { 340 339 screen_newline(); … … 343 342 } 344 343 345 static inline void print_ipc_head(void) 346 { 347 screen_style_inverted(); 348 printf("[taskid] [cls snt] [cls rcv] [ans snt]" 349 " [ans rcv] [irq rcv] [forward] [name"); 350 screen_newline(); 351 screen_style_normal(); 352 } 353 354 static inline void print_ipc(data_t *data) 344 static inline void print_table_head(const table_t *table) 355 345 { 356 346 sysarg_t cols; 357 347 sysarg_t rows; 358 348 screen_get_size(&cols, &rows); 349 350 screen_style_inverted(); 351 for (size_t i = 0; i < table->num_columns; i++) { 352 const char *name = table->columns[i].name; 353 int width = table->columns[i].width; 354 if (i != 0) { 355 puts(" "); 356 } 357 if (width == 0) { 358 sysarg_t col; 359 sysarg_t row; 360 screen_get_pos(&col, &row); 361 width = cols - col - 1; 362 } 363 printf("[%-*.*s]", width - 2, width - 2, name); 364 } 365 screen_newline(); 366 screen_style_normal(); 367 } 368 369 static inline void print_table(const table_t *table) 370 { 371 sysarg_t cols; 372 sysarg_t rows; 373 screen_get_size(&cols, &rows); 359 374 360 375 sysarg_t col; … … 363 378 364 379 size_t i; 365 for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) { 366 uint64_t call_sent; 367 uint64_t call_received; 368 uint64_t answer_sent; 369 uint64_t answer_received; 370 uint64_t irq_notif_received; 371 uint64_t forwarded; 372 373 char call_sent_suffix; 374 char call_received_suffix; 375 char answer_sent_suffix; 376 char answer_received_suffix; 377 char irq_notif_received_suffix; 378 char forwarded_suffix; 379 380 order_suffix(data->tasks[i].ipc_info.call_sent, &call_sent, 381 &call_sent_suffix); 382 order_suffix(data->tasks[i].ipc_info.call_received, 383 &call_received, &call_received_suffix); 384 order_suffix(data->tasks[i].ipc_info.answer_sent, 385 &answer_sent, &answer_sent_suffix); 386 order_suffix(data->tasks[i].ipc_info.answer_received, 387 &answer_received, &answer_received_suffix); 388 order_suffix(data->tasks[i].ipc_info.irq_notif_received, 389 &irq_notif_received, &irq_notif_received_suffix); 390 order_suffix(data->tasks[i].ipc_info.forwarded, &forwarded, 391 &forwarded_suffix); 392 393 printf("%-8" PRIu64 " %8" PRIu64 "%c %8" PRIu64 "%c" 394 " %8" PRIu64 "%c %8" PRIu64 "%c %8" PRIu64 "%c" 395 " %8" PRIu64 "%c ", data->tasks[i].task_id, 396 call_sent, call_sent_suffix, 397 call_received, call_received_suffix, 398 answer_sent, answer_sent_suffix, 399 answer_received, answer_received_suffix, 400 irq_notif_received, irq_notif_received_suffix, 401 forwarded, forwarded_suffix); 402 print_string(data->tasks[i].name); 403 404 screen_newline(); 380 for (i = 0; (i < table->num_fields) && (row < rows); i++) { 381 size_t column_index = i % table->num_columns; 382 int width = table->columns[column_index].width; 383 field_t *field = &table->fields[i]; 384 385 if (column_index != 0) { 386 puts(" "); 387 } 388 389 if (width == 0) { 390 screen_get_pos(&col, &row); 391 width = cols - col - 1; 392 } 393 394 switch (field->type) { 395 case FIELD_EMPTY: 396 printf("%*s", width, ""); 397 break; 398 case FIELD_UINT: 399 printf("%*" PRIu64, width, field->uint); 400 break; 401 case FIELD_UINT_SUFFIX_BIN: { 402 uint64_t val = field->uint; 403 const char *suffix; 404 width -= 3; 405 bin_order_suffix(val, &val, &suffix, true); 406 printf("%*" PRIu64 "%s", width, val, suffix); 407 break; 408 } 409 case FIELD_UINT_SUFFIX_DEC: { 410 uint64_t val = field->uint; 411 char suffix; 412 width -= 1; 413 order_suffix(val, &val, &suffix); 414 printf("%*" PRIu64 "%c", width, val, suffix); 415 break; 416 } 417 case FIELD_PERCENT: 418 width -= 5; /* nnn.% */ 419 if (width > 2) { 420 printf("%*s", width - 2, ""); 421 width = 2; 422 } 423 print_percent(field->fixed, width); 424 break; 425 case FIELD_STRING: 426 printf("%-*.*s", width, width, field->string); 427 break; 428 } 429 430 if (column_index == table->num_columns - 1) { 431 screen_newline(); 432 row++; 433 } 405 434 } 406 435 … … 411 440 } 412 441 413 static inline void print_excs_head(void) 414 { 415 screen_style_inverted(); 416 printf("[exc ] [count ] [%%count] [cycles ] [%%cycles] [description"); 417 screen_newline(); 418 screen_style_normal(); 419 } 420 421 static inline void print_excs(data_t *data) 422 { 423 sysarg_t cols; 424 sysarg_t rows; 425 screen_get_size(&cols, &rows); 426 427 sysarg_t col; 428 sysarg_t row; 429 screen_get_pos(&col, &row); 430 431 size_t i; 432 for (i = 0; (i < data->exceptions_count) && (row < rows); i++) { 433 /* Filter-out cold exceptions if not instructed otherwise */ 434 if ((!excs_all) && (!data->exceptions[i].hot)) 435 continue; 436 437 uint64_t count; 438 uint64_t cycles; 439 440 char count_suffix; 441 char cycles_suffix; 442 443 order_suffix(data->exceptions[i].count, &count, &count_suffix); 444 order_suffix(data->exceptions[i].cycles, &cycles, &cycles_suffix); 445 446 printf("%-8u %9" PRIu64 "%c ", 447 data->exceptions[i].id, count, count_suffix); 448 print_percent(data->exceptions_perc[i].count, 2); 449 printf(" %9" PRIu64 "%c ", cycles, cycles_suffix); 450 print_percent(data->exceptions_perc[i].cycles, 2); 451 puts(" "); 452 print_string(data->exceptions[i].desc); 453 454 screen_newline(); 455 row++; 456 } 457 458 while (row < rows) { 459 screen_newline(); 460 row++; 461 } 462 } 463 464 static inline void print_help_head(void) 465 { 466 screen_style_inverted(); 467 printf("Help"); 468 screen_newline(); 469 screen_style_normal(); 470 } 471 472 static void print_help(void) 473 { 474 sysarg_t cols; 475 sysarg_t rows; 476 screen_get_size(&cols, &rows); 477 478 screen_newline(); 479 480 printf("Operation modes:"); 481 screen_newline(); 482 483 printf(" t .. tasks statistics"); 484 screen_newline(); 485 486 printf(" i .. IPC statistics"); 487 screen_newline(); 488 489 printf(" e .. exceptions statistics"); 490 screen_newline(); 491 492 printf(" a .. toggle display of all/hot exceptions"); 493 screen_newline(); 494 495 printf(" h .. this help screen"); 496 screen_newline(); 497 498 screen_newline(); 499 500 printf("Other keys:"); 501 screen_newline(); 502 503 printf(" q .. quit"); 504 screen_newline(); 505 506 sysarg_t col; 507 sysarg_t row; 508 screen_get_pos(&col, &row); 509 510 while (row < rows) { 511 screen_newline(); 512 row++; 513 } 514 } 515 516 static void print_warning(void) 442 static inline void print_warning(void) 517 443 { 518 444 screen_get_pos(&warning_col, &warning_row); … … 538 464 print_warning(); 539 465 540 switch ( op_mode) {541 case OP_TASKS:542 print_ta sks_head();543 print_ta sks(data);466 switch (screen_mode) { 467 case SCREEN_TABLE: 468 print_table_head(&data->table); 469 print_table(&data->table); 544 470 break; 545 case OP_IPC: 546 print_ipc_head(); 547 print_ipc(data); 548 break; 549 case OP_EXCS: 550 print_excs_head(); 551 print_excs(data); 552 break; 553 case OP_HELP: 471 case SCREEN_HELP: 554 472 print_help_head(); 555 473 print_help();
Note:
See TracChangeset
for help on using the changeset viewer.