This and the next patch remove references to specific context structs or fields elsewhere than in the backends.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- v2: fix copy/paste error (thanks Jozef).
programs/winedbg/be_arm.c | 11 +++++++++++ programs/winedbg/be_arm64.c | 11 +++++++++++ programs/winedbg/be_cpu.h | 3 +++ programs/winedbg/be_i386.c | 7 +++++++ programs/winedbg/be_ppc.c | 11 +++++++++++ programs/winedbg/be_x86_64.c | 11 +++++++++++ programs/winedbg/gdbproxy.c | 2 +- programs/winedbg/stack.c | 4 +--- programs/winedbg/tgt_active.c | 14 +------------- 9 files changed, 57 insertions(+), 17 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index b7e42e1..a0e8027 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1889,6 +1889,16 @@ static BOOL be_arm_store_integer(const struct dbg_lvalue* lvalue, unsigned size, return memory_write_value(lvalue, size, &val); }
+static BOOL be_arm_get_context(HANDLE thread, dbg_ctx_t *ctx) +{ +#ifdef __arm__ + ctx->ctx.ContextFlags = CONTEXT_ALL; + return GetThreadContext(thread, &ctx->ctx); +#else + WINE_FIXME("Cannot debug an ARM process on this architecture.\n"); +#endif +} + struct backend_cpu be_arm = { IMAGE_FILE_MACHINE_ARMNT, @@ -1915,5 +1925,6 @@ struct backend_cpu be_arm = be_arm_fetch_integer, be_arm_fetch_float, be_arm_store_integer, + be_arm_get_context, }; #endif diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index dfeb552..6aa26a6 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -278,6 +278,16 @@ void be_arm64_disasm_one_insn(ADDRESS64 *addr, int display) dbg_printf("be_arm64_disasm_one_insn: not done\n"); }
+static BOOL be_arm64_get_context(HANDLE thread, dbg_ctx_t *ctx) +{ +#ifdef __aarch64__ + ctx->ctx.ContextFlags = CONTEXT_ALL; + return GetThreadContext(thread, &ctx->ctx); +#else + WINE_FIXME("Cannot debug an ARM64 process on this architecture.\n"); +#endif +} + struct backend_cpu be_arm64 = { IMAGE_FILE_MACHINE_ARM64, @@ -304,5 +314,6 @@ struct backend_cpu be_arm64 = be_arm64_fetch_integer, be_arm64_fetch_float, be_arm64_store_integer, + be_arm64_get_context, }; #endif diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index 03776d0..aa7d9f0 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -21,6 +21,7 @@ enum be_cpu_addr {be_cpu_addr_pc, be_cpu_addr_stack, be_cpu_addr_frame}; enum be_xpoint_type {be_xpoint_break, be_xpoint_watch_exec, be_xpoint_watch_read, be_xpoint_watch_write, be_xpoint_free=-1}; + struct backend_cpu { const DWORD machine; @@ -114,6 +115,8 @@ struct backend_cpu BOOL (*fetch_float)(const struct dbg_lvalue* lvalue, unsigned size, long double*); /* Writes an integer to memory */ BOOL (*store_integer)(const struct dbg_lvalue* lvalue, unsigned size, BOOL is_signed, LONGLONG); + + BOOL (*get_context)(HANDLE thread, dbg_ctx_t *ctx); };
/* some handy functions for non segmented CPUs */ diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index bdc2ece..c7f5ac1 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -853,6 +853,12 @@ static BOOL be_i386_store_integer(const struct dbg_lvalue* lvalue, unsigned size return memory_write_value(lvalue, size, &val); }
+static BOOL be_i386_get_context(HANDLE thread, dbg_ctx_t *ctx) +{ + ctx->x86.ContextFlags = WOW64_CONTEXT_ALL; + return Wow64GetThreadContext(thread, &ctx->x86); +} + struct backend_cpu be_i386 = { IMAGE_FILE_MACHINE_I386, @@ -879,5 +885,6 @@ struct backend_cpu be_i386 = be_i386_fetch_integer, be_i386_fetch_float, be_i386_store_integer, + be_i386_get_context, }; #endif diff --git a/programs/winedbg/be_ppc.c b/programs/winedbg/be_ppc.c index f1543bf..baf77dc 100644 --- a/programs/winedbg/be_ppc.c +++ b/programs/winedbg/be_ppc.c @@ -180,6 +180,16 @@ static BOOL be_ppc_store_integer(const struct dbg_lvalue* lvalue, unsigned size, return FALSE; }
+static BOOL be_ppc_get_context(HANDLE thread, dbg_ctx_t *ctx) +{ +#ifdef __powerpc__ + ctx->ctx.ContextFlags = CONTEXT_ALL; + return GetThreadContext(thread, &ctx->ctx); +#else + WINE_FIXME("Cannot debug a PowerPC process on this architecture.\n"); +#endif +} + struct backend_cpu be_ppc = { IMAGE_FILE_MACHINE_POWERPC, @@ -206,5 +216,6 @@ struct backend_cpu be_ppc = be_ppc_fetch_integer, be_ppc_fetch_float, be_ppc_store_integer, + be_ppc_get_context, }; #endif diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 450cc87..434f007 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -674,6 +674,16 @@ static BOOL be_x86_64_store_integer(const struct dbg_lvalue* lvalue, unsigned si return memory_write_value(lvalue, size, &val); }
+static BOOL be_x86_64_get_context(HANDLE thread, dbg_ctx_t *ctx) +{ +#ifdef __x86_64__ + ctx->ctx.ContextFlags = CONTEXT_ALL; + return GetThreadContext(thread, &ctx->ctx); +#else + WINE_FIXME("Cannot debug an x86-64 process on this architecture.\n"); +#endif +} + struct backend_cpu be_x86_64 = { IMAGE_FILE_MACHINE_AMD64, @@ -700,5 +710,6 @@ struct backend_cpu be_x86_64 = be_x86_64_fetch_integer, be_x86_64_fetch_float, be_x86_64_store_integer, + be_x86_64_get_context, }; #endif diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index d5786b2..b11a8b0 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -552,7 +552,7 @@ static inline void cpu_register_hex_from(dbg_ctx_t* ctx, unsigned idx, const cha
static BOOL fetch_context(struct gdb_context *gdbctx, HANDLE h, dbg_ctx_t *ctx) { - if (!GetThreadContext(h, &ctx->ctx)) + if (!gdbctx->process->be_cpu->get_context(h, ctx)) { if (gdbctx->trace & GDBPXY_TRC_WIN32_ERROR) fprintf(stderr, "Can't get thread's context\n"); diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index a036107..820200d 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -354,11 +354,9 @@ static void backtrace_tid(struct dbg_process* pcs, DWORD tid) dbg_ctx_t ctx = {0};
dbg_curr_tid = dbg_curr_thread->tid; - - ctx.ctx.ContextFlags = CONTEXT_FULL; if (SuspendThread(dbg_curr_thread->handle) != -1) { - if (!GetThreadContext(dbg_curr_thread->handle, &ctx.ctx)) + if (!pcs->be_cpu->get_context(dbg_curr_thread->handle, &ctx)) { dbg_printf("Can't get context for thread %04x in current process\n", tid); diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 8c94402..fccae0c 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -91,19 +91,7 @@ BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe)
static unsigned dbg_fetch_context(void) { - dbg_context.ctx.ContextFlags = CONTEXT_CONTROL - | CONTEXT_INTEGER -#ifdef CONTEXT_FLOATING_POINT - | CONTEXT_FLOATING_POINT -#endif -#ifdef CONTEXT_SEGMENTS - | CONTEXT_SEGMENTS -#endif -#ifdef CONTEXT_DEBUG_REGISTERS - | CONTEXT_DEBUG_REGISTERS -#endif - ; - if (!GetThreadContext(dbg_curr_thread->handle, &dbg_context.ctx)) + if (!dbg_curr_process->be_cpu->get_context(dbg_curr_thread->handle, &dbg_context)) { WINE_WARN("Can't get thread's context\n"); return FALSE;