Set or remove a breakpoint in the process that's associated with the file descriptor.

#include <sys/procfs.h>

#define DCMD_PROC_BREAK32  (__DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 14, procfs_break32))
#define DCMD_PROC_BREAK64  (__DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 14, procfs_break64))
#define DCMD_PROC_BREAK    (__DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 14, procfs_break))
Note: The generic command maps onto the 64-bit version, unless you're compiling for a 32-bit architecture and you define WANT_OLD_DEVCTLS before you include <sys/procfs.h>.

The arguments to devctl() are:

Argument Value
filedes A file descriptor for the process. You must have opened the file descriptor for writing.
dev_data_ptr A pointer to a procfs_break structure
n_bytes sizeof(procfs_break)
dev_info_ptr NULL

The argument is a pointer to a procfs_break structure (see debug_break_t in <sys/debug.h>) that specifies the breakpoint to be set or removed. For example:

procfs_break        brk;

memset(&brk, 0, sizeof brk);
brk.type = _DEBUG_BREAK_EXEC;
brk.addr = acc->break_addr.offset;
brk.size = 0;
devctl(fd, DCMD_PROC_BREAK, &brk, sizeof brk, 0);

Use a size of 0 to set a breakpoint, and a size of -1 to delete it.

Note: Breakpoints other than _DEBUG_BREAK_EXEC are highly dependent on the hardware. In many architectures, other types of breakpoints cause the kernel to make the process run in single-step, checking the watchpoints each time, which can be very slow.