.\" Automatically generated from an mdoc input file. Do not edit. .\"" SPDX-License-Identifier: MIT .TH "FEBUG-ABI" "3" "January 20, 2021" "OpenBSD 6.8" "Library Functions Manual" .nh .if n .ad l .SH "NAME" \fBstruct febug_message\fR, \fBstruct stop_febug_message\fR, \fBstruct attn_febug_message\fR \- User-space debugfs ABI .SH "SYNOPSIS" \fB#include \fR .PP \fBstruct febug_message;\fR .PP \fBstruct stop_febug_message;\fR .PP \fBstruct attn_febug_message;\fR .SH "DESCRIPTION" The febug ABI consists of two messages sent from the program wishing to be debugged to febug(8), and one sent from febug(8) to the program. .PP To be debugged, the program must create a socket with \fRsocket(AF_UNIX, SOCK_SEQPACKET, 0)\fR and connect(2) to the appropriate end-point (\fI/var/run/febug.sock\fR, conventionally). The filesystem will then immediately acquire effective credentials from the client. After febug(8) receives credentials, a directory corresponding to the debugged process' PID will be created in the filesystem. .PP \fIAll\fR messages must be sent in a single send(2) or sendmsg(2) call, specifying the exact size of the message, as that's what's used to differentiate between different messages. febug(8) will ignore messages (whose sizes) it does not recognise. .PP Afterward, for each variable of interest, the process should send a 4096-byte \fBfebug_message\fR, defined as follows: .nf .sp .RS 6n struct [[packed]] febug_message { uint64_t variable_id; uint64_t variable_type; uint8_t signal; char name[/* Enough to bring the overall size to 4096. */]; }; .RE .fi .PP Wherein: .TP 8n \fIvariable_id\fR is the locally unique identifier of the variable (e.g. a pointer to that variable). .TP 8n \fIvariable_type\fR is the moral equivalent of \fIvoid *\fR \fIuserdata\fR \[u2014] it is simply passed back to the program, unchanged (e.g. a function pointer to a formatter). .TP 8n \fIsignal\fR is the signal to send to the program when a variable is to be read (see below). \fIname\fR is the globally unique name of this variable \[u2014] a NUL terminator is respected, if it occurs before the end of the array, but is not required if the name truly spans to the final byte. If the name is the same as one of an already-present variable, it will be overridden. .PP When febug(8) receives \fBfebug_message\fR, it creates a file under the process' directory. When that file is opened, febug(8) will: .TP 8n 1.\& send the process an \fBattn_febug_message\fR with a single file descriptor via \fRSCM_RIGHTS\fR auxilliary data (confer cmsg(3)) representing the write end of a pipe \[u2014] subsequent reads are serviced directly by the opposing end. .TP 8n 2.\& kill(2) the process with the signal from the \fIsignal\fR field if it wasn't \fRSIGKILL\fR. .PP Note, that the sent file descriptor \fImust\fR be closed by the program when it's done serialising the variable, and therefore, if the process opts not to receive a signal, it \fImust\fR handle the message through some other mechanism. .PP \fBattn_febug_message\fR is 16 bytes, and defined as follows: .nf .sp .RS 6n struct [[packed]] attn_febug_message { uint64_t variable_id; uint64_t variable_type; }; .RE .fi .PP Both fields correspond to the ones sent in the \fBfebug_message\fR that installed the variable. .PP The process may receive any amount of \fBattn_febug_message\fR until it sends an 8-byte \fBstop_febug_message\fR, defined as follows: .nf .sp .RS 6n struct [[packed]] stop_febug_message { uint64_t variable_id; }; .RE .fi .PP Upon receipt, the corresponding variable, if any, is removed from the filesystem. .PP When the process' end of the socket is closed, all extant variables are freed, and the process' directory is removed. .SH "SEE ALSO" libfebug(3) and libfebug++(3) \[u2014] libraries that wrap this ABI. .SH "AUTHORS" Written by \[u043D]\[u0430]\[u0431] <\fInabijaczleweli@nabijaczleweli.xyz\fR> .SH "SPECIAL THANKS" To all who support further development, in particular: .PD 0 .TP 8n \fB\(bu\fR ThePhD .TP 8n \fB\(bu\fR Embark Studios .PD .SH "REPORTING BUGS" \fIfebug tracker\fR: \fBhttps://todo.sr.ht/~nabijaczleweli/febug\fR .PP febug mailing list: <\fI~nabijaczleweli/febug@lists.sr.ht\fR> archived at \fBhttps://lists.sr.ht/~nabijaczleweli/febug\fR