Backtracing the current thread

QNX SDP8.0TechnotesDeveloperUser

To backtrace the currently running process and thread, you can do one of the following:

  • Use the BT_PROCESS accessor flag, as described in Backtracing a thread in another process, but specify the current pid and tid.
  • Use the BT_THREAD accessor flag and select the currently running thread.
  • Use the BT_SELF accessor flag. This is the best way to insure that the currently active thread is backtraced:
    if (bt_init_accessor(&acc, BT_SELF) == -1)
    {
      fprintf( stderr, "%s:%i %s (%i)%s\n", __FUNCTION__, __LINE__,
               "bt_init_accessor", errno, strerror(errno));
      return -1;
    }
      

You can also use a preinitialized accessor called bt_acc_self.

Page updated: