With this series: - all expression computations inside WineDbg are done with largest available integer (64bit currently) - improved reading / writing integers (esp. on bit fields or different sizes) - implemented writing floats & doubles (including conversion when needed) - improved detection of incompatible types in assigment - code simplification (removed methods for managing floats and integers)
v2 -> v3: - renamed where bit field in struct dbg_lvalue into in_debuggee (and removed associated helper) - removed unused dbg_print_udecimal
v1 -> v2: - no change to basic types (esp. long) (new internal type int64 has been added) - removed console related patch (some more testing required)
there will be another serie after this one that will better integrate debuggee's generated types (but requires a bit of reworking in WineDbg parser that would be too large here)
A+
---
Eric Pouech (17): programs/winedbg: don't pretend all dbg_internal_var instances will hold DWORD_PTR programs/winedbg: let savable variables' size be a DWORD programs/winedbg: set pid and tid internal variables' type to be a DWORD programs/winedbg: introduce dbg_lg(u)int_t and migrate all integral computations on this type programs/winedbg: remove methods for fetching/storing integers in CPU backends programs/winedbg: renamed extract_longlong() into extract_lgint() for clarity programs/winedbg: split print_longlong into print_(s|u)decimal (to mimic print_hex) programs/winedbg: revamp dbg_lvalue structure and add helpers for init programs/winedbg: add bitfield capability to dbg_lvalue programs/winedbg: move bitfield extraction to extract_lgint dbghelp: in SymGetTypeInfo(), return the correct basetype for enums programs/winedbg: add helper to compare types and use it to detect wrong assigments programs/winedbg: add helper to transfer memory between lvalues programs/winedbg: correctly store integers into a bitfield programs/winedbg: remove fetch_float() method from CPU backends programs/winedbg: implement proper assignements of floating point numbers programs/winedbg: don't hard code sizes
dlls/dbghelp/type.c | 3 +- programs/winedbg/be_arm.c | 82 +++-------- programs/winedbg/be_arm64.c | 118 +++++---------- programs/winedbg/be_cpu.h | 7 - programs/winedbg/be_i386.c | 150 +++++++------------ programs/winedbg/be_x86_64.c | 196 ++++++++++--------------- programs/winedbg/break.c | 4 +- programs/winedbg/dbg.y | 6 +- programs/winedbg/debug.l | 8 +- programs/winedbg/debugger.h | 75 +++++++--- programs/winedbg/expr.c | 82 ++++------- programs/winedbg/memory.c | 192 ++++++++++++++++++++---- programs/winedbg/stack.c | 6 +- programs/winedbg/symbol.c | 21 +-- programs/winedbg/tgt_active.c | 6 +- programs/winedbg/types.c | 268 ++++++++++++++++++++++++++-------- programs/winedbg/winedbg.c | 14 +- 17 files changed, 663 insertions(+), 575 deletions(-)
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/be_arm.c | 34 +++++----- programs/winedbg/be_arm64.c | 70 ++++++++++---------- programs/winedbg/be_i386.c | 102 ++++++++++++++--------------- programs/winedbg/be_x86_64.c | 148 +++++++++++++++++++++--------------------- programs/winedbg/debugger.h | 6 +- programs/winedbg/winedbg.c | 2 - 6 files changed, 181 insertions(+), 181 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index 451eb50e772..435dad2e3cc 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1722,23 +1722,23 @@ 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", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R0), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 1, "r1", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R1), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 2, "r2", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R2), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 3, "r3", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R3), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 4, "r4", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R4), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 5, "r5", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R5), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 6, "r6", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R6), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 7, "r7", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R7), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 8, "r8", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R8), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 9, "r9", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R9), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 10, "r10", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R10), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 11, "r11", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R11), dbg_itype_unsigned_int}, - {CV_ARM_R0 + 12, "r12", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R12), dbg_itype_unsigned_int}, - {CV_ARM_SP, "sp", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Sp), dbg_itype_unsigned_int}, - {CV_ARM_LR, "lr", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Lr), dbg_itype_unsigned_int}, - {CV_ARM_PC, "pc", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Pc), dbg_itype_unsigned_int}, - {CV_ARM_CPSR, "cpsr", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Cpsr), dbg_itype_unsigned_int}, + {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} };
diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index aaf6ecf0bb6..39f17c7d67d 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -104,41 +104,41 @@ 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", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Cpsr), dbg_itype_unsigned_int}, - {CV_ARM64_X0 + 0, "x0", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X0), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 1, "x1", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X1), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 2, "x2", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X2), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 3, "x3", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X3), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 4, "x4", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X4), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 5, "x5", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X5), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 6, "x6", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X6), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 7, "x7", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X7), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 8, "x8", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X8), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 9, "x9", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X9), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 10, "x10", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X10), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 11, "x11", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X11), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 12, "x12", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X12), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 13, "x13", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X13), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 14, "x14", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X14), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 15, "x15", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X15), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 16, "x16", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X16), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 17, "x17", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X17), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 18, "x18", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X18), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 19, "x19", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X19), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 20, "x20", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X20), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 21, "x21", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X21), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 22, "x22", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X22), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 23, "x23", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X23), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 24, "x24", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X24), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 25, "x25", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X25), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 26, "x26", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X26), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 27, "x27", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X27), dbg_itype_unsigned_long_int}, - {CV_ARM64_X0 + 28, "x28", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.X28), dbg_itype_unsigned_long_int}, - {CV_ARM64_FP, "fp", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Fp), dbg_itype_unsigned_long_int}, - {CV_ARM64_LR, "lr", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Lr), dbg_itype_unsigned_long_int}, - {CV_ARM64_SP, "sp", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Sp), dbg_itype_unsigned_long_int}, - {CV_ARM64_PC, "pc", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Pc), dbg_itype_unsigned_long_int}, - {0, NULL, 0, dbg_itype_none} + {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}, + {0, NULL, 0, dbg_itype_none} };
static BOOL be_arm64_is_step_over_insn(const void* insn) diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index 3bb7b9b4240..8902185d0b0 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -277,57 +277,57 @@ 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", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_char_int}, - {CV_REG_CL, "CL", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_char_int}, - {CV_REG_DL, "DL", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_char_int}, - {CV_REG_BL, "BL", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_char_int}, - {CV_REG_AH, "AH", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, Eax)+1), dbg_itype_unsigned_char_int}, - {CV_REG_CH, "CH", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, Ecx)+1), dbg_itype_unsigned_char_int}, - {CV_REG_DH, "DH", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, Edx)+1), dbg_itype_unsigned_char_int}, - {CV_REG_BH, "BH", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, Ebx)+1), dbg_itype_unsigned_char_int}, - {CV_REG_AX, "AX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_short_int}, - {CV_REG_CX, "CX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_short_int}, - {CV_REG_DX, "DX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_short_int}, - {CV_REG_BX, "BX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_short_int}, - {CV_REG_SP, "SP", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Esp), dbg_itype_unsigned_short_int}, - {CV_REG_BP, "BP", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ebp), dbg_itype_unsigned_short_int}, - {CV_REG_SI, "SI", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Esi), dbg_itype_unsigned_short_int}, - {CV_REG_DI, "DI", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Edi), dbg_itype_unsigned_short_int}, - {CV_REG_EAX, "EAX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Eax), dbg_itype_unsigned_int}, - {CV_REG_ECX, "ECX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ecx), dbg_itype_unsigned_int}, - {CV_REG_EDX, "EDX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Edx), dbg_itype_unsigned_int}, - {CV_REG_EBX, "EBX", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ebx), dbg_itype_unsigned_int}, - {CV_REG_ESP, "ESP", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Esp), dbg_itype_unsigned_int}, - {CV_REG_EBP, "EBP", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Ebp), dbg_itype_unsigned_int}, - {CV_REG_ESI, "ESI", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Esi), dbg_itype_unsigned_int}, - {CV_REG_EDI, "EDI", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Edi), dbg_itype_unsigned_int}, - {CV_REG_ES, "ES", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, SegEs), dbg_itype_unsigned_short_int}, - {CV_REG_CS, "CS", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, SegCs), dbg_itype_unsigned_short_int}, - {CV_REG_SS, "SS", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, SegSs), dbg_itype_unsigned_short_int}, - {CV_REG_DS, "DS", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, SegDs), dbg_itype_unsigned_short_int}, - {CV_REG_FS, "FS", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, SegFs), dbg_itype_unsigned_short_int}, - {CV_REG_GS, "GS", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, SegGs), dbg_itype_unsigned_short_int}, - {CV_REG_IP, "IP", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Eip), dbg_itype_unsigned_short_int}, - {CV_REG_FLAGS, "FLAGS", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, EFlags), dbg_itype_unsigned_short_int}, - {CV_REG_EIP, "EIP", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, Eip), dbg_itype_unsigned_int}, - {CV_REG_EFLAGS, "EFLAGS", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, EFlags), dbg_itype_unsigned_int}, - {CV_REG_ST0, "ST0", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), dbg_itype_long_real}, - {CV_REG_ST0+1, "ST1", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), dbg_itype_long_real}, - {CV_REG_ST0+2, "ST2", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), dbg_itype_long_real}, - {CV_REG_ST0+3, "ST3", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), dbg_itype_long_real}, - {CV_REG_ST0+4, "ST4", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), dbg_itype_long_real}, - {CV_REG_ST0+5, "ST5", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), dbg_itype_long_real}, - {CV_REG_ST0+6, "ST6", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), dbg_itype_long_real}, - {CV_REG_ST0+7, "ST7", (DWORD_PTR*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), dbg_itype_long_real}, - {CV_AMD64_XMM0, "XMM0", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[0])), dbg_itype_m128a}, - {CV_AMD64_XMM0+1, "XMM1", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[1])), dbg_itype_m128a}, - {CV_AMD64_XMM0+2, "XMM2", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[2])), dbg_itype_m128a}, - {CV_AMD64_XMM0+3, "XMM3", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[3])), dbg_itype_m128a}, - {CV_AMD64_XMM0+4, "XMM4", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[4])), dbg_itype_m128a}, - {CV_AMD64_XMM0+5, "XMM5", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[5])), dbg_itype_m128a}, - {CV_AMD64_XMM0+6, "XMM6", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[6])), dbg_itype_m128a}, - {CV_AMD64_XMM0+7, "XMM7", (DWORD_PTR*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[7])), dbg_itype_m128a}, - {0, NULL, 0, dbg_itype_none} + {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_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}, + {CV_REG_ST0+3, "ST3", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), dbg_itype_long_real}, + {CV_REG_ST0+4, "ST4", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), dbg_itype_long_real}, + {CV_REG_ST0+5, "ST5", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), dbg_itype_long_real}, + {CV_REG_ST0+6, "ST6", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), dbg_itype_long_real}, + {CV_REG_ST0+7, "ST7", (void*)FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), dbg_itype_long_real}, + {CV_AMD64_XMM0, "XMM0", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[0])), dbg_itype_m128a}, + {CV_AMD64_XMM0+1, "XMM1", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[1])), dbg_itype_m128a}, + {CV_AMD64_XMM0+2, "XMM2", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[2])), dbg_itype_m128a}, + {CV_AMD64_XMM0+3, "XMM3", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[3])), dbg_itype_m128a}, + {CV_AMD64_XMM0+4, "XMM4", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[4])), dbg_itype_m128a}, + {CV_AMD64_XMM0+5, "XMM5", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[5])), dbg_itype_m128a}, + {CV_AMD64_XMM0+6, "XMM6", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[6])), dbg_itype_m128a}, + {CV_AMD64_XMM0+7, "XMM7", (void*)(FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XSAVE_FORMAT, XmmRegisters[7])), dbg_itype_m128a}, + {0, NULL, 0, dbg_itype_none} };
static BOOL be_i386_is_step_over_insn(const void* insn) diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 45c01a70594..af9f7284685 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -179,80 +179,80 @@ 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", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_char_int}, - {CV_AMD64_BL, "BL", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_char_int}, - {CV_AMD64_CL, "CL", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_char_int}, - {CV_AMD64_DL, "DL", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_char_int}, - {CV_AMD64_AH, "AH", (DWORD_PTR*)(FIELD_OFFSET(CONTEXT, Rax)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_BH, "BH", (DWORD_PTR*)(FIELD_OFFSET(CONTEXT, Rbx)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_CH, "CH", (DWORD_PTR*)(FIELD_OFFSET(CONTEXT, Rcx)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_DH, "DH", (DWORD_PTR*)(FIELD_OFFSET(CONTEXT, Rdx)+1), dbg_itype_unsigned_char_int}, - {CV_AMD64_AX, "AX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_short_int}, - {CV_AMD64_BX, "BX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_short_int}, - {CV_AMD64_CX, "CX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_short_int}, - {CV_AMD64_DX, "DX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_short_int}, - {CV_AMD64_SP, "SP", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_short_int}, - {CV_AMD64_BP, "BP", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_short_int}, - {CV_AMD64_SI, "SI", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_short_int}, - {CV_AMD64_DI, "DI", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_short_int}, - {CV_AMD64_EAX, "EAX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_int}, - {CV_AMD64_EBX, "EBX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_int}, - {CV_AMD64_ECX, "ECX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_int}, - {CV_AMD64_EDX, "EDX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_int}, - {CV_AMD64_ESP, "ESP", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_int}, - {CV_AMD64_EBP, "EBP", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_int}, - {CV_AMD64_ESI, "ESI", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_int}, - {CV_AMD64_EDI, "EDI", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_int}, - {CV_AMD64_ES, "ES", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, SegEs), dbg_itype_unsigned_short_int}, - {CV_AMD64_CS, "CS", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, SegCs), dbg_itype_unsigned_short_int}, - {CV_AMD64_SS, "SS", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, SegSs), dbg_itype_unsigned_short_int}, - {CV_AMD64_DS, "DS", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, SegDs), dbg_itype_unsigned_short_int}, - {CV_AMD64_FS, "FS", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, SegFs), dbg_itype_unsigned_short_int}, - {CV_AMD64_GS, "GS", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, SegGs), dbg_itype_unsigned_short_int}, - {CV_AMD64_FLAGS, "FLAGS", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, EFlags), dbg_itype_unsigned_short_int}, - {CV_AMD64_EFLAGS, "EFLAGS", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, EFlags), dbg_itype_unsigned_int}, - {CV_AMD64_RIP, "RIP", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rip), dbg_itype_unsigned_long_int}, - {CV_AMD64_RAX, "RAX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rax), dbg_itype_unsigned_long_int}, - {CV_AMD64_RBX, "RBX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rbx), dbg_itype_unsigned_long_int}, - {CV_AMD64_RCX, "RCX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rcx), dbg_itype_unsigned_long_int}, - {CV_AMD64_RDX, "RDX", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rdx), dbg_itype_unsigned_long_int}, - {CV_AMD64_RSP, "RSP", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rsp), dbg_itype_unsigned_long_int}, - {CV_AMD64_RBP, "RBP", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rbp), dbg_itype_unsigned_long_int}, - {CV_AMD64_RSI, "RSI", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rsi), dbg_itype_unsigned_long_int}, - {CV_AMD64_RDI, "RDI", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Rdi), dbg_itype_unsigned_long_int}, - {CV_AMD64_R8, "R8", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R8), dbg_itype_unsigned_long_int}, - {CV_AMD64_R9, "R9", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R9), dbg_itype_unsigned_long_int}, - {CV_AMD64_R10, "R10", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R10), dbg_itype_unsigned_long_int}, - {CV_AMD64_R11, "R11", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R11), dbg_itype_unsigned_long_int}, - {CV_AMD64_R12, "R12", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R12), dbg_itype_unsigned_long_int}, - {CV_AMD64_R13, "R13", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R13), dbg_itype_unsigned_long_int}, - {CV_AMD64_R14, "R14", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R14), dbg_itype_unsigned_long_int}, - {CV_AMD64_R15, "R15", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R15), dbg_itype_unsigned_long_int}, - {CV_AMD64_ST0, "ST0", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[0]), dbg_itype_long_real}, - {CV_AMD64_ST0+1, "ST1", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[1]), dbg_itype_long_real}, - {CV_AMD64_ST0+2, "ST2", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[2]), dbg_itype_long_real}, - {CV_AMD64_ST0+3, "ST3", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[3]), dbg_itype_long_real}, - {CV_AMD64_ST0+4, "ST4", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[4]), dbg_itype_long_real}, - {CV_AMD64_ST0+5, "ST5", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[5]), dbg_itype_long_real}, - {CV_AMD64_ST0+6, "ST6", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[6]), dbg_itype_long_real}, - {CV_AMD64_ST0+7, "ST7", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[7]), dbg_itype_long_real}, - {CV_AMD64_XMM0, "XMM0", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm0), dbg_itype_m128a}, - {CV_AMD64_XMM0+1, "XMM1", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm1), dbg_itype_m128a}, - {CV_AMD64_XMM0+2, "XMM2", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm2), dbg_itype_m128a}, - {CV_AMD64_XMM0+3, "XMM3", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm3), dbg_itype_m128a}, - {CV_AMD64_XMM0+4, "XMM4", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm4), dbg_itype_m128a}, - {CV_AMD64_XMM0+5, "XMM5", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm5), dbg_itype_m128a}, - {CV_AMD64_XMM0+6, "XMM6", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm6), dbg_itype_m128a}, - {CV_AMD64_XMM0+7, "XMM7", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm7), dbg_itype_m128a}, - {CV_AMD64_XMM8, "XMM8", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm8), dbg_itype_m128a}, - {CV_AMD64_XMM8+1, "XMM9", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm9), dbg_itype_m128a}, - {CV_AMD64_XMM8+2, "XMM10", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm10), dbg_itype_m128a}, - {CV_AMD64_XMM8+3, "XMM11", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm11), dbg_itype_m128a}, - {CV_AMD64_XMM8+4, "XMM12", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm12), dbg_itype_m128a}, - {CV_AMD64_XMM8+5, "XMM13", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm13), dbg_itype_m128a}, - {CV_AMD64_XMM8+6, "XMM14", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm14), dbg_itype_m128a}, - {CV_AMD64_XMM8+7, "XMM15", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, u.s.Xmm15), dbg_itype_m128a}, - {0, NULL, 0, dbg_itype_none} + {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_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}, + {CV_AMD64_ST0+3, "ST3", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[3]), dbg_itype_long_real}, + {CV_AMD64_ST0+4, "ST4", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[4]), dbg_itype_long_real}, + {CV_AMD64_ST0+5, "ST5", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[5]), dbg_itype_long_real}, + {CV_AMD64_ST0+6, "ST6", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[6]), dbg_itype_long_real}, + {CV_AMD64_ST0+7, "ST7", (void*)FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[7]), dbg_itype_long_real}, + {CV_AMD64_XMM0, "XMM0", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm0), dbg_itype_m128a}, + {CV_AMD64_XMM0+1, "XMM1", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm1), dbg_itype_m128a}, + {CV_AMD64_XMM0+2, "XMM2", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm2), dbg_itype_m128a}, + {CV_AMD64_XMM0+3, "XMM3", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm3), dbg_itype_m128a}, + {CV_AMD64_XMM0+4, "XMM4", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm4), dbg_itype_m128a}, + {CV_AMD64_XMM0+5, "XMM5", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm5), dbg_itype_m128a}, + {CV_AMD64_XMM0+6, "XMM6", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm6), dbg_itype_m128a}, + {CV_AMD64_XMM0+7, "XMM7", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm7), dbg_itype_m128a}, + {CV_AMD64_XMM8, "XMM8", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm8), dbg_itype_m128a}, + {CV_AMD64_XMM8+1, "XMM9", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm9), dbg_itype_m128a}, + {CV_AMD64_XMM8+2, "XMM10", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm10), dbg_itype_m128a}, + {CV_AMD64_XMM8+3, "XMM11", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm11), dbg_itype_m128a}, + {CV_AMD64_XMM8+4, "XMM12", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm12), dbg_itype_m128a}, + {CV_AMD64_XMM8+5, "XMM13", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm13), dbg_itype_m128a}, + {CV_AMD64_XMM8+6, "XMM14", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm14), dbg_itype_m128a}, + {CV_AMD64_XMM8+7, "XMM15", (void*)FIELD_OFFSET(CONTEXT, u.s.Xmm15), dbg_itype_m128a}, + {0, NULL, 0, dbg_itype_none} };
#define f_mod(b) ((b)>>6) diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 0e6d715a2d1..506a7d1797b 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -255,8 +255,8 @@ extern HANDLE dbg_houtput; struct dbg_internal_var { DWORD_PTR val; - const char* name; - DWORD_PTR *pval; + const char* name; + void* pval; ULONG typeid; /* always internal type */ };
@@ -509,7 +509,7 @@ extern struct dbg_internal_var dbg_internal_vars[];
#define DBG_IVARNAME(_var) dbg_internal_var_##_var #define DBG_IVARSTRUCT(_var) dbg_internal_vars[DBG_IVARNAME(_var)] -#define DBG_IVAR(_var) (*(DBG_IVARSTRUCT(_var).pval)) +#define DBG_IVAR(_var) (DBG_IVARSTRUCT(_var).val) #define INTERNAL_VAR(_var,_val,_ref,itype) DBG_IVARNAME(_var), enum debug_int_var { diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 659ca364544..803a26f1e55 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -240,7 +240,7 @@ const struct dbg_internal_var* dbg_get_internal_var(const char* name) struct dbg_internal_var* ret = (void*)lexeme_alloc_size(sizeof(*ret)); /* relocate register's field against current context */ *ret = *div; - ret->pval = (DWORD_PTR*)((char*)&dbg_context + (DWORD_PTR)div->pval); + ret->pval = (char*)&dbg_context + (DWORD_PTR)div->pval; return ret; } }
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 506a7d1797b..837384c21a8 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -254,7 +254,7 @@ extern HANDLE dbg_houtput;
struct dbg_internal_var { - DWORD_PTR val; + DWORD val; const char* name; void* pval; ULONG typeid; /* always internal type */
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 4 ++-- programs/winedbg/stack.c | 2 +- programs/winedbg/tgt_active.c | 6 +++--- programs/winedbg/winedbg.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 837384c21a8..1d3156bf8a3 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -245,9 +245,9 @@ struct be_process_io };
extern struct dbg_process* dbg_curr_process; -extern DWORD_PTR dbg_curr_pid; +extern DWORD dbg_curr_pid; extern struct dbg_thread* dbg_curr_thread; -extern DWORD_PTR dbg_curr_tid; +extern DWORD dbg_curr_tid; extern dbg_ctx_t dbg_context; extern BOOL dbg_interactiveP; extern HANDLE dbg_houtput; diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index 34ca6c985be..34089bcde04 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -409,7 +409,7 @@ static void backtrace_all(void) dbg_active_wait_for_first_exception(); }
- dbg_printf("\nBacktracing for thread %04x in process %04Ix (%s):\n", + dbg_printf("\nBacktracing for thread %04x in process %04x (%s):\n", entry.th32ThreadID, dbg_curr_pid, dbg_W2A(dbg_curr_process->imageName, -1)); backtrace_tid(dbg_curr_process, entry.th32ThreadID); diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 0993bddc985..70ad7e8b437 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -370,7 +370,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de) size = ARRAY_SIZE(u.buffer); if (!QueryFullProcessImageNameW( dbg_curr_process->handle, 0, u.buffer, &size )) { - swprintf( u.buffer, ARRAY_SIZE(u.buffer), L"Process_%08x", dbg_curr_pid); + swprintf(u.buffer, ARRAY_SIZE(u.buffer), L"Process_%08x", dbg_curr_pid); }
WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n", @@ -537,12 +537,12 @@ static void dbg_resume_debuggee(DWORD cont) if (dbg_curr_thread) { if (!dbg_curr_process->be_cpu->set_context(dbg_curr_thread->handle, &dbg_context)) - dbg_printf("Cannot set ctx on %04Ix\n", dbg_curr_tid); + dbg_printf("Cannot set ctx on %04x\n", dbg_curr_tid); } } dbg_interactiveP = FALSE; if (!ContinueDebugEvent(dbg_curr_pid, dbg_curr_tid, cont)) - dbg_printf("Cannot continue on %04Ix (%08x)\n", dbg_curr_tid, cont); + dbg_printf("Cannot continue on %04x (%08x)\n", dbg_curr_tid, cont); }
static void wait_exception(void) diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 803a26f1e55..283b126ba84 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -77,8 +77,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
struct dbg_process* dbg_curr_process = NULL; struct dbg_thread* dbg_curr_thread = NULL; -DWORD_PTR dbg_curr_tid = 0; -DWORD_PTR dbg_curr_pid = 0; +DWORD dbg_curr_tid = 0; +DWORD dbg_curr_pid = 0; dbg_ctx_t dbg_context; BOOL dbg_interactiveP = FALSE; HANDLE dbg_houtput = 0; @@ -569,7 +569,7 @@ void dbg_start_interactive(const char* filename, HANDLE hFile)
if (dbg_curr_process) { - dbg_printf("WineDbg starting on pid %04Ix\n", dbg_curr_pid); + dbg_printf("WineDbg starting on pid %04x\n", dbg_curr_pid); if (dbg_curr_process->active_debuggee) dbg_active_wait_for_first_exception(); }
as a side effect, the internal 'long int' type is now always 8 byte wide
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/dbg.y | 6 +++--- programs/winedbg/debug.l | 8 ++++---- programs/winedbg/debugger.h | 21 +++++++++++++++++---- programs/winedbg/expr.c | 40 ++++++++++++++++++++-------------------- programs/winedbg/memory.c | 2 +- programs/winedbg/types.c | 28 +++++++++++++++++++++++----- 6 files changed, 68 insertions(+), 37 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index c5e7b2b43ca..46a643bfb47 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -39,7 +39,7 @@ static void parser(const char*); { struct dbg_lvalue lvalue; char* string; - INT_PTR integer; + dbg_lgint_t integer; IMAGEHLP_LINE64 listing; struct expr* expression; struct type_expr_t type; @@ -286,9 +286,9 @@ info_command: | tINFO tCLASS { info_win32_class(NULL, NULL); } | tINFO tCLASS tSTRING { info_win32_class(NULL, $3); } | tINFO tWND { info_win32_window(NULL, FALSE); } - | tINFO tWND expr_rvalue { info_win32_window((HWND)$3, FALSE); } + | tINFO tWND expr_rvalue { info_win32_window((HWND)(DWORD_PTR)$3, FALSE); } | tINFO '*' tWND { info_win32_window(NULL, TRUE); } - | tINFO '*' tWND expr_rvalue { info_win32_window((HWND)$4, TRUE); } + | tINFO '*' tWND expr_rvalue { info_win32_window((HWND)(DWORD_PTR)$4, TRUE); } | tINFO tPROCESS { info_win32_processes(); } | tINFO tTHREAD { info_win32_threads(); } | tINFO tFRAME { info_win32_frame_exceptions(dbg_curr_tid); } diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index dc93901a71c..5c87f05abe5 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -139,11 +139,11 @@ STRING "(\[^\n]|[^\"\n])*" "[" { return *yytext; } "]" { return *yytext; }
-"0x"{HEXDIGIT}+ { sscanf(yytext, "%Ix", &dbg_lval.integer); return tNUM; } -{DIGIT}+ { sscanf(yytext, "%Id", &dbg_lval.integer); return tNUM; } +"0x"{HEXDIGIT}+ { sscanf(yytext, "%I64x", &dbg_lval.integer); return tNUM; } +{DIGIT}+ { sscanf(yytext, "%I64d", &dbg_lval.integer); return tNUM; } "'\''" { dbg_lval.integer = '''; return tNUM;} -"'\0"{OCTDIGIT}*"'" { sscanf(yytext + 3, "%Io", &dbg_lval.integer); return tNUM;} -"'\x"{HEXDIGIT}+"'" { sscanf(yytext + 3, "%Ix", &dbg_lval.integer); return tNUM;} +"'\0"{OCTDIGIT}*"'" { sscanf(yytext + 3, "%I64o", &dbg_lval.integer); return tNUM;} +"'\x"{HEXDIGIT}+"'" { sscanf(yytext + 3, "%I64x", &dbg_lval.integer); return tNUM;} "'\"[a-z]"'" { dbg_lval.integer = yytext[2] - 'a'; return tNUM;} "'"."'" { dbg_lval.integer = yytext[1]; return tNUM;}
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 1d3156bf8a3..d337381eb22 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -78,6 +78,11 @@ enum dbg_internal_types dbg_itype_signed_long_int, dbg_itype_unsigned_longlong_int, dbg_itype_signed_longlong_int, + + /* they represent the dbg_lg(u)int_t types */ + dbg_itype_lgint, + dbg_itype_lguint, + dbg_itype_char, dbg_itype_wchar, dbg_itype_short_real, /* aka float */ @@ -90,6 +95,14 @@ enum dbg_internal_types dbg_itype_none = 0xffffffff };
+/* Largest integers the debugger's compiler can support. + * It's large enough to store a pointer (in debuggee or debugger's address space). + * It can be smaller than the largest integer(s) of the debuggee. + * (eg. 64 bit on PE build of debugger, vs 128 int in ELF build of a library) + */ +typedef LONG64 dbg_lgint_t; +typedef ULONG64 dbg_lguint_t; + /* type description (in the following order): * - if 'id' is dbg_itype_none (whatever 'module' value), the type isn't known * - if 'module' is 0, it's an internal type (id is one of dbg_itype...) @@ -329,8 +342,8 @@ extern BOOL display_enable(int displaynum, int enable); extern void expr_free_all(void); extern struct expr* expr_alloc_internal_var(const char* name); extern struct expr* expr_alloc_symbol(const char* name); -extern struct expr* expr_alloc_sconstant(INT_PTR val); -extern struct expr* expr_alloc_uconstant(UINT_PTR val); +extern struct expr* expr_alloc_sconstant(dbg_lgint_t val); +extern struct expr* expr_alloc_uconstant(dbg_lguint_t val); extern struct expr* expr_alloc_string(const char* str); extern struct expr* expr_alloc_binary_op(int oper, struct expr*, struct expr*); extern struct expr* expr_alloc_unary_op(int oper, struct expr*); @@ -448,8 +461,8 @@ extern enum dbg_start tgt_module_load(const char* name, BOOL keep); extern void print_value(const struct dbg_lvalue* addr, char format, int level); extern BOOL types_print_type(const struct dbg_type*, BOOL details); extern BOOL print_types(void); -extern INT_PTR types_extract_as_integer(const struct dbg_lvalue*); -extern LONGLONG types_extract_as_longlong(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned); +extern dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue*); +extern dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned); extern void types_extract_as_address(const struct dbg_lvalue*, ADDRESS64*); extern BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from); extern BOOL types_udt_find_element(struct dbg_lvalue* value, const char* name, ULONG *tmpbuf); diff --git a/programs/winedbg/expr.c b/programs/winedbg/expr.c index 842fa8e7925..70bf6316785 100644 --- a/programs/winedbg/expr.c +++ b/programs/winedbg/expr.c @@ -35,12 +35,12 @@ struct expr { struct { - INT_PTR value; + dbg_lgint_t value; } s_const;
struct { - UINT_PTR value; + dbg_lguint_t value; } u_const;
struct @@ -62,7 +62,7 @@ struct expr { int unop_type; struct expr* exp1; - INT_PTR result; + dbg_lgint_t result; } unop;
struct @@ -70,7 +70,7 @@ struct expr int binop_type; struct expr* exp1; struct expr* exp2; - INT_PTR result; + dbg_lgint_t result; } binop;
struct @@ -83,7 +83,7 @@ struct expr { struct expr* exp1; const char* element_name; - ULONG result; + ULONG /* FIXME */ result; } structure;
struct @@ -91,7 +91,7 @@ struct expr const char* funcname; int nargs; struct expr* arg[5]; - ULONG result; + dbg_lguint_t result; } call;
} un; @@ -163,7 +163,7 @@ struct expr* expr_alloc_symbol(const char* name) return ex; }
-struct expr* expr_alloc_sconstant(INT_PTR value) +struct expr* expr_alloc_sconstant(dbg_lgint_t value) { struct expr* ex;
@@ -174,7 +174,7 @@ struct expr* expr_alloc_sconstant(INT_PTR value) return ex; }
-struct expr* expr_alloc_uconstant(UINT_PTR value) +struct expr* expr_alloc_uconstant(dbg_lguint_t value) { struct expr* ex;
@@ -347,13 +347,13 @@ struct dbg_lvalue expr_eval(struct expr* exp) break; case EXPR_TYPE_U_CONST: rtn.cookie = DLV_HOST; - rtn.type.id = dbg_itype_unsigned_long_int; + rtn.type.id = dbg_itype_lguint; rtn.type.module = 0; rtn.addr.Offset = (ULONG_PTR)&exp->un.u_const.value; break; case EXPR_TYPE_S_CONST: rtn.cookie = DLV_HOST; - rtn.type.id = dbg_itype_signed_long_int; + rtn.type.id = dbg_itype_lgint; rtn.type.module = 0; rtn.addr.Offset = (ULONG_PTR)&exp->un.s_const.value; break; @@ -476,7 +476,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) exp2 = expr_eval(exp->un.binop.exp2); if (exp1.type.id == dbg_itype_none || exp2.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); - rtn.type.id = dbg_itype_signed_long_int; + rtn.type.id = dbg_itype_lgint; rtn.type.module = 0; rtn.addr.Offset = (ULONG_PTR)&exp->un.binop.result; type1 = exp1.type; @@ -506,8 +506,8 @@ struct dbg_lvalue expr_eval(struct expr* exp) types_get_info(&type2, TI_GET_LENGTH, &scale1); rtn.type = exp2.type; } - exp->un.binop.result = types_extract_as_integer(&exp1) * (DWORD)scale1 + - (DWORD)scale2 * types_extract_as_integer(&exp2); + exp->un.binop.result = types_extract_as_integer(&exp1) * (dbg_lguint_t)scale1 + + (dbg_lguint_t)scale2 * types_extract_as_integer(&exp2); break; case EXP_OP_SUB: if (!types_get_info(&exp1.type, TI_GET_SYMTAG, &tag) || @@ -538,8 +538,8 @@ struct dbg_lvalue expr_eval(struct expr* exp) types_get_info(&type2, TI_GET_LENGTH, &scale1); rtn.type = exp2.type; } - exp->un.binop.result = (types_extract_as_integer(&exp1) * (DWORD)scale1 - - types_extract_as_integer(&exp2) * (DWORD)scale2) / (DWORD)scale3; + exp->un.binop.result = (types_extract_as_integer(&exp1) * (dbg_lguint_t)scale1 - + types_extract_as_integer(&exp2) * (dbg_lguint_t)scale2) / (dbg_lguint_t)scale3; break; case EXP_OP_SEG: rtn.type.id = dbg_itype_segptr; @@ -581,10 +581,10 @@ struct dbg_lvalue expr_eval(struct expr* exp) exp->un.binop.result = (types_extract_as_integer(&exp1) != types_extract_as_integer(&exp2)); break; case EXP_OP_SHL: - exp->un.binop.result = ((UINT_PTR)types_extract_as_integer(&exp1) << types_extract_as_integer(&exp2)); + exp->un.binop.result = types_extract_as_integer(&exp1) << types_extract_as_integer(&exp2); break; case EXP_OP_SHR: - exp->un.binop.result = ((UINT_PTR)types_extract_as_integer(&exp1) >> types_extract_as_integer(&exp2)); + exp->un.binop.result = types_extract_as_integer(&exp1) >> types_extract_as_integer(&exp2); break; case EXP_OP_MUL: exp->un.binop.result = (types_extract_as_integer(&exp1) * types_extract_as_integer(&exp2)); @@ -609,7 +609,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) exp1 = expr_eval(exp->un.unop.exp1); if (exp1.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); rtn.addr.Offset = (ULONG_PTR)&exp->un.unop.result; - rtn.type.id = dbg_itype_signed_long_int; + rtn.type.id = dbg_itype_lgint; rtn.type.module = 0; switch (exp->un.unop.unop_type) { @@ -687,10 +687,10 @@ BOOL expr_print(const struct expr* exp) dbg_printf("$%s", exp->un.intvar.name); break; case EXPR_TYPE_U_CONST: - dbg_printf("%Iu", exp->un.u_const.value); + dbg_printf("%I64u", exp->un.u_const.value); break; case EXPR_TYPE_S_CONST: - dbg_printf("%Id", exp->un.s_const.value); + dbg_printf("%I64d", exp->un.s_const.value); break; case EXPR_TYPE_STRING: dbg_printf(""%s"", exp->un.string.str); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 1653736e919..b666b077077 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -509,7 +509,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) if (format != 0) { unsigned size; - LONGLONG res = types_extract_as_longlong(lvalue, &size, NULL); + dbg_lgint_t res = types_extract_as_longlong(lvalue, &size, NULL); WCHAR wch;
switch (format) diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 9d82171c2c1..e940cfbc3b7 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -52,10 +52,10 @@ BOOL types_get_real_type(struct dbg_type* type, DWORD* tag) * Given a lvalue, try to get an integral (or pointer/address) value * out of it */ -LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue, - unsigned* psize, BOOL *issigned) +dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue* lvalue, + unsigned* psize, BOOL *issigned) { - LONGLONG rtn = 0; + dbg_lgint_t rtn = 0; DWORD tag, bt; DWORD64 size; struct dbg_type type = lvalue->type; @@ -136,7 +136,7 @@ LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue, * Given a lvalue, try to get an integral (or pointer/address) value * out of it */ -INT_PTR types_extract_as_integer(const struct dbg_lvalue* lvalue) +dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue* lvalue) { return types_extract_as_longlong(lvalue, NULL, NULL); } @@ -161,7 +161,7 @@ void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr)
BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from) { - LONGLONG val; + dbg_lgint_t val; DWORD64 size; BOOL is_signed;
@@ -777,6 +777,24 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v
switch (type->id) { + case dbg_itype_lguint: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = sizeof(dbg_lguint_t); break; + case TI_GET_BASETYPE: X(DWORD) = btUInt; break; + default: WINE_FIXME("unsupported %u for lguint_t\n", ti); return FALSE; + } + break; + case dbg_itype_lgint: + switch (ti) + { + case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break; + case TI_GET_LENGTH: X(DWORD64) = sizeof(dbg_lgint_t); break; + case TI_GET_BASETYPE: X(DWORD) = btInt; break; + default: WINE_FIXME("unsupported %u for lgint_t\n", ti); return FALSE; + } + break; case dbg_itype_unsigned_long_int: switch (ti) {
all integer code assume CPU of debuggee encode integers: - little endian - 2 complement for signed integers
so remove methods related to integer storage from CPU backends (they're all the same anyway)
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/be_arm.c | 30 ------------------------------ programs/winedbg/be_arm64.c | 30 ------------------------------ programs/winedbg/be_cpu.h | 4 ---- programs/winedbg/be_i386.c | 30 ------------------------------ programs/winedbg/be_x86_64.c | 30 ------------------------------ programs/winedbg/debugger.h | 3 +++ programs/winedbg/memory.c | 40 ++++++++++++++++++++++++++++++++++------ programs/winedbg/types.c | 15 +++++++-------- 8 files changed, 44 insertions(+), 138 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index 435dad2e3cc..02f72e9c789 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1831,27 +1831,6 @@ static int be_arm_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return step; }
-static BOOL be_arm_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG* ret) -{ - /* size must fit in ret and be a power of two */ - if (size > sizeof(*ret) || (size & (size - 1))) return FALSE; - - memset(ret, 0, sizeof(*ret)); /* clear unread bytes */ - /* FIXME: this assumes that debuggee and debugger use the same - * integral representation - */ - if (!memory_read_value(lvalue, size, ret)) return FALSE; - - /* propagate sign information */ - if (is_signed && size < 8 && (*ret >> (size * 8 - 1)) != 0) - { - ULONGLONG neg = -1; - *ret |= neg << (size * 8); - } - return TRUE; -} - static BOOL be_arm_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) { char tmp[sizeof(double)]; @@ -1869,13 +1848,6 @@ static BOOL be_arm_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, d return TRUE; }
-static BOOL be_arm_store_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG val) -{ - /* this is simple if we're on a little endian CPU */ - return memory_write_value(lvalue, size, &val); -} - static BOOL be_arm_get_context(HANDLE thread, dbg_ctx_t *ctx) { ctx->ctx.ContextFlags = CONTEXT_ALL; @@ -1932,9 +1904,7 @@ struct backend_cpu be_arm = be_arm_is_watchpoint_set, be_arm_clear_watchpoint, be_arm_adjust_pc_for_break, - be_arm_fetch_integer, be_arm_fetch_float, - be_arm_store_integer, be_arm_get_context, be_arm_set_context, be_arm_gdb_register_map, diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index 39f17c7d67d..8ca54e6c461 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -228,27 +228,6 @@ static int be_arm64_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return 4; }
-static BOOL be_arm64_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG* ret) -{ - /* size must fit in ret and be a power of two */ - if (size > sizeof(*ret) || (size & (size - 1))) return FALSE; - - memset(ret, 0, sizeof(*ret)); /* clear unread bytes */ - /* FIXME: this assumes that debuggee and debugger use the same - * integral representation - */ - if (!memory_read_value(lvalue, size, ret)) return FALSE; - - /* propagate sign information */ - if (is_signed && size < 8 && (*ret >> (size * 8 - 1)) != 0) - { - ULONGLONG neg = -1; - *ret |= neg << (size * 8); - } - return TRUE; -} - static BOOL be_arm64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) { char tmp[sizeof(double)]; @@ -266,13 +245,6 @@ static BOOL be_arm64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, return TRUE; }
-static BOOL be_arm64_store_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG val) -{ - /* this is simple if we're on a little endian CPU */ - return memory_write_value(lvalue, size, &val); -} - void be_arm64_disasm_one_insn(ADDRESS64 *addr, int display) { dbg_printf("be_arm64_disasm_one_insn: not done\n"); @@ -351,9 +323,7 @@ struct backend_cpu be_arm64 = be_arm64_is_watchpoint_set, be_arm64_clear_watchpoint, be_arm64_adjust_pc_for_break, - be_arm64_fetch_integer, be_arm64_fetch_float, - be_arm64_store_integer, be_arm64_get_context, be_arm64_set_context, be_arm64_gdb_register_map, diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index 14746d6665b..69e3e148f75 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -118,12 +118,8 @@ struct backend_cpu /* ------------------------------------------------------------------------------- * basic type read/write * -------------------------------------------------------------------------------*/ - /* Reads an integer from memory and stores it inside a long long int */ - BOOL (*fetch_integer)(const struct dbg_lvalue* lvalue, unsigned size, BOOL is_signed, LONGLONG*); /* Reads a real from memory and stores it inside a long double */ BOOL (*fetch_float)(const struct dbg_lvalue* lvalue, unsigned size, double*); - /* Writes an integer to memory */ - BOOL (*store_integer)(const struct dbg_lvalue* lvalue, unsigned size, BOOL is_signed, LONGLONG);
BOOL (*get_context)(HANDLE thread, dbg_ctx_t *ctx); BOOL (*set_context)(HANDLE thread, const dbg_ctx_t *ctx); diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index 8902185d0b0..9b3c615092c 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -777,27 +777,6 @@ static int be_i386_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return 1; }
-static BOOL be_i386_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG* ret) -{ - /* size must fit in ret and be a power of two */ - if (size > sizeof(*ret) || (size & (size - 1))) return FALSE; - - memset(ret, 0, sizeof(*ret)); /* clear unread bytes */ - /* FIXME: this assumes that debuggee and debugger use the same - * integral representation - */ - if (!memory_read_value(lvalue, size, ret)) return FALSE; - - /* propagate sign information */ - if (is_signed && size < 8 && (*ret >> (size * 8 - 1)) != 0) - { - ULONGLONG neg = -1; - *ret |= neg << (size * 8); - } - return TRUE; -} - static BOOL be_i386_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) { char tmp[sizeof(double)]; @@ -815,13 +794,6 @@ static BOOL be_i386_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, return TRUE; }
-static BOOL be_i386_store_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG val) -{ - /* this is simple as we're on a little endian CPU */ - return memory_write_value(lvalue, size, &val); -} - static BOOL be_i386_get_context(HANDLE thread, dbg_ctx_t *ctx) { ctx->x86.ContextFlags = WOW64_CONTEXT_ALL; @@ -903,9 +875,7 @@ struct backend_cpu be_i386 = be_i386_is_watchpoint_set, be_i386_clear_watchpoint, be_i386_adjust_pc_for_break, - be_i386_fetch_integer, be_i386_fetch_float, - be_i386_store_integer, be_i386_get_context, be_i386_set_context, be_i386_gdb_register_map, diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index af9f7284685..169a31a584d 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -699,27 +699,6 @@ static int be_x86_64_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return 1; }
-static BOOL be_x86_64_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG* ret) -{ - /* size must fit in ret and be a power of two */ - if (size > sizeof(*ret) || (size & (size - 1))) return FALSE; - - memset(ret, 0, sizeof(*ret)); /* clear unread bytes */ - /* FIXME: this assumes that debuggee and debugger use the same - * integral representation - */ - if (!memory_read_value(lvalue, size, ret)) return FALSE; - - /* propagate sign information */ - if (is_signed && size < sizeof(*ret) && (*ret >> (size * 8 - 1)) != 0) - { - ULONGLONG neg = -1; - *ret |= neg << (size * 8); - } - return TRUE; -} - static BOOL be_x86_64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) { char tmp[sizeof(double)]; @@ -737,13 +716,6 @@ static BOOL be_x86_64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size return TRUE; }
-static BOOL be_x86_64_store_integer(const struct dbg_lvalue* lvalue, unsigned size, - BOOL is_signed, LONGLONG val) -{ - /* this is simple as we're on a little endian CPU */ - return memory_write_value(lvalue, size, &val); -} - static BOOL be_x86_64_get_context(HANDLE thread, dbg_ctx_t *ctx) { ctx->ctx.ContextFlags = CONTEXT_ALL; @@ -841,9 +813,7 @@ struct backend_cpu be_x86_64 = be_x86_64_is_watchpoint_set, be_x86_64_clear_watchpoint, be_x86_64_adjust_pc_for_break, - be_x86_64_fetch_integer, be_x86_64_fetch_float, - be_x86_64_store_integer, be_x86_64_get_context, be_x86_64_set_context, be_x86_64_gdb_register_map, diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index d337381eb22..c3bc3c76fbe 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -373,6 +373,9 @@ extern void info_wine_dbg_channel(BOOL add, const char* chnl, const /* memory.c */ extern BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result); extern BOOL memory_write_value(const struct dbg_lvalue* val, DWORD size, void* value); +extern BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, + BOOL is_signed, dbg_lgint_t* ret); +extern BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val); extern void memory_examine(const struct dbg_lvalue *lvalue, int count, char format); extern void* memory_to_linear_addr(const ADDRESS64* address); extern BOOL memory_get_current_pc(ADDRESS64* address); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index b666b077077..4fb62e9e9d5 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -231,6 +231,34 @@ void memory_examine(const struct dbg_lvalue *lvalue, int count, char format) } }
+BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, + BOOL is_signed, dbg_lgint_t* ret) +{ + /* size must fit in ret and be a power of two */ + if (size > sizeof(*ret) || (size & (size - 1))) return FALSE; + + /* we are on little endian CPU */ + memset(ret, 0, sizeof(*ret)); /* clear unread bytes */ + if (!memory_read_value(lvalue, size, ret)) return FALSE; + + /* propagate sign information */ + if (is_signed && size < 8 && (*ret >> (size * 8 - 1)) != 0) + { + dbg_lguint_t neg = -1; + *ret |= neg << (size * 8); + } + return TRUE; +} + +BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val) +{ + DWORD64 size; + if (!types_get_info(&lvalue->type, TI_GET_LENGTH, &size)) return FALSE; + /* this is simple if we're on a little endian CPU */ + return memory_write_value(lvalue, (unsigned)size, &val); +} + + BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee, BOOL unicode, char* buffer, int size) { @@ -343,7 +371,7 @@ static void dbg_print_hex(DWORD size, ULONGLONG sv)
static void print_typed_basic(const struct dbg_lvalue* lvalue) { - LONGLONG val_int; + dbg_lgint_t val_int; void* val_ptr; double val_real; DWORD64 size64; @@ -369,13 +397,13 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) { case btInt: case btLong: - if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return; + 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: case btULong: - if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, FALSE, &val_int)) return; + if (!memory_fetch_integer(lvalue, size, FALSE, &val_int)) return; dbg_print_hex(size, val_int); break; case btFloat: @@ -387,7 +415,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) /* sometimes WCHAR is defined as btChar with size = 2, so discrimate * Ansi/Unicode based on size, not on basetype */ - if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return; + 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))) @@ -396,7 +424,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) dbg_printf("%d", (int)val_int); break; case btBool: - if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return; + if (!memory_fetch_integer(lvalue, size, TRUE, &val_int)) return; dbg_printf("%s", val_int ? "true" : "false"); break; default: @@ -441,7 +469,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) BOOL ok = FALSE;
if (!types_get_info(&type, TI_GET_LENGTH, &size64) || - !dbg_curr_process->be_cpu->fetch_integer(lvalue, size64, TRUE, &val_int)) return; + !memory_fetch_integer(lvalue, size64, TRUE, &val_int)) return;
if (types_get_info(&type, TI_GET_CHILDRENCOUNT, &count)) { diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index e940cfbc3b7..5c8969d8e23 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -91,11 +91,11 @@ dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue* lvalue, { case btChar: case btInt: - if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, (unsigned)size, s = TRUE, &rtn)) + if (!memory_fetch_integer(lvalue, (unsigned)size, s = TRUE, &rtn)) RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); break; case btUInt: - if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn)) + if (!memory_fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn)) RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); break; case btFloat: @@ -106,17 +106,17 @@ dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue* lvalue, break; case SymTagPointerType: if (!types_get_info(&type, TI_GET_LENGTH, &size) || - !dbg_curr_process->be_cpu->fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn)) + !memory_fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn)) RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); break; case SymTagArrayType: case SymTagUDT: - if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, sizeof(unsigned), s = FALSE, &rtn)) + if (!memory_fetch_integer(lvalue, sizeof(unsigned), s = FALSE, &rtn)) RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); break; case SymTagEnum: if (!types_get_info(&type, TI_GET_LENGTH, &size) || - !dbg_curr_process->be_cpu->fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn)) + !memory_fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn)) RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL); break; case SymTagFunctionType: @@ -163,7 +163,6 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv { dbg_lgint_t val; DWORD64 size; - BOOL is_signed;
if (!types_get_info(&lvalue_to->type, TI_GET_LENGTH, &size)) return FALSE; if (sizeof(val) < size) @@ -172,8 +171,8 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv return FALSE; } /* FIXME: should support floats as well */ - val = types_extract_as_longlong(lvalue_from, NULL, &is_signed); - return dbg_curr_process->be_cpu->store_integer(lvalue_to, size, is_signed, val); + val = types_extract_as_integer(lvalue_from); + return memory_store_integer(lvalue_to, val); }
/******************************************************************
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 2 +- programs/winedbg/memory.c | 4 ++-- programs/winedbg/types.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index c3bc3c76fbe..5da569574f7 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -465,7 +465,7 @@ extern void print_value(const struct dbg_lvalue* addr, char format, extern BOOL types_print_type(const struct dbg_type*, BOOL details); extern BOOL print_types(void); extern dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue*); -extern dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned); +extern dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned); extern void types_extract_as_address(const struct dbg_lvalue*, ADDRESS64*); extern BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from); extern BOOL types_udt_find_element(struct dbg_lvalue* value, const char* name, ULONG *tmpbuf); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 4fb62e9e9d5..db4060d816a 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -537,7 +537,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) if (format != 0) { unsigned size; - dbg_lgint_t res = types_extract_as_longlong(lvalue, &size, NULL); + dbg_lgint_t res = types_extract_as_lgint(lvalue, &size, NULL); WCHAR wch;
switch (format) @@ -570,7 +570,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) } if (lvalue->type.id == dbg_itype_segptr) { - dbg_print_longlong(types_extract_as_longlong(lvalue, NULL, NULL), TRUE); + dbg_print_longlong(types_extract_as_lgint(lvalue, NULL, NULL), TRUE); } else print_typed_basic(lvalue); } diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 5c8969d8e23..74ba06cc31c 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -47,13 +47,13 @@ BOOL types_get_real_type(struct dbg_type* type, DWORD* tag) }
/****************************************************************** - * types_extract_as_longlong + * types_extract_as_lgint * * Given a lvalue, try to get an integral (or pointer/address) value * out of it */ -dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue* lvalue, - unsigned* psize, BOOL *issigned) +dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue* lvalue, + unsigned* psize, BOOL *issigned) { dbg_lgint_t rtn = 0; DWORD tag, bt; @@ -138,7 +138,7 @@ dbg_lgint_t types_extract_as_longlong(const struct dbg_lvalue* lvalue, */ dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue* lvalue) { - return types_extract_as_longlong(lvalue, NULL, NULL); + return types_extract_as_lgint(lvalue, NULL, NULL); }
/****************************************************************** @@ -155,7 +155,7 @@ void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr) else { addr->Mode = AddrModeFlat; - addr->Offset = types_extract_as_longlong(lvalue, NULL, NULL); + addr->Offset = types_extract_as_lgint(lvalue, NULL, NULL); } }
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/memory.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index db4060d816a..b0111d69221 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -346,21 +346,12 @@ char* memory_offset_to_string(char *str, DWORD64 offset, unsigned mode) return str; }
-static void dbg_print_longlong(LONGLONG sv, BOOL is_signed) +static inline void dbg_print_sdecimal(dbg_lgint_t sv) { - char tmp[24], *ptr = tmp + sizeof(tmp) - 1; - ULONGLONG uv, div; - *ptr = '\0'; - if (is_signed && sv < 0) uv = -sv; - else { uv = sv; is_signed = FALSE; } - for (div = 10; uv; div *= 10, uv /= 10) - *--ptr = '0' + (uv % 10); - if (ptr == tmp + sizeof(tmp) - 1) *--ptr = '0'; - if (is_signed) *--ptr = '-'; - dbg_printf("%s", ptr); + dbg_printf("%I64d", sv); }
-static void dbg_print_hex(DWORD size, ULONGLONG sv) +static void dbg_print_hex(DWORD size, dbg_lgint_t sv) { if (!sv) dbg_printf("0"); @@ -512,7 +503,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) fcp->Start += 256; } } - if (!ok) dbg_print_longlong(val_int, TRUE); + if (!ok) dbg_print_sdecimal(val_int); } break; default: @@ -543,11 +534,11 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) switch (format) { case 'x': - dbg_print_hex(size, (ULONGLONG)res); + dbg_print_hex(size, res); return;
case 'd': - dbg_print_longlong(res, TRUE); + dbg_print_sdecimal(res); return;
case 'c': @@ -570,7 +561,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) } if (lvalue->type.id == dbg_itype_segptr) { - dbg_print_longlong(types_extract_as_lgint(lvalue, NULL, NULL), TRUE); + dbg_print_sdecimal(types_extract_as_integer(lvalue)); } else print_typed_basic(lvalue); }
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/break.c | 4 ++-- programs/winedbg/debugger.h | 25 ++++++++++++++++++------ programs/winedbg/expr.c | 45 +++++++++++-------------------------------- programs/winedbg/memory.c | 6 +++--- programs/winedbg/stack.c | 4 +--- programs/winedbg/symbol.c | 21 +++++++------------- programs/winedbg/types.c | 6 +++--- 7 files changed, 46 insertions(+), 65 deletions(-)
diff --git a/programs/winedbg/break.c b/programs/winedbg/break.c index d22dd7ac074..27a11a00d33 100644 --- a/programs/winedbg/break.c +++ b/programs/winedbg/break.c @@ -357,7 +357,7 @@ void break_check_delayed_bp(void) if (symbol_get_lvalue(dbp[i].u.symbol.name, dbp[i].u.symbol.lineno, &lvalue, TRUE) != sglv_found) continue; - if (lvalue.cookie != DLV_TARGET) continue; + if (!lvalue.in_debuggee) continue; } else lvalue.addr = dbp[i].u.addr; @@ -385,7 +385,7 @@ static void break_add_watch(const struct dbg_lvalue* lvalue, BOOL is_write) int num; DWORD64 l = 4;
- if (lvalue->cookie == DLV_HOST) + if (!lvalue->in_debuggee) { dbg_printf("Cannot set a watch point on register or register-based variable\n"); return; diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 5da569574f7..d3073c15f39 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -117,16 +117,29 @@ struct dbg_type
struct dbg_lvalue /* structure to hold left-values... */ { - int cookie; /* DLV_??? */ -/* DLV_TARGET references an address in debuggee's address space, whereas DLV_HOST - * references the winedbg's address space - */ -# define DLV_TARGET 0xF00D -# define DLV_HOST 0x50DA + unsigned in_debuggee : 1; /* 1 = debuggee address space, 0 = debugger address space) */ ADDRESS64 addr; struct dbg_type type; };
+static inline void init_lvalue(struct dbg_lvalue* lv, BOOL in_debuggee, void* addr) +{ + lv->in_debuggee = !!in_debuggee; + lv->addr.Mode = AddrModeFlat; + lv->addr.Offset = (DWORD_PTR)addr; + lv->type.module = 0; + lv->type.id = dbg_itype_none; +} + +static inline void init_lvalue_in_debugger(struct dbg_lvalue* lv, enum dbg_internal_types it, void* addr) +{ + lv->in_debuggee = 0; + lv->addr.Mode = AddrModeFlat; + lv->addr.Offset = (DWORD_PTR)addr; + lv->type.module = 0; + lv->type.id = it; +} + enum dbg_exec_mode { dbg_exec_cont, /* Continue execution */ diff --git a/programs/winedbg/expr.c b/programs/winedbg/expr.c index 70bf6316785..e7c41094544 100644 --- a/programs/winedbg/expr.c +++ b/programs/winedbg/expr.c @@ -281,12 +281,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) DWORD tag; const struct dbg_internal_var* div;
- rtn.cookie = 0; - rtn.type.id = dbg_itype_none; - rtn.type.module = 0; - rtn.addr.Mode = AddrModeFlat; - rtn.addr.Offset = 0; - rtn.addr.Segment = 0; + init_lvalue_in_debugger(&rtn, dbg_itype_none, NULL);
switch (exp->type) { @@ -340,22 +335,13 @@ struct dbg_lvalue expr_eval(struct expr* exp) } break; case EXPR_TYPE_STRING: - rtn.cookie = DLV_HOST; - rtn.type.id = dbg_itype_astring; - rtn.type.module = 0; - rtn.addr.Offset = (ULONG_PTR)&exp->un.string.str; + init_lvalue_in_debugger(&rtn, dbg_itype_astring, &exp->un.string.str); break; case EXPR_TYPE_U_CONST: - rtn.cookie = DLV_HOST; - rtn.type.id = dbg_itype_lguint; - rtn.type.module = 0; - rtn.addr.Offset = (ULONG_PTR)&exp->un.u_const.value; + init_lvalue_in_debugger(&rtn, dbg_itype_lguint, &exp->un.u_const.value); break; case EXPR_TYPE_S_CONST: - rtn.cookie = DLV_HOST; - rtn.type.id = dbg_itype_lgint; - rtn.type.module = 0; - rtn.addr.Offset = (ULONG_PTR)&exp->un.s_const.value; + init_lvalue_in_debugger(&rtn, dbg_itype_lgint, &exp->un.s_const.value); break; case EXPR_TYPE_SYMBOL: switch (symbol_get_lvalue(exp->un.symbol.name, -1, &rtn, FALSE)) @@ -457,28 +443,22 @@ struct dbg_lvalue expr_eval(struct expr* exp) */ exp->un.call.result = 0; #endif - rtn.cookie = DLV_HOST; - /* get return type from function signature tupe */ + init_lvalue_in_debugger(&rtn, 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); - rtn.addr.Offset = (ULONG_PTR)&exp->un.call.result; break; case EXPR_TYPE_INTVAR: - rtn.cookie = DLV_HOST; if (!(div = dbg_get_internal_var(exp->un.intvar.name))) RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL); - rtn.type.id = div->typeid; - rtn.type.module = 0; - rtn.addr.Offset = (ULONG_PTR)div->pval; + init_lvalue_in_debugger(&rtn, div->typeid, div->pval); break; case EXPR_TYPE_BINOP: - rtn.cookie = DLV_HOST; 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); - rtn.type.id = dbg_itype_lgint; - rtn.type.module = 0; - rtn.addr.Offset = (ULONG_PTR)&exp->un.binop.result; + init_lvalue_in_debugger(&rtn, dbg_itype_lgint, &exp->un.binop.result); type1 = exp1.type; type2 = exp2.type; switch (exp->un.binop.binop_type) @@ -605,12 +585,9 @@ struct dbg_lvalue expr_eval(struct expr* exp) } break; case EXPR_TYPE_UNOP: - rtn.cookie = DLV_HOST; exp1 = expr_eval(exp->un.unop.exp1); if (exp1.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); - rtn.addr.Offset = (ULONG_PTR)&exp->un.unop.result; - rtn.type.id = dbg_itype_lgint; - rtn.type.module = 0; + init_lvalue_in_debugger(&rtn, dbg_itype_lgint, &exp->un.unop.result); switch (exp->un.unop.unop_type) { case EXP_OP_NEG: @@ -628,7 +605,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) break; case EXP_OP_FORCE_DEREF: rtn = exp1; - if (exp1.cookie == DLV_TARGET) + 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: diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index a0f201e0423..68c66db7270 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -84,7 +84,7 @@ BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result { BOOL ret = FALSE;
- if (lvalue->cookie == DLV_TARGET) + if (lvalue->in_debuggee) { void* linear = memory_to_linear_addr(&lvalue->addr); if (!(ret = dbg_read_memory(linear, result, size))) @@ -120,7 +120,7 @@ BOOL memory_write_value(const struct dbg_lvalue* lvalue, DWORD size, void* value }
/* FIXME: only works on little endian systems */ - if (lvalue->cookie == DLV_TARGET) + if (lvalue->in_debuggee) { void* linear = memory_to_linear_addr(&lvalue->addr); if (!(ret = dbg_write_memory(linear, value, size))) @@ -445,7 +445,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) if (!val_ptr) dbg_printf("0x0"); else if (((bt == btChar || bt == btInt) && size64 == 1) || (bt == btUInt && size64 == 2)) { - if (memory_get_string(dbg_curr_process, val_ptr, sub_lvalue.cookie == DLV_TARGET, + if (memory_get_string(dbg_curr_process, val_ptr, sub_lvalue.in_debuggee, size64 == 2, buffer, sizeof(buffer))) dbg_printf(""%s"", buffer); else diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index 34089bcde04..c8352d8a994 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -39,10 +39,8 @@ void stack_info(int len)
if(len <= 0) len = 24; - - lvalue.cookie = 0; + init_lvalue(&lvalue, TRUE, 0); lvalue.type.id = dbg_itype_segptr; - lvalue.type.module = 0;
/* FIXME: we assume stack grows the same way as on i386 */ if (!memory_get_current_stack(&lvalue.addr)) diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c index 896690c9eaf..08e0317154e 100644 --- a/programs/winedbg/symbol.c +++ b/programs/winedbg/symbol.c @@ -71,8 +71,7 @@ static BOOL fill_sym_lvalue(const SYMBOL_INFO* sym, ULONG_PTR base,
if (!memory_get_register(sym->Register, &pval, buffer, sz)) return FALSE; - lvalue->cookie = DLV_HOST; - lvalue->addr.Offset = (DWORD_PTR)pval; + init_lvalue(lvalue, FALSE, pval); } else if (sym->Flags & SYMFLAG_REGREL) { @@ -85,8 +84,7 @@ static BOOL fill_sym_lvalue(const SYMBOL_INFO* sym, ULONG_PTR base, l = strlen(buffer); sz -= l; buffer += l; - lvalue->cookie = DLV_TARGET; - lvalue->addr.Offset = (ULONG64)*pval + sym->Address; + init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)(*pval + sym->Address)); if ((LONG64)sym->Address >= 0) snprintf(buffer, sz, "+%I64d]", sym->Address); else @@ -119,21 +117,18 @@ static BOOL fill_sym_lvalue(const SYMBOL_INFO* sym, ULONG_PTR base, /* this is likely Wine's dbghelp which passes const values by reference * (object is managed by dbghelp, hence in debugger address space) */ - lvalue->cookie = DLV_HOST; - lvalue->addr.Offset = (DWORD_PTR)sym->Value; + init_lvalue(lvalue, FALSE, (void*)(DWORD_PTR)sym->Value); } else { DWORD* pdw = (DWORD*)lexeme_alloc_size(sizeof(*pdw)); - lvalue->cookie = DLV_HOST; - lvalue->addr.Offset = (DWORD_PTR)pdw; + init_lvalue(lvalue, FALSE, pdw); *pdw = sym->Value; } } else if (sym->Flags & SYMFLAG_LOCAL) { - lvalue->cookie = DLV_TARGET; - lvalue->addr.Offset = base + sym->Address; + init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)(base + sym->Address)); } else if (sym->Flags & SYMFLAG_TLSREL) { @@ -176,13 +171,11 @@ static BOOL fill_sym_lvalue(const SYMBOL_INFO* sym, ULONG_PTR base,
addr += tlsindex * sizeof(DWORD_PTR); if (!dbg_read_memory((void*)addr, &addr, sizeof(addr))) goto tls_error; - lvalue->cookie = DLV_TARGET; - lvalue->addr.Offset = addr + sym->Address; + init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)(addr + sym->Address)); } else { - lvalue->cookie = DLV_TARGET; - lvalue->addr.Offset = sym->Address; + init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)sym->Address); } lvalue->addr.Mode = AddrModeFlat; lvalue->type.module = sym->ModBase; diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 74ba06cc31c..de1fee9f84b 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -211,7 +211,7 @@ static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue, *tmpbuf >>= bitoffset & 7; *tmpbuf &= ~mask;
- lvalue->cookie = DLV_HOST; + lvalue->in_debuggee = 0; lvalue->addr.Offset = (ULONG_PTR)tmpbuf;
/* @@ -337,7 +337,7 @@ BOOL types_array_index(const struct dbg_lvalue* lvalue, int index, struct dbg_lv * internal variables is very unlikely. A correct fix would be * rather large. */ - result->cookie = DLV_TARGET; + result->in_debuggee = 1; return TRUE; }
@@ -531,7 +531,7 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level) unsigned len = min(count, sizeof(buffer)); memory_get_string(dbg_curr_process, memory_to_linear_addr(&lvalue->addr), - lvalue->cookie == DLV_TARGET, TRUE, buffer, len); + lvalue->in_debuggee, TRUE, buffer, len); dbg_printf(""%s%s"", buffer, (len < count) ? "..." : ""); break; }
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index d3073c15f39..8a8921cb685 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -117,7 +117,9 @@ struct dbg_type
struct dbg_lvalue /* structure to hold left-values... */ { - unsigned in_debuggee : 1; /* 1 = debuggee address space, 0 = debugger address space) */ + unsigned in_debuggee : 1, /* 1 = debuggee address space, 0 = debugger address space) */ + bitstart : 8, /* in fact, 7 should be sufficient for underlying 128bit integers */ + bitlen; ADDRESS64 addr; struct dbg_type type; }; @@ -125,6 +127,8 @@ struct dbg_lvalue /* structure to hold left-values... */ static inline void init_lvalue(struct dbg_lvalue* lv, BOOL in_debuggee, void* addr) { lv->in_debuggee = !!in_debuggee; + lv->bitstart = 0; + lv->bitlen = 0; lv->addr.Mode = AddrModeFlat; lv->addr.Offset = (DWORD_PTR)addr; lv->type.module = 0; @@ -134,6 +138,8 @@ static inline void init_lvalue(struct dbg_lvalue* lv, BOOL in_debuggee, void* ad static inline void init_lvalue_in_debugger(struct dbg_lvalue* lv, 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;
(extraction is made on bitfield of width up to dbg_lgint_t size instead of LONG)
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 2 +- programs/winedbg/expr.c | 7 ++---- programs/winedbg/memory.c | 48 +++++++++++++++++++++++++++++++++++------- programs/winedbg/types.c | 49 +++++++++++-------------------------------- programs/winedbg/winedbg.c | 6 +++-- 5 files changed, 58 insertions(+), 54 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 8a8921cb685..2e316548511 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -487,7 +487,7 @@ extern dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue*); extern dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned); extern void types_extract_as_address(const struct dbg_lvalue*, ADDRESS64*); extern BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from); -extern BOOL types_udt_find_element(struct dbg_lvalue* value, const char* name, ULONG *tmpbuf); +extern BOOL types_udt_find_element(struct dbg_lvalue* value, const char* name); 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); diff --git a/programs/winedbg/expr.c b/programs/winedbg/expr.c index e7c41094544..5d9ef30ad13 100644 --- a/programs/winedbg/expr.c +++ b/programs/winedbg/expr.c @@ -83,7 +83,6 @@ struct expr { struct expr* exp1; const char* element_name; - ULONG /* FIXME */ result; } structure;
struct @@ -361,8 +360,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) if (exp1.type.id == dbg_itype_none || !types_array_index(&exp1, 0, &rtn) || rtn.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); - if (!types_udt_find_element(&rtn, exp->un.structure.element_name, - &exp->un.structure.result)) + if (!types_udt_find_element(&rtn, exp->un.structure.element_name)) { dbg_printf("%s\n", exp->un.structure.element_name); RaiseException(DEBUG_STATUS_NO_FIELD, 0, 0, NULL); @@ -372,8 +370,7 @@ struct dbg_lvalue expr_eval(struct expr* exp) exp1 = expr_eval(exp->un.structure.exp1); if (exp1.type.id == dbg_itype_none) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); rtn = exp1; - if (!types_udt_find_element(&rtn, exp->un.structure.element_name, - &exp->un.structure.result)) + if (!types_udt_find_element(&rtn, exp->un.structure.element_name)) { dbg_printf("%s\n", exp->un.structure.element_name); RaiseException(DEBUG_STATUS_NO_FIELD, 0, 0, NULL); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 68c66db7270..fd8293687b6 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -237,15 +237,47 @@ BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, /* size must fit in ret and be a power of two */ if (size > sizeof(*ret) || (size & (size - 1))) return FALSE;
- /* we are on little endian CPU */ - memset(ret, 0, sizeof(*ret)); /* clear unread bytes */ - if (!memory_read_value(lvalue, size, ret)) return FALSE; - - /* propagate sign information */ - if (is_signed && size < 8 && (*ret >> (size * 8 - 1)) != 0) + if (lvalue->bitlen) { - dbg_lguint_t neg = -1; - *ret |= neg << (size * 8); + struct dbg_lvalue alt_lvalue = *lvalue; + dbg_lguint_t mask; + DWORD bt; + /* FIXME: this test isn't sufficient, depending on start of bitfield + * (ie a 64 bit field can spread across 9 bytes) + */ + if (lvalue->bitlen > 8 * sizeof(dbg_lgint_t)) return FALSE; + alt_lvalue.addr.Offset += lvalue->bitstart >> 3; + /* + * Bitfield operation. We have to extract the field. + */ + if (!memory_read_value(&alt_lvalue, sizeof(*ret), ret)) return FALSE; + mask = ~(dbg_lguint_t)0 << lvalue->bitlen; + *ret >>= lvalue->bitstart & 7; + *ret &= ~mask; + + /* + * OK, now we have the correct part of the number. + * Check to see whether the basic type is signed or not, and if so, + * we need to sign extend the number. + */ + if (types_get_info(&lvalue->type, TI_GET_BASETYPE, &bt) && + (bt == btInt || bt == btLong) && (*ret & (1 << (lvalue->bitlen - 1)))) + { + *ret |= mask; + } + } + else + { + /* we are on little endian CPU */ + memset(ret, 0, sizeof(*ret)); /* clear unread bytes */ + if (!memory_read_value(lvalue, size, ret)) return FALSE; + + /* propagate sign information */ + if (is_signed && size < 8 && (*ret >> (size * 8 - 1)) != 0) + { + dbg_lguint_t neg = -1; + *ret |= neg << (size * 8); + } } return TRUE; } diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index de1fee9f84b..8f16a535606 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -68,6 +68,7 @@ dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue* lvalue, { return (LONG_PTR)memory_to_linear_addr(&lvalue->addr); } + if (tag != SymTagBaseType && lvalue->bitlen) dbg_printf("Unexpected bitfield on tag %d\n", tag);
if (psize) *psize = 0; if (issigned) *issigned = FALSE; @@ -180,15 +181,11 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv * * Implement a structure derefencement */ -static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue, - const struct dbg_type* type, ULONG *tmpbuf) +static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue, const struct dbg_type* type) { DWORD offset, bitoffset; - DWORD bt; DWORD64 length;
- unsigned mask; - types_get_info(type, TI_GET_TYPE, &lvalue->type.id); lvalue->type.module = type->module; if (!types_get_info(type, TI_GET_OFFSET, &offset)) return FALSE; @@ -197,38 +194,17 @@ static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue, if (types_get_info(type, TI_GET_BITPOSITION, &bitoffset)) { types_get_info(type, TI_GET_LENGTH, &length); - /* FIXME: this test isn't sufficient, depending on start of bitfield - * (ie a 32 bit field can spread across 5 bytes) - */ - if (length > 8 * sizeof(*tmpbuf)) return FALSE; - lvalue->addr.Offset += bitoffset >> 3; - /* - * Bitfield operation. We have to extract the field and store - * it in a temporary buffer so that we get it all right. - */ - if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE; - mask = 0xffffffff << (DWORD)length; - *tmpbuf >>= bitoffset & 7; - *tmpbuf &= ~mask; - - lvalue->in_debuggee = 0; - lvalue->addr.Offset = (ULONG_PTR)tmpbuf; - - /* - * OK, now we have the correct part of the number. - * Check to see whether the basic type is signed or not, and if so, - * we need to sign extend the number. - */ - if (types_get_info(&lvalue->type, TI_GET_BASETYPE, &bt) && - bt == btInt && (*tmpbuf & (1 << ((DWORD)length - 1)))) + lvalue->bitlen = length; + lvalue->bitstart = bitoffset; + if (lvalue->bitlen != length || lvalue->bitstart != bitoffset) { - *tmpbuf |= mask; + dbg_printf("too wide bitfields\n"); /* shouldn't happen */ + return FALSE; } } else - { - if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE; - } + lvalue->bitlen = lvalue->bitstart = 0; + return TRUE; }
@@ -236,7 +212,7 @@ static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue, * types_udt_find_element * */ -BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name, ULONG *tmpbuf) +BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name) { DWORD tag, count; char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)]; @@ -266,7 +242,7 @@ BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name, ULONG * WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL); HeapFree(GetProcessHeap(), 0, ptr); if (!strcmp(tmp, name)) - return types_get_udt_element_lvalue(lvalue, &type, tmpbuf); + return types_get_udt_element_lvalue(lvalue, &type); } } } @@ -475,7 +451,6 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level) char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)]; TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer; WCHAR* ptr; - ULONG tmpbuf; struct dbg_type sub_type;
dbg_printf("{"); @@ -493,7 +468,7 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level) dbg_printf("%ls=", ptr); HeapFree(GetProcessHeap(), 0, ptr); lvalue_field = *lvalue; - if (types_get_udt_element_lvalue(&lvalue_field, &sub_type, &tmpbuf)) + if (types_get_udt_element_lvalue(&lvalue_field, &sub_type)) { print_value(&lvalue_field, format, level + 1); } diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 283b126ba84..dab5fbd85a3 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -44,9 +44,9 @@ * - type management: * + some bits of internal types are missing (like type casts and the address * operator) - * + all computations should be made on long long - * o expr computations are in int:s - * o bitfield size is on a 4-bytes + * + all computations should be made on 64bit + * o bitfield spreading on more bytes than dbg_lgint_t isn't supported + * (can happen on 128bit integers, of an ELF build...) * - execution: * + set a better fix for gdb (proxy mode) than the step-mode hack * + implement function call in debuggee
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/type.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index b7eb49116e2..3140d30e0bc 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -613,8 +613,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(DWORD) = ((const struct symt_basic*)type)->bt; break; case SymTagEnum: - X(DWORD) = btInt; - break; + return symt_get_info(module, ((const struct symt_enum*)type)->base_type, req, pInfo); default: return FALSE; }
DbgHelp exposes in SymGetTypeInfo() requests for testing type equivalence, but native implementation is more than broken. So don't rely on DbgHelp (in sake of portability) and keep implementation inside debugger instead.
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 2 + programs/winedbg/types.c | 164 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 160 insertions(+), 6 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 2e316548511..35829e83f96 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -493,6 +493,8 @@ extern BOOL types_get_info(const struct dbg_type*, IMAGEHLP_SYMBOL_T 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_compare(const struct dbg_type, const struct dbg_type, BOOL* equal); +extern BOOL types_is_integral_type(const struct dbg_lvalue*);
/* winedbg.c */ extern void dbg_outputW(const WCHAR* buffer, int len); diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 8f16a535606..2d7bce5de7e 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -164,16 +164,33 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv { dbg_lgint_t val; DWORD64 size; + BOOL equal;
- if (!types_get_info(&lvalue_to->type, TI_GET_LENGTH, &size)) return FALSE; - if (sizeof(val) < size) + if (!lvalue_to->bitlen && !lvalue_from->bitlen) { - dbg_printf("Insufficient size\n"); - return FALSE; + if (!types_compare(lvalue_to->type, lvalue_from->type, &equal)) return FALSE; + if (equal) + { + if (!types_get_info(&lvalue_to->type, TI_GET_LENGTH, &size)) return FALSE; + if (sizeof(val) < size) + { + return memory_read_value(lvalue_from, size, &val) && + memory_write_value(lvalue_to, size, &val); + } + dbg_printf("NIY\n"); + /* else: should allocate intermediate buffer... */ + return FALSE; + } + } + if (types_is_integral_type(lvalue_from) && types_is_integral_type(lvalue_to)) + { + /* doing integer conversion (about sign, size) */ + val = types_extract_as_integer(lvalue_from); + return memory_store_integer(lvalue_to, val); } /* FIXME: should support floats as well */ - val = types_extract_as_integer(lvalue_from); - return memory_store_integer(lvalue_to, val); + dbg_printf("Cannot assign (different types)\n"); return FALSE; + return FALSE; }
/****************************************************************** @@ -910,3 +927,138 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v #undef X return TRUE; } + +BOOL types_compare(struct dbg_type type1, struct dbg_type type2, BOOL* equal); + +static BOOL types_compare_children(struct dbg_type type1, struct dbg_type type2, BOOL* equal) +{ + DWORD count1, count2, i; + DWORD* children; + BOOL ret = FALSE; + if (!types_get_info(&type1, TI_GET_CHILDRENCOUNT, &count1) || + !types_get_info(&type2, TI_GET_CHILDRENCOUNT, &count2)) return FALSE; + if (count1 != count2) {*equal = FALSE; return TRUE;} + if ((children = malloc(sizeof(*children) * 2 * count1)) == NULL) return FALSE; + if (types_get_info(&type1, TI_FINDCHILDREN, &children[0]) && + types_get_info(&type2, TI_FINDCHILDREN, &children[count1])) + { + for (i = 0; i < count1; ++i) + { + type1.id = children[i]; + type2.id = children[count1 + i]; + if (!types_compare(type1, type2, equal)) return FALSE; + if (!*equal) return TRUE; + } + ret = *equal = TRUE; + } + else ret = FALSE; + free(children); + return ret; +} + +BOOL types_compare(struct dbg_type type1, struct dbg_type type2, BOOL* equal) +{ + DWORD tag1, tag2; + DWORD64 size1, size2; + DWORD bt1, bt2; + LPWSTR name1, name2; + DWORD count1, count2; + + do + { + if (type1.module == type2.module && type1.id == type2.id) + return *equal = TRUE; + + if (!types_get_real_type(&type1, &tag1) || + !types_get_real_type(&type2, &tag2)) return FALSE; + + if (type1.module == type2.module && type1.id == type2.id) + return *equal = TRUE; + + if (tag1 != tag2) return !(*equal = FALSE); + + switch (tag1) + { + case SymTagBaseType: + if (!types_get_info(&type1, TI_GET_BASETYPE, &bt1) || + !types_get_info(&type2, TI_GET_BASETYPE, &bt2) || + !types_get_info(&type1, TI_GET_LENGTH, &size1) || + !types_get_info(&type2, TI_GET_LENGTH, &size2)) + return FALSE; + *equal = bt1 == bt2 && size1 == size2; + return TRUE; + case SymTagPointerType: + /* compare sub types */ + break; + case SymTagUDT: + case SymTagEnum: + if (!types_get_info(&type1, TI_GET_CHILDRENCOUNT, &count1) || + !types_get_info(&type2, TI_GET_CHILDRENCOUNT, &count2)) return FALSE; + if (count1 != count2) return !(*equal = FALSE); + *equal = FALSE; + if (types_get_info(&type1, TI_GET_SYMNAME, &name1)) + { + if (types_get_info(&type2, TI_GET_SYMNAME, &name2)) + { + if (!wcscmp(name1, name2)) + *equal = TRUE; + HeapFree(GetProcessHeap(), 0, name2); + } + HeapFree(GetProcessHeap(), 0, name1); + } + /* we would need to compare each field or value, but that's too complicated for now */ + if (tag1 == SymTagUDT) return TRUE; + /* compare underlying type for enums */ + break; + case SymTagArrayType: + if (!types_get_info(&type1, TI_GET_LENGTH, &size1) || + !types_get_info(&type2, TI_GET_LENGTH, &size2) || + !types_get_info(&type1, TI_GET_COUNT, &count1) || + !types_get_info(&type2, TI_GET_COUNT, &count2)) return FALSE; + if (size1 == size2 && count1 == count2) + { + struct dbg_type subtype1 = type1, subtype2 = type2; + if (!types_get_info(&type1, TI_GET_ARRAYINDEXTYPEID, &subtype1.id) || + !types_get_info(&type2, TI_GET_ARRAYINDEXTYPEID, &subtype2.id)) return FALSE; + if (!types_compare(subtype1, subtype2, equal)) return FALSE; + if (!*equal) return TRUE; + } + else return !(*equal = FALSE); + /* compare subtypes */ + break; + case SymTagFunctionType: + if (!types_compare_children(type1, type2, equal)) return FALSE; + if (!*equal) return TRUE; + /* compare return:ed type */ + break; + case SymTagFunctionArgType: + /* compare argument type */ + break; + default: + dbg_printf("Unsupported yet tag %d\n", tag1); + return FALSE; + } + } while (types_get_info(&type1, TI_GET_TYPE, &type1.id) && + types_get_info(&type2, TI_GET_TYPE, &type2.id)); + return FALSE; +} + +static BOOL is_basetype_char(DWORD bt) +{ + return bt == btChar || bt == btWChar || bt == btChar8 || bt == btChar16 || bt == btChar32; +} + +static BOOL is_basetype_integer(DWORD bt) +{ + return is_basetype_char(bt) || bt == btInt || bt == btUInt || bt == btLong || bt == btULong; +} + +BOOL types_is_integral_type(const struct dbg_lvalue* lv) +{ + struct dbg_type type = lv->type; + DWORD tag, bt; + if (lv->bitlen) return TRUE; + if (!types_get_real_type(&type, &tag) || + !types_get_info(&type, TI_GET_BASETYPE, &bt)) return FALSE; + return is_basetype_integer(bt); +}
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 1 + programs/winedbg/memory.c | 31 +++++++++++++++++++++++++++++++ programs/winedbg/types.c | 19 +++---------------- 3 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 35829e83f96..97f79a1883c 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -392,6 +392,7 @@ extern void info_wine_dbg_channel(BOOL add, const char* chnl, const /* memory.c */ extern BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result); extern BOOL memory_write_value(const struct dbg_lvalue* val, DWORD size, void* value); +extern BOOL memory_transfer_value(const struct dbg_lvalue* to, const struct dbg_lvalue* from); extern BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, BOOL is_signed, dbg_lgint_t* ret); extern BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index fd8293687b6..5e32caec1d2 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -133,6 +133,37 @@ BOOL memory_write_value(const struct dbg_lvalue* lvalue, DWORD size, void* value return ret; }
+/* transfer a block of memory + * the two lvalue:s are expected to be of same size + */ +BOOL memory_transfer_value(const struct dbg_lvalue* to, const struct dbg_lvalue* from) +{ + DWORD64 size_to, size_from; + BYTE tmp[256]; + BYTE* ptr = tmp; + BOOL ret; + + if (to->bitlen || from->bitlen) return FALSE; + if (!types_get_info(&to->type, TI_GET_LENGTH, &size_to) || + !types_get_info(&from->type, TI_GET_LENGTH, &size_from) || + size_from != size_to) return FALSE; + /* optimize debugger to debugger transfer */ + if (!to->in_debuggee && !from->in_debuggee) + { + memcpy(memory_to_linear_addr(&to->addr), memory_to_linear_addr(&from->addr), size_from); + return TRUE; + } + if (size_to > sizeof(tmp)) + { + ptr = malloc(size_from); + if (!ptr) return FALSE; + } + ret = memory_read_value(from, size_from, ptr) && + memory_write_value(to, size_from, ptr); + if (size_to > sizeof(tmp)) free(ptr); + return ret; +} + /*********************************************************************** * memory_examine * diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 2d7bce5de7e..3aca184942c 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -162,30 +162,17 @@ void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr)
BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from) { - dbg_lgint_t val; - DWORD64 size; - BOOL equal; - if (!lvalue_to->bitlen && !lvalue_from->bitlen) { + BOOL equal; if (!types_compare(lvalue_to->type, lvalue_from->type, &equal)) return FALSE; if (equal) - { - if (!types_get_info(&lvalue_to->type, TI_GET_LENGTH, &size)) return FALSE; - if (sizeof(val) < size) - { - return memory_read_value(lvalue_from, size, &val) && - memory_write_value(lvalue_to, size, &val); - } - dbg_printf("NIY\n"); - /* else: should allocate intermediate buffer... */ - return FALSE; - } + return memory_transfer_value(lvalue_to, lvalue_from); } if (types_is_integral_type(lvalue_from) && types_is_integral_type(lvalue_to)) { /* doing integer conversion (about sign, size) */ - val = types_extract_as_integer(lvalue_from); + dbg_lgint_t val = types_extract_as_integer(lvalue_from); return memory_store_integer(lvalue_to, val); } /* FIXME: should support floats as well */
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/memory.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 5e32caec1d2..a509309863f 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -317,6 +317,23 @@ BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val) { DWORD64 size; if (!types_get_info(&lvalue->type, TI_GET_LENGTH, &size)) return FALSE; + if (lvalue->bitlen) + { + struct dbg_lvalue alt_lvalue = *lvalue; + dbg_lguint_t mask, dst; + + /* FIXME: this test isn't sufficient, depending on start of bitfield + * (ie a 64 bit field can spread across 9 bytes) + */ + if (lvalue->bitlen > 8 * sizeof(dbg_lgint_t)) return FALSE; + /* mask is 1 where bitfield is present, 0 outside */ + mask = (~(dbg_lguint_t)0 >> (sizeof(val) * 8 - lvalue->bitlen)) << (lvalue->bitstart & 7); + alt_lvalue.addr.Offset += lvalue->bitstart >> 3; + val <<= lvalue->bitstart & 7; + if (!memory_read_value(&alt_lvalue, (unsigned)size, &dst)) return FALSE; + val = (dst & ~mask) | (val & mask); + return memory_write_value(&alt_lvalue, (unsigned)size, &val); + } /* this is simple if we're on a little endian CPU */ return memory_write_value(lvalue, (unsigned)size, &val); }
As they're all the same
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/be_arm.c | 18 ------------------ programs/winedbg/be_arm64.c | 18 ------------------ programs/winedbg/be_cpu.h | 3 --- programs/winedbg/be_i386.c | 18 ------------------ programs/winedbg/be_x86_64.c | 18 ------------------ programs/winedbg/debugger.h | 1 + programs/winedbg/memory.c | 17 ++++++++++++++++- 7 files changed, 17 insertions(+), 76 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index 02f72e9c789..a9551a40337 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1831,23 +1831,6 @@ static int be_arm_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return step; }
-static BOOL be_arm_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) -{ - char tmp[sizeof(double)]; - - /* FIXME: this assumes that debuggee and debugger use the same - * representation for reals - */ - if (size > sizeof(tmp)) return FALSE; - if (!memory_read_value(lvalue, size, tmp)) return FALSE; - - if (size == sizeof(float)) *ret = *(float*)tmp; - else if (size == sizeof(double)) *ret = *(double*)tmp; - else return FALSE; - - return TRUE; -} - static BOOL be_arm_get_context(HANDLE thread, dbg_ctx_t *ctx) { ctx->ctx.ContextFlags = CONTEXT_ALL; @@ -1904,7 +1887,6 @@ struct backend_cpu be_arm = be_arm_is_watchpoint_set, be_arm_clear_watchpoint, be_arm_adjust_pc_for_break, - be_arm_fetch_float, be_arm_get_context, be_arm_set_context, be_arm_gdb_register_map, diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index 8ca54e6c461..ab64801e6db 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -228,23 +228,6 @@ static int be_arm64_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return 4; }
-static BOOL be_arm64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) -{ - char tmp[sizeof(double)]; - - /* FIXME: this assumes that debuggee and debugger use the same - * representation for reals - */ - if (size > sizeof(tmp)) return FALSE; - if (!memory_read_value(lvalue, size, tmp)) return FALSE; - - if (size == sizeof(float)) *ret = *(float*)tmp; - else if (size == sizeof(double)) *ret = *(double*)tmp; - else return FALSE; - - return TRUE; -} - void be_arm64_disasm_one_insn(ADDRESS64 *addr, int display) { dbg_printf("be_arm64_disasm_one_insn: not done\n"); @@ -323,7 +306,6 @@ struct backend_cpu be_arm64 = be_arm64_is_watchpoint_set, be_arm64_clear_watchpoint, be_arm64_adjust_pc_for_break, - be_arm64_fetch_float, be_arm64_get_context, be_arm64_set_context, be_arm64_gdb_register_map, diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index 69e3e148f75..0c4f9b8f056 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -118,9 +118,6 @@ struct backend_cpu /* ------------------------------------------------------------------------------- * basic type read/write * -------------------------------------------------------------------------------*/ - /* Reads a real from memory and stores it inside a long double */ - BOOL (*fetch_float)(const struct dbg_lvalue* lvalue, unsigned size, double*); - BOOL (*get_context)(HANDLE thread, dbg_ctx_t *ctx); BOOL (*set_context)(HANDLE thread, const dbg_ctx_t *ctx);
diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index 9b3c615092c..262e68894d5 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -777,23 +777,6 @@ static int be_i386_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return 1; }
-static BOOL be_i386_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) -{ - char tmp[sizeof(double)]; - - /* FIXME: this assumes that debuggee and debugger use the same - * representation for reals - */ - if (size > sizeof(tmp)) return FALSE; - if (!memory_read_value(lvalue, size, tmp)) return FALSE; - - if (size == sizeof(float)) *ret = *(float*)tmp; - else if (size == sizeof(double)) *ret = *(double*)tmp; - else return FALSE; - - return TRUE; -} - static BOOL be_i386_get_context(HANDLE thread, dbg_ctx_t *ctx) { ctx->x86.ContextFlags = WOW64_CONTEXT_ALL; @@ -875,7 +858,6 @@ struct backend_cpu be_i386 = be_i386_is_watchpoint_set, be_i386_clear_watchpoint, be_i386_adjust_pc_for_break, - be_i386_fetch_float, be_i386_get_context, be_i386_set_context, be_i386_gdb_register_map, diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 169a31a584d..44079c2fe76 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -699,23 +699,6 @@ static int be_x86_64_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way) return 1; }
-static BOOL be_x86_64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret) -{ - char tmp[sizeof(double)]; - - /* FIXME: this assumes that debuggee and debugger use the same - * representation for reals - */ - if (size > sizeof(tmp)) return FALSE; - if (!memory_read_value(lvalue, size, tmp)) return FALSE; - - if (size == sizeof(float)) *ret = *(float*)tmp; - else if (size == sizeof(double)) *ret = *(double*)tmp; - else return FALSE; - - return TRUE; -} - static BOOL be_x86_64_get_context(HANDLE thread, dbg_ctx_t *ctx) { ctx->ctx.ContextFlags = CONTEXT_ALL; @@ -813,7 +796,6 @@ struct backend_cpu be_x86_64 = be_x86_64_is_watchpoint_set, be_x86_64_clear_watchpoint, be_x86_64_adjust_pc_for_break, - be_x86_64_fetch_float, be_x86_64_get_context, be_x86_64_set_context, be_x86_64_gdb_register_map, diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 97f79a1883c..9b6efccb69e 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -396,6 +396,7 @@ extern BOOL memory_transfer_value(const struct dbg_lvalue* to, const extern BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size, BOOL is_signed, dbg_lgint_t* ret); extern BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val); +extern BOOL memory_fetch_float(const struct dbg_lvalue* lvalue, double *ret); extern void memory_examine(const struct dbg_lvalue *lvalue, int count, char format); extern void* memory_to_linear_addr(const ADDRESS64* address); extern BOOL memory_get_current_pc(ADDRESS64* address); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index a509309863f..b2313cfa4c8 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -338,6 +338,21 @@ BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val) return memory_write_value(lvalue, (unsigned)size, &val); }
+BOOL memory_fetch_float(const struct dbg_lvalue* lvalue, double *ret) +{ + DWORD64 size; + if (!types_get_info(&lvalue->type, TI_GET_LENGTH, &size)) return FALSE; + /* FIXME: this assumes that debuggee and debugger use the same + * representation for reals + */ + if (size > sizeof(*ret)) return FALSE; + if (!memory_read_value(lvalue, size, ret)) return FALSE; + + if (size == sizeof(float)) *ret = *(float*)ret; + else if (size != sizeof(double)) return FALSE; + + return TRUE; +}
BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee, BOOL unicode, char* buffer, int size) @@ -483,7 +498,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) dbg_print_hex(size, val_int); break; case btFloat: - if (!dbg_curr_process->be_cpu->fetch_float(lvalue, size, &val_real)) return; + if (!memory_fetch_float(lvalue, &val_real)) return; dbg_printf("%f", val_real); break; case btChar:
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 2 ++ programs/winedbg/memory.c | 17 +++++++++++++++++ programs/winedbg/types.c | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 9b6efccb69e..f74ddfc210f 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -397,6 +397,7 @@ extern BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, un BOOL is_signed, dbg_lgint_t* ret); extern BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val); extern BOOL memory_fetch_float(const struct dbg_lvalue* lvalue, double *ret); +extern BOOL memory_store_float(const struct dbg_lvalue* lvalue, double *ret); extern void memory_examine(const struct dbg_lvalue *lvalue, int count, char format); extern void* memory_to_linear_addr(const ADDRESS64* address); extern BOOL memory_get_current_pc(ADDRESS64* address); @@ -497,6 +498,7 @@ 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_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*);
/* winedbg.c */ extern void dbg_outputW(const WCHAR* buffer, int len); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index b2313cfa4c8..4708dcdd1b1 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -354,6 +354,23 @@ BOOL memory_fetch_float(const struct dbg_lvalue* lvalue, double *ret) return TRUE; }
+BOOL memory_store_float(const struct dbg_lvalue* lvalue, double *ret) +{ + DWORD64 size; + if (!types_get_info(&lvalue->type, TI_GET_LENGTH, &size)) return FALSE; + /* FIXME: this assumes that debuggee and debugger use the same + * representation for reals + */ + if (size > sizeof(*ret)) return FALSE; + if (size == sizeof(float)) + { + float f = *ret; + return memory_write_value(lvalue, size, &f); + } + if (size != sizeof(double)) return FALSE; + return memory_write_value(lvalue, size, ret); +} + BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee, BOOL unicode, char* buffer, int size) { diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 3aca184942c..c8ff8446c90 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -168,6 +168,12 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv if (!types_compare(lvalue_to->type, lvalue_from->type, &equal)) return FALSE; if (equal) return memory_transfer_value(lvalue_to, lvalue_from); + if (types_is_float_type(lvalue_from) && types_is_float_type(lvalue_to)) + { + double d; + return memory_fetch_float(lvalue_from, &d) && + memory_store_float(lvalue_to, &d); + } } if (types_is_integral_type(lvalue_from) && types_is_integral_type(lvalue_to)) { @@ -175,7 +181,6 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv dbg_lgint_t val = types_extract_as_integer(lvalue_from); return memory_store_integer(lvalue_to, val); } - /* FIXME: should support floats as well */ dbg_printf("Cannot assign (different types)\n"); return FALSE; return FALSE; } @@ -1049,3 +1054,13 @@ BOOL types_is_integral_type(const struct dbg_lvalue* lv) !types_get_info(&type, TI_GET_BASETYPE, &bt)) return FALSE; return is_basetype_integer(bt); } + +BOOL types_is_float_type(const struct dbg_lvalue* lv) +{ + struct dbg_type type = lv->type; + DWORD tag, bt; + if (lv->bitlen) return FALSE; + if (!types_get_real_type(&type, &tag) || + !types_get_info(&type, TI_GET_BASETYPE, &bt)) return FALSE; + return bt == btFloat; +}
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 4708dcdd1b1..f6d2ef6bee2 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -474,7 +474,7 @@ static void dbg_print_hex(DWORD size, dbg_lgint_t sv) dbg_printf("0"); else /* clear unneeded high bits, esp. sign extension */ - dbg_printf("%#I64x", sv & (~0LLU >> (64 - 8 * size))); + dbg_printf("%#I64x", sv & (~(dbg_lguint_t)0 >> (8 * (sizeof(dbg_lgint_t) - size)))); }
static void print_typed_basic(const struct dbg_lvalue* lvalue)