4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 #pragma ident "%Z%%M% %I% %E% SMI"
25 * Copyright (c) 1983-1998 by Sun Microsystems, Inc.
26 * All rights reserved.
30 * Subroutines to be called by adbgen2.c, the C program generated
36 #include <sys/types.h>
43 * User claims offset is ok.
44 * This usually follows call to another script, which we cannot handle.
53 * Get adb.s dot to the right offset.
64 off_diff
= off
- last_off
;
68 printf("%ld", off_diff
);
74 printf("%ld", -off_diff
);
83 * Emit the format command, return the size.
88 int rcount
, width
, sum
, i
;
94 while (*cp
>= '0' && *cp
<= '9') {
95 rcount
= rcount
* 10 + *cp
++ - '0';
159 "Unknown format size \"%s\", assuming zero\n",
166 fprintf(stderr
, "Unknown format size: %s\n", acp
);
169 for (i
= 0; i
< rcount
; i
++) {
173 sum
+= width
* rcount
;
179 * Format struct member, checking size.
182 format(char *name
, size_t size
, char *fmt
)
187 if (fs
!= size
&& warnings
) {
189 "warning: \"%s\" size is %ld, \"%s\" width is %d\n",
190 name
, size
, fmt
, fs
);
197 * Get the value at offset based on base.
200 indirect(off_t offset
, size_t size
, char *base
, char *member
)
202 if (size
== 8 || size
== 4) {
206 printf("*(%s+0t%ld)", base
, offset
);
208 } else if (size
== 2) {
210 printf("(*%s&0xffff)", base
);
212 printf("(*(%s+0t%ld)&0xffff)", base
, offset
- 2);
214 } else if (size
== 1) {
216 printf("(*%s&0xff)", base
);
218 if ((offset
& 0x1) == 0x1) {
219 printf("(*(%s+0t%ld)&0xff)", base
, offset
- 3);
221 printf("((*(%s+0t%ld)&0xff00)/0x100)",
226 fprintf(stderr
, "Indirect size %ld not 1, 2, or 4: %s\n",