Thread information

Several of the devctl() commands use a procfs_status structure (which is the same as debug_thread_t), so let's look at this structure before going into the commands themselves:

The debug_thread_t structure is defined as follows in <sys/debug.h>:

typedef struct _debug_thread_info {
    pid_t                       pid;
    pthread_t                   tid;
    uint32_t                    flags;
    uint16_t                    why;
    uint16_t                    what;
    uint64_t                    ip;
    uint64_t                    sp;
    uint64_t                    stkbase;
    uint64_t                    tls;
    uint32_t                    stksize;
    uint32_t                    tid_flags;
    uint8_t                     priority;
    uint8_t                     real_priority;
    uint8_t                     policy;
    uint8_t                     state;
    int16_t                     syscall;
    uint16_t                    last_cpu;
    uint32_t                    timeout;
    int32_t                     last_chid;
    sigset_t                    sig_blocked;
    sigset_t                    sig_pending;
    siginfo_t                   info;
    union {
        struct {
            pthread_t                   tid;
        }                           join;
        struct {
            int32_t                     id;
            uintptr_t                   sync;
        }                           sync;
        struct {
            uint32_t                    nd;
            pid_t                       pid;
            int32_t                     coid;
            int32_t                     chid;
            int32_t                     scoid;
        }                           connect;
        struct {
            int32_t                     chid;
        }                           channel;
        struct {
            pid_t                       pid;
            uintptr_t                   vaddr;
            uint32_t                    flags;
        }                           waitpage;
        struct {
            uint32_t                    size;
        }                           stack;
        uint64_t                        filler[4];
    }                           blocked;
    uint64_t                    start_time;
    uint64_t                    sutime;
    uint8_t                     extsched[8];
    uint64_t                    reserved2[5];
}                           debug_thread_t;
Note: If you ask for information about a specific thread, and the thread no longer exists, the process manager returns information about the one with the next higher thread ID. If all the process's threads have exited, the tid member of the structure is set to 0.

The members include:

pid, tid
The process and thread IDs.
A combination of the following bits:
  • _DEBUG_FLAG_STOPPED — the thread isn't running.
  • _DEBUG_FLAG_ISTOP — the thread is stopped at a point of interest.
  • _DEBUG_FLAG_IPINVAL — the instruction pointer isn't valid.
  • _DEBUG_FLAG_ISSYS — system process.
  • _DEBUG_FLAG_SSTEP — stopped because of single-stepping.
  • _DEBUG_FLAG_CURTID — the thread is the current thread.
  • _DEBUG_FLAG_TRACE_EXEC — stopped because of a breakpoint.
  • _DEBUG_FLAG_TRACE_RD — stopped because of read access.
  • _DEBUG_FLAG_TRACE_WR — stopped because of write access.
  • _DEBUG_FLAG_TRACE_MODIFY — stopped because of modified memory.
  • _DEBUG_FLAG_RLC — the Run-on-Last-Close flag is set.
  • _DEBUG_FLAG_KLC — the Kill-on-Last-Close flag is set.
  • _DEBUG_FLAG_FORK — the child inherits flags (stop on fork or spawn).
One of the following:
The contents of this field depend on the why field:
why what
_DEBUG_WHY_TERMINATED The process's exit status
The current instruction pointer.
The thread's stack pointer.
The base address of the thread's stack region.
A pointer to the struct thread_local_storage *tls (which will be on the thread's stack). For more information, see "Local storage for private data" in the entry for ThreadCreate() in the QNX Neutrino C Library Reference.
The stack size.
The thread flags; see _NTO_TF_* in <sys/neutrino.h>.
The priority the thread is actually running at (e.g. its priority may have been boosted).
The actual priority the thread would be at with no boosting and so on.
The scheduling policy; one of SCHED_FIFO, SCHED_RR, SCHED_OTHER, or SCHED_SPORADIC.
The thread's state. The states themselves are defined in <sys/states.h>; for descriptions, see "Thread life cycle" in the QNX Neutrino Microkernel chapter of the System Architecture guide. If the thread is waiting for something, the blocked member may hold additional information, as described below.
The last system call; one of the __KER_* values defined in <sys/kercalls.h>.
The processor the thread last ran on.
_NTO_TF_ACTIVE|_NTO_TF_IMMEDIATE|(1 << state) — set by TimerTimeout() .
The ID of the last channel this thread received a message on.
The set of signals that are blocked for the thread.
The set of signals that are pending for the thread.
The struct siginfo of the last signal or fault received.
A union of the following:
  • join — if the state is STATE_JOIN or STATE_WAITTHREAD, this structure contains tid, the ID of the thread that this thread is waiting for.
  • sync — if the state is STATE_CONDVAR, STATE_MUTEX, or STATE_SEM, this structure contains:
    The address of the synchronization object.
    For a condvar, this is a pointer to the associated mutex; for a mutex, it's a pointer to the mutex.
  • connect — if the state is STATE_SEND or STATE_REPLY, this structure contains the node descriptor (nd), process ID (pid), connection ID (coid), channel ID (chid), and server connection ID (scoid) that the thread is waiting for.
  • channel — if the state is STATE_RECEIVE, this structure contains chid, the ID of the channel that the thread is waiting for.
  • waitpage — if the state is STATE_WAITPAGE, this structure contains:
    The ID of the process whose address space was active when the page fault occurred.
    The virtual address for which the thread is waiting for physical memory to be allocated.
    Internal use only.
  • stack — if the state is STATE_STACK, this structure contains size, the amount of stack that the thread is waiting for to be allocated.
The thread's starting time, in nanoseconds.
The thread's system plus user running time, in nanoseconds.
Extended scheduling information; a struct extsched_aps_dbg_thread structure if the adaptive partitioning thread scheduler is installed.