From 8629cdb6af99375e9d01cedf8be5021ce6990241 Mon Sep 17 00:00:00 2001 From: winesync Date: Fri, 11 Sep 2020 14:29:18 +0200 Subject: [PATCH] [WINESYNC] dbghelp/dwarf: Allow get_context_reg() to handle different register sizes. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard wine commit id 3507615f35777f38a20407b7879f7c7d6510b12a by Zebediah Figura --- dll/win32/dbghelp/cpu_arm.c | 2 +- dll/win32/dbghelp/cpu_arm64.c | 2 +- dll/win32/dbghelp/cpu_i386.c | 2 +- dll/win32/dbghelp/cpu_x86_64.c | 2 +- dll/win32/dbghelp/dbghelp_private.h | 2 +- dll/win32/dbghelp/dwarf.c | 30 +++++++++++++++-------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/dll/win32/dbghelp/cpu_arm.c b/dll/win32/dbghelp/cpu_arm.c index 3395b6e50cb..9385e2e4eb5 100644 --- a/dll/win32/dbghelp/cpu_arm.c +++ b/dll/win32/dbghelp/cpu_arm.c @@ -70,7 +70,7 @@ enum st_mode {stm_start, stm_arm, stm_done}; static BOOL fetch_next_frame(struct cpu_stack_walk* csw, union ctx *pcontext, DWORD_PTR curr_pc) { - DWORD_PTR xframe; + DWORD64 xframe; CONTEXT *context = &pcontext->ctx; DWORD oldReturn = context->Lr; diff --git a/dll/win32/dbghelp/cpu_arm64.c b/dll/win32/dbghelp/cpu_arm64.c index 7a4a94762e8..f3ab0936ebe 100644 --- a/dll/win32/dbghelp/cpu_arm64.c +++ b/dll/win32/dbghelp/cpu_arm64.c @@ -68,7 +68,7 @@ enum st_mode {stm_start, stm_arm64, stm_done}; static BOOL fetch_next_frame(struct cpu_stack_walk* csw, union ctx *pcontext, DWORD_PTR curr_pc) { - DWORD_PTR xframe; + DWORD64 xframe; CONTEXT *context = &pcontext->ctx; DWORD_PTR oldReturn = context->u.s.Lr; diff --git a/dll/win32/dbghelp/cpu_i386.c b/dll/win32/dbghelp/cpu_i386.c index 6ed98341343..420549b40d8 100644 --- a/dll/win32/dbghelp/cpu_i386.c +++ b/dll/win32/dbghelp/cpu_i386.c @@ -99,7 +99,7 @@ static BOOL i386_get_addr(HANDLE hThread, const CONTEXT* ctx, static BOOL fetch_next_frame32(struct cpu_stack_walk* csw, union ctx *pcontext, DWORD_PTR curr_pc) { - DWORD_PTR xframe; + DWORD64 xframe; struct pdb_cmd_pair cpair[4]; DWORD val32; WOW64_CONTEXT *context = &pcontext->x86; diff --git a/dll/win32/dbghelp/cpu_x86_64.c b/dll/win32/dbghelp/cpu_x86_64.c index 1087ce74646..83c1fb16bf7 100644 --- a/dll/win32/dbghelp/cpu_x86_64.c +++ b/dll/win32/dbghelp/cpu_x86_64.c @@ -577,7 +577,7 @@ static BOOL interpret_function_table_entry(struct cpu_stack_walk* csw, static BOOL fetch_next_frame(struct cpu_stack_walk *csw, union ctx *pcontext, DWORD_PTR curr_pc, void** prtf) { - DWORD_PTR cfa; + DWORD64 cfa; RUNTIME_FUNCTION* rtf; DWORD64 base; CONTEXT *context = &pcontext->ctx; diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index e0b2e3d1736..bdfca1d2934 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -725,7 +725,7 @@ extern BOOL dwarf2_parse(struct module* module, unsigned long load_offse const struct elf_thunk_area* thunks, struct image_file_map* fmap) DECLSPEC_HIDDEN; extern BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, - union ctx *ctx, ULONG_PTR *cfa) DECLSPEC_HIDDEN; + union ctx *ctx, DWORD64 *cfa) DECLSPEC_HIDDEN; /* rsym.c */ extern BOOL rsym_parse(struct module* module, unsigned long load_offset, diff --git a/dll/win32/dbghelp/dwarf.c b/dll/win32/dbghelp/dwarf.c index 0b9ef623a7c..27b9c1b4354 100644 --- a/dll/win32/dbghelp/dwarf.c +++ b/dll/win32/dbghelp/dwarf.c @@ -3031,18 +3031,19 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, } /* retrieve a context register from its dwarf number */ -static ULONG_PTR get_context_reg(struct cpu_stack_walk *csw, union ctx *context, +static DWORD64 get_context_reg(struct cpu_stack_walk *csw, union ctx *context, ULONG_PTR dw_reg) { unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz; - ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz); + void* ptr = csw->cpu->fetch_context_reg(context, regno, &sz); - if (sz != sizeof(ULONG_PTR)) - { - FIXME("reading register %lu/%u of wrong size %u\n", dw_reg, regno, sz); - return 0; - } - return *ptr; + if (sz == 8) + return *(DWORD64 *)ptr; + else if (sz == 4) + return *(DWORD *)ptr; + + FIXME("unhandled size %d\n", sz); + return 0; } /* set a context register from its dwarf number */ @@ -3102,7 +3103,8 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w const unsigned char* zp, union ctx *context) { dwarf2_traverse_context_t ctx; - ULONG_PTR reg, sz, tmp, stack[64]; + ULONG_PTR reg, sz, tmp; + DWORD64 stack[64]; int sp = -1; ULONG_PTR len; @@ -3140,7 +3142,7 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w case DW_OP_deref: if (!sw_read_mem(csw, stack[sp], &tmp, sizeof(tmp))) { - ERR("Couldn't read memory at %lx\n", stack[sp]); + ERR("Couldn't read memory at %s\n", wine_dbgstr_longlong(stack[sp])); tmp = 0; } stack[sp] = tmp; @@ -3190,7 +3192,7 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w sz = dwarf2_parse_byte(&ctx); if (!sw_read_mem(csw, stack[sp], &tmp, sz)) { - ERR("Couldn't read memory at %lx\n", stack[sp]); + ERR("Couldn't read memory at %s\n", wine_dbgstr_longlong(stack[sp])); tmp = 0; } /* do integral promotion */ @@ -3211,7 +3213,7 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w } static void apply_frame_state(const struct module* module, struct cpu_stack_walk* csw, - union ctx *context, struct frame_state *state, ULONG_PTR* cfa) + union ctx *context, struct frame_state *state, DWORD64 *cfa) { unsigned int i; ULONG_PTR value; @@ -3223,7 +3225,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk *cfa = eval_expression(module, csw, (const unsigned char*)state->cfa_offset, context); if (!sw_read_mem(csw, *cfa, cfa, sizeof(*cfa))) { - WARN("Couldn't read memory at %p\n", (void*)*cfa); + WARN("Couldn't read memory at %s\n", wine_dbgstr_longlong(*cfa)); return; } break; @@ -3268,7 +3270,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk * */ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, - union ctx *context, ULONG_PTR *cfa) + union ctx *context, DWORD64 *cfa) { struct module_pair pair; struct frame_info info; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 3f8c50e2700..b9808b10147 100644 --- a/sdk/tools/winesync/dbghelp.cfg +++ b/sdk/tools/winesync/dbghelp.cfg @@ -3,4 +3,4 @@ directories: files: include/dbghelp.h: sdk/include/psdk/dbghelp.h tags: - wine: 9ae588a96ef5f07ba22e0fadc3aacf61b274efe5 + wine: 3507615f35777f38a20407b7879f7c7d6510b12a