Module: wine Branch: refs/heads/master Commit: 5ca519705d889e2e8ccd70619ecfe52cb1b4f05d URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=5ca519705d889e2e8ccd7061...
Author: Eric Pouech eric.pouech@wanadoo.fr Date: Mon Feb 27 21:50:43 2006 +0100
winedbg: Added a close_process method to process_io.
- added a close_process method to process_io - made use of it to get rid of dbg_detach
---
programs/winedbg/dbg.y | 2 + programs/winedbg/debugger.h | 2 + programs/winedbg/stack.c | 4 +- programs/winedbg/tgt_active.c | 67 +++++++++++++++++++++-------------------- programs/winedbg/winedbg.c | 3 ++ 5 files changed, 41 insertions(+), 37 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index abb4704..66145ee 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -139,7 +139,7 @@ command: | tSYMBOLFILE pathname expr_rvalue { symbol_read_symtable($2, $3); } | tWHATIS expr_lvalue { dbg_printf("type = "); types_print_type(&$2.type, FALSE); dbg_printf("\n"); } | tATTACH tNUM { dbg_attach_debuggee($2, FALSE, TRUE); } - | tDETACH { dbg_detach_debuggee(); } + | tDETACH { dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); } | tMINIDUMP pathname { minidump_write($2, (dbg_curr_thread && dbg_curr_thread->in_exception) ? &dbg_curr_thread->excpt_record : NULL);} | tECHO tSTRING { dbg_printf("%s\n", $2); } | run_command diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index ecfe2f4..73e53a2 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -216,6 +216,7 @@ struct dbg_process /* describes the way the debugger interacts with a given process */ struct be_process_io { + BOOL (*close_process)(struct dbg_process*, BOOL); BOOL (WINAPI *read)(HANDLE, const void*, void*, DWORD, DWORD*); BOOL (WINAPI *write)(HANDLE, void*, const void*, DWORD, DWORD*); }; @@ -403,7 +404,6 @@ extern int dbg_printf(const char #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_detach_debuggee(void); extern BOOL dbg_interrupt_debuggee(void); extern struct dbg_process* dbg_add_process(DWORD pid, HANDLE h); extern void dbg_set_process_name(struct dbg_process* p, const char* name); diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index 675427b..bc996c0 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -338,7 +338,7 @@ static void backtrace_all(void) { if (entry.th32OwnerProcessID == GetCurrentProcessId()) continue; if (dbg_curr_process && dbg_curr_pid != entry.th32OwnerProcessID) - dbg_detach_debuggee(); + dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE);
if (entry.th32OwnerProcessID != dbg_curr_pid) { @@ -358,7 +358,7 @@ static void backtrace_all(void) while (Thread32Next(snapshot, &entry));
if (dbg_curr_process) - dbg_detach_debuggee(); + dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); } CloseHandle(snapshot); } diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 406c551..e778c3d 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -34,12 +34,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
static char* dbg_last_cmd_line;
-struct be_process_io be_process_active_io = -{ - ReadProcessMemory, - WriteProcessMemory, -}; - static void dbg_init_current_process(void) { } @@ -100,23 +94,6 @@ BOOL dbg_attach_debuggee(DWORD pid, BOOL return TRUE; }
-BOOL dbg_detach_debuggee(void) -{ - /* remove all set breakpoints in debuggee code */ - break_set_xpoints(FALSE); - /* needed for single stepping (ugly). - * should this be handled inside the server ??? - */ - be_cpu->single_step(&dbg_context, FALSE); - SetThreadContext(dbg_curr_thread->handle, &dbg_context); - if (dbg_curr_thread->in_exception) - ContinueDebugEvent(dbg_curr_pid, dbg_curr_tid, DBG_CONTINUE); - if (!DebugActiveProcessStop(dbg_curr_pid)) return FALSE; - dbg_del_process(dbg_curr_process); - - return TRUE; -} - static unsigned dbg_fetch_context(void) { dbg_context.ContextFlags = CONTEXT_CONTROL @@ -413,6 +390,8 @@ static DWORD dbg_handle_exception(const return DBG_CONTINUE; }
+static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill); + static unsigned dbg_handle_debug_event(DEBUG_EVENT* de) { char buffer[256]; @@ -507,15 +486,7 @@ static unsigned dbg_handle_debug_event(D WINE_ERR("Unknown process\n"); break; } - if (!SymCleanup(dbg_curr_process->handle)) - dbg_printf("Couldn't initiate DbgHelp\n"); - /* just in case */ - break_set_xpoints(FALSE); - /* kill last thread */ - dbg_del_thread(dbg_curr_process->threads); - dbg_del_process(dbg_curr_process); - - dbg_printf("Process of pid=0x%08lx has terminated\n", dbg_curr_pid); + tgt_process_active_close_process(dbg_curr_process, FALSE); break;
case CREATE_THREAD_DEBUG_EVENT: @@ -687,7 +658,6 @@ void dbg_wait_next_exception(DWORD cont, } dbg_interactiveP = TRUE; parser_handle(hFile); - dbg_printf("WineDbg terminated on pid 0x%lx\n", dbg_curr_pid);
return 0; } @@ -928,3 +898,34 @@ enum dbg_start dbg_active_auto(int argc, dbg_main_loop(hFile); return start_ok; } + +static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill) +{ + if (pcs == dbg_curr_process) + { + /* remove all set breakpoints in debuggee code */ + break_set_xpoints(FALSE); + /* needed for single stepping (ugly). + * should this be handled inside the server ??? + */ + be_cpu->single_step(&dbg_context, FALSE); + if (dbg_curr_thread->in_exception) + { + SetThreadContext(dbg_curr_thread->handle, &dbg_context); + ContinueDebugEvent(dbg_curr_pid, dbg_curr_tid, DBG_CONTINUE); + } + if (!kill && !DebugActiveProcessStop(dbg_curr_pid)) return FALSE; + } + SymCleanup(pcs->handle); + dbg_printf("Process of pid=0x%08lx has terminated\n", pcs->pid); + dbg_del_process(pcs); + + return TRUE; +} + +struct be_process_io be_process_active_io = +{ + tgt_process_active_close_process, + ReadProcessMemory, + WriteProcessMemory, +}; diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 7cd7695..cd40734 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -551,6 +551,9 @@ int main(int argc, char** argv) }
retv = dbg_main_loop(hFile); + while (dbg_process_list) + dbg_process_list->process_io->close_process(dbg_process_list, TRUE); + dbg_save_internal_vars();
return retv;