From 7ff21b5f306c17fb640d604a21c3da5db373fb16 Mon Sep 17 00:00:00 2001 From: Bryce Denney Date: Fri, 13 Sep 2002 18:15:20 +0000 Subject: [PATCH] - the implementation of accessors should not use BX_CPU_C_PREFIX. When static member functions are turned on, BX_CPU_C_PREFIX expands to nothing, and any method that uses BX_CPU_C_PREFIX instead of explictly writing "BX_CPU_C::" will not be a member function at all. This makes it impossible for code outside the BX_CPU_C object to call the accessor because sometimes the method is at ptr_to_cpu->get_EIP() and other times you'd have to do just get_EIP(). The only way I've found to solve this is to remove the BX_CPU_C_PREFIX and write BX_CPU_C:: instead. - in debug/dbg_main.cc I removed the EBP, EIP, ESP, SP shortcuts. Now the accessors are used everywhere. Also I replaced a reference to the short-lived get_erx() accessor with ones that work: get_EAX(), etc. - with these changes the current cvs compiles with any combination of debugger enabled/disabled, SMP enabled/disabled, and x86-64 enabled/disabled. --- bochs/cpu/cpu.h | 29 +++++++++++++++-------------- bochs/debug/dbg_main.cc | 37 ++++++++++++++----------------------- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/bochs/cpu/cpu.h b/bochs/cpu/cpu.h index a4e31cbc9..becd86d3f 100644 --- a/bochs/cpu/cpu.h +++ b/bochs/cpu/cpu.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpu.h,v 1.49 2002-09-13 17:04:11 kevinlawton Exp $ +// $Id: cpu.h,v 1.50 2002-09-13 18:15:19 bdenney Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -376,6 +376,7 @@ typedef struct { BX_CPP_INLINE void clear_##name (); \ BX_CPP_INLINE Boolean get_##name (); \ BX_CPP_INLINE void set_##name (Bit8u val); + // end of DECLARE_EFLAGS_ACCESSORS #define IMPLEMENT_EFLAGS_ACCESSORS(name,bitnum) \ BX_CPP_INLINE void BX_CPU_C::assert_##name () { \ @@ -391,7 +392,7 @@ typedef struct { BX_CPU_THIS_PTR eflags.val32 = \ (BX_CPU_THIS_PTR eflags.val32&~(1<gen_reg[5].get_erx()) -#if BX_SUPPORT_X86_64 -#define EIP (BX_CPU(dbg_cpu)->dword.eip) -#else -#define EIP (BX_CPU(dbg_cpu)->eip) -#endif -#define ESP (BX_CPU(dbg_cpu)->gen_reg[4].get_erx ()) -#define SP (BX_CPU(dbg_cpu)->gen_reg[4].word.rx) - - static unsigned doit = 0; #define SIM_NAME0 "bochs" @@ -1001,8 +990,8 @@ bx_dbg_where_command() fprintf(stderr, "non-zero stack base\n"); return; } - Bit32u bp = EBP; - Bit32u ip = EIP; + Bit32u bp = BX_CPU(dbg_cpu)->get_EBP (); + Bit32u ip = BX_CPU(dbg_cpu)->get_EIP (); fprintf(stderr, "(%d) 0x%08x\n", 0, ip); for (int i = 1; i < 50; i++) { // Up @@ -1247,7 +1236,9 @@ void bx_dbg_print_stack_command(int nwords) { // Get linear address for stack top - Bit32u sp = (BX_CPU(dbg_cpu)->sregs[BX_SREG_SS].cache.u.segment.d_b) ? ESP : SP; + Bit32u sp = (BX_CPU(dbg_cpu)->sregs[BX_SREG_SS].cache.u.segment.d_b)? + BX_CPU(dbg_cpu)->get_ESP () + : BX_CPU(dbg_cpu)->get_SP (); Bit32u linear_sp = sp + BX_CPU(dbg_cpu)->sregs[BX_SREG_SS].cache.u.segment.base; Bit8u buf[8]; @@ -2111,14 +2102,14 @@ void bx_dbg_disassemble_current (int which_cpu, int print_time) if( BX_CPU(dbg_cpu)->trace_reg ) fprintf( stderr, "eax: %08X\tecx: %08X\tedx: %08X\tebx: %08X\tesp: %08X\tebp: %08X\tesi: %08X\tedi: %08X\ncf=%u af=%u zf=%u sf=%u of=%u pf=%u tf=%u if=%u df=%u iopl=%u nt=%u rf=%u vm=%u\n", - BX_CPU(which_cpu)->gen_reg[0].get_erx(), - BX_CPU(which_cpu)->gen_reg[1].get_erx(), - BX_CPU(which_cpu)->gen_reg[2].get_erx(), - BX_CPU(which_cpu)->gen_reg[3].get_erx(), - BX_CPU(which_cpu)->gen_reg[4].get_erx(), - BX_CPU(which_cpu)->gen_reg[5].get_erx(), - BX_CPU(which_cpu)->gen_reg[6].get_erx(), - BX_CPU(which_cpu)->gen_reg[7].get_erx(), + BX_CPU(which_cpu)->get_EAX (), + BX_CPU(which_cpu)->get_EBX (), + BX_CPU(which_cpu)->get_ECX (), + BX_CPU(which_cpu)->get_EDX (), + BX_CPU(which_cpu)->get_ESP (), + BX_CPU(which_cpu)->get_EBP (), + BX_CPU(which_cpu)->get_ESI (), + BX_CPU(which_cpu)->get_EDI (), !!BX_CPU(which_cpu)->get_CF(), !!BX_CPU(which_cpu)->get_AF(), !!BX_CPU(which_cpu)->get_ZF(),