Commit 42bbeedb authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winedbg: Make be_cpu process-specific.

parent 14ff4bfe
......@@ -116,8 +116,6 @@ struct backend_cpu
BOOL (*store_integer)(const struct dbg_lvalue* lvalue, unsigned size, BOOL is_signed, LONGLONG);
};
extern struct backend_cpu* be_cpu;
/* some handy functions for non segmented CPUs */
void* be_cpu_linearize(HANDLE hThread, const ADDRESS64*);
BOOL be_cpu_build_addr(HANDLE hThread, const CONTEXT* ctx, ADDRESS64* addr,
......
......@@ -63,15 +63,13 @@ void break_set_xpoints(BOOL set)
addr = memory_to_linear_addr(&bp[i].addr);
if (set)
ret = be_cpu->insert_Xpoint(dbg_curr_process->handle,
dbg_curr_process->process_io,
&dbg_context, bp[i].xpoint_type, addr,
&bp[i].info, size);
ret = dbg_curr_process->be_cpu->insert_Xpoint(dbg_curr_process->handle,
dbg_curr_process->process_io, &dbg_context, bp[i].xpoint_type,
addr, &bp[i].info, size);
else
ret = be_cpu->remove_Xpoint(dbg_curr_process->handle,
dbg_curr_process->process_io,
&dbg_context, bp[i].xpoint_type, addr,
bp[i].info, size);
ret = dbg_curr_process->be_cpu->remove_Xpoint(dbg_curr_process->handle,
dbg_curr_process->process_io, &dbg_context, bp[i].xpoint_type,
addr, bp[i].info, size);
if (!ret)
{
dbg_printf("Invalid address (");
......@@ -572,9 +570,9 @@ static int find_triggered_watch(void)
DWORD64 val = 0;
if (bp[i].refcount && bp[i].enabled && !is_xpoint_break(i) &&
(be_cpu->is_watchpoint_set(&dbg_context, bp[i].info)))
(dbg_curr_process->be_cpu->is_watchpoint_set(&dbg_context, bp[i].info)))
{
be_cpu->clear_watchpoint(&dbg_context, bp[i].info);
dbg_curr_process->be_cpu->clear_watchpoint(&dbg_context, bp[i].info);
if (get_watched_value(i, &val))
{
......@@ -599,7 +597,7 @@ static int find_triggered_watch(void)
{
if (val != bp[i].w.oldval)
{
be_cpu->clear_watchpoint(&dbg_context, bp[i].info);
dbg_curr_process->be_cpu->clear_watchpoint(&dbg_context, bp[i].info);
bp[i].w.oldval = val;
found = i;
/* cannot break, because two watch points may have been triggered on
......@@ -805,7 +803,7 @@ void break_adjust_pc(ADDRESS64* addr, DWORD code, BOOL first_chance, BOOL* is_br
/* If not single-stepping, back up to the break instruction */
if (code == EXCEPTION_BREAKPOINT)
addr->Offset += be_cpu->adjust_pc_for_break(&dbg_context, TRUE);
addr->Offset += dbg_curr_process->be_cpu->adjust_pc_for_break(&dbg_context, TRUE);
dbg_curr_thread->stopped_xpoint = find_xpoint(addr, be_xpoint_break);
dbg_curr_process->bp[0].enabled = FALSE; /* disable the step-over breakpoint */
......@@ -821,7 +819,7 @@ void break_adjust_pc(ADDRESS64* addr, DWORD code, BOOL first_chance, BOOL* is_br
{
/* If not single-stepping, do not back up over the break instruction */
if (code == EXCEPTION_BREAKPOINT)
addr->Offset += be_cpu->adjust_pc_for_break(&dbg_context, FALSE);
addr->Offset += dbg_curr_process->be_cpu->adjust_pc_for_break(&dbg_context, FALSE);
return;
}
}
......@@ -833,7 +831,7 @@ void break_adjust_pc(ADDRESS64* addr, DWORD code, BOOL first_chance, BOOL* is_br
if (dbg_curr_thread->stopped_xpoint == -1 && code == EXCEPTION_BREAKPOINT)
{
*is_break = TRUE;
addr->Offset += be_cpu->adjust_pc_for_break(&dbg_context, FALSE);
addr->Offset += dbg_curr_process->be_cpu->adjust_pc_for_break(&dbg_context, FALSE);
}
}
......@@ -890,7 +888,7 @@ void break_restart_execution(int count)
dbg_printf("Not stopped at any breakpoint; argument ignored.\n");
}
if (mode == dbg_exec_finish && be_cpu->is_function_return(linear))
if (mode == dbg_exec_finish && dbg_curr_process->be_cpu->is_function_return(linear))
{
mode = ret_mode = dbg_exec_step_into_insn;
}
......@@ -901,7 +899,7 @@ void break_restart_execution(int count)
* FIXME - we need to check for things like thunks or trampolines,
* as the actual function may in fact have debug info.
*/
if (be_cpu->is_function_call(linear, &callee))
if (dbg_curr_process->be_cpu->is_function_call(linear, &callee))
{
status = symbol_get_function_line_status(&callee);
#if 0
......@@ -936,7 +934,7 @@ void break_restart_execution(int count)
switch (mode)
{
case dbg_exec_cont: /* Continuous execution */
be_cpu->single_step(&dbg_context, FALSE);
dbg_curr_process->be_cpu->single_step(&dbg_context, FALSE);
break_set_xpoints(TRUE);
break;
......@@ -968,16 +966,16 @@ void break_restart_execution(int count)
case dbg_exec_finish:
case dbg_exec_step_over_insn: /* Stepping over a call */
case dbg_exec_step_over_line: /* Stepping over a call */
if (be_cpu->is_step_over_insn(linear))
if (dbg_curr_process->be_cpu->is_step_over_insn(linear))
{
be_cpu->disasm_one_insn(&addr, FALSE);
dbg_curr_process->be_cpu->disasm_one_insn(&addr, FALSE);
dbg_curr_process->bp[0].addr = addr;
dbg_curr_process->bp[0].enabled = TRUE;
dbg_curr_process->bp[0].refcount = 1;
dbg_curr_process->bp[0].skipcount = 0;
dbg_curr_process->bp[0].xpoint_type = be_xpoint_break;
dbg_curr_process->bp[0].condition = NULL;
be_cpu->single_step(&dbg_context, FALSE);
dbg_curr_process->be_cpu->single_step(&dbg_context, FALSE);
break_set_xpoints(TRUE);
break;
}
......@@ -985,7 +983,7 @@ void break_restart_execution(int count)
case dbg_exec_step_into_line: /* Single-stepping a line */
case dbg_exec_step_into_insn: /* Single-stepping an instruction */
be_cpu->single_step(&dbg_context, TRUE);
dbg_curr_process->be_cpu->single_step(&dbg_context, TRUE);
break;
default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
}
......
......@@ -1800,8 +1800,8 @@ void be_i386_disasm_one_insn(ADDRESS64 *addr, int display)
short_addr ? 2 : 4, FALSE );
get_value_inc( address.Segment, addr, /* segment */
2, FALSE );
be_cpu->build_addr(dbg_curr_thread->handle, &dbg_context,
&address, address.Segment, address.Offset);
dbg_curr_process->be_cpu->build_addr(dbg_curr_thread->handle,
&dbg_context, &address, address.Segment, address.Offset);
if( db_display )
{
print_address( &address, TRUE );
......
......@@ -270,8 +270,8 @@ info_command:
tINFO tBREAK { break_info(); }
| tINFO tSHARE { info_win32_module(0); }
| tINFO tSHARE expr_rvalue { info_win32_module($3); }
| tINFO tREGS { be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 0); }
| tINFO tALLREGS { be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 1); }
| tINFO tREGS { dbg_curr_process->be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 0); }
| tINFO tALLREGS { dbg_curr_process->be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 1); }
| tINFO tSEGMENTS expr_rvalue { info_win32_segments($3 >> 3, 1); }
| tINFO tSEGMENTS { info_win32_segments(0, -1); }
| tINFO tSTACK tNUM { stack_info($3); }
......
......@@ -39,7 +39,7 @@
#include "oaidl.h"
#include <wine/list.h>
#define ADDRSIZE (be_cpu->pointer_size)
#define ADDRSIZE (dbg_curr_process->be_cpu->pointer_size)
#define ADDRWIDTH (ADDRSIZE * 2)
/* the debugger uses these exceptions for its internal use */
......@@ -228,6 +228,7 @@ struct dbg_process
void* pio_data;
const WCHAR* imageName;
struct list threads;
struct backend_cpu* be_cpu;
BOOL continue_on_first_exception : 1,
active_debuggee : 1;
struct dbg_breakpoint bp[MAX_BREAKPOINTS];
......
......@@ -546,8 +546,8 @@ struct dbg_lvalue expr_eval(struct expr* exp)
case EXP_OP_SEG:
rtn.type.id = dbg_itype_segptr;
rtn.type.module = 0;
be_cpu->build_addr(dbg_curr_thread->handle, &dbg_context, &rtn.addr,
types_extract_as_integer(&exp1), types_extract_as_integer(&exp2));
dbg_curr_process->be_cpu->build_addr(dbg_curr_thread->handle, &dbg_context, &rtn.addr,
types_extract_as_integer(&exp1), types_extract_as_integer(&exp2));
break;
case EXP_OP_LOR:
exp->un.binop.result = (types_extract_as_integer(&exp1) || types_extract_as_integer(&exp2));
......
......@@ -886,7 +886,8 @@ static void wait_for_debuggee(struct gdb_context* gdbctx)
static void detach_debuggee(struct gdb_context* gdbctx, BOOL kill)
{
be_cpu->single_step(&gdbctx->context, FALSE);
assert(gdbctx->process->be_cpu);
gdbctx->process->be_cpu->single_step(&gdbctx->context, FALSE);
resume_debuggee(gdbctx, DBG_CONTINUE);
if (!kill)
DebugActiveProcessStop(gdbctx->process->pid);
......@@ -1309,13 +1310,13 @@ static enum packet_return packet_verbose_cont(struct gdb_context* gdbctx)
switch (gdbctx->in_packet[actionIndex[i] + 1])
{
case 's': /* step */
be_cpu->single_step(&gdbctx->context, TRUE);
gdbctx->process->be_cpu->single_step(&gdbctx->context, TRUE);
/* fall through*/
case 'c': /* continue */
resume_debuggee_thread(gdbctx, DBG_CONTINUE, threadID);
break;
case 'S': /* step Sig, */
be_cpu->single_step(&gdbctx->context, TRUE);
gdbctx->process->be_cpu->single_step(&gdbctx->context, TRUE);
/* fall through */
case 'C': /* continue sig */
hex_from(&sig, gdbctx->in_packet + actionIndex[i] + 2, 1);
......@@ -1352,13 +1353,13 @@ static enum packet_return packet_verbose_cont(struct gdb_context* gdbctx)
switch (gdbctx->in_packet[actionIndex[defaultAction] + 1])
{
case 's': /* step */
be_cpu->single_step(&gdbctx->context, TRUE);
gdbctx->process->be_cpu->single_step(&gdbctx->context, TRUE);
/* fall through */
case 'c': /* continue */
resume_debuggee_thread(gdbctx, DBG_CONTINUE, threadID);
break;
case 'S':
be_cpu->single_step(&gdbctx->context, TRUE);
gdbctx->process->be_cpu->single_step(&gdbctx->context, TRUE);
/* fall through */
case 'C': /* continue sig */
hex_from(&sig, gdbctx->in_packet + actionIndex[defaultAction] + 2, 1);
......@@ -1375,7 +1376,7 @@ static enum packet_return packet_verbose_cont(struct gdb_context* gdbctx)
} /* if(defaultAction >=0) */
wait_for_debuggee(gdbctx);
be_cpu->single_step(&gdbctx->context, FALSE);
gdbctx->process->be_cpu->single_step(&gdbctx->context, FALSE);
return packet_reply_status(gdbctx);
}
......@@ -2090,10 +2091,10 @@ static enum packet_return packet_step(struct gdb_context* gdbctx)
if (gdbctx->trace & GDBPXY_TRC_COMMAND_FIXME)
fprintf(stderr, "NIY: step on %04x, while last thread is %04x\n",
gdbctx->exec_thread->tid, dbg_curr_thread->tid);
be_cpu->single_step(&gdbctx->context, TRUE);
gdbctx->process->be_cpu->single_step(&gdbctx->context, TRUE);
resume_debuggee(gdbctx, DBG_CONTINUE);
wait_for_debuggee(gdbctx);
be_cpu->single_step(&gdbctx->context, FALSE);
gdbctx->process->be_cpu->single_step(&gdbctx->context, FALSE);
return packet_reply_status(gdbctx);
}
......
......@@ -974,7 +974,7 @@ void info_win32_exception(void)
{
case AddrModeFlat:
dbg_printf(" in %d-bit code (%s)",
be_cpu->pointer_size * 8,
dbg_curr_process->be_cpu->pointer_size * 8,
memory_offset_to_string(hexbuf, addr.Offset, 0));
break;
case AddrModeReal:
......
......@@ -50,20 +50,20 @@ BOOL be_cpu_build_addr(HANDLE hThread, const CONTEXT* ctx, ADDRESS64* addr,
void* memory_to_linear_addr(const ADDRESS64* addr)
{
return be_cpu->linearize(dbg_curr_thread->handle, addr);
return dbg_curr_process->be_cpu->linearize(dbg_curr_thread->handle, addr);
}
BOOL memory_get_current_pc(ADDRESS64* addr)
{
assert(be_cpu->get_addr);
return be_cpu->get_addr(dbg_curr_thread->handle, &dbg_context,
assert(dbg_curr_process->be_cpu->get_addr);
return dbg_curr_process->be_cpu->get_addr(dbg_curr_thread->handle, &dbg_context,
be_cpu_addr_pc, addr);
}
BOOL memory_get_current_stack(ADDRESS64* addr)
{
assert(be_cpu->get_addr);
return be_cpu->get_addr(dbg_curr_thread->handle, &dbg_context,
assert(dbg_curr_process->be_cpu->get_addr);
return dbg_curr_process->be_cpu->get_addr(dbg_curr_thread->handle, &dbg_context,
be_cpu_addr_stack, addr);
}
......@@ -374,17 +374,17 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue)
{
case btInt:
case btLong:
if (!be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return;
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return;
if (size == 1) goto print_char;
dbg_print_hex(size, val_int);
break;
case btUInt:
case btULong:
if (!be_cpu->fetch_integer(lvalue, size, FALSE, &val_int)) return;
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, FALSE, &val_int)) return;
dbg_print_hex(size, val_int);
break;
case btFloat:
if (!be_cpu->fetch_float(lvalue, size, &val_real)) return;
if (!dbg_curr_process->be_cpu->fetch_float(lvalue, size, &val_real)) return;
dbg_printf("%Lf", val_real);
break;
case btChar:
......@@ -392,7 +392,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue)
/* sometimes WCHAR is defined as btChar with size = 2, so discrimate
* Ansi/Unicode based on size, not on basetype
*/
if (!be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return;
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return;
print_char:
if (size == 1 && isprint((char)val_int))
dbg_printf("'%c'", (char)val_int);
......@@ -407,7 +407,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue)
dbg_printf("%d", (int)val_int);
break;
case btBool:
if (!be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return;
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, size, TRUE, &val_int)) return;
dbg_printf("%s", val_int ? "true" : "false");
break;
default:
......@@ -455,7 +455,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue)
* (not supported yet in dbghelp)
* Assuming 4 as for an int
*/
if (!be_cpu->fetch_integer(lvalue, 4, TRUE, &val_int)) return;
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, 4, TRUE, &val_int)) return;
if (types_get_info(&type, TI_GET_CHILDRENCOUNT, &count))
{
......@@ -631,7 +631,7 @@ BOOL memory_disasm_one_insn(ADDRESS64* addr)
dbg_printf("-- no code accessible --\n");
return FALSE;
}
be_cpu->disasm_one_insn(addr, TRUE);
dbg_curr_process->be_cpu->disasm_one_insn(addr, TRUE);
dbg_printf("\n");
return TRUE;
}
......@@ -685,7 +685,7 @@ BOOL memory_get_register(DWORD regno, DWORD_PTR** value, char* buffer, int len)
return FALSE;
}
for (div = be_cpu->context_vars; div->name; div++)
for (div = dbg_curr_process->be_cpu->context_vars; div->name; div++)
{
if (div->val == regno)
{
......
......@@ -121,7 +121,7 @@ BOOL stack_get_register_frame(const struct dbg_internal_var* div, DWORD_PTR** pv
{
enum be_cpu_addr kind;
if (!be_cpu->get_register_info(div->val, &kind)) return FALSE;
if (!dbg_curr_process->be_cpu->get_register_info(div->val, &kind)) return FALSE;
/* reuse some known registers directly out of stackwalk details */
switch (kind)
......@@ -198,9 +198,9 @@ unsigned stack_fetch_frames(const CONTEXT* _ctx)
dbg_curr_thread->frames = NULL;
memset(&sf, 0, sizeof(sf));
be_cpu->get_addr(dbg_curr_thread->handle, &ctx, be_cpu_addr_frame, &sf.AddrFrame);
be_cpu->get_addr(dbg_curr_thread->handle, &ctx, be_cpu_addr_pc, &sf.AddrPC);
be_cpu->get_addr(dbg_curr_thread->handle, &ctx, be_cpu_addr_stack, &sf.AddrStack);
dbg_curr_process->be_cpu->get_addr(dbg_curr_thread->handle, &ctx, be_cpu_addr_frame, &sf.AddrFrame);
dbg_curr_process->be_cpu->get_addr(dbg_curr_thread->handle, &ctx, be_cpu_addr_pc, &sf.AddrPC);
dbg_curr_process->be_cpu->get_addr(dbg_curr_thread->handle, &ctx, be_cpu_addr_stack, &sf.AddrStack);
/* don't confuse StackWalk by passing in inconsistent addresses */
if ((sf.AddrPC.Mode == AddrModeFlat) && (sf.AddrFrame.Mode != AddrModeFlat))
......@@ -209,7 +209,7 @@ unsigned stack_fetch_frames(const CONTEXT* _ctx)
sf.AddrFrame.Mode = AddrModeFlat;
}
while ((ret = StackWalk64(be_cpu->machine, dbg_curr_process->handle,
while ((ret = StackWalk64(dbg_curr_process->be_cpu->machine, dbg_curr_process->handle,
dbg_curr_thread->handle, &sf, &ctx, stack_read_mem,
SymFunctionTableAccess64, SymGetModuleBase64, NULL)) ||
nf == 0) /* we always register first frame information */
......
......@@ -590,7 +590,7 @@ enum dbg_line_status symbol_get_function_line_status(const ADDRESS64* addr)
/* some compilers insert thunks in their code without debug info associated
* take care of this situation
*/
if (be_cpu->is_jump((void*)lin, &jumpee))
if (dbg_curr_process->be_cpu->is_jump((void*)lin, &jumpee))
return symbol_get_function_line_status(&jumpee);
return dbg_no_line_info;
}
......
......@@ -148,7 +148,8 @@ static BOOL dbg_exception_prolog(BOOL is_debug, const EXCEPTION_RECORD* rec)
case AddrMode1616: name = "16 bit"; break;
case AddrMode1632: name = "segmented 32 bit"; break;
case AddrModeReal: name = "vm86"; break;
case AddrModeFlat: name = be_cpu->pointer_size == 4 ? "32 bit" : "64 bit"; break;
case AddrModeFlat: name = dbg_curr_process->be_cpu->pointer_size == 4
? "32 bit" : "64 bit"; break;
}
dbg_printf("In %s mode.\n", name);
dbg_curr_thread->addr_mode = addr.Mode;
......@@ -158,9 +159,9 @@ static BOOL dbg_exception_prolog(BOOL is_debug, const EXCEPTION_RECORD* rec)
if (!is_debug)
{
/* This is a real crash, dump some info */
be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 0);
dbg_curr_process->be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 0);
stack_info(-1);
be_cpu->print_segment_info(dbg_curr_thread->handle, &dbg_context);
dbg_curr_process->be_cpu->print_segment_info(dbg_curr_thread->handle, &dbg_context);
stack_backtrace(dbg_curr_tid);
}
else
......@@ -997,7 +998,7 @@ static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill)
/* needed for single stepping (ugly).
* should this be handled inside the server ???
*/
be_cpu->single_step(&dbg_context, FALSE);
dbg_curr_process->be_cpu->single_step(&dbg_context, FALSE);
if (dbg_curr_thread->in_exception)
{
SetThreadContext(dbg_curr_thread->handle, &dbg_context);
......
......@@ -477,9 +477,9 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
min(sizeof(dbg_context), mes->ThreadContext.DataSize));
memory_get_current_pc(&addr);
stack_fetch_frames(&dbg_context);
be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 0);
dbg_curr_process->be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 0);
stack_info(-1);
be_cpu->print_segment_info(dbg_curr_thread->handle, &dbg_context);
dbg_curr_process->be_cpu->print_segment_info(dbg_curr_thread->handle, &dbg_context);
stack_backtrace(mes->ThreadId);
source_list_from_addr(&addr, 0);
}
......
......@@ -92,11 +92,11 @@ LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue,
{
case btChar:
case btInt:
if (!be_cpu->fetch_integer(lvalue, (unsigned)size, s = TRUE, &rtn))
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, (unsigned)size, s = TRUE, &rtn))
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
case btUInt:
if (!be_cpu->fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn))
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn))
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
case btFloat:
......@@ -106,17 +106,17 @@ LONGLONG types_extract_as_longlong(const struct dbg_lvalue* lvalue,
if (issigned) *issigned = s;
break;
case SymTagPointerType:
if (!be_cpu->fetch_integer(lvalue, sizeof(void*), s = FALSE, &rtn))
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, sizeof(void*), s = FALSE, &rtn))
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
case SymTagArrayType:
case SymTagUDT:
if (!be_cpu->fetch_integer(lvalue, sizeof(unsigned), s = FALSE, &rtn))
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, sizeof(unsigned), s = FALSE, &rtn))
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
case SymTagEnum:
/* FIXME: we don't handle enum size */
if (!be_cpu->fetch_integer(lvalue, sizeof(unsigned), s = FALSE, &rtn))
if (!dbg_curr_process->be_cpu->fetch_integer(lvalue, sizeof(unsigned), s = FALSE, &rtn))
RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
break;
case SymTagFunctionType:
......@@ -173,7 +173,7 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv
}
/* FIXME: should support floats as well */
val = types_extract_as_longlong(lvalue_from, NULL, &is_signed);
return be_cpu->store_integer(lvalue_to, size, is_signed, val);
return dbg_curr_process->be_cpu->store_integer(lvalue_to, size, is_signed, val);
}
/******************************************************************
......@@ -302,9 +302,10 @@ BOOL types_array_index(const struct dbg_lvalue* lvalue, int index, struct dbg_lv
result->addr = lvalue->addr;
break;
case SymTagPointerType:
if (!memory_read_value(lvalue, be_cpu->pointer_size, &result->addr.Offset)) return FALSE;
if (!memory_read_value(lvalue, dbg_curr_process->be_cpu->pointer_size, &result->addr.Offset))
return FALSE;
result->addr.Mode = AddrModeFlat;
switch (be_cpu->pointer_size)
switch (dbg_curr_process->be_cpu->pointer_size)
{
case 4: result->addr.Offset = (DWORD)result->addr.Offset; break;
case 8: break;
......
......@@ -241,7 +241,7 @@ const struct dbg_internal_var* dbg_get_internal_var(const char* name)
{
if (!strcmp(div->name, name)) return div;
}
for (div = be_cpu->context_vars; div->name; div++)
for (div = dbg_curr_process->be_cpu->context_vars; div->name; div++)
{
if (!strcasecmp(div->name, name))
{
......@@ -279,6 +279,20 @@ struct dbg_process* dbg_get_process_h(HANDLE h)
return NULL;
}
#ifdef __i386__
extern struct backend_cpu be_i386;
#elif defined(__powerpc__)
extern struct backend_cpu be_ppc;
#elif defined(__x86_64__)
extern struct backend_cpu be_x86_64;
#elif defined(__arm__) && !defined(__ARMEB__)
extern struct backend_cpu be_arm;
#elif defined(__aarch64__) && !defined(__AARCH64EB__)
extern struct backend_cpu be_arm64;
#else
# error CPU unknown
#endif
struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h)
{
struct dbg_process* p;
......@@ -318,6 +332,20 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
p->source_end_line = -1;
list_add_head(&dbg_process_list, &p->entry);
#ifdef __i386__
p->be_cpu = &be_i386;
#elif defined(__powerpc__)
p->be_cpu = &be_ppc;
#elif defined(__x86_64__)
p->be_cpu = &be_x86_64;
#elif defined(__arm__) && !defined(__ARMEB__)
p->be_cpu = &be_arm;
#elif defined(__aarch64__) && !defined(__AARCH64EB__)
p->be_cpu = &be_arm64;
#else
# error CPU unknown
#endif
return p;
}
......@@ -609,40 +637,12 @@ static LONG CALLBACK top_filter( EXCEPTION_POINTERS *ptr )
return EXCEPTION_EXECUTE_HANDLER;
}
struct backend_cpu* be_cpu;
#ifdef __i386__
extern struct backend_cpu be_i386;
#elif defined(__powerpc__)
extern struct backend_cpu be_ppc;
#elif defined(__x86_64__)
extern struct backend_cpu be_x86_64;
#elif defined(__arm__) && !defined(__ARMEB__)
extern struct backend_cpu be_arm;
#elif defined(__aarch64__) && !defined(__AARCH64EB__)
extern struct backend_cpu be_arm64;
#else
# error CPU unknown
#endif
int main(int argc, char** argv)
{
int retv = 0;
HANDLE hFile = INVALID_HANDLE_VALUE;
enum dbg_start ds;
#ifdef __i386__
be_cpu = &be_i386;
#elif defined(__powerpc__)
be_cpu = &be_ppc;
#elif defined(__x86_64__)
be_cpu = &be_x86_64;
#elif defined(__arm__) && !defined(__ARMEB__)
be_cpu = &be_arm;
#elif defined(__aarch64__) && !defined(__AARCH64EB__)
be_cpu = &be_arm64;
#else
# error CPU unknown
#endif
/* Initialize the output */
dbg_houtput = GetStdHandle(STD_OUTPUT_HANDLE);
......
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