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

winedbg: Use standard Wine lists for threads.

parent d9e42e87
...@@ -171,6 +171,7 @@ typedef struct tagTHREADNAME_INFO ...@@ -171,6 +171,7 @@ typedef struct tagTHREADNAME_INFO
struct dbg_thread struct dbg_thread
{ {
struct list entry;
struct dbg_process* process; struct dbg_process* process;
HANDLE handle; HANDLE handle;
DWORD tid; DWORD tid;
...@@ -181,8 +182,6 @@ struct dbg_thread ...@@ -181,8 +182,6 @@ struct dbg_thread
int stopped_xpoint; /* xpoint on which the thread has stopped (-1 if none) */ int stopped_xpoint; /* xpoint on which the thread has stopped (-1 if none) */
struct dbg_breakpoint step_over_bp; struct dbg_breakpoint step_over_bp;
char name[9]; char name[9];
struct dbg_thread* next;
struct dbg_thread* prev;
BOOL in_exception; /* TRUE if thread stopped with an exception */ BOOL in_exception; /* TRUE if thread stopped with an exception */
EXCEPTION_RECORD excpt_record; /* only valid when in_exception is TRUE */ EXCEPTION_RECORD excpt_record; /* only valid when in_exception is TRUE */
struct struct
...@@ -224,7 +223,7 @@ struct dbg_process ...@@ -224,7 +223,7 @@ struct dbg_process
const struct be_process_io* process_io; const struct be_process_io* process_io;
void* pio_data; void* pio_data;
const WCHAR* imageName; const WCHAR* imageName;
struct dbg_thread* threads; struct list threads;
unsigned continue_on_first_exception : 1, unsigned continue_on_first_exception : 1,
active_debuggee : 1; active_debuggee : 1;
struct dbg_breakpoint bp[MAX_BREAKPOINTS]; struct dbg_breakpoint bp[MAX_BREAKPOINTS];
......
...@@ -1105,7 +1105,7 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx) ...@@ -1105,7 +1105,7 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
/* Now, I have this default action thing that needs to be applied to all non counted threads */ /* Now, I have this default action thing that needs to be applied to all non counted threads */
/* go through all the threads and stick their ids in the to be done list. */ /* go through all the threads and stick their ids in the to be done list. */
for (thd = gdbctx->process->threads; thd; thd = thd->next) LIST_FOR_EACH_ENTRY(thd, &gdbctx->process->threads, struct dbg_thread, entry)
{ {
threadIDs[threadCount++] = thd->tid; threadIDs[threadCount++] = thd->tid;
/* check to see if we have more threads than I counted on, and tell the user what to do /* check to see if we have more threads than I counted on, and tell the user what to do
...@@ -1725,10 +1725,10 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) ...@@ -1725,10 +1725,10 @@ static enum packet_return packet_query(struct gdb_context* gdbctx)
packet_reply_open(gdbctx); packet_reply_open(gdbctx);
packet_reply_add(gdbctx, "m", 1); packet_reply_add(gdbctx, "m", 1);
for (thd = gdbctx->process->threads; thd; thd = thd->next) LIST_FOR_EACH_ENTRY(thd, &gdbctx->process->threads, struct dbg_thread, entry)
{ {
packet_reply_val(gdbctx, thd->tid, 4); packet_reply_val(gdbctx, thd->tid, 4);
if (thd->next != NULL) if (list_next(&gdbctx->process->threads, &thd->entry) != NULL)
packet_reply_add(gdbctx, ",", 1); packet_reply_add(gdbctx, ",", 1);
} }
packet_reply_close(gdbctx); packet_reply_close(gdbctx);
...@@ -1764,8 +1764,8 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) ...@@ -1764,8 +1764,8 @@ static enum packet_return packet_query(struct gdb_context* gdbctx)
struct dbg_thread* thd; struct dbg_thread* thd;
/* FIXME: doc says 16 bit val ??? */ /* FIXME: doc says 16 bit val ??? */
/* grab first created thread, aka last in list */ /* grab first created thread, aka last in list */
assert(gdbctx->process && gdbctx->process->threads); assert(gdbctx->process && !list_empty(&gdbctx->process->threads));
for (thd = gdbctx->process->threads; thd->next; thd = thd->next); thd = LIST_ENTRY(list_tail(&gdbctx->process->threads), struct dbg_thread, entry);
packet_reply_open(gdbctx); packet_reply_open(gdbctx);
packet_reply_add(gdbctx, "QC", 2); packet_reply_add(gdbctx, "QC", 2);
packet_reply_val(gdbctx, thd->tid, 4); packet_reply_val(gdbctx, thd->tid, 4);
......
...@@ -46,8 +46,7 @@ static void dbg_init_current_thread(void* start) ...@@ -46,8 +46,7 @@ static void dbg_init_current_thread(void* start)
{ {
if (start) if (start)
{ {
if (dbg_curr_process->threads && if (list_count(&dbg_curr_process->threads) == 1 /* first thread ? */ &&
!dbg_curr_process->threads->next && /* first thread ? */
DBG_IVAR(BreakAllThreadsStartup)) DBG_IVAR(BreakAllThreadsStartup))
{ {
ADDRESS64 addr; ADDRESS64 addr;
......
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
* every function call to catch the errors * every function call to catch the errors
* + BTW check also whether the exception mechanism is the best way to return * + BTW check also whether the exception mechanism is the best way to return
* errors (or find a proper fix for MinGW port) * errors (or find a proper fix for MinGW port)
* + use Wine standard list mechanism for all list handling
*/ */
WINE_DEFAULT_DEBUG_CHANNEL(winedbg); WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
...@@ -305,7 +304,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, ...@@ -305,7 +304,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
p->process_io = pio; p->process_io = pio;
p->pio_data = NULL; p->pio_data = NULL;
p->imageName = NULL; p->imageName = NULL;
p->threads = NULL; list_init(&p->threads);
p->continue_on_first_exception = FALSE; p->continue_on_first_exception = FALSE;
p->active_debuggee = FALSE; p->active_debuggee = FALSE;
p->next_bp = 1; /* breakpoint 0 is reserved for step-over */ p->next_bp = 1; /* breakpoint 0 is reserved for step-over */
...@@ -334,9 +333,12 @@ void dbg_set_process_name(struct dbg_process* p, const WCHAR* imageName) ...@@ -334,9 +333,12 @@ void dbg_set_process_name(struct dbg_process* p, const WCHAR* imageName)
void dbg_del_process(struct dbg_process* p) void dbg_del_process(struct dbg_process* p)
{ {
struct dbg_thread* t;
struct dbg_thread* t2;
int i; int i;
while (p->threads) dbg_del_thread(p->threads); LIST_FOR_EACH_ENTRY_SAFE(t, t2, &p->threads, struct dbg_thread, entry)
dbg_del_thread(t);
for (i = 0; i < p->num_delayed_bp; i++) for (i = 0; i < p->num_delayed_bp; i++)
if (p->delayed_bp[i].is_symbol) if (p->delayed_bp[i].is_symbol)
...@@ -447,9 +449,9 @@ struct dbg_thread* dbg_get_thread(struct dbg_process* p, DWORD tid) ...@@ -447,9 +449,9 @@ struct dbg_thread* dbg_get_thread(struct dbg_process* p, DWORD tid)
struct dbg_thread* t; struct dbg_thread* t;
if (!p) return NULL; if (!p) return NULL;
for (t = p->threads; t; t = t->next) LIST_FOR_EACH_ENTRY(t, &p->threads, struct dbg_thread, entry)
if (t->tid == tid) break; if (t->tid == tid) return t;
return t; return NULL;
} }
struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid, struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid,
...@@ -477,10 +479,7 @@ struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid, ...@@ -477,10 +479,7 @@ struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid,
snprintf(t->name, sizeof(t->name), "%04x", tid); snprintf(t->name, sizeof(t->name), "%04x", tid);
t->next = p->threads; list_add_head(&p->threads, &t->entry);
t->prev = NULL;
if (p->threads) p->threads->prev = t;
p->threads = t;
return t; return t;
} }
...@@ -488,9 +487,7 @@ struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid, ...@@ -488,9 +487,7 @@ struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid,
void dbg_del_thread(struct dbg_thread* t) void dbg_del_thread(struct dbg_thread* t)
{ {
HeapFree(GetProcessHeap(), 0, t->frames); HeapFree(GetProcessHeap(), 0, t->frames);
if (t->prev) t->prev->next = t->next; list_remove(&t->entry);
if (t->next) t->next->prev = t->prev;
if (t == t->process->threads) t->process->threads = t->next;
if (t == dbg_curr_thread) dbg_curr_thread = NULL; if (t == dbg_curr_thread) dbg_curr_thread = NULL;
HeapFree(GetProcessHeap(), 0, t); HeapFree(GetProcessHeap(), 0, t);
} }
......
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