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 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * ASSERTION: 29 * Declare a dynamic type and then use it to copyin the first 3 environment 30 * variable pointers from the current process. 31 * 32 * SECTION: Structs and Unions/Structs; 33 * Actions and Subroutines/copyin(); 34 * Actions and Subroutines/copyinstr(); 35 * Variables/External Variables 36 * 37 * NOTES: 38 * This test program declares a dynamic type and then uses it to copyin the 39 * first three environment variable pointers from the current process. We 40 * then use the dynamic type to access the result of our copyin(). The 41 * special "D" module type scope is also tested. 42 */ 43 44 #pragma D option quiet 45 46 struct env_vars_32 { 47 uint32_t e1; 48 uint32_t e2; 49 uint32_t e3; 50 }; 51 52 struct env_vars_flex_32 { 53 uint32_t e1; 54 uint32_t e2; 55 uint32_t e3[]; 56 }; 57 58 struct env_vars_64 { 59 uint64_t e1; 60 uint64_t e2; 61 uint64_t e3; 62 }; 63 64 struct env_vars_flex_64 { 65 uint64_t e1; 66 uint64_t e2; 67 uint64_t e3[]; 68 }; 69 70 BEGIN 71 /curpsinfo->pr_dmodel == PR_MODEL_ILP32/ 72 { 73 e32 = (struct D`env_vars_32 *) 74 copyin(curpsinfo->pr_envp, sizeof (struct D`env_vars_32)); 75 e32f = (struct D`env_vars_flex_32 *) 76 copyin(curpsinfo->pr_envp, sizeof (struct D`env_vars_flex_32) + 77 sizeof (uint32_t) * 2); 78 79 printf("e1 = \"%s\"\n", stringof(copyinstr(e32->e1))); 80 printf("e2 = \"%s\"\n", stringof(copyinstr(e32->e2))); 81 printf("e3 = \"%s\"\n", stringof(copyinstr(e32->e3))); 82 printf("\n"); 83 printf("e1 = \"%s\"\n", stringof(copyinstr(e32f->e1))); 84 printf("e2 = \"%s\"\n", stringof(copyinstr(e32f->e2))); 85 printf("e3[0] = \"%s\"\n", stringof(copyinstr(e32f->e3[0]))); 86 printf("e3[1] = \"%s\"\n", stringof(copyinstr(e32f->e3[1]))); 87 88 exit(0); 89 } 90 91 BEGIN 92 /curpsinfo->pr_dmodel == PR_MODEL_LP64/ 93 { 94 e64 = (struct D`env_vars_64 *) 95 copyin(curpsinfo->pr_envp, sizeof (struct D`env_vars_64)); 96 e64f = (struct D`env_vars_flex_64 *) 97 copyin(curpsinfo->pr_envp, sizeof (struct D`env_vars_flex_64) + 98 sizeof (uint64_t) * 2); 99 100 printf("e1 = \"%s\"\n", stringof(copyinstr(e64->e1))); 101 printf("e2 = \"%s\"\n", stringof(copyinstr(e64->e2))); 102 printf("e3 = \"%s\"\n", stringof(copyinstr(e64->e3))); 103 printf("\n"); 104 printf("e1 = \"%s\"\n", stringof(copyinstr(e64f->e1))); 105 printf("e2 = \"%s\"\n", stringof(copyinstr(e64f->e2))); 106 printf("e3[0] = \"%s\"\n", stringof(copyinstr(e64f->e3[0]))); 107 printf("e3[1] = \"%s\"\n", stringof(copyinstr(e64f->e3[1]))); 108 109 exit(0); 110 } 111