Commit 02ecb684 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Fixed stabs parsing for GCC 3.0 (default types).

Added boolean type support. Simplified internal types handling.
parent c19bb1ab
...@@ -328,7 +328,7 @@ void DEBUG_AddBreakpoint( const DBG_VALUE *_value, BOOL (*func)(void) ) ...@@ -328,7 +328,7 @@ void DEBUG_AddBreakpoint( const DBG_VALUE *_value, BOOL (*func)(void) )
int num; int num;
BYTE ch; BYTE ch;
if( value.type != NULL && value.type == DEBUG_TypeIntConst ) if( value.type != NULL && value.type == DEBUG_GetBasicType(DT_BASIC_CONST_INT) )
{ {
/* /*
* We know that we have the actual offset stored somewhere * We know that we have the actual offset stored somewhere
...@@ -460,7 +460,7 @@ void DEBUG_AddWatchpoint( const DBG_VALUE *_value, BOOL is_write ) ...@@ -460,7 +460,7 @@ void DEBUG_AddWatchpoint( const DBG_VALUE *_value, BOOL is_write )
DEBUG_FixAddress( &value.addr, DEBUG_context.SegCs ); DEBUG_FixAddress( &value.addr, DEBUG_context.SegCs );
#endif #endif
if ( value.type != NULL && value.type == DEBUG_TypeIntConst ) if ( value.type != NULL && value.type == DEBUG_GetBasicType(DT_BASIC_CONST_INT) )
{ {
/* /*
* We know that we have the actual offset stored somewhere * We know that we have the actual offset stored somewhere
......
...@@ -243,20 +243,20 @@ type_cast: ...@@ -243,20 +243,20 @@ type_cast:
type_expr: type_expr:
type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); } type_expr '*' { $$ = DEBUG_FindOrMakePointerType($1); }
| tINT { $$ = DEBUG_TypeCast(DT_BASIC, "int"); } | tINT { $$ = DEBUG_GetBasicType(DT_BASIC_INT); }
| tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "char"); } | tCHAR { $$ = DEBUG_GetBasicType(DT_BASIC_CHAR); }
| tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long int"); } | tLONG tINT { $$ = DEBUG_GetBasicType(DT_BASIC_LONGINT); }
| tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned int"); } | tUNSIGNED tINT { $$ = DEBUG_GetBasicType(DT_BASIC_UINT); }
| tLONG tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long unsigned int"); } | tLONG tUNSIGNED tINT { $$ = DEBUG_GetBasicType(DT_BASIC_ULONGINT); }
| tLONG tLONG tINT { $$ = DEBUG_TypeCast(DT_BASIC, "long long int"); } | tLONG tLONG tINT { $$ = DEBUG_GetBasicType(DT_BASIC_LONGLONGINT); }
| tLONG tLONG tUNSIGNED tINT{ $$ = DEBUG_TypeCast(DT_BASIC, "long long unsigned int"); } | tLONG tLONG tUNSIGNED tINT{ $$ = DEBUG_GetBasicType(DT_BASIC_ULONGLONGINT); }
| tSHORT tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short int"); } | tSHORT tINT { $$ = DEBUG_GetBasicType(DT_BASIC_SHORTINT); }
| tSHORT tUNSIGNED tINT { $$ = DEBUG_TypeCast(DT_BASIC, "short unsigned int"); } | tSHORT tUNSIGNED tINT { $$ = DEBUG_GetBasicType(DT_BASIC_USHORTINT); }
| tSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "signed char"); } | tSIGNED tCHAR { $$ = DEBUG_GetBasicType(DT_BASIC_SCHAR); }
| tUNSIGNED tCHAR { $$ = DEBUG_TypeCast(DT_BASIC, "unsigned char"); } | tUNSIGNED tCHAR { $$ = DEBUG_GetBasicType(DT_BASIC_UCHAR); }
| tFLOAT { $$ = DEBUG_TypeCast(DT_BASIC, "float"); } | tFLOAT { $$ = DEBUG_GetBasicType(DT_BASIC_FLOAT); }
| tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "double"); } | tDOUBLE { $$ = DEBUG_GetBasicType(DT_BASIC_DOUBLE); }
| tLONG tDOUBLE { $$ = DEBUG_TypeCast(DT_BASIC, "long double"); } | tLONG tDOUBLE { $$ = DEBUG_GetBasicType(DT_BASIC_LONGDOUBLE); }
| tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); } | tSTRUCT tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
| tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); } | tUNION tIDENTIFIER { $$ = DEBUG_TypeCast(DT_STRUCT, $2); }
| tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); } | tENUM tIDENTIFIER { $$ = DEBUG_TypeCast(DT_ENUM, $2); }
......
...@@ -29,6 +29,21 @@ ...@@ -29,6 +29,21 @@
enum debug_type {DT_BASIC, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM, enum debug_type {DT_BASIC, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM,
DT_FUNC, DT_BITFIELD}; DT_FUNC, DT_BITFIELD};
enum debug_type_basic {DT_BASIC_INT = 1, DT_BASIC_CHAR, DT_BASIC_LONGINT, DT_BASIC_UINT,
DT_BASIC_ULONGINT, DT_BASIC_LONGLONGINT, DT_BASIC_ULONGLONGINT,
DT_BASIC_SHORTINT, DT_BASIC_USHORTINT, DT_BASIC_SCHAR, DT_BASIC_UCHAR,
DT_BASIC_FLOAT, DT_BASIC_LONGDOUBLE, DT_BASIC_DOUBLE,
DT_BASIC_CMPLX_INT, DT_BASIC_CMPLX_FLOAT, DT_BASIC_CMPLX_DOUBLE,
DT_BASIC_CMPLX_LONGDOUBLE, DT_BASIC_VOID,
/* modifier on size isn't possible on current types definitions
* so we need to add more types... */
DT_BASIC_BOOL1, DT_BASIC_BOOL2, DT_BASIC_BOOL4,
/* this is not really a basic type... */
DT_BASIC_STRING,
/* this is for historical reasons... should take care of it RSN */
DT_BASIC_CONST_INT,
/* to be kept as last... sentinel entry... do not use */
DT_BASIC_LAST};
/* /*
* Return values for DEBUG_CheckLinenoStatus. Used to determine * Return values for DEBUG_CheckLinenoStatus. Used to determine
...@@ -39,15 +54,6 @@ enum debug_type {DT_BASIC, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM, ...@@ -39,15 +54,6 @@ enum debug_type {DT_BASIC, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM,
#define AT_LINENUMBER (2) #define AT_LINENUMBER (2)
#define FUNC_IS_TRAMPOLINE (3) #define FUNC_IS_TRAMPOLINE (3)
/*
* For constants generated by the parser, we use this datatype
*/
extern struct datatype * DEBUG_TypeShortUInt;
extern struct datatype * DEBUG_TypeInt;
extern struct datatype * DEBUG_TypeIntConst;
extern struct datatype * DEBUG_TypeUSInt;
extern struct datatype * DEBUG_TypeString;
typedef struct typedef struct
{ {
DWORD seg; /* 0xffffffff means current default segment (cs or ds) */ DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
...@@ -480,6 +486,7 @@ extern enum debug_type DEBUG_GetType(struct datatype * dt); ...@@ -480,6 +486,7 @@ extern enum debug_type DEBUG_GetType(struct datatype * dt);
extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *); extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
extern int DEBUG_PrintTypeCast(const struct datatype *); extern int DEBUG_PrintTypeCast(const struct datatype *);
extern int DEBUG_PrintType( const DBG_VALUE* addr ); extern int DEBUG_PrintType( const DBG_VALUE* addr );
extern struct datatype * DEBUG_GetBasicType(enum debug_type_basic);
/* debugger/winedbg.c */ /* debugger/winedbg.c */
#define DBG_CHN_MESG 1 #define DBG_CHN_MESG 1
......
...@@ -314,19 +314,19 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) ...@@ -314,19 +314,19 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
rtn.cookie = DV_TARGET; rtn.cookie = DV_TARGET;
break; break;
case EXPR_TYPE_STRING: case EXPR_TYPE_STRING:
rtn.type = DEBUG_TypeString; rtn.type = DEBUG_GetBasicType(DT_BASIC_STRING);
rtn.cookie = DV_HOST; rtn.cookie = DV_HOST;
rtn.addr.off = (unsigned int) &exp->un.string.str; rtn.addr.off = (unsigned int) &exp->un.string.str;
rtn.addr.seg = 0; rtn.addr.seg = 0;
break; break;
case EXPR_TYPE_CONST: case EXPR_TYPE_CONST:
rtn.type = DEBUG_TypeIntConst; rtn.type = DEBUG_GetBasicType(DT_BASIC_CONST_INT);
rtn.cookie = DV_HOST; rtn.cookie = DV_HOST;
rtn.addr.off = (unsigned int) &exp->un.constant.value; rtn.addr.off = (unsigned int) &exp->un.constant.value;
rtn.addr.seg = 0; rtn.addr.seg = 0;
break; break;
case EXPR_TYPE_US_CONST: case EXPR_TYPE_US_CONST:
rtn.type = DEBUG_TypeUSInt; rtn.type = DEBUG_GetBasicType(DT_BASIC_USHORTINT);
rtn.cookie = DV_HOST; rtn.cookie = DV_HOST;
rtn.addr.off = (unsigned int) &exp->un.u_const.value; rtn.addr.off = (unsigned int) &exp->un.u_const.value;
rtn.addr.seg = 0; rtn.addr.seg = 0;
...@@ -431,7 +431,7 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) ...@@ -431,7 +431,7 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
*/ */
exp->un.call.result = 0; exp->un.call.result = 0;
#endif #endif
rtn.type = DEBUG_TypeInt; rtn.type = DEBUG_GetBasicType(DT_BASIC_INT);
rtn.cookie = DV_HOST; rtn.cookie = DV_HOST;
rtn.addr.off = (unsigned int) &exp->un.call.result; rtn.addr.off = (unsigned int) &exp->un.call.result;
...@@ -456,13 +456,14 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) ...@@ -456,13 +456,14 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
{ {
RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL);
} }
if( exp1.type == DEBUG_TypeIntConst && exp2.type == DEBUG_TypeIntConst ) if( exp1.type == DEBUG_GetBasicType(DT_BASIC_CONST_INT) &&
exp2.type == DEBUG_GetBasicType(DT_BASIC_CONST_INT) )
{ {
rtn.type = exp1.type; rtn.type = exp1.type;
} }
else else
{ {
rtn.type = DEBUG_TypeInt; rtn.type = DEBUG_GetBasicType(DT_BASIC_INT);
} }
rtn.addr.seg = 0; rtn.addr.seg = 0;
rtn.addr.off = (unsigned int) &exp->un.binop.result; rtn.addr.off = (unsigned int) &exp->un.binop.result;
...@@ -595,13 +596,13 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) ...@@ -595,13 +596,13 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
} }
rtn.addr.seg = 0; rtn.addr.seg = 0;
rtn.addr.off = (unsigned int) &exp->un.unop.result; rtn.addr.off = (unsigned int) &exp->un.unop.result;
if( exp1.type == DEBUG_TypeIntConst ) if( exp1.type == DEBUG_GetBasicType(DT_BASIC_CONST_INT) )
{ {
rtn.type = exp1.type; rtn.type = exp1.type;
} }
else else
{ {
rtn.type = DEBUG_TypeInt; rtn.type = DEBUG_GetBasicType(DT_BASIC_INT);
} }
switch(exp->un.unop.unop_type) switch(exp->un.unop.unop_type)
{ {
......
...@@ -65,11 +65,7 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format ) ...@@ -65,11 +65,7 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format )
case 0: case 0:
if( default_format != NULL ) if( default_format != NULL )
{ {
if (strstr(default_format, "%S") == NULL) if (strstr(default_format, "%S") != NULL)
{
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, default_format, res );
}
else
{ {
char* ptr; char* ptr;
int state = 0; int state = 0;
...@@ -107,6 +103,14 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format ) ...@@ -107,6 +103,14 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format )
} }
} }
} }
else if (strcmp(default_format, "%B") == 0)
{
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, "%s", res ? "true" : "false");
}
else
{
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, default_format, res );
}
} }
break; break;
} }
......
...@@ -6,53 +6,53 @@ ...@@ -6,53 +6,53 @@
*/ */
/* break handling */ /* break handling */
INTERNAL_VAR(BreakAllThreadsStartup, FALSE, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(BreakAllThreadsStartup, FALSE, NULL, DT_BASIC_CONST_INT)
INTERNAL_VAR(BreakOnCritSectTimeOut, FALSE, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(BreakOnCritSectTimeOut, FALSE, NULL, DT_BASIC_CONST_INT)
INTERNAL_VAR(BreakOnAttach, FALSE, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(BreakOnAttach, FALSE, NULL, DT_BASIC_CONST_INT)
INTERNAL_VAR(BreakOnFirstChance, TRUE, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(BreakOnFirstChance, TRUE, NULL, DT_BASIC_CONST_INT)
INTERNAL_VAR(BreakOnDllLoad, FALSE, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(BreakOnDllLoad, FALSE, NULL, DT_BASIC_CONST_INT)
/* output handling */ /* output handling */
INTERNAL_VAR(ConChannelMask, DBG_CHN_MESG, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(ConChannelMask, DBG_CHN_MESG, NULL, DT_BASIC_CONST_INT)
INTERNAL_VAR(StdChannelMask, 0, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(StdChannelMask, 0, NULL, DT_BASIC_CONST_INT)
INTERNAL_VAR(UseXTerm, TRUE, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(UseXTerm, TRUE, NULL, DT_BASIC_CONST_INT)
/* debugging debugger */ /* debugging debugger */
INTERNAL_VAR(ExtDbgOnInvalidAddress, FALSE, NULL, DEBUG_TypeIntConst) INTERNAL_VAR(ExtDbgOnInvalidAddress, FALSE, NULL, DT_BASIC_CONST_INT)
/* current process/thread */ /* current process/thread */
INTERNAL_VAR(ThreadId, FALSE, &DEBUG_CurrTid, DEBUG_TypeIntConst) INTERNAL_VAR(ThreadId, FALSE, &DEBUG_CurrTid, DT_BASIC_CONST_INT)
INTERNAL_VAR(ProcessId, FALSE, &DEBUG_CurrPid, DEBUG_TypeIntConst) INTERNAL_VAR(ProcessId, FALSE, &DEBUG_CurrPid, DT_BASIC_CONST_INT)
/* context manipulation */ /* context manipulation */
#ifdef __i386__ #ifdef __i386__
/* FIXME: 16 bit registers use imply that CPU is little endian, which is /* FIXME: 16 bit registers use imply that CPU is little endian, which is
* the case when running natively i386 code * the case when running natively i386 code
*/ */
INTERNAL_VAR(eip, 0, &DEBUG_context.Eip, DEBUG_TypeIntConst) INTERNAL_VAR(eip, 0, &DEBUG_context.Eip, DT_BASIC_CONST_INT)
INTERNAL_VAR(ip, 0, &DEBUG_context.Eip, DEBUG_TypeShortUInt) INTERNAL_VAR(ip, 0, &DEBUG_context.Eip, DT_BASIC_USHORTINT)
INTERNAL_VAR(pc, 0, &DEBUG_context.Eip, DEBUG_TypeIntConst) INTERNAL_VAR(pc, 0, &DEBUG_context.Eip, DT_BASIC_CONST_INT)
INTERNAL_VAR(flags, 0, &DEBUG_context.EFlags, DEBUG_TypeIntConst) INTERNAL_VAR(flags, 0, &DEBUG_context.EFlags, DT_BASIC_CONST_INT)
INTERNAL_VAR(esp, 0, &DEBUG_context.Esp, DEBUG_TypeIntConst) INTERNAL_VAR(esp, 0, &DEBUG_context.Esp, DT_BASIC_CONST_INT)
INTERNAL_VAR(sp, 0, &DEBUG_context.Esp, DEBUG_TypeShortUInt) INTERNAL_VAR(sp, 0, &DEBUG_context.Esp, DT_BASIC_USHORTINT)
INTERNAL_VAR(eax, 0, &DEBUG_context.Eax, DEBUG_TypeIntConst) INTERNAL_VAR(eax, 0, &DEBUG_context.Eax, DT_BASIC_CONST_INT)
INTERNAL_VAR(ax, 0, &DEBUG_context.Eax, DEBUG_TypeShortUInt) INTERNAL_VAR(ax, 0, &DEBUG_context.Eax, DT_BASIC_USHORTINT)
INTERNAL_VAR(ebx, 0, &DEBUG_context.Ebx, DEBUG_TypeIntConst) INTERNAL_VAR(ebx, 0, &DEBUG_context.Ebx, DT_BASIC_CONST_INT)
INTERNAL_VAR(bx, 0, &DEBUG_context.Ebx, DEBUG_TypeShortUInt) INTERNAL_VAR(bx, 0, &DEBUG_context.Ebx, DT_BASIC_USHORTINT)
INTERNAL_VAR(ecx, 0, &DEBUG_context.Ecx, DEBUG_TypeIntConst) INTERNAL_VAR(ecx, 0, &DEBUG_context.Ecx, DT_BASIC_CONST_INT)
INTERNAL_VAR(cx, 0, &DEBUG_context.Ecx, DEBUG_TypeShortUInt) INTERNAL_VAR(cx, 0, &DEBUG_context.Ecx, DT_BASIC_USHORTINT)
INTERNAL_VAR(edx, 0, &DEBUG_context.Edx, DEBUG_TypeIntConst) INTERNAL_VAR(edx, 0, &DEBUG_context.Edx, DT_BASIC_CONST_INT)
INTERNAL_VAR(dx, 0, &DEBUG_context.Edx, DEBUG_TypeShortUInt) INTERNAL_VAR(dx, 0, &DEBUG_context.Edx, DT_BASIC_USHORTINT)
INTERNAL_VAR(esi, 0, &DEBUG_context.Esi, DEBUG_TypeIntConst) INTERNAL_VAR(esi, 0, &DEBUG_context.Esi, DT_BASIC_CONST_INT)
INTERNAL_VAR(si, 0, &DEBUG_context.Esi, DEBUG_TypeShortUInt) INTERNAL_VAR(si, 0, &DEBUG_context.Esi, DT_BASIC_USHORTINT)
INTERNAL_VAR(edi, 0, &DEBUG_context.Edi, DEBUG_TypeIntConst) INTERNAL_VAR(edi, 0, &DEBUG_context.Edi, DT_BASIC_CONST_INT)
INTERNAL_VAR(di, 0, &DEBUG_context.Edi, DEBUG_TypeShortUInt) INTERNAL_VAR(di, 0, &DEBUG_context.Edi, DT_BASIC_USHORTINT)
INTERNAL_VAR(ebp, 0, &DEBUG_context.Ebp, DEBUG_TypeIntConst) INTERNAL_VAR(ebp, 0, &DEBUG_context.Ebp, DT_BASIC_CONST_INT)
INTERNAL_VAR(bp, 0, &DEBUG_context.Ebp, DEBUG_TypeShortUInt) INTERNAL_VAR(bp, 0, &DEBUG_context.Ebp, DT_BASIC_USHORTINT)
INTERNAL_VAR(es, 0, &DEBUG_context.SegEs, DEBUG_TypeIntConst) INTERNAL_VAR(es, 0, &DEBUG_context.SegEs, DT_BASIC_CONST_INT)
INTERNAL_VAR(ds, 0, &DEBUG_context.SegDs, DEBUG_TypeIntConst) INTERNAL_VAR(ds, 0, &DEBUG_context.SegDs, DT_BASIC_CONST_INT)
INTERNAL_VAR(cs, 0, &DEBUG_context.SegCs, DEBUG_TypeIntConst) INTERNAL_VAR(cs, 0, &DEBUG_context.SegCs, DT_BASIC_CONST_INT)
INTERNAL_VAR(ss, 0, &DEBUG_context.SegSs, DEBUG_TypeIntConst) INTERNAL_VAR(ss, 0, &DEBUG_context.SegSs, DT_BASIC_CONST_INT)
INTERNAL_VAR(fs, 0, &DEBUG_context.SegFs, DEBUG_TypeIntConst) INTERNAL_VAR(fs, 0, &DEBUG_context.SegFs, DT_BASIC_CONST_INT)
INTERNAL_VAR(gs, 0, &DEBUG_context.SegGs, DEBUG_TypeIntConst) INTERNAL_VAR(gs, 0, &DEBUG_context.SegGs, DT_BASIC_CONST_INT)
#endif #endif
...@@ -212,7 +212,7 @@ BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode ) ...@@ -212,7 +212,7 @@ BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode )
* and hope that this is a sensible thing to do. * and hope that this is a sensible thing to do.
*/ */
if (value->type != NULL) { if (value->type != NULL) {
if (value->type == DEBUG_TypeIntConst) { if (value->type == DEBUG_GetBasicType(DT_BASIC_CONST_INT)) {
/* /*
* We know that we have the actual offset stored somewhere * We know that we have the actual offset stored somewhere
* else in 32-bit space. Grab it, and we * else in 32-bit space. Grab it, and we
...@@ -227,7 +227,7 @@ BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode ) ...@@ -227,7 +227,7 @@ BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode )
if (DEBUG_TypeDerefPointer(value, &testtype) == 0) if (DEBUG_TypeDerefPointer(value, &testtype) == 0)
return FALSE; return FALSE;
if (testtype != NULL || value->type == DEBUG_TypeIntConst) if (testtype != NULL || value->type == DEBUG_GetBasicType(DT_BASIC_CONST_INT))
value->addr.off = DEBUG_GetExprValue(value, NULL); value->addr.off = DEBUG_GetExprValue(value, NULL);
} }
} else if (!value->addr.seg && !value->addr.off) { } else if (!value->addr.seg && !value->addr.off) {
......
...@@ -1104,21 +1104,21 @@ DEBUG_InitCVDataTypes(void) ...@@ -1104,21 +1104,21 @@ DEBUG_InitCVDataTypes(void)
*/ */
cv_basic_types[T_NOTYPE] = NULL; cv_basic_types[T_NOTYPE] = NULL;
cv_basic_types[T_ABS] = NULL; cv_basic_types[T_ABS] = NULL;
cv_basic_types[T_VOID] = DEBUG_NewDataType(DT_BASIC, "void"); cv_basic_types[T_VOID] = DEBUG_GetBasicType(DT_BASIC_VOID);
cv_basic_types[T_CHAR] = DEBUG_NewDataType(DT_BASIC, "char"); cv_basic_types[T_CHAR] = DEBUG_GetBasicType(DT_BASIC_CHAR);
cv_basic_types[T_SHORT] = DEBUG_NewDataType(DT_BASIC, "short int"); cv_basic_types[T_SHORT] = DEBUG_GetBasicType(DT_BASIC_SHORTINT);
cv_basic_types[T_LONG] = DEBUG_NewDataType(DT_BASIC, "long int"); cv_basic_types[T_LONG] = DEBUG_GetBasicType(DT_BASIC_LONGINT);
cv_basic_types[T_QUAD] = DEBUG_NewDataType(DT_BASIC, "long long int"); cv_basic_types[T_QUAD] = DEBUG_GetBasicType(DT_BASIC_LONGLONGINT);
cv_basic_types[T_UCHAR] = DEBUG_NewDataType(DT_BASIC, "unsigned char"); cv_basic_types[T_UCHAR] = DEBUG_GetBasicType(DT_BASIC_UCHAR);
cv_basic_types[T_USHORT] = DEBUG_NewDataType(DT_BASIC, "short unsigned int"); cv_basic_types[T_USHORT] = DEBUG_GetBasicType(DT_BASIC_USHORTINT);
cv_basic_types[T_ULONG] = DEBUG_NewDataType(DT_BASIC, "long unsigned int"); cv_basic_types[T_ULONG] = DEBUG_GetBasicType(DT_BASIC_ULONGINT);
cv_basic_types[T_UQUAD] = DEBUG_NewDataType(DT_BASIC, "long long unsigned int"); cv_basic_types[T_UQUAD] = DEBUG_GetBasicType(DT_BASIC_ULONGLONGINT);
cv_basic_types[T_REAL32] = DEBUG_NewDataType(DT_BASIC, "float"); cv_basic_types[T_REAL32] = DEBUG_GetBasicType(DT_BASIC_FLOAT);
cv_basic_types[T_REAL64] = DEBUG_NewDataType(DT_BASIC, "double"); cv_basic_types[T_REAL64] = DEBUG_GetBasicType(DT_BASIC_DOUBLE);
cv_basic_types[T_RCHAR] = DEBUG_NewDataType(DT_BASIC, "char"); cv_basic_types[T_RCHAR] = DEBUG_GetBasicType(DT_BASIC_CHAR);
cv_basic_types[T_WCHAR] = DEBUG_NewDataType(DT_BASIC, "short"); cv_basic_types[T_WCHAR] = DEBUG_GetBasicType(DT_BASIC_SHORTINT);
cv_basic_types[T_INT4] = DEBUG_NewDataType(DT_BASIC, "int"); cv_basic_types[T_INT4] = DEBUG_GetBasicType(DT_BASIC_INT);
cv_basic_types[T_UINT4] = DEBUG_NewDataType(DT_BASIC, "unsigned int"); cv_basic_types[T_UINT4] = DEBUG_GetBasicType(DT_BASIC_UINT);
cv_basic_types[T_32PVOID] = DEBUG_FindOrMakePointerType(cv_basic_types[T_VOID]); cv_basic_types[T_32PVOID] = DEBUG_FindOrMakePointerType(cv_basic_types[T_VOID]);
cv_basic_types[T_32PCHAR] = DEBUG_FindOrMakePointerType(cv_basic_types[T_CHAR]); cv_basic_types[T_32PCHAR] = DEBUG_FindOrMakePointerType(cv_basic_types[T_CHAR]);
......
...@@ -395,7 +395,7 @@ static inline int DEBUG_PTS_ReadArray(struct ParseTypedefData* ptd, struct datat ...@@ -395,7 +395,7 @@ static inline int DEBUG_PTS_ReadArray(struct ParseTypedefData* ptd, struct datat
static int DEBUG_PTS_ReadTypedef(struct ParseTypedefData* ptd, const char* typename, static int DEBUG_PTS_ReadTypedef(struct ParseTypedefData* ptd, const char* typename,
struct datatype** ret_dt) struct datatype** ret_dt)
{ {
int idx, lo, hi; int idx, lo, hi, sz = -1;
struct datatype* new_dt = NULL; /* newly created data type */ struct datatype* new_dt = NULL; /* newly created data type */
struct datatype* ref_dt; /* referenced data type (pointer...) */ struct datatype* ref_dt; /* referenced data type (pointer...) */
struct datatype* dt1; /* intermediate data type (scope is limited) */ struct datatype* dt1; /* intermediate data type (scope is limited) */
...@@ -422,7 +422,7 @@ static int DEBUG_PTS_ReadTypedef(struct ParseTypedefData* ptd, const char* typen ...@@ -422,7 +422,7 @@ static int DEBUG_PTS_ReadTypedef(struct ParseTypedefData* ptd, const char* typen
case '@': case '@':
if (*++ptd->ptr == 's') { if (*++ptd->ptr == 's') {
ptd->ptr++; ptd->ptr++;
if (DEBUG_PTS_ReadNum(ptd, &lo) == -1) { if (DEBUG_PTS_ReadNum(ptd, &sz) == -1) {
DEBUG_Printf(DBG_CHN_MESG, "Not an attribute... NIY\n"); DEBUG_Printf(DBG_CHN_MESG, "Not an attribute... NIY\n");
ptd->ptr -= 2; ptd->ptr -= 2;
return -1; return -1;
...@@ -516,8 +516,56 @@ static int DEBUG_PTS_ReadTypedef(struct ParseTypedefData* ptd, const char* typen ...@@ -516,8 +516,56 @@ static int DEBUG_PTS_ReadTypedef(struct ParseTypedefData* ptd, const char* typen
new_dt = DEBUG_NewDataType(lo, ptd->buf + idx); new_dt = DEBUG_NewDataType(lo, ptd->buf + idx);
ptd->idx = idx; ptd->idx = idx;
break; break;
case '-':
if (DEBUG_PTS_ReadNum(ptd, &lo) == -1) {
DEBUG_Printf(DBG_CHN_MESG, "Should be a number (%s)...\n", ptd->ptr);
return -1;
} else {
enum debug_type_basic basic = DT_BASIC_LAST;
switch (lo)
{
case 1: basic = DT_BASIC_INT; break;
case 2: basic = DT_BASIC_CHAR; break;
case 3: basic = DT_BASIC_SHORTINT; break;
case 4: basic = DT_BASIC_LONGINT; break;
case 5: basic = DT_BASIC_UCHAR; break;
case 6: basic = DT_BASIC_SCHAR; break;
case 7: basic = DT_BASIC_USHORTINT; break;
case 8: basic = DT_BASIC_UINT; break;
/* case 9: basic = DT_BASIC_UINT"; */
case 10: basic = DT_BASIC_ULONGINT; break;
case 11: basic = DT_BASIC_VOID; break;
case 12: basic = DT_BASIC_FLOAT; break;
case 13: basic = DT_BASIC_DOUBLE; break;
case 14: basic = DT_BASIC_LONGDOUBLE; break;
/* case 15: basic = DT_BASIC_INT; break; */
case 16:
switch (sz) {
case 32: basic = DT_BASIC_BOOL1; break;
case 16: basic = DT_BASIC_BOOL2; break;
case 8: basic = DT_BASIC_BOOL4; break;
}
break;
/* case 17: basic = DT_BASIC_SHORT real; break; */
/* case 18: basic = DT_BASIC_REAL; break; */
case 25: basic = DT_BASIC_CMPLX_FLOAT; break;
case 26: basic = DT_BASIC_CMPLX_DOUBLE; break;
/* case 30: basic = DT_BASIC_wchar"; break; */
case 31: basic = DT_BASIC_LONGLONGINT; break;
case 32: basic = DT_BASIC_ULONGLONGINT; break;
default:
DEBUG_Printf(DBG_CHN_MESG, "Unsupported integral type (%d/%d)\n", lo, sz);
return -1;
}
if (!(new_dt = DEBUG_GetBasicType(basic))) {
DEBUG_Printf(DBG_CHN_MESG, "Basic type %d not found\n", basic);
return -1;
}
if (*ptd->ptr++ != ';') return -1;
}
break;
default: default:
DEBUG_Printf(DBG_CHN_MESG, "Unknown type '%c'\n", *ptd->ptr); DEBUG_Printf(DBG_CHN_MESG, "Unknown type '%c'\n", ptd->ptr[-1]);
return -1; return -1;
} }
} }
......
...@@ -87,36 +87,12 @@ struct datatype ...@@ -87,36 +87,12 @@ struct datatype
} un; } un;
}; };
#define BASIC_INT 1
#define BASIC_CHAR 2
#define BASIC_LONG 3
#define BASIC_UINT 4
#define BASIC_LUI 5
#define BASIC_LONGLONG 6
#define BASIC_ULONGLONGI 7
#define BASIC_SHORT 8
#define BASIC_SHORTUI 9
#define BASIC_SCHAR 10
#define BASIC_UCHAR 11
#define BASIC_FLT 12
#define BASIC_LONG_DOUBLE 13
#define BASIC_DOUBLE 14
#define BASIC_CMPLX_INT 15
#define BASIC_CMPLX_FLT 16
#define BASIC_CMPLX_DBL 17
#define BASIC_CMPLX_LONG_DBL 18
#define BASIC_VOID 19
struct datatype * DEBUG_TypeInt = NULL;
struct datatype * DEBUG_TypeIntConst = NULL;
struct datatype * DEBUG_TypeUSInt = NULL;
struct datatype * DEBUG_TypeString = NULL;
struct datatype * DEBUG_TypeShortUInt = NULL;
/* /*
* All of the types that have been defined so far. * All of the types that have been defined so far.
*/ */
static struct datatype * type_hash_table[NR_TYPE_HASH + 1]; static struct datatype * type_hash_table[NR_TYPE_HASH + 1];
static struct datatype * pointer_types = NULL; static struct datatype * pointer_types = NULL;
static struct datatype * basic_types[DT_BASIC_LAST];
static unsigned int type_hash( const char * name ) static unsigned int type_hash( const char * name )
{ {
...@@ -168,6 +144,7 @@ DEBUG_InitBasic(int type, char * name, int size, int b_signed, ...@@ -168,6 +144,7 @@ DEBUG_InitBasic(int type, char * name, int size, int b_signed,
dt->un.basic.basic_size = size; dt->un.basic.basic_size = size;
dt->un.basic.b_signed = b_signed; dt->un.basic.b_signed = b_signed;
dt->un.basic.output_format = output_format; dt->un.basic.output_format = output_format;
basic_types[type] = dt;
} }
return dt; return dt;
...@@ -200,6 +177,16 @@ DEBUG_LookupDataType(enum debug_type xtype, int hash, const char * typename) ...@@ -200,6 +177,16 @@ DEBUG_LookupDataType(enum debug_type xtype, int hash, const char * typename)
} }
struct datatype * struct datatype *
DEBUG_GetBasicType(enum debug_type_basic basic)
{
if (basic == 0 || basic >= DT_BASIC_LAST)
{
return NULL;
}
return basic_types[basic];
}
struct datatype *
DEBUG_NewDataType(enum debug_type xtype, const char * typename) DEBUG_NewDataType(enum debug_type xtype, const char * typename)
{ {
struct datatype * dt = NULL; struct datatype * dt = NULL;
...@@ -293,7 +280,6 @@ void ...@@ -293,7 +280,6 @@ void
DEBUG_InitTypes(void) DEBUG_InitTypes(void)
{ {
static int beenhere = 0; static int beenhere = 0;
struct datatype * chartype;
if( beenhere++ != 0 ) if( beenhere++ != 0 )
{ {
...@@ -301,36 +287,39 @@ DEBUG_InitTypes(void) ...@@ -301,36 +287,39 @@ DEBUG_InitTypes(void)
} }
/* /*
* Special version of int used with constants of various kinds. * Initialize a few builtin types.
*/ */
DEBUG_TypeIntConst = DEBUG_InitBasic(BASIC_INT,NULL,4,1,"%d");
DEBUG_InitBasic(DT_BASIC_INT,"int",4,1,"%d");
DEBUG_InitBasic(DT_BASIC_CHAR,"char",1,1,"'%c'");
DEBUG_InitBasic(DT_BASIC_LONGINT,"long int",4,1,"%d");
DEBUG_InitBasic(DT_BASIC_UINT,"unsigned int",4,0,"%d");
DEBUG_InitBasic(DT_BASIC_ULONGINT,"long unsigned int",4,0,"%d");
DEBUG_InitBasic(DT_BASIC_LONGLONGINT,"long long int",8,1,"%ld");
DEBUG_InitBasic(DT_BASIC_ULONGLONGINT,"long long unsigned int",8,0,"%ld");
DEBUG_InitBasic(DT_BASIC_SHORTINT,"short int",2,1,"%d");
DEBUG_InitBasic(DT_BASIC_USHORTINT,"short unsigned int",2,0,"%d");
DEBUG_InitBasic(DT_BASIC_SCHAR,"signed char",1,1,"'%c'");
DEBUG_InitBasic(DT_BASIC_UCHAR,"unsigned char",1,0,"'%c'");
DEBUG_InitBasic(DT_BASIC_FLOAT,"float",4,0,"%f");
DEBUG_InitBasic(DT_BASIC_DOUBLE,"long double",12,0,NULL);
DEBUG_InitBasic(DT_BASIC_LONGDOUBLE,"double",8,0,"%lf");
DEBUG_InitBasic(DT_BASIC_CMPLX_INT,"complex int",8,1,NULL);
DEBUG_InitBasic(DT_BASIC_CMPLX_FLOAT,"complex float",8,0,NULL);
DEBUG_InitBasic(DT_BASIC_CMPLX_DOUBLE,"complex double",16,0,NULL);
DEBUG_InitBasic(DT_BASIC_CMPLX_LONGDOUBLE,"complex long double",24,0,NULL);
DEBUG_InitBasic(DT_BASIC_VOID,"void",0,0,NULL);
DEBUG_InitBasic(DT_BASIC_BOOL1,NULL,1,0,"%B");
DEBUG_InitBasic(DT_BASIC_BOOL2,NULL,2,0,"%B");
DEBUG_InitBasic(DT_BASIC_BOOL4,NULL,4,0,"%B");
basic_types[DT_BASIC_STRING] = DEBUG_NewDataType(DT_POINTER, NULL);
DEBUG_SetPointerType(basic_types[DT_BASIC_STRING], basic_types[DT_BASIC_CHAR]);
/* /*
* Initialize a few builtin types. * Special version of int used with constants of various kinds.
*/ */
DEBUG_InitBasic(DT_BASIC_CONST_INT,NULL,4,1,"%d");
DEBUG_TypeInt = DEBUG_InitBasic(BASIC_INT,"int",4,1,"%d");
chartype = DEBUG_InitBasic(BASIC_CHAR,"char",1,1,"'%c'");
DEBUG_InitBasic(BASIC_LONG,"long int",4,1,"%d");
DEBUG_TypeUSInt = DEBUG_InitBasic(BASIC_UINT,"unsigned int",4,0,"%d");
DEBUG_InitBasic(BASIC_LUI,"long unsigned int",4,0,"%d");
DEBUG_InitBasic(BASIC_LONGLONG,"long long int",8,1,"%ld");
DEBUG_InitBasic(BASIC_ULONGLONGI,"long long unsigned int",8,0,"%ld");
DEBUG_InitBasic(BASIC_SHORT,"short int",2,1,"%d");
DEBUG_TypeShortUInt = DEBUG_InitBasic(BASIC_SHORTUI,"short unsigned int",2,0,"%d");
DEBUG_InitBasic(BASIC_SCHAR,"signed char",1,1,"'%c'");
DEBUG_InitBasic(BASIC_UCHAR,"unsigned char",1,0,"'%c'");
DEBUG_InitBasic(BASIC_FLT,"float",4,0,"%f");
DEBUG_InitBasic(BASIC_LONG_DOUBLE,"double",8,0,"%lf");
DEBUG_InitBasic(BASIC_DOUBLE,"long double",12,0,NULL);
DEBUG_InitBasic(BASIC_CMPLX_INT,"complex int",8,1,NULL);
DEBUG_InitBasic(BASIC_CMPLX_FLT,"complex float",8,0,NULL);
DEBUG_InitBasic(BASIC_CMPLX_DBL,"complex double",16,0,NULL);
DEBUG_InitBasic(BASIC_CMPLX_LONG_DBL,"complex long double",24,0,NULL);
DEBUG_InitBasic(BASIC_VOID,"void",0,0,NULL);
DEBUG_TypeString = DEBUG_NewDataType(DT_POINTER, NULL);
DEBUG_SetPointerType(DEBUG_TypeString, chartype);
/* /*
* Now initialize the builtins for codeview. * Now initialize the builtins for codeview.
...@@ -381,7 +370,7 @@ DEBUG_GetExprValue(const DBG_VALUE* _value, char** format) ...@@ -381,7 +370,7 @@ DEBUG_GetExprValue(const DBG_VALUE* _value, char** format)
rtn = rtn | ((-1) << (value.type->un.basic.basic_size * 8)); rtn = rtn | ((-1) << (value.type->un.basic.basic_size * 8));
} }
/* float type has to be promoted as a double */ /* float type has to be promoted as a double */
if (value.type->un.basic.basic_type == BASIC_FLT) { if (value.type->un.basic.basic_type == DT_BASIC_FLOAT) {
float f; float f;
double d; double d;
memcpy(&f, &rtn, sizeof(f)); memcpy(&f, &rtn, sizeof(f));
......
...@@ -72,7 +72,7 @@ static BOOL DEBUG_IntVarsRW(int read) ...@@ -72,7 +72,7 @@ static BOOL DEBUG_IntVarsRW(int read)
/* initializes internal vars table */ /* initializes internal vars table */
#define INTERNAL_VAR(_var,_val,_ref,_typ) \ #define INTERNAL_VAR(_var,_val,_ref,_typ) \
div->val = _val; div->name = #_var; div->pval = _ref; \ div->val = _val; div->name = #_var; div->pval = _ref; \
div->type = _typ; div++; div->type = DEBUG_GetBasicType(_typ); div++;
#include "intvar.h" #include "intvar.h"
#undef INTERNAL_VAR #undef INTERNAL_VAR
} }
......
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