Commit 7fe48483cd90401de2477733ce65037ee0ed0906
1 parent
8e3a9fd2
monitor fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1110 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
20 changed files
with
106 additions
and
82 deletions
cpu-all.h
... | ... | @@ -570,7 +570,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); |
570 | 570 | #define cpu_exec cpu_x86_exec |
571 | 571 | #define cpu_gen_code cpu_x86_gen_code |
572 | 572 | #define cpu_signal_handler cpu_x86_signal_handler |
573 | -#define cpu_dump_state cpu_x86_dump_state | |
574 | 573 | |
575 | 574 | #elif defined(TARGET_ARM) |
576 | 575 | |
... | ... | @@ -579,7 +578,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); |
579 | 578 | #define cpu_exec cpu_arm_exec |
580 | 579 | #define cpu_gen_code cpu_arm_gen_code |
581 | 580 | #define cpu_signal_handler cpu_arm_signal_handler |
582 | -#define cpu_dump_state cpu_arm_dump_state | |
583 | 581 | |
584 | 582 | #elif defined(TARGET_SPARC) |
585 | 583 | |
... | ... | @@ -588,7 +586,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); |
588 | 586 | #define cpu_exec cpu_sparc_exec |
589 | 587 | #define cpu_gen_code cpu_sparc_gen_code |
590 | 588 | #define cpu_signal_handler cpu_sparc_signal_handler |
591 | -#define cpu_dump_state cpu_sparc_dump_state | |
592 | 589 | |
593 | 590 | #elif defined(TARGET_PPC) |
594 | 591 | |
... | ... | @@ -597,7 +594,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); |
597 | 594 | #define cpu_exec cpu_ppc_exec |
598 | 595 | #define cpu_gen_code cpu_ppc_gen_code |
599 | 596 | #define cpu_signal_handler cpu_ppc_signal_handler |
600 | -#define cpu_dump_state cpu_ppc_dump_state | |
601 | 597 | |
602 | 598 | #else |
603 | 599 | |
... | ... | @@ -607,6 +603,10 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size); |
607 | 603 | |
608 | 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 | 610 | void cpu_abort(CPUState *env, const char *fmt, ...); |
611 | 611 | extern CPUState *cpu_single_env; |
612 | 612 | extern int code_copy_enabled; | ... | ... |
cpu-exec.c
... | ... | @@ -304,16 +304,16 @@ int cpu_exec(CPUState *env1) |
304 | 304 | env->regs[R_EBP] = EBP; |
305 | 305 | env->regs[R_ESP] = ESP; |
306 | 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 | 308 | env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); |
309 | 309 | #elif defined(TARGET_ARM) |
310 | 310 | env->cpsr = compute_cpsr(); |
311 | - cpu_arm_dump_state(env, logfile, 0); | |
311 | + cpu_dump_state(env, logfile, fprintf, 0); | |
312 | 312 | env->cpsr &= ~0xf0000000; |
313 | 313 | #elif defined(TARGET_SPARC) |
314 | - cpu_sparc_dump_state (env, logfile, 0); | |
314 | + cpu_dump_state (env, logfile, fprintf, 0); | |
315 | 315 | #elif defined(TARGET_PPC) |
316 | - cpu_ppc_dump_state(env, logfile, 0); | |
316 | + cpu_dump_state(env, logfile, fprintf, 0); | |
317 | 317 | #else |
318 | 318 | #error unsupported target CPU |
319 | 319 | #endif | ... | ... |
disas.c
... | ... | @@ -282,7 +282,7 @@ void monitor_disas(target_ulong pc, int nb_insn, int is_physical, int flags) |
282 | 282 | #elif defined(TARGET_PPC) |
283 | 283 | print_insn = print_insn_ppc; |
284 | 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 | 286 | return; |
287 | 287 | #endif |
288 | 288 | ... | ... |
exec.c
... | ... | @@ -1255,7 +1255,9 @@ void cpu_abort(CPUState *env, const char *fmt, ...) |
1255 | 1255 | vfprintf(stderr, fmt, ap); |
1256 | 1256 | fprintf(stderr, "\n"); |
1257 | 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 | 1261 | #endif |
1260 | 1262 | va_end(ap); |
1261 | 1263 | abort(); | ... | ... |
linux-user/main.c
... | ... | @@ -372,7 +372,7 @@ void cpu_loop(CPUARMState *env) |
372 | 372 | error: |
373 | 373 | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", |
374 | 374 | trapnr); |
375 | - cpu_arm_dump_state(env, stderr, 0); | |
375 | + cpu_dump_state(env, stderr, fprintf, 0); | |
376 | 376 | abort(); |
377 | 377 | } |
378 | 378 | process_pending_signals(env); |
... | ... | @@ -499,7 +499,7 @@ void cpu_loop (CPUSPARCState *env) |
499 | 499 | break; |
500 | 500 | default: |
501 | 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 | 503 | exit (1); |
504 | 504 | } |
505 | 505 | process_pending_signals (env); |
... | ... | @@ -563,7 +563,7 @@ void cpu_loop(CPUPPCState *env) |
563 | 563 | if (trapnr != EXCP_SYSCALL_USER && trapnr != EXCP_BRANCH && |
564 | 564 | trapnr != EXCP_TRACE) { |
565 | 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 | 569 | switch(trapnr) { | ... | ... |
monitor.c
... | ... | @@ -101,6 +101,15 @@ void term_printf(const char *fmt, ...) |
101 | 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 | 113 | static int compare_cmd(const char *name, const char *list) |
105 | 114 | { |
106 | 115 | const char *p, *pstart; |
... | ... | @@ -206,9 +215,11 @@ static void do_info_block(void) |
206 | 215 | static void do_info_registers(void) |
207 | 216 | { |
208 | 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 | 220 | #else |
211 | - cpu_dump_state(cpu_single_env, stdout, 0); | |
221 | + cpu_dump_state(cpu_single_env, stdout, monitor_fprintf, | |
222 | + 0); | |
212 | 223 | #endif |
213 | 224 | } |
214 | 225 | |
... | ... | @@ -1852,6 +1863,15 @@ void readline_find_completion(const char *cmdline) |
1852 | 1863 | completion_index = strlen(str); |
1853 | 1864 | bdrv_iterate(block_completion_it, (void *)str); |
1854 | 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 | 1875 | default: |
1856 | 1876 | break; |
1857 | 1877 | } | ... | ... |
target-arm/cpu.h
target-arm/translate.c
... | ... | @@ -824,18 +824,20 @@ void cpu_arm_close(CPUARMState *env) |
824 | 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 | 831 | int i; |
830 | 832 | |
831 | 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 | 835 | if ((i % 4) == 3) |
834 | - fprintf(f, "\n"); | |
836 | + cpu_fprintf(f, "\n"); | |
835 | 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 | 841 | env->cpsr, |
840 | 842 | env->cpsr & (1 << 31) ? 'N' : '-', |
841 | 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 | 454 | /* used to debug */ |
455 | 455 | #define X86_DUMP_FPU 0x0001 /* dump FPU state too */ |
456 | 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 | 458 | #define TARGET_PAGE_BITS 12 |
460 | 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 | 872 | } |
873 | 873 | fprintf(logfile, "\n"); |
874 | 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 | 877 | int i; |
878 | 878 | uint8_t *ptr; |
... | ... | @@ -1334,7 +1334,7 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip) |
1334 | 1334 | if (loglevel & CPU_LOG_PCALL) { |
1335 | 1335 | fprintf(logfile, "lcall %04x:%08x s=%d\n", |
1336 | 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 | 1339 | #endif |
1340 | 1340 | if ((new_cs & 0xfffc) == 0) |
... | ... | @@ -1596,7 +1596,7 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend) |
1596 | 1596 | if (loglevel & CPU_LOG_PCALL) { |
1597 | 1597 | fprintf(logfile, "lret new %04x:%08x s=%d addend=0x%x\n", |
1598 | 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 | 1601 | #endif |
1602 | 1602 | if ((new_cs & 0xfffc) == 0) | ... | ... |
target-i386/helper2.c
... | ... | @@ -168,14 +168,16 @@ static const char *cc_op_str[] = { |
168 | 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 | 175 | int eflags, i; |
174 | 176 | char cc_op_name[32]; |
175 | 177 | static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" }; |
176 | 178 | |
177 | 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 | 181 | "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n" |
180 | 182 | "EIP=%08x EFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d\n", |
181 | 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 | 195 | (env->a20_mask >> 20) & 1); |
194 | 196 | for(i = 0; i < 6; i++) { |
195 | 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 | 199 | seg_name[i], |
198 | 200 | sc->selector, |
199 | 201 | (int)sc->base, |
200 | 202 | sc->limit, |
201 | 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 | 206 | env->ldt.selector, |
205 | 207 | (int)env->ldt.base, |
206 | 208 | env->ldt.limit, |
207 | 209 | env->ldt.flags); |
208 | - fprintf(f, "TR =%04x %08x %08x %08x\n", | |
210 | + cpu_fprintf(f, "TR =%04x %08x %08x %08x\n", | |
209 | 211 | env->tr.selector, |
210 | 212 | (int)env->tr.base, |
211 | 213 | env->tr.limit, |
212 | 214 | env->tr.flags); |
213 | - fprintf(f, "GDT= %08x %08x\n", | |
215 | + cpu_fprintf(f, "GDT= %08x %08x\n", | |
214 | 216 | (int)env->gdt.base, env->gdt.limit); |
215 | - fprintf(f, "IDT= %08x %08x\n", | |
217 | + cpu_fprintf(f, "IDT= %08x %08x\n", | |
216 | 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 | 220 | env->cr[0], env->cr[2], env->cr[3], env->cr[4]); |
219 | 221 | |
220 | 222 | if (flags & X86_DUMP_CCOP) { |
... | ... | @@ -222,16 +224,16 @@ void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags) |
222 | 224 | snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->cc_op]); |
223 | 225 | else |
224 | 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 | 228 | env->cc_src, env->cc_dst, cc_op_name); |
227 | 229 | } |
228 | 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 | 232 | (double)env->fpregs[0], |
231 | 233 | (double)env->fpregs[1], |
232 | 234 | (double)env->fpregs[2], |
233 | 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 | 237 | (double)env->fpregs[4], |
236 | 238 | (double)env->fpregs[5], |
237 | 239 | (double)env->fpregs[7], | ... | ... |
target-i386/translate.c
... | ... | @@ -4641,7 +4641,7 @@ static inline int gen_intermediate_code_internal(CPUState *env, |
4641 | 4641 | |
4642 | 4642 | #ifdef DEBUG_DISAS |
4643 | 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 | 4646 | if (loglevel & CPU_LOG_TB_IN_ASM) { |
4647 | 4647 | fprintf(logfile, "----------------\n"); | ... | ... |
target-ppc/cpu.h
... | ... | @@ -189,7 +189,6 @@ int cpu_ppc_signal_handler(int host_signum, struct siginfo *info, |
189 | 189 | void do_interrupt (CPUPPCState *env); |
190 | 190 | void cpu_loop_exit(void); |
191 | 191 | |
192 | -void cpu_ppc_dump_state(CPUPPCState *env, FILE *f, int flags); | |
193 | 192 | void dump_stack (CPUPPCState *env); |
194 | 193 | |
195 | 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 | 521 | do_fault: |
522 | 522 | #if defined (DEBUG_MMU) |
523 | 523 | if (loglevel > 0) |
524 | - cpu_ppc_dump_state(env, logfile, 0); | |
524 | + cpu_dump_state(env, logfile, fprintf, 0); | |
525 | 525 | #endif |
526 | 526 | if (access_type == ACCESS_CODE) { |
527 | 527 | exception = EXCP_ISI; |
... | ... | @@ -676,7 +676,7 @@ void do_interrupt (CPUState *env) |
676 | 676 | env->nip, excp << 8, env->error_code); |
677 | 677 | } |
678 | 678 | if (loglevel > 0) |
679 | - cpu_ppc_dump_state(env, logfile, 0); | |
679 | + cpu_dump_state(env, logfile, fprintf, 0); | |
680 | 680 | } |
681 | 681 | #endif |
682 | 682 | if (loglevel & CPU_LOG_INT) { | ... | ... |
target-ppc/op_helper.c
... | ... | @@ -466,14 +466,14 @@ void do_store_dbat (int ul, int nr) |
466 | 466 | /* Special helpers for debug */ |
467 | 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 | 472 | void dump_rfi (void) |
473 | 473 | { |
474 | 474 | #if 0 |
475 | 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 | 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 | 2924 | /*****************************************************************************/ |
2925 | 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 | 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 | 2934 | "MSR=0x%08x\n", env->nip, env->lr, env->ctr, |
2933 | 2935 | _load_xer(env), _load_msr(env)); |
2934 | 2936 | for (i = 0; i < 32; i++) { |
2935 | 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 | 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 | 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 | 2947 | for (i = 0; i < 8; i++) { |
2946 | 2948 | char a = '-'; |
2947 | 2949 | if (env->crf[i] & 0x08) |
... | ... | @@ -2950,22 +2952,21 @@ void cpu_ppc_dump_state(CPUPPCState *env, FILE *f, int flags) |
2950 | 2952 | a = 'G'; |
2951 | 2953 | else if (env->crf[i] & 0x02) |
2952 | 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 | 2959 | cpu_ppc_load_tbl(env)); |
2958 | 2960 | for (i = 0; i < 16; i++) { |
2959 | 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 | 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 | 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 | 2972 | #if !defined(CONFIG_USER_ONLY) && defined (USE_OPENFIRMWARE) |
... | ... | @@ -3170,7 +3171,7 @@ int gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, |
3170 | 3171 | #ifdef DEBUG_DISAS |
3171 | 3172 | if (loglevel & CPU_LOG_TB_CPU) { |
3172 | 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 | 3176 | if (loglevel & CPU_LOG_TB_IN_ASM) { |
3176 | 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 | 147 | |
148 | 148 | struct siginfo; |
149 | 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 | 151 | #define TARGET_PAGE_BITS 12 /* 4k */ |
153 | 152 | #include "cpu-all.h" | ... | ... |
target-sparc/helper.c
target-sparc/translate.c
... | ... | @@ -1391,44 +1391,46 @@ CPUSPARCState *cpu_sparc_init(void) |
1391 | 1391 | |
1392 | 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 | 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 | 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 | 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 | 1408 | for (x = 0; x < 3; x++) { |
1407 | 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 | 1411 | (x == 0 ? 'o' : (x == 1 ? 'l' : 'i')), i, |
1410 | 1412 | env->regwptr[i + x * 8]); |
1411 | - fprintf(f, "\n"); | |
1413 | + cpu_fprintf(f, "\n"); | |
1412 | 1414 | for (; i < 8; i++) |
1413 | - fprintf(f, "%%%c%d: 0x%08x\t", | |
1415 | + cpu_fprintf(f, "%%%c%d: 0x%08x\t", | |
1414 | 1416 | (x == 0 ? 'o' : x == 1 ? 'l' : 'i'), i, |
1415 | 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 | 1421 | for (i = 0; i < 32; i++) { |
1420 | 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 | 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 | 1429 | GET_FLAG(PSR_ZERO, 'Z'), GET_FLAG(PSR_OVF, 'V'), |
1428 | 1430 | GET_FLAG(PSR_NEG, 'N'), GET_FLAG(PSR_CARRY, 'C'), |
1429 | 1431 | env->psrs?'S':'-', env->psrps?'P':'-', |
1430 | 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 | 1436 | target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr) | ... | ... |
vl.c
... | ... | @@ -406,9 +406,9 @@ void hw_error(const char *fmt, ...) |
406 | 406 | vfprintf(stderr, fmt, ap); |
407 | 407 | fprintf(stderr, "\n"); |
408 | 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 | 410 | #else |
411 | - cpu_dump_state(global_env, stderr, 0); | |
411 | + cpu_dump_state(global_env, stderr, fprintf, 0); | |
412 | 412 | #endif |
413 | 413 | va_end(ap); |
414 | 414 | abort(); | ... | ... |