Module: wine Branch: master Commit: b795f8735dd367316ba5aa075da153b38a48cd70 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b795f8735dd367316ba5aa075d...
Author: Eric Pouech eric.pouech@wanadoo.fr Date: Sat Feb 10 10:48:52 2007 +0100
winedbg: Support for debugging child processes.
Added internal flag (AlsoDebugProcChild) to let winedbg debug both parent and child (in the same WineDbg session).
---
programs/winedbg/debug.l | 2 +- programs/winedbg/debugger.h | 1 + programs/winedbg/intvar.h | 3 +++ programs/winedbg/tgt_active.c | 10 ++++++---- programs/winedbg/winedbg.c | 10 ++++++++++ 5 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index 9613fed..6be0f4c 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -95,7 +95,7 @@ STRING "[^\n"]+" %x NOPROCESS %% /* set to special state when no process is loaded. */ - if (!dbg_curr_process && YYSTATE == INITIAL) {BEGIN(NOPROCESS);} + if (!dbg_num_processes() && YYSTATE == INITIAL) {BEGIN(NOPROCESS);}
<<EOF>> { return tEOF; } <*>\n { BEGIN(INITIAL); syntax_error = 0; return tEOL; } diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 0317247..3ad2bd3 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -421,6 +421,7 @@ extern int dbg_printf(const char #endif extern const struct dbg_internal_var* dbg_get_internal_var(const char*); extern BOOL dbg_interrupt_debuggee(void); +extern unsigned dbg_num_processes(void); 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); diff --git a/programs/winedbg/intvar.h b/programs/winedbg/intvar.h index 1864211..a9c335e 100644 --- a/programs/winedbg/intvar.h +++ b/programs/winedbg/intvar.h @@ -33,3 +33,6 @@ INTERNAL_VAR(ProcessId, FALSE, &dbg_c
/* symbol manipulation */ INTERNAL_VAR(AlwaysShowThunks, FALSE, NULL, dbg_itype_unsigned_int) + + /* process manipulation */ +INTERNAL_VAR(AlsoDebugProcChild, FALSE, NULL, dbg_itype_unsigned_int) diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index d7b744f..8730f41 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -664,7 +664,7 @@ static void wait_exception(void) { DEBUG_EVENT de;
- while (dbg_curr_process && WaitForDebugEvent(&de, INFINITE)) + while (dbg_num_processes() && WaitForDebugEvent(&de, INFINITE)) { if (dbg_handle_debug_event(&de)) break; } @@ -704,6 +704,7 @@ static unsigned dbg_start_debuggee(LPSTR { PROCESS_INFORMATION info; STARTUPINFOA startup; + DWORD flags;
memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); @@ -713,9 +714,10 @@ static unsigned dbg_start_debuggee(LPSTR /* FIXME: shouldn't need the CREATE_NEW_CONSOLE, but as usual CUI:s need it * while GUI:s don't */ - if (!CreateProcess(NULL, cmdLine, NULL, NULL, - FALSE, - DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS|CREATE_NEW_CONSOLE, + flags = DEBUG_PROCESS | CREATE_NEW_CONSOLE; + if (!DBG_IVAR(AlsoDebugProcChild)) flags |= DEBUG_ONLY_THIS_PROCESS; + + if (!CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, flags, NULL, NULL, &startup, &info)) { dbg_printf("Couldn't start process '%s'\n", cmdLine); diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 6b60386..f3e9c78 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -242,6 +242,16 @@ const struct dbg_internal_var* dbg_get_i return NULL; }
+unsigned dbg_num_processes(void) +{ + struct dbg_process* p; + unsigned num = 0; + + for (p = dbg_process_list; p; p = p->next) + num++; + return num; +} + struct dbg_process* dbg_get_process(DWORD pid) { struct dbg_process* p;