Beispiel #1
0
int new_thread_callback(const td_thrhandle_t *th_p, void *data) {
  td_thrinfo_t ti;
  td_err_e err;

  err = td_thr_get_info(th_p, &ti);
  if (err != TD_OK) {
#ifdef DEBUG
    puts("cannot get thread info");
#endif
    return err;
  }

#ifdef DEBUG
  printf("new thread: %d (LWP %d)\n", ti.ti_tid, ti.ti_lid);
#endif

  if (ti.ti_lid != debuggee.pid) {
    if (!ptrace_attach(ti.ti_lid)) {
      printf("can't attach to thread %d (LWP %d)\n", ti.ti_tid, ti.ti_lid);
      return TD_ERR;
    }
  }

  add_thread(ti.ti_tid, ti.ti_lid);

  return TD_OK;
}
Beispiel #2
0
//--------------------------------------------------------------------------
static int display_thread_cb(const td_thrhandle_t *th_p, void *data)
{
  td_thrinfo_t ti;
  td_err_e err = td_thr_get_info(th_p, &ti);
  DIE_IF_FAILED("td_thr_get_info", err);

  if ( ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE )
    return 0;

  display_thrinfo(ti);
  return 0;
}
Beispiel #3
0
gboolean
mono_debugger_thread_db_get_thread_info (const td_thrhandle_t *th, guint64 *tid, guint64 *tls,
					 guint64 *lwp)
{
	td_thrinfo_t ti;
	td_err_e e;

	e = td_thr_get_info (th, &ti);
	if (e)
		return FALSE;

	*tid = (guint64) (gsize) ti.ti_tid;
	*tls = (guint64) (gsize) ti.ti_tls;
	*lwp = ti.ti_lid;

	return TRUE;
}
Beispiel #4
0
//--------------------------------------------------------------------------
void linux_debmod_t::display_thrinfo(thid_t tid)
{
  msg("tid=%d\n", tid);
  td_thrhandle_t th;
  td_err_e err = td_ta_map_lwp2thr(ta, tid, &th);
  COMPLAIN_IF_FAILED("td_ta_map_lwp2thr2", err);

  if ( err == 0 )
  {
    td_thrinfo_t thi;
    memset(&thi, 0 ,sizeof(thi));
    err = td_thr_get_info(&th, &thi);
    COMPLAIN_IF_FAILED("td_thr_get_info2", err);

    if ( err == 0 )
      ::display_thrinfo(thi);
  }
}
static int
find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
{
  td_thrinfo_t ti;
  td_err_e err;

  err = td_thr_get_info (th_p, &ti);
  if (err != TD_OK)
    error ("Cannot get thread info: %s", thread_db_err_str (err));

  /* Check for zombies.  */
  if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE)
    return 0;

  maybe_attach_thread (th_p, &ti);

  return 0;
}
// callback function for libthread_db
static int thread_db_callback(const td_thrhandle_t *th_p, void *data) {
  struct thread_db_client_data* ptr = (struct thread_db_client_data*) data;
  td_thrinfo_t ti;
  td_err_e err;

  memset(&ti, 0, sizeof(ti));
  err = td_thr_get_info(th_p, &ti);
  if (err != TD_OK) {
    print_debug("libthread_db : td_thr_get_info failed, can't get thread info\n");
    return err;
  }

  print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);

  if (ptr->callback(ptr->ph, (pthread_t)ti.ti_tid, ti.ti_lid) != true)
    return TD_ERR;

  return TD_OK;
}
Beispiel #7
0
static int update_threads_cb(const td_thrhandle_t *th_p, void *data)
{
  thrinfovec_t &newlist = *(thrinfovec_t *)data;

  thrinfo_t ti;
  td_err_e err = td_thr_get_info(th_p, &ti);
  DIE_IF_FAILED("td_thr_get_info", err);

  if ( ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE )
    return 0;

  if ( ti.ti_tid != 0 )
  {
    td_thr_events_t events;
    td_event_emptyset(&events);
    td_event_addset(&events, TD_CREATE);
    td_event_addset(&events, TD_DEATH);
  //  td_event_addset(&events, TD_CATCHSIG);
    err = td_thr_set_event(th_p, &events);
    DIE_IF_FAILED("td_thr_set_event", err);

    err = td_thr_event_enable(th_p, 1);
    DIE_IF_FAILED("td_thr_event_enable", err);

    sigset_t set;
    sigemptyset(&set);
    sigaddset(&set, SIGSTOP);
    td_thr_setsigpending(th_p, 1, &set);
  }

  ti.th_p = th_p;
#ifdef LDEB
  msg("update_threads_cb: got thread %d\n", ti.ti_lid);
  //td_thr_get_info(th_p, &ti);
  //display_thrinfo(ti);
#endif

  newlist.push_back(ti);
  return 0;
}
Beispiel #8
0
//--------------------------------------------------------------------------
// check if there are pending messages from thread DB
void linux_debmod_t::tdb_handle_messages(int tid)
{
  if ( ta == NULL )
    return;

  td_event_msg_t tmsg;
  thrinfo_t ti;
  td_err_e err;
  int loop = 1;
  td_thrhandle_t th;
  do
  {
    err = td_ta_event_getmsg(ta, &tmsg);
    if ( err != TD_OK )
    {
      if ( err == TD_NOMSG )
        return;
      msg("Cannot get thread event message: %s\n", tdb_strerr(err));
      return;
    }

    err = td_thr_get_info(tmsg.th_p, &ti);
    ti.th_p = tmsg.th_p;
    COMPLAIN_IF_FAILED("td_thr_get_info", err);
    switch ( tmsg.event )
    {
      case TD_CREATE:
        new_thread(&ti);
        break;

      case TD_DEATH:
        dead_thread(ti.ti_lid);
        break;

      default:
        msg("Spurious thread event %d.", tmsg.event);
    }
  }
  while (loop);
}