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.
flags
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).
why
One of the following:
  • _DEBUG_WHY_REQUESTED
  • _DEBUG_WHY_SIGNALLED
  • _DEBUG_WHY_FAULTED
  • _DEBUG_WHY_JOBCONTROL
  • _DEBUG_WHY_TERMINATED
  • _DEBUG_WHY_CHILD
  • _DEBUG_WHY_EXEC
what
The contents of this field depend on the why field:
why what
_DEBUG_WHY_TERMINATED The process's exit status
_DEBUG_WHY_SIGNALLED si_signo
_DEBUG_WHY_FAULTED si_fltno
_DEBUG_WHY_REQUESTED 0
ip
The current instruction pointer.
sp
The thread's stack pointer.
stkbase
The base address of the thread's stack region.
tls
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.
stksize
The stack size.
tid_flags
The thread flags; see _NTO_TF_* in <sys/neutrino.h>.
priority
The priority the thread is actually running at (e.g. its priority may have been boosted).
real_priority
The actual priority the thread would be at with no boosting and so on.
policy
The scheduling policy; one of SCHED_FIFO, SCHED_RR, SCHED_OTHER, or SCHED_SPORADIC.
state
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.
syscall
The last system call; one of the __KER_* values defined in <sys/kercalls.h>.
last_cpu
The processor the thread last ran on.
timeout
_NTO_TF_ACTIVE|_NTO_TF_IMMEDIATE|(1 << state) — set by TimerTimeout() .
last_chid
The ID of the last channel this thread received a message on.
sig_blocked
The set of signals that are blocked for the thread.
sig_pending
The set of signals that are pending for the thread.
info
The struct siginfo of the last signal or fault received.
blocked
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:
    id
    The address of the synchronization object.
    sync
    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:
    pid
    The ID of the process whose address space was active when the page fault occurred.
    vaddr
    The virtual address for which the thread is waiting for physical memory to be allocated.
    flags
    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.
start_time
The thread's starting time, in nanoseconds.
sutime
The thread's system plus user running time, in nanoseconds.
extsched
Extended scheduling information; a struct extsched_aps_dbg_thread structure if the adaptive partitioning thread scheduler is installed.