FEBUG-ABI(5) | File Formats Manual | FEBUG-ABI(5) |
struct febug_message
,
struct stop_febug_message
, struct
attn_febug_message
— User-space debugfs
ABI
#include
<febug-abi.h>
struct febug_message;
struct stop_febug_message;
struct attn_febug_message;
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.
To be debugged, the program must create a socket with
socket(AF_UNIX, SOCK_SEQPACKET, 0)
and
connect(2)
to the appropriate end-point (/run/febug.sock,
conventionally). Sending the first message will pass along client
credentials; sending the null message is a valid way to trigger this. After
febug(8) receives credentials, a
directory corresponding to the debugged process' PID will be created in the
filesystem.
All 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.
Afterward, for each variable of interest, the process should send
a 4096-byte febug_message
, defined as follows:
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. */]; };
When febug(8) receives a
febug_message
, it creates a file under the process'
directory. When that file is opened,
febug(8) will:
attn_febug_message
with a
single file descriptor via SCM_RIGHTS
auxilliary
data (see
cmsg(3))
representing the write end of a pipe.SIGKILL
.Note, that the sent file descriptor must be closed by the program when it's done serialising the variable, and therefore, if the process opts not to receive a signal, it must handle the message through some other mechanism.
attn_febug_message
is 16 bytes, and
defined as follows:
struct [[packed]] attn_febug_message { uint64_t variable_id; uint64_t variable_type; };
febug_message
that installed the variable.
The process may receive any number of
attn_febug_message
s until it sends an 8-byte
stop_febug_message
, defined as follows:
struct [[packed]] stop_febug_message { uint64_t variable_id; };
When the process' end of the socket is closed, all extant variables are freed, and the process' directory is removed.
libfebug(3), libfebug++(3), and libfebug.rs(3) — libraries that wrap this ABI.
To all who support further development, in particular:
febug mailing list: <~nabijaczleweli/febug@lists.sr.ht>, archived at https://lists.sr.ht/~nabijaczleweli/febug
September 2, 2024 | febug 1.0.0-2-g9ab5a53e |