Eric Pouech : winedbg: Store for context variables only the offsets of each register ( instead of the address of the register in dbg_context).
Module: wine Branch: master Commit: ea21a32707340cb4f5781691b9ebaab96a9ccab3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ea21a32707340cb4f5781691b9... Author: Eric Pouech <eric.pouech(a)orange.fr> Date: Sat Mar 27 09:08:20 2010 +0100 winedbg: Store for context variables only the offsets of each register (instead of the address of the register in dbg_context). --- programs/winedbg/be_alpha.c | 8 +------- programs/winedbg/be_cpu.h | 8 +++----- programs/winedbg/be_i386.c | 11 +---------- programs/winedbg/be_ppc.c | 8 +------- programs/winedbg/be_x86_64.c | 11 +---------- programs/winedbg/debugger.h | 1 - programs/winedbg/memory.c | 4 ++-- programs/winedbg/winedbg.c | 15 ++++++++++----- 8 files changed, 19 insertions(+), 47 deletions(-) diff --git a/programs/winedbg/be_alpha.c b/programs/winedbg/be_alpha.c index 57bdfd1..3c470e7 100644 --- a/programs/winedbg/be_alpha.c +++ b/programs/winedbg/be_alpha.c @@ -54,12 +54,6 @@ static struct dbg_internal_var be_alpha_ctx[] = {0, NULL, 0, dbg_itype_none} }; -static const struct dbg_internal_var* be_alpha_init_registers(CONTEXT* ctx) -{ - dbg_printf("not done\n"); - return be_alpha_ctx; -} - static unsigned be_alpha_is_step_over_insn(const void* insn) { dbg_printf("not done\n"); @@ -159,7 +153,7 @@ struct backend_cpu be_alpha = be_alpha_single_step, be_alpha_print_context, be_alpha_print_segment_info, - be_alpha_init_registers, + be_alpha_ctx, be_alpha_is_step_over_insn, be_alpha_is_function_return, be_alpha_is_break_insn, diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index 6679977..a08f8f0 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -59,11 +59,9 @@ struct backend_cpu * function empty */ void (*print_segment_info)(HANDLE hThread, const CONTEXT* ctx); - /* Do the initialization so that the debugger has internal variables linked - * to the context's registers - */ - const struct dbg_internal_var* - (*init_registers)(CONTEXT* ctx); + /* all the CONTEXT's relative variables, bound to this CPU */ + const struct dbg_internal_var* context_vars; + /* ------------------------------------------------------------------------------- * code inspection * -------------------------------------------------------------------------------*/ diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index 6ab5970..74676dd 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -290,15 +290,6 @@ static struct dbg_internal_var be_i386_ctx[] = {0, NULL, 0, dbg_itype_none} }; -static const struct dbg_internal_var* be_i386_init_registers(CONTEXT* ctx) -{ - struct dbg_internal_var* div; - - for (div = be_i386_ctx; div->name; div++) - div->pval = (DWORD_PTR*)((char*)ctx + (DWORD)div->pval); - return be_i386_ctx; -} - static unsigned be_i386_is_step_over_insn(const void* insn) { BYTE ch; @@ -754,7 +745,7 @@ struct backend_cpu be_i386 = be_i386_single_step, be_i386_print_context, be_i386_print_segment_info, - be_i386_init_registers, + be_i386_ctx, be_i386_is_step_over_insn, be_i386_is_function_return, be_i386_is_break_insn, diff --git a/programs/winedbg/be_ppc.c b/programs/winedbg/be_ppc.c index 9ba9994..22becf2 100644 --- a/programs/winedbg/be_ppc.c +++ b/programs/winedbg/be_ppc.c @@ -67,12 +67,6 @@ static struct dbg_internal_var be_ppc_ctx[] = {0, NULL, 0, dbg_itype_none} }; -static const struct dbg_internal_var* be_ppc_init_registers(CONTEXT* ctx) -{ - dbg_printf("not done\n"); - return be_ppc_ctx; -} - static unsigned be_ppc_is_step_over_insn(const void* insn) { dbg_printf("not done\n"); @@ -183,7 +177,7 @@ struct backend_cpu be_ppc = be_ppc_single_step, be_ppc_print_context, be_ppc_print_segment_info, - be_ppc_init_registers, + be_ppc_ctx, be_ppc_is_step_over_insn, be_ppc_is_function_return, be_ppc_is_break_insn, diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 682bd05..ac7f1fc 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -153,15 +153,6 @@ static struct dbg_internal_var be_x86_64_ctx[] = {0, NULL, 0, dbg_itype_none} }; -static const struct dbg_internal_var* be_x86_64_init_registers(CONTEXT* ctx) -{ - struct dbg_internal_var* div; - - for (div = be_x86_64_ctx; div->name; div++) - div->pval = (DWORD_PTR*)((char*)ctx + (DWORD_PTR)div->pval); - return be_x86_64_ctx; -} - #define f_mod(b) ((b)>>6) #define f_reg(b) (((b)>>3)&0x7) #define f_rm(b) ((b)&0x7) @@ -561,7 +552,7 @@ struct backend_cpu be_x86_64 = be_x86_64_single_step, be_x86_64_print_context, be_x86_64_print_segment_info, - be_x86_64_init_registers, + be_x86_64_ctx, be_x86_64_is_step_over_insn, be_x86_64_is_function_return, be_x86_64_is_break_insn, diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 300f48a..373600a 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -488,7 +488,6 @@ static inline void* dbg_heap_realloc(void* buffer, size_t size) } extern struct dbg_internal_var dbg_internal_vars[]; -extern const struct dbg_internal_var* dbg_context_vars; #define DBG_IVARNAME(_var) dbg_internal_var_##_var #define DBG_IVARSTRUCT(_var) dbg_internal_vars[DBG_IVARNAME(_var)] diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 9554ea4..2b17dab 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -690,7 +690,7 @@ BOOL memory_get_register(DWORD regno, DWORD_PTR** value, char* buffer, int len) return FALSE; } - for (div = dbg_context_vars; div->name; div++) + for (div = be_cpu->context_vars; div->name; div++) { if (div->val == regno) { @@ -703,7 +703,7 @@ BOOL memory_get_register(DWORD regno, DWORD_PTR** value, char* buffer, int len) } } else - *value = div->pval; + *value = (DWORD_PTR*)((char*)&dbg_context + (DWORD_PTR)div->pval); if (buffer) lstrcpynA(buffer, div->name, len); return TRUE; diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 78bf722..889bb3a 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -96,7 +96,6 @@ BOOL dbg_interactiveP = FALSE; static struct dbg_process* dbg_process_list = NULL; struct dbg_internal_var dbg_internal_vars[DBG_IV_LAST]; -const struct dbg_internal_var* dbg_context_vars; static HANDLE dbg_houtput; static void dbg_outputA(const char* buffer, int len) @@ -208,8 +207,7 @@ static unsigned dbg_load_internal_vars(void) } } RegCloseKey(hkey); - /* set up the debug variables for the CPU context */ - dbg_context_vars = be_cpu->init_registers(&dbg_context); + return TRUE; } @@ -245,9 +243,16 @@ const struct dbg_internal_var* dbg_get_internal_var(const char* name) { if (!strcmp(div->name, name)) return div; } - for (div = dbg_context_vars; div->name; div++) + for (div = be_cpu->context_vars; div->name; div++) { - if (!strcasecmp(div->name, name)) return div; + if (!strcasecmp(div->name, name)) + { + struct dbg_internal_var* ret = (void*)lexeme_alloc_size(sizeof(*ret)); + /* relocate register's field against current context */ + *ret = *div; + ret->pval = (DWORD_PTR*)((char*)&dbg_context + (DWORD_PTR)div->pval); + return ret; + } } return NULL;
participants (1)
-
Alexandre Julliard