Branch: Tag:

2001-02-27

2001-02-27 01:18:20 by Martin Stjernholm <mast@lysator.liu.se>

Added two functions for gdb_backtrace and gdb_backtraces.
gdb_thread_state_for_id is also quite useful by itself.

Rev: src/threads.c:1.155

1:   #include "global.h" - RCSID("$Id: threads.c,v 1.154 2001/02/06 17:57:53 grubba Exp $"); + RCSID("$Id: threads.c,v 1.155 2001/02/27 01:18:20 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;
513:    as you have the interpreter lock, unless tid == th_self() */   }    + struct thread_state *gdb_thread_state_for_id(THREAD_T tid) + /* Should only be used from a debugger session. */ + { +  unsigned INT32 h = thread_table_hash(&tid); +  struct thread_state *s; +  for (s = thread_table_chains[h]; s != NULL; s = s->hashlink) +  if(th_equal(s->id, tid)) +  break; +  return s; + } +  + INT32 gdb_next_thread_state(INT32 prev, struct thread_state **ts) + /* Used by gdb_backtraces. */ + { +  if (!*ts || !(*ts)->hashlink) { +  if (!*ts) prev = -1; +  while (++prev < THREAD_TABLE_SIZE) +  if ((*ts = thread_table_chains[prev])) +  return prev; +  *ts = NULL; +  return 0; +  } +  *ts = (*ts)->hashlink; +  return prev; + } +    PMOD_EXPORT struct object *thread_for_id(THREAD_T tid)   {    struct thread_state *s = thread_state_for_id(tid);