Commit 9f3e8a51 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Use cpu from debuggee's modules rather than debugger's.

parent e8b19532
...@@ -812,7 +812,7 @@ static unsigned dwarf2_map_register(int regno, const struct module* module) ...@@ -812,7 +812,7 @@ static unsigned dwarf2_map_register(int regno, const struct module* module)
FIXME("What the heck map reg 0x%x\n",regno); FIXME("What the heck map reg 0x%x\n",regno);
return 0; return 0;
} }
return dbghelp_current_cpu->map_dwarf_register(regno, module, FALSE); return module->cpu->map_dwarf_register(regno, module, FALSE);
} }
static enum location_error static enum location_error
...@@ -847,8 +847,8 @@ compute_location(const struct module *module, const dwarf2_cuhead_t* head, ...@@ -847,8 +847,8 @@ compute_location(const struct module *module, const dwarf2_cuhead_t* head,
DWORD cvreg = dwarf2_map_register(op - DW_OP_reg0, module); DWORD cvreg = dwarf2_map_register(op - DW_OP_reg0, module);
if (loc->reg != Wine_DW_no_register) if (loc->reg != Wine_DW_no_register)
FIXME("Only supporting one reg (%s/%d -> %s/%d)\n", FIXME("Only supporting one reg (%s/%d -> %s/%d)\n",
dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg, module->cpu->fetch_regname(loc->reg), loc->reg,
dbghelp_current_cpu->fetch_regname(cvreg), cvreg); module->cpu->fetch_regname(cvreg), cvreg);
loc->reg = cvreg; loc->reg = cvreg;
} }
loc->kind = loc_register; loc->kind = loc_register;
...@@ -864,8 +864,8 @@ compute_location(const struct module *module, const dwarf2_cuhead_t* head, ...@@ -864,8 +864,8 @@ compute_location(const struct module *module, const dwarf2_cuhead_t* head,
DWORD cvreg = dwarf2_map_register(op - DW_OP_breg0, module); DWORD cvreg = dwarf2_map_register(op - DW_OP_breg0, module);
if (loc->reg != Wine_DW_no_register) if (loc->reg != Wine_DW_no_register)
FIXME("Only supporting one breg (%s/%d -> %s/%d)\n", FIXME("Only supporting one breg (%s/%d -> %s/%d)\n",
dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg, module->cpu->fetch_regname(loc->reg), loc->reg,
dbghelp_current_cpu->fetch_regname(cvreg), cvreg); module->cpu->fetch_regname(cvreg), cvreg);
loc->reg = cvreg; loc->reg = cvreg;
} }
stack[++stk] = dwarf2_leb128_as_signed(ctx); stack[++stk] = dwarf2_leb128_as_signed(ctx);
...@@ -938,7 +938,7 @@ compute_location(const struct module *module, const dwarf2_cuhead_t* head, ...@@ -938,7 +938,7 @@ compute_location(const struct module *module, const dwarf2_cuhead_t* head,
case DW_OP_fbreg: case DW_OP_fbreg:
if (loc->reg != Wine_DW_no_register) if (loc->reg != Wine_DW_no_register)
FIXME("Only supporting one reg (%s/%d -> -2)\n", FIXME("Only supporting one reg (%s/%d -> -2)\n",
dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg); module->cpu->fetch_regname(loc->reg), loc->reg);
if (frame && frame->kind == loc_register) if (frame && frame->kind == loc_register)
{ {
loc->kind = loc_regrel; loc->kind = loc_regrel;
...@@ -2284,7 +2284,7 @@ static struct symt* dwarf2_parse_subprogram(dwarf2_debug_info_t* di) ...@@ -2284,7 +2284,7 @@ static struct symt* dwarf2_parse_subprogram(dwarf2_debug_info_t* di)
{ {
/* on stack !! */ /* on stack !! */
subpgm.frame.kind = loc_regrel; subpgm.frame.kind = loc_regrel;
subpgm.frame.reg = dbghelp_current_cpu->frame_regno; subpgm.frame.reg = di->unit_ctx->module_ctx->module->cpu->frame_regno;
subpgm.frame.offset = 0; subpgm.frame.offset = 0;
} }
subpgm.non_computed_variable = FALSE; subpgm.non_computed_variable = FALSE;
...@@ -3256,7 +3256,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3256,7 +3256,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_offset %s, %ld\n", TRACE("%lx: DW_CFA_offset %s, %ld\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)),
offset); offset);
info->state.regs[reg] = offset; info->state.regs[reg] = offset;
info->state.rules[reg] = RULE_CFA_OFFSET; info->state.rules[reg] = RULE_CFA_OFFSET;
...@@ -3268,7 +3268,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3268,7 +3268,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_restore %s\n", TRACE("%lx: DW_CFA_restore %s\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)));
info->state.rules[reg] = RULE_UNSET; info->state.rules[reg] = RULE_UNSET;
break; break;
} }
...@@ -3316,7 +3316,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3316,7 +3316,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_offset_extended %s, %ld\n", TRACE("%lx: DW_CFA_offset_extended %s, %ld\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)),
offset); offset);
info->state.regs[reg] = offset; info->state.regs[reg] = offset;
info->state.rules[reg] = RULE_CFA_OFFSET; info->state.rules[reg] = RULE_CFA_OFFSET;
...@@ -3328,7 +3328,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3328,7 +3328,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_restore_extended %s\n", TRACE("%lx: DW_CFA_restore_extended %s\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)));
info->state.rules[reg] = RULE_UNSET; info->state.rules[reg] = RULE_UNSET;
break; break;
} }
...@@ -3338,7 +3338,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3338,7 +3338,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_undefined %s\n", TRACE("%lx: DW_CFA_undefined %s\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)));
info->state.rules[reg] = RULE_UNDEFINED; info->state.rules[reg] = RULE_UNDEFINED;
break; break;
} }
...@@ -3348,7 +3348,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3348,7 +3348,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_same_value %s\n", TRACE("%lx: DW_CFA_same_value %s\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)));
info->state.regs[reg] = reg; info->state.regs[reg] = reg;
info->state.rules[reg] = RULE_SAME; info->state.rules[reg] = RULE_SAME;
break; break;
...@@ -3360,8 +3360,8 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3360,8 +3360,8 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg) || !valid_reg(reg2)) break; if (!valid_reg(reg) || !valid_reg(reg2)) break;
TRACE("%lx: DW_CFA_register %s == %s\n", TRACE("%lx: DW_CFA_register %s == %s\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)),
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg2, module, TRUE))); module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg2, module, TRUE)));
info->state.regs[reg] = reg2; info->state.regs[reg] = reg2;
info->state.rules[reg] = RULE_OTHER_REG; info->state.rules[reg] = RULE_OTHER_REG;
break; break;
...@@ -3389,7 +3389,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3389,7 +3389,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_def_cfa %s, %ld\n", TRACE("%lx: DW_CFA_def_cfa %s, %ld\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)),
offset); offset);
info->state.cfa_reg = reg; info->state.cfa_reg = reg;
info->state.cfa_offset = offset; info->state.cfa_offset = offset;
...@@ -3402,7 +3402,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3402,7 +3402,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_def_cfa_register %s\n", TRACE("%lx: DW_CFA_def_cfa_register %s\n",
info->ip, info->ip,
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)));
info->state.cfa_reg = reg; info->state.cfa_reg = reg;
info->state.cfa_rule = RULE_CFA_OFFSET; info->state.cfa_rule = RULE_CFA_OFFSET;
break; break;
...@@ -3436,7 +3436,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont ...@@ -3436,7 +3436,7 @@ static void execute_cfa_instructions(struct module* module, dwarf2_traverse_cont
if (!valid_reg(reg)) break; if (!valid_reg(reg)) break;
TRACE("%lx: DW_CFA_%sexpression %s %lx-%lx\n", TRACE("%lx: DW_CFA_%sexpression %s %lx-%lx\n",
info->ip, (op == DW_CFA_expression) ? "" : "val_", info->ip, (op == DW_CFA_expression) ? "" : "val_",
dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), module->cpu->fetch_regname(module->cpu->map_dwarf_register(reg, module, TRUE)),
expr, expr + len); expr, expr + len);
info->state.regs[reg] = expr; info->state.regs[reg] = expr;
info->state.rules[reg] = (op == DW_CFA_expression) ? RULE_EXPRESSION : RULE_VAL_EXPRESSION; info->state.rules[reg] = (op == DW_CFA_expression) ? RULE_EXPRESSION : RULE_VAL_EXPRESSION;
...@@ -3465,6 +3465,7 @@ static DWORD64 get_context_reg(const struct module* module, struct cpu_stack_wal ...@@ -3465,6 +3465,7 @@ static DWORD64 get_context_reg(const struct module* module, struct cpu_stack_wal
unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz; unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz;
void* ptr = csw->cpu->fetch_context_reg(context, regno, &sz); void* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
if (csw->cpu != module->cpu) FIXME("mismatch in cpu\n");
if (sz == 8) if (sz == 8)
return *(DWORD64 *)ptr; return *(DWORD64 *)ptr;
else if (sz == 4) else if (sz == 4)
...@@ -3481,6 +3482,7 @@ static void set_context_reg(const struct module* module, struct cpu_stack_walk* ...@@ -3481,6 +3482,7 @@ static void set_context_reg(const struct module* module, struct cpu_stack_walk*
unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, 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); ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
if (csw->cpu != module->cpu) FIXME("mismatch in cpu\n");
if (isdebuggee) if (isdebuggee)
{ {
char tmp[16]; char tmp[16];
...@@ -3518,6 +3520,7 @@ static void copy_context_reg(const struct module* module, struct cpu_stack_walk ...@@ -3518,6 +3520,7 @@ static void copy_context_reg(const struct module* module, struct cpu_stack_walk
ULONG_PTR* ptrdst = csw->cpu->fetch_context_reg(dstcontext, regdstno, &szdst); ULONG_PTR* ptrdst = csw->cpu->fetch_context_reg(dstcontext, regdstno, &szdst);
ULONG_PTR* ptrsrc = csw->cpu->fetch_context_reg(srccontext, regsrcno, &szsrc); ULONG_PTR* ptrsrc = csw->cpu->fetch_context_reg(srccontext, regsrcno, &szsrc);
if (csw->cpu != module->cpu) FIXME("mismatch in cpu\n");
if (szdst != szsrc) if (szdst != szsrc)
{ {
FIXME("Cannot copy register %lu/%u => %lu/%u because of size mismatch (%u => %u)\n", FIXME("Cannot copy register %lu/%u => %lu/%u because of size mismatch (%u => %u)\n",
...@@ -3536,6 +3539,7 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w ...@@ -3536,6 +3539,7 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w
int sp = -1; int sp = -1;
ULONG_PTR len; ULONG_PTR len;
if (csw->cpu != module->cpu) FIXME("mismatch in cpu\n");
ctx.data = zp; ctx.data = zp;
ctx.end_data = zp + 4; ctx.end_data = zp + 4;
len = dwarf2_leb128_as_unsigned(&ctx); len = dwarf2_leb128_as_unsigned(&ctx);
...@@ -3647,6 +3651,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk ...@@ -3647,6 +3651,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk
ULONG_PTR value; ULONG_PTR value;
union ctx new_context = *context; union ctx new_context = *context;
if (csw->cpu != module->cpu) FIXME("mismatch in cpu\n");
switch (state->cfa_rule) switch (state->cfa_rule)
{ {
case RULE_EXPRESSION: case RULE_EXPRESSION:
...@@ -3756,6 +3761,7 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, ...@@ -3756,6 +3761,7 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip,
struct frame_info info; struct frame_info info;
if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE; if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE;
if (csw->cpu != pair.effective->cpu) FIXME("mismatch in cpu\n");
if (!dwarf2_fetch_frame_info(pair.effective, csw->cpu, ip, &info)) return FALSE; if (!dwarf2_fetch_frame_info(pair.effective, csw->cpu, ip, &info)) return FALSE;
/* if at very beginning of function, return and use default unwinder */ /* if at very beginning of function, return and use default unwinder */
...@@ -3773,15 +3779,15 @@ static BOOL compute_call_frame_cfa(struct module* module, ULONG_PTR ip, struct l ...@@ -3773,15 +3779,15 @@ static BOOL compute_call_frame_cfa(struct module* module, ULONG_PTR ip, struct l
{ {
struct frame_info info; struct frame_info info;
if (!dwarf2_fetch_frame_info(module, dbghelp_current_cpu, ip, &info)) return FALSE; if (!dwarf2_fetch_frame_info(module, module->cpu, ip, &info)) return FALSE;
/* beginning of function, or no available dwarf information ? */ /* beginning of function, or no available dwarf information ? */
if (ip == info.ip || info.state.rules[info.retaddr_reg] == RULE_UNSET) if (ip == info.ip || info.state.rules[info.retaddr_reg] == RULE_UNSET)
{ {
/* fake the default unwinder */ /* fake the default unwinder */
frame->kind = loc_regrel; frame->kind = loc_regrel;
frame->reg = dbghelp_current_cpu->frame_regno; frame->reg = module->cpu->frame_regno;
frame->offset = dbghelp_current_cpu->word_size; /* FIXME stack direction */ frame->offset = module->cpu->word_size; /* FIXME stack direction */
} }
else else
{ {
...@@ -3798,7 +3804,7 @@ static BOOL compute_call_frame_cfa(struct module* module, ULONG_PTR ip, struct l ...@@ -3798,7 +3804,7 @@ static BOOL compute_call_frame_cfa(struct module* module, ULONG_PTR ip, struct l
return FALSE; return FALSE;
default: default:
frame->kind = loc_regrel; frame->kind = loc_regrel;
frame->reg = dbghelp_current_cpu->map_dwarf_register(info.state.cfa_reg, module, TRUE); frame->reg = module->cpu->map_dwarf_register(info.state.cfa_reg, module, TRUE);
frame->offset = info.state.cfa_offset; frame->offset = info.state.cfa_offset;
break; break;
} }
......
...@@ -1480,11 +1480,11 @@ PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase) ...@@ -1480,11 +1480,11 @@ PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase)
struct process* pcs = process_find_by_handle(hProcess); struct process* pcs = process_find_by_handle(hProcess);
struct module* module; struct module* module;
if (!pcs || !dbghelp_current_cpu->find_runtime_function) return NULL; if (!pcs) return NULL;
module = module_find_by_addr(pcs, AddrBase, DMT_UNKNOWN); module = module_find_by_addr(pcs, AddrBase, DMT_UNKNOWN);
if (!module) return NULL; if (!module || !module->cpu->find_runtime_function) return NULL;
return dbghelp_current_cpu->find_runtime_function(module, AddrBase); return module->cpu->find_runtime_function(module, AddrBase);
} }
static BOOL native_synchronize_module_list(struct process* pcs) static BOOL native_synchronize_module_list(struct process* pcs)
......
...@@ -1396,7 +1396,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, ...@@ -1396,7 +1396,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset,
continue; continue;
} }
loc.kind = loc_regrel; loc.kind = loc_regrel;
loc.reg = dbghelp_current_cpu->frame_regno; loc.reg = module->cpu->frame_regno;
loc.offset = n_value; loc.offset = n_value;
symt_add_func_local(module, curr_func, symt_add_func_local(module, curr_func,
(int)n_value >= 0 ? DataIsParam : DataIsLocal, (int)n_value >= 0 ? DataIsParam : DataIsLocal,
...@@ -1476,7 +1476,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, ...@@ -1476,7 +1476,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset,
case N_LSYM: case N_LSYM:
/* These are local variables */ /* These are local variables */
loc.kind = loc_regrel; loc.kind = loc_regrel;
loc.reg = dbghelp_current_cpu->frame_regno; loc.reg = module->cpu->frame_regno;
loc.offset = n_value; loc.offset = n_value;
if (curr_func != NULL) pending_add_var(&pending_block, ptr, DataIsLocal, &loc); if (curr_func != NULL) pending_add_var(&pending_block, ptr, DataIsLocal, &loc);
break; break;
......
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