Commit 9ae588a9 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

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

parent 3ce304e6
...@@ -443,6 +443,7 @@ struct cpu_stack_walk ...@@ -443,6 +443,7 @@ struct cpu_stack_walk
HANDLE hProcess; HANDLE hProcess;
HANDLE hThread; HANDLE hThread;
BOOL is32; BOOL is32;
struct cpu * cpu;
union union
{ {
struct struct
......
...@@ -3008,10 +3008,11 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, ...@@ -3008,10 +3008,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))
{ {
...@@ -3025,8 +3026,8 @@ static ULONG_PTR get_context_reg(union ctx *context, ULONG_PTR dw_reg) ...@@ -3025,8 +3026,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)
{ {
...@@ -3056,13 +3057,14 @@ static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context, ...@@ -3056,13 +3057,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 *dstcontext, ULONG_PTR dwregdst,
union ctx *srccontext, ULONG_PTR dwregsrc) 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)
{ {
...@@ -3094,9 +3096,10 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w ...@@ -3094,9 +3096,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;
...@@ -3153,12 +3156,12 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w ...@@ -3153,12 +3156,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);
...@@ -3205,7 +3208,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk ...@@ -3205,7 +3208,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;
...@@ -3222,7 +3225,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk ...@@ -3222,7 +3225,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);
...@@ -3282,7 +3285,7 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, ...@@ -3282,7 +3285,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;
......
...@@ -175,6 +175,7 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread, ...@@ -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, ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment