This serie revamps type management inside winedbg: - parsing of a type is done when input command is parsed (and no longer when it's executed). It allows to discriminate between identifier and type (as any C compiler would do) and act accordingly. - basic type (int, long...) are now searched inside data model - types can be prefixed by a module name (like struct ntdll!CONTEXT64) to force lookup of type inside that module (otherwise all modules are searched) - print command is extended to print the details of a type (p struct _CONTEXT64 will show details)
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winedbg/memory.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 16d322cd82c..aa5c32b42f2 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -500,7 +500,6 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) case btInt: case btLong: if (!memory_fetch_integer(lvalue, size, TRUE, &val_int)) return; - if (size == 1) goto print_char; dbg_print_hex(size, val_int); break; case btUInt: @@ -513,17 +512,18 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) dbg_printf("%f", val_real); break; case btChar: - case btWChar: - /* sometimes WCHAR is defined as btChar with size = 2, so discrimate - * Ansi/Unicode based on size, not on basetype - */ if (!memory_fetch_integer(lvalue, size, TRUE, &val_int)) return; - print_char: - if ((size == 1 && isprint((char)val_int)) || - (size == 2 && val_int < 127 && isprint((char)val_int))) + if (size == 1 && isprint((char)val_int)) dbg_printf("'%c'", (char)val_int); else - dbg_printf("%d", (int)val_int); + dbg_print_hex(size, val_int); + break; + case btWChar: + if (!memory_fetch_integer(lvalue, size, TRUE, &val_int)) return; + if (size == 2 && iswprint((WCHAR)val_int)) + dbg_printf("L'%lc'", (WCHAR)val_int); + else + dbg_print_hex(size, val_int); break; case btBool: if (!memory_fetch_integer(lvalue, size, TRUE, &val_int)) return; @@ -549,11 +549,11 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) char buffer[1024];
if (!val_ptr) dbg_printf("0x0"); - else if (((bt == btChar || bt == btInt) && size64 == 1) || (bt == btUInt && size64 == 2)) + else if ((bt == btChar && size64 == 1) || (bt == btWChar && size64 == 2)) { if (memory_get_string(dbg_curr_process, val_ptr, sub_lvalue.in_debuggee, - size64 == 2, buffer, sizeof(buffer))) - dbg_printf(""%s"", buffer); + bt == btWChar, buffer, sizeof(buffer))) + dbg_printf("%s"%s"", bt == btWChar ? "L" : "", buffer); else dbg_printf("*** invalid address %p ***", val_ptr); break;
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winedbg/types.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 899e7f472b2..0abd2320570 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -91,11 +91,15 @@ dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue* lvalue, switch (bt) { case btChar: + case btWChar: + case btBool: case btInt: + case btLong: if (!memory_fetch_integer(lvalue, (unsigned)size, s = TRUE, &rtn)) RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); break; case btUInt: + case btULong: if (!memory_fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn)) RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); break;
From: Eric Pouech eric.pouech@gmail.com
this will help mapping a name to a basic type
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winedbg/be_arm.c | 36 ++++++------- programs/winedbg/be_arm64.c | 68 ++++++++++++------------- programs/winedbg/be_i386.c | 68 ++++++++++++------------- programs/winedbg/be_x86_64.c | 98 +++++++++++++++++------------------ programs/winedbg/dbg.y | 34 ++++++------- programs/winedbg/debugger.h | 30 ++++++----- programs/winedbg/intvar.h | 22 ++++---- programs/winedbg/stack.c | 7 +-- programs/winedbg/types.c | 99 +++++++++++++++++++++++++++++------- 9 files changed, 266 insertions(+), 196 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index a9551a40337..a505697c9bb 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1722,24 +1722,24 @@ static void be_arm_print_segment_info(HANDLE hThread, const dbg_ctx_t *ctx)
static struct dbg_internal_var be_arm_ctx[] = { - {CV_ARM_R0 + 0, "r0", (void*)FIELD_OFFSET(CONTEXT, R0), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 1, "r1", (void*)FIELD_OFFSET(CONTEXT, R1), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 2, "r2", (void*)FIELD_OFFSET(CONTEXT, R2), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 3, "r3", (void*)FIELD_OFFSET(CONTEXT, R3), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 4, "r4", (void*)FIELD_OFFSET(CONTEXT, R4), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 5, "r5", (void*)FIELD_OFFSET(CONTEXT, R5), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 6, "r6", (void*)FIELD_OFFSET(CONTEXT, R6), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 7, "r7", (void*)FIELD_OFFSET(CONTEXT, R7), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 8, "r8", (void*)FIELD_OFFSET(CONTEXT, R8), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 9, "r9", (void*)FIELD_OFFSET(CONTEXT, R9), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 10, "r10", (void*)FIELD_OFFSET(CONTEXT, R10), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 11, "r11", (void*)FIELD_OFFSET(CONTEXT, R11), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 12, "r12", (void*)FIELD_OFFSET(CONTEXT, R12), dbg_itype_unsigned_int}, - {CV_ARM_SP, "sp", (void*)FIELD_OFFSET(CONTEXT, Sp), dbg_itype_unsigned_int}, - {CV_ARM_LR, "lr", (void*)FIELD_OFFSET(CONTEXT, Lr), dbg_itype_unsigned_int}, - {CV_ARM_PC, "pc", (void*)FIELD_OFFSET(CONTEXT, Pc), dbg_itype_unsigned_int}, - {CV_ARM_CPSR, "cpsr", (void*)FIELD_OFFSET(CONTEXT, Cpsr), dbg_itype_unsigned_int}, - {0, NULL, 0, dbg_itype_none} + {CV_ARM_R0 + 0, "r0", (void*)FIELD_OFFSET(CONTEXT, R0), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 1, "r1", (void*)FIELD_OFFSET(CONTEXT, R1), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 2, "r2", (void*)FIELD_OFFSET(CONTEXT, R2), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 3, "r3", (void*)FIELD_OFFSET(CONTEXT, R3), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 4, "r4", (void*)FIELD_OFFSET(CONTEXT, R4), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 5, "r5", (void*)FIELD_OFFSET(CONTEXT, R5), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 6, "r6", (void*)FIELD_OFFSET(CONTEXT, R6), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 7, "r7", (void*)FIELD_OFFSET(CONTEXT, R7), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 8, "r8", (void*)FIELD_OFFSET(CONTEXT, R8), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 9, "r9", (void*)FIELD_OFFSET(CONTEXT, R9), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 10, "r10", (void*)FIELD_OFFSET(CONTEXT, R10), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 11, "r11", (void*)FIELD_OFFSET(CONTEXT, R11), dbg_itype_unsigned_int32}, + {CV_ARM_R0 + 12, "r12", (void*)FIELD_OFFSET(CONTEXT, R12), dbg_itype_unsigned_int32}, + {CV_ARM_SP, "sp", (void*)FIELD_OFFSET(CONTEXT, Sp), dbg_itype_unsigned_int32}, + {CV_ARM_LR, "lr", (void*)FIELD_OFFSET(CONTEXT, Lr), dbg_itype_unsigned_int32}, + {CV_ARM_PC, "pc", (void*)FIELD_OFFSET(CONTEXT, Pc), dbg_itype_unsigned_int32}, + {CV_ARM_CPSR, "cpsr", (void*)FIELD_OFFSET(CONTEXT, Cpsr), dbg_itype_unsigned_int32}, + {0, NULL, 0, dbg_itype_none} };
static BOOL be_arm_is_step_over_insn(const void* insn) diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index ab64801e6db..d9e0a97bce5 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -104,40 +104,40 @@ static void be_arm64_print_segment_info(HANDLE hThread, const dbg_ctx_t *ctx)
static struct dbg_internal_var be_arm64_ctx[] = { - {CV_ARM64_PSTATE, "cpsr", (void*)FIELD_OFFSET(CONTEXT, Cpsr), dbg_itype_unsigned_int}, - {CV_ARM64_X0 + 0, "x0", (void*)FIELD_OFFSET(CONTEXT, u.s.X0), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 1, "x1", (void*)FIELD_OFFSET(CONTEXT, u.s.X1), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 2, "x2", (void*)FIELD_OFFSET(CONTEXT, u.s.X2), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 3, "x3", (void*)FIELD_OFFSET(CONTEXT, u.s.X3), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 4, "x4", (void*)FIELD_OFFSET(CONTEXT, u.s.X4), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 5, "x5", (void*)FIELD_OFFSET(CONTEXT, u.s.X5), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 6, "x6", (void*)FIELD_OFFSET(CONTEXT, u.s.X6), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 7, "x7", (void*)FIELD_OFFSET(CONTEXT, u.s.X7), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 8, "x8", (void*)FIELD_OFFSET(CONTEXT, u.s.X8), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 9, "x9", (void*)FIELD_OFFSET(CONTEXT, u.s.X9), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 10, "x10", (void*)FIELD_OFFSET(CONTEXT, u.s.X10), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 11, "x11", (void*)FIELD_OFFSET(CONTEXT, u.s.X11), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 12, "x12", (void*)FIELD_OFFSET(CONTEXT, u.s.X12), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 13, "x13", (void*)FIELD_OFFSET(CONTEXT, u.s.X13), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 14, "x14", (void*)FIELD_OFFSET(CONTEXT, u.s.X14), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 15, "x15", (void*)FIELD_OFFSET(CONTEXT, u.s.X15), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 16, "x16", (void*)FIELD_OFFSET(CONTEXT, u.s.X16), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 17, "x17", (void*)FIELD_OFFSET(CONTEXT, u.s.X17), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 18, "x18", (void*)FIELD_OFFSET(CONTEXT, u.s.X18), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 19, "x19", (void*)FIELD_OFFSET(CONTEXT, u.s.X19), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 20, "x20", (void*)FIELD_OFFSET(CONTEXT, u.s.X20), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 21, "x21", (void*)FIELD_OFFSET(CONTEXT, u.s.X21), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 22, "x22", (void*)FIELD_OFFSET(CONTEXT, u.s.X22), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 23, "x23", (void*)FIELD_OFFSET(CONTEXT, u.s.X23), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 24, "x24", (void*)FIELD_OFFSET(CONTEXT, u.s.X24), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 25, "x25", (void*)FIELD_OFFSET(CONTEXT, u.s.X25), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 26, "x26", (void*)FIELD_OFFSET(CONTEXT, u.s.X26), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 27, "x27", (void*)FIELD_OFFSET(CONTEXT, u.s.X27), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 28, "x28", (void*)FIELD_OFFSET(CONTEXT, u.s.X28), dbg_itype_unsigned_long_int}, - {CV_ARM64_FP, "fp", (void*)FIELD_OFFSET(CONTEXT, u.s.Fp), dbg_itype_unsigned_long_int}, - {CV_ARM64_LR, "lr", (void*)FIELD_OFFSET(CONTEXT, u.s.Lr), dbg_itype_unsigned_long_int}, - {CV_ARM64_SP, "sp", (void*)FIELD_OFFSET(CONTEXT, Sp), dbg_itype_unsigned_long_int}, - {CV_ARM64_PC, "pc", (void*)FIELD_OFFSET(CONTEXT, Pc), dbg_itype_unsigned_long_int}, + {CV_ARM64_PSTATE, "cpsr", (void*)FIELD_OFFSET(CONTEXT, Cpsr), dbg_itype_unsigned_int32}, + {CV_ARM64_X0 + 0, "x0", (void*)FIELD_OFFSET(CONTEXT, u.s.X0), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 1, "x1", (void*)FIELD_OFFSET(CONTEXT, u.s.X1), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 2, "x2", (void*)FIELD_OFFSET(CONTEXT, u.s.X2), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 3, "x3", (void*)FIELD_OFFSET(CONTEXT, u.s.X3), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 4, "x4", (void*)FIELD_OFFSET(CONTEXT, u.s.X4), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 5, "x5", (void*)FIELD_OFFSET(CONTEXT, u.s.X5), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 6, "x6", (void*)FIELD_OFFSET(CONTEXT, u.s.X6), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 7, "x7", (void*)FIELD_OFFSET(CONTEXT, u.s.X7), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 8, "x8", (void*)FIELD_OFFSET(CONTEXT, u.s.X8), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 9, "x9", (void*)FIELD_OFFSET(CONTEXT, u.s.X9), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 10, "x10", (void*)FIELD_OFFSET(CONTEXT, u.s.X10), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 11, "x11", (void*)FIELD_OFFSET(CONTEXT, u.s.X11), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 12, "x12", (void*)FIELD_OFFSET(CONTEXT, u.s.X12), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 13, "x13", (void*)FIELD_OFFSET(CONTEXT, u.s.X13), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 14, "x14", (void*)FIELD_OFFSET(CONTEXT, u.s.X14), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 15, "x15", (void*)FIELD_OFFSET(CONTEXT, u.s.X15), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 16, "x16", (void*)FIELD_OFFSET(CONTEXT, u.s.X16), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 17, "x17", (void*)FIELD_OFFSET(CONTEXT, u.s.X17), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 18, "x18", (void*)FIELD_OFFSET(CONTEXT, u.s.X18), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 19, "x19", (void*)FIELD_OFFSET(CONTEXT, u.s.X19), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 20, "x20", (void*)FIELD_OFFSET(CONTEXT, u.s.X20), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 21, "x21", (void*)FIELD_OFFSET(CONTEXT, u.s.X21), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 22, "x22", (void*)FIELD_OFFSET(CONTEXT, u.s.X22), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 23, "x23", (void*)FIELD_OFFSET(CONTEXT, u.s.X23), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 24, "x24", (void*)FIELD_OFFSET(CONTEXT, u.s.X24), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 25, "x25", (void*)FIELD_OFFSET(CONTEXT, u.s.X25), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 26, "x26", (void*)FIELD_OFFSET(CONTEXT, u.s.X26), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 27, "x27", (void*)FIELD_OFFSET(CONTEXT, u.s.X27), dbg_itype_unsigned_int64}, + {CV_ARM64_X0 + 28, "x28", (void*)FIELD_OFFSET(CONTEXT, u.s.X28), dbg_itype_unsigned_int64}, + {CV_ARM64_FP, "fp", (void*)FIELD_OFFSET(CONTEXT, u.s.Fp), dbg_itype_unsigned_int64}, + {CV_ARM64_LR, "lr", (void*)FIELD_OFFSET(CONTEXT, u.s.Lr), dbg_itype_unsigned_int64}, + {CV_ARM64_SP, "sp", (void*)FIELD_OFFSET(CONTEXT, Sp), dbg_itype_unsigned_int64}, + {CV_ARM64_PC, "pc", (void*)FIELD_OFFSET(CONTEXT, Pc), dbg_itype_unsigned_int64}, {0, NULL, 0, dbg_itype_none} };
diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index ab86f9ec647..eae009c2e4a 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -277,40 +277,40 @@ static void be_i386_print_segment_info(HANDLE hThread, const dbg_ctx_t *ctx)
static struct dbg_internal_var be_i386_ctx[] = { - {CV_REG_AL, "AL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_char_int}, - {CV_REG_CL, "CL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_char_int}, - {CV_REG_DL, "DL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_char_int}, - {CV_REG_BL, "BL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_char_int}, - {CV_REG_AH, "AH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Eax)+1), dbg_itype_unsigned_char_int}, - {CV_REG_CH, "CH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Ecx)+1), dbg_itype_unsigned_char_int}, - {CV_REG_DH, "DH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Edx)+1), dbg_itype_unsigned_char_int}, - {CV_REG_BH, "BH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Ebx)+1), dbg_itype_unsigned_char_int}, - {CV_REG_AX, "AX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_short_int}, - {CV_REG_CX, "CX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_short_int}, - {CV_REG_DX, "DX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_short_int}, - {CV_REG_BX, "BX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_short_int}, - {CV_REG_SP, "SP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esp), dbg_itype_unsigned_short_int}, - {CV_REG_BP, "BP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebp), dbg_itype_unsigned_short_int}, - {CV_REG_SI, "SI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esi), dbg_itype_unsigned_short_int}, - {CV_REG_DI, "DI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edi), dbg_itype_unsigned_short_int}, - {CV_REG_EAX, "EAX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_int}, - {CV_REG_ECX, "ECX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_int}, - {CV_REG_EDX, "EDX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_int}, - {CV_REG_EBX, "EBX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_int}, - {CV_REG_ESP, "ESP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esp), dbg_itype_unsigned_int}, - {CV_REG_EBP, "EBP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebp), dbg_itype_unsigned_int}, - {CV_REG_ESI, "ESI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esi), dbg_itype_unsigned_int}, - {CV_REG_EDI, "EDI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edi), dbg_itype_unsigned_int}, - {CV_REG_ES, "ES", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegEs), dbg_itype_unsigned_short_int}, - {CV_REG_CS, "CS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegCs), dbg_itype_unsigned_short_int}, - {CV_REG_SS, "SS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegSs), dbg_itype_unsigned_short_int}, - {CV_REG_DS, "DS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegDs), dbg_itype_unsigned_short_int}, - {CV_REG_FS, "FS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegFs), dbg_itype_unsigned_short_int}, - {CV_REG_GS, "GS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegGs), dbg_itype_unsigned_short_int}, - {CV_REG_IP, "IP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eip), dbg_itype_unsigned_short_int}, - {CV_REG_FLAGS, "FLAGS", (void*)FIELD_OFFSET(WOW64_CONTEXT, EFlags), dbg_itype_unsigned_short_int}, - {CV_REG_EIP, "EIP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eip), dbg_itype_unsigned_int}, - {CV_REG_EFLAGS, "EFLAGS", (void*)FIELD_OFFSET(WOW64_CONTEXT, EFlags), dbg_itype_unsigned_int}, + {CV_REG_AL, "AL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_int8}, + {CV_REG_CL, "CL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_int8}, + {CV_REG_DL, "DL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_int8}, + {CV_REG_BL, "BL", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_int8}, + {CV_REG_AH, "AH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Eax)+1), dbg_itype_unsigned_int8}, + {CV_REG_CH, "CH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Ecx)+1), dbg_itype_unsigned_int8}, + {CV_REG_DH, "DH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Edx)+1), dbg_itype_unsigned_int8}, + {CV_REG_BH, "BH", (void*)(FIELD_OFFSET(WOW64_CONTEXT, Ebx)+1), dbg_itype_unsigned_int8}, + {CV_REG_AX, "AX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_int16}, + {CV_REG_CX, "CX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_int16}, + {CV_REG_DX, "DX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_int16}, + {CV_REG_BX, "BX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_int16}, + {CV_REG_SP, "SP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esp), dbg_itype_unsigned_int16}, + {CV_REG_BP, "BP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebp), dbg_itype_unsigned_int16}, + {CV_REG_SI, "SI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esi), dbg_itype_unsigned_int16}, + {CV_REG_DI, "DI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edi), dbg_itype_unsigned_int16}, + {CV_REG_EAX, "EAX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_int32}, + {CV_REG_ECX, "ECX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_int32}, + {CV_REG_EDX, "EDX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_int32}, + {CV_REG_EBX, "EBX", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_int32}, + {CV_REG_ESP, "ESP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esp), dbg_itype_unsigned_int32}, + {CV_REG_EBP, "EBP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Ebp), dbg_itype_unsigned_int32}, + {CV_REG_ESI, "ESI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Esi), dbg_itype_unsigned_int32}, + {CV_REG_EDI, "EDI", (void*)FIELD_OFFSET(WOW64_CONTEXT, Edi), dbg_itype_unsigned_int32}, + {CV_REG_ES, "ES", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegEs), dbg_itype_unsigned_int16}, + {CV_REG_CS, "CS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegCs), dbg_itype_unsigned_int16}, + {CV_REG_SS, "SS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegSs), dbg_itype_unsigned_int16}, + {CV_REG_DS, "DS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegDs), dbg_itype_unsigned_int16}, + {CV_REG_FS, "FS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegFs), dbg_itype_unsigned_int16}, + {CV_REG_GS, "GS", (void*)FIELD_OFFSET(WOW64_CONTEXT, SegGs), dbg_itype_unsigned_int16}, + {CV_REG_IP, "IP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eip), dbg_itype_unsigned_int16}, + {CV_REG_FLAGS, "FLAGS", (void*)FIELD_OFFSET(WOW64_CONTEXT, EFlags), dbg_itype_unsigned_int16}, + {CV_REG_EIP, "EIP", (void*)FIELD_OFFSET(WOW64_CONTEXT, Eip), dbg_itype_unsigned_int32}, + {CV_REG_EFLAGS, "EFLAGS", (void*)FIELD_OFFSET(WOW64_CONTEXT, EFlags), dbg_itype_unsigned_int32}, {CV_REG_ST0, "ST0", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), dbg_itype_long_real}, {CV_REG_ST0+1, "ST1", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), dbg_itype_long_real}, {CV_REG_ST0+2, "ST2", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), dbg_itype_long_real}, diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index a01bbf86575..b110e624b1f 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -179,55 +179,55 @@ static void be_x86_64_print_segment_info(HANDLE hThread, const dbg_ctx_t *ctx)
static struct dbg_internal_var be_x86_64_ctx[] = { - {CV_AMD64_AL, "AL", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_char_int}, - {CV_AMD64_BL, "BL", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_char_int}, - {CV_AMD64_CL, "CL", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_char_int}, - {CV_AMD64_DL, "DL", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_char_int}, - {CV_AMD64_AH, "AH", (void*)(FIELD_OFFSET(CONTEXT, Rax)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_BH, "BH", (void*)(FIELD_OFFSET(CONTEXT, Rbx)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_CH, "CH", (void*)(FIELD_OFFSET(CONTEXT, Rcx)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_DH, "DH", (void*)(FIELD_OFFSET(CONTEXT, Rdx)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_AX, "AX", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_short_int}, - {CV_AMD64_BX, "BX", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_short_int}, - {CV_AMD64_CX, "CX", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_short_int}, - {CV_AMD64_DX, "DX", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_short_int}, - {CV_AMD64_SP, "SP", (void*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_short_int}, - {CV_AMD64_BP, "BP", (void*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_short_int}, - {CV_AMD64_SI, "SI", (void*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_short_int}, - {CV_AMD64_DI, "DI", (void*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_short_int}, - {CV_AMD64_EAX, "EAX", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_int}, - {CV_AMD64_EBX, "EBX", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_int}, - {CV_AMD64_ECX, "ECX", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_int}, - {CV_AMD64_EDX, "EDX", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_int}, - {CV_AMD64_ESP, "ESP", (void*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_int}, - {CV_AMD64_EBP, "EBP", (void*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_int}, - {CV_AMD64_ESI, "ESI", (void*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_int}, - {CV_AMD64_EDI, "EDI", (void*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_int}, - {CV_AMD64_ES, "ES", (void*)FIELD_OFFSET(CONTEXT, SegEs), dbg_itype_unsigned_short_int}, - {CV_AMD64_CS, "CS", (void*)FIELD_OFFSET(CONTEXT, SegCs), dbg_itype_unsigned_short_int}, - {CV_AMD64_SS, "SS", (void*)FIELD_OFFSET(CONTEXT, SegSs), dbg_itype_unsigned_short_int}, - {CV_AMD64_DS, "DS", (void*)FIELD_OFFSET(CONTEXT, SegDs), dbg_itype_unsigned_short_int}, - {CV_AMD64_FS, "FS", (void*)FIELD_OFFSET(CONTEXT, SegFs), dbg_itype_unsigned_short_int}, - {CV_AMD64_GS, "GS", (void*)FIELD_OFFSET(CONTEXT, SegGs), dbg_itype_unsigned_short_int}, - {CV_AMD64_FLAGS, "FLAGS", (void*)FIELD_OFFSET(CONTEXT, EFlags), dbg_itype_unsigned_short_int}, - {CV_AMD64_EFLAGS, "EFLAGS", (void*)FIELD_OFFSET(CONTEXT, EFlags), dbg_itype_unsigned_int}, - {CV_AMD64_RIP, "RIP", (void*)FIELD_OFFSET(CONTEXT, Rip), dbg_itype_unsigned_long_int}, - {CV_AMD64_RAX, "RAX", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_long_int}, - {CV_AMD64_RBX, "RBX", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_long_int}, - {CV_AMD64_RCX, "RCX", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_long_int}, - {CV_AMD64_RDX, "RDX", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_long_int}, - {CV_AMD64_RSP, "RSP", (void*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_long_int}, - {CV_AMD64_RBP, "RBP", (void*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_long_int}, - {CV_AMD64_RSI, "RSI", (void*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_long_int}, - {CV_AMD64_RDI, "RDI", (void*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_long_int}, - {CV_AMD64_R8, "R8", (void*)FIELD_OFFSET(CONTEXT, R8), dbg_itype_unsigned_long_int}, - {CV_AMD64_R9, "R9", (void*)FIELD_OFFSET(CONTEXT, R9), dbg_itype_unsigned_long_int}, - {CV_AMD64_R10, "R10", (void*)FIELD_OFFSET(CONTEXT, R10), dbg_itype_unsigned_long_int}, - {CV_AMD64_R11, "R11", (void*)FIELD_OFFSET(CONTEXT, R11), dbg_itype_unsigned_long_int}, - {CV_AMD64_R12, "R12", (void*)FIELD_OFFSET(CONTEXT, R12), dbg_itype_unsigned_long_int}, - {CV_AMD64_R13, "R13", (void*)FIELD_OFFSET(CONTEXT, R13), dbg_itype_unsigned_long_int}, - {CV_AMD64_R14, "R14", (void*)FIELD_OFFSET(CONTEXT, R14), dbg_itype_unsigned_long_int}, - {CV_AMD64_R15, "R15", (void*)FIELD_OFFSET(CONTEXT, R15), dbg_itype_unsigned_long_int}, + {CV_AMD64_AL, "AL", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_int8}, + {CV_AMD64_BL, "BL", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_int8}, + {CV_AMD64_CL, "CL", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_int8}, + {CV_AMD64_DL, "DL", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_int8}, + {CV_AMD64_AH, "AH", (void*)(FIELD_OFFSET(CONTEXT, Rax)+1), dbg_itype_unsigned_int8}, + {CV_AMD64_BH, "BH", (void*)(FIELD_OFFSET(CONTEXT, Rbx)+1), dbg_itype_unsigned_int8}, + {CV_AMD64_CH, "CH", (void*)(FIELD_OFFSET(CONTEXT, Rcx)+1), dbg_itype_unsigned_int8}, + {CV_AMD64_DH, "DH", (void*)(FIELD_OFFSET(CONTEXT, Rdx)+1), dbg_itype_unsigned_int8}, + {CV_AMD64_AX, "AX", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_int16}, + {CV_AMD64_BX, "BX", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_int16}, + {CV_AMD64_CX, "CX", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_int16}, + {CV_AMD64_DX, "DX", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_int16}, + {CV_AMD64_SP, "SP", (void*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_int16}, + {CV_AMD64_BP, "BP", (void*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_int16}, + {CV_AMD64_SI, "SI", (void*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_int16}, + {CV_AMD64_DI, "DI", (void*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_int16}, + {CV_AMD64_EAX, "EAX", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_int32}, + {CV_AMD64_EBX, "EBX", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_int32}, + {CV_AMD64_ECX, "ECX", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_int32}, + {CV_AMD64_EDX, "EDX", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_int32}, + {CV_AMD64_ESP, "ESP", (void*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_int32}, + {CV_AMD64_EBP, "EBP", (void*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_int32}, + {CV_AMD64_ESI, "ESI", (void*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_int32}, + {CV_AMD64_EDI, "EDI", (void*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_int32}, + {CV_AMD64_ES, "ES", (void*)FIELD_OFFSET(CONTEXT, SegEs), dbg_itype_unsigned_int16}, + {CV_AMD64_CS, "CS", (void*)FIELD_OFFSET(CONTEXT, SegCs), dbg_itype_unsigned_int16}, + {CV_AMD64_SS, "SS", (void*)FIELD_OFFSET(CONTEXT, SegSs), dbg_itype_unsigned_int16}, + {CV_AMD64_DS, "DS", (void*)FIELD_OFFSET(CONTEXT, SegDs), dbg_itype_unsigned_int16}, + {CV_AMD64_FS, "FS", (void*)FIELD_OFFSET(CONTEXT, SegFs), dbg_itype_unsigned_int16}, + {CV_AMD64_GS, "GS", (void*)FIELD_OFFSET(CONTEXT, SegGs), dbg_itype_unsigned_int16}, + {CV_AMD64_FLAGS, "FLAGS", (void*)FIELD_OFFSET(CONTEXT, EFlags), dbg_itype_unsigned_int16}, + {CV_AMD64_EFLAGS, "EFLAGS", (void*)FIELD_OFFSET(CONTEXT, EFlags), dbg_itype_unsigned_int32}, + {CV_AMD64_RIP, "RIP", (void*)FIELD_OFFSET(CONTEXT, Rip), dbg_itype_unsigned_int64}, + {CV_AMD64_RAX, "RAX", (void*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_int64}, + {CV_AMD64_RBX, "RBX", (void*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_int64}, + {CV_AMD64_RCX, "RCX", (void*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_int64}, + {CV_AMD64_RDX, "RDX", (void*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_int64}, + {CV_AMD64_RSP, "RSP", (void*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_int64}, + {CV_AMD64_RBP, "RBP", (void*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_int64}, + {CV_AMD64_RSI, "RSI", (void*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_int64}, + {CV_AMD64_RDI, "RDI", (void*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_int64}, + {CV_AMD64_R8, "R8", (void*)FIELD_OFFSET(CONTEXT, R8), dbg_itype_unsigned_int64}, + {CV_AMD64_R9, "R9", (void*)FIELD_OFFSET(CONTEXT, R9), dbg_itype_unsigned_int64}, + {CV_AMD64_R10, "R10", (void*)FIELD_OFFSET(CONTEXT, R10), dbg_itype_unsigned_int64}, + {CV_AMD64_R11, "R11", (void*)FIELD_OFFSET(CONTEXT, R11), dbg_itype_unsigned_int64}, + {CV_AMD64_R12, "R12", (void*)FIELD_OFFSET(CONTEXT, R12), dbg_itype_unsigned_int64}, + {CV_AMD64_R13, "R13", (void*)FIELD_OFFSET(CONTEXT, R13), dbg_itype_unsigned_int64}, + {CV_AMD64_R14, "R14", (void*)FIELD_OFFSET(CONTEXT, R14), dbg_itype_unsigned_int64}, + {CV_AMD64_R15, "R15", (void*)FIELD_OFFSET(CONTEXT, R15), dbg_itype_unsigned_int64}, {CV_AMD64_ST0, "ST0", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[0]), dbg_itype_long_real}, {CV_AMD64_ST0+1, "ST1", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[1]), dbg_itype_long_real}, {CV_AMD64_ST0+2, "ST2", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[2]), dbg_itype_long_real}, diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index ad21e3b81c5..1ce46bee0f8 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -306,23 +306,23 @@ noprocess_state:
type_expr: tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_char; } - | tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int; } - | tLONG tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_long_int; } - | tLONG { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_long_int; } - | tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int; } - | tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int; } - | tLONG tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_long_int; } - | tLONG tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_long_int; } - | tSHORT tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_short_int; } - | tSHORT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_short_int; } - | tSHORT tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_short_int; } - | tSHORT tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_short_int; } - | tSIGNED tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_char_int; } - | tUNSIGNED tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_char_int; } - | tLONG tLONG tUNSIGNED tINT{ $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_longlong_int; } - | tLONG tLONG tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_longlong_int; } - | tLONG tLONG tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_longlong_int; } - | tLONG tLONG { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_longlong_int; } + | tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int32; } + | tLONG tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_signed_long32 : dbg_itype_signed_long64; } + | tLONG { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_signed_long32 : dbg_itype_signed_long64; } + | tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int32; } + | tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int32; } + | tLONG tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_unsigned_long32 : dbg_itype_unsigned_long64; } + | tLONG tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_unsigned_long32 : dbg_itype_unsigned_long64; } + | tSHORT tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int16; } + | tSHORT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int16; } + | tSHORT tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int16; } + | tSHORT tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int16; } + | tSIGNED tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int8; } + | tUNSIGNED tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int8; } + | tLONG tLONG tUNSIGNED tINT{ $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int64; } + | tLONG tLONG tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int64; } + | tLONG tLONG tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int64; } + | tLONG tLONG { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int64; } | tFLOAT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_short_real; } | tDOUBLE { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_real; } | tLONG tDOUBLE { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_long_real; } diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index ac13a28e3ca..f8f65035d48 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -68,23 +68,29 @@ enum dbg_line_status enum dbg_internal_types { dbg_itype_first = 0xffffff00, - dbg_itype_unsigned_int, - dbg_itype_signed_int, - dbg_itype_signed_char_int, - dbg_itype_unsigned_char_int, - dbg_itype_unsigned_short_int, - dbg_itype_signed_short_int, - dbg_itype_unsigned_long_int, - dbg_itype_signed_long_int, - dbg_itype_unsigned_longlong_int, - dbg_itype_signed_longlong_int, + dbg_itype_char, + dbg_itype_wchar, + + dbg_itype_unsigned_int8, + dbg_itype_signed_int8, + dbg_itype_unsigned_int16, + dbg_itype_signed_int16, + dbg_itype_unsigned_int32, + dbg_itype_signed_int32, + dbg_itype_unsigned_int64, + dbg_itype_signed_int64, + dbg_itype_unsigned_int128, + dbg_itype_signed_int128, + + dbg_itype_unsigned_long32, + dbg_itype_signed_long32, + dbg_itype_unsigned_long64, + dbg_itype_signed_long64,
/* 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 */ dbg_itype_real, /* aka double */ dbg_itype_long_real, /* aka long double */ diff --git a/programs/winedbg/intvar.h b/programs/winedbg/intvar.h index 4d1a80d095f..db117c96561 100644 --- a/programs/winedbg/intvar.h +++ b/programs/winedbg/intvar.h @@ -20,22 +20,22 @@ */
/* break handling */ -INTERNAL_VAR(BreakAllThreadsStartup, FALSE, NULL, dbg_itype_unsigned_int) -INTERNAL_VAR(BreakOnCritSectTimeOut, FALSE, NULL, dbg_itype_unsigned_int) -INTERNAL_VAR(BreakOnAttach, FALSE, NULL, dbg_itype_unsigned_int) -INTERNAL_VAR(BreakOnFirstChance, FALSE, NULL, dbg_itype_unsigned_int) -INTERNAL_VAR(BreakOnDllLoad, FALSE, NULL, dbg_itype_unsigned_int) -INTERNAL_VAR(CanDeferOnBPByAddr, FALSE, NULL, dbg_itype_unsigned_int) +INTERNAL_VAR(BreakAllThreadsStartup, FALSE, NULL, dbg_itype_unsigned_int32) +INTERNAL_VAR(BreakOnCritSectTimeOut, FALSE, NULL, dbg_itype_unsigned_int32) +INTERNAL_VAR(BreakOnAttach, FALSE, NULL, dbg_itype_unsigned_int32) +INTERNAL_VAR(BreakOnFirstChance, FALSE, NULL, dbg_itype_unsigned_int32) +INTERNAL_VAR(BreakOnDllLoad, FALSE, NULL, dbg_itype_unsigned_int32) +INTERNAL_VAR(CanDeferOnBPByAddr, FALSE, NULL, dbg_itype_unsigned_int32)
/* current process/thread */ -INTERNAL_VAR(ThreadId, FALSE, &dbg_curr_tid, dbg_itype_unsigned_int) -INTERNAL_VAR(ProcessId, FALSE, &dbg_curr_pid, dbg_itype_unsigned_int) +INTERNAL_VAR(ThreadId, FALSE, &dbg_curr_tid, dbg_itype_unsigned_int32) +INTERNAL_VAR(ProcessId, FALSE, &dbg_curr_pid, dbg_itype_unsigned_int32)
/* symbol manipulation */ -INTERNAL_VAR(AlwaysShowThunks, FALSE, NULL, dbg_itype_unsigned_int) +INTERNAL_VAR(AlwaysShowThunks, FALSE, NULL, dbg_itype_unsigned_int32)
/* process manipulation */ -INTERNAL_VAR(AlsoDebugProcChild, FALSE, NULL, dbg_itype_unsigned_int) +INTERNAL_VAR(AlsoDebugProcChild, FALSE, NULL, dbg_itype_unsigned_int32)
/* automatic invocation on failure */ -INTERNAL_VAR(ShowCrashDialog, TRUE, NULL, dbg_itype_unsigned_int) +INTERNAL_VAR(ShowCrashDialog, TRUE, NULL, dbg_itype_unsigned_int32) diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index ba246889a55..50932e14ddd 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -108,6 +108,7 @@ BOOL stack_get_register_frame(const struct dbg_internal_var* div, struct dbg_lva else { enum be_cpu_addr kind; + DWORD itype = ADDRSIZE == 4 ? dbg_itype_unsigned_long32 : dbg_itype_unsigned_long64;
if (!dbg_curr_process->be_cpu->get_register_info(div->val, &kind)) return FALSE;
@@ -115,13 +116,13 @@ BOOL stack_get_register_frame(const struct dbg_internal_var* div, struct dbg_lva switch (kind) { case be_cpu_addr_pc: - init_lvalue_in_debugger(lvalue, dbg_itype_unsigned_long_int, &currfrm->linear_pc); + init_lvalue_in_debugger(lvalue, itype, &currfrm->linear_pc); break; case be_cpu_addr_stack: - init_lvalue_in_debugger(lvalue, dbg_itype_unsigned_long_int, &currfrm->linear_stack); + init_lvalue_in_debugger(lvalue, itype, &currfrm->linear_stack); break; case be_cpu_addr_frame: - init_lvalue_in_debugger(lvalue, dbg_itype_unsigned_long_int, &currfrm->linear_frame); + init_lvalue_in_debugger(lvalue, itype, &currfrm->linear_frame); break; } } diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 0abd2320570..e87af4c3211 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -894,76 +894,130 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v default: WINE_FIXME("unsupported %u for lgint_t\n", ti); return FALSE; } break; - case dbg_itype_unsigned_long_int: + case dbg_itype_unsigned_long32: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = ADDRSIZE; break; + case TI_GET_LENGTH: X(DWORD64) = 4; break; case TI_GET_BASETYPE: X(DWORD) = btUInt; break; default: WINE_FIXME("unsupported %u for u-long int\n", ti); return FALSE; } break; - case dbg_itype_signed_long_int: + case dbg_itype_signed_long32: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = ADDRSIZE; break; + case TI_GET_LENGTH: X(DWORD64) = 4; break; case TI_GET_BASETYPE: X(DWORD) = btInt; break; default: WINE_FIXME("unsupported %u for s-long int\n", ti); return FALSE; } break; - case dbg_itype_unsigned_int: + case dbg_itype_unsigned_long64: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 4; break; + case TI_GET_LENGTH: X(DWORD64) = 8; break; + case TI_GET_BASETYPE: X(DWORD) = btUInt; break; + default: WINE_FIXME("unsupported %u for u-long int\n", ti); return FALSE; + } + break; + case dbg_itype_signed_long64: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = 8; break; + case TI_GET_BASETYPE: X(DWORD) = btInt; break; + default: WINE_FIXME("unsupported %u for s-long int\n", ti); return FALSE; + } + break; + case dbg_itype_unsigned_int8: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = 1; break; case TI_GET_BASETYPE: X(DWORD) = btUInt; break; default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; } break; - case dbg_itype_signed_int: + case dbg_itype_signed_int8: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 4; break; + case TI_GET_LENGTH: X(DWORD64) = 1; break; case TI_GET_BASETYPE: X(DWORD) = btInt; break; default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; } break; - case dbg_itype_unsigned_short_int: + case dbg_itype_unsigned_int16: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; case TI_GET_LENGTH: X(DWORD64) = 2; break; case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-short int\n", ti); return FALSE; + default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; } break; - case dbg_itype_signed_short_int: + case dbg_itype_signed_int16: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; case TI_GET_LENGTH: X(DWORD64) = 2; break; case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-short int\n", ti); return FALSE; + default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; } break; - case dbg_itype_unsigned_char_int: + case dbg_itype_unsigned_int32: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 1; break; + case TI_GET_LENGTH: X(DWORD64) = 4; break; case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-char int\n", ti); return FALSE; + default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; } break; - case dbg_itype_signed_char_int: + case dbg_itype_signed_int32: switch (ti) { case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 1; break; + case TI_GET_LENGTH: X(DWORD64) = 4; break; case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-char int\n", ti); return FALSE; + default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; + } + break; + case dbg_itype_unsigned_int64: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = 8; break; + case TI_GET_BASETYPE: X(DWORD) = btUInt; break; + default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; + } + break; + case dbg_itype_signed_int64: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = 8; break; + case TI_GET_BASETYPE: X(DWORD) = btInt; break; + default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; + } + break; + case dbg_itype_unsigned_int128: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = 16; break; + case TI_GET_BASETYPE: X(DWORD) = btUInt; break; + default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; + } + break; + case dbg_itype_signed_int128: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = 16; break; + case TI_GET_BASETYPE: X(DWORD) = btInt; break; + default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; } break; case dbg_itype_char: @@ -975,6 +1029,15 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v default: WINE_FIXME("unsupported %u for char int\n", ti); return FALSE; } break; + case dbg_itype_wchar: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = 2; break; + case TI_GET_BASETYPE: X(DWORD) = btWChar; break; + default: WINE_FIXME("unsupported %u for char int\n", ti); return FALSE; + } + break; case dbg_itype_astring: switch (ti) {
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winedbg/dbg.y | 64 +++-- programs/winedbg/debug.l | 32 ++- programs/winedbg/debugger.h | 36 ++- programs/winedbg/types.c | 513 +++++++++++++++++------------------- 4 files changed, 329 insertions(+), 316 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 1ce46bee0f8..748d16e96c5 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -60,7 +60,8 @@ static void parser(const char*); %token tSYMBOLFILE tRUN tATTACH tDETACH tKILL tMAINTENANCE tTYPE tMINIDUMP %token tNOPROCESS
-%token tCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED +/* can be prefixed by module name */ +%token <string> tVOID tCHAR tWCHAR tSHORT tINT tLONG tFLOAT tDOUBLE tUNSIGNED tSIGNED %token tSTRUCT tUNION tENUM
/* %left ',' */ @@ -305,27 +306,46 @@ noprocess_state: ;
type_expr: - tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_char; } - | tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int32; } - | tLONG tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_signed_long32 : dbg_itype_signed_long64; } - | tLONG { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_signed_long32 : dbg_itype_signed_long64; } - | tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int32; } - | tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int32; } - | tLONG tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_unsigned_long32 : dbg_itype_unsigned_long64; } - | tLONG tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = ADDRSIZE == 4 ? dbg_itype_unsigned_long32 : dbg_itype_unsigned_long64; } - | tSHORT tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int16; } - | tSHORT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int16; } - | tSHORT tUNSIGNED tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int16; } - | tSHORT tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int16; } - | tSIGNED tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int8; } - | tUNSIGNED tCHAR { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int8; } - | tLONG tLONG tUNSIGNED tINT{ $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int64; } - | tLONG tLONG tUNSIGNED { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_unsigned_int64; } - | tLONG tLONG tINT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int64; } - | tLONG tLONG { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_signed_int64; } - | tFLOAT { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_short_real; } - | tDOUBLE { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_real; } - | tLONG tDOUBLE { $$.type = type_expr_type_id; $$.deref_count = 0; $$.u.type.module = 0; $$.u.type.id = dbg_itype_long_real; } + tVOID { if (!types_find_basic(L"void", $1, &$$)) YYERROR; } + | tCHAR { if (!types_find_basic(L"char", $1, &$$)) YYERROR; } + | tWCHAR { if (!types_find_basic(L"WCHAR", $1, &$$)) YYERROR; } + | tSIGNED tCHAR { if (!types_find_basic(L"signed char", $1, &$$)) YYERROR; } + | tUNSIGNED tCHAR { if (!types_find_basic(L"unsigned char", $1, &$$)) YYERROR; } + | tSHORT tINT { if (!types_find_basic(L"short int", $1, &$$)) YYERROR; } + | tSHORT { if (!types_find_basic(L"short int", $1, &$$)) YYERROR; } + | tSIGNED tSHORT tINT { if (!types_find_basic(L"short int", $1, &$$)) YYERROR; } + | tSIGNED tSHORT { if (!types_find_basic(L"short int", $1, &$$)) YYERROR; } + | tSHORT tSIGNED tINT { if (!types_find_basic(L"short int", $1, &$$)) YYERROR; } + | tSHORT tSIGNED { if (!types_find_basic(L"short int", $1, &$$)) YYERROR; } + | tSHORT tUNSIGNED { if (!types_find_basic(L"unsigned short int", $1, &$$)) YYERROR; } + | tSHORT tUNSIGNED tINT { if (!types_find_basic(L"unsigned short int", $1, &$$)) YYERROR; } + | tUNSIGNED tSHORT { if (!types_find_basic(L"unsigned short int", $1, &$$)) YYERROR; } + | tUNSIGNED tSHORT tINT { if (!types_find_basic(L"unsigned short int", $1, &$$)) YYERROR; } + | tINT { if (!types_find_basic(L"int", $1, &$$)) YYERROR; } + | tSIGNED tINT { if (!types_find_basic(L"int", $1, &$$)) YYERROR; } + | tUNSIGNED { if (!types_find_basic(L"unsigned int", $1, &$$)) YYERROR; } + | tUNSIGNED tINT { if (!types_find_basic(L"unsigned int", $1, &$$)) YYERROR; } + | tLONG { if (!types_find_basic(L"long int", $1, &$$)) YYERROR; } + | tLONG tINT { if (!types_find_basic(L"long int", $1, &$$)) YYERROR; } + | tSIGNED tLONG { if (!types_find_basic(L"long int", $1, &$$)) YYERROR; } + | tSIGNED tLONG tINT { if (!types_find_basic(L"long int", $1, &$$)) YYERROR; } + | tLONG tSIGNED { if (!types_find_basic(L"long int", $1, &$$)) YYERROR; } + | tLONG tSIGNED tINT { if (!types_find_basic(L"long int", $1, &$$)) YYERROR; } + | tLONG tUNSIGNED { if (!types_find_basic(L"unsigned long int", $1, &$$)) YYERROR; } + | tLONG tUNSIGNED tINT { if (!types_find_basic(L"unsigned long int", $1, &$$)) YYERROR; } + | tUNSIGNED tLONG { if (!types_find_basic(L"unsigned long int", $1, &$$)) YYERROR; } + | tUNSIGNED tLONG tINT { if (!types_find_basic(L"unsigned long int", $1, &$$)) YYERROR; } + | tLONG tLONG { if (!types_find_basic(L"long long int", $1, &$$)) YYERROR; } + | tLONG tLONG tINT { if (!types_find_basic(L"long long int", $1, &$$)) YYERROR; } + | tSIGNED tLONG tLONG { if (!types_find_basic(L"long long int", $1, &$$)) YYERROR; } + | tSIGNED tLONG tLONG tINT { if (!types_find_basic(L"long long int", $1, &$$)) YYERROR; } + | tUNSIGNED tLONG tLONG { if (!types_find_basic(L"unsigned long long int", $1, &$$)) YYERROR; } + | tUNSIGNED tLONG tLONG tINT{ if (!types_find_basic(L"unsigned long long int", $1, &$$)) YYERROR; } + | tLONG tLONG tUNSIGNED { if (!types_find_basic(L"unsigned long long int", $1, &$$)) YYERROR; } + | tLONG tLONG tUNSIGNED tINT{ if (!types_find_basic(L"unsigned long long int", $1, &$$)) YYERROR; } + | tFLOAT { if (!types_find_basic(L"float", $1, &$$)) YYERROR; } + | tDOUBLE { if (!types_find_basic(L"double", $1, &$$)) YYERROR; } + | tLONG tDOUBLE { if (!types_find_basic(L"long double", $1, &$$)) YYERROR; } | type_expr '*' { $$ = $1; $$.deref_count++; } | tCLASS identifier { $$.type = type_expr_udt_class; $$.deref_count = 0; $$.u.name = $2; } | tSTRUCT identifier { $$.type = type_expr_udt_struct; $$.deref_count = 0; $$.u.name = $2; } diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index 23073dd4c65..90dd4dfac11 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -54,6 +54,18 @@ static char* lexeme_alloc(const char* lexeme) return strcpy(ptr, lexeme); }
+static char* lexeme_alloc_if(const char* lexeme, unsigned sz) +{ + size_t len = strlen(lexeme); + char* ptr; + if (len <= sz) return NULL; + len -= sz; + ptr = lexeme_alloc_size(len + 1); + memcpy(ptr, lexeme, len); + ptr[len] = '\0'; + return ptr; +} + void lexeme_flush(void) { while (--next_lexeme >= 0) HeapFree(GetProcessHeap(), 0, local_lexemes[next_lexeme]); @@ -100,7 +112,7 @@ HEXDIGIT [0-9a-fA-F] FORMAT [ubcdgiswxa] IDENTIFIER [_a-zA-Z~?][_a-zA-Z0-9~?@]* SCOPED_IDENTIFIER [_a-zA-Z~?][_a-zA-Z0-9~?@]*"::" -MODULE_IDENTIFIER [_a-zA-Z~?*][_a-zA-Z0-9~?*@]*"!" +MODULE_IDENTIFIER [_a-zA-Z~?*][_a-zA-Z0-9~?*@.]*"!" PATHNAME [\/_a-zA-Z0-9.~@][\/-_a-zA-Z0-9.~@]* STRING "(\[^\n]|[^\"\n])*"
@@ -231,14 +243,16 @@ STRING "(\[^\n]|[^\"\n])*" <INITIAL,SHOW_CMD>directories|directorie|directori|director|directo|direct|direc|direc|dir { BEGIN(PATH_EXPECTED); return tDIR; }
-char { return tCHAR; } -short { return tSHORT; } -int { return tINT; } -long { return tLONG; } -float { return tFLOAT; } -double { return tDOUBLE; } -unsigned { return tUNSIGNED; } -signed { return tSIGNED; } +{MODULE_IDENTIFIER}?void { dbg_lval.string = lexeme_alloc_if(yytext, 5); return tVOID; } /* return modulename if present */ +{MODULE_IDENTIFIER}?char { dbg_lval.string = lexeme_alloc_if(yytext, 5); return tCHAR; } +{MODULE_IDENTIFIER}?WCHAR { dbg_lval.string = lexeme_alloc_if(yytext, 6); return tWCHAR; } +{MODULE_IDENTIFIER}?short { dbg_lval.string = lexeme_alloc_if(yytext, 6); return tSHORT; } +{MODULE_IDENTIFIER}?int { dbg_lval.string = lexeme_alloc_if(yytext, 4); return tINT; } +{MODULE_IDENTIFIER}?long { dbg_lval.string = lexeme_alloc_if(yytext, 5); return tLONG; } +{MODULE_IDENTIFIER}?float { dbg_lval.string = lexeme_alloc_if(yytext, 6); return tFLOAT; } +{MODULE_IDENTIFIER}?double { dbg_lval.string = lexeme_alloc_if(yytext, 7); return tDOUBLE; } +{MODULE_IDENTIFIER}?unsigned { dbg_lval.string = lexeme_alloc_if(yytext, 9); return tUNSIGNED; } +{MODULE_IDENTIFIER}?signed { dbg_lval.string = lexeme_alloc_if(yytext, 7); return tSIGNED; } struct { return tSTRUCT; } union { return tUNION; } enum { return tENUM; } diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index f8f65035d48..bde912eaee5 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -67,33 +67,42 @@ enum dbg_line_status
enum dbg_internal_types { + /* order here must match types.c:basic_types_details table */ dbg_itype_first = 0xffffff00, + dbg_itype_void = dbg_itype_first, + dbg_itype_bool, dbg_itype_char, dbg_itype_wchar, + dbg_itype_char8, + dbg_itype_char16, + dbg_itype_char32,
dbg_itype_unsigned_int8, - dbg_itype_signed_int8, dbg_itype_unsigned_int16, - dbg_itype_signed_int16, dbg_itype_unsigned_int32, - dbg_itype_signed_int32, dbg_itype_unsigned_int64, - dbg_itype_signed_int64, dbg_itype_unsigned_int128, - dbg_itype_signed_int128, - dbg_itype_unsigned_long32, - dbg_itype_signed_long32, dbg_itype_unsigned_long64, + + dbg_itype_signed_int8, + dbg_itype_signed_int16, + dbg_itype_signed_int32, + dbg_itype_signed_int64, + dbg_itype_signed_int128, + dbg_itype_signed_long32, dbg_itype_signed_long64,
+ dbg_itype_short_real, /* aka float */ + dbg_itype_real, /* aka double */ + dbg_itype_long_real, /* aka long double */ + + dbg_itype_last, + /* they represent the dbg_lg(u)int_t types */ dbg_itype_lgint, dbg_itype_lguint,
- dbg_itype_short_real, /* aka float */ - dbg_itype_real, /* aka double */ - dbg_itype_long_real, /* aka long double */ dbg_itype_astring, dbg_itype_ustring, dbg_itype_segptr, /* hack for segmented pointers */ @@ -506,6 +515,7 @@ extern struct dbg_type types_find_type(DWORD64 linear, const char* name, enum S extern BOOL types_compare(const struct dbg_type, const struct dbg_type, BOOL* equal); extern BOOL types_is_integral_type(const struct dbg_lvalue*); extern BOOL types_is_float_type(const struct dbg_lvalue*); +extern BOOL types_find_basic(const WCHAR*, const char*, struct type_expr_t* type);
/* winedbg.c */ #ifdef __GNUC__ @@ -553,10 +563,10 @@ static inline void* dbg_heap_realloc(void* buffer, size_t size)
struct data_model { - unsigned base_type; - unsigned size; - const WCHAR* name; + enum dbg_internal_types itype; + const WCHAR* name; }; + extern const struct data_model ilp32_data_model[]; extern const struct data_model lp64_data_model[]; extern const struct data_model llp64_data_model[]; diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index e87af4c3211..f9860bd12c1 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -718,92 +718,151 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) return TRUE; }
-const struct data_model ilp32_data_model[] = { - {btVoid, 0, L"void"}, - {btChar, 1, L"char"}, - {btWChar, 2, L"wchar_t"}, - {btInt, 1, L"signed char"}, - {btInt, 2, L"short int"}, - {btInt, 4, L"int"}, - {btInt, 8, L"__int64"}, - {btUInt, 1, L"unsigned char"}, - {btUInt, 2, L"unsigned short int"}, - {btUInt, 4, L"unsigned int"}, - {btUInt, 8, L"unsigned __int64"}, - {btFloat, 4, L"float"}, - {btFloat, 8, L"double"}, - {btFloat, 10, L"long double"}, - {btBool, 1, L"bool"}, - {btLong, 4, L"long"}, - {btLong, 8, L"long long"}, - {btULong, 4, L"unsigned long"}, - {btULong, 8, L"unsigned long long"}, - {btHresult, 4, L"char32_t"}, - {btChar16, 2, L"char16_t"}, - {btChar32, 4, L"char32_t"}, - {btChar8, 1, L"char8_t"}, - {0, 0, NULL} +/* order here must match order in enum dbg_internal_type */ +static struct +{ + unsigned char base_type; + unsigned char byte_size; +} + basic_types_details[] = +{ + {btVoid, 0}, + {btBool, 1}, + /* chars */ + {btChar, 1}, + {btWChar, 2}, + {btChar8, 1}, + {btChar16, 2}, + {btChar32, 4}, + /* unsigned integers */ + {btUInt, 1}, + {btUInt, 2}, + {btUInt, 4}, + {btUInt, 8}, + {btUInt, 16}, + {btULong, 4}, + {btULong, 8}, + /* signed integers */ + {btInt, 1}, + {btInt, 2}, + {btInt, 4}, + {btInt, 8}, + {btInt, 16}, + {btLong, 4}, + {btLong, 8}, + /* floats */ + {btFloat, 4}, + {btFloat, 8}, + {btFloat, 10}, };
-const struct data_model llp64_data_model[] = { - {btVoid, 0, L"void"}, - {btChar, 1, L"char"}, - {btWChar, 2, L"wchar_t"}, - {btInt, 1, L"signed char"}, - {btInt, 2, L"short int"}, - {btInt, 4, L"int"}, - {btInt, 8, L"__int64"}, - {btInt, 16, L"__int128"}, - {btUInt, 1, L"unsigned char"}, - {btUInt, 2, L"unsigned short int"}, - {btUInt, 4, L"unsigned int"}, - {btUInt, 8, L"unsigned __int64"}, - {btUInt, 16, L"unsigned __int128"}, - {btFloat, 4, L"float"}, - {btFloat, 8, L"double"}, - {btFloat, 10, L"long double"}, - {btBool, 1, L"bool"}, - {btLong, 4, L"long"}, - {btLong, 8, L"long long"}, - {btULong, 4, L"unsigned long"}, - {btULong, 8, L"unsigned long long"}, - {btHresult, 4, L"char32_t"}, - {btChar16, 2, L"char16_t"}, - {btChar32, 4, L"char32_t"}, - {btChar8, 1, L"char8_t"}, - {0, 0, NULL} +C_ASSERT(ARRAY_SIZE(basic_types_details) == dbg_itype_last - dbg_itype_first); + +const struct data_model ilp32_data_model[] = +{ + {dbg_itype_void, L"void"}, + + {dbg_itype_bool, L"bool"}, + + {dbg_itype_char, L"char"}, + {dbg_itype_wchar, L"WCHAR"}, + {dbg_itype_char8, L"char8_t"}, + {dbg_itype_char16, L"char16_t"}, + {dbg_itype_char32, L"char32_t"}, + + {dbg_itype_unsigned_int8, L"unsigned char"}, + {dbg_itype_unsigned_int16, L"unsigned short int"}, + {dbg_itype_unsigned_int32, L"unsigned int"}, + {dbg_itype_unsigned_int64, L"unsigned long long int"}, + {dbg_itype_unsigned_int64, L"unsigned __int64"}, + {dbg_itype_unsigned_long32, L"unsigned long int"}, + + {dbg_itype_signed_int8, L"signed char"}, + {dbg_itype_signed_int16, L"short int"}, + {dbg_itype_signed_int32, L"int"}, + {dbg_itype_signed_int64, L"long long int"}, + {dbg_itype_signed_int64, L"__int64"}, + {dbg_itype_signed_long32, L"long int"}, + + {dbg_itype_short_real, L"float"}, + {dbg_itype_real, L"double"}, + {dbg_itype_long_real, L"long double"}, + + {0, NULL} };
-const struct data_model lp64_data_model[] = { - {btVoid, 0, L"void"}, - {btChar, 1, L"char"}, - {btWChar, 2, L"wchar_t"}, - {btInt, 1, L"signed char"}, - {btInt, 2, L"short int"}, - {btInt, 4, L"int"}, - {btInt, 8, L"__int64"}, - {btInt, 16, L"__int128"}, - {btUInt, 1, L"unsigned char"}, - {btUInt, 2, L"unsigned short int"}, - {btUInt, 4, L"unsigned int"}, - {btUInt, 8, L"unsigned __int64"}, - {btUInt, 16, L"unsigned __int128"}, - {btFloat, 4, L"float"}, - {btFloat, 8, L"double"}, - {btFloat, 10, L"long double"}, - {btBool, 1, L"bool"}, - {btLong, 4, L"int"}, /* to print at least for such a regular Windows' type */ - {btLong, 8, L"long"}, /* we can't discriminate 'long' from 'long long' */ - {btULong, 4, L"unsigned int"}, /* to print at least for such a regular Windows' type */ - {btULong, 8, L"unsigned long"}, /* we can't discriminate 'unsigned long' from 'unsigned long long' */ - {btHresult, 4, L"char32_t"}, - {btChar16, 2, L"char16_t"}, - {btChar32, 4, L"char32_t"}, - {btChar8, 1, L"char8_t"}, - {0, 0, NULL} +const struct data_model llp64_data_model[] = +{ + {dbg_itype_void, L"void"}, + + {dbg_itype_bool, L"bool"}, + + {dbg_itype_char, L"char"}, + {dbg_itype_wchar, L"WCHAR"}, + {dbg_itype_char8, L"char8_t"}, + {dbg_itype_char16, L"char16_t"}, + {dbg_itype_char32, L"char32_t"}, + + {dbg_itype_unsigned_int8, L"unsigned char"}, + {dbg_itype_unsigned_int16, L"unsigned short int"}, + {dbg_itype_unsigned_int32, L"unsigned int"}, + {dbg_itype_unsigned_int64, L"unsigned long long int"}, + {dbg_itype_unsigned_int64, L"unsigned __int64"}, + {dbg_itype_unsigned_int128, L"unsigned __int128"}, + + {dbg_itype_unsigned_long32, L"unsigned long int"}, + + {dbg_itype_signed_int8, L"signed char"}, + {dbg_itype_signed_int16, L"short int"}, + {dbg_itype_signed_int32, L"int"}, + {dbg_itype_signed_int64, L"long long int"}, + {dbg_itype_signed_int64, L"__int64"}, + {dbg_itype_signed_int128, L"__int128"}, + {dbg_itype_signed_long32, L"long int"}, + + {dbg_itype_short_real, L"float"}, + {dbg_itype_real, L"double"}, + {dbg_itype_long_real, L"long double"}, + + {0, NULL} };
-static const struct data_model* get_data_model(DWORD modaddr) +const struct data_model lp64_data_model[] = +{ + {dbg_itype_void, L"void"}, + + {dbg_itype_bool, L"bool"}, + + {dbg_itype_char, L"char"}, + {dbg_itype_wchar, L"WCHAR"}, + {dbg_itype_char8, L"char8_t"}, + {dbg_itype_char16, L"char16_t"}, + {dbg_itype_char32, L"char32_t"}, + + {dbg_itype_unsigned_int8, L"unsigned char"}, + {dbg_itype_unsigned_int16, L"unsigned short int"}, + {dbg_itype_unsigned_int32, L"unsigned int"}, + {dbg_itype_unsigned_int64, L"unsigned long long int"}, + {dbg_itype_unsigned_int64, L"unsigned __int64"}, + {dbg_itype_unsigned_int128, L"unsigned __int128"}, + {dbg_itype_unsigned_long64, L"unsigned long int"}, /* we can't discriminate 'unsigned long' from 'unsigned long long' (on output) */ + + {dbg_itype_signed_int8, L"signed char"}, + {dbg_itype_signed_int16, L"short int"}, + {dbg_itype_signed_int32, L"int"}, + {dbg_itype_signed_int64, L"long long int"}, + {dbg_itype_signed_int64, L"__int64"}, + {dbg_itype_signed_int128, L"__int128"}, + {dbg_itype_signed_long64, L"long int"}, /* we can't discriminate 'long' from 'long long' (on output)*/ + + {dbg_itype_short_real, L"float"}, + {dbg_itype_real, L"double"}, + {dbg_itype_long_real, L"long double"}, + + {0, NULL} +}; + +static const struct data_model* get_data_model(DWORD64 modaddr) { const struct data_model *model;
@@ -826,28 +885,76 @@ static const struct data_model* get_data_model(DWORD modaddr) return model; }
-/* helper to typecast pInfo to its expected type (_t) */ -#define X(_t) (*((_t*)pInfo)) +struct mod_by_name +{ + const char* modname; + ULONG64 base; +};
-static BOOL lookup_base_type_in_data_model(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, void* pInfo) +static BOOL CALLBACK enum_mod_cb(const char* module, DWORD64 base, void* user) +{ + struct mod_by_name* mbn = user; + if (!mbn->modname) /* lookup data model from main module */ + { + IMAGEHLP_MODULE64 mi; + mi.SizeOfStruct = sizeof(mi); + if (SymGetModuleInfo64(dbg_curr_process->handle, base, &mi)) + { + size_t len = strlen(mi.ImageName); + if (len >= 4 && !strcmp(mi.ImageName + len - 4, ".exe")) + { + mbn->base = base; + return FALSE; + } + } + } + else if (SymMatchStringA(module, mbn->modname, FALSE)) + { + mbn->base = base; + return FALSE; + } + return TRUE; +} + +BOOL types_find_basic(const WCHAR* name, const char* mod, struct type_expr_t* type) +{ + const struct data_model* model; + struct mod_by_name mbn = {mod, 0}; + DWORD opt; + BOOL ret; + + opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); + ret = SymEnumerateModules64(dbg_curr_process->handle, enum_mod_cb, &mbn); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); + if (!ret || mbn.base == 0) + return FALSE; + type->type = type_expr_type_id; + type->deref_count = 0; + model = get_data_model(mbn.base); + for (; model->name; model++) + { + if (!wcscmp(name, model->name)) + { + type->u.type.module = 0; + type->u.type.id = model->itype; + return TRUE; + } + } + return FALSE; +} + +static BOOL lookup_base_type_in_data_model(DWORD64 module, unsigned bt, unsigned len, WCHAR** pname) { - DWORD tag, bt; - DWORD64 len; const WCHAR* name = NULL; WCHAR tmp[64]; const struct data_model* model;
- if (ti != TI_GET_SYMNAME || - !SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_SYMTAG, &tag) || - tag != SymTagBaseType || - !SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_BASETYPE, &bt) || - !SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_LENGTH, &len) || - len != (DWORD)len) return FALSE; - - model = get_data_model(type->module); + model = get_data_model(module); for (; model->name; model++) { - if (bt == model->base_type && model->size == len) + if (model->itype >= dbg_itype_first && model->itype < dbg_itype_last && + bt == basic_types_details[model->itype - dbg_itype_first].base_type && + len == basic_types_details[model->itype - dbg_itype_first].byte_size) { name = model->name; break; @@ -855,25 +962,58 @@ static BOOL lookup_base_type_in_data_model(const struct dbg_type* type, IMAGEHLP } if (!name) /* synthetize name */ { - WINE_FIXME("Unsupported basic type %lu %I64u\n", bt, len); - swprintf(tmp, ARRAY_SIZE(tmp), L"bt[%lu,%u]", bt, len); + WINE_FIXME("Unsupported basic type %u %u\n", bt, len); + swprintf(tmp, ARRAY_SIZE(tmp), L"bt[%u,%u]", bt, len); name = tmp; } - X(WCHAR*) = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(WCHAR)); - if (X(WCHAR*)) - lstrcpyW(X(WCHAR*), name); + *pname = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(WCHAR)); + if (!*pname) return FALSE; + lstrcpyW(*pname, name); return TRUE; }
+/* helper to typecast pInfo to its expected type (_t) */ +#define X(_t) (*((_t*)pInfo)) + BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, void* pInfo) { if (type->id == dbg_itype_none) return FALSE; if (type->module != 0) - return lookup_base_type_in_data_model(type, ti, pInfo) || - SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, ti, pInfo); + { + if (ti == TI_GET_SYMNAME) + { + DWORD tag, bt; + DWORD64 len; + WCHAR* name; + if (SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_SYMTAG, &tag) && + tag == SymTagBaseType && + SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_BASETYPE, &bt) && + SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_LENGTH, &len) && + len == (DWORD)len) + { + if (!lookup_base_type_in_data_model(type->module, bt, len, &name)) return FALSE; + X(WCHAR*) = name; + return TRUE; + } + } + return SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, ti, pInfo); + }
assert(type->id >= dbg_itype_first);
+ if (type->id >= dbg_itype_first && type->id < dbg_itype_last) + { + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = basic_types_details[type->id - dbg_itype_first].byte_size; break; + case TI_GET_BASETYPE: X(DWORD) = basic_types_details[type->id - dbg_itype_first].base_type; break; + case TI_GET_SYMNAME: return lookup_base_type_in_data_model(0, basic_types_details[type->id - dbg_itype_first].base_type, + basic_types_details[type->id - dbg_itype_first].byte_size, &X(WCHAR*)); + default: WINE_FIXME("unsupported %u for itype %#lx\n", ti, type->id); return FALSE; + } + return TRUE; + } switch (type->id) { case dbg_itype_lguint: @@ -894,150 +1034,6 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v default: WINE_FIXME("unsupported %u for lgint_t\n", ti); return FALSE; } break; - case dbg_itype_unsigned_long32: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 4; break; - case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-long int\n", ti); return FALSE; - } - break; - case dbg_itype_signed_long32: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 4; break; - case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-long int\n", ti); return FALSE; - } - break; - case dbg_itype_unsigned_long64: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 8; break; - case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-long int\n", ti); return FALSE; - } - break; - case dbg_itype_signed_long64: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 8; break; - case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-long int\n", ti); return FALSE; - } - break; - case dbg_itype_unsigned_int8: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 1; break; - case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; - } - break; - case dbg_itype_signed_int8: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 1; break; - case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; - } - break; - case dbg_itype_unsigned_int16: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 2; break; - case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; - } - break; - case dbg_itype_signed_int16: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 2; break; - case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; - } - break; - case dbg_itype_unsigned_int32: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 4; break; - case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; - } - break; - case dbg_itype_signed_int32: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 4; break; - case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; - } - break; - case dbg_itype_unsigned_int64: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 8; break; - case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; - } - break; - case dbg_itype_signed_int64: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 8; break; - case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; - } - break; - case dbg_itype_unsigned_int128: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 16; break; - case TI_GET_BASETYPE: X(DWORD) = btUInt; break; - default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE; - } - break; - case dbg_itype_signed_int128: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 16; break; - case TI_GET_BASETYPE: X(DWORD) = btInt; break; - default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE; - } - break; - case dbg_itype_char: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 1; break; - case TI_GET_BASETYPE: X(DWORD) = btChar; break; - default: WINE_FIXME("unsupported %u for char int\n", ti); return FALSE; - } - break; - case dbg_itype_wchar: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 2; break; - case TI_GET_BASETYPE: X(DWORD) = btWChar; break; - default: WINE_FIXME("unsupported %u for char int\n", ti); return FALSE; - } - break; case dbg_itype_astring: switch (ti) { @@ -1056,33 +1052,6 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v default: WINE_FIXME("unsupported %u for seg-ptr\n", ti); return FALSE; } break; - case dbg_itype_short_real: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 4; break; - case TI_GET_BASETYPE: X(DWORD) = btFloat; break; - default: WINE_FIXME("unsupported %u for short real\n", ti); return FALSE; - } - break; - case dbg_itype_real: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 8; break; - case TI_GET_BASETYPE: X(DWORD) = btFloat; break; - default: WINE_FIXME("unsupported %u for real\n", ti); return FALSE; - } - break; - case dbg_itype_long_real: - switch (ti) - { - case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; - case TI_GET_LENGTH: X(DWORD64) = 10; break; - case TI_GET_BASETYPE: X(DWORD) = btFloat; break; - default: WINE_FIXME("unsupported %u for long real\n", ti); return FALSE; - } - break; case dbg_itype_m128a: switch (ti) {
From: Eric Pouech eric.pouech@gmail.com
typically what a C compiler does... - get rid of struct type_expr_t - enabling back typecasts (and rewriting the typecast to fit the type parsing scheme)
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winedbg/dbg.y | 14 ++-- programs/winedbg/debug.l | 9 ++- programs/winedbg/debugger.h | 34 +++------- programs/winedbg/expr.c | 125 +++++++++++++++--------------------- programs/winedbg/stack.c | 8 +-- programs/winedbg/types.c | 85 +++++++++++++----------- 6 files changed, 130 insertions(+), 145 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 748d16e96c5..6faa196e052 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -44,7 +44,7 @@ static void parser(const char*); dbg_lgint_t integer; IMAGEHLP_LINE64 listing; struct expr* expression; - struct type_expr_t type; + struct dbg_type type; struct list_string* strings; }
@@ -57,6 +57,7 @@ static void parser(const char*); %token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS tSOURCE %token <string> tPATH tIDENTIFIER tSTRING tINTVAR %token <integer> tNUM tFORMAT +%token <type> tTYPEDEF %token tSYMBOLFILE tRUN tATTACH tDETACH tKILL tMAINTENANCE tTYPE tMINIDUMP %token tNOPROCESS
@@ -346,11 +347,12 @@ type_expr: | tFLOAT { if (!types_find_basic(L"float", $1, &$$)) YYERROR; } | tDOUBLE { if (!types_find_basic(L"double", $1, &$$)) YYERROR; } | tLONG tDOUBLE { if (!types_find_basic(L"long double", $1, &$$)) YYERROR; } - | type_expr '*' { $$ = $1; $$.deref_count++; } - | tCLASS identifier { $$.type = type_expr_udt_class; $$.deref_count = 0; $$.u.name = $2; } - | tSTRUCT identifier { $$.type = type_expr_udt_struct; $$.deref_count = 0; $$.u.name = $2; } - | tUNION identifier { $$.type = type_expr_udt_union; $$.deref_count = 0; $$.u.name = $2; } - | tENUM identifier { $$.type = type_expr_enumeration; $$.deref_count = 0; $$.u.name = $2; } + | tTYPEDEF { $$ = $1; } + | type_expr '*' { if (!types_find_pointer(&$1, &$$)) {yyerror("Cannot find pointer type\n"); YYERROR; } } + | tCLASS identifier { if (!types_find_type($2, SymTagUDT, &$$)) {yyerror("Unknown type\n"); YYERROR; } } + | tSTRUCT identifier { if (!types_find_type($2, SymTagUDT, &$$)) {yyerror("Unknown type\n"); YYERROR; } } + | tUNION identifier { if (!types_find_type($2, SymTagUDT, &$$)) {yyerror("Unknown type\n"); YYERROR; } } + | tENUM identifier { if (!types_find_type($2, SymTagEnum, &$$)) {yyerror("Unknown type\n"); YYERROR; } } ;
expr_lvalue: diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index 90dd4dfac11..1f8040ff976 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -100,6 +100,13 @@ static char* unescape_string(const char* str) return ret; }
+static int resolve_identifier(const char* id, DBG_STYPE* lval) +{ + if (types_find_type(id, SymTagTypedef, &lval->type)) return tTYPEDEF; + lval->string = lexeme_alloc(id); + return tIDENTIFIER; +} + #define YY_INPUT(buf,result,max_size) \ (result = input_lex_read_buffer(buf, max_size))
@@ -258,7 +265,7 @@ union { return tUNION; } enum { return tENUM; } all { return tALL; }
-{MODULE_IDENTIFIER}?{SCOPED_IDENTIFIER}*{IDENTIFIER} { dbg_lval.string = lexeme_alloc(yytext); return tIDENTIFIER; } +{MODULE_IDENTIFIER}?{SCOPED_IDENTIFIER}*{IDENTIFIER} { return resolve_identifier(yytext, &dbg_lval); } "$"{IDENTIFIER} { dbg_lval.string = lexeme_alloc(yytext+1); return tINTVAR; }
<PATH_EXPECTED,PATH_ACCEPTED>{PATHNAME} { dbg_lval.string = lexeme_alloc(yytext); return tPATH; } diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index bde912eaee5..d5c5934cceb 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -150,14 +150,15 @@ static inline void init_lvalue(struct dbg_lvalue* lv, BOOL in_debuggee, void* ad lv->type.id = dbg_itype_none; }
-static inline void init_lvalue_in_debugger(struct dbg_lvalue* lv, enum dbg_internal_types it, void* addr) +static inline void init_lvalue_in_debugger(struct dbg_lvalue* lv, DWORD_PTR module, + enum dbg_internal_types it, void* addr) { lv->in_debuggee = 0; lv->bitstart = 0; lv->bitlen = 0; lv->addr.Mode = AddrModeFlat; lv->addr.Offset = (DWORD_PTR)addr; - lv->type.module = 0; + lv->type.module = module; lv->type.id = it; }
@@ -310,26 +311,6 @@ struct dbg_internal_var
enum sym_get_lval {sglv_found, sglv_unknown, sglv_aborted};
-enum type_expr_e -{ - type_expr_type_id, - type_expr_udt_class, - type_expr_udt_struct, - type_expr_udt_union, - type_expr_enumeration -}; - -struct type_expr_t -{ - enum type_expr_e type; - unsigned deref_count; - union - { - struct dbg_type type; - const char* name; - } u; -}; - enum dbg_start {start_ok, start_error_parse, start_error_init};
/* break.c */ @@ -385,7 +366,7 @@ extern struct expr* expr_alloc_unary_op(int oper, struct expr*); extern struct expr* expr_alloc_pstruct(struct expr*, const char* element); extern struct expr* expr_alloc_struct(struct expr*, const char* element); extern struct expr* WINAPIV expr_alloc_func_call(const char*, int nargs, ...); -extern struct expr* expr_alloc_typecast(struct type_expr_t*, struct expr*); +extern struct expr* expr_alloc_typecast(struct dbg_type*, struct expr*); extern struct dbg_lvalue expr_eval(struct expr*); extern struct expr* expr_clone(const struct expr* exp, BOOL *local_binding); extern BOOL expr_free(struct expr* exp); @@ -510,12 +491,13 @@ extern BOOL types_udt_find_element(struct dbg_lvalue* value, const c extern BOOL types_array_index(const struct dbg_lvalue* value, int index, struct dbg_lvalue* result); extern BOOL types_get_info(const struct dbg_type*, IMAGEHLP_SYMBOL_TYPE_INFO, void*); extern BOOL types_get_real_type(struct dbg_type* type, DWORD* tag); -extern struct dbg_type types_find_pointer(const struct dbg_type* type); -extern struct dbg_type types_find_type(DWORD64 linear, const char* name, enum SymTagEnum tag); +extern BOOL types_find_pointer(const struct dbg_type* type, struct dbg_type* outtype); +extern BOOL types_find_type(const char* name, enum SymTagEnum tag, struct dbg_type* outtype); extern BOOL types_compare(const struct dbg_type, const struct dbg_type, BOOL* equal); extern BOOL types_is_integral_type(const struct dbg_lvalue*); extern BOOL types_is_float_type(const struct dbg_lvalue*); -extern BOOL types_find_basic(const WCHAR*, const char*, struct type_expr_t* type); +extern BOOL types_is_pointer_type(const struct dbg_lvalue*); +extern BOOL types_find_basic(const WCHAR*, const char*, struct dbg_type* type);
/* winedbg.c */ #ifdef __GNUC__ diff --git a/programs/winedbg/expr.c b/programs/winedbg/expr.c index 5d9ef30ad13..9a927338ba8 100644 --- a/programs/winedbg/expr.c +++ b/programs/winedbg/expr.c @@ -75,8 +75,9 @@ struct expr
struct { - struct type_expr_t cast_to; + struct dbg_type cast_to; struct expr* expr; + dbg_lgint_t result; } cast;
struct @@ -128,14 +129,14 @@ void expr_free_all(void) next_expr_free = 0; }
-struct expr* expr_alloc_typecast(struct type_expr_t* tet, struct expr* exp) +struct expr* expr_alloc_typecast(struct dbg_type* type, struct expr* exp) { struct expr* ex;
ex = expr_alloc();
ex->type = EXPR_TYPE_CAST; - ex->un.cast.cast_to = *tet; + ex->un.cast.cast_to = *type; ex->un.cast.expr = exp; return ex; } @@ -272,75 +273,74 @@ struct expr* WINAPIV expr_alloc_func_call(const char* funcname, int nargs, ...) struct dbg_lvalue expr_eval(struct expr* exp) { struct dbg_lvalue rtn; - int i; struct dbg_lvalue exp1; struct dbg_lvalue exp2; DWORD64 scale1, scale2, scale3; struct dbg_type type1, type2; DWORD tag; const struct dbg_internal_var* div; + BOOL ret;
- init_lvalue_in_debugger(&rtn, dbg_itype_none, NULL); + init_lvalue_in_debugger(&rtn, 0, dbg_itype_none, NULL);
switch (exp->type) { case EXPR_TYPE_CAST: - /* this is really brute force, we simply change the type... without - * checking if this is right or not - */ - rtn = expr_eval(exp->un.cast.expr); - switch (exp->un.cast.cast_to.type) + exp1 = expr_eval(exp->un.cast.expr); + if (exp1.type.id == dbg_itype_none) + RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); + rtn = exp1; + rtn.type = exp->un.cast.cast_to; + init_lvalue_in_debugger(&rtn, exp->un.cast.cast_to.module, exp->un.cast.cast_to.id, &exp->un.cast.result); + if (types_is_float_type(&exp1)) { - case type_expr_type_id: - if (exp->un.cast.cast_to.u.type.id == dbg_itype_none) + double dbl; + ret = memory_fetch_float(&exp1, &dbl); + if (ret) { - dbg_printf("Can't cast to unknown type\n"); - RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); + if (types_is_float_type(&rtn)) + ret = memory_store_float(&rtn, &dbl); + else if (types_is_integral_type(&rtn)) + ret = memory_store_integer(&rtn, (dbg_lgint_t)dbl); + else + ret = FALSE; } - rtn.type = exp->un.cast.cast_to.u.type; - break; - case type_expr_udt_class: - case type_expr_udt_struct: - case type_expr_udt_union: - rtn.type = types_find_type(rtn.type.module, exp->un.cast.cast_to.u.name, - SymTagUDT); - if (rtn.type.id == dbg_itype_none) - { - dbg_printf("Can't cast to UDT %s\n", exp->un.cast.cast_to.u.name); - RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); - } - break; - case type_expr_enumeration: - rtn.type = types_find_type(rtn.type.module, exp->un.cast.cast_to.u.name, - SymTagEnum); - if (rtn.type.id == dbg_itype_none) - { - dbg_printf("Can't cast to enumeration %s\n", exp->un.cast.cast_to.u.name); - RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); - } - break; - default: - dbg_printf("Unsupported cast type %u\n", exp->un.cast.cast_to.type); - RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); } - for (i = 0; i < exp->un.cast.cast_to.deref_count; i++) + else if (types_is_integral_type(&exp1)) { - rtn.type = types_find_pointer(&rtn.type); - if (rtn.type.id == dbg_itype_none) + dbg_lgint_t val = types_extract_as_integer(&exp1); + if (types_is_float_type(&rtn)) { - dbg_printf("Cannot find pointer type\n"); - RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); + double dbl = val; + ret = memory_store_float(&rtn, &dbl); } + else if (types_is_integral_type(&rtn) || types_is_pointer_type(&rtn)) + ret = memory_store_integer(&rtn, val); + else + ret = FALSE; + } + else if (types_is_pointer_type(&exp1)) + { + dbg_lgint_t val = types_extract_as_integer(&exp1); + + if (types_is_integral_type(&rtn) || types_is_pointer_type(&rtn)) + ret = memory_store_integer(&rtn, val); + else + ret = FALSE; } + else + ret = FALSE; + if (!ret) + RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); break; case EXPR_TYPE_STRING: - init_lvalue_in_debugger(&rtn, dbg_itype_astring, &exp->un.string.str); + init_lvalue_in_debugger(&rtn, 0, dbg_itype_astring, &exp->un.string.str); break; case EXPR_TYPE_U_CONST: - init_lvalue_in_debugger(&rtn, dbg_itype_lguint, &exp->un.u_const.value); + init_lvalue_in_debugger(&rtn, 0, dbg_itype_lguint, &exp->un.u_const.value); break; case EXPR_TYPE_S_CONST: - init_lvalue_in_debugger(&rtn, dbg_itype_lgint, &exp->un.s_const.value); + init_lvalue_in_debugger(&rtn, 0, dbg_itype_lgint, &exp->un.s_const.value); break; case EXPR_TYPE_SYMBOL: switch (symbol_get_lvalue(exp->un.symbol.name, -1, &rtn, FALSE)) @@ -440,7 +440,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) */ exp->un.call.result = 0; #endif - init_lvalue_in_debugger(&rtn, dbg_itype_none, &exp->un.call.result); + init_lvalue_in_debugger(&rtn, 0, dbg_itype_none, &exp->un.call.result); /* get return type from function signature type */ /* FIXME rtn.type.module should be set to function's module... */ types_get_info(&rtn.type, TI_GET_TYPE, &rtn.type.id); @@ -448,14 +448,14 @@ struct dbg_lvalue expr_eval(struct expr* exp) case EXPR_TYPE_INTVAR: if (!(div = dbg_get_internal_var(exp->un.intvar.name))) RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL); - init_lvalue_in_debugger(&rtn, div->typeid, div->pval); + init_lvalue_in_debugger(&rtn, 0, div->typeid, div->pval); break; case EXPR_TYPE_BINOP: exp1 = expr_eval(exp->un.binop.exp1); 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); - init_lvalue_in_debugger(&rtn, dbg_itype_lgint, &exp->un.binop.result); + init_lvalue_in_debugger(&rtn, 0, dbg_itype_lgint, &exp->un.binop.result); type1 = exp1.type; type2 = exp2.type; switch (exp->un.binop.binop_type) @@ -584,7 +584,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) case EXPR_TYPE_UNOP: exp1 = expr_eval(exp->un.unop.exp1); if (exp1.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); - init_lvalue_in_debugger(&rtn, dbg_itype_lgint, &exp->un.unop.result); + init_lvalue_in_debugger(&rtn, 0, dbg_itype_lgint, &exp->un.unop.result); switch (exp->un.unop.unop_type) { case EXP_OP_NEG: @@ -610,8 +610,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) if (exp1.addr.Mode != AddrModeFlat) RaiseException(DEBUG_STATUS_CANT_DEREF, 0, 0, NULL); exp->un.unop.result = (ULONG_PTR)memory_to_linear_addr(&exp1.addr); - rtn.type = types_find_pointer(&exp1.type); - if (rtn.type.id == dbg_itype_none) + if (!types_find_pointer(&exp1.type, &rtn.type)) RaiseException(DEBUG_STATUS_CANT_DEREF, 0, 0, NULL); break; default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); @@ -629,30 +628,12 @@ struct dbg_lvalue expr_eval(struct expr* exp) BOOL expr_print(const struct expr* exp) { int i; - struct dbg_type type;
switch (exp->type) { case EXPR_TYPE_CAST: - WINE_FIXME("No longer supported (missing module base)\n"); dbg_printf("(("); - switch (exp->un.cast.cast_to.type) - { - case type_expr_type_id: - type.module = 0; - type.id = exp->un.cast.cast_to.type; - types_print_type(&type, FALSE); break; - case type_expr_udt_class: - dbg_printf("class %s", exp->un.cast.cast_to.u.name); break; - case type_expr_udt_struct: - dbg_printf("struct %s", exp->un.cast.cast_to.u.name); break; - case type_expr_udt_union: - dbg_printf("union %s", exp->un.cast.cast_to.u.name); break; - case type_expr_enumeration: - dbg_printf("enum %s", exp->un.cast.cast_to.u.name); break; - } - for (i = 0; i < exp->un.cast.cast_to.deref_count; i++) - dbg_printf("*"); + types_print_type(&exp->un.cast.cast_to, FALSE); dbg_printf(")"); expr_print(exp->un.cast.expr); dbg_printf(")"); diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index 50932e14ddd..01a86108d6e 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -103,7 +103,7 @@ BOOL stack_get_register_frame(const struct dbg_internal_var* div, struct dbg_lva struct dbg_frame* currfrm = stack_get_curr_frame(); if (currfrm == NULL) return FALSE; if (currfrm->is_ctx_valid) - init_lvalue_in_debugger(lvalue, div->typeid, + init_lvalue_in_debugger(lvalue, 0, div->typeid, (char*)&currfrm->context + (DWORD_PTR)div->pval); else { @@ -116,13 +116,13 @@ BOOL stack_get_register_frame(const struct dbg_internal_var* div, struct dbg_lva switch (kind) { case be_cpu_addr_pc: - init_lvalue_in_debugger(lvalue, itype, &currfrm->linear_pc); + init_lvalue_in_debugger(lvalue, 0, itype, &currfrm->linear_pc); break; case be_cpu_addr_stack: - init_lvalue_in_debugger(lvalue, itype, &currfrm->linear_stack); + init_lvalue_in_debugger(lvalue, 0, itype, &currfrm->linear_stack); break; case be_cpu_addr_frame: - init_lvalue_in_debugger(lvalue, itype, &currfrm->linear_frame); + init_lvalue_in_debugger(lvalue, 0, itype, &currfrm->linear_frame); break; } } diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index f9860bd12c1..b8f29058162 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -300,7 +300,8 @@ BOOL types_array_index(const struct dbg_lvalue* lvalue, int index, struct dbg_lv } break; default: - assert(FALSE); + FIXME("unexpected tag %lx\n", tag); + return FALSE; } /* * Get the base type, so we know how much to index by. @@ -332,13 +333,9 @@ BOOL types_array_index(const struct dbg_lvalue* lvalue, int index, struct dbg_lv
struct type_find_t { - ULONG result; /* out: the found type */ enum SymTagEnum tag; /* in: the tag to look for */ - union - { - ULONG typeid; /* when tag is SymTagUDT */ - const char* name; /* when tag is SymTagPointerType */ - } u; + struct dbg_type type; /* out: the type found */ + ULONG ptr_typeid; /* in: when tag is SymTagPointerType */ };
static BOOL CALLBACK types_cb(PSYMBOL_INFO sym, ULONG size, void* _user) @@ -353,18 +350,18 @@ static BOOL CALLBACK types_cb(PSYMBOL_INFO sym, ULONG size, void* _user) switch (user->tag) { case SymTagUDT: - if (!strcmp(user->u.name, sym->Name)) - { - user->result = sym->TypeIndex; - ret = FALSE; - } + case SymTagEnum: + case SymTagTypedef: + user->type.module = sym->ModBase; + user->type.id = sym->TypeIndex; + ret = FALSE; break; case SymTagPointerType: type.module = sym->ModBase; type.id = sym->TypeIndex; - if (types_get_info(&type, TI_GET_TYPE, &type_id) && type_id == user->u.typeid) + if (types_get_info(&type, TI_GET_TYPE, &type_id) && type_id == user->ptr_typeid) { - user->result = sym->TypeIndex; + user->type = type; ret = FALSE; } break; @@ -380,18 +377,17 @@ static BOOL CALLBACK types_cb(PSYMBOL_INFO sym, ULONG size, void* _user) * Should look up in module based at linear whether (typeid*) exists * Otherwise, we could create it locally */ -struct dbg_type types_find_pointer(const struct dbg_type* type) +BOOL types_find_pointer(const struct dbg_type* type, struct dbg_type* outtype) { struct type_find_t f; - struct dbg_type ret;
- f.result = dbg_itype_none; + f.type.id = dbg_itype_none; f.tag = SymTagPointerType; - f.u.typeid = type->id; - SymEnumTypes(dbg_curr_process->handle, type->module, types_cb, &f); - ret.module = type->module; - ret.id = f.result; - return ret; + f.ptr_typeid = type->id; + if (!SymEnumTypes(dbg_curr_process->handle, type->module, types_cb, &f) || f.type.id == dbg_itype_none) + return FALSE; + *outtype = f.type; + return TRUE; }
/****************************************************************** @@ -400,19 +396,29 @@ struct dbg_type types_find_pointer(const struct dbg_type* type) * Should look up in the module based at linear address whether a type * named 'name' and with the correct tag exists */ -struct dbg_type types_find_type(DWORD64 linear, const char* name, enum SymTagEnum tag) - +BOOL types_find_type(const char* name, enum SymTagEnum tag, struct dbg_type* outtype) { struct type_find_t f; - struct dbg_type ret; + char* str = NULL; + BOOL ret;
- f.result = dbg_itype_none; + if (!strchr(name, '!')) /* no module, lookup across all modules */ + { + str = malloc(strlen(name) + 3); + if (!str) return FALSE; + str[0] = '*'; + str[1] = '!'; + strcpy(str + 2, name); + name = str; + } + f.type.id = dbg_itype_none; f.tag = tag; - f.u.name = name; - SymEnumTypes(dbg_curr_process->handle, linear, types_cb, &f); - ret.module = linear; - ret.id = f.result; - return ret; + ret = SymEnumTypesByName(dbg_curr_process->handle, 0, name, types_cb, &f); + free(str); + if (!ret || f.type.id == dbg_itype_none) + return FALSE; + *outtype = f.type; + return TRUE; }
/*********************************************************************** @@ -916,7 +922,7 @@ static BOOL CALLBACK enum_mod_cb(const char* module, DWORD64 base, void* user) return TRUE; }
-BOOL types_find_basic(const WCHAR* name, const char* mod, struct type_expr_t* type) +BOOL types_find_basic(const WCHAR* name, const char* mod, struct dbg_type* type) { const struct data_model* model; struct mod_by_name mbn = {mod, 0}; @@ -928,15 +934,13 @@ BOOL types_find_basic(const WCHAR* name, const char* mod, struct typ SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); if (!ret || mbn.base == 0) return FALSE; - type->type = type_expr_type_id; - type->deref_count = 0; model = get_data_model(mbn.base); for (; model->name; model++) { if (!wcscmp(name, model->name)) { - type->u.type.module = 0; - type->u.type.id = model->itype; + type->module = 0; + type->id = model->itype; return TRUE; } } @@ -1238,3 +1242,12 @@ BOOL types_is_float_type(const struct dbg_lvalue* lv) !types_get_info(&type, TI_GET_BASETYPE, &bt)) return FALSE; return bt == btFloat; } + +BOOL types_is_pointer_type(const struct dbg_lvalue* lv) +{ + struct dbg_type type = lv->type; + DWORD tag; + if (lv->bitlen) return FALSE; + return types_get_real_type(&type, &tag) && + (tag == SymTagPointerType || tag == SymTagArrayType || tag == SymTagFunctionType); +}
From: Eric Pouech eric.pouech@gmail.com
'print struct foo' will show all fields of structure 'print enum bar' will show all definitions inside of enum (and their value) 'print /d <type>' will show the type size (in bytes)
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winedbg/dbg.y | 1 + programs/winedbg/types.c | 83 +++++++++++++++++++++++++++++++++++----- 2 files changed, 75 insertions(+), 9 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 6faa196e052..235c0928f76 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -225,6 +225,7 @@ x_command: print_command: tPRINT expr_lvalue { print_value(&$2, 0, 0); } | tPRINT tFORMAT expr_lvalue { if (($2 >> 8) == 1) print_value(&$3, $2 & 0xff, 0); else dbg_printf("Count is meaningless in print command\n"); } + | tPRINT type_expr { types_print_type(&$2, TRUE); dbg_printf("\n"); } ;
break_command: diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index b8f29058162..bf1276c6adb 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -591,7 +591,8 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) { WCHAR* ptr; const WCHAR* name; - DWORD tag, udt, count; + DWORD tag, udt, count, bitoffset, bt; + DWORD64 bitlen; struct dbg_type subtype;
if (type->id == dbg_itype_none || !types_get_info(type, TI_GET_SYMTAG, &tag)) @@ -605,7 +606,13 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) switch (tag) { case SymTagBaseType: - if (details) dbg_printf("Basic<%ls>", name); else dbg_printf("%ls", name); + dbg_printf("%ls", name); + if (details && types_get_info(type, TI_GET_LENGTH, &bitlen) && types_get_info(type, TI_GET_BASETYPE, &bt)) + { + const char* longness = ""; + if (bt == btLong || bt == btULong) longness = " long"; + dbg_printf(": size=%I64d%s", bitlen, longness); + } break; case SymTagPointerType: types_get_info(type, TI_GET_TYPE, &subtype.id); @@ -643,14 +650,21 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) type_elt.module = type->module; type_elt.id = fcp->ChildId[i]; if (!types_get_info(&type_elt, TI_GET_SYMNAME, &ptr) || !ptr) continue; - dbg_printf("%ls", ptr); - HeapFree(GetProcessHeap(), 0, ptr); + if (!types_get_info(&type_elt, TI_GET_BITPOSITION, &bitoffset) || + !types_get_info(&type_elt, TI_GET_LENGTH, &bitlen)) + bitlen = ~(DWORD64)0; if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt.id)) { - dbg_printf(":"); - types_print_type(&type_elt, details); + /* print details of embedded UDT:s */ + types_print_type(&type_elt, types_get_info(&type_elt, TI_GET_UDTKIND, &udt)); } - if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", "); + else dbg_printf("<unknown>"); + dbg_printf(" %ls", ptr); + HeapFree(GetProcessHeap(), 0, ptr); + if (bitlen != ~(DWORD64)0) + dbg_printf(" : %I64u", bitlen); + dbg_printf(";"); + if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(" "); } } count -= min(count, 256); @@ -662,7 +676,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) case SymTagArrayType: types_get_info(type, TI_GET_TYPE, &subtype.id); subtype.module = type->module; - types_print_type(&subtype, details); + types_print_type(&subtype, FALSE); if (types_get_info(type, TI_GET_COUNT, &count)) dbg_printf(" %ls[%ld]", name, count); else @@ -670,6 +684,51 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) break; case SymTagEnum: dbg_printf("enum %ls", name); + if (details && + types_get_info(type, TI_GET_CHILDRENCOUNT, &count)) + { + char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)]; + TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer; + WCHAR* ptr; + int i; + struct dbg_type type_elt; + VARIANT variant; + + dbg_printf(" {"); + + fcp->Start = 0; + while (count) + { + fcp->Count = min(count, 256); + if (types_get_info(type, TI_FINDCHILDREN, fcp)) + { + for (i = 0; i < min(fcp->Count, count); i++) + { + type_elt.module = type->module; + type_elt.id = fcp->ChildId[i]; + if (!types_get_info(&type_elt, TI_GET_SYMNAME, &ptr) || !ptr) continue; + if (!types_get_info(&type_elt, TI_GET_VALUE, &variant) || !ptr) continue; + dbg_printf("%ls = ", ptr); + switch (V_VT(&variant)) + { + case VT_I1: dbg_printf("%d", V_I1(&variant)); break; + case VT_I2: dbg_printf("%d", V_I2(&variant)); break; + case VT_I4: dbg_printf("%ld", V_I4(&variant)); break; + case VT_I8: dbg_printf("%I64d", V_I8(&variant)); break; + case VT_UI1: dbg_printf("%u", V_UI1(&variant)); break; + case VT_UI2: dbg_printf("%u", V_UI2(&variant)); break; + case VT_UI4: dbg_printf("%lu", V_UI4(&variant)); break; + case VT_UI8: dbg_printf("%I64u", V_UI8(&variant)); break; + } + HeapFree(GetProcessHeap(), 0, ptr); + if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", "); + } + } + count -= min(count, 256); + fcp->Start += 256; + } + dbg_printf("}"); + } break; case SymTagFunctionType: types_get_info(type, TI_GET_TYPE, &subtype.id); @@ -713,7 +772,13 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) dbg_printf(")"); break; case SymTagTypedef: - dbg_printf("%ls", name); + if (details && types_get_info(type, TI_GET_TYPE, &subtype.id)) + { + dbg_printf("typedef %ls => ", name); + subtype.module = type->module; + types_print_type(&subtype, FALSE); + } + else dbg_printf("%ls", name); break; default: WINE_ERR("Unknown type %lu for %ls\n", tag, name);
From: Eric Pouech eric.pouech@gmail.com
(simply use DEREF unary op)
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winedbg/dbg.y | 2 +- programs/winedbg/expr.c | 5 ----- programs/winedbg/expr.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 235c0928f76..30701a660be 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -428,7 +428,7 @@ lvalue: | lvalue OP_DRF tIDENTIFIER { $$ = expr_alloc_pstruct($1, $3); } | lvalue '.' tIDENTIFIER { $$ = expr_alloc_struct($1, $3); } | lvalue '[' expr ']' { $$ = expr_alloc_binary_op(EXP_OP_ARR, $1, $3); } - | '*' expr { $$ = expr_alloc_unary_op(EXP_OP_FORCE_DEREF, $2); } + | '*' expr { $$ = expr_alloc_unary_op(EXP_OP_DEREF, $2); } ;
%% diff --git a/programs/winedbg/expr.c b/programs/winedbg/expr.c index 9a927338ba8..5a3bc496e83 100644 --- a/programs/winedbg/expr.c +++ b/programs/winedbg/expr.c @@ -600,11 +600,6 @@ struct dbg_lvalue expr_eval(struct expr* exp) if (!types_array_index(&exp1, 0, &rtn)) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); break; - case EXP_OP_FORCE_DEREF: - rtn = exp1; - if (exp1.in_debuggee) - dbg_read_memory(memory_to_linear_addr(&exp1.addr), &rtn.addr.Offset, sizeof(rtn.addr.Offset)); - break; case EXP_OP_ADDR: /* only do it on linear addresses */ if (exp1.addr.Mode != AddrModeFlat) diff --git a/programs/winedbg/expr.h b/programs/winedbg/expr.h index 295543ec292..24303a4a562 100644 --- a/programs/winedbg/expr.h +++ b/programs/winedbg/expr.h @@ -41,4 +41,3 @@ #define EXP_OP_ADDR 0x27 #define EXP_OP_ARR 0x28 #define EXP_OP_SEG 0x29 -#define EXP_OP_FORCE_DEREF 0x2a