[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: [PATCH 2/6] dbghelp/dwarf: Use the correct backend CPU in dwarf2_virtual_unwind().
From: Zebediah Figura <z.figura12 () gmail ! com>
Date: 2018-07-31 16:17:35
Message-ID: 1533053859-30438-2-git-send-email-z.figura12 () gmail ! com
[Download RAW message or body]
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/dbghelp/dbghelp_private.h | 1 +
dlls/dbghelp/dwarf.c | 39 +++++++++++++++++++++------------------
dlls/dbghelp/stack.c | 2 ++
3 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 871b81e..57af60b 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -443,6 +443,7 @@ struct cpu_stack_walk
HANDLE hProcess;
HANDLE hThread;
BOOL is32;
+ struct cpu * cpu;
union
{
struct
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c
index e07c9f0..4053e5e 100644
--- a/dlls/dbghelp/dwarf.c
+++ b/dlls/dbghelp/dwarf.c
@@ -3008,10 +3008,11 @@ static void \
execute_cfa_instructions(dwarf2_traverse_context_t* ctx, }
/* 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;
- ULONG_PTR* ptr = dbghelp_current_cpu->fetch_context_reg(context, regno, &sz);
+ unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz;
+ ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
if (sz != sizeof(ULONG_PTR))
{
@@ -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,
ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee)
{
- unsigned regno = dbghelp_current_cpu->map_dwarf_register(dw_reg, TRUE), sz;
- ULONG_PTR* ptr = dbghelp_current_cpu->fetch_context_reg(context, regno, &sz);
+ unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz;
+ ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
if (isdebuggee)
{
@@ -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 */
-static void copy_context_reg(union ctx *dstcontext, ULONG_PTR dwregdst,
- union ctx *srccontext, ULONG_PTR dwregsrc)
+static void copy_context_reg(struct cpu_stack_walk *csw,
+ union ctx *dstcontext, ULONG_PTR dwregdst,
+ union ctx *srccontext, ULONG_PTR dwregsrc)
{
- unsigned regdstno = dbghelp_current_cpu->map_dwarf_register(dwregdst, TRUE), \
szdst;
- unsigned regsrcno = dbghelp_current_cpu->map_dwarf_register(dwregsrc, TRUE), \
szsrc;
- ULONG_PTR* ptrdst = dbghelp_current_cpu->fetch_context_reg(dstcontext, regdstno, \
&szdst);
- ULONG_PTR* ptrsrc = dbghelp_current_cpu->fetch_context_reg(srccontext, regsrcno, \
&szsrc); + unsigned regdstno = csw->cpu->map_dwarf_register(dwregdst, TRUE), \
szdst; + unsigned regsrcno = csw->cpu->map_dwarf_register(dwregsrc, TRUE), szsrc;
+ ULONG_PTR* ptrdst = csw->cpu->fetch_context_reg(dstcontext, regdstno, &szdst);
+ ULONG_PTR* ptrsrc = csw->cpu->fetch_context_reg(srccontext, regsrcno, &szsrc);
if (szdst != szsrc)
{
@@ -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)
stack[++sp] = opcode - DW_OP_lit0;
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)
- 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)
{
case DW_OP_nop: break;
@@ -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);
break;
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;
case DW_OP_bregx:
reg = dwarf2_leb128_as_unsigned(&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;
case DW_OP_deref_size:
sz = dwarf2_parse_byte(&ctx);
@@ -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); break;
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;
}
if (!*cfa) return;
@@ -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);
break;
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;
case RULE_EXPRESSION:
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,
TRACE("function %lx/%lx code_align %lu data_align %ld retaddr %s\n",
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 (ip == info.ip) return FALSE;
diff --git a/dlls/dbghelp/stack.c b/dlls/dbghelp/stack.c
index 21412f6..b3845db 100644
--- a/dlls/dbghelp/stack.c
+++ b/dlls/dbghelp/stack.c
@@ -175,6 +175,7 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE \
hThread, csw.hProcess = hProcess;
csw.hThread = hThread;
csw.is32 = TRUE;
+ csw.cpu = cpu;
/* 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_xlat_adr = f_xlat_adr;
@@ -231,6 +232,7 @@ BOOL WINAPI StackWalk64(DWORD MachineType, HANDLE hProcess, \
HANDLE hThread, csw.hProcess = hProcess;
csw.hThread = hThread;
csw.is32 = FALSE;
+ csw.cpu = cpu;
/* 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_xlat_adr = (f_xlat_adr) ? f_xlat_adr : addr_to_linear;
--
2.7.4
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic