This commit makes the code for info_cpus simpler in monitor.c Signed-off-by: Glauber Costa <[EMAIL PROTECTED]> --- exec-all.h | 2 ++ monitor.c | 17 +++++------------ target-alpha/helper.c | 2 ++ target-arm/helper.c | 2 ++ target-cris/helper.c | 2 ++ target-i386/helper.c | 6 ++++++ target-m68k/helper.c | 2 ++ target-mips/helper.c | 2 ++ target-ppc/helper.c | 6 ++++++ target-sh4/helper.c | 2 ++ target-sparc/helper.c | 6 ++++++ 11 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/exec-all.h b/exec-all.h index 0c36c04..072172c 100644 --- a/exec-all.h +++ b/exec-all.h @@ -77,6 +77,8 @@ int cpu_restore_state_copy(struct TranslationBlock *tb, void cpu_resume_from_signal(CPUState *env1, void *puc); void cpu_exec_init(CPUState *env); +extern int cpu_info_ip(CPUState *env, char *buf); + int page_unprotect(target_ulong address, unsigned long pc, void *puc); void tb_invalidate_phys_page_range(target_phys_addr_t start, target_phys_addr_t end, int is_cpu_write_access); diff --git a/monitor.c b/monitor.c index 5a9a7fa..406f6d2 100644 --- a/monitor.c +++ b/monitor.c @@ -36,6 +36,8 @@ #include "disas.h" #include <dirent.h> +#include "exec-all.h" + #ifdef CONFIG_PROFILER #include "qemu-timer.h" /* for ticks_per_sec */ #endif @@ -304,6 +306,7 @@ static void do_info_registers(void) static void do_info_cpus(void) { CPUState *env; + char buf[1024]; /* just to set the default cpu if not already done */ mon_get_cpu(); @@ -312,18 +315,8 @@ static void do_info_cpus(void) term_printf("%c CPU #%d:", (env == mon_cpu) ? '*' : ' ', env->cpu_index); -#if defined(TARGET_I386) - term_printf(" pc=0x" TARGET_FMT_lx, env->eip + env->segs[R_CS].base); -#elif defined(TARGET_PPC) - term_printf(" nip=0x" TARGET_FMT_lx, env->nip); -#elif defined(TARGET_SPARC) - term_printf(" pc=0x" TARGET_FMT_lx " npc=0x" TARGET_FMT_lx, env->pc, env->npc); -#elif defined(TARGET_MIPS) - term_printf(" PC=0x" TARGET_FMT_lx, env->PC[env->current_tc]); -#endif - if (env->halted) - term_printf(" (halted)"); - term_printf("\n"); + if (cpu_info_ip(env, buf)) + term_printf("%s %s\n", buf, env->halted ? "(halted)" : ""); } } diff --git a/target-alpha/helper.c b/target-alpha/helper.c index fd39f5f..507929e 100644 --- a/target-alpha/helper.c +++ b/target-alpha/helper.c @@ -452,3 +452,5 @@ void cpu_dump_EA (target_ulong EA) f = stdout; fprintf(f, "Memory access at address " TARGET_FMT_lx "\n", EA); } + +int cpu_info_ip(CPUState *env, char *buf) { return 0; } diff --git a/target-arm/helper.c b/target-arm/helper.c index 8e85435..8dd6209 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2522,3 +2522,5 @@ uint32_t HELPER(rsqrte_u32)(uint32_t a, CPUState *env) tmp = float32_scalbn(tmp, 31, s); return float32_to_int32(tmp, s); } + +int cpu_info_ip(CPUState *env, char *buf) { return 0; } diff --git a/target-cris/helper.c b/target-cris/helper.c index c16a58a..5e566b4 100644 --- a/target-cris/helper.c +++ b/target-cris/helper.c @@ -182,3 +182,5 @@ target_phys_addr_t cpu_get_phys_page_debug(CPUState * env, target_ulong addr) return phy; } #endif + +int cpu_info_ip(CPUState *env, char *buf) { return 0; } diff --git a/target-i386/helper.c b/target-i386/helper.c index f993fa7..997e377 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -779,6 +779,12 @@ void cpu_x86_flush_tlb(CPUX86State *env, target_ulong addr) tlb_flush_page(env, addr); } +int cpu_info_ip(CPUState *env, char *buf) +{ + sprintf(buf, " pc=0x" TARGET_FMT_lx, env->eip + env->segs[R_CS].base); + return 1; +} + #if defined(CONFIG_USER_ONLY) int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, diff --git a/target-m68k/helper.c b/target-m68k/helper.c index 7f01392..4503006 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -880,3 +880,5 @@ void HELPER(set_mac_extu)(CPUState *env, uint32_t val, uint32_t acc) res |= (uint64_t)(val & 0xffff0000) << 16; env->macc[acc + 1] = res; } + +int cpu_info_ip(CPUState *env, char *buf) { return 0; } diff --git a/target-mips/helper.c b/target-mips/helper.c index b962295..3e0b172 100644 --- a/target-mips/helper.c +++ b/target-mips/helper.c @@ -636,3 +636,5 @@ void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra) } } } + +int cpu_info_ip(CPUState *env, char *buf) { return 0; } diff --git a/target-ppc/helper.c b/target-ppc/helper.c index 2a52dc6..464a92e 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -2988,3 +2988,9 @@ void cpu_ppc_close (CPUPPCState *env) /* Should also remove all opcode tables... */ qemu_free(env); } + +int cpu_info_ip(CPUState *env, char *buf) +{ + sprintf(buf, " nip=0x" TARGET_FMT_lx, env->nip); + return 1; +} diff --git a/target-sh4/helper.c b/target-sh4/helper.c index 917f02f..1e5ca19 100644 --- a/target-sh4/helper.c +++ b/target-sh4/helper.c @@ -534,3 +534,5 @@ void cpu_load_tlb(CPUState * env) } #endif + +int cpu_info_ip(CPUState *env, char *buf) { return 0; } diff --git a/target-sparc/helper.c b/target-sparc/helper.c index 8bf40e4..9b6eba4 100644 --- a/target-sparc/helper.c +++ b/target-sparc/helper.c @@ -1525,6 +1525,12 @@ void cpu_dump_state(CPUState *env, FILE *f, cpu_fprintf(f, "fsr: 0x%08x\n", GET_FSR32(env)); } +int cpu_info_ip(CPUState *env, char *buf) +{ + sprintf(buf, " pc=0x" TARGET_FMT_lx " npc=0x" TARGET_FMT_lx, env->pc, env->npc); + return 1; +} + #ifdef TARGET_SPARC64 #if !defined(CONFIG_USER_ONLY) #include "qemu-common.h" -- 1.5.4.5 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html