From c918e80ed2fded210cdc2766058067e452ee3341 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 1 Mar 2006 21:05:31 +0100 Subject: [PATCH] winedbg: process_io - added ability to specify process_io at process creation/attachment time - created a process_io structure for gdbproxy --- programs/winedbg/debugger.h | 4 ++-- programs/winedbg/gdbproxy.c | 11 ++++++++++- programs/winedbg/tgt_active.c | 9 +++++---- programs/winedbg/winedbg.c | 8 +++----- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 68cf2a65015..5114138914d 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -375,6 +375,7 @@ extern void dbg_wait_next_exception(DWORD cont, int count, int mode) extern enum dbg_start dbg_active_attach(int argc, char* argv[]); extern enum dbg_start dbg_active_launch(int argc, char* argv[]); extern enum dbg_start dbg_active_auto(int argc, char* argv[]); +extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe); /* tgt_minidump.c */ extern void minidump_write(const char*, const EXCEPTION_RECORD*); @@ -401,9 +402,8 @@ extern int dbg_printf(const char* format, ...) __attribute__((format (pr extern int dbg_printf(const char* format, ...); #endif extern const struct dbg_internal_var* dbg_get_internal_var(const char*); -extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe); extern BOOL dbg_interrupt_debuggee(void); -extern struct dbg_process* dbg_add_process(DWORD pid, HANDLE h); +extern struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h); extern void dbg_set_process_name(struct dbg_process* p, const char* name); extern struct dbg_process* dbg_get_process(DWORD pid); extern void dbg_del_process(struct dbg_process* p); diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index ade801c8aa1..76496ca3ce2 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -102,6 +102,8 @@ struct gdb_context unsigned long wine_segs[3]; /* load addresses of the ELF wine exec segments (text, bss and data) */ }; +static struct be_process_io be_process_gdbproxy_io; + /* =============================================== * * B A S I C M A N I P U L A T I O N S * * =============================================== * @@ -444,7 +446,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de) switch (de->dwDebugEventCode) { case CREATE_PROCESS_DEBUG_EVENT: - gdbctx->process = dbg_add_process(de->dwProcessId, + gdbctx->process = dbg_add_process(&be_process_gdbproxy_io, de->dwProcessId, de->u.CreateProcessInfo.hProcess); if (!gdbctx->process) break; memory_get_string_indirect(gdbctx->process, @@ -2278,3 +2280,10 @@ int gdb_main(int argc, char* argv[]) return gdb_remote(gdb_flags); return -1; } + +static struct be_process_io be_process_gdbproxy_io = +{ + NULL, /* we shouldn't use close_process() in gdbproxy */ + ReadProcessMemory, + WriteProcessMemory +}; diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index a52d9023887..d4eaade6f3b 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(winedbg); static char* dbg_last_cmd_line; +static struct be_process_io be_process_active_io; static void dbg_init_current_process(void) { @@ -72,7 +73,7 @@ BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe) { DEBUG_EVENT de; - if (!(dbg_curr_process = dbg_add_process(pid, 0))) return FALSE; + if (!(dbg_curr_process = dbg_add_process(&be_process_active_io, pid, 0))) return FALSE; if (!DebugActiveProcess(pid)) { @@ -436,7 +437,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de) break; case CREATE_PROCESS_DEBUG_EVENT: - dbg_curr_process = dbg_add_process(de->dwProcessId, + dbg_curr_process = dbg_add_process(&be_process_active_io, de->dwProcessId, de->u.CreateProcessInfo.hProcess); if (dbg_curr_process == NULL) { @@ -698,7 +699,7 @@ static unsigned dbg_start_debuggee(LPSTR cmdLine) return TRUE; } dbg_curr_pid = info.dwProcessId; - if (!(dbg_curr_process = dbg_add_process(dbg_curr_pid, 0))) return FALSE; + if (!(dbg_curr_process = dbg_add_process(&be_process_active_io, dbg_curr_pid, 0))) return FALSE; dbg_wait_for_first_exception(); return TRUE; @@ -920,7 +921,7 @@ static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill) return TRUE; } -struct be_process_io be_process_active_io = +static struct be_process_io be_process_active_io = { tgt_process_active_close_process, ReadProcessMemory, diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 472d365da46..4c2ae002308 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -250,11 +250,8 @@ struct dbg_process* dbg_get_process(DWORD pid) return p; } -struct dbg_process* dbg_add_process(DWORD pid, HANDLE h) +struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h) { - /* FIXME: temporary */ - extern struct be_process_io be_process_active_io; - struct dbg_process* p; if ((p = dbg_get_process(pid))) @@ -266,6 +263,7 @@ struct dbg_process* dbg_add_process(DWORD pid, HANDLE h) else { p->handle = h; + p->process_io = pio; p->imageName = NULL; } return p; @@ -274,7 +272,7 @@ struct dbg_process* dbg_add_process(DWORD pid, HANDLE h) if (!(p = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dbg_process)))) return NULL; p->handle = h; p->pid = pid; - p->process_io = &be_process_active_io; + p->process_io = pio; p->imageName = NULL; p->threads = NULL; p->continue_on_first_exception = FALSE;