Commit 38480c59 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winedbg: Remove uses of dbg_curr_thread from gdbproxy.

parent 983d02c0
...@@ -268,14 +268,14 @@ static struct dbg_thread* dbg_thread_from_tid(struct gdb_context* gdbctx, int ti ...@@ -268,14 +268,14 @@ static struct dbg_thread* dbg_thread_from_tid(struct gdb_context* gdbctx, int ti
if (!process) return NULL; if (!process) return NULL;
if (tid == 0) return dbg_curr_thread; if (tid == 0) tid = gdbctx->de.dwThreadId;
LIST_FOR_EACH_ENTRY(thread, &process->threads, struct dbg_thread, entry) LIST_FOR_EACH_ENTRY(thread, &process->threads, struct dbg_thread, entry)
{ {
if (tid > 0 && thread->tid != tid) continue; if (tid > 0 && thread->tid != tid) continue;
return thread; return thread;
} }
return dbg_curr_thread; return NULL;
} }
static void dbg_thread_set_single_step(struct dbg_thread *thread, BOOL enable) static void dbg_thread_set_single_step(struct dbg_thread *thread, BOOL enable)
...@@ -357,7 +357,7 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e ...@@ -357,7 +357,7 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
SIZE_T read; SIZE_T read;
if (threadname->dwThreadID == -1) if (threadname->dwThreadID == -1)
thread = dbg_curr_thread; thread = dbg_get_thread(gdbctx->process, gdbctx->de.dwThreadId);
else else
thread = dbg_get_thread(gdbctx->process, threadname->dwThreadID); thread = dbg_get_thread(gdbctx->process, threadname->dwThreadID);
if (thread) if (thread)
...@@ -394,7 +394,6 @@ static void handle_debug_event(struct gdb_context* gdbctx) ...@@ -394,7 +394,6 @@ static void handle_debug_event(struct gdb_context* gdbctx)
WCHAR buffer[256]; WCHAR buffer[256];
} u; } u;
dbg_curr_thread = dbg_get_thread(gdbctx->process, de->dwThreadId);
gdbctx->exec_tid = de->dwThreadId; gdbctx->exec_tid = de->dwThreadId;
gdbctx->other_tid = de->dwThreadId; gdbctx->other_tid = de->dwThreadId;
gdbctx->de_reply = DBG_REPLY_LATER; gdbctx->de_reply = DBG_REPLY_LATER;
...@@ -426,14 +425,12 @@ static void handle_debug_event(struct gdb_context* gdbctx) ...@@ -426,14 +425,12 @@ static void handle_debug_event(struct gdb_context* gdbctx)
fprintf(stderr, "%04x:%04x: create thread I @%p\n", de->dwProcessId, fprintf(stderr, "%04x:%04x: create thread I @%p\n", de->dwProcessId,
de->dwThreadId, de->u.CreateProcessInfo.lpStartAddress); de->dwThreadId, de->u.CreateProcessInfo.lpStartAddress);
assert(dbg_curr_thread == NULL); /* shouldn't be there */
dbg_add_thread(gdbctx->process, de->dwThreadId, dbg_add_thread(gdbctx->process, de->dwThreadId,
de->u.CreateProcessInfo.hThread, de->u.CreateProcessInfo.hThread,
de->u.CreateProcessInfo.lpThreadLocalBase); de->u.CreateProcessInfo.lpThreadLocalBase);
break; break;
case LOAD_DLL_DEBUG_EVENT: case LOAD_DLL_DEBUG_EVENT:
assert(dbg_curr_thread);
memory_get_string_indirect(gdbctx->process, memory_get_string_indirect(gdbctx->process,
de->u.LoadDll.lpImageName, de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode, de->u.LoadDll.fUnicode,
...@@ -456,7 +453,6 @@ static void handle_debug_event(struct gdb_context* gdbctx) ...@@ -456,7 +453,6 @@ static void handle_debug_event(struct gdb_context* gdbctx)
break; break;
case EXCEPTION_DEBUG_EVENT: case EXCEPTION_DEBUG_EVENT:
assert(dbg_curr_thread);
TRACE("%08x:%08x: exception code=0x%08x\n", de->dwProcessId, TRACE("%08x:%08x: exception code=0x%08x\n", de->dwProcessId,
de->dwThreadId, de->u.Exception.ExceptionRecord.ExceptionCode); de->dwThreadId, de->u.Exception.ExceptionRecord.ExceptionCode);
...@@ -476,9 +472,8 @@ static void handle_debug_event(struct gdb_context* gdbctx) ...@@ -476,9 +472,8 @@ static void handle_debug_event(struct gdb_context* gdbctx)
case EXIT_THREAD_DEBUG_EVENT: case EXIT_THREAD_DEBUG_EVENT:
fprintf(stderr, "%08x:%08x: exit thread (%u)\n", fprintf(stderr, "%08x:%08x: exit thread (%u)\n",
de->dwProcessId, de->dwThreadId, de->u.ExitThread.dwExitCode); de->dwProcessId, de->dwThreadId, de->u.ExitThread.dwExitCode);
if ((thread = dbg_get_thread(gdbctx->process, de->dwThreadId)))
assert(dbg_curr_thread); dbg_del_thread(thread);
dbg_del_thread(dbg_curr_thread);
break; break;
case EXIT_PROCESS_DEBUG_EVENT: case EXIT_PROCESS_DEBUG_EVENT:
...@@ -493,7 +488,6 @@ static void handle_debug_event(struct gdb_context* gdbctx) ...@@ -493,7 +488,6 @@ static void handle_debug_event(struct gdb_context* gdbctx)
break; break;
case OUTPUT_DEBUG_STRING_EVENT: case OUTPUT_DEBUG_STRING_EVENT:
assert(dbg_curr_thread);
memory_get_string(gdbctx->process, memory_get_string(gdbctx->process,
de->u.DebugString.lpDebugStringData, TRUE, de->u.DebugString.lpDebugStringData, TRUE,
de->u.DebugString.fUnicode, u.bufferA, sizeof(u.bufferA)); de->u.DebugString.fUnicode, u.bufferA, sizeof(u.bufferA));
...@@ -525,7 +519,7 @@ static void handle_step_or_continue(struct gdb_context* gdbctx, int tid, BOOL st ...@@ -525,7 +519,7 @@ static void handle_step_or_continue(struct gdb_context* gdbctx, int tid, BOOL st
struct dbg_process *process = gdbctx->process; struct dbg_process *process = gdbctx->process;
struct dbg_thread *thread; struct dbg_thread *thread;
if (tid == 0) tid = dbg_curr_thread->tid; if (tid == 0) tid = gdbctx->de.dwThreadId;
LIST_FOR_EACH_ENTRY(thread, &process->threads, struct dbg_thread, entry) LIST_FOR_EACH_ENTRY(thread, &process->threads, struct dbg_thread, entry)
{ {
if (tid != -1 && thread->tid != tid) continue; if (tid != -1 && thread->tid != tid) continue;
...@@ -596,7 +590,6 @@ static void wait_for_debuggee(struct gdb_context* gdbctx) ...@@ -596,7 +590,6 @@ static void wait_for_debuggee(struct gdb_context* gdbctx)
assert(!gdbctx->process || assert(!gdbctx->process ||
gdbctx->process->pid == 0 || gdbctx->process->pid == 0 ||
gdbctx->de.dwProcessId == gdbctx->process->pid); gdbctx->de.dwProcessId == gdbctx->process->pid);
assert(!dbg_curr_thread || gdbctx->de.dwThreadId == dbg_curr_thread->tid);
if (gdbctx->in_trap) break; if (gdbctx->in_trap) break;
ContinueDebugEvent(gdbctx->de.dwProcessId, gdbctx->de.dwThreadId, DBG_CONTINUE); ContinueDebugEvent(gdbctx->de.dwProcessId, gdbctx->de.dwThreadId, DBG_CONTINUE);
} }
...@@ -828,6 +821,7 @@ static inline void packet_reply_register_hex_to(struct gdb_context* gdbctx, dbg_ ...@@ -828,6 +821,7 @@ static inline void packet_reply_register_hex_to(struct gdb_context* gdbctx, dbg_
static enum packet_return packet_reply_status(struct gdb_context* gdbctx) static enum packet_return packet_reply_status(struct gdb_context* gdbctx)
{ {
struct dbg_process *process = gdbctx->process; struct dbg_process *process = gdbctx->process;
struct dbg_thread *thread;
struct backend_cpu *backend; struct backend_cpu *backend;
dbg_ctx_t ctx; dbg_ctx_t ctx;
size_t i; size_t i;
...@@ -838,7 +832,8 @@ static enum packet_return packet_reply_status(struct gdb_context* gdbctx) ...@@ -838,7 +832,8 @@ static enum packet_return packet_reply_status(struct gdb_context* gdbctx)
if (!(backend = process->be_cpu)) return packet_error; if (!(backend = process->be_cpu)) return packet_error;
if (!backend->get_context(dbg_curr_thread->handle, &ctx)) if (!(thread = dbg_get_thread(process, gdbctx->de.dwThreadId)) ||
!backend->get_context(thread->handle, &ctx))
return packet_error; return packet_error;
packet_reply_open(gdbctx); packet_reply_open(gdbctx);
...@@ -846,7 +841,7 @@ static enum packet_return packet_reply_status(struct gdb_context* gdbctx) ...@@ -846,7 +841,7 @@ static enum packet_return packet_reply_status(struct gdb_context* gdbctx)
sig = gdbctx->last_sig; sig = gdbctx->last_sig;
packet_reply_val(gdbctx, sig, 1); packet_reply_val(gdbctx, sig, 1);
packet_reply_add(gdbctx, "thread:"); packet_reply_add(gdbctx, "thread:");
packet_reply_val(gdbctx, dbg_curr_thread->tid, 4); packet_reply_val(gdbctx, gdbctx->de.dwThreadId, 4);
packet_reply_add(gdbctx, ";"); packet_reply_add(gdbctx, ";");
for (i = 0; i < backend->gdb_num_regs; i++) for (i = 0; i < backend->gdb_num_regs; i++)
......
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