~nabijaczleweli/febug

ref: f9c5f814d44b8ee05f8d308d59a7567d52daf4a7 febug/FreeBSD/febug-abi.5 -rw-r--r-- 4.3 KiB
f9c5f814 — наб autouploader FreeBSD manpage update by job 402262 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
.\" Automatically generated from an mdoc input file.  Do not edit.
.\"" SPDX-License-Identifier: MIT
.TH "FEBUG-ABI" "3" "January 20, 2021" "FreeBSD 12.1-RELEASE-p10" "FreeBSD 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 <febug-abi.h>\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).
Afterward, it should send the null message with auxilliary data of type
\fRSCM_CREDS\fR.
However, sending it alongside the first non-null message works as well.
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