Don't know how much it helps ...

First step to make bx debugger supporting x86-64. guard_found object fields conerted to bx_address for x86-64 support.
This commit is contained in:
Stanislav Shwartsman 2006-01-19 18:32:39 +00:00
parent 99c8f9c8ae
commit 08c15c67c0
6 changed files with 58 additions and 65 deletions

View File

@ -12,7 +12,7 @@ Changes in 2.2.6 (not yet released):
- enabled LAHF/SAHF instructions in x86-64 mode (Stanislav Shwartsman)
- determine number of processors in SMP configuration through .bochsrc file
- new .bochsrc option to choose number of processors to emulate
- new to configure option --enable-smp to configure Bochs for SMP support,
- new configure option --enable-smp to configure Bochs for SMP support,
the old --enable-processors=N option is deprecated
- updated Bochs instrumentation examples (Stanislav Shwartsman)
- fixed bug in PMULUDQ SSE2 instruction (Kevin Lawton)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: bochs.h,v 1.165 2006-01-18 18:35:30 sshwarts Exp $
// $Id: bochs.h,v 1.166 2006-01-19 18:32:39 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -405,9 +405,9 @@ BOCHSAPI extern logfunc_t *genlog;
#endif
#if BX_SUPPORT_X86_64
#define FMT_ADDRX FMT_LL "x"
#define FMT_ADDRX FMT_ADDRX64
#else
#define FMT_ADDRX "%08x"
#define FMT_ADDRX FMT_ADDRX32
#endif
#if BX_DISASM

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: dbg_main.cc,v 1.34 2006-01-18 18:35:37 sshwarts Exp $
// $Id: dbg_main.cc,v 1.35 2006-01-19 18:32:39 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -444,9 +444,11 @@ process_sim2:
BX_CPU(i)->guard_found.cs = BX_CPU(i)->sregs[BX_SEG_REG_CS].selector.value;
BX_CPU(i)->guard_found.eip = BX_CPU(i)->prev_eip;
BX_CPU(i)->guard_found.laddr =
BX_CPU(i)->get_segment_base(BX_SEG_REG_CS) + BX_CPU(i)->prev_eip;
(BX_CPU(i)->get_segment_base(BX_SEG_REG_CS) + BX_CPU(i)->prev_eip);
BX_CPU(i)->guard_found.is_32bit_code =
BX_CPU(i)->sregs[BX_SEG_REG_CS].cache.u.segment.d_b;
(BX_CPU(i)->sregs[BX_SEG_REG_CS].cache.u.segment.d_b);
BX_CPU(i)->guard_found.is_64bit_code =
(BX_CPU(i)->get_cpu_mode() == BX_MODE_LONG_64);
}
// finally, call the usual function to print the disassembly
dbg_printf ("Next at t=" FMT_LL "d\n", bx_pc_system.time_ticks ());
@ -1099,7 +1101,7 @@ void bx_dbg_show_command(char* arg)
last_pe = BX_CPU(dbg_cpu)->cr0.pe;
last_vm = BX_CPU(dbg_cpu)->getB_VM ();
dbg_printf (FMT_TICK ": address %04x:%08x %08x\n\n",
dbg_printf (FMT_TICK ": address %04x:" FMT_ADDRX " " FMT_ADDRX "\n\n",
bx_pc_system.time_ticks(),
BX_CPU(dbg_cpu)->guard_found.cs,
BX_CPU(dbg_cpu)->guard_found.eip,
@ -1314,7 +1316,7 @@ one_more:
int max_executed = 0;
for (cpu=0; cpu<BX_SMP_PROCESSORS; cpu++) {
if (BX_CPU(cpu)->guard_found.icount > max_executed)
max_executed = BX_CPU(cpu)->guard_found.icount;
max_executed = BX_CPU(cpu)->guard_found.icount;
}
// potential deadlock if all processors are halted. Then
// max_executed will be 0, tick will be incremented by zero, and
@ -1405,10 +1407,8 @@ void bx_dbg_disassemble_current (int which_cpu, int print_time)
BX_CPU(which_cpu)->mem->dbg_fetch_mem(phy, 16, bx_disasm_ibuf);
unsigned cpu_mode = BX_CPU(which_cpu)->get_cpu_mode();
ilen = bx_disassemble.disasm(BX_CPU(which_cpu)->guard_found.is_32bit_code,
cpu_mode == BX_MODE_LONG_64 /* is_64 */,
BX_CPU(which_cpu)->guard_found.is_64bit_code,
BX_CPU(which_cpu)->get_segment_base(BX_SEG_REG_CS),
BX_CPU(which_cpu)->guard_found.eip, bx_disasm_ibuf, bx_disasm_tbuf);
@ -1446,19 +1446,17 @@ void bx_dbg_disassemble_current (int which_cpu, int print_time)
else
dbg_printf ("(%u) ", which_cpu);
if (BX_CPU(which_cpu)->get_cpu_mode() == BX_MODE_IA32_PROTECTED) { // 16bit & 32bit protected mode
dbg_printf ("[0x%08x] %04x:%08x (%s): ",
phy,
(unsigned) BX_CPU(which_cpu)->guard_found.cs,
(unsigned) BX_CPU(which_cpu)->guard_found.eip,
dbg_printf ("[0x%08x] %04x:" FMT_ADDRX " (%s): ",
phy, BX_CPU(which_cpu)->guard_found.cs,
BX_CPU(which_cpu)->guard_found.eip,
bx_dbg_symbolic_address((BX_CPU(which_cpu)->cr3) >> 12, BX_CPU(which_cpu)->guard_found.eip, BX_CPU(which_cpu)->get_segment_base(BX_SEG_REG_CS)));
}
}
else { // Real & V86 mode
dbg_printf ("[0x%08x] %04x:%04x (%s): ",
phy,
(unsigned) BX_CPU(which_cpu)->guard_found.cs,
phy, BX_CPU(which_cpu)->guard_found.cs,
(unsigned) BX_CPU(which_cpu)->guard_found.eip,
bx_dbg_symbolic_address_16bit(BX_CPU(which_cpu)->guard_found.eip, BX_CPU(which_cpu)->sregs[BX_SEG_REG_CS].selector.value));
}
}
dbg_printf ("%-25s ; ", bx_disasm_tbuf);
for (unsigned j=0; j<ilen; j++)
dbg_printf ("%02x", (unsigned) bx_disasm_ibuf[j]);
@ -1482,7 +1480,7 @@ for (sim=0; sim<BX_SMP_PROCESSORS; sim++) {
#if BX_DBG_SUPPORT_VIR_BPOINT
else if (found & BX_DBG_GUARD_IADDR_VIR) {
i = BX_CPU(sim)->guard_found.iaddr_index;
dbg_printf ("(%u) Breakpoint %u, 0x%x (0x%x:0x%x)\n",
dbg_printf ("(%u) Breakpoint %u, " FMT_ADDRX " (0x%04x:" FMT_ADDRX ")\n",
sim,
bx_guard.iaddr.vir[i].bpoint_id,
BX_CPU(sim)->guard_found.laddr,
@ -1494,7 +1492,7 @@ for (sim=0; sim<BX_SMP_PROCESSORS; sim++) {
else if (found & BX_DBG_GUARD_IADDR_LIN) {
i = BX_CPU(sim)->guard_found.iaddr_index;
if (bx_guard.iaddr.lin[i].bpoint_id != 0)
dbg_printf ("(%u) Breakpoint %u, 0x%x in ?? ()\n",
dbg_printf ("(%u) Breakpoint %u, 0x" FMT_ADDRX " in ?? ()\n",
sim,
bx_guard.iaddr.lin[i].bpoint_id,
BX_CPU(sim)->guard_found.laddr);
@ -1503,7 +1501,7 @@ for (sim=0; sim<BX_SMP_PROCESSORS; sim++) {
#if BX_DBG_SUPPORT_PHY_BPOINT
else if (found & BX_DBG_GUARD_IADDR_PHY) {
i = BX_CPU(sim)->guard_found.iaddr_index;
dbg_printf ("(%u) Breakpoint %u, 0x%x in ?? ()\n",
dbg_printf ("(%u) Breakpoint %u, 0x" FMT_ADDRX " in ?? ()\n",
sim,
bx_guard.iaddr.phy[i].bpoint_id,
BX_CPU(sim)->guard_found.laddr);
@ -3409,21 +3407,21 @@ int bx_dbg_symbolic_output(void)
/* interrupts */
if (dbg_show_mask & 0x40) {
if(BX_CPU(dbg_cpu)->show_flag & 0x4) {
dbg_printf (FMT_TICK ": softint %04x:%08x %08x\n",
dbg_printf (FMT_TICK ": softint %04x:" FMT_ADDRX " " FMT_ADDRX "\n",
bx_pc_system.time_ticks(),
BX_CPU(dbg_cpu)->guard_found.cs,
BX_CPU(dbg_cpu)->guard_found.eip,
BX_CPU(dbg_cpu)->guard_found.laddr);
}
if((BX_CPU(dbg_cpu)->show_flag & 0x10) && !(BX_CPU(dbg_cpu)->show_flag & 0x4)) {
dbg_printf ("\n" FMT_TICK ": exception (not softint) %04x:%08x %08x\n",
dbg_printf (FMT_TICK ": exception (not softint) %04x:" FMT_ADDRX " " FMT_ADDRX "\n",
bx_pc_system.time_ticks(),
BX_CPU(dbg_cpu)->guard_found.cs,
BX_CPU(dbg_cpu)->guard_found.eip,
BX_CPU(dbg_cpu)->guard_found.laddr);
}
if(BX_CPU(dbg_cpu)->show_flag & 0x8) {
dbg_printf (FMT_TICK ": iret %04x:%08x %08x (from %08x)\n\n",
dbg_printf (FMT_TICK ": iret %04x:" FMT_ADDRX " " FMT_ADDRX "(from " FMT_ADDRX ")\n",
bx_pc_system.time_ticks(),
BX_CPU(dbg_cpu)->guard_found.cs,
BX_CPU(dbg_cpu)->guard_found.eip,
@ -3441,10 +3439,8 @@ int bx_dbg_symbolic_output(void)
BX_CPU(dbg_cpu)->dbg_xlate_linear2phy(BX_CPU(dbg_cpu)->guard_found.laddr,
&phy, &valid);
// mingw doesn't like %ll and %*s in one statement
dbg_printf (FMT_TICK ":", bx_pc_system.time_ticks());
dbg_printf ("%*s call %04x:%08x 0x%08x (%08x) %s",
symbol_level+1," ",
dbg_printf (FMT_TICK ": %*s call %04x:" FMT_ADDRX " 0x" FMT_ADDRX " (%08x) %s",
bx_pc_system.time_ticks(), symbol_level+1," ",
BX_CPU(dbg_cpu)->guard_found.cs,
BX_CPU(dbg_cpu)->guard_found.eip,
BX_CPU(dbg_cpu)->guard_found.laddr,
@ -4373,7 +4369,7 @@ void bx_dbg_info_flags(void)
if(BX_CPU(dbg_cpu)->getB_PF())
dbg_printf ("PF ");
if(BX_CPU(dbg_cpu)->getB_CF())
dbg_printf ("CF");
dbg_printf ("CF ");
dbg_printf ("\n");
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: debug.h,v 1.6 2006-01-15 17:55:25 sshwarts Exp $
// $Id: debug.h,v 1.7 2006-01-19 18:32:39 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -194,7 +194,7 @@ extern Bit32u read_watchpoint[MAX_READ_WATCHPOINTS];
typedef enum {
STOP_NO_REASON = 0, STOP_TIME_BREAK_POINT, STOP_READ_WATCH_POINT,
STOP_WRITE_WATCH_POINT, STOP_MAGIC_BREAK_POINT, UNUSED_STOP_TRACE,
STOP_WRITE_WATCH_POINT, STOP_MAGIC_BREAK_POINT,
STOP_MODE_BREAK_POINT, STOP_CPU_HALTED, STOP_CPU_PANIC
} stop_reason_t;
@ -219,12 +219,9 @@ typedef enum {
#define BX_DBG_REG_FS 24
#define BX_DBG_REG_GS 25
#define BX_DBG_PENDING_DMA 1
#define BX_DBG_PENDING_IRQ 2
void bx_debug_break ();
void bx_dbg_exit(int code);
@ -260,7 +257,6 @@ void dbg_printf (const char *fmt, ...);
#define BX_DBG_GUARD_ICOUNT 0x0400
#define BX_DBG_GUARD_CTRL_C 0x0800
typedef struct {
unsigned long guard_for;
@ -351,16 +347,16 @@ typedef struct bx_guard_found_t {
unsigned long guard_found;
unsigned iaddr_index;
bx_dbg_icount_t icount; // number of completed instructions
Bit32u cs; // cs:eip and linear addr of instruction at guard point
Bit32u eip;
Bit32u laddr;
bx_bool is_32bit_code; // CS seg size at guard point
bx_bool ctrl_c; // simulator stopped due to Ctrl-C request
Bit64u time_tick; //time tick when guard reached
Bit32u cs; // cs:eip and linear addr of instruction at guard point
bx_address eip;
bx_address laddr;
bx_bool is_32bit_code; // CS seg size at guard point
bx_bool is_64bit_code;
bx_bool ctrl_c; // simulator stopped due to Ctrl-C request
Bit64u time_tick; // time tick when guard reached
} bx_guard_found_t;
extern bx_guard_t bx_guard;
extern bx_guard_t bx_guard;
int bx_dbg_main(int argc, char *argv[]);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.cc,v 1.122 2006-01-18 18:35:37 sshwarts Exp $
// $Id: cpu.cc,v 1.123 2006-01-19 18:32:39 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -179,12 +179,13 @@ void BX_CPU_C::cpu_loop(Bit32s max_instr_count)
#if BX_DEBUGGER
{
Bit32u debug_eip = BX_CPU_THIS_PTR prev_eip;
if ( dbg_is_begin_instr_bpoint(
bx_address debug_eip = BX_CPU_THIS_PTR prev_eip;
if (dbg_is_begin_instr_bpoint(
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
debug_eip,
BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_CS) + debug_eip,
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b) )
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b,
Is64BitMode()))
{
return;
}
@ -471,12 +472,14 @@ debugger_check:
{
// check for icount or control-C. If found, set guard reg and return.
Bit32u debug_eip = BX_CPU_THIS_PTR prev_eip;
if ( dbg_is_end_instr_bpoint(
bx_address debug_eip = BX_CPU_THIS_PTR prev_eip;
if (dbg_is_end_instr_bpoint(
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
debug_eip,
BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_CS) + debug_eip,
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b) ) {
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b,
Is64BitMode()))
{
return;
}
}
@ -875,15 +878,15 @@ void BX_CPU_C::trap_debugger (bx_bool callnow)
#if BX_DEBUGGER
extern unsigned int dbg_show_mask;
bx_bool BX_CPU_C::dbg_is_begin_instr_bpoint(Bit32u cs, Bit32u eip, Bit32u laddr, Bit32u is_32)
bx_bool BX_CPU_C::dbg_is_begin_instr_bpoint(Bit16u cs, bx_address eip, bx_address laddr, bx_bool is_32, bx_bool is_64)
{
Bit64u tt = bx_pc_system.time_ticks();
//fprintf (stderr, "begin_instr_bp: checking cs:eip %04x:%08x\n", cs, eip);
BX_CPU_THIS_PTR guard_found.cs = cs;
BX_CPU_THIS_PTR guard_found.eip = eip;
BX_CPU_THIS_PTR guard_found.laddr = laddr;
BX_CPU_THIS_PTR guard_found.is_32bit_code = is_32;
BX_CPU_THIS_PTR guard_found.is_64bit_code = is_64;
// BW mode switch breakpoint
// instruction which generate exceptions never reach the end of the
@ -914,7 +917,8 @@ bx_bool BX_CPU_C::dbg_is_begin_instr_bpoint(Bit32u cs, Bit32u eip, Bit32u laddr,
for (unsigned i=0; i<bx_guard.iaddr.num_virtual; i++) {
if ( bx_guard.iaddr.vir[i].enabled &&
(bx_guard.iaddr.vir[i].cs == cs) &&
(bx_guard.iaddr.vir[i].eip == eip) ) {
(bx_guard.iaddr.vir[i].eip == eip) )
{
BX_CPU_THIS_PTR guard_found.guard_found = BX_DBG_GUARD_IADDR_VIR;
BX_CPU_THIS_PTR guard_found.iaddr_index = i;
BX_CPU_THIS_PTR guard_found.time_tick = tt;
@ -931,7 +935,8 @@ bx_bool BX_CPU_C::dbg_is_begin_instr_bpoint(Bit32u cs, Bit32u eip, Bit32u laddr,
{
for (unsigned i=0; i<bx_guard.iaddr.num_linear; i++) {
if (bx_guard.iaddr.lin[i].enabled &&
(bx_guard.iaddr.lin[i].addr == BX_CPU_THIS_PTR guard_found.laddr) ) {
(bx_guard.iaddr.lin[i].addr == BX_CPU_THIS_PTR guard_found.laddr) )
{
BX_CPU_THIS_PTR guard_found.guard_found = BX_DBG_GUARD_IADDR_LIN;
BX_CPU_THIS_PTR guard_found.iaddr_index = i;
BX_CPU_THIS_PTR guard_found.time_tick = tt;
@ -971,9 +976,7 @@ bx_bool BX_CPU_C::dbg_is_begin_instr_bpoint(Bit32u cs, Bit32u eip, Bit32u laddr,
return(0); // not on a breakpoint
}
bx_bool
BX_CPU_C::dbg_is_end_instr_bpoint(Bit32u cs, Bit32u eip, Bit32u laddr,
Bit32u is_32)
bx_bool BX_CPU_C::dbg_is_end_instr_bpoint(Bit16u cs, bx_address eip, bx_address laddr, bx_bool is_32, bx_bool is_64)
{
//fprintf (stderr, "end_instr_bp: checking for icount or ^C\n");
BX_CPU_THIS_PTR guard_found.icount++;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.252 2006-01-18 18:35:37 sshwarts Exp $
// $Id: cpu.h,v 1.253 2006-01-19 18:32:39 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1182,7 +1182,7 @@ public: // for now...
Bit8u trace_reg;
Bit8u mode_break; /* BW */
bx_bool debug_vm; /* BW contains current mode*/
Bit8u show_eip; /* BW record eip at special instr f.ex eip */
bx_address show_eip; /* BW record eip at special instr f.ex eip */
Bit8u show_flag; /* BW shows instr class executed */
bx_guard_found_t guard_found;
#endif
@ -2607,10 +2607,8 @@ public: // for now...
BX_SMF Bit32u dbg_get_descriptor_l(bx_descriptor_t *);
BX_SMF Bit32u dbg_get_descriptor_h(bx_descriptor_t *);
BX_SMF Bit32u dbg_get_eflags(void);
BX_SMF bx_bool dbg_is_begin_instr_bpoint(Bit32u cs, Bit32u eip, Bit32u laddr,
Bit32u is_32);
BX_SMF bx_bool dbg_is_end_instr_bpoint(Bit32u cs, Bit32u eip,
Bit32u laddr, Bit32u is_32);
BX_SMF bx_bool dbg_is_begin_instr_bpoint(Bit16u cs, bx_address eip, bx_address laddr, bx_bool is_32, bx_bool is_64);
BX_SMF bx_bool dbg_is_end_instr_bpoint(Bit16u cs, bx_address eip, bx_address laddr, bx_bool is_32, bx_bool is_64);
#endif
#if BX_DEBUGGER || BX_DISASM || BX_INSTRUMENTATION || BX_GDBSTUB
BX_SMF void dbg_xlate_linear2phy(bx_address linear, Bit32u *phy, bx_bool *valid);