Commit 53ae7824 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedbg: Introduce dbg_lg(u)int_t and migrate all integral computations on this type.

As a side effect, the internal 'long int' type is now always 8 byte wide. Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent ac3ee768
......@@ -39,7 +39,7 @@ static void parser(const char*);
{
struct dbg_lvalue lvalue;
char* string;
INT_PTR integer;
dbg_lgint_t integer;
IMAGEHLP_LINE64 listing;
struct expr* expression;
struct type_expr_t type;
......@@ -286,9 +286,9 @@ info_command:
| tINFO tCLASS { info_win32_class(NULL, NULL); }
| tINFO tCLASS tSTRING { info_win32_class(NULL, $3); }
| tINFO tWND { info_win32_window(NULL, FALSE); }
| tINFO tWND expr_rvalue { info_win32_window((HWND)$3, FALSE); }
| tINFO tWND expr_rvalue { info_win32_window((HWND)(DWORD_PTR)$3, FALSE); }
| tINFO '*' tWND { info_win32_window(NULL, TRUE); }
| tINFO '*' tWND expr_rvalue { info_win32_window((HWND)$4, TRUE); }
| tINFO '*' tWND expr_rvalue { info_win32_window((HWND)(DWORD_PTR)$4, TRUE); }
| tINFO tPROCESS { info_win32_processes(); }
| tINFO tTHREAD { info_win32_threads(); }
| tINFO tFRAME { info_win32_frame_exceptions(dbg_curr_tid); }
......
......@@ -139,11 +139,11 @@ STRING \"(\\[^\n]|[^\\"\n])*\"
"[" { return *yytext; }
"]" { return *yytext; }
"0x"{HEXDIGIT}+ { sscanf(yytext, "%Ix", &dbg_lval.integer); return tNUM; }
{DIGIT}+ { sscanf(yytext, "%Id", &dbg_lval.integer); return tNUM; }
"0x"{HEXDIGIT}+ { sscanf(yytext, "%I64x", &dbg_lval.integer); return tNUM; }
{DIGIT}+ { sscanf(yytext, "%I64d", &dbg_lval.integer); return tNUM; }
"'\\''" { dbg_lval.integer = '\''; return tNUM;}
"'\\0"{OCTDIGIT}*"'" { sscanf(yytext + 3, "%Io", &dbg_lval.integer); return tNUM;}
"'\\x"{HEXDIGIT}+"'" { sscanf(yytext + 3, "%Ix", &dbg_lval.integer); return tNUM;}
"'\\0"{OCTDIGIT}*"'" { sscanf(yytext + 3, "%I64o", &dbg_lval.integer); return tNUM;}
"'\\x"{HEXDIGIT}+"'" { sscanf(yytext + 3, "%I64x", &dbg_lval.integer); return tNUM;}
"'\\"[a-z]"'" { dbg_lval.integer = yytext[2] - 'a'; return tNUM;}
"'"."'" { dbg_lval.integer = yytext[1]; return tNUM;}
......
......@@ -78,6 +78,11 @@ enum dbg_internal_types
dbg_itype_signed_long_int,
dbg_itype_unsigned_longlong_int,
dbg_itype_signed_longlong_int,
/* they represent the dbg_lg(u)int_t types */
dbg_itype_lgint,
dbg_itype_lguint,
dbg_itype_char,
dbg_itype_wchar,
dbg_itype_short_real, /* aka float */
......@@ -90,6 +95,14 @@ enum dbg_internal_types
dbg_itype_none = 0xffffffff
};
/* Largest integers the debugger's compiler can support.
* It's large enough to store a pointer (in debuggee or debugger's address space).
* It can be smaller than the largest integer(s) of the debuggee.
* (eg. 64 bit on PE build of debugger, vs 128 int in ELF build of a library)
*/
typedef LONG64 dbg_lgint_t;
typedef ULONG64 dbg_lguint_t;
/* type description (in the following order):
* - if 'id' is dbg_itype_none (whatever 'module' value), the type isn't known
* - if 'module' is 0, it's an internal type (id is one of dbg_itype...)
......@@ -329,8 +342,8 @@ extern BOOL display_enable(int displaynum, int enable);
extern void expr_free_all(void);
extern struct expr* expr_alloc_internal_var(const char* name);
extern struct expr* expr_alloc_symbol(const char* name);
extern struct expr* expr_alloc_sconstant(INT_PTR val);
extern struct expr* expr_alloc_uconstant(UINT_PTR val);
extern struct expr* expr_alloc_sconstant(dbg_lgint_t val);
extern struct expr* expr_alloc_uconstant(dbg_lguint_t val);
extern struct expr* expr_alloc_string(const char* str);
extern struct expr* expr_alloc_binary_op(int oper, struct expr*, struct expr*);
extern struct expr* expr_alloc_unary_op(int oper, struct expr*);
......@@ -448,8 +461,8 @@ extern enum dbg_start tgt_module_load(const char* name, BOOL keep);
extern void print_value(const struct dbg_lvalue* addr, char format, int level);
extern BOOL types_print_type(const struct dbg_type*, BOOL details);
extern BOOL print_types(void);
extern INT_PTR types_extract_as_integer(const struct dbg_lvalue*);
extern LONGLONG types_extract_as_longlong(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned);
extern dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue*);
extern dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned);
extern void types_extract_as_address(const struct dbg_lvalue*, ADDRESS64*);
extern BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from);
extern BOOL types_udt_find_element(struct dbg_lvalue* value, const char* name, ULONG *tmpbuf);
......
......@@ -35,12 +35,12 @@ struct expr
{
struct
{
INT_PTR value;
dbg_lgint_t value;
} s_const;
struct
{
UINT_PTR value;
dbg_lguint_t value;
} u_const;
struct
......@@ -62,7 +62,7 @@ struct expr
{
int unop_type;
struct expr* exp1;
INT_PTR result;
dbg_lgint_t result;
} unop;
struct
......@@ -70,7 +70,7 @@ struct expr
int binop_type;
struct expr* exp1;
struct expr* exp2;
INT_PTR result;
dbg_lgint_t result;
} binop;
struct
......@@ -83,7 +83,7 @@ struct expr
{
struct expr* exp1;
const char* element_name;
ULONG result;
ULONG /* FIXME */ result;
} structure;
struct
......@@ -91,7 +91,7 @@ struct expr
const char* funcname;
int nargs;
struct expr* arg[5];
ULONG result;
dbg_lguint_t result;
} call;
} un;
......@@ -163,7 +163,7 @@ struct expr* expr_alloc_symbol(const char* name)
return ex;
}
struct expr* expr_alloc_sconstant(INT_PTR value)
struct expr* expr_alloc_sconstant(dbg_lgint_t value)
{
struct expr* ex;
......@@ -174,7 +174,7 @@ struct expr* expr_alloc_sconstant(INT_PTR value)
return ex;
}
struct expr* expr_alloc_uconstant(UINT_PTR value)
struct expr* expr_alloc_uconstant(dbg_lguint_t value)
{
struct expr* ex;
......@@ -347,13 +347,13 @@ struct dbg_lvalue expr_eval(struct expr* exp)
break;
case EXPR_TYPE_U_CONST:
rtn.cookie = DLV_HOST;
rtn.type.id = dbg_itype_unsigned_long_int;
rtn.type.id = dbg_itype_lguint;
rtn.type.module = 0;
rtn.addr.Offset = (ULONG_PTR)&exp->un.u_const.value;
break;
case EXPR_TYPE_S_CONST:
rtn.cookie = DLV_HOST;
rtn.type.id = dbg_itype_signed_long_int;
rtn.type.id = dbg_itype_lgint;
rtn.type.module = 0;
rtn.addr.Offset = (ULONG_PTR)&exp->un.s_const.value;
break;
......@@ -476,7 +476,7 @@ struct dbg_lvalue expr_eval(struct expr* exp)
exp2 = expr_eval(exp->un.binop.exp2);
if (exp1.type.id == dbg_itype_none || exp2.type.id == dbg_itype_none)
RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL);
rtn.type.id = dbg_itype_signed_long_int;
rtn.type.id = dbg_itype_lgint;
rtn.type.module = 0;
rtn.addr.Offset = (ULONG_PTR)&exp->un.binop.result;
type1 = exp1.type;
......@@ -506,8 +506,8 @@ struct dbg_lvalue expr_eval(struct expr* exp)
types_get_info(&type2, TI_GET_LENGTH, &scale1);
rtn.type = exp2.type;
}
exp->un.binop.result = types_extract_as_integer(&exp1) * (DWORD)scale1 +
(DWORD)scale2 * types_extract_as_integer(&exp2);
exp->un.binop.result = types_extract_as_integer(&exp1) * (dbg_lguint_t)scale1 +
(dbg_lguint_t)scale2 * types_extract_as_integer(&exp2);
break;
case EXP_OP_SUB:
if (!types_get_info(&exp1.type, TI_GET_SYMTAG, &tag) ||
......@@ -538,8 +538,8 @@ struct dbg_lvalue expr_eval(struct expr* exp)
types_get_info(&type2, TI_GET_LENGTH, &scale1);
rtn.type = exp2.type;
}
exp->un.binop.result = (types_extract_as_integer(&exp1) * (DWORD)scale1 -
types_extract_as_integer(&exp2) * (DWORD)scale2) / (DWORD)scale3;
exp->un.binop.result = (types_extract_as_integer(&exp1) * (dbg_lguint_t)scale1 -
types_extract_as_integer(&exp2) * (dbg_lguint_t)scale2) / (dbg_lguint_t)scale3;
break;
case EXP_OP_SEG:
rtn.type.id = dbg_itype_segptr;
......@@ -581,10 +581,10 @@ struct dbg_lvalue expr_eval(struct expr* exp)
exp->un.binop.result = (types_extract_as_integer(&exp1) != types_extract_as_integer(&exp2));
break;
case EXP_OP_SHL:
exp->un.binop.result = ((UINT_PTR)types_extract_as_integer(&exp1) << types_extract_as_integer(&exp2));
exp->un.binop.result = types_extract_as_integer(&exp1) << types_extract_as_integer(&exp2);
break;
case EXP_OP_SHR:
exp->un.binop.result = ((UINT_PTR)types_extract_as_integer(&exp1) >> types_extract_as_integer(&exp2));
exp->un.binop.result = types_extract_as_integer(&exp1) >> types_extract_as_integer(&exp2);
break;
case EXP_OP_MUL:
exp->un.binop.result = (types_extract_as_integer(&exp1) * types_extract_as_integer(&exp2));
......@@ -609,7 +609,7 @@ struct dbg_lvalue expr_eval(struct expr* exp)
exp1 = expr_eval(exp->un.unop.exp1);
if (exp1.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL);
rtn.addr.Offset = (ULONG_PTR)&exp->un.unop.result;
rtn.type.id = dbg_itype_signed_long_int;
rtn.type.id = dbg_itype_lgint;
rtn.type.module = 0;
switch (exp->un.unop.unop_type)
{
......@@ -687,10 +687,10 @@ BOOL expr_print(const struct expr* exp)
dbg_printf("$%s", exp->un.intvar.name);
break;
case EXPR_TYPE_U_CONST:
dbg_printf("%Iu", exp->un.u_const.value);
dbg_printf("%I64u", exp->un.u_const.value);
break;
case EXPR_TYPE_S_CONST:
dbg_printf("%Id", exp->un.s_const.value);
dbg_printf("%I64d", exp->un.s_const.value);
break;
case EXPR_TYPE_STRING:
dbg_printf("\"%s\"", exp->un.string.str);
......
......@@ -509,7 +509,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format)
if (format != 0)
{
unsigned size;
LONGLONG res = types_extract_as_longlong(lvalue, &size, NULL);
dbg_lgint_t res = types_extract_as_longlong(lvalue, &size, NULL);
WCHAR wch;
switch (format)
......
......@@ -52,10 +52,10 @@ BOOL types_get_real_type(struct dbg_type* type, DWORD* tag)
* Given a lvalue, try to get an integral (or pointer/address) value
* out of it
*/
LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue,
unsigned* psize, BOOL *issigned)
dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue* lvalue,
unsigned* psize, BOOL *issigned)
{
LONGLONG rtn = 0;
dbg_lgint_t rtn = 0;
DWORD tag, bt;
DWORD64 size;
struct dbg_type type = lvalue->type;
......@@ -136,7 +136,7 @@ LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue,
* Given a lvalue, try to get an integral (or pointer/address) value
* out of it
*/
INT_PTR types_extract_as_integer(const struct dbg_lvalue* lvalue)
dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue* lvalue)
{
return types_extract_as_longlong(lvalue, NULL, NULL);
}
......@@ -161,7 +161,7 @@ void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr)
BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from)
{
LONGLONG val;
dbg_lgint_t val;
DWORD64 size;
BOOL is_signed;
......@@ -777,6 +777,24 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v
switch (type->id)
{
case dbg_itype_lguint:
switch (ti)
{
case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
case TI_GET_LENGTH: X(DWORD64) = sizeof(dbg_lguint_t); break;
case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
default: WINE_FIXME("unsupported %u for lguint_t\n", ti); return FALSE;
}
break;
case dbg_itype_lgint:
switch (ti)
{
case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
case TI_GET_LENGTH: X(DWORD64) = sizeof(dbg_lgint_t); break;
case TI_GET_BASETYPE: X(DWORD) = btInt; break;
default: WINE_FIXME("unsupported %u for lgint_t\n", ti); return FALSE;
}
break;
case dbg_itype_unsigned_long_int:
switch (ti)
{
......
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