Commit b3ec4b91 authored by Ulrich Weigand's avatar Ulrich Weigand Committed by Alexandre Julliard

Made debugger compile and marginally work on non-Intel archs.

parent 6bba78e1
...@@ -76,6 +76,7 @@ static void DEBUG_SetOpcode( const DBG_ADDR *addr, BYTE op ) ...@@ -76,6 +76,7 @@ static void DEBUG_SetOpcode( const DBG_ADDR *addr, BYTE op )
*/ */
static BOOL DEBUG_IsStepOverInstr() static BOOL DEBUG_IsStepOverInstr()
{ {
#ifdef __i386__
BYTE *instr = (BYTE *)CTX_SEG_OFF_TO_LIN( &DEBUG_context, BYTE *instr = (BYTE *)CTX_SEG_OFF_TO_LIN( &DEBUG_context,
CS_reg(&DEBUG_context), CS_reg(&DEBUG_context),
EIP_reg(&DEBUG_context) ); EIP_reg(&DEBUG_context) );
...@@ -133,6 +134,9 @@ static BOOL DEBUG_IsStepOverInstr() ...@@ -133,6 +134,9 @@ static BOOL DEBUG_IsStepOverInstr()
return FALSE; return FALSE;
} }
} }
#else
return FALSE;
#endif
} }
...@@ -144,6 +148,7 @@ static BOOL DEBUG_IsStepOverInstr() ...@@ -144,6 +148,7 @@ static BOOL DEBUG_IsStepOverInstr()
*/ */
BOOL DEBUG_IsFctReturn(void) BOOL DEBUG_IsFctReturn(void)
{ {
#ifdef __i386__
BYTE *instr = (BYTE *)CTX_SEG_OFF_TO_LIN( &DEBUG_context, BYTE *instr = (BYTE *)CTX_SEG_OFF_TO_LIN( &DEBUG_context,
CS_reg(&DEBUG_context), CS_reg(&DEBUG_context),
EIP_reg(&DEBUG_context) ); EIP_reg(&DEBUG_context) );
...@@ -159,6 +164,9 @@ BOOL DEBUG_IsFctReturn(void) ...@@ -159,6 +164,9 @@ BOOL DEBUG_IsFctReturn(void)
return FALSE; return FALSE;
} }
} }
#else
return FALSE;
#endif
} }
...@@ -391,18 +399,13 @@ BOOL DEBUG_ShouldContinue( enum exec_mode mode, int * count ) ...@@ -391,18 +399,13 @@ BOOL DEBUG_ShouldContinue( enum exec_mode mode, int * count )
DBG_ADDR cond_addr; DBG_ADDR cond_addr;
int bpnum; int bpnum;
struct list_id list; struct list_id list;
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
#ifdef __i386__
/* If not single-stepping, back up over the int3 instruction */ /* If not single-stepping, back up over the int3 instruction */
if (!(EFL_reg(&DEBUG_context) & STEP_FLAG)) EIP_reg(&DEBUG_context)--; if (!(EFL_reg(&DEBUG_context) & STEP_FLAG)) EIP_reg(&DEBUG_context)--;
#endif
addr.seg = CS_reg(&DEBUG_context); DEBUG_GetCurrentAddress( &addr );
addr.off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context)) addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16; else
if (IS_SELECTOR_SYSTEM(addr.seg)) addr.seg = 0;
GlobalUnlock16( GetCurrentTask() );
bpnum = DEBUG_FindBreakpoint( &addr ); bpnum = DEBUG_FindBreakpoint( &addr );
breakpoints[0].enabled = 0; /* disable the step-over breakpoint */ breakpoints[0].enabled = 0; /* disable the step-over breakpoint */
...@@ -493,10 +496,12 @@ BOOL DEBUG_ShouldContinue( enum exec_mode mode, int * count ) ...@@ -493,10 +496,12 @@ BOOL DEBUG_ShouldContinue( enum exec_mode mode, int * count )
} }
} }
#ifdef __i386__
/* If there's no breakpoint and we are not single-stepping, then we */ /* If there's no breakpoint and we are not single-stepping, then we */
/* must have encountered an int3 in the Windows program; let's skip it. */ /* must have encountered an int3 in the Windows program; let's skip it. */
if ((bpnum == -1) && !(EFL_reg(&DEBUG_context) & STEP_FLAG)) if ((bpnum == -1) && !(EFL_reg(&DEBUG_context) & STEP_FLAG))
EIP_reg(&DEBUG_context)++; EIP_reg(&DEBUG_context)++;
#endif
/* no breakpoint, continue if in continuous mode */ /* no breakpoint, continue if in continuous mode */
return (mode == EXEC_CONT || mode == EXEC_PASS || mode == EXEC_FINISH); return (mode == EXEC_CONT || mode == EXEC_PASS || mode == EXEC_FINISH);
...@@ -516,17 +521,10 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -516,17 +521,10 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
int bp; int bp;
int delta; int delta;
int status; int status;
unsigned int * value;
enum exec_mode ret_mode; enum exec_mode ret_mode;
BYTE *instr; BYTE *instr;
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
addr.seg = CS_reg(&DEBUG_context); DEBUG_GetCurrentAddress( &addr );
addr.off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context)) addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16; else
if (IS_SELECTOR_SYSTEM(addr.seg)) addr.seg = 0;
GlobalUnlock16( GetCurrentTask() );
/* /*
* This is the mode we will be running in after we finish. We would like * This is the mode we will be running in after we finish. We would like
...@@ -559,9 +557,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -559,9 +557,7 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
mode = ret_mode = EXEC_STEPI_INSTR; mode = ret_mode = EXEC_STEPI_INSTR;
} }
instr = (BYTE *)CTX_SEG_OFF_TO_LIN( &DEBUG_context, instr = DBG_ADDR_TO_LIN( &addr );
CS_reg(&DEBUG_context),
EIP_reg(&DEBUG_context) );
/* /*
* See if the function we are stepping into has debug info * See if the function we are stepping into has debug info
* and line numbers. If not, then we step over it instead. * and line numbers. If not, then we step over it instead.
...@@ -615,7 +611,9 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -615,7 +611,9 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
{ {
case EXEC_CONT: /* Continuous execution */ case EXEC_CONT: /* Continuous execution */
case EXEC_PASS: /* Continue, passing exception */ case EXEC_PASS: /* Continue, passing exception */
#ifdef __i386__
EFL_reg(&DEBUG_context) &= ~STEP_FLAG; EFL_reg(&DEBUG_context) &= ~STEP_FLAG;
#endif
DEBUG_SetBreakpoints( TRUE ); DEBUG_SetBreakpoints( TRUE );
break; break;
...@@ -626,9 +624,10 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -626,9 +624,10 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
* off the stack, and we set the breakpoint there instead of the * off the stack, and we set the breakpoint there instead of the
* address just after the call. * address just after the call.
*/ */
value = (unsigned int *) ESP_reg(&DEBUG_context) + 2; #ifdef __i386__
addr.off = *value; addr.off = *((unsigned int *) ESP_reg(&DEBUG_context) + 2);
EFL_reg(&DEBUG_context) &= ~STEP_FLAG; EFL_reg(&DEBUG_context) &= ~STEP_FLAG;
#endif
breakpoints[0].addr = addr; breakpoints[0].addr = addr;
breakpoints[0].enabled = TRUE; breakpoints[0].enabled = TRUE;
breakpoints[0].in_use = TRUE; breakpoints[0].in_use = TRUE;
...@@ -642,7 +641,9 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -642,7 +641,9 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
case EXEC_STEP_OVER: /* Stepping over a call */ case EXEC_STEP_OVER: /* Stepping over a call */
if (DEBUG_IsStepOverInstr()) if (DEBUG_IsStepOverInstr())
{ {
#ifdef __i386__
EFL_reg(&DEBUG_context) &= ~STEP_FLAG; EFL_reg(&DEBUG_context) &= ~STEP_FLAG;
#endif
DEBUG_Disasm(&addr, FALSE); DEBUG_Disasm(&addr, FALSE);
breakpoints[0].addr = addr; breakpoints[0].addr = addr;
breakpoints[0].enabled = TRUE; breakpoints[0].enabled = TRUE;
...@@ -656,7 +657,9 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count ) ...@@ -656,7 +657,9 @@ enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count )
case EXEC_STEP_INSTR: /* Single-stepping an instruction */ case EXEC_STEP_INSTR: /* Single-stepping an instruction */
case EXEC_STEPI_INSTR: /* Single-stepping an instruction */ case EXEC_STEPI_INSTR: /* Single-stepping an instruction */
#ifdef __i386__
EFL_reg(&DEBUG_context) |= STEP_FLAG; EFL_reg(&DEBUG_context) |= STEP_FLAG;
#endif
break; break;
} }
return ret_mode; return ret_mode;
......
...@@ -65,6 +65,8 @@ ...@@ -65,6 +65,8 @@
#include <stdio.h> #include <stdio.h>
#include "debugger.h" #include "debugger.h"
#ifdef __i386__
/* /*
* Switch to disassemble 16-bit code. * Switch to disassemble 16-bit code.
*/ */
...@@ -1611,3 +1613,12 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display ) ...@@ -1611,3 +1613,12 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display )
} }
} }
} }
#else /* __i386__ */
void DEBUG_Disasm( DBG_ADDR *addr, int display )
{
}
#endif /* __i386__ */
...@@ -252,16 +252,7 @@ break_command: ...@@ -252,16 +252,7 @@ break_command:
} }
| tBREAK tNUM tEOL { struct name_hash *nh; | tBREAK tNUM tEOL { struct name_hash *nh;
DBG_ADDR addr; DBG_ADDR addr;
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() ); DEBUG_GetCurrentAddress( &addr );
addr.type = NULL;
addr.seg = CS_reg(&DEBUG_context);
addr.off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context))
addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
DBG_FIX_ADDR_SEG( &addr, CS_reg(&DEBUG_context) );
GlobalUnlock16( GetCurrentTask() );
DEBUG_FindNearestSymbol(&addr, TRUE, DEBUG_FindNearestSymbol(&addr, TRUE,
&nh, 0, NULL); &nh, 0, NULL);
if( nh != NULL ) if( nh != NULL )
...@@ -277,15 +268,7 @@ break_command: ...@@ -277,15 +268,7 @@ break_command:
} }
| tBREAK tEOL { DBG_ADDR addr; | tBREAK tEOL { DBG_ADDR addr;
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() ); DEBUG_GetCurrentAddress( &addr );
addr.type = NULL;
addr.seg = CS_reg(&DEBUG_context);
addr.off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context))
addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
GlobalUnlock16( GetCurrentTask() );
DEBUG_AddBreakpoint( &addr ); DEBUG_AddBreakpoint( &addr );
} }
...@@ -495,11 +478,15 @@ static void DEBUG_Main( BOOL is_debug ) ...@@ -495,11 +478,15 @@ static void DEBUG_Main( BOOL is_debug )
if (!is_debug) if (!is_debug)
{ {
#ifdef __i386__
if (IS_SELECTOR_SYSTEM(CS_reg(&DEBUG_context))) if (IS_SELECTOR_SYSTEM(CS_reg(&DEBUG_context)))
fprintf( stderr, " in 32-bit code (0x%08lx).\n", EIP_reg(&DEBUG_context)); fprintf( stderr, " in 32-bit code (0x%08lx).\n", EIP_reg(&DEBUG_context));
else else
fprintf( stderr, " in 16-bit code (%04x:%04lx).\n", fprintf( stderr, " in 16-bit code (%04x:%04lx).\n",
(WORD)CS_reg(&DEBUG_context), EIP_reg(&DEBUG_context) ); (WORD)CS_reg(&DEBUG_context), EIP_reg(&DEBUG_context) );
#else
fprintf( stderr, " (%p).\n", GET_IP(&DEBUG_context) );
#endif
} }
if (!loaded_symbols) if (!loaded_symbols)
...@@ -562,22 +549,18 @@ static void DEBUG_Main( BOOL is_debug ) ...@@ -562,22 +549,18 @@ static void DEBUG_Main( BOOL is_debug )
if (!is_debug || !DEBUG_ShouldContinue( dbg_exec_mode, &dbg_exec_count )) if (!is_debug || !DEBUG_ShouldContinue( dbg_exec_mode, &dbg_exec_count ))
{ {
DBG_ADDR addr; DBG_ADDR addr;
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() ); DEBUG_GetCurrentAddress( &addr );
addr.seg = CS_reg(&DEBUG_context);
addr.off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context)) addr.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
addr.type = NULL;
DBG_FIX_ADDR_SEG( &addr, 0 );
GlobalUnlock16( GetCurrentTask() );
DEBUG_Freeze( TRUE ); DEBUG_Freeze( TRUE );
/* Put the display in a correct state */ /* Put the display in a correct state */
USER_Driver->pBeginDebugging(); USER_Driver->pBeginDebugging();
#ifdef __i386__
newmode = ISV86(&DEBUG_context) ? 16 : IS_SELECTOR_32BIT(addr.seg) ? 32 : 16; newmode = ISV86(&DEBUG_context) ? 16 : IS_SELECTOR_32BIT(addr.seg) ? 32 : 16;
#else
newmode = 32;
#endif
if (newmode != dbg_mode) if (newmode != dbg_mode)
fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode); fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);
...@@ -587,6 +570,7 @@ static void DEBUG_Main( BOOL is_debug ) ...@@ -587,6 +570,7 @@ static void DEBUG_Main( BOOL is_debug )
{ {
DEBUG_InfoRegisters(); DEBUG_InfoRegisters();
DEBUG_InfoStack(); DEBUG_InfoStack();
#ifdef __i386__
if (dbg_mode == 16) if (dbg_mode == 16)
{ {
LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 ); LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 );
...@@ -594,6 +578,7 @@ static void DEBUG_Main( BOOL is_debug ) ...@@ -594,6 +578,7 @@ static void DEBUG_Main( BOOL is_debug )
LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 ); LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 );
} }
LDT_Print( SELECTOR_TO_ENTRY(FS_reg(&DEBUG_context)), 1 ); LDT_Print( SELECTOR_TO_ENTRY(FS_reg(&DEBUG_context)), 1 );
#endif
DEBUG_BackTrace(); DEBUG_BackTrace();
} }
else else
...@@ -626,9 +611,8 @@ static void DEBUG_Main( BOOL is_debug ) ...@@ -626,9 +611,8 @@ static void DEBUG_Main( BOOL is_debug )
issue_prompt(); issue_prompt();
yyparse(); yyparse();
flush_symbols(); flush_symbols();
addr.seg = CS_reg(&DEBUG_context) | (addr.seg&0xffff0000);
addr.off = EIP_reg(&DEBUG_context); DEBUG_GetCurrentAddress( &addr );
DBG_FIX_ADDR_SEG( &addr, 0 );
ret_ok = DEBUG_ValidateRegisters(); ret_ok = DEBUG_ValidateRegisters();
if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 ); if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 );
} while (!ret_ok); } while (!ret_ok);
......
...@@ -417,10 +417,12 @@ DEBUG_EvalExpr(struct expr * exp) ...@@ -417,10 +417,12 @@ DEBUG_EvalExpr(struct expr * exp)
rtn.type = DEBUG_TypeIntConst; rtn.type = DEBUG_TypeIntConst;
exp->un.rgister.result = DEBUG_GetRegister(exp->un.rgister.reg); exp->un.rgister.result = DEBUG_GetRegister(exp->un.rgister.reg);
rtn.off = (unsigned int) &exp->un.rgister.result; rtn.off = (unsigned int) &exp->un.rgister.result;
#ifdef __i386__
if( exp->un.rgister.reg == REG_EIP ) if( exp->un.rgister.reg == REG_EIP )
rtn.seg = CS_reg(&DEBUG_context); rtn.seg = CS_reg(&DEBUG_context);
else else
rtn.seg = DS_reg(&DEBUG_context); rtn.seg = DS_reg(&DEBUG_context);
#endif
DBG_FIX_ADDR_SEG( &rtn, 0 ); DBG_FIX_ADDR_SEG( &rtn, 0 );
break; break;
case EXPR_TYPE_BINOP: case EXPR_TYPE_BINOP:
...@@ -494,11 +496,13 @@ DEBUG_EvalExpr(struct expr * exp) ...@@ -494,11 +496,13 @@ DEBUG_EvalExpr(struct expr * exp)
case EXP_OP_SEG: case EXP_OP_SEG:
rtn.seg = VAL(exp1); rtn.seg = VAL(exp1);
exp->un.binop.result = VAL(exp2); exp->un.binop.result = VAL(exp2);
#ifdef __i386__
if (ISV86(&DEBUG_context)) { if (ISV86(&DEBUG_context)) {
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() ); TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
rtn.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16; rtn.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16;
GlobalUnlock16( GetCurrentTask() ); GlobalUnlock16( GetCurrentTask() );
} }
#endif
break; break;
case EXP_OP_LOR: case EXP_OP_LOR:
rtn.seg = 0; rtn.seg = 0;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define PATH_MAX _MAX_PATH #define PATH_MAX _MAX_PATH
#endif #endif
#ifdef __i386__
static char * reg_name[] = static char * reg_name[] =
{ {
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"
...@@ -35,6 +36,10 @@ static unsigned reg_ofs[] = ...@@ -35,6 +36,10 @@ static unsigned reg_ofs[] =
FIELD_OFFSET(CONTEXT, Esp), FIELD_OFFSET(CONTEXT, Ebp), FIELD_OFFSET(CONTEXT, Esp), FIELD_OFFSET(CONTEXT, Ebp),
FIELD_OFFSET(CONTEXT, Esi), FIELD_OFFSET(CONTEXT, Edi) FIELD_OFFSET(CONTEXT, Esi), FIELD_OFFSET(CONTEXT, Edi)
}; };
#else
static char * reg_name[] = { NULL }; /* FIXME */
static unsigned reg_ofs[] = { 0 };
#endif
struct name_hash struct name_hash
......
...@@ -115,6 +115,7 @@ BOOL DEBUG_checkmap_bad( const char *addr, size_t size, int rwflag) ...@@ -115,6 +115,7 @@ BOOL DEBUG_checkmap_bad( const char *addr, size_t size, int rwflag)
*/ */
BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size ) BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size )
{ {
#ifdef __i386__
if (!IS_SELECTOR_V86(address->seg)) if (!IS_SELECTOR_V86(address->seg))
if (address->seg) /* segmented addr */ if (address->seg) /* segmented addr */
{ {
...@@ -122,6 +123,7 @@ BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size ) ...@@ -122,6 +123,7 @@ BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size )
(WORD)address->seg ), size )) (WORD)address->seg ), size ))
return TRUE; return TRUE;
} }
#endif
return DEBUG_checkmap_bad( DBG_ADDR_TO_LIN(address), size, 1); return DEBUG_checkmap_bad( DBG_ADDR_TO_LIN(address), size, 1);
} }
...@@ -133,6 +135,7 @@ BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size ) ...@@ -133,6 +135,7 @@ BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size )
*/ */
BOOL DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size ) BOOL DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size )
{ {
#ifdef __i386__
if (!IS_SELECTOR_V86(address->seg)) if (!IS_SELECTOR_V86(address->seg))
if (address->seg) /* segmented addr */ if (address->seg) /* segmented addr */
{ {
...@@ -142,6 +145,7 @@ BOOL DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size ) ...@@ -142,6 +145,7 @@ BOOL DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size )
(WORD)address->seg ), size )) (WORD)address->seg ), size ))
return TRUE; return TRUE;
} }
#endif
return DEBUG_checkmap_bad( DBG_ADDR_TO_LIN(address), size, 0); return DEBUG_checkmap_bad( DBG_ADDR_TO_LIN(address), size, 0);
} }
......
...@@ -19,6 +19,7 @@ CONTEXT DEBUG_context; ...@@ -19,6 +19,7 @@ CONTEXT DEBUG_context;
*/ */
void DEBUG_SetRegister( enum debug_regs reg, int val ) void DEBUG_SetRegister( enum debug_regs reg, int val )
{ {
#ifdef __i386__
switch(reg) switch(reg)
{ {
case REG_EAX: EAX_reg(&DEBUG_context) = val; break; case REG_EAX: EAX_reg(&DEBUG_context) = val; break;
...@@ -48,12 +49,14 @@ void DEBUG_SetRegister( enum debug_regs reg, int val ) ...@@ -48,12 +49,14 @@ void DEBUG_SetRegister( enum debug_regs reg, int val )
case REG_IP: SET_LOWORD(EIP_reg(&DEBUG_context),val); break; case REG_IP: SET_LOWORD(EIP_reg(&DEBUG_context),val); break;
case REG_SP: SET_LOWORD(ESP_reg(&DEBUG_context),val); break; case REG_SP: SET_LOWORD(ESP_reg(&DEBUG_context),val); break;
} }
#endif
} }
int int
DEBUG_PrintRegister(enum debug_regs reg) DEBUG_PrintRegister(enum debug_regs reg)
{ {
#ifdef __i386__
switch(reg) switch(reg)
{ {
case REG_EAX: fprintf(stderr, "%%eax"); break; case REG_EAX: fprintf(stderr, "%%eax"); break;
...@@ -84,6 +87,9 @@ DEBUG_PrintRegister(enum debug_regs reg) ...@@ -84,6 +87,9 @@ DEBUG_PrintRegister(enum debug_regs reg)
case REG_GS: fprintf(stderr, "%%gs"); break; case REG_GS: fprintf(stderr, "%%gs"); break;
} }
return TRUE; return TRUE;
#else
return FALSE;
#endif
} }
/*********************************************************************** /***********************************************************************
...@@ -93,6 +99,7 @@ DEBUG_PrintRegister(enum debug_regs reg) ...@@ -93,6 +99,7 @@ DEBUG_PrintRegister(enum debug_regs reg)
*/ */
int DEBUG_GetRegister( enum debug_regs reg ) int DEBUG_GetRegister( enum debug_regs reg )
{ {
#ifdef __i386__
switch(reg) switch(reg)
{ {
case REG_EAX: return EAX_reg(&DEBUG_context); case REG_EAX: return EAX_reg(&DEBUG_context);
...@@ -122,6 +129,7 @@ int DEBUG_GetRegister( enum debug_regs reg ) ...@@ -122,6 +129,7 @@ int DEBUG_GetRegister( enum debug_regs reg )
case REG_IP: return LOWORD(EIP_reg(&DEBUG_context)); case REG_IP: return LOWORD(EIP_reg(&DEBUG_context));
case REG_SP: return LOWORD(ESP_reg(&DEBUG_context)); case REG_SP: return LOWORD(ESP_reg(&DEBUG_context));
} }
#endif
return 0; /* should not happen */ return 0; /* should not happen */
} }
...@@ -187,10 +195,9 @@ char *DEBUG_Flags( DWORD flag, char *buf ) ...@@ -187,10 +195,9 @@ char *DEBUG_Flags( DWORD flag, char *buf )
*/ */
void DEBUG_InfoRegisters(void) void DEBUG_InfoRegisters(void)
{ {
char flag[33];
fprintf(stderr,"Register dump:\n"); fprintf(stderr,"Register dump:\n");
#ifdef __i386__
/* First get the segment registers out of the way */ /* First get the segment registers out of the way */
fprintf( stderr," CS:%04x SS:%04x DS:%04x ES:%04x FS:%04x GS:%04x", fprintf( stderr," CS:%04x SS:%04x DS:%04x ES:%04x FS:%04x GS:%04x",
(WORD)CS_reg(&DEBUG_context), (WORD)SS_reg(&DEBUG_context), (WORD)CS_reg(&DEBUG_context), (WORD)SS_reg(&DEBUG_context),
...@@ -198,6 +205,8 @@ void DEBUG_InfoRegisters(void) ...@@ -198,6 +205,8 @@ void DEBUG_InfoRegisters(void)
(WORD)FS_reg(&DEBUG_context), (WORD)GS_reg(&DEBUG_context) ); (WORD)FS_reg(&DEBUG_context), (WORD)GS_reg(&DEBUG_context) );
if (dbg_mode == 16) if (dbg_mode == 16)
{ {
char flag[33];
fprintf( stderr,"\n IP:%04x SP:%04x BP:%04x FLAGS:%04x(%s)\n", fprintf( stderr,"\n IP:%04x SP:%04x BP:%04x FLAGS:%04x(%s)\n",
LOWORD(EIP_reg(&DEBUG_context)), LOWORD(ESP_reg(&DEBUG_context)), LOWORD(EIP_reg(&DEBUG_context)), LOWORD(ESP_reg(&DEBUG_context)),
LOWORD(EBP_reg(&DEBUG_context)), LOWORD(EFL_reg(&DEBUG_context)), LOWORD(EBP_reg(&DEBUG_context)), LOWORD(EFL_reg(&DEBUG_context)),
...@@ -209,6 +218,8 @@ void DEBUG_InfoRegisters(void) ...@@ -209,6 +218,8 @@ void DEBUG_InfoRegisters(void)
} }
else /* 32-bit mode */ else /* 32-bit mode */
{ {
char flag[33];
fprintf( stderr, "\n EIP:%08lx ESP:%08lx EBP:%08lx EFLAGS:%08lx(%s)\n", fprintf( stderr, "\n EIP:%08lx ESP:%08lx EBP:%08lx EFLAGS:%08lx(%s)\n",
EIP_reg(&DEBUG_context), ESP_reg(&DEBUG_context), EIP_reg(&DEBUG_context), ESP_reg(&DEBUG_context),
EBP_reg(&DEBUG_context), EFL_reg(&DEBUG_context), EBP_reg(&DEBUG_context), EFL_reg(&DEBUG_context),
...@@ -219,6 +230,7 @@ void DEBUG_InfoRegisters(void) ...@@ -219,6 +230,7 @@ void DEBUG_InfoRegisters(void)
fprintf( stderr, " ESI:%08lx EDI:%08lx\n", fprintf( stderr, " ESI:%08lx EDI:%08lx\n",
ESI_reg(&DEBUG_context), EDI_reg(&DEBUG_context) ); ESI_reg(&DEBUG_context), EDI_reg(&DEBUG_context) );
} }
#endif
} }
...@@ -230,6 +242,7 @@ void DEBUG_InfoRegisters(void) ...@@ -230,6 +242,7 @@ void DEBUG_InfoRegisters(void)
*/ */
BOOL DEBUG_ValidateRegisters(void) BOOL DEBUG_ValidateRegisters(void)
{ {
#ifdef __i386__
WORD cs, ds; WORD cs, ds;
if (ISV86(&DEBUG_context)) return TRUE; if (ISV86(&DEBUG_context)) return TRUE;
...@@ -270,4 +283,7 @@ BOOL DEBUG_ValidateRegisters(void) ...@@ -270,4 +283,7 @@ BOOL DEBUG_ValidateRegisters(void)
} }
return TRUE; return TRUE;
#undef CHECK_SEG #undef CHECK_SEG
#else
return TRUE;
#endif
} }
...@@ -430,6 +430,27 @@ DEBUG_List(struct list_id * source1, struct list_id * source2, ...@@ -430,6 +430,27 @@ DEBUG_List(struct list_id * source1, struct list_id * source2,
DBG_ADDR DEBUG_LastDisassemble={NULL,0,0}; DBG_ADDR DEBUG_LastDisassemble={NULL,0,0};
void DEBUG_GetCurrentAddress( DBG_ADDR *addr )
{
#ifdef __i386__
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
addr->type = NULL;
addr->seg = CS_reg(&DEBUG_context);
addr->off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context)) addr->seg |= (DWORD)(pTask? pTask->hModule : 0) << 16;
else if (IS_SELECTOR_SYSTEM(addr->seg)) addr->seg = 0;
GlobalUnlock16( GetCurrentTask() );
#else
addr->type = NULL;
addr->seg = 0;
addr->off = (DWORD)GET_IP(&DEBUG_context);
#endif
}
static int static int
_disassemble(DBG_ADDR *addr) _disassemble(DBG_ADDR *addr)
{ {
...@@ -494,14 +515,8 @@ DEBUG_Disassemble(const DBG_ADDR *xstart,const DBG_ADDR *xend,int offset) ...@@ -494,14 +515,8 @@ DEBUG_Disassemble(const DBG_ADDR *xstart,const DBG_ADDR *xend,int offset)
if (!xstart && !xend) { if (!xstart && !xend) {
last = DEBUG_LastDisassemble; last = DEBUG_LastDisassemble;
if (!last.seg && !last.off) if (!last.seg && !last.off)
{ DEBUG_GetCurrentAddress( &last );
TDB *pTask = (TDB*)GlobalLock16( GetCurrentTask() );
last.seg = CS_reg(&DEBUG_context);
last.off = EIP_reg(&DEBUG_context);
if (ISV86(&DEBUG_context)) last.seg |= (DWORD)(pTask?(pTask->hModule):0)<<16; else
if (IS_SELECTOR_SYSTEM(last.seg)) last.seg = 0;
GlobalUnlock16( GetCurrentTask() );
}
for (i=0;i<offset;i++) for (i=0;i<offset;i++)
if (!_disassemble(&last)) break; if (!_disassemble(&last)) break;
memcpy(&DEBUG_LastDisassemble,&last,sizeof(last)); memcpy(&DEBUG_LastDisassemble,&last,sizeof(last));
......
...@@ -53,6 +53,7 @@ typedef struct ...@@ -53,6 +53,7 @@ typedef struct
*/ */
void DEBUG_InfoStack(void) void DEBUG_InfoStack(void)
{ {
#ifdef __i386__
DBG_ADDR addr; DBG_ADDR addr;
addr.type = NULL; addr.type = NULL;
...@@ -70,9 +71,10 @@ void DEBUG_InfoStack(void) ...@@ -70,9 +71,10 @@ void DEBUG_InfoStack(void)
DEBUG_ExamineMemory( &addr, 24, 'w' ); DEBUG_ExamineMemory( &addr, 24, 'w' );
} }
fprintf(stderr,"\n"); fprintf(stderr,"\n");
#endif
} }
#ifdef __i386__
static void DEBUG_ForceFrame(DBG_ADDR *stack, DBG_ADDR *code, int frameno, int bits, int noisy) static void DEBUG_ForceFrame(DBG_ADDR *stack, DBG_ADDR *code, int frameno, int bits, int noisy)
{ {
int theframe = nframe++; int theframe = nframe++;
...@@ -333,6 +335,9 @@ static void DEBUG_DoBackTrace(int noisy) ...@@ -333,6 +335,9 @@ static void DEBUG_DoBackTrace(int noisy)
} }
if (noisy) fprintf( stderr, "\n" ); if (noisy) fprintf( stderr, "\n" );
} }
#endif
/*********************************************************************** /***********************************************************************
* DEBUG_BackTrace * DEBUG_BackTrace
...@@ -341,7 +346,9 @@ static void DEBUG_DoBackTrace(int noisy) ...@@ -341,7 +346,9 @@ static void DEBUG_DoBackTrace(int noisy)
*/ */
void DEBUG_BackTrace(void) void DEBUG_BackTrace(void)
{ {
#ifdef __i386__
DEBUG_DoBackTrace( TRUE ); DEBUG_DoBackTrace( TRUE );
#endif
} }
/*********************************************************************** /***********************************************************************
...@@ -351,7 +358,9 @@ void DEBUG_BackTrace(void) ...@@ -351,7 +358,9 @@ void DEBUG_BackTrace(void)
*/ */
void DEBUG_SilentBackTrace(void) void DEBUG_SilentBackTrace(void)
{ {
#ifdef __i386__
DEBUG_DoBackTrace( FALSE ); DEBUG_DoBackTrace( FALSE );
#endif
} }
int int
......
...@@ -84,6 +84,8 @@ struct wine_locals { ...@@ -84,6 +84,8 @@ struct wine_locals {
typedef struct wine_locals WineLocals; typedef struct wine_locals WineLocals;
#ifdef __i386__
#define DBG_V86_MODULE(seg) ((seg)>>16) #define DBG_V86_MODULE(seg) ((seg)>>16)
#define IS_SELECTOR_V86(seg) DBG_V86_MODULE(seg) #define IS_SELECTOR_V86(seg) DBG_V86_MODULE(seg)
...@@ -99,6 +101,13 @@ typedef struct wine_locals WineLocals; ...@@ -99,6 +101,13 @@ typedef struct wine_locals WineLocals;
(IS_SELECTOR_SYSTEM((addr)->seg) ? (char *)(addr)->off \ (IS_SELECTOR_SYSTEM((addr)->seg) ? (char *)(addr)->off \
: (char *)PTR_SEG_OFF_TO_LIN((addr)->seg,(addr)->off))) : (char *)PTR_SEG_OFF_TO_LIN((addr)->seg,(addr)->off)))
#else /* __i386__ */
#define DBG_FIX_ADDR_SEG(addr,default)
#define DBG_ADDR_TO_LIN(addr) ((char *)(addr)->off)
#endif /* __386__ */
#define DBG_CHECK_READ_PTR(addr,len) \ #define DBG_CHECK_READ_PTR(addr,len) \
(!DEBUG_IsBadReadPtr((addr),(len)) || \ (!DEBUG_IsBadReadPtr((addr),(len)) || \
(fprintf(stderr,"*** Invalid address "), \ (fprintf(stderr,"*** Invalid address "), \
...@@ -313,6 +322,7 @@ extern void DEBUG_AddPath(const char * path); ...@@ -313,6 +322,7 @@ extern void DEBUG_AddPath(const char * path);
extern void DEBUG_List(struct list_id * line1, struct list_id * line2, extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
int delta); int delta);
extern void DEBUG_NukePath(void); extern void DEBUG_NukePath(void);
extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
extern void DEBUG_Disassemble( const DBG_ADDR *, const DBG_ADDR*, int offset ); extern void DEBUG_Disassemble( const DBG_ADDR *, const DBG_ADDR*, int offset );
/* debugger/dbg.y */ /* debugger/dbg.y */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment