xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/print/tst.array.d (revision 132157d7fb25c120ae1deca2a65fa7c78e8fcfd0)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2011 by Delphix. All rights reserved.
24  */
25 
26 #pragma D option quiet
27 
28 typedef struct bar {
29 	int alpha;
30 } bar_t;
31 
32 typedef struct foo {
33 	int a[3];
34 	char b[30];
35 	bar_t c[2];
36 	char d[3];
37 } foo_t;
38 
39 BEGIN
40 {
41 	this->f = (foo_t *)alloca(sizeof (foo_t));
42 
43 	this->f->a[0] = 1;
44 	this->f->a[1] = 2;
45 	this->f->a[2] = 3;
46 	this->f->b[0] = 'a';
47 	this->f->b[1] = 'b';
48 	this->f->b[2] = 0;
49 	this->f->c[0].alpha = 5;
50 	this->f->c[1].alpha = 6;
51 	this->f->c[2].alpha = 7;
52 	this->f->d[0] = 4;
53 	this->f->d[1] = 0;
54 	this->f->d[2] = 0;
55 
56 	print(this->f->a);
57 	print(this->f->b);
58 	print(this->f->c);
59 	print(*this->f);
60 
61 	exit(0);
62 }
63