struct dbg_thread
{
+ struct list entry;
struct dbg_process* process;
HANDLE handle;
DWORD tid;
int stopped_xpoint; /* xpoint on which the thread has stopped (-1 if none) */
struct dbg_breakpoint step_over_bp;
char name[9];
- struct dbg_thread* next;
- struct dbg_thread* prev;
BOOL in_exception; /* TRUE if thread stopped with an exception */
EXCEPTION_RECORD excpt_record; /* only valid when in_exception is TRUE */
struct
const struct be_process_io* process_io;
void* pio_data;
const WCHAR* imageName;
- struct dbg_thread* threads;
+ struct list threads;
unsigned continue_on_first_exception : 1,
active_debuggee : 1;
struct dbg_breakpoint bp[MAX_BREAKPOINTS];
/* 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. */
- 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;
/* check to see if we have more threads than I counted on, and tell the user what to do
packet_reply_open(gdbctx);
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);
- if (thd->next != NULL)
+ if (list_next(&gdbctx->process->threads, &thd->entry) != NULL)
packet_reply_add(gdbctx, ",", 1);
}
packet_reply_close(gdbctx);
struct dbg_thread* thd;
/* FIXME: doc says 16 bit val ??? */
/* grab first created thread, aka last in list */
- assert(gdbctx->process && gdbctx->process->threads);
- for (thd = gdbctx->process->threads; thd->next; thd = thd->next);
+ assert(gdbctx->process && !list_empty(&gdbctx->process->threads));
+ thd = LIST_ENTRY(list_tail(&gdbctx->process->threads), struct dbg_thread, entry);
packet_reply_open(gdbctx);
packet_reply_add(gdbctx, "QC", 2);
packet_reply_val(gdbctx, thd->tid, 4);
{
if (start)
{
- if (dbg_curr_process->threads &&
- !dbg_curr_process->threads->next && /* first thread ? */
+ if (list_count(&dbg_curr_process->threads) == 1 /* first thread ? */ &&
DBG_IVAR(BreakAllThreadsStartup))
{
ADDRESS64 addr;
* every function call to catch the errors
* + BTW check also whether the exception mechanism is the best way to return
* errors (or find a proper fix for MinGW port)
- * + use Wine standard list mechanism for all list handling
*/
WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
p->process_io = pio;
p->pio_data = NULL;
p->imageName = NULL;
- p->threads = NULL;
+ list_init(&p->threads);
p->continue_on_first_exception = FALSE;
p->active_debuggee = FALSE;
p->next_bp = 1; /* breakpoint 0 is reserved for step-over */
void dbg_del_process(struct dbg_process* p)
{
+ struct dbg_thread* t;
+ struct dbg_thread* t2;
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++)
if (p->delayed_bp[i].is_symbol)
struct dbg_thread* t;
if (!p) return NULL;
- for (t = p->threads; t; t = t->next)
- if (t->tid == tid) break;
- return t;
+ LIST_FOR_EACH_ENTRY(t, &p->threads, struct dbg_thread, entry)
+ if (t->tid == tid) return t;
+ return NULL;
}
struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid,
snprintf(t->name, sizeof(t->name), "%04x", tid);
- t->next = p->threads;
- t->prev = NULL;
- if (p->threads) p->threads->prev = t;
- p->threads = t;
+ list_add_head(&p->threads, &t->entry);
return t;
}
void dbg_del_thread(struct dbg_thread* t)
{
HeapFree(GetProcessHeap(), 0, t->frames);
- if (t->prev) t->prev->next = t->next;
- if (t->next) t->next->prev = t->prev;
- if (t == t->process->threads) t->process->threads = t->next;
+ list_remove(&t->entry);
if (t == dbg_curr_thread) dbg_curr_thread = NULL;
HeapFree(GetProcessHeap(), 0, t);
}