[WINESYNC] dbghelp/dwarf: Use the correct backend CPU in dwarf2_virtual_unwind().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 9ae588a96ef5f07ba22e0fadc3aacf61b274efe5 by Zebediah Figura <z.figura12@gmail.com>
This commit is contained in:
winesync 2020-09-11 14:29:16 +02:00 committed by Jérôme Gardou
parent 7470eb9ced
commit 1825a61069
4 changed files with 25 additions and 19 deletions

View file

@ -473,6 +473,7 @@ struct cpu_stack_walk
HANDLE hProcess; HANDLE hProcess;
HANDLE hThread; HANDLE hThread;
BOOL is32; BOOL is32;
struct cpu * cpu;
union union
{ {
struct struct

View file

@ -3031,10 +3031,11 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx,
} }
/* retrieve a context register from its dwarf number */ /* retrieve a context register from its dwarf number */
static ULONG_PTR get_context_reg(union ctx *context, ULONG_PTR dw_reg) static ULONG_PTR get_context_reg(struct cpu_stack_walk *csw, union ctx *context,
ULONG_PTR dw_reg)
{ {
unsigned regno = dbghelp_current_cpu->map_dwarf_register(dw_reg, TRUE), sz; unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz;
ULONG_PTR* ptr = dbghelp_current_cpu->fetch_context_reg(context, regno, &sz); ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
if (sz != sizeof(ULONG_PTR)) if (sz != sizeof(ULONG_PTR))
{ {
@ -3048,8 +3049,8 @@ static ULONG_PTR get_context_reg(union ctx *context, ULONG_PTR dw_reg)
static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context, static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context,
ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee) ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee)
{ {
unsigned regno = dbghelp_current_cpu->map_dwarf_register(dw_reg, TRUE), sz; unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz;
ULONG_PTR* ptr = dbghelp_current_cpu->fetch_context_reg(context, regno, &sz); ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
if (isdebuggee) if (isdebuggee)
{ {
@ -3079,13 +3080,14 @@ static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context,
} }
/* copy a register from one context to another using dwarf number */ /* copy a register from one context to another using dwarf number */
static void copy_context_reg(union ctx *dstcontext, ULONG_PTR dwregdst, static void copy_context_reg(struct cpu_stack_walk *csw,
union ctx *srccontext, ULONG_PTR dwregsrc) union ctx *dstcontext, ULONG_PTR dwregdst,
union ctx *srccontext, ULONG_PTR dwregsrc)
{ {
unsigned regdstno = dbghelp_current_cpu->map_dwarf_register(dwregdst, TRUE), szdst; unsigned regdstno = csw->cpu->map_dwarf_register(dwregdst, TRUE), szdst;
unsigned regsrcno = dbghelp_current_cpu->map_dwarf_register(dwregsrc, TRUE), szsrc; unsigned regsrcno = csw->cpu->map_dwarf_register(dwregsrc, TRUE), szsrc;
ULONG_PTR* ptrdst = dbghelp_current_cpu->fetch_context_reg(dstcontext, regdstno, &szdst); ULONG_PTR* ptrdst = csw->cpu->fetch_context_reg(dstcontext, regdstno, &szdst);
ULONG_PTR* ptrsrc = dbghelp_current_cpu->fetch_context_reg(srccontext, regsrcno, &szsrc); ULONG_PTR* ptrsrc = csw->cpu->fetch_context_reg(srccontext, regsrcno, &szsrc);
if (szdst != szsrc) if (szdst != szsrc)
{ {
@ -3117,9 +3119,10 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w
if (opcode >= DW_OP_lit0 && opcode <= DW_OP_lit31) if (opcode >= DW_OP_lit0 && opcode <= DW_OP_lit31)
stack[++sp] = opcode - DW_OP_lit0; stack[++sp] = opcode - DW_OP_lit0;
else if (opcode >= DW_OP_reg0 && opcode <= DW_OP_reg31) else if (opcode >= DW_OP_reg0 && opcode <= DW_OP_reg31)
stack[++sp] = get_context_reg(context, opcode - DW_OP_reg0); stack[++sp] = get_context_reg(csw, context, opcode - DW_OP_reg0);
else if (opcode >= DW_OP_breg0 && opcode <= DW_OP_breg31) else if (opcode >= DW_OP_breg0 && opcode <= DW_OP_breg31)
stack[++sp] = get_context_reg(context, opcode - DW_OP_breg0) + dwarf2_leb128_as_signed(&ctx); stack[++sp] = get_context_reg(csw, context, opcode - DW_OP_breg0)
+ dwarf2_leb128_as_signed(&ctx);
else switch (opcode) else switch (opcode)
{ {
case DW_OP_nop: break; case DW_OP_nop: break;
@ -3176,12 +3179,12 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w
stack[++sp] = dwarf2_parse_augmentation_ptr(&ctx, tmp); stack[++sp] = dwarf2_parse_augmentation_ptr(&ctx, tmp);
break; break;
case DW_OP_regx: case DW_OP_regx:
stack[++sp] = get_context_reg(context, dwarf2_leb128_as_unsigned(&ctx)); stack[++sp] = get_context_reg(csw, context, dwarf2_leb128_as_unsigned(&ctx));
break; break;
case DW_OP_bregx: case DW_OP_bregx:
reg = dwarf2_leb128_as_unsigned(&ctx); reg = dwarf2_leb128_as_unsigned(&ctx);
tmp = dwarf2_leb128_as_signed(&ctx); tmp = dwarf2_leb128_as_signed(&ctx);
stack[++sp] = get_context_reg(context, reg) + tmp; stack[++sp] = get_context_reg(csw, context, reg) + tmp;
break; break;
case DW_OP_deref_size: case DW_OP_deref_size:
sz = dwarf2_parse_byte(&ctx); sz = dwarf2_parse_byte(&ctx);
@ -3228,7 +3231,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); *cfa = eval_expression(module, csw, (const unsigned char*)state->cfa_offset, context);
break; break;
default: default:
*cfa = get_context_reg(context, state->cfa_reg) + state->cfa_offset; *cfa = get_context_reg(csw, context, state->cfa_reg) + state->cfa_offset;
break; break;
} }
if (!*cfa) return; if (!*cfa) return;
@ -3245,7 +3248,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk
set_context_reg(csw, &new_context, i, *cfa + state->regs[i], TRUE); set_context_reg(csw, &new_context, i, *cfa + state->regs[i], TRUE);
break; break;
case RULE_OTHER_REG: case RULE_OTHER_REG:
copy_context_reg(&new_context, i, context, state->regs[i]); copy_context_reg(csw, &new_context, i, context, state->regs[i]);
break; break;
case RULE_EXPRESSION: case RULE_EXPRESSION:
value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context); value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context);
@ -3305,7 +3308,7 @@ 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", TRACE("function %lx/%lx code_align %lu data_align %ld retaddr %s\n",
ip, info.ip, info.code_align, info.data_align, ip, info.ip, info.code_align, info.data_align,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(info.retaddr_reg, TRUE))); csw->cpu->fetch_regname(csw->cpu->map_dwarf_register(info.retaddr_reg, TRUE)));
/* if at very beginning of function, return and use default unwinder */ /* if at very beginning of function, return and use default unwinder */
if (ip == info.ip) return FALSE; if (ip == info.ip) return FALSE;

View file

@ -175,6 +175,7 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
csw.hProcess = hProcess; csw.hProcess = hProcess;
csw.hThread = hThread; csw.hThread = hThread;
csw.is32 = TRUE; csw.is32 = TRUE;
csw.cpu = cpu;
/* sigh... MS isn't even consistent in the func prototypes */ /* sigh... MS isn't even consistent in the func prototypes */
csw.u.s32.f_read_mem = (f_read_mem) ? f_read_mem : read_mem; csw.u.s32.f_read_mem = (f_read_mem) ? f_read_mem : read_mem;
csw.u.s32.f_xlat_adr = f_xlat_adr; csw.u.s32.f_xlat_adr = f_xlat_adr;
@ -231,6 +232,7 @@ BOOL WINAPI StackWalk64(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
csw.hProcess = hProcess; csw.hProcess = hProcess;
csw.hThread = hThread; csw.hThread = hThread;
csw.is32 = FALSE; csw.is32 = FALSE;
csw.cpu = cpu;
/* sigh... MS isn't even consistent in the func prototypes */ /* sigh... MS isn't even consistent in the func prototypes */
csw.u.s64.f_read_mem = (f_read_mem) ? f_read_mem : read_mem64; csw.u.s64.f_read_mem = (f_read_mem) ? f_read_mem : read_mem64;
csw.u.s64.f_xlat_adr = (f_xlat_adr) ? f_xlat_adr : addr_to_linear; csw.u.s64.f_xlat_adr = (f_xlat_adr) ? f_xlat_adr : addr_to_linear;

View file

@ -3,4 +3,4 @@ directories:
files: files:
include/dbghelp.h: sdk/include/psdk/dbghelp.h include/dbghelp.h: sdk/include/psdk/dbghelp.h
tags: tags:
wine: 3ce304e60100962503bcded0adb69659f849d1b4 wine: 9ae588a96ef5f07ba22e0fadc3aacf61b274efe5