?? monitor.c
字號:
suffix, addr, size * 2, val);}static void do_system_reset(void){ qemu_system_reset_request();}static void do_system_powerdown(void){ qemu_system_powerdown_request();}#if defined(TARGET_I386)static void print_pte(uint32_t addr, uint32_t pte, uint32_t mask){ term_printf("%08x: %08x %c%c%c%c%c%c%c%c\n", addr, pte & mask, pte & PG_GLOBAL_MASK ? 'G' : '-', pte & PG_PSE_MASK ? 'P' : '-', pte & PG_DIRTY_MASK ? 'D' : '-', pte & PG_ACCESSED_MASK ? 'A' : '-', pte & PG_PCD_MASK ? 'C' : '-', pte & PG_PWT_MASK ? 'T' : '-', pte & PG_USER_MASK ? 'U' : '-', pte & PG_RW_MASK ? 'W' : '-');}static void tlb_info(void){ CPUState *env; int l1, l2; uint32_t pgd, pde, pte; env = mon_get_cpu(); if (!env) return; if (!(env->cr[0] & CR0_PG_MASK)) { term_printf("PG disabled\n"); return; } pgd = env->cr[3] & ~0xfff; for(l1 = 0; l1 < 1024; l1++) { cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4); pde = le32_to_cpu(pde); if (pde & PG_PRESENT_MASK) { if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { print_pte((l1 << 22), pde, ~((1 << 20) - 1)); } else { for(l2 = 0; l2 < 1024; l2++) { cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, (uint8_t *)&pte, 4); pte = le32_to_cpu(pte); if (pte & PG_PRESENT_MASK) { print_pte((l1 << 22) + (l2 << 12), pte & ~PG_PSE_MASK, ~0xfff); } } } } }}static void mem_print(uint32_t *pstart, int *plast_prot, uint32_t end, int prot){ int prot1; prot1 = *plast_prot; if (prot != prot1) { if (*pstart != -1) { term_printf("%08x-%08x %08x %c%c%c\n", *pstart, end, end - *pstart, prot1 & PG_USER_MASK ? 'u' : '-', 'r', prot1 & PG_RW_MASK ? 'w' : '-'); } if (prot != 0) *pstart = end; else *pstart = -1; *plast_prot = prot; }}static void mem_info(void){ CPUState *env; int l1, l2, prot, last_prot; uint32_t pgd, pde, pte, start, end; env = mon_get_cpu(); if (!env) return; if (!(env->cr[0] & CR0_PG_MASK)) { term_printf("PG disabled\n"); return; } pgd = env->cr[3] & ~0xfff; last_prot = 0; start = -1; for(l1 = 0; l1 < 1024; l1++) { cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4); pde = le32_to_cpu(pde); end = l1 << 22; if (pde & PG_PRESENT_MASK) { if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK); mem_print(&start, &last_prot, end, prot); } else { for(l2 = 0; l2 < 1024; l2++) { cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, (uint8_t *)&pte, 4); pte = le32_to_cpu(pte); end = (l1 << 22) + (l2 << 12); if (pte & PG_PRESENT_MASK) { prot = pte & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK); } else { prot = 0; } mem_print(&start, &last_prot, end, prot); } } } else { prot = 0; mem_print(&start, &last_prot, end, prot); } }}#endifstatic void do_info_kqemu(void){#ifdef USE_KQEMU CPUState *env; int val; val = 0; env = mon_get_cpu(); if (!env) { term_printf("No cpu initialized yet"); return; } val = env->kqemu_enabled; term_printf("kqemu support: "); switch(val) { default: case 0: term_printf("disabled\n"); break; case 1: term_printf("enabled for user code\n"); break; case 2: term_printf("enabled for user and kernel code\n"); break; }#else term_printf("kqemu support: not compiled\n");#endif}#ifdef CONFIG_PROFILERint64_t kqemu_time;int64_t qemu_time;int64_t kqemu_exec_count;int64_t dev_time;int64_t kqemu_ret_int_count;int64_t kqemu_ret_excp_count;int64_t kqemu_ret_intr_count;static void do_info_profile(void){ int64_t total; total = qemu_time; if (total == 0) total = 1; term_printf("async time %" PRId64 " (%0.3f)\n", dev_time, dev_time / (double)ticks_per_sec); term_printf("qemu time %" PRId64 " (%0.3f)\n", qemu_time, qemu_time / (double)ticks_per_sec); term_printf("kqemu time %" PRId64 " (%0.3f %0.1f%%) count=%" PRId64 " int=%" PRId64 " excp=%" PRId64 " intr=%" PRId64 "\n", kqemu_time, kqemu_time / (double)ticks_per_sec, kqemu_time / (double)total * 100.0, kqemu_exec_count, kqemu_ret_int_count, kqemu_ret_excp_count, kqemu_ret_intr_count); qemu_time = 0; kqemu_time = 0; kqemu_exec_count = 0; dev_time = 0; kqemu_ret_int_count = 0; kqemu_ret_excp_count = 0; kqemu_ret_intr_count = 0;#ifdef USE_KQEMU kqemu_record_dump();#endif}#elsestatic void do_info_profile(void){ term_printf("Internal profiler not compiled\n");}#endif/* Capture support */static LIST_HEAD (capture_list_head, CaptureState) capture_head;static void do_info_capture (void){ int i; CaptureState *s; for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) { term_printf ("[%d]: ", i); s->ops.info (s->opaque); }}static void do_stop_capture (int n){ int i; CaptureState *s; for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) { if (i == n) { s->ops.destroy (s->opaque); LIST_REMOVE (s, entries); qemu_free (s); return; } }}#ifdef HAS_AUDIOint wav_start_capture (CaptureState *s, const char *path, int freq, int bits, int nchannels);static void do_wav_capture (const char *path, int has_freq, int freq, int has_bits, int bits, int has_channels, int nchannels){ CaptureState *s; s = qemu_mallocz (sizeof (*s)); if (!s) { term_printf ("Not enough memory to add wave capture\n"); return; } freq = has_freq ? freq : 44100; bits = has_bits ? bits : 16; nchannels = has_channels ? nchannels : 2; if (wav_start_capture (s, path, freq, bits, nchannels)) { term_printf ("Faied to add wave capture\n"); qemu_free (s); } LIST_INSERT_HEAD (&capture_head, s, entries);}#endifstatic term_cmd_t term_cmds[] = { { "help|?", "s?", do_help, "[cmd]", "show the help" }, { "commit", "s", do_commit, "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" }, { "info", "s?", do_info, "subcommand", "show various information about the system state" }, { "q|quit", "", do_quit, "", "quit the emulator" }, { "eject", "-fB", do_eject, "[-f] device", "eject a removable medium (use -f to force it)" }, { "change", "BF", do_change, "device filename", "change a removable medium" }, { "screendump", "F", do_screen_dump, "filename", "save screen into PPM image 'filename'" }, { "logfile", "s", do_logfile, "filename", "output logs to 'filename'" }, { "log", "s", do_log, "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, { "savevm", "s?", do_savevm, "tag|id", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" }, { "loadvm", "s", do_loadvm, "tag|id", "restore a VM snapshot from its tag or id" }, { "delvm", "s", do_delvm, "tag|id", "delete a VM snapshot from its tag or id" }, { "stop", "", do_stop, "", "stop emulation", }, { "c|cont", "", do_cont, "", "resume emulation", },#ifdef CONFIG_GDBSTUB { "gdbserver", "s?", do_gdbserver, "[port]", "start gdbserver session (default port=1234)", },#endif { "x", "/l", do_memory_dump, "/fmt addr", "virtual memory dump starting at 'addr'", }, { "xp", "/l", do_physical_memory_dump, "/fmt addr", "physical memory dump starting at 'addr'", }, { "p|print", "/l", do_print, "/fmt expr", "print expression value (use $reg for CPU register access)", }, { "i", "/ii.", do_ioport_read, "/fmt addr", "I/O port read" }, { "sendkey", "s", do_send_key, "keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" }, { "system_reset", "", do_system_reset, "", "reset the system" }, { "system_powerdown", "", do_system_powerdown, "", "send system power down event" }, { "sum", "ii", do_sum, "addr size", "compute the checksum of a memory region" }, { "usb_add", "s", do_usb_add, "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" }, { "usb_del", "s", do_usb_del, "device", "remove USB device 'bus.addr'" }, { "cpu", "i", do_cpu_set, "index", "set the default CPU" }, { "mouse_move", "sss?", do_mouse_move, "dx dy [dz]", "send mouse move events" }, { "mouse_button", "i", do_mouse_button, "state", "change mouse button state (1=L, 2=M, 4=R)" }, { "mouse_set", "i", do_mouse_set, "index", "set which mouse device receives events" },#ifdef HAS_AUDIO { "wavcapture", "si?i?i?", do_wav_capture, "path [frequency bits channels]", "capture audio to a wave file (default frequency=44100 bits=16 channels=2)" },#endif { "stopcapture", "i", do_stop_capture, "capture index", "stop capture" }, { "memsave", "lis", do_memory_save, "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, { NULL, NULL, },};static term_cmd_t info_cmds[] = { { "version", "", do_info_version, "", "show the version of qemu" }, { "network", "", do_info_network, "", "show the network state" }, { "block", "", do_info_block, "", "show the block devices" }, { "blockstats", "", do_info_blockstats, "", "show block device statistics" }, { "registers", "", do_info_registers, "", "show the cpu registers" }, { "cpus", "", do_info_cpus, "", "show infos for each CPU" }, { "history", "", do_info_history, "", "show the command line history", }, { "irq", "", irq_info, "", "show the interrupts statistics (if available)", }, { "pic", "", pic_info, "", "show i8259 (PIC) state", }, { "pci", "", pci_info, "", "show PCI info", },#if defined(TARGET_I386) { "tlb", "", tlb_info, "", "show virtual to physical memory mappings", }, { "mem", "", mem_info, "", "show the active virtual memory mappings", },#endif { "jit", "", do_info_jit, "", "show dynamic compiler info", }, { "kqemu", "", do_info_kqemu, "", "show kqemu information", }, { "usb", "", usb_info, "", "show guest USB devices", }, { "usbhost", "", usb_host_info, "", "show host USB devices", }, { "profile", "", do_info_profile, "", "show profiling information", }, { "capture", "", do_info_capture, "", "show capture information" }, { "snapshots", "", do_info_snapshots, "", "show the currently saved VM snapshots" }, { "pcmcia", "", pcmcia_info, "", "show guest PCMCIA status" }, { "mice", "", do_info_mice, "", "show which guest mouse is receiving events" }, { "vnc", "", do_info_vnc, "", "show the vnc server status"}, { "name", "", do_info_name, "", "show the current VM name" },#if defined(TARGET_PPC) { "cpustats", "", do_info_cpu_stats, "", "show CPU statistics", },#endif#if defined(CONFIG_SLIRP) { "slirp", "", do_info_slirp, "", "show SLIRP statistics", },#endif { NULL, NULL, },};/*******************************************************************/static const char *pch;static jmp_buf expr_env;#define MD_TLONG 0#define MD_I32 1typedef struct MonitorDef { const char *name; int offset; target_long (*get_value)(struct MonitorDef *md, int val); int type;} MonitorDef;#if defined(TARGET_I386)static target_long monitor_get_pc (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); if (!env) return 0; return env->eip + env->segs[R_CS].base;}#endif#if defined(TARGET_PPC)static target_long monitor_get_ccr (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); unsigned int u; int i; if (!env) return 0; u = 0; for (i = 0; i < 8; i++) u |= env->crf[i] << (32 - (4 * i)); return u;}static target_long monitor_get_msr (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); if (!env) return 0; return env->msr;}static target_long monitor_get_xer (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); if (!env) return 0; return ppc_load_xer(env);}static target_long monitor_get_decr (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); if (!env) return 0; return cpu_ppc_load_decr(env);}static target_long monitor_get_tbu (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); if (!env) return 0; return cpu_ppc_load_tbu(env);}static target_long monitor_get_tbl (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); if (!env) return 0; return cpu_ppc_load_tbl(env);}#endif#if defined(TARGET_SPARC)#ifndef TARGET_SPARC64static target_long monitor_get_psr (struct MonitorDef *md, int val){ CPUState *env = mon_get_cpu(); if (!env) return 0; return GET_PSR(env);}#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -