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*); ...@@ -39,7 +39,7 @@ static void parser(const char*);
{ {
struct dbg_lvalue lvalue; struct dbg_lvalue lvalue;
char* string; char* string;
INT_PTR integer; dbg_lgint_t integer;
IMAGEHLP_LINE64 listing; IMAGEHLP_LINE64 listing;
struct expr* expression; struct expr* expression;
struct type_expr_t type; struct type_expr_t type;
...@@ -286,9 +286,9 @@ info_command: ...@@ -286,9 +286,9 @@ info_command:
| tINFO tCLASS { info_win32_class(NULL, NULL); } | tINFO tCLASS { info_win32_class(NULL, NULL); }
| tINFO tCLASS tSTRING { info_win32_class(NULL, $3); } | tINFO tCLASS tSTRING { info_win32_class(NULL, $3); }
| tINFO tWND { info_win32_window(NULL, FALSE); } | 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 { 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 tPROCESS { info_win32_processes(); }
| tINFO tTHREAD { info_win32_threads(); } | tINFO tTHREAD { info_win32_threads(); }
| tINFO tFRAME { info_win32_frame_exceptions(dbg_curr_tid); } | tINFO tFRAME { info_win32_frame_exceptions(dbg_curr_tid); }
......
...@@ -139,11 +139,11 @@ STRING \"(\\[^\n]|[^\\"\n])*\" ...@@ -139,11 +139,11 @@ STRING \"(\\[^\n]|[^\\"\n])*\"
"[" { return *yytext; } "[" { return *yytext; }
"]" { return *yytext; } "]" { return *yytext; }
"0x"{HEXDIGIT}+ { sscanf(yytext, "%Ix", &dbg_lval.integer); return tNUM; } "0x"{HEXDIGIT}+ { sscanf(yytext, "%I64x", &dbg_lval.integer); return tNUM; }
{DIGIT}+ { sscanf(yytext, "%Id", &dbg_lval.integer); return tNUM; } {DIGIT}+ { sscanf(yytext, "%I64d", &dbg_lval.integer); return tNUM; }
"'\\''" { dbg_lval.integer = '\''; return tNUM;} "'\\''" { dbg_lval.integer = '\''; return tNUM;}
"'\\0"{OCTDIGIT}*"'" { sscanf(yytext + 3, "%Io", &dbg_lval.integer); return tNUM;} "'\\0"{OCTDIGIT}*"'" { sscanf(yytext + 3, "%I64o", &dbg_lval.integer); return tNUM;}
"'\\x"{HEXDIGIT}+"'" { sscanf(yytext + 3, "%Ix", &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;} "'\\"[a-z]"'" { dbg_lval.integer = yytext[2] - 'a'; return tNUM;}
"'"."'" { dbg_lval.integer = yytext[1]; return tNUM;} "'"."'" { dbg_lval.integer = yytext[1]; return tNUM;}
......
...@@ -78,6 +78,11 @@ enum dbg_internal_types ...@@ -78,6 +78,11 @@ enum dbg_internal_types
dbg_itype_signed_long_int, dbg_itype_signed_long_int,
dbg_itype_unsigned_longlong_int, dbg_itype_unsigned_longlong_int,
dbg_itype_signed_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_char,
dbg_itype_wchar, dbg_itype_wchar,
dbg_itype_short_real, /* aka float */ dbg_itype_short_real, /* aka float */
...@@ -90,6 +95,14 @@ enum dbg_internal_types ...@@ -90,6 +95,14 @@ enum dbg_internal_types
dbg_itype_none = 0xffffffff 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): /* type description (in the following order):
* - if 'id' is dbg_itype_none (whatever 'module' value), the type isn't known * - 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...) * - 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); ...@@ -329,8 +342,8 @@ extern BOOL display_enable(int displaynum, int enable);
extern void expr_free_all(void); extern void expr_free_all(void);
extern struct expr* expr_alloc_internal_var(const char* name); extern struct expr* expr_alloc_internal_var(const char* name);
extern struct expr* expr_alloc_symbol(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_sconstant(dbg_lgint_t val);
extern struct expr* expr_alloc_uconstant(UINT_PTR 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_string(const char* str);
extern struct expr* expr_alloc_binary_op(int oper, struct expr*, struct expr*); extern struct expr* expr_alloc_binary_op(int oper, struct expr*, struct expr*);
extern struct expr* expr_alloc_unary_op(int oper, 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); ...@@ -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 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 types_print_type(const struct dbg_type*, BOOL details);
extern BOOL print_types(void); extern BOOL print_types(void);
extern INT_PTR types_extract_as_integer(const struct dbg_lvalue*); extern dbg_lgint_t 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_longlong(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned);
extern void types_extract_as_address(const struct dbg_lvalue*, ADDRESS64*); 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_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); extern BOOL types_udt_find_element(struct dbg_lvalue* value, const char* name, ULONG *tmpbuf);
......
...@@ -35,12 +35,12 @@ struct expr ...@@ -35,12 +35,12 @@ struct expr
{ {
struct struct
{ {
INT_PTR value; dbg_lgint_t value;
} s_const; } s_const;
struct struct
{ {
UINT_PTR value; dbg_lguint_t value;
} u_const; } u_const;
struct struct
...@@ -62,7 +62,7 @@ struct expr ...@@ -62,7 +62,7 @@ struct expr
{ {
int unop_type; int unop_type;
struct expr* exp1; struct expr* exp1;
INT_PTR result; dbg_lgint_t result;
} unop; } unop;
struct struct
...@@ -70,7 +70,7 @@ struct expr ...@@ -70,7 +70,7 @@ struct expr
int binop_type; int binop_type;
struct expr* exp1; struct expr* exp1;
struct expr* exp2; struct expr* exp2;
INT_PTR result; dbg_lgint_t result;
} binop; } binop;
struct struct
...@@ -83,7 +83,7 @@ struct expr ...@@ -83,7 +83,7 @@ struct expr
{ {
struct expr* exp1; struct expr* exp1;
const char* element_name; const char* element_name;
ULONG result; ULONG /* FIXME */ result;
} structure; } structure;
struct struct
...@@ -91,7 +91,7 @@ struct expr ...@@ -91,7 +91,7 @@ struct expr
const char* funcname; const char* funcname;
int nargs; int nargs;
struct expr* arg[5]; struct expr* arg[5];
ULONG result; dbg_lguint_t result;
} call; } call;
} un; } un;
...@@ -163,7 +163,7 @@ struct expr* expr_alloc_symbol(const char* name) ...@@ -163,7 +163,7 @@ struct expr* expr_alloc_symbol(const char* name)
return ex; return ex;
} }
struct expr* expr_alloc_sconstant(INT_PTR value) struct expr* expr_alloc_sconstant(dbg_lgint_t value)
{ {
struct expr* ex; struct expr* ex;
...@@ -174,7 +174,7 @@ struct expr* expr_alloc_sconstant(INT_PTR value) ...@@ -174,7 +174,7 @@ struct expr* expr_alloc_sconstant(INT_PTR value)
return ex; return ex;
} }
struct expr* expr_alloc_uconstant(UINT_PTR value) struct expr* expr_alloc_uconstant(dbg_lguint_t value)
{ {
struct expr* ex; struct expr* ex;
...@@ -347,13 +347,13 @@ struct dbg_lvalue expr_eval(struct expr* exp) ...@@ -347,13 +347,13 @@ struct dbg_lvalue expr_eval(struct expr* exp)
break; break;
case EXPR_TYPE_U_CONST: case EXPR_TYPE_U_CONST:
rtn.cookie = DLV_HOST; rtn.cookie = DLV_HOST;
rtn.type.id = dbg_itype_unsigned_long_int; rtn.type.id = dbg_itype_lguint;
rtn.type.module = 0; rtn.type.module = 0;
rtn.addr.Offset = (ULONG_PTR)&exp->un.u_const.value; rtn.addr.Offset = (ULONG_PTR)&exp->un.u_const.value;
break; break;
case EXPR_TYPE_S_CONST: case EXPR_TYPE_S_CONST:
rtn.cookie = DLV_HOST; rtn.cookie = DLV_HOST;
rtn.type.id = dbg_itype_signed_long_int; rtn.type.id = dbg_itype_lgint;
rtn.type.module = 0; rtn.type.module = 0;
rtn.addr.Offset = (ULONG_PTR)&exp->un.s_const.value; rtn.addr.Offset = (ULONG_PTR)&exp->un.s_const.value;
break; break;
...@@ -476,7 +476,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) ...@@ -476,7 +476,7 @@ struct dbg_lvalue expr_eval(struct expr* exp)
exp2 = expr_eval(exp->un.binop.exp2); exp2 = expr_eval(exp->un.binop.exp2);
if (exp1.type.id == dbg_itype_none || exp2.type.id == dbg_itype_none) if (exp1.type.id == dbg_itype_none || exp2.type.id == dbg_itype_none)
RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); 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.type.module = 0;
rtn.addr.Offset = (ULONG_PTR)&exp->un.binop.result; rtn.addr.Offset = (ULONG_PTR)&exp->un.binop.result;
type1 = exp1.type; type1 = exp1.type;
...@@ -506,8 +506,8 @@ struct dbg_lvalue expr_eval(struct expr* exp) ...@@ -506,8 +506,8 @@ struct dbg_lvalue expr_eval(struct expr* exp)
types_get_info(&type2, TI_GET_LENGTH, &scale1); types_get_info(&type2, TI_GET_LENGTH, &scale1);
rtn.type = exp2.type; rtn.type = exp2.type;
} }
exp->un.binop.result = types_extract_as_integer(&exp1) * (DWORD)scale1 + exp->un.binop.result = types_extract_as_integer(&exp1) * (dbg_lguint_t)scale1 +
(DWORD)scale2 * types_extract_as_integer(&exp2); (dbg_lguint_t)scale2 * types_extract_as_integer(&exp2);
break; break;
case EXP_OP_SUB: case EXP_OP_SUB:
if (!types_get_info(&exp1.type, TI_GET_SYMTAG, &tag) || if (!types_get_info(&exp1.type, TI_GET_SYMTAG, &tag) ||
...@@ -538,8 +538,8 @@ struct dbg_lvalue expr_eval(struct expr* exp) ...@@ -538,8 +538,8 @@ struct dbg_lvalue expr_eval(struct expr* exp)
types_get_info(&type2, TI_GET_LENGTH, &scale1); types_get_info(&type2, TI_GET_LENGTH, &scale1);
rtn.type = exp2.type; rtn.type = exp2.type;
} }
exp->un.binop.result = (types_extract_as_integer(&exp1) * (DWORD)scale1 - exp->un.binop.result = (types_extract_as_integer(&exp1) * (dbg_lguint_t)scale1 -
types_extract_as_integer(&exp2) * (DWORD)scale2) / (DWORD)scale3; types_extract_as_integer(&exp2) * (dbg_lguint_t)scale2) / (dbg_lguint_t)scale3;
break; break;
case EXP_OP_SEG: case EXP_OP_SEG:
rtn.type.id = dbg_itype_segptr; rtn.type.id = dbg_itype_segptr;
...@@ -581,10 +581,10 @@ struct dbg_lvalue expr_eval(struct expr* exp) ...@@ -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)); exp->un.binop.result = (types_extract_as_integer(&exp1) != types_extract_as_integer(&exp2));
break; break;
case EXP_OP_SHL: 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; break;
case EXP_OP_SHR: 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; break;
case EXP_OP_MUL: case EXP_OP_MUL:
exp->un.binop.result = (types_extract_as_integer(&exp1) * types_extract_as_integer(&exp2)); 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) ...@@ -609,7 +609,7 @@ struct dbg_lvalue expr_eval(struct expr* exp)
exp1 = expr_eval(exp->un.unop.exp1); exp1 = expr_eval(exp->un.unop.exp1);
if (exp1.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); 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.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; rtn.type.module = 0;
switch (exp->un.unop.unop_type) switch (exp->un.unop.unop_type)
{ {
...@@ -687,10 +687,10 @@ BOOL expr_print(const struct expr* exp) ...@@ -687,10 +687,10 @@ BOOL expr_print(const struct expr* exp)
dbg_printf("$%s", exp->un.intvar.name); dbg_printf("$%s", exp->un.intvar.name);
break; break;
case EXPR_TYPE_U_CONST: case EXPR_TYPE_U_CONST:
dbg_printf("%Iu", exp->un.u_const.value); dbg_printf("%I64u", exp->un.u_const.value);
break; break;
case EXPR_TYPE_S_CONST: case EXPR_TYPE_S_CONST:
dbg_printf("%Id", exp->un.s_const.value); dbg_printf("%I64d", exp->un.s_const.value);
break; break;
case EXPR_TYPE_STRING: case EXPR_TYPE_STRING:
dbg_printf("\"%s\"", exp->un.string.str); dbg_printf("\"%s\"", exp->un.string.str);
......
...@@ -509,7 +509,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) ...@@ -509,7 +509,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format)
if (format != 0) if (format != 0)
{ {
unsigned size; unsigned size;
LONGLONG res = types_extract_as_longlong(lvalue, &size, NULL); dbg_lgint_t res = types_extract_as_longlong(lvalue, &size, NULL);
WCHAR wch; WCHAR wch;
switch (format) switch (format)
......
...@@ -52,10 +52,10 @@ BOOL types_get_real_type(struct dbg_type* type, DWORD* tag) ...@@ -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 * Given a lvalue, try to get an integral (or pointer/address) value
* out of it * out of it
*/ */
LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue, dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue* lvalue,
unsigned* psize, BOOL *issigned) unsigned* psize, BOOL *issigned)
{ {
LONGLONG rtn = 0; dbg_lgint_t rtn = 0;
DWORD tag, bt; DWORD tag, bt;
DWORD64 size; DWORD64 size;
struct dbg_type type = lvalue->type; struct dbg_type type = lvalue->type;
...@@ -136,7 +136,7 @@ LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue, ...@@ -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 * Given a lvalue, try to get an integral (or pointer/address) value
* out of it * 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); return types_extract_as_longlong(lvalue, NULL, NULL);
} }
...@@ -161,7 +161,7 @@ void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr) ...@@ -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) BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from)
{ {
LONGLONG val; dbg_lgint_t val;
DWORD64 size; DWORD64 size;
BOOL is_signed; BOOL is_signed;
...@@ -777,6 +777,24 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v ...@@ -777,6 +777,24 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v
switch (type->id) 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: case dbg_itype_unsigned_long_int:
switch (ti) 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