From 0b8d0e0a613a3486c91eb7aa168dfc912c6a2ec8 Mon Sep 17 00:00:00 2001 From: winesync Date: Fri, 11 Sep 2020 18:45:02 +0200 Subject: [PATCH] [WINESYNC] dbghelp: Pass module to map_dwarf_register. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard wine commit id 5d8067c6088a30cdb4fe6945e6ae1cda0da85467 by Jacek Caban --- 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_ppc.c | 2 +- dll/win32/dbghelp/cpu_x86_64.c | 2 +- dll/win32/dbghelp/dbghelp_private.h | 2 +- dll/win32/dbghelp/dwarf.c | 84 ++++++++++++++--------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/dll/win32/dbghelp/cpu_arm.c b/dll/win32/dbghelp/cpu_arm.c index 9385e2e4eb5..a05bd90c9ae 100644 --- a/dll/win32/dbghelp/cpu_arm.c +++ b/dll/win32/dbghelp/cpu_arm.c @@ -161,7 +161,7 @@ static BOOL arm_stack_walk(struct cpu_stack_walk *csw, STACKFRAME64 *frame, } #endif -static unsigned arm_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned arm_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { if (regno <= 15) return CV_ARM_R0 + regno; if (regno == 128) return CV_ARM_CPSR; diff --git a/dll/win32/dbghelp/cpu_arm64.c b/dll/win32/dbghelp/cpu_arm64.c index f3ab0936ebe..515294fe95c 100644 --- a/dll/win32/dbghelp/cpu_arm64.c +++ b/dll/win32/dbghelp/cpu_arm64.c @@ -155,7 +155,7 @@ static BOOL arm64_stack_walk(struct cpu_stack_walk* csw, STACKFRAME64 *frame, } #endif -static unsigned arm64_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned arm64_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { if (regno <= 28) return CV_ARM64_X0 + regno; if (regno == 29) return CV_ARM64_FP; diff --git a/dll/win32/dbghelp/cpu_i386.c b/dll/win32/dbghelp/cpu_i386.c index 6c10107ba3d..1528b603221 100644 --- a/dll/win32/dbghelp/cpu_i386.c +++ b/dll/win32/dbghelp/cpu_i386.c @@ -514,7 +514,7 @@ done_err: } #endif /* DBGHELP_STATIC_LIB */ -static unsigned i386_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned i386_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { unsigned reg; diff --git a/dll/win32/dbghelp/cpu_ppc.c b/dll/win32/dbghelp/cpu_ppc.c index e1e1cb332ca..80db2be704b 100644 --- a/dll/win32/dbghelp/cpu_ppc.c +++ b/dll/win32/dbghelp/cpu_ppc.c @@ -55,7 +55,7 @@ static BOOL ppc_stack_walk(struct cpu_stack_walk* csw, STACKFRAME64 *frame, return FALSE; } -static unsigned ppc_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned ppc_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { FIXME("not done\n"); return 0; diff --git a/dll/win32/dbghelp/cpu_x86_64.c b/dll/win32/dbghelp/cpu_x86_64.c index 57cfa112446..f0c12207357 100644 --- a/dll/win32/dbghelp/cpu_x86_64.c +++ b/dll/win32/dbghelp/cpu_x86_64.c @@ -724,7 +724,7 @@ static void* x86_64_find_runtime_function(struct module* module, DWORD64 addr return NULL; } -static unsigned x86_64_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned x86_64_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { unsigned reg; diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 6608c78ad53..521f64881ad 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -587,7 +587,7 @@ struct cpu void* (*find_runtime_function)(struct module*, DWORD64 addr); /* dwarf dedicated information */ - unsigned (*map_dwarf_register)(unsigned regno, BOOL eh_frame); + unsigned (*map_dwarf_register)(unsigned regno, const struct module* module, BOOL eh_frame); /* context related manipulation */ void * (*fetch_context_reg)(union ctx *ctx, unsigned regno, unsigned *size); diff --git a/dll/win32/dbghelp/dwarf.c b/dll/win32/dbghelp/dwarf.c index bf7fb9ce232..04985003653 100644 --- a/dll/win32/dbghelp/dwarf.c +++ b/dll/win32/dbghelp/dwarf.c @@ -655,18 +655,18 @@ static void dwarf2_load_one_entry(dwarf2_parse_context_t*, dwarf2_debug_info_t*) #define Wine_DW_no_register 0x7FFFFFFF -static unsigned dwarf2_map_register(int regno) +static unsigned dwarf2_map_register(int regno, const struct module* module) { if (regno == Wine_DW_no_register) { FIXME("What the heck map reg 0x%x\n",regno); return 0; } - return dbghelp_current_cpu->map_dwarf_register(regno, FALSE); + return dbghelp_current_cpu->map_dwarf_register(regno, module, FALSE); } static enum location_error -compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, +compute_location(const struct module *module, dwarf2_traverse_context_t* ctx, struct location* loc, HANDLE hproc, const struct location* frame) { DWORD_PTR tmp, stack[64]; @@ -693,7 +693,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, */ if (!piece_found) { - DWORD cvreg = dwarf2_map_register(op - DW_OP_reg0); + DWORD cvreg = dwarf2_map_register(op - DW_OP_reg0, module); if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one reg (%s/%d -> %s/%d)\n", dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg, @@ -710,7 +710,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, */ if (!piece_found) { - DWORD cvreg = dwarf2_map_register(op - DW_OP_breg0); + DWORD cvreg = dwarf2_map_register(op - DW_OP_breg0, module); if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one breg (%s/%d -> %s/%d)\n", dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg, @@ -769,7 +769,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, { if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one reg\n"); - loc->reg = dwarf2_map_register(tmp); + loc->reg = dwarf2_map_register(tmp, module); } loc->kind = loc_register; break; @@ -777,7 +777,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, tmp = dwarf2_leb128_as_unsigned(ctx); if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one regx\n"); - loc->reg = dwarf2_map_register(tmp); + loc->reg = dwarf2_map_register(tmp, module); stack[++stk] = dwarf2_leb128_as_signed(ctx); loc->kind = loc_regrel; break; @@ -936,7 +936,7 @@ static BOOL dwarf2_compute_location_attr(dwarf2_parse_context_t* ctx, lctx.end_data = xloc.u.block.ptr + xloc.u.block.size; lctx.word_size = ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size; - err = compute_location(&lctx, loc, NULL, frame); + err = compute_location(ctx->module, &lctx, loc, NULL, frame); if (err < 0) { loc->kind = loc_error; @@ -949,7 +949,7 @@ static BOOL dwarf2_compute_location_attr(dwarf2_parse_context_t* ctx, *ptr = xloc.u.block.size; memcpy(ptr + 1, xloc.u.block.ptr, xloc.u.block.size); loc->offset = (ULONG_PTR)ptr; - compute_location(&lctx, loc, NULL, frame); + compute_location(ctx->module, &lctx, loc, NULL, frame); } } return TRUE; @@ -2546,7 +2546,7 @@ static enum location_error loc_compute_frame(struct process* pcs, modfmt->u.dwarf2_info->debug_loc.address + pframe->offset, ip, &lctx)) return loc_err_out_of_scope; - if ((err = compute_location(&lctx, frame, pcs->handle, NULL)) < 0) return err; + if ((err = compute_location(modfmt->module, &lctx, frame, pcs->handle, NULL)) < 0) return err; if (frame->kind >= loc_user) { WARN("Couldn't compute runtime frame location\n"); @@ -2800,7 +2800,7 @@ static int valid_reg(ULONG_PTR reg) return (reg < NB_FRAME_REGS); } -static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, +static void execute_cfa_instructions(struct module* module, dwarf2_traverse_context_t* ctx, ULONG_PTR last_ip, struct frame_info *info) { while (ctx->data < ctx->end_data && info->ip <= last_ip + info->signal_frame) @@ -2825,7 +2825,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_offset %s, %ld\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), offset); info->state.regs[reg] = offset; info->state.rules[reg] = RULE_CFA_OFFSET; @@ -2837,7 +2837,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_restore %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.rules[reg] = RULE_UNSET; break; } @@ -2884,7 +2884,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_offset_extended %s, %ld\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), offset); info->state.regs[reg] = offset; info->state.rules[reg] = RULE_CFA_OFFSET; @@ -2896,7 +2896,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_restore_extended %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.rules[reg] = RULE_UNSET; break; } @@ -2906,7 +2906,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_undefined %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.rules[reg] = RULE_UNDEFINED; break; } @@ -2916,7 +2916,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_same_value %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.regs[reg] = reg; info->state.rules[reg] = RULE_SAME; break; @@ -2928,8 +2928,8 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg) || !valid_reg(reg2)) break; TRACE("%lx: DW_CFA_register %s == %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg2, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg2, module, TRUE))); info->state.regs[reg] = reg2; info->state.rules[reg] = RULE_OTHER_REG; break; @@ -2957,7 +2957,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_def_cfa %s, %ld\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), offset); info->state.cfa_reg = reg; info->state.cfa_offset = offset; @@ -2970,7 +2970,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_def_cfa_register %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.cfa_reg = reg; info->state.cfa_rule = RULE_CFA_OFFSET; break; @@ -3004,7 +3004,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_%sexpression %s %lx-%lx\n", info->ip, (op == DW_CFA_expression) ? "" : "val_", - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), expr, expr + len); info->state.regs[reg] = expr; info->state.rules[reg] = (op == DW_CFA_expression) ? RULE_EXPRESSION : RULE_VAL_EXPRESSION; @@ -3027,10 +3027,10 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, } /* retrieve a context register from its dwarf number */ -static DWORD64 get_context_reg(struct cpu_stack_walk *csw, union ctx *context, +static DWORD64 get_context_reg(const struct module* module, struct cpu_stack_walk *csw, union ctx *context, ULONG_PTR dw_reg) { - unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz; + unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz; void* ptr = csw->cpu->fetch_context_reg(context, regno, &sz); if (sz == 8) @@ -3043,10 +3043,10 @@ static DWORD64 get_context_reg(struct cpu_stack_walk *csw, union ctx *context, } /* set a context register from its dwarf number */ -static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context, +static void set_context_reg(const struct module* module, struct cpu_stack_walk* csw, union ctx *context, ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee) { - unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz; + unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz; ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz); if (isdebuggee) @@ -3077,12 +3077,12 @@ static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context, } /* copy a register from one context to another using dwarf number */ -static void copy_context_reg(struct cpu_stack_walk *csw, +static void copy_context_reg(const struct module* module, struct cpu_stack_walk *csw, union ctx *dstcontext, ULONG_PTR dwregdst, union ctx *srccontext, ULONG_PTR dwregsrc) { - unsigned regdstno = csw->cpu->map_dwarf_register(dwregdst, TRUE), szdst; - unsigned regsrcno = csw->cpu->map_dwarf_register(dwregsrc, TRUE), szsrc; + unsigned regdstno = csw->cpu->map_dwarf_register(dwregdst, module, TRUE), szdst; + unsigned regsrcno = csw->cpu->map_dwarf_register(dwregsrc, module, TRUE), szsrc; ULONG_PTR* ptrdst = csw->cpu->fetch_context_reg(dstcontext, regdstno, &szdst); ULONG_PTR* ptrsrc = csw->cpu->fetch_context_reg(srccontext, regsrcno, &szsrc); @@ -3117,9 +3117,9 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w if (opcode >= DW_OP_lit0 && opcode <= DW_OP_lit31) stack[++sp] = opcode - DW_OP_lit0; else if (opcode >= DW_OP_reg0 && opcode <= DW_OP_reg31) - stack[++sp] = get_context_reg(csw, context, opcode - DW_OP_reg0); + stack[++sp] = get_context_reg(module, csw, context, opcode - DW_OP_reg0); else if (opcode >= DW_OP_breg0 && opcode <= DW_OP_breg31) - stack[++sp] = get_context_reg(csw, context, opcode - DW_OP_breg0) + stack[++sp] = get_context_reg(module, csw, context, opcode - DW_OP_breg0) + dwarf2_leb128_as_signed(&ctx); else switch (opcode) { @@ -3178,12 +3178,12 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w stack[++sp] = dwarf2_parse_augmentation_ptr(&ctx, tmp); break; case DW_OP_regx: - stack[++sp] = get_context_reg(csw, context, dwarf2_leb128_as_unsigned(&ctx)); + stack[++sp] = get_context_reg(module, csw, context, dwarf2_leb128_as_unsigned(&ctx)); break; case DW_OP_bregx: reg = dwarf2_leb128_as_unsigned(&ctx); tmp = dwarf2_leb128_as_signed(&ctx); - stack[++sp] = get_context_reg(csw, context, reg) + tmp; + stack[++sp] = get_context_reg(module, csw, context, reg) + tmp; break; case DW_OP_deref_size: sz = dwarf2_parse_byte(&ctx); @@ -3230,7 +3230,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); break; default: - *cfa = get_context_reg(csw, context, state->cfa_reg) + state->cfa_offset; + *cfa = get_context_reg(module, csw, context, state->cfa_reg) + state->cfa_offset; break; } if (!*cfa) return; @@ -3244,18 +3244,18 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk case RULE_SAME: break; case RULE_CFA_OFFSET: - set_context_reg(csw, &new_context, i, *cfa + state->regs[i], TRUE); + set_context_reg(module, csw, &new_context, i, *cfa + state->regs[i], TRUE); break; case RULE_OTHER_REG: - copy_context_reg(csw, &new_context, i, context, state->regs[i]); + copy_context_reg(module, csw, &new_context, i, context, state->regs[i]); break; case RULE_EXPRESSION: value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context); - set_context_reg(csw, &new_context, i, value, TRUE); + set_context_reg(module, csw, &new_context, i, value, TRUE); break; case RULE_VAL_EXPRESSION: value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context); - set_context_reg(csw, &new_context, i, value, FALSE); + set_context_reg(module, csw, &new_context, i, value, FALSE); break; } } @@ -3307,11 +3307,11 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, TRACE("function %lx/%lx code_align %lu data_align %ld retaddr %s\n", ip, info.ip, info.code_align, info.data_align, - csw->cpu->fetch_regname(csw->cpu->map_dwarf_register(info.retaddr_reg, TRUE))); + csw->cpu->fetch_regname(csw->cpu->map_dwarf_register(info.retaddr_reg, pair.effective, TRUE))); /* if at very beginning of function, return and use default unwinder */ if (ip == info.ip) return FALSE; - execute_cfa_instructions(&cie_ctx, ip, &info); + execute_cfa_instructions(pair.effective, &cie_ctx, ip, &info); if (info.aug_z_format) /* get length of augmentation data */ { @@ -3322,7 +3322,7 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, dwarf2_parse_augmentation_ptr(&fde_ctx, info.lsda_encoding); /* handler_data */ if (end) fde_ctx.data = end; - execute_cfa_instructions(&fde_ctx, ip, &info); + execute_cfa_instructions(pair.effective, &fde_ctx, ip, &info); /* if there is no information about retaddr, use default unwinder */ if (info.state.rules[info.retaddr_reg] == RULE_UNSET) return FALSE; @@ -3375,7 +3375,7 @@ static void dwarf2_location_compute(struct process* pcs, } do_compute: /* now get the variable */ - err = compute_location(&lctx, loc, pcs->handle, &frame); + err = compute_location(modfmt->module, &lctx, loc, pcs->handle, &frame); break; case loc_register: case loc_regrel: diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 89e893dadfe..4cfa407ebcf 100644 --- a/sdk/tools/winesync/dbghelp.cfg +++ b/sdk/tools/winesync/dbghelp.cfg @@ -4,4 +4,4 @@ files: include/dbghelp.h: sdk/include/psdk/dbghelp.h include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h tags: - wine: f7a091af4812ef692fb2b1ec835b8146668aec5c + wine: 5d8067c6088a30cdb4fe6945e6ae1cda0da85467