[PATCH 5/8] [WineDbg]: main_loop

Eric Pouech eric.pouech at wanadoo.fr
Mon Feb 27 14:50:46 CST 2006


- split dbg_main_loop in two parts (one for finishing the debuggee
  attachment, the second one really for handling the main loop)
- removed now longer needed dbg_main_loop

A+
---

 programs/winedbg/debugger.h   |    2 --
 programs/winedbg/tgt_active.c |   29 ++++++++++++-----------------
 programs/winedbg/winedbg.c    |    6 ++++--
 3 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h
index 73e53a2..68cf2a6 100644
--- a/programs/winedbg/debugger.h
+++ b/programs/winedbg/debugger.h
@@ -375,8 +375,6 @@ 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[]);
-  /* temporary for tgt_active.c */
-extern unsigned         dbg_main_loop(HANDLE);
 
   /* tgt_minidump.c */
 extern void             minidump_write(const char*, const EXCEPTION_RECORD*);
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
index e778c3d..5496765 100644
--- a/programs/winedbg/tgt_active.c
+++ b/programs/winedbg/tgt_active.c
@@ -644,7 +644,7 @@ void dbg_wait_next_exception(DWORD cont,
                dbg_curr_thread->exec_count);
 }
 
-/*static*/	unsigned        dbg_main_loop(HANDLE hFile)
+static void     dbg_wait_for_first_exception(void)
 {
     DEBUG_EVENT		de;
 
@@ -656,10 +656,6 @@ void dbg_wait_next_exception(DWORD cont,
     {
         if (dbg_handle_debug_event(&de)) break;
     }
-    dbg_interactiveP = TRUE;
-    parser_handle(hFile);
-
-    return 0;
 }
 
 static	unsigned dbg_start_debuggee(LPSTR cmdLine)
@@ -703,6 +699,7 @@ static	unsigned dbg_start_debuggee(LPSTR
     }
     dbg_curr_pid = info.dwProcessId;
     if (!(dbg_curr_process = dbg_add_process(dbg_curr_pid, 0))) return FALSE;
+    dbg_wait_for_first_exception();
 
     return TRUE;
 }
@@ -754,17 +751,12 @@ enum dbg_start  dbg_active_attach(int ar
     /* try the form <myself> pid */
     if (argc == 1 && str2int(argv[0], &pid) && pid != 0)
     {
-        if (dbg_attach_debuggee(pid, FALSE, FALSE))
-        {
-            dbg_curr_pid = pid;
-            return start_ok;
-        }
-        return start_error_init;
+        if (!dbg_attach_debuggee(pid, FALSE, FALSE))
+            return start_error_init;
     }
-
     /* try the form <myself> pid evt (Win32 JIT debugger) */
-    if (argc == 2 && str2int(argv[0], &pid) && pid != 0 &&
-        str2int(argv[1], &evt) && evt != 0)
+    else if (argc == 2 && str2int(argv[0], &pid) && pid != 0 &&
+             str2int(argv[1], &evt) && evt != 0)
     {
         if (!dbg_attach_debuggee(pid, TRUE, FALSE))
         {
@@ -778,10 +770,12 @@ enum dbg_start  dbg_active_attach(int ar
             return start_error_init;
         }
         CloseHandle((HANDLE)evt);
-        dbg_curr_pid = pid;
-	return start_ok;
     }
-    return start_error_parse;
+    else return start_error_parse;
+
+    dbg_curr_pid = pid;
+    dbg_wait_for_first_exception();
+    return start_ok;
 }
 
 /******************************************************************
@@ -895,6 +889,7 @@ enum dbg_start dbg_active_auto(int argc,
     }
     else return start_error_parse;
     if (hFile == INVALID_HANDLE_VALUE) return start_error_parse;
+    dbg_wait_for_first_exception();
     dbg_main_loop(hFile);
     return start_ok;
 }
diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c
index cd40734..472d365 100644
--- a/programs/winedbg/winedbg.c
+++ b/programs/winedbg/winedbg.c
@@ -550,11 +550,13 @@ int main(int argc, char** argv)
     case start_error_init:      return -1;
     }
 
-    retv = dbg_main_loop(hFile);
+    dbg_interactiveP = TRUE;
+    parser_handle(hFile);
+
     while (dbg_process_list)
         dbg_process_list->process_io->close_process(dbg_process_list, TRUE);
 
     dbg_save_internal_vars();
 
-    return retv;
+    return 0;
 }





More information about the wine-patches mailing list