Skip to content

Commit

Permalink
monitor fixes
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1110 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
bellard committed Oct 9, 2004
1 parent 8e3a9fd commit 7fe4848
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 82 deletions.
8 changes: 4 additions & 4 deletions cpu-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
#define cpu_exec cpu_x86_exec
#define cpu_gen_code cpu_x86_gen_code
#define cpu_signal_handler cpu_x86_signal_handler
#define cpu_dump_state cpu_x86_dump_state

#elif defined(TARGET_ARM)

Expand All @@ -579,7 +578,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
#define cpu_exec cpu_arm_exec
#define cpu_gen_code cpu_arm_gen_code
#define cpu_signal_handler cpu_arm_signal_handler
#define cpu_dump_state cpu_arm_dump_state

#elif defined(TARGET_SPARC)

Expand All @@ -588,7 +586,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
#define cpu_exec cpu_sparc_exec
#define cpu_gen_code cpu_sparc_gen_code
#define cpu_signal_handler cpu_sparc_signal_handler
#define cpu_dump_state cpu_sparc_dump_state

#elif defined(TARGET_PPC)

Expand All @@ -597,7 +594,6 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);
#define cpu_exec cpu_ppc_exec
#define cpu_gen_code cpu_ppc_gen_code
#define cpu_signal_handler cpu_ppc_signal_handler
#define cpu_dump_state cpu_ppc_dump_state

#else

Expand All @@ -607,6 +603,10 @@ void page_unprotect_range(uint8_t *data, unsigned long data_size);

#endif /* SINGLE_CPU_DEFINES */

void cpu_dump_state(CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags);

void cpu_abort(CPUState *env, const char *fmt, ...);
extern CPUState *cpu_single_env;
extern int code_copy_enabled;
Expand Down
8 changes: 4 additions & 4 deletions cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,16 @@ int cpu_exec(CPUState *env1)
env->regs[R_EBP] = EBP;
env->regs[R_ESP] = ESP;
env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP);
cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
#elif defined(TARGET_ARM)
env->cpsr = compute_cpsr();
cpu_arm_dump_state(env, logfile, 0);
cpu_dump_state(env, logfile, fprintf, 0);
env->cpsr &= ~0xf0000000;
#elif defined(TARGET_SPARC)
cpu_sparc_dump_state (env, logfile, 0);
cpu_dump_state (env, logfile, fprintf, 0);
#elif defined(TARGET_PPC)
cpu_ppc_dump_state(env, logfile, 0);
cpu_dump_state(env, logfile, fprintf, 0);
#else
#error unsupported target CPU
#endif
Expand Down
2 changes: 1 addition & 1 deletion disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void monitor_disas(target_ulong pc, int nb_insn, int is_physical, int flags)
#elif defined(TARGET_PPC)
print_insn = print_insn_ppc;
#else
fprintf(out, "Asm output not supported on this arch\n");
term_printf("Asm output not supported on this arch\n");
return;
#endif

Expand Down
4 changes: 3 additions & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,9 @@ void cpu_abort(CPUState *env, const char *fmt, ...)
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
#ifdef TARGET_I386
cpu_x86_dump_state(env, stderr, X86_DUMP_FPU | X86_DUMP_CCOP);
cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU | X86_DUMP_CCOP);
#else
cpu_dump_state(env, stderr, fprintf, 0);
#endif
va_end(ap);
abort();
Expand Down
6 changes: 3 additions & 3 deletions linux-user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void cpu_loop(CPUARMState *env)
error:
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
trapnr);
cpu_arm_dump_state(env, stderr, 0);
cpu_dump_state(env, stderr, fprintf, 0);
abort();
}
process_pending_signals(env);
Expand Down Expand Up @@ -499,7 +499,7 @@ void cpu_loop (CPUSPARCState *env)
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_sparc_dump_state(env, stderr, 0);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
Expand Down Expand Up @@ -563,7 +563,7 @@ void cpu_loop(CPUPPCState *env)
if (trapnr != EXCP_SYSCALL_USER && trapnr != EXCP_BRANCH &&
trapnr != EXCP_TRACE) {
if (loglevel > 0) {
cpu_ppc_dump_state(env, logfile, 0);
cpu_dump_state(env, logfile, fprintf, 0);
}
}
switch(trapnr) {
Expand Down
24 changes: 22 additions & 2 deletions monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ void term_printf(const char *fmt, ...)
va_end(ap);
}

static int monitor_fprintf(FILE *stream, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
term_vprintf(fmt, ap);
va_end(ap);
return 0;
}

static int compare_cmd(const char *name, const char *list)
{
const char *p, *pstart;
Expand Down Expand Up @@ -206,9 +215,11 @@ static void do_info_block(void)
static void do_info_registers(void)
{
#ifdef TARGET_I386
cpu_dump_state(cpu_single_env, stdout, X86_DUMP_FPU | X86_DUMP_CCOP);
cpu_dump_state(cpu_single_env, stdout, monitor_fprintf,
X86_DUMP_FPU | X86_DUMP_CCOP);
#else
cpu_dump_state(cpu_single_env, stdout, 0);
cpu_dump_state(cpu_single_env, stdout, monitor_fprintf,
0);
#endif
}

Expand Down Expand Up @@ -1852,6 +1863,15 @@ void readline_find_completion(const char *cmdline)
completion_index = strlen(str);
bdrv_iterate(block_completion_it, (void *)str);
break;
case 's':
/* XXX: more generic ? */
if (!strcmp(cmd->name, "info")) {
completion_index = strlen(str);
for(cmd = info_cmds; cmd->name != NULL; cmd++) {
cmd_completion(str, cmd->name);
}
}
break;
default:
break;
}
Expand Down
2 changes: 0 additions & 2 deletions target-arm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ struct siginfo;
int cpu_arm_signal_handler(int host_signum, struct siginfo *info,
void *puc);

void cpu_arm_dump_state(CPUARMState *env, FILE *f, int flags);

#define TARGET_PAGE_BITS 12
#include "cpu-all.h"

Expand Down
12 changes: 7 additions & 5 deletions target-arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,18 +824,20 @@ void cpu_arm_close(CPUARMState *env)
free(env);
}

void cpu_arm_dump_state(CPUARMState *env, FILE *f, int flags)
void cpu_dump_state(CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags)
{
int i;

for(i=0;i<16;i++) {
fprintf(f, "R%02d=%08x", i, env->regs[i]);
cpu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
if ((i % 4) == 3)
fprintf(f, "\n");
cpu_fprintf(f, "\n");
else
fprintf(f, " ");
cpu_fprintf(f, " ");
}
fprintf(f, "PSR=%08x %c%c%c%c\n",
cpu_fprintf(f, "PSR=%08x %c%c%c%c\n",
env->cpsr,
env->cpsr & (1 << 31) ? 'N' : '-',
env->cpsr & (1 << 30) ? 'Z' : '-',
Expand Down
1 change: 0 additions & 1 deletion target-i386/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
/* used to debug */
#define X86_DUMP_FPU 0x0001 /* dump FPU state too */
#define X86_DUMP_CCOP 0x0002 /* dump qemu flag cache */
void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags);

#define TARGET_PAGE_BITS 12
#include "cpu-all.h"
Expand Down
6 changes: 3 additions & 3 deletions target-i386/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ void do_interrupt(int intno, int is_int, int error_code,
}
fprintf(logfile, "\n");
#if 0
cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP);
cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
{
int i;
uint8_t *ptr;
Expand Down Expand Up @@ -1334,7 +1334,7 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip)
if (loglevel & CPU_LOG_PCALL) {
fprintf(logfile, "lcall %04x:%08x s=%d\n",
new_cs, new_eip, shift);
cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP);
cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
}
#endif
if ((new_cs & 0xfffc) == 0)
Expand Down Expand Up @@ -1596,7 +1596,7 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend)
if (loglevel & CPU_LOG_PCALL) {
fprintf(logfile, "lret new %04x:%08x s=%d addend=0x%x\n",
new_cs, new_eip, shift, addend);
cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP);
cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
}
#endif
if ((new_cs & 0xfffc) == 0)
Expand Down
24 changes: 13 additions & 11 deletions target-i386/helper2.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,16 @@ static const char *cc_op_str[] = {
"SARL",
};

void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags)
void cpu_dump_state(CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags)
{
int eflags, i;
char cc_op_name[32];
static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };

eflags = env->eflags;
fprintf(f, "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
cpu_fprintf(f, "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"
"EIP=%08x EFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d\n",
env->regs[R_EAX], env->regs[R_EBX], env->regs[R_ECX], env->regs[R_EDX],
Expand All @@ -193,45 +195,45 @@ void cpu_x86_dump_state(CPUX86State *env, FILE *f, int flags)
(env->a20_mask >> 20) & 1);
for(i = 0; i < 6; i++) {
SegmentCache *sc = &env->segs[i];
fprintf(f, "%s =%04x %08x %08x %08x\n",
cpu_fprintf(f, "%s =%04x %08x %08x %08x\n",
seg_name[i],
sc->selector,
(int)sc->base,
sc->limit,
sc->flags);
}
fprintf(f, "LDT=%04x %08x %08x %08x\n",
cpu_fprintf(f, "LDT=%04x %08x %08x %08x\n",
env->ldt.selector,
(int)env->ldt.base,
env->ldt.limit,
env->ldt.flags);
fprintf(f, "TR =%04x %08x %08x %08x\n",
cpu_fprintf(f, "TR =%04x %08x %08x %08x\n",
env->tr.selector,
(int)env->tr.base,
env->tr.limit,
env->tr.flags);
fprintf(f, "GDT= %08x %08x\n",
cpu_fprintf(f, "GDT= %08x %08x\n",
(int)env->gdt.base, env->gdt.limit);
fprintf(f, "IDT= %08x %08x\n",
cpu_fprintf(f, "IDT= %08x %08x\n",
(int)env->idt.base, env->idt.limit);
fprintf(f, "CR0=%08x CR2=%08x CR3=%08x CR4=%08x\n",
cpu_fprintf(f, "CR0=%08x CR2=%08x CR3=%08x CR4=%08x\n",
env->cr[0], env->cr[2], env->cr[3], env->cr[4]);

if (flags & X86_DUMP_CCOP) {
if ((unsigned)env->cc_op < CC_OP_NB)
snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->cc_op]);
else
snprintf(cc_op_name, sizeof(cc_op_name), "[%d]", env->cc_op);
fprintf(f, "CCS=%08x CCD=%08x CCO=%-8s\n",
cpu_fprintf(f, "CCS=%08x CCD=%08x CCO=%-8s\n",
env->cc_src, env->cc_dst, cc_op_name);
}
if (flags & X86_DUMP_FPU) {
fprintf(f, "ST0=%f ST1=%f ST2=%f ST3=%f\n",
cpu_fprintf(f, "ST0=%f ST1=%f ST2=%f ST3=%f\n",
(double)env->fpregs[0],
(double)env->fpregs[1],
(double)env->fpregs[2],
(double)env->fpregs[3]);
fprintf(f, "ST4=%f ST5=%f ST6=%f ST7=%f\n",
cpu_fprintf(f, "ST4=%f ST5=%f ST6=%f ST7=%f\n",
(double)env->fpregs[4],
(double)env->fpregs[5],
(double)env->fpregs[7],
Expand Down
2 changes: 1 addition & 1 deletion target-i386/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4641,7 +4641,7 @@ static inline int gen_intermediate_code_internal(CPUState *env,

#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_CPU) {
cpu_dump_state(env, logfile, X86_DUMP_CCOP);
cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
}
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "----------------\n");
Expand Down
1 change: 0 additions & 1 deletion target-ppc/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ int cpu_ppc_signal_handler(int host_signum, struct siginfo *info,
void do_interrupt (CPUPPCState *env);
void cpu_loop_exit(void);

void cpu_ppc_dump_state(CPUPPCState *env, FILE *f, int flags);
void dump_stack (CPUPPCState *env);

uint32_t _load_xer (CPUPPCState *env);
Expand Down
4 changes: 2 additions & 2 deletions target-ppc/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ int cpu_ppc_handle_mmu_fault (CPUState *env, uint32_t address, int rw,
do_fault:
#if defined (DEBUG_MMU)
if (loglevel > 0)
cpu_ppc_dump_state(env, logfile, 0);
cpu_dump_state(env, logfile, fprintf, 0);
#endif
if (access_type == ACCESS_CODE) {
exception = EXCP_ISI;
Expand Down Expand Up @@ -676,7 +676,7 @@ void do_interrupt (CPUState *env)
env->nip, excp << 8, env->error_code);
}
if (loglevel > 0)
cpu_ppc_dump_state(env, logfile, 0);
cpu_dump_state(env, logfile, fprintf, 0);
}
#endif
if (loglevel & CPU_LOG_INT) {
Expand Down
4 changes: 2 additions & 2 deletions target-ppc/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ void do_store_dbat (int ul, int nr)
/* Special helpers for debug */
void dump_state (void)
{
// cpu_ppc_dump_state(env, stdout, 0);
// cpu_dump_state(env, stdout, fprintf, 0);
}

void dump_rfi (void)
{
#if 0
printf("Return from interrupt => 0x%08x\n", env->nip);
// cpu_ppc_dump_state(env, stdout, 0);
// cpu_dump_state(env, stdout, fprintf, 0);
#endif
}

Expand Down
Loading

0 comments on commit 7fe4848

Please sign in to comment.