1#!/usr/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2025 Oxide Computer Company 15# 16 17# 18# Test that we can correctly determine the offsets in various anonymous 19# structures and unions. 20# 21 22if (( $# != 1 )); then 23 printf "%s\n" "expected one argument: <dtrace-path>" >&2 24 exit 2 25fi 26 27dtrace=$1 28$dtrace -c ./tst.anon.exe -qs /dev/stdin <<EOF 29BEGIN 30{ 31 printf("a: %d, exp 0\n", offsetof(struct pid\`foo, a)); 32 printf("b: %d, exp 4\n", offsetof(struct pid\`foo, b)); 33 printf("c: %d, exp 4\n", offsetof(struct pid\`foo, c)); 34 printf("d: %d, exp 4\n", offsetof(struct pid\`foo, d)); 35 printf("e: %d, exp 8\n", offsetof(struct pid\`foo, e)); 36 printf("f: %d, exp 12\n", offsetof(struct pid\`foo, f)); 37 printf("g: %d, exp 4\n", offsetof(struct pid\`foo, g)); 38 printf("h: %d, exp 16\n", offsetof(struct pid\`foo, h)); 39 printf("i: %d, exp 20\n", offsetof(struct pid\`foo, i)); 40 printf("j: %d, exp 20\n", offsetof(struct pid\`foo, j)); 41 printf("k: %d, exp 24\n", offsetof(struct pid\`foo, k)); 42 printf("l: %d, exp 24\n", offsetof(struct pid\`foo, l)); 43 printf("m: %d, exp 28\n", offsetof(struct pid\`foo, m)); 44 printf("n: %d, exp 32\n", offsetof(struct pid\`foo, n)); 45 printf("o: %d, exp 32\n", offsetof(struct pid\`foo, o)); 46 printf("p: %d, exp 36\n", offsetof(struct pid\`foo, p)); 47 printf("q: %d, exp 24\n", offsetof(struct pid\`foo, q)); 48 printf("r: %d, exp 40\n", offsetof(struct pid\`foo, r)); 49 printf("s: %d, exp 20\n", offsetof(struct pid\`foo, s)); 50 printf("t: %d, exp 44\n", offsetof(struct pid\`foo, t)); 51 52 exit(0); 53} 54EOF 55