diff options
Diffstat (limited to 'usr/src/cmd/dtrace')
94 files changed, 4467 insertions, 74 deletions
diff --git a/usr/src/cmd/dtrace/Makefile.com b/usr/src/cmd/dtrace/Makefile.com index 2f69e31be5..81aad72bbf 100644 --- a/usr/src/cmd/dtrace/Makefile.com +++ b/usr/src/cmd/dtrace/Makefile.com @@ -29,6 +29,7 @@ OBJS = dtrace.o SRCS = $(OBJS:%.o=../%.c) include ../../Makefile.cmd +include ../../Makefile.ctf CFLAGS += $(CCVERBOSE) CFLAGS64 += $(CCVERBOSE) @@ -53,5 +54,6 @@ lint: lint_SRCS %.o: ../%.c $(COMPILE.c) $< + $(POST_PROCESS_O) include ../../Makefile.targ diff --git a/usr/src/cmd/dtrace/dtrace.c b/usr/src/cmd/dtrace/dtrace.c index e74e3df690..f005629fc9 100644 --- a/usr/src/cmd/dtrace/dtrace.c +++ b/usr/src/cmd/dtrace/dtrace.c @@ -25,6 +25,7 @@ */ /* * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ #include <sys/types.h> @@ -488,6 +489,7 @@ static void print_probe_info(const dtrace_probeinfo_t *p) { char buf[BUFSIZ]; + char *user; int i; oprintf("\n\tProbe Description Attributes\n"); @@ -511,10 +513,14 @@ print_probe_info(const dtrace_probeinfo_t *p) oprintf("\n\tArgument Types\n"); for (i = 0; i < p->dtp_argc; i++) { + if (p->dtp_argv[i].dtt_flags & DTT_FL_USER) + user = "userland "; + else + user = ""; if (ctf_type_name(p->dtp_argv[i].dtt_ctfp, p->dtp_argv[i].dtt_type, buf, sizeof (buf)) == NULL) (void) strlcpy(buf, "(unknown)", sizeof (buf)); - oprintf("\t\targs[%d]: %s\n", i, buf); + oprintf("\t\targs[%d]: %s%s\n", i, user, buf); } if (p->dtp_argc == 0) diff --git a/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl b/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl index d6f1c8c277..e7f9189822 100644 --- a/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl +++ b/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl @@ -566,7 +566,7 @@ $defdir = -d $dt_tst ? $dt_tst : '.'; $bindir = -d $dt_bin ? $dt_bin : '.'; if (!$opt_F) { - my @dependencies = ("gcc", "make", "java", "perl"); + my @dependencies = ("gcc", "cc", "make", "java", "perl", "printenv"); for my $dep (@dependencies) { if (!inpath($dep)) { diff --git a/usr/src/cmd/dtrace/test/tst/common/Makefile b/usr/src/cmd/dtrace/test/tst/common/Makefile index 4b813cb231..efa32d9179 100644 --- a/usr/src/cmd/dtrace/test/tst/common/Makefile +++ b/usr/src/cmd/dtrace/test/tst/common/Makefile @@ -26,6 +26,12 @@ # # Copyright (c) 2012 by Delphix. All rights reserved. +# Copyright (c) 2013, Joyent, Inc. All rights reserved. +# + +# +# WARNING: Do not include Makefile.ctf here. That will cause tests to +# break. # include $(SRC)/Makefile.master @@ -72,6 +78,50 @@ pid/tst.gcc.exe: pid/tst.gcc.c $(GCC) -o pid/tst.gcc.exe pid/tst.gcc.c $(LDFLAGS) $(POST_PROCESS) ; $(STRIP_STABS) +json/tst.usdt.o: json/usdt.h + +json/usdt.h: json/usdt.d + $(DTRACE) -h -s json/usdt.d -o json/usdt.h + +json/usdt.o: json/usdt.d json/tst.usdt.o + $(COMPILE.d) -o json/usdt.o -s json/usdt.d json/tst.usdt.o + +json/tst.usdt.exe: json/tst.usdt.o json/usdt.o + $(LINK.c) -o json/tst.usdt.exe json/tst.usdt.o json/usdt.o $(LDLIBS) + $(POST_PROCESS) ; $(STRIP_STABS) + +# +# Tests that use the next three programs rely on the binaries having +# valid CTF data. +# +uctf/tst.aouttype.exe: uctf/tst.aouttype.c + $(COMPILE.c) $(CTF_FLAGS) -o uctf/tst.aouttype.o uctf/tst.aouttype.c + $(CTFCONVERT) -i -L VERSION uctf/tst.aouttype.o + $(LINK.c) -o uctf/tst.aouttype.exe uctf/tst.aouttype.o $(LDLIBS) + $(CTFMERGE) -L VERSION -o $@ uctf/tst.aouttype.o + $(POST_PROCESS) ; $(STRIP_STABS) + +uctf/tst.chasestrings.exe: uctf/tst.chasestrings.c + $(COMPILE.c) $(CTF_FLAGS) -o uctf/tst.chasestrings.o uctf/tst.chasestrings.c + $(CTFCONVERT) -i -L VERSION uctf/tst.chasestrings.o + $(LINK.c) -o uctf/tst.chasestrings.exe uctf/tst.chasestrings.o $(LDLIBS) + $(CTFMERGE) -L VERSION -o $@ uctf/tst.chasestrings.o + $(POST_PROCESS) ; $(STRIP_STABS) + +uctf/tst.printtype.exe: uctf/tst.printtype.c + $(COMPILE.c) $(CTF_FLAGS) -o uctf/tst.printtype.o uctf/tst.printtype.c + $(CTFCONVERT) -i -L VERSION uctf/tst.printtype.o + $(LINK.c) -o uctf/tst.printtype.exe uctf/tst.printtype.o $(LDLIBS) + $(CTFMERGE) -L VERSION -o $@ uctf/tst.printtype.o + $(POST_PROCESS) ; $(STRIP_STABS) + +# +# This program should never have any ctf data in it. +# +uctf/tst.libtype.exe: + $(LINK.c) -o uctf/tst.libtype.exe uctf/tst.libtype.c $(LDLIBS) + $(POST_PROCESS) ; $(STRIP_STABS) + usdt/tst.args.exe: usdt/tst.args.o usdt/args.o $(LINK.c) -o usdt/tst.args.exe usdt/tst.args.o usdt/args.o $(LDLIBS) $(POST_PROCESS) ; $(STRIP_STABS) @@ -100,6 +150,14 @@ usdt/tst.forker.o: usdt/forker.h usdt/forker.h: usdt/forker.d $(DTRACE) -h -s usdt/forker.d -o usdt/forker.h +ustack/tst.unpriv.exe: ustack/tst.unpriv.o ustack/unpriv_helper.o + $(LINK.c) -o ustack/tst.unpriv.exe \ + ustack/tst.unpriv.o ustack/unpriv_helper.o $(LDLIBS) + $(POST_PROCESS) ; $(STRIP_STABS) + +ustack/unpriv_helper.o: ustack/unpriv_helper.d + $(COMPILE.d) -o ustack/unpriv_helper.o -s ustack/unpriv_helper.d + usdt/tst.lazyprobe.exe: usdt/tst.lazyprobe.o usdt/lazyprobe.o $(LINK.c) -o usdt/tst.lazyprobe.exe \ usdt/tst.lazyprobe.o usdt/lazyprobe.o $(LDLIBS) diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggencoding.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggencoding.d new file mode 100644 index 0000000000..a594afc7d6 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggencoding.d @@ -0,0 +1,32 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet +#pragma D option encoding=utf8 +#pragma D option aggzoom + +tick-1ms +/i++ < 320/ +{ + @ = lquantize(i, 0, 640, 1, i); + @ = lquantize(641 - i, 0, 640, 1, i); +} + +tick-1ms +/i == 320/ +{ + printa(@); + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggencoding.d.out b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggencoding.d.out new file mode 100644 index 0000000000..68482ffbe1 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggencoding.d.out @@ -0,0 +1,646 @@ + + + value ------------- Distribution ------------- count + 0 | 0 + 1 | 1 + 2 |▏ 2 + 3 |▎ 3 + 4 |▍ 4 + 5 |▌ 5 + 6 |▋ 6 + 7 |▊ 7 + 8 |▉ 8 + 9 |█ 9 + 10 |█▏ 10 + 11 |█▎ 11 + 12 |█▍ 12 + 13 |█▌ 13 + 14 |█▋ 14 + 15 |█▊ 15 + 16 |█▉ 16 + 17 |██ 17 + 18 |██▏ 18 + 19 |██▎ 19 + 20 |██▍ 20 + 21 |██▍ 21 + 22 |██▌ 22 + 23 |██▋ 23 + 24 |██▊ 24 + 25 |██▉ 25 + 26 |███ 26 + 27 |███▏ 27 + 28 |███▎ 28 + 29 |███▍ 29 + 30 |███▌ 30 + 31 |███▋ 31 + 32 |███▊ 32 + 33 |███▉ 33 + 34 |████ 34 + 35 |████▏ 35 + 36 |████▎ 36 + 37 |████▍ 37 + 38 |████▌ 38 + 39 |████▋ 39 + 40 |████▊ 40 + 41 |████▊ 41 + 42 |████▉ 42 + 43 |█████ 43 + 44 |█████▏ 44 + 45 |█████▎ 45 + 46 |█████▍ 46 + 47 |█████▌ 47 + 48 |█████▋ 48 + 49 |█████▊ 49 + 50 |█████▉ 50 + 51 |██████ 51 + 52 |██████▏ 52 + 53 |██████▎ 53 + 54 |██████▍ 54 + 55 |██████▌ 55 + 56 |██████▋ 56 + 57 |██████▊ 57 + 58 |██████▉ 58 + 59 |███████ 59 + 60 |███████▏ 60 + 61 |███████▏ 61 + 62 |███████▎ 62 + 63 |███████▍ 63 + 64 |███████▌ 64 + 65 |███████▋ 65 + 66 |███████▊ 66 + 67 |███████▉ 67 + 68 |████████ 68 + 69 |████████▏ 69 + 70 |████████▎ 70 + 71 |████████▍ 71 + 72 |████████▌ 72 + 73 |████████▋ 73 + 74 |████████▊ 74 + 75 |████████▉ 75 + 76 |█████████ 76 + 77 |█████████▏ 77 + 78 |█████████▎ 78 + 79 |█████████▍ 79 + 80 |█████████▌ 80 + 81 |█████████▌ 81 + 82 |█████████▋ 82 + 83 |█████████▊ 83 + 84 |█████████▉ 84 + 85 |██████████ 85 + 86 |██████████▏ 86 + 87 |██████████▎ 87 + 88 |██████████▍ 88 + 89 |██████████▌ 89 + 90 |██████████▋ 90 + 91 |██████████▊ 91 + 92 |██████████▉ 92 + 93 |███████████ 93 + 94 |███████████▏ 94 + 95 |███████████▎ 95 + 96 |███████████▍ 96 + 97 |███████████▌ 97 + 98 |███████████▋ 98 + 99 |███████████▊ 99 + 100 |███████████▉ 100 + 101 |███████████▉ 101 + 102 |████████████ 102 + 103 |████████████▏ 103 + 104 |████████████▎ 104 + 105 |████████████▍ 105 + 106 |████████████▌ 106 + 107 |████████████▋ 107 + 108 |████████████▊ 108 + 109 |████████████▉ 109 + 110 |█████████████ 110 + 111 |█████████████▏ 111 + 112 |█████████████▎ 112 + 113 |█████████████▍ 113 + 114 |█████████████▌ 114 + 115 |█████████████▋ 115 + 116 |█████████████▊ 116 + 117 |█████████████▉ 117 + 118 |██████████████ 118 + 119 |██████████████▏ 119 + 120 |██████████████▎ 120 + 121 |██████████████▎ 121 + 122 |██████████████▍ 122 + 123 |██████████████▌ 123 + 124 |██████████████▋ 124 + 125 |██████████████▊ 125 + 126 |██████████████▉ 126 + 127 |███████████████ 127 + 128 |███████████████▏ 128 + 129 |███████████████▎ 129 + 130 |███████████████▍ 130 + 131 |███████████████▌ 131 + 132 |███████████████▋ 132 + 133 |███████████████▊ 133 + 134 |███████████████▉ 134 + 135 |████████████████ 135 + 136 |████████████████▏ 136 + 137 |████████████████▎ 137 + 138 |████████████████▍ 138 + 139 |████████████████▌ 139 + 140 |████████████████▋ 140 + 141 |████████████████▋ 141 + 142 |████████████████▊ 142 + 143 |████████████████▉ 143 + 144 |█████████████████ 144 + 145 |█████████████████▏ 145 + 146 |█████████████████▎ 146 + 147 |█████████████████▍ 147 + 148 |█████████████████▌ 148 + 149 |█████████████████▋ 149 + 150 |█████████████████▊ 150 + 151 |█████████████████▉ 151 + 152 |██████████████████ 152 + 153 |██████████████████▏ 153 + 154 |██████████████████▎ 154 + 155 |██████████████████▍ 155 + 156 |██████████████████▌ 156 + 157 |██████████████████▋ 157 + 158 |██████████████████▊ 158 + 159 |██████████████████▉ 159 + 160 |███████████████████ 160 + 161 |███████████████████ 161 + 162 |███████████████████▏ 162 + 163 |███████████████████▎ 163 + 164 |███████████████████▍ 164 + 165 |███████████████████▌ 165 + 166 |███████████████████▋ 166 + 167 |███████████████████▊ 167 + 168 |███████████████████▉ 168 + 169 |████████████████████ 169 + 170 |████████████████████▏ 170 + 171 |████████████████████▎ 171 + 172 |████████████████████▍ 172 + 173 |████████████████████▌ 173 + 174 |████████████████████▋ 174 + 175 |████████████████████▊ 175 + 176 |████████████████████▉ 176 + 177 |█████████████████████ 177 + 178 |█████████████████████▏ 178 + 179 |█████████████████████▎ 179 + 180 |█████████████████████▍ 180 + 181 |█████████████████████▍ 181 + 182 |█████████████████████▌ 182 + 183 |█████████████████████▋ 183 + 184 |█████████████████████▊ 184 + 185 |█████████████████████▉ 185 + 186 |██████████████████████ 186 + 187 |██████████████████████▏ 187 + 188 |██████████████████████▎ 188 + 189 |██████████████████████▍ 189 + 190 |██████████████████████▌ 190 + 191 |██████████████████████▋ 191 + 192 |██████████████████████▊ 192 + 193 |██████████████████████▉ 193 + 194 |███████████████████████ 194 + 195 |███████████████████████▏ 195 + 196 |███████████████████████▎ 196 + 197 |███████████████████████▍ 197 + 198 |███████████████████████▌ 198 + 199 |███████████████████████▋ 199 + 200 |███████████████████████▊ 200 + 201 |███████████████████████▊ 201 + 202 |███████████████████████▉ 202 + 203 |████████████████████████ 203 + 204 |████████████████████████▏ 204 + 205 |████████████████████████▎ 205 + 206 |████████████████████████▍ 206 + 207 |████████████████████████▌ 207 + 208 |████████████████████████▋ 208 + 209 |████████████████████████▊ 209 + 210 |████████████████████████▉ 210 + 211 |█████████████████████████ 211 + 212 |█████████████████████████▏ 212 + 213 |█████████████████████████▎ 213 + 214 |█████████████████████████▍ 214 + 215 |█████████████████████████▌ 215 + 216 |█████████████████████████▋ 216 + 217 |█████████████████████████▊ 217 + 218 |█████████████████████████▉ 218 + 219 |██████████████████████████ 219 + 220 |██████████████████████████▏ 220 + 221 |██████████████████████████▏ 221 + 222 |██████████████████████████▎ 222 + 223 |██████████████████████████▍ 223 + 224 |██████████████████████████▌ 224 + 225 |██████████████████████████▋ 225 + 226 |██████████████████████████▊ 226 + 227 |██████████████████████████▉ 227 + 228 |███████████████████████████ 228 + 229 |███████████████████████████▏ 229 + 230 |███████████████████████████▎ 230 + 231 |███████████████████████████▍ 231 + 232 |███████████████████████████▌ 232 + 233 |███████████████████████████▋ 233 + 234 |███████████████████████████▊ 234 + 235 |███████████████████████████▉ 235 + 236 |████████████████████████████ 236 + 237 |████████████████████████████▏ 237 + 238 |████████████████████████████▎ 238 + 239 |████████████████████████████▍ 239 + 240 |████████████████████████████▌ 240 + 241 |████████████████████████████▌ 241 + 242 |████████████████████████████▋ 242 + 243 |████████████████████████████▊ 243 + 244 |████████████████████████████▉ 244 + 245 |█████████████████████████████ 245 + 246 |█████████████████████████████▏ 246 + 247 |█████████████████████████████▎ 247 + 248 |█████████████████████████████▍ 248 + 249 |█████████████████████████████▌ 249 + 250 |█████████████████████████████▋ 250 + 251 |█████████████████████████████▊ 251 + 252 |█████████████████████████████▉ 252 + 253 |██████████████████████████████ 253 + 254 |██████████████████████████████▏ 254 + 255 |██████████████████████████████▎ 255 + 256 |██████████████████████████████▍ 256 + 257 |██████████████████████████████▌ 257 + 258 |██████████████████████████████▋ 258 + 259 |██████████████████████████████▊ 259 + 260 |██████████████████████████████▉ 260 + 261 |██████████████████████████████▉ 261 + 262 |███████████████████████████████ 262 + 263 |███████████████████████████████▏ 263 + 264 |███████████████████████████████▎ 264 + 265 |███████████████████████████████▍ 265 + 266 |███████████████████████████████▌ 266 + 267 |███████████████████████████████▋ 267 + 268 |███████████████████████████████▊ 268 + 269 |███████████████████████████████▉ 269 + 270 |████████████████████████████████ 270 + 271 |████████████████████████████████▏ 271 + 272 |████████████████████████████████▎ 272 + 273 |████████████████████████████████▍ 273 + 274 |████████████████████████████████▌ 274 + 275 |████████████████████████████████▋ 275 + 276 |████████████████████████████████▊ 276 + 277 |████████████████████████████████▉ 277 + 278 |█████████████████████████████████ 278 + 279 |█████████████████████████████████▏ 279 + 280 |█████████████████████████████████▎ 280 + 281 |█████████████████████████████████▎ 281 + 282 |█████████████████████████████████▍ 282 + 283 |█████████████████████████████████▌ 283 + 284 |█████████████████████████████████▋ 284 + 285 |█████████████████████████████████▊ 285 + 286 |█████████████████████████████████▉ 286 + 287 |██████████████████████████████████ 287 + 288 |██████████████████████████████████▏ 288 + 289 |██████████████████████████████████▎ 289 + 290 |██████████████████████████████████▍ 290 + 291 |██████████████████████████████████▌ 291 + 292 |██████████████████████████████████▋ 292 + 293 |██████████████████████████████████▊ 293 + 294 |██████████████████████████████████▉ 294 + 295 |███████████████████████████████████ 295 + 296 |███████████████████████████████████▏ 296 + 297 |███████████████████████████████████▎ 297 + 298 |███████████████████████████████████▍ 298 + 299 |███████████████████████████████████▌ 299 + 300 |███████████████████████████████████▋ 300 + 301 |███████████████████████████████████▋ 301 + 302 |███████████████████████████████████▊ 302 + 303 |███████████████████████████████████▉ 303 + 304 |████████████████████████████████████ 304 + 305 |████████████████████████████████████▏ 305 + 306 |████████████████████████████████████▎ 306 + 307 |████████████████████████████████████▍ 307 + 308 |████████████████████████████████████▌ 308 + 309 |████████████████████████████████████▋ 309 + 310 |████████████████████████████████████▊ 310 + 311 |████████████████████████████████████▉ 311 + 312 |█████████████████████████████████████ 312 + 313 |█████████████████████████████████████▏ 313 + 314 |█████████████████████████████████████▎ 314 + 315 |█████████████████████████████████████▍ 315 + 316 |█████████████████████████████████████▌ 316 + 317 |█████████████████████████████████████▋ 317 + 318 |█████████████████████████████████████▊ 318 + 319 |█████████████████████████████████████▉ 319 + 320 |██████████████████████████████████████ 320 + 321 |██████████████████████████████████████ 320 + 322 |█████████████████████████████████████▉ 319 + 323 |█████████████████████████████████████▊ 318 + 324 |█████████████████████████████████████▋ 317 + 325 |█████████████████████████████████████▌ 316 + 326 |█████████████████████████████████████▍ 315 + 327 |█████████████████████████████████████▎ 314 + 328 |█████████████████████████████████████▏ 313 + 329 |█████████████████████████████████████ 312 + 330 |████████████████████████████████████▉ 311 + 331 |████████████████████████████████████▊ 310 + 332 |████████████████████████████████████▋ 309 + 333 |████████████████████████████████████▌ 308 + 334 |████████████████████████████████████▍ 307 + 335 |████████████████████████████████████▎ 306 + 336 |████████████████████████████████████▏ 305 + 337 |████████████████████████████████████ 304 + 338 |███████████████████████████████████▉ 303 + 339 |███████████████████████████████████▊ 302 + 340 |███████████████████████████████████▋ 301 + 341 |███████████████████████████████████▋ 300 + 342 |███████████████████████████████████▌ 299 + 343 |███████████████████████████████████▍ 298 + 344 |███████████████████████████████████▎ 297 + 345 |███████████████████████████████████▏ 296 + 346 |███████████████████████████████████ 295 + 347 |██████████████████████████████████▉ 294 + 348 |██████████████████████████████████▊ 293 + 349 |██████████████████████████████████▋ 292 + 350 |██████████████████████████████████▌ 291 + 351 |██████████████████████████████████▍ 290 + 352 |██████████████████████████████████▎ 289 + 353 |██████████████████████████████████▏ 288 + 354 |██████████████████████████████████ 287 + 355 |█████████████████████████████████▉ 286 + 356 |█████████████████████████████████▊ 285 + 357 |█████████████████████████████████▋ 284 + 358 |█████████████████████████████████▌ 283 + 359 |█████████████████████████████████▍ 282 + 360 |█████████████████████████████████▎ 281 + 361 |█████████████████████████████████▎ 280 + 362 |█████████████████████████████████▏ 279 + 363 |█████████████████████████████████ 278 + 364 |████████████████████████████████▉ 277 + 365 |████████████████████████████████▊ 276 + 366 |████████████████████████████████▋ 275 + 367 |████████████████████████████████▌ 274 + 368 |████████████████████████████████▍ 273 + 369 |████████████████████████████████▎ 272 + 370 |████████████████████████████████▏ 271 + 371 |████████████████████████████████ 270 + 372 |███████████████████████████████▉ 269 + 373 |███████████████████████████████▊ 268 + 374 |███████████████████████████████▋ 267 + 375 |███████████████████████████████▌ 266 + 376 |███████████████████████████████▍ 265 + 377 |███████████████████████████████▎ 264 + 378 |███████████████████████████████▏ 263 + 379 |███████████████████████████████ 262 + 380 |██████████████████████████████▉ 261 + 381 |██████████████████████████████▉ 260 + 382 |██████████████████████████████▊ 259 + 383 |██████████████████████████████▋ 258 + 384 |██████████████████████████████▌ 257 + 385 |██████████████████████████████▍ 256 + 386 |██████████████████████████████▎ 255 + 387 |██████████████████████████████▏ 254 + 388 |██████████████████████████████ 253 + 389 |█████████████████████████████▉ 252 + 390 |█████████████████████████████▊ 251 + 391 |█████████████████████████████▋ 250 + 392 |█████████████████████████████▌ 249 + 393 |█████████████████████████████▍ 248 + 394 |█████████████████████████████▎ 247 + 395 |█████████████████████████████▏ 246 + 396 |█████████████████████████████ 245 + 397 |████████████████████████████▉ 244 + 398 |████████████████████████████▊ 243 + 399 |████████████████████████████▋ 242 + 400 |████████████████████████████▌ 241 + 401 |████████████████████████████▌ 240 + 402 |████████████████████████████▍ 239 + 403 |████████████████████████████▎ 238 + 404 |████████████████████████████▏ 237 + 405 |████████████████████████████ 236 + 406 |███████████████████████████▉ 235 + 407 |███████████████████████████▊ 234 + 408 |███████████████████████████▋ 233 + 409 |███████████████████████████▌ 232 + 410 |███████████████████████████▍ 231 + 411 |███████████████████████████▎ 230 + 412 |███████████████████████████▏ 229 + 413 |███████████████████████████ 228 + 414 |██████████████████████████▉ 227 + 415 |██████████████████████████▊ 226 + 416 |██████████████████████████▋ 225 + 417 |██████████████████████████▌ 224 + 418 |██████████████████████████▍ 223 + 419 |██████████████████████████▎ 222 + 420 |██████████████████████████▏ 221 + 421 |██████████████████████████▏ 220 + 422 |██████████████████████████ 219 + 423 |█████████████████████████▉ 218 + 424 |█████████████████████████▊ 217 + 425 |█████████████████████████▋ 216 + 426 |█████████████████████████▌ 215 + 427 |█████████████████████████▍ 214 + 428 |█████████████████████████▎ 213 + 429 |█████████████████████████▏ 212 + 430 |█████████████████████████ 211 + 431 |████████████████████████▉ 210 + 432 |████████████████████████▊ 209 + 433 |████████████████████████▋ 208 + 434 |████████████████████████▌ 207 + 435 |████████████████████████▍ 206 + 436 |████████████████████████▎ 205 + 437 |████████████████████████▏ 204 + 438 |████████████████████████ 203 + 439 |███████████████████████▉ 202 + 440 |███████████████████████▊ 201 + 441 |███████████████████████▊ 200 + 442 |███████████████████████▋ 199 + 443 |███████████████████████▌ 198 + 444 |███████████████████████▍ 197 + 445 |███████████████████████▎ 196 + 446 |███████████████████████▏ 195 + 447 |███████████████████████ 194 + 448 |██████████████████████▉ 193 + 449 |██████████████████████▊ 192 + 450 |██████████████████████▋ 191 + 451 |██████████████████████▌ 190 + 452 |██████████████████████▍ 189 + 453 |██████████████████████▎ 188 + 454 |██████████████████████▏ 187 + 455 |██████████████████████ 186 + 456 |█████████████████████▉ 185 + 457 |█████████████████████▊ 184 + 458 |█████████████████████▋ 183 + 459 |█████████████████████▌ 182 + 460 |█████████████████████▍ 181 + 461 |█████████████████████▍ 180 + 462 |█████████████████████▎ 179 + 463 |█████████████████████▏ 178 + 464 |█████████████████████ 177 + 465 |████████████████████▉ 176 + 466 |████████████████████▊ 175 + 467 |████████████████████▋ 174 + 468 |████████████████████▌ 173 + 469 |████████████████████▍ 172 + 470 |████████████████████▎ 171 + 471 |████████████████████▏ 170 + 472 |████████████████████ 169 + 473 |███████████████████▉ 168 + 474 |███████████████████▊ 167 + 475 |███████████████████▋ 166 + 476 |███████████████████▌ 165 + 477 |███████████████████▍ 164 + 478 |███████████████████▎ 163 + 479 |███████████████████▏ 162 + 480 |███████████████████ 161 + 481 |███████████████████ 160 + 482 |██████████████████▉ 159 + 483 |██████████████████▊ 158 + 484 |██████████████████▋ 157 + 485 |██████████████████▌ 156 + 486 |██████████████████▍ 155 + 487 |██████████████████▎ 154 + 488 |██████████████████▏ 153 + 489 |██████████████████ 152 + 490 |█████████████████▉ 151 + 491 |█████████████████▊ 150 + 492 |█████████████████▋ 149 + 493 |█████████████████▌ 148 + 494 |█████████████████▍ 147 + 495 |█████████████████▎ 146 + 496 |█████████████████▏ 145 + 497 |█████████████████ 144 + 498 |████████████████▉ 143 + 499 |████████████████▊ 142 + 500 |████████████████▋ 141 + 501 |████████████████▋ 140 + 502 |████████████████▌ 139 + 503 |████████████████▍ 138 + 504 |████████████████▎ 137 + 505 |████████████████▏ 136 + 506 |████████████████ 135 + 507 |███████████████▉ 134 + 508 |███████████████▊ 133 + 509 |███████████████▋ 132 + 510 |███████████████▌ 131 + 511 |███████████████▍ 130 + 512 |███████████████▎ 129 + 513 |███████████████▏ 128 + 514 |███████████████ 127 + 515 |██████████████▉ 126 + 516 |██████████████▊ 125 + 517 |██████████████▋ 124 + 518 |██████████████▌ 123 + 519 |██████████████▍ 122 + 520 |██████████████▎ 121 + 521 |██████████████▎ 120 + 522 |██████████████▏ 119 + 523 |██████████████ 118 + 524 |█████████████▉ 117 + 525 |█████████████▊ 116 + 526 |█████████████▋ 115 + 527 |█████████████▌ 114 + 528 |█████████████▍ 113 + 529 |█████████████▎ 112 + 530 |█████████████▏ 111 + 531 |█████████████ 110 + 532 |████████████▉ 109 + 533 |████████████▊ 108 + 534 |████████████▋ 107 + 535 |████████████▌ 106 + 536 |████████████▍ 105 + 537 |████████████▎ 104 + 538 |████████████▏ 103 + 539 |████████████ 102 + 540 |███████████▉ 101 + 541 |███████████▉ 100 + 542 |███████████▊ 99 + 543 |███████████▋ 98 + 544 |███████████▌ 97 + 545 |███████████▍ 96 + 546 |███████████▎ 95 + 547 |███████████▏ 94 + 548 |███████████ 93 + 549 |██████████▉ 92 + 550 |██████████▊ 91 + 551 |██████████▋ 90 + 552 |██████████▌ 89 + 553 |██████████▍ 88 + 554 |██████████▎ 87 + 555 |██████████▏ 86 + 556 |██████████ 85 + 557 |█████████▉ 84 + 558 |█████████▊ 83 + 559 |█████████▋ 82 + 560 |█████████▌ 81 + 561 |█████████▌ 80 + 562 |█████████▍ 79 + 563 |█████████▎ 78 + 564 |█████████▏ 77 + 565 |█████████ 76 + 566 |████████▉ 75 + 567 |████████▊ 74 + 568 |████████▋ 73 + 569 |████████▌ 72 + 570 |████████▍ 71 + 571 |████████▎ 70 + 572 |████████▏ 69 + 573 |████████ 68 + 574 |███████▉ 67 + 575 |███████▊ 66 + 576 |███████▋ 65 + 577 |███████▌ 64 + 578 |███████▍ 63 + 579 |███████▎ 62 + 580 |███████▏ 61 + 581 |███████▏ 60 + 582 |███████ 59 + 583 |██████▉ 58 + 584 |██████▊ 57 + 585 |██████▋ 56 + 586 |██████▌ 55 + 587 |██████▍ 54 + 588 |██████▎ 53 + 589 |██████▏ 52 + 590 |██████ 51 + 591 |█████▉ 50 + 592 |█████▊ 49 + 593 |█████▋ 48 + 594 |█████▌ 47 + 595 |█████▍ 46 + 596 |█████▎ 45 + 597 |█████▏ 44 + 598 |█████ 43 + 599 |████▉ 42 + 600 |████▊ 41 + 601 |████▊ 40 + 602 |████▋ 39 + 603 |████▌ 38 + 604 |████▍ 37 + 605 |████▎ 36 + 606 |████▏ 35 + 607 |████ 34 + 608 |███▉ 33 + 609 |███▊ 32 + 610 |███▋ 31 + 611 |███▌ 30 + 612 |███▍ 29 + 613 |███▎ 28 + 614 |███▏ 27 + 615 |███ 26 + 616 |██▉ 25 + 617 |██▊ 24 + 618 |██▋ 23 + 619 |██▌ 22 + 620 |██▍ 21 + 621 |██▍ 20 + 622 |██▎ 19 + 623 |██▏ 18 + 624 |██ 17 + 625 |█▉ 16 + 626 |█▊ 15 + 627 |█▋ 14 + 628 |█▌ 13 + 629 |█▍ 12 + 630 |█▎ 11 + 631 |█▏ 10 + 632 |█ 9 + 633 |▉ 8 + 634 |▊ 7 + 635 |▋ 6 + 636 |▌ 5 + 637 |▍ 4 + 638 |▎ 3 + 639 |▏ 2 + >= 640 | 1 + + diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.agghist.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.agghist.d new file mode 100644 index 0000000000..317aecefdd --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.agghist.d @@ -0,0 +1,46 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option agghist +#pragma D option quiet + +BEGIN +{ + @["demerit"] = sum(-10); + @["wtf"] = sum(10); + @["bot"] = sum(20); + + @bagnoogle["SOAP/XML"] = sum(1); + @bagnoogle["XACML store"] = sum(5); + @bagnoogle["SAML token"] = sum(6); + + @stalloogle["breakfast"] = sum(-5); + @stalloogle["non-diet pepsi"] = sum(-20); + @stalloogle["parrot"] = sum(-100); + + printa(@); + printa(@bagnoogle); + printa(@stalloogle); + + printf("\nzoomed:"); + + setopt("aggzoom"); + printa(@); + printa(@bagnoogle); + printa(@stalloogle); + + exit(0); +} + diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.agghist.d.out b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.agghist.d.out new file mode 100644 index 0000000000..d76e4da4b8 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.agghist.d.out @@ -0,0 +1,38 @@ + + + key ------------- Distribution ------------- count + demerit @@@@@| -10 + wtf |@@@@@ 10 + bot |@@@@@@@@@@ 20 + + + key ------------- Distribution ------------- count + SOAP/XML |@@@ 1 + XACML store |@@@@@@@@@@@@@@@@@ 5 + SAML token |@@@@@@@@@@@@@@@@@@@@ 6 + + + key ------------- Distribution ------------- count + parrot @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -100 + non-diet pepsi @@@@@@| -20 + breakfast @@| -5 + +zoomed: + + key ------------- Distribution ------------- count + demerit @@@@@@@@@@| -10 + wtf |@@@@@@@@@@ 10 + bot |@@@@@@@@@@@@@@@@@@@ 20 + + + key ------------- Distribution ------------- count + SOAP/XML |@@@@@@@ 1 + XACML store |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + SAML token |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + + + key ------------- Distribution ------------- count + parrot @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -100 + non-diet pepsi @@@@@@@@| -20 + breakfast @@| -5 + diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpack.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpack.d new file mode 100644 index 0000000000..c9fdba76c4 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpack.d @@ -0,0 +1,53 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option aggpack +#pragma D option encoding=ascii +#pragma D option quiet + +BEGIN +{ + @x = quantize(1 << 32); + @y[1] = quantize(1); + @z["mumble"] = quantize(1); + @xx["foo", (char)1, (short)2, (long)3] = quantize(1); + + @neg = lquantize(-10, -10, 20, 1, -1); + @neg = lquantize(-5, -10, 20, 1, 1); + @neg = lquantize(0, -10, 20, 1, 1); + + i = 0; +} + +tick-1ms +{ + @a[i] = quantize(0, i); + @a[i] = quantize(1, 100 - i); + i++; +} + +tick-1ms +/i > 100/ +{ + exit(0); +} + +END +{ + setopt("aggzoom", "true"); + printa(@neg); + setopt("aggzoom", "false"); + printa(@neg); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpack.d.out b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpack.d.out new file mode 100644 index 0000000000..5300ebdbe9 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpack.d.out @@ -0,0 +1,124 @@ + + + min .--------------------------------. max | count + < -10 : V X X : >= 20 | 1 + + + min .--------------------------------. max | count + < -10 : v x x : >= 20 | 1 + + + min .---. max | count + 2147483648 : X : 8589934592 | 1 + + key min .---. max | count + 1 0 : X : 2 | 1 + + key min .---. max | count + mumble 0 : X : 2 | 1 + + key min .---. max | count + foo 1 2 3 0 : X : 2 | 1 + + key min .---. max | count + 100 0 :X : 2 | 100 + 99 0 :X_ : 2 | 100 + 98 0 :X_ : 2 | 100 + 97 0 :X_ : 2 | 100 + 96 0 :X_ : 2 | 100 + 95 0 :X_ : 2 | 100 + 94 0 :X_ : 2 | 100 + 93 0 :X_ : 2 | 100 + 92 0 :X_ : 2 | 100 + 91 0 :X_ : 2 | 100 + 90 0 :X_ : 2 | 100 + 89 0 :X_ : 2 | 100 + 88 0 :X_ : 2 | 100 + 87 0 :X_ : 2 | 100 + 86 0 :X_ : 2 | 100 + 85 0 :X_ : 2 | 100 + 84 0 :X_ : 2 | 100 + 83 0 :X_ : 2 | 100 + 82 0 :X_ : 2 | 100 + 81 0 :X_ : 2 | 100 + 80 0 :X_ : 2 | 100 + 79 0 :X_ : 2 | 100 + 78 0 :xx : 2 | 100 + 77 0 :xx : 2 | 100 + 76 0 :xx : 2 | 100 + 75 0 :xx : 2 | 100 + 74 0 :xx : 2 | 100 + 73 0 :xx : 2 | 100 + 72 0 :xx : 2 | 100 + 71 0 :xx : 2 | 100 + 70 0 :xx : 2 | 100 + 69 0 :xx : 2 | 100 + 68 0 :xx : 2 | 100 + 67 0 :xx : 2 | 100 + 66 0 :xx : 2 | 100 + 65 0 :xx : 2 | 100 + 64 0 :xx : 2 | 100 + 63 0 :xx : 2 | 100 + 62 0 :xx : 2 | 100 + 61 0 :xx : 2 | 100 + 60 0 :xx : 2 | 100 + 59 0 :xx : 2 | 100 + 58 0 :xx : 2 | 100 + 57 0 :xx : 2 | 100 + 56 0 :xx : 2 | 100 + 55 0 :xx : 2 | 100 + 54 0 :xx : 2 | 100 + 53 0 :xx : 2 | 100 + 52 0 :xx : 2 | 100 + 51 0 :xx : 2 | 100 + 50 0 :xx : 2 | 100 + 49 0 :xx : 2 | 100 + 48 0 :xx : 2 | 100 + 47 0 :xx : 2 | 100 + 46 0 :xx : 2 | 100 + 45 0 :xx : 2 | 100 + 44 0 :xx : 2 | 100 + 43 0 :xx : 2 | 100 + 42 0 :xx : 2 | 100 + 41 0 :xx : 2 | 100 + 40 0 :xx : 2 | 100 + 39 0 :xx : 2 | 100 + 38 0 :xx : 2 | 100 + 37 0 :xx : 2 | 100 + 36 0 :xx : 2 | 100 + 35 0 :xx : 2 | 100 + 34 0 :xx : 2 | 100 + 33 0 :xx : 2 | 100 + 32 0 :xx : 2 | 100 + 31 0 :xx : 2 | 100 + 30 0 :xx : 2 | 100 + 29 0 :xx : 2 | 100 + 28 0 :xx : 2 | 100 + 27 0 :xx : 2 | 100 + 26 0 :xx : 2 | 100 + 25 0 :xx : 2 | 100 + 24 0 :xx : 2 | 100 + 23 0 :xx : 2 | 100 + 22 0 :xx : 2 | 100 + 21 0 :_X : 2 | 100 + 20 0 :_X : 2 | 100 + 19 0 :_X : 2 | 100 + 18 0 :_X : 2 | 100 + 17 0 :_X : 2 | 100 + 16 0 :_X : 2 | 100 + 15 0 :_X : 2 | 100 + 14 0 :_X : 2 | 100 + 13 0 :_X : 2 | 100 + 12 0 :_X : 2 | 100 + 11 0 :_X : 2 | 100 + 10 0 :_X : 2 | 100 + 9 0 :_X : 2 | 100 + 8 0 :_X : 2 | 100 + 7 0 :_X : 2 | 100 + 6 0 :_X : 2 | 100 + 5 0 :_X : 2 | 100 + 4 0 :_X : 2 | 100 + 3 0 :_X : 2 | 100 + 2 0 :_X : 2 | 100 + 1 0 :_X : 2 | 100 + 0 0 : X : 2 | 100 diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackbanner.ksh b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackbanner.ksh new file mode 100644 index 0000000000..e53a89b0bb --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackbanner.ksh @@ -0,0 +1,75 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +let width=8 + +function outputchar +{ + banner $3 | awk -v line=$1 -v pos=$2 -v width=$width '{ \ + for (i = 1; i <= length($0); i++) { \ + if (substr($0, i, 1) == " ") \ + continue; \ + printf("\t@letter%d[%d] = lquantize(%d, 0, 40, 1);\n", \ + line, NR, i + (pos * width)); + } \ + }' +} + +function outputstr +{ + let pos=0; + let line=0 + + printf "#pragma D option aggpack\n#pragma D option aggsortkey\n" + + printf "BEGIN\n{\n" + for c in `echo "$1" | awk '{ \ + for (i = 1; i <= length($0); i++) { \ + c = substr($0, i, 1); \ + printf("%s\n", c == " " ? "space" : \ + c == "\n" ? "newline" : c); \ + } \ + }'`; do + if [[ "$c" == "space" ]]; then + let line=line+1 + let pos=0 + continue + fi + + outputchar $line $pos $c + let pos=pos+1 + done + + let i=0 + + while [[ $i -le $line ]]; do + printf "\tprinta(@letter%d);\n" $i + let i=i+1 + done + printf "\texit(0);\n}\n" +} + +dtrace -qs /dev/stdin -x encoding=utf8 <<EOF +`outputstr "why must i do this"` +EOF + +dtrace -qs /dev/stdin -x encoding=ascii -x aggzoom <<EOF +`outputstr "i am not well"` +EOF + +dtrace -qs /dev/stdin -x encoding=utf8 -x aggzoom <<EOF +`outputstr "send help"` +EOF + diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackbanner.ksh.out b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackbanner.ksh.out new file mode 100644 index 0000000000..a7eba38785 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackbanner.ksh.out @@ -0,0 +1,102 @@ + + + key min .------------------------------------------. max | count + 2 < 0 : ▂ ▂ ▂ ▂ ▂ ▂ : >= 40 | 6 + 3 < 0 : ▂ ▂ ▂ ▂ ▂ ▂ : >= 40 | 6 + 4 < 0 : ▂ ▂ ▂▂▂▂▂▂ ▂ : >= 40 | 9 + 5 < 0 : ▂ ▂▂ ▂ ▂ ▂ ▂ : >= 40 | 7 + 6 < 0 : ▂▂ ▂▂ ▂ ▂ ▂ : >= 40 | 7 + 7 < 0 : ▂ ▂ ▂ ▂ ▂ : >= 40 | 5 + + + key min .------------------------------------------. max | count + 2 < 0 : ▂ ▂ ▂ ▂ ▂▂▂▂ ▂▂▂▂▂ : >= 40 | 13 + 3 < 0 : ▂▂ ▂▂ ▂ ▂ ▂ ▂ : >= 40 | 8 + 4 < 0 : ▂ ▂▂ ▂ ▂ ▂ ▂▂▂▂ ▂ : >= 40 | 11 + 5 < 0 : ▂ ▂ ▂ ▂ ▂ ▂ : >= 40 | 6 + 6 < 0 : ▂ ▂ ▂ ▂ ▂ ▂ ▂ : >= 40 | 7 + 7 < 0 : ▂ ▂ ▂▂▂▂ ▂▂▂▂ ▂ : >= 40 | 11 + + + key min .------------------------------------------. max | count + 2 < 0 : █ : >= 40 | 1 + 3 < 0 : █ : >= 40 | 1 + 4 < 0 : █ : >= 40 | 1 + 5 < 0 : █ : >= 40 | 1 + 6 < 0 : █ : >= 40 | 1 + 7 < 0 : █ : >= 40 | 1 + + + key min .------------------------------------------. max | count + 2 < 0 : ▂▂▂▂▂ ▂▂▂▂ : >= 40 | 9 + 3 < 0 : ▃ ▃ ▃ ▃ : >= 40 | 4 + 4 < 0 : ▃ ▃ ▃ ▃ : >= 40 | 4 + 5 < 0 : ▃ ▃ ▃ ▃ : >= 40 | 4 + 6 < 0 : ▃ ▃ ▃ ▃ : >= 40 | 4 + 7 < 0 : ▂▂▂▂▂ ▂▂▂▂ : >= 40 | 9 + + + key min .------------------------------------------. max | count + 2 < 0 : ▂▂▂▂▂ ▂ ▂ ▂ ▂▂▂▂ : >= 40 | 12 + 3 < 0 : ▂ ▂ ▂ ▂ ▂ : >= 40 | 5 + 4 < 0 : ▂ ▂▂▂▂▂▂ ▂ ▂▂▂▂ : >= 40 | 12 + 5 < 0 : ▂ ▂ ▂ ▂ ▂ : >= 40 | 5 + 6 < 0 : ▂ ▂ ▂ ▂ ▂ ▂ : >= 40 | 6 + 7 < 0 : ▂ ▂ ▂ ▂ ▂▂▂▂ : >= 40 | 8 + + + + key min .------------------------------------------. max | count + 2 < 0 : X : >= 40 | 1 + 3 < 0 : X : >= 40 | 1 + 4 < 0 : X : >= 40 | 1 + 5 < 0 : X : >= 40 | 1 + 6 < 0 : X : >= 40 | 1 + 7 < 0 : X : >= 40 | 1 + + + key min .------------------------------------------. max | count + 2 < 0 : XX X X : >= 40 | 4 + 3 < 0 : X X XX XX : >= 40 | 6 + 4 < 0 : X X X XX X : >= 40 | 6 + 5 < 0 : XXXXXX X X : >= 40 | 8 + 6 < 0 : X X X X : >= 40 | 4 + 7 < 0 : X X X X : >= 40 | 4 + + + key min .------------------------------------------. max | count + 2 < 0 : X X XXXX XXXXX : >= 40 | 11 + 3 < 0 : XX X X X X : >= 40 | 6 + 4 < 0 : X X X X X X : >= 40 | 6 + 5 < 0 : X X X X X X : >= 40 | 6 + 6 < 0 : X XX X X X : >= 40 | 6 + 7 < 0 : X X XXXX X : >= 40 | 7 + + + key min .------------------------------------------. max | count + 2 < 0 : X X XXXXXX X X : >= 40 | 10 + 3 < 0 : X X X X X : >= 40 | 5 + 4 < 0 : X X XXXXX X X : >= 40 | 9 + 5 < 0 : X XX X X X X : >= 40 | 7 + 6 < 0 : XX XX X X X : >= 40 | 7 + 7 < 0 : X X XXXXXX XXXXXX XXXXXX : >= 40 | 20 + + + + key min .------------------------------------------. max | count + 2 < 0 : ████ ██████ █ █ █████ : >= 40 | 17 + 3 < 0 : █ █ ██ █ █ █ : >= 40 | 7 + 4 < 0 : ████ █████ █ █ █ █ █ : >= 40 | 14 + 5 < 0 : █ █ █ █ █ █ █ : >= 40 | 7 + 6 < 0 : █ █ █ █ ██ █ █ : >= 40 | 8 + 7 < 0 : ████ ██████ █ █ █████ : >= 40 | 17 + + + key min .------------------------------------------. max | count + 2 < 0 : █ █ ██████ █ █████ : >= 40 | 14 + 3 < 0 : █ █ █ █ █ █ : >= 40 | 6 + 4 < 0 : ██████ █████ █ █ █ : >= 40 | 14 + 5 < 0 : █ █ █ █ █████ : >= 40 | 9 + 6 < 0 : █ █ █ █ █ : >= 40 | 5 + 7 < 0 : █ █ ██████ ██████ █ : >= 40 | 15 + diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackzoom.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackzoom.d new file mode 100644 index 0000000000..537d1defe5 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackzoom.d @@ -0,0 +1,42 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +tick-1ms +/i++ < 30/ +{ + @[1] = lquantize(i, 0, 40, 1, 1000); + @[2] = lquantize(i, 0, 40, 1, 1000); + @[3] = lquantize(i, 0, 40, 1, 1000); +} + +tick-1ms +/i == 40/ +{ + @[1] = lquantize(0, 0, 40, 1, 1); + @[1] = lquantize(i, 0, 40, 1, 2000); + @[2] = lquantize(0, 0, 40, 1, 1); + @[2] = lquantize(i, 0, 40, 1, 2000); + @[3] = lquantize(0, 0, 40, 1, 1); + @[3] = lquantize(i, 0, 40, 1, 2000); + + printa(@); + setopt("aggpack"); + printa(@); + setopt("aggzoom"); + printa(@); + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackzoom.d.out b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackzoom.d.out new file mode 100644 index 0000000000..bc7ec00ca5 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggpackzoom.d.out @@ -0,0 +1,149 @@ + + 1 + value ------------- Distribution ------------- count + < 0 | 0 + 0 | 1 + 1 |@ 1000 + 2 |@ 1000 + 3 |@ 1000 + 4 |@ 1000 + 5 |@ 1000 + 6 |@ 1000 + 7 |@ 1000 + 8 |@ 1000 + 9 |@ 1000 + 10 |@ 1000 + 11 |@ 1000 + 12 |@ 1000 + 13 |@ 1000 + 14 |@ 1000 + 15 |@ 1000 + 16 |@ 1000 + 17 |@ 1000 + 18 |@ 1000 + 19 |@ 1000 + 20 |@ 1000 + 21 |@ 1000 + 22 |@ 1000 + 23 |@ 1000 + 24 |@ 1000 + 25 |@ 1000 + 26 |@ 1000 + 27 |@ 1000 + 28 |@ 1000 + 29 |@ 1000 + 30 |@ 1000 + 31 | 0 + 32 | 0 + 33 | 0 + 34 | 0 + 35 | 0 + 36 | 0 + 37 | 0 + 38 | 0 + 39 | 0 + >= 40 |@@ 2000 + + 2 + value ------------- Distribution ------------- count + < 0 | 0 + 0 | 1 + 1 |@ 1000 + 2 |@ 1000 + 3 |@ 1000 + 4 |@ 1000 + 5 |@ 1000 + 6 |@ 1000 + 7 |@ 1000 + 8 |@ 1000 + 9 |@ 1000 + 10 |@ 1000 + 11 |@ 1000 + 12 |@ 1000 + 13 |@ 1000 + 14 |@ 1000 + 15 |@ 1000 + 16 |@ 1000 + 17 |@ 1000 + 18 |@ 1000 + 19 |@ 1000 + 20 |@ 1000 + 21 |@ 1000 + 22 |@ 1000 + 23 |@ 1000 + 24 |@ 1000 + 25 |@ 1000 + 26 |@ 1000 + 27 |@ 1000 + 28 |@ 1000 + 29 |@ 1000 + 30 |@ 1000 + 31 | 0 + 32 | 0 + 33 | 0 + 34 | 0 + 35 | 0 + 36 | 0 + 37 | 0 + 38 | 0 + 39 | 0 + >= 40 |@@ 2000 + + 3 + value ------------- Distribution ------------- count + < 0 | 0 + 0 | 1 + 1 |@ 1000 + 2 |@ 1000 + 3 |@ 1000 + 4 |@ 1000 + 5 |@ 1000 + 6 |@ 1000 + 7 |@ 1000 + 8 |@ 1000 + 9 |@ 1000 + 10 |@ 1000 + 11 |@ 1000 + 12 |@ 1000 + 13 |@ 1000 + 14 |@ 1000 + 15 |@ 1000 + 16 |@ 1000 + 17 |@ 1000 + 18 |@ 1000 + 19 |@ 1000 + 20 |@ 1000 + 21 |@ 1000 + 22 |@ 1000 + 23 |@ 1000 + 24 |@ 1000 + 25 |@ 1000 + 26 |@ 1000 + 27 |@ 1000 + 28 |@ 1000 + 29 |@ 1000 + 30 |@ 1000 + 31 | 0 + 32 | 0 + 33 | 0 + 34 | 0 + 35 | 0 + 36 | 0 + 37 | 0 + 38 | 0 + 39 | 0 + >= 40 |@@ 2000 + + + + key min .------------------------------------------. max | count + 1 < 0 : ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁: >= 40 | 32001 + 2 < 0 : ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁: >= 40 | 32001 + 3 < 0 : ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁: >= 40 | 32001 + + + key min .------------------------------------------. max | count + 1 < 0 : ▁▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ █: >= 40 | 32001 + 2 < 0 : ▁▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ █: >= 40 | 32001 + 3 < 0 : ▁▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ █: >= 40 | 32001 + diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggzoom.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggzoom.d new file mode 100644 index 0000000000..860a169336 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggzoom.d @@ -0,0 +1,34 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +tick-1ms +/i++ < 90/ +{ + @ = lquantize(i, 0, 100, 1, 1000); +} + +tick-1ms +/i == 100/ +{ + @ = lquantize(i++, 0, 100, 1, 2000); + @ = lquantize(i++, 0, 100, 1, 3000); + + printa(@); + setopt("aggzoom"); + printa(@); + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggzoom.d.out b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggzoom.d.out new file mode 100644 index 0000000000..acddf7f731 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.aggzoom.d.out @@ -0,0 +1,211 @@ + + + value ------------- Distribution ------------- count + 0 | 0 + 1 | 1000 + 2 | 1000 + 3 | 1000 + 4 | 1000 + 5 | 1000 + 6 | 1000 + 7 | 1000 + 8 | 1000 + 9 | 1000 + 10 | 1000 + 11 | 1000 + 12 | 1000 + 13 | 1000 + 14 | 1000 + 15 | 1000 + 16 | 1000 + 17 | 1000 + 18 | 1000 + 19 | 1000 + 20 | 1000 + 21 | 1000 + 22 | 1000 + 23 | 1000 + 24 | 1000 + 25 | 1000 + 26 | 1000 + 27 | 1000 + 28 | 1000 + 29 | 1000 + 30 | 1000 + 31 | 1000 + 32 | 1000 + 33 | 1000 + 34 | 1000 + 35 | 1000 + 36 | 1000 + 37 | 1000 + 38 | 1000 + 39 | 1000 + 40 | 1000 + 41 | 1000 + 42 | 1000 + 43 | 1000 + 44 | 1000 + 45 | 1000 + 46 | 1000 + 47 | 1000 + 48 | 1000 + 49 | 1000 + 50 | 1000 + 51 | 1000 + 52 | 1000 + 53 | 1000 + 54 | 1000 + 55 | 1000 + 56 | 1000 + 57 | 1000 + 58 | 1000 + 59 | 1000 + 60 | 1000 + 61 | 1000 + 62 | 1000 + 63 | 1000 + 64 | 1000 + 65 | 1000 + 66 | 1000 + 67 | 1000 + 68 | 1000 + 69 | 1000 + 70 | 1000 + 71 | 1000 + 72 | 1000 + 73 | 1000 + 74 | 1000 + 75 | 1000 + 76 | 1000 + 77 | 1000 + 78 | 1000 + 79 | 1000 + 80 | 1000 + 81 | 1000 + 82 | 1000 + 83 | 1000 + 84 | 1000 + 85 | 1000 + 86 | 1000 + 87 | 1000 + 88 | 1000 + 89 | 1000 + 90 | 1000 + 91 | 0 + 92 | 0 + 93 | 0 + 94 | 0 + 95 | 0 + 96 | 0 + 97 | 0 + 98 | 0 + 99 | 0 + >= 100 |@@ 5000 + + + + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@ 1000 + 2 |@@@@@@@@ 1000 + 3 |@@@@@@@@ 1000 + 4 |@@@@@@@@ 1000 + 5 |@@@@@@@@ 1000 + 6 |@@@@@@@@ 1000 + 7 |@@@@@@@@ 1000 + 8 |@@@@@@@@ 1000 + 9 |@@@@@@@@ 1000 + 10 |@@@@@@@@ 1000 + 11 |@@@@@@@@ 1000 + 12 |@@@@@@@@ 1000 + 13 |@@@@@@@@ 1000 + 14 |@@@@@@@@ 1000 + 15 |@@@@@@@@ 1000 + 16 |@@@@@@@@ 1000 + 17 |@@@@@@@@ 1000 + 18 |@@@@@@@@ 1000 + 19 |@@@@@@@@ 1000 + 20 |@@@@@@@@ 1000 + 21 |@@@@@@@@ 1000 + 22 |@@@@@@@@ 1000 + 23 |@@@@@@@@ 1000 + 24 |@@@@@@@@ 1000 + 25 |@@@@@@@@ 1000 + 26 |@@@@@@@@ 1000 + 27 |@@@@@@@@ 1000 + 28 |@@@@@@@@ 1000 + 29 |@@@@@@@@ 1000 + 30 |@@@@@@@@ 1000 + 31 |@@@@@@@@ 1000 + 32 |@@@@@@@@ 1000 + 33 |@@@@@@@@ 1000 + 34 |@@@@@@@@ 1000 + 35 |@@@@@@@@ 1000 + 36 |@@@@@@@@ 1000 + 37 |@@@@@@@@ 1000 + 38 |@@@@@@@@ 1000 + 39 |@@@@@@@@ 1000 + 40 |@@@@@@@@ 1000 + 41 |@@@@@@@@ 1000 + 42 |@@@@@@@@ 1000 + 43 |@@@@@@@@ 1000 + 44 |@@@@@@@@ 1000 + 45 |@@@@@@@@ 1000 + 46 |@@@@@@@@ 1000 + 47 |@@@@@@@@ 1000 + 48 |@@@@@@@@ 1000 + 49 |@@@@@@@@ 1000 + 50 |@@@@@@@@ 1000 + 51 |@@@@@@@@ 1000 + 52 |@@@@@@@@ 1000 + 53 |@@@@@@@@ 1000 + 54 |@@@@@@@@ 1000 + 55 |@@@@@@@@ 1000 + 56 |@@@@@@@@ 1000 + 57 |@@@@@@@@ 1000 + 58 |@@@@@@@@ 1000 + 59 |@@@@@@@@ 1000 + 60 |@@@@@@@@ 1000 + 61 |@@@@@@@@ 1000 + 62 |@@@@@@@@ 1000 + 63 |@@@@@@@@ 1000 + 64 |@@@@@@@@ 1000 + 65 |@@@@@@@@ 1000 + 66 |@@@@@@@@ 1000 + 67 |@@@@@@@@ 1000 + 68 |@@@@@@@@ 1000 + 69 |@@@@@@@@ 1000 + 70 |@@@@@@@@ 1000 + 71 |@@@@@@@@ 1000 + 72 |@@@@@@@@ 1000 + 73 |@@@@@@@@ 1000 + 74 |@@@@@@@@ 1000 + 75 |@@@@@@@@ 1000 + 76 |@@@@@@@@ 1000 + 77 |@@@@@@@@ 1000 + 78 |@@@@@@@@ 1000 + 79 |@@@@@@@@ 1000 + 80 |@@@@@@@@ 1000 + 81 |@@@@@@@@ 1000 + 82 |@@@@@@@@ 1000 + 83 |@@@@@@@@ 1000 + 84 |@@@@@@@@ 1000 + 85 |@@@@@@@@ 1000 + 86 |@@@@@@@@ 1000 + 87 |@@@@@@@@ 1000 + 88 |@@@@@@@@ 1000 + 89 |@@@@@@@@ 1000 + 90 |@@@@@@@@ 1000 + 91 | 0 + 92 | 0 + 93 | 0 + 94 | 0 + 95 | 0 + 96 | 0 + 97 | 0 + 98 | 0 + 99 | 0 + >= 100 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5000 + + diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d index bb0739f0d3..ccafc2edd1 100644 --- a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d @@ -22,6 +22,7 @@ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ #include <sys/dtrace.h> @@ -98,6 +99,9 @@ STRFUNC(inet_ntoa6((in6_addr_t *)alloca(sizeof (in6_addr_t)))) STRFUNC(inet_ntop(AF_INET, (void *)alloca(sizeof (ipaddr_t)))) STRFUNC(toupper("foo")) STRFUNC(tolower("BAR")) +INTFUNC(getf(0)) +INTFUNC(strtoll("0x12EE5D5", 16)) +STRFUNC(json("{\"systemtap\": false}", "systemtap")) BEGIN /subr == DIF_SUBR_MAX + 1/ diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.nonarrow.ksh b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.nonarrow.ksh new file mode 100644 index 0000000000..3a2942e9f1 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.nonarrow.ksh @@ -0,0 +1,48 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# + +# +# Somewhat surprisingly, DTrace very much relies on the fact that when 32-bit +# is forced, pointers are not, in fact, narrowed to 32-bits. In particular, if +# this is not so (that is, if pointers are narrowed to their seemingly correct +# 32-bit width), helpers attached to 32-bit programs will fail to operate: +# they will erroneously zero the high 32-bits of the return values of 64-bit +# kernel pointers as returned by copyin(), alloca(), etc. This test asserts +# this implicit behavior -- and this comment regrettably serves as this +# behavior's only documentation. +# +doit() +{ + /usr/sbin/dtrace $1 -n BEGIN'{trace(sizeof (long))}' \ + -n 'BEGIN{*(int *)alloca(4) = 21506; exit(0)}' \ + -n 'ERROR{exit(1)}' + + if [ "$?" -ne 0 ]; then + exit $? + fi +} + +doit +doit -32 diff --git a/usr/src/cmd/dtrace/test/tst/common/json/tst.general.d b/usr/src/cmd/dtrace/test/tst/common/json/tst.general.d new file mode 100644 index 0000000000..4600811d95 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/tst.general.d @@ -0,0 +1,179 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2012, Joyent, Inc. All rights reserved. + */ + +/* + * General functional tests of JSON parser for json(). + */ + +#pragma D option quiet +#pragma D option strsize=1k + +#define TST(name) \ + printf("\ntst |%s|\n", name) +#define IN2(vala, valb) \ + in = strjoin(vala, valb); \ + printf("in |%s|\n", in) +#define IN(val) \ + in = val; \ + printf("in |%s|\n", in) +#define SEL(ss) \ + out = json(in, ss); \ + printf("sel |%s|\nout |%s|\n", ss, \ + out != NULL ? out : "<NULL>") + +BEGIN +{ + TST("empty array"); + IN("[]"); + SEL("0"); + + TST("one-element array: integer"); + IN("[1]"); + SEL("0"); + SEL("1"); + SEL("100"); + SEL("-1"); + + TST("one-element array: hex integer (not in spec, not supported)"); + IN("[0x1000]"); + SEL("0"); + + TST("one-element array: float"); + IN("[1.5001]"); + SEL("0"); + + TST("one-element array: float + exponent"); + IN("[16.3e10]"); + SEL("0"); + + TST("one-element array: integer + whitespace"); + IN("[ \t 5\t]"); + SEL("0"); + + TST("one-element array: integer + exponent + whitespace"); + IN("[ \t \t 16E10 \t ]"); + SEL("0"); + + TST("one-element array: string"); + IN("[\"alpha\"]"); + SEL("0"); + + TST("alternative first-element indexing"); + IN("[1,5,10,15,20]"); + SEL("[0]"); + SEL("[3]"); + SEL("[4]"); + SEL("[5]"); + + TST("one-element array: object"); + IN("[ { \"first\": true, \"second\": false }]"); + SEL("0.first"); + SEL("0.second"); + SEL("0.third"); + + TST("many-element array: integers"); + IN("[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377]"); + SEL("10"); /* F(10) = 55 */ + SEL("14"); /* F(14) = 377 */ + SEL("19"); + + TST("many-element array: multiple types"); + IN2("[\"string\",32,true,{\"a\":9,\"b\":false},100.3e10,false,200.5,", + "{\"key\":\"val\"},null]"); + SEL("0"); + SEL("0.notobject"); + SEL("1"); + SEL("2"); + SEL("3"); + SEL("3.a"); + SEL("3.b"); + SEL("3.c"); + SEL("4"); + SEL("5"); + SEL("6"); + SEL("7"); + SEL("7.key"); + SEL("7.key.notobject"); + SEL("7.nonexist"); + SEL("8"); + SEL("9"); + + TST("many-element array: multiple types + whitespace"); + IN2("\n[\t\"string\" ,\t32 , true\t,\t {\"a\": 9,\t\"b\": false},\t\t", + "100.3e10, false, 200.5,{\"key\" \t:\n \"val\"},\t\t null ]\t\t"); + SEL("0"); + SEL("0.notobject"); + SEL("1"); + SEL("2"); + SEL("3"); + SEL("3.a"); + SEL("3.b"); + SEL("3.c"); + SEL("4"); + SEL("5"); + SEL("6"); + SEL("7"); + SEL("7.key"); + SEL("7.key.notobject"); + SEL("7.nonexist"); + SEL("8"); + SEL("9"); + + TST("two-element array: various string escape codes"); + IN2("[\"abcd \\\" \\\\ \\/ \\b \\f \\n \\r \\t \\u0000 \\uf00F \", ", + "\"final\"]"); + SEL("0"); + SEL("1"); + + TST("three-element array: broken escape code"); + IN("[\"fine here\", \"dodgey \\u00AZ\", \"wont get here\"]"); + SEL("0"); + SEL("1"); + SEL("2"); + + TST("nested objects"); + IN2("{ \"top\": { \"mid\" : { \"legs\": \"feet\" }, \"number\": 9, ", + "\"array\":[0,1,{\"a\":true,\"bb\":[1,2,false,{\"x\":\"yz\"}]}]}}"); + SEL("top"); + SEL("fargo"); + SEL("top.mid"); + SEL("top.centre"); + SEL("top.mid.legs"); + SEL("top.mid.number"); + SEL("top.mid.array"); + SEL("top.number"); + SEL("top.array"); + SEL("top.array[0]"); + SEL("top.array[1]"); + SEL("top.array[2]"); + SEL("top.array[2].a"); + SEL("top.array[2].b"); + SEL("top.array[2].bb"); + SEL("top.array[2].bb[0]"); + SEL("top.array[2].bb[1]"); + SEL("top.array[2].bb[2]"); + SEL("top.array[2].bb[3]"); + SEL("top.array[2].bb[3].x"); + SEL("top.array[2].bb[3].x.nofurther"); + SEL("top.array[2].bb[4]"); + SEL("top.array[3]"); + + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/json/tst.general.d.out b/usr/src/cmd/dtrace/test/tst/common/json/tst.general.d.out new file mode 100644 index 0000000000..a857ab91d8 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/tst.general.d.out @@ -0,0 +1,218 @@ + +tst |empty array| +in |[]| +sel |0| +out |<NULL>| + +tst |one-element array: integer| +in |[1]| +sel |0| +out |1| +sel |1| +out |<NULL>| +sel |100| +out |<NULL>| +sel |-1| +out |<NULL>| + +tst |one-element array: hex integer (not in spec, not supported)| +in |[0x1000]| +sel |0| +out |<NULL>| + +tst |one-element array: float| +in |[1.5001]| +sel |0| +out |1.5001| + +tst |one-element array: float + exponent| +in |[16.3e10]| +sel |0| +out |16.3e10| + +tst |one-element array: integer + whitespace| +in |[ 5 ]| +sel |0| +out |5| + +tst |one-element array: integer + exponent + whitespace| +in |[ 16E10 ]| +sel |0| +out |16E10| + +tst |one-element array: string| +in |["alpha"]| +sel |0| +out |alpha| + +tst |alternative first-element indexing| +in |[1,5,10,15,20]| +sel |[0]| +out |1| +sel |[3]| +out |15| +sel |[4]| +out |20| +sel |[5]| +out |<NULL>| + +tst |one-element array: object| +in |[ { "first": true, "second": false }]| +sel |0.first| +out |true| +sel |0.second| +out |false| +sel |0.third| +out |<NULL>| + +tst |many-element array: integers| +in |[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377]| +sel |10| +out |55| +sel |14| +out |377| +sel |19| +out |<NULL>| + +tst |many-element array: multiple types| +in |["string",32,true,{"a":9,"b":false},100.3e10,false,200.5,{"key":"val"},null]| +sel |0| +out |string| +sel |0.notobject| +out |<NULL>| +sel |1| +out |32| +sel |2| +out |true| +sel |3| +out |{"a":9,"b":false}| +sel |3.a| +out |9| +sel |3.b| +out |false| +sel |3.c| +out |<NULL>| +sel |4| +out |100.3e10| +sel |5| +out |false| +sel |6| +out |200.5| +sel |7| +out |{"key":"val"}| +sel |7.key| +out |val| +sel |7.key.notobject| +out |<NULL>| +sel |7.nonexist| +out |<NULL>| +sel |8| +out |null| +sel |9| +out |<NULL>| + +tst |many-element array: multiple types + whitespace| +in | +[ "string" , 32 , true , {"a": 9, "b": false}, 100.3e10, false, 200.5,{"key" : + "val"}, null ] | +sel |0| +out |string| +sel |0.notobject| +out |<NULL>| +sel |1| +out |32| +sel |2| +out |true| +sel |3| +out |{"a": 9, "b": false}| +sel |3.a| +out |9| +sel |3.b| +out |false| +sel |3.c| +out |<NULL>| +sel |4| +out |100.3e10| +sel |5| +out |false| +sel |6| +out |200.5| +sel |7| +out |{"key" : + "val"}| +sel |7.key| +out |val| +sel |7.key.notobject| +out |<NULL>| +sel |7.nonexist| +out |<NULL>| +sel |8| +out |null| +sel |9| +out |<NULL>| + +tst |two-element array: various string escape codes| +in |["abcd \" \\ \/ \b \f \n \r \t \u0000 \uf00F ", "final"]| +sel |0| +out |abcd \" \\ \/ \b \f \n \r \t \u0000 \uf00F | +sel |1| +out |final| + +tst |three-element array: broken escape code| +in |["fine here", "dodgey \u00AZ", "wont get here"]| +sel |0| +out |fine here| +sel |1| +out |<NULL>| +sel |2| +out |<NULL>| + +tst |nested objects| +in |{ "top": { "mid" : { "legs": "feet" }, "number": 9, "array":[0,1,{"a":true,"bb":[1,2,false,{"x":"yz"}]}]}}| +sel |top| +out |{ "mid" : { "legs": "feet" }, "number": 9, "array":[0,1,{"a":true,"bb":[1,2,false,{"x":"yz"}]}]}| +sel |fargo| +out |<NULL>| +sel |top.mid| +out |{ "legs": "feet" }| +sel |top.centre| +out |<NULL>| +sel |top.mid.legs| +out |feet| +sel |top.mid.number| +out |<NULL>| +sel |top.mid.array| +out |<NULL>| +sel |top.number| +out |9| +sel |top.array| +out |[0,1,{"a":true,"bb":[1,2,false,{"x":"yz"}]}]| +sel |top.array[0]| +out |0| +sel |top.array[1]| +out |1| +sel |top.array[2]| +out |{"a":true,"bb":[1,2,false,{"x":"yz"}]}| +sel |top.array[2].a| +out |true| +sel |top.array[2].b| +out |<NULL>| +sel |top.array[2].bb| +out |[1,2,false,{"x":"yz"}]| +sel |top.array[2].bb[0]| +out |1| +sel |top.array[2].bb[1]| +out |2| +sel |top.array[2].bb[2]| +out |false| +sel |top.array[2].bb[3]| +out |{"x":"yz"}| +sel |top.array[2].bb[3].x| +out |yz| +sel |top.array[2].bb[3].x.nofurther| +out |<NULL>| +sel |top.array[2].bb[4]| +out |<NULL>| +sel |top.array[3]| +out |<NULL>| + diff --git a/usr/src/cmd/dtrace/test/tst/common/json/tst.strsize.d b/usr/src/cmd/dtrace/test/tst/common/json/tst.strsize.d new file mode 100644 index 0000000000..6aa50b9ad0 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/tst.strsize.d @@ -0,0 +1,51 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2012, Joyent, Inc. All rights reserved. + */ + +/* + * ASSERTION: + * json() run time must be bounded above by strsize. This test makes strsize + * small and deliberately overflows it to prove we bail and return NULL in + * the event that we run off the end of the string. + * + */ + +#pragma D option quiet +#pragma D option strsize=18 + +BEGIN +{ + in = "{\"a\": 1024}"; /* length == 19 */ + out = json(in, "a"); + printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>"); + + in = "{\"a\": 1024}"; /* length == 11 */ + out = json(in, "a"); + printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>"); + + in = "{\"a\":false,\"b\":true}"; /* length == 20 */ + out = json(in, "b"); + printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>"); + + in = "{\"a\":false,\"b\":20}"; /* length == 18 */ + out = json(in, "b"); + printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>"); + + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/json/tst.strsize.d.out b/usr/src/cmd/dtrace/test/tst/common/json/tst.strsize.d.out new file mode 100644 index 0000000000..7f1d79b6fe --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/tst.strsize.d.out @@ -0,0 +1,13 @@ +|{"a": 1024| +<NULL> + +|{"a": 1024}| +1024 + +|{"a":false,"b":tru| +<NULL> + +|{"a":false,"b":20}| +20 + + diff --git a/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.c b/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.c new file mode 100644 index 0000000000..307106d903 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.c @@ -0,0 +1,61 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2012 (c), Joyent, Inc. All rights reserved. + */ + +#include <sys/sdt.h> +#include "usdt.h" + +#define FMT "{" \ + " \"sizes\": [ \"first\", 2, %f ]," \ + " \"index\": %d," \ + " \"facts\": {" \ + " \"odd\": \"%s\"," \ + " \"even\": \"%s\"" \ + " }," \ + " \"action\": \"%s\"" \ + "}\n" + +int +waiting(volatile int *a) +{ + return (*a); +} + +int +main(int argc, char **argv) +{ + volatile int a = 0; + int idx; + double size = 250.5; + + while (waiting(&a) == 0) + continue; + + for (idx = 0; idx < 10; idx++) { + char *odd, *even, *json, *action; + + size *= 1.78; + odd = idx % 2 == 1 ? "true" : "false"; + even = idx % 2 == 0 ? "true" : "false"; + action = idx == 7 ? "ignore" : "print"; + + asprintf(&json, FMT, size, idx, odd, even, action); + BUNYAN_FAKE_LOG_DEBUG(json); + free(json); + } + + BUNYAN_FAKE_LOG_DEBUG("{\"finished\": true}"); + + return (0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.d b/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.d new file mode 100644 index 0000000000..f0fbdd5cab --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.d @@ -0,0 +1,65 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + +#pragma D option strsize=4k +#pragma D option quiet +#pragma D option destructive + +/* + * This test reads a JSON string from a USDT probe, roughly simulating the + * primary motivating use case for the json() subroutine: filtering + * JSON-formatted log messages from a logging subsystem like node-bunyan. + */ + +pid$1:a.out:waiting:entry +{ + this->value = (int *)alloca(sizeof (int)); + *this->value = 1; + copyout(this->value, arg0, sizeof (int)); +} + +bunyan*$1:::log-* +{ + this->j = copyinstr(arg0); +} + +bunyan*$1:::log-* +/json(this->j, "finished") == NULL && json(this->j, "action") != "ignore"/ +{ + this->index = strtoll(json(this->j, "index")); + this->size = json(this->j, "sizes[2]"); + this->odd = json(this->j, "facts.odd"); + this->even = json(this->j, "facts.even"); + printf("[%d] sz %s odd %s even %s\n", this->index, this->size, + this->odd, this->even); +} + +bunyan*$1:::log-* +/json(this->j, "finished") != NULL/ +{ + printf("FINISHED!\n"); + exit(0); +} + +tick-10s +{ + printf("ERROR: Timed out before finish message!\n"); + exit(1); +} + +ERROR +{ + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.d.out b/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.d.out new file mode 100644 index 0000000000..c7f58bb535 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/tst.usdt.d.out @@ -0,0 +1,11 @@ +[0] sz 445.890000 odd false even true +[1] sz 793.684200 odd true even false +[2] sz 1412.757876 odd false even true +[3] sz 2514.709019 odd true even false +[4] sz 4476.182054 odd false even true +[5] sz 7967.604057 odd true even false +[6] sz 14182.335221 odd false even true +[8] sz 44935.310914 odd false even true +[9] sz 79984.853427 odd true even false +FINISHED! + diff --git a/usr/src/cmd/dtrace/test/tst/common/json/usdt.d b/usr/src/cmd/dtrace/test/tst/common/json/usdt.d new file mode 100644 index 0000000000..1a4fc87f60 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/json/usdt.d @@ -0,0 +1,27 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2012, Joyent, Inc. All rights reserved. + */ + +/* + * Sets up a fake node-bunyan-like USDT provider for use from C. + */ + +provider bunyan_fake { + probe log__trace(char *msg); + probe log__debug(char *msg); + probe log__info(char *msg); + probe log__warn(char *msg); + probe log__error(char *msg); + probe log__fatal(char *msg); +}; diff --git a/usr/src/cmd/dtrace/test/tst/common/llquantize/tst.range.d b/usr/src/cmd/dtrace/test/tst/common/llquantize/tst.range.d index e2882b3f8e..a9138d2f54 100644 --- a/usr/src/cmd/dtrace/test/tst/common/llquantize/tst.range.d +++ b/usr/src/cmd/dtrace/test/tst/common/llquantize/tst.range.d @@ -19,10 +19,6 @@ * CDDL HEADER END */ -/* - * Copyright (c) 2011, Joyent, Inc. All rights reserved. - */ - #pragma D option quiet BEGIN diff --git a/usr/src/cmd/dtrace/test/tst/common/mdb/tst.postmort.ksh b/usr/src/cmd/dtrace/test/tst/common/mdb/tst.postmort.ksh new file mode 100644 index 0000000000..c5921b8d28 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/mdb/tst.postmort.ksh @@ -0,0 +1,69 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2011, Joyent, Inc. All rights reserved. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +expected=`od -t u8 -N 8 /dev/urandom | head -1 | cut -d ' ' -f2` + +$dtrace -x bufpolicy=ring -x bufsize=10k -qs /dev/stdin > /dev/null 2>&1 <<EOF & + tick-1ms + /i < 10000/ + { + printf("%d: expected is $expected!\n", i++); + } + + tick-1ms + /i >= 10000/ + { + exit(0); + } +EOF + +background=$! + +# +# Give some time for the enabling to get there... +# +sleep 2 + +echo "::walk dtrace_state | ::dtrace" | mdb -k | tee test.out +grep "expected is $expected" test.out 2> /dev/null 1>&2 +status=$? + +kill $background + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/usr/src/cmd/dtrace/test/tst/common/misc/tst.dofmax.ksh b/usr/src/cmd/dtrace/test/tst/common/misc/tst.dofmax.ksh new file mode 100644 index 0000000000..22c267dcfc --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/misc/tst.dofmax.ksh @@ -0,0 +1,97 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# + +let j=8 + +enable() +{ + prog=/var/tmp/dtest.$$.d + err=/var/tmp/dtest.$$.err + + nawk -v nprobes=$1 'BEGIN { \ + for (i = 0; i < nprobes - 1; i++) { \ + printf("dtrace:::BEGIN,\n"); \ + } \ + \ + printf("dtrace:::BEGIN { exit(0); }\n"); \ + }' /dev/null > $prog + + dtrace -qs $prog > /dev/null 2> $err + + if [[ "$?" -eq 0 ]]; then + return 0 + else + if ! grep "DIF program exceeds maximum program size" $err \ + 1> /dev/null 2>&1 ; then + echo "failed to enable $prog: `cat $err`" + exit 1 + fi + + return 1 + fi +} + +# +# First, establish an upper bound +# +let upper=1 + +while enable $upper ; do + let lower=upper + let upper=upper+upper + echo success at $lower, raised to $upper +done + +# +# Now search for the highest value that can be enabled +# +while [[ "$lower" -lt "$upper" ]]; do + let guess=$(((lower + upper) / 2)) + echo "lower is $lower; upper is $upper; guess is $guess\c" + + if enable $guess ; then + if [[ $((upper - lower)) -le 2 ]]; then + let upper=guess + fi + + echo " (success)" + let lower=guess + else + echo " (failure)" + let upper=guess + fi +done + +let expected=10000 + +if [[ "$lower" -lt "$expected" ]]; then + echo "expected support for enablings of at least $expected probes; \c" + echo "found $lower" + exit 1 +fi + +echo "maximum supported enabled probes found to be $lower" +exit 0 + diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh index 692a715303..b16ea53c81 100644 --- a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh @@ -45,10 +45,10 @@ cat > Makefile <<EOF all: main main: main.o - gcc -o main main.o + gcc -m32 -o main main.o main.o: main.c - gcc -c main.c + gcc -m32 -c main.c EOF cat > main.c <<EOF diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh index 03b6003fed..d447c2225f 100644 --- a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh @@ -45,16 +45,16 @@ cat > Makefile <<EOF all: main altlib.so main: main.o - gcc -o main main.o + gcc -m32 -o main main.o main.o: main.c - gcc -c main.c + gcc -m32 -c main.c altlib.so: altlib.o - gcc -shared -o altlib.so altlib.o -lc + gcc -m32 -shared -o altlib.so altlib.o -lc altlib.o: altlib.c - gcc -c altlib.c + gcc -m32 -fPIC -c altlib.c EOF cat > altlib.c <<EOF diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh index 4a74cb050a..dcd4d4111a 100644 --- a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh @@ -46,10 +46,10 @@ cat > Makefile <<EOF all: main main: main.o prov.o - gcc -o main main.o prov.o + gcc -m32 -o main main.o prov.o main.o: main.c prov.h - gcc -c main.c + gcc -m32 -c main.c prov.h: prov.d $dtrace -h -s prov.d diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh index 8d326ad7c1..7030be7394 100644 --- a/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh @@ -46,10 +46,10 @@ cat > Makefile <<EOF all: main altlib.so main: main.o provmain.o - gcc -o main main.o provmain.o + gcc -m32 -o main main.o provmain.o main.o: main.c prov.h - gcc -c main.c + gcc -m32 -c main.c prov.h: prov.d $dtrace -h -s prov.d @@ -58,10 +58,10 @@ provmain.o: prov.d main.o $dtrace -G -32 -o provmain.o -s prov.d main.o altlib.so: altlib.o provalt.o - gcc -shared -o altlib.so altlib.o provalt.o -lc + gcc -m32 -shared -o altlib.so altlib.o provalt.o -lc altlib.o: altlib.c prov.h - gcc -c altlib.c + gcc -m32 -c altlib.c provalt.o: prov.d altlib.o $dtrace -G -32 -o provalt.o -s prov.d altlib.o diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh new file mode 100644 index 0000000000..c5d4abfb59 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +DIR=/var/tmp/dtest.$$ +mkdir $DIR +cd $DIR + +cat > foo.c <<EOF +#include <stdio.h> + +void +foo() +{ + printf("in foo\n"); +} + +void +main() +{ + foo(); +} +EOF + +if ! gcc -m32 -S -o foo.orig.s foo.c ; then + print -u 2 "failed to compile foo in $DIR" + exit 1 +fi + +# +# There's the right way, the wrong way, and the Max Power way! +# +cat foo.orig.s | sed 's/foo/foø/g' > foo.s +gcc -o foo foo.s + +if ! dtrace -n 'pid$target:a.out:f*:entry{printf("probefunc: %s\n", \ + probefunc)}' -qc ./foo ; then + print -u 2 "dtrace failed in $DIR" + exit 1 +fi + +cd +rm -rf $DIR +exit 0 diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh.out b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh.out new file mode 100644 index 0000000000..d575ad8418 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh.out @@ -0,0 +1,3 @@ +in foø +probefunc: foø + diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh new file mode 100644 index 0000000000..d56ef1ca18 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh @@ -0,0 +1,64 @@ +#!/bin/ksh -p +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +DIR=/var/tmp/dtest.$$ +mkdir $DIR +cd $DIR + +cat > foo.c <<EOF +#include <stdlib.h> + +extern void foo(); + +void +main() +{ + foo(); +} +EOF + +cat > libfoo.c <<EOF +#include <stdio.h> + +void +foo() +{ + printf("called foo\n"); +} +EOF + +if ! gcc -m32 -fPIC -shared -o libføo.so libfoo.c -lc ; then + print -u 2 "failed to compile libfoo in $DIR" + exit 1 +fi + + +if ! gcc -m32 -o foo foo.c -lføo -L. ; then + print -u 2 "failed to compile foo in $DIR" + exit 1 +fi + +export LD_LIBRARY_PATH=`pwd` + +if ! dtrace -n 'pid$target:libf*::entry{printf("probemod: %s\n", probemod)}' \ + -qc ./foo ; then + print -u 2 "dtrace failed in $DIR" + exit 1 +fi + +cd +rm -rf $DIR + diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh.out b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh.out new file mode 100644 index 0000000000..0d959f3bf0 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh.out @@ -0,0 +1,3 @@ +called foo +probemod: libføo.so + diff --git a/usr/src/cmd/dtrace/test/tst/common/privs/tst.fds.ksh b/usr/src/cmd/dtrace/test/tst/common/privs/tst.fds.ksh new file mode 100644 index 0000000000..a5aa27137e --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/privs/tst.fds.ksh @@ -0,0 +1,91 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# + +tmpin=/tmp/tst.fds.$$.d +tmpout1=/tmp/tst.fds.$$.out1 +tmpout2=/tmp/tst.fds.$$.out2 + +cat > $tmpin <<EOF +#define DUMPFIELD(fd, fmt, field) \ + errmsg = "could not dump field"; \ + printf("%d: field =fmt\n", fd, fds[fd].field); + +/* + * Note that we are explicitly not looking at fi_mount -- it (by design) does + * not work if not running with kernel permissions. + */ +#define DUMP(fd) \ + DUMPFIELD(fd, %s, fi_name); \ + DUMPFIELD(fd, %s, fi_dirname); \ + DUMPFIELD(fd, %s, fi_pathname); \ + DUMPFIELD(fd, %d, fi_offset); \ + DUMPFIELD(fd, %s, fi_fs); \ + DUMPFIELD(fd, %o, fi_oflags); + +BEGIN +{ + DUMP(0); + DUMP(1); + DUMP(2); + DUMP(3); + DUMP(4); + exit(0); +} + +ERROR +{ + printf("error: %s\n", errmsg); + exit(1); +} +EOF + +# +# First, with all privs +# +/usr/sbin/dtrace -q -Cs /dev/stdin < $tmpin > $tmpout2 +mv $tmpout2 $tmpout1 + +# +# And now with only dtrace_proc and dtrace_user -- the output should be +# identical. +# +ppriv -s A=basic,dtrace_proc,dtrace_user $$ + +/usr/sbin/dtrace -q -Cs /dev/stdin < $tmpin > $tmpout2 + +echo ">>> $tmpout1" +cat $tmpout1 + +echo ">>> $tmpout2" +cat $tmpout2 + +rval=0 + +if ! cmp $tmpout1 $tmpout2 ; then + rval=1 +fi + +rm $tmpout1 $tmpout2 $tmpin +exit $rval diff --git a/usr/src/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh b/usr/src/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh index ae4934cdeb..da9bb4c6c6 100644 --- a/usr/src/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh @@ -22,8 +22,8 @@ # # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright (c) 2012, Joyent, Inc. All rights reserved. # -#ident "%Z%%M% %I% %E% SMI" ppriv -s A=basic,dtrace_proc,dtrace_user $$ @@ -31,7 +31,7 @@ ppriv -s A=basic,dtrace_proc,dtrace_user $$ BEGIN { errorcount = 0; - expected_errorcount = 23; + expected_errorcount = 27; } BEGIN { trace(mutex_owned(&`pidlock)); } @@ -55,6 +55,8 @@ BEGIN { trace(strtok(`initname, "/")); } BEGIN { trace(strtok(NULL, "/")); } BEGIN { trace(strtok("foo/bar", `initname)); } BEGIN { trace(strtok(NULL, `initname)); } +BEGIN { trace(strtoll(`initname)); } +BEGIN { trace(strtoll(`initname, 10)); } BEGIN { trace(substr(`initname, 2, 3)); } BEGIN { trace(ddi_pathname(`top_devinfo, 1)); } @@ -63,6 +65,9 @@ BEGIN { trace(strjoin("foo", `initname)); } BEGIN { trace(dirname(`initname)); } BEGIN { trace(cleanpath(`initname)); } +BEGIN { j = "{\"/sbin/init\":\"uh oh\"}"; trace(json(j, `initname)); } +BEGIN { trace(json(`initname, "x")); } + ERROR { errorcount++; } diff --git a/usr/src/cmd/dtrace/test/tst/common/privs/tst.getf.ksh b/usr/src/cmd/dtrace/test/tst/common/privs/tst.getf.ksh new file mode 100644 index 0000000000..8f4d65dfd5 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/privs/tst.getf.ksh @@ -0,0 +1,98 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# + +ppriv -s A=basic,dtrace_proc,dtrace_user $$ + +/usr/sbin/dtrace -q -Cs /dev/stdin <<EOF + +#define CANREAD(field) \ + BEGIN { this->fp = getf(0); errmsg = "can't read field"; \ + printf("field: "); trace(this->fp->field); printf("\n"); } + +#define CANTREAD(field) \ + BEGIN { errmsg = ""; this->fp = getf(0); trace(this->fp->field); \ + printf("\nable to successfully read field!"); exit(1); } + +CANREAD(f_flag) +CANREAD(f_flag2) +CANREAD(f_vnode) +CANREAD(f_offset) +CANREAD(f_cred) +CANREAD(f_audit_data) +CANREAD(f_count) + +/* + * We can potentially read parts of our cred, but we can't dereference + * through cr_zone. + */ +CANTREAD(f_cred->cr_zone->zone_id) + +CANREAD(f_vnode->v_path) +CANREAD(f_vnode->v_op) +CANREAD(f_vnode->v_op->vnop_name) + +CANTREAD(f_vnode->v_flag) +CANTREAD(f_vnode->v_count) +CANTREAD(f_vnode->v_pages) +CANTREAD(f_vnode->v_type) +CANTREAD(f_vnode->v_vfsmountedhere) +CANTREAD(f_vnode->v_op->vop_open) + +BEGIN +{ + errmsg = ""; + this->fp = getf(0); + this->fp2 = getf(1); + + trace(this->fp->f_vnode); + printf("\nable to successfully read this->fp!"); + exit(1); +} + +BEGIN +{ + errmsg = ""; + this->fp = getf(0); +} + +BEGIN +{ + trace(this->fp->f_vnode); + printf("\nable to successfully read this->fp from prior clause!"); +} + +BEGIN +{ + exit(0); +} + +ERROR +/errmsg != ""/ +{ + printf("fatal error: %s", errmsg); + exit(1); +} + +EOF diff --git a/usr/src/cmd/dtrace/test/tst/common/privs/tst.procpriv.ksh b/usr/src/cmd/dtrace/test/tst/common/privs/tst.procpriv.ksh new file mode 100755 index 0000000000..6227a057da --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/privs/tst.procpriv.ksh @@ -0,0 +1,138 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# + +ppriv -s A=basic,dtrace_proc,dtrace_user $$ + +# +# When we have dtrace_proc (but lack dtrace_kernel), we expect to be able to +# read certain curpsinfo/curlwpsinfo/curcpu fields even though they require +# reading in-kernel state. However, there are other fields in these translated +# structures that we know we shouldn't be able to read, as they require reading +# in-kernel state that we cannot read with only dtrace_proc. Finally, there +# are a few fields that we may or may not be able to read depending on the +# specifics of context. This test therefore asserts that we can read what we +# think we should be able to, that we can't read what we think we shouldn't be +# able to, and (for purposes of completeness) that we are indifferent about +# what we cannot assert one way or the other. +# +/usr/sbin/dtrace -q -Cs /dev/stdin <<EOF + +#define CANREAD(what, field) \ + BEGIN { errmsg = "can't read field from what"; printf("field: "); \ + trace(what->field); printf("\n"); } + +#define CANTREAD(what, field) \ + BEGIN { errmsg = ""; trace(what->field); \ + printf("\nable to successfully read field from what!"); exit(1); } + +#define MIGHTREAD(what, field) \ + BEGIN { errmsg = ""; printf("field: "); trace(what->field); printf("\n"); } + +#define CANREADVAR(vname) \ + BEGIN { errmsg = "can't read vname"; printf("vname: "); \ + trace(vname); printf("\n"); } + +#define CANTREADVAR(vname) \ + BEGIN { errmsg = ""; trace(vname); \ + printf("\nable to successfully read vname!"); exit(1); } + +#define MIGHTREADVAR(vname) \ + BEGIN { errmsg = ""; printf("vname: "); trace(vname); printf("\n"); } + +CANREAD(curpsinfo, pr_pid) +CANREAD(curpsinfo, pr_nlwp) +CANREAD(curpsinfo, pr_ppid) +CANREAD(curpsinfo, pr_uid) +CANREAD(curpsinfo, pr_euid) +CANREAD(curpsinfo, pr_gid) +CANREAD(curpsinfo, pr_egid) +CANREAD(curpsinfo, pr_addr) +CANREAD(curpsinfo, pr_start) +CANREAD(curpsinfo, pr_fname) +CANREAD(curpsinfo, pr_psargs) +CANREAD(curpsinfo, pr_argc) +CANREAD(curpsinfo, pr_argv) +CANREAD(curpsinfo, pr_envp) +CANREAD(curpsinfo, pr_dmodel) + +/* + * If our p_pgidp points to the same pid structure as our p_pidp, we will + * be able to read pr_pgid -- but we won't if not. + */ +MIGHTREAD(curpsinfo, pr_pgid) + +CANTREAD(curpsinfo, pr_sid) +CANTREAD(curpsinfo, pr_ttydev) +CANTREAD(curpsinfo, pr_projid) +CANTREAD(curpsinfo, pr_zoneid) +CANTREAD(curpsinfo, pr_contract) + +CANREAD(curlwpsinfo, pr_flag) +CANREAD(curlwpsinfo, pr_lwpid) +CANREAD(curlwpsinfo, pr_addr) +CANREAD(curlwpsinfo, pr_wchan) +CANREAD(curlwpsinfo, pr_stype) +CANREAD(curlwpsinfo, pr_state) +CANREAD(curlwpsinfo, pr_sname) +CANREAD(curlwpsinfo, pr_syscall) +CANREAD(curlwpsinfo, pr_pri) +CANREAD(curlwpsinfo, pr_onpro) +CANREAD(curlwpsinfo, pr_bindpro) +CANREAD(curlwpsinfo, pr_bindpset) + +CANTREAD(curlwpsinfo, pr_clname) +CANTREAD(curlwpsinfo, pr_lgrp) + +CANREAD(curcpu, cpu_id) + +CANTREAD(curcpu, cpu_pset) +CANTREAD(curcpu, cpu_chip) +CANTREAD(curcpu, cpu_lgrp) +CANTREAD(curcpu, cpu_info) + +/* + * We cannot assert one thing or another about the variable "root": for those + * with only dtrace_proc, it will be readable in the global but not readable in + * the non-global. + */ +MIGHTREADVAR(root) + +CANREADVAR(cpu) +CANTREADVAR(pset) +CANTREADVAR(cwd) +CANTREADVAR(chip) +CANTREADVAR(lgrp) + +BEGIN +{ + exit(0); +} + +ERROR +/errmsg != ""/ +{ + printf("fatal error: %s", errmsg); + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/privs/tst.providers.ksh b/usr/src/cmd/dtrace/test/tst/common/privs/tst.providers.ksh new file mode 100644 index 0000000000..94c3722f78 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/privs/tst.providers.ksh @@ -0,0 +1,126 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# + +# +# First, make sure that we can successfully enable the io provider +# +if ! dtrace -P io -n BEGIN'{exit(0)}' > /dev/null 2>&1 ; then + echo failed to enable io provider with full privs + exit 1 +fi + +ppriv -s A=basic,dtrace_proc,dtrace_user $$ + +# +# Now make sure that we cannot enable the io provider with reduced privs +# +if ! dtrace -x errtags -P io -n BEGIN'{exit(1)}' 2>&1 | \ + grep D_PDESC_ZERO > /dev/null 2>&1 ; then + echo successfully enabled the io provider with reduced privs + exit 1 +fi + +# +# Keeping our reduced privs, we want to assure that we can see every provider +# that we think we should be able to see -- and that we can see curpsinfo +# state but can't otherwise see arguments. +# +/usr/sbin/dtrace -wq -Cs /dev/stdin <<EOF + +int seen[string]; +int err; + +#define CANENABLE(provider) \ +provider::: \ +/err == 0 && progenyof(\$pid) && !seen["provider"]/ \ +{ \ + trace(arg0); \ + printf("\nsuccessful trace of arg0 in %s:%s:%s:%s\n", \ + probeprov, probemod, probefunc, probename); \ + exit(++err); \ +} \ + \ +provider::: \ +/progenyof(\$pid)/ \ +{ \ + seen["provider"]++; \ +} \ + \ +provider::: \ +/progenyof(\$pid)/ \ +{ \ + errstr = "provider"; \ + this->ignore = stringof(curpsinfo->pr_psargs); \ + errstr = ""; \ +} \ + \ +END \ +/err == 0 && !seen["provider"]/ \ +{ \ + printf("no probes from provider\n"); \ + exit(++err); \ +} \ + \ +END \ +/err == 0/ \ +{ \ + printf("saw %d probes from provider\n", seen["provider"]); \ +} + +CANENABLE(proc) +CANENABLE(sched) +CANENABLE(vminfo) +CANENABLE(sysinfo) + +BEGIN +{ + /* + * We'll kick off a system of a do-nothing command -- which should be + * enough to kick proc, sched, vminfo and sysinfo probes. + */ + system("echo > /dev/null"); +} + +ERROR +/err == 0 && errstr != ""/ +{ + printf("fatal error: couldn't read curpsinfo->pr_psargs in "); + printf("%s-provided probe\n", errstr); + exit(++err); +} + +proc:::exit +/progenyof(\$pid)/ +{ + exit(0); +} + +tick-10ms +/i++ > 500/ +{ + printf("exit probe did not seem to fire\n"); + exit(++err); +} +EOF diff --git a/usr/src/cmd/dtrace/test/tst/common/strtoll/err.BaseTooLarge.d b/usr/src/cmd/dtrace/test/tst/common/strtoll/err.BaseTooLarge.d new file mode 100644 index 0000000000..4d6b5af75b --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/strtoll/err.BaseTooLarge.d @@ -0,0 +1,35 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + +/* + * ASSERTION: + * The largest base we will accept is Base 36 -- i.e. using all of 0-9 and + * A-Z as numerals. + * + * SECTION: Actions and Subroutines/strtoll() + */ + +#pragma D option quiet + +BEGIN +{ + printf("%d\n", strtoll("0", 37)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/strtoll/err.BaseTooSmall.d b/usr/src/cmd/dtrace/test/tst/common/strtoll/err.BaseTooSmall.d new file mode 100644 index 0000000000..de56b50e9e --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/strtoll/err.BaseTooSmall.d @@ -0,0 +1,34 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + +/* + * ASSERTION: + * The smallest base we will accept is Base 2. + * + * SECTION: Actions and Subroutines/strtoll() + */ + +#pragma D option quiet + +BEGIN +{ + printf("%d\n", strtoll("0", 1)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/strtoll/tst.strtoll.d b/usr/src/cmd/dtrace/test/tst/common/strtoll/tst.strtoll.d new file mode 100644 index 0000000000..0b1812a53c --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/strtoll/tst.strtoll.d @@ -0,0 +1,66 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + +/* + * ASSERTION: + * Test the strtoll() subroutine. + * + * SECTION: Actions and Subroutines/strtoll() + */ + +#pragma D option quiet + +BEGIN +{ + + /* minimum base (2) and maximum base (36): */ + printf("%d\n", strtoll("0", 2)); + printf("%d\n", strtoll("1", 36)); + + /* simple tests: */ + printf("%d\n", strtoll("0x20", 16)); + printf("%d\n", strtoll("-32", 10)); + printf("%d\n", strtoll("010", 8)); + printf("%d\n", strtoll("101010", 2)); + + /* INT64_MIN and INT64_MAX: */ + printf("%d\n", strtoll("9223372036854775807")); + printf("%d\n", strtoll("-9223372036854775808")); + printf("%d\n", strtoll("0777777777777777777777", 8)); + printf("%d\n", strtoll("-01000000000000000000000", 8)); + + /* wrapping: */ + printf("%d\n", strtoll("1000000000000000000000", 8)); + printf("%d\n", strtoll("-1000000000000000000001", 8)); + + /* hex without prefix: */ + printf("%d\n", strtoll("baddcafe", 16)); + + /* stopping at first out-of-base character: */ + printf("%d\n", strtoll("12j", 10)); + printf("%d\n", strtoll("102", 2)); + + /* base 36: */ + printf("%d\n", strtoll("-0DTrace4EverZ", 36)); + + /* base 10 is assumed: */ + printf("%d\n", strtoll("1985")); + printf("%d\n", strtoll("-2012")); + + /* empty string: */ + printf("%d\n", strtoll("")); + + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/strtoll/tst.strtoll.d.out b/usr/src/cmd/dtrace/test/tst/common/strtoll/tst.strtoll.d.out new file mode 100644 index 0000000000..d12eb9c197 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/strtoll/tst.strtoll.d.out @@ -0,0 +1,20 @@ +0 +1 +32 +-32 +8 +42 +9223372036854775807 +-9223372036854775808 +9223372036854775807 +-9223372036854775808 +-9223372036854775808 +9223372036854775807 +3135097598 +12 +2 +-1819882045752187535 +1985 +-2012 +0 + diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid.d b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid.d new file mode 100644 index 0000000000..4865d81ee1 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid.d @@ -0,0 +1,21 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + trace((pidfoo`int)0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid2.d b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid2.d new file mode 100644 index 0000000000..bafed12172 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid2.d @@ -0,0 +1,21 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + trace((pid8foo`int)0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid3.d b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid3.d new file mode 100644 index 0000000000..fb9443a828 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidpid3.d @@ -0,0 +1,21 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2013 Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + trace((pid0`int)0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh new file mode 100644 index 0000000000..978cde3cf0 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh @@ -0,0 +1,34 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# While it's hard to be completely certain that a type of the name we want +# doesn't exist, we're going to try to pick a name which is rather unique. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="season_8_mountain_of_madness_t" +pid=$$ + +rc=`$dtrace -n "BEGIN{ trace(pid$pid`$t)0); }"` + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh new file mode 100644 index 0000000000..e64ed526ed --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh @@ -0,0 +1,35 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# While it's hard to be completely certain that a type of the name we want +# doesn't exist, we're going to try to pick a name which is rather +# unique. This time we're also going to use the pid$target alias. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="season_8_mountain_of_madness_t" +pid=$$ + +rc=`$dtrace -n "BEGIN{ trace(pid`$t)0); }"` -p $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh new file mode 100644 index 0000000000..d987c8da7a --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh @@ -0,0 +1,90 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# This test is purposefully using a 64-bit DTrace and thus 64-bit types +# when compared with a 32-bit process. This test uses the userland +# keyword and so the implicit copyin should access illegal memory and +# thus exit. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="zelda_info_t" +exe="tst.chasestrings.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -64 -qs /dev/stdin <<EOF +typedef struct info { + char *zi_gamename; + int zi_ndungeons; + char *zi_villain; + int zi_haszelda; +} info_t; + +pid$pid::has_princess:entry +/next == 0/ +{ + this->t = (userland info_t *)arg0; + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(this->t->zi_gamename), this->t->zi_ndungeons, + stringof(this->t->zi_villain), this->t->zi_haszelda); + next = 1; +} + +pid$pid::has_dungeons:entry +/next == 1/ +{ + this->t = (userland info_t *)arg0; + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(this->t->zi_gamename), this->t->zi_ndungeons, + stringof(this->t->zi_villain), this->t->zi_haszelda); + next = 2; +} + +pid$pid::has_villain:entry +/next == 2/ +{ + this->t = (userland info_t *)arg0; + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(this->t->zi_gamename), this->t->zi_ndungeons, + stringof(this->t->zi_villain), this->t->zi_haszelda); + exit(0); +} + +ERROR +{ + exit(1); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.aouttype.c b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.aouttype.c new file mode 100644 index 0000000000..a4d25f8ca8 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.aouttype.c @@ -0,0 +1,46 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2013 (c) Joyent, Inc. All rights reserved. + */ + +/* + * This test tries to make sure that we have CTF data for a type that only this + * binary would reasonably have. In this case, the + * season_7_lisa_the_vegetarian_t. + */ +#include <unistd.h> + +typedef struct season_7_lisa_the_vegetarian { + int fr_salad; +} season_7_lisa_the_vegetarian_t; + +int +sleeper(season_7_lisa_the_vegetarian_t *lp) +{ + for (;;) { + sleep(lp->fr_salad); + } + /*NOTREACHED*/ + return (0); +} + +int +main(void) +{ + season_7_lisa_the_vegetarian_t l; + l.fr_salad = 100; + + sleeper(&l); + + return (0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh new file mode 100644 index 0000000000..151a93676d --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh @@ -0,0 +1,44 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# Lookup a type that is inside a.out. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="season_7_lisa_the_vegetrian_t *" +exe="tst.aouttype.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"` + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.c b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.c new file mode 100644 index 0000000000..595a7cb6c5 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.c @@ -0,0 +1,79 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2013 (c) Joyent, Inc. All rights reserved. + */ + +/* + * This test takes data from the current binary which is basically running in a + * loop between two functions and our goal is to have two unique types that they + * contain which we can print. + */ + +#include <unistd.h> + +typedef struct zelda_info { + char *zi_gamename; + int zi_ndungeons; + char *zi_villain; + int zi_haszelda; +} zelda_info_t; + +static int +has_princess(zelda_info_t *z) +{ + return (z->zi_haszelda); +} + +static int +has_dungeons(zelda_info_t *z) +{ + return (z->zi_ndungeons != 0); +} + +static const char * +has_villain(zelda_info_t *z) +{ + return (z->zi_villain); +} + +int +main(void) +{ + zelda_info_t oot; + zelda_info_t la; + zelda_info_t lttp; + + oot.zi_gamename = "Ocarina of Time"; + oot.zi_ndungeons = 10; + oot.zi_villain = "Ganondorf"; + oot.zi_haszelda = 1; + + la.zi_gamename = "Link's Awakening"; + la.zi_ndungeons = 9; + la.zi_villain = "Nightmare"; + la.zi_haszelda = 0; + + lttp.zi_gamename = "A Link to the Past"; + lttp.zi_ndungeons = 12; + lttp.zi_villain = "Ganon"; + lttp.zi_haszelda = 1; + + for (;;) { + (void) has_princess(&oot); + (void) has_dungeons(&la); + (void) has_villain(<tp); + sleep(1); + } + + return (0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh new file mode 100644 index 0000000000..25028460db --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh @@ -0,0 +1,76 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# This test is checking that we can read members and that pointers inside +# members point to valid data that is intelligible, eg. strings. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="zelda_info_t" +exe="tst.chasestrings.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -qs /dev/stdin <<EOF +pid$pid::has_princess:entry +/next == 0/ +{ + this->t = (pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t))); + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + copyinstr((uintptr_t)this->t->zi_gamename), this->t->zi_ndungeons, + copyinstr((uintptr_t)this->t->zi_villain), this->t->zi_haszelda); + next = 1; +} + +pid$pid::has_dungeons:entry +/next == 1/ +{ + this->t = (pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t))); + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + copyinstr((uintptr_t)this->t->zi_gamename), this->t->zi_ndungeons, + copyinstr((uintptr_t)this->t->zi_villain), this->t->zi_haszelda); + next = 2; +} + +pid$pid::has_villain:entry +/next == 2/ +{ + this->t = (pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t))); + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + copyinstr((uintptr_t)this->t->zi_gamename), this->t->zi_ndungeons, + copyinstr((uintptr_t)this->t->zi_villain), this->t->zi_haszelda); + exit(0); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh.out b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh.out new file mode 100644 index 0000000000..219e406e61 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh.out @@ -0,0 +1,4 @@ +game: Ocarina of Time, dungeon: 10, villain: Ganondorf, zelda: 1 +game: Link's Awakening, dungeon: 9, villain: Nightmare, zelda: 0 +game: A Link to the Past, dungeon: 12, villain: Ganon, zelda: 1 + diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.libtype.c b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.libtype.c new file mode 100644 index 0000000000..916a5b51b9 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.libtype.c @@ -0,0 +1,29 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2013 (c) Joyent, Inc. All rights reserved. + */ + +/* + * We're linked against libc which has types, though we do not. + */ +#include <unistd.h> + +int +main(void) +{ + for (;;) { + sleep(1000); + } + /*NOTREACHED*/ + return (0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh new file mode 100644 index 0000000000..af7c6c8fe1 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh @@ -0,0 +1,45 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# Here we want to make sure that the program in question does not have ctf data +# in its a.out; however, we can get types out of a linked libc. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="int" +exe="tst.libtype.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -eq 0 ]]; then + echo "CTF exists in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"` + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.linkmap.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.linkmap.ksh new file mode 100644 index 0000000000..f767def53d --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.linkmap.ksh @@ -0,0 +1,44 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# We should be able to see both strstr from libc and from ld on an +# alternate linkmap. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -q -p $$ -s /dev/stdin <<EOF +pid\$target:LM1\`ld.so.1:strstr:entry, +pid\$target:libc.so.1:strstr:entry +{ + exit (0); +} + +BEGIN +{ + exit (0); +} +EOF +rc=$? + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh new file mode 100644 index 0000000000..febb015918 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh @@ -0,0 +1,69 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# Use print() on userland CTF types and verify we get the data we expect. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="final_fantasy_info_t" +exe="tst.printtype.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -qs /dev/stdin <<EOF +pid$pid::ff_getgameid:entry +/next == 0/ +{ + print(*args[0]); + printf("\n"); + next = 1; +} + +pid$pid::ff_getpartysize:entry +/next == 1/ +{ + print(*args[0]); + printf("\n"); + next = 2; +} + +pid$pid::ff_getsummons:entry +/next == 2/ +{ + print(*args[0]); + printf("\n"); + exit(0); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh new file mode 100644 index 0000000000..7398dc41d9 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh @@ -0,0 +1,70 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# Use print() on userland CTF types and verify we get the data we +# expect. This time, use $target to make sure that path works correctly. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="final_fantasy_info_t" +exe="tst.printtype.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -p $pid -qs /dev/stdin <<EOF +pid\$target::ff_getgameid:entry +/next == 0/ +{ + print(*args[0]); + printf("\n"); + next = 1; +} + +pid\$target::ff_getpartysize:entry +/next == 1/ +{ + print(*args[0]); + printf("\n"); + next = 2; +} + +pid\$target::ff_getsummons:entry +/next == 2/ +{ + print(*args[0]); + printf("\n"); + exit(0); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.c b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.c new file mode 100644 index 0000000000..6c27593e97 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.c @@ -0,0 +1,72 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2013 (c) Joyent, Inc. All rights reserved. + */ + +/* + * The point of this is to use print() on various functions to make sure that we + * can print basic structures. Note that we purposefully are making sure that + * there are no pointers here. + */ +#include <unistd.h> + +typedef struct final_fantasy_info { + int ff_gameid; + int ff_partysize; + int ff_hassummons; +} final_fantasy_info_t; + +static int +ff_getgameid(final_fantasy_info_t *f) +{ + return (0); +} + +static int +ff_getpartysize(final_fantasy_info_t *f) +{ + return (0); +} + +static int +ff_getsummons(final_fantasy_info_t *f) +{ + return (0); +} + +int +main(void) +{ + final_fantasy_info_t ffiii, ffx, ffi; + + ffi.ff_gameid = 1; + ffi.ff_partysize = 4; + ffi.ff_hassummons = 0; + + ffiii.ff_gameid = 6; + ffiii.ff_partysize = 4; + ffiii.ff_hassummons = 1; + + ffx.ff_gameid = 10; + ffx.ff_partysize = 3; + ffx.ff_hassummons = 1; + + for (;;) { + ff_getgameid(&ffi); + ff_getpartysize(&ffx); + ff_getsummons(&ffiii); + sleep(1); + } + /*NOTREACHED*/ + return (0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh new file mode 100644 index 0000000000..dfc1535829 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh @@ -0,0 +1,69 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# Use print() on userland CTF types and verify we get the data we expect. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="final_fantasy_info_t" +exe="tst.printtype.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -qs /dev/stdin <<EOF +pid$pid::ff_getgameid:entry +/next == 0/ +{ + print(*(pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t)))); + printf("\n"); + next = 1; +} + +pid$pid::ff_getpartysize:entry +/next == 1/ +{ + print(*(pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t)))); + printf("\n"); + next = 2; +} + +pid$pid::ff_getsummons:entry +/next == 2/ +{ + print(*(pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t)))); + printf("\n"); + exit(0); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh.out b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh.out new file mode 100644 index 0000000000..1770ba2354 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh.out @@ -0,0 +1,16 @@ +final_fantasy_info_t { + int ff_gameid = 0x1 + int ff_partysize = 0x4 + int ff_hassummons = 0 +} +final_fantasy_info_t { + int ff_gameid = 0xa + int ff_partysize = 0x3 + int ff_hassummons = 0x1 +} +final_fantasy_info_t { + int ff_gameid = 0x6 + int ff_partysize = 0x4 + int ff_hassummons = 0x1 +} + diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh new file mode 100644 index 0000000000..025d4a8c02 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh @@ -0,0 +1,70 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# Use print() on userland CTF types and verify we get the data we +# expect. Use the pid` alias for $target. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="final_fantasy_info_t" +exe="tst.printtype.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -p $pid -qs /dev/stdin <<EOF +pid\$target::ff_getgameid:entry +/next == 0/ +{ + print(*(pid\`$t *)(copyin(arg0, sizeof (pid\`$t)))); + printf("\n"); + next = 1; +} + +pid\$target::ff_getpartysize:entry +/next == 1/ +{ + print(*(pid\`$t *)(copyin(arg0, sizeof (pid\`$t)))); + printf("\n"); + next = 2; +} + +pid\$target::ff_getsummons:entry +/next == 2/ +{ + print(*(pid\`$t *)(copyin(arg0, sizeof (pid\`$t)))); + printf("\n"); + exit(0); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh new file mode 100644 index 0000000000..58811ff6fb --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh @@ -0,0 +1,83 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# Simple test that if we manually use the userland keyword that it +# works. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +t="zelda_info_t" +exe="tst.chasestrings.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -32 -qs /dev/stdin <<EOF +typedef struct info { + char *zi_gamename; + int zi_ndungeons; + char *zi_villain; + int zi_haszelda; +} info_t; + +pid$pid::has_princess:entry +/next == 0/ +{ + this->t = (userland info_t *)arg0; + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(this->t->zi_gamename), this->t->zi_ndungeons, + stringof(this->t->zi_villain), this->t->zi_haszelda); + next = 1; +} + +pid$pid::has_dungeons:entry +/next == 1/ +{ + this->t = (userland info_t *)arg0; + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(this->t->zi_gamename), this->t->zi_ndungeons, + stringof(this->t->zi_villain), this->t->zi_haszelda); + next = 2; +} + +pid$pid::has_villain:entry +/next == 2/ +{ + this->t = (userland info_t *)arg0; + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(this->t->zi_gamename), this->t->zi_ndungeons, + stringof(this->t->zi_villain), this->t->zi_haszelda); + exit(0); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh.out b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh.out new file mode 100644 index 0000000000..219e406e61 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh.out @@ -0,0 +1,4 @@ +game: Ocarina of Time, dungeon: 10, villain: Ganondorf, zelda: 1 +game: Link's Awakening, dungeon: 9, villain: Nightmare, zelda: 0 +game: A Link to the Past, dungeon: 12, villain: Ganon, zelda: 1 + diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh new file mode 100644 index 0000000000..79d79de8ae --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh @@ -0,0 +1,72 @@ +#! /usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2013 Joyent, Inc. All rights reserved. +# + +# +# This test is checking that we can read members and that pointers inside +# members point to valid data that is intelligible, eg. strings. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +exe="tst.chasestrings.exe" + +elfdump "./$exe" | grep -q '.SUNW_ctf' +if [[ $? -ne 0 ]]; then + echo "CTF does not exist in $exe, that's a bug" >&2 + exit 1 +fi + +./$exe & +pid=$! + +$dtrace -qs /dev/stdin <<EOF +pid$pid::has_princess:entry +/next == 0/ +{ + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(args[0]->zi_gamename), args[0]->zi_ndungeons, + stringof(args[0]->zi_villain), args[0]->zi_haszelda); + next = 1; +} + +pid$pid::has_dungeons:entry +/next == 1/ +{ + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(args[0]->zi_gamename), args[0]->zi_ndungeons, + stringof(args[0]->zi_villain), args[0]->zi_haszelda); + next = 2; +} + +pid$pid::has_villain:entry +/next == 2/ +{ + printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", + stringof(args[0]->zi_gamename), args[0]->zi_ndungeons, + stringof(args[0]->zi_villain), args[0]->zi_haszelda); + exit(0); +} +EOF +rc=$? + +kill -9 $pid + +exit $rc diff --git a/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh.out b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh.out new file mode 100644 index 0000000000..219e406e61 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh.out @@ -0,0 +1,4 @@ +game: Ocarina of Time, dungeon: 10, villain: Ganondorf, zelda: 1 +game: Link's Awakening, dungeon: 9, villain: Nightmare, zelda: 0 +game: A Link to the Past, dungeon: 12, villain: Ganon, zelda: 1 + diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh index c9bcb03e63..3480d34862 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh @@ -60,10 +60,10 @@ cat > Makefile <<EOF all: main main: main.o prov.o - gcc -o main main.o prov.o + gcc -m32 -o main main.o prov.o main.o: main.c prov.h - gcc -c main.c + gcc -m32 -c main.c prov.h: prov.d $dtrace -h -s prov.d diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh index ade3a54d48..da1b2b3e28 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh @@ -45,17 +45,17 @@ cat > Makefile <<EOF all: main livelib.so deadlib.so main: main.o prov.o - gcc -o main main.o + gcc -m32 -o main main.o main.o: main.c - gcc -c main.c + gcc -m32 -c main.c livelib.so: livelib.o prov.o - gcc -shared -o livelib.so livelib.o prov.o -lc + gcc -m32 -shared -o livelib.so livelib.o prov.o -lc livelib.o: livelib.c prov.h - gcc -c livelib.c + gcc -m32 -fPIC -c livelib.c prov.o: livelib.o prov.d $dtrace -G -s prov.d livelib.o @@ -65,10 +65,10 @@ prov.h: prov.d deadlib.so: deadlib.o - gcc -shared -o deadlib.so deadlib.o -lc + gcc -m32 -shared -o deadlib.so deadlib.o -lc deadlib.o: deadlib.c - gcc -c deadlib.c + gcc -m32 -fPIC -c deadlib.c clean: rm -f main.o livelib.o prov.o prov.h deadlib.o diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh index 692c8d9b5c..328db12cc1 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh @@ -40,17 +40,17 @@ cat > Makefile <<EOF all: main livelib.so deadlib.so main: main.o prov.o - gcc -o main main.o + gcc -m32 -o main main.o main.o: main.c - gcc -c main.c + gcc -m32 -c main.c livelib.so: livelib.o prov.o - gcc -shared -o livelib.so livelib.o prov.o -lc + gcc -m32 -shared -o livelib.so livelib.o prov.o -lc livelib.o: livelib.c prov.h - gcc -c livelib.c + gcc -m32 -fPIC -c livelib.c prov.o: livelib.o prov.d $dtrace -G -s prov.d livelib.o @@ -60,10 +60,10 @@ prov.h: prov.d deadlib.so: deadlib.o - gcc -shared -o deadlib.so deadlib.o -lc + gcc -m32 -shared -o deadlib.so deadlib.o -lc deadlib.o: deadlib.c - gcc -c deadlib.c + gcc -m32 -fPIC -c deadlib.c clean: rm -f main.o livelib.o prov.o prov.h deadlib.o diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh index e950eb4af2..73400cda99 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh @@ -45,17 +45,17 @@ cat > Makefile <<EOF all: main livelib.so deadlib.so main: main.o prov.o - gcc -o main main.o + gcc -m32 -o main main.o main.o: main.c - gcc -c main.c + gcc -m32 -c main.c livelib.so: livelib.o prov.o - gcc -shared -o livelib.so livelib.o prov.o -lc + gcc -m32 -shared -o livelib.so livelib.o prov.o -lc livelib.o: livelib.c prov.h - gcc -c livelib.c + gcc -m32 -fPIC -c livelib.c prov.o: livelib.o prov.d $dtrace -G -s prov.d livelib.o @@ -65,10 +65,10 @@ prov.h: prov.d deadlib.so: deadlib.o - gcc -shared -o deadlib.so deadlib.o -lc + gcc -m32 -shared -o deadlib.so deadlib.o -lc deadlib.o: deadlib.c - gcc -c deadlib.c + gcc -m32 -fPIC -c deadlib.c clean: rm -f main.o livelib.o prov.o prov.h deadlib.o diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh index 3d50443370..307b8a02a0 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh @@ -71,7 +71,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -81,7 +81,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh index 47ea79f376..abf037f92f 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh @@ -60,7 +60,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -70,7 +70,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh index 9b71ac2637..72efdf1a30 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh @@ -76,7 +76,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -86,7 +86,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh index 79e8266192..630f4c9342 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh @@ -69,7 +69,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -79,7 +79,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh index 1264e3ffb6..9449313483 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh @@ -70,7 +70,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -80,7 +80,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.header.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.header.ksh index f4679bc3f8..9fc5838db2 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.header.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.header.ksh @@ -64,7 +64,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -74,7 +74,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh index bbe1a4acc9..2f659a20d1 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh @@ -61,7 +61,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -71,7 +71,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh index 35d97afc48..f740ae0b16 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh @@ -63,7 +63,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -73,7 +73,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh index 852f5a0b3c..515d5d50c7 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh @@ -64,7 +64,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -74,7 +74,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh index 338dcdf03e..a2472b0d14 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh @@ -51,7 +51,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -61,7 +61,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh index a2e5edee38..9c12f60e1f 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh @@ -51,7 +51,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -61,7 +61,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh index a1e939c883..512595d012 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh @@ -61,7 +61,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -71,7 +71,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh index f18c585ef6..80156de173 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh @@ -51,7 +51,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -61,7 +61,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh index 2f0ee33f1e..76d9391179 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh @@ -51,7 +51,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -61,7 +61,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static.ksh index 85b0e553c4..b646cf067e 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static.ksh @@ -62,7 +62,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -72,7 +72,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh index 07b765702c..162074501c 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh @@ -66,7 +66,7 @@ provider test_prov { }; EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -82,7 +82,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create final DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.user.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.user.ksh index f52c1c351e..0b28060600 100644 --- a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.user.ksh +++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.user.ksh @@ -61,7 +61,7 @@ main(int argc, char **argv) } EOF -gcc -c test.c +gcc -m32 -c test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 @@ -71,7 +71,7 @@ if [ $? -ne 0 ]; then print -u2 "failed to create DOF" exit 1 fi -gcc -o test test.o prov.o +gcc -m32 -o test test.o prov.o if [ $? -ne 0 ]; then print -u2 "failed to link final executable" exit 1 diff --git a/usr/src/cmd/dtrace/test/tst/common/ustack/tst.unpriv.c b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.unpriv.c new file mode 100644 index 0000000000..43ba244444 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.unpriv.c @@ -0,0 +1,7 @@ +int +main(int argc, char *argv[]) +{ + for (;;) + ; + return (0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/ustack/tst.unpriv.ksh b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.unpriv.ksh new file mode 100644 index 0000000000..26c430bff7 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/ustack/tst.unpriv.ksh @@ -0,0 +1,68 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2011, Joyent, Inc. All rights reserved. +# + +ppriv -s A=basic,dtrace_user,dtrace_proc $$ + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +file=out.$$ +dtrace=$1 + +rm -f $file + +dir=`/bin/dirname $tst` + +$dtrace -o $file -c $dir/tst.unpriv.exe -ws /dev/stdin <<EOF + profile-1234hz + /pid == \$target/ + { + @[ustack(20, 8192)] = count(); + } + + tick-1s + { + secs++; + } + + tick-1s + /secs > 10/ + { + trace("test timed out"); + exit(1); + } + + profile-1234hz + /pid == \$target && secs > 5/ + { + raise(SIGINT); + exit(0); + } +EOF + +status=$? +exit $status diff --git a/usr/src/cmd/dtrace/test/tst/common/ustack/unpriv_helper.d b/usr/src/cmd/dtrace/test/tst/common/ustack/unpriv_helper.d new file mode 100644 index 0000000000..eb7b0e9e9d --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/ustack/unpriv_helper.d @@ -0,0 +1,4 @@ +dtrace:helper:ustack: +{ + this->otherstr = "doogle"; +} |
