[PATCH 2/4] [WineDbg] process_io

Eric Pouech eric.pouech at wanadoo.fr
Wed Mar 1 14:05:31 CST 2006


- added ability to specify process_io at process creation/attachment
  time
- created a process_io structure for gdbproxy

A+
---

 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 68cf2a6..5114138 100644
--- a/programs/winedbg/debugger.h
+++ b/programs/winedbg/debugger.h
@@ -375,6 +375,7 @@ extern void             dbg_wait_next_ex
 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
 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 ade801c..76496ca 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 gd
     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 a52d902..d4eaade 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
 {
     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(D
         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
         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_pro
     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 472d365..4c2ae00 100644
--- a/programs/winedbg/winedbg.c
+++ b/programs/winedbg/winedbg.c
@@ -250,11 +250,8 @@ struct dbg_process*     dbg_get_process(
     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(DWOR
         else
         {
             p->handle = h;
+            p->process_io = pio;
             p->imageName = NULL;
         }
         return p;
@@ -274,7 +272,7 @@ struct dbg_process*	dbg_add_process(DWOR
     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;





More information about the wine-patches mailing list