Print this page
4474 DTrace Userland CTF Support
4475 DTrace userland Keyword
4476 DTrace tests should be better citizens
4479 pid provider types
4480 dof emulation missing checks
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh
+++ new/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh
1 1 #!/bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 if [ $# != 1 ]; then
29 29 echo expected one argument: '<'dtrace-path'>'
30 30 exit 2
31 31 fi
32 32
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
33 33 dtrace=$1
34 34 DIR=/var/tmp/dtest.$$
35 35
36 36 mkdir $DIR
37 37 cd $DIR
38 38
39 39 cat > Makefile <<EOF
40 40 all: main livelib.so deadlib.so
41 41
42 42 main: main.o prov.o
43 - gcc -o main main.o
43 + gcc -m32 -o main main.o
44 44
45 45 main.o: main.c
46 - gcc -c main.c
46 + gcc -m32 -c main.c
47 47
48 48
49 49 livelib.so: livelib.o prov.o
50 - gcc -shared -o livelib.so livelib.o prov.o -lc
50 + gcc -m32 -shared -o livelib.so livelib.o prov.o -lc
51 51
52 52 livelib.o: livelib.c prov.h
53 - gcc -c livelib.c
53 + gcc -m32 -fPIC -c livelib.c
54 54
55 55 prov.o: livelib.o prov.d
56 56 $dtrace -G -s prov.d livelib.o
57 57
58 58 prov.h: prov.d
59 59 $dtrace -h -s prov.d
60 60
61 61
62 62 deadlib.so: deadlib.o
63 - gcc -shared -o deadlib.so deadlib.o -lc
63 + gcc -m32 -shared -o deadlib.so deadlib.o -lc
64 64
65 65 deadlib.o: deadlib.c
66 - gcc -c deadlib.c
66 + gcc -m32 -fPIC -c deadlib.c
67 67
68 68 clean:
69 69 rm -f main.o livelib.o prov.o prov.h deadlib.o
70 70
71 71 clobber: clean
72 72 rm -f main livelib.so deadlib.so
73 73 EOF
74 74
75 75 cat > prov.d <<EOF
76 76 provider test_prov {
77 77 probe go();
78 78 };
79 79 EOF
80 80
81 81 cat > livelib.c <<EOF
82 82 #include "prov.h"
83 83
84 84 void
85 85 go(void)
86 86 {
87 87 TEST_PROV_GO();
88 88 }
89 89 EOF
90 90
91 91 cat > deadlib.c <<EOF
92 92 void
93 93 go(void)
94 94 {
95 95 }
96 96 EOF
97 97
98 98
99 99 cat > main.c <<EOF
100 100 #include <dlfcn.h>
101 101 #include <unistd.h>
102 102 #include <stdio.h>
103 103
104 104 int
105 105 main(int argc, char **argv)
106 106 {
107 107 void *live, *dead;
108 108 void *go;
109 109
110 110 if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
111 111 printf("dlopen of livelib.so failed: %s\n", dlerror());
112 112 return (1);
113 113 }
114 114
115 115 (void) dlclose(live);
116 116
117 117 if ((dead = dlopen("./deadlib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
118 118 printf("dlopen of deadlib.so failed: %s\n", dlerror());
119 119 return (1);
120 120 }
121 121
122 122 if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
123 123 printf("dlopen of livelib.so failed: %s\n", dlerror());
124 124 return (1);
125 125 }
126 126
127 127 if ((go = dlsym(live, "go")) == NULL) {
128 128 printf("failed to lookup 'go' in livelib.so\n");
129 129 return (1);
130 130 }
131 131
132 132 ((void (*)(void))go)();
133 133
134 134 return (0);
135 135 }
136 136 EOF
137 137
138 138 make > /dev/null
139 139 if [ $? -ne 0 ]; then
140 140 print -u2 "failed to build"
141 141 exit 1
142 142 fi
143 143
144 144 script() {
145 145 $dtrace -w -c ./main -Zqs /dev/stdin <<EOF
146 146 test_prov*:::
147 147 {
148 148 printf("%s:%s:%s\n", probemod, probefunc, probename);
149 149 }
150 150 EOF
151 151 }
152 152
153 153 script
154 154 status=$?
155 155
156 156 cd /
157 157 /usr/bin/rm -rf $DIR
158 158
159 159 exit $status
↓ open down ↓ |
83 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX