DCMD_PROC_BREAK

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

#include <sys/procfs.h>

#define DCMD_PROC_BREAK	 __DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 14, procfs_break)

The arguments to devctl() are:

Argument Value
filedes A file descriptor for the process. You must have opened the file descriptor for writing.
dcmd DCMD_PROC_BREAK
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.