Commit 7fe48483cd90401de2477733ce65037ee0ed0906

Authored by bellard
1 parent 8e3a9fd2

monitor fixes


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1110 c046a42c-6fe2-441c-8c8c-71466251a162
cpu-all.h
@@ -570,7 +570,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); @@ -570,7 +570,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
570 #define cpu_exec cpu_x86_exec 570 #define cpu_exec cpu_x86_exec
571 #define cpu_gen_code cpu_x86_gen_code 571 #define cpu_gen_code cpu_x86_gen_code
572 #define cpu_signal_handler cpu_x86_signal_handler 572 #define cpu_signal_handler cpu_x86_signal_handler
573 -#define cpu_dump_state cpu_x86_dump_state  
574 573
575 #elif defined(TARGET_ARM) 574 #elif defined(TARGET_ARM)
576 575
@@ -579,7 +578,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); @@ -579,7 +578,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
579 #define cpu_exec cpu_arm_exec 578 #define cpu_exec cpu_arm_exec
580 #define cpu_gen_code cpu_arm_gen_code 579 #define cpu_gen_code cpu_arm_gen_code
581 #define cpu_signal_handler cpu_arm_signal_handler 580 #define cpu_signal_handler cpu_arm_signal_handler
582 -#define cpu_dump_state cpu_arm_dump_state  
583 581
584 #elif defined(TARGET_SPARC) 582 #elif defined(TARGET_SPARC)
585 583
@@ -588,7 +586,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); @@ -588,7 +586,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
588 #define cpu_exec cpu_sparc_exec 586 #define cpu_exec cpu_sparc_exec
589 #define cpu_gen_code cpu_sparc_gen_code 587 #define cpu_gen_code cpu_sparc_gen_code
590 #define cpu_signal_handler cpu_sparc_signal_handler 588 #define cpu_signal_handler cpu_sparc_signal_handler
591 -#define cpu_dump_state cpu_sparc_dump_state  
592 589
593 #elif defined(TARGET_PPC) 590 #elif defined(TARGET_PPC)
594 591
@@ -597,7 +594,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); @@ -597,7 +594,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
597 #define cpu_exec cpu_ppc_exec 594 #define cpu_exec cpu_ppc_exec
598 #define cpu_gen_code cpu_ppc_gen_code 595 #define cpu_gen_code cpu_ppc_gen_code
599 #define cpu_signal_handler cpu_ppc_signal_handler 596 #define cpu_signal_handler cpu_ppc_signal_handler
600 -#define cpu_dump_state cpu_ppc_dump_state  
601 597
602 #else 598 #else
603 599
@@ -607,6 +603,10 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); @@ -607,6 +603,10 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
607 603
608 #endif /* SINGLE_CPU_DEFINES */ 604 #endif /* SINGLE_CPU_DEFINES */
609 605
  606 +void cpu_dump_state(CPUState *env, FILE *f,
  607 + int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
  608 + int flags);
  609 +
610 void cpu_abort(CPUState *env, const char *fmt, ...); 610 void cpu_abort(CPUState *env, const char *fmt, ...);
611 extern CPUState *cpu_single_env; 611 extern CPUState *cpu_single_env;
612 extern int code_copy_enabled; 612 extern int code_copy_enabled;
cpu-exec.c
@@ -304,16 +304,16 @@ int cpu_exec(CPUState *env1) @@ -304,16 +304,16 @@ int cpu_exec(CPUState *env1)
304 env->regs[R_EBP] = EBP; 304 env->regs[R_EBP] = EBP;
305 env->regs[R_ESP] = ESP; 305 env->regs[R_ESP] = ESP;
306 env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK); 306 env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
307 - cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP); 307 + cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
308 env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); 308 env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
309 #elif defined(TARGET_ARM) 309 #elif defined(TARGET_ARM)
310 env->cpsr = compute_cpsr(); 310 env->cpsr = compute_cpsr();
311 - cpu_arm_dump_state(env, logfile, 0); 311 + cpu_dump_state(env, logfile, fprintf, 0);
312 env->cpsr &= ~0xf0000000; 312 env->cpsr &= ~0xf0000000;
313 #elif defined(TARGET_SPARC) 313 #elif defined(TARGET_SPARC)
314 - cpu_sparc_dump_state (env, logfile, 0); 314 + cpu_dump_state (env, logfile, fprintf, 0);
315 #elif defined(TARGET_PPC) 315 #elif defined(TARGET_PPC)
316 - cpu_ppc_dump_state(env, logfile, 0); 316 + cpu_dump_state(env, logfile, fprintf, 0);
317 #else 317 #else
318 #error unsupported target CPU 318 #error unsupported target CPU
319 #endif 319 #endif
@@ -282,7 +282,7 @@ void monitor_disas(target_ulong pc, int nb_insn, int is_physical, int flags) @@ -282,7 +282,7 @@ void monitor_disas(target_ulong pc, int nb_insn, int is_physical, int flags)
282 #elif defined(TARGET_PPC) 282 #elif defined(TARGET_PPC)
283 print_insn = print_insn_ppc; 283 print_insn = print_insn_ppc;
284 #else 284 #else
285 - fprintf(out, "Asm output not supported on this arch\n"); 285 + term_printf("Asm output not supported on this arch\n");
286 return; 286 return;
287 #endif 287 #endif
288 288
@@ -1255,7 +1255,9 @@ void cpu_abort(CPUState *env, const char *fmt, ...) @@ -1255,7 +1255,9 @@ void cpu_abort(CPUState *env, const char *fmt, ...)
1255 vfprintf(stderr, fmt, ap); 1255 vfprintf(stderr, fmt, ap);
1256 fprintf(stderr, "\n"); 1256 fprintf(stderr, "\n");
1257 #ifdef TARGET_I386 1257 #ifdef TARGET_I386
1258 - cpu_x86_dump_state(env, stderr, X86_DUMP_FPU | X86_DUMP_CCOP); 1258 + cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU | X86_DUMP_CCOP);
  1259 +#else
  1260 + cpu_dump_state(env, stderr, fprintf, 0);
1259 #endif 1261 #endif
1260 va_end(ap); 1262 va_end(ap);
1261 abort(); 1263 abort();
linux-user/main.c
@@ -372,7 +372,7 @@ void cpu_loop(CPUARMState *env) @@ -372,7 +372,7 @@ void cpu_loop(CPUARMState *env)
372 error: 372 error:
373 fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", 373 fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
374 trapnr); 374 trapnr);
375 - cpu_arm_dump_state(env, stderr, 0); 375 + cpu_dump_state(env, stderr, fprintf, 0);
376 abort(); 376 abort();
377 } 377 }
378 process_pending_signals(env); 378 process_pending_signals(env);
@@ -499,7 +499,7 @@ void cpu_loop (CPUSPARCState *env) @@ -499,7 +499,7 @@ void cpu_loop (CPUSPARCState *env)
499 break; 499 break;
500 default: 500 default:
501 printf ("Unhandled trap: 0x%x\n", trapnr); 501 printf ("Unhandled trap: 0x%x\n", trapnr);
502 - cpu_sparc_dump_state(env, stderr, 0); 502 + cpu_dump_state(env, stderr, fprintf, 0);
503 exit (1); 503 exit (1);
504 } 504 }
505 process_pending_signals (env); 505 process_pending_signals (env);
@@ -563,7 +563,7 @@ void cpu_loop(CPUPPCState *env) @@ -563,7 +563,7 @@ void cpu_loop(CPUPPCState *env)
563 if (trapnr != EXCP_SYSCALL_USER && trapnr != EXCP_BRANCH && 563 if (trapnr != EXCP_SYSCALL_USER && trapnr != EXCP_BRANCH &&
564 trapnr != EXCP_TRACE) { 564 trapnr != EXCP_TRACE) {
565 if (loglevel > 0) { 565 if (loglevel > 0) {
566 - cpu_ppc_dump_state(env, logfile, 0); 566 + cpu_dump_state(env, logfile, fprintf, 0);
567 } 567 }
568 } 568 }
569 switch(trapnr) { 569 switch(trapnr) {
monitor.c
@@ -101,6 +101,15 @@ void term_printf(const char *fmt, ...) @@ -101,6 +101,15 @@ void term_printf(const char *fmt, ...)
101 va_end(ap); 101 va_end(ap);
102 } 102 }
103 103
  104 +static int monitor_fprintf(FILE *stream, const char *fmt, ...)
  105 +{
  106 + va_list ap;
  107 + va_start(ap, fmt);
  108 + term_vprintf(fmt, ap);
  109 + va_end(ap);
  110 + return 0;
  111 +}
  112 +
104 static int compare_cmd(const char *name, const char *list) 113 static int compare_cmd(const char *name, const char *list)
105 { 114 {
106 const char *p, *pstart; 115 const char *p, *pstart;
@@ -206,9 +215,11 @@ static void do_info_block(void) @@ -206,9 +215,11 @@ static void do_info_block(void)
206 static void do_info_registers(void) 215 static void do_info_registers(void)
207 { 216 {
208 #ifdef TARGET_I386 217 #ifdef TARGET_I386
209 - cpu_dump_state(cpu_single_env, stdout, X86_DUMP_FPU | X86_DUMP_CCOP); 218 + cpu_dump_state(cpu_single_env, stdout, monitor_fprintf,
  219 + X86_DUMP_FPU | X86_DUMP_CCOP);
210 #else 220 #else
211 - cpu_dump_state(cpu_single_env, stdout, 0); 221 + cpu_dump_state(cpu_single_env, stdout, monitor_fprintf,
  222 + 0);
212 #endif 223 #endif
213 } 224 }
214 225
@@ -1852,6 +1863,15 @@ void readline_find_completion(const char *cmdline) @@ -1852,6 +1863,15 @@ void readline_find_completion(const char *cmdline)
1852 completion_index = strlen(str); 1863 completion_index = strlen(str);
1853 bdrv_iterate(block_completion_it, (void *)str); 1864 bdrv_iterate(block_completion_it, (void *)str);
1854 break; 1865 break;
  1866 + case 's':
  1867 + /* XXX: more generic ? */
  1868 + if (!strcmp(cmd->name, "info")) {
  1869 + completion_index = strlen(str);
  1870 + for(cmd = info_cmds; cmd->name != NULL; cmd++) {
  1871 + cmd_completion(str, cmd->name);
  1872 + }
  1873 + }
  1874 + break;
1855 default: 1875 default:
1856 break; 1876 break;
1857 } 1877 }
target-arm/cpu.h
@@ -64,8 +64,6 @@ struct siginfo; @@ -64,8 +64,6 @@ struct siginfo;
64 int cpu_arm_signal_handler(int host_signum, struct siginfo *info, 64 int cpu_arm_signal_handler(int host_signum, struct siginfo *info,
65 void *puc); 65 void *puc);
66 66
67 -void cpu_arm_dump_state(CPUARMState *env, FILE *f, int flags);  
68 -  
69 #define TARGET_PAGE_BITS 12 67 #define TARGET_PAGE_BITS 12
70 #include "cpu-all.h" 68 #include "cpu-all.h"
71 69
target-arm/translate.c
@@ -824,18 +824,20 @@ void cpu_arm_close(CPUARMState *env) @@ -824,18 +824,20 @@ void cpu_arm_close(CPUARMState *env)
824 free(env); 824 free(env);
825 } 825 }
826 826
827 -void cpu_arm_dump_state(CPUARMState *env, FILE *f, int flags) 827 +void cpu_dump_state(CPUState *env, FILE *f,
  828 + int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
  829 + int flags)
828 { 830 {
829 int i; 831 int i;
830 832
831 for(i=0;i<16;i++) { 833 for(i=0;i<16;i++) {
832 - fprintf(f, "R%02d=%08x", i, env->regs[i]); 834 + cpu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
833 if ((i % 4) == 3) 835 if ((i % 4) == 3)
834 - fprintf(f, "\n"); 836 + cpu_fprintf(f, "\n");
835 else 837 else
836 - fprintf(f, " "); 838 + cpu_fprintf(f, " ");
837 } 839 }
838 - fprintf(f, "PSR=%08x %c%c%c%c\n", 840 + cpu_fprintf(f, "PSR=%08x %c%c%c%c\n",
839 env->cpsr, 841 env->cpsr,
840 env->cpsr & (1 << 31) ? 'N' : '-', 842 env->cpsr & (1 << 31) ? 'N' : '-',
841 env->cpsr & (1 << 30) ? 'Z' : '-', 843 env->cpsr & (1 << 30) ? 'Z' : '-',
target-i386/cpu.h
@@ -454,7 +454,6 @@ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0); @@ -454,7 +454,6 @@ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
454 /* used to debug */ 454 /* used to debug */
455 #define X86_DUMP_FPU 0x0001 /* dump FPU state too */ 455 #define X86_DUMP_FPU 0x0001 /* dump FPU state too */
456 #define X86_DUMP_CCOP 0x0002 /* dump qemu flag cache */ 456 #define X86_DUMP_CCOP 0x0002 /* dump qemu flag cache */
457 -void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags);  
458 457
459 #define TARGET_PAGE_BITS 12 458 #define TARGET_PAGE_BITS 12
460 #include "cpu-all.h" 459 #include "cpu-all.h"
target-i386/helper.c
@@ -872,7 +872,7 @@ void do_interrupt(int intno, int is_int, int error_code, @@ -872,7 +872,7 @@ void do_interrupt(int intno, int is_int, int error_code,
872 } 872 }
873 fprintf(logfile, "\n"); 873 fprintf(logfile, "\n");
874 #if 0 874 #if 0
875 - cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP); 875 + cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
876 { 876 {
877 int i; 877 int i;
878 uint8_t *ptr; 878 uint8_t *ptr;
@@ -1334,7 +1334,7 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip) @@ -1334,7 +1334,7 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip)
1334 if (loglevel & CPU_LOG_PCALL) { 1334 if (loglevel & CPU_LOG_PCALL) {
1335 fprintf(logfile, "lcall %04x:%08x s=%d\n", 1335 fprintf(logfile, "lcall %04x:%08x s=%d\n",
1336 new_cs, new_eip, shift); 1336 new_cs, new_eip, shift);
1337 - cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP); 1337 + cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
1338 } 1338 }
1339 #endif 1339 #endif
1340 if ((new_cs & 0xfffc) == 0) 1340 if ((new_cs & 0xfffc) == 0)
@@ -1596,7 +1596,7 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend) @@ -1596,7 +1596,7 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend)
1596 if (loglevel & CPU_LOG_PCALL) { 1596 if (loglevel & CPU_LOG_PCALL) {
1597 fprintf(logfile, "lret new %04x:%08x s=%d addend=0x%x\n", 1597 fprintf(logfile, "lret new %04x:%08x s=%d addend=0x%x\n",
1598 new_cs, new_eip, shift, addend); 1598 new_cs, new_eip, shift, addend);
1599 - cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP); 1599 + cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
1600 } 1600 }
1601 #endif 1601 #endif
1602 if ((new_cs & 0xfffc) == 0) 1602 if ((new_cs & 0xfffc) == 0)
target-i386/helper2.c
@@ -168,14 +168,16 @@ static const char *cc_op_str[] = { @@ -168,14 +168,16 @@ static const char *cc_op_str[] = {
168 "SARL", 168 "SARL",
169 }; 169 };
170 170
171 -void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags) 171 +void cpu_dump_state(CPUState *env, FILE *f,
  172 + int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
  173 + int flags)
172 { 174 {
173 int eflags, i; 175 int eflags, i;
174 char cc_op_name[32]; 176 char cc_op_name[32];
175 static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" }; 177 static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
176 178
177 eflags = env->eflags; 179 eflags = env->eflags;
178 - fprintf(f, "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n" 180 + cpu_fprintf(f, "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
179 "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n" 181 "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"
180 "EIP=%08x EFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d\n", 182 "EIP=%08x EFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d\n",
181 env->regs[R_EAX], env->regs[R_EBX], env->regs[R_ECX], env->regs[R_EDX], 183 env->regs[R_EAX], env->regs[R_EBX], env->regs[R_ECX], env->regs[R_EDX],
@@ -193,28 +195,28 @@ void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags) @@ -193,28 +195,28 @@ void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags)
193 (env->a20_mask >> 20) & 1); 195 (env->a20_mask >> 20) & 1);
194 for(i = 0; i < 6; i++) { 196 for(i = 0; i < 6; i++) {
195 SegmentCache *sc = &env->segs[i]; 197 SegmentCache *sc = &env->segs[i];
196 - fprintf(f, "%s =%04x %08x %08x %08x\n", 198 + cpu_fprintf(f, "%s =%04x %08x %08x %08x\n",
197 seg_name[i], 199 seg_name[i],
198 sc->selector, 200 sc->selector,
199 (int)sc->base, 201 (int)sc->base,
200 sc->limit, 202 sc->limit,
201 sc->flags); 203 sc->flags);
202 } 204 }
203 - fprintf(f, "LDT=%04x %08x %08x %08x\n", 205 + cpu_fprintf(f, "LDT=%04x %08x %08x %08x\n",
204 env->ldt.selector, 206 env->ldt.selector,
205 (int)env->ldt.base, 207 (int)env->ldt.base,
206 env->ldt.limit, 208 env->ldt.limit,
207 env->ldt.flags); 209 env->ldt.flags);
208 - fprintf(f, "TR =%04x %08x %08x %08x\n", 210 + cpu_fprintf(f, "TR =%04x %08x %08x %08x\n",
209 env->tr.selector, 211 env->tr.selector,
210 (int)env->tr.base, 212 (int)env->tr.base,
211 env->tr.limit, 213 env->tr.limit,
212 env->tr.flags); 214 env->tr.flags);
213 - fprintf(f, "GDT= %08x %08x\n", 215 + cpu_fprintf(f, "GDT= %08x %08x\n",
214 (int)env->gdt.base, env->gdt.limit); 216 (int)env->gdt.base, env->gdt.limit);
215 - fprintf(f, "IDT= %08x %08x\n", 217 + cpu_fprintf(f, "IDT= %08x %08x\n",
216 (int)env->idt.base, env->idt.limit); 218 (int)env->idt.base, env->idt.limit);
217 - fprintf(f, "CR0=%08x CR2=%08x CR3=%08x CR4=%08x\n", 219 + cpu_fprintf(f, "CR0=%08x CR2=%08x CR3=%08x CR4=%08x\n",
218 env->cr[0], env->cr[2], env->cr[3], env->cr[4]); 220 env->cr[0], env->cr[2], env->cr[3], env->cr[4]);
219 221
220 if (flags & X86_DUMP_CCOP) { 222 if (flags & X86_DUMP_CCOP) {
@@ -222,16 +224,16 @@ void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags) @@ -222,16 +224,16 @@ void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags)
222 snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->cc_op]); 224 snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->cc_op]);
223 else 225 else
224 snprintf(cc_op_name, sizeof(cc_op_name), "[%d]", env->cc_op); 226 snprintf(cc_op_name, sizeof(cc_op_name), "[%d]", env->cc_op);
225 - fprintf(f, "CCS=%08x CCD=%08x CCO=%-8s\n", 227 + cpu_fprintf(f, "CCS=%08x CCD=%08x CCO=%-8s\n",
226 env->cc_src, env->cc_dst, cc_op_name); 228 env->cc_src, env->cc_dst, cc_op_name);
227 } 229 }
228 if (flags & X86_DUMP_FPU) { 230 if (flags & X86_DUMP_FPU) {
229 - fprintf(f, "ST0=%f ST1=%f ST2=%f ST3=%f\n", 231 + cpu_fprintf(f, "ST0=%f ST1=%f ST2=%f ST3=%f\n",
230 (double)env->fpregs[0], 232 (double)env->fpregs[0],
231 (double)env->fpregs[1], 233 (double)env->fpregs[1],
232 (double)env->fpregs[2], 234 (double)env->fpregs[2],
233 (double)env->fpregs[3]); 235 (double)env->fpregs[3]);
234 - fprintf(f, "ST4=%f ST5=%f ST6=%f ST7=%f\n", 236 + cpu_fprintf(f, "ST4=%f ST5=%f ST6=%f ST7=%f\n",
235 (double)env->fpregs[4], 237 (double)env->fpregs[4],
236 (double)env->fpregs[5], 238 (double)env->fpregs[5],
237 (double)env->fpregs[7], 239 (double)env->fpregs[7],
target-i386/translate.c
@@ -4641,7 +4641,7 @@ static inline int gen_intermediate_code_internal(CPUState *env, @@ -4641,7 +4641,7 @@ static inline int gen_intermediate_code_internal(CPUState *env,
4641 4641
4642 #ifdef DEBUG_DISAS 4642 #ifdef DEBUG_DISAS
4643 if (loglevel & CPU_LOG_TB_CPU) { 4643 if (loglevel & CPU_LOG_TB_CPU) {
4644 - cpu_dump_state(env, logfile, X86_DUMP_CCOP); 4644 + cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
4645 } 4645 }
4646 if (loglevel & CPU_LOG_TB_IN_ASM) { 4646 if (loglevel & CPU_LOG_TB_IN_ASM) {
4647 fprintf(logfile, "----------------\n"); 4647 fprintf(logfile, "----------------\n");
target-ppc/cpu.h
@@ -189,7 +189,6 @@ int cpu_ppc_signal_handler(int host_signum, struct siginfo *info, @@ -189,7 +189,6 @@ int cpu_ppc_signal_handler(int host_signum, struct siginfo *info,
189 void do_interrupt (CPUPPCState *env); 189 void do_interrupt (CPUPPCState *env);
190 void cpu_loop_exit(void); 190 void cpu_loop_exit(void);
191 191
192 -void cpu_ppc_dump_state(CPUPPCState *env, FILE *f, int flags);  
193 void dump_stack (CPUPPCState *env); 192 void dump_stack (CPUPPCState *env);
194 193
195 uint32_t _load_xer (CPUPPCState *env); 194 uint32_t _load_xer (CPUPPCState *env);
target-ppc/helper.c
@@ -521,7 +521,7 @@ int cpu_ppc_handle_mmu_fault (CPUState *env, uint32_t address, int rw, @@ -521,7 +521,7 @@ int cpu_ppc_handle_mmu_fault (CPUState *env, uint32_t address, int rw,
521 do_fault: 521 do_fault:
522 #if defined (DEBUG_MMU) 522 #if defined (DEBUG_MMU)
523 if (loglevel > 0) 523 if (loglevel > 0)
524 - cpu_ppc_dump_state(env, logfile, 0); 524 + cpu_dump_state(env, logfile, fprintf, 0);
525 #endif 525 #endif
526 if (access_type == ACCESS_CODE) { 526 if (access_type == ACCESS_CODE) {
527 exception = EXCP_ISI; 527 exception = EXCP_ISI;
@@ -676,7 +676,7 @@ void do_interrupt (CPUState *env) @@ -676,7 +676,7 @@ void do_interrupt (CPUState *env)
676 env->nip, excp << 8, env->error_code); 676 env->nip, excp << 8, env->error_code);
677 } 677 }
678 if (loglevel > 0) 678 if (loglevel > 0)
679 - cpu_ppc_dump_state(env, logfile, 0); 679 + cpu_dump_state(env, logfile, fprintf, 0);
680 } 680 }
681 #endif 681 #endif
682 if (loglevel & CPU_LOG_INT) { 682 if (loglevel & CPU_LOG_INT) {
target-ppc/op_helper.c
@@ -466,14 +466,14 @@ void do_store_dbat (int ul, int nr) @@ -466,14 +466,14 @@ void do_store_dbat (int ul, int nr)
466 /* Special helpers for debug */ 466 /* Special helpers for debug */
467 void dump_state (void) 467 void dump_state (void)
468 { 468 {
469 - // cpu_ppc_dump_state(env, stdout, 0); 469 + // cpu_dump_state(env, stdout, fprintf, 0);
470 } 470 }
471 471
472 void dump_rfi (void) 472 void dump_rfi (void)
473 { 473 {
474 #if 0 474 #if 0
475 printf("Return from interrupt => 0x%08x\n", env->nip); 475 printf("Return from interrupt => 0x%08x\n", env->nip);
476 - // cpu_ppc_dump_state(env, stdout, 0); 476 + // cpu_dump_state(env, stdout, fprintf, 0);
477 #endif 477 #endif
478 } 478 }
479 479
target-ppc/translate.c
@@ -2924,24 +2924,26 @@ static int create_ppc_proc (opc_handler_t **ppc_opcodes, unsigned long pvr) @@ -2924,24 +2924,26 @@ static int create_ppc_proc (opc_handler_t **ppc_opcodes, unsigned long pvr)
2924 /*****************************************************************************/ 2924 /*****************************************************************************/
2925 /* Misc PPC helpers */ 2925 /* Misc PPC helpers */
2926 2926
2927 -void cpu_ppc_dump_state(CPUPPCState *env, FILE *f, int flags) 2927 +void cpu_dump_state(CPUState *env, FILE *f,
  2928 + int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
  2929 + int flags)
2928 { 2930 {
2929 int i; 2931 int i;
2930 2932
2931 - fprintf(f, "nip=0x%08x LR=0x%08x CTR=0x%08x XER=0x%08x " 2933 + cpu_fprintf(f, "nip=0x%08x LR=0x%08x CTR=0x%08x XER=0x%08x "
2932 "MSR=0x%08x\n", env->nip, env->lr, env->ctr, 2934 "MSR=0x%08x\n", env->nip, env->lr, env->ctr,
2933 _load_xer(env), _load_msr(env)); 2935 _load_xer(env), _load_msr(env));
2934 for (i = 0; i < 32; i++) { 2936 for (i = 0; i < 32; i++) {
2935 if ((i & 7) == 0) 2937 if ((i & 7) == 0)
2936 - fprintf(f, "GPR%02d:", i);  
2937 - fprintf(f, " %08x", env->gpr[i]); 2938 + cpu_fprintf(f, "GPR%02d:", i);
  2939 + cpu_fprintf(f, " %08x", env->gpr[i]);
2938 if ((i & 7) == 7) 2940 if ((i & 7) == 7)
2939 - fprintf(f, "\n"); 2941 + cpu_fprintf(f, "\n");
2940 } 2942 }
2941 - fprintf(f, "CR: 0x"); 2943 + cpu_fprintf(f, "CR: 0x");
2942 for (i = 0; i < 8; i++) 2944 for (i = 0; i < 8; i++)
2943 - fprintf(f, "%01x", env->crf[i]);  
2944 - fprintf(f, " ["); 2945 + cpu_fprintf(f, "%01x", env->crf[i]);
  2946 + cpu_fprintf(f, " [");
2945 for (i = 0; i < 8; i++) { 2947 for (i = 0; i < 8; i++) {
2946 char a = '-'; 2948 char a = '-';
2947 if (env->crf[i] & 0x08) 2949 if (env->crf[i] & 0x08)
@@ -2950,22 +2952,21 @@ void cpu_ppc_dump_state(CPUPPCState *env, FILE *f, int flags) @@ -2950,22 +2952,21 @@ void cpu_ppc_dump_state(CPUPPCState *env, FILE *f, int flags)
2950 a = 'G'; 2952 a = 'G';
2951 else if (env->crf[i] & 0x02) 2953 else if (env->crf[i] & 0x02)
2952 a = 'E'; 2954 a = 'E';
2953 - fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); 2955 + cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
2954 } 2956 }
2955 - fprintf(f, " ] ");  
2956 - fprintf(f, "TB: 0x%08x %08x\n", cpu_ppc_load_tbu(env), 2957 + cpu_fprintf(f, " ] ");
  2958 + cpu_fprintf(f, "TB: 0x%08x %08x\n", cpu_ppc_load_tbu(env),
2957 cpu_ppc_load_tbl(env)); 2959 cpu_ppc_load_tbl(env));
2958 for (i = 0; i < 16; i++) { 2960 for (i = 0; i < 16; i++) {
2959 if ((i & 3) == 0) 2961 if ((i & 3) == 0)
2960 - fprintf(f, "FPR%02d:", i);  
2961 - fprintf(f, " %016llx", *((uint64_t *)&env->fpr[i])); 2962 + cpu_fprintf(f, "FPR%02d:", i);
  2963 + cpu_fprintf(f, " %016llx", *((uint64_t *)&env->fpr[i]));
2962 if ((i & 3) == 3) 2964 if ((i & 3) == 3)
2963 - fprintf(f, "\n"); 2965 + cpu_fprintf(f, "\n");
2964 } 2966 }
2965 - fprintf(f, "SRR0 0x%08x SRR1 0x%08x DECR=0x%08x\n", 2967 + cpu_fprintf(f, "SRR0 0x%08x SRR1 0x%08x DECR=0x%08x\n",
2966 env->spr[SRR0], env->spr[SRR1], cpu_ppc_load_decr(env)); 2968 env->spr[SRR0], env->spr[SRR1], cpu_ppc_load_decr(env));
2967 - fprintf(f, "reservation 0x%08x\n", env->reserve);  
2968 - fflush(f); 2969 + cpu_fprintf(f, "reservation 0x%08x\n", env->reserve);
2969 } 2970 }
2970 2971
2971 #if !defined(CONFIG_USER_ONLY) && defined (USE_OPENFIRMWARE) 2972 #if !defined(CONFIG_USER_ONLY) && defined (USE_OPENFIRMWARE)
@@ -3170,7 +3171,7 @@ int gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, @@ -3170,7 +3171,7 @@ int gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
3170 #ifdef DEBUG_DISAS 3171 #ifdef DEBUG_DISAS
3171 if (loglevel & CPU_LOG_TB_CPU) { 3172 if (loglevel & CPU_LOG_TB_CPU) {
3172 fprintf(logfile, "---------------- excp: %04x\n", ctx.exception); 3173 fprintf(logfile, "---------------- excp: %04x\n", ctx.exception);
3173 - cpu_ppc_dump_state(env, logfile, 0); 3174 + cpu_dump_state(env, logfile, fprintf, 0);
3174 } 3175 }
3175 if (loglevel & CPU_LOG_TB_IN_ASM) { 3176 if (loglevel & CPU_LOG_TB_IN_ASM) {
3176 fprintf(logfile, "IN: %s\n", lookup_symbol((void *)pc_start)); 3177 fprintf(logfile, "IN: %s\n", lookup_symbol((void *)pc_start));
target-sparc/cpu.h
@@ -147,7 +147,6 @@ int cpu_sparc_close(CPUSPARCState *s); @@ -147,7 +147,6 @@ int cpu_sparc_close(CPUSPARCState *s);
147 147
148 struct siginfo; 148 struct siginfo;
149 int cpu_sparc_signal_handler(int hostsignum, struct siginfo *info, void *puc); 149 int cpu_sparc_signal_handler(int hostsignum, struct siginfo *info, void *puc);
150 -void cpu_sparc_dump_state(CPUSPARCState *env, FILE *f, int flags);  
151 150
152 #define TARGET_PAGE_BITS 12 /* 4k */ 151 #define TARGET_PAGE_BITS 12 /* 4k */
153 #include "cpu-all.h" 152 #include "cpu-all.h"
target-sparc/helper.c
@@ -290,7 +290,7 @@ void do_interrupt(int intno, int is_int, int error_code, @@ -290,7 +290,7 @@ void do_interrupt(int intno, int is_int, int error_code,
290 env->pc, 290 env->pc,
291 env->npc, env->regwptr[6]); 291 env->npc, env->regwptr[6]);
292 #if 0 292 #if 0
293 - cpu_sparc_dump_state(env, logfile, 0); 293 + cpu_dump_state(env, logfile, fprintf, 0);
294 { 294 {
295 int i; 295 int i;
296 uint8_t *ptr; 296 uint8_t *ptr;
target-sparc/translate.c
@@ -1391,44 +1391,46 @@ CPUSPARCState *cpu_sparc_init(void) @@ -1391,44 +1391,46 @@ CPUSPARCState *cpu_sparc_init(void)
1391 1391
1392 #define GET_FLAG(a,b) ((env->psr & a)?b:'-') 1392 #define GET_FLAG(a,b) ((env->psr & a)?b:'-')
1393 1393
1394 -void cpu_sparc_dump_state(CPUSPARCState * env, FILE * f, int flags) 1394 +void cpu_dump_state(CPUState *env, FILE *f,
  1395 + int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
  1396 + int flags)
1395 { 1397 {
1396 int i, x; 1398 int i, x;
1397 1399
1398 - fprintf(f, "pc: 0x%08x npc: 0x%08x\n", (int) env->pc, (int) env->npc);  
1399 - fprintf(f, "General Registers:\n"); 1400 + cpu_fprintf(f, "pc: 0x%08x npc: 0x%08x\n", (int) env->pc, (int) env->npc);
  1401 + cpu_fprintf(f, "General Registers:\n");
1400 for (i = 0; i < 4; i++) 1402 for (i = 0; i < 4; i++)
1401 - fprintf(f, "%%g%c: 0x%08x\t", i + '0', env->gregs[i]);  
1402 - fprintf(f, "\n"); 1403 + cpu_fprintf(f, "%%g%c: 0x%08x\t", i + '0', env->gregs[i]);
  1404 + cpu_fprintf(f, "\n");
1403 for (; i < 8; i++) 1405 for (; i < 8; i++)
1404 - fprintf(f, "%%g%c: 0x%08x\t", i + '0', env->gregs[i]);  
1405 - fprintf(f, "\nCurrent Register Window:\n"); 1406 + cpu_fprintf(f, "%%g%c: 0x%08x\t", i + '0', env->gregs[i]);
  1407 + cpu_fprintf(f, "\nCurrent Register Window:\n");
1406 for (x = 0; x < 3; x++) { 1408 for (x = 0; x < 3; x++) {
1407 for (i = 0; i < 4; i++) 1409 for (i = 0; i < 4; i++)
1408 - fprintf(f, "%%%c%d: 0x%08x\t", 1410 + cpu_fprintf(f, "%%%c%d: 0x%08x\t",
1409 (x == 0 ? 'o' : (x == 1 ? 'l' : 'i')), i, 1411 (x == 0 ? 'o' : (x == 1 ? 'l' : 'i')), i,
1410 env->regwptr[i + x * 8]); 1412 env->regwptr[i + x * 8]);
1411 - fprintf(f, "\n"); 1413 + cpu_fprintf(f, "\n");
1412 for (; i < 8; i++) 1414 for (; i < 8; i++)
1413 - fprintf(f, "%%%c%d: 0x%08x\t", 1415 + cpu_fprintf(f, "%%%c%d: 0x%08x\t",
1414 (x == 0 ? 'o' : x == 1 ? 'l' : 'i'), i, 1416 (x == 0 ? 'o' : x == 1 ? 'l' : 'i'), i,
1415 env->regwptr[i + x * 8]); 1417 env->regwptr[i + x * 8]);
1416 - fprintf(f, "\n"); 1418 + cpu_fprintf(f, "\n");
1417 } 1419 }
1418 - fprintf(f, "\nFloating Point Registers:\n"); 1420 + cpu_fprintf(f, "\nFloating Point Registers:\n");
1419 for (i = 0; i < 32; i++) { 1421 for (i = 0; i < 32; i++) {
1420 if ((i & 3) == 0) 1422 if ((i & 3) == 0)
1421 - fprintf(f, "%%f%02d:", i);  
1422 - fprintf(f, " %016lf", env->fpr[i]); 1423 + cpu_fprintf(f, "%%f%02d:", i);
  1424 + cpu_fprintf(f, " %016lf", env->fpr[i]);
1423 if ((i & 3) == 3) 1425 if ((i & 3) == 3)
1424 - fprintf(f, "\n"); 1426 + cpu_fprintf(f, "\n");
1425 } 1427 }
1426 - fprintf(f, "psr: 0x%08x -> %c%c%c%c %c%c%c wim: 0x%08x\n", GET_PSR(env), 1428 + cpu_fprintf(f, "psr: 0x%08x -> %c%c%c%c %c%c%c wim: 0x%08x\n", GET_PSR(env),
1427 GET_FLAG(PSR_ZERO, 'Z'), GET_FLAG(PSR_OVF, 'V'), 1429 GET_FLAG(PSR_ZERO, 'Z'), GET_FLAG(PSR_OVF, 'V'),
1428 GET_FLAG(PSR_NEG, 'N'), GET_FLAG(PSR_CARRY, 'C'), 1430 GET_FLAG(PSR_NEG, 'N'), GET_FLAG(PSR_CARRY, 'C'),
1429 env->psrs?'S':'-', env->psrps?'P':'-', 1431 env->psrs?'S':'-', env->psrps?'P':'-',
1430 env->psret?'E':'-', env->wim); 1432 env->psret?'E':'-', env->wim);
1431 - fprintf(f, "fsr: 0x%08x\n", env->fsr); 1433 + cpu_fprintf(f, "fsr: 0x%08x\n", env->fsr);
1432 } 1434 }
1433 1435
1434 target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr) 1436 target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
@@ -406,9 +406,9 @@ void hw_error(const char *fmt, ...) @@ -406,9 +406,9 @@ void hw_error(const char *fmt, ...)
406 vfprintf(stderr, fmt, ap); 406 vfprintf(stderr, fmt, ap);
407 fprintf(stderr, "\n"); 407 fprintf(stderr, "\n");
408 #ifdef TARGET_I386 408 #ifdef TARGET_I386
409 - cpu_x86_dump_state(global_env, stderr, X86_DUMP_FPU | X86_DUMP_CCOP); 409 + cpu_dump_state(global_env, stderr, fprintf, X86_DUMP_FPU | X86_DUMP_CCOP);
410 #else 410 #else
411 - cpu_dump_state(global_env, stderr, 0); 411 + cpu_dump_state(global_env, stderr, fprintf, 0);
412 #endif 412 #endif
413 va_end(ap); 413 va_end(ap);
414 abort(); 414 abort();