From: Stanislav S. <ssh...@us...> - 2005-12-19 17:58:20
|
Update of /cvsroot/bochs/bochs/cpu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1082/cpu Modified Files: cpu.h debugstuff.cc Log Message: New debug function in cpu Index: cpu.h =================================================================== RCS file: /cvsroot/bochs/bochs/cpu/cpu.h,v retrieving revision 1.249 retrieving revision 1.250 diff -u -d -r1.249 -r1.250 --- cpu.h 14 Dec 2005 20:05:40 -0000 1.249 +++ cpu.h 19 Dec 2005 17:58:08 -0000 1.250 @@ -2817,6 +2817,9 @@ BX_SMF void sanity_checks(void); BX_SMF void debug(bx_address offset); +#if BX_DISASM + BX_SMF void debug_disasm_instruction(bx_address offset); +#endif #if BX_EXTERNAL_DEBUGGER BX_SMF void trap_debugger(bx_bool callnow); Index: debugstuff.cc =================================================================== RCS file: /cvsroot/bochs/bochs/cpu/debugstuff.cc,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- debugstuff.cc 14 Dec 2005 20:05:40 -0000 1.46 +++ debugstuff.cc 19 Dec 2005 17:58:08 -0000 1.47 @@ -25,12 +25,43 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - #define NEED_CPU_REG_SHORTCUTS 1 #include "bochs.h" #define LOG_THIS BX_CPU_THIS_PTR +#if BX_DISASM +void BX_CPU_C::debug_disasm_instruction(bx_address offset) +{ + bx_bool valid; + Bit32u phy_addr; + Bit8u instr_buf[16]; + char char_buf[256]; + unsigned isize; + + static disassembler bx_disassemble; + + dbg_xlate_linear2phy(BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_CS) + offset, + &phy_addr, &valid); + if (valid && BX_CPU_THIS_PTR mem!=NULL) { + BX_CPU_THIS_PTR mem->dbg_fetch_mem(phy_addr, 16, instr_buf); + isize = bx_disassemble.disasm( + BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b, + BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64, + BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_CS), offset, + instr_buf, char_buf); +#if BX_SUPPORT_X86_64 + if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) isize = 16; +#endif + for (unsigned j=0; j<isize; j++) + BX_INFO((">> %02x", (unsigned) instr_buf[j])); + BX_INFO((">> : %s", char_buf)); + } + else { + BX_INFO(("(instruction unavailable) page not present")); + } +} +#endif // #if BX_DISASM + void BX_CPU_C::debug(bx_address offset) { @@ -177,35 +208,7 @@ #if BX_DISASM - bx_bool valid; - Bit32u phy_addr; - Bit8u instr_buf[32]; - char char_buf[256]; - unsigned isize; - - static disassembler bx_disassemble; - - dbg_xlate_linear2phy(BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_CS) + offset, - &phy_addr, &valid); - if (valid && BX_CPU_THIS_PTR mem!=NULL) { - BX_CPU_THIS_PTR mem->dbg_fetch_mem(phy_addr, 16, instr_buf); - isize = bx_disassemble.disasm( - BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b, - BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64, - BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_CS), offset, - instr_buf, char_buf); -#if BX_SUPPORT_X86_64 - if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) isize = 16; -#endif - for (unsigned j=0; j<isize; j++) - BX_INFO((">> %02x", (unsigned) instr_buf[j])); - BX_INFO((">> : %s", char_buf)); - } - else { - BX_INFO(("(instruction unavailable) page not present")); - } -#else - UNUSED(offset); + debug_disasm_instruction(offset); #endif // #if BX_DISASM } |