Attach a process to the profiler


#include <sys/dcmd_prof.h>

#define DCMD_PROF_ATTACH          __DIOT(_DCMD_MISC, PROF_ATTACH, struct __prof_clientinfo)

Arguments to devctl():

Argument Value
filedes A file descriptor for the profiler that you obtained by opening /dev/profiler.
dev_data_ptr A pointer to a struct __prof_clientinfo (see below)
n_bytes sizeof(struct __prof_clientinfo)
dev_info_ptr NULL


This command attaches a process to the profiler.

The __prof_clientinfo structure is defined in <sys/profiler.h> as follows:

struct __prof_clientinfo {
    unsigned     cmd;          /* Command for this request */
    unsigned     cap_flags;    /* capabilities */
    unsigned     version;      /* Version of the profile code */
    int          reserved;
    uintptr_t    lowpc;        /* Low address for this mapping */
    uintptr_t    highpc;       /* High address for this mapping */
    void         *mcounts;     /* Address in process for count array if present */
    void         *arcdata;     /* Address in process for arc data if present */
    void         *bb_head;     /* Address in process for basic block info if present */
    int          from_off;     /* Offset in shared memory for the from structures */
    int          from_size;    /* Size of froms structures in bytes */
    int          tos_off;      /* Offset in shared memory for the tos structure */
    int          tos_size;     /* Size of tos structures in bytes */
    int          hash_frac;    /* Hash fraction for tos structures */
    int          shmem_key;    /* Key used to identify shared memory */
    int          map_name_len; /* name of mapping identifier if present */
    __FLEXARY(char, map_name); /* char map_name[] */

The bits for the cmd member include:

The bits for the cap_flags member include:

Normally, the executable puts the arc information in a shared memory object that has the form /dev/shmem/prof-pid-%d, where %d is the key. The profiler agent uses the information in shared memory to get call pairs, total call numbers, and so on.

The name of the mapping is passed in for information purposes. This is typically the basename of the executable for the main text segment, and the soname of libraries when passing in shared library information.




See also:

devctl() in the QNX Neutrino C Library Reference