static int tty_setWinTitle_25(struct pvm_object me , struct data_area_4_thread *tc ) { DEBUG_INFO; struct data_area_4_tty *da = pvm_data_area( me, tty ); int n_param = POP_ISTACK; CHECK_PARAM_COUNT(n_param, 1); struct pvm_object _text = POP_ARG; ASSERT_STRING(_text); int len = pvm_get_str_len( _text ); const char * data = (const char *)pvm_get_str_data(_text); if( len > PVM_MAX_TTY_TITLE-1 ) len = PVM_MAX_TTY_TITLE-1 ; strlcpy( da->title, data, len+1 ); //buf[len] = 0; SYS_FREE_O(_text); w_set_title( &(da->w), da->w.title ); SYSCALL_RETURN_NOTHING; }
static void phantom_debug_window_loop() { static char buf[DEBBS+1]; int step = 0; int show = 's'; t_current_set_name("Debug Win"); // Which thread will receive typein for this window phantom_debug_window->owner = get_current_tid(); int wx = 600; #if CONF_NEW_CTTY if( t_new_ctty( get_current_tid() ) ) panic("console t_new_ctty"); #else // Need separate ctty t_set_ctty( get_current_tid(), wtty_init( WTTY_SMALL_BUF ) ); #endif // TODO HACK! Need ioctl to check num of bytes? wtty_t *tty; t_get_ctty( get_current_tid(), &tty ); while(1) { if(tty && !wtty_is_empty(tty)) { char c = wtty_getc( tty ); switch(c) { case '?': case'h': printf( "Commands:\n" "---------\n" "w\t- show windows list\n" "t\t- show threads list\n" "s\t- show stats\n" "p\t- show profiler\n" "d\t- dump threads to JSON\n" ); break; case 'p': // profiler case 't': //w_set_title( phantom_debug_window, "Threads" ); //show = c; //break; case 'w': //w_set_title( phantom_debug_window, "Windows" ); //show = c; //break; case 's': //w_set_title( phantom_debug_window, "Stats" ); show = c; break; case 'd': { json_output jo = { 0 }; json_start( &jo ); json_dump_threads( &jo ); json_stop( &jo ); } break; } } { static char old_show = 0; if( old_show != show ) { old_show = show; switch(show) { case 't': w_set_title( phantom_debug_window, "Threads" ); break; case 'w': w_set_title( phantom_debug_window, "Windows" ); break; case 's': w_set_title( phantom_debug_window, "Stats" ); break; case 'p': w_set_title( phantom_debug_window, "Profiler" ); break; } } } //hal_sleep_msec(1000); hal_sleep_msec(100); #if 1 #if 1 w_clear( phantom_debug_window ); ttyd = DEBWIN_YS-20; ttxd = 0; #endif //put_progress(); void *bp = buf; int len = DEBBS; int rc; time_t sec = uptime(); int min = sec/60; sec %= 60; int hr = min/60; min %= 60; int days = hr/24; hr %= 24; struct tm mt = *current_time; rc = snprintf(bp, len, " View: \x1b[32mt\x1b[37mhreads \x1b[32ms\x1b[37mtats \x1b[32mw\x1b[37mindows \x1b[32mp\x1b[37mrofile \x1b[32m?\x1b[37m - help\n \x1b[32mStep %d, uptime %dd, %02d:%02d:%02d\x1b[37m, %d events\n Time %04d/%02d/%02d %02d:%02d:%02d GMT, CPU 0 %2d%% idle\n", step++, days, hr, min, (int)sec, ev_get_n_events_in_q(), mt.tm_year + 1900, mt.tm_mon, mt.tm_mday, mt.tm_hour, mt.tm_min, mt.tm_sec, 100-percpu_cpu_load[0] ); bp += rc; len -= rc; switch(show) { case 't': default: phantom_dump_threads_buf(bp,len); break; case 'w': phantom_dump_windows_buf(bp,len); break; case 's': phantom_dump_stats_buf(bp,len); break; case 'p': phantom_dump_profiler_buf(bp,len); break; } phantom_debug_window_puts(buf); if(wx == 600) wx = 620; else wx = 600; //w_move( phantom_debug_window, wx, 50 ); #endif put_progress(); w_update( phantom_debug_window ); } }