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 there are no threads with a higher ID, devctl() returns ESRCH.

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).
  • _DEBUG_FLAG_EXEC — (QNX Neutrino 6.6 or later) stop on exec.
  • _DEBUG_FLAG_THREAD_EV — (QNX Neutrino 6.6 or later) stop when creating or destroying a thread.
why, what
The why field indicates why the process was stopped; the what field gives additional information:
why Description what
_DEBUG_WHY_CHILD A child process is ready to run; the parent gets a chance to connect to it The child's process ID
_DEBUG_WHY_EXEC The process was created by a call to an exec*() function 0
_DEBUG_WHY_FAULTED The thread faulted The fault number; see siginfo_t
_DEBUG_WHY_JOBCONTROL The thread is under job control The signal number
_DEBUG_WHY_REQUESTED The thread was working normally before being stopped by request 0
_DEBUG_WHY_SIGNALLED The thread received a signal The signal number
_DEBUG_WHY_TERMINATED The thread terminated The process's exit status
_DEBUG_WHY_THREAD (QNX Neutrino 6.6 or later) A thread was created or destroyed The thread ID
The current instruction pointer.
The thread's stack pointer.
The base address of the thread's stack region.
A pointer to the thread's local storage, which is on the thread's stack. For more information, see struct _thread_local_storage in <sys/storage.h>.
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.
A siginfo_t structure that contains information about 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.