winedbg: Store for context variables only the offsets of each register (instead of the address of the register in dbg_context).

This commit is contained in:
Eric Pouech 2010-03-27 09:08:20 +01:00 committed by Alexandre Julliard
parent 036392c5d1
commit ea21a32707
8 changed files with 19 additions and 47 deletions

View File

@ -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,

View File

@ -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
* -------------------------------------------------------------------------------*/

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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)]

View File

@ -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;

View File

@ -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;