This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

unresolved symbols with libthread_db library


I'm trying to compile a simple program which uses the libthread_db library
(see code at the end). However I have some unresolved symbols. Does anyone
know what to include to resolve these symbols. Or should I implement
something myself? With this program I want to try debugging a multithreaded
program with use of gdbserver.

/*Specify libthread_db.so.1 on link line to access correct version.
 *   cc thisfile.c /lib/libthread_db.so.1
 */
#include <stdio.h>
#include <sys/types.h>
#include <thread_db.h>
#include <dlfcn.h>

static int thread_cb( const td_thrhandle_t *th_p, void *s );
struct ps_prochandle {
   pid_t pid;
};
struct ps_prochandle ph = {1};
td_thragent_t *ta_p;

/*
 *   libthread_db example.
 *      Initialize libthread_db
 *      Create a thread agent
 *      Call thread iterator
 */
int main()
{
   td_err_e td_return;
   /*
    *   td_init()
    */
   td_return = td_init();
   if ( td_return != TD_OK ) {
      printf("Initialization error on td_init() call\n");
      return 0;
   }
   /*
    *   td_ta_new()
    */
   td_return = td_ta_new(&ph, &ta_p);
   if ( td_return == TD_OK ) {
      /*
       * td_ta_thr_iter()
       */
      (void) td_ta_thr_iter(ta_p, thread_cb, "Import calls test",
         TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
         TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
   }

   return 0;
}

static int thread_cb( const td_thrhandle_t *th_p, void *s )
/*
 *  Description:
 *     Call back function for iterator
 *
 *  Input:
 *     *th_p - thread handle
 *     *s - data
 *
 *  Output:
 *     none
 *
 */
{
   int return_val = 0;
   td_err_e td_return;
   td_thrinfo_t to;
   td_return = td_thr_get_info(th_p, &(to));
   if ( td_return == TD_ERR ) {
      printf("Thread update failed\n");
      return_val = 1;
   }
   return return_val;
}


TIA,
Frank


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]