bool debug_ask(Machine *pmach){ char input[NMAX]; while(1){ printf("DEBUG? "); gets(input); if(strcmp(input,"h")==0){ printf("h\thelp\n"); printf("c\tcontinue(exit interactive debug mode)\n"); printf("s\tstep by step(next instruction)\n"); printf("RET\tstep by step(next instruction)\n"); printf("r\tprint registers\n"); printf("d\tprint data memory\n"); printf("t\tprint text(program) memory\n"); printf("p\tprint text(program) memory\n"); printf("m\tprint registers and data memory\n"); } if(strcmp(input,"c")==0) return false; if(strcmp(input,"r")==0) print_cpu(pmach); if(strcmp(input,"RET")==0 || strcmp(input,"s")==0 || strcmp(input,"\0")==0) return true; if(strcmp(input,"d")==0) print_data(pmach); if(strcmp(input,"t")==0) print_program(pmach); if(strcmp(input,"p")==0) print_program(pmach); if(strcmp(input,"m")==0){ print_cpu(pmach); print_data(pmach); } } return true; }
void cpu_print_filter(pid_t pid) { EUID_ASSERT(); // if the pid is that of a firejail process, use the pid of the first child process EUID_ROOT(); // grsecurity char *comm = pid_proc_comm(pid); EUID_USER(); // grsecurity if (comm) { if (strcmp(comm, "firejail") == 0) { pid_t child; if (find_child(pid, &child) == 0) { pid = child; } } free(comm); } // check privileges for non-root users uid_t uid = getuid(); if (uid != 0) { uid_t sandbox_uid = pid_get_uid(pid); if (uid != sandbox_uid) { fprintf(stderr, "Error: permission denied.\n"); exit(1); } } print_cpu(pid); exit(0); }
static int sched_debug_show(struct seq_file *m, void *v) { u64 now = ktime_to_ns(ktime_get()); int cpu; SEQ_printf(m, "Sched Debug Version: v0.09, %s %.*s\n", init_utsname()->release, (int)strcspn(init_utsname()->version, " "), init_utsname()->version); SEQ_printf(m, "now at %Lu.%06ld msecs\n", SPLIT_NS(now)); #define P(x) \ SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x)) #define PN(x) \ SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) P(jiffies); PN(sysctl_sched_latency); PN(sysctl_sched_min_granularity); PN(sysctl_sched_wakeup_granularity); PN(sysctl_sched_child_runs_first); P(sysctl_sched_features); #undef PN #undef P for_each_online_cpu(cpu) print_cpu(m, cpu); SEQ_printf(m, "\n"); return 0; }
int main(int argc, char** argv) { printf(PIPEMENU_BEGIN); print_cpu(0, count_cpus()); printf(PIPEMENU_END); return 0; }
static int sched_debug_show(struct seq_file *m, void *v) { u64 ktime, sched_clk, cpu_clk; unsigned long flags; int cpu; local_irq_save(flags); ktime = ktime_to_ns(ktime_get()); sched_clk = sched_clock(); cpu_clk = local_clock(); local_irq_restore(flags); SEQ_printf(m, "Sched Debug Version: v0.10, %s %.*s\n", init_utsname()->release, (int)strcspn(init_utsname()->version, " "), init_utsname()->version); #define P(x) \ SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x)) #define PN(x) \ SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) PN(ktime); PN(sched_clk); PN(cpu_clk); P(jiffies); #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK P(sched_clock_stable); #endif #undef PN #undef P SEQ_printf(m, "\n"); SEQ_printf(m, "sysctl_sched\n"); #define P(x) \ SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x)) #define PN(x) \ SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) PN(sysctl_sched_latency); PN(sysctl_sched_min_granularity); PN(sysctl_sched_wakeup_granularity); P(sysctl_sched_child_runs_first); P(sysctl_sched_features); #undef PN #undef P SEQ_printf(m, " .%-40s: %d (%s)\n", "sysctl_sched_tunable_scaling", sysctl_sched_tunable_scaling, sched_tunable_scaling_names[sysctl_sched_tunable_scaling]); read_lock_irqsave(&tasklist_lock, flags); //for_each_online_cpu(cpu) for_each_possible_cpu(cpu) print_cpu(m, cpu); read_unlock_irqrestore(&tasklist_lock, flags); SEQ_printf(m, "\n"); return 0; }
void sysrq_sched_debug_show(void) { int cpu; sched_debug_header(NULL); for_each_online_cpu(cpu) print_cpu(NULL, cpu); }
int registers_cmd(struct _6510_cpu* cpu, char memory[][9], char* string){ char regname[5] = "1234"; char buffer_reg[8+1] = "00000000"; int key, content=-1; int i; // mon> mem af 02 ; mam[af] <- 02 sscanf(string, " %*s %s %2x ", &(regname[0]), &content); key = -1; for(i=0;names[i]!=NULL;i++){ if(strcmp(regname,names[i])==0){ key=i; break; } } if(content!=-1){ int2register(content, buffer_reg); switch(key) { case ACC: cp_register(buffer_reg, cpu->rega); break; case ABRL: cp_register(buffer_reg, cpu->abrl); break; case ABRH: cp_register(buffer_reg, cpu->abrh); break; case DBR: cp_register(buffer_reg, cpu->dbr); break; case IDX: cp_register(buffer_reg, cpu->regx); break; case IDY: cp_register(buffer_reg, cpu->regy); break; case PCL: cp_register(buffer_reg, cpu->pcl); break; case PCH: cp_register(buffer_reg, cpu->pch); break; case IR: cp_register(buffer_reg, cpu->ir); break; case SP: cp_register(buffer_reg, cpu->sp); break; default: break; } } print_cpu(cpu); return 1; }
/*! * Cette fonction gère le dialogue pour l'option \c -d (debug). Dans ce mode, * elle est invoquée après l'exécution de chaque instruction. Elle affiche le * menu de mise au point et on exécute le choix de l'utilisateur. Si cette * fonction retourne faux, on abandonne le mode de mise au point interactive * pour les instructions suivantes et jusqu'à la fin du programme. * * \param mach la machine/programme en cours de simulation * \return vrai si l'on doit continuer en mode debug, faux sinon */ bool debug_ask(Machine *pmach){ printf("DEBUG? "); char commande = '\n'; bool premier = true; char rep; while( (rep=getchar()) != '\n' && rep != EOF){ if(premier) commande = rep; premier = false; }; switch(commande){ case 'h': printf("Available commands :\n\th\thelp\n\tc\tcontinue (exit interactive debug mode)\n\ts\tstep by step (next instruction)\n\tRET\tstep by step (next instruction)\n\tr\tprint registers\n\td\tprint data memory\n\tt\tprint text (program) memory\n\tp\tprint text (program) memory\n\tm\tprint registers and data memory\n"); break; case 'c': return false; break; case 's': return true; break; case 'r': print_cpu(pmach); break; case 'd': print_data(pmach); break; case 't': print_program(pmach); break; case 'p': print_program(pmach); break; case 'm': print_cpu(pmach); print_data(pmach); break; case '\n': return true; break; default: break; } return debug_ask(pmach); }
static int sched_debug_show(struct seq_file *m, void *v) { int cpu = (unsigned long)(v - 2); if (cpu != -1) print_cpu(m, cpu); else sched_debug_header(m); return 0; }
int main(void) { FILE *fp_mail; char *status = (char *)alloca(200); int b, d, m; b = BATTERY_INTERVAL; d = DATE_INTERVAL; m = MAIL_INTERVAL; struct timespec interval = { .tv_sec = UPDATE_INTERVAL, .tv_nsec = 0 }; int sockfd = socket(AF_INET, SOCK_DGRAM, 0); for ( ; ; nanosleep(&interval, NULL)) { if (++b > BATTERY_INTERVAL) { print_battery(); b = 0; } if (++d > DATE_INTERVAL) { print_time(); d = 0; } if (++m > MAIL_INTERVAL) { if (print_mail(fp_mail) == 0) { m = 0; } if (errno == EBADF) { fp_mail = mail_init(); } } if (sockfd != -1) { print_iw(sockfd); } strncpy(_root, print_free("/"), _FREE_LEN); strncpy(_home, print_free("/home"), _FREE_LEN); print_time(); print_cpu(); print_memory(); snprintf(status, 200, "%s %s | %s | %s | %s | %s | %s | %s" , _root, _home, _iw, _battery, _mail, _cpu , _mem, _date); printf("%s\n", status); }//break; } pclose(fp_mail); cleanup(sockfd); } double get_battery_stats(const char *path) { FILE *stats; double value = 0; if ((stats = fopen(path, "r"))== NULL) { return -1; } fscanf(stats, "%lf", &value); fclose(stats); return value; }
void *load_check(void *param) { //int n=(int)param; cpu_t cpu1, cpu2; while(1) { cpu_t *p_cpu1 = cpu_check(&cpu1); sleep(1); cpu_t *p_cpu2 = cpu_check(&cpu2); print_cpu(p_cpu1, p_cpu2); } pthread_exit(0); }
void Summary::print() { print_versions(); print_memory(); print_cpu(); print_threads(); print_pools(); # ifndef XMRIG_NO_API print_api(); # endif print_commands(); }
static int timer_list_show(struct seq_file *m, void *v) { struct timer_list_iter *iter = v; if (iter->cpu == -1 && !iter->second_pass) timer_list_header(m, iter->now); else if (!iter->second_pass) print_cpu(m, iter->cpu, iter->now); #ifdef CONFIG_GENERIC_CLOCKEVENTS else if (iter->cpu == -1 && iter->second_pass) timer_list_show_tickdevices_header(m); else print_tickdevice(m, tick_get_device(iter->cpu), iter->cpu); #endif return 0; }
void cpu(pid_t pid) { if (getuid() == 0) firemon_drop_privs(); pid_read(pid); // print processes int i; for (i = 0; i < max_pids; i++) { if (pids[i].level == 1) { pid_print_list(i, 0); int child = find_child(i); if (child != -1) print_cpu(child); } } }
int print_hub(t_taupe *taupe) { wclear(taupe->top->win); print_sys(taupe->sys, taupe->top); print_task(taupe->task, taupe->top); print_cpu(taupe->cpu, taupe->top); print_mem(taupe->mem, taupe->top); if (taupe->signal->on) { print_opt(taupe->signal, "Send Signal"); print_signal(taupe->signal, taupe->pid); } else if (taupe->sort->on) print_opt(taupe->sort, "Sort By"); print_main(taupe); return (0); }
void sysrq_timer_list_show(void) { u64 now = ktime_to_ns(ktime_get()); int cpu; timer_list_header(NULL, now); for_each_online_cpu(cpu) print_cpu(NULL, cpu, now); #ifdef CONFIG_GENERIC_CLOCKEVENTS timer_list_show_tickdevices_header(NULL); for_each_online_cpu(cpu) print_tickdevice(NULL, tick_get_device(cpu), cpu); #endif return; }
void cpu(void) { if (getuid() == 0) firemon_drop_privs(); pid_read(0); // include all processes // print processes int i; for (i = 0; i < MAX_PIDS; i++) { if (pids[i].level == 1) { pid_print_list(i, 0); int child = find_child(i); if (child != -1) print_cpu(child); } } }
static int timer_list_show(struct seq_file *m, void *v) { u64 now = ktime_to_ns(ktime_get()); int cpu; SEQ_printf(m, "Timer List Version: v0.6\n"); SEQ_printf(m, "HRTIMER_MAX_CLOCK_BASES: %d\n", HRTIMER_MAX_CLOCK_BASES); SEQ_printf(m, "now at %Ld nsecs\n", (unsigned long long)now); for_each_online_cpu(cpu) print_cpu(m, cpu, now); SEQ_printf(m, "\n"); timer_list_show_tickdevices(m); return 0; }
PUBLIC void root_cpuinfo(void) { struct cpu_info cpu_info[CONFIG_MAX_CPUS]; struct machine machine; unsigned c; if (sys_getmachine(&machine)) { printf("PROCFS: cannot get machine\n"); return; } if (sys_getcpuinfo(&cpu_info)) { printf("PROCFS: cannot get cpu info\n"); return; } for (c = 0; c < machine.processors_count; c++) print_cpu(&cpu_info[c], c); }
/*! * Options de la ligne de commande : * * <dl> * <dt>-d</dt><dd>mode pas à pas (mise au point)</dd> * * <dt>-f</dt><dd>le programme est dans un fichier binaire ; le nom de ce * fichier doit être fourni également en paramètre de la ligne de * commande ; sans cette option, on exécute un programme de test prédéfini.</dd> * * </dl> */ int main(int argc, char *argv[]) { bool debug = false; bool binfile = false; bool no_exec = false; char *programfile = NULL; if (argc > 1) { for (int iarg = 1; iarg < argc; ++iarg) { if (argv[iarg][0] == '-') switch (argv[iarg][1]) { case 'd': debug = true; break; case 'b': binfile = true; break; case 'l': no_exec = true; break; case 'h': usage(); exit(EXIT_SUCCESS); default: fprintf(stderr, "Unknown option: %s\n", argv[iarg]); usage(); exit(EXIT_FAILURE); } else if (binfile) programfile = argv[iarg]; else fprintf(stderr, "Trailing options ignored...\n"); } } Machine mach; if (!binfile) load_program(&mach, textsize, text, datasize, data, dataend); else read_program(&mach, programfile); printf("\n*** Sauvegarde des programmes et données initiales en format binaire ***\n\n"); dump_memory(&mach); printf("\n*** Machine state before execution ***\n"); print_program(&mach); print_data(&mach); print_cpu(&mach); if (no_exec) return 0; printf("\n*** Execution trace ***\n\n"); simul(&mach, debug); printf("\n*** Machine state after execution ***\n"); print_cpu(&mach); print_data(&mach); if(allocated){ free(mach._text); free(mach._data); } return 0; }
int ls_cmd(struct _6510_cpu* cpu, char memory[][9], char* string){ print_cpu(cpu); return 1; }
void print_cpu(unsigned int cpu, unsigned int n_cpus) { int i; char str[MAXLEN]; char premark[MAXLEN]; char postmark[MAXLEN]; unsigned long curfreq, freq; struct cpufreq_available_frequencies* freqs; struct cpufreq_available_governors* govs; struct cpufreq_policy* policy; if (cpu + 1 == n_cpus) // last cpu column printf("<item label='cpu %u'/>\n", cpu); else if (cpu + 1 < n_cpus) { printf("<menu label='cpu %u' id='obcpufreq-cpu%u'>\n", cpu, cpu + 1); print_cpu(cpu + 1, n_cpus); printf("</menu>\n"); } printf(SEPARATOR); curfreq = cpufreq_get_freq_kernel(cpu); policy = cpufreq_get_policy(cpu); // print available governors govs = cpufreq_get_available_governors(cpu); if (govs) { printf("<menu label='governors' id='obcpufreq-governors%u'>\n", cpu); for (; govs; govs = govs->next) { premark[0] = ' '; premark[1] = '\0'; if (!strcmp(govs->governor, policy->governor)) premark[0] = '*'; printf(" <item label='%s%s'><action name='Execute'><command>" CPUFREQ_SET " --cpu %u -g %s</command></action></item>\n", premark, govs->governor, cpu, govs->governor); } printf("</menu>\n"); cpufreq_put_available_governors(govs); } else printf("<item label='%s'/>\n", "no available governors"); printf(SEPARATOR); // print available freqs freqs = cpufreq_get_available_frequencies(cpu); if (freqs) { for (i = 0; freqs; freqs = freqs->next, i++) { freq = freqs->frequency; get_human_speed(str, freq); premark[0] = ' '; premark[1] = '\0'; if (freq == curfreq) premark[0] = '*'; postmark[0] = '\0'; if (policy) { if (freq == policy->max && freq == policy->min) strcpy(postmark, " (max,min)"); else if (freq == policy->max) strcpy(postmark, " (max)"); else if (freq == policy->min) strcpy(postmark, " (min)"); } printf("<menu label='%s%s%s' id='obcpufreq-freq%d'>\n" " <item label='set as max'><action name='Execute'><command>" CPUFREQ_SET " --cpu %u --max %lu</command></action></item>\n" " <item label='set as min'><action name='Execute'><command>" CPUFREQ_SET " --cpu %u --min %lu</command></action></item>\n</menu>\n", premark, str, postmark, i, cpu, freqs->frequency, cpu, freqs->frequency); } cpufreq_put_available_frequencies(freqs); } else printf("<item label='%s'/>\n", "no available freqs"); cpufreq_put_policy(policy); return; }
static int sysinfo_cb (char *word[], char *word_eol[], void *userdata) { error_printed = 0; int announce = 0; int buffer; char format[bsize]; if (!hexchat_pluginpref_get_str (ph, "format", format)) { hexchat_printf (ph, "%s\tError reading config file!", name); return HEXCHAT_EAT_ALL; } if (hexchat_list_int (ph, NULL, "type") >= 2) { announce = 1; } if (!g_ascii_strcasecmp ("HELP", word[2])) { hexchat_printf (ph, sysinfo_help); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("LIST", word[2])) { list_settings (); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("SET", word[2])) { if (!g_ascii_strcasecmp ("", word_eol[4])) { hexchat_printf (ph, "%s\tEnter a value!\n", name); return HEXCHAT_EAT_ALL; } if (!g_ascii_strcasecmp ("format", word[3])) { hexchat_pluginpref_set_str (ph, "format", word_eol[4]); hexchat_printf (ph, "%s\tformat is set to: %s\n", name, word_eol[4]); } else if (!g_ascii_strcasecmp ("percent", word[3])) { buffer = atoi (word[4]); /* don't use word_eol, numbers must not contain spaces */ if (buffer > 0 && buffer < INT_MAX) { hexchat_pluginpref_set_int (ph, "percent", buffer); hexchat_printf (ph, "%s\tpercent is set to: %d\n", name, buffer); } else { hexchat_printf (ph, "%s\tInvalid input!\n", name); } } else if (!g_ascii_strcasecmp ("pciids", word[3])) { hexchat_pluginpref_set_str (ph, "pciids", word_eol[4]); hexchat_printf (ph, "%s\tpciids is set to: %s\n", name, word_eol[4]); } else { hexchat_printf (ph, "%s\tInvalid variable name! Use 'pciids', 'format' or 'percent'!\n", name); return HEXCHAT_EAT_ALL; } return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("RESET", word[2])) { reset_settings (); hexchat_printf (ph, "%s\tSettings have been restored to defaults.\n", name); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("OS", word[2])) { print_os (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("DISTRO", word[2])) { print_distro (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("CPU", word[2])) { print_cpu (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("RAM", word[2])) { print_ram (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("DISK", word[2])) { print_disk (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("VGA", word[2])) { print_vga (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("SOUND", word[2])) { print_sound (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("ETHERNET", word[2])) { print_ethernet (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("UPTIME", word[2])) { print_uptime (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("", word[2])) { print_summary (announce, format); return HEXCHAT_EAT_ALL; } else { hexchat_printf (ph, sysinfo_help); return HEXCHAT_EAT_ALL; } }
static void print_cfg(struct event_loop_config *elcfgs, unsigned int num_event_loops) { unsigned int i, j; unsigned int bridge_tos; struct event_loop_config *curloopcfg; struct stack_config *curstackcfg; struct interface_config *curifcfg; struct uinet_demo_config *curappcfg; unsigned int stack_index; unsigned int if_index; unsigned int app_index; int rxcpu, txcpu; for (i = 0; i < num_event_loops; i++) { curloopcfg = &elcfgs[i]; printf("Event loop [%s]: cpu=", curloopcfg->name); if (curloopcfg->cpu < 0) printf("auto"); else printf("%u", curloopcfg->cpu); printf("\n"); for (stack_index = 0; stack_index < curloopcfg->num_stacks; stack_index++) { curstackcfg = curloopcfg->scfgs[stack_index]; printf(" Stack instance [%s]: sts-mode=%s\n", curstackcfg->name, curstackcfg->sts ? "yes" : "no"); for (if_index = 0; if_index < curstackcfg->num_ifs; if_index++) { curifcfg = curstackcfg->ifcfgs[if_index]; printf(" Interface [%s (%s)]: type=%s rxbatch=%u txiqlen=%u gen=%s len=%u", curifcfg->ucfg.alias, curifcfg->ucfg.configstr, curifcfg->type_name, curifcfg->ucfg.rx_batch_size, curifcfg->ucfg.tx_inject_queue_len, curifcfg->generate ? "yes" : "no", curifcfg->generate ? curifcfg->gen_len : 0); printf(" bridge_to="); if (curifcfg->num_bridge_to) { for (j = 0; j < curifcfg->num_bridge_to; j++) { printf("%s%s (%s)", (j > 0) ? "," : "", curifcfg->bridge_to[j]->ucfg.alias, curifcfg->bridge_to[j]->ucfg.configstr); } } else printf("<none>"); if (curstackcfg->sts) txcpu = rxcpu = curloopcfg->cpu; else { txcpu = curifcfg->ucfg.tx_cpu; rxcpu = curifcfg->ucfg.rx_cpu; } print_cpu(" rxcpu", txcpu); print_cpu(" txcpu", txcpu); print_timestamp_mode(" tstamp", curifcfg->ucfg.timestamp_mode); switch (curifcfg->ucfg.type) { case UINET_IFTYPE_NETMAP: printf(" trace=0x%08x", curifcfg->ucfg.type_cfg.netmap.trace_mask); printf(" valebufs=%u", curifcfg->ucfg.type_cfg.netmap.vale_num_extra_bufs); break; case UINET_IFTYPE_PCAP: printf(" txio=%s", curifcfg->ucfg.type_cfg.pcap.use_file_io_thread ? "remote" : "local"); printf(" txsnaplen=%u", curifcfg->ucfg.type_cfg.pcap.file_snapshot_length); printf(" txfiles=%s", curifcfg->ucfg.type_cfg.pcap.file_per_flow ? "per-flow" : "single"); printf(" txmaxfds=%u", curifcfg->ucfg.type_cfg.pcap.max_concurrent_files); printf(" txdirbits=%u", curifcfg->ucfg.type_cfg.pcap.dir_bits); break; default: break; } printf("\n"); } if (if_index == 0) printf(" <no interfaces>\n"); for (app_index = 0; app_index < curstackcfg->num_apps; app_index++) { curappcfg = curstackcfg->acfgs[app_index]; printf(" %s [%s]: ", uinet_demo_name(curappcfg->which), curappcfg->name); uinet_demo_print_cfg(curappcfg); printf("\n"); } if (app_index == 0) printf(" <no apps>\n"); } if (stack_index == 0) printf(" <no stacks>\n"); } }