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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
'\" te
.\" Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH ADBGEN 8 "Feb 20, 1998"
.SH NAME
adbgen \- generate adb script
.SH SYNOPSIS
.LP
.nf
\fB/usr/lib/adb/adbgen\fR [\fB-m\fR \fImodel\fR] \fIfilename\fR.adb .\|.\|.
.fi
.SH DESCRIPTION
.sp
.LP
\fBadbgen\fR makes it possible to write \fBadb\fR(1) scripts that do not
contain hard-coded dependencies on structure member offsets. The input to
\fBadbgen\fR is a file named \fIfilename\fR\fB\&.adb\fR that contains header
information, then a null line, then the name of a structure, and finally an
\fBadb\fR script. \fBadbgen\fR only deals with one structure per file; all
member names are assumed to be in this structure. The output of \fBadbgen\fR is
an \fBadb\fR script in \fIfilename\fR. \fBadbgen\fR operates by generating a C
program which determines structure member offsets and sizes, which in turn
generate the \fBadb\fR script.
.sp
.LP
The header lines, up to the null line, are copied verbatim into the generated C
program. Typically, these are \fB#include\fR statements, which include the
headers containing the relevant structure declarations.
.sp
.LP
The \fBadb\fR script part may contain any valid \fBadb\fR commands (see
\fBadb\fR(1)), and may also contain \fBadbgen\fR requests, each enclosed in
braces (\fB\|{\|}\fR\|). Request types are:
.RS +4
.TP
.ie t \(bu
.el o
Print a structure member. The request form is
\fB{\fR\fImember\fR\fB,\fR\fI\|format\fR\fB}.\fR \fImember\fR is a member name
of the \fIstructure\fR given earlier, and \fBformat\fR is any valid \fBadb\fR
format request or any of the \fBadbgen\fR format specifiers (such as
\fB{POINTER}\fR) listed below. For example, to print the \fBp_pid\fR field of
the \fIproc\fR structure as a decimal number, you would write \fB{p_pid,d}\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Print the appropriate \fBadb\fR format character for the given \fBadbgen\fR
format specifier. This action takes the data model into consideration. The
request form is \fB{\fR\fIformat specifier\fR\fB}.\fR The valid \fBadbgen\fR
format specifiers are:
.RS
.sp
.ne 2
.na
\fB\fB{POINTER}\fR\fR
.ad
.RS 14n
pointer value in hexadecimal
.RE
.sp
.ne 2
.na
\fB\fB{LONGDEC}\fR\fR
.ad
.RS 14n
long value in decimal
.RE
.sp
.ne 2
.na
\fB\fB{ULONGDEC}\fR\fR
.ad
.RS 14n
unsigned long value in decimal
.RE
.sp
.ne 2
.na
\fB\fB{ULONGHEX}\fR\fR
.ad
.RS 14n
unsigned long value in hexadecimal
.RE
.sp
.ne 2
.na
\fB\fB{LONGOCT}\fR\fR
.ad
.RS 14n
long value in octal
.RE
.sp
.ne 2
.na
\fB\fB{ULONGOCT}\fR\fR
.ad
.RS 14n
unsigned long value in octal
.RE
.RE
.RE
.RS +4
.TP
.ie t \(bu
.el o
Reference a structure member. The request form is
\fB{*\fR\fImember\fR\fB,\fR\fI\|base\fR\fB}.\fR \fImember\fR is the member name
whose value is desired, and \fIbase\fR is an \fBadb\fR register name which
contains the base address of the structure. For example, to get the \fBp_pid\fR
field of the \fIproc\fR structure, you would get the \fIproc\fR structure
address in an \fBadb\fR register, for example \fB<f\fR, and write
\fB{*p_pid,<f}\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Tell \fBadbgen\fR that the offset is valid. The request form is
\fB{OFFSETOK}\fR. This is useful after invoking another \fBadb\fR script which
moves the \fBadb\fR \fIdot\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Get the size of the \fIstructure\fR. The request form is \fB{SIZEOF}\fR.
\fBadbgen\fR replaces this request with the size of the structure. This is
useful in incrementing a pointer to step through an array of structures.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Calculate an arbitrary C expression. The request form is
\fB{EXPR,\fR\fI\|expression\fR\fB}.\fR \fBadbgen\fR replaces this request with
the value of the expression. This is useful when more than one structure is
involved in the script.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Get the offset to the end of the structure. The request form is \fB{END}\fR.
This is useful at the end of the structure to get \fBadb\fR to align the
\fIdot\fR for printing the next structure member.
.RE
.sp
.LP
\fBadbgen\fR keeps track of the movement of the \fBadb\fR \fIdot\fR and
generates \fBadb\fR code to move forward or backward as necessary before
printing any structure member in a script. \fBadbgen\fR's model of the behavior
of \fBadb\fR's \fIdot\fR is simple: it is assumed that the first line of the
script is of the form \fIstruct_address\fR/\fIadb text\fR and that subsequent
lines are of the form +/\fIadb text\fR. The \fBadb\fR \fIdot\fR then moves in a
sane fashion. \fBadbgen\fR does not check the script to ensure that these
limitations are met. \fBadbgen\fR also checks the size of the structure member
against the size of the \fBadb\fR format code and warns if they are not equal.
.SH OPTIONS
.sp
.LP
The following option is supported:
.sp
.ne 2
.na
\fB\fB-m\fR \fImodel\fR\fR
.ad
.RS 12n
Specifies the data type model to be used by \fBadbgen\fR for the macro. This
affects the outcome of the \fB{\fR\fIformat specifier\fR\fB}\fR requests
described under \fBDESCRIPTION\fR and the offsets and sizes of data types.
\fImodel\fR can be \fBilp32\fR or \fBlp64\fR. If the \fB-m\fR option is not
given, the data type model defaults to \fBilp32\fR.
.RE
.SH OPERANDS
.sp
.LP
The following operand is supported:
.sp
.ne 2
.na
\fB\fIfilename\fR\fB\&.adb\fR\fR
.ad
.RS 18n
Input file that contains header information, followed by a null line, the name
of the structure, and finally an \fBadb\fR script.
.RE
.SH EXAMPLES
.LP
\fBExample 1 \fRA sample \fBadbgen\fR file.
.sp
.LP
For an include file \fBx.h\fR which contained
.sp
.in +2
.nf
struct x {
char *x_cp;
char x_c;
int x_i;
};
.fi
.in -2
.sp
.sp
.LP
then , an \fBadbgen\fR file (call it \fBscript.adb\fR) to print the file
\fBx.h\fR would be:
.sp
.in +2
.nf
#include "x.h"
x
\&./"x_cp"16t"x_c"8t"x_i"n{x_cp,{POINTER}}{x_c,C}{x_i,D}
.fi
.in -2
.sp
.sp
.LP
After running \fBadbgen\fR as follows,
.sp
.in +2
.nf
% /usr/lib/adb/adbgen \|script.adb
.fi
.in -2
.sp
.sp
.LP
the output file \fBscript\fR contains:
.sp
.in +2
.nf
\&./"x_cp"16t"x_c"8t"x_i"nXC3+D
.fi
.in -2
.sp
.sp
.LP
For a macro generated for a 64-bit program using the \fBlp64\fR data model as
follows,
.sp
.in +2
.nf
\fB% /usr/lib/adb/adbgen/ \fR\fB-m\fR\fB lp64 \|script.adb\fR
.fi
.in -2
.sp
.sp
.LP
the output file \fBscript\fR would contain:
.sp
.in +2
.nf
\&./"x_cp"16t"x_c"8t"x_i"nJC3+D
.fi
.in -2
.sp
.sp
.LP
To invoke the script, type:
.sp
.in +2
.nf
example% adb program
x$<script
.fi
.in -2
.sp
.SH FILES
.sp
.ne 2
.na
\fB\fB/usr/platform/\fR\fIplatform-name\fR\fB/lib/adb/*\fR\fR
.ad
.sp .6
.RS 4n
platform-specific \fBadb\fR scripts for debugging the 32-bit kernel
.RE
.sp
.ne 2
.na
\fB\fB/usr/platform/\fR\fIplatform-name\fR\fB/lib/adb/sparcv9/*\fR\fR
.ad
.sp .6
.RS 4n
platform-specific \fBadb\fR scripts for debugging the 64-bit SPARC V9 kernel
.RE
.sp
.ne 2
.na
\fB\fB/usr/lib/adb/*\fR\fR
.ad
.sp .6
.RS 4n
\fBadb\fR scripts for debugging the 32-bit kernel
.RE
.sp
.ne 2
.na
\fB\fB/usr/lib/adb/sparcv9/*\fR\fR
.ad
.sp .6
.RS 4n
\fBadb\fR scripts for debugging the 64-bit SPARC V9 kernel
.RE
.SH SEE ALSO
.sp
.LP
.BR adb (1),
.BR uname (1),
.BR attributes (7),
.BR kadb (8)
.SH DIAGNOSTICS
.sp
.LP
Warnings are given about structure member sizes not equal to \fBadb\fR format
items and about badly formatted requests. The C compiler complains if a
structure member that does not exist is referenced. It also complains about an
ampersand before array names; these complaints may be ignored.
.SH NOTES
.sp
.LP
\fIplatform-name\fR can be found using the \fB-i\fR option of \fBuname\fR(1).
.SH BUGS
.sp
.LP
\fBadb\fR syntax is ugly; there should be a higher level interface for
generating scripts.
.sp
.LP
Structure members which are bit fields cannot be handled because C will not
give the address of a bit field. The address is needed to determine the offset.
|