Commit f7908160 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedbg: Fixed bt all so that current process/thread isn't lost.

parent b32cfb18
...@@ -351,6 +351,9 @@ static void backtrace_tid(struct dbg_process* pcs, DWORD tid) ...@@ -351,6 +351,9 @@ static void backtrace_tid(struct dbg_process* pcs, DWORD tid)
static void backtrace_all(void) static void backtrace_all(void)
{ {
struct dbg_process* process = dbg_curr_process; struct dbg_process* process = dbg_curr_process;
struct dbg_thread* thread = dbg_curr_thread;
CONTEXT ctx = dbg_context;
DWORD cpid = dbg_curr_pid;
THREADENTRY32 entry; THREADENTRY32 entry;
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
...@@ -366,10 +369,16 @@ static void backtrace_all(void) ...@@ -366,10 +369,16 @@ static void backtrace_all(void)
do do
{ {
if (entry.th32OwnerProcessID == GetCurrentProcessId()) continue; if (entry.th32OwnerProcessID == GetCurrentProcessId()) continue;
if (dbg_curr_process && dbg_curr_pid != entry.th32OwnerProcessID) if (dbg_curr_process && dbg_curr_pid != entry.th32OwnerProcessID &&
cpid != dbg_curr_pid)
dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE);
if (entry.th32OwnerProcessID != dbg_curr_pid) if (entry.th32OwnerProcessID == cpid)
{
dbg_curr_process = process;
dbg_curr_pid = cpid;
}
else if (entry.th32OwnerProcessID != dbg_curr_pid)
{ {
if (!dbg_attach_debuggee(entry.th32OwnerProcessID, FALSE)) if (!dbg_attach_debuggee(entry.th32OwnerProcessID, FALSE))
{ {
...@@ -387,12 +396,15 @@ static void backtrace_all(void) ...@@ -387,12 +396,15 @@ static void backtrace_all(void)
} }
while (Thread32Next(snapshot, &entry)); while (Thread32Next(snapshot, &entry));
if (dbg_curr_process) if (dbg_curr_process && cpid != dbg_curr_pid)
dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE);
} }
CloseHandle(snapshot); CloseHandle(snapshot);
dbg_curr_process = process; dbg_curr_process = process;
dbg_curr_pid = process ? process->pid : 0; dbg_curr_pid = cpid;
dbg_curr_thread = thread;
dbg_curr_tid = thread ? thread->tid : 0;
dbg_context = ctx;
} }
void stack_backtrace(DWORD tid) void stack_backtrace(DWORD tid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment