Backtracing another thread within the same process

Updated: April 19, 2023

Backtracing a different thread in the current process is similar to backtracing a thread in a different process (see above). The only difference is how you initialize the accessor structure. The flags passed to bt_init_accessor() define which process to backtrace. If you specify BT_THREAD, a different thread within the same process is set up for backtracing:

if (bt_init_accessor(&acc, BT_THREAD, tid) == -1)
  fprintf( stderr, "%s:%i %s (%i)%s\n", __FUNCTION__, __LINE__,
           "bt_init_accessor", errno, strerror(errno));
  return -1;