1adbgen(1M) System Administration Commands adbgen(1M)
2
3
4
6 adbgen - generate adb script
7
9 /usr/lib/adb/adbgen [-m model] filename.adb ...
10
11
13 adbgen makes it possible to write adb(1) scripts that do not contain
14 hard-coded dependencies on structure member offsets. The input to adb‐
15 gen is a file named filename.adb that contains header information, then
16 a null line, then the name of a structure, and finally an adb script.
17 adbgen only deals with one structure per file; all member names are
18 assumed to be in this structure. The output of adbgen is an adb script
19 in filename. adbgen operates by generating a C program which determines
20 structure member offsets and sizes, which in turn generate the adb
21 script.
22
23
24 The header lines, up to the null line, are copied verbatim into the
25 generated C program. Typically, these are #include statements, which
26 include the headers containing the relevant structure declarations.
27
28
29 The adb script part may contain any valid adb commands (see adb(1)),
30 and may also contain adbgen requests, each enclosed in braces ({}).
31 Request types are:
32
33 o Print a structure member. The request form is {member,for‐
34 mat}. member is a member name of the structure given ear‐
35 lier, and format is any valid adb format request or any of
36 the adbgen format specifiers (such as {POINTER}) listed
37 below. For example, to print the p_pid field of the proc
38 structure as a decimal number, you would write {p_pid,d}.
39
40 o Print the appropriate adb format character for the given
41 adbgen format specifier. This action takes the data model
42 into consideration. The request form is {format specifier}.
43 The valid adbgen format specifiers are:
44
45
46 {POINTER} pointer value in hexadecimal
47
48
49 {LONGDEC} long value in decimal
50
51
52 {ULONGDEC} unsigned long value in decimal
53
54
55 {ULONGHEX} unsigned long value in hexadecimal
56
57
58 {LONGOCT} long value in octal
59
60
61 {ULONGOCT} unsigned long value in octal
62
63
64
65 o Reference a structure member. The request form is {*mem‐
66 ber,base}. member is the member name whose value is desired,
67 and base is an adb register name which contains the base
68 address of the structure. For example, to get the p_pid
69 field of the proc structure, you would get the proc struc‐
70 ture address in an adb register, for example <f, and write
71 {*p_pid,<f}.
72
73 o Tell adbgen that the offset is valid. The request form is
74 {OFFSETOK}. This is useful after invoking another adb script
75 which moves the adb dot.
76
77 o Get the size of the structure. The request form is {SIZEOF}.
78 adbgen replaces this request with the size of the structure.
79 This is useful in incrementing a pointer to step through an
80 array of structures.
81
82 o Calculate an arbitrary C expression. The request form is
83 {EXPR,expression}. adbgen replaces this request with the
84 value of the expression. This is useful when more than one
85 structure is involved in the script.
86
87 o Get the offset to the end of the structure. The request form
88 is {END}. This is useful at the end of the structure to get
89 adb to align the dot for printing the next structure member.
90
91
92 adbgen keeps track of the movement of the adb dot and generates adb
93 code to move forward or backward as necessary before printing any
94 structure member in a script. adbgen's model of the behavior of adb's
95 dot is simple: it is assumed that the first line of the script is of
96 the form struct_address/adb text and that subsequent lines are of the
97 form +/adb text. The adb dot then moves in a sane fashion. adbgen does
98 not check the script to ensure that these limitations are met. adbgen
99 also checks the size of the structure member against the size of the
100 adb format code and warns if they are not equal.
101
103 The following option is supported:
104
105 -m model Specifies the data type model to be used by adbgen for the
106 macro. This affects the outcome of the {format specifier}
107 requests described under DESCRIPTION and the offsets and
108 sizes of data types. model can be ilp32 or lp64. If the -m
109 option is not given, the data type model defaults to ilp32.
110
111
113 The following operand is supported:
114
115 filename.adb Input file that contains header information, followed
116 by a null line, the name of the structure, and
117 finally an adb script.
118
119
121 Example 1 A sample adbgen file.
122
123
124 For an include file x.h which contained
125
126
127 struct x {
128 char *x_cp;
129 char x_c;
130 int x_i;
131 };
132
133
134
135
136 then , an adbgen file (call it script.adb) to print the file x.h would
137 be:
138
139
140 #include "x.h"
141 x
142 ./"x_cp"16t"x_c"8t"x_i"n{x_cp,{POINTER}}{x_c,C}{x_i,D}
143
144
145
146
147 After running adbgen as follows,
148
149
150 % /usr/lib/adb/adbgen script.adb
151
152
153
154
155 the output file script contains:
156
157
158 ./"x_cp"16t"x_c"8t"x_i"nXC3+D
159
160
161
162
163 For a macro generated for a 64-bit program using the lp64 data model as
164 follows,
165
166
167 % /usr/lib/adb/adbgen/ -m lp64 script.adb
168
169
170
171
172 the output file script would contain:
173
174
175 ./"x_cp"16t"x_c"8t"x_i"nJC3+D
176
177
178
179
180 To invoke the script, type:
181
182
183 example% adb program
184 x$<script
185
186
187
189 /usr/platform/platform-name/lib/adb/*
190
191 platform-specific adb scripts for debugging the 32-bit kernel
192
193
194 /usr/platform/platform-name/lib/adb/sparcv9/*
195
196 platform-specific adb scripts for debugging the 64-bit SPARC V9
197 kernel
198
199
200 /usr/lib/adb/*
201
202 adb scripts for debugging the 32-bit kernel
203
204
205 /usr/lib/adb/sparcv9/*
206
207 adb scripts for debugging the 64-bit SPARC V9 kernel
208
209
211 See attributes(5) for descriptions of the following attributes:
212
213
214
215
216 ┌─────────────────────────────┬─────────────────────────────┐
217 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
218 ├─────────────────────────────┼─────────────────────────────┤
219 │Availability │SUNWesu │
220 └─────────────────────────────┴─────────────────────────────┘
221
223 adb(1), uname(1), kadb(1M), attributes(5)
224
226 Warnings are given about structure member sizes not equal to adb format
227 items and about badly formatted requests. The C compiler complains if a
228 structure member that does not exist is referenced. It also complains
229 about an ampersand before array names; these complaints may be ignored.
230
232 platform-name can be found using the -i option of uname(1).
233
235 adb syntax is ugly; there should be a higher level interface for gener‐
236 ating scripts.
237
238
239 Structure members which are bit fields cannot be handled because C will
240 not give the address of a bit field. The address is needed to determine
241 the offset.
242
243
244
245SunOS 5.11 20 Feb 1998 adbgen(1M)