From: Eric Pouech epouech@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57157
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/winedbg/dbg.y | 2 +- programs/winedbg/debug.l | 2 +- programs/winedbg/stack.c | 1 - programs/winedbg/tgt_active.c | 12 ++++++++++-- 4 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 6f4bb10fed8..a0d0ebb34f4 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -140,7 +140,7 @@ command: | tSYMBOLFILE pathname { symbol_read_symtable($2, 0); } | tSYMBOLFILE pathname expr_rvalue { symbol_read_symtable($2, $3); } | tWHATIS expr_lvalue { dbg_printf("type = "); types_print_type(&$2.type, FALSE, NULL); dbg_printf("\n"); } - | tATTACH tNUM { dbg_attach_debuggee($2); dbg_active_wait_for_first_exception(); } + | tATTACH tNUM { if (dbg_attach_debuggee($2)) dbg_active_wait_for_first_exception(); } | tATTACH pathname { minidump_reload($2); } | tDETACH { dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); } | tTHREAD tNUM { dbg_set_curr_thread($2); } diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index a05a27dfc79..f7931855233 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -230,7 +230,7 @@ STRING "(\[^\n]|[^\"\n])*" <INITIAL,NOPROCESS>maintenance|maint { BEGIN(MAINT_CMD); return tMAINTENANCE; } <INITIAL>minidump|mdmp { BEGIN(PATH_EXPECTED); return tMINIDUMP; } <INITIAL>echo { BEGIN(ASTRING_EXPECTED); return tECHO; } -<NOPROCESS>attach|attac|atta|att { BEGIN(NOCMD); return tATTACH; } +<INITIAL,NOPROCESS>attach|attac|atta|att { BEGIN(NOCMD); return tATTACH; } <INFO_CMD>share|shar|sha { return tSHARE; } <MAINT_CMD>module|modul|mod { BEGIN(ASTRING_EXPECTED); return tMODULE; } <INFO_CMD>locals|local|loca|loc { return tLOCAL; } diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index 4acb5666079..7860e73c088 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -408,7 +408,6 @@ static void backtrace_all(void) entry.th32OwnerProcessID); continue; } - dbg_curr_pid = dbg_curr_process->pid; dbg_active_wait_for_first_exception(); }
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 209d82374c6..a919f70a486 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -75,6 +75,11 @@ BOOL dbg_attach_debuggee(DWORD pid) dbg_printf("WineDbg can't debug its own process. Please use another process ID.\n"); return FALSE; } + if (dbg_curr_process) + { + dbg_printf("WineDbg can't debug several processes at once.\nEither 'detach' from current one, or use another instance of WineDbg\n"); + return FALSE; + } if (!(dbg_curr_process = dbg_add_process(&be_process_active_io, pid, 0))) return FALSE;
if (!DebugActiveProcess(pid)) @@ -87,7 +92,11 @@ BOOL dbg_attach_debuggee(DWORD pid) SetEnvironmentVariableA("DBGHELP_NOLIVE", NULL);
dbg_curr_process->active_debuggee = TRUE; - dbg_printf("WineDbg attached to pid %04lx\n", dbg_curr_pid); + dbg_printf("WineDbg attached to pid %04lx\n", pid); + dbg_curr_pid = pid; + dbg_curr_thread = NULL; + dbg_curr_tid = 0; + return TRUE; }
@@ -853,7 +862,6 @@ enum dbg_start dbg_active_attach(int argc, char* argv[]) } else return start_error_parse;
- dbg_curr_pid = pid; return start_ok; }