Compile fixes for non-i386 archs.

This commit is contained in:
Ulrich Weigand 2000-06-04 01:33:21 +00:00 committed by Alexandre Julliard
parent b09c6ef5ae
commit 1cbf27a33f
7 changed files with 90 additions and 25 deletions

View File

@ -179,7 +179,6 @@ void DEBUG_SetBreakpoints( BOOL set )
{
#ifdef __i386__
char ch = set ? INT3 : breakpoints[i].u.b.opcode;
#endif
if (!DEBUG_WRITE_MEM( (void*)DEBUG_ToLinear(&breakpoints[i].addr),
&ch, sizeof(ch) ))
@ -187,6 +186,7 @@ void DEBUG_SetBreakpoints( BOOL set )
DEBUG_Printf(DBG_CHN_MESG, "Invalid address for breakpoint %d, disabling it\n", i);
breakpoints[i].enabled = FALSE;
}
#endif
}
break;
case DBG_WATCH:
@ -331,7 +331,9 @@ void DEBUG_AddBreakpoint( const DBG_VALUE *_value, BOOL (*func)(void) )
assert(_value->cookie == DV_TARGET || _value->cookie == DV_HOST);
#ifdef __i386__
DEBUG_FixAddress( &value.addr, DEBUG_context.SegCs );
#endif
if( value.type != NULL && value.type == DEBUG_TypeIntConst )
{
@ -376,7 +378,7 @@ void DEBUG_AddBreakpoint( const DBG_VALUE *_value, BOOL (*func)(void) )
void DEBUG_AddWatchpoint( const DBG_VALUE *_value, BOOL is_write )
{
DBG_VALUE value = *_value;
int num, reg;
int num, reg = -1;
unsigned seg2;
DWORD mask = 0;
@ -497,7 +499,6 @@ static int DEBUG_FindTriggeredWatchpoint(LPDWORD oldval)
{
int i;
int found = -1;
DWORD val = 0;
/* Method 1 => get triggered watchpoint from context (doesn't work on Linux
* 2.2.x)
@ -505,6 +506,8 @@ static int DEBUG_FindTriggeredWatchpoint(LPDWORD oldval)
for (i = 0; i < next_bp; i++)
{
#ifdef __i386__
DWORD val = 0;
if (breakpoints[i].refcount && breakpoints[i].enabled &&
breakpoints[i].type == DBG_WATCH &&
(DEBUG_context.Dr6 & (1 << breakpoints[i].u.w.reg)))
@ -529,6 +532,8 @@ static int DEBUG_FindTriggeredWatchpoint(LPDWORD oldval)
for (i = 0; i < next_bp; i++)
{
#ifdef __i386__
DWORD val = 0;
if (breakpoints[i].refcount && breakpoints[i].enabled &&
breakpoints[i].type == DBG_WATCH &&
DEBUG_GetWatchedValue(i, &val))
@ -644,6 +649,7 @@ BOOL DEBUG_ShouldContinue( DWORD code, enum exec_mode mode, int * count )
int bpnum;
DWORD oldval;
int wpnum;
int addrlen = 32;
struct symbol_info syminfo;
#ifdef __i386__
@ -683,9 +689,11 @@ BOOL DEBUG_ShouldContinue( DWORD code, enum exec_mode mode, int * count )
}
if (!DEBUG_ShallBreak(wpnum)) return TRUE;
#ifdef __i386__
addrlen = !addr.seg? 32 : DEBUG_GetSelectorType( addr.seg );
#endif
DEBUG_Printf(DBG_CHN_MESG, "Stopped on watchpoint %d at ", wpnum);
syminfo = DEBUG_PrintAddress( &addr, !addr.seg ? 32 :
DEBUG_GetSelectorType( addr.seg ), TRUE );
syminfo = DEBUG_PrintAddress( &addr, addrlen, TRUE );
DEBUG_Printf(DBG_CHN_MESG, " values: old=%lu new=%lu\n",
oldval, breakpoints[wpnum].u.w.oldval);

View File

@ -224,6 +224,20 @@ typedef struct {
#define OFFSET_OF(__c,__f) ((int)(((char*)&(((__c*)0)->__f))-((char*)0)))
#ifdef __i386__
# define GET_IP(context) ((DWORD)(context)->Eip)
#endif
#ifdef __sparc__
# define GET_IP(context) ((DWORD)(context)->pc)
#endif
#if !defined(GET_IP)
# error You must define GET_IP for this CPU
#endif
/* debugger/break.c */
extern void DEBUG_SetBreakpoints( BOOL set );
extern void DEBUG_AddBreakpoint( const DBG_VALUE *addr, BOOL (*func)(void) );
@ -348,9 +362,9 @@ extern void DEBUG_WriteMemory( const DBG_VALUE* val, int value );
extern void DEBUG_ExamineMemory( const DBG_VALUE *addr, int count, char format);
extern void DEBUG_InvalAddr( const DBG_ADDR* addr );
extern void DEBUG_InvalLinAddr( void* addr );
#ifdef __i386__
extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
extern DWORD DEBUG_ToLinear( const DBG_ADDR *address );
extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
#ifdef __i386__
extern void DEBUG_FixAddress( DBG_ADDR *address, DWORD def );
extern BOOL DEBUG_FixSegment( DBG_ADDR* addr );
extern int DEBUG_GetSelectorType( WORD sel );

View File

@ -462,7 +462,11 @@ BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *value )
if (!nh) return FALSE;
nh->value = *value;
nh->flags &= ~SYM_INVALID;
#ifdef __i386__
DEBUG_FixAddress( &nh->value.addr, DEBUG_context.SegDs );
#endif
return TRUE;
}

View File

@ -19,6 +19,7 @@
#define DBG_V86_MODULE(seg) ((seg)>>16)
#define IS_SELECTOR_V86(seg) DBG_V86_MODULE(seg)
#endif
static void DEBUG_Die(const char* msg)
{
@ -51,6 +52,7 @@ char* DEBUG_XStrDup(const char *str)
return res;
}
#ifdef __i386__
void DEBUG_FixAddress( DBG_ADDR *addr, DWORD def)
{
if (addr->seg == 0xffffffff) addr->seg = def;
@ -67,21 +69,6 @@ BOOL DEBUG_FixSegment( DBG_ADDR* addr )
return FALSE;
}
DWORD DEBUG_ToLinear( const DBG_ADDR *addr )
{
LDT_ENTRY le;
if (IS_SELECTOR_V86(addr->seg))
return (DWORD) DOSMEM_MemoryBase(DBG_V86_MODULE(addr->seg)) + (((addr->seg)&0xFFFF)<<4) + addr->off;
if (DEBUG_IsSelectorSystem(addr->seg))
return addr->off;
if (GetThreadSelectorEntry( DEBUG_CurrThread->handle, addr->seg, &le)) {
return (le.HighWord.Bits.BaseHi << 24) + (le.HighWord.Bits.BaseMid << 16) + le.BaseLow + addr->off;
}
return 0;
}
int DEBUG_GetSelectorType( WORD sel )
{
LDT_ENTRY le;
@ -103,6 +90,25 @@ BOOL DEBUG_IsSelectorSystem(WORD sel)
}
#endif /* __i386__ */
DWORD DEBUG_ToLinear( const DBG_ADDR *addr )
{
#ifdef __i386__
LDT_ENTRY le;
if (IS_SELECTOR_V86(addr->seg))
return (DWORD) DOSMEM_MemoryBase(DBG_V86_MODULE(addr->seg)) + (((addr->seg)&0xFFFF)<<4) + addr->off;
if (DEBUG_IsSelectorSystem(addr->seg))
return addr->off;
if (GetThreadSelectorEntry( DEBUG_CurrThread->handle, addr->seg, &le)) {
return (le.HighWord.Bits.BaseHi << 24) + (le.HighWord.Bits.BaseMid << 16) + le.BaseLow + addr->off;
}
return 0;
#else
return addr->off;
#endif
}
void DEBUG_GetCurrentAddress( DBG_ADDR *addr )
{
#ifdef __i386__
@ -113,7 +119,7 @@ void DEBUG_GetCurrentAddress( DBG_ADDR *addr )
addr->off = DEBUG_context.Eip;
#else
addr->seg = 0;
addr->off = 0;
addr->off = GET_IP( &DEBUG_context );
#endif
}
@ -155,7 +161,9 @@ int DEBUG_ReadMemory( const DBG_VALUE* val )
DBG_ADDR addr = val->addr;
void* lin;
#ifdef __i386__
DEBUG_FixAddress( &addr, DEBUG_context.SegDs );
#endif
lin = (void*)DEBUG_ToLinear( &addr );
DEBUG_READ_MEM_VERBOSE(lin, &value, os);
@ -184,7 +192,9 @@ void DEBUG_WriteMemory( const DBG_VALUE* val, int value )
DBG_ADDR addr = val->addr;
void* lin;
#ifdef __i386__
DEBUG_FixAddress( &addr, DEBUG_context.SegDs );
#endif
lin = (void*)DEBUG_ToLinear( &addr );
DEBUG_WRITE_MEM_VERBOSE(lin, &value, os);
} else {
@ -207,10 +217,12 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
assert(_value->cookie == DV_TARGET || _value->cookie == DV_HOST);
#ifdef __i386__
DEBUG_FixAddress( &value.addr,
(format == 'i') ?
DEBUG_context.SegCs :
DEBUG_context.SegDs );
#endif
/*
* Dereference pointer to get actual memory address we need to be

View File

@ -103,7 +103,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
int i;
struct open_filelist * ol;
int nlines;
char * basename;
char * basename = NULL;
char * pnt;
int rtn;
struct searchlist * sl;
@ -445,7 +445,9 @@ _disassemble_fixaddr(DBG_VALUE *value) {
assert(value->cookie == DV_TARGET || value->cookie == DV_HOST);
#ifdef __i386__
DEBUG_FixAddress(&value->addr, DEBUG_context.SegCs);
#endif
if( value->type != NULL )
{

View File

@ -383,6 +383,7 @@ void DEBUG_BackTrace(BOOL noisy)
int
DEBUG_SetFrame(int newframe)
{
#ifdef __i386__
int rtn = FALSE;
curr_frame = newframe;
@ -404,12 +405,16 @@ DEBUG_SetFrame(int newframe)
rtn = TRUE;
return (rtn);
#else /* __i386__ */
return FALSE;
#endif /* __i386__ */
}
int
DEBUG_GetCurrentFrame(struct name_hash ** name, unsigned int * eip,
unsigned int * ebp)
{
#ifdef __i386__
/*
* If we don't have a valid backtrace, then just return.
*/
@ -432,5 +437,8 @@ DEBUG_GetCurrentFrame(struct name_hash ** name, unsigned int * eip,
*ebp = frames[curr_frame].ebp;
return TRUE;
#else /* __i386__ */
return FALSE;
#endif /* __i386__ */
}

View File

@ -326,14 +326,22 @@ static BOOL DEBUG_HandleException( EXCEPTION_RECORD *rec, BOOL first_chance, BOO
DEBUG_Printf(DBG_CHN_TRACE,
"Entering debugger PC=%lx EFL=%08lx mode=%d count=%d\n",
#ifdef __i386__
DEBUG_context.Eip, DEBUG_context.EFlags,
#else
0L, 0L,
#endif
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count);
ret = DEBUG_Main( is_debug, force, rec->ExceptionCode );
DEBUG_Printf(DBG_CHN_TRACE,
"Exiting debugger PC=%lx EFL=%08lx mode=%d count=%d\n",
#ifdef __i386__
DEBUG_context.Eip, DEBUG_context.EFlags,
#else
0L, 0L,
#endif
DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count);
return ret;
@ -376,7 +384,16 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont)
}
}
DEBUG_context.ContextFlags = CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS|CONTEXT_DEBUG_REGISTERS;
DEBUG_context.ContextFlags = CONTEXT_CONTROL
| CONTEXT_INTEGER
#ifdef CONTEXT_SEGMENTS
| CONTEXT_SEGMENTS
#endif
#ifdef CONTEXT_DEBUG_REGISTERS
| CONTEXT_DEBUG_REGISTERS
#endif
;
if (!GetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context)) {
DEBUG_Printf(DBG_CHN_WARN, "Can't get thread's context\n");
break;