Manipulating a process or thread
Once you have a file descriptor to a particular process's /proc/pid/ctl file, you can get information about and control that process and its associated threads.
All of these functions are performed using the devctl() call as described in the sections that follow. To be able to use these devctl() calls, you'll need at least the following:
#include <devctl.h>
#include <sys/procfs.h>
#define DCMD_PROC_STATUS32 (__DIOF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 7, procfs_status32))
#define DCMD_PROC_STATUS64 (__DIOF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 7, procfs_status64))
#define DCMD_PROC_STATUS (__DIOF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 7, procfs_status))
The first two forms are for specific sizes; the generic form (DCMD_PROC_STATUS) maps onto the 64-bit version, whether you compile for a 32- or 64-bit architecture. If you're compiling for a 32-bit architecture, and you want the generic version to map onto the 32-bit command, define WANT_OLD_DEVCTLS before you include <sys/procfs.h>. If you're compiling for a 64-bit architecture, the generic version always maps onto the 64-bit version of the command.
You can use the devctl() commands (described in the sections that follow) to do the following:
- Select a thread for further operations. When you first perform the open() to a particular process, by default you're connected to the first thread (the thread that executed the main() function). If you wish to switch a different thread, use the DCMD_PROC_CURTHREAD command. To find out how many threads are available in the given process, see the DCMD_PROC_INFO command.
- Start and stop processes and threads:
You must have opened the file descriptor for writing.
- Set breakpoints:
You must have opened the file descriptor for writing.
- Examine process and thread attributes:
- DCMD_PROC_SYSINFO
- DCMD_PROC_INFO
- DCMD_PROC_MAPINFO
- DCMD_PROC_MAPDEBUG
- DCMD_PROC_MAPDEBUG_BASE
- DCMD_PROC_SIGNAL
- DCMD_PROC_STATUS
- DCMD_PROC_TIDSTATUS
- DCMD_PROC_GETGREG
- DCMD_PROC_SETGREG
- DCMD_PROC_GETFPREG
- DCMD_PROC_SETFPREG
- DCMD_PROC_GETREGSET
- DCMD_PROC_SETREGSET
- DCMD_PROC_EVENT
- DCMD_PROC_SET_FLAG
- DCMD_PROC_CLEAR_FLAG
- DCMD_PROC_PAGEDATA
- DCMD_PROC_PTINFO
- DCMD_PROC_GETALTREG
- DCMD_PROC_SETALTREG
- DCMD_PROC_TIMERS
- DCMD_PROC_IRQS
- DCMD_PROC_THREADCTL
- DCMD_PROC_CHANNELS
