summaryrefslogtreecommitdiffstats
path: root/src/VBox/ExtPacks/VBoxDTrace
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
commitf215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch)
tree6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/ExtPacks/VBoxDTrace
parentInitial commit. (diff)
downloadvirtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz
virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/ExtPacks/VBoxDTrace')
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/.scm-settings34
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/CDDL-ONLY2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/COPYING378
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/ExtPack.xml8
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/Makefile.kmk367
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/Samples/Hello.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceMain.cpp130
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0.cpp2174
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0A.asm32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceWrapper.cpp202
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.c3729
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.h290
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/generated/dt_lex.c3516
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceLibCWrappers.h101
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h472
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/COPYING378
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.com57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile167
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/time.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/clear.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/dateprof.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/denorm.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/lquantize.d30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/normalize.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/renormalize.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/trunc.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writes.d30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmd.d30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmdfd.d30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetime.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetimeq.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/iprb.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/ring.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/chapters125
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/begin.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/end.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/error.d35
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/delay.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/putnext.d30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/ssd.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/xioctl.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/countdown.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/counter.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/hello.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/rwtime.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/trussrw.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/applicat.d32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iocpu.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iosnoop.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iothrough.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iotime.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whoio.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whowrite.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipio.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipproto.d45
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/tcprst.d284
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/whatlock.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/mkdemo.pl227
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/printa.d35
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/lwptime.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/progtime.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/sig.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/whoexec.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/prof.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/profpri.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/restest.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d95
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/interp.d33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/syscall.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/tracewrite.d32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/callout.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/interval.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/intr.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/spec.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/specopen.d93
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/kstat.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/ksyms.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/rwinfo.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/find.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/Makefile.kup0
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcp1stbyte.d37
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytes.d36
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytesstat.d45
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpconnlat.d37
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpio.d32
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpioflags.d64
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpsnoop.d78
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpstate.d39
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcptop.d138
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/Makefile.kup0
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytes.d36
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytesstat.d45
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpio.d32
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpsnoop.d59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udptop.d133
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/badopen.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/errorpath.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/libc.d30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/userfunc.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/clause.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/rtime.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/soffice.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/dtrace.c2085
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.subdirs41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/README32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/baddof.c207
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/badioctl.c145
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.com76
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/chkargs.c149
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Getopt.java453
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/JDTrace.java1042
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile109
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/exception.lst77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/jdtrace.c60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/jdtrace.jar-manifest3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile.kup0
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dstyle.pl235
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dtest.pl704
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.com104
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile101
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_FUNC.bad.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_MDIM.bad.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_NULL.bad.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_REDEF.redef.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.avgtoofew.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.maxnoarg.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.mintoofew.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.quantizetoofew.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.stddevtoofew.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.sumtoofew.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_AGGARG.bad.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_PROTO.bad.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_IDENT.bad.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_UNDEF.badaggfunc.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badexpr.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badkey3.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.noeffect.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey1.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey2.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey4.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqbad1.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqshort.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASEVAL.bad.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMTYPE.lqbad1.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMVAL.bad.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.d33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.order.d33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.d33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.order.d33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHSTEP.d33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MISMATCH.lqbadarg.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPLARGE.lqtoofew.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPSMALL.bad.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPTYPE.lqbadinc.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPVAL.bad.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_AGGARG.bad.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_PROTO.bad.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_SCALAR.bad.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_ARG.lquantizetoofew.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgnoarg.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgtoomany.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.counttoomany.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizenoarg.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizetoomany.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxnoarg.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxtoomany.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.minnoarg.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.mintoomany.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizenoarg.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizetoomany.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevnoarg.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevtoomany.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumnoarg.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumtoomany.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_AGGARG.bad.d35
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badmany.d34
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badnone.d33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_SCALAR.bad.d34
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d.out131
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d.out22
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d.out16
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d.out22
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d.out94
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d.out22
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count3.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.goodkey.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d108
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d.out160
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d.out61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d.out16
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d.out23
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d.out9
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d96
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d.out910
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d.out15
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d150
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d.out64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d.out376
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d115
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d.out55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d.out11
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d.out46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d.out33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d.out61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d.out1208
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d.out9
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d.out146
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signature.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d120
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d.out44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d115
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d.out61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.subr.d112
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d.out11
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d.out46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_1.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_2.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.modby0.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.addmin.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.divmin.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muladd.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muldiv.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_ARR_BADREF.bad.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRNULL.bad.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRSUB.bad.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_PROTO_TYPE.badtuple.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_IDENT_UNDEF.badureg.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic1.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic2.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic3.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic4.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic5.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic6.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.uregsarray.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupgtype.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupttype.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.this.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_ARG.badsig.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toofew.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toomany.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_SYNTAX.errassign.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.tupoflow.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.cpyarray.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.diffprofile.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.initialize.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.invalidref.d75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.misc.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.orthogonality.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.this.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.valassign.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.begin.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.tick.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_ADDROF_BITFIELD.BitfieldAddress.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.NegBitField.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.ZeroBitField.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.ExceedBaseType.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.GreaterThan64.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFTYPE.badtype.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_OFFSETOF_BITFIELD.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_SIZEOF_BITFIELD.SizeofBitfield.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.BitFieldPromotion.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.SizeofBitField.d109
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.end.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize1.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize2.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize3.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.zerobuf.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.alignring.d81
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.cputime.ksh90
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.dynvarsize.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d115
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d.out9
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize1.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize2.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize3.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring1.d75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.smallring.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d.out11
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.cpuusage.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.nice.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.priority.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.prsize.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.rssize.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0clause.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8clause.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller1.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid1.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno1.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.execname.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.hpriority.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo1.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo1.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid1.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.timestamp.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.vtimestamp.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.body.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.both.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.pred.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.nopred.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.pred.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predfirst.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predlast.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.lowfrequency.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.malformedoverflow.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.nonexistentevent.d40
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart1.ksh78
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart2.ksh70
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackfailtostart.ksh77
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackterminates.ksh70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.toomanyenablings.d55
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.allcpus.ksh107
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.genericevent.d48
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.platformevent.ksh81
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LOCASSC.NonLocalAssoc.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LONGINT.LongStruct.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PARMCLASS.BadStorageClass.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_NAME.VoidName.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_TYPE.Dyn.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VARARGS.VarLenArgs.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VOID.NonSoleVoid.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_SIGNINT.UnsignedStruct.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_VOIDATTR.ShortVoidDecl.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.arrays.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.basics.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.funcs.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.pointers.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.varargsfuncs.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/badptr.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/countdown.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/counter.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/errorpath.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/hello.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/kstat.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/ksyms.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/renormalize.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rtime.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rw.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwinfo.d74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwtime.d50
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/specopen.d79
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/truss.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/trussrw.d52
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/userfunc.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_AGGREGATION.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DBLERROR.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DYNAMIC.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.end.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPEC.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPECUNAVAIL.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/err.D_PDESC_ZERO.InvalidDescription1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.APIVersion.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.AddSearchPath.d55
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ELFGeneration.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.IncludedFilePath.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithFunctions99
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithIDs77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithModules91
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithNames128
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithProviders82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ShowCompilerCode.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceFunctions115
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceIDs70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceModule114
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceNames129
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceProvider83
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.VerboseStabilityReport.d47
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.AddSearchPath.d.ksh82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeGiga.d.ksh45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeKilo.d.ksh45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeMega.d.ksh45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeTera.d.ksh45
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel32.d.ksh73
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel64.d.ksh74
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh.out2
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithoutW.d.ksh55
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationOut.d.ksh73
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationWithO.d.ksh74
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus1.d.ksh56
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus2.d.ksh55
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExtraneousProbeIds.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName1.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName2.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId1.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId2.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId3.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule1.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule2.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule3.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule4.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProbeIdentifier.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider1.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider2.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider3.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider4.d.ksh59
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc1.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc2.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc3.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc4.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc5.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc6.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc7.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc8.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc9.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID1.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID2.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID3.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID4.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID5.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID6.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID7.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule1.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule2.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule3.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule4.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule5.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule6.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule7.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule8.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName1.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName2.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName3.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName4.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName5.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName6.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName7.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName8.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName9.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider1.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider2.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider3.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider4.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider5.d.ksh58
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.MultipleInvalidProbeId.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.PreprocessorStatement.d.ksh70
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh.out0
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.UnDefineNameWithCPP.d.ksh71
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbeIdentfier.d.ksh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbesWithoutZ.d.ksh57
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/err.D_IDENT_UNDEF.timespent.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.end.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.endwithoutbegin.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multibeginend.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multiend.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_DECL_IDRED.EnumSameName.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumEquality.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumSameValue.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumValAssign.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_BADADDR.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_DIVZERO.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_UNKNOWN.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.error.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.errorend.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.D_PROTO_LEN.noarg.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.exitarg1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/tst.basic1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/err.D_PDESC_ZERO.notreturn.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.basic.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionentry.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionreturnvalue.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.ioctlargs.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offset.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offsetzero.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return0.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.tailcall.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_FUNC_UNDEF.progenyofbad1.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_OP_VFPTR.badop.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.chillbadarg.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoofew.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoomany.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrbadarg.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrtoofew.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoofew.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoomany.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtabadarg.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_VAR_UNDEF.badvar.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca2.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy1.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy2.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy3.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy4.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy5.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy6.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badchill.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.chillbadarg.ksh69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyout.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutbadaddr.ksh71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutstrbadaddr.ksh70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh102
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d87
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out163
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.bcopy.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.chill.ksh77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d.out22
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyin.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyinto.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ddi_pathname.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.default.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.freopen.ksh111
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh.out11
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.hton.d97
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d226
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d.out1126
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d95
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out8
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d135
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out13
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d.out8
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owned.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.progenyof.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.rand.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d89
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d.out10
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d146
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok_null.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d231
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d.out254
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d.out8
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_ADDROF_LVAL.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_EMPTY.empty.d34
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.clauses.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.stmts.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef1.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef2.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_IDENT_UNDEF.recur.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef1.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef2.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.badxlate.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineDataAssign.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineExpression.d80
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineTypedef.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineWritableAssign.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.c100
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d.out36
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/Makefile.kup0
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl104
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl88
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh125
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh93
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out6
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh81
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh128
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh88
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out5
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out6
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh88
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh182
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out18
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh172
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out15
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile79
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/test.jar-manifest2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java158
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestBean.java706
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestClose.java90
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestDrop.java169
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestEnable.java151
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java114
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestGetAggregate.java252
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMaxConsumers.java97
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMultiAggPrinta.java144
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeData.java110
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeDescription.java55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStateMachine.java627
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStopLock.java67
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh.out722
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh.out1
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.c51
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out3
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.GetAggregate.ksh36
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh.out17
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh.out78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.c93
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh.out50
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh.out8
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh.out70
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d.out47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NL.char.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NULL.char.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_DIGIT.InvalidDigit.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_OFLOW.BigInt.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_STR_NL.string.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace1.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace2.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack1.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack2.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack3.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren1.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren2.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren3.d39
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/tst.D_MACRO_OFLOW.ParIntOvflow.d.ksh54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/Makefile.kup0
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/tst.dtracedcmd.ksh85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh79
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.tcp.ksh155
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.udp.ksh74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/err.D_PRAGMA_OPTSET.d34
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.badopt.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d.out31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.enablerace.ksh89
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.haslam.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.include.ksh135
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out15
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.roch.d93
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.schrock.ksh79
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGKEY.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGPROTO.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d311
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d.out265
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d.out201
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d.out1021
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d.out55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d.out72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.c120
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.c441
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.d91
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_BITFIELD.bitfield.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.badtype.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.notsou.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.OffsetofNULL.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.badmemb.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofAlias.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofArith.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofUnion.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.d38
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badproc1.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_BADPID.badproc2.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.d36
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.d40
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.d38
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.d38
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.d38
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.d38
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.d40
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe29
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.addprobes.ksh61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.c52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.d75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.d51
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d.out3
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.c46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.c63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.d86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.c63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.d52
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh41
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.main.ksh59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh70
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh.out7
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh54
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh93
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh131
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh.out3
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh102
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh.out3
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh154
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.c64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.c58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.c65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.c58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.d83
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.c58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.d83
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.d39
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.d39
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d174
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGERR.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_DEPEND.main.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_INVAL.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_MALFORM.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_UNUSED.UnusedPragma.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.circlibdep.ksh58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.invalidlibdep.ksh57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libchain.ksh58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdep.ksh66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdepfullyconnected.ksh100
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_PRED_SCALAR.NonScalarPred.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.invalid.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.operr.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.argsnotcached.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d126
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d.out83
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh197
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_IDENT_UNDEF.afterprobe.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_PRAGCTL_INVAL.tabdefine.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_SYNTAX.withoutpound.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.defincomp.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefelsenotendif.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefincomp.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefnotendif.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.incompelse.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.mulelse.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.predicatedeclare.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.withinprobe.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badagg.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badfmt.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badval.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_PROTO.bad.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.jstack.d36
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.stack.d36
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.ustack.d36
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d.out19
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.largeusersym.ksh83
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.many.d76
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.stack.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d.out8
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_AGG_CONV.aggfmt.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.toomany.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.widths.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_FMT.badfmt.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_PROTO.novalue.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.aggarg.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.recursive.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.noprec.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.nowidth.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badprec.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badwidth.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PROTO_LEN.toofew.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv1.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv2.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv3.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d.out26
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d.out7
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d87
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d.out45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d.out14
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d.out16
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d.out14
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths1.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d.out22
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.op_access.ksh70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.unpriv_funcs.ksh79
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probeqtn.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probestar.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.tickstar.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.assign.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declare.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declarein.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.lbraces.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.probespec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.rbraces.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.recdec.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.basic1.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.check.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declare.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declareafter.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.emptyprobe.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragma.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaaftertab.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmainside.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaoutside.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.probestar.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.create.ksh67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.discard.ksh74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exec.ksh73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ENOENT.ksh84
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ksh86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh95
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitexit.ksh67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitkilled.ksh75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.signal.ksh84
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.c75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh89
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZERO.profile.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonens.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonensec.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneus.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneusec.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.func.ksh74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.mod.ksh70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.sym.ksh70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.c78
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh.out6
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_INVAL.wrongdec4.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.nonprofile.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec1.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec2.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec3.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginexit.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d.out1
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.c47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.c52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.c52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d.out101
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.statusrate.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d.out101
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.basename.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.caller.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.cleanpath.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin.d83
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin2.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ddi_pathname.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.dirname.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.errno.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.execname.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.gid.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.hton.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.index.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgdsize.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgsize.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.null.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.pid.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ppid.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.progenyof.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.random.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.rw.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.shortstr.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stack.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stackdepth.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stddev.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strchr.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strjoin.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strstr.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strtok.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.substr.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ucaller.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uid.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.unalign.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uregs.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustack.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustackdepth.d53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.vahole.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.violentdeath.ksh51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.zonename.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_ARR_LOCAL.thisarray.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.selfthis.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.thisself.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_IDRED.errval.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dec.err.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupgtype.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupltype.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupttype.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_SYNTAX.declare.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.localvar.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.misc.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.self.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray2.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfthis.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.this.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.thisself.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.enqueue.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.oncpu.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.stackdepth.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_MACRO_UNDEF.invalidargs.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_LVAL.rdonly.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_WRITE.usepidmacro.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.concat.d45
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.desc.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.inval.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.pid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.D_MACRO_UNUSED.overflow.ksh80
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arg0.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arguments.ksh90
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.assign.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.basic.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.ksh97
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.d44
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.ksh86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.ksh86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pgid.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pid.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.ksh86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.ksh86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.quite.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.ksh86
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.stringmacro.ksh78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.ksh86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.trace.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.d43
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.ksh86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d122
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/bug.1001148.SpecSizeVariations.d87
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d88
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations2.d88
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithChill.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithStop.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_COMM.AggAftCommit.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithCount.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMax.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMin.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithStddev.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithSum.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.CommitAftCommit.d82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.DisjointCommit.d102
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_DREC.CommitAftDataRec.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.DataRecAftCommit.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.ExitAfterCommit.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_EXIT_SPEC.ExitAftSpec.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_MALFORM.NspecExpr.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.HugeNspecValue.d76
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.InvalidSpecSize.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.NegSpecSize.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PROTO_LEN.SpecNoId.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_COMM.SpecAftCommit.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_DREC.SpecAftDataRec.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_SPEC.SpecAftSpec.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeBufSize.d88
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeNspec.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeSpecSize.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations1.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations2.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitAfterDiscard.d86
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitWithZero.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DataRecAftDiscard.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftCommit.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDataRec.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDiscard.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardWithZero.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.ExitAftDiscard.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations1.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations2.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculateWithRandom.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationCommit.d75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationDiscard.d74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationID.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationWithZero.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.TwoSpecBuffers.d77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negcommit.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negspec.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.zerosize.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/err.D_ATTR_MIN.MinAttributes.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_PROTO.bad.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_SIZE.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_FRAMES.bad.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_PROTO.bad.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_STRSIZE.bad.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/tst.default.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/tst.default.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.c37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.c37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/tst.strlen1.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_ADDROF_VAR.StructPointer.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon.d74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon1.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.circular.d66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order2.d108
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.recursive.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.simple.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_VOIDOBJ.baddec.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_PROTO_ARG.DupStructAssoc.d80
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructAssoc.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructDataTypes.d133
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructInside.d124
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.c41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.d46
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.openret.ksh75
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.c45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.d88
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.d87
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZERO.tick.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonens.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonensec.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneus.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneusec.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickarg0.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_PROTO_LEN.bad.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_TRACE_VOID.bad.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.misc.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.string.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_ARG.badsize.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toofew.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toomany.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ADDR.badaddr.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.negsize.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.zerosize.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/tst.rootvp.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_DECL_TYPERED.BadTransDecl.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_OP_INCOMPLETE.NonExistentInput1.d54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl1.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl3.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl4.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_TYPE_MEMBER.NonExistentInput2.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_INCOMPAT.BadInputType1.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_MEMB.NonExistentOutput2.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_NONE.BadTransDecl6.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_REDECL.RepeatTransDecl.d67
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransDecl8.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransInt.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.NonExistentOutput1.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.CircularTransDecl.d100
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.EmptyTransDecl.d79
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ForwardTag.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputAliasTrans.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputIntTrans.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialDereferencing.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialOutputTransDefn.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ProcModelTrans.d53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.RepeatDeclaration.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.SimultaneousTranslators.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.StructureAssignment.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransNonPointer.d84
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransOutputPointer.d80
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransPointer.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TranslateSelf.d76
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionInputTrans.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionOutputTrans.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_DECL_IDRED.DupTypeDef.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.BadExistingTypedef.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.TypedefInClause.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.ChainTypedef.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.TypedefDataAssign.d118
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CAST_INVAL.badcast.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CG_DYN.ResultDynType.d47
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CHR_OFLOW.charconst.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_BADCLASS.bad.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_CHARATTR.badtype3.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype4.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype5.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENCONST.badeval.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enoflow.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enuflow.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_SCOPE.scopeop.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_USELESS.baddec.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ACT.badcond.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ARITH.badoperand.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INCOMPAT.badassign.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badbitop.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badshift.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badcond.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badincop.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badlogop.d43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_PROTO_LEN.badcond1.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badenum.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badid.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badstruct.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype1.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype2.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupenum.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupstruct.d39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_XLATE_REDECL.ResultDynType.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.assignops.d82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.badshiftops.d49
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d.out16
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.bitops.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.charconstants.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.complex.d74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.condexpr.d61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.constants.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.conv.d109
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.enum.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intincop.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intops.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.inttypes.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrincop.d72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrops.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relenum.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relstring.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.shiftops.d62
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.stringconstants.d51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.struct.d84
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.typedef.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.unaryop.d50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_ADDROF_VAR.UnionPointer.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon1.d68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.circular.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.order.d69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.recursive.d59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.simple.d58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_PROTO_ARG.DupUnionAssoc.d80
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionAssoc.d71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionDataTypes.d132
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionInside.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/argmap.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/args.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/forker.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.andpid.ksh46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.c39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.d65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.c39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh84
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh107
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh159
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh.out3
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh160
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh.out2
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh170
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh106
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh96
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh113
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh118
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh.out10
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh105
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.c47
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh96
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh100
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.header.ksh85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.include.ksh61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh84
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh99
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh90
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh98
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh98
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh.out5
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh108
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh.out5
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh96
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh.out2
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.c61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.depth.ksh110
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.c61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.ksh139
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.gid.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.nullassign.d94
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ppid.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh.out3
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.uid.d41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.walltimestamp.d55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/tst.1.0.d48
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/tst.uregsarray.d63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyin.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyinstr.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyout.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyoutstr.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.s73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.s68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.d76
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.s114
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.ksh50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.s51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/annotated_helper.d32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/helper_helper.d32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.c43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d35
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.s43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.c82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.basic.ksh77
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.hvmenable.ksh64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.memenable.ksh65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh121
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedenable.ksh74
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/tst.uregsarray.d85
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.d40
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.exe29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d70
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d.out23
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.s81
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.d78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.s63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.d73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.s59
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/tst.tailcall.ksh132
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/annotated_helper.d32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/helper_helper.d32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.c43
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d35
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.s44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.c81
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d.out4
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.trapstat.ksh87
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c1370
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c190
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c99
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c180
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h353
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c158
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c322
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c972
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c847
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c154
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/dtrace_data.c113
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile55
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.com72
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/amd64/Makefile31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c596
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c119
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/llib-lctf32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/mapfile-vers114
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/i386/Makefile30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparc/Makefile30
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparcv9/Makefile31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile63
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.com233
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/drti.c190
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_aggregate.c1917
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.c507
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.h66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.c181
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.h71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cc.c2321
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cg.c1973
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_consume.c2342
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.c1130
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.h128
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dis.c524
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.c969
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.h68
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_error.c219
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_errtags.h249
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_grammar.y846
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_handle.c483
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.c1049
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.h185
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_impl.h669
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.c117
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.h71
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_lex.l931
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_link.c1634
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.c117
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.h57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_map.c428
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.c1348
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.h58
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c1500
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_options.c1118
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.c4907
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.h290
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.c193
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.h105
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.c757
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.h66
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pragma.c509
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.c2057
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.h137
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.c1111
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.h136
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.c622
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.h65
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.c890
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.h120
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.c112
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.h57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.c348
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.h51
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.c295
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.h76
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_subr.c1028
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_work.c322
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.c390
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.h89
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dtrace.h595
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/fc.d183
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.d.in218
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.sed.in69
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.d.in374
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.sed.in78
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/iscsit.d454
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/llib-ldtrace32
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mapfile-vers127
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrno.sh40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sed33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sh61
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sed38
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sh53
-rwxr-xr-xsrc/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mksignal.sh40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.d.in44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.sed.in41
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/nfs.d138
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.d.in365
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.sed.in163
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sched.d82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/scsi.d89
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/srp.d168
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.d.in50
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.sed.in34
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.d.in269
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.sed.in53
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.d.in73
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.sed.in29
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/unistd.d56
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile54
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/dt_isadep.c488
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.d.in117
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.sed.in82
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/dt_isadep.c338
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/regs.d120
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile36
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.c1214
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.conf33
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.c16292
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.conf28
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/fasttrap.c2378
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.c343
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.conf28
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.c577
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.conf28
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/sdt_subr.c1191
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.c374
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.conf28
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/dtrace_subr.c337
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf.h364
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf_api.h251
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace.h2276
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace_impl.h1304
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/dtrace_subr.c400
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile76
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_asm.s457
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_isa.c746
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap.conf39
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap_isa.c1745
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.c849
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.conf28
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.c557
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.conf28
1939 files changed, 189993 insertions, 0 deletions
diff --git a/src/VBox/ExtPacks/VBoxDTrace/.scm-settings b/src/VBox/ExtPacks/VBoxDTrace/.scm-settings
new file mode 100644
index 00000000..0dc13d36
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/.scm-settings
@@ -0,0 +1,34 @@
+# $Id: .scm-settings $
+## @file
+# Source code massager settings for VBoxDTrace.
+#
+
+#
+# Copyright (C) 2010-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from http://www.virtualbox.org.
+#
+# The contents of this file are subject to the terms of the Common
+# Development and Distribution License Version 1.0 (CDDL) only, as it
+# comes in the "COPYING.CDDL" file of the VirtualBox distribution.
+#
+# SPDX-License-Identifier: CDDL-1.0
+#
+
+
+--filter-out-dirs "/onnv/cmd/."
+--filter-out-dirs "/onnv/common/."
+--filter-out-dirs "/onnv/lib/."
+--filter-out-dirs "/onnv/uts/."
+
+--filter-out-files "/generated/dt_*"
+--filter-out-files "/CDDL-ONLY"
+
+# This is CDDL licensed
+--license-ose-cddl
+VBoxDTraceMain.cpp: --license-mit
+
+# MIT license on the samples.
+/Samples/*: --license-mit
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/CDDL-ONLY b/src/VBox/ExtPacks/VBoxDTrace/CDDL-ONLY
new file mode 100644
index 00000000..b36dbc60
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/CDDL-ONLY
@@ -0,0 +1,2 @@
+The ExtPacks/VBoxDTrace sources are only licensed under the Common Development
+and Distribution License, Version 1.0 (CDDL), see ExtPacks/COPYING for details.
diff --git a/src/VBox/ExtPacks/VBoxDTrace/COPYING b/src/VBox/ExtPacks/VBoxDTrace/COPYING
new file mode 100644
index 00000000..11f71082
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/COPYING
@@ -0,0 +1,378 @@
+The ExtPacks/VBoxDTrace sources are licensed under the Common Development
+and Distribution License, Version 1.0 (CDDL), as shown below.
+
+---
+
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0
+
+1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that creates
+ or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original
+ Software, prior Modifications used by a Contributor (if any),
+ and the Modifications made by that particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or (b)
+ Modifications, or (c) the combination of files containing
+ Original Software with files containing Modifications, in
+ each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form other
+ than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity that first
+ makes Original Software available under this License.
+
+ 1.6. "Larger Work" means a work which combines Covered Software or
+ portions thereof with code not governed by the terms of this
+ License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "Licensable" means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed
+ herein.
+
+ 1.9. "Modifications" means the Source Code and Executable form of
+ any of the following:
+
+ A. Any file that results from an addition to, deletion from or
+ modification of the contents of a file containing Original
+ Software or previous Modifications;
+
+ B. Any new file that contains any part of the Original
+ Software or previous Modifications; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and Executable
+ form of computer software code that is originally released
+ under this License.
+
+ 1.11. "Patent Claims" means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by
+ grantor.
+
+ 1.12. "Source Code" means (a) the common form of computer software
+ code in which modifications are made and (b) associated
+ documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal entity
+ exercising rights under, and complying with all of the terms
+ of, this License. For legal entities, "You" includes any
+ entity which controls, is controlled by, or is under common
+ control with You. For purposes of this definition,
+ "control" means (a) the power, direct or indirect, to cause
+ the direction or management of such entity, whether by
+ contract or otherwise, or (b) ownership of more than fifty
+ percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the Initial
+ Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer, to use,
+ reproduce, modify, display, perform, sublicense and
+ distribute the Original Software (or portions thereof),
+ with or without Modifications, and/or as part of a Larger
+ Work; and
+
+ (b) under Patent Claims infringed by the making, using or
+ selling of Original Software, to make, have made, use,
+ practice, sell, and offer for sale, and/or otherwise
+ dispose of the Original Software (or portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b) are
+ effective on the date Initial Developer first distributes
+ or otherwise makes the Original Software available to a
+ third party under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: (1) for code that You delete from the Original
+ Software, or (2) for infringements caused by: (i) the
+ modification of the Original Software, or (ii) the
+ combination of the Original Software with other software
+ or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor to use, reproduce,
+ modify, display, perform, sublicense and distribute the
+ Modifications created by such Contributor (or portions
+ thereof), either on an unmodified basis, with other
+ Modifications, as Covered Software and/or as part of a
+ Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either
+ alone and/or in combination with its Contributor Version
+ (or portions of such combination), to make, use, sell,
+ offer for sale, have made, and/or otherwise dispose of:
+ (1) Modifications made by that Contributor (or portions
+ thereof); and (2) the combination of Modifications made by
+ that Contributor with its Contributor Version (or portions
+ of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first distributes or
+ otherwise makes the Modifications available to a third
+ party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: (1) for any code that Contributor has deleted
+ from the Contributor Version; (2) for infringements caused
+ by: (i) third party modifications of Contributor Version,
+ or (ii) the combination of Modifications made by that
+ Contributor with other software (except as part of the
+ Contributor Version) or other devices; or (3) under Patent
+ Claims infringed by Covered Software in the absence of
+ Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in Source
+ Code form and that Source Code form must be distributed only under
+ the terms of this License. You must include a copy of this
+ License with every copy of the Source Code form of the Covered
+ Software You distribute or otherwise make available. You must
+ inform recipients of any such Covered Software in Executable form
+ as to how they can obtain such Covered Software in Source Code
+ form in a reasonable manner on or through a medium customarily
+ used for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You contribute are
+ governed by the terms of this License. You represent that You
+ believe Your Modifications are Your original creation(s) and/or
+ You have sufficient rights to grant the rights conveyed by this
+ License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications that
+ identifies You as the Contributor of the Modification. You may
+ not remove or alter any copyright, patent or trademark notices
+ contained within the Covered Software, or any notices of licensing
+ or any descriptive text giving attribution to any Contributor or
+ the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered Software in
+ Source Code form that alters or restricts the applicable version
+ of this License or the recipients' rights hereunder. You may
+ choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of
+ Covered Software. However, you may do so only on Your own behalf,
+ and not on behalf of the Initial Developer or any Contributor.
+ You must make it absolutely clear that any such warranty, support,
+ indemnity or liability obligation is offered by You alone, and You
+ hereby agree to indemnify the Initial Developer and every
+ Contributor for any liability incurred by the Initial Developer or
+ such Contributor as a result of warranty, support, indemnity or
+ liability terms You offer.
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered Software
+ under the terms of this License or under the terms of a license of
+ Your choice, which may contain terms different from this License,
+ provided that You are in compliance with the terms of this License
+ and that the license for the Executable form does not attempt to
+ limit or alter the recipient's rights in the Source Code form from
+ the rights set forth in this License. If You distribute the
+ Covered Software in Executable form under a different license, You
+ must make it absolutely clear that any terms which differ from
+ this License are offered by You alone, not by the Initial
+ Developer or Contributor. You hereby agree to indemnify the
+ Initial Developer and every Contributor for any liability incurred
+ by the Initial Developer or such Contributor as a result of any
+ such terms You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software with
+ other code not governed by the terms of this License and
+ distribute the Larger Work as a single product. In such a case,
+ You must make sure the requirements of this License are fulfilled
+ for the Covered Software.
+
+4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and may
+ publish revised and/or new versions of this License from time to
+ time. Each version will be given a distinguishing version number.
+ Except as provided in Section 4.3, no one other than the license
+ steward has the right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise make the
+ Covered Software available under the terms of the version of the
+ License under which You originally received the Covered Software.
+ If the Initial Developer includes a notice in the Original
+ Software prohibiting it from being distributed or otherwise made
+ available under any subsequent version of the License, You must
+ distribute and make the Covered Software available under the terms
+ of the version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to use,
+ distribute or otherwise make the Covered Software available under
+ the terms of any subsequent version of the License published by
+ the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a new
+ license for Your Original Software, You may create and use a
+ modified version of this License if You: (a) rename the license
+ and remove any references to the name of the license steward
+ (except to note that the license differs from this License); and
+ (b) otherwise make it clear that the license contains terms which
+ differ from this License.
+
+5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY
+ NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to
+ cure such breach within 30 days of becoming aware of the breach.
+ Provisions which, by their nature, must remain in effect beyond
+ the termination of this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or a
+ Contributor (the Initial Developer or Contributor against whom You
+ assert such claim is referred to as "Participant") alleging that
+ the Participant Software (meaning the Contributor Version where
+ the Participant is a Contributor or the Original Software where
+ the Participant is the Initial Developer) directly or indirectly
+ infringes any patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial Developer (if
+ the Initial Developer is not the Participant) and all Contributors
+ under Sections 2.1 and/or 2.2 of this License shall, upon 60 days
+ notice from Participant terminate prospectively and automatically
+ at the expiration of such 60 day notice period, unless if within
+ such 60 day period You withdraw Your claim with respect to the
+ Participant Software against such Participant either unilaterally
+ or pursuant to a written agreement with Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2 above,
+ all end user licenses that have been validly granted by You or any
+ distributor hereunder prior to termination (excluding licenses
+ granted to You by any distributor) shall survive termination.
+
+7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+ STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+ INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+ APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+ NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+ APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48
+ C.F.R. 252.227-7014(a)(1)) and "commercial computer software
+ documentation" as such terms are used in 48 C.F.R. 12.212
+ (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48
+ C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all
+ U.S. Government End Users acquire Covered Software with only those
+ rights set forth herein. This U.S. Government Rights clause is in
+ lieu of, and supersedes, any other FAR, DFAR, or other clause or
+ provision that addresses Government rights in computer software
+ under this License.
+
+9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed
+ by the law of the jurisdiction specified in a notice contained
+ within the Original Software (except to the extent applicable law,
+ if any, provides otherwise), excluding such jurisdiction's
+ conflict-of-law provisions. Any litigation relating to this
+ License shall be subject to the jurisdiction of the courts located
+ in the jurisdiction and venue specified in a notice contained
+ within the Original Software, with the losing party responsible
+ for costs, including, without limitation, court costs and
+ reasonable attorneys' fees and expenses. The application of the
+ United Nations Convention on Contracts for the International Sale
+ of Goods is expressly excluded. Any law or regulation which
+ provides that the language of a contract shall be construed
+ against the drafter shall not apply to this License. You agree
+ that You alone are responsible for compliance with the United
+ States export administration regulations (and the export control
+ laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
+--------------------------------------------------------------------
+
+NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND
+DISTRIBUTION LICENSE (CDDL)
+
+For Covered Software in this distribution, this License shall be
+governed by the laws of Germany. Legal venue shall be Stuttgart,
+Germany.
diff --git a/src/VBox/ExtPacks/VBoxDTrace/ExtPack.xml b/src/VBox/ExtPacks/VBoxDTrace/ExtPack.xml
new file mode 100644
index 00000000..178a5349
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/ExtPack.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<VirtualBoxExtensionPack xmlns="http://www.virtualbox.org/VirtualBoxExtensionPack" version="1.0">
+ <Name>Oracle VBoxDTrace Extension Pack</Name>
+ <Description>Experimental and unsupported extension pack providing DTrace features to VirtualBox.</Description>
+ <Version revision="@VBOX_SVN_REV@">@VBOX_VERSION_STRING@</Version>
+ <MainModule>VBoxDTraceMain</MainModule>
+</VirtualBoxExtensionPack>
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/Makefile.kmk b/src/VBox/ExtPacks/VBoxDTrace/Makefile.kmk
new file mode 100644
index 00000000..081f02b0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/Makefile.kmk
@@ -0,0 +1,367 @@
+# $Id: Makefile.kmk $
+## @file
+# Sub-makefile for VBoxDTrace.
+#
+# Contributed by: bird
+#
+
+#
+# Copyright (C) 2012-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from http://www.virtualbox.org.
+#
+# The contents of this file are subject to the terms of the Common
+# Development and Distribution License Version 1.0 (CDDL) only, as it
+# comes in the "COPYING.CDDL" file of the VirtualBox distribution.
+#
+# SPDX-License-Identifier: CDDL-1.0
+#
+
+SUB_DEPTH = ../../../../
+include $(KBUILD_PATH)/subheader.kmk
+
+
+#
+# Globals.
+#
+VBOX_EXTPACK_VBOXDTRACE_NAME := Oracle VBoxDTrace Extension Pack
+VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME := Oracle_VBoxDTrace_Extension_Pack
+VBOX_PATH_EXTPACK_VBOXDTRACE = $(PATH_STAGE)/$(INST_EXTPACK)$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)
+INST_EXTPACK_VBOXDTRACE = $(INST_EXTPACK)$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)/
+
+VBOXDT_PATH := $(PATH_ROOT)/src/VBox/ExtPacks/VBoxDTrace
+VBOXDT_PATH_ONNV := $(VBOXDT_PATH)/onnv
+VBOXDT_PATH_UTS := $(VBOXDT_PATH_ONNV)/uts
+VBOXDT_PATH_CMD := $(VBOXDT_PATH_ONNV)/cmd
+VBOXDT_PATH_LIBCTF := $(VBOXDT_PATH_ONNV)/lib/libctf
+VBOXDT_PATH_CMN_CTF := $(VBOXDT_PATH_ONNV)/common/ctf
+VBOXDT_PATH_LIBDTRACE := $(VBOXDT_PATH_ONNV)/lib/libdtrace
+VBOXDT_PATH_CMN_DTRACE := $(VBOXDT_PATH_ONNV)/common/dtrace
+
+
+ifndef VBOX_ONLY_EXTPACKS
+ #
+ # The generic wrapper that selects native or extpack dtrace cmd and adds our
+ # library path to the command line.
+ #
+ # Note! This is not installed as part of the extension pack, but always shipped
+ # with the base VBox installation.
+ #
+ PROGRAMS += VBoxDTrace
+ VBoxDTrace_TEMPLATE := VBoxR3Exe
+ VBoxDTrace_SOURCES := VBoxDTraceWrapper.cpp
+ VBoxDTrace_LIBS = $(LIB_RUNTIME)
+ $(call VBOX_SET_VER_INFO_DLL,VBoxDTrace,VirtualBox DTrace Chooser)
+endif
+
+
+if defined(VBOX_WITH_EXTPACK_VBOXDTRACE) && defined(VBOX_WITH_EXTPACK)
+
+ #
+ # Extend the extension pack templates.
+ #
+ TEMPLATE_VBoxR3ExtPackDTrace = For the ring-3 context modules in the VBoxDTrace extension pack.
+ TEMPLATE_VBoxR3ExtPackDTrace_EXTENDS = VBoxR3ExtPack
+ TEMPLATE_VBoxR3ExtPackDTrace_INST = $(INST_EXTPACK_VBOXDTRACE)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
+ TEMPLATE_VBoxR3ExtPackDTrace_DEFS = $(TEMPLATE_VBoxR3ExtPack_DEFS) VBOX_IN_DTRACE_EXTPACK
+ if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
+ # -wd4456: declaration of 'rval' hides previous local declaration
+ # -wd4477: 'fprintf' : format string '%02lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'ulong_t'
+ # -wd4457: warning C4457: declaration of 'arg' hides function parameter
+ TEMPLATE_VBoxR3ExtPackDTrace_CFLAGS.win = $(TEMPLATE_VBoxR3ExtPack_CFLAGS.win) -wd4456 -wd4477 -wd4457
+ endif
+
+ TEMPLATE_VBoxR0ExtPackDTrace = For the ring-0 context modules in the VBoxDTrace extension pack.
+ TEMPLATE_VBoxR0ExtPackDTrace_EXTENDS = VBoxR0ExtPack
+ TEMPLATE_VBoxR0ExtPackDTrace_INST = $(INST_EXTPACK_VBOXDTRACE)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
+ TEMPLATE_VBoxR0ExtPackDTrace_DEFS = $(TEMPLATE_VBoxR0ExtPack_DEFS) VBOX_IN_DTRACE_EXTPACK
+
+ TEMPLATE_VBoxInsExtPackDTrace = For the install targets for the VBoxDTrace extension pack.
+ TEMPLATE_VBoxInsExtPackDTrace_EXTENDS = VBoxR0ExtPack
+ TEMPLATE_VBoxInsExtPackDTrace_INST = $(INST_EXTPACK_VBOXDTRACE)
+
+
+ #
+ # Install the description.
+ #
+ INSTALLS += VBoxDTraceIns
+ VBoxDTraceIns_TEMPLATE = VBoxInsExtPackDTrace
+ VBoxDTraceIns_SOURCES = \
+ $(VBoxDTraceIns_0_OUTDIR)/ExtPack.xml \
+ COPYING=>ExtPack-SourceCodeLicense.txt
+ $(call VBOX_EDIT_VERSION_RULE_FN,VBoxDTraceIns,ExtPack.xml)
+
+
+ #
+ # VBoxDTraceMain - The module which the VirtualBox Main API talks to.
+ #
+ DLLS += VBoxDTraceMain
+ VBoxDTraceMain_TEMPLATE = VBoxR3ExtPackDTrace
+ VBoxDTraceMain_SOURCES = VBoxDTraceMain.cpp
+ $(call VBOX_SET_VER_INFO_DLL,VBoxDTraceMain,VBoxDTrace Main module)
+
+
+ #
+ # The ring-3 VBoxDTrace command implementation (library).
+ #
+ ifneq ($(KBUILD_TARGET),solaris) # Temporarily disabled on Solaris (not really needed)...
+ DLLS += VBoxDTraceCmd
+ VBoxDTraceCmd_TEMPLATE = VBoxR3ExtPackDTrace
+ ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
+ VBoxDTraceCmd_DEFS = RTMEM_WRAP_TO_EF_APIS VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME="$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)"
+ else
+ VBoxDTraceCmd_DEFS = RTMEM_WRAP_TO_EF_APIS VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME=\"$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)\"
+ endif
+ #VBoxDTraceCmd_DEFS += YYDEBUG
+ VBoxDTraceCmd_DEFS.linux = _XOPEN_SOURCE=700 _LARGEFILE64_SOURCE
+ VBoxDTraceCmd_DEFS.win = YY_USE_PROTOS=1 YYENABLE_NLS=0 YYLTYPE_IS_TRIVIAL=0
+ VBoxDTraceCmd_SDKS = VBoxZlib
+ ifn1of ($(KBUILD_TARGET), win)
+ VBoxDTraceCmd_CFLAGS = -Wno-format $(VBOX_GCC_Wno-overlength-strings) -Wno-sign-compare -Wno-strict-prototypes -Wno-missing-prototypes -Wno-missing-declarations -Wno-shadow
+ endif
+ VBoxDTraceCmd_INCS = \
+ include \
+ $(VBOXDT_PATH_UTS)/common \
+ $(VBOXDT_PATH_LIBCTF)/common \
+ $(VBOXDT_PATH_LIBDTRACE)/common \
+ $(VBOXDT_PATH_CMN_CTF)
+ VBoxDTraceCmd_SOURCES = \
+ $(VBOXDT_PATH_CMD)/dtrace/dtrace.c \
+ \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_as.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_aggregate.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_buf.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_cc.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_cg.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_consume.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_decl.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_dis.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_dof.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_error.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_handle.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_ident.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_inttab.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_list.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_map.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_module.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_program.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_open.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_options.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_parser.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_pcb.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_pragma.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_printf.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_proc.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_provider.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_regset.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_string.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_strtab.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_subr.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_work.c \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_xlator.c \
+ \
+ $(VBoxDTraceCmd_0_OUTDIR)/dt_errtags.c \
+ $(VBoxDTraceCmd_0_OUTDIR)/dt_names.c \
+ \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_create.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_error.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_decl.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_hash.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_labels.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_lookup.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_open.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_types.c \
+ $(VBOXDT_PATH_CMN_CTF)/ctf_util.c \
+ \
+ $(VBOXDT_PATH_LIBCTF)/common/ctf_subr.c \
+ $(VBOXDT_PATH_LIBCTF)/common/ctf_lib.c
+
+ # Source not used or wanted:
+ # $(VBOXDT_PATH_LIBDTRACE)/common/dt_link.c
+ # $(VBOXDT_PATH_LIBDTRACE)/common/dt_pid.c
+
+ # Generate sources
+ VBoxDTraceCmd_CLEAN = \
+ $(VBoxDTraceCmd_0_OUTDIR)/dt_errtags.c \
+ $(VBoxDTraceCmd_0_OUTDIR)/dt_names.c
+
+ $$(VBoxDTraceCmd_0_OUTDIR)/dt_errtags.c: \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_errtags.h \
+ $(VBOXDT_PATH_LIBDTRACE)/common/mkerrtags.sed \
+ | $$(dir $$@)
+ $(MSG_GENERATE,VBoxDTraceCmd,$@,$<)
+ $(SED) -n -f $(VBOXDT_PATH_LIBDTRACE)/common/mkerrtags.sed --output $@ $<
+
+ $$(VBoxDTraceCmd_0_OUTDIR)/dt_names.c: \
+ $(VBOXDT_PATH_UTS)/common/sys/dtrace.h \
+ $(VBOXDT_PATH_LIBDTRACE)/common/mknames.sed \
+ | $$(dir $$@)
+ $(MSG_GENERATE,VBoxDTraceCmd,$@,$<)
+ $(SED) -n -f $(VBOXDT_PATH_LIBDTRACE)/common/mknames.sed --output $@ $<
+
+ ifdef VBOX_HAVE_BISON
+ USES += yacc
+ VBoxDTraceCmd_USES += yacc
+ VBoxDTraceCmd_YACCTOOL = BISON
+ VBoxDTraceCmd_YACCFLAGS = -d -y
+ VBoxDTraceCmd_SOURCES += \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_grammar.y
+ VBoxDTraceCmd_INCS += $(VBoxDTraceCmd_0_OUTDIR)/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common
+ else
+ VBoxDTraceCmd_SOURCES += \
+ $(VBOXDT_PATH)/generated/dt_grammar.c
+ VBoxDTraceCmd_INCS += \
+ $(VBOXDT_PATH)/generated/
+ endif
+
+ ifdef VBOX_HAVE_FLEX
+ USES += lex
+ VBoxDTraceCmd_USES += lex
+ VBoxDTraceCmd_LEXTOOL = FLEX
+ VBoxDTraceCmd_LEXFLAGS = -l -B #-d -T
+ VBoxDTraceCmd_SOURCES += \
+ $(VBOXDT_PATH_LIBDTRACE)/common/dt_lex.l
+ else
+ VBoxDTraceCmd_SOURCES += \
+ $(VBOXDT_PATH)/generated/dt_lex.c
+ endif
+ ifeq ($(KBUILD_HOST),linux)
+ if $(VBOX_GCC_VERSION_CXX) >= 70000
+ VBoxDTraceCmd_CFLAGS += -Wno-implicit-fallthrough
+ endif
+ endif
+ VBoxDTraceCmd_DEFS += USING_FLEX
+ $(call VBOX_SET_VER_INFO_DLL,VBoxDTraceCmd,VBoxDTrace Command Implementation)
+
+ #
+ # Updates the sources generated by flex and biosn.
+ # The SED processing removes the paths the from #line statements.
+ #
+ vboxdtrace-update-generated-sources: \
+ $$(VBoxDTraceCmd_0_OUTDIR)/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_grammar.c \
+ $$(VBoxDTraceCmd_0_OUTDIR)/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_grammar.h \
+ $$(VBoxDTraceCmd_0_OUTDIR)/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_lex.c
+ $(foreach file,dt_grammar.c dt_grammar.h dt_lex.c \
+ ,$(NLTAB)$(SED) -e 's,$(VBOXDT_PATH_LIBDTRACE)/common/,,g'\
+ -e 's,$(VBoxDTraceCmd_0_OUTDIR)/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/,,g' \
+ --output $(VBOXDT_PATH)/generated/$(file) \
+ $(VBoxDTraceCmd_0_OUTDIR)/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/$(file))
+ endif # Temporarily disabled on Solaris.
+
+ #
+ # The ring-0 part of VBoxDTrace.
+ #
+ ifneq ($(KBUILD_TARGET),solaris) # disabled on solaris - neiter needed nor currently able to build it here.
+ $(if-expr defined(VBOX_WITH_VBOXR0_AS_DLL),DLLS,SYSMODS) += VBoxDTraceR0
+ endif
+ VBoxDTraceR0_TEMPLATE = VBoxR0ExtPackDTrace
+ VBoxDTraceR0_DEFS = IN_VBOXDTRACE_R0 IN_RT_R0
+ ifeq ($(VBOX_LDR_FMT),elf)
+ VBoxDTraceR0_LDFLAGS = -e ModuleInit
+ endif
+ VBoxDTraceR0_INCS = \
+ include \
+ $(VBOXDT_PATH_UTS)/common
+ VBoxDTraceR0_SOURCES = \
+ VBoxDTraceR0.cpp \
+ VBoxDTraceR0A.asm \
+ $(VBOXDT_PATH_UTS)/common/dtrace/dtrace.c
+ VBoxDTraceR0_LIBS = \
+ $(PATH_STAGE_LIB)/RuntimeR0$(VBOX_SUFF_LIB) \
+ $(VBOX_LIB_SUPR0)
+ $(call VBOX_SET_VER_INFO_R0,VBoxDTraceR0,VBoxDTrace Core (ring-0))
+
+
+ #
+ # Packing.
+ #
+ ifndef VBOX_WITHOUT_EXTPACK_VBOXDTRACE_PACKING
+ PACKING += $(VBOX_PATH_PACKAGES)/$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)-$(VBOX_VERSION_STRING)r$(VBOX_SVN_REV).vbox-extpack
+ endif
+
+ ifndef VBOX_WITH_EXTPACK_OS_ARCHS
+ ifeq ($(USER),bird) # for now
+ VBOX_WITH_EXTPACK_OS_ARCHS = $(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)
+ endif
+ endif
+
+ # Build the file list. The macro takes 1=darwin.x86, 2=dist/VirtualBox.app/Contents/MacOS, 3=dylib
+ VBOX_VBOXDTRACE_FILES_MACRO = \
+ $(PATH_OUT_BASE)/$(1)/$(KBUILD_TYPE)/$(2)/ExtensionPacks/$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)/$(1)/VBoxDTraceMain.$(3)=>$(1)/VBoxDTraceMain.$(3) \
+ $(if $(intersects $1, solaris.x86 solaris.amd64),, \
+ $(PATH_OUT_BASE)/$(1)/$(KBUILD_TYPE)/$(2)/ExtensionPacks/$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)/$(1)/VBoxDTraceCmd.$(3)=>$(1)/VBoxDTraceCmd.$(3) \
+ $(PATH_OUT_BASE)/$(1)/$(KBUILD_TYPE)/$(2)/ExtensionPacks/$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)/$(1)/VBoxDTraceR0.r0=>$(1)/VBoxDTraceR0.r0 \
+ )
+
+ VBOX_VBOXDTRACE_FILES := \
+ $(VBOX_PATH_EXTPACK_VBOXDTRACE)/ExtPack.xml=>ExtPack.xml \
+ $(VBOX_PATH_EXTPACK_VBOXDTRACE)/ExtPack-SourceCodeLicense.txt=>ExtPack-SourceCodeLicense.txt
+
+ if1of (darwin.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,darwin.amd64,dist/VirtualBox.app/Contents/MacOS,dylib)
+ endif
+ if1of (darwin.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,darwin.x86,dist/VirtualBox.app/Contents/MacOS,dylib)
+ endif
+ if1of (freebsd.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,freebsd.amd64,bin,so)
+ endif
+ if1of (freebsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,freebsd.x86,bin,so)
+ endif
+ if1of (linux.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,linux.amd64,bin,so)
+ endif
+ if1of (linux.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,linux.x86,bin,so)
+ endif
+ if1of (os2.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,os2.x86,bin,so)
+ endif
+ if1of (solaris.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,solaris.amd64,bin,so)
+ endif
+ if1of (solaris.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,solaris.x86,bin,so)
+ endif
+ if1of (win.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,win.amd64,bin,dll)
+ endif
+ if1of (win.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,win.x86,bin,dll)
+ endif
+
+ # Pack it all up using a temporary staging directory.
+ $(VBOX_PATH_PACKAGES)/$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)-$(VBOX_VERSION_STRING)r$(VBOX_SVN_REV).vbox-extpack: \
+ $$(foreach file, $$(VBOX_VBOXDTRACE_FILES), $$(firstword $$(subst =>,$$(SP),$$(file)))) \
+ | $(VBOX_PATH_PACKAGES)/
+ $(RM) -f $(wildcard $(VBOX_PATH_PACKAGES)/$(VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME)-*.vbox-extpack) \
+ $(VBoxDTraceIns_0_OUTDIR)/ExtPack.manifest \
+ $(VBoxDTraceIns_0_OUTDIR)/ExtPack.signature
+ # Stage all the files
+ $(RM) -Rf $(VBoxDTraceIns_0_OUTDIR)/Stage/
+ $(foreach file, $(VBOX_VBOXDTRACE_FILES),\
+ $(NLTAB)$(MKDIR) -p $(dir $(lastword $(subst =>,$(SP)$(VBoxDTraceIns_0_OUTDIR)/Stage/,$(file)))) \
+ $(NLTAB)$(CP) $(subst =>,$(SP)$(VBoxDTraceIns_0_OUTDIR)/Stage/,$(file)) )
+ # Create the manifest
+ $(VBOX_RTMANIFEST) \
+ --manifest $(VBoxDTraceIns_0_OUTDIR)/Stage/ExtPack.manifest \
+ --chdir $(VBoxDTraceIns_0_OUTDIR)/Stage/ \
+ $(foreach file, $(VBOX_VBOXDTRACE_FILES), $(lastword $(subst =>,$(SP),$(file))))
+ $(APPEND) $(VBoxDTraceIns_0_OUTDIR)/Stage/ExtPack.signature "todo"
+ $(CHMOD) a+r \
+ $(VBoxDTraceIns_0_OUTDIR)/Stage/ExtPack.manifest \
+ $(VBoxDTraceIns_0_OUTDIR)/Stage/ExtPack.signature
+ # Tar it up.
+ tar -cvf - -C $(VBoxDTraceIns_0_OUTDIR)/Stage/ . | gzip -9c > $@
+ # Clean up
+ $(RM) -Rf $(VBoxDTraceIns_0_OUTDIR)/Stage/
+
+ BLDDIRS += $(VBOX_PATH_PACKAGES)/
+
+endif # VBOX_WITH_EXTPACK_VBOXDTRACE
+
+
+include $(FILE_KBUILD_SUB_FOOTER)
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/Samples/Hello.d b/src/VBox/ExtPacks/VBoxDTrace/Samples/Hello.d
new file mode 100644
index 00000000..1f925756
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/Samples/Hello.d
@@ -0,0 +1,38 @@
+/* $Id: Hello.d $ */
+/** @file
+ * VBoxDTrace - Hello world sample.
+ */
+
+/*
+ * Copyright (C) 2010-2023 Oracle and/or its affiliates.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/* This works by matching the dtrace:::BEGIN probe, printing the greeting and
+ then quitting immediately. */
+BEGIN {
+ trace("Hello VBox World!");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceMain.cpp b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceMain.cpp
new file mode 100644
index 00000000..4db3c737
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceMain.cpp
@@ -0,0 +1,130 @@
+/* $Id: VBoxDTraceMain.cpp $ */
+/** @file
+ * VBoxDTrace main module.
+ */
+
+/*
+ * Copyright (C) 2010-2023 Oracle and/or its affiliates.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include <VBox/ExtPack/ExtPack.h>
+
+#include <iprt/errcore.h>
+#include <VBox/version.h>
+#include <iprt/string.h>
+#include <iprt/param.h>
+#include <iprt/path.h>
+
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
+/** Pointer to the extension pack helpers. */
+static PCVBOXEXTPACKHLP g_pHlp;
+
+
+// /**
+// * @interface_method_impl{VBOXEXTPACKREG,pfnInstalled}
+// */
+// static DECLCALLBACK(void) vboxDTraceExtPack_Installed(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, PRTERRINFO pErrInfo);
+//
+// /**
+// * @interface_method_impl{VBOXEXTPACKREG,pfnUninstall}
+// */
+// static DECLCALLBACK(int) vboxDTraceExtPack_Uninstall(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
+//
+// /**
+// * @interface_method_impl{VBOXEXTPACKREG,pfnVirtualBoxReady}
+// */
+// static DECLCALLBACK(void) vboxDTraceExtPack_VirtualBoxReady(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
+//
+// /**
+// * @interface_method_impl{VBOXEXTPACKREG,pfnUnload}
+// */
+// static DECLCALLBACK(void) vboxDTraceExtPack_Unload(PCVBOXEXTPACKREG pThis);
+//
+// /**
+// * @interface_method_impl{VBOXEXTPACKREG,pfnVMCreated}
+// */
+// static DECLCALLBACK(int) vboxDTraceExtPack_VMCreated(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, VBOXEXTPACK_IF_CS(IMachine) *pMachine);
+//
+// /**
+// * @interface_method_impl{VBOXEXTPACKREG,pfnQueryObject}
+// */
+// static DECLCALLBACK(void) vboxDTraceExtPack_QueryObject(PCVBOXEXTPACKREG pThis, PCRTUUID pObjectId);
+
+
+static const VBOXEXTPACKREG g_vboxDTraceExtPackReg =
+{
+ VBOXEXTPACKREG_VERSION,
+ /* .uVBoxFullVersion = */ VBOX_FULL_VERSION,
+ /* .pszNlsBaseName = */ NULL,
+ /* .pfnInstalled = */ NULL,
+ /* .pfnUninstall = */ NULL,
+ /* .pfnVirtualBoxReady =*/ NULL,
+ /* .pfnUnload = */ NULL,
+ /* .pfnVMCreated = */ NULL,
+ /* .pfnQueryObject = */ NULL,
+ /* .pfnReserved1 = */ NULL,
+ /* .pfnReserved2 = */ NULL,
+ /* .pfnReserved3 = */ NULL,
+ /* .pfnReserved4 = */ NULL,
+ /* .pfnReserved5 = */ NULL,
+ /* .pfnReserved6 = */ NULL,
+ /* .uReserved7 = */ 0,
+ VBOXEXTPACKREG_VERSION
+};
+
+
+/** @callback_method_impl{FNVBOXEXTPACKREGISTER} */
+extern "C" DECLEXPORT(int) VBoxExtPackRegister(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKREG *ppReg, PRTERRINFO pErrInfo)
+{
+ /*
+ * Check the VirtualBox version.
+ */
+ if (!VBOXEXTPACK_IS_VER_COMPAT(pHlp->u32Version, VBOXEXTPACKHLP_VERSION))
+ return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
+ "Helper version mismatch - expected %#x got %#x",
+ VBOXEXTPACKHLP_VERSION, pHlp->u32Version);
+ if ( VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MAJOR
+ || VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MINOR)
+ return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
+ "VirtualBox version mismatch - expected %u.%u got %u.%u",
+ VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR,
+ VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion),
+ VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion));
+
+ /*
+ * We're good, save input and return the registration structure.
+ */
+ g_pHlp = pHlp;
+ *ppReg = &g_vboxDTraceExtPackReg;
+
+ return VINF_SUCCESS;
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0.cpp b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0.cpp
new file mode 100644
index 00000000..8f4e3542
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0.cpp
@@ -0,0 +1,2174 @@
+/* $Id: VBoxDTraceR0.cpp $ */
+/** @file
+ * VBoxDTraceR0.
+ *
+ * Contributed by: bird
+ */
+
+/*
+ * Copyright (C) 2012-2023 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from http://www.virtualbox.org.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License Version 1.0 (CDDL) only, as it
+ * comes in the "COPYING.CDDL" file of the VirtualBox distribution.
+ *
+ * SPDX-License-Identifier: CDDL-1.0
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include <VBox/sup.h>
+#include <VBox/log.h>
+
+#include <iprt/asm-amd64-x86.h>
+#include <iprt/assert.h>
+#include <iprt/ctype.h>
+#include <iprt/err.h>
+#include <iprt/mem.h>
+#include <iprt/mp.h>
+#include <iprt/process.h>
+#include <iprt/semaphore.h>
+#include <iprt/spinlock.h>
+#include <iprt/string.h>
+#include <iprt/thread.h>
+#include <iprt/time.h>
+
+#include <sys/dtrace_impl.h>
+
+#include <VBox/VBoxTpG.h>
+
+
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
+//#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
+//# define HAVE_RTMEMALLOCEX_FEATURES
+//#endif
+
+
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
+
+/** Caller indicator. */
+typedef enum VBOXDTCALLER
+{
+ kVBoxDtCaller_Invalid = 0,
+ kVBoxDtCaller_Generic,
+ kVBoxDtCaller_ProbeFireUser,
+ kVBoxDtCaller_ProbeFireKernel
+} VBOXDTCALLER;
+
+/**
+ * Stack data used for thread structure and such.
+ *
+ * This is planted in every external entry point and used to emulate solaris
+ * curthread, CRED, curproc and similar. It is also used to get at the
+ * uncached probe arguments.
+ */
+typedef struct VBoxDtStackData
+{
+ /** Eyecatcher no. 1 (VBDT_STACK_DATA_MAGIC2). */
+ uint32_t u32Magic1;
+ /** Eyecatcher no. 2 (VBDT_STACK_DATA_MAGIC2). */
+ uint32_t u32Magic2;
+ /** The format of the caller specific data. */
+ VBOXDTCALLER enmCaller;
+ /** Caller specific data. */
+ union
+ {
+ /** kVBoxDtCaller_ProbeFireKernel. */
+ struct
+ {
+ /** The caller. */
+ uintptr_t uCaller;
+ /** Pointer to the stack arguments of a probe function call. */
+ uintptr_t *pauStackArgs;
+ } ProbeFireKernel;
+ /** kVBoxDtCaller_ProbeFireUser. */
+ struct
+ {
+ /** The user context. */
+ PCSUPDRVTRACERUSRCTX pCtx;
+ /** The argument displacement caused by 64-bit arguments passed directly to
+ * dtrace_probe. */
+ int offArg;
+ } ProbeFireUser;
+ } u;
+ /** Credentials allocated by VBoxDtGetCurrentCreds. */
+ struct VBoxDtCred *pCred;
+ /** Thread structure currently being held by this thread. */
+ struct VBoxDtThread *pThread;
+ /** Pointer to this structure.
+ * This is the final bit of integrity checking. */
+ struct VBoxDtStackData *pSelf;
+} VBDTSTACKDATA;
+/** Pointer to the on-stack thread specific data. */
+typedef VBDTSTACKDATA *PVBDTSTACKDATA;
+
+/** The first magic value. */
+#define VBDT_STACK_DATA_MAGIC1 RT_MAKE_U32_FROM_U8('V', 'B', 'o', 'x')
+/** The second magic value. */
+#define VBDT_STACK_DATA_MAGIC2 RT_MAKE_U32_FROM_U8('D', 'T', 'r', 'c')
+
+/** The alignment of the stack data.
+ * The data doesn't require more than sizeof(uintptr_t) alignment, but the
+ * greater alignment the quicker lookup. */
+#define VBDT_STACK_DATA_ALIGN 32
+
+/** Plants the stack data. */
+#define VBDT_SETUP_STACK_DATA(a_enmCaller) \
+ uint8_t abBlob[sizeof(VBDTSTACKDATA) + VBDT_STACK_DATA_ALIGN - 1]; \
+ PVBDTSTACKDATA pStackData = (PVBDTSTACKDATA)( (uintptr_t)&abBlob[VBDT_STACK_DATA_ALIGN - 1] \
+ & ~(uintptr_t)(VBDT_STACK_DATA_ALIGN - 1)); \
+ pStackData->u32Magic1 = VBDT_STACK_DATA_MAGIC1; \
+ pStackData->u32Magic2 = VBDT_STACK_DATA_MAGIC2; \
+ pStackData->enmCaller = a_enmCaller; \
+ pStackData->pCred = NULL; \
+ pStackData->pThread = NULL; \
+ pStackData->pSelf = pStackData
+
+/** Passifies the stack data and frees up resource held within it. */
+#define VBDT_CLEAR_STACK_DATA() \
+ do \
+ { \
+ pStackData->u32Magic1 = 0; \
+ pStackData->u32Magic2 = 0; \
+ pStackData->pSelf = NULL; \
+ if (pStackData->pCred) \
+ crfree(pStackData->pCred); \
+ if (pStackData->pThread) \
+ VBoxDtReleaseThread(pStackData->pThread); \
+ } while (0)
+
+
+/** Simple SUPR0Printf-style logging. */
+#if 0 /*def DEBUG_bird*/
+# define LOG_DTRACE(a) SUPR0Printf a
+#else
+# define LOG_DTRACE(a) do { } while (0)
+#endif
+
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
+/** Per CPU information */
+cpucore_t g_aVBoxDtCpuCores[RTCPUSET_MAX_CPUS];
+/** Dummy mutex. */
+struct VBoxDtMutex g_DummyMtx;
+/** Pointer to the tracer helpers provided by VBoxDrv. */
+static PCSUPDRVTRACERHLP g_pVBoxDTraceHlp;
+
+dtrace_cacheid_t dtrace_predcache_id = DTRACE_CACHEIDNONE + 1;
+
+#if 0
+void (*dtrace_cpu_init)(processorid_t);
+void (*dtrace_modload)(struct modctl *);
+void (*dtrace_modunload)(struct modctl *);
+void (*dtrace_helpers_cleanup)(void);
+void (*dtrace_helpers_fork)(proc_t *, proc_t *);
+void (*dtrace_cpustart_init)(void);
+void (*dtrace_cpustart_fini)(void);
+void (*dtrace_cpc_fire)(uint64_t);
+void (*dtrace_debugger_init)(void);
+void (*dtrace_debugger_fini)(void);
+#endif
+
+
+/**
+ * Gets the stack data.
+ *
+ * @returns Pointer to the stack data. Never NULL.
+ */
+static PVBDTSTACKDATA vboxDtGetStackData(void)
+{
+ int volatile iDummy = 1; /* use this to get the stack address. */
+ PVBDTSTACKDATA pData = (PVBDTSTACKDATA)( ((uintptr_t)&iDummy + VBDT_STACK_DATA_ALIGN - 1)
+ & ~(uintptr_t)(VBDT_STACK_DATA_ALIGN - 1));
+ for (;;)
+ {
+ if ( pData->u32Magic1 == VBDT_STACK_DATA_MAGIC1
+ && pData->u32Magic2 == VBDT_STACK_DATA_MAGIC2
+ && pData->pSelf == pData)
+ return pData;
+ pData = (PVBDTSTACKDATA)((uintptr_t)pData + VBDT_STACK_DATA_ALIGN);
+ }
+}
+
+
+void dtrace_toxic_ranges(void (*pfnAddOne)(uintptr_t uBase, uintptr_t cbRange))
+{
+ /** @todo ? */
+ RT_NOREF_PV(pfnAddOne);
+}
+
+
+
+/**
+ * Dummy callback used by dtrace_sync.
+ */
+static DECLCALLBACK(void) vboxDtSyncCallback(RTCPUID idCpu, void *pvUser1, void *pvUser2)
+{
+ NOREF(idCpu); NOREF(pvUser1); NOREF(pvUser2);
+}
+
+
+/**
+ * Synchronzie across all CPUs (expensive).
+ */
+void dtrace_sync(void)
+{
+ int rc = RTMpOnAll(vboxDtSyncCallback, NULL, NULL);
+ AssertRC(rc);
+}
+
+
+/**
+ * Fetch a 8-bit "word" from userland.
+ *
+ * @return The byte value.
+ * @param pvUserAddr The userland address.
+ */
+uint8_t dtrace_fuword8( void *pvUserAddr)
+{
+ uint8_t u8;
+ int rc = RTR0MemUserCopyFrom(&u8, (uintptr_t)pvUserAddr, sizeof(u8));
+ if (RT_FAILURE(rc))
+ {
+ RTCPUID iCpu = VBDT_GET_CPUID();
+ cpu_core[iCpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
+ cpu_core[iCpu].cpuc_dtrace_illval = (uintptr_t)pvUserAddr;
+ u8 = 0;
+ }
+ return u8;
+}
+
+
+/**
+ * Fetch a 16-bit word from userland.
+ *
+ * @return The word value.
+ * @param pvUserAddr The userland address.
+ */
+uint16_t dtrace_fuword16(void *pvUserAddr)
+{
+ uint16_t u16;
+ int rc = RTR0MemUserCopyFrom(&u16, (uintptr_t)pvUserAddr, sizeof(u16));
+ if (RT_FAILURE(rc))
+ {
+ RTCPUID iCpu = VBDT_GET_CPUID();
+ cpu_core[iCpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
+ cpu_core[iCpu].cpuc_dtrace_illval = (uintptr_t)pvUserAddr;
+ u16 = 0;
+ }
+ return u16;
+}
+
+
+/**
+ * Fetch a 32-bit word from userland.
+ *
+ * @return The dword value.
+ * @param pvUserAddr The userland address.
+ */
+uint32_t dtrace_fuword32(void *pvUserAddr)
+{
+ uint32_t u32;
+ int rc = RTR0MemUserCopyFrom(&u32, (uintptr_t)pvUserAddr, sizeof(u32));
+ if (RT_FAILURE(rc))
+ {
+ RTCPUID iCpu = VBDT_GET_CPUID();
+ cpu_core[iCpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
+ cpu_core[iCpu].cpuc_dtrace_illval = (uintptr_t)pvUserAddr;
+ u32 = 0;
+ }
+ return u32;
+}
+
+
+/**
+ * Fetch a 64-bit word from userland.
+ *
+ * @return The qword value.
+ * @param pvUserAddr The userland address.
+ */
+uint64_t dtrace_fuword64(void *pvUserAddr)
+{
+ uint64_t u64;
+ int rc = RTR0MemUserCopyFrom(&u64, (uintptr_t)pvUserAddr, sizeof(u64));
+ if (RT_FAILURE(rc))
+ {
+ RTCPUID iCpu = VBDT_GET_CPUID();
+ cpu_core[iCpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
+ cpu_core[iCpu].cpuc_dtrace_illval = (uintptr_t)pvUserAddr;
+ u64 = 0;
+ }
+ return u64;
+}
+
+
+/** copyin implementation */
+int VBoxDtCopyIn(void const *pvUser, void *pvDst, size_t cb)
+{
+ int rc = RTR0MemUserCopyFrom(pvDst, (uintptr_t)pvUser, cb);
+ return RT_SUCCESS(rc) ? 0 : -1;
+}
+
+
+/** copyout implementation */
+int VBoxDtCopyOut(void const *pvSrc, void *pvUser, size_t cb)
+{
+ int rc = RTR0MemUserCopyTo((uintptr_t)pvUser, pvSrc, cb);
+ return RT_SUCCESS(rc) ? 0 : -1;
+}
+
+
+/**
+ * Copy data from userland into the kernel.
+ *
+ * @param uUserAddr The userland address.
+ * @param uKrnlAddr The kernel buffer address.
+ * @param cb The number of bytes to copy.
+ * @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
+ */
+void dtrace_copyin( uintptr_t uUserAddr, uintptr_t uKrnlAddr, size_t cb, volatile uint16_t *pfFlags)
+{
+ int rc = RTR0MemUserCopyFrom((void *)uKrnlAddr, uUserAddr, cb);
+ if (RT_FAILURE(rc))
+ {
+ *pfFlags |= CPU_DTRACE_BADADDR;
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = uUserAddr;
+ }
+}
+
+
+/**
+ * Copy data from the kernel into userland.
+ *
+ * @param uKrnlAddr The kernel buffer address.
+ * @param uUserAddr The userland address.
+ * @param cb The number of bytes to copy.
+ * @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
+ */
+void dtrace_copyout( uintptr_t uKrnlAddr, uintptr_t uUserAddr, size_t cb, volatile uint16_t *pfFlags)
+{
+ int rc = RTR0MemUserCopyTo(uUserAddr, (void const *)uKrnlAddr, cb);
+ if (RT_FAILURE(rc))
+ {
+ *pfFlags |= CPU_DTRACE_BADADDR;
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = uUserAddr;
+ }
+}
+
+
+/**
+ * Copy a string from userland into the kernel.
+ *
+ * @param uUserAddr The userland address.
+ * @param uKrnlAddr The kernel buffer address.
+ * @param cbMax The maximum number of bytes to copy. May stop
+ * earlier if zero byte is encountered.
+ * @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
+ */
+void dtrace_copyinstr( uintptr_t uUserAddr, uintptr_t uKrnlAddr, size_t cbMax, volatile uint16_t *pfFlags)
+{
+ if (!cbMax)
+ return;
+
+ char *pszDst = (char *)uKrnlAddr;
+ int rc = RTR0MemUserCopyFrom(pszDst, uUserAddr, cbMax);
+ if (RT_FAILURE(rc))
+ {
+ /* Byte by byte - lazy bird! */
+ size_t off = 0;
+ while (off < cbMax)
+ {
+ rc = RTR0MemUserCopyFrom(&pszDst[off], uUserAddr + off, 1);
+ if (RT_FAILURE(rc))
+ {
+ *pfFlags |= CPU_DTRACE_BADADDR;
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = uUserAddr;
+ pszDst[off] = '\0';
+ return;
+ }
+ if (!pszDst[off])
+ return;
+ off++;
+ }
+ }
+
+ pszDst[cbMax - 1] = '\0';
+}
+
+
+/**
+ * Copy a string from the kernel and into user land.
+ *
+ * @param uKrnlAddr The kernel string address.
+ * @param uUserAddr The userland address.
+ * @param cbMax The maximum number of bytes to copy. Will stop
+ * earlier if zero byte is encountered.
+ * @param pfFlags Pointer to the relevant cpuc_dtrace_flags.
+ */
+void dtrace_copyoutstr(uintptr_t uKrnlAddr, uintptr_t uUserAddr, size_t cbMax, volatile uint16_t *pfFlags)
+{
+ const char *pszSrc = (const char *)uKrnlAddr;
+ size_t cbActual = RTStrNLen(pszSrc, cbMax);
+ cbActual += cbActual < cbMax;
+ dtrace_copyout(uKrnlAddr,uUserAddr, cbActual, pfFlags);
+}
+
+
+/**
+ * Get the caller @a cCallFrames call frames up the stack.
+ *
+ * @returns The caller's return address or ~(uintptr_t)0.
+ * @param cCallFrames The number of frames.
+ */
+uintptr_t dtrace_caller(int cCallFrames)
+{
+ PVBDTSTACKDATA pData = vboxDtGetStackData();
+ if (pData->enmCaller == kVBoxDtCaller_ProbeFireKernel)
+ return pData->u.ProbeFireKernel.uCaller;
+ RT_NOREF_PV(cCallFrames);
+ return ~(uintptr_t)0;
+}
+
+
+/**
+ * Get argument number @a iArg @a cCallFrames call frames up the stack.
+ *
+ * @returns The caller's return address or ~(uintptr_t)0.
+ * @param iArg The argument to get.
+ * @param cCallFrames The number of frames.
+ */
+uint64_t dtrace_getarg(int iArg, int cCallFrames)
+{
+ PVBDTSTACKDATA pData = vboxDtGetStackData();
+ AssertReturn(iArg >= 5, UINT64_MAX);
+
+ if (pData->enmCaller == kVBoxDtCaller_ProbeFireKernel)
+ return pData->u.ProbeFireKernel.pauStackArgs[iArg - 5];
+ RT_NOREF_PV(cCallFrames);
+ return UINT64_MAX;
+}
+
+
+/**
+ * Produce a traceback of the kernel stack.
+ *
+ * @param paPcStack Where to return the program counters.
+ * @param cMaxFrames The maximum number of PCs to return.
+ * @param cSkipFrames The number of artificial callstack frames to
+ * skip at the top.
+ * @param pIntr Not sure what this is...
+ */
+void dtrace_getpcstack(pc_t *paPcStack, int cMaxFrames, int cSkipFrames, uint32_t *pIntr)
+{
+ int iFrame = 0;
+ while (iFrame < cMaxFrames)
+ {
+ paPcStack[iFrame] = NULL;
+ iFrame++;
+ }
+ RT_NOREF_PV(pIntr);
+ RT_NOREF_PV(cSkipFrames);
+}
+
+
+/**
+ * Get the number of call frames on the stack.
+ *
+ * @returns The stack depth.
+ * @param cSkipFrames The number of artificial callstack frames to
+ * skip at the top.
+ */
+int dtrace_getstackdepth(int cSkipFrames)
+{
+ RT_NOREF_PV(cSkipFrames);
+ return 1;
+}
+
+
+/**
+ * Produce a traceback of the userland stack.
+ *
+ * @param paPcStack Where to return the program counters.
+ * @param paFpStack Where to return the frame pointers.
+ * @param cMaxFrames The maximum number of frames to return.
+ */
+void dtrace_getufpstack(uint64_t *paPcStack, uint64_t *paFpStack, int cMaxFrames)
+{
+ int iFrame = 0;
+ while (iFrame < cMaxFrames)
+ {
+ paPcStack[iFrame] = 0;
+ paFpStack[iFrame] = 0;
+ iFrame++;
+ }
+}
+
+
+/**
+ * Produce a traceback of the userland stack.
+ *
+ * @param paPcStack Where to return the program counters.
+ * @param cMaxFrames The maximum number of frames to return.
+ */
+void dtrace_getupcstack(uint64_t *paPcStack, int cMaxFrames)
+{
+ int iFrame = 0;
+ while (iFrame < cMaxFrames)
+ {
+ paPcStack[iFrame] = 0;
+ iFrame++;
+ }
+}
+
+
+/**
+ * Computes the depth of the userland stack.
+ */
+int dtrace_getustackdepth(void)
+{
+ return 0;
+}
+
+
+/**
+ * Get the current IPL/IRQL.
+ *
+ * @returns Current level.
+ */
+int dtrace_getipl(void)
+{
+#ifdef RT_ARCH_AMD64
+ /* CR8 is normally the same as IRQL / IPL on AMD64. */
+ return ASMGetCR8();
+#else
+ /* Just fake it on x86. */
+ return !ASMIntAreEnabled();
+#endif
+}
+
+
+/**
+ * Get current monotonic timestamp.
+ *
+ * @returns Timestamp, nano seconds.
+ */
+hrtime_t dtrace_gethrtime(void)
+{
+ return RTTimeNanoTS();
+}
+
+
+/**
+ * Get current walltime.
+ *
+ * @returns Timestamp, nano seconds.
+ */
+hrtime_t dtrace_gethrestime(void)
+{
+ /** @todo try get better resolution here somehow ... */
+ RTTIMESPEC Now;
+ return RTTimeSpecGetNano(RTTimeNow(&Now));
+}
+
+
+/**
+ * DTrace panic routine.
+ *
+ * @param pszFormat Panic message.
+ * @param va Arguments to the panic message.
+ */
+void dtrace_vpanic(const char *pszFormat, va_list va)
+{
+ RTAssertMsg1(NULL, __LINE__, __FILE__, __FUNCTION__);
+ RTAssertMsg2WeakV(pszFormat, va);
+ RTR0AssertPanicSystem();
+ for (;;)
+ {
+ ASMBreakpoint();
+ volatile char *pchCrash = (volatile char *)~(uintptr_t)0;
+ *pchCrash = '\0';
+ }
+}
+
+
+/**
+ * DTrace panic routine.
+ *
+ * @param pszFormat Panic message.
+ * @param ... Arguments to the panic message.
+ */
+void VBoxDtPanic(const char *pszFormat, ...)
+{
+ va_list va;
+ va_start(va, pszFormat);
+ dtrace_vpanic(pszFormat, va);
+ /*va_end(va); - unreachable */
+}
+
+
+/**
+ * DTrace kernel message routine.
+ *
+ * @param pszFormat Kernel message.
+ * @param ... Arguments to the panic message.
+ */
+void VBoxDtCmnErr(int iLevel, const char *pszFormat, ...)
+{
+ va_list va;
+ va_start(va, pszFormat);
+ SUPR0Printf("%N", pszFormat, va);
+ va_end(va);
+ RT_NOREF_PV(iLevel);
+}
+
+
+/** uprintf implementation */
+void VBoxDtUPrintf(const char *pszFormat, ...)
+{
+ va_list va;
+ va_start(va, pszFormat);
+ VBoxDtUPrintfV(pszFormat, va);
+ va_end(va);
+}
+
+
+/** vuprintf implementation */
+void VBoxDtUPrintfV(const char *pszFormat, va_list va)
+{
+ SUPR0Printf("%N", pszFormat, va);
+}
+
+
+/* CRED implementation. */
+cred_t *VBoxDtGetCurrentCreds(void)
+{
+ PVBDTSTACKDATA pData = vboxDtGetStackData();
+ if (!pData->pCred)
+ {
+ struct VBoxDtCred *pCred;
+#ifdef HAVE_RTMEMALLOCEX_FEATURES
+ int rc = RTMemAllocEx(sizeof(*pCred), 0, RTMEMALLOCEX_FLAGS_ANY_CTX, (void **)&pCred);
+#else
+ int rc = RTMemAllocEx(sizeof(*pCred), 0, 0, (void **)&pCred);
+#endif
+ AssertFatalRC(rc);
+ pCred->cr_refs = 1;
+ /** @todo get the right creds on unix systems. */
+ pCred->cr_uid = 0;
+ pCred->cr_ruid = 0;
+ pCred->cr_suid = 0;
+ pCred->cr_gid = 0;
+ pCred->cr_rgid = 0;
+ pCred->cr_sgid = 0;
+ pCred->cr_zone = 0;
+ pData->pCred = pCred;
+ }
+
+ return pData->pCred;
+}
+
+
+/* crhold implementation */
+void VBoxDtCredHold(struct VBoxDtCred *pCred)
+{
+ int32_t cRefs = ASMAtomicIncS32(&pCred->cr_refs);
+ Assert(cRefs > 1); NOREF(cRefs);
+}
+
+
+/* crfree implementation */
+void VBoxDtCredFree(struct VBoxDtCred *pCred)
+{
+ int32_t cRefs = ASMAtomicDecS32(&pCred->cr_refs);
+ Assert(cRefs >= 0);
+ if (!cRefs)
+ RTMemFreeEx(pCred, sizeof(*pCred));
+}
+
+/** Spinlock protecting the thread structures. */
+static RTSPINLOCK g_hThreadSpinlock = NIL_RTSPINLOCK;
+/** List of threads by usage age. */
+static RTLISTANCHOR g_ThreadAgeList;
+/** Hash table for looking up thread structures. */
+static struct VBoxDtThread *g_apThreadsHash[16384];
+/** Fake kthread_t structures.
+ * The size of this array is making horrible ASSUMPTIONS about the number of
+ * thread in the system that will be subjected to DTracing. */
+static struct VBoxDtThread g_aThreads[8192];
+
+
+static int vboxDtInitThreadDb(void)
+{
+ int rc = RTSpinlockCreate(&g_hThreadSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDtThreadDb");
+ if (RT_FAILURE(rc))
+ return rc;
+
+ RTListInit(&g_ThreadAgeList);
+ for (uint32_t i = 0; i < RT_ELEMENTS(g_aThreads); i++)
+ {
+ g_aThreads[i].hNative = NIL_RTNATIVETHREAD;
+ g_aThreads[i].uPid = NIL_RTPROCESS;
+ RTListPrepend(&g_ThreadAgeList, &g_aThreads[i].AgeEntry);
+ }
+
+ return VINF_SUCCESS;
+}
+
+
+static void vboxDtTermThreadDb(void)
+{
+ RTSpinlockDestroy(g_hThreadSpinlock);
+ g_hThreadSpinlock = NIL_RTSPINLOCK;
+ RTListInit(&g_ThreadAgeList);
+}
+
+
+/* curthread implementation, providing a fake kthread_t. */
+struct VBoxDtThread *VBoxDtGetCurrentThread(void)
+{
+ /*
+ * Once we've retrieved a thread, we hold on to it until the thread exits
+ * the VBoxDTrace module.
+ */
+ PVBDTSTACKDATA pData = vboxDtGetStackData();
+ if (pData->pThread)
+ {
+ AssertPtr(pData->pThread);
+ Assert(pData->pThread->hNative == RTThreadNativeSelf());
+ Assert(pData->pThread->uPid == RTProcSelf());
+ Assert(RTListIsEmpty(&pData->pThread->AgeEntry));
+ return pData->pThread;
+ }
+
+ /*
+ * Lookup the thread in the hash table.
+ */
+ RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
+ RTPROCESS uPid = RTProcSelf();
+ uintptr_t iHash = (hNativeSelf * 2654435761U) % RT_ELEMENTS(g_apThreadsHash);
+
+ RTSpinlockAcquire(g_hThreadSpinlock);
+
+ struct VBoxDtThread *pThread = g_apThreadsHash[iHash];
+ while (pThread)
+ {
+ if (pThread->hNative == hNativeSelf)
+ {
+ if (pThread->uPid != uPid)
+ {
+ /* Re-initialize the reused thread. */
+ pThread->uPid = uPid;
+ pThread->t_dtrace_vtime = 0;
+ pThread->t_dtrace_start = 0;
+ pThread->t_dtrace_stop = 0;
+ pThread->t_dtrace_scrpc = 0;
+ pThread->t_dtrace_astpc = 0;
+ pThread->t_predcache = 0;
+ }
+
+ /* Hold the thread in the on-stack data, making sure it does not
+ get reused till the thread leaves VBoxDTrace. */
+ RTListNodeRemove(&pThread->AgeEntry);
+ pData->pThread = pThread;
+
+ RTSpinlockRelease(g_hThreadSpinlock);
+ return pThread;
+ }
+
+ pThread = pThread->pNext;
+ }
+
+ /*
+ * Unknown thread. Allocate a new entry, recycling unused or old ones.
+ */
+ pThread = RTListGetLast(&g_ThreadAgeList, struct VBoxDtThread, AgeEntry);
+ AssertFatal(pThread);
+ RTListNodeRemove(&pThread->AgeEntry);
+ if (pThread->hNative != NIL_RTNATIVETHREAD)
+ {
+ uintptr_t iHash2 = (pThread->hNative * 2654435761U) % RT_ELEMENTS(g_apThreadsHash);
+ if (g_apThreadsHash[iHash2] == pThread)
+ g_apThreadsHash[iHash2] = pThread->pNext;
+ else
+ {
+ for (struct VBoxDtThread *pPrev = g_apThreadsHash[iHash2]; ; pPrev = pPrev->pNext)
+ {
+ AssertPtr(pPrev);
+ if (pPrev->pNext == pThread)
+ {
+ pPrev->pNext = pThread->pNext;
+ break;
+ }
+ }
+ }
+ }
+
+ /*
+ * Initialize the data.
+ */
+ pThread->t_dtrace_vtime = 0;
+ pThread->t_dtrace_start = 0;
+ pThread->t_dtrace_stop = 0;
+ pThread->t_dtrace_scrpc = 0;
+ pThread->t_dtrace_astpc = 0;
+ pThread->t_predcache = 0;
+ pThread->hNative = hNativeSelf;
+ pThread->uPid = uPid;
+
+ /*
+ * Add it to the hash as well as the on-stack data.
+ */
+ pThread->pNext = g_apThreadsHash[iHash];
+ g_apThreadsHash[iHash] = pThread->pNext;
+
+ pData->pThread = pThread;
+
+ RTSpinlockRelease(g_hThreadSpinlock);
+ return pThread;
+}
+
+
+/**
+ * Called by the stack data destructor.
+ *
+ * @param pThread The thread to release.
+ *
+ */
+static void VBoxDtReleaseThread(struct VBoxDtThread *pThread)
+{
+ RTSpinlockAcquire(g_hThreadSpinlock);
+
+ RTListAppend(&g_ThreadAgeList, &pThread->AgeEntry);
+
+ RTSpinlockRelease(g_hThreadSpinlock);
+}
+
+
+
+
+/*
+ *
+ * Virtual Memory / Resource Allocator.
+ * Virtual Memory / Resource Allocator.
+ * Virtual Memory / Resource Allocator.
+ *
+ */
+
+
+/** The number of bits per chunk.
+ * @remarks The 32 bytes are for heap headers and such like. */
+#define VBOXDTVMEMCHUNK_BITS ( ((_64K - 32 - sizeof(uint32_t) * 2) / sizeof(uint32_t)) * 32)
+
+/**
+ * Resource allocator chunk.
+ */
+typedef struct VBoxDtVMemChunk
+{
+ /** The ordinal (unbased) of the first item. */
+ uint32_t iFirst;
+ /** The current number of free items in this chunk. */
+ uint32_t cCurFree;
+ /** The allocation bitmap. */
+ uint32_t bm[VBOXDTVMEMCHUNK_BITS / 32];
+} VBOXDTVMEMCHUNK;
+/** Pointer to a resource allocator chunk. */
+typedef VBOXDTVMEMCHUNK *PVBOXDTVMEMCHUNK;
+
+
+
+/**
+ * Resource allocator instance.
+ */
+typedef struct VBoxDtVMem
+{
+ /** Spinlock protecting the data (interrupt safe). */
+ RTSPINLOCK hSpinlock;
+ /** Magic value. */
+ uint32_t u32Magic;
+ /** The current number of free items in the chunks. */
+ uint32_t cCurFree;
+ /** The current number of chunks that we have allocated. */
+ uint32_t cCurChunks;
+ /** The configured resource base. */
+ uint32_t uBase;
+ /** The configured max number of items. */
+ uint32_t cMaxItems;
+ /** The size of the apChunks array. */
+ uint32_t cMaxChunks;
+ /** Array of chunk pointers.
+ * (The size is determined at creation.) */
+ PVBOXDTVMEMCHUNK apChunks[1];
+} VBOXDTVMEM;
+/** Pointer to a resource allocator instance. */
+typedef VBOXDTVMEM *PVBOXDTVMEM;
+
+/** Magic value for the VBOXDTVMEM structure. */
+#define VBOXDTVMEM_MAGIC RT_MAKE_U32_FROM_U8('V', 'M', 'e', 'm')
+
+
+/* vmem_create implementation */
+struct VBoxDtVMem *VBoxDtVMemCreate(const char *pszName, void *pvBase, size_t cb, size_t cbUnit,
+ PFNRT pfnAlloc, PFNRT pfnFree, struct VBoxDtVMem *pSrc,
+ size_t cbQCacheMax, uint32_t fFlags)
+{
+ /*
+ * Assert preconditions of this implementation.
+ */
+ AssertMsgReturn((uintptr_t)pvBase <= UINT32_MAX, ("%p\n", pvBase), NULL);
+ AssertMsgReturn(cb <= UINT32_MAX, ("%zu\n", cb), NULL);
+ AssertMsgReturn((uintptr_t)pvBase + cb - 1 <= UINT32_MAX, ("%p %zu\n", pvBase, cb), NULL);
+ AssertMsgReturn(cbUnit == 1, ("%zu\n", cbUnit), NULL);
+ AssertReturn(!pfnAlloc, NULL);
+ AssertReturn(!pfnFree, NULL);
+ AssertReturn(!pSrc, NULL);
+ AssertReturn(!cbQCacheMax, NULL);
+ AssertReturn(fFlags & VM_SLEEP, NULL);
+ AssertReturn(fFlags & VMC_IDENTIFIER, NULL);
+ RT_NOREF_PV(pszName);
+
+ /*
+ * Allocate the instance.
+ */
+ uint32_t cChunks = (uint32_t)cb / VBOXDTVMEMCHUNK_BITS;
+ if (cb % VBOXDTVMEMCHUNK_BITS)
+ cChunks++;
+ PVBOXDTVMEM pThis = (PVBOXDTVMEM)RTMemAllocZ(RT_UOFFSETOF_DYN(VBOXDTVMEM, apChunks[cChunks]));
+ if (!pThis)
+ return NULL;
+ int rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDtVMem");
+ if (RT_FAILURE(rc))
+ {
+ RTMemFree(pThis);
+ return NULL;
+ }
+ pThis->u32Magic = VBOXDTVMEM_MAGIC;
+ pThis->cCurFree = 0;
+ pThis->cCurChunks = 0;
+ pThis->uBase = (uint32_t)(uintptr_t)pvBase;
+ pThis->cMaxItems = (uint32_t)cb;
+ pThis->cMaxChunks = cChunks;
+
+ return pThis;
+}
+
+
+/* vmem_destroy implementation */
+void VBoxDtVMemDestroy(struct VBoxDtVMem *pThis)
+{
+ if (!pThis)
+ return;
+ AssertPtrReturnVoid(pThis);
+ AssertReturnVoid(pThis->u32Magic == VBOXDTVMEM_MAGIC);
+
+ /*
+ * Invalidate the instance.
+ */
+ RTSpinlockAcquire(pThis->hSpinlock); /* paranoia */
+ pThis->u32Magic = 0;
+ RTSpinlockRelease(pThis->hSpinlock);
+ RTSpinlockDestroy(pThis->hSpinlock);
+
+ /*
+ * Free the chunks, then the instance.
+ */
+ uint32_t iChunk = pThis->cCurChunks;
+ while (iChunk-- > 0)
+ {
+ RTMemFree(pThis->apChunks[iChunk]);
+ pThis->apChunks[iChunk] = NULL;
+ }
+ RTMemFree(pThis);
+}
+
+
+/* vmem_alloc implementation */
+void *VBoxDtVMemAlloc(struct VBoxDtVMem *pThis, size_t cbMem, uint32_t fFlags)
+{
+ /*
+ * Validate input.
+ */
+ AssertReturn(fFlags & VM_BESTFIT, NULL);
+ AssertReturn(fFlags & VM_SLEEP, NULL);
+ AssertReturn(cbMem == 1, NULL);
+ AssertPtrReturn(pThis, NULL);
+ AssertReturn(pThis->u32Magic == VBOXDTVMEM_MAGIC, NULL);
+
+ /*
+ * Allocation loop.
+ */
+ RTSpinlockAcquire(pThis->hSpinlock);
+ for (;;)
+ {
+ PVBOXDTVMEMCHUNK pChunk;
+ uint32_t const cChunks = pThis->cCurChunks;
+
+ if (RT_LIKELY(pThis->cCurFree > 0))
+ {
+ for (uint32_t iChunk = 0; iChunk < cChunks; iChunk++)
+ {
+ pChunk = pThis->apChunks[iChunk];
+ if (pChunk->cCurFree > 0)
+ {
+ int iBit = ASMBitFirstClear(pChunk->bm, VBOXDTVMEMCHUNK_BITS);
+ AssertMsgReturnStmt(iBit >= 0 && (unsigned)iBit < VBOXDTVMEMCHUNK_BITS, ("%d\n", iBit),
+ RTSpinlockRelease(pThis->hSpinlock),
+ NULL);
+
+ ASMBitSet(pChunk->bm, iBit);
+ pChunk->cCurFree--;
+ pThis->cCurFree--;
+
+ uint32_t iRet = (uint32_t)iBit + pChunk->iFirst + pThis->uBase;
+ RTSpinlockRelease(pThis->hSpinlock);
+ return (void *)(uintptr_t)iRet;
+ }
+ }
+ AssertFailedBreak();
+ }
+
+ /* Out of resources? */
+ if (cChunks >= pThis->cMaxChunks)
+ break;
+
+ /*
+ * Allocate another chunk.
+ */
+ uint32_t const iFirstBit = cChunks > 0 ? pThis->apChunks[cChunks - 1]->iFirst + VBOXDTVMEMCHUNK_BITS : 0;
+ uint32_t const cFreeBits = cChunks + 1 == pThis->cMaxChunks
+ ? pThis->cMaxItems - (iFirstBit - pThis->uBase)
+ : VBOXDTVMEMCHUNK_BITS;
+ Assert(cFreeBits <= VBOXDTVMEMCHUNK_BITS);
+
+ RTSpinlockRelease(pThis->hSpinlock);
+
+ pChunk = (PVBOXDTVMEMCHUNK)RTMemAllocZ(sizeof(*pChunk));
+ if (!pChunk)
+ return NULL;
+
+ pChunk->iFirst = iFirstBit;
+ pChunk->cCurFree = cFreeBits;
+ if (cFreeBits != VBOXDTVMEMCHUNK_BITS)
+ {
+ /* lazy bird. */
+ uint32_t iBit = cFreeBits;
+ while (iBit < VBOXDTVMEMCHUNK_BITS)
+ {
+ ASMBitSet(pChunk->bm, iBit);
+ iBit++;
+ }
+ }
+
+ RTSpinlockAcquire(pThis->hSpinlock);
+
+ /*
+ * Insert the new chunk. If someone raced us here, we'll drop it to
+ * avoid wasting resources.
+ */
+ if (pThis->cCurChunks == cChunks)
+ {
+ pThis->apChunks[cChunks] = pChunk;
+ pThis->cCurFree += pChunk->cCurFree;
+ pThis->cCurChunks += 1;
+ }
+ else
+ {
+ RTSpinlockRelease(pThis->hSpinlock);
+ RTMemFree(pChunk);
+ RTSpinlockAcquire(pThis->hSpinlock);
+ }
+ }
+ RTSpinlockRelease(pThis->hSpinlock);
+
+ return NULL;
+}
+
+/* vmem_free implementation */
+void VBoxDtVMemFree(struct VBoxDtVMem *pThis, void *pvMem, size_t cbMem)
+{
+ /*
+ * Validate input.
+ */
+ AssertReturnVoid(cbMem == 1);
+ AssertPtrReturnVoid(pThis);
+ AssertReturnVoid(pThis->u32Magic == VBOXDTVMEM_MAGIC);
+
+ AssertReturnVoid((uintptr_t)pvMem < UINT32_MAX);
+ uint32_t uMem = (uint32_t)(uintptr_t)pvMem;
+ AssertReturnVoid(uMem >= pThis->uBase);
+ uMem -= pThis->uBase;
+ AssertReturnVoid(uMem < pThis->cMaxItems);
+
+
+ /*
+ * Free it.
+ */
+ RTSpinlockAcquire(pThis->hSpinlock);
+ uint32_t const iChunk = uMem / VBOXDTVMEMCHUNK_BITS;
+ if (iChunk < pThis->cCurChunks)
+ {
+ PVBOXDTVMEMCHUNK pChunk = pThis->apChunks[iChunk];
+ uint32_t iBit = uMem - pChunk->iFirst;
+ AssertReturnVoidStmt(iBit < VBOXDTVMEMCHUNK_BITS, RTSpinlockRelease(pThis->hSpinlock));
+ AssertReturnVoidStmt(ASMBitTestAndClear(pChunk->bm, iBit), RTSpinlockRelease(pThis->hSpinlock));
+
+ pChunk->cCurFree++;
+ pThis->cCurFree++;
+ }
+
+ RTSpinlockRelease(pThis->hSpinlock);
+}
+
+
+/*
+ *
+ * Memory Allocators.
+ * Memory Allocators.
+ * Memory Allocators.
+ *
+ */
+
+
+/* kmem_alloc implementation */
+void *VBoxDtKMemAlloc(size_t cbMem, uint32_t fFlags)
+{
+ void *pvMem;
+#ifdef HAVE_RTMEMALLOCEX_FEATURES
+ uint32_t fMemAllocFlags = fFlags & KM_NOSLEEP ? RTMEMALLOCEX_FLAGS_ANY_CTX : 0;
+#else
+ uint32_t fMemAllocFlags = 0;
+ RT_NOREF_PV(fFlags);
+#endif
+ int rc = RTMemAllocEx(cbMem, 0, fMemAllocFlags, &pvMem);
+ AssertRCReturn(rc, NULL);
+ AssertPtr(pvMem);
+ return pvMem;
+}
+
+
+/* kmem_zalloc implementation */
+void *VBoxDtKMemAllocZ(size_t cbMem, uint32_t fFlags)
+{
+ void *pvMem;
+#ifdef HAVE_RTMEMALLOCEX_FEATURES
+ uint32_t fMemAllocFlags = (fFlags & KM_NOSLEEP ? RTMEMALLOCEX_FLAGS_ANY_CTX : 0) | RTMEMALLOCEX_FLAGS_ZEROED;
+#else
+ uint32_t fMemAllocFlags = RTMEMALLOCEX_FLAGS_ZEROED;
+ RT_NOREF_PV(fFlags);
+#endif
+ int rc = RTMemAllocEx(cbMem, 0, fMemAllocFlags, &pvMem);
+ AssertRCReturn(rc, NULL);
+ AssertPtr(pvMem);
+ return pvMem;
+}
+
+
+/* kmem_free implementation */
+void VBoxDtKMemFree(void *pvMem, size_t cbMem)
+{
+ RTMemFreeEx(pvMem, cbMem);
+}
+
+
+/**
+ * Memory cache mockup structure.
+ * No slab allocator here!
+ */
+struct VBoxDtMemCache
+{
+ uint32_t u32Magic;
+ size_t cbBuf;
+ size_t cbAlign;
+};
+
+
+/* Limited kmem_cache_create implementation. */
+struct VBoxDtMemCache *VBoxDtKMemCacheCreate(const char *pszName, size_t cbBuf, size_t cbAlign,
+ PFNRT pfnCtor, PFNRT pfnDtor, PFNRT pfnReclaim,
+ void *pvUser, void *pvVM, uint32_t fFlags)
+{
+ /*
+ * Check the input.
+ */
+ AssertReturn(cbBuf > 0 && cbBuf < _1G, NULL);
+ AssertReturn(RT_IS_POWER_OF_TWO(cbAlign), NULL);
+ AssertReturn(!pfnCtor, NULL);
+ AssertReturn(!pfnDtor, NULL);
+ AssertReturn(!pfnReclaim, NULL);
+ AssertReturn(!pvUser, NULL);
+ AssertReturn(!pvVM, NULL);
+ AssertReturn(!fFlags, NULL);
+ RT_NOREF_PV(pszName);
+
+ /*
+ * Create a parameter container. Don't bother with anything fancy here yet,
+ * just get something working.
+ */
+ struct VBoxDtMemCache *pThis = (struct VBoxDtMemCache *)RTMemAlloc(sizeof(*pThis));
+ if (!pThis)
+ return NULL;
+
+ pThis->cbAlign = cbAlign;
+ pThis->cbBuf = cbBuf;
+ return pThis;
+}
+
+
+/* Limited kmem_cache_destroy implementation. */
+void VBoxDtKMemCacheDestroy(struct VBoxDtMemCache *pThis)
+{
+ RTMemFree(pThis);
+}
+
+
+/* kmem_cache_alloc implementation. */
+void *VBoxDtKMemCacheAlloc(struct VBoxDtMemCache *pThis, uint32_t fFlags)
+{
+ void *pvMem;
+#ifdef HAVE_RTMEMALLOCEX_FEATURES
+ uint32_t fMemAllocFlags = (fFlags & KM_NOSLEEP ? RTMEMALLOCEX_FLAGS_ANY_CTX : 0) | RTMEMALLOCEX_FLAGS_ZEROED;
+#else
+ uint32_t fMemAllocFlags = RTMEMALLOCEX_FLAGS_ZEROED;
+ RT_NOREF_PV(fFlags);
+#endif
+ int rc = RTMemAllocEx(pThis->cbBuf, /*pThis->cbAlign*/0, fMemAllocFlags, &pvMem);
+ AssertRCReturn(rc, NULL);
+ AssertPtr(pvMem);
+ return pvMem;
+}
+
+
+/* kmem_cache_free implementation. */
+void VBoxDtKMemCacheFree(struct VBoxDtMemCache *pThis, void *pvMem)
+{
+ RTMemFreeEx(pvMem, pThis->cbBuf);
+}
+
+
+/*
+ *
+ * Mutex Semaphore Wrappers.
+ *
+ */
+
+
+/** Initializes a mutex. */
+int VBoxDtMutexInit(struct VBoxDtMutex *pMtx)
+{
+ AssertReturn(pMtx != &g_DummyMtx, -1);
+ AssertPtr(pMtx);
+
+ pMtx->hOwner = NIL_RTNATIVETHREAD;
+ pMtx->hMtx = NIL_RTSEMMUTEX;
+ int rc = RTSemMutexCreate(&pMtx->hMtx);
+ if (RT_SUCCESS(rc))
+ return 0;
+ return -1;
+}
+
+
+/** Deletes a mutex. */
+void VBoxDtMutexDelete(struct VBoxDtMutex *pMtx)
+{
+ AssertReturnVoid(pMtx != &g_DummyMtx);
+ AssertPtr(pMtx);
+ if (pMtx->hMtx == NIL_RTSEMMUTEX)
+ return;
+
+ Assert(pMtx->hOwner == NIL_RTNATIVETHREAD);
+ int rc = RTSemMutexDestroy(pMtx->hMtx); AssertRC(rc);
+ pMtx->hMtx = NIL_RTSEMMUTEX;
+}
+
+
+/* mutex_enter implementation */
+void VBoxDtMutexEnter(struct VBoxDtMutex *pMtx)
+{
+ AssertPtr(pMtx);
+ if (pMtx == &g_DummyMtx)
+ return;
+
+ RTNATIVETHREAD hSelf = RTThreadNativeSelf();
+
+ int rc = RTSemMutexRequest(pMtx->hMtx, RT_INDEFINITE_WAIT);
+ AssertFatalRC(rc);
+
+ Assert(pMtx->hOwner == NIL_RTNATIVETHREAD);
+ pMtx->hOwner = hSelf;
+}
+
+
+/* mutex_exit implementation */
+void VBoxDtMutexExit(struct VBoxDtMutex *pMtx)
+{
+ AssertPtr(pMtx);
+ if (pMtx == &g_DummyMtx)
+ return;
+
+ Assert(pMtx->hOwner == RTThreadNativeSelf());
+
+ pMtx->hOwner = NIL_RTNATIVETHREAD;
+ int rc = RTSemMutexRelease(pMtx->hMtx);
+ AssertFatalRC(rc);
+}
+
+
+/* MUTEX_HELD implementation */
+bool VBoxDtMutexIsOwner(struct VBoxDtMutex *pMtx)
+{
+ AssertPtrReturn(pMtx, false);
+ if (pMtx == &g_DummyMtx)
+ return true;
+ return pMtx->hOwner == RTThreadNativeSelf();
+}
+
+
+
+/*
+ *
+ * Helpers for handling VTG structures.
+ * Helpers for handling VTG structures.
+ * Helpers for handling VTG structures.
+ *
+ */
+
+
+
+/**
+ * Converts an attribute from VTG description speak to DTrace.
+ *
+ * @param pDtAttr The DTrace attribute (dst).
+ * @param pVtgAttr The VTG attribute descriptor (src).
+ */
+static void vboxDtVtgConvAttr(dtrace_attribute_t *pDtAttr, PCVTGDESCATTR pVtgAttr)
+{
+ pDtAttr->dtat_name = pVtgAttr->u8Code - 1;
+ pDtAttr->dtat_data = pVtgAttr->u8Data - 1;
+ pDtAttr->dtat_class = pVtgAttr->u8DataDep - 1;
+}
+
+/**
+ * Gets a string from the string table.
+ *
+ * @returns Pointer to the string.
+ * @param pVtgHdr The VTG object header.
+ * @param offStrTab The string table offset.
+ */
+static const char *vboxDtVtgGetString(PVTGOBJHDR pVtgHdr, uint32_t offStrTab)
+{
+ Assert(offStrTab < pVtgHdr->cbStrTab);
+ return (const char *)pVtgHdr + pVtgHdr->offStrTab + offStrTab;
+}
+
+
+
+/*
+ *
+ * DTrace Provider Interface.
+ * DTrace Provider Interface.
+ * DTrace Provider Interface.
+ *
+ */
+
+
+/**
+ * @callback_method_impl{dtrace_pops_t,dtps_provide}
+ */
+static void vboxDtPOps_Provide(void *pvProv, const dtrace_probedesc_t *pDtProbeDesc)
+{
+ PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv;
+ AssertPtrReturnVoid(pProv);
+ LOG_DTRACE(("%s: %p / %p pDtProbeDesc=%p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, pDtProbeDesc));
+
+ if (pDtProbeDesc)
+ return; /* We don't generate probes, so never mind these requests. */
+
+ if (pProv->TracerData.DTrace.fZombie)
+ return;
+
+ dtrace_provider_id_t const idProvider = pProv->TracerData.DTrace.idProvider;
+ AssertPtrReturnVoid(idProvider);
+
+ AssertPtrReturnVoid(pProv->pHdr);
+ AssertReturnVoid(pProv->pHdr->offProbeLocs != 0);
+ uint32_t const cProbeLocs = pProv->pHdr->cbProbeLocs / sizeof(VTGPROBELOC);
+
+ /* Need a buffer for extracting the function names and mangling them in
+ case of collision. */
+ size_t const cbFnNmBuf = _4K + _1K;
+ char *pszFnNmBuf = (char *)RTMemAlloc(cbFnNmBuf);
+ if (!pszFnNmBuf)
+ return;
+
+ /*
+ * Itereate the probe location list and register all probes related to
+ * this provider.
+ */
+ uint16_t const idxProv = (uint16_t)((PVTGDESCPROVIDER)((uintptr_t)pProv->pHdr + pProv->pHdr->offProviders) - pProv->pDesc);
+ for (uint32_t idxProbeLoc = 0; idxProbeLoc < cProbeLocs; idxProbeLoc++)
+ {
+ /* Skip probe location belonging to other providers or once that
+ we've already reported. */
+ PCVTGPROBELOC pProbeLocRO = &pProv->paProbeLocsRO[idxProbeLoc];
+ PVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe;
+ if (pProbeDesc->idxProvider != idxProv)
+ continue;
+
+ uint32_t *pidProbe;
+ if (!pProv->fUmod)
+ pidProbe = (uint32_t *)&pProbeLocRO->idProbe;
+ else
+ pidProbe = &pProv->paR0ProbeLocs[idxProbeLoc].idProbe;
+ if (*pidProbe != 0)
+ continue;
+
+ /* The function name may need to be stripped since we're using C++
+ compilers for most of the code. ASSUMES nobody are brave/stupid
+ enough to use function pointer returns without typedef'ing
+ properly them (e.g. signal). */
+ const char *pszPrbName = vboxDtVtgGetString(pProv->pHdr, pProbeDesc->offName);
+ const char *pszFunc = pProbeLocRO->pszFunction;
+ const char *psz = strchr(pProbeLocRO->pszFunction, '(');
+ size_t cch;
+ if (psz)
+ {
+ /* skip blanks preceeding the parameter parenthesis. */
+ while ( (uintptr_t)psz > (uintptr_t)pProbeLocRO->pszFunction
+ && RT_C_IS_BLANK(psz[-1]))
+ psz--;
+
+ /* Find the start of the function name. */
+ pszFunc = psz - 1;
+ while ((uintptr_t)pszFunc > (uintptr_t)pProbeLocRO->pszFunction)
+ {
+ char ch = pszFunc[-1];
+ if (!RT_C_IS_ALNUM(ch) && ch != '_' && ch != ':')
+ break;
+ pszFunc--;
+ }
+ cch = psz - pszFunc;
+ }
+ else
+ cch = strlen(pszFunc);
+ RTStrCopyEx(pszFnNmBuf, cbFnNmBuf, pszFunc, cch);
+
+ /* Look up the probe, if we have one in the same function, mangle
+ the function name a little to avoid having to deal with having
+ multiple location entries with the same probe ID. (lazy bird) */
+ Assert(!*pidProbe);
+ if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) != DTRACE_IDNONE)
+ {
+ RTStrPrintf(pszFnNmBuf+cch, cbFnNmBuf - cch, "-%u", pProbeLocRO->uLine);
+ if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) != DTRACE_IDNONE)
+ {
+ unsigned iOrd = 2;
+ while (iOrd < 128)
+ {
+ RTStrPrintf(pszFnNmBuf+cch, cbFnNmBuf - cch, "-%u-%u", pProbeLocRO->uLine, iOrd);
+ if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) == DTRACE_IDNONE)
+ break;
+ iOrd++;
+ }
+ if (iOrd >= 128)
+ {
+ LogRel(("VBoxDrv: More than 128 duplicate probe location instances at line %u in function %s [%s], probe %s\n",
+ pProbeLocRO->uLine, pProbeLocRO->pszFunction, pszFnNmBuf, pszPrbName));
+ continue;
+ }
+ }
+ }
+
+ /* Create the probe. */
+ AssertCompile(sizeof(*pidProbe) == sizeof(dtrace_id_t));
+ *pidProbe = dtrace_probe_create(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName,
+ 1 /*aframes*/, (void *)(uintptr_t)idxProbeLoc);
+ pProv->TracerData.DTrace.cProvidedProbes++;
+ }
+
+ RTMemFree(pszFnNmBuf);
+ LOG_DTRACE(("%s: returns\n", __FUNCTION__));
+}
+
+
+/**
+ * @callback_method_impl{dtrace_pops_t,dtps_enable}
+ */
+static int vboxDtPOps_Enable(void *pvProv, dtrace_id_t idProbe, void *pvProbe)
+{
+ PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv;
+ LOG_DTRACE(("%s: %p / %p - %#x / %p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe));
+ AssertPtrReturn(pProv->TracerData.DTrace.idProvider, EINVAL);
+ RT_NOREF_PV(idProbe);
+
+ if (!pProv->TracerData.DTrace.fZombie)
+ {
+ uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe;
+ PVTGPROBELOC32 pProbeLocEn = (PVTGPROBELOC32)( (uintptr_t)pProv->pvProbeLocsEn + idxProbeLoc * pProv->cbProbeLocsEn);
+ PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc];
+ PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe;
+ uint32_t const idxProbe = pProbeDesc->idxEnabled;
+
+ if (!pProv->fUmod)
+ {
+ if (!pProbeLocEn->fEnabled)
+ {
+ pProbeLocEn->fEnabled = 1;
+ ASMAtomicIncU32(&pProv->pacProbeEnabled[idxProbe]);
+ ASMAtomicIncU32(&pProv->pDesc->cProbesEnabled);
+ ASMAtomicIncU32(&pProv->pDesc->uSettingsSerialNo);
+ }
+ }
+ else
+ {
+ /* Update kernel mode structure */
+ if (!pProv->paR0ProbeLocs[idxProbeLoc].fEnabled)
+ {
+ pProv->paR0ProbeLocs[idxProbeLoc].fEnabled = 1;
+ ASMAtomicIncU32(&pProv->paR0Probes[idxProbe].cEnabled);
+ ASMAtomicIncU32(&pProv->pDesc->cProbesEnabled);
+ ASMAtomicIncU32(&pProv->pDesc->uSettingsSerialNo);
+ }
+
+ /* Update user mode structure. */
+ pProbeLocEn->fEnabled = 1;
+ pProv->pacProbeEnabled[idxProbe] = pProv->paR0Probes[idxProbe].cEnabled;
+ }
+ }
+
+ return 0;
+}
+
+
+/**
+ * @callback_method_impl{dtrace_pops_t,dtps_disable}
+ */
+static void vboxDtPOps_Disable(void *pvProv, dtrace_id_t idProbe, void *pvProbe)
+{
+ PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv;
+ AssertPtrReturnVoid(pProv);
+ LOG_DTRACE(("%s: %p / %p - %#x / %p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe));
+ AssertPtrReturnVoid(pProv->TracerData.DTrace.idProvider);
+ RT_NOREF_PV(idProbe);
+
+ if (!pProv->TracerData.DTrace.fZombie)
+ {
+ uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe;
+ PVTGPROBELOC32 pProbeLocEn = (PVTGPROBELOC32)( (uintptr_t)pProv->pvProbeLocsEn + idxProbeLoc * pProv->cbProbeLocsEn);
+ PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc];
+ PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe;
+ uint32_t const idxProbe = pProbeDesc->idxEnabled;
+
+ if (!pProv->fUmod)
+ {
+ if (pProbeLocEn->fEnabled)
+ {
+ pProbeLocEn->fEnabled = 0;
+ ASMAtomicDecU32(&pProv->pacProbeEnabled[idxProbe]);
+ ASMAtomicDecU32(&pProv->pDesc->cProbesEnabled);
+ ASMAtomicIncU32(&pProv->pDesc->uSettingsSerialNo);
+ }
+ }
+ else
+ {
+ /* Update kernel mode structure */
+ if (pProv->paR0ProbeLocs[idxProbeLoc].fEnabled)
+ {
+ pProv->paR0ProbeLocs[idxProbeLoc].fEnabled = 0;
+ ASMAtomicDecU32(&pProv->paR0Probes[idxProbe].cEnabled);
+ ASMAtomicDecU32(&pProv->pDesc->cProbesEnabled);
+ ASMAtomicIncU32(&pProv->pDesc->uSettingsSerialNo);
+ }
+
+ /* Update user mode structure. */
+ pProbeLocEn->fEnabled = 0;
+ pProv->pacProbeEnabled[idxProbe] = pProv->paR0Probes[idxProbe].cEnabled;
+ }
+ }
+}
+
+
+/**
+ * @callback_method_impl{dtrace_pops_t,dtps_getargdesc}
+ */
+static void vboxDtPOps_GetArgDesc(void *pvProv, dtrace_id_t idProbe, void *pvProbe,
+ dtrace_argdesc_t *pArgDesc)
+{
+ PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv;
+ unsigned uArg = pArgDesc->dtargd_ndx;
+ RT_NOREF_PV(idProbe);
+
+ pArgDesc->dtargd_ndx = DTRACE_ARGNONE;
+ AssertPtrReturnVoid(pProv);
+ LOG_DTRACE(("%s: %p / %p - %#x / %p uArg=%d\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe, uArg));
+ AssertPtrReturnVoid(pProv->TracerData.DTrace.idProvider);
+
+ if (!pProv->TracerData.DTrace.fZombie)
+ {
+ uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe;
+ PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc];
+ PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe;
+ PCVTGDESCARGLIST pArgList = (PCVTGDESCARGLIST)( (uintptr_t)pProv->pHdr
+ + pProv->pHdr->offArgLists
+ + pProbeDesc->offArgList);
+ AssertReturnVoid(pProbeDesc->offArgList < pProv->pHdr->cbArgLists);
+
+ if (uArg < pArgList->cArgs)
+ {
+ const char *pszType = vboxDtVtgGetString(pProv->pHdr, pArgList->aArgs[uArg].offType);
+ size_t cchType = strlen(pszType);
+ if (cchType < sizeof(pArgDesc->dtargd_native))
+ {
+ memcpy(pArgDesc->dtargd_native, pszType, cchType + 1);
+ /** @todo mapping? */
+ pArgDesc->dtargd_ndx = uArg;
+ LOG_DTRACE(("%s: returns dtargd_native = %s\n", __FUNCTION__, pArgDesc->dtargd_native));
+ return;
+ }
+ }
+ }
+}
+
+
+/**
+ * @callback_method_impl{dtrace_pops_t,dtps_getargval}
+ */
+static uint64_t vboxDtPOps_GetArgVal(void *pvProv, dtrace_id_t idProbe, void *pvProbe,
+ int iArg, int cFrames)
+{
+ PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv;
+ AssertPtrReturn(pProv, UINT64_MAX);
+ LOG_DTRACE(("%s: %p / %p - %#x / %p iArg=%d cFrames=%u\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe, iArg, cFrames));
+ AssertReturn(iArg >= 5, UINT64_MAX);
+ RT_NOREF_PV(idProbe); RT_NOREF_PV(cFrames);
+
+ if (pProv->TracerData.DTrace.fZombie)
+ return UINT64_MAX;
+
+ uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe;
+ PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc];
+ PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe;
+ PCVTGDESCARGLIST pArgList = (PCVTGDESCARGLIST)( (uintptr_t)pProv->pHdr
+ + pProv->pHdr->offArgLists
+ + pProbeDesc->offArgList);
+ AssertReturn(pProbeDesc->offArgList < pProv->pHdr->cbArgLists, UINT64_MAX);
+
+ PVBDTSTACKDATA pData = vboxDtGetStackData();
+
+ /*
+ * Get the stack data. This is a wee bit complicated on 32-bit systems
+ * since we want to support 64-bit integer arguments.
+ */
+ uint64_t u64Ret;
+ if (iArg >= 20)
+ u64Ret = UINT64_MAX;
+ else if (pData->enmCaller == kVBoxDtCaller_ProbeFireKernel)
+ {
+#if ARCH_BITS == 64
+ u64Ret = pData->u.ProbeFireKernel.pauStackArgs[iArg - 5];
+#else
+ if ( !pArgList->fHaveLargeArgs
+ || iArg >= pArgList->cArgs)
+ u64Ret = pData->u.ProbeFireKernel.pauStackArgs[iArg - 5];
+ else
+ {
+ /* Similar to what we did for mac in when calling dtrace_probe(). */
+ uint32_t offArg = 0;
+ for (int i = 5; i < iArg; i++)
+ if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType))
+ offArg++;
+ u64Ret = pData->u.ProbeFireKernel.pauStackArgs[iArg - 5 + offArg];
+ if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType))
+ u64Ret |= (uint64_t)pData->u.ProbeFireKernel.pauStackArgs[iArg - 5 + offArg + 1] << 32;
+ }
+#endif
+ }
+ else if (pData->enmCaller == kVBoxDtCaller_ProbeFireUser)
+ {
+ int offArg = pData->u.ProbeFireUser.offArg;
+ PCSUPDRVTRACERUSRCTX pCtx = pData->u.ProbeFireUser.pCtx;
+ AssertPtrReturn(pCtx, UINT64_MAX);
+
+ if (pCtx->cBits == 32)
+ {
+ if ( !pArgList->fHaveLargeArgs
+ || iArg >= pArgList->cArgs)
+ {
+ if (iArg + offArg < (int)RT_ELEMENTS(pCtx->u.X86.aArgs))
+ u64Ret = pCtx->u.X86.aArgs[iArg + offArg];
+ else
+ u64Ret = UINT64_MAX;
+ }
+ else
+ {
+ for (int i = 5; i < iArg; i++)
+ if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType))
+ offArg++;
+ if (offArg + iArg < (int)RT_ELEMENTS(pCtx->u.X86.aArgs))
+ {
+ u64Ret = pCtx->u.X86.aArgs[iArg + offArg];
+ if ( VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType)
+ && offArg + iArg + 1 < (int)RT_ELEMENTS(pCtx->u.X86.aArgs))
+ u64Ret |= (uint64_t)pCtx->u.X86.aArgs[iArg + offArg + 1] << 32;
+ }
+ else
+ u64Ret = UINT64_MAX;
+ }
+ }
+ else
+ {
+ if (iArg + offArg < (int)RT_ELEMENTS(pCtx->u.Amd64.aArgs))
+ u64Ret = pCtx->u.Amd64.aArgs[iArg + offArg];
+ else
+ u64Ret = UINT64_MAX;
+ }
+ }
+ else
+ AssertFailedReturn(UINT64_MAX);
+
+ LOG_DTRACE(("%s: returns %#llx\n", __FUNCTION__, u64Ret));
+ return u64Ret;
+}
+
+
+/**
+ * @callback_method_impl{dtrace_pops_t,dtps_destroy}
+ */
+static void vboxDtPOps_Destroy(void *pvProv, dtrace_id_t idProbe, void *pvProbe)
+{
+ PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv;
+ AssertPtrReturnVoid(pProv);
+ LOG_DTRACE(("%s: %p / %p - %#x / %p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe));
+ AssertReturnVoid(pProv->TracerData.DTrace.cProvidedProbes > 0);
+ AssertPtrReturnVoid(pProv->TracerData.DTrace.idProvider);
+
+ if (!pProv->TracerData.DTrace.fZombie)
+ {
+ uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe;
+ PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc];
+ uint32_t *pidProbe;
+ if (!pProv->fUmod)
+ {
+ pidProbe = (uint32_t *)&pProbeLocRO->idProbe;
+ Assert(!pProbeLocRO->fEnabled);
+ Assert(*pidProbe == idProbe);
+ }
+ else
+ {
+ pidProbe = &pProv->paR0ProbeLocs[idxProbeLoc].idProbe;
+ Assert(!pProv->paR0ProbeLocs[idxProbeLoc].fEnabled);
+ Assert(*pidProbe == idProbe); NOREF(idProbe);
+ }
+ *pidProbe = 0;
+ }
+ pProv->TracerData.DTrace.cProvidedProbes--;
+}
+
+
+
+/**
+ * DTrace provider method table.
+ */
+static const dtrace_pops_t g_vboxDtVtgProvOps =
+{
+ /* .dtps_provide = */ vboxDtPOps_Provide,
+ /* .dtps_provide_module = */ NULL,
+ /* .dtps_enable = */ vboxDtPOps_Enable,
+ /* .dtps_disable = */ vboxDtPOps_Disable,
+ /* .dtps_suspend = */ NULL,
+ /* .dtps_resume = */ NULL,
+ /* .dtps_getargdesc = */ vboxDtPOps_GetArgDesc,
+ /* .dtps_getargval = */ vboxDtPOps_GetArgVal,
+ /* .dtps_usermode = */ NULL,
+ /* .dtps_destroy = */ vboxDtPOps_Destroy
+};
+
+
+
+
+/*
+ *
+ * Support Driver Tracer Interface.
+ * Support Driver Tracer Interface.
+ * Support Driver Tracer Interface.
+ *
+ */
+
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnProbeFireKernel}
+ */
+static DECLCALLBACK(void) vboxDtTOps_ProbeFireKernel(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
+ uintptr_t uArg3, uintptr_t uArg4)
+{
+ AssertPtrReturnVoid(pVtgProbeLoc);
+ LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pVtgProbeLoc, pVtgProbeLoc->idProbe));
+ AssertPtrReturnVoid(pVtgProbeLoc->pProbe);
+ AssertPtrReturnVoid(pVtgProbeLoc->pszFunction);
+
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_ProbeFireKernel);
+
+ pStackData->u.ProbeFireKernel.pauStackArgs = &uArg4 + 1;
+
+#if defined(RT_OS_DARWIN) && ARCH_BITS == 32
+ /*
+ * Convert arguments from uintptr_t to uint64_t.
+ */
+ PVTGDESCPROBE pProbe = pVtgProbeLoc->pProbe;
+ AssertPtrReturnVoid(pProbe);
+ PVTGOBJHDR pVtgHdr = (PVTGOBJHDR)((uintptr_t)pProbe + pProbe->offObjHdr);
+ AssertPtrReturnVoid(pVtgHdr);
+ PVTGDESCARGLIST pArgList = (PVTGDESCARGLIST)((uintptr_t)pVtgHdr + pVtgHdr->offArgLists + pProbe->offArgList);
+ AssertPtrReturnVoid(pArgList);
+ if (!pArgList->fHaveLargeArgs)
+ dtrace_probe(pVtgProbeLoc->idProbe, uArg0, uArg1, uArg2, uArg3, uArg4);
+ else
+ {
+ uintptr_t *auSrcArgs = &uArg0;
+ uint32_t iSrcArg = 0;
+ uint32_t iDstArg = 0;
+ uint64_t au64DstArgs[5];
+
+ while ( iDstArg < RT_ELEMENTS(au64DstArgs)
+ && iSrcArg < pArgList->cArgs)
+ {
+ au64DstArgs[iDstArg] = auSrcArgs[iSrcArg];
+ if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iDstArg].fType))
+ au64DstArgs[iDstArg] |= (uint64_t)auSrcArgs[++iSrcArg] << 32;
+ iSrcArg++;
+ iDstArg++;
+ }
+ while (iDstArg < RT_ELEMENTS(au64DstArgs))
+ au64DstArgs[iDstArg++] = auSrcArgs[iSrcArg++];
+
+ pStackData->u.ProbeFireKernel.pauStackArgs = &auSrcArgs[iSrcArg];
+ dtrace_probe(pVtgProbeLoc->idProbe, au64DstArgs[0], au64DstArgs[1], au64DstArgs[2], au64DstArgs[3], au64DstArgs[4]);
+ }
+#else
+ dtrace_probe(pVtgProbeLoc->idProbe, uArg0, uArg1, uArg2, uArg3, uArg4);
+#endif
+
+ VBDT_CLEAR_STACK_DATA();
+ LOG_DTRACE(("%s: returns\n", __FUNCTION__));
+}
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnProbeFireUser}
+ */
+static DECLCALLBACK(void) vboxDtTOps_ProbeFireUser(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx,
+ PCVTGOBJHDR pVtgHdr, PCVTGPROBELOC pProbeLocRO)
+{
+ LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pCtx, pCtx->idProbe));
+ AssertPtrReturnVoid(pProbeLocRO);
+ AssertPtrReturnVoid(pVtgHdr);
+ RT_NOREF_PV(pThis);
+ RT_NOREF_PV(pSession);
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_ProbeFireUser);
+
+ if (pCtx->cBits == 32)
+ {
+ pStackData->u.ProbeFireUser.pCtx = pCtx;
+ pStackData->u.ProbeFireUser.offArg = 0;
+
+#if ARCH_BITS == 64 || defined(RT_OS_DARWIN)
+ /*
+ * Combine two 32-bit arguments into one 64-bit argument where needed.
+ */
+ PVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe;
+ AssertPtrReturnVoid(pProbeDesc);
+ PVTGDESCARGLIST pArgList = (PVTGDESCARGLIST)((uintptr_t)pVtgHdr + pVtgHdr->offArgLists + pProbeDesc->offArgList);
+ AssertPtrReturnVoid(pArgList);
+
+ if (!pArgList->fHaveLargeArgs)
+ dtrace_probe(pCtx->idProbe,
+ pCtx->u.X86.aArgs[0],
+ pCtx->u.X86.aArgs[1],
+ pCtx->u.X86.aArgs[2],
+ pCtx->u.X86.aArgs[3],
+ pCtx->u.X86.aArgs[4]);
+ else
+ {
+ uint32_t const *auSrcArgs = &pCtx->u.X86.aArgs[0];
+ uint32_t iSrcArg = 0;
+ uint32_t iDstArg = 0;
+ uint64_t au64DstArgs[5];
+
+ while ( iDstArg < RT_ELEMENTS(au64DstArgs)
+ && iSrcArg < pArgList->cArgs)
+ {
+ au64DstArgs[iDstArg] = auSrcArgs[iSrcArg];
+ if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iDstArg].fType))
+ au64DstArgs[iDstArg] |= (uint64_t)auSrcArgs[++iSrcArg] << 32;
+ iSrcArg++;
+ iDstArg++;
+ }
+ while (iDstArg < RT_ELEMENTS(au64DstArgs))
+ au64DstArgs[iDstArg++] = auSrcArgs[iSrcArg++];
+
+ pStackData->u.ProbeFireUser.offArg = iSrcArg - RT_ELEMENTS(au64DstArgs);
+ dtrace_probe(pCtx->idProbe, au64DstArgs[0], au64DstArgs[1], au64DstArgs[2], au64DstArgs[3], au64DstArgs[4]);
+ }
+#else
+ dtrace_probe(pCtx->idProbe,
+ pCtx->u.X86.aArgs[0],
+ pCtx->u.X86.aArgs[1],
+ pCtx->u.X86.aArgs[2],
+ pCtx->u.X86.aArgs[3],
+ pCtx->u.X86.aArgs[4]);
+#endif
+ }
+ else if (pCtx->cBits == 64)
+ {
+ pStackData->u.ProbeFireUser.pCtx = pCtx;
+ pStackData->u.ProbeFireUser.offArg = 0;
+ dtrace_probe(pCtx->idProbe,
+ pCtx->u.Amd64.aArgs[0],
+ pCtx->u.Amd64.aArgs[1],
+ pCtx->u.Amd64.aArgs[2],
+ pCtx->u.Amd64.aArgs[3],
+ pCtx->u.Amd64.aArgs[4]);
+ }
+ else
+ AssertFailed();
+
+ VBDT_CLEAR_STACK_DATA();
+ LOG_DTRACE(("%s: returns\n", __FUNCTION__));
+}
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnTracerOpen}
+ */
+static DECLCALLBACK(int) vboxDtTOps_TracerOpen(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie,
+ uintptr_t uArg, uintptr_t *puSessionData)
+{
+ if (uCookie != RT_MAKE_U32_FROM_U8('V', 'B', 'D', 'T'))
+ return VERR_INVALID_MAGIC;
+ if (uArg)
+ return VERR_INVALID_PARAMETER;
+ RT_NOREF_PV(pThis); RT_NOREF_PV(pSession);
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_Generic);
+
+ int rc = dtrace_open((dtrace_state_t **)puSessionData, VBoxDtGetCurrentCreds());
+
+ VBDT_CLEAR_STACK_DATA();
+ return RTErrConvertFromErrno(rc);
+}
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnTracerClose}
+ */
+static DECLCALLBACK(int) vboxDtTOps_TracerIoCtl(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData,
+ uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal)
+{
+ AssertPtrReturn(uSessionData, VERR_INVALID_POINTER);
+ RT_NOREF_PV(pThis); RT_NOREF_PV(pSession);
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_Generic);
+
+ int rc = dtrace_ioctl((dtrace_state_t *)uSessionData, (intptr_t)uCmd, (intptr_t)uArg, piRetVal);
+
+ VBDT_CLEAR_STACK_DATA();
+ return RTErrConvertFromErrno(rc);
+}
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnTracerClose}
+ */
+static DECLCALLBACK(void) vboxDtTOps_TracerClose(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData)
+{
+ AssertPtrReturnVoid(uSessionData);
+ RT_NOREF_PV(pThis); RT_NOREF_PV(pSession);
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_Generic);
+
+ dtrace_close((dtrace_state_t *)uSessionData);
+
+ VBDT_CLEAR_STACK_DATA();
+}
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnProviderRegister}
+ */
+static DECLCALLBACK(int) vboxDtTOps_ProviderRegister(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore)
+{
+ LOG_DTRACE(("%s: %p %s/%s\n", __FUNCTION__, pThis, pCore->pszModName, pCore->pszName));
+ AssertReturn(pCore->TracerData.DTrace.idProvider == 0, VERR_INTERNAL_ERROR_3);
+ RT_NOREF_PV(pThis);
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_Generic);
+
+ PVTGDESCPROVIDER pDesc = pCore->pDesc;
+ dtrace_pattr_t DtAttrs;
+ vboxDtVtgConvAttr(&DtAttrs.dtpa_provider, &pDesc->AttrSelf);
+ vboxDtVtgConvAttr(&DtAttrs.dtpa_mod, &pDesc->AttrModules);
+ vboxDtVtgConvAttr(&DtAttrs.dtpa_func, &pDesc->AttrFunctions);
+ vboxDtVtgConvAttr(&DtAttrs.dtpa_name, &pDesc->AttrNames);
+ vboxDtVtgConvAttr(&DtAttrs.dtpa_args, &pDesc->AttrArguments);
+
+ /* Note! DTrace may call us back before dtrace_register returns, so we
+ have to point it to pCore->TracerData.DTrace.idProvider. */
+ AssertCompile(sizeof(dtrace_provider_id_t) == sizeof(pCore->TracerData.DTrace.idProvider));
+ int rc = dtrace_register(pCore->pszName,
+ &DtAttrs,
+ DTRACE_PRIV_KERNEL,
+ NULL /* cred */,
+ &g_vboxDtVtgProvOps,
+ pCore,
+ &pCore->TracerData.DTrace.idProvider);
+ if (!rc)
+ {
+ LOG_DTRACE(("%s: idProvider=%p\n", __FUNCTION__, pCore->TracerData.DTrace.idProvider));
+ AssertPtr(pCore->TracerData.DTrace.idProvider);
+ rc = VINF_SUCCESS;
+ }
+ else
+ {
+ pCore->TracerData.DTrace.idProvider = 0;
+ rc = RTErrConvertFromErrno(rc);
+ }
+
+ VBDT_CLEAR_STACK_DATA();
+ LOG_DTRACE(("%s: returns %Rrc\n", __FUNCTION__, rc));
+ return rc;
+}
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnProviderDeregister}
+ */
+static DECLCALLBACK(int) vboxDtTOps_ProviderDeregister(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore)
+{
+ uintptr_t idProvider = pCore->TracerData.DTrace.idProvider;
+ LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pThis, idProvider));
+ AssertPtrReturn(idProvider, VERR_INTERNAL_ERROR_3);
+ RT_NOREF_PV(pThis);
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_Generic);
+
+ dtrace_invalidate(idProvider);
+ int rc = dtrace_unregister(idProvider);
+ if (!rc)
+ {
+ pCore->TracerData.DTrace.idProvider = 0;
+ rc = VINF_SUCCESS;
+ }
+ else
+ {
+ AssertMsg(rc == EBUSY, ("%d\n", rc));
+ pCore->TracerData.DTrace.fZombie = true;
+ rc = VERR_TRY_AGAIN;
+ }
+
+ VBDT_CLEAR_STACK_DATA();
+ LOG_DTRACE(("%s: returns %Rrc\n", __FUNCTION__, rc));
+ return rc;
+}
+
+
+/**
+ * interface_method_impl{SUPDRVTRACERREG,pfnProviderDeregisterZombie}
+ */
+static DECLCALLBACK(int) vboxDtTOps_ProviderDeregisterZombie(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore)
+{
+ uintptr_t idProvider = pCore->TracerData.DTrace.idProvider;
+ LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pThis, idProvider));
+ AssertPtrReturn(idProvider, VERR_INTERNAL_ERROR_3);
+ Assert(pCore->TracerData.DTrace.fZombie);
+ RT_NOREF_PV(pThis);
+ VBDT_SETUP_STACK_DATA(kVBoxDtCaller_Generic);
+
+ int rc = dtrace_unregister(idProvider);
+ if (!rc)
+ {
+ pCore->TracerData.DTrace.idProvider = 0;
+ rc = VINF_SUCCESS;
+ }
+ else
+ {
+ AssertMsg(rc == EBUSY, ("%d\n", rc));
+ rc = VERR_TRY_AGAIN;
+ }
+
+ VBDT_CLEAR_STACK_DATA();
+ LOG_DTRACE(("%s: returns %Rrc\n", __FUNCTION__, rc));
+ return rc;
+}
+
+
+
+/**
+ * The tracer registration record of the VBox DTrace implementation
+ */
+static SUPDRVTRACERREG g_VBoxDTraceReg =
+{
+ SUPDRVTRACERREG_MAGIC,
+ SUPDRVTRACERREG_VERSION,
+ vboxDtTOps_ProbeFireKernel,
+ vboxDtTOps_ProbeFireUser,
+ vboxDtTOps_TracerOpen,
+ vboxDtTOps_TracerIoCtl,
+ vboxDtTOps_TracerClose,
+ vboxDtTOps_ProviderRegister,
+ vboxDtTOps_ProviderDeregister,
+ vboxDtTOps_ProviderDeregisterZombie,
+ SUPDRVTRACERREG_MAGIC
+};
+
+
+
+/**
+ * Module termination code.
+ *
+ * @param hMod Opque module handle.
+ */
+DECLEXPORT(void) ModuleTerm(void *hMod)
+{
+ SUPR0TracerDeregisterImpl(hMod, NULL);
+ dtrace_detach();
+ vboxDtTermThreadDb();
+}
+
+
+/**
+ * Module initialization code.
+ *
+ * @param hMod Opque module handle.
+ */
+DECLEXPORT(int) ModuleInit(void *hMod)
+{
+ int rc = vboxDtInitThreadDb();
+ if (RT_SUCCESS(rc))
+ {
+ rc = dtrace_attach();
+ if (rc == DDI_SUCCESS)
+ {
+ rc = SUPR0TracerRegisterImpl(hMod, NULL, &g_VBoxDTraceReg, &g_pVBoxDTraceHlp);
+ if (RT_SUCCESS(rc))
+ return rc;
+
+ dtrace_detach();
+ }
+ else
+ {
+ SUPR0Printf("dtrace_attach -> %d\n", rc);
+ rc = VERR_INTERNAL_ERROR_5;
+ }
+ vboxDtTermThreadDb();
+ }
+ else
+ SUPR0Printf("vboxDtInitThreadDb -> %d\n", rc);
+
+ return rc;
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0A.asm b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0A.asm
new file mode 100644
index 00000000..299606a2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0A.asm
@@ -0,0 +1,32 @@
+; $Id: VBoxDTraceR0A.asm $
+;; @file
+; VBoxDTraceR0 - Assembly Hacks.
+;
+; Contributed by: bird
+;
+
+;
+; Copyright (C) 2012-2023 Oracle and/or its affiliates.
+;
+; This file is part of VirtualBox base platform packages, as
+; available from http://www.virtualbox.org.
+;
+; The contents of this file are subject to the terms of the Common
+; Development and Distribution License Version 1.0 (CDDL) only, as it
+; comes in the "COPYING.CDDL" file of the VirtualBox distribution.
+;
+; SPDX-License-Identifier: CDDL-1.0
+;
+
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+
+extern NAME(dtrace_probe)
+
+GLOBALNAME dtrace_probe6
+ jmp NAME(dtrace_probe)
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceWrapper.cpp b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceWrapper.cpp
new file mode 100644
index 00000000..7221e7c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceWrapper.cpp
@@ -0,0 +1,202 @@
+/* $Id: VBoxDTraceWrapper.cpp $ */
+/** @file
+ * VBoxDTrace - Wrapper that selects the right dtrace implemetation and adds
+ * our library to the search path.
+ */
+
+/*
+ * Copyright (C) 2016-2023 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from http://www.virtualbox.org.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License Version 1.0 (CDDL) only, as it
+ * comes in the "COPYING.CDDL" file of the VirtualBox distribution.
+ *
+ * SPDX-License-Identifier: CDDL-1.0
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include <iprt/buildconfig.h>
+#include <iprt/env.h>
+#include <iprt/file.h>
+#include <iprt/initterm.h>
+#include <iprt/ldr.h>
+#include <iprt/message.h>
+#include <iprt/path.h>
+#include <iprt/process.h>
+#include <iprt/string.h>
+
+#include <VBox/sup.h>
+
+#include "../../Main/include/ExtPackUtil.h"
+
+
+/*********************************************************************************************************************************
+* Defined Constants And Macros *
+*********************************************************************************************************************************/
+/** The VBoxDTrace extension pack name. */
+#define VBOX_EXTPACK_VBOXDTRACE_NAME "Oracle VBoxDTrace Extension Pack"
+/** The mangled version of VBOX_EXTPACK_VBOXDTRACE_NAME (also in Config.kmk). */
+#define VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME "Oracle_VBoxDTrace_Extension_Pack"
+
+
+/*********************************************************************************************************************************
+* Structures and Typedefs *
+*********************************************************************************************************************************/
+/** The main function of VBoxDTrace.so/dylib/dll. */
+typedef int (RTCALL *PFNVBOXDTRACEMAIN)(int argc, char **argv);
+
+
+int main(int argc, char **argv)
+{
+ /*
+ * Init IPRT.
+ */
+ int rc = RTR3InitExe(argc, &argv, 0);
+ if (RT_FAILURE(rc))
+ return RTMsgInitFailure(rc);
+
+ /*
+ * Locate a native DTrace command binary.
+ */
+ bool fIsNativeDTrace = false;
+ char szDTraceCmd[RTPATH_MAX];
+ szDTraceCmd[0] = '\0';
+
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
+ /*
+ * 1. Try native first on platforms where it's applicable.
+ */
+ static const char * const s_apszNativeDTrace[] =
+ {
+ "/usr/sbin/dtrace",
+ "/sbin/dtrace",
+ "/usr/bin/dtrace",
+ "/bin/dtrace",
+ "/usr/local/sbin/dtrace",
+ "/usr/local/bin/dtrace"
+ };
+ if (!RTEnvExist("VBOX_DTRACE_NO_NATIVE"))
+ for (uint32_t i = 0; i < RT_ELEMENTS(s_apszNativeDTrace); i++)
+ if (RTFileExists(s_apszNativeDTrace[i]))
+ {
+ fIsNativeDTrace = true;
+ strcpy(szDTraceCmd, s_apszNativeDTrace[i]);
+# ifdef RT_OS_LINUX
+ /** @todo Warn if the dtrace modules haven't been loaded or vboxdrv isn't
+ * compiled against them. */
+# endif
+ break;
+ }
+ if (szDTraceCmd[0] == '\0')
+#endif
+ {
+ /*
+ * 2. VBoxDTrace extension pack installed?
+ *
+ * Note! We cannot use the COM API here because this program is usually
+ * run thru sudo or directly as root, even if the target
+ * VirtualBox process is running as regular user. This is due to
+ * the privileges required to run dtrace scripts on a host.
+ */
+ rc = RTPathAppPrivateArch(szDTraceCmd, sizeof(szDTraceCmd));
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szDTraceCmd, sizeof(szDTraceCmd),
+ VBOX_EXTPACK_INSTALL_DIR RTPATH_SLASH_STR VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME);
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szDTraceCmd, sizeof(szDTraceCmd), RTBldCfgTargetDotArch());
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szDTraceCmd, sizeof(szDTraceCmd), "VBoxDTraceCmd");
+ if (RT_SUCCESS(rc))
+ rc = RTStrCat(szDTraceCmd, sizeof(szDTraceCmd), RTLdrGetSuff());
+ if (RT_FAILURE(rc))
+ return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing extension pack path: %Rrc", rc);
+ if (!RTFileExists(szDTraceCmd))
+ return RTMsgErrorExit(RTEXITCODE_FAILURE,
+ "Unable to find a DTrace implementation. VBoxDTrace Extension Pack installed?");
+ fIsNativeDTrace = false;
+ }
+
+
+ /*
+ * Construct a new command line that includes our libary.
+ */
+ char szDTraceLibDir[RTPATH_MAX];
+ rc = RTPathAppPrivateNoArch(szDTraceLibDir, sizeof(szDTraceLibDir));
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szDTraceLibDir, sizeof(szDTraceLibDir), "dtrace" RTPATH_SLASH_STR "lib");
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szDTraceLibDir, sizeof(szDTraceLibDir), RTBldCfgTargetArch());
+ if (RT_FAILURE(rc))
+ return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing dtrace library path for VBox: %Rrc", rc);
+
+ char **papszArgs = (char **)RTMemAlloc((argc + 3) * sizeof(char *));
+ if (!papszArgs)
+ return RTMsgErrorExit(RTEXITCODE_FAILURE, "No memory for argument list.");
+
+ int cArgs = 1;
+ papszArgs[0] = fIsNativeDTrace ? szDTraceCmd : argv[0];
+ if (argc > 1)
+ {
+ papszArgs[cArgs++] = (char *)"-L";
+ papszArgs[cArgs++] = szDTraceLibDir;
+ }
+ for (int i = 1; i < argc; i++)
+ papszArgs[cArgs++] = argv[i];
+ papszArgs[cArgs] = NULL;
+ Assert(cArgs <= argc + 3);
+
+
+ /*
+ * The native DTrace we execute as a sub-process and wait for.
+ */
+ RTEXITCODE rcExit;
+ if (fIsNativeDTrace)
+ {
+ RTPROCESS hProc;
+ rc = RTProcCreate(szDTraceCmd, papszArgs, RTENV_DEFAULT, 0, &hProc);
+ if (RT_SUCCESS(rc))
+ {
+ RTPROCSTATUS Status;
+ rc = RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &Status);
+ if (RT_SUCCESS(rc))
+ {
+ if (Status.enmReason == RTPROCEXITREASON_NORMAL)
+ rcExit = (RTEXITCODE)Status.iStatus;
+ else
+ rcExit = RTEXITCODE_FAILURE;
+ }
+ else
+ rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Error waiting for child process: %Rrc", rc);
+ }
+ else
+ rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Error executing '%s': %Rrc", szDTraceCmd, rc);
+ }
+ /*
+ * While the VBoxDTrace we load and call the main function of.
+ */
+ else
+ {
+ RTERRINFOSTATIC ErrInfo;
+ RTLDRMOD hMod;
+ rc = SUPR3HardenedLdrLoadPlugIn(szDTraceCmd, &hMod, RTErrInfoInitStatic(&ErrInfo));
+ if (RT_SUCCESS(rc))
+ {
+ PFNVBOXDTRACEMAIN pfnVBoxDTraceMain;
+ rc = RTLdrGetSymbol(hMod, "VBoxDTraceMain", (void **)&pfnVBoxDTraceMain);
+ if (RT_SUCCESS(rc))
+ rcExit = (RTEXITCODE)pfnVBoxDTraceMain(cArgs, papszArgs);
+ else
+ rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Error locating 'VBoxDTraceMain' in '%s': %Rrc", szDTraceCmd, rc);
+ }
+ else
+ rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Error loading '%s': %Rrc (%s)", szDTraceCmd, rc, ErrInfo.szMsg);
+ }
+ return rcExit;
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.c b/src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.c
new file mode 100644
index 00000000..7ba1a4bb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.c
@@ -0,0 +1,3729 @@
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.4.1"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 189 of yacc.c */
+#line 1 "dt_grammar.y"
+
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#else
+# ifdef _MSC_VER
+# pragma warning(disable:4255 4702)
+# endif
+#endif
+
+#include <dt_impl.h>
+
+#define OP1(op, c) dt_node_op1(op, c)
+#define OP2(op, l, r) dt_node_op2(op, l, r)
+#define OP3(x, y, z) dt_node_op3(x, y, z)
+#define LINK(l, r) dt_node_link(l, r)
+#define DUP(s) strdup(s)
+
+#ifdef VBOX
+# define YYMALLOC RTMemAlloc
+# define YYFREE RTMemFree
+#endif
+
+
+
+
+/* Line 189 of yacc.c */
+#line 124 "dt_grammar.c"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ DT_TOK_EOF = 0,
+ DT_TOK_COMMA = 258,
+ DT_TOK_ELLIPSIS = 259,
+ DT_TOK_ASGN = 260,
+ DT_TOK_ADD_EQ = 261,
+ DT_TOK_SUB_EQ = 262,
+ DT_TOK_MUL_EQ = 263,
+ DT_TOK_DIV_EQ = 264,
+ DT_TOK_MOD_EQ = 265,
+ DT_TOK_AND_EQ = 266,
+ DT_TOK_XOR_EQ = 267,
+ DT_TOK_OR_EQ = 268,
+ DT_TOK_LSH_EQ = 269,
+ DT_TOK_RSH_EQ = 270,
+ DT_TOK_QUESTION = 271,
+ DT_TOK_COLON = 272,
+ DT_TOK_LOR = 273,
+ DT_TOK_LXOR = 274,
+ DT_TOK_LAND = 275,
+ DT_TOK_BOR = 276,
+ DT_TOK_XOR = 277,
+ DT_TOK_BAND = 278,
+ DT_TOK_EQU = 279,
+ DT_TOK_NEQ = 280,
+ DT_TOK_LT = 281,
+ DT_TOK_LE = 282,
+ DT_TOK_GT = 283,
+ DT_TOK_GE = 284,
+ DT_TOK_LSH = 285,
+ DT_TOK_RSH = 286,
+ DT_TOK_ADD = 287,
+ DT_TOK_SUB = 288,
+ DT_TOK_MUL = 289,
+ DT_TOK_DIV = 290,
+ DT_TOK_MOD = 291,
+ DT_TOK_LNEG = 292,
+ DT_TOK_BNEG = 293,
+ DT_TOK_ADDADD = 294,
+ DT_TOK_SUBSUB = 295,
+ DT_TOK_PREINC = 296,
+ DT_TOK_POSTINC = 297,
+ DT_TOK_PREDEC = 298,
+ DT_TOK_POSTDEC = 299,
+ DT_TOK_IPOS = 300,
+ DT_TOK_INEG = 301,
+ DT_TOK_DEREF = 302,
+ DT_TOK_ADDROF = 303,
+ DT_TOK_OFFSETOF = 304,
+ DT_TOK_SIZEOF = 305,
+ DT_TOK_STRINGOF = 306,
+ DT_TOK_XLATE = 307,
+ DT_TOK_LPAR = 308,
+ DT_TOK_RPAR = 309,
+ DT_TOK_LBRAC = 310,
+ DT_TOK_RBRAC = 311,
+ DT_TOK_PTR = 312,
+ DT_TOK_DOT = 313,
+ DT_TOK_STRING = 314,
+ DT_TOK_IDENT = 315,
+ DT_TOK_PSPEC = 316,
+ DT_TOK_AGG = 317,
+ DT_TOK_TNAME = 318,
+ DT_TOK_INT = 319,
+ DT_KEY_AUTO = 320,
+ DT_KEY_BREAK = 321,
+ DT_KEY_CASE = 322,
+ DT_KEY_CHAR = 323,
+ DT_KEY_CONST = 324,
+ DT_KEY_CONTINUE = 325,
+ DT_KEY_COUNTER = 326,
+ DT_KEY_DEFAULT = 327,
+ DT_KEY_DO = 328,
+ DT_KEY_DOUBLE = 329,
+ DT_KEY_ELSE = 330,
+ DT_KEY_ENUM = 331,
+ DT_KEY_EXTERN = 332,
+ DT_KEY_FLOAT = 333,
+ DT_KEY_FOR = 334,
+ DT_KEY_GOTO = 335,
+ DT_KEY_IF = 336,
+ DT_KEY_IMPORT = 337,
+ DT_KEY_INLINE = 338,
+ DT_KEY_INT = 339,
+ DT_KEY_LONG = 340,
+ DT_KEY_PROBE = 341,
+ DT_KEY_PROVIDER = 342,
+ DT_KEY_REGISTER = 343,
+ DT_KEY_RESTRICT = 344,
+ DT_KEY_RETURN = 345,
+ DT_KEY_SELF = 346,
+ DT_KEY_SHORT = 347,
+ DT_KEY_SIGNED = 348,
+ DT_KEY_STATIC = 349,
+ DT_KEY_STRING = 350,
+ DT_KEY_STRUCT = 351,
+ DT_KEY_SWITCH = 352,
+ DT_KEY_THIS = 353,
+ DT_KEY_TYPEDEF = 354,
+ DT_KEY_UNION = 355,
+ DT_KEY_UNSIGNED = 356,
+ DT_KEY_VOID = 357,
+ DT_KEY_VOLATILE = 358,
+ DT_KEY_WHILE = 359,
+ DT_KEY_XLATOR = 360,
+ DT_TOK_EPRED = 361,
+ DT_CTX_DEXPR = 362,
+ DT_CTX_DPROG = 363,
+ DT_CTX_DTYPE = 364
+ };
+#endif
+/* Tokens. */
+#define DT_TOK_EOF 0
+#define DT_TOK_COMMA 258
+#define DT_TOK_ELLIPSIS 259
+#define DT_TOK_ASGN 260
+#define DT_TOK_ADD_EQ 261
+#define DT_TOK_SUB_EQ 262
+#define DT_TOK_MUL_EQ 263
+#define DT_TOK_DIV_EQ 264
+#define DT_TOK_MOD_EQ 265
+#define DT_TOK_AND_EQ 266
+#define DT_TOK_XOR_EQ 267
+#define DT_TOK_OR_EQ 268
+#define DT_TOK_LSH_EQ 269
+#define DT_TOK_RSH_EQ 270
+#define DT_TOK_QUESTION 271
+#define DT_TOK_COLON 272
+#define DT_TOK_LOR 273
+#define DT_TOK_LXOR 274
+#define DT_TOK_LAND 275
+#define DT_TOK_BOR 276
+#define DT_TOK_XOR 277
+#define DT_TOK_BAND 278
+#define DT_TOK_EQU 279
+#define DT_TOK_NEQ 280
+#define DT_TOK_LT 281
+#define DT_TOK_LE 282
+#define DT_TOK_GT 283
+#define DT_TOK_GE 284
+#define DT_TOK_LSH 285
+#define DT_TOK_RSH 286
+#define DT_TOK_ADD 287
+#define DT_TOK_SUB 288
+#define DT_TOK_MUL 289
+#define DT_TOK_DIV 290
+#define DT_TOK_MOD 291
+#define DT_TOK_LNEG 292
+#define DT_TOK_BNEG 293
+#define DT_TOK_ADDADD 294
+#define DT_TOK_SUBSUB 295
+#define DT_TOK_PREINC 296
+#define DT_TOK_POSTINC 297
+#define DT_TOK_PREDEC 298
+#define DT_TOK_POSTDEC 299
+#define DT_TOK_IPOS 300
+#define DT_TOK_INEG 301
+#define DT_TOK_DEREF 302
+#define DT_TOK_ADDROF 303
+#define DT_TOK_OFFSETOF 304
+#define DT_TOK_SIZEOF 305
+#define DT_TOK_STRINGOF 306
+#define DT_TOK_XLATE 307
+#define DT_TOK_LPAR 308
+#define DT_TOK_RPAR 309
+#define DT_TOK_LBRAC 310
+#define DT_TOK_RBRAC 311
+#define DT_TOK_PTR 312
+#define DT_TOK_DOT 313
+#define DT_TOK_STRING 314
+#define DT_TOK_IDENT 315
+#define DT_TOK_PSPEC 316
+#define DT_TOK_AGG 317
+#define DT_TOK_TNAME 318
+#define DT_TOK_INT 319
+#define DT_KEY_AUTO 320
+#define DT_KEY_BREAK 321
+#define DT_KEY_CASE 322
+#define DT_KEY_CHAR 323
+#define DT_KEY_CONST 324
+#define DT_KEY_CONTINUE 325
+#define DT_KEY_COUNTER 326
+#define DT_KEY_DEFAULT 327
+#define DT_KEY_DO 328
+#define DT_KEY_DOUBLE 329
+#define DT_KEY_ELSE 330
+#define DT_KEY_ENUM 331
+#define DT_KEY_EXTERN 332
+#define DT_KEY_FLOAT 333
+#define DT_KEY_FOR 334
+#define DT_KEY_GOTO 335
+#define DT_KEY_IF 336
+#define DT_KEY_IMPORT 337
+#define DT_KEY_INLINE 338
+#define DT_KEY_INT 339
+#define DT_KEY_LONG 340
+#define DT_KEY_PROBE 341
+#define DT_KEY_PROVIDER 342
+#define DT_KEY_REGISTER 343
+#define DT_KEY_RESTRICT 344
+#define DT_KEY_RETURN 345
+#define DT_KEY_SELF 346
+#define DT_KEY_SHORT 347
+#define DT_KEY_SIGNED 348
+#define DT_KEY_STATIC 349
+#define DT_KEY_STRING 350
+#define DT_KEY_STRUCT 351
+#define DT_KEY_SWITCH 352
+#define DT_KEY_THIS 353
+#define DT_KEY_TYPEDEF 354
+#define DT_KEY_UNION 355
+#define DT_KEY_UNSIGNED 356
+#define DT_KEY_VOID 357
+#define DT_KEY_VOLATILE 358
+#define DT_KEY_WHILE 359
+#define DT_KEY_XLATOR 360
+#define DT_TOK_EPRED 361
+#define DT_CTX_DEXPR 362
+#define DT_CTX_DPROG 363
+#define DT_CTX_DTYPE 364
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 214 of yacc.c */
+#line 51 "dt_grammar.y"
+
+ dt_node_t *l_node;
+ dt_decl_t *l_decl;
+ char *l_str;
+ uintmax_t l_int;
+ int l_tok;
+
+
+
+/* Line 214 of yacc.c */
+#line 390 "dt_grammar.c"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 264 of yacc.c */
+#line 402 "dt_grammar.c"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined _STDLIB_H \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 99
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 837
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 113
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 81
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 239
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 363
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 364
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 110,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 111, 2, 112, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
+ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
+ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint16 yyprhs[] =
+{
+ 0, 0, 3, 6, 9, 12, 14, 17, 19, 22,
+ 24, 27, 29, 32, 34, 36, 38, 40, 42, 43,
+ 51, 62, 72, 74, 77, 82, 89, 95, 97, 100,
+ 107, 112, 114, 119, 124, 132, 134, 136, 140, 142,
+ 144, 146, 150, 151, 153, 155, 159, 161, 163, 165,
+ 167, 169, 171, 175, 177, 182, 186, 191, 195, 199,
+ 203, 207, 210, 213, 220, 227, 235, 237, 240, 243,
+ 246, 249, 254, 257, 259, 261, 263, 265, 267, 269,
+ 271, 276, 278, 282, 286, 290, 292, 296, 300, 302,
+ 306, 310, 312, 316, 320, 324, 328, 330, 334, 338,
+ 340, 344, 346, 350, 352, 356, 358, 362, 364, 368,
+ 370, 374, 376, 378, 384, 386, 390, 392, 394, 396,
+ 398, 400, 402, 404, 406, 408, 410, 412, 414, 418,
+ 421, 425, 427, 430, 432, 435, 437, 440, 442, 445,
+ 447, 450, 452, 455, 457, 459, 461, 463, 465, 467,
+ 469, 471, 473, 475, 477, 479, 481, 483, 485, 487,
+ 489, 491, 493, 495, 497, 499, 501, 503, 507, 510,
+ 513, 516, 520, 524, 526, 528, 530, 533, 535, 539,
+ 541, 545, 547, 550, 552, 555, 557, 561, 563, 566,
+ 570, 574, 577, 580, 583, 587, 591, 593, 597, 599,
+ 603, 605, 608, 610, 614, 617, 620, 622, 624, 627,
+ 630, 634, 636, 639, 641, 643, 647, 649, 653, 655,
+ 658, 661, 663, 666, 668, 670, 673, 677, 680, 682,
+ 685, 687, 688, 693, 694, 696, 698, 699, 704, 705
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int16 yyrhs[] =
+{
+ 114, 0, -1, 115, 0, -1, 116, 0, -1, 117,
+ 0, -1, 107, -1, 107, 155, -1, 108, -1, 108,
+ 118, -1, 109, -1, 109, 185, -1, 119, -1, 118,
+ 119, -1, 120, -1, 122, -1, 125, -1, 128, -1,
+ 156, -1, -1, 83, 157, 177, 121, 5, 153, 110,
+ -1, 105, 185, 26, 185, 60, 28, 111, 123, 112,
+ 110, -1, 105, 185, 26, 185, 60, 28, 111, 112,
+ 110, -1, 124, -1, 123, 124, -1, 60, 5, 153,
+ 110, -1, 87, 60, 111, 126, 112, 110, -1, 87,
+ 60, 111, 112, 110, -1, 127, -1, 126, 127, -1,
+ 86, 60, 191, 17, 191, 110, -1, 86, 60, 191,
+ 110, -1, 129, -1, 129, 111, 132, 112, -1, 129,
+ 35, 155, 106, -1, 129, 35, 155, 106, 111, 132,
+ 112, -1, 130, -1, 131, -1, 130, 3, 131, -1,
+ 61, -1, 64, -1, 133, -1, 132, 110, 133, -1,
+ -1, 155, -1, 153, -1, 134, 3, 153, -1, 60,
+ -1, 62, -1, 64, -1, 59, -1, 91, -1, 98,
+ -1, 53, 155, 54, -1, 135, -1, 136, 55, 134,
+ 56, -1, 136, 53, 54, -1, 136, 53, 134, 54,
+ -1, 136, 58, 60, -1, 136, 58, 63, -1, 136,
+ 57, 60, -1, 136, 57, 63, -1, 136, 39, -1,
+ 136, 40, -1, 49, 53, 185, 3, 60, 54, -1,
+ 49, 53, 185, 3, 63, 54, -1, 52, 26, 185,
+ 28, 53, 155, 54, -1, 136, -1, 39, 137, -1,
+ 40, 137, -1, 138, 139, -1, 50, 137, -1, 50,
+ 53, 185, 54, -1, 51, 137, -1, 23, -1, 34,
+ -1, 32, -1, 33, -1, 38, -1, 37, -1, 137,
+ -1, 53, 185, 54, 139, -1, 139, -1, 140, 34,
+ 139, -1, 140, 35, 139, -1, 140, 36, 139, -1,
+ 140, -1, 141, 32, 140, -1, 141, 33, 140, -1,
+ 141, -1, 142, 30, 141, -1, 142, 31, 141, -1,
+ 142, -1, 143, 26, 142, -1, 143, 28, 142, -1,
+ 143, 27, 142, -1, 143, 29, 142, -1, 143, -1,
+ 144, 24, 143, -1, 144, 25, 143, -1, 144, -1,
+ 145, 23, 144, -1, 145, -1, 146, 22, 145, -1,
+ 146, -1, 147, 21, 146, -1, 147, -1, 148, 20,
+ 147, -1, 148, -1, 149, 19, 148, -1, 149, -1,
+ 150, 18, 149, -1, 152, -1, 150, -1, 150, 16,
+ 155, 17, 152, -1, 152, -1, 137, 154, 153, -1,
+ 5, -1, 8, -1, 9, -1, 10, -1, 6, -1,
+ 7, -1, 14, -1, 15, -1, 11, -1, 12, -1,
+ 13, -1, 153, -1, 155, 3, 153, -1, 157, 110,
+ -1, 157, 167, 110, -1, 160, -1, 160, 157, -1,
+ 161, -1, 161, 157, -1, 162, -1, 162, 157, -1,
+ 159, -1, 159, 157, -1, 161, -1, 161, 157, -1,
+ 162, -1, 162, 157, -1, 65, -1, 88, -1, 94,
+ -1, 77, -1, 99, -1, 159, -1, 91, -1, 98,
+ -1, 102, -1, 68, -1, 92, -1, 84, -1, 85,
+ -1, 78, -1, 74, -1, 93, -1, 101, -1, 95,
+ -1, 63, -1, 163, -1, 173, -1, 69, -1, 89,
+ -1, 103, -1, 164, 166, 112, -1, 165, 60, -1,
+ 165, 63, -1, 165, 111, -1, 165, 60, 111, -1,
+ 165, 63, 111, -1, 96, -1, 100, -1, 169, -1,
+ 166, 169, -1, 168, -1, 167, 3, 168, -1, 177,
+ -1, 170, 171, 110, -1, 161, -1, 161, 170, -1,
+ 162, -1, 162, 170, -1, 172, -1, 171, 3, 172,
+ -1, 177, -1, 17, 151, -1, 177, 17, 151, -1,
+ 174, 175, 112, -1, 76, 60, -1, 76, 63, -1,
+ 76, 111, -1, 76, 60, 111, -1, 76, 63, 111,
+ -1, 176, -1, 175, 3, 176, -1, 60, -1, 60,
+ 5, 155, -1, 178, -1, 180, 178, -1, 60, -1,
+ 179, 177, 54, -1, 178, 188, -1, 178, 191, -1,
+ 53, -1, 34, -1, 34, 181, -1, 34, 180, -1,
+ 34, 181, 180, -1, 162, -1, 181, 162, -1, 183,
+ -1, 4, -1, 183, 3, 4, -1, 184, -1, 183,
+ 3, 184, -1, 158, -1, 158, 177, -1, 158, 186,
+ -1, 170, -1, 170, 186, -1, 180, -1, 187, -1,
+ 180, 187, -1, 179, 186, 54, -1, 187, 188, -1,
+ 188, -1, 187, 191, -1, 191, -1, -1, 55, 189,
+ 190, 56, -1, -1, 151, -1, 182, -1, -1, 53,
+ 192, 193, 54, -1, -1, 182, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 221, 221, 222, 223, 226, 227, 230, 231, 234,
+ 235, 239, 240, 244, 245, 246, 247, 248, 253, 252,
+ 268, 272, 279, 280, 284, 290, 293, 299, 300, 304,
+ 307, 314, 330, 333, 337, 344, 348, 349, 355, 356,
+ 359, 360, 363, 364, 368, 369, 375, 376, 377, 378,
+ 379, 380, 381, 385, 386, 390, 393, 397, 400, 403,
+ 406, 409, 412, 415, 419, 423, 430, 431, 432, 433,
+ 434, 435, 438, 443, 444, 445, 446, 447, 448, 452,
+ 453, 459, 460, 463, 466, 472, 473, 476, 482, 483,
+ 486, 492, 493, 496, 499, 502, 508, 509, 512, 518,
+ 519, 525, 526, 532, 533, 539, 540, 546, 547, 553,
+ 554, 559, 563, 564, 569, 570, 576, 577, 578, 579,
+ 580, 581, 582, 583, 584, 585, 586, 589, 590, 595,
+ 600, 608, 609, 610, 611, 612, 613, 617, 618, 619,
+ 620, 621, 622, 626, 627, 628, 629, 630, 634, 635,
+ 636, 639, 640, 641, 642, 643, 644, 645, 646, 647,
+ 648, 651, 652, 653, 656, 657, 658, 662, 665, 666,
+ 670, 671, 672, 676, 677, 681, 682, 686, 687, 693,
+ 700, 706, 707, 708, 709, 713, 714, 718, 719, 720,
+ 726, 727, 728, 732, 733, 734, 738, 739, 742, 743,
+ 748, 749, 753, 754, 755, 756, 759, 762, 763, 764,
+ 765, 769, 770, 774, 775, 776, 781, 782, 788, 791,
+ 794, 799, 802, 808, 809, 810, 814, 815, 816, 817,
+ 818, 821, 821, 829, 830, 831, 834, 834, 842, 843
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "DT_TOK_EOF", "error", "$undefined", "DT_TOK_COMMA", "DT_TOK_ELLIPSIS",
+ "DT_TOK_ASGN", "DT_TOK_ADD_EQ", "DT_TOK_SUB_EQ", "DT_TOK_MUL_EQ",
+ "DT_TOK_DIV_EQ", "DT_TOK_MOD_EQ", "DT_TOK_AND_EQ", "DT_TOK_XOR_EQ",
+ "DT_TOK_OR_EQ", "DT_TOK_LSH_EQ", "DT_TOK_RSH_EQ", "DT_TOK_QUESTION",
+ "DT_TOK_COLON", "DT_TOK_LOR", "DT_TOK_LXOR", "DT_TOK_LAND", "DT_TOK_BOR",
+ "DT_TOK_XOR", "DT_TOK_BAND", "DT_TOK_EQU", "DT_TOK_NEQ", "DT_TOK_LT",
+ "DT_TOK_LE", "DT_TOK_GT", "DT_TOK_GE", "DT_TOK_LSH", "DT_TOK_RSH",
+ "DT_TOK_ADD", "DT_TOK_SUB", "DT_TOK_MUL", "DT_TOK_DIV", "DT_TOK_MOD",
+ "DT_TOK_LNEG", "DT_TOK_BNEG", "DT_TOK_ADDADD", "DT_TOK_SUBSUB",
+ "DT_TOK_PREINC", "DT_TOK_POSTINC", "DT_TOK_PREDEC", "DT_TOK_POSTDEC",
+ "DT_TOK_IPOS", "DT_TOK_INEG", "DT_TOK_DEREF", "DT_TOK_ADDROF",
+ "DT_TOK_OFFSETOF", "DT_TOK_SIZEOF", "DT_TOK_STRINGOF", "DT_TOK_XLATE",
+ "DT_TOK_LPAR", "DT_TOK_RPAR", "DT_TOK_LBRAC", "DT_TOK_RBRAC",
+ "DT_TOK_PTR", "DT_TOK_DOT", "DT_TOK_STRING", "DT_TOK_IDENT",
+ "DT_TOK_PSPEC", "DT_TOK_AGG", "DT_TOK_TNAME", "DT_TOK_INT",
+ "DT_KEY_AUTO", "DT_KEY_BREAK", "DT_KEY_CASE", "DT_KEY_CHAR",
+ "DT_KEY_CONST", "DT_KEY_CONTINUE", "DT_KEY_COUNTER", "DT_KEY_DEFAULT",
+ "DT_KEY_DO", "DT_KEY_DOUBLE", "DT_KEY_ELSE", "DT_KEY_ENUM",
+ "DT_KEY_EXTERN", "DT_KEY_FLOAT", "DT_KEY_FOR", "DT_KEY_GOTO",
+ "DT_KEY_IF", "DT_KEY_IMPORT", "DT_KEY_INLINE", "DT_KEY_INT",
+ "DT_KEY_LONG", "DT_KEY_PROBE", "DT_KEY_PROVIDER", "DT_KEY_REGISTER",
+ "DT_KEY_RESTRICT", "DT_KEY_RETURN", "DT_KEY_SELF", "DT_KEY_SHORT",
+ "DT_KEY_SIGNED", "DT_KEY_STATIC", "DT_KEY_STRING", "DT_KEY_STRUCT",
+ "DT_KEY_SWITCH", "DT_KEY_THIS", "DT_KEY_TYPEDEF", "DT_KEY_UNION",
+ "DT_KEY_UNSIGNED", "DT_KEY_VOID", "DT_KEY_VOLATILE", "DT_KEY_WHILE",
+ "DT_KEY_XLATOR", "DT_TOK_EPRED", "DT_CTX_DEXPR", "DT_CTX_DPROG",
+ "DT_CTX_DTYPE", "';'", "'{'", "'}'", "$accept", "dtrace_program",
+ "d_expression", "d_program", "d_type", "translation_unit",
+ "external_declaration", "inline_definition", "$@1",
+ "translator_definition", "translator_member_list", "translator_member",
+ "provider_definition", "provider_probe_list", "provider_probe",
+ "probe_definition", "probe_specifiers", "probe_specifier_list",
+ "probe_specifier", "statement_list", "statement",
+ "argument_expression_list", "primary_expression", "postfix_expression",
+ "unary_expression", "unary_operator", "cast_expression",
+ "multiplicative_expression", "additive_expression", "shift_expression",
+ "relational_expression", "equality_expression", "and_expression",
+ "exclusive_or_expression", "inclusive_or_expression",
+ "logical_and_expression", "logical_xor_expression",
+ "logical_or_expression", "constant_expression", "conditional_expression",
+ "assignment_expression", "assignment_operator", "expression",
+ "declaration", "declaration_specifiers",
+ "parameter_declaration_specifiers", "storage_class_specifier",
+ "d_storage_class_specifier", "type_specifier", "type_qualifier",
+ "struct_or_union_specifier", "struct_or_union_definition",
+ "struct_or_union", "struct_declaration_list", "init_declarator_list",
+ "init_declarator", "struct_declaration", "specifier_qualifier_list",
+ "struct_declarator_list", "struct_declarator", "enum_specifier",
+ "enum_definition", "enumerator_list", "enumerator", "declarator",
+ "direct_declarator", "lparen", "pointer", "type_qualifier_list",
+ "parameter_type_list", "parameter_list", "parameter_declaration",
+ "type_name", "abstract_declarator", "direct_abstract_declarator",
+ "array", "$@2", "array_parameters", "function", "$@3",
+ "function_parameters", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+ 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
+ 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
+ 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
+ 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
+ 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
+ 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
+ 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
+ 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
+ 59, 123, 125
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 113, 114, 114, 114, 115, 115, 116, 116, 117,
+ 117, 118, 118, 119, 119, 119, 119, 119, 121, 120,
+ 122, 122, 123, 123, 124, 125, 125, 126, 126, 127,
+ 127, 128, 128, 128, 128, 129, 130, 130, 131, 131,
+ 132, 132, 133, 133, 134, 134, 135, 135, 135, 135,
+ 135, 135, 135, 136, 136, 136, 136, 136, 136, 136,
+ 136, 136, 136, 136, 136, 136, 137, 137, 137, 137,
+ 137, 137, 137, 138, 138, 138, 138, 138, 138, 139,
+ 139, 140, 140, 140, 140, 141, 141, 141, 142, 142,
+ 142, 143, 143, 143, 143, 143, 144, 144, 144, 145,
+ 145, 146, 146, 147, 147, 148, 148, 149, 149, 150,
+ 150, 151, 152, 152, 153, 153, 154, 154, 154, 154,
+ 154, 154, 154, 154, 154, 154, 154, 155, 155, 156,
+ 156, 157, 157, 157, 157, 157, 157, 158, 158, 158,
+ 158, 158, 158, 159, 159, 159, 159, 159, 160, 160,
+ 160, 161, 161, 161, 161, 161, 161, 161, 161, 161,
+ 161, 161, 161, 161, 162, 162, 162, 163, 163, 163,
+ 164, 164, 164, 165, 165, 166, 166, 167, 167, 168,
+ 169, 170, 170, 170, 170, 171, 171, 172, 172, 172,
+ 173, 173, 173, 174, 174, 174, 175, 175, 176, 176,
+ 177, 177, 178, 178, 178, 178, 179, 180, 180, 180,
+ 180, 181, 181, 182, 182, 182, 183, 183, 184, 184,
+ 184, 185, 185, 186, 186, 186, 187, 187, 187, 187,
+ 187, 189, 188, 190, 190, 190, 192, 191, 193, 193
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 2, 2, 2, 1, 2, 1, 2, 1,
+ 2, 1, 2, 1, 1, 1, 1, 1, 0, 7,
+ 10, 9, 1, 2, 4, 6, 5, 1, 2, 6,
+ 4, 1, 4, 4, 7, 1, 1, 3, 1, 1,
+ 1, 3, 0, 1, 1, 3, 1, 1, 1, 1,
+ 1, 1, 3, 1, 4, 3, 4, 3, 3, 3,
+ 3, 2, 2, 6, 6, 7, 1, 2, 2, 2,
+ 2, 4, 2, 1, 1, 1, 1, 1, 1, 1,
+ 4, 1, 3, 3, 3, 1, 3, 3, 1, 3,
+ 3, 1, 3, 3, 3, 3, 1, 3, 3, 1,
+ 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
+ 3, 1, 1, 5, 1, 3, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2,
+ 3, 1, 2, 1, 2, 1, 2, 1, 2, 1,
+ 2, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 3, 2, 2,
+ 2, 3, 3, 1, 1, 1, 2, 1, 3, 1,
+ 3, 1, 2, 1, 2, 1, 3, 1, 2, 3,
+ 3, 2, 2, 2, 3, 3, 1, 3, 1, 3,
+ 1, 2, 1, 3, 2, 2, 1, 1, 2, 2,
+ 3, 1, 2, 1, 1, 3, 1, 3, 1, 2,
+ 2, 1, 2, 1, 1, 2, 3, 2, 1, 2,
+ 1, 0, 4, 0, 1, 1, 0, 4, 0, 1
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 5, 7, 9, 0, 0, 0, 0, 73, 75,
+ 76, 74, 78, 77, 0, 0, 0, 0, 0, 0,
+ 0, 49, 46, 47, 48, 50, 51, 53, 66, 79,
+ 0, 81, 85, 88, 91, 96, 99, 101, 103, 105,
+ 107, 109, 112, 114, 127, 6, 38, 161, 39, 143,
+ 152, 164, 157, 0, 146, 156, 0, 154, 155, 0,
+ 144, 165, 149, 153, 158, 145, 160, 173, 150, 147,
+ 174, 159, 151, 166, 0, 8, 11, 13, 14, 15,
+ 16, 31, 35, 36, 17, 0, 148, 131, 133, 135,
+ 162, 0, 0, 163, 0, 181, 183, 221, 10, 1,
+ 2, 3, 4, 0, 67, 68, 0, 0, 70, 72,
+ 0, 0, 0, 61, 62, 0, 0, 0, 0, 116,
+ 120, 121, 117, 118, 119, 124, 125, 126, 122, 123,
+ 0, 79, 69, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 191, 192, 193, 0, 0, 0,
+ 12, 0, 42, 0, 207, 206, 202, 129, 0, 177,
+ 179, 200, 0, 0, 132, 134, 136, 0, 175, 0,
+ 168, 169, 170, 198, 0, 196, 182, 184, 236, 231,
+ 0, 223, 222, 224, 228, 230, 0, 0, 0, 52,
+ 0, 55, 0, 44, 0, 59, 60, 57, 58, 115,
+ 82, 83, 84, 86, 87, 89, 90, 92, 94, 93,
+ 95, 97, 98, 100, 102, 104, 106, 108, 0, 110,
+ 128, 194, 195, 18, 0, 0, 0, 0, 40, 43,
+ 37, 211, 209, 208, 0, 130, 236, 204, 205, 0,
+ 201, 167, 176, 0, 0, 185, 187, 171, 172, 0,
+ 0, 190, 238, 233, 0, 225, 227, 229, 0, 71,
+ 0, 80, 0, 56, 54, 0, 0, 0, 0, 0,
+ 27, 0, 33, 42, 32, 212, 210, 178, 203, 188,
+ 111, 0, 180, 0, 199, 197, 214, 218, 137, 139,
+ 141, 239, 213, 216, 0, 234, 235, 0, 226, 0,
+ 0, 0, 45, 113, 0, 0, 26, 0, 28, 0,
+ 42, 41, 186, 189, 219, 0, 223, 220, 138, 140,
+ 142, 0, 237, 232, 63, 64, 0, 0, 0, 25,
+ 0, 0, 215, 217, 65, 19, 0, 30, 0, 34,
+ 0, 0, 0, 0, 22, 29, 0, 21, 0, 23,
+ 0, 20, 24
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int16 yydefgoto[] =
+{
+ -1, 4, 5, 6, 7, 75, 76, 77, 276, 78,
+ 353, 354, 79, 279, 280, 80, 81, 82, 83, 237,
+ 238, 202, 27, 28, 131, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 289, 43,
+ 44, 130, 111, 84, 85, 297, 86, 87, 95, 96,
+ 90, 91, 92, 177, 168, 169, 178, 97, 254, 255,
+ 93, 94, 184, 185, 170, 171, 172, 173, 243, 301,
+ 302, 303, 98, 264, 193, 194, 263, 307, 195, 262,
+ 304
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -224
+static const yytype_int16 yypact[] =
+{
+ 148, 553, 641, 723, 26, 49, 57, 76, -224, -224,
+ -224, -224, -224, -224, 596, 596, 88, 629, 596, 72,
+ 446, -224, -224, -224, -224, -224, -224, -224, 179, 822,
+ 553, -224, 152, 37, 118, 109, 56, 132, 137, 154,
+ 149, 162, 175, -224, -224, 205, -224, -224, -224, -224,
+ -224, -224, -224, 11, -224, -224, 682, -224, -224, 155,
+ -224, -224, -224, -224, -224, -224, -224, -224, -224, -224,
+ -224, -224, -224, -224, 723, 641, -224, -224, -224, -224,
+ -224, 10, 217, -224, -224, 7, -224, 682, 682, 682,
+ -224, 723, 22, -224, 167, 723, 723, 139, -224, -224,
+ -224, -224, -224, 553, -224, -224, 723, 446, -224, -224,
+ 723, 58, 177, -224, -224, 520, 553, -5, 80, -224,
+ -224, -224, -224, -224, -224, -224, -224, -224, -224, -224,
+ 553, -224, -224, 553, 553, 553, 553, 553, 553, 553,
+ 553, 553, 553, 553, 553, 553, 553, 553, 553, 553,
+ 553, 553, 553, 553, 127, 131, -224, 110, 133, 209,
+ -224, 553, 553, 81, 4, -224, -224, -224, 17, -224,
+ -224, 145, 110, 50, -224, -224, -224, 121, -224, 94,
+ 159, 161, -224, 243, 18, -224, -224, -224, 119, -224,
+ 139, 156, -224, 145, -224, -224, 247, 213, 231, -224,
+ 553, -224, 62, -224, 48, -224, -224, -224, -224, -224,
+ -224, -224, -224, 152, 152, 37, 37, 118, 118, 118,
+ 118, 109, 109, 56, 132, 137, 154, 149, 45, 162,
+ -224, -224, -224, -224, -49, 723, 19, 116, -224, 205,
+ -224, -224, -224, 4, 110, -224, -224, -224, -224, 219,
+ 145, -224, -224, 553, 21, -224, 257, -224, -224, 553,
+ 167, -224, 331, 289, 221, 145, -224, -224, 117, -224,
+ 223, -224, 553, -224, -224, 553, 272, 218, 169, -44,
+ -224, 220, 170, 553, -224, -224, -224, -224, -224, -224,
+ -224, 94, -224, 553, -224, -224, -224, 123, 682, 682,
+ 682, -224, 280, -224, 230, -224, -224, 229, -224, 232,
+ 233, 553, -224, -224, 553, 236, -224, 180, -224, 263,
+ 553, -224, -224, -224, -224, 123, 79, -224, -224, -224,
+ -224, 372, -224, -224, -224, -224, 69, 182, 16, -224,
+ 183, 129, -224, -224, -224, -224, 236, -224, -35, -224,
+ 185, 291, 187, -13, -224, -224, 553, -224, 194, -224,
+ 195, -224, -224
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int16 yypgoto[] =
+{
+ -224, -224, -224, -224, -224, -224, 234, -224, -224, -224,
+ -224, -47, -224, -224, 28, -224, -224, -224, 151, -12,
+ 32, 201, -224, -224, -1, -224, -15, 66, 122, 111,
+ 124, 165, 171, 172, 181, 174, 184, -224, -210, -209,
+ -107, -224, 5, -224, -53, -224, -223, -224, 3, 0,
+ -224, -224, -224, -224, -224, 89, 160, -64, -224, 41,
+ -224, -224, -224, 83, -129, -155, -96, -85, -224, 82,
+ -224, 13, -10, -93, -180, -141, -224, -224, -164, -224,
+ -224
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -207
+static const yytype_int16 yytable[] =
+{
+ 29, 190, 89, 157, 192, 88, 45, 248, 203, 203,
+ 112, 265, 191, 104, 105, 132, 108, 109, 250, 29,
+ 244, 260, 153, 209, 291, 351, 99, 179, 233, 267,
+ 247, 186, 187, 346, 174, 175, 176, 277, 164, 298,
+ 298, 164, 277, 249, 290, 161, 230, 351, 153, 100,
+ 256, 272, 266, 305, 290, 205, 89, 101, 206, 88,
+ 165, 153, 275, 278, 159, 272, 313, 166, 317, 136,
+ 137, 154, 153, 51, 155, 89, 102, 352, 88, 242,
+ 144, 145, 180, 323, 290, 181, 248, 89, 89, 89,
+ 88, 88, 88, 61, 190, 190, 196, 197, 110, 358,
+ 198, 267, 29, 165, 274, 191, 29, 73, 298, 247,
+ 166, 253, 199, 179, 29, 29, 273, 167, 210, 211,
+ 212, 162, 156, 344, 266, 282, 347, 245, 164, 29,
+ 261, 292, 188, 182, 189, 140, 141, 142, 143, 166,
+ 207, 106, 46, 208, 164, 48, 265, 165, 138, 139,
+ 29, 338, 29, -206, 166, 146, 228, 164, 286, 147,
+ 29, 29, 256, 165, 241, 312, 236, 239, 324, 149,
+ 166, 250, -206, 164, -206, 148, 188, 309, 189, -206,
+ 310, 150, 350, 166, 47, 271, 133, 134, 135, 50,
+ 51, 151, 188, 152, 189, 52, 249, 53, 246, 55,
+ 189, 325, 213, 214, 327, 57, 58, 337, 153, 188,
+ 61, 189, 326, 63, 64, 158, 66, 67, 113, 114,
+ 163, 70, 71, 72, 73, 281, 283, 183, 284, 325,
+ 325, 200, 115, 251, 116, 235, 117, 118, 231, 283,
+ 326, 349, 232, 285, 234, 328, 329, 330, 259, 360,
+ 268, 217, 218, 219, 220, 1, 2, 3, 29, 270,
+ 215, 216, 300, 300, 294, 299, 299, 269, 221, 222,
+ 257, 29, 258, 288, 293, 308, 311, 314, 315, 316,
+ 319, 320, 29, 331, 332, 333, 334, 335, 239, 246,
+ 339, 340, 345, 296, 348, 355, 356, 357, 89, 89,
+ 89, 88, 88, 88, 361, 362, 359, 318, 341, 160,
+ 29, 223, 8, 29, 240, 321, 336, 204, 224, 29,
+ 225, 9, 10, 11, 227, 239, 12, 13, 14, 15,
+ 226, 300, 322, 287, 299, 296, 229, 252, 16, 17,
+ 18, 19, 20, 295, 343, 306, 0, 0, 21, 22,
+ 0, 23, 47, 24, 49, 29, 0, 50, 51, 0,
+ 0, 0, 0, 52, 0, 53, 54, 55, 0, 0,
+ 0, 0, 0, 57, 58, 0, 342, 60, 61, 0,
+ 25, 63, 64, 65, 66, 67, 0, 26, 69, 70,
+ 71, 72, 73, 0, 47, 0, 49, 0, 0, 50,
+ 51, 0, 0, 0, 0, 52, 0, 53, 54, 55,
+ 0, 0, 0, 0, 0, 57, 58, 0, 0, 60,
+ 61, 0, 0, 63, 64, 65, 66, 67, 0, 0,
+ 69, 70, 71, 72, 73, 47, 0, 49, 0, 0,
+ 50, 51, 0, 0, 0, 0, 52, 0, 53, 54,
+ 55, 0, 0, 0, 0, 0, 57, 58, 0, 0,
+ 60, 61, 0, 0, 63, 64, 65, 66, 67, 8,
+ 0, 69, 70, 71, 72, 73, 0, 0, 9, 10,
+ 11, 0, 0, 12, 13, 14, 15, 0, 0, 0,
+ 0, 0, 0, 0, 0, 16, 17, 18, 19, 20,
+ 0, 0, 0, 0, 0, 21, 22, 0, 23, 47,
+ 24, 0, 0, 0, 50, 51, 0, 0, 0, 0,
+ 52, 0, 53, 0, 55, 0, 0, 0, 0, 0,
+ 57, 58, 0, 0, 0, 61, 0, 25, 63, 64,
+ 0, 66, 67, 8, 26, 0, 70, 71, 72, 73,
+ 0, 0, 9, 10, 11, 0, 0, 12, 13, 14,
+ 15, 0, 0, 0, 0, 0, 0, 0, 0, 16,
+ 17, 18, 19, 20, 201, 0, 8, 0, 0, 21,
+ 22, 0, 23, 0, 24, 9, 10, 11, 0, 0,
+ 12, 13, 14, 15, 0, 0, 0, 0, 0, 0,
+ 0, 0, 16, 17, 18, 19, 20, 0, 0, 0,
+ 0, 25, 21, 22, 0, 23, 0, 24, 26, 8,
+ 0, 0, 0, 0, 0, 0, 0, 0, 9, 10,
+ 11, 0, 0, 12, 13, 14, 15, 0, 0, 0,
+ 0, 0, 0, 0, 25, 16, 17, 18, 19, 103,
+ 0, 26, 8, 0, 0, 21, 22, 0, 23, 0,
+ 24, 9, 10, 11, 0, 0, 12, 13, 14, 15,
+ 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
+ 18, 19, 107, 0, 0, 0, 0, 25, 21, 22,
+ 0, 23, 0, 24, 26, 0, 0, 0, 0, 0,
+ 0, 0, 46, 0, 47, 48, 49, 0, 0, 50,
+ 51, 0, 0, 0, 0, 52, 0, 53, 54, 55,
+ 25, 0, 0, 0, 56, 57, 58, 26, 59, 60,
+ 61, 0, 62, 63, 64, 65, 66, 67, 0, 68,
+ 69, 70, 71, 72, 73, 47, 74, 49, 0, 0,
+ 50, 51, 0, 0, 0, 0, 52, 0, 53, 54,
+ 55, 0, 0, 0, 0, 0, 57, 58, 0, 0,
+ 60, 61, 0, 62, 63, 64, 65, 66, 67, 0,
+ 68, 69, 70, 71, 72, 73, 47, 0, 0, 0,
+ 0, 50, 51, 0, 0, 0, 0, 52, 0, 53,
+ 0, 55, 0, 0, 0, 0, 0, 57, 58, 0,
+ 0, 0, 61, 0, 0, 63, 64, 0, 66, 67,
+ 0, 0, 0, 70, 71, 72, 73, 119, 120, 121,
+ 122, 123, 124, 125, 126, 127, 128, 129
+};
+
+static const yytype_int16 yycheck[] =
+{
+ 1, 97, 2, 56, 97, 2, 1, 171, 115, 116,
+ 20, 191, 97, 14, 15, 30, 17, 18, 173, 20,
+ 3, 3, 3, 130, 3, 60, 0, 91, 157, 193,
+ 171, 95, 96, 17, 87, 88, 89, 86, 34, 262,
+ 263, 34, 86, 172, 253, 35, 153, 60, 3, 0,
+ 179, 3, 193, 263, 263, 60, 56, 0, 63, 56,
+ 53, 3, 17, 112, 74, 3, 275, 60, 112, 32,
+ 33, 60, 3, 69, 63, 75, 0, 112, 75, 164,
+ 24, 25, 60, 293, 293, 63, 250, 87, 88, 89,
+ 87, 88, 89, 89, 190, 191, 106, 107, 26, 112,
+ 110, 265, 103, 53, 56, 190, 107, 103, 331, 250,
+ 60, 17, 54, 177, 115, 116, 54, 110, 133, 134,
+ 135, 111, 111, 54, 265, 106, 110, 110, 34, 130,
+ 112, 110, 53, 111, 55, 26, 27, 28, 29, 60,
+ 60, 53, 61, 63, 34, 64, 326, 53, 30, 31,
+ 151, 315, 153, 34, 60, 23, 151, 34, 243, 22,
+ 161, 162, 291, 53, 164, 272, 161, 162, 297, 20,
+ 60, 326, 53, 34, 55, 21, 53, 60, 55, 60,
+ 63, 19, 346, 60, 63, 200, 34, 35, 36, 68,
+ 69, 16, 53, 18, 55, 74, 325, 76, 53, 78,
+ 55, 297, 136, 137, 297, 84, 85, 314, 3, 53,
+ 89, 55, 297, 92, 93, 60, 95, 96, 39, 40,
+ 3, 100, 101, 102, 103, 235, 110, 60, 112, 325,
+ 326, 54, 53, 112, 55, 26, 57, 58, 111, 110,
+ 325, 112, 111, 243, 111, 298, 299, 300, 5, 356,
+ 3, 140, 141, 142, 143, 107, 108, 109, 259, 28,
+ 138, 139, 262, 263, 259, 262, 263, 54, 144, 145,
+ 111, 272, 111, 54, 17, 54, 53, 5, 60, 110,
+ 60, 111, 283, 3, 54, 56, 54, 54, 283, 53,
+ 110, 28, 110, 4, 111, 110, 5, 110, 298, 299,
+ 300, 298, 299, 300, 110, 110, 353, 279, 320, 75,
+ 311, 146, 23, 314, 163, 283, 311, 116, 147, 320,
+ 148, 32, 33, 34, 150, 320, 37, 38, 39, 40,
+ 149, 331, 291, 244, 331, 4, 152, 177, 49, 50,
+ 51, 52, 53, 260, 331, 263, -1, -1, 59, 60,
+ -1, 62, 63, 64, 65, 356, -1, 68, 69, -1,
+ -1, -1, -1, 74, -1, 76, 77, 78, -1, -1,
+ -1, -1, -1, 84, 85, -1, 4, 88, 89, -1,
+ 91, 92, 93, 94, 95, 96, -1, 98, 99, 100,
+ 101, 102, 103, -1, 63, -1, 65, -1, -1, 68,
+ 69, -1, -1, -1, -1, 74, -1, 76, 77, 78,
+ -1, -1, -1, -1, -1, 84, 85, -1, -1, 88,
+ 89, -1, -1, 92, 93, 94, 95, 96, -1, -1,
+ 99, 100, 101, 102, 103, 63, -1, 65, -1, -1,
+ 68, 69, -1, -1, -1, -1, 74, -1, 76, 77,
+ 78, -1, -1, -1, -1, -1, 84, 85, -1, -1,
+ 88, 89, -1, -1, 92, 93, 94, 95, 96, 23,
+ -1, 99, 100, 101, 102, 103, -1, -1, 32, 33,
+ 34, -1, -1, 37, 38, 39, 40, -1, -1, -1,
+ -1, -1, -1, -1, -1, 49, 50, 51, 52, 53,
+ -1, -1, -1, -1, -1, 59, 60, -1, 62, 63,
+ 64, -1, -1, -1, 68, 69, -1, -1, -1, -1,
+ 74, -1, 76, -1, 78, -1, -1, -1, -1, -1,
+ 84, 85, -1, -1, -1, 89, -1, 91, 92, 93,
+ -1, 95, 96, 23, 98, -1, 100, 101, 102, 103,
+ -1, -1, 32, 33, 34, -1, -1, 37, 38, 39,
+ 40, -1, -1, -1, -1, -1, -1, -1, -1, 49,
+ 50, 51, 52, 53, 54, -1, 23, -1, -1, 59,
+ 60, -1, 62, -1, 64, 32, 33, 34, -1, -1,
+ 37, 38, 39, 40, -1, -1, -1, -1, -1, -1,
+ -1, -1, 49, 50, 51, 52, 53, -1, -1, -1,
+ -1, 91, 59, 60, -1, 62, -1, 64, 98, 23,
+ -1, -1, -1, -1, -1, -1, -1, -1, 32, 33,
+ 34, -1, -1, 37, 38, 39, 40, -1, -1, -1,
+ -1, -1, -1, -1, 91, 49, 50, 51, 52, 53,
+ -1, 98, 23, -1, -1, 59, 60, -1, 62, -1,
+ 64, 32, 33, 34, -1, -1, 37, 38, 39, 40,
+ -1, -1, -1, -1, -1, -1, -1, -1, 49, 50,
+ 51, 52, 53, -1, -1, -1, -1, 91, 59, 60,
+ -1, 62, -1, 64, 98, -1, -1, -1, -1, -1,
+ -1, -1, 61, -1, 63, 64, 65, -1, -1, 68,
+ 69, -1, -1, -1, -1, 74, -1, 76, 77, 78,
+ 91, -1, -1, -1, 83, 84, 85, 98, 87, 88,
+ 89, -1, 91, 92, 93, 94, 95, 96, -1, 98,
+ 99, 100, 101, 102, 103, 63, 105, 65, -1, -1,
+ 68, 69, -1, -1, -1, -1, 74, -1, 76, 77,
+ 78, -1, -1, -1, -1, -1, 84, 85, -1, -1,
+ 88, 89, -1, 91, 92, 93, 94, 95, 96, -1,
+ 98, 99, 100, 101, 102, 103, 63, -1, -1, -1,
+ -1, 68, 69, -1, -1, -1, -1, 74, -1, 76,
+ -1, 78, -1, -1, -1, -1, -1, 84, 85, -1,
+ -1, -1, 89, -1, -1, 92, 93, -1, 95, 96,
+ -1, -1, -1, 100, 101, 102, 103, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 107, 108, 109, 114, 115, 116, 117, 23, 32,
+ 33, 34, 37, 38, 39, 40, 49, 50, 51, 52,
+ 53, 59, 60, 62, 64, 91, 98, 135, 136, 137,
+ 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
+ 148, 149, 150, 152, 153, 155, 61, 63, 64, 65,
+ 68, 69, 74, 76, 77, 78, 83, 84, 85, 87,
+ 88, 89, 91, 92, 93, 94, 95, 96, 98, 99,
+ 100, 101, 102, 103, 105, 118, 119, 120, 122, 125,
+ 128, 129, 130, 131, 156, 157, 159, 160, 161, 162,
+ 163, 164, 165, 173, 174, 161, 162, 170, 185, 0,
+ 0, 0, 0, 53, 137, 137, 53, 53, 137, 137,
+ 26, 155, 185, 39, 40, 53, 55, 57, 58, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 154, 137, 139, 34, 35, 36, 32, 33, 30, 31,
+ 26, 27, 28, 29, 24, 25, 23, 22, 21, 20,
+ 19, 16, 18, 3, 60, 63, 111, 157, 60, 185,
+ 119, 35, 111, 3, 34, 53, 60, 110, 167, 168,
+ 177, 178, 179, 180, 157, 157, 157, 166, 169, 170,
+ 60, 63, 111, 60, 175, 176, 170, 170, 53, 55,
+ 179, 180, 186, 187, 188, 191, 185, 185, 185, 54,
+ 54, 54, 134, 153, 134, 60, 63, 60, 63, 153,
+ 139, 139, 139, 140, 140, 141, 141, 142, 142, 142,
+ 142, 143, 143, 144, 145, 146, 147, 148, 155, 149,
+ 153, 111, 111, 177, 111, 26, 155, 132, 133, 155,
+ 131, 162, 180, 181, 3, 110, 53, 188, 191, 177,
+ 178, 112, 169, 17, 171, 172, 177, 111, 111, 5,
+ 3, 112, 192, 189, 186, 187, 188, 191, 3, 54,
+ 28, 139, 3, 54, 56, 17, 121, 86, 112, 126,
+ 127, 185, 106, 110, 112, 162, 180, 168, 54, 151,
+ 152, 3, 110, 17, 155, 176, 4, 158, 159, 161,
+ 162, 182, 183, 184, 193, 151, 182, 190, 54, 60,
+ 63, 53, 153, 152, 5, 60, 110, 112, 127, 60,
+ 111, 133, 172, 151, 177, 179, 180, 186, 157, 157,
+ 157, 3, 54, 56, 54, 54, 155, 153, 191, 110,
+ 28, 132, 4, 184, 54, 110, 17, 110, 111, 112,
+ 191, 60, 112, 123, 124, 110, 5, 110, 112, 124,
+ 153, 110, 110
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+
+#define YYFAIL goto yyerrlab
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ yytoken = YYTRANSLATE (yychar); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into YYRESULT an error message about the unexpected token
+ YYCHAR while in state YYSTATE. Return the number of bytes copied,
+ including the terminating null byte. If YYRESULT is null, do not
+ copy anything; just return the number of bytes that would be
+ copied. As a special case, return 0 if an ordinary "syntax error"
+ message will do. Return YYSIZE_MAXIMUM if overflow occurs during
+ size calculation. */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
+{
+ int yyn = yypact[yystate];
+
+ if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+ return 0;
+ else
+ {
+ int yytype = YYTRANSLATE (yychar);
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ int yysize_overflow = 0;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ int yyx;
+
+# if 0
+ /* This is so xgettext sees the translatable formats that are
+ constructed on the fly. */
+ YY_("syntax error, unexpected %s");
+ YY_("syntax error, unexpected %s, expecting %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+ char *yyfmt;
+ char const *yyf;
+ static char const yyunexpected[] = "syntax error, unexpected %s";
+ static char const yyexpecting[] = ", expecting %s";
+ static char const yyor[] = " or %s";
+ char yyformat[sizeof yyunexpected
+ + sizeof yyexpecting - 1
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+ * (sizeof yyor - 1))];
+ char const *yyprefix = yyexpecting;
+
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yycount = 1;
+
+ yyarg[0] = yytname[yytype];
+ yyfmt = yystpcpy (yyformat, yyunexpected);
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ yyformat[sizeof yyunexpected - 1] = '\0';
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+ yyfmt = yystpcpy (yyfmt, yyprefix);
+ yyprefix = yyor;
+ }
+
+ yyf = YY_(yyformat);
+ yysize1 = yysize + yystrlen (yyf);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+
+ if (yysize_overflow)
+ return YYSIZE_MAXIMUM;
+
+ if (yyresult)
+ {
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ char *yyp = yyresult;
+ int yyi = 0;
+ while ((*yyp = *yyf) != '\0')
+ {
+ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyf += 2;
+ }
+ else
+ {
+ yyp++;
+ yyf++;
+ }
+ }
+ }
+ return yysize;
+ }
+}
+#endif /* YYERROR_VERBOSE */
+
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+
+
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yyn == YYPACT_NINF)
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yyn == 0 || yyn == YYTABLE_NINF)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 2:
+
+/* Line 1455 of yacc.c */
+#line 221 "dt_grammar.y"
+ { return (dt_node_root((yyvsp[(1) - (2)].l_node))); }
+ break;
+
+ case 3:
+
+/* Line 1455 of yacc.c */
+#line 222 "dt_grammar.y"
+ { return (dt_node_root((yyvsp[(1) - (2)].l_node))); }
+ break;
+
+ case 4:
+
+/* Line 1455 of yacc.c */
+#line 223 "dt_grammar.y"
+ { return (dt_node_root((yyvsp[(1) - (2)].l_node))); }
+ break;
+
+ case 5:
+
+/* Line 1455 of yacc.c */
+#line 226 "dt_grammar.y"
+ { (yyval.l_node) = NULL; }
+ break;
+
+ case 6:
+
+/* Line 1455 of yacc.c */
+#line 227 "dt_grammar.y"
+ { (yyval.l_node) = (yyvsp[(2) - (2)].l_node); }
+ break;
+
+ case 7:
+
+/* Line 1455 of yacc.c */
+#line 230 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_program(NULL); }
+ break;
+
+ case 8:
+
+/* Line 1455 of yacc.c */
+#line 231 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_program((yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 9:
+
+/* Line 1455 of yacc.c */
+#line 234 "dt_grammar.y"
+ { (yyval.l_node) = NULL; }
+ break;
+
+ case 10:
+
+/* Line 1455 of yacc.c */
+#line 235 "dt_grammar.y"
+ { (yyval.l_node) = (dt_node_t *)(yyvsp[(2) - (2)].l_decl); }
+ break;
+
+ case 12:
+
+/* Line 1455 of yacc.c */
+#line 240 "dt_grammar.y"
+ { (yyval.l_node) = LINK((yyvsp[(1) - (2)].l_node), (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 18:
+
+/* Line 1455 of yacc.c */
+#line 253 "dt_grammar.y"
+ { dt_scope_push(NULL, CTF_ERR); }
+ break;
+
+ case 19:
+
+/* Line 1455 of yacc.c */
+#line 254 "dt_grammar.y"
+ {
+ /*
+ * We push a new declaration scope before shifting the
+ * assignment_expression in order to preserve ds_class
+ * and ds_ident for use in dt_node_inline(). Once the
+ * entire inline_definition rule is matched, pop the
+ * scope and construct the inline using the saved decl.
+ */
+ dt_scope_pop();
+ (yyval.l_node) = dt_node_inline((yyvsp[(6) - (7)].l_node));
+ }
+ break;
+
+ case 20:
+
+/* Line 1455 of yacc.c */
+#line 269 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_xlator((yyvsp[(2) - (10)].l_decl), (yyvsp[(4) - (10)].l_decl), (yyvsp[(5) - (10)].l_str), (yyvsp[(8) - (10)].l_node));
+ }
+ break;
+
+ case 21:
+
+/* Line 1455 of yacc.c */
+#line 273 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_xlator((yyvsp[(2) - (9)].l_decl), (yyvsp[(4) - (9)].l_decl), (yyvsp[(5) - (9)].l_str), NULL);
+ }
+ break;
+
+ case 23:
+
+/* Line 1455 of yacc.c */
+#line 280 "dt_grammar.y"
+ { (yyval.l_node) = LINK((yyvsp[(1) - (2)].l_node),(yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 24:
+
+/* Line 1455 of yacc.c */
+#line 284 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_member(NULL, (yyvsp[(1) - (4)].l_str), (yyvsp[(3) - (4)].l_node));
+ }
+ break;
+
+ case 25:
+
+/* Line 1455 of yacc.c */
+#line 290 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_provider((yyvsp[(2) - (6)].l_str), (yyvsp[(4) - (6)].l_node));
+ }
+ break;
+
+ case 26:
+
+/* Line 1455 of yacc.c */
+#line 293 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_provider((yyvsp[(2) - (5)].l_str), NULL);
+ }
+ break;
+
+ case 28:
+
+/* Line 1455 of yacc.c */
+#line 300 "dt_grammar.y"
+ { (yyval.l_node) = LINK((yyvsp[(1) - (2)].l_node), (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 29:
+
+/* Line 1455 of yacc.c */
+#line 304 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_probe((yyvsp[(2) - (6)].l_str), 2, (yyvsp[(3) - (6)].l_node), (yyvsp[(5) - (6)].l_node));
+ }
+ break;
+
+ case 30:
+
+/* Line 1455 of yacc.c */
+#line 307 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_probe((yyvsp[(2) - (4)].l_str), 1, (yyvsp[(3) - (4)].l_node), NULL);
+ }
+ break;
+
+ case 31:
+
+/* Line 1455 of yacc.c */
+#line 314 "dt_grammar.y"
+ {
+ /*
+ * If the input stream is a file, do not permit a probe
+ * specification without / <pred> / or { <act> } after
+ * it. This can only occur if the next token is EOF or
+ * an ambiguous predicate was slurped up as a comment.
+ * We cannot perform this check if input() is a string
+ * because dtrace(1M) [-fmnP] also use the compiler and
+ * things like dtrace -n BEGIN have to be accepted.
+ */
+ if (yypcb->pcb_fileptr != NULL) {
+ dnerror((yyvsp[(1) - (1)].l_node), D_SYNTAX, "expected predicate and/"
+ "or actions following probe description\n");
+ }
+ (yyval.l_node) = dt_node_clause((yyvsp[(1) - (1)].l_node), NULL, NULL);
+ }
+ break;
+
+ case 32:
+
+/* Line 1455 of yacc.c */
+#line 330 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_clause((yyvsp[(1) - (4)].l_node), NULL, (yyvsp[(3) - (4)].l_node));
+ }
+ break;
+
+ case 33:
+
+/* Line 1455 of yacc.c */
+#line 333 "dt_grammar.y"
+ {
+ dnerror((yyvsp[(3) - (4)].l_node), D_SYNTAX, "expected actions { } following "
+ "probe description and predicate\n");
+ }
+ break;
+
+ case 34:
+
+/* Line 1455 of yacc.c */
+#line 338 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_clause((yyvsp[(1) - (7)].l_node), (yyvsp[(3) - (7)].l_node), (yyvsp[(6) - (7)].l_node));
+ }
+ break;
+
+ case 35:
+
+/* Line 1455 of yacc.c */
+#line 344 "dt_grammar.y"
+ { yybegin(YYS_EXPR); (yyval.l_node) = (yyvsp[(1) - (1)].l_node); }
+ break;
+
+ case 37:
+
+/* Line 1455 of yacc.c */
+#line 349 "dt_grammar.y"
+ {
+ (yyval.l_node) = LINK((yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 38:
+
+/* Line 1455 of yacc.c */
+#line 355 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_pdesc_by_name((yyvsp[(1) - (1)].l_str)); }
+ break;
+
+ case 39:
+
+/* Line 1455 of yacc.c */
+#line 356 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_pdesc_by_id((yyvsp[(1) - (1)].l_int)); }
+ break;
+
+ case 40:
+
+/* Line 1455 of yacc.c */
+#line 359 "dt_grammar.y"
+ { (yyval.l_node) = (yyvsp[(1) - (1)].l_node); }
+ break;
+
+ case 41:
+
+/* Line 1455 of yacc.c */
+#line 360 "dt_grammar.y"
+ { (yyval.l_node) = LINK((yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node)); }
+ break;
+
+ case 42:
+
+/* Line 1455 of yacc.c */
+#line 363 "dt_grammar.y"
+ { (yyval.l_node) = NULL; }
+ break;
+
+ case 43:
+
+/* Line 1455 of yacc.c */
+#line 364 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_statement((yyvsp[(1) - (1)].l_node)); }
+ break;
+
+ case 45:
+
+/* Line 1455 of yacc.c */
+#line 369 "dt_grammar.y"
+ {
+ (yyval.l_node) = LINK((yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 46:
+
+/* Line 1455 of yacc.c */
+#line 375 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_ident((yyvsp[(1) - (1)].l_str)); }
+ break;
+
+ case 47:
+
+/* Line 1455 of yacc.c */
+#line 376 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_ident((yyvsp[(1) - (1)].l_str)); }
+ break;
+
+ case 48:
+
+/* Line 1455 of yacc.c */
+#line 377 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_int((yyvsp[(1) - (1)].l_int)); }
+ break;
+
+ case 49:
+
+/* Line 1455 of yacc.c */
+#line 378 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_string((yyvsp[(1) - (1)].l_str)); }
+ break;
+
+ case 50:
+
+/* Line 1455 of yacc.c */
+#line 379 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_ident(DUP("self")); }
+ break;
+
+ case 51:
+
+/* Line 1455 of yacc.c */
+#line 380 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_ident(DUP("this")); }
+ break;
+
+ case 52:
+
+/* Line 1455 of yacc.c */
+#line 381 "dt_grammar.y"
+ { (yyval.l_node) = (yyvsp[(2) - (3)].l_node); }
+ break;
+
+ case 54:
+
+/* Line 1455 of yacc.c */
+#line 387 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LBRAC, (yyvsp[(1) - (4)].l_node), (yyvsp[(3) - (4)].l_node));
+ }
+ break;
+
+ case 55:
+
+/* Line 1455 of yacc.c */
+#line 390 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_func((yyvsp[(1) - (3)].l_node), NULL);
+ }
+ break;
+
+ case 56:
+
+/* Line 1455 of yacc.c */
+#line 394 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_func((yyvsp[(1) - (4)].l_node), (yyvsp[(3) - (4)].l_node));
+ }
+ break;
+
+ case 57:
+
+/* Line 1455 of yacc.c */
+#line 397 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_DOT, (yyvsp[(1) - (3)].l_node), dt_node_ident((yyvsp[(3) - (3)].l_str)));
+ }
+ break;
+
+ case 58:
+
+/* Line 1455 of yacc.c */
+#line 400 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_DOT, (yyvsp[(1) - (3)].l_node), dt_node_ident((yyvsp[(3) - (3)].l_str)));
+ }
+ break;
+
+ case 59:
+
+/* Line 1455 of yacc.c */
+#line 403 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_PTR, (yyvsp[(1) - (3)].l_node), dt_node_ident((yyvsp[(3) - (3)].l_str)));
+ }
+ break;
+
+ case 60:
+
+/* Line 1455 of yacc.c */
+#line 406 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_PTR, (yyvsp[(1) - (3)].l_node), dt_node_ident((yyvsp[(3) - (3)].l_str)));
+ }
+ break;
+
+ case 61:
+
+/* Line 1455 of yacc.c */
+#line 409 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP1(DT_TOK_POSTINC, (yyvsp[(1) - (2)].l_node));
+ }
+ break;
+
+ case 62:
+
+/* Line 1455 of yacc.c */
+#line 412 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP1(DT_TOK_POSTDEC, (yyvsp[(1) - (2)].l_node));
+ }
+ break;
+
+ case 63:
+
+/* Line 1455 of yacc.c */
+#line 416 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_offsetof((yyvsp[(3) - (6)].l_decl), (yyvsp[(5) - (6)].l_str));
+ }
+ break;
+
+ case 64:
+
+/* Line 1455 of yacc.c */
+#line 420 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_offsetof((yyvsp[(3) - (6)].l_decl), (yyvsp[(5) - (6)].l_str));
+ }
+ break;
+
+ case 65:
+
+/* Line 1455 of yacc.c */
+#line 424 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_XLATE, dt_node_type((yyvsp[(3) - (7)].l_decl)), (yyvsp[(6) - (7)].l_node));
+ }
+ break;
+
+ case 67:
+
+/* Line 1455 of yacc.c */
+#line 431 "dt_grammar.y"
+ { (yyval.l_node) = OP1(DT_TOK_PREINC, (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 68:
+
+/* Line 1455 of yacc.c */
+#line 432 "dt_grammar.y"
+ { (yyval.l_node) = OP1(DT_TOK_PREDEC, (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 69:
+
+/* Line 1455 of yacc.c */
+#line 433 "dt_grammar.y"
+ { (yyval.l_node) = OP1((yyvsp[(1) - (2)].l_tok), (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 70:
+
+/* Line 1455 of yacc.c */
+#line 434 "dt_grammar.y"
+ { (yyval.l_node) = OP1(DT_TOK_SIZEOF, (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 71:
+
+/* Line 1455 of yacc.c */
+#line 435 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP1(DT_TOK_SIZEOF, dt_node_type((yyvsp[(3) - (4)].l_decl)));
+ }
+ break;
+
+ case 72:
+
+/* Line 1455 of yacc.c */
+#line 438 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP1(DT_TOK_STRINGOF, (yyvsp[(2) - (2)].l_node));
+ }
+ break;
+
+ case 73:
+
+/* Line 1455 of yacc.c */
+#line 443 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_ADDROF; }
+ break;
+
+ case 74:
+
+/* Line 1455 of yacc.c */
+#line 444 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_DEREF; }
+ break;
+
+ case 75:
+
+/* Line 1455 of yacc.c */
+#line 445 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_IPOS; }
+ break;
+
+ case 76:
+
+/* Line 1455 of yacc.c */
+#line 446 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_INEG; }
+ break;
+
+ case 77:
+
+/* Line 1455 of yacc.c */
+#line 447 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_BNEG; }
+ break;
+
+ case 78:
+
+/* Line 1455 of yacc.c */
+#line 448 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_LNEG; }
+ break;
+
+ case 80:
+
+/* Line 1455 of yacc.c */
+#line 453 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LPAR, dt_node_type((yyvsp[(2) - (4)].l_decl)), (yyvsp[(4) - (4)].l_node));
+ }
+ break;
+
+ case 82:
+
+/* Line 1455 of yacc.c */
+#line 460 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_MUL, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 83:
+
+/* Line 1455 of yacc.c */
+#line 463 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_DIV, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 84:
+
+/* Line 1455 of yacc.c */
+#line 466 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_MOD, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 86:
+
+/* Line 1455 of yacc.c */
+#line 473 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_ADD, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 87:
+
+/* Line 1455 of yacc.c */
+#line 476 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_SUB, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 89:
+
+/* Line 1455 of yacc.c */
+#line 483 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LSH, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 90:
+
+/* Line 1455 of yacc.c */
+#line 486 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_RSH, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 92:
+
+/* Line 1455 of yacc.c */
+#line 493 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LT, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 93:
+
+/* Line 1455 of yacc.c */
+#line 496 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_GT, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 94:
+
+/* Line 1455 of yacc.c */
+#line 499 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LE, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 95:
+
+/* Line 1455 of yacc.c */
+#line 502 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_GE, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 97:
+
+/* Line 1455 of yacc.c */
+#line 509 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_EQU, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 98:
+
+/* Line 1455 of yacc.c */
+#line 512 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_NEQ, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 100:
+
+/* Line 1455 of yacc.c */
+#line 519 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_BAND, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 102:
+
+/* Line 1455 of yacc.c */
+#line 526 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_XOR, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 104:
+
+/* Line 1455 of yacc.c */
+#line 533 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_BOR, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 106:
+
+/* Line 1455 of yacc.c */
+#line 540 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LAND, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 108:
+
+/* Line 1455 of yacc.c */
+#line 547 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LXOR, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 110:
+
+/* Line 1455 of yacc.c */
+#line 554 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_LOR, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 113:
+
+/* Line 1455 of yacc.c */
+#line 565 "dt_grammar.y"
+ { (yyval.l_node) = OP3((yyvsp[(1) - (5)].l_node), (yyvsp[(3) - (5)].l_node), (yyvsp[(5) - (5)].l_node)); }
+ break;
+
+ case 115:
+
+/* Line 1455 of yacc.c */
+#line 570 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2((yyvsp[(2) - (3)].l_tok), (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 116:
+
+/* Line 1455 of yacc.c */
+#line 576 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_ASGN; }
+ break;
+
+ case 117:
+
+/* Line 1455 of yacc.c */
+#line 577 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_MUL_EQ; }
+ break;
+
+ case 118:
+
+/* Line 1455 of yacc.c */
+#line 578 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_DIV_EQ; }
+ break;
+
+ case 119:
+
+/* Line 1455 of yacc.c */
+#line 579 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_MOD_EQ; }
+ break;
+
+ case 120:
+
+/* Line 1455 of yacc.c */
+#line 580 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_ADD_EQ; }
+ break;
+
+ case 121:
+
+/* Line 1455 of yacc.c */
+#line 581 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_SUB_EQ; }
+ break;
+
+ case 122:
+
+/* Line 1455 of yacc.c */
+#line 582 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_LSH_EQ; }
+ break;
+
+ case 123:
+
+/* Line 1455 of yacc.c */
+#line 583 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_RSH_EQ; }
+ break;
+
+ case 124:
+
+/* Line 1455 of yacc.c */
+#line 584 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_AND_EQ; }
+ break;
+
+ case 125:
+
+/* Line 1455 of yacc.c */
+#line 585 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_XOR_EQ; }
+ break;
+
+ case 126:
+
+/* Line 1455 of yacc.c */
+#line 586 "dt_grammar.y"
+ { (yyval.l_tok) = DT_TOK_OR_EQ; }
+ break;
+
+ case 128:
+
+/* Line 1455 of yacc.c */
+#line 590 "dt_grammar.y"
+ {
+ (yyval.l_node) = OP2(DT_TOK_COMMA, (yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 129:
+
+/* Line 1455 of yacc.c */
+#line 595 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_decl();
+ dt_decl_free(dt_decl_pop());
+ yybegin(YYS_CLAUSE);
+ }
+ break;
+
+ case 130:
+
+/* Line 1455 of yacc.c */
+#line 600 "dt_grammar.y"
+ {
+ (yyval.l_node) = (yyvsp[(2) - (3)].l_node);
+ dt_decl_free(dt_decl_pop());
+ yybegin(YYS_CLAUSE);
+ }
+ break;
+
+ case 143:
+
+/* Line 1455 of yacc.c */
+#line 626 "dt_grammar.y"
+ { dt_decl_class(DT_DC_AUTO); }
+ break;
+
+ case 144:
+
+/* Line 1455 of yacc.c */
+#line 627 "dt_grammar.y"
+ { dt_decl_class(DT_DC_REGISTER); }
+ break;
+
+ case 145:
+
+/* Line 1455 of yacc.c */
+#line 628 "dt_grammar.y"
+ { dt_decl_class(DT_DC_STATIC); }
+ break;
+
+ case 146:
+
+/* Line 1455 of yacc.c */
+#line 629 "dt_grammar.y"
+ { dt_decl_class(DT_DC_EXTERN); }
+ break;
+
+ case 147:
+
+/* Line 1455 of yacc.c */
+#line 630 "dt_grammar.y"
+ { dt_decl_class(DT_DC_TYPEDEF); }
+ break;
+
+ case 149:
+
+/* Line 1455 of yacc.c */
+#line 635 "dt_grammar.y"
+ { dt_decl_class(DT_DC_SELF); }
+ break;
+
+ case 150:
+
+/* Line 1455 of yacc.c */
+#line 636 "dt_grammar.y"
+ { dt_decl_class(DT_DC_THIS); }
+ break;
+
+ case 151:
+
+/* Line 1455 of yacc.c */
+#line 639 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_INTEGER, DUP("void")); }
+ break;
+
+ case 152:
+
+/* Line 1455 of yacc.c */
+#line 640 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_INTEGER, DUP("char")); }
+ break;
+
+ case 153:
+
+/* Line 1455 of yacc.c */
+#line 641 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_attr(DT_DA_SHORT); }
+ break;
+
+ case 154:
+
+/* Line 1455 of yacc.c */
+#line 642 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_INTEGER, DUP("int")); }
+ break;
+
+ case 155:
+
+/* Line 1455 of yacc.c */
+#line 643 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_attr(DT_DA_LONG); }
+ break;
+
+ case 156:
+
+/* Line 1455 of yacc.c */
+#line 644 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_FLOAT, DUP("float")); }
+ break;
+
+ case 157:
+
+/* Line 1455 of yacc.c */
+#line 645 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_FLOAT, DUP("double")); }
+ break;
+
+ case 158:
+
+/* Line 1455 of yacc.c */
+#line 646 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_attr(DT_DA_SIGNED); }
+ break;
+
+ case 159:
+
+/* Line 1455 of yacc.c */
+#line 647 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_attr(DT_DA_UNSIGNED); }
+ break;
+
+ case 160:
+
+/* Line 1455 of yacc.c */
+#line 648 "dt_grammar.y"
+ {
+ (yyval.l_decl) = dt_decl_spec(CTF_K_TYPEDEF, DUP("string"));
+ }
+ break;
+
+ case 161:
+
+/* Line 1455 of yacc.c */
+#line 651 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_TYPEDEF, (yyvsp[(1) - (1)].l_str)); }
+ break;
+
+ case 164:
+
+/* Line 1455 of yacc.c */
+#line 656 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_attr(DT_DA_CONST); }
+ break;
+
+ case 165:
+
+/* Line 1455 of yacc.c */
+#line 657 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_attr(DT_DA_RESTRICT); }
+ break;
+
+ case 166:
+
+/* Line 1455 of yacc.c */
+#line 658 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_attr(DT_DA_VOLATILE); }
+ break;
+
+ case 167:
+
+/* Line 1455 of yacc.c */
+#line 662 "dt_grammar.y"
+ {
+ (yyval.l_decl) = dt_scope_pop();
+ }
+ break;
+
+ case 168:
+
+/* Line 1455 of yacc.c */
+#line 665 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec((yyvsp[(1) - (2)].l_tok), (yyvsp[(2) - (2)].l_str)); }
+ break;
+
+ case 169:
+
+/* Line 1455 of yacc.c */
+#line 666 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec((yyvsp[(1) - (2)].l_tok), (yyvsp[(2) - (2)].l_str)); }
+ break;
+
+ case 170:
+
+/* Line 1455 of yacc.c */
+#line 670 "dt_grammar.y"
+ { dt_decl_sou((yyvsp[(1) - (2)].l_tok), NULL); }
+ break;
+
+ case 171:
+
+/* Line 1455 of yacc.c */
+#line 671 "dt_grammar.y"
+ { dt_decl_sou((yyvsp[(1) - (3)].l_tok), (yyvsp[(2) - (3)].l_str)); }
+ break;
+
+ case 172:
+
+/* Line 1455 of yacc.c */
+#line 672 "dt_grammar.y"
+ { dt_decl_sou((yyvsp[(1) - (3)].l_tok), (yyvsp[(2) - (3)].l_str)); }
+ break;
+
+ case 173:
+
+/* Line 1455 of yacc.c */
+#line 676 "dt_grammar.y"
+ { (yyval.l_tok) = CTF_K_STRUCT; }
+ break;
+
+ case 174:
+
+/* Line 1455 of yacc.c */
+#line 677 "dt_grammar.y"
+ { (yyval.l_tok) = CTF_K_UNION; }
+ break;
+
+ case 178:
+
+/* Line 1455 of yacc.c */
+#line 687 "dt_grammar.y"
+ {
+ (yyval.l_node) = LINK((yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 179:
+
+/* Line 1455 of yacc.c */
+#line 693 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_decl();
+ dt_decl_reset();
+ }
+ break;
+
+ case 180:
+
+/* Line 1455 of yacc.c */
+#line 700 "dt_grammar.y"
+ {
+ dt_decl_free(dt_decl_pop());
+ }
+ break;
+
+ case 182:
+
+/* Line 1455 of yacc.c */
+#line 707 "dt_grammar.y"
+ { (yyval.l_decl) = (yyvsp[(2) - (2)].l_decl); }
+ break;
+
+ case 184:
+
+/* Line 1455 of yacc.c */
+#line 709 "dt_grammar.y"
+ { (yyval.l_decl) = (yyvsp[(2) - (2)].l_decl); }
+ break;
+
+ case 187:
+
+/* Line 1455 of yacc.c */
+#line 718 "dt_grammar.y"
+ { dt_decl_member(NULL); }
+ break;
+
+ case 188:
+
+/* Line 1455 of yacc.c */
+#line 719 "dt_grammar.y"
+ { dt_decl_member((yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 189:
+
+/* Line 1455 of yacc.c */
+#line 720 "dt_grammar.y"
+ {
+ dt_decl_member((yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 190:
+
+/* Line 1455 of yacc.c */
+#line 726 "dt_grammar.y"
+ { (yyval.l_decl) = dt_scope_pop(); }
+ break;
+
+ case 191:
+
+/* Line 1455 of yacc.c */
+#line 727 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_ENUM, (yyvsp[(2) - (2)].l_str)); }
+ break;
+
+ case 192:
+
+/* Line 1455 of yacc.c */
+#line 728 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_spec(CTF_K_ENUM, (yyvsp[(2) - (2)].l_str)); }
+ break;
+
+ case 193:
+
+/* Line 1455 of yacc.c */
+#line 732 "dt_grammar.y"
+ { dt_decl_enum(NULL); }
+ break;
+
+ case 194:
+
+/* Line 1455 of yacc.c */
+#line 733 "dt_grammar.y"
+ { dt_decl_enum((yyvsp[(2) - (3)].l_str)); }
+ break;
+
+ case 195:
+
+/* Line 1455 of yacc.c */
+#line 734 "dt_grammar.y"
+ { dt_decl_enum((yyvsp[(2) - (3)].l_str)); }
+ break;
+
+ case 198:
+
+/* Line 1455 of yacc.c */
+#line 742 "dt_grammar.y"
+ { dt_decl_enumerator((yyvsp[(1) - (1)].l_str), NULL); }
+ break;
+
+ case 199:
+
+/* Line 1455 of yacc.c */
+#line 743 "dt_grammar.y"
+ {
+ dt_decl_enumerator((yyvsp[(1) - (3)].l_str), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 202:
+
+/* Line 1455 of yacc.c */
+#line 753 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_ident((yyvsp[(1) - (1)].l_str)); }
+ break;
+
+ case 203:
+
+/* Line 1455 of yacc.c */
+#line 754 "dt_grammar.y"
+ { (yyval.l_decl) = (yyvsp[(2) - (3)].l_decl); }
+ break;
+
+ case 204:
+
+/* Line 1455 of yacc.c */
+#line 755 "dt_grammar.y"
+ { dt_decl_array((yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 205:
+
+/* Line 1455 of yacc.c */
+#line 756 "dt_grammar.y"
+ { dt_decl_func((yyvsp[(1) - (2)].l_decl), (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 206:
+
+/* Line 1455 of yacc.c */
+#line 759 "dt_grammar.y"
+ { dt_decl_top()->dd_attr |= DT_DA_PAREN; }
+ break;
+
+ case 207:
+
+/* Line 1455 of yacc.c */
+#line 762 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_ptr(); }
+ break;
+
+ case 208:
+
+/* Line 1455 of yacc.c */
+#line 763 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_ptr(); }
+ break;
+
+ case 209:
+
+/* Line 1455 of yacc.c */
+#line 764 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_ptr(); }
+ break;
+
+ case 210:
+
+/* Line 1455 of yacc.c */
+#line 765 "dt_grammar.y"
+ { (yyval.l_decl) = dt_decl_ptr(); }
+ break;
+
+ case 212:
+
+/* Line 1455 of yacc.c */
+#line 770 "dt_grammar.y"
+ { (yyval.l_decl) = (yyvsp[(2) - (2)].l_decl); }
+ break;
+
+ case 214:
+
+/* Line 1455 of yacc.c */
+#line 775 "dt_grammar.y"
+ { (yyval.l_node) = dt_node_vatype(); }
+ break;
+
+ case 215:
+
+/* Line 1455 of yacc.c */
+#line 776 "dt_grammar.y"
+ {
+ (yyval.l_node) = LINK((yyvsp[(1) - (3)].l_node), dt_node_vatype());
+ }
+ break;
+
+ case 217:
+
+/* Line 1455 of yacc.c */
+#line 782 "dt_grammar.y"
+ {
+ (yyval.l_node) = LINK((yyvsp[(1) - (3)].l_node), (yyvsp[(3) - (3)].l_node));
+ }
+ break;
+
+ case 218:
+
+/* Line 1455 of yacc.c */
+#line 788 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_type(NULL);
+ }
+ break;
+
+ case 219:
+
+/* Line 1455 of yacc.c */
+#line 791 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_type(NULL);
+ }
+ break;
+
+ case 220:
+
+/* Line 1455 of yacc.c */
+#line 794 "dt_grammar.y"
+ {
+ (yyval.l_node) = dt_node_type(NULL);
+ }
+ break;
+
+ case 221:
+
+/* Line 1455 of yacc.c */
+#line 799 "dt_grammar.y"
+ {
+ (yyval.l_decl) = dt_decl_pop();
+ }
+ break;
+
+ case 222:
+
+/* Line 1455 of yacc.c */
+#line 802 "dt_grammar.y"
+ {
+ (yyval.l_decl) = dt_decl_pop();
+ }
+ break;
+
+ case 226:
+
+/* Line 1455 of yacc.c */
+#line 814 "dt_grammar.y"
+ { (yyval.l_decl) = (yyvsp[(2) - (3)].l_decl); }
+ break;
+
+ case 227:
+
+/* Line 1455 of yacc.c */
+#line 815 "dt_grammar.y"
+ { dt_decl_array((yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 228:
+
+/* Line 1455 of yacc.c */
+#line 816 "dt_grammar.y"
+ { dt_decl_array((yyvsp[(1) - (1)].l_node)); (yyval.l_decl) = NULL; }
+ break;
+
+ case 229:
+
+/* Line 1455 of yacc.c */
+#line 817 "dt_grammar.y"
+ { dt_decl_func((yyvsp[(1) - (2)].l_decl), (yyvsp[(2) - (2)].l_node)); }
+ break;
+
+ case 230:
+
+/* Line 1455 of yacc.c */
+#line 818 "dt_grammar.y"
+ { dt_decl_func(NULL, (yyvsp[(1) - (1)].l_node)); }
+ break;
+
+ case 231:
+
+/* Line 1455 of yacc.c */
+#line 821 "dt_grammar.y"
+ { dt_scope_push(NULL, CTF_ERR); }
+ break;
+
+ case 232:
+
+/* Line 1455 of yacc.c */
+#line 822 "dt_grammar.y"
+ {
+ dt_scope_pop();
+ (yyval.l_node) = (yyvsp[(3) - (4)].l_node);
+ }
+ break;
+
+ case 233:
+
+/* Line 1455 of yacc.c */
+#line 829 "dt_grammar.y"
+ { (yyval.l_node) = NULL; }
+ break;
+
+ case 234:
+
+/* Line 1455 of yacc.c */
+#line 830 "dt_grammar.y"
+ { (yyval.l_node) = (yyvsp[(1) - (1)].l_node); }
+ break;
+
+ case 235:
+
+/* Line 1455 of yacc.c */
+#line 831 "dt_grammar.y"
+ { (yyval.l_node) = (yyvsp[(1) - (1)].l_node); }
+ break;
+
+ case 236:
+
+/* Line 1455 of yacc.c */
+#line 834 "dt_grammar.y"
+ { dt_scope_push(NULL, CTF_ERR); }
+ break;
+
+ case 237:
+
+/* Line 1455 of yacc.c */
+#line 835 "dt_grammar.y"
+ {
+ dt_scope_pop();
+ (yyval.l_node) = (yyvsp[(3) - (4)].l_node);
+ }
+ break;
+
+ case 238:
+
+/* Line 1455 of yacc.c */
+#line 842 "dt_grammar.y"
+ { (yyval.l_node) = NULL; }
+ break;
+
+ case 239:
+
+/* Line 1455 of yacc.c */
+#line 843 "dt_grammar.y"
+ { (yyval.l_node) = (yyvsp[(1) - (1)].l_node); }
+ break;
+
+
+
+/* Line 1455 of yacc.c */
+#line 3516 "dt_grammar.c"
+ default: break;
+ }
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+ {
+ YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+ if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+ {
+ YYSIZE_T yyalloc = 2 * yysize;
+ if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+ yyalloc = YYSTACK_ALLOC_MAXIMUM;
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+ if (yymsg)
+ yymsg_alloc = yyalloc;
+ else
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ }
+ }
+
+ if (0 < yysize && yysize <= yymsg_alloc)
+ {
+ (void) yysyntax_error (yymsg, yystate, yychar);
+ yyerror (yymsg);
+ }
+ else
+ {
+ yyerror (YY_("syntax error"));
+ if (yysize != 0)
+ goto yyexhaustedlab;
+ }
+ }
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (yyn != YYPACT_NINF)
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
+/* Line 1675 of yacc.c */
+#line 846 "dt_grammar.y"
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.h b/src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.h
new file mode 100644
index 00000000..cf624531
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/generated/dt_grammar.h
@@ -0,0 +1,290 @@
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ DT_TOK_EOF = 0,
+ DT_TOK_COMMA = 258,
+ DT_TOK_ELLIPSIS = 259,
+ DT_TOK_ASGN = 260,
+ DT_TOK_ADD_EQ = 261,
+ DT_TOK_SUB_EQ = 262,
+ DT_TOK_MUL_EQ = 263,
+ DT_TOK_DIV_EQ = 264,
+ DT_TOK_MOD_EQ = 265,
+ DT_TOK_AND_EQ = 266,
+ DT_TOK_XOR_EQ = 267,
+ DT_TOK_OR_EQ = 268,
+ DT_TOK_LSH_EQ = 269,
+ DT_TOK_RSH_EQ = 270,
+ DT_TOK_QUESTION = 271,
+ DT_TOK_COLON = 272,
+ DT_TOK_LOR = 273,
+ DT_TOK_LXOR = 274,
+ DT_TOK_LAND = 275,
+ DT_TOK_BOR = 276,
+ DT_TOK_XOR = 277,
+ DT_TOK_BAND = 278,
+ DT_TOK_EQU = 279,
+ DT_TOK_NEQ = 280,
+ DT_TOK_LT = 281,
+ DT_TOK_LE = 282,
+ DT_TOK_GT = 283,
+ DT_TOK_GE = 284,
+ DT_TOK_LSH = 285,
+ DT_TOK_RSH = 286,
+ DT_TOK_ADD = 287,
+ DT_TOK_SUB = 288,
+ DT_TOK_MUL = 289,
+ DT_TOK_DIV = 290,
+ DT_TOK_MOD = 291,
+ DT_TOK_LNEG = 292,
+ DT_TOK_BNEG = 293,
+ DT_TOK_ADDADD = 294,
+ DT_TOK_SUBSUB = 295,
+ DT_TOK_PREINC = 296,
+ DT_TOK_POSTINC = 297,
+ DT_TOK_PREDEC = 298,
+ DT_TOK_POSTDEC = 299,
+ DT_TOK_IPOS = 300,
+ DT_TOK_INEG = 301,
+ DT_TOK_DEREF = 302,
+ DT_TOK_ADDROF = 303,
+ DT_TOK_OFFSETOF = 304,
+ DT_TOK_SIZEOF = 305,
+ DT_TOK_STRINGOF = 306,
+ DT_TOK_XLATE = 307,
+ DT_TOK_LPAR = 308,
+ DT_TOK_RPAR = 309,
+ DT_TOK_LBRAC = 310,
+ DT_TOK_RBRAC = 311,
+ DT_TOK_PTR = 312,
+ DT_TOK_DOT = 313,
+ DT_TOK_STRING = 314,
+ DT_TOK_IDENT = 315,
+ DT_TOK_PSPEC = 316,
+ DT_TOK_AGG = 317,
+ DT_TOK_TNAME = 318,
+ DT_TOK_INT = 319,
+ DT_KEY_AUTO = 320,
+ DT_KEY_BREAK = 321,
+ DT_KEY_CASE = 322,
+ DT_KEY_CHAR = 323,
+ DT_KEY_CONST = 324,
+ DT_KEY_CONTINUE = 325,
+ DT_KEY_COUNTER = 326,
+ DT_KEY_DEFAULT = 327,
+ DT_KEY_DO = 328,
+ DT_KEY_DOUBLE = 329,
+ DT_KEY_ELSE = 330,
+ DT_KEY_ENUM = 331,
+ DT_KEY_EXTERN = 332,
+ DT_KEY_FLOAT = 333,
+ DT_KEY_FOR = 334,
+ DT_KEY_GOTO = 335,
+ DT_KEY_IF = 336,
+ DT_KEY_IMPORT = 337,
+ DT_KEY_INLINE = 338,
+ DT_KEY_INT = 339,
+ DT_KEY_LONG = 340,
+ DT_KEY_PROBE = 341,
+ DT_KEY_PROVIDER = 342,
+ DT_KEY_REGISTER = 343,
+ DT_KEY_RESTRICT = 344,
+ DT_KEY_RETURN = 345,
+ DT_KEY_SELF = 346,
+ DT_KEY_SHORT = 347,
+ DT_KEY_SIGNED = 348,
+ DT_KEY_STATIC = 349,
+ DT_KEY_STRING = 350,
+ DT_KEY_STRUCT = 351,
+ DT_KEY_SWITCH = 352,
+ DT_KEY_THIS = 353,
+ DT_KEY_TYPEDEF = 354,
+ DT_KEY_UNION = 355,
+ DT_KEY_UNSIGNED = 356,
+ DT_KEY_VOID = 357,
+ DT_KEY_VOLATILE = 358,
+ DT_KEY_WHILE = 359,
+ DT_KEY_XLATOR = 360,
+ DT_TOK_EPRED = 361,
+ DT_CTX_DEXPR = 362,
+ DT_CTX_DPROG = 363,
+ DT_CTX_DTYPE = 364
+ };
+#endif
+/* Tokens. */
+#define DT_TOK_EOF 0
+#define DT_TOK_COMMA 258
+#define DT_TOK_ELLIPSIS 259
+#define DT_TOK_ASGN 260
+#define DT_TOK_ADD_EQ 261
+#define DT_TOK_SUB_EQ 262
+#define DT_TOK_MUL_EQ 263
+#define DT_TOK_DIV_EQ 264
+#define DT_TOK_MOD_EQ 265
+#define DT_TOK_AND_EQ 266
+#define DT_TOK_XOR_EQ 267
+#define DT_TOK_OR_EQ 268
+#define DT_TOK_LSH_EQ 269
+#define DT_TOK_RSH_EQ 270
+#define DT_TOK_QUESTION 271
+#define DT_TOK_COLON 272
+#define DT_TOK_LOR 273
+#define DT_TOK_LXOR 274
+#define DT_TOK_LAND 275
+#define DT_TOK_BOR 276
+#define DT_TOK_XOR 277
+#define DT_TOK_BAND 278
+#define DT_TOK_EQU 279
+#define DT_TOK_NEQ 280
+#define DT_TOK_LT 281
+#define DT_TOK_LE 282
+#define DT_TOK_GT 283
+#define DT_TOK_GE 284
+#define DT_TOK_LSH 285
+#define DT_TOK_RSH 286
+#define DT_TOK_ADD 287
+#define DT_TOK_SUB 288
+#define DT_TOK_MUL 289
+#define DT_TOK_DIV 290
+#define DT_TOK_MOD 291
+#define DT_TOK_LNEG 292
+#define DT_TOK_BNEG 293
+#define DT_TOK_ADDADD 294
+#define DT_TOK_SUBSUB 295
+#define DT_TOK_PREINC 296
+#define DT_TOK_POSTINC 297
+#define DT_TOK_PREDEC 298
+#define DT_TOK_POSTDEC 299
+#define DT_TOK_IPOS 300
+#define DT_TOK_INEG 301
+#define DT_TOK_DEREF 302
+#define DT_TOK_ADDROF 303
+#define DT_TOK_OFFSETOF 304
+#define DT_TOK_SIZEOF 305
+#define DT_TOK_STRINGOF 306
+#define DT_TOK_XLATE 307
+#define DT_TOK_LPAR 308
+#define DT_TOK_RPAR 309
+#define DT_TOK_LBRAC 310
+#define DT_TOK_RBRAC 311
+#define DT_TOK_PTR 312
+#define DT_TOK_DOT 313
+#define DT_TOK_STRING 314
+#define DT_TOK_IDENT 315
+#define DT_TOK_PSPEC 316
+#define DT_TOK_AGG 317
+#define DT_TOK_TNAME 318
+#define DT_TOK_INT 319
+#define DT_KEY_AUTO 320
+#define DT_KEY_BREAK 321
+#define DT_KEY_CASE 322
+#define DT_KEY_CHAR 323
+#define DT_KEY_CONST 324
+#define DT_KEY_CONTINUE 325
+#define DT_KEY_COUNTER 326
+#define DT_KEY_DEFAULT 327
+#define DT_KEY_DO 328
+#define DT_KEY_DOUBLE 329
+#define DT_KEY_ELSE 330
+#define DT_KEY_ENUM 331
+#define DT_KEY_EXTERN 332
+#define DT_KEY_FLOAT 333
+#define DT_KEY_FOR 334
+#define DT_KEY_GOTO 335
+#define DT_KEY_IF 336
+#define DT_KEY_IMPORT 337
+#define DT_KEY_INLINE 338
+#define DT_KEY_INT 339
+#define DT_KEY_LONG 340
+#define DT_KEY_PROBE 341
+#define DT_KEY_PROVIDER 342
+#define DT_KEY_REGISTER 343
+#define DT_KEY_RESTRICT 344
+#define DT_KEY_RETURN 345
+#define DT_KEY_SELF 346
+#define DT_KEY_SHORT 347
+#define DT_KEY_SIGNED 348
+#define DT_KEY_STATIC 349
+#define DT_KEY_STRING 350
+#define DT_KEY_STRUCT 351
+#define DT_KEY_SWITCH 352
+#define DT_KEY_THIS 353
+#define DT_KEY_TYPEDEF 354
+#define DT_KEY_UNION 355
+#define DT_KEY_UNSIGNED 356
+#define DT_KEY_VOID 357
+#define DT_KEY_VOLATILE 358
+#define DT_KEY_WHILE 359
+#define DT_KEY_XLATOR 360
+#define DT_TOK_EPRED 361
+#define DT_CTX_DEXPR 362
+#define DT_CTX_DPROG 363
+#define DT_CTX_DTYPE 364
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 1676 of yacc.c */
+#line 51 "dt_grammar.y"
+
+ dt_node_t *l_node;
+ dt_decl_t *l_decl;
+ char *l_str;
+ uintmax_t l_int;
+ int l_tok;
+
+
+
+/* Line 1676 of yacc.c */
+#line 282 "dt_grammar.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+extern YYSTYPE yylval;
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/generated/dt_lex.c b/src/VBox/ExtPacks/VBoxDTrace/generated/dt_lex.c
new file mode 100644
index 00000000..3d54d443
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/generated/dt_lex.c
@@ -0,0 +1,3516 @@
+#line 2 "dt_lex.c"
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator). This
+ * avoids problems with code like:
+ *
+ * if ( condition_holds )
+ * yyless( 5 );
+ * else
+ * do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ *yy_cp = yy_hold_char; \
+ YY_RESTORE_YY_MORE_OFFSET \
+ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+ };
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! yy_current_buffer ) \
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! yy_current_buffer ) \
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+
+#define YY_USES_REJECT
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+#define YY_FLEX_LEX_COMPAT
+extern int yylineno;
+int yylineno = 1;
+extern char yytext[];
+
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ yytext_ptr = yy_bp; \
+ yyleng = (int) (yy_cp - yy_bp); \
+ yy_hold_char = *yy_cp; \
+ *yy_cp = '\0'; \
+ if ( yyleng + yy_more_offset >= YYLMAX ) \
+ YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
+ yy_flex_strncpy( &yytext[yy_more_offset], yytext_ptr, yyleng + 1 ); \
+ yyleng += yy_more_offset; \
+ yy_prev_more_offset = yy_more_offset; \
+ yy_more_offset = 0; \
+ yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 162
+#define YY_END_OF_BUFFER 163
+static yyconst short int yy_acclist[740] =
+ { 0,
+ 163, 162, 149, 162, 147, 149, 162, 147, 162, 126,
+ 149, 162, 149, 162,16469, 149, 162, 124, 149, 162,
+ 109, 149, 162, 149, 162,16472, 100, 149, 162, 101,
+ 149, 162, 123, 149, 162, 121, 149, 162, 145, 149,
+ 162, 122, 149, 162, 129, 149, 162, 99, 149, 162,
+ 81, 84, 149, 162, 81, 84, 149, 162, 128, 149,
+ 162, 146, 149, 162, 115, 149, 162, 131, 149, 162,
+ 117, 149, 162, 127, 149, 162, 80, 149, 162, 78,
+ 149, 162, 102, 149, 162, 149, 162, 103, 149, 162,
+ 108, 149, 162, 78, 149, 162, 78, 149, 162, 78,
+
+ 149, 162, 78, 149, 162, 78, 149, 162, 78, 149,
+ 162, 78, 149, 162, 78, 149, 162, 78, 149, 162,
+ 78, 149, 162, 78, 149, 162, 78, 149, 162, 78,
+ 149, 162, 78, 149, 162, 78, 149, 162, 78, 149,
+ 162, 78, 149, 162, 78, 149, 162, 104, 149, 162,
+ 107, 149, 162, 106, 149, 162, 125, 149, 162, 147,
+ 149, 162, 94, 149, 162, 152, 162, 152, 162, 152,
+ 162, 157, 162, 156, 157, 162, 156, 162, 153, 157,
+ 162, 155, 157, 162, 154, 157, 162, 82, 157, 162,
+ 82, 157, 162, 153, 157, 162, 153, 157, 162, 153,
+
+ 157, 162, 153, 157, 162, 153, 157, 162, 153, 157,
+ 162, 153, 157, 162, 153, 157, 162, 153, 157, 162,
+ 153, 157, 162, 153, 157, 162, 153, 157, 162, 153,
+ 157, 162, 105, 157, 162, 156, 157, 162, 95, 157,
+ 162, 160, 161, 162, 159, 161, 162, 158, 162, 161,
+ 162,16469, 83, 160, 161, 162, 83, 160, 161, 162,
+ 97, 162, 98, 162, 97, 162, 96, 97, 162, 114,
+ 16469, 8277, 86, 75, 77, 136, 110, 137,16472, 8280,
+ 89, 134, 142, 132, 143, 133, 130, 84, 90, 135,
+ 84, 81, 84, 84, 81, 84, 81, 119, 116, 113,
+
+ 118, 120, 79, 78, 148, 138, 111, 78, 78, 78,
+ 78, 78, 78, 9, 78, 78, 78, 78, 78, 78,
+ 78, 17, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 139, 112, 94, 92, 151, 150, 153, 91, 82,
+ 82, 82, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 95, 93, 160, 159,16469, 87, 83,
+ 160, 83, 160, 83, 160, 160, 96, 74, 76, 77,
+ 144, 84, 84, 81, 81, 81, 140, 141, 79, 78,
+
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 15, 78, 78, 78, 78, 20, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 92, 82, 82, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 56, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 93, 83, 160, 83, 160, 76, 1, 78, 78,
+ 3, 78, 4, 78, 78, 78, 78, 78, 78, 11,
+ 78, 12, 78, 78, 78, 16, 78, 78, 78, 21,
+
+ 78, 78, 78, 78, 78, 78, 78, 28, 78, 78,
+ 78, 78, 78, 78, 78, 78, 37, 78, 78, 78,
+ 78, 78, 42, 78, 78, 78, 78, 46, 153, 47,
+ 153, 153, 153, 153, 51, 153, 153, 153, 153, 153,
+ 57, 153, 153, 153, 153, 61, 153, 153, 153, 153,
+ 153, 153, 67, 153, 153, 153, 153, 153, 72, 153,
+ 153, 2, 78, 5, 78, 78, 78, 78, 78, 78,
+ 14, 78, 78, 78, 78, 23, 78, 78, 78, 78,
+ 78, 29, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 40, 78, 78, 78, 44, 78, 45, 78, 48,
+
+ 153, 153, 153, 153, 53, 153, 153, 153, 153, 153,
+ 153, 62, 153, 153, 153, 153, 153, 153, 153, 70,
+ 153, 153, 153, 78, 78, 78, 10, 78, 13, 78,
+ 18, 78, 19, 78, 78, 78, 78, 78, 27, 78,
+ 30, 78, 31, 78, 32, 78, 33, 78, 35, 78,
+ 36, 78, 78, 78, 78, 78, 153, 50, 153, 52,
+ 153, 54, 153, 55, 153, 153, 153, 153, 63, 153,
+ 64, 153, 65, 153, 66, 153, 153, 153, 153, 153,
+ 78, 7, 78, 8, 78, 78, 78, 78, 78, 78,
+ 78, 39, 78, 78, 78, 49, 153, 153, 153, 153,
+
+ 153, 69, 153, 153, 153, 6, 78, 22, 78, 24,
+ 78, 25, 78, 26, 78, 34, 78, 78, 41, 78,
+ 43, 78, 58, 153, 59, 153, 60, 153, 153, 71,
+ 153, 73, 153, 78, 153, 38, 78, 68, 153
+ } ;
+
+static yyconst short int yy_accept[511] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 2, 3, 5, 8, 10, 13, 16,
+ 18, 21, 24, 27, 30, 33, 36, 39, 42, 45,
+ 48, 51, 55, 59, 62, 65, 68, 71, 74, 77,
+ 80, 83, 86, 88, 91, 94, 97, 100, 103, 106,
+ 109, 112, 115, 118, 121, 124, 127, 130, 133, 136,
+ 139, 142, 145, 148, 151, 154, 157, 160, 163, 166,
+ 168, 170, 172, 174, 177, 179, 182, 185, 188, 191,
+ 194, 197, 200, 203, 206, 209, 212, 215, 218, 221,
+ 224, 227, 230, 233, 236, 239, 242, 245, 248, 250,
+
+ 253, 257, 261, 263, 265, 267, 270, 271, 272, 273,
+ 274, 274, 274, 275, 276, 277, 278, 279, 280, 281,
+ 282, 282, 283, 284, 285, 286, 287, 288, 288, 289,
+ 290, 291, 292, 294, 294, 295, 297, 298, 298, 299,
+ 300, 301, 302, 303, 304, 305, 306, 307, 308, 309,
+ 310, 311, 312, 313, 314, 316, 317, 318, 319, 320,
+ 321, 322, 324, 325, 326, 327, 328, 329, 330, 331,
+ 332, 333, 334, 335, 336, 337, 338, 339, 340, 341,
+ 342, 343, 344, 344, 345, 346, 347, 348, 349, 350,
+ 351, 352, 353, 353, 354, 355, 356, 357, 358, 359,
+
+ 360, 361, 362, 363, 364, 365, 366, 367, 368, 369,
+ 370, 371, 372, 373, 374, 374, 375, 376, 377, 378,
+ 379, 380, 380, 382, 384, 386, 387, 387, 388, 389,
+ 390, 391, 392, 393, 393, 394, 395, 396, 397, 398,
+ 399, 400, 401, 402, 403, 404, 405, 406, 407, 408,
+ 409, 410, 411, 412, 414, 415, 416, 417, 419, 420,
+ 421, 422, 423, 424, 425, 426, 427, 428, 429, 430,
+ 431, 432, 433, 434, 435, 436, 437, 438, 439, 440,
+ 441, 442, 443, 444, 445, 446, 447, 448, 449, 450,
+ 451, 452, 453, 454, 456, 457, 458, 459, 460, 461,
+
+ 462, 463, 464, 465, 466, 467, 468, 469, 470, 471,
+ 472, 473, 475, 477, 478, 480, 481, 483, 485, 486,
+ 487, 488, 489, 490, 492, 494, 495, 496, 498, 499,
+ 500, 502, 503, 504, 505, 506, 507, 508, 510, 511,
+ 512, 513, 514, 515, 516, 517, 519, 520, 521, 522,
+ 523, 525, 526, 527, 528, 530, 532, 533, 534, 535,
+ 537, 538, 539, 540, 541, 543, 544, 545, 546, 548,
+ 549, 550, 551, 552, 553, 555, 556, 557, 558, 559,
+ 561, 562, 564, 566, 567, 568, 569, 570, 571, 573,
+ 574, 575, 576, 578, 579, 580, 581, 582, 584, 585,
+
+ 586, 587, 588, 589, 590, 591, 592, 594, 595, 596,
+ 598, 600, 602, 603, 604, 605, 607, 608, 609, 610,
+ 611, 612, 614, 615, 616, 617, 618, 619, 620, 622,
+ 623, 624, 625, 626, 627, 629, 631, 633, 635, 636,
+ 637, 638, 639, 641, 643, 645, 647, 649, 651, 653,
+ 654, 655, 656, 657, 658, 660, 662, 664, 666, 667,
+ 668, 669, 671, 673, 675, 677, 678, 679, 680, 681,
+ 682, 684, 686, 687, 688, 689, 690, 691, 692, 694,
+ 695, 696, 698, 699, 700, 701, 702, 704, 705, 706,
+ 708, 710, 712, 714, 716, 718, 719, 721, 723, 725,
+
+ 727, 729, 730, 732, 734, 735, 736, 738, 740, 740
+ } ;
+
+static yyconst int yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 29, 29, 29, 30, 31,
+ 32, 32, 32, 32, 32, 33, 32, 32, 32, 32,
+ 32, 32, 32, 32, 34, 32, 32, 35, 32, 32,
+ 36, 37, 38, 39, 32, 40, 41, 42, 43, 44,
+
+ 45, 46, 47, 48, 49, 32, 50, 51, 52, 53,
+ 54, 55, 32, 56, 57, 58, 59, 60, 61, 62,
+ 63, 64, 65, 66, 67, 68, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst int yy_meta[69] =
+ { 0,
+ 1, 2, 3, 1, 4, 2, 1, 5, 1, 1,
+ 1, 1, 1, 4, 1, 1, 4, 4, 1, 6,
+ 6, 4, 1, 1, 1, 1, 4, 1, 7, 7,
+ 7, 8, 8, 8, 8, 4, 4, 4, 1, 9,
+ 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 1, 1, 1, 1
+ } ;
+
+static yyconst short int yy_base[530] =
+ { 0,
+ 0, 0, 0, 67, 56, 57, 76, 143, 145, 150,
+ 811, 152, 813, 815, 815, 815, 815, 787, 143, 152,
+ 786, 151, 164, 815, 815, 785, 143, 815, 152, 161,
+ 149, 184, 122, 815, 815, 48, 784, 160, 815, 0,
+ 0, 815, 805, 815, 158, 748, 750, 146, 144, 137,
+ 141, 751, 157, 750, 757, 746, 756, 163, 175, 747,
+ 745, 750, 746, 815, 166, 815, 815, 218, 791, 815,
+ 776, 780, 815, 815, 815, 0, 815, 779, 206, 216,
+ 733, 159, 737, 180, 739, 192, 735, 732, 742, 203,
+ 199, 733, 731, 815, 251, 779, 0, 781, 815, 253,
+
+ 243, 249, 815, 815, 264, 815, 815, 278, 815, 815,
+ 779, 252, 259, 0, 815, 815, 815, 282, 815, 815,
+ 778, 815, 815, 815, 815, 815, 815, 762, 266, 815,
+ 815, 283, 239, 303, 815, 183, 255, 0, 754, 815,
+ 815, 815, 753, 0, 0, 815, 815, 815, 719, 731,
+ 718, 733, 169, 727, 713, 714, 711, 711, 714, 711,
+ 708, 0, 710, 240, 711, 717, 708, 274, 710, 706,
+ 245, 254, 710, 709, 716, 701, 273, 113, 706, 713,
+ 815, 815, 331, 748, 0, 815, 815, 0, 815, 306,
+ 256, 292, 0, 694, 710, 201, 691, 690, 690, 693,
+
+ 691, 284, 692, 690, 149, 692, 688, 694, 295, 691,
+ 698, 683, 288, 295, 345, 732, 0, 0, 734, 347,
+ 815, 732, 328, 308, 321, 368, 353, 815, 343, 0,
+ 0, 815, 350, 346, 371, 815, 323, 335, 815, 815,
+ 0, 680, 692, 687, 675, 318, 677, 688, 686, 682,
+ 674, 680, 683, 0, 669, 668, 672, 0, 673, 662,
+ 340, 669, 659, 657, 669, 658, 660, 667, 653, 344,
+ 652, 652, 655, 662, 652, 656, 660, 662, 651, 643,
+ 0, 815, 372, 646, 643, 641, 644, 654, 643, 649,
+ 652, 638, 642, 0, 643, 629, 639, 629, 640, 629,
+
+ 631, 625, 359, 625, 628, 635, 625, 629, 633, 635,
+ 0, 0, 412, 0, 0, 625, 0, 0, 616, 624,
+ 614, 612, 619, 0, 0, 613, 610, 0, 611, 613,
+ 0, 620, 619, 614, 605, 605, 604, 0, 601, 613,
+ 603, 607, 602, 611, 610, 0, 595, 607, 597, 602,
+ 0, 590, 602, 601, 0, 0, 587, 586, 592, 0,
+ 586, 583, 584, 586, 0, 589, 580, 580, 0, 577,
+ 589, 584, 579, 588, 0, 573, 585, 575, 580, 0,
+ 568, 0, 0, 572, 579, 572, 577, 568, 0, 562,
+ 574, 560, 0, 573, 558, 566, 561, 0, 569, 566,
+
+ 568, 563, 551, 560, 556, 561, 0, 552, 555, 0,
+ 0, 0, 558, 557, 548, 0, 542, 554, 554, 529,
+ 527, 0, 501, 501, 423, 411, 417, 422, 0, 413,
+ 416, 405, 406, 403, 0, 0, 0, 0, 406, 414,
+ 407, 408, 0, 0, 0, 0, 396, 0, 0, 408,
+ 402, 402, 393, 384, 0, 0, 0, 0, 394, 393,
+ 394, 0, 0, 0, 0, 395, 389, 389, 379, 384,
+ 0, 0, 382, 371, 370, 367, 378, 363, 0, 376,
+ 374, 0, 360, 359, 349, 332, 0, 341, 333, 0,
+ 0, 0, 0, 0, 0, 323, 0, 0, 0, 0,
+
+ 0, 319, 0, 0, 302, 137, 0, 0, 815, 471,
+ 480, 489, 498, 507, 512, 521, 524, 527, 533, 542,
+ 551, 555, 559, 563, 565, 573, 577, 584, 588
+ } ;
+
+static yyconst short int yy_def[530] =
+ { 0,
+ 510, 510, 509, 3, 511, 511, 509, 7, 512, 512,
+ 513, 513, 509, 509, 509, 509, 509, 509, 514, 515,
+ 509, 509, 516, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 32, 509, 509, 509, 509, 509, 509, 517,
+ 518, 509, 509, 509, 509, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 519, 509, 509, 509, 509,
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+ 519, 519, 519, 509, 509, 509, 520, 509, 509, 521,
+
+ 520, 520, 509, 509, 509, 509, 509, 514, 509, 509,
+ 514, 522, 509, 523, 509, 509, 509, 516, 509, 509,
+ 516, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 32, 509, 509, 509, 509, 524, 509, 509,
+ 509, 509, 509, 525, 518, 509, 509, 509, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 509, 509, 509, 509, 526, 509, 509, 519, 509, 509,
+ 509, 509, 527, 519, 519, 519, 519, 519, 519, 519,
+
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+ 519, 519, 519, 519, 509, 509, 528, 520, 509, 521,
+ 509, 521, 520, 520, 520, 520, 509, 509, 509, 529,
+ 523, 509, 509, 509, 509, 509, 509, 524, 509, 509,
+ 525, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 526, 509, 527, 519, 519, 519, 519, 519, 519, 519,
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+ 528, 520, 520, 529, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 519, 519, 519, 519, 519, 519,
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+ 519, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519,
+ 519, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 518, 518, 519, 519, 519, 519, 519, 519, 519,
+ 519, 519, 519, 519, 519, 519, 519, 519, 519, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518,
+ 518, 519, 519, 519, 519, 519, 519, 519, 519, 518,
+ 518, 518, 518, 518, 518, 518, 518, 518, 519, 519,
+
+ 519, 519, 519, 519, 518, 519, 518, 519, 0, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509
+ } ;
+
+static yyconst short int yy_nxt[884] =
+ { 0,
+ 15, 16, 17, 16, 18, 19, 15, 20, 21, 22,
+ 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 41,
+ 41, 41, 41, 41, 41, 42, 43, 44, 45, 41,
+ 46, 47, 48, 49, 50, 51, 52, 41, 53, 41,
+ 54, 41, 41, 55, 56, 57, 58, 59, 60, 61,
+ 62, 63, 41, 41, 64, 65, 66, 67, 68, 71,
+ 71, 139, 140, 69, 72, 72, 73, 74, 75, 74,
+ 76, 73, 73, 76, 73, 73, 73, 73, 73, 76,
+ 73, 77, 76, 76, 78, 79, 80, 76, 73, 73,
+
+ 73, 73, 76, 73, 76, 76, 76, 76, 76, 76,
+ 76, 76, 76, 76, 73, 73, 81, 76, 82, 83,
+ 84, 85, 76, 76, 86, 76, 87, 76, 76, 76,
+ 88, 89, 90, 91, 92, 93, 76, 76, 76, 76,
+ 94, 73, 73, 73, 95, 109, 98, 99, 110, 96,
+ 100, 98, 99, 105, 104, 100, 509, 123, 106, 112,
+ 116, 277, 130, 278, 101, 102, 119, 124, 125, 101,
+ 102, 113, 113, 131, 120, 117, 126, 127, 128, 111,
+ 129, 129, 147, 509, 142, 143, 151, 156, 154, 157,
+ 181, 159, 508, 152, 160, 297, 148, 155, 158, 153,
+
+ 121, 132, 162, 133, 133, 298, 195, 169, 163, 164,
+ 170, 171, 196, 134, 135, 236, 136, 137, 138, 183,
+ 172, 246, 174, 173, 184, 190, 190, 247, 134, 135,
+ 175, 182, 198, 236, 136, 190, 190, 176, 191, 192,
+ 193, 199, 137, 201, 202, 138, 210, 206, 191, 192,
+ 207, 208, 215, 286, 211, 109, 191, 216, 221, 287,
+ 209, 212, 223, 223, 192, 227, 191, 193, 223, 223,
+ 228, 229, 229, 509, 192, 224, 225, 226, 113, 113,
+ 109, 224, 225, 110, 119, 129, 129, 237, 282, 222,
+ 257, 267, 120, 224, 269, 134, 135, 258, 135, 224,
+
+ 509, 225, 233, 233, 226, 237, 282, 225, 268, 270,
+ 134, 135, 134, 135, 111, 135, 135, 234, 121, 234,
+ 262, 275, 235, 235, 191, 190, 190, 134, 135, 276,
+ 263, 264, 183, 135, 293, 302, 307, 184, 191, 192,
+ 312, 294, 191, 309, 308, 310, 215, 223, 223, 109,
+ 303, 216, 221, 224, 227, 236, 191, 507, 312, 228,
+ 224, 225, 229, 229, 192, 235, 235, 237, 137, 233,
+ 233, 224, 506, 236, 319, 320, 505, 504, 224, 134,
+ 135, 333, 135, 222, 503, 237, 225, 313, 313, 502,
+ 235, 235, 343, 137, 134, 135, 313, 313, 313, 334,
+
+ 135, 135, 344, 135, 191, 192, 501, 373, 313, 313,
+ 313, 313, 313, 313, 500, 499, 135, 374, 498, 497,
+ 496, 135, 191, 495, 494, 493, 492, 491, 490, 489,
+ 192, 313, 313, 488, 487, 486, 485, 484, 483, 482,
+ 313, 313, 313, 481, 224, 225, 480, 479, 478, 477,
+ 476, 475, 313, 313, 313, 313, 313, 313, 474, 473,
+ 472, 471, 224, 470, 469, 468, 467, 466, 465, 464,
+ 225, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 97,
+ 97, 97, 97, 97, 97, 97, 97, 97, 103, 103,
+
+ 103, 103, 103, 103, 103, 103, 103, 108, 108, 108,
+ 108, 108, 108, 108, 108, 108, 114, 114, 114, 114,
+ 114, 118, 118, 118, 118, 118, 118, 118, 118, 118,
+ 144, 144, 145, 145, 145, 145, 188, 188, 188, 188,
+ 188, 188, 218, 463, 462, 218, 218, 218, 218, 218,
+ 218, 220, 220, 220, 220, 220, 220, 220, 220, 220,
+ 230, 230, 230, 230, 231, 231, 231, 231, 238, 238,
+ 241, 241, 241, 281, 281, 461, 281, 281, 281, 281,
+ 281, 281, 283, 283, 311, 311, 460, 311, 311, 311,
+ 311, 311, 311, 314, 314, 314, 314, 459, 458, 457,
+
+ 456, 455, 454, 453, 452, 451, 450, 449, 448, 447,
+ 446, 445, 444, 443, 442, 441, 440, 439, 438, 437,
+ 436, 435, 434, 433, 432, 431, 430, 429, 428, 427,
+ 426, 425, 424, 423, 422, 421, 420, 419, 418, 417,
+ 416, 415, 414, 413, 412, 411, 410, 409, 408, 407,
+ 406, 405, 404, 403, 402, 401, 400, 399, 398, 397,
+ 396, 395, 394, 393, 392, 391, 390, 389, 388, 387,
+ 386, 385, 384, 383, 382, 381, 380, 379, 378, 377,
+ 376, 375, 372, 371, 370, 369, 368, 367, 366, 365,
+ 364, 363, 362, 361, 360, 359, 358, 357, 356, 355,
+
+ 354, 353, 352, 351, 350, 349, 348, 347, 346, 345,
+ 342, 341, 340, 339, 338, 337, 336, 335, 332, 331,
+ 330, 329, 328, 327, 326, 325, 324, 323, 322, 321,
+ 318, 317, 316, 315, 509, 219, 217, 306, 305, 304,
+ 301, 300, 299, 296, 295, 292, 291, 290, 289, 288,
+ 285, 284, 185, 280, 279, 274, 273, 272, 271, 266,
+ 265, 261, 260, 259, 256, 255, 254, 253, 252, 251,
+ 250, 249, 248, 245, 244, 243, 242, 240, 239, 232,
+ 509, 509, 219, 217, 214, 213, 205, 204, 203, 200,
+ 197, 194, 189, 187, 186, 185, 180, 179, 178, 177,
+
+ 168, 167, 166, 165, 161, 150, 149, 146, 141, 122,
+ 115, 107, 509, 104, 13, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509
+ } ;
+
+static yyconst short int yy_chk[884] =
+ { 0,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 4, 5,
+ 6, 36, 36, 4, 5, 6, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 8, 19, 9, 9, 19, 8,
+ 9, 10, 10, 12, 12, 10, 33, 27, 12, 20,
+ 22, 178, 31, 178, 9, 9, 23, 27, 29, 10,
+ 10, 20, 20, 31, 23, 22, 29, 29, 30, 19,
+ 30, 30, 45, 33, 38, 38, 48, 50, 49, 50,
+ 65, 51, 506, 48, 51, 205, 45, 49, 50, 48,
+
+ 23, 32, 53, 32, 32, 205, 82, 58, 53, 53,
+ 58, 58, 82, 32, 32, 136, 32, 32, 32, 68,
+ 58, 153, 59, 58, 68, 79, 79, 153, 32, 32,
+ 59, 65, 84, 136, 32, 80, 80, 59, 79, 79,
+ 79, 84, 32, 86, 86, 32, 91, 90, 80, 80,
+ 90, 90, 95, 196, 91, 100, 79, 95, 100, 196,
+ 90, 91, 101, 101, 79, 105, 80, 79, 102, 102,
+ 105, 112, 112, 133, 80, 101, 101, 101, 113, 113,
+ 108, 102, 102, 108, 118, 129, 129, 137, 191, 100,
+ 164, 171, 118, 101, 172, 129, 129, 164, 129, 102,
+
+ 133, 101, 132, 132, 101, 137, 191, 102, 171, 172,
+ 129, 129, 132, 132, 108, 132, 129, 134, 118, 134,
+ 168, 177, 134, 134, 192, 190, 190, 132, 132, 177,
+ 168, 168, 183, 132, 202, 209, 213, 183, 190, 190,
+ 224, 202, 192, 214, 213, 214, 215, 223, 223, 220,
+ 209, 215, 220, 225, 227, 237, 190, 505, 224, 227,
+ 223, 223, 229, 229, 190, 234, 234, 238, 238, 233,
+ 233, 225, 502, 237, 246, 246, 496, 489, 223, 233,
+ 233, 261, 233, 220, 488, 238, 223, 226, 226, 486,
+ 235, 235, 270, 238, 233, 233, 226, 226, 226, 261,
+
+ 233, 235, 270, 235, 283, 283, 485, 303, 226, 226,
+ 226, 226, 226, 226, 484, 483, 235, 303, 481, 480,
+ 478, 235, 283, 477, 476, 475, 474, 473, 470, 469,
+ 283, 313, 313, 468, 467, 466, 461, 460, 459, 454,
+ 313, 313, 313, 453, 313, 313, 452, 451, 450, 447,
+ 442, 441, 313, 313, 313, 313, 313, 313, 440, 439,
+ 434, 433, 313, 432, 431, 430, 428, 427, 426, 425,
+ 313, 510, 510, 510, 510, 510, 510, 510, 510, 510,
+ 511, 511, 511, 511, 511, 511, 511, 511, 511, 512,
+ 512, 512, 512, 512, 512, 512, 512, 512, 513, 513,
+
+ 513, 513, 513, 513, 513, 513, 513, 514, 514, 514,
+ 514, 514, 514, 514, 514, 514, 515, 515, 515, 515,
+ 515, 516, 516, 516, 516, 516, 516, 516, 516, 516,
+ 517, 517, 518, 518, 518, 518, 519, 519, 519, 519,
+ 519, 519, 520, 424, 423, 520, 520, 520, 520, 520,
+ 520, 521, 521, 521, 521, 521, 521, 521, 521, 521,
+ 522, 522, 522, 522, 523, 523, 523, 523, 524, 524,
+ 525, 525, 525, 526, 526, 421, 526, 526, 526, 526,
+ 526, 526, 527, 527, 528, 528, 420, 528, 528, 528,
+ 528, 528, 528, 529, 529, 529, 529, 419, 418, 417,
+
+ 415, 414, 413, 409, 408, 406, 405, 404, 403, 402,
+ 401, 400, 399, 397, 396, 395, 394, 392, 391, 390,
+ 388, 387, 386, 385, 384, 381, 379, 378, 377, 376,
+ 374, 373, 372, 371, 370, 368, 367, 366, 364, 363,
+ 362, 361, 359, 358, 357, 354, 353, 352, 350, 349,
+ 348, 347, 345, 344, 343, 342, 341, 340, 339, 337,
+ 336, 335, 334, 333, 332, 330, 329, 327, 326, 323,
+ 322, 321, 320, 319, 316, 310, 309, 308, 307, 306,
+ 305, 304, 302, 301, 300, 299, 298, 297, 296, 295,
+ 293, 292, 291, 290, 289, 288, 287, 286, 285, 284,
+
+ 280, 279, 278, 277, 276, 275, 274, 273, 272, 271,
+ 269, 268, 267, 266, 265, 264, 263, 262, 260, 259,
+ 257, 256, 255, 253, 252, 251, 250, 249, 248, 247,
+ 245, 244, 243, 242, 222, 219, 216, 212, 211, 210,
+ 208, 207, 206, 204, 203, 201, 200, 199, 198, 197,
+ 195, 194, 184, 180, 179, 176, 175, 174, 173, 170,
+ 169, 167, 166, 165, 163, 161, 160, 159, 158, 157,
+ 156, 155, 154, 152, 151, 150, 149, 143, 139, 128,
+ 121, 111, 98, 96, 93, 92, 89, 88, 87, 85,
+ 83, 81, 78, 72, 71, 69, 63, 62, 61, 60,
+
+ 57, 56, 55, 54, 52, 47, 46, 43, 37, 26,
+ 21, 18, 13, 11, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509, 509, 509, 509, 509, 509, 509, 509,
+ 509, 509, 509
+ } ;
+
+static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
+static char *yy_full_match;
+static int yy_lp;
+static int yy_looking_for_trail_begin = 0;
+static int yy_full_lp;
+static int *yy_full_state;
+#define YY_TRAILING_MASK 0x2000
+#define YY_TRAILING_HEAD_MASK 0x4000
+#define REJECT \
+{ \
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
+yy_cp = yy_full_match; /* restore poss. backed-over text */ \
+yy_lp = yy_full_lp; /* restore orig. accepting pos. */ \
+yy_state_ptr = yy_full_state; /* restore orig. state */ \
+yy_current_state = *yy_state_ptr; /* restore curr. state */ \
+++yy_lp; \
+goto find_rule; \
+}
+static int yy_more_offset = 0;
+static int yy_prev_more_offset = 0;
+#define yymore() (yy_more_offset = yy_flex_strlen( yytext ))
+#define YY_NEED_STRLEN
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET \
+ { \
+ yy_more_offset = yy_prev_more_offset; \
+ yyleng -= yy_more_offset; \
+ }
+#ifndef YYLMAX
+#define YYLMAX 8192
+#endif
+
+char yytext[YYLMAX];
+char *yytext_ptr;
+#line 1 "dt_lex.l"
+#define INITIAL 0
+#line 2 "dt_lex.l"
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#else /* VBOX */
+# ifdef RT_OS_WINDOWS /* No unistd.h on windows, avoid redef warnings of the [U]INTxx_MAX defines caused by no inttypes.h/stdint.h. */
+# define YY_NO_UNISTD_H
+# undef INT8_MAX
+# undef INT16_MAX
+# undef INT32_MAX
+# undef INT64_MAX
+# undef UINT8_MAX
+# undef UINT16_MAX
+# undef UINT32_MAX
+# undef UINT64_MAX
+# endif
+# ifdef _MSC_VER
+# pragma warning(disable:4668 4131 4255)
+# endif
+# ifdef __GNUC__
+# if ((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x40002
+# pragma GCC diagnostic ignored "-Wunused-function"
+# endif
+# endif
+# include <iprt/ctype.h>
+# include <iprt/err.h>
+# define isdigit(a_ch) RT_C_IS_DIGIT(a_ch)
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_grammar.h>
+#include <dt_parser.h>
+#include <dt_string.h>
+
+#ifndef USING_FLEX
+/*
+ * We need to undefine lex's input and unput macros so that references to these
+ * call the functions provided at the end of this source file.
+ */
+#undef input
+#undef unput
+#else /* USING_FLEX */
+# define YY_INPUT(buf, result, max_size) \
+ do { \
+ if (yypcb->pcb_fileptr != NULL) { \
+ result = (int)fread(buf, 1, max_size, yypcb->pcb_fileptr); \
+ if (!result && ferror(yypcb->pcb_fileptr)) \
+ longjmp(yypcb->pcb_jmpbuf, EDT_FIO); \
+ /*YY_FATAL_ERROR("input in flex scanner failed");*/ \
+ } else { \
+ size_t off = yypcb->pcb_strptr - yypcb->pcb_string; \
+ if (off < yypcb->pcb_strlen) { \
+ off = yypcb->pcb_strlen - off; \
+ result = max_size; \
+ if ((size_t)result > off) \
+ result = (int)off; \
+ memcpy(buf, yypcb->pcb_strptr, result); \
+ yypcb->pcb_strptr += result; \
+ /*fprintf(stderr, "yy_input -> %d '%.*s'\n", result, result, buf);*/ \
+ } else { \
+ buf[0] = '\0'; \
+ result = 0; \
+ /*fprintf(stderr, "yy_input -> %d\n", result);*/ \
+ } \
+ } \
+ } while (0)
+#endif /* USING_FLEX */
+
+static int id_or_type(const char *);
+#ifndef USING_FLEX
+static int input(void);
+static void unput(int);
+#endif
+
+/*
+ * We first define a set of labeled states for use in the D lexer and then a
+ * set of regular expressions to simplify things below. The lexer states are:
+ *
+ * S0 - D program clause and expression lexing
+ * S1 - D comments (i.e. skip everything until end of comment)
+ * S2 - D program outer scope (probe specifiers and declarations)
+ * S3 - D control line parsing (i.e. after ^# is seen but before \n)
+ * S4 - D control line scan (locate control directives only and invoke S3)
+ */
+#define S0 1
+#define S1 2
+#define S2 3
+#define S3 4
+#define S4 5
+
+#line 968 "dt_lex.c"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines. This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( yy_current_buffer->yy_is_interactive ) \
+ { \
+ int c = '*', n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+ && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ if ( yyleng > 0 ) \
+ yy_current_buffer->yy_at_bol = \
+ (yytext[yyleng - 1] == '\n'); \
+ YY_USER_ACTION
+
+YY_DECL
+ {
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 132 "dt_lex.l"
+
+
+
+
+/*
+ * We insert a special prologue into yylex() itself: if the pcb contains a
+ * context token, we return that prior to running the normal lexer. This
+ * allows libdtrace to force yacc into one of our three parsing contexts: D
+ * expression (DT_CTX_DEXPR), D program (DT_CTX_DPROG) or D type (DT_CTX_DTYPE).
+ * Once the token is returned, we clear it so this only happens once.
+ */
+if (yypcb->pcb_token != 0) {
+ int tok = yypcb->pcb_token;
+ yypcb->pcb_token = 0;
+ return (tok);
+}
+
+
+
+#line 1142 "dt_lex.c"
+
+ if ( yy_init )
+ {
+ yy_init = 0;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! yy_start )
+ yy_start = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! yy_current_buffer )
+ yy_current_buffer =
+ yy_create_buffer( yyin, YY_BUF_SIZE );
+
+ yy_load_buffer_state();
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = yy_c_buf_p;
+
+ /* Support of yytext. */
+ *yy_cp = yy_hold_char;
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = yy_start;
+ yy_current_state += YY_AT_BOL();
+ yy_state_ptr = yy_state_buf;
+ *yy_state_ptr++ = yy_current_state;
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 510 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ *yy_state_ptr++ = yy_current_state;
+ ++yy_cp;
+ }
+ while ( yy_current_state != 509 );
+
+yy_find_action:
+ yy_current_state = *--yy_state_ptr;
+ yy_lp = yy_accept[yy_current_state];
+find_rule: /* we branch to this label when backing up */
+ for ( ; ; ) /* until we find what rule we matched */
+ {
+ if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
+ {
+ yy_act = yy_acclist[yy_lp];
+ if ( yy_act & YY_TRAILING_HEAD_MASK ||
+ yy_looking_for_trail_begin )
+ {
+ if ( yy_act == yy_looking_for_trail_begin )
+ {
+ yy_looking_for_trail_begin = 0;
+ yy_act &= ~YY_TRAILING_HEAD_MASK;
+ break;
+ }
+ }
+ else if ( yy_act & YY_TRAILING_MASK )
+ {
+ yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK;
+ yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK;
+ yy_full_match = yy_cp;
+ yy_full_state = yy_state_ptr;
+ yy_full_lp = yy_lp;
+ }
+ else
+ {
+ yy_full_match = yy_cp;
+ yy_full_state = yy_state_ptr;
+ yy_full_lp = yy_lp;
+ break;
+ }
+ ++yy_lp;
+ goto find_rule;
+ }
+ --yy_cp;
+ yy_current_state = *--yy_state_ptr;
+ yy_lp = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < yyleng; ++yyl )
+ if ( yytext[yyl] == '\n' )
+ ++yylineno;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+case 1:
+YY_RULE_SETUP
+#line 151 "dt_lex.l"
+return (DT_KEY_AUTO);
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 152 "dt_lex.l"
+return (DT_KEY_BREAK);
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 153 "dt_lex.l"
+return (DT_KEY_CASE);
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 154 "dt_lex.l"
+return (DT_KEY_CHAR);
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 155 "dt_lex.l"
+return (DT_KEY_CONST);
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 156 "dt_lex.l"
+return (DT_KEY_CONTINUE);
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 157 "dt_lex.l"
+return (DT_KEY_COUNTER);
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 158 "dt_lex.l"
+return (DT_KEY_DEFAULT);
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 159 "dt_lex.l"
+return (DT_KEY_DO);
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 160 "dt_lex.l"
+return (DT_KEY_DOUBLE);
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 161 "dt_lex.l"
+return (DT_KEY_ELSE);
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 162 "dt_lex.l"
+return (DT_KEY_ENUM);
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 163 "dt_lex.l"
+return (DT_KEY_EXTERN);
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 164 "dt_lex.l"
+return (DT_KEY_FLOAT);
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 165 "dt_lex.l"
+return (DT_KEY_FOR);
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 166 "dt_lex.l"
+return (DT_KEY_GOTO);
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 167 "dt_lex.l"
+return (DT_KEY_IF);
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 168 "dt_lex.l"
+return (DT_KEY_IMPORT);
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 169 "dt_lex.l"
+return (DT_KEY_INLINE);
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 170 "dt_lex.l"
+return (DT_KEY_INT);
+ YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 171 "dt_lex.l"
+return (DT_KEY_LONG);
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 172 "dt_lex.l"
+return (DT_TOK_OFFSETOF);
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 173 "dt_lex.l"
+return (DT_KEY_PROBE);
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 174 "dt_lex.l"
+return (DT_KEY_PROVIDER);
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 175 "dt_lex.l"
+return (DT_KEY_REGISTER);
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 176 "dt_lex.l"
+return (DT_KEY_RESTRICT);
+ YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 177 "dt_lex.l"
+return (DT_KEY_RETURN);
+ YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 178 "dt_lex.l"
+return (DT_KEY_SELF);
+ YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 179 "dt_lex.l"
+return (DT_KEY_SHORT);
+ YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 180 "dt_lex.l"
+return (DT_KEY_SIGNED);
+ YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 181 "dt_lex.l"
+return (DT_TOK_SIZEOF);
+ YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 182 "dt_lex.l"
+return (DT_KEY_STATIC);
+ YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 183 "dt_lex.l"
+return (DT_KEY_STRING);
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 184 "dt_lex.l"
+return (DT_TOK_STRINGOF);
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 185 "dt_lex.l"
+return (DT_KEY_STRUCT);
+ YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 186 "dt_lex.l"
+return (DT_KEY_SWITCH);
+ YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 187 "dt_lex.l"
+return (DT_KEY_THIS);
+ YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 188 "dt_lex.l"
+return (DT_KEY_XLATOR);
+ YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 189 "dt_lex.l"
+return (DT_KEY_TYPEDEF);
+ YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 190 "dt_lex.l"
+return (DT_KEY_UNION);
+ YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 191 "dt_lex.l"
+return (DT_KEY_UNSIGNED);
+ YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 192 "dt_lex.l"
+return (DT_KEY_VOID);
+ YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 193 "dt_lex.l"
+return (DT_KEY_VOLATILE);
+ YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 194 "dt_lex.l"
+return (DT_KEY_WHILE);
+ YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 195 "dt_lex.l"
+return (DT_TOK_XLATE);
+ YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 197 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_AUTO); }
+ YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 198 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_CHAR); }
+ YY_BREAK
+case 48:
+YY_RULE_SETUP
+#line 199 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_CONST); }
+ YY_BREAK
+case 49:
+YY_RULE_SETUP
+#line 200 "dt_lex.l"
+{ yybegin(YYS_DEFINE); return (DT_KEY_COUNTER); }
+ YY_BREAK
+case 50:
+YY_RULE_SETUP
+#line 201 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_DOUBLE); }
+ YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 202 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_ENUM); }
+ YY_BREAK
+case 52:
+YY_RULE_SETUP
+#line 203 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_EXTERN); }
+ YY_BREAK
+case 53:
+YY_RULE_SETUP
+#line 204 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_FLOAT); }
+ YY_BREAK
+case 54:
+YY_RULE_SETUP
+#line 205 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_IMPORT); }
+ YY_BREAK
+case 55:
+YY_RULE_SETUP
+#line 206 "dt_lex.l"
+{ yybegin(YYS_DEFINE); return (DT_KEY_INLINE); }
+ YY_BREAK
+case 56:
+YY_RULE_SETUP
+#line 207 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_INT); }
+ YY_BREAK
+case 57:
+YY_RULE_SETUP
+#line 208 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_LONG); }
+ YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 209 "dt_lex.l"
+{ yybegin(YYS_DEFINE); return (DT_KEY_PROVIDER); }
+ YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 210 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_REGISTER); }
+ YY_BREAK
+case 60:
+YY_RULE_SETUP
+#line 211 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_RESTRICT); }
+ YY_BREAK
+case 61:
+YY_RULE_SETUP
+#line 212 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_SELF); }
+ YY_BREAK
+case 62:
+YY_RULE_SETUP
+#line 213 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_SHORT); }
+ YY_BREAK
+case 63:
+YY_RULE_SETUP
+#line 214 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_SIGNED); }
+ YY_BREAK
+case 64:
+YY_RULE_SETUP
+#line 215 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_STATIC); }
+ YY_BREAK
+case 65:
+YY_RULE_SETUP
+#line 216 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_STRING); }
+ YY_BREAK
+case 66:
+YY_RULE_SETUP
+#line 217 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_STRUCT); }
+ YY_BREAK
+case 67:
+YY_RULE_SETUP
+#line 218 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_THIS); }
+ YY_BREAK
+case 68:
+YY_RULE_SETUP
+#line 219 "dt_lex.l"
+{ yybegin(YYS_DEFINE); return (DT_KEY_XLATOR); }
+ YY_BREAK
+case 69:
+YY_RULE_SETUP
+#line 220 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_TYPEDEF); }
+ YY_BREAK
+case 70:
+YY_RULE_SETUP
+#line 221 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_UNION); }
+ YY_BREAK
+case 71:
+YY_RULE_SETUP
+#line 222 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_UNSIGNED); }
+ YY_BREAK
+case 72:
+YY_RULE_SETUP
+#line 223 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_VOID); }
+ YY_BREAK
+case 73:
+YY_RULE_SETUP
+#line 224 "dt_lex.l"
+{ yybegin(YYS_EXPR); return (DT_KEY_VOLATILE); }
+ YY_BREAK
+case 74:
+YY_RULE_SETUP
+#line 226 "dt_lex.l"
+{
+ int i = atoi(yytext + 2);
+ char *v = "";
+
+ /*
+ * A macro argument reference substitutes the text of
+ * an argument in place of the current token. When we
+ * see $$<d> we fetch the saved string from pcb_sargv
+ * (or use the default argument if the option has been
+ * set and the argument hasn't been specified) and
+ * return a token corresponding to this string.
+ */
+ if (i < 0 || (i >= yypcb->pcb_sargc &&
+ !(yypcb->pcb_cflags & DTRACE_C_DEFARG))) {
+ xyerror(D_MACRO_UNDEF, "macro argument %s is "
+ "not defined\n", yytext);
+ }
+
+ if (i < yypcb->pcb_sargc) {
+ v = yypcb->pcb_sargv[i]; /* get val from pcb */
+ yypcb->pcb_sflagv[i] |= DT_IDFLG_REF;
+ }
+
+ if ((yylval.l_str = strdup(v)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) stresc2chr(yylval.l_str);
+ return (DT_TOK_STRING);
+ }
+ YY_BREAK
+case 75:
+YY_RULE_SETUP
+#line 256 "dt_lex.l"
+{
+ int i = atoi(yytext + 1);
+ char *p, *v = "0";
+
+ /*
+ * A macro argument reference substitutes the text of
+ * one identifier or integer pattern for another. When
+ * we see $<d> we fetch the saved string from pcb_sargv
+ * (or use the default argument if the option has been
+ * set and the argument hasn't been specified) and
+ * return a token corresponding to this string.
+ */
+ if (i < 0 || (i >= yypcb->pcb_sargc &&
+ !(yypcb->pcb_cflags & DTRACE_C_DEFARG))) {
+ xyerror(D_MACRO_UNDEF, "macro argument %s is "
+ "not defined\n", yytext);
+ }
+
+ if (i < yypcb->pcb_sargc) {
+ v = yypcb->pcb_sargv[i]; /* get val from pcb */
+ yypcb->pcb_sflagv[i] |= DT_IDFLG_REF;
+ }
+
+ /*
+ * If the macro text is not a valid integer or ident,
+ * then we treat it as a string. The string may be
+ * optionally enclosed in quotes, which we strip.
+ */
+ if (strbadidnum(v)) {
+ size_t len = strlen(v);
+
+ if (len != 1 && *v == '"' && v[len - 1] == '"')
+ yylval.l_str = strndup(v + 1, len - 2);
+ else
+ yylval.l_str = strndup(v, len);
+
+ if (yylval.l_str == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) stresc2chr(yylval.l_str);
+ return (DT_TOK_STRING);
+ }
+
+ /*
+ * If the macro text is not a string an begins with a
+ * digit or a +/- sign, process it as an integer token.
+ */
+ if (isdigit(v[0]) || v[0] == '-' || v[0] == '+') {
+#ifdef VBOX
+ int rc;
+#endif
+ if (isdigit(v[0]))
+ yyintprefix = 0;
+ else
+ yyintprefix = *v++;
+
+#ifndef VBOX
+ errno = 0;
+ yylval.l_int = strtoull(v, &p, 0);
+ (void) strncpy(yyintsuffix, p,
+ sizeof (yyintsuffix));
+#else
+ rc = RTStrToUInt64Ex(v, &p, 0, &yylval.l_int);
+ RTStrCopy(yyintsuffix, sizeof(yyintsuffix), p);
+#endif
+ yyintdecimal = *v != '0';
+
+#ifndef VBOX
+ if (errno == ERANGE)
+#else
+ if (rc == VWRN_NUMBER_TOO_BIG || rc == VWRN_NEGATIVE_UNSIGNED)
+#endif
+ xyerror(D_MACRO_OFLOW, "macro argument"
+ " %s constant %s results in integer"
+ " overflow\n", yytext, v);
+
+ return (DT_TOK_INT);
+ }
+
+ return (id_or_type(v));
+ }
+ YY_BREAK
+case 76:
+YY_RULE_SETUP
+#line 337 "dt_lex.l"
+{
+ dt_ident_t *idp = dt_idhash_lookup(
+ yypcb->pcb_hdl->dt_macros, yytext + 2);
+
+ char s[16]; /* enough for UINT_MAX + \0 */
+
+ if (idp == NULL) {
+ xyerror(D_MACRO_UNDEF, "macro variable %s "
+ "is not defined\n", yytext);
+ }
+
+ /*
+ * For the moment, all current macro variables are of
+ * type id_t (refer to dtrace_update() for details).
+ */
+ (void) snprintf(s, sizeof (s), "%u", idp->di_id);
+ if ((yylval.l_str = strdup(s)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ return (DT_TOK_STRING);
+ }
+ YY_BREAK
+case 77:
+YY_RULE_SETUP
+#line 359 "dt_lex.l"
+{
+ dt_ident_t *idp = dt_idhash_lookup(
+ yypcb->pcb_hdl->dt_macros, yytext + 1);
+
+ if (idp == NULL) {
+ xyerror(D_MACRO_UNDEF, "macro variable %s "
+ "is not defined\n", yytext);
+ }
+
+ /*
+ * For the moment, all current macro variables are of
+ * type id_t (refer to dtrace_update() for details).
+ */
+ yylval.l_int = (intmax_t)(int)idp->di_id;
+ yyintprefix = 0;
+ yyintsuffix[0] = '\0';
+ yyintdecimal = 1;
+
+ return (DT_TOK_INT);
+ }
+ YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 380 "dt_lex.l"
+{
+ return (id_or_type(yytext));
+ }
+ YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 384 "dt_lex.l"
+{
+ if ((yylval.l_str = strdup(yytext)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ return (DT_TOK_AGG);
+ }
+ YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 390 "dt_lex.l"
+{
+ if ((yylval.l_str = strdup("@_")) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ return (DT_TOK_AGG);
+ }
+ YY_BREAK
+case 81:
+#line 397 "dt_lex.l"
+case 82:
+#line 398 "dt_lex.l"
+case 83:
+YY_RULE_SETUP
+#line 398 "dt_lex.l"
+{
+ char *p;
+
+#ifndef VBOX
+ errno = 0;
+ yylval.l_int = strtoull(yytext, &p, 0);
+ (void) strncpy(yyintsuffix, p, sizeof (yyintsuffix));
+#else
+ int rc = RTStrToUInt64Ex(yytext, &p, 0, &yylval.l_int);
+ RTStrCopy(yyintsuffix, sizeof(yyintsuffix), p);
+#endif
+ yyintprefix = 0;
+ yyintdecimal = yytext[0] != '0';
+
+#ifndef VBOX
+ if (errno == ERANGE)
+#else
+ if (rc == VWRN_NUMBER_TOO_BIG || rc == VWRN_NEGATIVE_UNSIGNED)
+#endif
+ xyerror(D_INT_OFLOW, "constant %s results in "
+ "integer overflow\n", yytext);
+
+ if (*p != '\0' && strchr("uUlL", *p) == NULL) {
+ xyerror(D_INT_DIGIT, "constant %s contains "
+ "invalid digit %c\n", yytext, *p);
+ }
+
+ if ((YYSTATE) != S3)
+ return (DT_TOK_INT);
+
+ yypragma = dt_node_link(yypragma,
+ dt_node_int(yylval.l_int));
+ }
+ YY_BREAK
+case 84:
+YY_RULE_SETUP
+#line 431 "dt_lex.l"
+yyerror("floating-point constants are not permitted\n");
+ YY_BREAK
+/* VBOX changed:
+<S0>\"{RGX_STR}$ |
+<S3>\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal");
+ input: */
+case 85:
+YY_RULE_SETUP
+#line 437 "dt_lex.l"
+xyerror(D_STR_NL, "newline encountered in string literal");
+ YY_BREAK
+case 86:
+#line 440 "dt_lex.l"
+case 87:
+YY_RULE_SETUP
+#line 440 "dt_lex.l"
+{
+ /*
+ * Quoted string -- convert C escape sequences and
+ * return the string as a token.
+ */
+ yylval.l_str = strndup(yytext + 1, yyleng - 2);
+
+ if (yylval.l_str == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) stresc2chr(yylval.l_str);
+ if ((YYSTATE) != S3)
+ return (DT_TOK_STRING);
+
+ yypragma = dt_node_link(yypragma,
+ dt_node_string(yylval.l_str));
+ }
+ YY_BREAK
+case 88:
+YY_RULE_SETUP
+#line 458 "dt_lex.l"
+xyerror(D_CHR_NL, "newline encountered in character constant");
+ YY_BREAK
+case 89:
+YY_RULE_SETUP
+#line 460 "dt_lex.l"
+{
+ char *s, *p, *q;
+ size_t nbytes;
+
+ /*
+ * Character constant -- convert C escape sequences and
+ * return the character as an integer immediate value.
+ */
+ if (yyleng == 2)
+ xyerror(D_CHR_NULL, "empty character constant");
+
+ s = yytext + 1;
+ yytext[yyleng - 1] = '\0';
+ nbytes = stresc2chr(s);
+ yylval.l_int = 0;
+ yyintprefix = 0;
+ yyintsuffix[0] = '\0';
+ yyintdecimal = 1;
+
+ if (nbytes > sizeof (yylval.l_int)) {
+ xyerror(D_CHR_OFLOW, "character constant is "
+ "too long");
+ }
+#ifdef _LITTLE_ENDIAN
+ p = ((char *)&yylval.l_int) + nbytes - 1;
+ for (q = s; nbytes != 0; nbytes--)
+ *p-- = *q++;
+#else
+ bcopy(s, ((char *)&yylval.l_int) +
+ sizeof (yylval.l_int) - nbytes, nbytes);
+#endif
+ return (DT_TOK_INT);
+ }
+ YY_BREAK
+case 90:
+#line 495 "dt_lex.l"
+case 91:
+YY_RULE_SETUP
+#line 495 "dt_lex.l"
+{
+ yypcb->pcb_cstate = (YYSTATE);
+ BEGIN(S1);
+ }
+ YY_BREAK
+case 92:
+#line 501 "dt_lex.l"
+case 93:
+YY_RULE_SETUP
+#line 501 "dt_lex.l"
+; /* discard any #! lines */
+ YY_BREAK
+case 94:
+#line 504 "dt_lex.l"
+case 95:
+#line 505 "dt_lex.l"
+case 96:
+YY_RULE_SETUP
+#line 505 "dt_lex.l"
+{
+ assert(yypragma == NULL);
+ yypcb->pcb_cstate = (YYSTATE);
+ BEGIN(S3);
+ }
+ YY_BREAK
+case 97:
+YY_RULE_SETUP
+#line 511 "dt_lex.l"
+; /* discard */
+ YY_BREAK
+case 98:
+YY_RULE_SETUP
+#line 512 "dt_lex.l"
+; /* discard */
+ YY_BREAK
+case 99:
+YY_RULE_SETUP
+#line 514 "dt_lex.l"
+{
+ int c, tok;
+
+ /*
+ * The use of "/" as the predicate delimiter and as the
+ * integer division symbol requires special lookahead
+ * to avoid a shift/reduce conflict in the D grammar.
+ * We look ahead to the next non-whitespace character.
+ * If we encounter EOF, ";", "{", or "/", then this "/"
+ * closes the predicate and we return DT_TOK_EPRED.
+ * If we encounter anything else, it's DT_TOK_DIV.
+ */
+ while ((c = input()) != 0) {
+ if (strchr("\f\n\r\t\v ", c) == NULL)
+ break;
+ }
+
+ if (c == 0 || c == ';' || c == '{' || c == '/') {
+ if (yypcb->pcb_parens != 0) {
+ yyerror("closing ) expected in "
+ "predicate before /\n");
+ }
+ if (yypcb->pcb_brackets != 0) {
+ yyerror("closing ] expected in "
+ "predicate before /\n");
+ }
+ tok = DT_TOK_EPRED;
+ } else
+ tok = DT_TOK_DIV;
+
+ if (c != EOF) unput(c);
+ return (tok);
+ }
+ YY_BREAK
+case 100:
+YY_RULE_SETUP
+#line 548 "dt_lex.l"
+{
+ yypcb->pcb_parens++;
+ return (DT_TOK_LPAR);
+ }
+ YY_BREAK
+case 101:
+YY_RULE_SETUP
+#line 553 "dt_lex.l"
+{
+ if (--yypcb->pcb_parens < 0)
+ yyerror("extra ) in input stream\n");
+ return (DT_TOK_RPAR);
+ }
+ YY_BREAK
+case 102:
+YY_RULE_SETUP
+#line 559 "dt_lex.l"
+{
+ yypcb->pcb_brackets++;
+ return (DT_TOK_LBRAC);
+ }
+ YY_BREAK
+case 103:
+YY_RULE_SETUP
+#line 564 "dt_lex.l"
+{
+ if (--yypcb->pcb_brackets < 0)
+ yyerror("extra ] in input stream\n");
+ return (DT_TOK_RBRAC);
+ }
+ YY_BREAK
+case 104:
+#line 571 "dt_lex.l"
+case 105:
+YY_RULE_SETUP
+#line 571 "dt_lex.l"
+{
+ yypcb->pcb_braces++;
+ return ('{');
+ }
+ YY_BREAK
+case 106:
+YY_RULE_SETUP
+#line 576 "dt_lex.l"
+{
+ if (--yypcb->pcb_braces < 0)
+ yyerror("extra } in input stream\n");
+ return ('}');
+ }
+ YY_BREAK
+case 107:
+YY_RULE_SETUP
+#line 582 "dt_lex.l"
+return (DT_TOK_BOR);
+ YY_BREAK
+case 108:
+YY_RULE_SETUP
+#line 583 "dt_lex.l"
+return (DT_TOK_XOR);
+ YY_BREAK
+case 109:
+YY_RULE_SETUP
+#line 584 "dt_lex.l"
+return (DT_TOK_BAND);
+ YY_BREAK
+case 110:
+YY_RULE_SETUP
+#line 585 "dt_lex.l"
+return (DT_TOK_LAND);
+ YY_BREAK
+case 111:
+YY_RULE_SETUP
+#line 586 "dt_lex.l"
+return (DT_TOK_LXOR);
+ YY_BREAK
+case 112:
+YY_RULE_SETUP
+#line 587 "dt_lex.l"
+return (DT_TOK_LOR);
+ YY_BREAK
+case 113:
+YY_RULE_SETUP
+#line 588 "dt_lex.l"
+return (DT_TOK_EQU);
+ YY_BREAK
+case 114:
+YY_RULE_SETUP
+#line 589 "dt_lex.l"
+return (DT_TOK_NEQ);
+ YY_BREAK
+case 115:
+YY_RULE_SETUP
+#line 590 "dt_lex.l"
+return (DT_TOK_LT);
+ YY_BREAK
+case 116:
+YY_RULE_SETUP
+#line 591 "dt_lex.l"
+return (DT_TOK_LE);
+ YY_BREAK
+case 117:
+YY_RULE_SETUP
+#line 592 "dt_lex.l"
+return (DT_TOK_GT);
+ YY_BREAK
+case 118:
+YY_RULE_SETUP
+#line 593 "dt_lex.l"
+return (DT_TOK_GE);
+ YY_BREAK
+case 119:
+YY_RULE_SETUP
+#line 594 "dt_lex.l"
+return (DT_TOK_LSH);
+ YY_BREAK
+case 120:
+YY_RULE_SETUP
+#line 595 "dt_lex.l"
+return (DT_TOK_RSH);
+ YY_BREAK
+case 121:
+YY_RULE_SETUP
+#line 596 "dt_lex.l"
+return (DT_TOK_ADD);
+ YY_BREAK
+case 122:
+YY_RULE_SETUP
+#line 597 "dt_lex.l"
+return (DT_TOK_SUB);
+ YY_BREAK
+case 123:
+YY_RULE_SETUP
+#line 598 "dt_lex.l"
+return (DT_TOK_MUL);
+ YY_BREAK
+case 124:
+YY_RULE_SETUP
+#line 599 "dt_lex.l"
+return (DT_TOK_MOD);
+ YY_BREAK
+case 125:
+YY_RULE_SETUP
+#line 600 "dt_lex.l"
+return (DT_TOK_BNEG);
+ YY_BREAK
+case 126:
+YY_RULE_SETUP
+#line 601 "dt_lex.l"
+return (DT_TOK_LNEG);
+ YY_BREAK
+case 127:
+YY_RULE_SETUP
+#line 602 "dt_lex.l"
+return (DT_TOK_QUESTION);
+ YY_BREAK
+case 128:
+YY_RULE_SETUP
+#line 603 "dt_lex.l"
+return (DT_TOK_COLON);
+ YY_BREAK
+case 129:
+YY_RULE_SETUP
+#line 604 "dt_lex.l"
+return (DT_TOK_DOT);
+ YY_BREAK
+case 130:
+YY_RULE_SETUP
+#line 605 "dt_lex.l"
+return (DT_TOK_PTR);
+ YY_BREAK
+case 131:
+YY_RULE_SETUP
+#line 606 "dt_lex.l"
+return (DT_TOK_ASGN);
+ YY_BREAK
+case 132:
+YY_RULE_SETUP
+#line 607 "dt_lex.l"
+return (DT_TOK_ADD_EQ);
+ YY_BREAK
+case 133:
+YY_RULE_SETUP
+#line 608 "dt_lex.l"
+return (DT_TOK_SUB_EQ);
+ YY_BREAK
+case 134:
+YY_RULE_SETUP
+#line 609 "dt_lex.l"
+return (DT_TOK_MUL_EQ);
+ YY_BREAK
+case 135:
+YY_RULE_SETUP
+#line 610 "dt_lex.l"
+return (DT_TOK_DIV_EQ);
+ YY_BREAK
+case 136:
+YY_RULE_SETUP
+#line 611 "dt_lex.l"
+return (DT_TOK_MOD_EQ);
+ YY_BREAK
+case 137:
+YY_RULE_SETUP
+#line 612 "dt_lex.l"
+return (DT_TOK_AND_EQ);
+ YY_BREAK
+case 138:
+YY_RULE_SETUP
+#line 613 "dt_lex.l"
+return (DT_TOK_XOR_EQ);
+ YY_BREAK
+case 139:
+YY_RULE_SETUP
+#line 614 "dt_lex.l"
+return (DT_TOK_OR_EQ);
+ YY_BREAK
+case 140:
+YY_RULE_SETUP
+#line 615 "dt_lex.l"
+return (DT_TOK_LSH_EQ);
+ YY_BREAK
+case 141:
+YY_RULE_SETUP
+#line 616 "dt_lex.l"
+return (DT_TOK_RSH_EQ);
+ YY_BREAK
+case 142:
+YY_RULE_SETUP
+#line 617 "dt_lex.l"
+return (DT_TOK_ADDADD);
+ YY_BREAK
+case 143:
+YY_RULE_SETUP
+#line 618 "dt_lex.l"
+return (DT_TOK_SUBSUB);
+ YY_BREAK
+case 144:
+YY_RULE_SETUP
+#line 619 "dt_lex.l"
+return (DT_TOK_ELLIPSIS);
+ YY_BREAK
+case 145:
+YY_RULE_SETUP
+#line 620 "dt_lex.l"
+return (DT_TOK_COMMA);
+ YY_BREAK
+case 146:
+YY_RULE_SETUP
+#line 621 "dt_lex.l"
+return (';');
+ YY_BREAK
+case 147:
+YY_RULE_SETUP
+#line 622 "dt_lex.l"
+; /* discard */
+ YY_BREAK
+case 148:
+YY_RULE_SETUP
+#line 623 "dt_lex.l"
+; /* discard */
+ YY_BREAK
+case 149:
+YY_RULE_SETUP
+#line 624 "dt_lex.l"
+yyerror("syntax error near \"%c\"\n", yytext[0]);
+ YY_BREAK
+case 150:
+YY_RULE_SETUP
+#line 626 "dt_lex.l"
+yyerror("/* encountered inside a comment\n");
+ YY_BREAK
+case 151:
+YY_RULE_SETUP
+#line 627 "dt_lex.l"
+BEGIN(yypcb->pcb_cstate);
+ YY_BREAK
+/* VBOX - START */
+case YY_STATE_EOF(S1):
+#line 629 "dt_lex.l"
+yyerror("end-of-file encountered before matching */\n");
+ YY_BREAK
+/* VBOX - END */
+case 152:
+YY_RULE_SETUP
+#line 631 "dt_lex.l"
+; /* discard */
+ YY_BREAK
+case 153:
+YY_RULE_SETUP
+#line 633 "dt_lex.l"
+{
+ /*
+ * S2 has an ambiguity because RGX_PSPEC includes '*'
+ * as a glob character and '*' also can be DT_TOK_STAR.
+ * Since lex always matches the longest token, this
+ * rule can be matched by an input string like "int*",
+ * which could begin a global variable declaration such
+ * as "int*x;" or could begin a RGX_PSPEC with globbing
+ * such as "int* { trace(timestamp); }". If C_PSPEC is
+ * not set, we must resolve the ambiguity in favor of
+ * the type and perform lexer pushback if the fragment
+ * before '*' or entire fragment matches a type name.
+ * If C_PSPEC is set, we always return a PSPEC token.
+ * If C_PSPEC is off, the user can avoid ambiguity by
+ * including a ':' delimiter in the specifier, which
+ * they should be doing anyway to specify the provider.
+ */
+ if (!(yypcb->pcb_cflags & DTRACE_C_PSPEC) &&
+ strchr(yytext, ':') == NULL) {
+
+ char *p = strchr(yytext, '*');
+ char *q = yytext + yyleng - 1;
+
+ if (p != NULL && p > yytext)
+ *p = '\0'; /* prune yytext */
+
+ if (dt_type_lookup(yytext, NULL) == 0) {
+ yylval.l_str = strdup(yytext);
+
+ if (yylval.l_str == NULL) {
+ longjmp(yypcb->pcb_jmpbuf,
+ EDT_NOMEM);
+ }
+
+ if (p != NULL && p > yytext) {
+ for (*p = '*'; q >= p; q--)
+ unput(*q);
+ }
+
+ yybegin(YYS_EXPR);
+ return (DT_TOK_TNAME);
+ }
+
+ if (p != NULL && p > yytext)
+ *p = '*'; /* restore yytext */
+ }
+
+ if ((yylval.l_str = strdup(yytext)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ return (DT_TOK_PSPEC);
+ }
+ YY_BREAK
+case 154:
+YY_RULE_SETUP
+#line 686 "dt_lex.l"
+return (DT_TOK_DIV);
+ YY_BREAK
+case 155:
+YY_RULE_SETUP
+#line 687 "dt_lex.l"
+return (DT_TOK_COMMA);
+ YY_BREAK
+case 156:
+YY_RULE_SETUP
+#line 689 "dt_lex.l"
+; /* discard */
+ YY_BREAK
+case 157:
+YY_RULE_SETUP
+#line 690 "dt_lex.l"
+yyerror("syntax error near \"%c\"\n", yytext[0]);
+ YY_BREAK
+case 158:
+YY_RULE_SETUP
+#line 692 "dt_lex.l"
+{
+ dt_pragma(yypragma);
+ yypragma = NULL;
+ BEGIN(yypcb->pcb_cstate);
+ }
+ YY_BREAK
+case 159:
+YY_RULE_SETUP
+#line 698 "dt_lex.l"
+; /* discard */
+ YY_BREAK
+case 160:
+YY_RULE_SETUP
+#line 700 "dt_lex.l"
+{
+ dt_node_t *dnp;
+
+ if ((yylval.l_str = strdup(yytext)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * We want to call dt_node_ident() here, but we can't
+ * because it will expand inlined identifiers, which we
+ * don't want to do from #pragma context in order to
+ * support pragmas that apply to the ident itself. We
+ * call dt_node_string() and then reset dn_op instead.
+ */
+ dnp = dt_node_string(yylval.l_str);
+ dnp->dn_kind = DT_NODE_IDENT;
+ dnp->dn_op = DT_TOK_IDENT;
+ yypragma = dt_node_link(yypragma, dnp);
+ }
+ YY_BREAK
+/* VBOX - BEGIN */
+case YY_STATE_EOF(S3):
+#line 720 "dt_lex.l"
+yyerror("end-of-file encountered before end of control line\n");
+ YY_BREAK
+/* VBOX - END */
+case 161:
+YY_RULE_SETUP
+#line 722 "dt_lex.l"
+yyerror("syntax error near \"%c\"\n", yytext[0]);
+ YY_BREAK
+case 162:
+YY_RULE_SETUP
+#line 724 "dt_lex.l"
+ECHO;
+ YY_BREAK
+#line 2426 "dt_lex.c"
+ case YY_STATE_EOF(INITIAL):
+ case YY_STATE_EOF(S0):
+ case YY_STATE_EOF(S2):
+ case YY_STATE_EOF(S4):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = yy_hold_char;
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between yy_current_buffer and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ yy_n_chars = yy_current_buffer->yy_n_chars;
+ yy_current_buffer->yy_input_file = yyin;
+ yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state();
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++yy_c_buf_p;
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = yy_c_buf_p;
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer() )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ yy_did_buffer_switch_on_eof = 0;
+
+ if ( yywrap() )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yy_c_buf_p =
+ yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state();
+
+ yy_cp = yy_c_buf_p;
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ yy_c_buf_p =
+ &yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+ yy_current_state = yy_get_previous_state();
+
+ yy_cp = yy_c_buf_p;
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+ } /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+ {
+ register char *dest = yy_current_buffer->yy_ch_buf;
+ register char *source = yytext_ptr;
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( yy_current_buffer->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+ else
+ {
+ int num_to_read =
+ yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+ YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = yy_current_buffer;
+
+ int yy_c_buf_p_offset =
+ (int) (yy_c_buf_p - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yy_flex_realloc( (void *) b->yy_ch_buf,
+ b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = yy_current_buffer->yy_buf_size -
+ number_to_move - 1;
+#endif
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+ yy_n_chars, num_to_read );
+
+ yy_current_buffer->yy_n_chars = yy_n_chars;
+ }
+
+ if ( yy_n_chars == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart( yyin );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ yy_current_buffer->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ yy_n_chars += number_to_move;
+ yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+ yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+ return ret_val;
+ }
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+ {
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = yy_start;
+ yy_current_state += YY_AT_BOL();
+ yy_state_ptr = yy_state_buf;
+ *yy_state_ptr++ = yy_current_state;
+
+ for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 510 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ *yy_state_ptr++ = yy_current_state;
+ }
+
+ return yy_current_state;
+ }
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+ {
+ register int yy_is_jam;
+
+ register YY_CHAR yy_c = 1;
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 510 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 509);
+ if ( ! yy_is_jam )
+ *yy_state_ptr++ = yy_current_state;
+
+ return yy_is_jam ? 0 : yy_current_state;
+ }
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+ {
+ register char *yy_cp = yy_c_buf_p;
+
+ /* undo effects of setting up yytext */
+ *yy_cp = yy_hold_char;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ { /* need to shift things up to make room */
+ /* +2 for EOB chars. */
+ register int number_to_move = yy_n_chars + 2;
+ register char *dest = &yy_current_buffer->yy_ch_buf[
+ yy_current_buffer->yy_buf_size + 2];
+ register char *source =
+ &yy_current_buffer->yy_ch_buf[number_to_move];
+
+ while ( source > yy_current_buffer->yy_ch_buf )
+ *--dest = *--source;
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+ yy_current_buffer->yy_n_chars =
+ yy_n_chars = yy_current_buffer->yy_buf_size;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+ }
+
+ *--yy_cp = (char) c;
+
+ if ( c == '\n' )
+ --yylineno;
+
+ yytext_ptr = yy_bp;
+ yy_hold_char = *yy_cp;
+ yy_c_buf_p = yy_cp;
+ }
+#endif /* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+ {
+ int c;
+
+ *yy_c_buf_p = yy_hold_char;
+
+ if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ /* This was really a NUL. */
+ *yy_c_buf_p = '\0';
+
+ else
+ { /* need more input */
+ int offset = yy_c_buf_p - yytext_ptr;
+ ++yy_c_buf_p;
+
+ switch ( yy_get_next_buffer() )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart( yyin );
+
+ /* fall through */
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap() )
+ return EOF;
+
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yy_c_buf_p = yytext_ptr + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
+ *yy_c_buf_p = '\0'; /* preserve yytext */
+ yy_hold_char = *++yy_c_buf_p;
+
+ yy_current_buffer->yy_at_bol = (c == '\n');
+ if ( yy_current_buffer->yy_at_bol )
+ ++yylineno;
+
+ return c;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+ {
+ if ( ! yy_current_buffer )
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+ yy_init_buffer( yy_current_buffer, input_file );
+ yy_load_buffer_state();
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+ {
+ if ( yy_current_buffer == new_buffer )
+ return;
+
+ if ( yy_current_buffer )
+ {
+ /* Flush out information for old buffer. */
+ *yy_c_buf_p = yy_hold_char;
+ yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+ yy_current_buffer->yy_n_chars = yy_n_chars;
+ }
+
+ yy_current_buffer = new_buffer;
+ yy_load_buffer_state();
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ yy_did_buffer_switch_on_eof = 1;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+ {
+ yy_n_chars = yy_current_buffer->yy_n_chars;
+ yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+ yyin = yy_current_buffer->yy_input_file;
+ yy_hold_char = *yy_c_buf_p;
+ }
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+ {
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer( b, file );
+
+ return b;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+ {
+ if ( ! b )
+ return;
+
+ if ( b == yy_current_buffer )
+ yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yy_flex_free( (void *) b->yy_ch_buf );
+
+ yy_flex_free( (void *) b );
+ }
+
+
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+ {
+ yy_flush_buffer( b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+ b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+ b->yy_is_interactive = 0;
+#else
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+ {
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == yy_current_buffer )
+ yy_load_buffer_state();
+ }
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+ {
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer( b );
+
+ return b;
+ }
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+#else
+YY_BUFFER_STATE yy_scan_string( yy_str )
+yyconst char *yy_str;
+#endif
+ {
+ int len;
+ for ( len = 0; yy_str[len]; ++len )
+ ;
+
+ return yy_scan_bytes( yy_str, len );
+ }
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+ {
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = len + 2;
+ buf = (char *) yy_flex_alloc( n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < len; ++i )
+ buf[i] = bytes[i];
+
+ buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer( buf, n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+ }
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+ {
+ if ( yy_start_stack_ptr >= yy_start_stack_depth )
+ {
+ yy_size_t new_size;
+
+ yy_start_stack_depth += YY_START_STACK_INCR;
+ new_size = yy_start_stack_depth * sizeof( int );
+
+ if ( ! yy_start_stack )
+ yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+ else
+ yy_start_stack = (int *) yy_flex_realloc(
+ (void *) yy_start_stack, new_size );
+
+ if ( ! yy_start_stack )
+ YY_FATAL_ERROR(
+ "out of memory expanding start-condition stack" );
+ }
+
+ yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+ BEGIN(new_state);
+ }
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+ {
+ if ( --yy_start_stack_ptr < 0 )
+ YY_FATAL_ERROR( "start-condition stack underflow" );
+
+ BEGIN(yy_start_stack[yy_start_stack_ptr]);
+ }
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+ {
+ return yy_start_stack[yy_start_stack_ptr - 1];
+ }
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+ {
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+ }
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ yytext[yyleng] = yy_hold_char; \
+ yy_c_buf_p = yytext + n; \
+ yy_hold_char = *yy_c_buf_p; \
+ *yy_c_buf_p = '\0'; \
+ yyleng = n; \
+ } \
+ while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+ {
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+ }
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+ {
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+ }
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+ {
+ return (void *) malloc( size );
+ }
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+ {
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+ }
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+ {
+ free( ptr );
+ }
+
+#if YY_MAIN
+int main()
+ {
+ yylex();
+ return 0;
+ }
+#endif
+#line 724 "dt_lex.l"
+
+
+/*
+ * yybegin provides a wrapper for use from C code around the lex BEGIN() macro.
+ * We use two main states for lexing because probe descriptions use a syntax
+ * that is incompatible with the normal D tokens (e.g. names can contain "-").
+ * yybegin also handles the job of switching between two lists of dt_nodes
+ * as we allocate persistent definitions, like inlines, and transient nodes
+ * that will be freed once we are done parsing the current program file.
+ */
+void
+yybegin(yystate_t state)
+{
+#if YYDEBUG /* VBOX: ifdef YYDEBUG => if YYDEBUG */
+ yydebug = _dtrace_debug;
+#endif
+ if (yypcb->pcb_yystate == state)
+ return; /* nothing to do if we're in the state already */
+
+ if (yypcb->pcb_yystate == YYS_DEFINE) {
+ yypcb->pcb_list = yypcb->pcb_hold;
+ yypcb->pcb_hold = NULL;
+ }
+
+ switch (state) {
+ case YYS_CLAUSE:
+ BEGIN(S2);
+ break;
+ case YYS_DEFINE:
+ assert(yypcb->pcb_hold == NULL);
+ yypcb->pcb_hold = yypcb->pcb_list;
+ yypcb->pcb_list = NULL;
+ /*FALLTHRU*/
+ case YYS_EXPR:
+ BEGIN(S0);
+ break;
+ case YYS_DONE:
+ break;
+ case YYS_CONTROL:
+ BEGIN(S4);
+ break;
+ default:
+ xyerror(D_UNKNOWN, "internal error -- bad yystate %d\n", state);
+ }
+
+ yypcb->pcb_yystate = state;
+}
+
+void
+yyinit(dt_pcb_t *pcb)
+{
+ yypcb = pcb;
+ yylineno = 1;
+ yypragma = NULL;
+#ifndef USING_FLEX
+ yysptr = yysbuf;
+#else
+ yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
+#endif
+}
+
+/*
+ * Given a lexeme 's' (typically yytext), set yylval and return an appropriate
+ * token to the parser indicating either an identifier or a typedef name.
+ * User-defined global variables always take precedence over types, but we do
+ * use some heuristics because D programs can look at an ever-changing set of
+ * kernel types and also can implicitly instantiate variables by assignment,
+ * unlike in C. The code here is ordered carefully as lookups are not cheap.
+ */
+static int
+id_or_type(const char *s)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_decl_t *ddp = yypcb->pcb_dstack.ds_decl;
+ int c0, c1, ttok = DT_TOK_TNAME;
+ dt_ident_t *idp;
+
+ if ((s = yylval.l_str = strdup(s)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * If the lexeme is a global variable or likely identifier or *not* a
+ * type_name, then it is an identifier token.
+ */
+ if (dt_idstack_lookup(&yypcb->pcb_globals, s) != NULL ||
+ dt_idhash_lookup(yypcb->pcb_idents, s) != NULL ||
+ dt_type_lookup(s, NULL) != 0)
+ return (DT_TOK_IDENT);
+
+ /*
+ * If we're in the midst of parsing a declaration and a type_specifier
+ * has already been shifted, then return DT_TOK_IDENT instead of TNAME.
+ * This semantic is necessary to permit valid ISO C code such as:
+ *
+ * typedef int foo;
+ * struct s { foo foo; };
+ *
+ * without causing shift/reduce conflicts in the direct_declarator part
+ * of the grammar. The result is that we must check for conflicting
+ * redeclarations of the same identifier as part of dt_node_decl().
+ */
+ if (ddp != NULL && ddp->dd_name != NULL)
+ return (DT_TOK_IDENT);
+
+ /*
+ * If the lexeme is a type name and we are not in a program clause,
+ * then always interpret it as a type and return DT_TOK_TNAME.
+ */
+ if ((YYSTATE) != S0)
+ return (DT_TOK_TNAME);
+
+ /*
+ * If the lexeme matches a type name but is in a program clause, then
+ * it could be a type or it could be an undefined variable. Peek at
+ * the next token to decide. If we see ++, --, [, or =, we know there
+ * might be an assignment that is trying to create a global variable,
+ * so we optimistically return DT_TOK_IDENT. There is no harm in being
+ * wrong: a type_name followed by ++, --, [, or = is a syntax error.
+ */
+ while ((c0 = input()) != 0) {
+ if (strchr("\f\n\r\t\v ", c0) == NULL)
+ break;
+ }
+
+ switch (c0) {
+ case '+':
+ case '-':
+ if ((c1 = input()) == c0)
+ ttok = DT_TOK_IDENT;
+ if (c1 != EOF) unput(c1);
+ break;
+
+ case '=':
+ if ((c1 = input()) != c0)
+ ttok = DT_TOK_IDENT;
+ if (c1 != EOF) unput(c1);
+ break;
+ case '[':
+ ttok = DT_TOK_IDENT;
+ break;
+ }
+
+ if (ttok == DT_TOK_IDENT) {
+ idp = dt_idhash_insert(yypcb->pcb_idents, s, DT_IDENT_SCALAR, 0,
+ 0, _dtrace_defattr, 0, &dt_idops_thaw, NULL, dtp->dt_gen);
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ if (c0 != EOF) unput(c0);
+ return (ttok);
+}
+
+#ifndef USING_FLEX
+
+static int
+input(void)
+{
+ int c;
+
+ if (yysptr > yysbuf)
+ c = *--yysptr;
+ else if (yypcb->pcb_fileptr != NULL)
+ c = fgetc(yypcb->pcb_fileptr);
+ else if (yypcb->pcb_strptr < yypcb->pcb_string + yypcb->pcb_strlen)
+ c = *(unsigned char *)(yypcb->pcb_strptr++);
+ else
+ c = EOF;
+
+ if (c == '\n')
+ yylineno++;
+
+ if (c != EOF)
+ return (c);
+
+ if ((YYSTATE) == S1)
+ yyerror("end-of-file encountered before matching */\n");
+
+ if ((YYSTATE) == S3)
+ yyerror("end-of-file encountered before end of control line\n");
+
+ if (yypcb->pcb_fileptr != NULL && ferror(yypcb->pcb_fileptr))
+ longjmp(yypcb->pcb_jmpbuf, EDT_FIO);
+
+ return (0); /* EOF */
+}
+
+static void
+unput(int c)
+{
+ if (c == '\n')
+ yylineno--;
+
+ *yysptr++ = c;
+ yytchar = c;
+}
+
+#endif /* USING_FLEX */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceLibCWrappers.h b/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceLibCWrappers.h
new file mode 100644
index 00000000..b2345519
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceLibCWrappers.h
@@ -0,0 +1,101 @@
+/* $Id: VBoxDTraceLibCWrappers.h $ */
+/** @file
+ * VBoxDTraceTLibCWrappers.h - IPRT wrappers/fake for lib C stuff.
+ *
+ * Contributed by: bird
+ */
+
+/*
+ * Copyright (C) 2012-2023 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from http://www.virtualbox.org.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License Version 1.0 (CDDL) only, as it
+ * comes in the "COPYING.CDDL" file of the VirtualBox distribution.
+ *
+ * SPDX-License-Identifier: CDDL-1.0
+ */
+
+#ifndef VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceLibCWrappers_h
+#define VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceLibCWrappers_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef RT_OS_WINDOWS
+# include <process.h>
+#else
+# include <sys/types.h>
+# include <limits.h> /* Workaround for syslimit.h bug in gcc 4.8.3 on gentoo. */
+# ifdef RT_OS_DARWIN
+# include <sys/syslimits.h> /* PATH_MAX */
+# elif !defined(RT_OS_SOLARIS) && !defined(RT_OS_FREEBSD)
+# include <syslimits.h> /* PATH_MAX */
+# endif
+# include <libgen.h> /* basename */
+# include <unistd.h>
+# include <strings.h> /* bzero & bcopy.*/
+#endif
+
+#include <iprt/mem.h>
+#include <iprt/process.h>
+#include <iprt/param.h>
+#include <iprt/alloca.h>
+#include <iprt/assert.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
+#include <iprt/time.h>
+
+
+#undef gethrtime
+#define gethrtime() RTTimeNanoTS()
+#undef strcasecmp
+#define strcasecmp(a_psz1, a_psz2) RTStrICmp(a_psz1, a_psz2)
+#undef strncasecmp
+#define strncasecmp(a_psz1, a_psz2, a_cch) RTStrNICmp(a_psz1, a_psz2, a_cch)
+#undef strlcpy
+#define strlcpy(a_pszDst, a_pszSrc, a_cbDst) ((void)RTStrCopy(a_pszDst, a_cbDst, a_pszSrc))
+
+#undef assert
+#define assert(expr) Assert(expr)
+
+#undef PATH_MAX
+#define PATH_MAX RTPATH_MAX
+
+#undef getpid
+#define getpid RTProcSelf
+
+#undef basename
+#define basename(a_pszPath) RTPathFilename(a_pszPath)
+
+#undef malloc
+#define malloc(a_cb) RTMemAlloc(a_cb)
+#undef calloc
+#define calloc(a_cItems, a_cb) RTMemAllocZ((size_t)(a_cb) * (a_cItems))
+#undef realloc
+#define realloc(a_pvOld, a_cbNew) RTMemRealloc(a_pvOld, a_cbNew)
+#undef free
+#define free(a_pv) RTMemFree(a_pv)
+
+/* Not using RTStrDup and RTStrNDup here because the allocation won't be freed
+ by RTStrFree and thus may cause trouble when using the efence. */
+#undef strdup
+#define strdup(a_psz) ((char *)RTMemDup(a_psz, strlen(a_psz) + 1))
+#undef strndup
+#define strndup(a_psz, a_cchMax) ((char *)RTMemDupEx(a_psz, RTStrNLen(a_psz, a_cchMax), 1))
+
+/* For various stupid reasons, these are duplicated in VBoxDTraceTypes.h. */
+#undef bcopy
+#define bcopy(a_pSrc, a_pDst, a_cb) ((void)memmove(a_pDst, a_pSrc, a_cb))
+#undef bzero
+#define bzero(a_pDst, a_cb) ((void)memset(a_pDst, 0, a_cb))
+#undef bcmp
+#define bcmp(a_p1, a_p2, a_cb) (memcmp(a_p1, a_p2, a_cb))
+
+#endif /* !VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceLibCWrappers_h */
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h b/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h
new file mode 100644
index 00000000..691ddc2f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h
@@ -0,0 +1,472 @@
+
+/* $Id: VBoxDTraceTypes.h $ */
+/** @file
+ * VBoxDTraceTypes.h - Fake a bunch of Solaris types.
+ *
+ * Contributed by: bird
+ */
+
+/*
+ * Copyright (C) 2012-2023 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from http://www.virtualbox.org.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License Version 1.0 (CDDL) only, as it
+ * comes in the "COPYING.CDDL" file of the VirtualBox distribution.
+ *
+ * SPDX-License-Identifier: CDDL-1.0
+ */
+
+#ifndef VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceTypes_h
+#define VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceTypes_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <iprt/types.h>
+#include <iprt/stdarg.h>
+#include <iprt/assert.h>
+#include <iprt/param.h>
+#include <iprt/errno.h>
+#ifdef IN_RING0
+# include <iprt/list.h>
+#endif
+#ifdef IN_RING3
+# include <sys/types.h>
+# include <limits.h>
+# ifdef RT_OS_LINUX
+# include <sys/ucontext.h> /* avoid greg_t trouble */
+# endif
+# if defined(_MSC_VER)
+# include <stdio.h>
+# endif
+#endif
+
+RT_C_DECLS_BEGIN
+
+struct modctl;
+
+typedef unsigned char uchar_t;
+typedef unsigned short ushort_t;
+typedef unsigned int uint_t;
+typedef uintptr_t ulong_t;
+#ifndef RT_OS_SOLARIS
+typedef int64_t longlong_t;
+typedef uint64_t u_longlong_t;
+typedef uint64_t hrtime_t;
+# ifndef RT_OS_FREEBSD
+typedef uint32_t id_t;
+# endif
+typedef uint32_t zoneid_t;
+#endif
+#if (!defined(__NGREG) && !defined(NGREG)) || !defined(RT_OS_LINUX)
+typedef RTCCINTREG greg_t;
+#else
+AssertCompileSize(greg_t, sizeof(RTCCINTREG));
+#endif
+typedef uintptr_t pc_t;
+typedef unsigned int model_t;
+typedef RTCPUID processorid_t;
+#if defined(_MSC_VER) || defined(IN_RING0)
+typedef RTUID uid_t;
+typedef RTPROCESS pid_t;
+#endif
+#if defined(_MSC_VER) || defined(IN_RING0) || defined(RT_OS_LINUX)
+typedef char *caddr_t;
+#endif
+
+#if !defined(NANOSEC) || !defined(RT_OS_SOLARIS)
+# define NANOSEC RT_NS_1SEC
+#endif
+#if !defined(MICROSEC) || !defined(RT_OS_SOLARIS)
+# define MICROSEC RT_US_1SEC
+#endif
+#if !defined(MILLISEC) || !defined(RT_OS_SOLARIS)
+# define MILLISEC RT_MS_1SEC
+#endif
+#if !defined(SEC) || !defined(RT_OS_SOLARIS)
+# define SEC (1)
+#endif
+#define MAXPATHLEN RTPATH_MAX
+#undef PATH_MAX
+#define PATH_MAX RTPATH_MAX
+#undef NBBY
+#define NBBY (8)
+#define NCPU RTCPUSET_MAX_CPUS
+#define B_FALSE (0)
+#define B_TRUE (1)
+#define MIN(a1, a2) RT_MIN(a1, a2)
+#define MAX(a1, a2) RT_MAX(a1, a2)
+#define ABS(a_iValue) RT_ABS(a_iValue)
+#define IS_P2ALIGNED(uWhat, uAlign) ( !((uWhat) & ((uAlign) - 1)) )
+#define P2ROUNDUP(uWhat, uAlign) ( ((uWhat) + (uAlign) - 1) & ~(uAlign - 1) )
+#define roundup(uWhat, uUnit) ( ( (uWhat) + ((uUnit) - 1)) / (uUnit) * (uUnit) )
+
+#if defined(RT_ARCH_X86)
+# ifndef __i386
+# define __i386 1
+# endif
+# ifndef __x86
+# define __x86 1
+# endif
+# ifndef _IPL32
+# define _IPL32 1
+# endif
+# if !defined(_LITTLE_ENDIAN) || (!defined(RT_OS_SOLARIS) && !defined(RT_OS_FREEBSD))
+# define _LITTLE_ENDIAN 1
+# endif
+
+#elif defined(RT_ARCH_AMD64)
+# ifndef __x86_64
+# define __x86_64 1
+# endif
+# ifndef __x86
+# define __x86 1
+# endif
+# ifndef _LP64
+# define _LP64 1
+# endif
+# if !defined(_LITTLE_ENDIAN) || (!defined(RT_OS_SOLARIS) && !defined(RT_OS_FREEBSD))
+# define _LITTLE_ENDIAN 1
+# endif
+
+#else
+# error "unsupported arch!"
+#endif
+
+/** Mark a cast added when porting the code to VBox.
+ * Avoids lots of \#ifdef VBOX otherwise needed to mark up the changes. */
+#define VBDTCAST(a_Type) (a_Type)
+/** Mark a type change made when porting the code to VBox.
+ * This is usually signed -> unsigned type changes that avoids a whole lot of
+ * comparsion warnings. */
+#define VBDTTYPE(a_VBox, a_Org) a_VBox
+/** Mark missing void in a parameter list. */
+#define VBDTVOID void
+/** Mark missing static in a function definition. */
+#define VBDTSTATIC static
+#define VBDTUNASS(a_Value) = a_Value
+#define VBDTGCC(a_Value) = a_Value
+#define VBDTMSC(a_Value) = a_Value
+
+/*
+ * string
+ */
+#ifdef IN_RING0
+# undef bcopy
+# define bcopy(a_pSrc, a_pDst, a_cb) ((void)memmove(a_pDst, a_pSrc, a_cb))
+# undef bzero
+# define bzero(a_pDst, a_cb) ((void)memset(a_pDst, 0, a_cb))
+# undef bcmp
+# define bcmp(a_p1, a_p2, a_cb) (memcmp(a_p1, a_p2, a_cb))
+#endif
+#if defined(_MSC_VER) || defined(IN_RING0)
+# define snprintf (int)RTStrPrintf /** @todo wrong return value */
+# define vsnprintf (int)RTStrPrintfV /** @todo wrong return value */
+#endif
+
+/*
+ * Bitmap stuff.
+ */
+#define BT_SIZEOFMAP(a_cBits) ( (a_cBits + 63) / 8 )
+#define BT_SET(a_aulBitmap, iBit) ASMBitSet(a_aulBitmap, iBit)
+#define BT_CLEAR(a_aulBitmap, iBit) ASMBitClear(a_aulBitmap, iBit)
+#define BT_TEST(a_aulBitmap, iBit) ASMBitTest(a_aulBitmap, iBit)
+#if ARCH_BITS == 32
+# define BT_NBIPUL 32
+# define BT_ULSHIFT 5 /* log2(32) = 5 */
+# define BT_ULMASK 0x1f
+# define BT_BITOUL(a_cBits) ( ((a_cBits) + 31) / 32 )
+#elif ARCH_BITS == 64
+# define BT_NBIPUL 64
+# define BT_ULSHIFT 6 /* log2(32) = 6 */
+# define BT_ULMASK 0x3f
+# define BT_BITOUL(a_cBits) ( ((a_cBits) + 63) / 64 )
+#else
+# error Bad ARCH_BITS...
+#endif
+
+
+#ifdef IN_RING0
+
+/*
+ * Kernel stuff...
+ */
+#define CPU_ON_INTR(a_pCpu) (false)
+
+#define KERNELBASE VBoxDtGetKernelBase()
+uintptr_t VBoxDtGetKernelBase(void);
+
+
+typedef struct VBoxDtCred
+{
+ int32_t cr_refs;
+ RTUID cr_uid;
+ RTUID cr_ruid;
+ RTUID cr_suid;
+ RTGID cr_gid;
+ RTGID cr_rgid;
+ RTGID cr_sgid;
+ zoneid_t cr_zone;
+} cred_t;
+#define PRIV_POLICY_ONLY(a_pCred, a_uPriv, a_fAll) (true)
+#define priv_isequalset(a, b) (true)
+#define crgetuid(a_pCred) ((a_pCred)->cr_uid)
+#define crgetzoneid(a_pCred) ((a_pCred)->cr_zone)
+#define crhold VBoxDtCredHold
+#define crfree VBoxDtCredFree
+void VBoxDtCredHold(struct VBoxDtCred *pCred);
+void VBoxDtCredFree(struct VBoxDtCred *pCred);
+
+
+typedef struct RTTIMER *cyclic_id_t;
+#define CYCLIC_NONE ((struct RTTIMER *)NULL)
+#define cyclic_remove(a_hTimer) RTTimerDestroy(a_hTimer)
+
+typedef struct VBoxDtThread
+{
+ /** The next thread with the same hash table entry.
+ * Or the next free thread. */
+ struct VBoxDtThread *pNext;
+ /** Age list node. */
+ RTLISTNODE AgeEntry;
+ /** The native thread handle. */
+ RTNATIVETHREAD hNative;
+ /** The process ID. */
+ RTPROCESS uPid;
+
+ uint32_t t_predcache;
+ uintptr_t t_dtrace_scrpc;
+ uintptr_t t_dtrace_astpc;
+ hrtime_t t_dtrace_vtime;
+ hrtime_t t_dtrace_start;
+ uint8_t t_dtrace_stop;
+} kthread_t;
+struct VBoxDtThread *VBoxDtGetCurrentThread(void);
+#define curthread (VBoxDtGetCurrentThread())
+
+
+typedef struct VBoxDtProcess proc_t;
+# if 0 /* not needed ? */
+struct VBoxDtProcess proc_t;
+{
+/* uint32_t p_flag; - don't bother with this */
+ RTPROCESS p_pid;
+ struct dtrace_helpers *p_dtrace_helpers;
+}
+proc_t *VBoxDtGetCurrentProc(void);
+# define curproc (VBoxDtGetCurrentProc())
+/*# define SNOCD RT_BIT(0) - don't bother with this */
+# endif
+
+typedef struct VBoxDtTaskQueue taskq_t;
+
+typedef struct VBoxDtMutex
+{
+ RTSEMMUTEX hMtx;
+ RTNATIVETHREAD volatile hOwner;
+} kmutex_t;
+#define mutex_enter VBoxDtMutexEnter
+#define mutex_exit VBoxDtMutexExit
+#define MUTEX_HELD(a_pMtx) VBoxDtMutexIsOwner(a_pMtx)
+#define MUTEX_NOT_HELD(a_pMtx) (!VBoxDtMutexIsOwner(a_pMtx))
+#define mod_lock g_DummyMtx
+#define cpu_lock g_DummyMtx
+int VBoxDtMutexInit(struct VBoxDtMutex *pMtx);
+void VBoxDtMutexDelete(struct VBoxDtMutex *pMtx);
+void VBoxDtMutexEnter(struct VBoxDtMutex *pMtx);
+void VBoxDtMutexExit(struct VBoxDtMutex *pMtx);
+bool VBoxDtMutexIsOwner(struct VBoxDtMutex *pMtx);
+extern struct VBoxDtMutex g_DummyMtx;
+
+
+typedef struct VBoxDtCpuCore
+{
+ RTCPUID cpu_id;
+ uintptr_t cpuc_dtrace_illval;
+ uint16_t volatile cpuc_dtrace_flags;
+
+} cpucore_t;
+
+#define CPU_DTRACE_BADADDR RT_BIT(0)
+#define CPU_DTRACE_BADALIGN RT_BIT(1)
+#define CPU_DTRACE_BADSTACK RT_BIT(2)
+#define CPU_DTRACE_KPRIV RT_BIT(3)
+#define CPU_DTRACE_DIVZERO RT_BIT(4)
+#define CPU_DTRACE_ILLOP RT_BIT(5)
+#define CPU_DTRACE_NOSCRATCH RT_BIT(6)
+#define CPU_DTRACE_UPRIV RT_BIT(7)
+#define CPU_DTRACE_TUPOFLOW RT_BIT(8)
+#define CPU_DTRACE_ENTRY RT_BIT(9)
+#define CPU_DTRACE_FAULT UINT16_C(0x03ff)
+#define CPU_DTRACE_DROP RT_BIT(12)
+#define CPU_DTRACE_ERROR UINT16_C(0x13ff)
+#define CPU_DTRACE_NOFAULT RT_BIT(15)
+
+extern cpucore_t g_aVBoxDtCpuCores[RTCPUSET_MAX_CPUS];
+#define cpu_core (g_aVBoxDtCpuCores)
+
+struct VBoxDtCred *VBoxDtGetCurrentCreds(void);
+#define CRED() VBoxDtGetCurrentCreds()
+
+proc_t *VBoxDtThreadToProc(kthread_t *);
+
+
+#define ASSERT(a_Expr) Assert(a_Expr)
+#define panic VBoxDtPanic
+void VBoxDtPanic(const char *pszFormat, ...);
+#define cmn_err VBoxDtCmnErr
+void VBoxDtCmnErr(int iLevel, const char *pszFormat, ...);
+#define CE_WARN 10
+#define CE_NOTE 11
+#define uprintf VBoxDtUPrintf
+#define vuprintf VBoxDtUPrintfV
+void VBoxDtUPrintf(const char *pszFormat, ...);
+void VBoxDtUPrintfV(const char *pszFormat, va_list va);
+
+/*
+ * Memory allocation wrappers.
+ */
+#define KM_SLEEP RT_BIT(0)
+#define KM_NOSLEEP RT_BIT(1)
+#define kmem_alloc VBoxDtKMemAlloc
+#define kmem_zalloc VBoxDtKMemAllocZ
+#define kmem_free VBoxDtKMemFree
+void *VBoxDtKMemAlloc(size_t cbMem, uint32_t fFlags);
+void *VBoxDtKMemAllocZ(size_t cbMem, uint32_t fFlags);
+void VBoxDtKMemFree(void *pvMem, size_t cbMem);
+
+
+typedef struct VBoxDtMemCache kmem_cache_t;
+#define kmem_cache_create VBoxDtKMemCacheCreate
+#define kmem_cache_destroy VBoxDtKMemCacheDestroy
+#define kmem_cache_alloc VBoxDtKMemCacheAlloc
+#define kmem_cache_free VBoxDtKMemCacheFree
+struct VBoxDtMemCache *VBoxDtKMemCacheCreate(const char *pszName, size_t cbBuf, size_t cbAlign,
+ PFNRT pfnCtor, PFNRT pfnDtor, PFNRT pfnReclaim,
+ void *pvUser, void *pvVM, uint32_t fFlags);
+void VBoxDtKMemCacheDestroy(struct VBoxDtMemCache *pCache);
+void *VBoxDtKMemCacheAlloc(struct VBoxDtMemCache *pCache, uint32_t fFlags);
+void VBoxDtKMemCacheFree(struct VBoxDtMemCache *pCache, void *pvMem);
+
+
+typedef struct VBoxDtVMem vmem_t;
+#define VM_SLEEP RT_BIT(0)
+#define VM_BESTFIT RT_BIT(1)
+#define VMC_IDENTIFIER RT_BIT(16)
+#define vmem_create VBoxDtVMemCreate
+#define vmem_destroy VBoxDtVMemDestroy
+#define vmem_alloc VBoxDtVMemAlloc
+#define vmem_free VBoxDtVMemFree
+struct VBoxDtVMem *VBoxDtVMemCreate(const char *pszName, void *pvBase, size_t cb, size_t cbUnit,
+ PFNRT pfnAlloc, PFNRT pfnFree, struct VBoxDtVMem *pSrc,
+ size_t cbQCacheMax, uint32_t fFlags);
+void VBoxDtVMemDestroy(struct VBoxDtVMem *pVMemArena);
+void *VBoxDtVMemAlloc(struct VBoxDtVMem *pVMemArena, size_t cbMem, uint32_t fFlags);
+void VBoxDtVMemFree(struct VBoxDtVMem *pVMemArena, void *pvMem, size_t cbMem);
+
+/*
+ * Copy In/Out
+ */
+#define copyin VBoxDtCopyIn
+#define copyout VBoxDtCopyOut
+int VBoxDtCopyIn(void const *pvUser, void *pvDst, size_t cb);
+int VBoxDtCopyOut(void const *pvSrc, void *pvUser, size_t cb);
+
+/*
+ * Device numbers.
+ */
+typedef uint64_t dev_t;
+typedef uint32_t major_t;
+typedef uint32_t minor_t;
+#define makedevice(a_Maj, a_Min) RT_MAKE_U64(a_Min, a_Maj)
+#define getemajor(a_Dev) RT_HIDWORD(a_Dev)
+#define geteminor(a_Dev) RT_LODWORD(a_Dev)
+#define getminor(a_Dev) RT_LODWORD(a_Dev)
+
+/*
+ * DDI
+ */
+# define DDI_SUCCESS (0)
+# define DDI_FAILURE (-1)
+# if 0 /* not needed */
+# define ddi_soft_state_init VBoxDtDdiSoftStateInit
+# define ddi_soft_state_fini VBoxDtDdiSoftStateTerm
+# define ddi_soft_state_zalloc VBoxDtDdiSoftStateAllocZ
+# define ddi_get_soft_state VBoxDtDdiSoftStateGet
+# define ddi_soft_state_free VBoxDtDdiSoftStateFree
+int VBoxDtDdiSoftStateInit(void **ppvSoftStates, size_t cbSoftState, uint32_t cMaxItems);
+int VBoxDtDdiSoftStateTerm(void **ppvSoftStates);
+int VBoxDtDdiSoftStateAllocZ(void *pvSoftStates, RTDEV uMinor);
+int VBoxDtDdiSoftStateFree(void *pvSoftStates, RTDEV uMinor);
+void *VBoxDtDdiSoftStateGet(void *pvSoftStates, RTDEV uMinor);
+
+typedef enum { DDI_ATT_CMD_DUMMY } ddi_attach_cmd_t;
+typedef enum { DDI_DETACH, DDI_SUSPEND } ddi_detach_cmd_t;
+typedef struct VBoxDtDevInfo dev_info_t;
+# define ddi_driver_major VBoxDtDdiDriverMajor
+# define ddi_report_dev VBoxDtDdiReportDev
+major_t VBoxDtDdiDriverMajor(struct VBoxDtDevInfo *pDevInfo);
+void VBoxDtDdiReportDev(struct VBoxDtDevInfo *pDevInfo);
+# endif
+
+/*
+ * DTrace bits we've made external.
+ */
+extern int dtrace_attach(void);
+extern int dtrace_detach(void);
+struct dtrace_state;
+extern int dtrace_open(struct dtrace_state **ppState, struct VBoxDtCred *cred_p);
+extern int dtrace_ioctl(struct dtrace_state *state, int cmd, intptr_t arg, int32_t *rv);
+extern int dtrace_close(struct dtrace_state *state);
+
+#endif /* IN_RING0 */
+
+
+#ifdef IN_RING3
+/*
+ * Make life a little easier in ring-3.
+ */
+
+/* Replacement for strndup(), requires editing the code unfortunately. */
+# define MY_STRDUPA(a_pszRes, a_pszSrc) \
+ do { \
+ size_t cb = strlen(a_pszSrc) + 1; \
+ (a_pszRes) = (char *)alloca(cb); \
+ memcpy(a_pszRes, a_pszSrc, cb); \
+ } while (0)
+
+/*
+ * gelf
+ */
+# include <iprt/formats/elf64.h>
+typedef Elf64_Half GElf_Half;
+typedef Elf64_Xword GElf_Xword;
+typedef Elf64_Shdr GElf_Shdr;
+typedef Elf64_Ehdr GElf_Ehdr;
+typedef Elf64_Sym GElf_Sym;
+typedef Elf64_Addr GElf_Addr;
+#define GELF_ST_INFO ELF64_ST_INFO
+#define GELF_ST_TYPE ELF64_ST_TYPE
+#define GELF_ST_BIND ELF64_ST_BIND
+
+/*
+ * MSC stuff.
+ */
+# ifdef _MSC_VER
+# ifndef SIZE_MAX
+# if ARCH_BITS == 32
+# define SIZE_MAX UINT32_MAX
+# else
+# define SIZE_MAX UINT64_MAX
+# endif
+# endif
+# endif /* _MSC_VER */
+
+#endif /* IN_RING3 */
+
+RT_C_DECLS_END
+#endif /* !VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceTypes_h */
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/COPYING b/src/VBox/ExtPacks/VBoxDTrace/onnv/COPYING
new file mode 100644
index 00000000..eaceed4c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/COPYING
@@ -0,0 +1,378 @@
+The ExtPacks/VBoxDTrace/onnv sources are licensed under the Common Development
+and Distribution License, Version 1.0 (CDDL), as shown below.
+
+---
+
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0
+
+1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that creates
+ or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original
+ Software, prior Modifications used by a Contributor (if any),
+ and the Modifications made by that particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or (b)
+ Modifications, or (c) the combination of files containing
+ Original Software with files containing Modifications, in
+ each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form other
+ than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity that first
+ makes Original Software available under this License.
+
+ 1.6. "Larger Work" means a work which combines Covered Software or
+ portions thereof with code not governed by the terms of this
+ License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "Licensable" means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed
+ herein.
+
+ 1.9. "Modifications" means the Source Code and Executable form of
+ any of the following:
+
+ A. Any file that results from an addition to, deletion from or
+ modification of the contents of a file containing Original
+ Software or previous Modifications;
+
+ B. Any new file that contains any part of the Original
+ Software or previous Modifications; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and Executable
+ form of computer software code that is originally released
+ under this License.
+
+ 1.11. "Patent Claims" means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by
+ grantor.
+
+ 1.12. "Source Code" means (a) the common form of computer software
+ code in which modifications are made and (b) associated
+ documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal entity
+ exercising rights under, and complying with all of the terms
+ of, this License. For legal entities, "You" includes any
+ entity which controls, is controlled by, or is under common
+ control with You. For purposes of this definition,
+ "control" means (a) the power, direct or indirect, to cause
+ the direction or management of such entity, whether by
+ contract or otherwise, or (b) ownership of more than fifty
+ percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the Initial
+ Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer, to use,
+ reproduce, modify, display, perform, sublicense and
+ distribute the Original Software (or portions thereof),
+ with or without Modifications, and/or as part of a Larger
+ Work; and
+
+ (b) under Patent Claims infringed by the making, using or
+ selling of Original Software, to make, have made, use,
+ practice, sell, and offer for sale, and/or otherwise
+ dispose of the Original Software (or portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b) are
+ effective on the date Initial Developer first distributes
+ or otherwise makes the Original Software available to a
+ third party under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: (1) for code that You delete from the Original
+ Software, or (2) for infringements caused by: (i) the
+ modification of the Original Software, or (ii) the
+ combination of the Original Software with other software
+ or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor to use, reproduce,
+ modify, display, perform, sublicense and distribute the
+ Modifications created by such Contributor (or portions
+ thereof), either on an unmodified basis, with other
+ Modifications, as Covered Software and/or as part of a
+ Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either
+ alone and/or in combination with its Contributor Version
+ (or portions of such combination), to make, use, sell,
+ offer for sale, have made, and/or otherwise dispose of:
+ (1) Modifications made by that Contributor (or portions
+ thereof); and (2) the combination of Modifications made by
+ that Contributor with its Contributor Version (or portions
+ of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first distributes or
+ otherwise makes the Modifications available to a third
+ party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: (1) for any code that Contributor has deleted
+ from the Contributor Version; (2) for infringements caused
+ by: (i) third party modifications of Contributor Version,
+ or (ii) the combination of Modifications made by that
+ Contributor with other software (except as part of the
+ Contributor Version) or other devices; or (3) under Patent
+ Claims infringed by Covered Software in the absence of
+ Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in Source
+ Code form and that Source Code form must be distributed only under
+ the terms of this License. You must include a copy of this
+ License with every copy of the Source Code form of the Covered
+ Software You distribute or otherwise make available. You must
+ inform recipients of any such Covered Software in Executable form
+ as to how they can obtain such Covered Software in Source Code
+ form in a reasonable manner on or through a medium customarily
+ used for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You contribute are
+ governed by the terms of this License. You represent that You
+ believe Your Modifications are Your original creation(s) and/or
+ You have sufficient rights to grant the rights conveyed by this
+ License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications that
+ identifies You as the Contributor of the Modification. You may
+ not remove or alter any copyright, patent or trademark notices
+ contained within the Covered Software, or any notices of licensing
+ or any descriptive text giving attribution to any Contributor or
+ the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered Software in
+ Source Code form that alters or restricts the applicable version
+ of this License or the recipients' rights hereunder. You may
+ choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of
+ Covered Software. However, you may do so only on Your own behalf,
+ and not on behalf of the Initial Developer or any Contributor.
+ You must make it absolutely clear that any such warranty, support,
+ indemnity or liability obligation is offered by You alone, and You
+ hereby agree to indemnify the Initial Developer and every
+ Contributor for any liability incurred by the Initial Developer or
+ such Contributor as a result of warranty, support, indemnity or
+ liability terms You offer.
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered Software
+ under the terms of this License or under the terms of a license of
+ Your choice, which may contain terms different from this License,
+ provided that You are in compliance with the terms of this License
+ and that the license for the Executable form does not attempt to
+ limit or alter the recipient's rights in the Source Code form from
+ the rights set forth in this License. If You distribute the
+ Covered Software in Executable form under a different license, You
+ must make it absolutely clear that any terms which differ from
+ this License are offered by You alone, not by the Initial
+ Developer or Contributor. You hereby agree to indemnify the
+ Initial Developer and every Contributor for any liability incurred
+ by the Initial Developer or such Contributor as a result of any
+ such terms You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software with
+ other code not governed by the terms of this License and
+ distribute the Larger Work as a single product. In such a case,
+ You must make sure the requirements of this License are fulfilled
+ for the Covered Software.
+
+4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and may
+ publish revised and/or new versions of this License from time to
+ time. Each version will be given a distinguishing version number.
+ Except as provided in Section 4.3, no one other than the license
+ steward has the right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise make the
+ Covered Software available under the terms of the version of the
+ License under which You originally received the Covered Software.
+ If the Initial Developer includes a notice in the Original
+ Software prohibiting it from being distributed or otherwise made
+ available under any subsequent version of the License, You must
+ distribute and make the Covered Software available under the terms
+ of the version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to use,
+ distribute or otherwise make the Covered Software available under
+ the terms of any subsequent version of the License published by
+ the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a new
+ license for Your Original Software, You may create and use a
+ modified version of this License if You: (a) rename the license
+ and remove any references to the name of the license steward
+ (except to note that the license differs from this License); and
+ (b) otherwise make it clear that the license contains terms which
+ differ from this License.
+
+5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY
+ NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to
+ cure such breach within 30 days of becoming aware of the breach.
+ Provisions which, by their nature, must remain in effect beyond
+ the termination of this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or a
+ Contributor (the Initial Developer or Contributor against whom You
+ assert such claim is referred to as "Participant") alleging that
+ the Participant Software (meaning the Contributor Version where
+ the Participant is a Contributor or the Original Software where
+ the Participant is the Initial Developer) directly or indirectly
+ infringes any patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial Developer (if
+ the Initial Developer is not the Participant) and all Contributors
+ under Sections 2.1 and/or 2.2 of this License shall, upon 60 days
+ notice from Participant terminate prospectively and automatically
+ at the expiration of such 60 day notice period, unless if within
+ such 60 day period You withdraw Your claim with respect to the
+ Participant Software against such Participant either unilaterally
+ or pursuant to a written agreement with Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2 above,
+ all end user licenses that have been validly granted by You or any
+ distributor hereunder prior to termination (excluding licenses
+ granted to You by any distributor) shall survive termination.
+
+7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+ STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+ INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+ APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+ NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+ APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48
+ C.F.R. 252.227-7014(a)(1)) and "commercial computer software
+ documentation" as such terms are used in 48 C.F.R. 12.212
+ (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48
+ C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all
+ U.S. Government End Users acquire Covered Software with only those
+ rights set forth herein. This U.S. Government Rights clause is in
+ lieu of, and supersedes, any other FAR, DFAR, or other clause or
+ provision that addresses Government rights in computer software
+ under this License.
+
+9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed
+ by the law of the jurisdiction specified in a notice contained
+ within the Original Software (except to the extent applicable law,
+ if any, provides otherwise), excluding such jurisdiction's
+ conflict-of-law provisions. Any litigation relating to this
+ License shall be subject to the jurisdiction of the courts located
+ in the jurisdiction and venue specified in a notice contained
+ within the Original Software, with the losing party responsible
+ for costs, including, without limitation, court costs and
+ reasonable attorneys' fees and expenses. The application of the
+ United Nations Convention on Contracts for the International Sale
+ of Goods is expressly excluded. Any law or regulation which
+ provides that the language of a contract shall be construed
+ against the drafter shall not apply to this License. You agree
+ that You alone are responsible for compliance with the United
+ States export administration regulations (and the export control
+ laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
+--------------------------------------------------------------------
+
+NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND
+DISTRIBUTION LICENSE (CDDL)
+
+For Covered Software in this distribution, this License shall be
+governed by the laws of Germany. Legal venue shall be Stuttgart,
+Germany.
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile
new file mode 100644
index 00000000..ebb091d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile
@@ -0,0 +1,57 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+PROG= dtrace
+
+include ../Makefile.cmd
+
+SUBDIRS= $(MACH) demo test
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
+
+.KEEP_STATE:
+
+all: $(SUBDIRS)
+
+clean clobber lint: $(SUBDIRS)
+
+install: $(SUBDIRS)
+ -$(RM) $(ROOTUSRSBINPROG)
+ -$(LN) $(ISAEXEC) $(ROOTUSRSBINPROG)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.com b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.com
new file mode 100644
index 00000000..2f69e31b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.com
@@ -0,0 +1,57 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+PROG = dtrace
+OBJS = dtrace.o
+SRCS = $(OBJS:%.o=../%.c)
+
+include ../../Makefile.cmd
+
+CFLAGS += $(CCVERBOSE)
+CFLAGS64 += $(CCVERBOSE)
+LDLIBS += -ldtrace -lproc -lctf -lelf
+
+FILEMODE = 0555
+
+CLEANFILES += $(OBJS)
+
+.KEEP_STATE:
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(LINK.c) -o $@ $(OBJS) $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+clean:
+ -$(RM) $(CLEANFILES)
+
+lint: lint_SRCS
+
+%.o: ../%.c
+ $(COMPILE.c) $<
+
+include ../../Makefile.targ
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile
new file mode 100644
index 00000000..a34a1e5e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.cmd.64
+
+install: all $(ROOTUSRSBINPROG64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/amd64/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile
new file mode 100644
index 00000000..7da281ed
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile
@@ -0,0 +1,167 @@
+#
+# 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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../../Makefile.cmd
+
+i386_DFILES = \
+ iprb.d
+
+DFILES = \
+ applicat.d \
+ badopen.d \
+ begin.d \
+ callout.d \
+ clause.d \
+ clear.d \
+ countdown.d \
+ counter.d \
+ dateprof.d \
+ delay.d \
+ denorm.d \
+ end.d \
+ error.d \
+ errorpath.d \
+ find.d \
+ firebird.d \
+ hello.d \
+ howlong.d \
+ interp.d \
+ interval.d \
+ intr.d \
+ iocpu.d \
+ iosnoop.d \
+ iothrough.d \
+ iotime.d \
+ ipio.d \
+ ipproto.d \
+ tcprst.d \
+ kstat.d \
+ ksyms.d \
+ libc.d \
+ lquantize.d \
+ lwptime.d \
+ normalize.d \
+ nscd.d \
+ pri.d \
+ printa.d \
+ pritime.d \
+ prof.d \
+ profpri.d \
+ progtime.d \
+ putnext.d \
+ qlen.d \
+ qtime.d \
+ renormalize.d \
+ restest.d \
+ ring.d \
+ rtime.d \
+ rwinfo.d \
+ rwtime.d \
+ sig.d \
+ soffice.d \
+ spec.d \
+ specopen.d \
+ ssd.d \
+ syscall.d \
+ tcp1stbyte.d \
+ tcpbytes.d \
+ tcpbytesstat.d \
+ tcpconnlat.d \
+ tcpio.d \
+ tcpioflags.d \
+ tcpsnoop.d \
+ tcpstate.d \
+ tcptop.d \
+ tick.d \
+ ticktime.d \
+ time.d \
+ tracewrite.d \
+ trunc.d \
+ trussrw.d \
+ udpbytes.d \
+ udpbytesstat.d \
+ udpio.d \
+ udpsnoop.d \
+ udptop.d \
+ userfunc.d \
+ whatfor.d \
+ whatlock.d \
+ where.d \
+ whererun.d \
+ whoexec.d \
+ whofor.d \
+ whoio.d \
+ whopreempt.d \
+ whoqueue.d \
+ whosteal.d \
+ whowrite.d \
+ writes.d \
+ writesbycmd.d \
+ writesbycmdfd.d \
+ writetime.d \
+ writetimeq.d \
+ xioctl.d \
+ xterm.d \
+ xwork.d \
+ $($(MACH)_DFILES)
+
+HTMLFILES = index.html
+
+DEMOFILES = \
+ $(DFILES) \
+ $(HTMLFILES) \
+ sunlogo.gif
+
+MKDEMO = mkdemo
+CLEANFILES += $(DFILES) $(MKDEMO)
+
+ROOTDEMODIR = $(ROOT)/usr/demo/dtrace
+ROOTDEMOFILES = $(DEMOFILES:%=$(ROOTDEMODIR)/%)
+
+all: $(DEMOFILES)
+
+clobber clean:
+ -$(RM) $(CLEANFILES)
+
+clean.lint install_h lint:
+
+install: $(ROOTDEMOFILES)
+
+$(ROOTDEMODIR):
+ $(INS.dir)
+
+$(ROOTDEMODIR)/%: %
+ $(INS.file)
+
+$(HTMLFILES): $(DFILES) $(MKDEMO)
+ ./$(MKDEMO) $@
+
+$(DFILES): $(MKDEMO)
+ ./$(MKDEMO) $@
+
+$(ROOTDEMOFILES): $(ROOTDEMODIR)
+
+$(ROOTDEMODIR) := DIRMODE = 755
+
+$(ROOTDEMOFILES) := FILEMODE = 644
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/time.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/time.d
new file mode 100644
index 00000000..b7afd4cb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/act/time.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+#pragma D option destructive
+#pragma D option switchrate=5sec
+
+tick-1sec
+/n++ < 5/
+{
+ printf("walltime : %Y\n", walltimestamp);
+ printf("date : ");
+ system("date");
+ printf("\n");
+}
+
+tick-1sec
+/n == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/clear.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/clear.d
new file mode 100644
index 00000000..4b90a09a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/clear.d
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ last = timestamp;
+}
+
+syscall:::entry
+{
+ @func[execname] = count();
+}
+
+tick-10sec
+{
+ normalize(@func, (timestamp - last) / 1000000000);
+ printa(@func);
+ clear(@func);
+ last = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/dateprof.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/dateprof.d
new file mode 100644
index 00000000..19a63c5e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/dateprof.d
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::exec:return,
+syscall::exece:return
+/execname == "date"/
+{
+ self->start = vtimestamp;
+}
+
+syscall:::entry
+/self->start/
+{
+ /*
+ * We linearly quantize on the current virtual time minus our
+ * process's start time. We divide by 1000 to yield microseconds
+ * rather than nanoseconds. The range runs from 0 to 10 milliseconds
+ * in steps of 100 microseconds; we expect that no date(1) process
+ * will take longer than 10 milliseconds to complete.
+ */
+ @["system calls over time"] =
+ lquantize((vtimestamp - self->start) / 1000, 0, 10000, 100);
+}
+
+syscall::rexit:entry
+/self->start/
+{
+ self->start = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/denorm.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/denorm.d
new file mode 100644
index 00000000..6e58596f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/denorm.d
@@ -0,0 +1,51 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ start = timestamp;
+}
+
+syscall:::entry
+{
+ @func[execname] = count();
+}
+
+END
+{
+ this->seconds = (timestamp - start) / 1000000000;
+ printf("Ran for %d seconds.\n", this->seconds);
+
+ printf("Per-second rate:\n");
+ normalize(@func, this->seconds);
+ printa(@func);
+
+ printf("\nRaw counts:\n");
+ denormalize(@func);
+ printa(@func);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/lquantize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/lquantize.d
new file mode 100644
index 00000000..833c73ac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/lquantize.d
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::write:entry
+{
+ @fds[execname] = lquantize(arg0, 0, 100, 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/normalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/normalize.d
new file mode 100644
index 00000000..cce12027
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/normalize.d
@@ -0,0 +1,49 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ /*
+ * Get the start time, in nanoseconds.
+ */
+ start = timestamp;
+}
+
+syscall:::entry
+{
+ @func[execname] = count();
+}
+
+END
+{
+ /*
+ * Normalize the aggregation based on the number of seconds we have
+ * been running. (There are 1,000,000,000 nanoseconds in one second.)
+ */
+ normalize(@func, (timestamp - start) / 1000000000);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/renormalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/renormalize.d
new file mode 100644
index 00000000..a6a15107
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/renormalize.d
@@ -0,0 +1,43 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ start = timestamp;
+}
+
+syscall:::entry
+{
+ @func[execname] = count();
+}
+
+tick-10sec
+{
+ normalize(@func, (timestamp - start) / 1000000000);
+ printa(@func);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/trunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/trunc.d
new file mode 100644
index 00000000..76965f8b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/trunc.d
@@ -0,0 +1,46 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ last = timestamp;
+}
+
+syscall:::entry
+{
+ @func[execname] = count();
+}
+
+tick-10sec
+{
+ trunc(@func, 10);
+ normalize(@func, (timestamp - last) / 1000000000);
+ printa(@func);
+ clear(@func);
+ last = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writes.d
new file mode 100644
index 00000000..9de61541
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writes.d
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::write:entry
+{
+ @counts["write system calls"] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmd.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmd.d
new file mode 100644
index 00000000..bcbefae1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmd.d
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::write:entry
+{
+ @counts[execname] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmdfd.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmdfd.d
new file mode 100644
index 00000000..8b92cb83
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writesbycmdfd.d
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::write:entry
+{
+ @counts[execname, arg0] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetime.d
new file mode 100644
index 00000000..b770f5b0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetime.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::write:entry
+{
+ self->ts = timestamp;
+}
+
+syscall::write:return
+/self->ts/
+{
+ @time[execname] = avg(timestamp - self->ts);
+ self->ts = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetimeq.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetimeq.d
new file mode 100644
index 00000000..9b494090
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/agg/writetimeq.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::write:entry
+{
+ self->ts = timestamp;
+}
+
+syscall::write:return
+/self->ts/
+{
+ @time[execname] = quantize(timestamp - self->ts);
+ self->ts = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/iprb.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/iprb.d
new file mode 100644
index 00000000..f73f6a73
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/anon/iprb.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+fbt::iprbattach:entry
+{
+ self->trace = 1;
+}
+
+fbt:::
+/self->trace/
+{}
+
+fbt::iprbattach:return
+{
+ self->trace = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/ring.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/ring.d
new file mode 100644
index 00000000..116bbd41
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/buf/ring.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option bufpolicy=ring
+#pragma D option bufsize=16k
+
+syscall:::entry
+/execname == $1/
+{
+ trace(timestamp);
+}
+
+syscall::rexit:entry
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/chapters b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/chapters
new file mode 100644
index 00000000..2160a0cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/chapters
@@ -0,0 +1,125 @@
+name: book
+title: Solaris Dynamic Tracing Guide
+index: 0
+url: http://wikis.sun.com/display/DTrace/Documentation
+
+name: act
+title: Actions and Subroutines
+index: 10
+url: http://wikis.sun.com/display/DTrace/Actions+and+Subroutines
+
+name: agg
+title: Aggregations
+index: 9
+url: http://wikis.sun.com/display/DTrace/Aggregations
+
+name: anon
+title: Anonymous Tracing
+index: 34
+url: http://wikis.sun.com/display/DTrace/Anonymous+Tracing
+
+name: buf
+title: Buffers and Buffering
+index: 11
+url: http://wikis.sun.com/display/DTrace/Buffers+and+Buffering
+
+name: dtrace
+title: dtrace Provider
+index: 17
+url: http://wikis.sun.com/display/DTrace/dtrace+Provider
+
+name: fbt
+title: fbt Provider
+index: 20
+url: http://wikis.sun.com/display/DTrace/fbt+Provider
+
+name: intro
+title: Introduction
+index: 1
+url: http://wikis.sun.com/display/DTrace/Introduction
+
+name: io
+title: io Provider
+index: 27
+url: http://wikis.sun.com/display/DTrace/io+Provider
+
+name: lockstat
+title: lockstat Provider
+index: 18
+url: http://wikis.sun.com/display/DTrace/lockstat+Provider
+
+name: out
+title: Output Formatting
+index: 12
+url: http://wikis.sun.com/display/DTrace/Output+Formatting
+
+name: proc
+title: proc Provider
+index: 25
+url: http://wikis.sun.com/display/DTrace/proc+Provider
+
+name: profile
+title: profile Provider
+index: 19
+url: http://wikis.sun.com/display/DTrace/profile+Provider
+
+name: sched
+title: sched Provider
+index: 26
+url: http://wikis.sun.com/display/DTrace/sched+Provider
+
+name: script
+title: Scripting
+index: 15
+url: http://wikis.sun.com/display/DTrace/Scripting
+
+name: sdt
+title: sdt Provider
+index: 22
+url: http://wikis.sun.com/display/DTrace/sdt+Provider
+
+name: spec
+title: Speculative Tracing
+index: 13
+url: http://wikis.sun.com/display/DTrace/Speculative+Tracing
+
+name: struct
+title: Structs and Unions
+index: 7
+url: http://wikis.sun.com/display/DTrace/Structs+and+Unions
+
+name: sysinfo
+title: sysinfo Provider
+index: 23
+url: http://wikis.sun.com/display/DTrace/sysinfo+Provider
+
+name: user
+title: User Process Tracing
+index: 32
+url: http://wikis.sun.com/display/DTrace/User+Process+Tracing
+
+name: vars
+title: Variables
+index: 3
+url: http://wikis.sun.com/display/DTrace/Variables
+
+name: vminfo
+title: vminfo Provider
+index: 24
+url: http://wikis.sun.com/display/DTrace/vminfo+Provider
+
+name: ip
+title: ip Provider
+index: 101
+url: http://wikis.sun.com/display/DTrace/ip+Provider
+
+name: tcp
+title: tcp Provider
+index: 102
+url: http://wikis.sun.com/display/DTrace/tcp+Provider
+
+name: udp
+title: udp Provider
+index: 103
+url: http://wikis.sun.com/display/DTrace/udp+Provider
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/begin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/begin.d
new file mode 100644
index 00000000..a3786017
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/begin.d
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+BEGIN
+{
+ prot[0] = "---";
+ prot[1] = "r--";
+ prot[2] = "-w-";
+ prot[3] = "rw-";
+ prot[4] = "--x";
+ prot[5] = "r-x";
+ prot[6] = "-wx";
+ prot[7] = "rwx";
+}
+
+syscall::mmap:entry
+{
+ printf("mmap with prot = %s", prot[arg2 & 0x7]);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/end.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/end.d
new file mode 100644
index 00000000..4390b10a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/end.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+BEGIN
+{
+ start = timestamp;
+}
+
+/*
+ * ... other tracing actions...
+ */
+
+END
+{
+ printf("total time: %d secs", (timestamp - start) / 1000000000);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/error.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/error.d
new file mode 100644
index 00000000..97115763
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/dtrace/error.d
@@ -0,0 +1,35 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+BEGIN
+{
+ *(char *)NULL;
+}
+
+ERROR
+{
+ printf("Hit an error!");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/delay.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/delay.d
new file mode 100644
index 00000000..1a523336
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/delay.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+fbt::delay:entry,
+fbt::drv_usecwait:entry
+{
+ self->in = timestamp
+}
+
+fbt::delay:return,
+fbt::drv_usecwait:return
+/self->in/
+{
+ @snoozers[stack()] = quantize(timestamp - self->in);
+ self->in = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/putnext.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/putnext.d
new file mode 100644
index 00000000..dd91ea06
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/putnext.d
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+fbt::putnext:entry
+{
+ @calls[stringof(args[0]->q_qinfo->qi_minfo->mi_idname)] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/ssd.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/ssd.d
new file mode 100644
index 00000000..6b78ab9d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/ssd.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+fbt:ssd::return
+/arg1 == EIO/
+{
+ printf("%s+%x returned EIO.", probefunc, arg0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/xioctl.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/xioctl.d
new file mode 100644
index 00000000..33147682
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/fbt/xioctl.d
@@ -0,0 +1,50 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * To make the output more readable, we want to indent every function entry
+ * (and unindent every function return). This is done by setting the
+ * "flowindent" option.
+ */
+#pragma D option flowindent
+
+syscall::ioctl:entry
+/execname == "xclock" && guard++ == 0/
+{
+ self->traceme = 1;
+ printf("fd: %d", arg0);
+}
+
+fbt:::
+/self->traceme/
+{}
+
+syscall::ioctl:return
+/self->traceme/
+{
+ self->traceme = 0;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/countdown.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/countdown.d
new file mode 100644
index 00000000..3fdb7904
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/countdown.d
@@ -0,0 +1,43 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+dtrace:::BEGIN
+{
+ i = 10;
+}
+
+profile:::tick-1sec
+/i > 0/
+{
+ trace(i--);
+}
+
+profile:::tick-1sec
+/i == 0/
+{
+ trace("blastoff!");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/counter.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/counter.d
new file mode 100644
index 00000000..bda153a8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/counter.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * Count off and report the number of seconds elapsed
+ */
+dtrace:::BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ i = i + 1;
+ trace(i);
+}
+
+dtrace:::END
+{
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/hello.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/hello.d
new file mode 100644
index 00000000..b5842915
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/hello.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+BEGIN
+{
+ trace("hello, world");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/rwtime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/rwtime.d
new file mode 100644
index 00000000..c005fbc4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/rwtime.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::read:entry,
+syscall::write:entry
+/pid == $1/
+{
+ ts[probefunc] = timestamp;
+}
+
+syscall::read:return,
+syscall::write:return
+/pid == $1 && ts[probefunc] != 0/
+{
+ printf("%d nsecs", timestamp - ts[probefunc]);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/trussrw.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/trussrw.d
new file mode 100644
index 00000000..590782f2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/intro/trussrw.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::read:entry,
+syscall::write:entry
+/pid == $1/
+{
+ printf("%s(%d, 0x%x, %4d)", probefunc, arg0, arg1, arg2);
+}
+
+syscall::read:return, syscall::write:return
+/pid == $1/
+{
+ printf("\t\t = %d\n", arg1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/applicat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/applicat.d
new file mode 100644
index 00000000..44bce364
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/applicat.d
@@ -0,0 +1,32 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+io:::start
+/execname == "soffice.bin" && args[2]->fi_name == "applicat.rdb"/
+{
+ @ = lquantize(args[2]->fi_offset != -1 ?
+ args[2]->fi_offset / (1000 * 1024) : -1, 0, 1000);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iocpu.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iocpu.d
new file mode 100644
index 00000000..6957071c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iocpu.d
@@ -0,0 +1,65 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::on-cpu
+/execname == "soffice.bin"/
+{
+ self->on = vtimestamp;
+}
+
+sched:::off-cpu
+/self->on/
+{
+ @time["<on cpu>"] = sum(vtimestamp - self->on);
+ self->on = 0;
+}
+
+io:::wait-start
+/execname == "soffice.bin"/
+{
+ self->wait = timestamp;
+}
+
+io:::wait-done
+/self->wait/
+{
+ @io[args[2]->fi_name] = sum(timestamp - self->wait);
+ @time["<I/O wait>"] = sum(timestamp - self->wait);
+ self->wait = 0;
+}
+
+END
+{
+ printf("Time breakdown (milliseconds):\n");
+ normalize(@time, 1000000);
+ printa(" %-50s %15@d\n", @time);
+
+ printf("\nI/O wait breakdown (milliseconds):\n");
+ normalize(@io, 1000000);
+ printa(" %-50s %15@d\n", @io);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iosnoop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iosnoop.d
new file mode 100644
index 00000000..1db6290c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iosnoop.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("%10s %58s %2s\n", "DEVICE", "FILE", "RW");
+}
+
+io:::start
+{
+ printf("%10s %58s %2s\n", args[1]->dev_statname,
+ args[2]->fi_pathname, args[0]->b_flags & B_READ ? "R" : "W");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iothrough.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iothrough.d
new file mode 100644
index 00000000..b5b2e7e3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iothrough.d
@@ -0,0 +1,66 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+io:::start
+{
+ start[args[0]->b_edev, args[0]->b_blkno] = timestamp;
+}
+
+io:::done
+/start[args[0]->b_edev, args[0]->b_blkno]/
+{
+ /*
+ * We want to get an idea of our throughput to this device in KB/sec.
+ * What we have, however, is nanoseconds and bytes. That is we want
+ * to calculate:
+ *
+ * bytes / 1024
+ * ------------------------
+ * nanoseconds / 1000000000
+ *
+ * But we can't calculate this using integer arithmetic without losing
+ * precision (the denomenator, for one, is between 0 and 1 for nearly
+ * all I/Os). So we restate the fraction, and cancel:
+ *
+ * bytes 1000000000 bytes 976562
+ * --------- * ------------- = --------- * -------------
+ * 1024 nanoseconds 1 nanoseconds
+ *
+ * This is easy to calculate using integer arithmetic; this is what
+ * we do below.
+ */
+ this->elapsed = timestamp - start[args[0]->b_edev, args[0]->b_blkno];
+ @[args[1]->dev_statname, args[1]->dev_pathname] =
+ quantize((args[0]->b_bcount * 976562) / this->elapsed);
+ start[args[0]->b_edev, args[0]->b_blkno] = 0;
+}
+
+END
+{
+ printa(" %s (%s)\n%@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iotime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iotime.d
new file mode 100644
index 00000000..0e0f6ac7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/iotime.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("%10s %58s %2s %7s\n", "DEVICE", "FILE", "RW", "MS");
+}
+
+io:::start
+{
+ start[args[0]->b_edev, args[0]->b_blkno] = timestamp;
+}
+
+io:::done
+/start[args[0]->b_edev, args[0]->b_blkno]/
+{
+ this->elapsed = timestamp - start[args[0]->b_edev, args[0]->b_blkno];
+ printf("%10s %58s %2s %3d.%03d\n", args[1]->dev_statname,
+ args[2]->fi_pathname, args[0]->b_flags & B_READ ? "R" : "W",
+ this->elapsed / 1000000, (this->elapsed / 1000) % 1000);
+ start[args[0]->b_edev, args[0]->b_blkno] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whoio.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whoio.d
new file mode 100644
index 00000000..f660b343
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whoio.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+io:::start
+{
+ @[args[1]->dev_statname, execname, pid] = sum(args[0]->b_bcount);
+}
+
+END
+{
+ printf("%10s %20s %10s %15s\n", "DEVICE", "APP", "PID", "BYTES");
+ printa("%10s %20s %10d %15@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whowrite.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whowrite.d
new file mode 100644
index 00000000..6a4ffdd8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/io/whowrite.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+io:::start
+/args[0]->b_flags & B_WRITE/
+{
+ @[execname, args[2]->fi_dirname] = count();
+}
+
+END
+{
+ printf("%20s %51s %5s\n", "WHO", "WHERE", "COUNT");
+ printa("%20s %51s %5@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipio.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipio.d
new file mode 100644
index 00000000..0a7cc6f3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipio.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10hz
+
+dtrace:::BEGIN
+{
+ printf(" %3s %10s %15s %15s %8s %6s\n", "CPU", "DELTA(us)",
+ "SOURCE", "DEST", "INT", "BYTES");
+ last = timestamp;
+}
+
+ip:::send
+{
+ this->elapsed = (timestamp - last) / 1000;
+ printf(" %3d %10d %15s -> %15s %8s %6d\n", cpu, this->elapsed,
+ args[2]->ip_saddr, args[2]->ip_daddr, args[3]->if_name,
+ args[2]->ip_plength);
+ last = timestamp;
+}
+
+ip:::receive
+{
+ this->elapsed = (timestamp - last) / 1000;
+ printf(" %3d %10d %15s <- %15s %8s %6d\n", cpu, this->elapsed,
+ args[2]->ip_daddr, args[2]->ip_saddr, args[3]->if_name,
+ args[2]->ip_plength);
+ last = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipproto.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipproto.d
new file mode 100644
index 00000000..f5f3656e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/ipproto.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+ip:::send,
+ip:::receive
+{
+ this->protostr = args[2]->ip_ver == 4 ?
+ args[4]->ipv4_protostr : args[5]->ipv6_nextstr;
+ @num[args[2]->ip_saddr, args[2]->ip_daddr, this->protostr] = count();
+}
+
+dtrace:::END
+{
+ printf(" %-28s %-28s %6s %8s\n", "SADDR", "DADDR", "PROTO", "COUNT");
+ printa(" %-28s %-28s %6s %@8d\n", @num);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/tcprst.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/tcprst.d
new file mode 100755
index 00000000..a2d88e1c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/ip/tcprst.d
@@ -0,0 +1,284 @@
+#!/usr/sbin/dtrace -Cqs
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option dynvarsize=64m
+
+#define TH_RST 0x04
+#define MAX_RECORDS 10
+#define M_CTL 0x0d
+
+#define PRINT_MAIN_HEADER() \
+ (printf("\n%-25s %-6s %-25s %-6s %-10s %-10s %8s %8s\n", \
+ "LADDR", "LPORT", "RADDR", "RPORT", "ISS", "IRS", \
+ "SND_CNT", "RCV_CNT"))
+
+#define PRINT_RECORD_HEADER() \
+ (printf("%-20s %-20s %-3s %15s %15s %8s %8s %5s\n", \
+ "PROBENAME", "TIME", "S/R", "SEQ", "ACK", "DATALEN", \
+ "WND", "FLAGS"))
+
+#define PRINT_MAIN_HEADER_VALUES() \
+ (printf("%-25s %-6d %-25s %-6d %-10d %-10d %8d %8d\n", \
+ laddr[self->conn_id], lport[self->conn_id], \
+ faddr[self->conn_id], fport[self->conn_id], \
+ iss[self->conn_id], irs[self->conn_id], \
+ send_count[self->conn_id], recv_count[self->conn_id]))
+
+#define PRINT_HEADER() \
+ PRINT_MAIN_HEADER(); PRINT_MAIN_HEADER_VALUES(); \
+ PRINT_RECORD_HEADER()
+
+#define PRINT_RECORD(i) \
+ (printf("%-20s %-20Y %-3s %15d %15d %8d %8d %2x\n", \
+ probe_name[self->conn_id, i], \
+ conn_time[self->conn_id, i], \
+ send_recv[self->conn_id, i], \
+ seqno[self->conn_id, i], \
+ ack[self->conn_id, i], \
+ datalen[self->conn_id, i], \
+ wnd[self->conn_id, i], \
+ flags[self->conn_id, i]))
+
+tcp-trace-*
+{
+ /* extract connection details */
+
+ this->mp = (mblk_t *)arg0;
+ this->mp = (this->mp->b_datap->db_type == M_CTL?
+ this->mp->b_cont : this->mp);
+ self->tcpp = (tcp_t *)arg1;
+ this->connp = (conn_t *)self->tcpp->tcp_connp;
+
+ self->iph = (ipha_t *)this->mp->b_rptr;
+ this->iph_length =
+ (int)(((ipha_t *)self->iph)->ipha_version_and_hdr_length
+ & 0xF) << 2;
+ self->tcph = (tcpha_t *)((char *)self->iph + this->iph_length);
+ this->tcph_length =
+ (((tcph_t *)self->tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2);
+
+ /* ports */
+ self->i_lport = ntohs(this->connp->u_port.tcpu_ports.tcpu_lport);
+ self->i_fport = ntohs(this->connp->u_port.tcpu_ports.tcpu_fport);
+
+ /* IP addresses */
+ this->i_fad = (in6_addr_t *)&this->connp->connua_v6addr.connua_faddr;
+ this->i_lad = (in6_addr_t *)&this->connp->connua_v6addr.connua_laddr;
+
+ /* the address would either be IPv6 or IPv4-mapped-IPv6 */
+ self->i_faddr = inet_ntop(AF_INET6, (void *)this->i_fad);
+ self->i_laddr = inet_ntop(AF_INET6, (void *)this->i_lad);
+
+ /* create connection identifier, so we can track packets by conn */
+ self->conn_id = (uint64_t)self->tcpp->tcp_connp;
+}
+
+tcp-trace-*
+/first[self->conn_id] == 0/
+{
+ /* initialize counters - this is the first packet for this connection */
+ pcount[self->conn_id] = -1;
+ rollover[self->conn_id] = 0;
+ end_ptr[self->conn_id] = 0;
+ num[self->conn_id] = 0;
+
+ first[self->conn_id] = 1;
+
+ /* connection info */
+ laddr[self->conn_id] = self->i_laddr;
+ faddr[self->conn_id] = self->i_faddr;
+ lport[self->conn_id] = self->i_lport;
+ fport[self->conn_id] = self->i_fport;
+ iss[self->conn_id] = self->tcpp->tcp_iss;
+ irs[self->conn_id] = self->tcpp->tcp_irs;
+
+}
+
+tcp-trace-*
+{
+ /* counters, to keep track of how much info to dump */
+ pcount[self->conn_id]++;
+ rollover[self->conn_id] |= pcount[self->conn_id]/MAX_RECORDS;
+ pcount[self->conn_id] = pcount[self->conn_id]%MAX_RECORDS;
+ self->pcount = pcount[self->conn_id];
+ end_ptr[self->conn_id] = self->pcount;
+ num[self->conn_id] = (rollover[self->conn_id]?
+ MAX_RECORDS : pcount[self->conn_id] + 1);
+ conn_time[self->conn_id, self->pcount] = walltimestamp;
+
+ /* tcp state info */
+ seqno[self->conn_id, self->pcount] = ntohl(self->tcph->tha_seq);
+ ack[self->conn_id, self->pcount] = ntohl(self->tcph->tha_ack);
+ datalen[self->conn_id, self->pcount] = ntohs(self->iph->ipha_length);
+ wnd[self->conn_id, self->pcount] = ntohs(self->tcph->tha_win);
+ probe_name[self->conn_id, self->pcount] = probename;
+
+ /* flag 0x04 indicates a RST packet */
+ flags[self->conn_id, self->pcount] = self->tcph->tha_flags;
+ self->flags = self->tcph->tha_flags;
+}
+
+tcp-trace-send
+{
+ send_count[self->conn_id]++;
+ send_recv[self->conn_id, self->pcount] = "S";
+}
+
+tcp-trace-recv
+{
+ recv_count[self->conn_id]++;
+ send_recv[self->conn_id, self->pcount] = "R";
+}
+
+tcp-trace-*
+/(self->flags & TH_RST)/
+{
+ PRINT_HEADER();
+
+ self->i = (end_ptr[self->conn_id] + MAX_RECORDS - num[self->conn_id]
+ + 1)%MAX_RECORDS;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 10)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 9)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 8)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 7)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 6)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 5)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 4)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 3)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 2)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+}
+
+tcp-trace-*
+/(self->flags & TH_RST) && (num[self->conn_id] >= 1)/
+{
+ PRINT_RECORD(self->i);
+ self->i = (self->i + 1)%MAX_RECORDS;
+
+ num[self->conn_id]--;
+ self->reset = self->conn_id;
+}
+
+tcp-trace-*
+/self->reset/
+{
+ pcount[self->reset] = -1;
+ rollover[self->reset] = 0;
+ end_ptr[self->reset] = 0;
+ num[self->reset] = 0;
+
+ self->reset = 0;
+}
+
+conn-destroy
+{
+ /* clear old connection state */
+ this->conn_id = (uint64_t)arg0;
+
+ pcount[this->conn_id] = -1;
+ rollover[this->conn_id] = 0;
+ end_ptr[this->conn_id] = 0;
+ num[this->conn_id] = 0;
+ first[this->conn_id] = 0;
+
+ laddr[this->conn_id] = 0;
+ faddr[this->conn_id] = 0;
+ lport[this->conn_id] = 0;
+ fport[this->conn_id] = 0;
+ iss[this->conn_id] = 0;
+ irs[this->conn_id] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/whatlock.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/whatlock.d
new file mode 100644
index 00000000..7ad20c5c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/lockstat/whatlock.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+lockstat:::adaptive-acquire
+/execname == "date"/
+{
+ @locks["adaptive"] = count();
+}
+
+lockstat:::spin-acquire
+/execname == "date"/
+{
+ @locks["spin"] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/mkdemo.pl b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/mkdemo.pl
new file mode 100644
index 00000000..f2bc3ec7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/mkdemo.pl
@@ -0,0 +1,227 @@
+#!/usr/perl5/bin/perl -w
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+require 5.005;
+
+use strict;
+use warnings;
+use Time::localtime;
+use File::Basename;
+
+our ($cmd, $chapfile, $htmlfile, $dtrace_url, %chaps);
+
+$cmd = "mkdemo";
+$chapfile = "chapters";
+$htmlfile = "index.html";
+$dtrace_url = "http://www.sun.com/bigadmin/content/dtrace";
+
+sub chaps_read {
+ my $fatal;
+ my %hash;
+
+ open(CHAPS, "$chapfile");
+
+ while (<CHAPS>) {
+ my $field;
+ my $value;
+
+ chop;
+
+ if (/^#/) {
+ next;
+ }
+
+ if (!/:/) {
+ if (exists $hash{'name'}) {
+ if (exists $chaps{$hash{'name'}}) {
+ print "$cmd: chapter $hash{'name'} ";
+ print "has two entries.\n";
+ $fatal = 1;
+ }
+
+ $chaps{$hash{'name'}} = { %hash };
+ %hash = ();
+ next;
+ }
+
+ %hash = ();
+ next;
+ }
+
+ ($field, $value) = split /:\s*/, $_, 2;
+
+ if ($field eq "descr") {
+ $value .= " ";
+ }
+
+ $hash{$field} .= $value;
+ }
+
+ if ($fatal) {
+ print "$cmd: fatal errors; cannot proceed.\n";
+ exit;
+ }
+
+ close (CHAPS);
+}
+
+sub chaps_ascending {
+ $chaps{$a}{index} <=> $chaps{$b}{index};
+}
+
+sub demo_process {
+ my $chap = $_[0];
+ my $demo = $_[1];
+ my $year = localtime->year() + 1900;
+
+ open DEMO, "<$chap/$demo" or die "Can't open demo $chap/$demo";
+ open OUT, ">$demo" or die "Can't open $demo";
+
+ while (<DEMO>) {
+ print OUT $_;
+
+ if (/Use is subject to license terms/) {
+ print OUT <<EOF;
+ *
+ * This D script is used as an example in the Solaris Dynamic Tracing Guide
+ * wiki in the \"$chaps{$chap}{title}\" Chapter.
+ *
+ * The full text of the this chapter may be found here:
+ *
+ * $chaps{$chap}{url}
+ *
+ * On machines that have DTrace installed, this script is available as
+ * $demo in /usr/demo/dtrace, a directory that contains all D scripts
+ * used in the Solaris Dynamic Tracing Guide. A table of the scripts and their
+ * corresponding chapters may be found here:
+ *
+ * file:///usr/demo/dtrace/index.html
+EOF
+ }
+ }
+
+ close (DEMO);
+ close (OUT);
+}
+
+sub demo_find {
+ my $demo = $_[0];
+ my $chap;
+
+ foreach $chap (keys %chaps) {
+ if (!stat("$chap/$demo")) {
+ next;
+ }
+
+ demo_process($chap, $demo);
+ return;
+ }
+
+ die "Couldn't find $demo in any chapter";
+}
+
+sub chaps_process {
+ my $outfile = $_[0];
+ my $chap;
+
+ open HTML, ">$outfile" or die "Can't open $outfile.";
+
+ print HTML "<html>\n<head>\n";
+ print HTML "<title>Example DTrace Scripts</title>\n";
+ print HTML "</head>\n<body bgcolor=\"#ffffff\">\n";
+
+ print HTML "<table width=\"85%\" border=0 align=\"center\"><tr><td>";
+ print HTML "<h2>DTrace Examples</h2>\n";
+
+ print HTML "<hr><p>\n";
+ print HTML "Here are the <a href=\"$dtrace_url\">DTrace</a> scripts\n";
+ print HTML "that are used as examples in the\n";
+ print HTML "<a href=\"$chaps{book}{url}\">$chaps{book}{title}</a>. ";
+ print HTML "For more information on any one script, follow the link\n";
+ print HTML "to its corresponding chapter.\n";
+ print HTML "<p>\n<hr><p>\n";
+
+ print HTML "<left><table width=\"85%\" border=1 cellpadding=4 ";
+ print HTML "cellspacing=0 align=\"center\" bgcolor=\"#ffffff\">\n";
+ print HTML "<tr bgcolor=\"#5882a1\"><td width=\"50%\">";
+ print HTML "<font color=\"#ffffff\"><b>Chapter</b></td></font>\n";
+ print HTML "<td><font color=\"#ffffff\"><b>Script</b></td>\n";
+ print HTML "</font></tr>\n";
+
+ foreach $chap (sort chaps_ascending (keys %chaps)) {
+ my @demos;
+ my $demo;
+
+ #
+ # Open the directory associated with the chapter.
+ #
+ if ($chap =~ /^book$/) {
+ next;
+ }
+
+ opendir(DEMOS, $chap) || die("Cannot open directory $chap");
+ @demos = readdir(DEMOS);
+ closedir(DEMOS);
+
+ print HTML "<tr>\n";
+ print HTML "<td align=left>";
+ print HTML "<a href=\"$chaps{$chap}{url}\">";
+ print HTML "$chaps{$chap}{title}</a></td>\n";
+
+ print HTML "<td><table border=0>\n";
+
+ foreach $demo (sort(@demos)) {
+ if ($demo !~ /^[a-z].*\.d$/) {
+ next;
+ }
+
+ print HTML "<tr><td><a href=\"$demo\">$demo</a>";
+ print HTML "</td></tr>\n";
+
+ demo_process($chap, $demo);
+ }
+
+ print HTML "</table></td></tr>\n";
+ }
+
+ print HTML "</table>\n</td>\n<p>\n\n";
+ print HTML "</td></tr>\n";
+ print HTML "<tr><td><hr><small>Copyright ";
+ print HTML localtime->year() + 1900;
+ print HTML " Sun Microsystems</small>\n";
+ print HTML "</table>\n";
+ print HTML "</body>\n</html>\n";
+ close HTML;
+}
+
+chaps_read();
+
+if (basename($ARGV[0]) ne "$htmlfile") {
+ demo_find(basename($ARGV[0]));
+} else {
+ chaps_process($htmlfile);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/printa.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/printa.d
new file mode 100644
index 00000000..f3cee56c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/out/printa.d
@@ -0,0 +1,35 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+profile:::profile-997
+{
+ @a[caller] = count();
+}
+
+END
+{
+ printa("%@8u %a\n", @a);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/lwptime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/lwptime.d
new file mode 100644
index 00000000..53949af4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/lwptime.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+proc:::lwp-start
+/tid != 1/
+{
+ self->start = timestamp;
+}
+
+proc:::lwp-exit
+/self->start/
+{
+ @[execname] = quantize(timestamp - self->start);
+ self->start = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/progtime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/progtime.d
new file mode 100644
index 00000000..8bfa369f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/progtime.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+proc:::start
+{
+ self->start = timestamp;
+}
+
+proc:::exit
+/self->start/
+{
+ @[execname] = quantize(timestamp - self->start);
+ self->start = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/sig.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/sig.d
new file mode 100644
index 00000000..07d9b25c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/sig.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+proc:::signal-send
+{
+ @[execname, stringof(args[1]->pr_fname), args[2]] = count();
+}
+
+END
+{
+ printf("%20s %20s %12s %s\n",
+ "SENDER", "RECIPIENT", "SIG", "COUNT");
+ printa("%20s %20s %12d %@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/whoexec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/whoexec.d
new file mode 100644
index 00000000..ee0fe4ff
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/proc/whoexec.d
@@ -0,0 +1,51 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+proc:::exec
+{
+ self->parent = execname;
+}
+
+proc:::exec-success
+/self->parent != NULL/
+{
+ @[self->parent, execname] = count();
+ self->parent = NULL;
+}
+
+proc:::exec-failure
+/self->parent != NULL/
+{
+ self->parent = NULL;
+}
+
+END
+{
+ printf("%-20s %-20s %s\n", "WHO", "WHAT", "COUNT");
+ printa("%-20s %-20s %@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/prof.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/prof.d
new file mode 100644
index 00000000..4eedf502
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/prof.d
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+profile-97
+/pid != 0/
+{
+ @proc[pid, execname] = count();
+}
+
+END
+{
+ printf("%-8s %-40s %s\n", "PID", "CMD", "COUNT");
+ printa("%-8d %-40s %@d\n", @proc);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/profpri.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/profpri.d
new file mode 100644
index 00000000..615594b5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/profpri.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+profile-1001
+/pid == $1/
+{
+ @proc[execname] = lquantize(curlwpsinfo->pr_pri, 0, 100, 10);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/restest.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/restest.d
new file mode 100644
index 00000000..390ea124
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/profile/restest.d
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+profile-5000
+{
+ /*
+ * We divide by 1,000,000 to convert nanoseconds to milliseconds, and
+ * then we take the value mod 10 to get the current millisecond within
+ * a 10 millisecond window. On platforms that do not support truly
+ * arbitrary resolution profile probes, all of the profile-5000 probes
+ * will fire on roughly the same millisecond. On platforms that
+ * support a truly arbitrary resolution, the probe firings will be
+ * evenly distributed across the milliseconds.
+ */
+ @ms = lquantize((timestamp / 1000000) % 10, 0, 10, 1);
+}
+
+tick-1sec
+/i++ >= 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d
new file mode 100644
index 00000000..ab65e956
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::sleep
+/execname == "MozillaFirebird" && curlwpsinfo->pr_stype == SOBJ_CV/
+{
+ bedtime[curlwpsinfo->pr_addr] = timestamp;
+}
+
+sched:::wakeup
+/execname == "MozillaFirebird" && bedtime[args[0]->pr_addr]/
+{
+ @[args[1]->pr_pid, args[0]->pr_lwpid, pid, curlwpsinfo->pr_lwpid] =
+ quantize(timestamp - bedtime[args[0]->pr_addr]);
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+sched:::wakeup
+/bedtime[args[0]->pr_addr]/
+{
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+END
+{
+ printa("%d/%d sleeping on %d/%d:\n%@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d
new file mode 100644
index 00000000..0fcfa1c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::off-cpu
+/curlwpsinfo->pr_state == SSLEEP/
+{
+ self->cpu = cpu;
+ self->ts = timestamp;
+}
+
+sched:::on-cpu
+/self->ts/
+{
+ @[self->cpu == cpu ?
+ "sleep time, no CPU migration" : "sleep time, CPU migration"] =
+ lquantize((timestamp - self->ts) / 1000000, 0, 500, 25);
+ self->ts = 0;
+ self->cpu = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d
new file mode 100644
index 00000000..8e30ac44
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::sleep
+/curlwpsinfo->pr_stype == SOBJ_SHUTTLE/
+{
+ bedtime[curlwpsinfo->pr_addr] = timestamp;
+}
+
+sched:::wakeup
+/execname == "nscd" && bedtime[args[0]->pr_addr]/
+{
+ @[stringof(curpsinfo->pr_fname), stringof(args[1]->pr_fname)] =
+ quantize(timestamp - bedtime[args[0]->pr_addr]);
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+sched:::wakeup
+/bedtime[args[0]->pr_addr]/
+{
+ bedtime[args[0]->pr_addr] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d
new file mode 100644
index 00000000..ea76fd79
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::change-pri
+{
+ @[stringof(args[0]->pr_clname)] =
+ lquantize(args[2] - args[0]->pr_pri, -50, 50, 5);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d
new file mode 100644
index 00000000..2c80e6a7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ start = timestamp;
+}
+
+sched:::change-pri
+/args[1]->pr_pid == $1 && args[0]->pr_lwpid == $2/
+{
+ printf("%d %d\n", timestamp - start, args[2]);
+}
+
+tick-1sec
+/++n == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d
new file mode 100644
index 00000000..a34ae4cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::enqueue
+{
+ this->len = qlen[args[2]->cpu_id]++;
+ @[args[2]->cpu_id] = lquantize(this->len, 0, 100);
+}
+
+sched:::dequeue
+/qlen[args[2]->cpu_id]/
+{
+ qlen[args[2]->cpu_id]--;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d
new file mode 100644
index 00000000..54ebf5f5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::enqueue
+{
+ ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id] =
+ timestamp;
+}
+
+sched:::dequeue
+/ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id]/
+{
+ @[args[2]->cpu_id] = quantize(timestamp -
+ ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id]);
+ ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d
new file mode 100644
index 00000000..88427593
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::tick,
+sched:::enqueue
+{
+ @[probename] = lquantize((timestamp / 1000000) % 10, 0, 10);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d
new file mode 100644
index 00000000..e24a80ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+uint64_t last[int];
+
+sched:::tick
+/last[cpu]/
+{
+ @[cpu] = min(timestamp - last[cpu]);
+}
+
+sched:::tick
+{
+ last[cpu] = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d
new file mode 100644
index 00000000..d8b6edb0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d
@@ -0,0 +1,64 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::off-cpu
+/curlwpsinfo->pr_state == SSLEEP/
+{
+ /*
+ * We're sleeping. Track our sobj type.
+ */
+ self->sobj = curlwpsinfo->pr_stype;
+ self->bedtime = timestamp;
+}
+
+sched:::off-cpu
+/curlwpsinfo->pr_state == SRUN/
+{
+ self->bedtime = timestamp;
+}
+
+sched:::on-cpu
+/self->bedtime && !self->sobj/
+{
+ @["preempted"] = quantize(timestamp - self->bedtime);
+ self->bedtime = 0;
+}
+
+sched:::on-cpu
+/self->sobj/
+{
+ @[self->sobj == SOBJ_MUTEX ? "kernel-level lock" :
+ self->sobj == SOBJ_RWLOCK ? "rwlock" :
+ self->sobj == SOBJ_CV ? "condition variable" :
+ self->sobj == SOBJ_SEMA ? "semaphore" :
+ self->sobj == SOBJ_USER ? "user-level lock" :
+ self->sobj == SOBJ_USER_PI ? "user-level prio-inheriting lock" :
+ self->sobj == SOBJ_SHUTTLE ? "shuttle" : "unknown"] =
+ quantize(timestamp - self->bedtime);
+
+ self->sobj = 0;
+ self->bedtime = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d
new file mode 100644
index 00000000..af026244
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::on-cpu
+{
+ self->ts = timestamp;
+}
+
+sched:::off-cpu
+/self->ts/
+{
+ @[cpu] = quantize(timestamp - self->ts);
+ self->ts = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d
new file mode 100644
index 00000000..ddd13f75
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d
@@ -0,0 +1,60 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ start = timestamp;
+}
+
+sched:::on-cpu
+/execname == $$1/
+{
+ self->ts = timestamp;
+}
+
+sched:::off-cpu
+/self->ts/
+{
+ @[cpu] = sum(timestamp - self->ts);
+ self->ts = 0;
+}
+
+profile:::tick-1sec
+/++x == 10/
+{
+ exit(0);
+}
+
+dtrace:::END
+{
+ printf("CPU distribution over %d seconds:\n\n",
+ (timestamp - start) / 1000000000);
+ printf("CPU microseconds\n--- ------------\n");
+ normalize(@, 1000);
+ printa("%3d %@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d
new file mode 100644
index 00000000..f0243d60
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d
@@ -0,0 +1,46 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::sleep
+/!(curlwpsinfo->pr_flag & PR_ISSYS) && curlwpsinfo->pr_stype == SOBJ_CV/
+{
+ bedtime[curlwpsinfo->pr_addr] = timestamp;
+}
+
+sched:::wakeup
+/bedtime[args[0]->pr_addr]/
+{
+ @[stringof(args[1]->pr_fname), execname] =
+ quantize(timestamp - bedtime[args[0]->pr_addr]);
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+END
+{
+ printa("%s sleeping on %s:\n%@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d
new file mode 100644
index 00000000..e8dd8633
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d
@@ -0,0 +1,57 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::preempt
+{
+ self->preempt = 1;
+}
+
+sched:::remain-cpu
+/self->preempt/
+{
+ self->preempt = 0;
+}
+
+sched:::off-cpu
+/self->preempt/
+{
+ /*
+ * If we were told to preempt ourselves, see who we ended up giving
+ * the CPU to.
+ */
+ @[stringof(args[1]->pr_fname), args[0]->pr_pri, execname,
+ curlwpsinfo->pr_pri] = count();
+ self->preempt = 0;
+}
+
+END
+{
+ printf("%30s %3s %30s %3s %5s\n", "PREEMPTOR", "PRI",
+ "PREEMPTED", "PRI", "#");
+ printa("%30s %3d %30s %3d %5@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d
new file mode 100644
index 00000000..c2ab47a3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d
@@ -0,0 +1,95 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+#pragma D option nspec=4
+#pragma D option specsize=100k
+
+int maxlen;
+int spec[int];
+
+sched:::enqueue
+{
+ this->len = ++qlen[this->cpu = args[2]->cpu_id];
+ in[args[0]->pr_addr] = timestamp;
+}
+
+sched:::enqueue
+/this->len > maxlen && spec[this->cpu]/
+{
+ /*
+ * There is already a speculation for this CPU. We just set a new
+ * record, so we'll discard the old one.
+ */
+ discard(spec[this->cpu]);
+}
+
+sched:::enqueue
+/this->len > maxlen/
+{
+ /*
+ * We have a winner. Set the new maximum length and set the timestamp
+ * of the longest length.
+ */
+ maxlen = this->len;
+ longtime[this->cpu] = timestamp;
+
+ /*
+ * Now start a new speculation, and speculatively trace the length.
+ */
+ this->spec = spec[this->cpu] = speculation();
+ speculate(this->spec);
+ printf("Run queue of length %d:\n", this->len);
+}
+
+sched:::dequeue
+/(this->in = in[args[0]->pr_addr]) &&
+ this->in <= longtime[this->cpu = args[2]->cpu_id]/
+{
+ speculate(spec[this->cpu]);
+ printf(" %d/%d (%s)\n",
+ args[1]->pr_pid, args[0]->pr_lwpid,
+ stringof(args[1]->pr_fname));
+}
+
+sched:::dequeue
+/qlen[args[2]->cpu_id]/
+{
+ in[args[0]->pr_addr] = 0;
+ this->len = --qlen[args[2]->cpu_id];
+}
+
+sched:::dequeue
+/this->len == 0 && spec[this->cpu]/
+{
+ /*
+ * We just processed the last thread that was enqueued at the time
+ * of longest length; commit the speculation, which by now contains
+ * each thread that was enqueued when the queue was longest.
+ */
+ commit(spec[this->cpu]);
+ spec[this->cpu] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d
new file mode 100644
index 00000000..c698e4f1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::dequeue
+/args[2]->cpu_id != -1 && cpu != args[2]->cpu_id &&
+ (curlwpsinfo->pr_flag & PR_IDLE)/
+{
+ @[stringof(args[1]->pr_fname), args[2]->cpu_id] =
+ lquantize(cpu, 0, 100);
+}
+
+END
+{
+ printa("%s stolen from CPU %d by:\n%@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d
new file mode 100644
index 00000000..bb5ed33c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ start = timestamp;
+}
+
+sched:::wakeup
+/stringof(args[1]->pr_fname) == "xterm"/
+{
+ @[execname] = lquantize((timestamp - start) / 1000000000, 0, 10);
+}
+
+profile:::tick-1sec
+/++x == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d
new file mode 100644
index 00000000..cbaf1057
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+self int last;
+
+sched:::wakeup
+/self->last && args[0]->pr_stype == SOBJ_CV/
+{
+ @[stringof(args[1]->pr_fname)] = sum(vtimestamp - self->last);
+ self->last = 0;
+}
+
+sched:::wakeup
+/execname == "Xsun" && self->last == 0/
+{
+ self->last = vtimestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/interp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/interp.d
new file mode 100644
index 00000000..c3e419ec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/interp.d
@@ -0,0 +1,33 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#!/usr/sbin/dtrace -s
+
+BEGIN
+{
+ trace("hello");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/syscall.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/syscall.d
new file mode 100644
index 00000000..c47fb922
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/syscall.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall:::entry
+/pid == $target/
+{
+ @[probefunc] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/tracewrite.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/tracewrite.d
new file mode 100644
index 00000000..c1336cf7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/script/tracewrite.d
@@ -0,0 +1,32 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#!/usr/sbin/dtrace -s
+
+syscall::write:entry
+/pid == $1/
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/callout.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/callout.d
new file mode 100644
index 00000000..2044536f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/callout.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sdt:::callout-start
+{
+ @callouts[((callout_t *)arg0)->c_func] = count();
+}
+
+tick-1sec
+{
+ printa("%40a %10@d\n", @callouts);
+ clear(@callouts);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/interval.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/interval.d
new file mode 100644
index 00000000..d4a6a320
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/interval.d
@@ -0,0 +1,54 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sdt:::callout-start
+{
+ self->callout = ((callout_t *)arg0)->c_func;
+}
+
+fbt::timeout:entry
+/self->callout && arg2 <= 100/
+{
+ /*
+ * In this case, we are most interested in interval timeout(9F)s that
+ * are short. We therefore do a linear quantization from 0 ticks to
+ * 100 ticks. The system clock's frequency ? set by the variable
+ * "hz" ? defaults to 100, so 100 system clock ticks is one second.
+ */
+ @callout[self->callout] = lquantize(arg2, 0, 100);
+}
+
+sdt:::callout-end
+{
+ self->callout = NULL;
+}
+
+END
+{
+ printa("%a\n%@d\n\n", @callout);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/intr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/intr.d
new file mode 100644
index 00000000..5233450f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sdt/intr.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+interrupt-start
+{
+ self->ts = vtimestamp;
+}
+
+interrupt-complete
+/self->ts/
+{
+ this->devi = (struct dev_info *)arg0;
+ @[stringof(`devnamesp[this->devi->devi_major].dn_name),
+ this->devi->devi_instance] = quantize(vtimestamp - self->ts);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/spec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/spec.d
new file mode 100644
index 00000000..dc162a1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/spec.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::open:entry
+{
+ self->spec = speculation();
+}
+
+syscall:::
+/self->spec/
+{
+ speculate(self->spec);
+ printf("this is speculative");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/specopen.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/specopen.d
new file mode 100644
index 00000000..f1975ff8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/spec/specopen.d
@@ -0,0 +1,93 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#!/usr/sbin/dtrace -Fs
+
+syscall::open:entry,
+syscall::open64:entry
+{
+ /*
+ * The call to speculation() creates a new speculation. If this fails,
+ * dtrace(1M) will generate an error message indicating the reason for
+ * the failed speculation(), but subsequent speculative tracing will be
+ * silently discarded.
+ */
+ self->spec = speculation();
+ speculate(self->spec);
+
+ /*
+ * Because this printf() follows the speculate(), it is being
+ * speculatively traced; it will only appear in the data buffer if the
+ * speculation is subsequently commited.
+ */
+ printf("%s", stringof(copyinstr(arg0)));
+}
+
+fbt:::
+/self->spec/
+{
+ /*
+ * A speculate() with no other actions speculates the default action:
+ * tracing the EPID.
+ */
+ speculate(self->spec);
+}
+
+syscall::open:return,
+syscall::open64:return
+/self->spec/
+{
+ /*
+ * To balance the output with the -F option, we want to be sure that
+ * every entry has a matching return. Because we speculated the
+ * open entry above, we want to also speculate the open return.
+ * This is also a convenient time to trace the errno value.
+ */
+ speculate(self->spec);
+ trace(errno);
+}
+
+syscall::open:return,
+syscall::open64:return
+/self->spec && errno != 0/
+{
+ /*
+ * If errno is non-zero, we want to commit the speculation.
+ */
+ commit(self->spec);
+ self->spec = 0;
+}
+
+syscall::open:return,
+syscall::open64:return
+/self->spec && errno == 0/
+{
+ /*
+ * If errno is not set, we discard the speculation.
+ */
+ discard(self->spec);
+ self->spec = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/kstat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/kstat.d
new file mode 100644
index 00000000..1b40ddaa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/kstat.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+pid$1:libkstat:kstat_data_lookup:entry
+{
+ self->ksname = arg1;
+}
+
+pid$1:libkstat:kstat_data_lookup:return
+/self->ksname != NULL && arg1 != NULL/
+{
+ this->ksp = (kstat_named_t *) copyin(arg1, sizeof (kstat_named_t));
+ printf("%s has ui64 value %u\n",
+ copyinstr(self->ksname), this->ksp->value.ui64);
+}
+
+pid$1:libkstat:kstat_data_lookup:return
+/self->ksname != NULL && arg1 == NULL/
+{
+ self->ksname = NULL;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/ksyms.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/ksyms.d
new file mode 100644
index 00000000..ab2f1cb5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/ksyms.d
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * When our strings(1) invocation starts a read(2), set a watched flag on
+ * the current thread. When the read(2) finishes, clear the watched flag.
+ */
+syscall::read:entry
+/curpsinfo->pr_psargs == "strings -a /dev/ksyms"/
+{
+ printf("read %u bytes to user address %x\n", arg2, arg1);
+ self->watched = 1;
+}
+
+syscall::read:return
+/self->watched/
+{
+ self->watched = 0;
+}
+
+/*
+ * Instrument uiomove(9F). The prototype for this function is as follows:
+ * int uiomove(caddr_t addr, size_t nbytes, enum uio_rw rwflag, uio_t *uio);
+ */
+fbt::uiomove:entry
+/self->watched/
+{
+ this->iov = args[3]->uio_iov;
+
+ printf("uiomove %u bytes to %p in pid %d\n",
+ this->iov->iov_len, this->iov->iov_base, pid);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/rwinfo.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/rwinfo.d
new file mode 100644
index 00000000..866678ef
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/struct/rwinfo.d
@@ -0,0 +1,59 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+struct callinfo {
+ uint64_t ts; /* timestamp of last syscall entry */
+ uint64_t elapsed; /* total elapsed time in nanoseconds */
+ uint64_t calls; /* number of calls made */
+ size_t maxbytes; /* maximum byte count argument */
+};
+
+struct callinfo i[string]; /* declare i as an associative array */
+
+syscall::read:entry, syscall::write:entry
+/pid == $1/
+{
+ i[probefunc].ts = timestamp;
+ i[probefunc].calls++;
+ i[probefunc].maxbytes = arg2 > i[probefunc].maxbytes ?
+ arg2 : i[probefunc].maxbytes;
+}
+
+syscall::read:return, syscall::write:return
+/i[probefunc].ts != 0 && pid == $1/
+{
+ i[probefunc].elapsed += timestamp - i[probefunc].ts;
+}
+
+END
+{
+ printf(" calls max bytes elapsed nsecs\n");
+ printf("------ ----- --------- -------------\n");
+ printf(" read %5d %9d %d\n",
+ i["read"].calls, i["read"].maxbytes, i["read"].elapsed);
+ printf(" write %5d %9d %d\n",
+ i["write"].calls, i["write"].maxbytes, i["write"].elapsed);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/find.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/find.d
new file mode 100644
index 00000000..d927072c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sysinfo/find.d
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall:::entry
+/execname == "find"/
+{
+ self->syscall = probefunc;
+ self->insys = 1;
+}
+
+sysinfo:::xcalls
+/execname == "find"/
+{
+ @[self->insys ? self->syscall : "<none>"] = count();
+}
+
+syscall:::return
+/self->insys/
+{
+ self->insys = 0;
+ self->syscall = NULL;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcp1stbyte.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcp1stbyte.d
new file mode 100755
index 00000000..94001296
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcp1stbyte.d
@@ -0,0 +1,37 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+tcp:::connect-established
+{
+ start[args[1]->cs_cid] = timestamp;
+}
+
+tcp:::receive
+/start[args[1]->cs_cid] && (args[2]->ip_plength - args[4]->tcp_offset) > 0/
+{
+ @latency["1st Byte Latency (ns)", args[2]->ip_saddr] =
+ quantize(timestamp - start[args[1]->cs_cid]);
+ start[args[1]->cs_cid] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytes.d
new file mode 100755
index 00000000..7fb68de9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytes.d
@@ -0,0 +1,36 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+tcp:::receive
+{
+ @bytes[args[2]->ip_saddr, args[4]->tcp_dport] =
+ sum(args[2]->ip_plength - args[4]->tcp_offset);
+}
+
+tcp:::send
+{
+ @bytes[args[2]->ip_daddr, args[4]->tcp_sport] =
+ sum(args[2]->ip_plength - args[4]->tcp_offset);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytesstat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytesstat.d
new file mode 100755
index 00000000..ecd9b044
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpbytesstat.d
@@ -0,0 +1,45 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#pragma D option quiet
+
+tcp:::receive
+{
+ @bytes[args[2]->ip_saddr, args[4]->tcp_dport] =
+ sum(args[2]->ip_plength - args[4]->tcp_offset);
+}
+
+tcp:::send
+{
+ @bytes[args[2]->ip_daddr, args[4]->tcp_sport] =
+ sum(args[2]->ip_plength - args[4]->tcp_offset);
+}
+
+profile:::tick-1sec
+{
+ printf("\n %-32s %16s\n", "HOST", "BYTES/s");
+ printa(" %-32s %@16d\n", @bytes);
+ trunc(@bytes);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpconnlat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpconnlat.d
new file mode 100755
index 00000000..bc395f97
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpconnlat.d
@@ -0,0 +1,37 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+tcp:::connect-request
+{
+ start[args[1]->cs_cid] = timestamp;
+}
+
+tcp:::connect-established
+/start[args[1]->cs_cid] /
+{
+ @latency["Connect Latency (ns)", args[3]->tcps_raddr] =
+ quantize(timestamp - start[args[1]->cs_cid]);
+ start[args[1]->cs_cid] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpio.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpio.d
new file mode 100755
index 00000000..b3628430
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpio.d
@@ -0,0 +1,32 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+tcp:::send,
+tcp:::receive
+{
+ printf("%15s:%-5d -> %15s:%-5d",
+ args[2]->ip_saddr, args[4]->tcp_sport,
+ args[2]->ip_daddr, args[4]->tcp_dport);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpioflags.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpioflags.d
new file mode 100755
index 00000000..cdfbd2aa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpioflags.d
@@ -0,0 +1,64 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10hz
+
+dtrace:::BEGIN
+{
+ printf(" %15s:%-5s %15s:%-5s %6s %s\n",
+ "LADDR", "PORT", "RADDR", "PORT", "BYTES", "FLAGS");
+}
+
+tcp:::send
+{
+ this->length = args[2]->ip_plength - args[4]->tcp_offset;
+ printf(" %15s:%-5d -> %15s:%-5d %6d (",
+ args[2]->ip_saddr, args[4]->tcp_sport,
+ args[2]->ip_daddr, args[4]->tcp_dport, this->length);
+}
+
+tcp:::receive
+{
+ this->length = args[2]->ip_plength - args[4]->tcp_offset;
+ printf(" %15s:%-5d <- %15s:%-5d %6d (",
+ args[2]->ip_daddr, args[4]->tcp_dport,
+ args[2]->ip_saddr, args[4]->tcp_sport, this->length);
+}
+
+tcp:::send,
+tcp:::receive
+{
+ printf("%s", args[4]->tcp_flags & TH_FIN ? "FIN|" : "");
+ printf("%s", args[4]->tcp_flags & TH_SYN ? "SYN|" : "");
+ printf("%s", args[4]->tcp_flags & TH_RST ? "RST|" : "");
+ printf("%s", args[4]->tcp_flags & TH_PUSH ? "PUSH|" : "");
+ printf("%s", args[4]->tcp_flags & TH_ACK ? "ACK|" : "");
+ printf("%s", args[4]->tcp_flags & TH_URG ? "URG|" : "");
+ printf("%s", args[4]->tcp_flags & TH_ECE ? "ECE|" : "");
+ printf("%s", args[4]->tcp_flags & TH_CWR ? "CWR|" : "");
+ printf("%s", args[4]->tcp_flags == 0 ? "null " : "");
+ printf("\b)\n");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpsnoop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpsnoop.d
new file mode 100755
index 00000000..9d44519e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpsnoop.d
@@ -0,0 +1,78 @@
+#!/usr/sbin/dtrace -s
+/*
+ * tcpsnoop - snoop TCP network packets by process.
+ * Written using DTrace tcp Provider.
+ *
+ * This analyses TCP network packets and prints the responsible PID plus
+ * standard details such as IP address and port. This captures traffic
+ * from existing and newly created TCP connections. It can help identify
+ * which processes are causing TCP traffic.
+ *
+ * SEE ALSO: snoop -rS
+ *
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Portions Copyright 2010 Brendan Gregg
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10hz
+
+dtrace:::BEGIN
+{
+ printf("%6s %6s %15s:%-5s %15s:%-5s %6s %s\n",
+ "TIME", "PID", "LADDR", "PORT", "RADDR", "PORT", "BYTES", "FLAGS");
+}
+
+tcp:::send
+{
+ this->length = args[2]->ip_plength - args[4]->tcp_offset;
+ printf("%6d %6d %15s:%-5d -> %15s:%-5d %6d (",
+ timestamp/1000, args[1]->cs_pid, args[2]->ip_saddr,
+ args[4]->tcp_sport, args[2]->ip_daddr, args[4]->tcp_dport,
+ this->length);
+}
+
+tcp:::receive
+{
+ this->length = args[2]->ip_plength - args[4]->tcp_offset;
+ printf("%6d %6d %15s:%-5d <- %15s:%-5d %6d (",
+ timestamp/1000, args[1]->cs_pid, args[2]->ip_daddr,
+ args[4]->tcp_dport, args[2]->ip_saddr, args[4]->tcp_sport,
+ this->length);
+}
+
+tcp:::send,
+tcp:::receive
+{
+ printf("%s", args[4]->tcp_flags & TH_FIN ? "FIN|" : "");
+ printf("%s", args[4]->tcp_flags & TH_SYN ? "SYN|" : "");
+ printf("%s", args[4]->tcp_flags & TH_RST ? "RST|" : "");
+ printf("%s", args[4]->tcp_flags & TH_PUSH ? "PUSH|" : "");
+ printf("%s", args[4]->tcp_flags & TH_ACK ? "ACK|" : "");
+ printf("%s", args[4]->tcp_flags & TH_URG ? "URG|" : "");
+ printf("%s", args[4]->tcp_flags & TH_ECE ? "ECE|" : "");
+ printf("%s", args[4]->tcp_flags & TH_CWR ? "CWR|" : "");
+ printf("%s", args[4]->tcp_flags == 0 ? "null " : "");
+ printf("\b)\n");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpstate.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpstate.d
new file mode 100755
index 00000000..38f0470a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcpstate.d
@@ -0,0 +1,39 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("%-10s %-10s %-20s %-20s\n", "C", "PID", "PREV", "NEW");
+}
+
+
+tcp:::state-change
+{
+ printf("%-10d %-10d %-20s -> %-20s\n", cpu, args[1]->cs_pid,
+ tcp_state_string[args[5]->tcps_state],
+ tcp_state_string[args[3]->tcps_state]);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcptop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcptop.d
new file mode 100755
index 00000000..450f496e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/tcp/tcptop.d
@@ -0,0 +1,138 @@
+#!/usr/sbin/dtrace -s
+/*
+ * tcptop: display top TCP network packets by process.
+ * Written using DTrace tcp Provider.
+ *
+ * Usage: dtrace -s tcptop.d [count] [interval]
+ *
+ * This analyses TCP network packets and prints the responsible PID plus
+ * standard details such as IP address and port. This captures traffic
+ * of newly created TCP connections that were established while this program
+ * was running along with traffic from existing connections. It can help
+ * identify which processes is causing TCP traffic.
+ *
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Portions Copyright 2010 Brendan Gregg
+ */
+
+#pragma D option quiet
+#pragma D option defaultargs
+#pragma D option switchrate=10hz
+
+/*
+ * Print header
+ */
+dtrace:::BEGIN
+{
+ /* starting values */
+ counts = $1 ? $1 : 10;
+ secs = $2 ? $2 : 5;
+ TCP_out = 0;
+ TCP_in = 0;
+
+ printf("Sampling... Please wait.\n");
+}
+
+
+tcp:::send
+/ args[1]->cs_pid != -1 /
+{
+ @out[args[1]->cs_zoneid, args[1]->cs_pid, args[2]->ip_saddr,
+ args[4]->tcp_sport, args[2]->ip_daddr, args[4]->tcp_dport] =
+ sum(args[2]->ip_plength - args[4]->tcp_offset);
+}
+
+tcp:::receive
+/ args[1]->cs_pid != -1 /
+{
+ @out[args[1]->cs_zoneid, args[1]->cs_pid, args[2]->ip_daddr,
+ args[4]->tcp_dport, args[2]->ip_saddr, args[4]->tcp_sport] =
+ sum(args[2]->ip_plength - args[4]->tcp_offset);
+}
+
+/*
+ * TCP Systemwide Stats
+ */
+mib:::tcpOutDataBytes { TCP_out += args[0]; }
+mib:::tcpRetransBytes { TCP_out += args[0]; }
+mib:::tcpInDataInorderBytes { TCP_in += args[0]; }
+mib:::tcpInDataDupBytes { TCP_in += args[0]; }
+mib:::tcpInDataUnorderBytes { TCP_in += args[0]; }
+
+profile:::tick-1sec
+/secs != 0/
+{
+ secs--;
+}
+
+/*
+ * Print Report
+ */
+profile:::tick-1sec
+/secs == 0/
+{
+ /* fetch 1 min load average */
+ this->load1a = `hp_avenrun[0] / 65536;
+ this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536;
+
+ /* convert TCP counters to Kb */
+ TCP_out /= 1024;
+ TCP_in /= 1024;
+
+ /* print status */
+ printf("%Y, load: %d.%02d, TCPin: %6d Kb, TCPout: %6d Kb\n\n",
+ walltimestamp, this->load1a, this->load1b, TCP_in, TCP_out);
+
+ /* print headers */
+ printf("%6s %6s %-15s %5s %-15s %5s %9s\n",
+ "ZONE", "PID", "LADDR", "LPORT", "RADDR", "RPORT", "SIZE");
+
+ /* print data */
+ printa("%6d %6d %-15s %5d %-15s %5d %@9d\n", @out);
+ printf("\n");
+
+ /* clear data */
+ trunc(@out);
+ TCP_in = 0;
+ TCP_out = 0;
+ secs = 5;
+ counts--;
+}
+
+/*
+ * End of program
+ */
+profile:::tick-1sec
+/counts == 0/
+{
+ exit(0);
+}
+
+/*
+ * Cleanup for Ctrl-C
+ */
+dtrace:::END
+{
+ trunc(@out);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytes.d
new file mode 100755
index 00000000..29d85fcd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytes.d
@@ -0,0 +1,36 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+udp:::receive
+{
+ @bytes[args[2]->ip_saddr, args[4]->udp_dport] =
+ sum(args[4]->udp_length);
+}
+
+udp:::send
+{
+ @bytes[args[2]->ip_daddr, args[4]->udp_sport] =
+ sum(args[4]->udp_length);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytesstat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytesstat.d
new file mode 100755
index 00000000..58fa826a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpbytesstat.d
@@ -0,0 +1,45 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#pragma D option quiet
+
+udp:::receive
+{
+ @bytes[args[2]->ip_saddr, args[4]->udp_dport] =
+ sum(args[4]->udp_length);
+}
+
+udp:::send
+{
+ @bytes[args[2]->ip_daddr, args[4]->udp_sport] =
+ sum(args[4]->udp_length);
+}
+
+profile:::tick-1sec
+{
+ printf("\n %-32s %16s\n", "HOST", "BYTES/s");
+ printa(" %-32s %@16d\n", @bytes);
+ trunc(@bytes);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpio.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpio.d
new file mode 100755
index 00000000..78b3f482
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpio.d
@@ -0,0 +1,32 @@
+#!/usr/sbin/dtrace -s
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+udp:::send,
+udp:::receive
+{
+ printf("%15s:%-5d -> %15s:%-5d",
+ args[2]->ip_saddr, args[4]->udp_sport,
+ args[2]->ip_daddr, args[4]->udp_dport);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpsnoop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpsnoop.d
new file mode 100755
index 00000000..fffc2904
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udpsnoop.d
@@ -0,0 +1,59 @@
+#!/usr/sbin/dtrace -s
+/*
+ * udpsnoop - snoop UDP network packets by process.
+ * Written using DTrace udp Provider.
+ *
+ * This analyses UDP network packets and prints the responsible PID plus
+ * standard details such as IP address and port. This captures traffic
+ * from existing and newly created UDP connections. It can help identify
+ * which processes are causing UDP traffic.
+ *
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Portions Copyright 2010 Brendan Gregg
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10hz
+
+dtrace:::BEGIN
+{
+ printf("%6s %6s %15s:%-5s %15s:%-5s %6s\n",
+ "TIME", "PID", "LADDR", "PORT", "RADDR", "PORT", "BYTES");
+}
+
+udp:::send
+{
+ printf("%6d %6d %15s:%-5d -> %15s:%-5d %6d\n",
+ timestamp/1000, args[1]->cs_pid, args[2]->ip_saddr,
+ args[4]->udp_sport, args[2]->ip_daddr, args[4]->udp_dport,
+ args[4]->udp_length);
+}
+
+udp:::receive
+{
+ printf("%6d %6d %15s:%-5d <- %15s:%-5d %6d\n",
+ timestamp/1000, args[1]->cs_pid, args[2]->ip_daddr,
+ args[4]->udp_dport, args[2]->ip_saddr, args[4]->udp_sport,
+ args[4]->udp_length);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udptop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udptop.d
new file mode 100755
index 00000000..a626e571
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/udp/udptop.d
@@ -0,0 +1,133 @@
+#!/usr/sbin/dtrace -s
+/*
+ * udptop: display top UDP network packets by process.
+ * Written using DTrace udp Provider.
+ *
+ * Usage: dtrace -s udptop.d [count] [interval]
+ *
+ * This analyses UDP network packets and prints the responsible PID plus
+ * standard details such as IP address and port. This captures traffic
+ * of newly created UDP connections that were established while this program
+ * was running along with traffic from existing connections. It can help
+ * identify which processes is causing UDP traffic.
+ *
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Portions Copyright 2010 Brendan Gregg
+ */
+
+#pragma D option quiet
+#pragma D option defaultargs
+#pragma D option switchrate=10hz
+
+/*
+ * Print header
+ */
+dtrace:::BEGIN
+{
+ /* starting values */
+ counts = $1 ? $1 : 10;
+ secs = $2 ? $2 : 5;
+ UDP_out = 0;
+ UDP_in = 0;
+
+ printf("Sampling... Please wait.\n");
+}
+
+
+udp:::send
+/ args[1]->cs_pid != -1 /
+{
+ @out[args[1]->cs_zoneid, args[1]->cs_pid, args[2]->ip_saddr,
+ args[4]->udp_sport, args[2]->ip_daddr, args[4]->udp_dport] =
+ sum(args[4]->udp_length);
+}
+
+udp:::receive
+/ args[1]->cs_pid != -1 /
+{
+ @out[args[1]->cs_zoneid, args[1]->cs_pid, args[2]->ip_daddr,
+ args[4]->udp_dport, args[2]->ip_saddr, args[4]->udp_sport] =
+ sum(args[4]->udp_length);
+}
+
+/*
+ * UDP Systemwide Stats
+ */
+mib:::udpHCOutDatagrams { UDP_out += args[0]; }
+mib:::udpHCInDatagrams { UDP_in += args[0]; }
+
+profile:::tick-1sec
+/secs != 0/
+{
+ secs--;
+}
+
+/*
+ * Print Report
+ */
+profile:::tick-1sec
+/secs == 0/
+{
+ /* fetch 1 min load average */
+ this->load1a = `hp_avenrun[0] / 65536;
+ this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536;
+
+ /* print status */
+ printf(%Y, load: %d.%02d, UDP datagrams in: %6d, ",
+ walltimestamp, this->load1a, this->load1b, UDP_in);
+ printf("UDP datagrams out: %6d\n\n", UDP_out);
+
+ /* print headers */
+ printf("%6s %6s %-15s %5s %-15s %5s %9s\n",
+ "ZONE", "PID", "LADDR", "LPORT", "RADDR", "RPORT", "SIZE");
+
+ /* print data */
+ printa("%6d %6d %-15s %5d %-15s %5d %@9d\n", @out);
+ printf("\n");
+
+ /* clear data */
+ trunc(@out);
+ UDP_in = 0;
+ UDP_out = 0;
+ secs = 5;
+ counts--;
+}
+
+/*
+ * End of program
+ */
+profile:::tick-1sec
+/counts == 0/
+{
+ exit(0);
+}
+
+/*
+ * Cleanup for Ctrl-C
+ */
+dtrace:::END
+{
+ trunc(@out);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/badopen.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/badopen.d
new file mode 100644
index 00000000..7e6d22b7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/badopen.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::open:entry
+/pid == $1/
+{
+ self->path = copyinstr(arg0);
+}
+
+syscall::open:return
+/self->path != NULL && arg1 == -1/
+{
+ printf("open for '%s' failed", self->path);
+ ustack();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/errorpath.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/errorpath.d
new file mode 100644
index 00000000..95c82e51
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/errorpath.d
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+pid$1::$2:entry
+{
+ self->spec = speculation();
+ speculate(self->spec);
+ printf("%x %x %x %x %x", arg0, arg1, arg2, arg3, arg4);
+}
+
+pid$1::$2:
+/self->spec/
+{
+ speculate(self->spec);
+}
+
+pid$1::$2:return
+/self->spec && arg1 == 0/
+{
+ discard(self->spec);
+ self->spec = 0;
+}
+
+pid$1::$2:return
+/self->spec && arg1 != 0/
+{
+ commit(self->spec);
+ self->spec = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/libc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/libc.d
new file mode 100644
index 00000000..92b20cfe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/libc.d
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+pid$target:libc.so::entry
+{
+ @[probefunc] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/userfunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/userfunc.d
new file mode 100644
index 00000000..0c98d675
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/user/userfunc.d
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+pid$1::$2:entry
+{
+ self->trace = 1;
+}
+
+pid$1::$2:return
+/self->trace/
+{
+ self->trace = 0;
+}
+
+pid$1:::entry,
+pid$1:::return
+/self->trace/
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/clause.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/clause.d
new file mode 100644
index 00000000..056329fe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/clause.d
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+int me; /* an integer global variable */
+this int foo; /* an integer clause-local variable */
+
+tick-1sec
+{
+ /*
+ * Set foo to be 10 if and only if this is the first clause executed.
+ */
+ this->foo = (me % 3 == 0) ? 10 : this->foo;
+ printf("Clause 1 is number %d; foo is %d\n", me++ % 3, this->foo++);
+}
+
+tick-1sec
+{
+ /*
+ * Set foo to be 20 if and only if this is the first clause executed.
+ */
+ this->foo = (me % 3 == 0) ? 20 : this->foo;
+ printf("Clause 2 is number %d; foo is %d\n", me++ % 3, this->foo++);
+}
+
+tick-1sec
+{
+ /*
+ * Set foo to be 30 if and only if this is the first clause executed.
+ */
+ this->foo = (me % 3 == 0) ? 30 : this->foo;
+ printf("Clause 3 is number %d; foo is %d\n", me++ % 3, this->foo++);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/rtime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/rtime.d
new file mode 100644
index 00000000..e2db52f3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vars/rtime.d
@@ -0,0 +1,43 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+syscall::read:entry
+{
+ self->t = timestamp;
+}
+
+syscall::read:return
+/self->t != 0/
+{
+ printf("%d/%d spent %d nsecs in read(2)\n",
+ pid, tid, timestamp - self->t);
+
+ /*
+ * We're done with this thread-local variable; assign zero to it to
+ * allow the DTrace runtime to reclaim the underlying storage.
+ */
+ self->t = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/soffice.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/soffice.d
new file mode 100644
index 00000000..fa6435cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/vminfo/soffice.d
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+vminfo:::maj_fault,
+vminfo:::zfod,
+vminfo:::as_fault
+/execname == "soffice.bin" && start == 0/
+{
+ /*
+ * This is the first time that a vminfo probe has been hit; record
+ * our initial timestamp.
+ */
+ start = timestamp;
+}
+
+vminfo:::maj_fault,
+vminfo:::zfod,
+vminfo:::as_fault
+/execname == "soffice.bin"/
+{
+ /*
+ * Aggregate on the probename, and lquantize() the number of seconds
+ * since our initial timestamp. (There are 1,000,000,000 nanoseconds
+ * in a second.) We assume that the script will be terminated before
+ * 60 seconds elapses.
+ */
+ @[probename] =
+ lquantize((timestamp - start) / 1000000000, 0, 60);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/dtrace.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/dtrace.c
new file mode 100644
index 00000000..624ca872
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/dtrace.c
@@ -0,0 +1,2085 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifndef _MSC_VER
+# include <sys/wait.h>
+#endif
+
+#include <dtrace.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#ifndef VBOX
+# include <strings.h>
+#endif
+#ifndef _MSC_VER
+# include <unistd.h>
+#else
+# include <direct.h>
+# include <io.h>
+#endif
+#include <limits.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#ifndef VBOX
+#include <alloca.h>
+#include <libgen.h>
+#include <libproc.h>
+#endif
+
+#ifdef VBOX
+# include <stdio.h>
+
+# include <iprt/alloca.h>
+# include <iprt/err.h>
+# include <iprt/getopt.h>
+# include <iprt/initterm.h>
+# include <iprt/path.h>
+# include <iprt/message.h>
+# include <iprt/process.h>
+# include <iprt/string.h>
+
+# include "VBoxDTraceLibCWrappers.h"
+
+# ifdef _MSC_VER
+# pragma warning(disable:4267) /* size_t conversion warnings */
+# pragma warning(disable:4018) /* signed/unsigned mismatch */
+# endif
+#endif
+
+typedef struct dtrace_cmd {
+ void (*dc_func)(struct dtrace_cmd *); /* function to compile arg */
+ dtrace_probespec_t dc_spec; /* probe specifier context */
+ char *dc_arg; /* argument from main argv */
+ const char *dc_name; /* name for error messages */
+ const char *dc_desc; /* desc for error messages */
+ dtrace_prog_t *dc_prog; /* program compiled from arg */
+ char dc_ofile[PATH_MAX]; /* derived output file name */
+} dtrace_cmd_t;
+
+#define DMODE_VERS 0 /* display version information and exit (-V) */
+#define DMODE_EXEC 1 /* compile program for enabling (-a/e/E) */
+#define DMODE_ANON 2 /* compile program for anonymous tracing (-A) */
+#define DMODE_LINK 3 /* compile program for linking with ELF (-G) */
+#define DMODE_LIST 4 /* compile program and list probes (-l) */
+#define DMODE_HEADER 5 /* compile program for headergen (-h) */
+
+#define E_SUCCESS 0
+#define E_ERROR 1
+#define E_USAGE 2
+
+#ifndef VBOX
+static const char DTRACE_OPTSTR[] =
+ "3:6:aAb:Bc:CD:ef:FGhHi:I:lL:m:n:o:p:P:qs:SU:vVwx:X:Z";
+#else
+static const RTGETOPTDEF g_aOptions[] =
+{
+ { "-32", 10064, RTGETOPT_REQ_NOTHING },
+ { "-64", 10032, RTGETOPT_REQ_NOTHING },
+ { NULL, 'a', RTGETOPT_REQ_NOTHING },
+ { NULL, 'A', RTGETOPT_REQ_NOTHING },
+ { NULL, 'b', RTGETOPT_REQ_STRING },
+ { NULL, 'B', RTGETOPT_REQ_NOTHING },
+ { NULL, 'c', RTGETOPT_REQ_STRING },
+ { NULL, 'C', RTGETOPT_REQ_NOTHING },
+ { NULL, 'D', RTGETOPT_REQ_STRING },
+ { NULL, 'e', RTGETOPT_REQ_NOTHING },
+ { NULL, 'f', RTGETOPT_REQ_STRING },
+ { NULL, 'F', RTGETOPT_REQ_NOTHING },
+ { NULL, 'G', RTGETOPT_REQ_NOTHING },
+ { NULL, 'h', RTGETOPT_REQ_NOTHING },
+ { NULL, 'H', RTGETOPT_REQ_NOTHING },
+ { NULL, 'i', RTGETOPT_REQ_STRING },
+ { NULL, 'I', RTGETOPT_REQ_STRING },
+ { NULL, 'l', RTGETOPT_REQ_NOTHING },
+ { NULL, 'L', RTGETOPT_REQ_STRING },
+ { NULL, 'M', RTGETOPT_REQ_STRING },
+ { NULL, 'n', RTGETOPT_REQ_STRING },
+ { NULL, 'o', RTGETOPT_REQ_STRING },
+ { NULL, 'p', RTGETOPT_REQ_STRING },
+ { NULL, 'P', RTGETOPT_REQ_STRING },
+ { NULL, 'q', RTGETOPT_REQ_NOTHING },
+ { NULL, 's', RTGETOPT_REQ_STRING },
+ { NULL, 'S', RTGETOPT_REQ_NOTHING },
+ { NULL, 'U', RTGETOPT_REQ_STRING },
+ { NULL, 'v', RTGETOPT_REQ_NOTHING },
+ { NULL, 'V', RTGETOPT_REQ_NOTHING },
+ { NULL, 'w', RTGETOPT_REQ_NOTHING },
+ { NULL, 'x', RTGETOPT_REQ_STRING },
+ { NULL, 'X', RTGETOPT_REQ_STRING },
+ { NULL, 'Z', RTGETOPT_REQ_NOTHING },
+};
+#endif /* VBOX */
+
+
+static char **g_argv;
+static int g_argc;
+#ifndef VBOX /* No linking. */
+static char **g_objv;
+static int g_objc;
+#endif
+static dtrace_cmd_t *g_cmdv;
+static int g_cmdc;
+static struct ps_prochandle **g_psv;
+static int g_psc;
+static int g_pslive;
+static char *g_pname;
+static int g_quiet;
+static int g_flowindent;
+#ifdef VBOX /* Added volatile to signal handler variables. */
+static int volatile g_intr;
+static int volatile g_impatient;
+static int volatile g_newline;
+#else
+static int g_intr;
+static int g_impatient;
+static int g_newline;
+#endif
+static int g_total;
+static int g_cflags;
+static int g_oflags;
+static int g_verbose;
+static int g_exec = 1;
+static int g_mode = DMODE_EXEC;
+static int g_status = E_SUCCESS;
+static int g_grabanon = 0;
+static const char *g_ofile = NULL;
+#ifndef VBOX /* stdout isn't a necessarily constant usable like this in C code. */
+static FILE *g_ofp = stdout;
+#else
+static FILE *g_ofp = NULL;
+#endif
+static dtrace_hdl_t *g_dtp;
+static char *g_etcfile = "/etc/system";
+static const char *g_etcbegin = "* vvvv Added by DTrace";
+static const char *g_etcend = "* ^^^^ Added by DTrace";
+
+static const char *g_etc[] = {
+"*",
+"* The following forceload directives were added by dtrace(1M) to allow for",
+"* tracing during boot. If these directives are removed, the system will",
+"* continue to function, but tracing will not occur during boot as desired.",
+"* To remove these directives (and this block comment) automatically, run",
+"* \"dtrace -A\" without additional arguments. See the \"Anonymous Tracing\"",
+"* chapter of the Solaris Dynamic Tracing Guide for details.",
+"*",
+NULL };
+
+static int
+usage(FILE *fp)
+{
+ static const char predact[] = "[[ predicate ] action ]";
+
+ (void) fprintf(fp, "Usage: %s [-32|-64] [-aACeFGhHlqSvVwZ] "
+ "[-b bufsz] [-c cmd] [-D name[=def]]\n\t[-I path] [-L path] "
+ "[-o output] [-p pid] [-s script] [-U name]\n\t"
+ "[-x opt[=val]] [-X a|c|s|t]\n\n"
+ "\t[-P provider %s]\n"
+ "\t[-m [ provider: ] module %s]\n"
+ "\t[-f [[ provider: ] module: ] func %s]\n"
+ "\t[-n [[[ provider: ] module: ] func: ] name %s]\n"
+ "\t[-i probe-id %s] [ args ... ]\n\n", g_pname,
+ predact, predact, predact, predact, predact);
+
+ (void) fputs(
+ "\tpredicate -> '/' D-expression '/'\n"
+ "\t action -> '{' D-statements '}'\n", fp);
+
+ (void) fputs(
+ "\n"
+ "\t-32 generate 32-bit D programs and ELF files\n"
+ "\t-64 generate 64-bit D programs and ELF files\n\n"
+ "\t-a claim anonymous tracing state\n"
+ "\t-A generate driver.conf(4) directives for anonymous tracing\n"
+ "\t-b set trace buffer size\n"
+ "\t-c run specified command and exit upon its completion\n", fp);
+ (void) fputs(
+ "\t-C run cpp(1) preprocessor on script files\n"
+ "\t-D define symbol when invoking preprocessor\n"
+ "\t-e exit after compiling request but prior to enabling probes\n"
+ "\t-f enable or list probes matching the specified function name\n"
+ "\t-F coalesce trace output by function\n", fp);
+ (void) fputs(
+ "\t-G generate an ELF file containing embedded dtrace program\n"
+ "\t-h generate a header file with definitions for static probes\n"
+ "\t-H print included files when invoking preprocessor\n"
+ "\t-i enable or list probes matching the specified probe id\n"
+ "\t-I add include directory to preprocessor search path\n"
+ "\t-l list probes matching specified criteria\n", fp);
+ (void) fputs(
+ "\t-L add library directory to library search path\n"
+ "\t-m enable or list probes matching the specified module name\n"
+ "\t-n enable or list probes matching the specified probe name\n"
+ "\t-o set output file\n"
+ "\t-p grab specified process-ID and cache its symbol tables\n"
+ "\t-P enable or list probes matching the specified provider name\n", fp);
+ (void) fputs(
+ "\t-q set quiet mode (only output explicitly traced data)\n"
+ "\t-s enable or list probes according to the specified D script\n"
+ "\t-S print D compiler intermediate code\n"
+ "\t-U undefine symbol when invoking preprocessor\n"
+ "\t-v set verbose mode (report stability attributes, arguments)\n", fp);
+ (void) fputs(
+ "\t-V report DTrace API version\n"
+ "\t-w permit destructive actions\n"
+ "\t-x enable or modify compiler and tracing options\n"
+ "\t-X specify ISO C conformance settings for preprocessor\n"
+ "\t-Z permit probe descriptions that match zero probes\n", fp);
+
+ return (E_USAGE);
+}
+
+static void
+verror(const char *fmt, va_list ap)
+{
+ int error = errno;
+
+ (void) fprintf(stderr, "%s: ", g_pname);
+ (void) vfprintf(stderr, fmt, ap);
+
+ if (fmt[strlen(fmt) - 1] != '\n')
+ (void) fprintf(stderr, ": %s\n", strerror(error));
+}
+
+/*PRINTFLIKE1*/
+static void
+fatal(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ verror(fmt, ap);
+ va_end(ap);
+
+ exit(E_ERROR);
+}
+
+/*PRINTFLIKE1*/
+static void
+dfatal(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ (void) fprintf(stderr, "%s: ", g_pname);
+ if (fmt != NULL)
+ (void) vfprintf(stderr, fmt, ap);
+
+ va_end(ap);
+
+ if (fmt != NULL && fmt[strlen(fmt) - 1] != '\n') {
+ (void) fprintf(stderr, ": %s\n",
+ dtrace_errmsg(g_dtp, dtrace_errno(g_dtp)));
+ } else if (fmt == NULL) {
+ (void) fprintf(stderr, "%s\n",
+ dtrace_errmsg(g_dtp, dtrace_errno(g_dtp)));
+ }
+
+ /*
+ * Close the DTrace handle to ensure that any controlled processes are
+ * correctly restored and continued.
+ */
+ dtrace_close(g_dtp);
+
+ exit(E_ERROR);
+}
+
+/*PRINTFLIKE1*/
+static void
+error(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ verror(fmt, ap);
+ va_end(ap);
+}
+
+/*PRINTFLIKE1*/
+static void
+notice(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (g_quiet)
+ return; /* -q or quiet pragma suppresses notice()s */
+
+ va_start(ap, fmt);
+ verror(fmt, ap);
+ va_end(ap);
+}
+
+/*PRINTFLIKE1*/
+static void
+oprintf(const char *fmt, ...)
+{
+ va_list ap;
+ int n;
+
+ if (g_ofp == NULL)
+ return;
+
+ va_start(ap, fmt);
+ n = vfprintf(g_ofp, fmt, ap);
+ va_end(ap);
+
+ if (n < 0) {
+ if (errno != EINTR) {
+ fatal("failed to write to %s",
+ g_ofile ? g_ofile : "<stdout>");
+ }
+ clearerr(g_ofp);
+ }
+}
+
+#ifndef VBOX
+static char **
+make_argv(char *s)
+{
+ const char *ws = "\f\n\r\t\v ";
+ char **argv = malloc(sizeof (char *) * (strlen(s) / 2 + 1));
+ int argc = 0;
+ char *p = s;
+
+ if (argv == NULL)
+ return (NULL);
+
+ for (p = strtok(s, ws); p != NULL; p = strtok(NULL, ws))
+ argv[argc++] = p;
+
+ if (argc == 0)
+ argv[argc++] = s;
+
+ argv[argc] = NULL;
+ return (argv);
+}
+#endif /* !VBOX */
+
+static void
+dof_prune(const char *fname)
+{
+ struct stat sbuf;
+ size_t sz, i, j, mark, len;
+ char *buf;
+ int msg = 0, fd;
+
+ if ((fd = open(fname, O_RDONLY)) == -1) {
+ /*
+ * This is okay only if the file doesn't exist at all.
+ */
+ if (errno != ENOENT)
+ fatal("failed to open %s", fname);
+ return;
+ }
+
+ if (fstat(fd, &sbuf) == -1)
+ fatal("failed to fstat %s", fname);
+
+ if ((buf = malloc((sz = sbuf.st_size) + 1)) == NULL)
+ fatal("failed to allocate memory for %s", fname);
+
+ if ((size_t/*vbox*/)read(fd, buf, sz) != sz)
+ fatal("failed to read %s", fname);
+
+ buf[sz] = '\0';
+ (void) close(fd);
+
+ if ((fd = open(fname, O_WRONLY | O_TRUNC)) == -1)
+ fatal("failed to open %s for writing", fname);
+
+ len = strlen("dof-data-");
+
+ for (mark = 0, i = 0; i < sz; i++) {
+ if (strncmp(&buf[i], "dof-data-", len) != 0)
+ continue;
+
+ /*
+ * This is only a match if it's in the 0th column.
+ */
+ if (i != 0 && buf[i - 1] != '\n')
+ continue;
+
+ if (msg++ == 0) {
+ error("cleaned up old anonymous "
+ "enabling in %s\n", fname);
+ }
+
+ /*
+ * We have a match. First write out our data up until now.
+ */
+ if (i != mark) {
+ if ((size_t/*vbox*/)write(fd, &buf[mark], i - mark) != i - mark)
+ fatal("failed to write to %s", fname);
+ }
+
+ /*
+ * Now scan forward until we scan past a newline.
+ */
+ for (j = i; j < sz && buf[j] != '\n'; j++)
+ continue;
+
+ /*
+ * Reset our mark.
+ */
+ if ((mark = j + 1) >= sz)
+ break;
+
+ i = j;
+ }
+
+ if (mark < sz) {
+ if ((size_t/*vbox*/)write(fd, &buf[mark], sz - mark) != sz - mark)
+ fatal("failed to write to %s", fname);
+ }
+
+ (void) close(fd);
+ free(buf);
+}
+
+static void
+etcsystem_prune(void)
+{
+ struct stat sbuf;
+ size_t sz;
+ char *buf, *start, *end;
+ int fd;
+ char *fname = g_etcfile, *tmpname;
+
+ if ((fd = open(fname, O_RDONLY)) == -1)
+ fatal("failed to open %s", fname);
+
+ if (fstat(fd, &sbuf) == -1)
+ fatal("failed to fstat %s", fname);
+
+ if ((buf = malloc((sz = sbuf.st_size) + 1)) == NULL)
+ fatal("failed to allocate memory for %s", fname);
+
+ if ((size_t/*vbox*/)read(fd, buf, sz) != sz)
+ fatal("failed to read %s", fname);
+
+ buf[sz] = '\0';
+ (void) close(fd);
+
+ if ((start = strstr(buf, g_etcbegin)) == NULL)
+ goto out;
+
+ if (strlen(buf) != sz) {
+ fatal("embedded nul byte in %s; manual repair of %s "
+ "required\n", fname, fname);
+ }
+
+ if (strstr(start + 1, g_etcbegin) != NULL) {
+ fatal("multiple start sentinels in %s; manual repair of %s "
+ "required\n", fname, fname);
+ }
+
+ if ((end = strstr(buf, g_etcend)) == NULL) {
+ fatal("missing end sentinel in %s; manual repair of %s "
+ "required\n", fname, fname);
+ }
+
+ if (start > end) {
+ fatal("end sentinel preceeds start sentinel in %s; manual "
+ "repair of %s required\n", fname, fname);
+ }
+
+ end += strlen(g_etcend) + 1;
+ bcopy(end, start, strlen(end) + 1);
+
+ tmpname = alloca(sz = strlen(fname) + 80);
+ (void) snprintf(tmpname, sz, "%s.dtrace.%d", fname, getpid());
+
+ if ((fd = open(tmpname,
+ O_WRONLY | O_CREAT | O_EXCL, sbuf.st_mode)) == -1)
+ fatal("failed to create %s", tmpname);
+
+ if (write(fd, buf, strlen(buf)) < (ssize_t/*vbox*/)strlen(buf)) {
+ (void) unlink(tmpname);
+ fatal("failed to write to %s", tmpname);
+ }
+
+ (void) close(fd);
+
+#ifndef _MSC_VER
+ if (chown(tmpname, sbuf.st_uid, sbuf.st_gid) != 0) {
+ (void) unlink(tmpname);
+ fatal("failed to chown(2) %s to uid %d, gid %d", tmpname,
+ (int)sbuf.st_uid, (int)sbuf.st_gid);
+ }
+#endif
+
+ if (rename(tmpname, fname) == -1)
+ fatal("rename of %s to %s failed", tmpname, fname);
+
+ error("cleaned up forceload directives in %s\n", fname);
+out:
+ free(buf);
+}
+
+static void
+etcsystem_add(void)
+{
+ const char *mods[20];
+ int nmods, line;
+
+ if ((g_ofp = fopen(g_ofile = g_etcfile, "a")) == NULL)
+ fatal("failed to open output file '%s'", g_ofile);
+
+ oprintf("%s\n", g_etcbegin);
+
+ for (line = 0; g_etc[line] != NULL; line++)
+ oprintf("%s\n", g_etc[line]);
+
+ nmods = dtrace_provider_modules(g_dtp, mods,
+ sizeof (mods) / sizeof (char *) - 1);
+
+ if (nmods >= sizeof (mods) / sizeof (char *))
+ fatal("unexpectedly large number of modules!");
+
+ mods[nmods++] = "dtrace";
+
+ for (line = 0; line < nmods; line++)
+ oprintf("forceload: drv/%s\n", mods[line]);
+
+ oprintf("%s\n", g_etcend);
+
+ if (fclose(g_ofp) == EOF)
+ fatal("failed to close output file '%s'", g_ofile);
+
+ error("added forceload directives to %s\n", g_ofile);
+}
+
+static void
+print_probe_info(const dtrace_probeinfo_t *p)
+{
+ char buf[BUFSIZ];
+ int i;
+
+ oprintf("\n\tProbe Description Attributes\n");
+
+ oprintf("\t\tIdentifier Names: %s\n",
+ dtrace_stability_name(p->dtp_attr.dtat_name));
+ oprintf("\t\tData Semantics: %s\n",
+ dtrace_stability_name(p->dtp_attr.dtat_data));
+ oprintf("\t\tDependency Class: %s\n",
+ dtrace_class_name(p->dtp_attr.dtat_class));
+
+ oprintf("\n\tArgument Attributes\n");
+
+ oprintf("\t\tIdentifier Names: %s\n",
+ dtrace_stability_name(p->dtp_arga.dtat_name));
+ oprintf("\t\tData Semantics: %s\n",
+ dtrace_stability_name(p->dtp_arga.dtat_data));
+ oprintf("\t\tDependency Class: %s\n",
+ dtrace_class_name(p->dtp_arga.dtat_class));
+
+ oprintf("\n\tArgument Types\n");
+
+ for (i = 0; i < p->dtp_argc; i++) {
+ 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);
+ }
+
+ if (p->dtp_argc == 0)
+ oprintf("\t\tNone\n");
+
+ oprintf("\n");
+}
+
+/*ARGSUSED*/
+static int
+info_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
+ dtrace_stmtdesc_t *stp, dtrace_ecbdesc_t **last)
+{
+ dtrace_ecbdesc_t *edp = stp->dtsd_ecbdesc;
+ dtrace_probedesc_t *pdp = &edp->dted_probe;
+ dtrace_probeinfo_t p;
+ RT_NOREF1(pgp);
+
+ if (edp == *last)
+ return (0);
+
+ oprintf("\n%s:%s:%s:%s\n",
+ pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name);
+
+ if (dtrace_probe_info(dtp, pdp, &p) == 0)
+ print_probe_info(&p);
+
+ *last = edp;
+ return (0);
+}
+
+/*
+ * Execute the specified program by enabling the corresponding instrumentation.
+ * If -e has been specified, we get the program info but do not enable it. If
+ * -v has been specified, we print a stability report for the program.
+ */
+static void
+exec_prog(const dtrace_cmd_t *dcp)
+{
+ dtrace_ecbdesc_t *last = NULL;
+ dtrace_proginfo_t dpi;
+
+ if (!g_exec) {
+ dtrace_program_info(g_dtp, dcp->dc_prog, &dpi);
+ } else if (dtrace_program_exec(g_dtp, dcp->dc_prog, &dpi) == -1) {
+ dfatal("failed to enable '%s'", dcp->dc_name);
+ } else {
+ notice("%s '%s' matched %u probe%s\n",
+ dcp->dc_desc, dcp->dc_name,
+ dpi.dpi_matches, dpi.dpi_matches == 1 ? "" : "s");
+ }
+
+ if (g_verbose) {
+ oprintf("\nStability attributes for %s %s:\n",
+ dcp->dc_desc, dcp->dc_name);
+
+ oprintf("\n\tMinimum Probe Description Attributes\n");
+ oprintf("\t\tIdentifier Names: %s\n",
+ dtrace_stability_name(dpi.dpi_descattr.dtat_name));
+ oprintf("\t\tData Semantics: %s\n",
+ dtrace_stability_name(dpi.dpi_descattr.dtat_data));
+ oprintf("\t\tDependency Class: %s\n",
+ dtrace_class_name(dpi.dpi_descattr.dtat_class));
+
+ oprintf("\n\tMinimum Statement Attributes\n");
+
+ oprintf("\t\tIdentifier Names: %s\n",
+ dtrace_stability_name(dpi.dpi_stmtattr.dtat_name));
+ oprintf("\t\tData Semantics: %s\n",
+ dtrace_stability_name(dpi.dpi_stmtattr.dtat_data));
+ oprintf("\t\tDependency Class: %s\n",
+ dtrace_class_name(dpi.dpi_stmtattr.dtat_class));
+
+ if (!g_exec) {
+ (void) dtrace_stmt_iter(g_dtp, dcp->dc_prog,
+ (dtrace_stmt_f *)info_stmt, &last);
+ } else
+ oprintf("\n");
+ }
+
+ g_total += dpi.dpi_matches;
+}
+
+/*
+ * Print out the specified DOF buffer as a set of ASCII bytes appropriate for
+ * storing in a driver.conf(4) file associated with the dtrace driver.
+ */
+static void
+anon_prog(const dtrace_cmd_t *dcp, dof_hdr_t *dof, int n)
+{
+ const uchar_t *p, *q;
+
+ if (dof == NULL)
+ dfatal("failed to create DOF image for '%s'", dcp->dc_name);
+
+ p = (uchar_t *)dof;
+ q = p + dof->dofh_loadsz;
+
+ oprintf("dof-data-%d=0x%x", n, *p++);
+
+ while (p < q)
+ oprintf(",0x%x", *p++);
+
+ oprintf(";\n");
+ dtrace_dof_destroy(g_dtp, dof);
+}
+
+#ifndef VBOX
+/*
+ * Link the specified D program in DOF form into an ELF file for use in either
+ * helpers, userland provider definitions, or both. If -o was specified, that
+ * path is used as the output file name. If -o wasn't specified and the input
+ * program is from a script whose name is %.d, use basename(%.o) as the output
+ * file name. Otherwise we use "d.out" as the default output file name.
+ */
+static void
+link_prog(dtrace_cmd_t *dcp)
+{
+ char *p;
+
+ if (g_cmdc == 1 && g_ofile != NULL) {
+ (void) strlcpy(dcp->dc_ofile, g_ofile, sizeof (dcp->dc_ofile));
+ } else if ((p = strrchr(dcp->dc_arg, '.')) != NULL &&
+ strcmp(p, ".d") == 0) {
+ p[0] = '\0'; /* strip .d suffix */
+ (void) snprintf(dcp->dc_ofile, sizeof (dcp->dc_ofile),
+ "%s.o", basename(dcp->dc_arg));
+ } else {
+ (void) snprintf(dcp->dc_ofile, sizeof (dcp->dc_ofile),
+ g_cmdc > 1 ? "%s.%d" : "%s", "d.out", (int)(dcp - g_cmdv));
+ }
+
+ if (dtrace_program_link(g_dtp, dcp->dc_prog, DTRACE_D_PROBES,
+ dcp->dc_ofile, g_objc, g_objv) != 0)
+ dfatal("failed to link %s %s", dcp->dc_desc, dcp->dc_name);
+}
+#endif /* !VBOX */
+
+/*ARGSUSED*/
+static int
+list_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
+{
+ dtrace_probeinfo_t p;
+ RT_NOREF1(arg);
+
+ oprintf("%5d %10s %17s %33s %s\n", pdp->dtpd_id,
+ pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name);
+
+ if (g_verbose && dtrace_probe_info(dtp, pdp, &p) == 0)
+ print_probe_info(&p);
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+list_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
+ dtrace_stmtdesc_t *stp, dtrace_ecbdesc_t **last)
+{
+ dtrace_ecbdesc_t *edp = stp->dtsd_ecbdesc;
+ RT_NOREF1(pgp);
+
+ if (edp == *last)
+ return (0);
+
+ if (dtrace_probe_iter(g_dtp, &edp->dted_probe, list_probe, NULL) != 0) {
+ error("failed to match %s:%s:%s:%s: %s\n",
+ edp->dted_probe.dtpd_provider, edp->dted_probe.dtpd_mod,
+ edp->dted_probe.dtpd_func, edp->dted_probe.dtpd_name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ *last = edp;
+ return (0);
+}
+
+/*
+ * List the probes corresponding to the specified program by iterating over
+ * each statement and then matching probes to the statement probe descriptions.
+ */
+static void
+list_prog(const dtrace_cmd_t *dcp)
+{
+ dtrace_ecbdesc_t *last = NULL;
+
+ (void) dtrace_stmt_iter(g_dtp, dcp->dc_prog,
+ (dtrace_stmt_f *)list_stmt, &last);
+}
+
+static void
+compile_file(dtrace_cmd_t *dcp)
+{
+ char *arg0;
+ FILE *fp;
+
+ if ((fp = fopen(dcp->dc_arg, "r")) == NULL)
+ fatal("failed to open %s", dcp->dc_arg);
+
+ arg0 = g_argv[0];
+ g_argv[0] = dcp->dc_arg;
+
+ if ((dcp->dc_prog = dtrace_program_fcompile(g_dtp, fp,
+ g_cflags, g_argc, g_argv)) == NULL)
+ dfatal("failed to compile script %s", dcp->dc_arg);
+
+ g_argv[0] = arg0;
+ (void) fclose(fp);
+
+ dcp->dc_desc = "script";
+ dcp->dc_name = dcp->dc_arg;
+}
+
+static void
+compile_str(dtrace_cmd_t *dcp)
+{
+ char *p;
+
+ if ((dcp->dc_prog = dtrace_program_strcompile(g_dtp, dcp->dc_arg,
+ dcp->dc_spec, g_cflags | DTRACE_C_PSPEC, g_argc, g_argv)) == NULL)
+ dfatal("invalid probe specifier %s", dcp->dc_arg);
+
+ if ((p = strpbrk(dcp->dc_arg, "{/;")) != NULL)
+ *p = '\0'; /* crop name for reporting */
+
+ dcp->dc_desc = "description";
+ dcp->dc_name = dcp->dc_arg;
+}
+
+/*ARGSUSED*/
+static void
+prochandler(struct ps_prochandle *P, const char *msg, void *arg)
+{
+#ifndef VBOX
+ const psinfo_t *prp = Ppsinfo(P);
+ int pid = Pstatus(P)->pr_pid;
+ char name[SIG2STR_MAX];
+
+ if (msg != NULL) {
+ notice("pid %d: %s\n", pid, msg);
+ return;
+ }
+
+ switch (Pstate(P)) {
+ case PS_UNDEAD:
+ /*
+ * Ideally we would like to always report pr_wstat here, but it
+ * isn't possible given current /proc semantics. If we grabbed
+ * the process, Ppsinfo() will either fail or return a zeroed
+ * psinfo_t depending on how far the parent is in reaping it.
+ * When /proc provides a stable pr_wstat in the status file,
+ * this code can be improved by examining this new pr_wstat.
+ */
+ if (prp != NULL && WIFSIGNALED(prp->pr_wstat)) {
+ notice("pid %d terminated by %s\n", pid,
+ proc_signame(WTERMSIG(prp->pr_wstat),
+ name, sizeof (name)));
+ } else if (prp != NULL && WEXITSTATUS(prp->pr_wstat) != 0) {
+ notice("pid %d exited with status %d\n",
+ pid, WEXITSTATUS(prp->pr_wstat));
+ } else {
+ notice("pid %d has exited\n", pid);
+ }
+ g_pslive--;
+ break;
+
+ case PS_LOST:
+ notice("pid %d exec'd a set-id or unobservable program\n", pid);
+ g_pslive--;
+ break;
+ }
+#else
+ RT_NOREF3(P, msg, arg);
+#endif /* VBOX */
+}
+
+/*ARGSUSED*/
+static int
+errhandler(const dtrace_errdata_t *data, void *arg)
+{
+ RT_NOREF1(arg);
+ error(data->dteda_msg);
+ return (DTRACE_HANDLE_OK);
+}
+
+/*ARGSUSED*/
+static int
+drophandler(const dtrace_dropdata_t *data, void *arg)
+{
+ RT_NOREF1(arg);
+ error(data->dtdda_msg);
+ return (DTRACE_HANDLE_OK);
+}
+
+/*ARGSUSED*/
+static int
+setopthandler(const dtrace_setoptdata_t *data, void *arg)
+{
+ RT_NOREF1(arg);
+ if (strcmp(data->dtsda_option, "quiet") == 0)
+ g_quiet = data->dtsda_newval != DTRACEOPT_UNSET;
+
+ if (strcmp(data->dtsda_option, "flowindent") == 0)
+ g_flowindent = data->dtsda_newval != DTRACEOPT_UNSET;
+
+ return (DTRACE_HANDLE_OK);
+}
+
+#define BUFDUMPHDR(hdr) \
+ (void) printf("%s: %s%s\n", g_pname, hdr, strlen(hdr) > 0 ? ":" : "");
+
+#ifdef VBOX /* The orignal upsets VC++ 14.1 with variable 'c' shadowing variable in the function.
+ * This version is faster and does not try to print '\0' as that doesn't look like it's intentional */
+#define BUFDUMPSTR(ptr, field) do { \
+ const char *pszField = (ptr)->field; \
+ if (pszField) { \
+ const char *pszStart = pszField; \
+ char ch; \
+ printf("%s: %20s => \"", g_pname, #field); \
+ while ((ch = *pszField) != '\0') { \
+ if (ch != '\n') \
+ pszField++; \
+ else { \
+ printf("%*.*s\\n", (int)(pszField - pszStart), \
+ (int)(pszField - pszStart), pszStart); \
+ pszStart = ++pszField; \
+ } \
+ } \
+ printf("%*.*s\"", (int)(pszField - pszStart), \
+ (int)(pszField - pszStart), pszStart); \
+ } else { \
+ printf("%s: %20s => <NULL>\n", g_pname, #field); \
+ } \
+} while (0)
+#else
+#define BUFDUMPSTR(ptr, field) \
+ (void) printf("%s: %20s => ", g_pname, #field); \
+ if ((ptr)->field != NULL) { \
+ const char *c = (ptr)->field; \
+ (void) printf("\""); \
+ do { \
+ if (*c == '\n') { \
+ (void) printf("\\n"); \
+ continue; \
+ } \
+ \
+ (void) printf("%c", *c); \
+ } while (*c++ != '\0'); \
+ (void) printf("\"\n"); \
+ } else { \
+ (void) printf("<NULL>\n"); \
+ }
+#endif
+
+#define BUFDUMPASSTR(ptr, field, str) \
+ (void) printf("%s: %20s => %s\n", g_pname, #field, str);
+
+#define BUFDUMP(ptr, field) \
+ (void) printf("%s: %20s => %lld\n", g_pname, #field, \
+ (long long)(ptr)->field);
+
+#define BUFDUMPPTR(ptr, field) \
+ (void) printf("%s: %20s => %s\n", g_pname, #field, \
+ (ptr)->field != NULL ? "<non-NULL>" : "<NULL>");
+
+/*ARGSUSED*/
+static int
+bufhandler(const dtrace_bufdata_t *bufdata, void *arg)
+{
+ const dtrace_aggdata_t *agg = bufdata->dtbda_aggdata;
+ const dtrace_recdesc_t *rec = bufdata->dtbda_recdesc;
+ const dtrace_probedesc_t *pd;
+ uint32_t flags = bufdata->dtbda_flags;
+ char buf[512], *c = buf, *end = c + sizeof (buf);
+ int i, printed;
+
+ struct {
+ const char *name;
+ uint32_t value;
+ } flagnames[] = {
+ { "AGGVAL", DTRACE_BUFDATA_AGGVAL },
+ { "AGGKEY", DTRACE_BUFDATA_AGGKEY },
+ { "AGGFORMAT", DTRACE_BUFDATA_AGGFORMAT },
+ { "AGGLAST", DTRACE_BUFDATA_AGGLAST },
+ { "???", UINT32_MAX },
+ { NULL }
+ };
+ RT_NOREF1(arg);
+
+ if (bufdata->dtbda_probe != NULL) {
+ pd = bufdata->dtbda_probe->dtpda_pdesc;
+ } else if (agg != NULL) {
+ pd = agg->dtada_pdesc;
+ } else {
+ pd = NULL;
+ }
+
+ BUFDUMPHDR(">>> Called buffer handler");
+ BUFDUMPHDR("");
+
+ BUFDUMPHDR(" dtrace_bufdata");
+ BUFDUMPSTR(bufdata, dtbda_buffered);
+ BUFDUMPPTR(bufdata, dtbda_probe);
+ BUFDUMPPTR(bufdata, dtbda_aggdata);
+ BUFDUMPPTR(bufdata, dtbda_recdesc);
+
+ (void) snprintf(c, end - c, "0x%x ", bufdata->dtbda_flags);
+ c += strlen(c);
+
+ for (i = 0, printed = 0; flagnames[i].name != NULL; i++) {
+ if (!(flags & flagnames[i].value))
+ continue;
+
+ (void) snprintf(c, end - c,
+ "%s%s", printed++ ? " | " : "(", flagnames[i].name);
+ c += strlen(c);
+ flags &= ~flagnames[i].value;
+ }
+
+ if (printed)
+ (void) snprintf(c, end - c, ")");
+
+ BUFDUMPASSTR(bufdata, dtbda_flags, buf);
+ BUFDUMPHDR("");
+
+ if (pd != NULL) {
+ BUFDUMPHDR(" dtrace_probedesc");
+ BUFDUMPSTR(pd, dtpd_provider);
+ BUFDUMPSTR(pd, dtpd_mod);
+ BUFDUMPSTR(pd, dtpd_func);
+ BUFDUMPSTR(pd, dtpd_name);
+ BUFDUMPHDR("");
+ }
+
+ if (rec != NULL) {
+ BUFDUMPHDR(" dtrace_recdesc");
+ BUFDUMP(rec, dtrd_action);
+ BUFDUMP(rec, dtrd_size);
+
+ if (agg != NULL) {
+ uint8_t *data;
+ int lim = rec->dtrd_size;
+
+ (void) sprintf(buf, "%d (data: ", rec->dtrd_offset);
+ c = buf + strlen(buf);
+
+ if (lim > sizeof (uint64_t))
+ lim = sizeof (uint64_t);
+
+ data = (uint8_t *)agg->dtada_data + rec->dtrd_offset;
+
+ for (i = 0; i < lim; i++) {
+ (void) snprintf(c, end - c, "%s%02x",
+ i == 0 ? "" : " ", *data++);
+ c += strlen(c);
+ }
+
+ (void) snprintf(c, end - c,
+ "%s)", lim < rec->dtrd_size ? " ..." : "");
+ BUFDUMPASSTR(rec, dtrd_offset, buf);
+ } else {
+ BUFDUMP(rec, dtrd_offset);
+ }
+
+ BUFDUMPHDR("");
+ }
+
+ if (agg != NULL) {
+ dtrace_aggdesc_t *desc = agg->dtada_desc;
+
+ BUFDUMPHDR(" dtrace_aggdesc");
+ BUFDUMPSTR(desc, dtagd_name);
+ BUFDUMP(desc, dtagd_varid);
+ BUFDUMP(desc, dtagd_id);
+ BUFDUMP(desc, dtagd_nrecs);
+ BUFDUMPHDR("");
+ }
+
+ return (DTRACE_HANDLE_OK);
+}
+
+/*ARGSUSED*/
+static int
+chewrec(const dtrace_probedata_t *data, const dtrace_recdesc_t *rec, void *arg)
+{
+ dtrace_actkind_t act;
+ uintptr_t addr;
+ RT_NOREF1(arg);
+
+ if (rec == NULL) {
+ /*
+ * We have processed the final record; output the newline if
+ * we're not in quiet mode.
+ */
+ if (!g_quiet)
+ oprintf("\n");
+
+ return (DTRACE_CONSUME_NEXT);
+ }
+
+ act = rec->dtrd_action;
+ addr = (uintptr_t)data->dtpda_data;
+
+ if (act == DTRACEACT_EXIT) {
+ g_status = *((uint32_t *)addr);
+ return (DTRACE_CONSUME_NEXT);
+ }
+
+ return (DTRACE_CONSUME_THIS);
+}
+
+/*ARGSUSED*/
+static int
+chew(const dtrace_probedata_t *data, void *arg)
+{
+ dtrace_probedesc_t *pd = data->dtpda_pdesc;
+ processorid_t cpu = data->dtpda_cpu;
+ static int heading;
+ RT_NOREF1(arg);
+
+ if (g_impatient) {
+ g_newline = 0;
+ return (DTRACE_CONSUME_ABORT);
+ }
+
+ if (heading == 0) {
+ if (!g_flowindent) {
+ if (!g_quiet) {
+ oprintf("%3s %6s %32s\n",
+ "CPU", "ID", "FUNCTION:NAME");
+ }
+ } else {
+ oprintf("%3s %-41s\n", "CPU", "FUNCTION");
+ }
+ heading = 1;
+ }
+
+ if (!g_flowindent) {
+ if (!g_quiet) {
+ char name[DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 2];
+
+ (void) snprintf(name, sizeof (name), "%s:%s",
+ pd->dtpd_func, pd->dtpd_name);
+
+ oprintf("%3d %6d %32s ", cpu, pd->dtpd_id, name);
+ }
+ } else {
+ int indent = data->dtpda_indent;
+ char *name;
+ size_t len;
+
+ if (data->dtpda_flow == DTRACEFLOW_NONE) {
+ len = indent + DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 5;
+ name = alloca(len);
+ (void) snprintf(name, len, "%*s%s%s:%s", indent, "",
+ data->dtpda_prefix, pd->dtpd_func,
+ pd->dtpd_name);
+ } else {
+ len = indent + DTRACE_FUNCNAMELEN + 5;
+ name = alloca(len);
+ (void) snprintf(name, len, "%*s%s%s", indent, "",
+ data->dtpda_prefix, pd->dtpd_func);
+ }
+
+ oprintf("%3d %-41s ", cpu, name);
+ }
+
+ return (DTRACE_CONSUME_THIS);
+}
+
+static void
+go(void)
+{
+ int i;
+
+ struct {
+ char *name;
+ char *optname;
+ dtrace_optval_t val;
+ } bufs[] = {
+ { "buffer size", "bufsize" },
+ { "aggregation size", "aggsize" },
+ { "speculation size", "specsize" },
+ { "dynamic variable size", "dynvarsize" },
+ { NULL }
+ }, rates[] = {
+ { "cleaning rate", "cleanrate" },
+ { "status rate", "statusrate" },
+ { NULL }
+ };
+
+ for (i = 0; bufs[i].name != NULL; i++) {
+ if (dtrace_getopt(g_dtp, bufs[i].optname, &bufs[i].val) == -1)
+ fatal("couldn't get option %s", bufs[i].optname);
+ }
+
+ for (i = 0; rates[i].name != NULL; i++) {
+ if (dtrace_getopt(g_dtp, rates[i].optname, &rates[i].val) == -1)
+ fatal("couldn't get option %s", rates[i].optname);
+ }
+
+ if (dtrace_go(g_dtp) == -1)
+ dfatal("could not enable tracing");
+
+ for (i = 0; bufs[i].name != NULL; i++) {
+ dtrace_optval_t j = 0, mul = 10;
+ dtrace_optval_t nsize;
+
+ if (bufs[i].val == DTRACEOPT_UNSET)
+ continue;
+
+ (void) dtrace_getopt(g_dtp, bufs[i].optname, &nsize);
+
+ if (nsize == DTRACEOPT_UNSET || nsize == 0)
+ continue;
+
+ if (nsize >= bufs[i].val - sizeof (uint64_t))
+ continue;
+
+ for (; (INT64_C(1) << mul) <= nsize; j++, mul += 10)
+ continue;
+
+ if (!(nsize & ((INT64_C(1) << (mul - 10)) - 1))) {
+ error("%s lowered to %lld%c\n", bufs[i].name,
+ (long long)nsize >> (mul - 10), " kmgtpe"[j]);
+ } else {
+ error("%s lowered to %lld bytes\n", bufs[i].name,
+ (long long)nsize);
+ }
+ }
+
+ for (i = 0; rates[i].name != NULL; i++) {
+ dtrace_optval_t nval;
+ char *dir;
+
+ if (rates[i].val == DTRACEOPT_UNSET)
+ continue;
+
+ (void) dtrace_getopt(g_dtp, rates[i].optname, &nval);
+
+ if (nval == DTRACEOPT_UNSET || nval == 0)
+ continue;
+
+ if (rates[i].val == nval)
+ continue;
+
+ dir = nval > rates[i].val ? "reduced" : "increased";
+
+ if (nval <= NANOSEC && (NANOSEC % nval) == 0) {
+ error("%s %s to %lld hz\n", rates[i].name, dir,
+ (long long)NANOSEC / (long long)nval);
+ continue;
+ }
+
+ if ((nval % NANOSEC) == 0) {
+ error("%s %s to once every %lld seconds\n",
+ rates[i].name, dir,
+ (long long)nval / (long long)NANOSEC);
+ continue;
+ }
+
+ error("%s %s to once every %lld nanoseconds\n",
+ rates[i].name, dir, (long long)nval);
+ }
+}
+
+/*ARGSUSED*/
+static void
+intr(int signo)
+{
+ if (!g_intr)
+ g_newline = 1;
+
+ if (g_intr++)
+ g_impatient = 1;
+#ifdef _MSC_VER
+ /* Reinstall signal handler. Seems MSVCRT is System V style. */
+ signal(signo, intr);
+#else
+ RT_NOREF(signo);
+#endif
+}
+
+#ifdef VBOX
+DECLEXPORT(int) RTCALL VBoxDTraceMain(int argc, char **argv)
+#else
+int
+main(int argc, char *argv[])
+#endif
+{
+ dtrace_bufdesc_t buf;
+#ifndef _MSC_VER
+ struct sigaction act, oact;
+#endif
+ dtrace_status_t status[2];
+ dtrace_optval_t opt;
+ dtrace_cmd_t *dcp;
+
+ int done = 0, mode = 0;
+ int err, i;
+#ifndef VBOX
+ char c, *p, **v;
+ struct ps_prochandle *P;
+ pid_t pid;
+
+ g_pname = basename(argv[0]);
+#else
+ int c;
+ char *p;
+ RTGETOPTUNION ValueUnion;
+ RTGETOPTSTATE GetState;
+
+ err = RTR3InitDll(0);
+ if (RT_FAILURE(err))
+ return RTMsgInitFailure(err);
+ dtrace_init();
+
+ g_ofp = stdout;
+ g_pname = (char *)RTProcShortName();
+#endif
+
+ if (argc == 1)
+ return (usage(stderr));
+
+ if ((g_argv = malloc(sizeof (char *) * argc)) == NULL ||
+ (g_cmdv = malloc(sizeof (dtrace_cmd_t) * argc)) == NULL ||
+ (g_psv = malloc(sizeof (struct ps_prochandle *) * argc)) == NULL)
+ fatal("failed to allocate memory for arguments");
+
+ g_argv[g_argc++] = argv[0]; /* propagate argv[0] to D as $0/$$0 */
+ argv[0] = g_pname; /* rewrite argv[0] for getopt errors */
+
+ bzero(status, sizeof (status));
+ bzero(&buf, sizeof (buf));
+
+ /*
+ * Make an initial pass through argv[] processing any arguments that
+ * affect our behavior mode (g_mode) and flags used for dtrace_open().
+ * We also accumulate arguments that are not affiliated with getopt
+ * options into g_argv[], and abort if any invalid options are found.
+ */
+#ifndef VBOX
+ for (optind = 1; optind < argc; optind++) {
+ while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != EOF) {
+#else
+ RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, 0);
+ while ((c = RTGetOpt(&GetState, &ValueUnion))) {
+ {
+ /* const char *optarg = ValueUnion.psz; - unused */
+#endif
+ switch (c) {
+#ifndef VBOX
+ case '3':
+ if (strcmp(optarg, "2") != 0) {
+ (void) fprintf(stderr,
+ "%s: illegal option -- 3%s\n",
+ argv[0], optarg);
+ return (usage(stderr));
+ }
+#else
+ case 10032:
+#endif
+ g_oflags &= ~DTRACE_O_LP64;
+ g_oflags |= DTRACE_O_ILP32;
+ break;
+
+#ifndef VBOX
+ case '6':
+ if (strcmp(optarg, "4") != 0) {
+ (void) fprintf(stderr,
+ "%s: illegal option -- 6%s\n",
+ argv[0], optarg);
+ return (usage(stderr));
+ }
+#else
+ case 10064:
+#endif
+ g_oflags &= ~DTRACE_O_ILP32;
+ g_oflags |= DTRACE_O_LP64;
+ break;
+
+ case 'a':
+ g_grabanon++; /* also checked in pass 2 below */
+ break;
+
+ case 'A':
+ g_mode = DMODE_ANON;
+ g_exec = 0;
+ mode++;
+ break;
+
+ case 'e':
+ g_exec = 0;
+ done = 1;
+ break;
+
+ case 'h':
+ g_mode = DMODE_HEADER;
+ g_oflags |= DTRACE_O_NODEV;
+ g_cflags |= DTRACE_C_ZDEFS; /* -h implies -Z */
+ g_exec = 0;
+ mode++;
+ break;
+
+#ifndef VBOX
+ case 'G':
+ g_mode = DMODE_LINK;
+ g_oflags |= DTRACE_O_NODEV;
+ g_cflags |= DTRACE_C_ZDEFS; /* -G implies -Z */
+ g_exec = 0;
+ mode++;
+ break;
+#endif
+
+ case 'l':
+ g_mode = DMODE_LIST;
+ g_cflags |= DTRACE_C_ZDEFS; /* -l implies -Z */
+ mode++;
+ break;
+
+ case 'V':
+ g_mode = DMODE_VERS;
+ mode++;
+ break;
+
+#ifndef VBOX
+ default:
+ if (strchr(DTRACE_OPTSTR, c) == NULL)
+ return (usage(stderr));
+#else
+ case 'c':
+ case 'p':
+ case 'G':
+ fprintf(stderr, "%s: -%c is not supported\n", g_pname, c);
+ return (E_USAGE);
+
+ case VINF_GETOPT_NOT_OPTION:
+ g_argv[g_argc++] = (char *)ValueUnion.psz;
+ break;
+
+ default:
+ if (c < 0) { /* Note: Not all options are handled. */
+ RTGetOptPrintError(c, &ValueUnion);
+ return (usage(stderr));
+ }
+#endif
+ }
+ }
+
+#ifndef VBOX
+ if (optind < argc)
+ g_argv[g_argc++] = argv[optind];
+#endif
+ }
+
+ if (mode > 1) {
+ (void) fprintf(stderr, "%s: only one of the [-AGhlV] options "
+ "can be specified at a time\n", g_pname);
+ return (E_USAGE);
+ }
+
+ if (g_mode == DMODE_VERS)
+ return (printf("%s: %s\n", g_pname, _dtrace_version) <= 0);
+
+#ifndef VBOX
+ /*
+ * If we're in linker mode and the data model hasn't been specified,
+ * we try to guess the appropriate setting by examining the object
+ * files. We ignore certain errors since we'll catch them later when
+ * we actually process the object files.
+ */
+ if (g_mode == DMODE_LINK &&
+ (g_oflags & (DTRACE_O_ILP32 | DTRACE_O_LP64)) == 0 &&
+ elf_version(EV_CURRENT) != EV_NONE) {
+ int fd;
+ Elf *elf;
+ GElf_Ehdr ehdr;
+
+ for (i = 1; i < g_argc; i++) {
+ if ((fd = open64(g_argv[i], O_RDONLY)) == -1)
+ break;
+
+ if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
+ (void) close(fd);
+ break;
+ }
+
+ if (elf_kind(elf) != ELF_K_ELF ||
+ gelf_getehdr(elf, &ehdr) == NULL) {
+ (void) close(fd);
+ (void) elf_end(elf);
+ break;
+ }
+
+ (void) close(fd);
+ (void) elf_end(elf);
+
+ if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
+ if (g_oflags & DTRACE_O_ILP32) {
+ fatal("can't mix 32-bit and 64-bit "
+ "object files\n");
+ }
+ g_oflags |= DTRACE_O_LP64;
+ } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
+ if (g_oflags & DTRACE_O_LP64) {
+ fatal("can't mix 32-bit and 64-bit "
+ "object files\n");
+ }
+ g_oflags |= DTRACE_O_ILP32;
+ } else {
+ break;
+ }
+ }
+ }
+#endif /* !VBOX */
+
+ /*
+ * Open libdtrace. If we are not actually going to be enabling any
+ * instrumentation attempt to reopen libdtrace using DTRACE_O_NODEV.
+ */
+ while ((g_dtp = dtrace_open(DTRACE_VERSION, g_oflags, &err)) == NULL) {
+ if (!(g_oflags & DTRACE_O_NODEV) && !g_exec && !g_grabanon) {
+ g_oflags |= DTRACE_O_NODEV;
+ continue;
+ }
+
+ fatal("failed to initialize dtrace: %s\n",
+ dtrace_errmsg(NULL, err));
+ }
+
+ (void) dtrace_setopt(g_dtp, "bufsize", "4m");
+ (void) dtrace_setopt(g_dtp, "aggsize", "4m");
+
+ /*
+ * If -G is specified, enable -xlink=dynamic and -xunodefs to permit
+ * references to undefined symbols to remain as unresolved relocations.
+ * If -A is specified, enable -xlink=primary to permit static linking
+ * only to kernel symbols that are defined in a primary kernel module.
+ */
+ if (g_mode == DMODE_LINK) {
+#ifndef VBOX /* No link mode. */
+ (void) dtrace_setopt(g_dtp, "linkmode", "dynamic");
+ (void) dtrace_setopt(g_dtp, "unodefs", NULL);
+
+ /*
+ * Use the remaining arguments as the list of object files
+ * when in linker mode.
+ */
+ g_objc = g_argc - 1;
+ g_objv = g_argv + 1;
+
+ /*
+ * We still use g_argv[0], the name of the executable.
+ */
+ g_argc = 1;
+#else /* VBOX */
+ AssertFailed();
+#endif /* VBOX */
+ } else if (g_mode == DMODE_ANON)
+ (void) dtrace_setopt(g_dtp, "linkmode", "primary");
+
+ /*
+ * Now that we have libdtrace open, make a second pass through argv[]
+ * to perform any dtrace_setopt() calls and change any compiler flags.
+ * We also accumulate any program specifications into our g_cmdv[] at
+ * this time; these will compiled as part of the fourth processing pass.
+ */
+#ifndef VBOX
+ for (optind = 1; optind < argc; optind++) {
+ while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != EOF) {
+#else
+ RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, 0);
+ while ((c = RTGetOpt(&GetState, &ValueUnion))) {
+ {
+ char *optarg = (char *)ValueUnion.psz;
+#endif
+
+ switch (c) {
+ case 'a':
+ if (dtrace_setopt(g_dtp, "grabanon", 0) != 0)
+ dfatal("failed to set -a");
+ break;
+
+ case 'b':
+ if (dtrace_setopt(g_dtp,
+ "bufsize", optarg) != 0)
+ dfatal("failed to set -b %s", optarg);
+ break;
+
+ case 'B':
+ g_ofp = NULL;
+ break;
+
+ case 'C':
+ g_cflags |= DTRACE_C_CPP;
+ break;
+
+ case 'D':
+ if (dtrace_setopt(g_dtp, "define", optarg) != 0)
+ dfatal("failed to set -D %s", optarg);
+ break;
+
+ case 'f':
+ dcp = &g_cmdv[g_cmdc++];
+ dcp->dc_func = compile_str;
+ dcp->dc_spec = DTRACE_PROBESPEC_FUNC;
+ dcp->dc_arg = optarg;
+ break;
+
+ case 'F':
+ if (dtrace_setopt(g_dtp, "flowindent", 0) != 0)
+ dfatal("failed to set -F");
+ break;
+
+ case 'H':
+ if (dtrace_setopt(g_dtp, "cpphdrs", 0) != 0)
+ dfatal("failed to set -H");
+ break;
+
+ case 'i':
+ dcp = &g_cmdv[g_cmdc++];
+ dcp->dc_func = compile_str;
+ dcp->dc_spec = DTRACE_PROBESPEC_NAME;
+ dcp->dc_arg = optarg;
+ break;
+
+ case 'I':
+ if (dtrace_setopt(g_dtp, "incdir", optarg) != 0)
+ dfatal("failed to set -I %s", optarg);
+ break;
+
+ case 'L':
+ if (dtrace_setopt(g_dtp, "libdir", optarg) != 0)
+ dfatal("failed to set -L %s", optarg);
+ break;
+
+ case 'm':
+ dcp = &g_cmdv[g_cmdc++];
+ dcp->dc_func = compile_str;
+ dcp->dc_spec = DTRACE_PROBESPEC_MOD;
+ dcp->dc_arg = optarg;
+ break;
+
+ case 'n':
+ dcp = &g_cmdv[g_cmdc++];
+ dcp->dc_func = compile_str;
+ dcp->dc_spec = DTRACE_PROBESPEC_NAME;
+ dcp->dc_arg = optarg;
+ break;
+
+ case 'P':
+ dcp = &g_cmdv[g_cmdc++];
+ dcp->dc_func = compile_str;
+ dcp->dc_spec = DTRACE_PROBESPEC_PROVIDER;
+ dcp->dc_arg = optarg;
+ break;
+
+ case 'q':
+ if (dtrace_setopt(g_dtp, "quiet", 0) != 0)
+ dfatal("failed to set -q");
+ break;
+
+ case 'o':
+ g_ofile = optarg;
+ break;
+
+ case 's':
+ dcp = &g_cmdv[g_cmdc++];
+ dcp->dc_func = compile_file;
+ dcp->dc_spec = DTRACE_PROBESPEC_NONE;
+ dcp->dc_arg = optarg;
+ break;
+
+ case 'S':
+ g_cflags |= DTRACE_C_DIFV;
+ break;
+
+ case 'U':
+ if (dtrace_setopt(g_dtp, "undef", optarg) != 0)
+ dfatal("failed to set -U %s", optarg);
+ break;
+
+ case 'v':
+ g_verbose++;
+ break;
+
+ case 'w':
+ if (dtrace_setopt(g_dtp, "destructive", 0) != 0)
+ dfatal("failed to set -w");
+ break;
+
+ case 'x':
+ if ((p = strchr(optarg, '=')) != NULL)
+ *p++ = '\0';
+
+ if (dtrace_setopt(g_dtp, optarg, p) != 0)
+ dfatal("failed to set -x %s", optarg);
+ break;
+
+ case 'X':
+ if (dtrace_setopt(g_dtp, "stdc", optarg) != 0)
+ dfatal("failed to set -X %s", optarg);
+ break;
+
+ case 'Z':
+ g_cflags |= DTRACE_C_ZDEFS;
+ break;
+
+#ifndef VBOX
+ default:
+ if (strchr(DTRACE_OPTSTR, c) == NULL)
+ return (usage(stderr));
+#else
+ default:
+ if (c < 0) { /* Note: Not all options are handled. */
+ RTGetOptPrintError(c, &ValueUnion);
+ return (usage(stderr));
+ }
+#endif
+ }
+ }
+ }
+
+ if (g_ofp == NULL && g_mode != DMODE_EXEC) {
+ (void) fprintf(stderr, "%s: -B not valid in combination"
+ " with [-AGl] options\n", g_pname);
+ return (E_USAGE);
+ }
+
+ if (g_ofp == NULL && g_ofile != NULL) {
+ (void) fprintf(stderr, "%s: -B not valid in combination"
+ " with -o option\n", g_pname);
+ return (E_USAGE);
+ }
+
+#ifndef VBOX
+ /*
+ * In our third pass we handle any command-line options related to
+ * grabbing or creating victim processes. The behavior of these calls
+ * may been affected by any library options set by the second pass.
+ */
+# ifndef VBOX
+ for (optind = 1; optind < argc; optind++) {
+ while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != EOF) {
+# else
+ RTGetOptInit(&GetState, argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), 1, 0);
+ while ((c = RTGetOpt(&GetState, &ValueUnion))) {
+ {
+ char *optarg = (char *)ValueUnion.psz;
+# endif
+ switch (c) {
+ case 'c':
+ if ((v = make_argv(optarg)) == NULL)
+ fatal("failed to allocate memory");
+
+ P = dtrace_proc_create(g_dtp, v[0], v);
+ if (P == NULL)
+ dfatal(NULL); /* dtrace_errmsg() only */
+
+ g_psv[g_psc++] = P;
+ free(v);
+ break;
+
+ case 'p':
+ errno = 0;
+ pid = strtol(optarg, &p, 10);
+
+ if (errno != 0 || p == optarg || p[0] != '\0')
+ fatal("invalid pid: %s\n", optarg);
+
+ P = dtrace_proc_grab(g_dtp, pid, 0);
+ if (P == NULL)
+ dfatal(NULL); /* dtrace_errmsg() only */
+
+ g_psv[g_psc++] = P;
+ break;
+ }
+ }
+ }
+#endif /* !VBOX */
+
+ /*
+ * In our fourth pass we finish g_cmdv[] by calling dc_func to convert
+ * each string or file specification into a compiled program structure.
+ */
+ for (i = 0; i < g_cmdc; i++)
+ g_cmdv[i].dc_func(&g_cmdv[i]);
+
+ if (g_mode != DMODE_LIST) {
+ if (dtrace_handle_err(g_dtp, &errhandler, NULL) == -1)
+ dfatal("failed to establish error handler");
+
+ if (dtrace_handle_drop(g_dtp, &drophandler, NULL) == -1)
+ dfatal("failed to establish drop handler");
+
+ if (dtrace_handle_proc(g_dtp, &prochandler, NULL) == -1)
+ dfatal("failed to establish proc handler");
+
+ if (dtrace_handle_setopt(g_dtp, &setopthandler, NULL) == -1)
+ dfatal("failed to establish setopt handler");
+
+ if (g_ofp == NULL &&
+ dtrace_handle_buffered(g_dtp, &bufhandler, NULL) == -1)
+ dfatal("failed to establish buffered handler");
+ }
+
+ (void) dtrace_getopt(g_dtp, "flowindent", &opt);
+ g_flowindent = opt != DTRACEOPT_UNSET;
+
+ (void) dtrace_getopt(g_dtp, "grabanon", &opt);
+ g_grabanon = opt != DTRACEOPT_UNSET;
+
+ (void) dtrace_getopt(g_dtp, "quiet", &opt);
+ g_quiet = opt != DTRACEOPT_UNSET;
+
+ /*
+ * Now make a fifth and final pass over the options that have been
+ * turned into programs and saved in g_cmdv[], performing any mode-
+ * specific processing. If g_mode is DMODE_EXEC, we will break out
+ * of the switch() and continue on to the data processing loop. For
+ * other modes, we will exit dtrace once mode-specific work is done.
+ */
+ switch (g_mode) {
+ case DMODE_EXEC:
+ if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL)
+ fatal("failed to open output file '%s'", g_ofile);
+
+ for (i = 0; i < g_cmdc; i++)
+ exec_prog(&g_cmdv[i]);
+
+ if (done && !g_grabanon) {
+ dtrace_close(g_dtp);
+ return (g_status);
+ }
+ break;
+
+ case DMODE_ANON:
+ if (g_ofile == NULL)
+ g_ofile = "/kernel/drv/dtrace.conf";
+
+ dof_prune(g_ofile); /* strip out any old DOF directives */
+ etcsystem_prune(); /* string out any forceload directives */
+
+ if (g_cmdc == 0) {
+ dtrace_close(g_dtp);
+ return (g_status);
+ }
+
+ if ((g_ofp = fopen(g_ofile, "a")) == NULL)
+ fatal("failed to open output file '%s'", g_ofile);
+
+ for (i = 0; i < g_cmdc; i++) {
+ anon_prog(&g_cmdv[i],
+ dtrace_dof_create(g_dtp, g_cmdv[i].dc_prog, 0), i);
+ }
+
+ /*
+ * Dump out the DOF corresponding to the error handler and the
+ * current options as the final DOF property in the .conf file.
+ */
+ anon_prog(NULL, dtrace_geterr_dof(g_dtp), i++);
+ anon_prog(NULL, dtrace_getopt_dof(g_dtp), i++);
+
+ if (fclose(g_ofp) == EOF)
+ fatal("failed to close output file '%s'", g_ofile);
+
+ /*
+ * These messages would use notice() rather than error(), but
+ * we don't want them suppressed when -A is run on a D program
+ * that itself contains a #pragma D option quiet.
+ */
+ error("saved anonymous enabling in %s\n", g_ofile);
+ etcsystem_add();
+ error("run update_drv(1M) or reboot to enable changes\n");
+
+ dtrace_close(g_dtp);
+ return (g_status);
+
+ case DMODE_LINK:
+#ifndef VBOX /* No link mode. */
+ if (g_cmdc == 0) {
+ (void) fprintf(stderr, "%s: -G requires one or more "
+ "scripts or enabling options\n", g_pname);
+ dtrace_close(g_dtp);
+ return (E_USAGE);
+ }
+
+ for (i = 0; i < g_cmdc; i++)
+ link_prog(&g_cmdv[i]);
+
+ if (g_cmdc > 1 && g_ofile != NULL) {
+ char **objv = alloca(g_cmdc * sizeof (char *));
+
+ for (i = 0; i < g_cmdc; i++)
+ objv[i] = g_cmdv[i].dc_ofile;
+
+ if (dtrace_program_link(g_dtp, NULL, DTRACE_D_PROBES,
+ g_ofile, g_cmdc, objv) != 0)
+ dfatal(NULL); /* dtrace_errmsg() only */
+ }
+
+ dtrace_close(g_dtp);
+ return (g_status);
+#else /* VBOX */
+ AssertFailed();
+ dtrace_close(g_dtp);
+ return (E_USAGE);
+#endif /* VBOX */
+
+ case DMODE_LIST:
+ if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL)
+ fatal("failed to open output file '%s'", g_ofile);
+
+ oprintf("%5s %10s %17s %33s %s\n",
+ "ID", "PROVIDER", "MODULE", "FUNCTION", "NAME");
+
+ for (i = 0; i < g_cmdc; i++)
+ list_prog(&g_cmdv[i]);
+
+ if (g_cmdc == 0)
+ (void) dtrace_probe_iter(g_dtp, NULL, list_probe, NULL);
+
+ dtrace_close(g_dtp);
+ return (g_status);
+
+ case DMODE_HEADER:
+ if (g_cmdc == 0) {
+ (void) fprintf(stderr, "%s: -h requires one or more "
+ "scripts or enabling options\n", g_pname);
+ dtrace_close(g_dtp);
+ return (E_USAGE);
+ }
+
+ if (g_ofile == NULL) {
+#ifndef VBOX
+ char *p;
+#endif
+
+ if (g_cmdc > 1) {
+ (void) fprintf(stderr, "%s: -h requires an "
+ "output file if multiple scripts are "
+ "specified\n", g_pname);
+ dtrace_close(g_dtp);
+ return (E_USAGE);
+ }
+
+ if ((p = strrchr(g_cmdv[0].dc_arg, '.')) == NULL ||
+ strcmp(p, ".d") != 0) {
+ (void) fprintf(stderr, "%s: -h requires an "
+ "output file if no scripts are "
+ "specified\n", g_pname);
+ dtrace_close(g_dtp);
+ return (E_USAGE);
+ }
+
+ p[0] = '\0'; /* strip .d suffix */
+ g_ofile = p = g_cmdv[0].dc_ofile;
+ (void) snprintf(p, sizeof (g_cmdv[0].dc_ofile),
+ "%s.h", basename(g_cmdv[0].dc_arg));
+ }
+
+ if ((g_ofp = fopen(g_ofile, "w")) == NULL)
+ fatal("failed to open header file '%s'", g_ofile);
+
+ oprintf("/*\n * Generated by dtrace(1M).\n */\n\n");
+
+ if (dtrace_program_header(g_dtp, g_ofp, g_ofile) != 0 ||
+ fclose(g_ofp) == EOF)
+ dfatal("failed to create header file %s", g_ofile);
+
+ dtrace_close(g_dtp);
+ return (g_status);
+ }
+
+ /*
+ * If -a and -Z were not specified and no probes have been matched, no
+ * probe criteria was specified on the command line and we abort.
+ */
+ if (g_total == 0 && !g_grabanon && !(g_cflags & DTRACE_C_ZDEFS))
+ dfatal("no probes %s\n", g_cmdc ? "matched" : "specified");
+
+ /*
+ * Start tracing. Once we dtrace_go(), reload any options that affect
+ * our globals in case consuming anonymous state has changed them.
+ */
+ go();
+
+ (void) dtrace_getopt(g_dtp, "flowindent", &opt);
+ g_flowindent = opt != DTRACEOPT_UNSET;
+
+ (void) dtrace_getopt(g_dtp, "grabanon", &opt);
+ g_grabanon = opt != DTRACEOPT_UNSET;
+
+ (void) dtrace_getopt(g_dtp, "quiet", &opt);
+ g_quiet = opt != DTRACEOPT_UNSET;
+
+ (void) dtrace_getopt(g_dtp, "destructive", &opt);
+ if (opt != DTRACEOPT_UNSET)
+ notice("allowing destructive actions\n");
+
+#ifndef _MSC_VER
+ (void) sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = intr;
+
+ if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
+ (void) sigaction(SIGINT, &act, NULL);
+
+ if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
+ (void) sigaction(SIGTERM, &act, NULL);
+#else
+ signal(SIGINT, intr);
+ signal(SIGTERM, intr);
+#endif
+
+ /*
+ * Now that tracing is active and we are ready to consume trace data,
+ * continue any grabbed or created processes, setting them running
+ * using the /proc control mechanism inside of libdtrace.
+ */
+#ifndef VBOX
+ for (i = 0; i < g_psc; i++)
+ dtrace_proc_continue(g_dtp, g_psv[i]);
+#endif
+
+ g_pslive = g_psc; /* count for prochandler() */
+
+ do {
+ if (!g_intr && !done)
+ dtrace_sleep(g_dtp);
+
+ if (g_newline) {
+ /*
+ * Output a newline just to make the output look
+ * slightly cleaner. Note that we do this even in
+ * "quiet" mode...
+ */
+ oprintf("\n");
+ g_newline = 0;
+ }
+
+ if (done || g_intr || (g_psc != 0 && g_pslive == 0)) {
+ done = 1;
+ if (dtrace_stop(g_dtp) == -1)
+ dfatal("couldn't stop tracing");
+ }
+
+ switch (dtrace_work(g_dtp, g_ofp, chew, chewrec, NULL)) {
+ case DTRACE_WORKSTATUS_DONE:
+ done = 1;
+ break;
+ case DTRACE_WORKSTATUS_OKAY:
+ break;
+ default:
+ if (!g_impatient && dtrace_errno(g_dtp) != EINTR)
+ dfatal("processing aborted");
+ }
+
+ if (g_ofp != NULL && fflush(g_ofp) == EOF)
+ clearerr(g_ofp);
+ } while (!done);
+
+ oprintf("\n");
+
+ if (!g_impatient) {
+ if (dtrace_aggregate_print(g_dtp, g_ofp, NULL) == -1 &&
+ dtrace_errno(g_dtp) != EINTR)
+ dfatal("failed to print aggregations");
+ }
+
+ dtrace_close(g_dtp);
+ return (g_status);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile
new file mode 100644
index 00000000..42abe337
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include ../Makefile.com
+
+install: all $(ROOTUSRSBINPROG32)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/i386/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile
new file mode 100644
index 00000000..42abe337
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include ../Makefile.com
+
+install: all $(ROOTUSRSBINPROG32)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile
new file mode 100644
index 00000000..45508077
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include ../Makefile.com
+include ../../Makefile.cmd.64
+
+install: all $(ROOTUSRSBINPROG64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/sparcv9/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile
new file mode 100644
index 00000000..b6af1e53
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile
@@ -0,0 +1,46 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include $(SRC)/Makefile.master
+
+SUBDIRS = cmd tst
+
+ROOTOPTPKG = $(ROOT)/opt/SUNWdtrt
+
+include Makefile.subdirs
+
+install: $(ROOTOPTPKG)/README $(SUBDIRS)
+
+pkg: install
+ @cd $(SRC)/pkg; pwd; $(MAKE) SUNWdtrt.pub
+
+$(ROOTOPTPKG)/% := FILEMODE = 0444
+
+$(ROOTOPTPKG):
+ $(INS.dir)
+
+$(ROOTOPTPKG)/%: ./% $(ROOTOPTPKG)
+ $(INS.file)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.subdirs b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.subdirs
new file mode 100644
index 00000000..2ff551ca
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/Makefile.subdirs
@@ -0,0 +1,41 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+.KEEP_STATE:
+
+all := TARGET += all
+clean := TARGET += clean
+clobber := TARGET += clobber
+install := TARGET += install
+lint := TARGET += lint
+
+all clean clobber install lint: $(SUBDIRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/README b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/README
new file mode 100644
index 00000000..51ab650f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/README
@@ -0,0 +1,32 @@
+
+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 2006 Sun Microsystems, Inc. All rights reserved.
+Use is subject to license terms.
+
+ident "%Z%%M% %I% %E% SMI"
+
+DTrace Testing Suite
+
+The SUNWdtrt package delivers a set of test programs and D source
+files into the directory /opt/SUNWdtrt. For more information see
+the following web site:
+
+ http://www.opensolaris.org/os/community/dtrace/dtest
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile
new file mode 100644
index 00000000..28af4ee6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile
@@ -0,0 +1,31 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/Makefile.master
+
+SUBDIRS = scripts baddof badioctl chkargs jdtrace
+include ../Makefile.subdirs
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile
new file mode 100644
index 00000000..bb7a746d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile
@@ -0,0 +1,59 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/cmd/Makefile.cmd
+
+.KEEP_STATE:
+
+ROOTOPTPKG = $(ROOT)/opt/SUNWdtrt
+ROOTBIN = $(ROOTOPTPKG)/bin
+
+LDFLAGS += $(ZNODEFS) $(ZTEXTOFF)
+LDLIBS = $(LDLIBS.cmd)
+LDLIBS += -ldtrace
+
+SRCS = baddof
+CMDS = $(SRCS:%=$(ROOTBIN)/%)
+
+$(CMDS) := FILEMODE = 0555
+
+all: $(SRCS)
+
+install: $(CMDS)
+
+clean lint:
+
+clobber:
+ $(RM) $(SRCS)
+
+$(CMDS): $(ROOTBIN) $(SRCS)
+
+$(ROOTBIN):
+ $(INS.dir)
+
+$(ROOTBIN)/%: %
+ $(INS.file)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/baddof.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/baddof.c
new file mode 100644
index 00000000..1c14c659
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/baddof/baddof.c
@@ -0,0 +1,207 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/varargs.h>
+#include <errno.h>
+#include <math.h>
+#include <dtrace.h>
+
+void
+fatal(char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ fprintf(stderr, "%s: ", "baddof");
+ vfprintf(stderr, fmt, ap);
+
+ if (fmt[strlen(fmt) - 1] != '\n')
+ fprintf(stderr, ": %s\n", strerror(errno));
+
+ exit(1);
+}
+
+#define LEAP_DISTANCE 20
+
+void
+corrupt(int fd, unsigned char *buf, int len)
+{
+ static int ttl, valid;
+ int bit, i;
+ unsigned char saved;
+ int val[LEAP_DISTANCE], pos[LEAP_DISTANCE];
+ int new, rv;
+
+again:
+ printf("valid DOF #%d\n", valid++);
+
+ /*
+ * We are going iterate through, flipping one bit and attempting
+ * to enable.
+ */
+ for (bit = 0; bit < len * 8; bit++) {
+ saved = buf[bit / 8];
+ buf[bit / 8] ^= (1 << (bit % 8));
+
+ if ((bit % 100) == 0)
+ printf("%d\n", bit);
+
+ if ((rv = ioctl(fd, DTRACEIOC_ENABLE, buf)) == -1) {
+ /*
+ * That failed -- restore the bit and drive on.
+ */
+ buf[bit / 8] = saved;
+ continue;
+ }
+
+ /*
+ * That worked -- and it may have enabled probes. To keep
+ * enabled probes down to a reasonable level, we'll close
+ * and reopen pseudodevice if we have more than 10,000
+ * probes enabled.
+ */
+ ttl += rv;
+
+ if (ttl < 10000) {
+ buf[bit / 8] = saved;
+ continue;
+ }
+
+ printf("enabled %d probes; resetting device.\n", ttl);
+ close(fd);
+
+ new = open("/devices/pseudo/dtrace@0:dtrace", O_RDWR);
+
+ if (new == -1)
+ fatal("couldn't open DTrace pseudo device");
+
+ if (new != fd) {
+ dup2(new, fd);
+ close(new);
+ }
+
+ ttl = 0;
+ buf[bit / 8] = saved;
+ }
+
+ for (;;) {
+ /*
+ * Now we want to get as many bits away as possible. We flip
+ * bits randomly -- getting as far away as we can until we don't
+ * seem to be making any progress.
+ */
+ for (i = 0; i < LEAP_DISTANCE; i++) {
+ /*
+ * Pick a random bit and corrupt it.
+ */
+ bit = lrand48() % (len * 8);
+
+ val[i] = buf[bit / 8];
+ pos[i] = bit / 8;
+ buf[bit / 8] ^= (1 << (bit % 8));
+ }
+
+ /*
+ * Let's see if that managed to get us valid DOF...
+ */
+ if ((rv = ioctl(fd, DTRACEIOC_ENABLE, buf)) > 0) {
+ /*
+ * Success! This will be our new base for valid DOF.
+ */
+ ttl += rv;
+ goto again;
+ }
+
+ /*
+ * No luck -- we'll restore those bits and try flipping a
+ * different set. Note that this must be done in reverse
+ * order...
+ */
+ for (i = LEAP_DISTANCE - 1; i >= 0; i--)
+ buf[pos[i]] = val[i];
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ char *filename = argv[1];
+ dtrace_hdl_t *dtp;
+ dtrace_prog_t *pgp;
+ int err, fd, len;
+ FILE *fp;
+ unsigned char *dof, *copy;
+
+ if (argc < 2)
+ fatal("expected D script as argument\n");
+
+ if ((fp = fopen(filename, "r")) == NULL)
+ fatal("couldn't open %s", filename);
+
+ /*
+ * First, we need to compile our provided D into DOF.
+ */
+ if ((dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) {
+ fatal("cannot open dtrace library: %s\n",
+ dtrace_errmsg(NULL, err));
+ }
+
+ pgp = dtrace_program_fcompile(dtp, fp, 0, 0, NULL);
+ fclose(fp);
+
+ if (pgp == NULL) {
+ fatal("failed to compile script %s: %s\n", filename,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ dof = dtrace_dof_create(dtp, pgp, 0);
+ len = ((dof_hdr_t *)dof)->dofh_loadsz;
+
+ if ((copy = malloc(len)) == NULL)
+ fatal("could not allocate copy of %d bytes", len);
+
+ for (;;) {
+ bcopy(dof, copy, len);
+ /*
+ * Open another instance of the dtrace device.
+ */
+ fd = open("/devices/pseudo/dtrace@0:dtrace", O_RDWR);
+
+ if (fd == -1)
+ fatal("couldn't open DTrace pseudo device");
+
+ corrupt(fd, copy, len);
+ close(fd);
+ }
+
+ /* NOTREACHED */
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile
new file mode 100644
index 00000000..6c3257df
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile
@@ -0,0 +1,58 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/cmd/Makefile.cmd
+
+.KEEP_STATE:
+
+ROOTOPTPKG = $(ROOT)/opt/SUNWdtrt
+ROOTBIN = $(ROOTOPTPKG)/bin
+
+LDFLAGS += $(ZNODEFS) $(ZTEXTOFF)
+LDLIBS = $(LDLIBS.cmd)
+
+SRCS = badioctl
+CMDS = $(SRCS:%=$(ROOTBIN)/%)
+
+$(CMDS) := FILEMODE = 0555
+
+all: $(SRCS)
+
+install: $(CMDS)
+
+clean lint:
+
+clobber:
+ $(RM) $(SRCS)
+
+$(CMDS): $(ROOTBIN) $(SRCS)
+
+$(ROOTBIN):
+ $(INS.dir)
+
+$(ROOTBIN)/%: %
+ $(INS.file)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/badioctl.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/badioctl.c
new file mode 100644
index 00000000..8d6833d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/badioctl/badioctl.c
@@ -0,0 +1,145 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/varargs.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define DTRACEIOC (('d' << 24) | ('t' << 16) | ('r' << 8))
+#define DTRACEIOC_MAX 17
+
+void
+fatal(char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ fprintf(stderr, "%s: ", "badioctl");
+ vfprintf(stderr, fmt, ap);
+
+ if (fmt[strlen(fmt) - 1] != '\n')
+ fprintf(stderr, ": %s\n", strerror(errno));
+
+ exit(1);
+}
+
+void
+badioctl(pid_t parent)
+{
+ int fd = -1, random, ps = sysconf(_SC_PAGESIZE);
+ int i = 0, seconds;
+ caddr_t addr;
+ hrtime_t now, last = 0, end;
+
+ if ((random = open("/dev/random", O_RDONLY)) == -1)
+ fatal("couldn't open /dev/random");
+
+ if ((addr = mmap(0, ps, PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE, -1, 0)) == (caddr_t)-1)
+ fatal("mmap");
+
+ for (;;) {
+ unsigned int ioc;
+
+ if ((now = gethrtime()) - last > NANOSEC) {
+ if (kill(parent, 0) == -1 && errno == ESRCH) {
+ /*
+ * Our parent died. We will kill ourselves in
+ * sympathy.
+ */
+ exit(0);
+ }
+
+ /*
+ * Once a second, we'll reopen the device.
+ */
+ if (fd != -1)
+ close(fd);
+
+ fd = open("/devices/pseudo/dtrace@0:dtrace", O_RDONLY);
+
+ if (fd == -1)
+ fatal("couldn't open DTrace pseudo device");
+
+ last = now;
+ }
+
+
+ if ((i++ % 1000) == 0) {
+ /*
+ * Every thousand iterations, change our random gunk.
+ */
+ read(random, addr, ps);
+ }
+
+ read(random, &ioc, sizeof (ioc));
+ ioc %= DTRACEIOC_MAX;
+ ioc++;
+ ioctl(fd, DTRACEIOC | ioc, addr);
+ }
+}
+
+int
+main()
+{
+ pid_t child, parent = getpid();
+ int status;
+
+ for (;;) {
+ if ((child = fork()) == 0)
+ badioctl(parent);
+
+ while (waitpid(child, &status, WEXITED) != child)
+ continue;
+
+ if (WIFEXITED(status)) {
+ /*
+ * Our child exited by design -- we'll exit with
+ * the same status code.
+ */
+ exit(WEXITSTATUS(status));
+ }
+
+ /*
+ * Our child died on a signal. Respawn it.
+ */
+ printf("badioctl: child died on signal %d; respawning.\n",
+ WTERMSIG(status));
+ fflush(stdout);
+ }
+
+ /* NOTREACHED */
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile
new file mode 100644
index 00000000..0510b9bf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile
@@ -0,0 +1,33 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/cmd/Makefile.cmd
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+include ../../Makefile.subdirs
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.com b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.com
new file mode 100644
index 00000000..f9ad9605
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.com
@@ -0,0 +1,76 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/cmd/Makefile.cmd
+
+.KEEP_STATE:
+
+ROOTBIN = $(ROOT)/opt/SUNWdtrt/bin
+ROOTBIN32 = $(ROOTBIN)/$(MACH32)
+ROOTBIN64 = $(ROOTBIN)/$(MACH64)
+
+PROG = chkargs
+LDLIBS = $(LDLIBS.cmd)
+LDLIBS += -ldtrace -lctf
+
+ROOTISAEXEC = $(ROOTBIN)/$(PROG)
+ROOTPROG32 = $(ROOTBIN32)/$(PROG)
+ROOTPROG64 = $(ROOTBIN64)/$(PROG)
+
+$(ROOTPROG32) := FILEMODE = 0555
+$(ROOTPROG64) := FILEMODE = 0555
+
+all: $(PROG)
+
+clean lint:
+
+clobber:
+ $(RM) $(PROG) $(ROOTISAEXEC)
+
+$(PROG): ../$(PROG).c
+ $(LINK.c) -o $@ ../$(PROG).c $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+$(ROOTPROG32): $(ROOTBIN32) $(PROG)
+
+$(ROOTPROG64): $(ROOTBIN64) $(PROG)
+
+$(ROOTBIN32)/%: %
+ $(INS.file)
+
+$(ROOTBIN64)/%: %
+ $(INS.file)
+
+$(ROOTISAEXEC):
+ $(RM) $@;
+ $(CP) -p $(ISAEXEC) $@
+
+$(ROOTBIN)/%: $(ROOTBIN)
+ $(INS.dir)
+
+$(ROOTBIN):
+ $(INS.dir)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile
new file mode 100644
index 00000000..38bbfc0a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile
@@ -0,0 +1,31 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+include ../Makefile.com
+include $(SRC)/cmd/Makefile.cmd.64
+
+install: $(ROOTPROG64) $(ROOTISAEXEC)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/amd64/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/chkargs.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/chkargs.c
new file mode 100644
index 00000000..a7e0222f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/chkargs.c
@@ -0,0 +1,149 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <strings.h>
+#include <unistd.h>
+#include <dtrace.h>
+
+static int g_count;
+static int g_errs;
+static int g_fd;
+static int g_verbose;
+static int g_errexit;
+static char *g_progname;
+
+static int
+probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *data)
+{
+ dtrace_probeinfo_t p;
+ dtrace_argdesc_t arg;
+ char buf[BUFSIZ];
+ int i;
+
+ (void) printf("\r%6d", ++g_count);
+ (void) fflush(stdout);
+
+ if (dtrace_probe_info(dtp, pdp, &p) != 0) {
+ (void) printf(" failed to get probe info for "
+ "%s:%s:%s:%s [%d]\n", pdp->dtpd_provider, pdp->dtpd_mod,
+ pdp->dtpd_func, pdp->dtpd_name, pdp->dtpd_id);
+ g_errs++;
+ return (0);
+ }
+
+ for (i = 0; i < p.dtp_argc; i++) {
+ if (p.dtp_argv[i].dtt_type == CTF_ERR) {
+ bzero(&arg, sizeof (dtrace_argdesc_t));
+ arg.dtargd_id = pdp->dtpd_id;
+ arg.dtargd_ndx = i;
+ (void) ioctl(g_fd, DTRACEIOC_PROBEARG, &arg);
+
+ (void) printf(" failed to get types for args[%d] "
+ "of %s:%s:%s:%s [%d]: <%s> -> <%s>\n", i,
+ pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func,
+ pdp->dtpd_name, pdp->dtpd_id,
+ arg.dtargd_native, arg.dtargd_xlate);
+
+ g_errs++;
+
+ if (g_errexit)
+ return (-1);
+
+ } else if (g_verbose) {
+ (void) printf("%d args[%d] : %s\n", pdp->dtpd_id, i,
+ ctf_type_name(p.dtp_argv[i].dtt_ctfp,
+ p.dtp_argv[i].dtt_type, buf, sizeof (buf)));
+ }
+ }
+
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ dtrace_probedesc_t pd, *pdp = NULL;
+ dtrace_hdl_t *dtp;
+ int err, c;
+ char *p;
+
+ g_progname = argv[0];
+
+ if ((dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) {
+ (void) fprintf(stderr, "%s: failed to open dtrace: %s\n",
+ g_progname, dtrace_errmsg(dtp, err));
+ return (1);
+ }
+
+ while ((c = getopt(argc, argv, "evx:")) != -1) {
+ switch (c) {
+ case 'e':
+ g_errexit++;
+ break;
+ case 'v':
+ g_verbose++;
+ break;
+ case 'x':
+ if ((p = strchr(optarg, '=')) != NULL)
+ *p++ = '\0';
+
+ if (dtrace_setopt(dtp, optarg, p) != 0) {
+ (void) fprintf(stderr, "%s: failed to set "
+ "option -x %s: %s\n", g_progname, optarg,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ return (2);
+ }
+ break;
+
+ default:
+ (void) fprintf(stderr, "Usage: %s [-ev] "
+ "[-x opt[=arg]] [probedesc]\n", g_progname);
+ return (2);
+ }
+ }
+
+ argv += optind;
+ argc -= optind;
+
+ if (argc > 0) {
+ if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, argv[0], &pd)) {
+ (void) fprintf(stderr, "%s: invalid probe description "
+ "%s: %s\n", g_progname, argv[0],
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ return (2);
+ }
+ pdp = &pd;
+ }
+
+ g_fd = dtrace_ctlfd(dtp);
+ (void) dtrace_probe_iter(dtp, pdp, probe, NULL);
+ dtrace_close(dtp);
+
+ (void) printf("\nTotal probes: %d\n", g_count);
+ (void) printf("Total errors: %d\n\n", g_errs);
+
+ return (g_errs != 0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile
new file mode 100644
index 00000000..596e5b08
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile
@@ -0,0 +1,30 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+include ../Makefile.com
+
+install: $(ROOTPROG32) $(ROOTISAEXEC)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/i386/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile
new file mode 100644
index 00000000..596e5b08
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile
@@ -0,0 +1,30 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+include ../Makefile.com
+
+install: $(ROOTPROG32) $(ROOTISAEXEC)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile
new file mode 100644
index 00000000..38bbfc0a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile
@@ -0,0 +1,31 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+include ../Makefile.com
+include $(SRC)/cmd/Makefile.cmd.64
+
+install: $(ROOTPROG64) $(ROOTISAEXEC)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/chkargs/sparcv9/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Getopt.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Getopt.java
new file mode 100644
index 00000000..e06a170d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Getopt.java
@@ -0,0 +1,453 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+/* Copyright (c) 1988 AT&T */
+/* All Rights Reserved */
+
+import java.io.StringWriter;
+import java.io.PrintWriter;
+
+/**
+ * A Java port of Solaris {@code lib/libc/port/gen/getopt.c}, which is a
+ * port of System V UNIX getopt. See <b>getopt(3C)</b> and SUS/XPG
+ * getopt() for function definition and requirements. Unlike that
+ * definition, this implementation moves non-options to the end of the
+ * argv array rather than quitting at the first non-option.
+ */
+public class Getopt {
+ static final int EOF = -1;
+
+ private String progname;
+ private String[] args;
+ private int argc;
+ private String optstring;
+ private int optind = 0; // args index
+ private int optopt = 0;
+ private String optarg = null;
+ private boolean opterr = true;
+
+ /*
+ * _sp is required to keep state between successive calls to
+ * getopt() while extracting aggregated short-options (ie: -abcd).
+ */
+ private int _sp = 1;
+
+ /**
+ * Creates a {Code Getopt} instance to parse the given command-line
+ * arguments. Modifies the given args array by swapping the
+ * positions of non-options and options so that non-options appear
+ * at the end of the array.
+ */
+ public Getopt(String programName, String[] args,
+ String optionString)
+ {
+ progname = programName;
+ // No defensive copy; Getopt is expected to modify the given
+ // args array
+ this.args = args;
+ argc = this.args.length;
+ optstring = optionString;
+ validate();
+ }
+
+ private void
+ validate()
+ {
+ if (progname == null) {
+ throw new NullPointerException("program name is null");
+ }
+ int i = 0;
+ for (String s : args) {
+ if (s == null) {
+ throw new NullPointerException("null arg at index " + i);
+ }
+ ++i;
+ }
+ if (optstring == null) {
+ throw new NullPointerException("option string is null");
+ }
+ }
+
+ private static class StringRef {
+ private String s;
+
+ public String
+ get()
+ {
+ return s;
+ }
+
+ public StringRef
+ set(String value)
+ {
+ s = value;
+ return this;
+ }
+ }
+
+ /*
+ * Generalized error processing method. If the optstr parameter is
+ * null, the character c is converted to a string and displayed
+ * instead.
+ */
+ void
+ err(String format, char c, String optstr)
+ {
+ if (opterr && optstring.charAt(0) != ':') {
+ StringWriter w = new StringWriter();
+ PrintWriter p = new PrintWriter(w);
+ p.printf(format, progname, (optstr == null ?
+ Character.toString(c) : optstr.substring(2)));
+ System.err.println(w.toString());
+ }
+ }
+
+ /*
+ * Determine if the specified character (c) is present in the string
+ * (optstring) as a regular, single character option. If the option
+ * is found, return an index into optstring where the short-option
+ * character is found, otherwise return -1. The characters ':' and
+ * '(' are not allowed.
+ */
+ static int
+ parseshort(String optstring, char c)
+ {
+ if (c == ':' || c == '(') {
+ return -1;
+ }
+
+ int ch;
+ int len = optstring.length();
+ for (int i = 0; i < len; ++i) {
+ ch = optstring.charAt(i);
+ if (ch == c) {
+ return i;
+ }
+
+ while (i < len && ch == '(') {
+ for (++i; i < len && (ch = optstring.charAt(i)) != ')'; ++i);
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Determine if the specified string (opt) is present in the string
+ * (optstring) as a long-option contained within parenthesis. If the
+ * long-option specifies option-argument, return a reference to it
+ * in longoptarg. Otherwise set the longoptarg reference to null.
+ * If the option is found, return an index into optstring at the
+ * position of the short-option character associated with the
+ * long-option; otherwise return -1.
+ *
+ * @param optstring the entire optstring passed to the {@code
+ * Getopt} constructor
+ * @param opt the long option read from the command line
+ * @param longoptarg the value of the option is returned in this
+ * parameter, if an option exists. Possible return values in
+ * longoptarg are:
+ * <ul>
+ * <li><b>NULL:</b> No argument was found</li>
+ * <li><b>empty string (""):</b> Argument was explicitly left empty
+ * by the user (e.g., --option= )</li>
+ * <li><b>valid string:</b> Argument found on the command line</li>
+ * </ul>
+ * @return index to equivalent short-option in optstring, or -1 if
+ * option not found in optstring.
+ */
+ static int
+ parselong(String optstring, String opt, StringRef longoptarg)
+ {
+ int cp; // index into optstring, beginning of one option spec
+ int ip; // index into optstring, traverses every char
+ char ic; // optstring char
+ int il; // optstring length
+ int op; // index into opt
+ char oc; // opt char
+ int ol; // opt length
+ boolean match; // true if opt is matching part of optstring
+
+ longoptarg.set(null);
+ cp = ip = 0;
+ il = optstring.length();
+ ol = opt.length();
+ do {
+ ic = optstring.charAt(ip);
+ if (ic != '(' && ++ip == il)
+ break;
+ ic = optstring.charAt(ip);
+ if (ic == ':' && ++ip == il)
+ break;
+ ic = optstring.charAt(ip);
+ while (ic == '(') {
+ if (++ip == il)
+ break;
+ op = 0;
+ match = true;
+ while (ip < il && (ic = optstring.charAt(ip)) != ')' &&
+ op < ol) {
+ oc = opt.charAt(op++);
+ match = (ic == oc && match);
+ ++ip;
+ }
+
+ if (match && ip < il && ic == ')' && (op >= ol ||
+ opt.charAt(op) == '=')) {
+ if (op < ol && opt.charAt(op) == '=') {
+ /* may be an empty string - OK */
+ longoptarg.set(opt.substring(op + 1));
+ } else {
+ longoptarg.set(null);
+ }
+ return cp;
+ }
+ if (ip < il && ic == ')' && ++ip == il)
+ break;
+ ic = optstring.charAt(ip);
+ }
+ cp = ip;
+ /*
+ * Handle double-colon in optstring ("a::(longa)") The old
+ * getopt() accepts it and treats it as a required argument.
+ */
+ while ((cp > 0) && (cp < il) && (optstring.charAt(cp) == ':')) {
+ --cp;
+ }
+ } while (cp < il);
+ return -1;
+ }
+
+ /**
+ * Get the current option value.
+ */
+ public String
+ getOptarg()
+ {
+ return optarg;
+ }
+
+ /**
+ * Get the index of the next option to be parsed.
+ */
+ public int
+ getOptind()
+ {
+ return optind;
+ }
+
+ /**
+ * Gets the command-line arguments.
+ */
+ public String[]
+ getArgv()
+ {
+ // No defensive copy: Getopt is expected to modify the given
+ // args array.
+ return args;
+ }
+
+ /**
+ * Gets the aggregated short option that just failed. Since long
+ * options can't be aggregated, a failed long option can be obtained
+ * by {@code getArgv()[getOptind() - 1]}.
+ */
+ public int
+ getOptopt()
+ {
+ return optopt;
+ }
+
+ /**
+ * Set to {@code false} to suppress diagnostic messages to stderr.
+ */
+ public void
+ setOpterr(boolean err)
+ {
+ opterr = err;
+ }
+
+ /**
+ * Gets the next option character, or -1 if there are no more
+ * options. If getopt() encounters a short-option character or a
+ * long-option string not described in the {@code optionString}
+ * argument to the constructor, it returns the question-mark (?)
+ * character. If it detects a missing option-argument, it also
+ * returns the question-mark (?) character, unless the first
+ * character of the {@code optionString} argument was a colon (:),
+ * in which case getopt() returns the colon (:) character.
+ * <p>
+ * This implementation swaps the positions of options and
+ * non-options in the given argv array.
+ */
+ public int
+ getopt()
+ {
+ char c;
+ int cp;
+ boolean longopt;
+ StringRef longoptarg = new StringRef();
+
+ /*
+ * Has the end of the options been encountered? The following
+ * implements the SUS requirements:
+ *
+ * If, when getopt() is called:
+ * - the first character of argv[optind] is not '-'
+ * - argv[optind] is the string "-"
+ * getopt() returns -1 without changing optind if
+ * - argv[optind] is the string "--"
+ * getopt() returns -1 after incrementing optind
+ */
+ if (_sp == 1) {
+ boolean nonOption;
+ do {
+ nonOption = false;
+ if (optind >= argc || args[optind].equals("-")) {
+ return EOF;
+ } else if (args[optind].equals("--")) {
+ ++optind;
+ return EOF;
+ } else if (args[optind].charAt(0) != '-') {
+ // non-option: here we deviate from the SUS requirements
+ // by not quitting, and instead move non-options to the
+ // end of the args array
+ nonOption = true;
+ String tmp = args[optind];
+ if (optind + 1 < args.length) {
+ System.arraycopy(args, optind + 1, args, optind,
+ args.length - (optind + 1));
+ args[args.length - 1] = tmp;
+ }
+ --argc;
+ }
+ } while (nonOption);
+ }
+
+ /*
+ * Getting this far indicates that an option has been encountered.
+ * Note that the syntax of optstring applies special meanings to
+ * the characters ':' and '(', so they are not permissible as
+ * option letters. A special meaning is also applied to the ')'
+ * character, but its meaning can be determined from context.
+ * Note that the specification only requires that the alnum
+ * characters be accepted.
+ *
+ * If the second character of the argument is a '-' this must be
+ * a long-option, otherwise it must be a short option. Scan for
+ * the option in optstring by the appropriate algorithm. Either
+ * scan will return an index to the short-option character in
+ * optstring if the option is found and -1 otherwise.
+ *
+ * For an unrecognized long-option, optopt will equal 0, but
+ * since long-options can't aggregate the failing option can be
+ * identified by argv[optind-1].
+ */
+ optopt = c = args[optind].charAt(_sp);
+ optarg = null;
+ longopt = (_sp == 1 && c == '-');
+ if (!(longopt
+ ? ((cp = parselong(optstring, args[optind].substring(2),
+ longoptarg)) != -1)
+ : ((cp = parseshort(optstring, c)) != -1))) {
+ err("%s: illegal option -- %s", c,
+ (longopt ? args[optind] : null));
+ /*
+ * Note: When the long option is unrecognized, optopt will
+ * be '-' here, which matches the specification.
+ */
+ if (args[optind].length() == ++_sp || longopt) {
+ ++optind;
+ _sp = 1;
+ }
+ return '?';
+ }
+ optopt = c = optstring.charAt(cp);
+
+ /*
+ * A valid option has been identified. If it should have an
+ * option-argument, process that now. SUS defines the setting
+ * of optarg as follows:
+ *
+ * 1. If the option was the last character in an element of
+ * argv, then optarg contains the next element of argv, and
+ * optind is incremented by 2. If the resulting value of
+ * optind is not less than argc, this indicates a missing
+ * option-argument, and getopt() returns an error indication.
+ *
+ * 2. Otherwise, optarg points to the string following the
+ * option character in that element of argv, and optind is
+ * incremented by 1.
+ *
+ * The second clause allows -abcd (where b requires an
+ * option-argument) to be interpreted as "-a -b cd".
+ *
+ * Note that the option-argument can legally be an empty string,
+ * such as:
+ * command --option= operand
+ * which explicitly sets the value of --option to nil
+ */
+ if (cp + 1 < optstring.length() && optstring.charAt(cp + 1) == ':') {
+ // The option takes an argument
+ if (!longopt && ((_sp + 1) < args[optind].length())) {
+ optarg = args[optind++].substring(_sp + 1);
+ } else if (longopt && (longoptarg.get() != null)) {
+ /*
+ * The option argument was explicitly set to the empty
+ * string on the command line (--option=)
+ */
+ optind++;
+ optarg = longoptarg.get();
+ } else if (++optind >= argc) {
+ err("%s: option requires an argument -- %s", c,
+ (longopt ? args[optind - 1] : null));
+ _sp = 1;
+ optarg = null;
+ return (optstring.charAt(0) == ':' ? ':' : '?');
+ } else
+ optarg = args[optind++];
+ _sp = 1;
+ } else {
+ // The option does NOT take an argument
+ if (longopt && (longoptarg.get() != null)) {
+ // User supplied an arg to an option that takes none
+ err("%s: option doesn't take an argument -- %s", (char)0,
+ (longopt ? args[optind] : null));
+ optarg = longoptarg.set(null).get();
+ c = '?';
+ }
+
+ if (longopt || args[optind].length() == ++_sp) {
+ _sp = 1;
+ ++optind;
+ }
+ optarg = null;
+ }
+ return (c);
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/JDTrace.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/JDTrace.java
new file mode 100644
index 00000000..3c5654d8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/JDTrace.java
@@ -0,0 +1,1042 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+import org.opensolaris.os.dtrace.*;
+import java.io.*;
+import java.util.*;
+import java.util.logging.*;
+
+/**
+ * Emulates {@code dtrace(1M)} using the Java DTrace API.
+ */
+public class JDTrace {
+ static Logger logger = Logger.getLogger(JDTrace.class.getName());
+
+ static Consumer dtrace;
+
+ static {
+ Handler handler = new ConsoleHandler();
+ handler.setLevel(Level.ALL);
+ logger.addHandler(handler);
+ }
+
+ static final String CLASSNAME = "JDTrace";
+ static final String OPTSTR =
+ "3:6:b:c:CD:ef:Fi:I:lL:m:n:o:p:P:qs:U:vVwx:X:Z";
+ static boolean heading = false;
+ static boolean quiet = false;
+ static boolean flow = false;
+ static int stackindent = 14;
+ static int exitStatus = 0;
+ static boolean started;
+ static boolean stopped;
+ static PrintStream out = System.out;
+ static final String ATS = "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
+ static final String SPACES = " ";
+ static final int QUANTIZE_ZERO_BUCKET = 63;
+
+ enum Mode {
+ EXEC,
+ INFO,
+ LIST,
+ VERSION
+ }
+
+ enum ProgramType {
+ STRING,
+ FILE
+ }
+
+ static class CompileRequest {
+ String s;
+ ProgramType type;
+ ProbeDescription.Spec probespec;
+ }
+
+ // Modify program string by expanding an incomplete probe
+ // description according to the requested probespec.
+ static void
+ applyProbespec(CompileRequest req)
+ {
+ ProbeDescription.Spec spec = ((req.probespec == null)
+ ? ProbeDescription.Spec.NAME
+ : req.probespec);
+
+ int colons = 0;
+ switch (req.probespec) {
+ case PROVIDER:
+ colons = 3;
+ break;
+ case MODULE:
+ colons = 2;
+ break;
+ case FUNCTION:
+ colons = 1;
+ break;
+ }
+
+ StringBuffer buf = new StringBuffer();
+ if (colons > 0) {
+ char ch;
+ int len = req.s.length();
+
+ int i = 0;
+ // Find first whitespace character not including leading
+ // whitespace (end of first token). Ignore whitespace
+ // inside a block if the block is concatenated with the
+ // probe description.
+ for (; (i < len) && Character.isWhitespace(req.s.charAt(i)); ++i);
+ int npos = i;
+ boolean inBlock = false;
+ for (; (npos < len) &&
+ (!Character.isWhitespace(ch = req.s.charAt(npos)) ||
+ inBlock); ++npos) {
+ if (ch == '{') {
+ inBlock = true;
+ } else if (ch == '}') {
+ inBlock = false;
+ }
+ }
+
+ // libdtrace lets you concatenate multiple probe
+ // descriptions separated by code blocks in curly braces,
+ // for example genunix::'{printf("FOUND");}'::entry, as long
+ // as the concatenated probe descriptions begin with ':' and
+ // not a specific field such as 'syscall'. So to expand the
+ // possibly multiple probe descriptions, we need to insert
+ // colons before each open curly brace, and again at the end
+ // only if there is at least one non-whitespace (probe
+ // specifying) character after the last closing curly brace.
+
+ int prev_i = 0;
+ while (i < npos) {
+ for (; (i < npos) && (req.s.charAt(i) != '{'); ++i);
+ buf.append(req.s.substring(prev_i, i));
+ if ((i < npos) || ((i > 0) && (req.s.charAt(i - 1) != '}'))) {
+ for (int c = 0; c < colons; ++c) {
+ buf.append(':');
+ }
+ }
+ if (i < npos) {
+ buf.append(req.s.charAt(i++));
+ }
+ prev_i = i;
+ }
+
+ // append remainder of program text
+ buf.append(req.s.substring(i));
+
+ req.s = buf.toString();
+ }
+ }
+
+ static void
+ printValue(Object value, int bytes, String stringFormat)
+ {
+ if (value instanceof Integer) {
+ if (bytes == 1) {
+ out.printf(" %3d", (Integer)value);
+ } else if (bytes == 2) {
+ out.printf(" %5d", (Integer)value);
+ } else {
+ out.printf(" %8d", (Integer)value);
+ }
+ } else if (value instanceof Long) {
+ out.printf(" %16d", (Long)value);
+ } else {
+ out.printf(stringFormat, value.toString());
+ }
+ }
+
+ static void
+ consumeProbeData(ProbeData data)
+ {
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer(data.toString());
+ }
+
+ if (!heading) {
+ if (flow) {
+ out.printf("%3s %-41s\n", "CPU", "FUNCTION");
+ } else {
+ if (!quiet) {
+ out.printf("%3s %6s %32s\n",
+ "CPU", "ID", "FUNCTION:NAME");
+ }
+ }
+ heading = true;
+ }
+ ProbeDescription probe = data.getEnabledProbeDescription();
+ if (flow) {
+ Flow flow = data.getFlow();
+ int indent = (flow.getDepth() * 2);
+ StringBuffer buf = new StringBuffer();
+ // indent
+ buf.append(' ');
+ for (int i = 0; i < indent; ++i) {
+ buf.append(' ');
+ }
+ // prefix
+ switch (flow.getKind()) {
+ case ENTRY:
+ if (indent == 0) {
+ buf.append("=> ");
+ } else {
+ buf.append("-> ");
+ }
+ break;
+ case RETURN:
+ if (indent == 0) {
+ buf.append("<= ");
+ } else {
+ buf.append("<- ");
+ }
+ break;
+ }
+
+ switch (flow.getKind()) {
+ case NONE:
+ buf.append(probe.getFunction());
+ buf.append(':');
+ buf.append(probe.getName());
+ break;
+ default:
+ buf.append(probe.getFunction());
+ }
+
+ out.printf("%3s %-41s ", data.getCPU(),
+ buf.toString());
+ } else {
+ if (!quiet) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(probe.getFunction());
+ buf.append(':');
+ buf.append(probe.getName());
+ out.printf("%3s %6s %32s ",
+ data.getCPU(), probe.getID(),
+ buf.toString());
+ }
+ }
+ Record record = null;
+ Object value;
+ List <Record> records = data.getRecords();
+ Iterator <Record> itr = records.iterator();
+ while (itr.hasNext()) {
+ record = itr.next();
+
+ if (record instanceof ExitRecord) {
+ exitStatus = ((ExitRecord)record).getStatus();
+ } else if (record instanceof ScalarRecord) {
+ ScalarRecord scalar = (ScalarRecord)record;
+ value = scalar.getValue();
+ if (value instanceof byte[]) {
+ out.print(record.toString());
+ } else {
+ if (quiet) {
+ out.print(value);
+ } else {
+ printValue(value, scalar.getNumberOfBytes(),
+ " %-33s");
+ }
+ }
+ } else if (record instanceof PrintfRecord) {
+ out.print(record);
+ } else if (record instanceof PrintaRecord) {
+ PrintaRecord printa = (PrintaRecord)record;
+ List <Tuple> tuples = printa.getTuples();
+ if (tuples.isEmpty()) {
+ out.print(printa.getOutput());
+ } else {
+ for (Tuple t : tuples) {
+ out.print(printa.getFormattedString(t));
+ }
+ }
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(printa.toString());
+ }
+ } else if (record instanceof StackValueRecord) {
+ printStack((StackValueRecord)record);
+ }
+ }
+ if (!quiet) {
+ out.println();
+ }
+ }
+
+ static void
+ printDistribution(Distribution d)
+ {
+ out.printf("\n%16s %41s %-9s\n", "value",
+ "------------- Distribution -------------",
+ "count");
+ long v; // bucket frequency (value)
+ long b; // lower bound of bucket range
+ double total = 0;
+ boolean positives = false;
+ boolean negatives = false;
+
+ Distribution.Bucket bucket;
+ int b1 = 0; // first displayed bucket
+ int b2 = d.size() - 1; // last displayed bucket
+ for (; (b1 <= b2) && (d.get(b1).getFrequency() == 0); ++b1);
+ // If possible, get one bucket before the first non-zero
+ // bucket and one bucket after the last.
+ if (b1 > b2) {
+ // There isn't any data. This is possible if (and only if)
+ // negative increment values have been used. In this case,
+ // print the buckets around the base.
+ if (d instanceof LinearDistribution) {
+ b1 = 0;
+ b2 = 2;
+ } else {
+ b1 = QUANTIZE_ZERO_BUCKET - 1;
+ b2 = QUANTIZE_ZERO_BUCKET + 1;
+ }
+ } else {
+ if (b1 > 0) --b1;
+ for (; (b2 > 0) && (d.get(b2).getFrequency() == 0); --b2);
+ if (b2 < (d.size() - 1)) ++b2;
+ }
+ for (int i = b1; i <= b2; ++i) {
+ v = d.get(i).getFrequency();
+ if (v > 0) {
+ positives = true;
+ }
+ if (v < 0) {
+ negatives = true;
+ }
+ total += Math.abs((double)v);
+ }
+ for (int i = b1; i <= b2; ++i) {
+ bucket = d.get(i);
+ v = bucket.getFrequency();
+ b = bucket.getMin();
+
+ if (d instanceof LinearDistribution) {
+ if (b == Long.MIN_VALUE) {
+ String lt = "< " + ((LinearDistribution)d).getBase();
+ out.printf("%16s ", lt);
+ } else if (bucket.getMax() == Long.MAX_VALUE) {
+ String ge = ">= " + b;
+ out.printf("%16s ", ge);
+ } else {
+ out.printf("%16d ", b);
+ }
+ } else {
+ out.printf("%16d ", b);
+ }
+
+ printDistributionLine(v, total, positives, negatives);
+ }
+ }
+
+ static void
+ printDistributionLine(long val, double total, boolean positives,
+ boolean negatives)
+ {
+ double f;
+ int depth, len = 40;
+
+ assert (ATS.length() == len && SPACES.length() == len);
+ assert (!(total == 0 && (positives || negatives)));
+ assert (!(val < 0 && !negatives));
+ assert (!(val > 0 && !positives));
+ assert (!(val != 0 && total == 0));
+
+ if (!negatives) {
+ if (positives) {
+ f = (Math.abs((double)val) * (double)len) / total;
+ depth = (int)(f + 0.5);
+ } else {
+ depth = 0;
+ }
+
+ out.printf("|%s%s %-9d\n", ATS.substring(len - depth),
+ SPACES.substring(depth), val);
+ return;
+ }
+
+ if (!positives) {
+ f = (Math.abs((double)val) * (double)len) / total;
+ depth = (int)(f + 0.5);
+
+ out.printf("%s%s| %-9d\n", SPACES.substring(depth),
+ ATS.substring(len - depth), val);
+ return;
+ }
+
+ /*
+ * If we're here, we have both positive and negative bucket values.
+ * To express this graphically, we're going to generate both positive
+ * and negative bars separated by a centerline. These bars are half
+ * the size of normal quantize()/lquantize() bars, so we divide the
+ * length in half before calculating the bar length.
+ */
+ len /= 2;
+ String ats = ATS.substring(len);
+ String spaces = SPACES.substring(len);
+
+ f = (Math.abs((double)val) * (double)len) / total;
+ depth = (int)(f + 0.5);
+
+ if (val <= 0) {
+ out.printf("%s%s|%s %-9d\n", spaces.substring(depth),
+ ats.substring(len - depth), repeat(" ", len), val);
+ return;
+ } else {
+ out.printf("%20s|%s%s %-9d\n", "", ats.substring(len - depth),
+ spaces.substring(depth), val);
+ }
+ }
+
+ public static String
+ repeat(String s, int n)
+ {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < n; ++i) {
+ buf.append(s);
+ }
+ return buf.toString();
+ }
+
+ static void
+ printStack(StackValueRecord rec)
+ {
+ StackFrame[] frames = rec.getStackFrames();
+ int i;
+ out.println();
+ String s;
+ for (StackFrame f : frames) {
+ for (i = 0; i < stackindent; ++i) {
+ out.print(' ');
+ }
+ s = f.getFrame();
+ if (s.indexOf('[') == 0) {
+ out.print(" ");
+ }
+ out.println(s);
+ }
+ }
+
+ static void
+ printAggregate(Aggregate aggregate)
+ {
+ printAggregationRecords(aggregate.getOrderedRecords());
+ }
+
+ static void
+ printAggregationRecords(List <AggregationRecord> list)
+ {
+ Tuple tuple;
+ AggregationValue value;
+ ValueRecord tupleRecord;
+ int i;
+ int len;
+ for (AggregationRecord r : list) {
+ tuple = r.getTuple();
+ value = r.getValue();
+ len = tuple.size();
+ for (i = 0; i < len; ++i) {
+ tupleRecord = tuple.get(i);
+ if (tupleRecord instanceof StackValueRecord) {
+ printStack((StackValueRecord)tupleRecord);
+ } else if (tupleRecord instanceof SymbolValueRecord) {
+ printValue(tupleRecord.toString(), -1, " %-50s");
+ } else {
+ printValue(tupleRecord.getValue(),
+ ((ScalarRecord)tupleRecord).getNumberOfBytes(),
+ " %-50s");
+ }
+ }
+ if (value instanceof Distribution) {
+ Distribution d = (Distribution)value;
+ printDistribution(d);
+ } else {
+ Number v = value.getValue();
+ printValue(v, -1, " %-50s");
+ }
+ out.println();
+ }
+ }
+
+ static void
+ exit(int status)
+ {
+ out.flush();
+ System.err.flush();
+ if (status == 0) {
+ status = exitStatus;
+ }
+ System.exit(status);
+ }
+
+ static void
+ usage()
+ {
+ String predact = "[[ predicate ] action ]";
+ System.err.printf("Usage: java %s [-32|-64] [-CeFlqvVwZ] " +
+ "[-b bufsz] [-c cmd] [-D name[=def]]\n\t[-I path] [-L path] " +
+ "[-o output] [-p pid] [-s script] [-U name]\n\t" +
+ "[-x opt[=val]] [-X a|c|s|t]\n\n" +
+ "\t[-P provider %s]\n" +
+ "\t[-m [ provider: ] module %s]\n" +
+ "\t[-f [[ provider: ] module: ] func %s]\n" +
+ "\t[-n [[[ provider: ] module: ] func: ] name %s]\n" +
+ "\t[-i probe-id %s] [ args ... ]\n\n", CLASSNAME,
+ predact, predact, predact, predact, predact);
+ System.err.printf("\tpredicate -> '/' D-expression '/'\n");
+ System.err.printf("\t action -> '{' D-statements '}'\n");
+ System.err.printf("\n" +
+ "\t-32 generate 32-bit D programs\n" +
+ "\t-64 generate 64-bit D programs\n\n" +
+ "\t-b set trace buffer size\n" +
+ "\t-c run specified command and exit upon its completion\n" +
+ "\t-C run cpp(1) preprocessor on script files\n" +
+ "\t-D define symbol when invoking preprocessor\n" +
+ "\t-e exit after compiling request but prior to enabling " +
+ "probes\n" +
+ "\t-f enable or list probes matching the specified " +
+ "function name\n" +
+ "\t-F coalesce trace output by function\n" +
+ "\t-i enable or list probes matching the specified probe id\n" +
+ "\t-I add include directory to preprocessor search path\n" +
+ "\t-l list probes matching specified criteria\n" +
+ "\t-L add library directory to library search path\n" +
+ "\t-m enable or list probes matching the specified " +
+ "module name\n" +
+ "\t-n enable or list probes matching the specified probe name\n" +
+ "\t-o set output file\n" +
+ "\t-p grab specified process-ID and cache its symbol tables\n" +
+ "\t-P enable or list probes matching the specified " +
+ "provider name\n" +
+ "\t-q set quiet mode (only output explicitly traced data)\n" +
+ "\t-s enable or list probes according to the specified " +
+ "D script\n" +
+ "\t-U undefine symbol when invoking preprocessor\n" +
+ "\t-v set verbose mode (report stability attributes, " +
+ "arguments)\n" +
+ "\t-V report DTrace API version\n" +
+ "\t-w permit destructive actions\n" +
+ "\t-x enable or modify compiler and tracing options\n" +
+ "\t-X specify ISO C conformance settings for preprocessor\n" +
+ "\t-Z permit probe descriptions that match zero probes\n" +
+ "\n" +
+ "\tTo log PrintaRecord, set this environment variable:\n" +
+ "\t\tJDTRACE_LOGGING_LEVEL=FINE\n" +
+ "\tTo log ProbeData, set JDTRACE_LOGGING_LEVEL=FINER\n");
+ exit(2);
+ }
+
+ static void
+ printProgramStability(String programType, String programDescription,
+ ProgramInfo info)
+ {
+ out.println();
+ out.printf("Stability data for %s %s:\n\n",
+ programType, programDescription);
+ InterfaceAttributes a;
+ out.println("\tMinimum probe description " +
+ "attributes");
+ a = info.getMinimumProbeAttributes();
+ out.printf("\t\tIdentifier Names: %s\n",
+ a.getNameStability());
+ out.printf("\t\tData Semantics: %s\n",
+ a.getDataStability());
+ out.printf("\t\tDependency Class: %s\n",
+ a.getDependencyClass());
+ out.println("\tMinimum probe statement attributes");
+ a = info.getMinimumStatementAttributes();
+ out.printf("\t\tIdentifier Names: %s\n",
+ a.getNameStability());
+ out.printf("\t\tData Semantics: %s\n",
+ a.getDataStability());
+ out.printf("\t\tDependency Class: %s\n",
+ a.getDependencyClass());
+ }
+
+ static void
+ printProbeDescription(ProbeDescription p)
+ {
+ out.printf("%5d %10s %17s %33s %s\n", p.getID(),
+ p.getProvider(), p.getModule(),
+ p.getFunction(), p.getName());
+ }
+
+ static void
+ printProbeInfo(ProbeInfo p)
+ {
+ InterfaceAttributes a;
+ out.println("\n\tProbe Description Attributes");
+
+ a = p.getProbeAttributes();
+ out.printf("\t\tIdentifier Names: %s\n",
+ a.getNameStability());
+ out.printf("\t\tData Semantics: %s\n",
+ a.getDataStability());
+ out.printf("\t\tDependency Class: %s\n",
+ a.getDependencyClass());
+
+ out.println("\n\tArgument Attributes");
+
+ a = p.getArgumentAttributes();
+ out.printf("\t\tIdentifier Names: %s\n",
+ a.getNameStability());
+ out.printf("\t\tData Semantics: %s\n",
+ a.getDataStability());
+ out.printf("\t\tDependency Class: %s\n",
+ a.getDependencyClass());
+
+ // Argument types unsupported for now.
+
+ out.println();
+ }
+
+ public static void
+ main(String[] args)
+ {
+ String loggingLevel = System.getenv().get("JDTRACE_LOGGING_LEVEL");
+ try {
+ logger.setLevel(Level.parse(loggingLevel));
+ } catch (Exception e) {
+ logger.setLevel(Level.OFF);
+ }
+
+ if (args.length == 0) {
+ usage();
+ }
+
+ List <CompileRequest> compileRequests = new LinkedList
+ <CompileRequest> ();
+ List <Program> programList = new LinkedList <Program> ();
+ boolean verbose = false;
+ Mode mode = Mode.EXEC;
+
+ final ExceptionHandler exceptionHandler = new ExceptionHandler() {
+ public void handleException(Throwable e) {
+ if (e instanceof DTraceException) {
+ DTraceException de = (DTraceException)e;
+ System.err.printf("dtrace: %s\n", de.getMessage());
+ } else if (e instanceof ConsumerException) {
+ ConsumerException ce = (ConsumerException)e;
+ Object msg = ce.getNotificationObject();
+ if ((msg instanceof org.opensolaris.os.dtrace.Error) ||
+ (msg instanceof Drop)) {
+ System.err.printf("dtrace: %s\n", ce.getMessage());
+ } else {
+ ce.printStackTrace();
+ }
+ } else {
+ e.printStackTrace();
+ }
+ exit(1);
+ }
+ };
+
+ Getopt g = new Getopt(CLASSNAME, args, OPTSTR);
+ int c = 0;
+
+ List <Consumer.OpenFlag> openFlags =
+ new ArrayList <Consumer.OpenFlag> ();
+
+ while ((c = g.getopt()) != -1) {
+ switch (c) {
+ case '3': {
+ String s = g.getOptarg();
+ if (!s.equals("2")) {
+ System.err.println("dtrace: illegal option -- 3" + s);
+ usage();
+ }
+ openFlags.add(Consumer.OpenFlag.ILP32);
+ break;
+ }
+ case '6': {
+ String s = g.getOptarg();
+ if (!s.equals("4")) {
+ System.err.println("dtrace: illegal option -- 6" + s);
+ usage();
+ }
+ openFlags.add(Consumer.OpenFlag.LP64);
+ break;
+ }
+ }
+ }
+
+ Consumer.OpenFlag[] oflags = new Consumer.OpenFlag[openFlags.size()];
+ oflags = openFlags.toArray(oflags);
+
+ dtrace = new LocalConsumer() {
+ protected Thread createThread() {
+ Thread t = super.createThread();
+ t.setDaemon(false);
+ t.setPriority(Thread.MIN_PRIORITY);
+ return t;
+ }
+ };
+
+ g = new Getopt(CLASSNAME, args, OPTSTR);
+ c = 0;
+
+ try {
+ dtrace.open(oflags);
+
+ // Set default options that may be overriden by options or #pragma
+ dtrace.setOption(Option.bufsize, Option.mb(4));
+ dtrace.setOption(Option.aggsize, Option.mb(4));
+
+ CompileRequest r;
+ while ((c = g.getopt()) != -1) {
+ switch (c) {
+ case 'b':
+ dtrace.setOption(Option.bufsize, g.getOptarg());
+ break;
+ case 'c':
+ dtrace.createProcess(g.getOptarg());
+ break;
+ case 'C':
+ dtrace.setOption(Option.cpp);
+ break;
+ case 'D':
+ dtrace.setOption(Option.define, g.getOptarg());
+ break;
+ case 'e':
+ mode = Mode.INFO;
+ break;
+ case 'f':
+ r = new CompileRequest();
+ r.s = g.getOptarg();
+ r.type = ProgramType.STRING;
+ r.probespec = ProbeDescription.Spec.FUNCTION;
+ compileRequests.add(r);
+ break;
+ case 'F':
+ dtrace.setOption(Option.flowindent);
+ break;
+ case 'i':
+ r = new CompileRequest();
+ r.s = g.getOptarg();
+ r.type = ProgramType.STRING;
+ r.probespec = ProbeDescription.Spec.NAME;
+ compileRequests.add(r);
+ break;
+ case 'I':
+ dtrace.setOption(Option.incdir, g.getOptarg());
+ break;
+ case 'l':
+ mode = Mode.LIST;
+ dtrace.setOption(Option.zdefs); // -l implies -Z
+ break;
+ case 'L':
+ dtrace.setOption(Option.libdir, g.getOptarg());
+ break;
+ case 'm':
+ r = new CompileRequest();
+ r.s = g.getOptarg();
+ r.type = ProgramType.STRING;
+ r.probespec = ProbeDescription.Spec.MODULE;
+ compileRequests.add(r);
+ break;
+ case 'n':
+ r = new CompileRequest();
+ r.s = g.getOptarg();
+ r.type = ProgramType.STRING;
+ r.probespec = ProbeDescription.Spec.NAME;
+ compileRequests.add(r);
+ break;
+ case 'o':
+ String outFileName = g.getOptarg();
+ File outFile = new File(outFileName);
+ try {
+ FileOutputStream fos = new FileOutputStream(
+ outFile, true);
+ out = new PrintStream(fos);
+ } catch (FileNotFoundException e) {
+ System.err.println("failed to open " +
+ outFileName + " in write mode");
+ exit(1);
+ } catch (SecurityException e) {
+ System.err.println("failed to open " +
+ outFileName);
+ exit(1);
+ }
+ break;
+ case 'p':
+ String pidstr = g.getOptarg();
+ int pid = -1;
+ try {
+ pid = Integer.parseInt(pidstr);
+ } catch (NumberFormatException e) {
+ System.err.println("invalid pid: " + pidstr);
+ exit(1);
+ }
+ dtrace.grabProcess(pid);
+ break;
+ case 'P':
+ r = new CompileRequest();
+ r.s = g.getOptarg();
+ r.type = ProgramType.STRING;
+ r.probespec = ProbeDescription.Spec.PROVIDER;
+ compileRequests.add(r);
+ break;
+ case 'q':
+ dtrace.setOption(Option.quiet);
+ break;
+ case 's':
+ r = new CompileRequest();
+ r.s = g.getOptarg();
+ r.type = ProgramType.FILE;
+ compileRequests.add(r);
+ break;
+ case 'U':
+ dtrace.setOption(Option.undef, g.getOptarg());
+ break;
+ case 'v':
+ verbose = true;
+ break;
+ case 'V':
+ mode = Mode.VERSION;
+ break;
+ case 'w':
+ dtrace.setOption(Option.destructive);
+ break;
+ case 'x':
+ String[] xarg = g.getOptarg().split("=", 2);
+ if (xarg.length > 1) {
+ dtrace.setOption(xarg[0], xarg[1]);
+ } else if (xarg.length == 1) {
+ dtrace.setOption(xarg[0]);
+ }
+ break;
+ case 'X':
+ dtrace.setOption(Option.stdc, g.getOptarg());
+ break;
+ case 'Z':
+ dtrace.setOption(Option.zdefs);
+ break;
+ case '?':
+ usage(); // getopt() already printed an error
+ break;
+ default:
+ System.err.print("getopt() returned " + c + "\n");
+ c = 0;
+ }
+ }
+ c = 0;
+ List <String> argList = new LinkedList <String> ();
+ for (int i = g.getOptind(); i < args.length; ++i) {
+ argList.add(args[i]);
+ }
+
+ if (mode == Mode.VERSION) {
+ out.printf("dtrace: %s\n", dtrace.getVersion());
+ dtrace.close();
+ exit(0);
+ }
+
+ String[] compileArgs = new String[argList.size()];
+ compileArgs = argList.toArray(compileArgs);
+
+ Program program;
+ for (CompileRequest req : compileRequests) {
+ switch (req.type) {
+ case STRING:
+ applyProbespec(req);
+ program = dtrace.compile(req.s, compileArgs);
+ break;
+ case FILE:
+ File file = new File(req.s);
+ program = dtrace.compile(file, compileArgs);
+ break;
+ default:
+ throw new IllegalArgumentException(
+ "Unexpected program type: " + req.type);
+ }
+
+ programList.add(program);
+ }
+
+ // Get options set by #pragmas in compiled program
+ long optval;
+ quiet = (dtrace.getOption(Option.quiet) != Option.UNSET);
+ flow = (dtrace.getOption(Option.flowindent) != Option.UNSET);
+ optval = dtrace.getOption("stackindent");
+ if (optval != Option.UNSET) {
+ stackindent = (int)optval;
+ }
+
+ if (mode == Mode.LIST) {
+ out.printf("%5s %10s %17s %33s %s\n",
+ "ID", "PROVIDER", "MODULE", "FUNCTION", "NAME");
+
+ if (verbose) {
+ List <List <Probe>> lists =
+ new LinkedList <List <Probe>> ();
+ for (Program p : programList) {
+ lists.add(dtrace.listProgramProbeDetail(p));
+ }
+ ProbeDescription p;
+ ProbeInfo pinfo;
+ for (List <Probe> list : lists) {
+ for (Probe probe : list) {
+ p = probe.getDescription();
+ pinfo = probe.getInfo();
+ printProbeDescription(p);
+ printProbeInfo(pinfo);
+ }
+ }
+ } else {
+ List <List <ProbeDescription>> lists =
+ new LinkedList <List <ProbeDescription>> ();
+ for (Program p : programList) {
+ lists.add(dtrace.listProgramProbes(p));
+ }
+ for (List <ProbeDescription> list : lists) {
+ for (ProbeDescription p : list) {
+ printProbeDescription(p);
+ }
+ }
+ }
+ exit(0);
+ }
+
+ String programType;
+ String programDescription;
+ ProgramInfo info;
+ for (Program p : programList) {
+ if (p instanceof Program.File) {
+ Program.File pf = (Program.File)p;
+ programType = "script";
+ programDescription = pf.getFile().getPath();
+ } else {
+ programType = "description";
+ programDescription =
+ p.getContents().split("[/{;]", 2)[0];
+ }
+
+ if (mode == Mode.EXEC) {
+ dtrace.enable(p);
+ } else {
+ dtrace.getProgramInfo(p);
+ }
+ info = p.getInfo();
+ if ((mode == Mode.EXEC) && !quiet) {
+ System.err.printf("dtrace: %s '%s' matched %d probe%s\n",
+ programType, programDescription,
+ info.getMatchingProbeCount(),
+ info.getMatchingProbeCount() == 1 ? "" : "s");
+ }
+ if (verbose) {
+ printProgramStability(programType,
+ programDescription, info);
+ }
+ }
+ if (mode != Mode.EXEC) {
+ exit(0);
+ }
+ dtrace.addConsumerListener(new ConsumerAdapter() {
+ public void consumerStarted(ConsumerEvent e) {
+ started = true;
+ }
+ public void consumerStopped(ConsumerEvent e) {
+ stopped = true;
+ out.println();
+ try {
+ Aggregate aggregate = dtrace.getAggregate();
+ if (aggregate != null) {
+ printAggregate(aggregate);
+ }
+ dtrace.close();
+ } catch (Throwable x) {
+ exceptionHandler.handleException(x);
+ }
+ exit(0);
+ }
+ public void dataDropped(DropEvent e) {
+ System.err.printf("dtrace: %s",
+ e.getDrop().getDefaultMessage());
+ }
+ public void errorEncountered(ErrorEvent e)
+ throws ConsumerException {
+ org.opensolaris.os.dtrace.Error error = e.getError();
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(error.toString());
+ }
+ System.err.printf("dtrace: %s",
+ error.getDefaultMessage());
+ }
+ public void dataReceived(DataEvent e)
+ throws ConsumerException {
+ consumeProbeData(e.getProbeData());
+ }
+ public void processStateChanged(ProcessEvent e)
+ throws ConsumerException {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(e.getProcessState().toString());
+ }
+ }
+ });
+ // Print unprinted aggregations after Ctrl-C
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ if (stopped || !started) {
+ return;
+ }
+
+ try {
+ Aggregate aggregate = dtrace.getAggregate();
+ if (aggregate != null) {
+ out.println();
+ out.println();
+ printAggregate(aggregate);
+ }
+ } catch (Throwable x) {
+ exceptionHandler.handleException(x);
+ }
+ }
+ });
+ dtrace.go(exceptionHandler);
+ } catch (DTraceException e) {
+ if (c > 0) {
+ // set option error
+ if (g.getOptarg() == null) {
+ System.err.printf("dtrace: failed to set -%c: %s\n",
+ c, e.getMessage());
+ } else {
+ System.err.printf("dtrace: failed to set -%c %s: %s\n",
+ c, g.getOptarg(), e.getMessage());
+ }
+ } else {
+ // any other error
+ System.err.printf("dtrace: %s\n", e.getMessage());
+ }
+ exit(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile
new file mode 100644
index 00000000..99a571be
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile
@@ -0,0 +1,109 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+PROG = jdtrace
+SRCS = jdtrace.c
+
+include $(SRC)/cmd/Makefile.cmd
+
+ROOTOPTPKG = $(ROOT)/opt/SUNWdtrt
+ROOTBIN = $(ROOTOPTPKG)/bin
+ROOTLIB = $(ROOTOPTPKG)/lib
+ROOTLIBJAVA = $(ROOTLIB)/java
+
+# Use the proto dtrace.jar if it exists, otherwise use whatever is
+# installed on the system. It should be possible to build
+# usr/src/cmd/dtrace/test independently, even if only on systems that
+# have a compatible dtrace.jar installed.
+DTRACE_JAR=usr/share/lib/java/dtrace.jar
+PROTO_DTRACE_JAR=$(ROOT)/$(DTRACE_JAR)
+INSTALLED_DTRACE_JAR=/$(DTRACE_JAR)
+CLASSPATH=$(PROTO_DTRACE_JAR):$(INSTALLED_DTRACE_JAR)
+DTEST_DIR=$(SRC)/cmd/dtrace/test
+CLASSDIR=classes
+LIBDIR=lib
+MANIFESTDIR=manifest
+MANIFEST=$(MANIFESTDIR)/jdtrace.jar-manifest
+JDTRACE_JAR=$(LIBDIR)/jdtrace.jar
+
+PROTO_JDTRACE_JAR=$(ROOTLIBJAVA)/jdtrace.jar
+CMD = $(ROOTBIN)/jdtrace
+XLIST = $(ROOTBIN)/exception.lst
+
+$(PROTO_JDTRACE_JAR) := FILEMODE = 0644
+$(CMD) := FILEMODE = 0555
+$(XLIST) := FILEMODE = 0444
+
+all: $(JDTRACE_JAR) $(PROG)
+
+clean:
+ -$(RM) $(CLASSDIR)/*.class
+
+clobber: clean
+ -$(RM) $(JDTRACE_JAR)
+ -$(RM) $(PROG)
+
+lint:
+
+install: all $(PROTO_JDTRACE_JAR) $(CMD) $(XLIST)
+
+$(PROG): $(SRCS)
+ $(LINK.c) -o $@ $(SRCS) $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+JFLAGS= -g -cp $(CLASSPATH) -d $(CLASSDIR) -deprecation
+JFLAGS += -target 1.5
+JFLAGS += -Xlint
+COMPILE.java=$(JAVAC) $(JFLAGS)
+JAVASRC= JDTrace.java Getopt.java
+
+$(JDTRACE_JAR): $(JAVASRC)
+ @mkdir -p $(CLASSDIR)
+ @mkdir -p $(LIBDIR)
+ $(COMPILE.java) $(JAVASRC)
+ $(JAR) -cmf $(MANIFEST) $(JDTRACE_JAR) -C $(CLASSDIR) .
+
+$(PROTO_JDTRACE_JAR): $(ROOTLIBJAVA)
+
+$(CMD): $(ROOTBIN)
+
+$(XLIST): $(ROOTBIN)
+
+$(ROOTBIN):
+ $(INS.dir)
+
+$(ROOTLIB):
+ $(INS.dir)
+
+$(ROOTLIBJAVA): $(ROOTLIB)
+ $(INS.dir)
+
+$(ROOTLIBJAVA)/%.jar: $(LIBDIR)/%.jar
+ $(INS.file)
+
+$(ROOTBIN)/%: %
+ $(INS.file)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/exception.lst b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/exception.lst
new file mode 100644
index 00000000..261f8707
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/exception.lst
@@ -0,0 +1,77 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+# Exception list: names tests that are bypassed when running in Java
+# mode (relative to /opt/SUNWdtrt/tst)
+
+# double precision (64-bit floating point) not same in java
+common/aggs/tst.neglquant.d
+common/aggs/tst.negquant.d
+
+# freopen() (to suppress output) not supported by Java DTrace API
+common/printa/tst.walltimestamp.ksh
+
+# -G option not supported by jdtrace
+common/dtraceUtil/tst.ELFGenerationOut.d.ksh
+common/dtraceUtil/tst.ELFGenerationWithO.d.ksh
+
+# -H option not supported by jdtrace
+common/dtraceUtil/tst.PreprocessorStatement.d.ksh
+
+# -G and -h options not supported by jdtrace
+common/usdt/tst.badguess.ksh
+common/usdt/tst.dlclose1.ksh
+common/usdt/tst.dlclose2.ksh
+common/usdt/tst.dlclose3.ksh
+common/usdt/tst.eliminate.ksh
+common/usdt/tst.enabled.ksh
+common/usdt/tst.enabled2.ksh
+common/usdt/tst.entryreturn.ksh
+common/usdt/tst.fork.ksh
+common/usdt/tst.header.ksh
+common/usdt/tst.guess32.ksh
+common/usdt/tst.guess64.ksh
+common/usdt/tst.linkpriv.ksh
+common/usdt/tst.linkunpriv.ksh
+common/usdt/tst.multiple.ksh
+common/usdt/tst.nodtrace.ksh
+common/usdt/tst.onlyenabled.ksh
+common/usdt/tst.reeval.ksh
+common/usdt/tst.static.ksh
+common/usdt/tst.static2.ksh
+common/usdt/tst.user.ksh
+sparc/usdt/tst.tailcall.ksh
+common/pid/tst.provregex3.ksh
+common/pid/tst.provregex4.ksh
+
+# freopen() and ftruncate() not supported by Java DTrace API
+common/funcs/tst.badfreopen.ksh
+common/funcs/tst.freopen.ksh
+common/funcs/tst.ftruncate.ksh
+
+# jdtrace doesn't pull in library files?
+common/pragma/tst.libdepfullyconnected.ksh
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/jdtrace.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/jdtrace.c
new file mode 100644
index 00000000..09512656
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/jdtrace.c
@@ -0,0 +1,60 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <alloca.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/systeminfo.h>
+
+int
+main(int argc, char **argv)
+{
+ int i, ac, has64;
+ char **av, **p;
+
+ ac = argc + 3;
+ av = p = alloca(sizeof (char *) * ac);
+
+ *p++ = "java";
+ *p++ = "-jar";
+ *p++ = "/opt/SUNWdtrt/lib/java/jdtrace.jar";
+
+ argc--;
+ argv++;
+
+ for (i = 0; i < argc; i++) {
+ p[i] = argv[i];
+ }
+ p[i] = NULL;
+
+ (void) execvp(av[0], av);
+
+ perror("exec failed");
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/jdtrace.jar-manifest b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/jdtrace.jar-manifest
new file mode 100644
index 00000000..323c4a4c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/jdtrace/manifest/jdtrace.jar-manifest
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: JDTrace
+Class-Path: /usr/share/lib/java/dtrace.jar
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile
new file mode 100644
index 00000000..0a7b167c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile
@@ -0,0 +1,56 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/Makefile.master
+
+.KEEP_STATE:
+
+ROOTOPTPKG = $(ROOT)/opt/SUNWdtrt
+ROOTBIN = $(ROOTOPTPKG)/bin
+
+SRCS = dtest itest dstyle
+CMDS = $(SRCS:%=$(ROOTBIN)/%)
+
+$(CMDS) := FILEMODE = 0555
+
+all clean clobber lint:
+
+install: $(CMDS)
+
+$(CMDS): $(ROOTBIN)
+
+$(ROOTBIN):
+ $(INS.dir)
+
+$(ROOTBIN)/%: %.pl
+ $(INS.rename)
+
+$(ROOTBIN)/%: %.sh
+ $(INS.rename)
+
+$(ROOTBIN)/%: %.ksh
+ $(INS.rename)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dstyle.pl b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dstyle.pl
new file mode 100755
index 00000000..c1075a36
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dstyle.pl
@@ -0,0 +1,235 @@
+#!/usr/perl5/bin/perl
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+require 5.8.4;
+
+$PNAME = $0;
+$PNAME =~ s:.*/::;
+$USAGE = "Usage: $PNAME [file ...]\n";
+$errs = 0;
+
+sub err
+{
+ my($msg) = @_;
+
+ print "$file: $lineno: $msg\n";
+ $errs++;
+}
+
+sub dstyle
+{
+ open(FILE, "$file");
+ $lineno = 0;
+ $inclause = 0;
+ $skipnext = 0;
+
+ while (<FILE>) {
+ $lineno++;
+
+ chop;
+
+ if ($skipnext) {
+ $skipnext = 0;
+ next;
+ }
+
+ #
+ # Amazingly, some ident strings are longer than 80 characters!
+ #
+ if (/^#pragma ident/) {
+ next;
+ }
+
+ #
+ # The algorithm to calculate line length from cstyle.
+ #
+ $line = $_;
+ if ($line =~ tr/\t/\t/ * 7 + length($line) > 80) {
+ # yes, there is a chance.
+ # replace tabs with spaces and check again.
+ $eline = $line;
+ 1 while $eline =~
+ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
+
+ if (length($eline) > 80) {
+ err "line > 80 characters";
+ }
+ }
+
+ if (/\/\*DSTYLED\*\//) {
+ $skipnext = 1;
+ next;
+ }
+
+ if (/^#pragma/) {
+ next;
+ }
+
+ if (/^#include/) {
+ next;
+ }
+
+ #
+ # Before we do any more analysis, we want to prune out any
+ # quoted strings. This is a bit tricky because we need
+ # to be careful of backslashed quotes within quoted strings.
+ # I'm sure there is a very crafty way to do this with a
+ # single regular expression, but that will have to wait for
+ # somone with better regex juju that I; we do this by first
+ # eliminating the backslashed quotes, and then eliminating
+ # whatever quoted strings are left. Note that we eliminate
+ # the string by replacing it with "quotedstr"; this is to
+ # allow lines to end with a quoted string. (If we simply
+ # eliminated the quoted string, dstyle might complain about
+ # the line ending in a space or tab.)
+ #
+ s/\\\"//g;
+ s/\"[^\"]*\"/quotedstr/g;
+
+ if (/[ \t]$/) {
+ err "space or tab at end of line";
+ }
+
+ if (/^[\t]+[ ]+[\t]+/) {
+ err "spaces between tabs";
+ }
+
+ if (/^[\t]* \*/) {
+ next;
+ }
+
+ if (/^ /) {
+ err "indented by spaces not tabs";
+ }
+
+ if (/^{}$/) {
+ next;
+ }
+
+ if (!/^enum/ && !/^\t*struct/ && !/^\t*union/ && !/^typedef/ &&
+ !/^translator/ && !/^provider/) {
+ if (/[\w\s]+{/) {
+ err "left brace not on its own line";
+ }
+
+ if (/{[\w\s]+/) {
+ err "left brace not on its own line";
+ }
+ }
+
+ if (!/;$/) {
+ if (/[\w\s]+}/) {
+ err "right brace not on its own line";
+ }
+
+ if (/}[\w\s]+/) {
+ err "right brace not on its own line";
+ }
+ }
+
+ if (/^}/) {
+ $inclause = 0;
+ }
+
+ if (!$inclause && /^[\w ]+\//) {
+ err "predicate not at beginning of line";
+ }
+
+ if (!$inclause && /^\/[ \t]+\w/) {
+ err "space between '/' and expression in predicate";
+ }
+
+ if (!$inclause && /\w[ \t]+\/$/) {
+ err "space between expression and '/' in predicate";
+ }
+
+ if (!$inclause && /\s,/) {
+ err "space before comma in probe description";
+ }
+
+ if (!$inclause && /\w,[\w\s]/ && !/;$/) {
+ if (!/extern/ && !/\(/ && !/inline/) {
+ err "multiple probe descriptions on same line";
+ }
+ }
+
+ if ($inclause && /sizeof\(/) {
+ err "missing space after sizeof";
+ }
+
+ if ($inclause && /^[\w ]/) {
+ err "line doesn't begin with a tab";
+ }
+
+ if ($inclause && /,[\w]/) {
+ err "comma without trailing space";
+ }
+
+ if (/\w&&/ || /&&\w/ || /\w\|\|/ || /\|\|\w/) {
+ err "logical operator not set off with spaces";
+ }
+
+ #
+ # We want to catch "i<0" variants, but we don't want to
+ # erroneously flag translators.
+ #
+ if (!/\w<\w+>\(/) {
+ if (/\w>/ || / >\w/ || /\w</ || /<\w/) {
+ err "comparison operator not set " .
+ "off with spaces";
+ }
+ }
+
+ if (/\w==/ || /==\w/ || /\w<=/ || />=\w/ || /\w!=/ || /!=\w/) {
+ err "comparison operator not set off with spaces";
+ }
+
+ if (/\w=/ || /=\w/) {
+ err "assignment operator not set off with spaces";
+ }
+
+ if (/^{/) {
+ $inclause = 1;
+ }
+ }
+}
+
+foreach $arg (@ARGV) {
+ if (-f $arg) {
+ push(@files, $arg);
+ } else {
+ die "$PNAME: $arg is not a valid file\n";
+ }
+}
+
+die $USAGE if (scalar(@files) == 0);
+
+foreach $file (@files) {
+ dstyle($file);
+}
+
+exit($errs != 0);
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dtest.pl b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dtest.pl
new file mode 100755
index 00000000..3f244295
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/cmd/scripts/dtest.pl
@@ -0,0 +1,704 @@
+#!/usr/perl5/bin/perl
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+require 5.8.4;
+
+use File::Find;
+use File::Basename;
+use Getopt::Std;
+use Cwd;
+use Cwd 'abs_path';
+
+$PNAME = $0;
+$PNAME =~ s:.*/::;
+$OPTSTR = 'abd:fghi:jlnqsx:';
+$USAGE = "Usage: $PNAME [-abfghjlnqs] [-d dir] [-i isa] "
+ . "[-x opt[=arg]] [file | dir ...]\n";
+($MACH = `uname -p`) =~ s/\W*\n//;
+($PLATFORM = `uname -i`) =~ s/\W*\n//;
+
+@dtrace_argv = ();
+
+$ksh_path = '/usr/bin/ksh';
+
+@files = ();
+%exceptions = ();
+%results = ();
+$errs = 0;
+
+#
+# If no test files are specified on the command-line, execute a find on "."
+# and append any tst.*.d, tst.*.ksh, err.*.d or drp.*.d files found within
+# the directory tree.
+#
+sub wanted
+{
+ push(@files, $File::Find::name)
+ if ($_ =~ /^(tst|err|drp)\..+\.(d|ksh)$/ && -f "$_");
+}
+
+sub dirname {
+ my($s) = @_;
+ my($i);
+
+ $s = substr($s, 0, $i) if (($i = rindex($s, '/')) != -1);
+ return $i == -1 ? '.' : $i == 0 ? '/' : $s;
+}
+
+sub usage
+{
+ print $USAGE;
+ print "\t -a execute test suite using anonymous enablings\n";
+ print "\t -b execute bad ioctl test program\n";
+ print "\t -d specify directory for test results files and cores\n";
+ print "\t -g enable libumem debugging when running tests\n";
+ print "\t -f force bypassed tests to run\n";
+ print "\t -h display verbose usage message\n";
+ print "\t -i specify ISA to test instead of isaexec(3C) default\n";
+ print "\t -j execute test suite using jdtrace (Java API) only\n";
+ print "\t -l save log file of results and PIDs used by tests\n";
+ print "\t -n execute test suite using dtrace(1m) only\n";
+ print "\t -q set quiet mode (only report errors and summary)\n";
+ print "\t -s save results files even for tests that pass\n";
+ print "\t -x pass corresponding -x argument to dtrace(1M)\n";
+ exit(2);
+}
+
+sub errmsg
+{
+ my($msg) = @_;
+
+ print STDERR $msg;
+ print LOG $msg if ($opt_l);
+ $errs++;
+}
+
+sub fail
+{
+ my(@parms) = @_;
+ my($msg) = $parms[0];
+ my($errfile) = $parms[1];
+ my($n) = 0;
+ my($dest) = basename($file);
+
+ while (-d "$opt_d/failure.$n") {
+ $n++;
+ }
+
+ unless (mkdir "$opt_d/failure.$n") {
+ warn "ERROR: failed to make directory $opt_d/failure.$n: $!\n";
+ exit(125);
+ }
+
+ open(README, ">$opt_d/failure.$n/README");
+ print README "ERROR: " . $file . " " . $msg;
+
+ if (scalar @parms > 1) {
+ print README "; see $errfile\n";
+ } else {
+ if (-f "$opt_d/$pid.core") {
+ print README "; see $pid.core\n";
+ } else {
+ print README "\n";
+ }
+ }
+
+ close(README);
+
+ if (-f "$opt_d/$pid.out") {
+ rename("$opt_d/$pid.out", "$opt_d/failure.$n/$pid.out");
+ link("$file.out", "$opt_d/failure.$n/$dest.out");
+ }
+
+ if (-f "$opt_d/$pid.err") {
+ rename("$opt_d/$pid.err", "$opt_d/failure.$n/$pid.err");
+ link("$file.err", "$opt_d/failure.$n/$dest.err");
+ }
+
+ if (-f "$opt_d/$pid.core") {
+ rename("$opt_d/$pid.core", "$opt_d/failure.$n/$pid.core");
+ }
+
+ link("$file", "$opt_d/failure.$n/$dest");
+
+ $msg = "ERROR: " . $dest . " " . $msg;
+
+ if (scalar @parms > 1) {
+ $msg = $msg . "; see $errfile in failure.$n\n";
+ } else {
+ $msg = $msg . "; details in failure.$n\n";
+ }
+
+ errmsg($msg);
+}
+
+sub logmsg
+{
+ my($msg) = @_;
+
+ print STDOUT $msg unless ($opt_q);
+ print LOG $msg if ($opt_l);
+}
+
+# Trim leading and trailing whitespace
+sub trim {
+ my($s) = @_;
+
+ $s =~ s/^\s*//;
+ $s =~ s/\s*$//;
+ return $s;
+}
+
+# Load exception set of skipped tests from the file at the given
+# pathname. The test names are assumed to be paths relative to $dt_tst,
+# for example: common/aggs/tst.neglquant.d, and specify tests to be
+# skipped.
+sub load_exceptions {
+ my($listfile) = @_;
+ my($line) = "";
+
+ %exceptions = ();
+ if (length($listfile) > 0) {
+ exit(123) unless open(STDIN, "<$listfile");
+ while (<STDIN>) {
+ chomp;
+ $line = $_;
+ # line is non-empty and not a comment
+ if ((length($line) > 0) && ($line =~ /^\s*[^\s#]/ )) {
+ $exceptions{trim($line)} = 1;
+ }
+ }
+ }
+}
+
+# Return 1 if the test is found in the exception set, 0 otherwise.
+sub is_exception {
+ my($file) = @_;
+ my($i) = -1;
+
+ if (scalar(keys(%exceptions)) == 0) {
+ return 0;
+ }
+
+ # hash absolute pathname after $dt_tst/
+ $file = abs_path($file);
+ $i = index($file, $dt_tst);
+ if ($i == 0) {
+ $file = substr($file, length($dt_tst) + 1);
+ return $exceptions{$file};
+ }
+ return 0;
+}
+
+#
+# Iterate over the set of test files specified on the command-line or by a find
+# on "$defdir/common", "$defdir/$MACH" and "$defdir/$PLATFORM" and execute each
+# one. If the test file is executable, we fork and exec it. If the test is a
+# .ksh file, we run it with $ksh_path. Otherwise we run dtrace -s on it. If
+# the file is named tst.* we assume it should return exit status 0. If the
+# file is named err.* we assume it should return exit status 1. If the file is
+# named err.D_[A-Z0-9]+[.*].d we use dtrace -xerrtags and examine stderr to
+# ensure that a matching error tag was produced. If the file is named
+# drp.[A-Z0-9]+[.*].d we use dtrace -xdroptags and examine stderr to ensure
+# that a matching drop tag was produced. If any *.out or *.err files are found
+# we perform output comparisons.
+#
+# run_tests takes two arguments: The first is the pathname of the dtrace
+# command to invoke when running the tests. The second is the pathname
+# of a file (may be the empty string) listing tests that ought to be
+# skipped (skipped tests are listed as paths relative to $dt_tst, for
+# example: common/aggs/tst.neglquant.d).
+#
+sub run_tests {
+ my($dtrace, $exceptions_path) = @_;
+ my($passed) = 0;
+ my($bypassed) = 0;
+ my($failed) = $errs;
+ my($total) = 0;
+
+ die "$PNAME: $dtrace not found\n" unless (-x "$dtrace");
+ logmsg($dtrace . "\n");
+
+ load_exceptions($exceptions_path);
+
+ foreach $file (sort @files) {
+ $file =~ m:.*/((.*)\.(\w+)):;
+ $name = $1;
+ $base = $2;
+ $ext = $3;
+
+ $dir = dirname($file);
+ $isksh = 0;
+ $tag = 0;
+ $droptag = 0;
+
+ if ($name =~ /^tst\./) {
+ $isksh = ($ext eq 'ksh');
+ $status = 0;
+ } elsif ($name =~ /^err\.(D_[A-Z0-9_]+)\./) {
+ $status = 1;
+ $tag = $1;
+ } elsif ($name =~ /^err\./) {
+ $status = 1;
+ } elsif ($name =~ /^drp\.([A-Z0-9_]+)\./) {
+ $status = 0;
+ $droptag = $1;
+ } else {
+ errmsg("ERROR: $file is not a valid test file name\n");
+ next;
+ }
+
+ $fullname = "$dir/$name";
+ $exe = "$dir/$base.exe";
+ $exe_pid = -1;
+
+ if ($opt_a && ($status != 0 || $tag != 0 || $droptag != 0 ||
+ -x $exe || $isksh || -x $fullname)) {
+ $bypassed++;
+ next;
+ }
+
+ if (!$opt_f && is_exception("$dir/$name")) {
+ $bypassed++;
+ next;
+ }
+
+ if (!$isksh && -x $exe) {
+ if (($exe_pid = fork()) == -1) {
+ errmsg(
+ "ERROR: failed to fork to run $exe: $!\n");
+ next;
+ }
+
+ if ($exe_pid == 0) {
+ open(STDIN, '</dev/null');
+
+ exec($exe);
+
+ warn "ERROR: failed to exec $exe: $!\n";
+ }
+ }
+
+ logmsg("testing $file ... ");
+
+ if (($pid = fork()) == -1) {
+ errmsg("ERROR: failed to fork to run test $file: $!\n");
+ next;
+ }
+
+ if ($pid == 0) {
+ open(STDIN, '</dev/null');
+ exit(125) unless open(STDOUT, ">$opt_d/$$.out");
+ exit(125) unless open(STDERR, ">$opt_d/$$.err");
+
+ unless (chdir($dir)) {
+ warn "ERROR: failed to chdir for $file: $!\n";
+ exit(126);
+ }
+
+ push(@dtrace_argv, '-xerrtags') if ($tag);
+ push(@dtrace_argv, '-xdroptags') if ($droptag);
+ push(@dtrace_argv, $exe_pid) if ($exe_pid != -1);
+
+ if ($isksh) {
+ exit(123) unless open(STDIN, "<$name");
+ exec("$ksh_path /dev/stdin $dtrace");
+ } elsif (-x $name) {
+ warn "ERROR: $name is executable\n";
+ exit(1);
+ } else {
+ if ($tag == 0 && $status == $0 && $opt_a) {
+ push(@dtrace_argv, '-A');
+ }
+
+ push(@dtrace_argv, '-C');
+ push(@dtrace_argv, '-s');
+ push(@dtrace_argv, $name);
+ exec($dtrace, @dtrace_argv);
+ }
+
+ warn "ERROR: failed to exec for $file: $!\n";
+ exit(127);
+ }
+
+ if (waitpid($pid, 0) == -1) {
+ errmsg("ERROR: timed out waiting for $file\n");
+ kill(9, $exe_pid) if ($exe_pid != -1);
+ kill(9, $pid);
+ next;
+ }
+
+ kill(9, $exe_pid) if ($exe_pid != -1);
+
+ if ($tag == 0 && $status == $0 && $opt_a) {
+ #
+ # We can chuck the earler output.
+ #
+ unlink($pid . '.out');
+ unlink($pid . '.err');
+
+ #
+ # This is an anonymous enabling. We need to get
+ # the module unloaded.
+ #
+ system("dtrace -ae 1> /dev/null 2> /dev/null");
+ system("svcadm disable -s " .
+ "svc:/network/nfs/mapid:default");
+ system("modunload -i 0 ; modunload -i 0 ; " .
+ "modunload -i 0");
+ if (!system("modinfo | grep dtrace")) {
+ warn "ERROR: couldn't unload dtrace\n";
+ system("svcadm enable " .
+ "-s svc:/network/nfs/mapid:default");
+ exit(124);
+ }
+
+ #
+ # DTrace is gone. Now update_drv(1M), and rip
+ # everything out again.
+ #
+ system("update_drv dtrace");
+ system("dtrace -ae 1> /dev/null 2> /dev/null");
+ system("modunload -i 0 ; modunload -i 0 ; " .
+ "modunload -i 0");
+ if (!system("modinfo | grep dtrace")) {
+ warn "ERROR: couldn't unload dtrace\n";
+ system("svcadm enable " .
+ "-s svc:/network/nfs/mapid:default");
+ exit(124);
+ }
+
+ #
+ # Now bring DTrace back in.
+ #
+ system("sync ; sync");
+ system("dtrace -l -n bogusprobe 1> /dev/null " .
+ "2> /dev/null");
+ system("svcadm enable -s " .
+ "svc:/network/nfs/mapid:default");
+
+ #
+ # That should have caused DTrace to reload with
+ # the new configuration file. Now we can try to
+ # snag our anonymous state.
+ #
+ if (($pid = fork()) == -1) {
+ errmsg("ERROR: failed to fork to run " .
+ "test $file: $!\n");
+ next;
+ }
+
+ if ($pid == 0) {
+ open(STDIN, '</dev/null');
+ exit(125) unless open(STDOUT, ">$opt_d/$$.out");
+ exit(125) unless open(STDERR, ">$opt_d/$$.err");
+
+ push(@dtrace_argv, '-a');
+
+ unless (chdir($dir)) {
+ warn "ERROR: failed to chdir " .
+ "for $file: $!\n";
+ exit(126);
+ }
+
+ exec($dtrace, @dtrace_argv);
+ warn "ERROR: failed to exec for $file: $!\n";
+ exit(127);
+ }
+
+ if (waitpid($pid, 0) == -1) {
+ errmsg("ERROR: timed out waiting for $file\n");
+ kill(9, $pid);
+ next;
+ }
+ }
+
+ logmsg("[$pid]\n");
+ $wstat = $?;
+ $wifexited = ($wstat & 0xFF) == 0;
+ $wexitstat = ($wstat >> 8) & 0xFF;
+ $wtermsig = ($wstat & 0x7F);
+
+ if (!$wifexited) {
+ fail("died from signal $wtermsig");
+ next;
+ }
+
+ if ($wexitstat == 125) {
+ die "$PNAME: failed to create output file in $opt_d " .
+ "(cd elsewhere or use -d)\n";
+ }
+
+ if ($wexitstat != $status) {
+ fail("returned $wexitstat instead of $status");
+ next;
+ }
+
+ if (-f "$file.out" &&
+ system("cmp -s $file.out $opt_d/$pid.out") != 0) {
+ fail("stdout mismatch", "$pid.out");
+ next;
+ }
+
+ if (-f "$file.err" &&
+ system("cmp -s $file.err $opt_d/$pid.err") != 0) {
+ fail("stderr mismatch: see $pid.err");
+ next;
+ }
+
+ if ($tag) {
+ open(TSTERR, "<$opt_d/$pid.err");
+ $tsterr = <TSTERR>;
+ close(TSTERR);
+
+ unless ($tsterr =~ /: \[$tag\] line \d+:/) {
+ fail("errtag mismatch: see $pid.err");
+ next;
+ }
+ }
+
+ if ($droptag) {
+ $found = 0;
+ open(TSTERR, "<$opt_d/$pid.err");
+
+ while (<TSTERR>) {
+ if (/\[$droptag\] /) {
+ $found = 1;
+ last;
+ }
+ }
+
+ close (TSTERR);
+
+ unless ($found) {
+ fail("droptag mismatch: see $pid.err");
+ next;
+ }
+ }
+
+ unless ($opt_s) {
+ unlink($pid . '.out');
+ unlink($pid . '.err');
+ }
+ }
+
+ if ($opt_a) {
+ #
+ # If we're running with anonymous enablings, we need to
+ # restore the .conf file.
+ #
+ system("dtrace -A 1> /dev/null 2> /dev/null");
+ system("dtrace -ae 1> /dev/null 2> /dev/null");
+ system("modunload -i 0 ; modunload -i 0 ; modunload -i 0");
+ system("update_drv dtrace");
+ }
+
+ $total = scalar(@files);
+ $failed = $errs - $failed;
+ $passed = ($total - $failed - $bypassed);
+ $results{$dtrace} = {
+ "passed" => $passed,
+ "bypassed" => $bypassed,
+ "failed" => $failed,
+ "total" => $total
+ };
+}
+
+die $USAGE unless (getopts($OPTSTR));
+usage() if ($opt_h);
+
+foreach $arg (@ARGV) {
+ if (-f $arg) {
+ push(@files, $arg);
+ } elsif (-d $arg) {
+ find(\&wanted, $arg);
+ } else {
+ die "$PNAME: $arg is not a valid file or directory\n";
+ }
+}
+
+$dt_tst = '/opt/SUNWdtrt/tst';
+$dt_bin = '/opt/SUNWdtrt/bin';
+$defdir = -d $dt_tst ? $dt_tst : '.';
+$bindir = -d $dt_bin ? $dt_bin : '.';
+
+find(\&wanted, "$defdir/common") if (scalar(@ARGV) == 0);
+find(\&wanted, "$defdir/$MACH") if (scalar(@ARGV) == 0);
+find(\&wanted, "$defdir/$PLATFORM") if (scalar(@ARGV) == 0);
+die $USAGE if (scalar(@files) == 0);
+
+$dtrace_path = '/usr/sbin/dtrace';
+$jdtrace_path = "$bindir/jdtrace";
+
+%exception_lists = ("$jdtrace_path" => "$bindir/exception.lst");
+
+if ($opt_j || $opt_n || $opt_i) {
+ @dtrace_cmds = ();
+ push(@dtrace_cmds, $dtrace_path) if ($opt_n);
+ push(@dtrace_cmds, $jdtrace_path) if ($opt_j);
+ push(@dtrace_cmds, "/usr/sbin/$opt_i/dtrace") if ($opt_i);
+} else {
+ @dtrace_cmds = ($dtrace_path, $jdtrace_path);
+}
+
+if ($opt_d) {
+ die "$PNAME: -d arg must be absolute path\n" unless ($opt_d =~ /^\//);
+ die "$PNAME: -d arg $opt_d is not a directory\n" unless (-d "$opt_d");
+ system("coreadm -p $opt_d/%p.core");
+} else {
+ my $dir = getcwd;
+ system("coreadm -p $dir/%p.core");
+ $opt_d = '.';
+}
+
+if ($opt_x) {
+ push(@dtrace_argv, '-x');
+ push(@dtrace_argv, $opt_x);
+}
+
+die "$PNAME: failed to open $PNAME.$$.log: $!\n"
+ unless (!$opt_l || open(LOG, ">$PNAME.$$.log"));
+
+if ($opt_g) {
+ $ENV{'UMEM_DEBUG'} = 'default,verbose';
+ $ENV{'UMEM_LOGGING'} = 'fail,contents';
+ $ENV{'LD_PRELOAD'} = 'libumem.so';
+}
+
+#
+# Ensure that $PATH contains a cc(1) so that we can execute the
+# test programs that require compilation of C code.
+#
+$ENV{'PATH'} = $ENV{'PATH'} . ':/ws/onnv-tools/SUNWspro/SS11/bin';
+
+if ($opt_b) {
+ logmsg("badioctl'ing ... ");
+
+ if (($badioctl = fork()) == -1) {
+ errmsg("ERROR: failed to fork to run badioctl: $!\n");
+ next;
+ }
+
+ if ($badioctl == 0) {
+ open(STDIN, '</dev/null');
+ exit(125) unless open(STDOUT, ">$opt_d/$$.out");
+ exit(125) unless open(STDERR, ">$opt_d/$$.err");
+
+ exec($bindir . "/badioctl");
+ warn "ERROR: failed to exec badioctl: $!\n";
+ exit(127);
+ }
+
+
+ logmsg("[$badioctl]\n");
+
+ #
+ # If we're going to be bad, we're just going to iterate over each
+ # test file.
+ #
+ foreach $file (sort @files) {
+ ($name = $file) =~ s:.*/::;
+ $dir = dirname($file);
+
+ if (!($name =~ /^tst\./ && $name =~ /\.d$/)) {
+ next;
+ }
+
+ logmsg("baddof'ing $file ... ");
+
+ if (($pid = fork()) == -1) {
+ errmsg("ERROR: failed to fork to run baddof: $!\n");
+ next;
+ }
+
+ if ($pid == 0) {
+ open(STDIN, '</dev/null');
+ exit(125) unless open(STDOUT, ">$opt_d/$$.out");
+ exit(125) unless open(STDERR, ">$opt_d/$$.err");
+
+ unless (chdir($dir)) {
+ warn "ERROR: failed to chdir for $file: $!\n";
+ exit(126);
+ }
+
+ exec($bindir . "/baddof", $name);
+
+ warn "ERROR: failed to exec for $file: $!\n";
+ exit(127);
+ }
+
+ sleep 60;
+ kill(9, $pid);
+ waitpid($pid, 0);
+
+ logmsg("[$pid]\n");
+
+ unless ($opt_s) {
+ unlink($pid . '.out');
+ unlink($pid . '.err');
+ }
+ }
+
+ kill(9, $badioctl);
+ waitpid($badioctl, 0);
+
+ unless ($opt_s) {
+ unlink($badioctl . '.out');
+ unlink($badioctl . '.err');
+ }
+
+ exit(0);
+}
+
+#
+# Run all the tests specified on the command-line (the entire test suite
+# by default) once for each dtrace command tested, skipping any tests
+# not valid for that command.
+#
+foreach $dtrace_cmd (@dtrace_cmds) {
+ run_tests($dtrace_cmd, $exception_lists{$dtrace_cmd});
+}
+
+$opt_q = 0; # force final summary to appear regardless of -q option
+
+logmsg("\n==== TEST RESULTS ====\n");
+foreach $key (keys %results) {
+ my $passed = $results{$key}{"passed"};
+ my $bypassed = $results{$key}{"bypassed"};
+ my $failed = $results{$key}{"failed"};
+ my $total = $results{$key}{"total"};
+
+ logmsg("\n mode: " . $key . "\n");
+ logmsg(" passed: " . $passed . "\n");
+ if ($bypassed) {
+ logmsg(" bypassed: " . $bypassed . "\n");
+ }
+ logmsg(" failed: " . $failed . "\n");
+ logmsg(" total: " . $total . "\n");
+}
+
+exit($errs != 0);
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile
new file mode 100644
index 00000000..27c9c699
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile
@@ -0,0 +1,39 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/Makefile.master
+
+SUBDIRS= common $(MACH:i386=i386 i86xpv)
+include ../Makefile.subdirs
+
+dstyle := TARGET += dstyle
+
+check: FRC
+ @$(ECHO) "checking dstyle"
+ @$(MAKE) dstyle
+
+dstyle: $(SUBDIRS)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.com b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.com
new file mode 100644
index 00000000..a23b8d65
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.com
@@ -0,0 +1,104 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include $(SRC)/cmd/Makefile.cmd
+
+.KEEP_STATE:
+
+ROOTOPTPKG = $(ROOT)/opt/SUNWdtrt
+ROOTTST = $(ROOTOPTPKG)/tst
+SUBDIR :sh= basename `pwd`
+TSTDIR = $(ROOTTST)/$(SUBDIR)
+DSTYLE = $(ROOTOPTPKG)/bin/dstyle
+
+CSRCS :sh= find . -name SCCS -prune -o -name *.c -print | cut -b3-
+SSRCS :sh= find . -name SCCS -prune -o -name *.s -print | cut -b3-
+DSRCS :sh= find . -name SCCS -prune -o -name *.d -print | cut -b3-
+
+TSTS :sh= find . -name tst.*.d -o -name err.*.d -o \
+ -name tst.*.d.out -o -name err.*.d.out -o -name tst.*.ksh \
+ -o -name err.*.ksh -o -name tst.*.ksh.out -o -name drp.*.d \
+ -o -name get.*.pl
+
+EXES :sh= find . -name SCCS -prune -o \( -name *.exe -o -name \*.pl \) -print \
+ | cut -b3-
+EXES += $(CSRCS:%.c=%.exe)
+EXES += $(SSRCS:%.s=%.exe)
+
+ROOT_TSTS = $(TSTS:%=$(TSTDIR)/%)
+ROOT_EXES = $(EXES:%=$(TSTDIR)/%)
+
+$(ROOT_TSTS) := FILEMODE = 0444
+$(ROOT_EXES) := FILEMODE = 0555
+
+all: $(EXES)
+
+clean lint:
+
+clobber: FRC
+ -$(RM) $(CSRCS:%.c=%.exe) $(CSRCS:%.c=%.o)
+ -$(RM) $(SSRCS:%.s=%.exe) $(SSRCS:%.s=%.o)
+ -$(RM) $(DSRCS:%.d=%.o)
+ -$(RM) $(CLOBBERFILES)
+
+install: $(ROOT_TSTS) $(ROOT_EXES)
+
+$(ROOT_TSTS): $(TSTDIR)
+
+$(ROOT_EXES): $(TSTDIR)
+
+$(TSTDIR):
+ $(INS.dir)
+
+$(TSTDIR)/%: %
+ $(INS) -s -d -m $(DIRMODE) $(@D)
+ $(INS.file)
+
+%.exe: %.c
+ $(LINK.c) -o $@ $< $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+%.exe: %.o
+ $(LINK.c) -o $@ $< $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+%.o: %.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+%.o: %.s
+ $(COMPILE.s) -o $@ $<
+ $(POST_PROCESS_O)
+
+scripts: FRC
+ @cd ../cmd/scripts; pwd; $(MAKE) install
+
+dstyle: FRC
+ @if [ -n "$(DSRCS)" ]; then $(DSTYLE) $(DSRCS); fi
+
+FRC:
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile
new file mode 100644
index 00000000..065124ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile
@@ -0,0 +1,101 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include $(SRC)/Makefile.master
+include ../Makefile.com
+
+SNOOPDIR = $(SRC)/cmd/cmd-inet/usr.sbin/snoop
+SNOOPOBJS = nfs4_xdr.o
+SNOOPSRCS = ${SNOOPOBJS:%.o=%.c}
+CLOBBERFILES += nfs/$(SNOOPOBJS)
+
+RPCSVCDIR = $(SRC)/head/rpcsvc
+RPCSVCOBJS = nfs_prot.o
+RPCSVCSRCS = ${RPCSVCOBJS:%o=%c}
+CLOBBERFILES += nfs/$(RPCSVCOBJS) $(RPCSVCDIR)/$(RPCSVCSRCS)
+
+fasttrap/tst.fasttrap.exe := LDLIBS += -ldtrace
+fasttrap/tst.stack.exe := LDLIBS += -ldtrace
+
+sysevent/tst.post.exe := LDLIBS += -lsysevent
+sysevent/tst.post_chan.exe := LDLIBS += -lsysevent
+
+ustack/tst.bigstack.exe := COPTFLAG += -xO1
+
+GCC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
+
+nfs/%.o: $(SNOOPDIR)/%.c
+ $(COMPILE.c) -o $@ $< -I$(SNOOPDIR)
+ $(POST_PROCESS_O)
+nfs/tst.call.exe: nfs/tst.call.o nfs/$(SNOOPOBJS)
+ $(LINK.c) -o $@ nfs/tst.call.o nfs/$(SNOOPOBJS) $(LDLIBS) -lnsl
+ $(POST_PROCESS) ; $(STRIP_STABS)
+$(RPCSVCDIR)/%.c: $(RPCSVCDIR)/%.x
+ $(RPCGEN) -Cc $< > $@
+nfs/$(RPCSVCOBJS): $(RPCSVCDIR)/$(RPCSVCSRCS)
+ $(COMPILE.c) -o $@ $(RPCSVCDIR)/$(RPCSVCSRCS)
+ $(POST_PROCESS_O)
+nfs/tst.call3.exe: nfs/tst.call3.o nfs/$(RPCSVCOBJS)
+ $(LINK.c) -o $@ nfs/tst.call3.o nfs/$(RPCSVCOBJS) \
+ $(LDLIBS) -lnsl -lrpcsvc
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+pid/tst.gcc.exe: pid/tst.gcc.c
+ $(GCC) -o pid/tst.gcc.exe pid/tst.gcc.c $(LDFLAGS)
+ $(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)
+
+usdt/args.o: usdt/args.d usdt/tst.args.o
+ $(COMPILE.d) -o usdt/args.o -s usdt/args.d usdt/tst.args.o
+
+usdt/tst.argmap.exe: usdt/tst.argmap.o usdt/argmap.o
+ $(LINK.c) -o usdt/tst.argmap.exe usdt/tst.argmap.o usdt/argmap.o \
+ $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+usdt/argmap.o: usdt/argmap.d usdt/tst.argmap.o
+ $(COMPILE.d) -o usdt/argmap.o -s usdt/argmap.d usdt/tst.argmap.o
+
+usdt/tst.forker.exe: usdt/tst.forker.o usdt/forker.o
+ $(LINK.c) -o usdt/tst.forker.exe usdt/tst.forker.o usdt/forker.o \
+ $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+usdt/forker.o: usdt/forker.d usdt/tst.forker.o
+ $(COMPILE.d) -o usdt/forker.o -s usdt/forker.d usdt/tst.forker.o
+
+usdt/tst.forker.o: usdt/forker.h
+
+usdt/forker.h: usdt/forker.d
+ $(DTRACE) -h -s usdt/forker.d -o usdt/forker.h
+
+SUBDIRS = java_api
+include ../../Makefile.subdirs
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_FUNC.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_FUNC.bad.d
new file mode 100644
index 00000000..d12454be
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_FUNC.bad.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * An aggregation must call an aggregating function.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+
+ @counts["xyz"] = breakpoint();
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_MDIM.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_MDIM.bad.d
new file mode 100644
index 00000000..2c47289b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_MDIM.bad.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * An aggregation may not be used as a multi-dimensional array
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+
+ @counts[0][2] = count();
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_NULL.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_NULL.bad.d
new file mode 100644
index 00000000..87d18187
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_NULL.bad.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * An aggregation must have an aggregating function applied.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+
+ @a[1];
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_REDEF.redef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_REDEF.redef.d
new file mode 100644
index 00000000..9b4b425e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_REDEF.redef.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test redefining the aggregation
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a = count();
+}
+
+END
+{
+ @a = max(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.avgtoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.avgtoofew.d
new file mode 100644
index 00000000..106f4cde
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.avgtoofew.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * avg() should not accept a non-scalar value
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a[pid] = avg(probefunc);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.maxnoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.maxnoarg.d
new file mode 100644
index 00000000..181e1962
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.maxnoarg.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * max() should not accept a non-scalar value
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+BEGIN
+{
+ @a[pid] = max(probefunc);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.mintoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.mintoofew.d
new file mode 100644
index 00000000..3ca34ffb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.mintoofew.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * min() should not accept a non-scalar value
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[pid] = min(probefunc);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.quantizetoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.quantizetoofew.d
new file mode 100644
index 00000000..b7464552
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.quantizetoofew.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * quantize() should not accept a non-scalar value
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[pid] = quantize(probefunc);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.stddevtoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.stddevtoofew.d
new file mode 100644
index 00000000..262040f1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.stddevtoofew.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * stddev() should not accept a non-scalar value
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a[pid] = stddev(probefunc);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.sumtoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.sumtoofew.d
new file mode 100644
index 00000000..a77a2d5d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.sumtoofew.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * sum() should not accept a non-scalar value
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[pid] = sum(probefunc);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_AGGARG.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_AGGARG.bad.d
new file mode 100644
index 00000000..0e6060ae
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_AGGARG.bad.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * The argument to clear() must be an aggregation.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=10ms
+#pragma D option switchrate=10ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i%5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 10/
+{
+ printf("Aggregation data before clear():\n");
+ printa(@func);
+
+ clear(count());
+
+ printf("Aggregation data after clear():\n");
+ printa(@func);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("Final aggregation data:\n");
+ printa(@func);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_PROTO.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_PROTO.bad.d
new file mode 100644
index 00000000..57fa8841
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_PROTO.bad.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * clear() should handle no args as an error.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=10ms
+#pragma D option switchrate=10ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i%5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 10/
+{
+ printf("Aggregation data before clear():\n");
+ printa(@func);
+
+ clear();
+
+ printf("Aggregation data after clear():\n");
+ printa(@func);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("Final aggregation data:\n");
+ printa(@func);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_IDENT.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_IDENT.bad.d
new file mode 100644
index 00000000..866a7acf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_IDENT.bad.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * An aggregation must call an aggregating function, not a probe
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+
+ @counts[0][2] = tick-1();
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_UNDEF.badaggfunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_UNDEF.badaggfunc.d
new file mode 100644
index 00000000..65c12da4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_UNDEF.badaggfunc.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the use of a non-supported aggregate function.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+
+BEGIN
+{
+ @counts["badtest"] = foo();
+
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badexpr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badexpr.d
new file mode 100644
index 00000000..83e6ab79
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badexpr.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test using an aggregation in an expression context.
+ * This should result in a compile-time error.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ trace(@a + 3);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badkey3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badkey3.d
new file mode 100644
index 00000000..67c5b64e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badkey3.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the use of a dynamic expression as an aggregation key.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ @t[i] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.noeffect.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.noeffect.d
new file mode 100644
index 00000000..9bdff789
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.noeffect.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test compiling an aggregation statement that has no effect.
+ * This should result in a compile-time error.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey1.d
new file mode 100644
index 00000000..abf3dd8c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey1.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the use of a void expression as an aggregation key.
+ * This should result in a compile-time error.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1, (void)0] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey2.d
new file mode 100644
index 00000000..9490b821
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey2.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the use of a dynamic expression as an aggregation key.
+ * This should result in a compile-time error.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[0] = count();
+ @b[@a] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey4.d
new file mode 100644
index 00000000..057746eb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey4.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test the use of a dynamic expression as an aggregation key.
+ * This should result in a compile-time error.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ @a[curpsinfo] = count();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqbad1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqbad1.d
new file mode 100644
index 00000000..6bb6765a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqbad1.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() lower bound around must be an integer constant
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ x = 'a';
+ @a[1] = lquantize(timestamp, x, 1000, 1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqshort.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqshort.d
new file mode 100644
index 00000000..6bb6765a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqshort.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() lower bound around must be an integer constant
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ x = 'a';
+ @a[1] = lquantize(timestamp, x, 1000, 1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASEVAL.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASEVAL.bad.d
new file mode 100644
index 00000000..23d318e7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASEVAL.bad.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() lower bound must be a 32-bit quantity
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = lquantize(timestamp, 2147483657, 1000, 1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMTYPE.lqbad1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMTYPE.lqbad1.d
new file mode 100644
index 00000000..894f064a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMTYPE.lqbad1.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() upper bound around must be an integer constant
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ x = 'a';
+ @a[1] = lquantize(timestamp, 100, rand(), 1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMVAL.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMVAL.bad.d
new file mode 100644
index 00000000..0a2f5e7f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMVAL.bad.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() upper bound around must be an integer constant
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ x = 'a';
+ @a[1] = lquantize(timestamp, 100, 2147483657, 1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.d
new file mode 100644
index 00000000..b93ffabf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.d
@@ -0,0 +1,33 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @ = lquantize(0, 10, 20, 1);
+ @ = lquantize(0, 15, 20, 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.order.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.order.d
new file mode 100644
index 00000000..763c1e0b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.order.d
@@ -0,0 +1,33 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @ = lquantize(0, 10, 20, 1);
+ @ = lquantize(0, 15, 30, 10);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.d
new file mode 100644
index 00000000..d9ba023e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.d
@@ -0,0 +1,33 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @ = lquantize(0, 10, 20, 1);
+ @ = lquantize(0, 10, 2000, 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.order.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.order.d
new file mode 100644
index 00000000..62be0c5b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.order.d
@@ -0,0 +1,33 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @ = lquantize(0, 10, 20, 1);
+ @ = lquantize(0, 10, 2000, 10);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHSTEP.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHSTEP.d
new file mode 100644
index 00000000..086f4392
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHSTEP.d
@@ -0,0 +1,33 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @ = lquantize(0, 10, 20, 1);
+ @ = lquantize(0, 10, 20, 2);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MISMATCH.lqbadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MISMATCH.lqbadarg.d
new file mode 100644
index 00000000..a4444ad1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MISMATCH.lqbadarg.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Upper bound must be greater than lower bound argument
+ *
+ * SECTION: Aggregations/Aggregations
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-1
+/i < 1000/
+{
+ @a[i] = lquantize(i, 1100, -100, -100 );
+ i += 100;
+}
+
+tick-1
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPLARGE.lqtoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPLARGE.lqtoofew.d
new file mode 100644
index 00000000..664f70f2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPLARGE.lqtoofew.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() should not accept more than 4 arguments.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = lquantize(1, 2, 3, 4, 5);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPSMALL.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPSMALL.bad.d
new file mode 100644
index 00000000..634e8c06
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPSMALL.bad.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Number of quantization levels must be a 16-bit quantity
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a[i] = lquantize(i, 0, 1000000, 10);
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPTYPE.lqbadinc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPTYPE.lqbadinc.d
new file mode 100644
index 00000000..87c51273
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPTYPE.lqbadinc.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Upper bound must be greater than lower bound argument
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-1
+/i < 1000/
+{
+ @a[i] = lquantize(i, 0, 1100, -100);
+ i += 100;
+}
+
+tick-1
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPVAL.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPVAL.bad.d
new file mode 100644
index 00000000..a90d7571
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPVAL.bad.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() step value should be a 16-bit quantity
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a[i] = lquantize(i, 100, 1100, 200000 );
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_AGGARG.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_AGGARG.bad.d
new file mode 100644
index 00000000..7e5974c5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_AGGARG.bad.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * The first argument to normalize() should be an aggregation.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=1ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i % 5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+
+ printf("normalized data:\n");
+ normalize(count(), 4);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_PROTO.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_PROTO.bad.d
new file mode 100644
index 00000000..82d819d4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_PROTO.bad.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * normalize() accepts 2 args - passing fewer is an error.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=1ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i % 5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("normalized data:\n");
+ normalize(@func);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_SCALAR.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_SCALAR.bad.d
new file mode 100644
index 00000000..14a25864
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_SCALAR.bad.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * The second argument to normalize() should be a scalar.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=1ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i % 5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("normalized data:\n");
+ normalize(@func, "hello");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_ARG.lquantizetoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_ARG.lquantizetoofew.d
new file mode 100644
index 00000000..db4567f8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_ARG.lquantizetoofew.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() should not accept a non-scalar value
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[pid] = lquantize(probefunc, probefunc, probefunc, probefunc);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgnoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgnoarg.d
new file mode 100644
index 00000000..628eeaba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgnoarg.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * avg() should not accept a call with no arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a[1] = avg();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgtoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgtoomany.d
new file mode 100644
index 00000000..42e5c1cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgtoomany.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * avg() should not more than one argument
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a[1] = avg(1, 2);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.counttoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.counttoomany.d
new file mode 100644
index 00000000..5dc5b800
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.counttoomany.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * count() should not accept any arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a["badtest"] = count(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizenoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizenoarg.d
new file mode 100644
index 00000000..ae4b6724
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizenoarg.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * lquantize() should not accept a call with no arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = lquantize();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizetoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizetoomany.d
new file mode 100644
index 00000000..bf87a468
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizetoomany.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * lquantize() should not have more than five (!) arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @[1] = lquantize(10, 0, 100, 1, 10, 20);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxnoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxnoarg.d
new file mode 100644
index 00000000..aad2c249
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxnoarg.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * max() should not accept a call with no arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = max();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxtoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxtoomany.d
new file mode 100644
index 00000000..d0fb0918
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxtoomany.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * max() should not more than one argument
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = max(1, 2);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.minnoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.minnoarg.d
new file mode 100644
index 00000000..09db51f2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.minnoarg.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * min() should not accept a call with no arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = min();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.mintoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.mintoomany.d
new file mode 100644
index 00000000..2647402c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.mintoomany.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * min() should not more than one argument
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = min(1, 2);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizenoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizenoarg.d
new file mode 100644
index 00000000..b33957a2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizenoarg.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * quantize() should not accept a call with no arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = quantize();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizetoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizetoomany.d
new file mode 100644
index 00000000..9b162bd2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizetoomany.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * quantize() should not have more than two arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[1] = quantize(1, 2, 3);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevnoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevnoarg.d
new file mode 100644
index 00000000..2952cf50
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevnoarg.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * stddev() should not accept a call with no arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a[1] = stddev();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevtoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevtoomany.d
new file mode 100644
index 00000000..c42e9628
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevtoomany.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * stddev() should not have more than one argument
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a[1] = stddev(1, 2);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumnoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumnoarg.d
new file mode 100644
index 00000000..4f279017
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumnoarg.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * sum() should not accept a call with no arguments
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[pid] = sum();
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumtoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumtoomany.d
new file mode 100644
index 00000000..5e899be6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumtoomany.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * sum() should not more than one argument
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+BEGIN
+{
+ @a[pid] = sum(1, 2);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_AGGARG.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_AGGARG.bad.d
new file mode 100644
index 00000000..69cb7291
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_AGGARG.bad.d
@@ -0,0 +1,35 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+int i;
+
+BEGIN
+{
+ trunc(i);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badmany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badmany.d
new file mode 100644
index 00000000..61271a74
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badmany.d
@@ -0,0 +1,34 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @[0] = count();
+ trunc(@, 10, 20);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badnone.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badnone.d
new file mode 100644
index 00000000..e141e6c9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badnone.d
@@ -0,0 +1,33 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ trunc();
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_SCALAR.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_SCALAR.bad.d
new file mode 100644
index 00000000..e5485766
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_SCALAR.bad.d
@@ -0,0 +1,34 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @[0] = count();
+ trunc(@, @);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d
new file mode 100644
index 00000000..26241b31
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+int i;
+
+tick-10ms
+{
+ @ = quantize(1LL << i);
+ @ = quantize((1LL << i) + 1);
+ @ = quantize(-(1LL << i));
+ @ = quantize(-(1LL << i) - 1);
+ i++;
+}
+
+tick-10ms
+/i == 64/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d.out
new file mode 100644
index 00000000..356d6b46
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.allquant.d.out
@@ -0,0 +1,131 @@
+
+
+ value ------------- Distribution ------------- count
+-4611686018427387904 |@ 5
+-2305843009213693952 | 2
+-1152921504606846976 | 2
+-576460752303423488 | 2
+-288230376151711744 | 2
+-144115188075855872 | 2
+-72057594037927936 | 2
+-36028797018963968 | 2
+-18014398509481984 | 2
+-9007199254740992 | 2
+-4503599627370496 | 2
+-2251799813685248 | 2
+-1125899906842624 | 2
+-562949953421312 | 2
+-281474976710656 | 2
+-140737488355328 | 2
+ -70368744177664 | 2
+ -35184372088832 | 2
+ -17592186044416 | 2
+ -8796093022208 | 2
+ -4398046511104 | 2
+ -2199023255552 | 2
+ -1099511627776 | 2
+ -549755813888 | 2
+ -274877906944 | 2
+ -137438953472 | 2
+ -68719476736 | 2
+ -34359738368 | 2
+ -17179869184 | 2
+ -8589934592 | 2
+ -4294967296 | 2
+ -2147483648 | 2
+ -1073741824 | 2
+ -536870912 | 2
+ -268435456 | 2
+ -134217728 | 2
+ -67108864 | 2
+ -33554432 | 2
+ -16777216 | 2
+ -8388608 | 2
+ -4194304 | 2
+ -2097152 | 2
+ -1048576 | 2
+ -524288 | 2
+ -262144 | 2
+ -131072 | 2
+ -65536 | 2
+ -32768 | 2
+ -16384 | 2
+ -8192 | 2
+ -4096 | 2
+ -2048 | 2
+ -1024 | 2
+ -512 | 2
+ -256 | 2
+ -128 | 2
+ -64 | 2
+ -32 | 2
+ -16 | 2
+ -8 | 2
+ -4 | 2
+ -2 | 3
+ -1 | 1
+ 0 | 0
+ 1 | 1
+ 2 | 3
+ 4 | 2
+ 8 | 2
+ 16 | 2
+ 32 | 2
+ 64 | 2
+ 128 | 2
+ 256 | 2
+ 512 | 2
+ 1024 | 2
+ 2048 | 2
+ 4096 | 2
+ 8192 | 2
+ 16384 | 2
+ 32768 | 2
+ 65536 | 2
+ 131072 | 2
+ 262144 | 2
+ 524288 | 2
+ 1048576 | 2
+ 2097152 | 2
+ 4194304 | 2
+ 8388608 | 2
+ 16777216 | 2
+ 33554432 | 2
+ 67108864 | 2
+ 134217728 | 2
+ 268435456 | 2
+ 536870912 | 2
+ 1073741824 | 2
+ 2147483648 | 2
+ 4294967296 | 2
+ 8589934592 | 2
+ 17179869184 | 2
+ 34359738368 | 2
+ 68719476736 | 2
+ 137438953472 | 2
+ 274877906944 | 2
+ 549755813888 | 2
+ 1099511627776 | 2
+ 2199023255552 | 2
+ 4398046511104 | 2
+ 8796093022208 | 2
+ 17592186044416 | 2
+ 35184372088832 | 2
+ 70368744177664 | 2
+ 140737488355328 | 2
+ 281474976710656 | 2
+ 562949953421312 | 2
+1125899906842624 | 2
+2251799813685248 | 2
+4503599627370496 | 2
+9007199254740992 | 2
+18014398509481984 | 2
+36028797018963968 | 2
+72057594037927936 | 2
+144115188075855872 | 2
+288230376151711744 | 2
+576460752303423488 | 2
+1152921504606846976 | 2
+2305843009213693952 | 2
+4611686018427387904 | 3
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d
new file mode 100644
index 00000000..a4bfd3cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive avg() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is a simple verifiable positive test of the avg() function.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a = avg(i);
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d.out
new file mode 100644
index 00000000..e3c0687d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg.d.out
@@ -0,0 +1,2 @@
+
+ 450
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d
new file mode 100644
index 00000000..5c1e77d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive avg() test using negative values
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is a simple verifiable positive test of the avg() function.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @ = avg(0);
+ @ = avg(-900);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d.out
new file mode 100644
index 00000000..3fafcd45
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d.out
@@ -0,0 +1,2 @@
+
+ -450
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d
new file mode 100644
index 00000000..2acd8ee9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d
@@ -0,0 +1,75 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for clearing aggregations
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=50ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i%5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 10/
+{
+ printf("Aggregation data before clear():\n");
+ printa(@func);
+
+ clear(@func);
+
+ printf("Aggregation data after clear():\n");
+ printa(@func);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("Final aggregation data:\n");
+ printa(@func);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d.out
new file mode 100644
index 00000000..486e4ac0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clear.d.out
@@ -0,0 +1,22 @@
+Aggregation data before clear():
+
+ 0 500
+ 1 700
+ 2 900
+ 3 1100
+ 4 1300
+Aggregation data after clear():
+
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+Final aggregation data:
+
+ 0 1500
+ 1 2700
+ 2 2900
+ 3 3100
+ 4 3300
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d
new file mode 100644
index 00000000..135e511b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive avg() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES:
+ * Verifies that printing a clear()'d aggregation with an avg()
+ * aggregation function doesn't cause problems.
+ *
+ */
+
+#pragma D option quiet
+
+tick-10ms
+/i++ < 5/
+{
+ @a = avg(timestamp);
+}
+
+tick-10ms
+/i == 5/
+{
+ exit(2);
+}
+
+END
+{
+ clear(@a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d.out
new file mode 100644
index 00000000..8d23188f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d.out
@@ -0,0 +1,2 @@
+
+ 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d
new file mode 100644
index 00000000..0f7a9584
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive avg() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES:
+ * Verifies that printing a clear()'d aggregation with an avg()
+ * aggregation function of 0 doesn't cause divide-by-zero problems.
+ *
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=50ms
+#pragma D option aggrate=1ms
+
+tick-100ms
+/(x++ % 5) == 0/
+{
+ @time = avg(0);
+}
+
+tick-100ms
+/x > 5 && x <= 20/
+{
+ printa(" %@d\n", @time);
+ clear(@time);
+}
+
+tick-100ms
+/x > 20/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d.out
new file mode 100644
index 00000000..7cceedda
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d.out
@@ -0,0 +1,16 @@
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d
new file mode 100644
index 00000000..7aefed03
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Denormalized aggregations can be cleared
+ *
+ * SECTION: Aggregations/Normalization;
+ * Aggregations/Clearing aggregations
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=50ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i != 10 || i != 20/
+{
+ @func[i%5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 10/
+{
+ printf("Denormalized data before clear:\n");
+ denormalize(@func);
+ printa(@func);
+
+ clear(@func);
+
+ printf("Aggregation data after clear:\n");
+ printa(@func);
+ i++
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("Final (denormalized) aggregation data:\n");
+ denormalize(@func);
+ printa(@func);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d.out
new file mode 100644
index 00000000..ed7f2f34
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d.out
@@ -0,0 +1,22 @@
+Denormalized data before clear:
+
+ 0 500
+ 1 700
+ 2 900
+ 3 1100
+ 4 1300
+Aggregation data after clear:
+
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+Final (denormalized) aggregation data:
+
+ 0 1500
+ 1 2700
+ 2 2900
+ 3 3100
+ 4 3300
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d
new file mode 100644
index 00000000..2d0ff838
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive lquantize()/clear() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES:
+ * Verifies that printing a clear()'d aggregation with an lquantize()
+ * aggregation function doesn't cause problems.
+ *
+ */
+
+
+#pragma D option switchrate=50ms
+#pragma D option aggrate=1ms
+#pragma D option quiet
+
+tick-100ms
+{
+ x++;
+ @a["linear"] = lquantize(x, 0, 100, 1);
+ @b["exp"] = quantize(x);
+}
+
+tick-100ms
+/(x % 5) == 0 && y++ < 5/
+{
+ printa(@a);
+ printa(@b);
+ clear(@a);
+ clear(@b);
+}
+
+tick-100ms
+/(x % 5) == 0 && y == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d.out
new file mode 100644
index 00000000..e7e2a600
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d.out
@@ -0,0 +1,94 @@
+
+ linear
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@ 1
+ 2 |@@@@@@@@ 1
+ 3 |@@@@@@@@ 1
+ 4 |@@@@@@@@ 1
+ 5 |@@@@@@@@ 1
+ 6 | 0
+
+
+ exp
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@ 1
+ 2 |@@@@@@@@@@@@@@@@ 2
+ 4 |@@@@@@@@@@@@@@@@ 2
+ 8 | 0
+
+
+ linear
+ value ------------- Distribution ------------- count
+ 5 | 0
+ 6 |@@@@@@@@ 1
+ 7 |@@@@@@@@ 1
+ 8 |@@@@@@@@ 1
+ 9 |@@@@@@@@ 1
+ 10 |@@@@@@@@ 1
+ 11 | 0
+
+
+ exp
+ value ------------- Distribution ------------- count
+ 2 | 0
+ 4 |@@@@@@@@@@@@@@@@ 2
+ 8 |@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 16 | 0
+
+
+ linear
+ value ------------- Distribution ------------- count
+ 10 | 0
+ 11 |@@@@@@@@ 1
+ 12 |@@@@@@@@ 1
+ 13 |@@@@@@@@ 1
+ 14 |@@@@@@@@ 1
+ 15 |@@@@@@@@ 1
+ 16 | 0
+
+
+ exp
+ value ------------- Distribution ------------- count
+ 4 | 0
+ 8 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 16 | 0
+
+
+ linear
+ value ------------- Distribution ------------- count
+ 15 | 0
+ 16 |@@@@@@@@ 1
+ 17 |@@@@@@@@ 1
+ 18 |@@@@@@@@ 1
+ 19 |@@@@@@@@ 1
+ 20 |@@@@@@@@ 1
+ 21 | 0
+
+
+ exp
+ value ------------- Distribution ------------- count
+ 8 | 0
+ 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 32 | 0
+
+
+ linear
+ value ------------- Distribution ------------- count
+ 20 | 0
+ 21 |@@@@@@@@ 1
+ 22 |@@@@@@@@ 1
+ 23 |@@@@@@@@ 1
+ 24 |@@@@@@@@ 1
+ 25 |@@@@@@@@ 1
+ 26 | 0
+
+
+ exp
+ value ------------- Distribution ------------- count
+ 8 | 0
+ 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 32 | 0
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d
new file mode 100644
index 00000000..75cfa2d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Normalized aggregation data can be cleared
+ *
+ * SECTION: Aggregations/Normalization;
+ * Aggregations/Clearing aggregations
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=50ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i % 5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 10/
+{
+ printf("Normalized data before clear:\n");
+ normalize(@func, 5);
+ printa(@func);
+
+ clear(@func);
+
+ printf("Aggregation data after clear:\n");
+ printa(@func);
+ i++
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("Final (normalized) aggregation data:\n");
+ normalize(@func, 5);
+ printa(@func);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d.out
new file mode 100644
index 00000000..e568427e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d.out
@@ -0,0 +1,22 @@
+Normalized data before clear:
+
+ 0 100
+ 1 140
+ 2 180
+ 3 220
+ 4 260
+Aggregation data after clear:
+
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+Final (normalized) aggregation data:
+
+ 0 300
+ 1 540
+ 2 580
+ 3 620
+ 4 660
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d
new file mode 100644
index 00000000..af3ecd56
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Positive stddev() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES:
+ * Verifies that printing a clear()'d aggregation with an stddev()
+ * aggregation function doesn't cause problems.
+ *
+ */
+
+#pragma D option quiet
+
+tick-10ms
+/i++ < 5/
+{
+ @a = stddev(timestamp);
+}
+
+tick-10ms
+/i == 5/
+{
+ exit(2);
+}
+
+END
+{
+ clear(@a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d.out
new file mode 100644
index 00000000..8d23188f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d.out
@@ -0,0 +1,2 @@
+
+ 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d
new file mode 100644
index 00000000..e81d123d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Postive count() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a = count();
+ @a = count();
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d.out
new file mode 100644
index 00000000..d34fd3b0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count.d.out
@@ -0,0 +1,2 @@
+
+ 2
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d
new file mode 100644
index 00000000..624b1b4e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive count() test
+ *
+ * SECTION: Aggregations/Aggregations
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i != 10/
+{
+ i++;
+ @counts["tick-count"] = count();
+}
+
+tick-10ms
+/i == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d.out
new file mode 100644
index 00000000..4998a339
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count2.d.out
@@ -0,0 +1,2 @@
+
+ tick-count 10
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count3.d
new file mode 100644
index 00000000..5913ff60
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.count3.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test multiple count() calls.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i != 10/
+{
+ i++;
+ @counts1[execname] = count();
+ @counts2[execname, arg0] = count();
+}
+
+tick-10ms
+/i == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d
new file mode 100644
index 00000000..37269e82
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Simple denormalization test
+ *
+ * SECTION: Aggregations/Normalization
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-10ms
+/i < 20/
+{
+ @func[i % 5] = sum(i * 100);
+ i++;
+}
+
+tick-10ms
+/i == 20/
+{
+ normalize(@func, 5);
+
+ printf("denormalized:");
+ denormalize(@func);
+ printa(@func);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d.out
new file mode 100644
index 00000000..fa4d0da7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d.out
@@ -0,0 +1,7 @@
+denormalized:
+ 0 3000
+ 1 3400
+ 2 3800
+ 3 4200
+ 4 4600
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d
new file mode 100644
index 00000000..d63a83e6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * denormalize() should work even if normalize() isn't called.
+ *
+ * SECTION: Aggregations/Normalization
+ *
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-10ms
+/i < 20/
+{
+ @func[i%5] = sum(i * 100);
+ i++;
+}
+
+tick-10ms
+/i == 20/
+{
+ printf("denormalized:");
+ denormalize(@func);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d.out
new file mode 100644
index 00000000..cc16f277
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d.out
@@ -0,0 +1,6 @@
+denormalized:
+ 0 3000
+ 1 3400
+ 2 3800
+ 3 4200
+ 4 4600
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d
new file mode 100644
index 00000000..8ff3aabf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for normalization() with printa()
+ *
+ * SECTION: Aggregations/Normalization
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=50ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i % 5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("normalized data:\n");
+ normalize(@func, 5);
+ printa("%u %@u\n", @func);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d.out
new file mode 100644
index 00000000..bbf345be
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d.out
@@ -0,0 +1,7 @@
+normalized data:
+0 600
+1 680
+2 760
+3 840
+4 920
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d
new file mode 100644
index 00000000..2b08a12d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive aggregation test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a = count();
+ @b = max(1);
+ @c[0] = count();
+ @d[0] = max(1);
+
+ printa("\n@a = %@u\n", @a);
+ printa("@b = %@u\n", @b);
+ printa("@c = %@u\n", @c);
+ printa("@d = %@u\n", @d);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d.out
new file mode 100644
index 00000000..1f31450d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.forms.d.out
@@ -0,0 +1,6 @@
+
+@a = 1
+@b = 1
+@c = 1
+@d = 1
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.goodkey.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.goodkey.d
new file mode 100644
index 00000000..46becd56
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.goodkey.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive aggregation key test
+ *
+ * SECTION: Aggregations/Aggregations
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i != 5/
+{
+ i++;
+ @counts[execname, pid, id, tid, arg0, vtimestamp ] = count();
+
+}
+
+tick-10ms
+/i == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d
new file mode 100644
index 00000000..dbc8b6d2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d
@@ -0,0 +1,108 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ j = 0;
+
+ @tour["Ghent", i++, j] = sum(5 - j);
+ j++;
+
+ @tour["Berlin", i++, j] = sum(5 - j);
+ j++;
+
+ @tour["London", i++, j] = sum(5 - j);
+ @tour["Dublin", i++, j] = sum(5 - j);
+ j++;
+
+ @tour["Shanghai", i++, j] = sum(5 - j);
+ j++;
+
+ @tour["Zurich", i++, j] = sum(5 - j);
+ j++;
+
+ @tour["Regina", i++, j] = sum(5 - j);
+ @tour["Winnipeg", i++, j] = sum(5 - j);
+ @tour["Edmonton", i++, j] = sum(5 - j);
+ @tour["Calgary", i++, j] = sum(5 - j);
+ @tour["Vancouver", i++, j] = sum(5 - j);
+ @tour["Victoria", i++, j] = sum(5 - j);
+ j++;
+
+ @tour["Prague", i++, j] = sum(5 - j);
+ @tour["London", i++, j] = sum(5 - j);
+ j++;
+
+ @tour["Brisbane", i++, j] = sum(5 - j);
+ @tour["Sydney", i++, j] = sum(5 - j);
+ @tour["Melbourne", i++, j] = sum(5 - j);
+ j++;
+
+ setopt("aggsortkey", "false");
+ setopt("aggsortkeypos", "0");
+ @tour["Amsterdam", i++, j] = sum(5 - j);
+
+ printf("By value:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ setopt("aggsortkey");
+ printf("\nBy key, position 0:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ setopt("aggsortkeypos", "1");
+ printf("\nBy key, position 1:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ setopt("aggsortkeypos", "2");
+ printf("\nBy key, position 2:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ setopt("aggsortkey", "false");
+ setopt("aggsortkeypos", "0");
+ setopt("aggsortrev");
+
+ printf("\nReversed by value:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ setopt("aggsortkey");
+ printf("\nReversed by key, position 0:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ setopt("aggsortkeypos", "1");
+ printf("\nReversed by key, position 1:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ setopt("aggsortkeypos", "2");
+ printf("\nReversed by key, position 2:\n");
+ printa("%20s %8d %8d %8@d\n", @tour);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d.out
new file mode 100644
index 00000000..250d84b9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.keysort.d.out
@@ -0,0 +1,160 @@
+By value:
+ Amsterdam 17 8 -3
+ Brisbane 14 7 -2
+ Melbourne 16 7 -2
+ Sydney 15 7 -2
+ London 13 6 -1
+ Prague 12 6 -1
+ Calgary 9 5 0
+ Edmonton 8 5 0
+ Regina 6 5 0
+ Vancouver 10 5 0
+ Victoria 11 5 0
+ Winnipeg 7 5 0
+ Zurich 5 4 1
+ Shanghai 4 3 2
+ Dublin 3 2 3
+ London 2 2 3
+ Berlin 1 1 4
+ Ghent 0 0 5
+
+By key, position 0:
+ Amsterdam 17 8 -3
+ Berlin 1 1 4
+ Brisbane 14 7 -2
+ Calgary 9 5 0
+ Dublin 3 2 3
+ Edmonton 8 5 0
+ Ghent 0 0 5
+ London 2 2 3
+ London 13 6 -1
+ Melbourne 16 7 -2
+ Prague 12 6 -1
+ Regina 6 5 0
+ Shanghai 4 3 2
+ Sydney 15 7 -2
+ Vancouver 10 5 0
+ Victoria 11 5 0
+ Winnipeg 7 5 0
+ Zurich 5 4 1
+
+By key, position 1:
+ Ghent 0 0 5
+ Berlin 1 1 4
+ London 2 2 3
+ Dublin 3 2 3
+ Shanghai 4 3 2
+ Zurich 5 4 1
+ Regina 6 5 0
+ Winnipeg 7 5 0
+ Edmonton 8 5 0
+ Calgary 9 5 0
+ Vancouver 10 5 0
+ Victoria 11 5 0
+ Prague 12 6 -1
+ London 13 6 -1
+ Brisbane 14 7 -2
+ Sydney 15 7 -2
+ Melbourne 16 7 -2
+ Amsterdam 17 8 -3
+
+By key, position 2:
+ Ghent 0 0 5
+ Berlin 1 1 4
+ Dublin 3 2 3
+ London 2 2 3
+ Shanghai 4 3 2
+ Zurich 5 4 1
+ Calgary 9 5 0
+ Edmonton 8 5 0
+ Regina 6 5 0
+ Vancouver 10 5 0
+ Victoria 11 5 0
+ Winnipeg 7 5 0
+ London 13 6 -1
+ Prague 12 6 -1
+ Brisbane 14 7 -2
+ Melbourne 16 7 -2
+ Sydney 15 7 -2
+ Amsterdam 17 8 -3
+
+Reversed by value:
+ Ghent 0 0 5
+ Berlin 1 1 4
+ London 2 2 3
+ Dublin 3 2 3
+ Shanghai 4 3 2
+ Zurich 5 4 1
+ Winnipeg 7 5 0
+ Victoria 11 5 0
+ Vancouver 10 5 0
+ Regina 6 5 0
+ Edmonton 8 5 0
+ Calgary 9 5 0
+ Prague 12 6 -1
+ London 13 6 -1
+ Sydney 15 7 -2
+ Melbourne 16 7 -2
+ Brisbane 14 7 -2
+ Amsterdam 17 8 -3
+
+Reversed by key, position 0:
+ Zurich 5 4 1
+ Winnipeg 7 5 0
+ Victoria 11 5 0
+ Vancouver 10 5 0
+ Sydney 15 7 -2
+ Shanghai 4 3 2
+ Regina 6 5 0
+ Prague 12 6 -1
+ Melbourne 16 7 -2
+ London 13 6 -1
+ London 2 2 3
+ Ghent 0 0 5
+ Edmonton 8 5 0
+ Dublin 3 2 3
+ Calgary 9 5 0
+ Brisbane 14 7 -2
+ Berlin 1 1 4
+ Amsterdam 17 8 -3
+
+Reversed by key, position 1:
+ Amsterdam 17 8 -3
+ Melbourne 16 7 -2
+ Sydney 15 7 -2
+ Brisbane 14 7 -2
+ London 13 6 -1
+ Prague 12 6 -1
+ Victoria 11 5 0
+ Vancouver 10 5 0
+ Calgary 9 5 0
+ Edmonton 8 5 0
+ Winnipeg 7 5 0
+ Regina 6 5 0
+ Zurich 5 4 1
+ Shanghai 4 3 2
+ Dublin 3 2 3
+ London 2 2 3
+ Berlin 1 1 4
+ Ghent 0 0 5
+
+Reversed by key, position 2:
+ Amsterdam 17 8 -3
+ Sydney 15 7 -2
+ Melbourne 16 7 -2
+ Brisbane 14 7 -2
+ Prague 12 6 -1
+ London 13 6 -1
+ Winnipeg 7 5 0
+ Victoria 11 5 0
+ Vancouver 10 5 0
+ Regina 6 5 0
+ Edmonton 8 5 0
+ Calgary 9 5 0
+ Zurich 5 4 1
+ Shanghai 4 3 2
+ London 2 2 3
+ Dublin 3 2 3
+ Berlin 1 1 4
+ Ghent 0 0 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d
new file mode 100644
index 00000000..dd25f861
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive lquantize() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is verifiable simple positive test of the lquantize() function.
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a[i] = lquantize(i, -100, 1100, 100 );
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d.out
new file mode 100644
index 00000000..fecb4483
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d.out
@@ -0,0 +1,61 @@
+
+ 0
+ value ------------- Distribution ------------- count
+ -100 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 100 | 0
+
+ 100
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 100 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 200 | 0
+
+ 200
+ value ------------- Distribution ------------- count
+ 100 | 0
+ 200 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 300 | 0
+
+ 300
+ value ------------- Distribution ------------- count
+ 200 | 0
+ 300 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 400 | 0
+
+ 400
+ value ------------- Distribution ------------- count
+ 300 | 0
+ 400 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 500 | 0
+
+ 500
+ value ------------- Distribution ------------- count
+ 400 | 0
+ 500 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 600 | 0
+
+ 600
+ value ------------- Distribution ------------- count
+ 500 | 0
+ 600 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 700 | 0
+
+ 700
+ value ------------- Distribution ------------- count
+ 600 | 0
+ 700 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 800 | 0
+
+ 800
+ value ------------- Distribution ------------- count
+ 700 | 0
+ 800 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 900 | 0
+
+ 900
+ value ------------- Distribution ------------- count
+ 800 | 0
+ 900 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1000 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d
new file mode 100644
index 00000000..003f846f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+tick-10ms
+/i++ < 10/
+{
+ @ = lquantize(i, 0, 10);
+ @ = lquantize(i, 0, 10);
+ @ = lquantize(i, 0, 10);
+ @ = lquantize(i, 0, 10);
+ @ = lquantize(i, 0, 10);
+}
+
+tick-10ms
+/i == 10/
+{
+ exit(0);
+}
+
+END
+{
+ normalize(@, 5);
+ printa(@);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d.out
new file mode 100644
index 00000000..76b55b9c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d.out
@@ -0,0 +1,16 @@
+
+
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@ 1
+ 2 |@@@@ 1
+ 3 |@@@@ 1
+ 4 |@@@@ 1
+ 5 |@@@@ 1
+ 6 |@@@@ 1
+ 7 |@@@@ 1
+ 8 |@@@@ 1
+ 9 |@@@@ 1
+ >= 10 |@@@@ 1
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d
new file mode 100644
index 00000000..e9e67165
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @["Nixon"] = lquantize(-20, -10, 10, 1, 25);
+ @["Hoover"] = lquantize(20, -10, 10, 1, -100);
+ @["Harding"] = lquantize(-10, -10, 10, 1, 15);
+ @["Bush"] = lquantize(10, -10, 10, 1, 150);
+
+ printa(@);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d.out
new file mode 100644
index 00000000..88d3505b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d.out
@@ -0,0 +1,23 @@
+
+ Hoover
+ value ------------- Distribution ------------- count
+ 9 | 0
+ >= 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -100
+
+ Nixon
+ value ------------- Distribution ------------- count
+ < -10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 25
+ -10 | 0
+
+ Harding
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 15
+ -9 | 0
+
+ Bush
+ value ------------- Distribution ------------- count
+ 9 | 0
+ >= 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 150
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d
new file mode 100644
index 00000000..ad609ed2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+/*
+ * This test verifies that the height of the ASCII quantization bars is
+ * determined using rounding and not truncated integer arithmetic.
+ */
+tick-10ms
+/i++ >= 27/
+{
+ exit(0);
+}
+
+tick-10ms
+/i > 8/
+{
+ @ = lquantize(2, 0, 4);
+}
+
+tick-10ms
+/i > 2 && i <= 8/
+{
+ @ = lquantize(1, 0, 4);
+}
+
+tick-10ms
+/i <= 2/
+{
+ @ = lquantize(0, 0, 4);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d.out
new file mode 100644
index 00000000..1aa94e33
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d.out
@@ -0,0 +1,9 @@
+
+
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@ 2
+ 1 |@@@@@@@@@ 6
+ 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 19
+ 3 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d
new file mode 100644
index 00000000..3905f2bd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d
@@ -0,0 +1,96 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ a = 7;
+ b = 13;
+ val = (-a * b) + a;
+}
+
+tick-1ms
+{
+ incr = val % b;
+ val += a;
+}
+
+tick-1ms
+/val == 0/
+{
+ val += a;
+}
+
+tick-1ms
+/incr != 0/
+{
+ i++;
+ @one[i] = lquantize(0, 10, 20, 1, incr);
+ @two[i] = lquantize(0, 1, 20, 5, incr);
+ @three[i] = lquantize(0, 0, 20, 1, incr);
+ @four[i] = lquantize(0, -10, 10, 1, incr);
+ @five[i] = lquantize(0, -10, 0, 1, incr);
+ @six[i] = lquantize(0, -10, -1, 1, incr);
+ @seven[i] = lquantize(0, -10, -2, 1, incr);
+}
+
+tick-1ms
+/incr == 0/
+{
+ printf("Zero below the range:\n");
+ printa(@one);
+ printf("\n");
+
+ printf("Zero just below the range:\n");
+ printa(@two);
+ printf("\n");
+
+ printf("Zero at the bottom of the range:\n");
+ printa(@three);
+ printf("\n");
+
+ printf("Zero within the range:\n");
+ printa(@four);
+ printf("\n");
+
+ printf("Zero at the top of the range:\n");
+ printa(@five);
+ printf("\n");
+
+ printf("Zero just above the range:\n");
+ printa(@six);
+ printf("\n");
+
+ printf("Zero above the range:\n");
+ printa(@seven);
+ printf("\n");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d.out
new file mode 100644
index 00000000..330de38a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d.out
@@ -0,0 +1,910 @@
+Zero below the range:
+
+ 2
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+ 10 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+ 10 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+ 10 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+ 10 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+ 10 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+ 10 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+ 10 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+ 10 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+ 10 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+ 10 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+ 10 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+ 10 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 10 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 10 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 10 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+ 10 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 10 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+ 10 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+ 10 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+ 10 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+ 10 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+ 10 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+ 10 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+ 10 | 0
+
+
+Zero just below the range:
+
+ 2
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+ 1 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+ 1 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+ 1 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+ 1 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+ 1 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+ 1 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+ 1 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+ 1 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+ 1 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+ 1 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+ 1 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+ 1 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 1 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 1 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+ 1 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 1 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+ 1 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+ 1 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+ 1 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+ 1 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+ 1 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+ 1 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+ 1 | 0
+
+
+Zero at the bottom of the range:
+
+ 2
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+ 1 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+ 1 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+ 1 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+ 1 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+ 1 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+ 1 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+ 1 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+ 1 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+ 1 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+ 1 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+ 1 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+ 1 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 1 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 1 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+ 1 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 1 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+ 1 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+ 1 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+ 1 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+ 1 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+ 1 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+ 1 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+ 1 | 0
+
+
+Zero within the range:
+
+ 2
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+ 1 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+ 1 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+ 1 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+ 1 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+ 1 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+ 1 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+ 1 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+ 1 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+ 1 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+ 1 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+ 1 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+ 1 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 1 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 1 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+ 1 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 1 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+ 1 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+ 1 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+ 1 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+ 1 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+ 1 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+ 1 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+ 1 | 0
+
+
+Zero at the top of the range:
+
+ 2
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+
+ 4
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+
+ 6
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+
+ 8
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+
+ 10
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+
+ 12
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+
+ 1
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+
+ 3
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+
+ 5
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+
+ 7
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+
+ 9
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+
+ 11
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+
+ 14
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+
+ 16
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+
+ 18
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+
+ 20
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+
+ 22
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+
+ 24
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+
+ 13
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+
+ 15
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+
+ 17
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+
+ 19
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+
+ 21
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+
+ 23
+ value ------------- Distribution ------------- count
+ -1 | 0
+ >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+
+
+Zero just above the range:
+
+ 2
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+
+ 4
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+
+ 6
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+
+ 8
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+
+ 10
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+
+ 12
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+
+ 1
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+
+ 3
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+
+ 5
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+
+ 7
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+
+ 9
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+
+ 11
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+
+ 14
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+
+ 16
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+
+ 18
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+
+ 20
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+
+ 22
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+
+ 24
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+
+ 13
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+
+ 15
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+
+ 17
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+
+ 19
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+
+ 21
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+
+ 23
+ value ------------- Distribution ------------- count
+ -2 | 0
+ >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+
+
+Zero above the range:
+
+ 23
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+
+ 21
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+
+ 19
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+
+ 17
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+
+ 15
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+
+ 13
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+
+ 24
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+
+ 22
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+
+ 20
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+
+ 18
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+
+ 16
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+
+ 14
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+
+ 11
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+
+ 9
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+
+ 7
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+
+ 5
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+
+ 3
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+
+ 1
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+
+ 12
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+
+ 10
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+
+ 8
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+
+ 6
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+
+ 4
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+
+ 2
+ value ------------- Distribution ------------- count
+ -3 | 0
+ >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d
new file mode 100644
index 00000000..0c973ad5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive max() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is verifiable simple positive test of the max() function.
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a = max(i);
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ printa(@a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d.out
new file mode 100644
index 00000000..d3957f4c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max.d.out
@@ -0,0 +1,3 @@
+
+ 900
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d
new file mode 100644
index 00000000..63486e5f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive max() test using negative values
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is verifiable simple positive test of the max() function.
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @ = max(0);
+ @ = max(-900);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d.out
new file mode 100644
index 00000000..8d23188f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d.out
@@ -0,0 +1,2 @@
+
+ 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d
new file mode 100644
index 00000000..aff5452e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive min() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is verifiable simple positive test of the min() function.
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a = min(i);
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d.out
new file mode 100644
index 00000000..8d23188f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min.d.out
@@ -0,0 +1,2 @@
+
+ 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d
new file mode 100644
index 00000000..20f0a56d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive min() test using negative values
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is verifiable simple positive test of the min() function.
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @ = min(0);
+ @ = min(-900);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d.out
new file mode 100644
index 00000000..461b29cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d.out
@@ -0,0 +1,2 @@
+
+ -900
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d
new file mode 100644
index 00000000..c65fb529
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Multiple aggregates can be used within the same D script.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ time_1 = timestamp;
+ i = 0;
+}
+
+tick-10ms
+/i <= 10/
+{
+ time_2 = timestamp;
+ new_time = time_2 - time_1;
+ @a[pid] = max(new_time);
+ @b[pid] = min(new_time);
+ @c[pid] = avg(new_time);
+ @d[pid] = sum(new_time);
+ @e[pid] = quantize(new_time);
+ @f[pid] = stddev(new_time);
+ @g[timestamp] = max(new_time);
+ @h[timestamp] = quantize(new_time);
+ @i[timestamp] = lquantize(new_time, 0, 10000, 1000);
+
+ time_1 = time_2;
+ i++;
+}
+
+tick-10ms
+/i == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d
new file mode 100644
index 00000000..b34d73fa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Test multiple aggregations and the default output order
+ *
+ * SECTION: Aggregations/Aggregations;
+ * Aggregations/Output
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a = avg(i);
+ @b = sum(i);
+ @c = min(i);
+ @d = max(i);
+ @e = quantize(i);
+ @f = lquantize(i, 0, 1000, 100);
+ @g = stddev(i);
+
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out
new file mode 100644
index 00000000..579f78dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out
@@ -0,0 +1,37 @@
+
+ 450
+ 4500
+ 0
+ 900
+
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@ 1
+ 1 | 0
+ 2 | 0
+ 4 | 0
+ 8 | 0
+ 16 | 0
+ 32 | 0
+ 64 |@@@@ 1
+ 128 |@@@@ 1
+ 256 |@@@@@@@@@@@@ 3
+ 512 |@@@@@@@@@@@@@@@@ 4
+ 1024 | 0
+
+
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@ 1
+ 100 |@@@@ 1
+ 200 |@@@@ 1
+ 300 |@@@@ 1
+ 400 |@@@@ 1
+ 500 |@@@@ 1
+ 600 |@@@@ 1
+ 700 |@@@@ 1
+ 800 |@@@@ 1
+ 900 |@@@@ 1
+ >= 1000 | 0
+
+ 287
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d
new file mode 100644
index 00000000..21d2fa9e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d
@@ -0,0 +1,74 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Test multiple aggregations and overriding default order with
+ * printa() statements.
+ *
+ * SECTION: Aggregations/Aggregations;
+ * Aggregations/Output
+ *
+ * NOTES: This is a simple verifiable test.
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a = count();
+ @b = avg(i);
+ @c = sum(i);
+ @d = min(i);
+ @e = max(i);
+ @f = quantize(i);
+ @g = lquantize(i, 0, 1000, 100);
+ @h = stddev(i);
+
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ printa("%@d\n", @h);
+ printa("%@d\n", @g);
+ printa("%@d\n", @f);
+ printa("%@d\n", @e);
+ printa("%@d\n", @d);
+ printa("%@d\n", @c);
+ printa("%@d\n", @b);
+ printa("%@d\n", @a);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out
new file mode 100644
index 00000000..ab976601
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out
@@ -0,0 +1,38 @@
+287
+
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@ 1
+ 100 |@@@@ 1
+ 200 |@@@@ 1
+ 300 |@@@@ 1
+ 400 |@@@@ 1
+ 500 |@@@@ 1
+ 600 |@@@@ 1
+ 700 |@@@@ 1
+ 800 |@@@@ 1
+ 900 |@@@@ 1
+ >= 1000 | 0
+
+
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@ 1
+ 1 | 0
+ 2 | 0
+ 4 | 0
+ 8 | 0
+ 16 | 0
+ 32 | 0
+ 64 |@@@@ 1
+ 128 |@@@@ 1
+ 256 |@@@@@@@@@@@@ 3
+ 512 |@@@@@@@@@@@@@@@@ 4
+ 1024 | 0
+
+900
+0
+4500
+450
+10
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d
new file mode 100644
index 00000000..2cfa1848
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Multiple aggregations are supported
+ *
+ * SECTION: Aggregations/Normalization
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=50ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func1[i % 5] = sum(i * 100);
+ @func2[i % 5 + 1] = sum(i * 200);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("normalized data #1:\n");
+ normalize(@func1, 5);
+ printa(@func1);
+
+ printf("\nnormalized data #2:\n");
+ normalize(@func2, 5);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d.out
new file mode 100644
index 00000000..992b31e2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d.out
@@ -0,0 +1,15 @@
+normalized data #1:
+
+ 0 600
+ 1 680
+ 2 760
+ 3 840
+ 4 920
+
+normalized data #2:
+
+ 1 1200
+ 2 1360
+ 3 1520
+ 4 1680
+ 5 1840
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d
new file mode 100644
index 00000000..d24884b5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d
@@ -0,0 +1,150 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @["j-church"] = lquantize(1, 0, 10, 1, 100);
+ @["j-church"] = lquantize(1, 0, 10, 1, -99);
+ @["j-church"] = lquantize(1, 0, 10, 1, -1);
+ val = 123;
+}
+
+BEGIN
+{
+ @["k-ingleside"] = lquantize(1, 0, 10, 1, -val);
+}
+
+BEGIN
+{
+ @["l-taraval"] = lquantize(0, 0, 10, 1, -val);
+ @["l-taraval"] = lquantize(-1, 0, 10, 1, -val);
+ @["l-taraval"] = lquantize(1, 0, 10, 1, val);
+ @["l-taraval"] = lquantize(1, 0, 10, 1, val);
+}
+
+BEGIN
+{
+ @["m-oceanview"] = lquantize(1, 0, 10, 1, (1 << 63) - 1);
+ @["m-oceanview"] = lquantize(1, 0, 10, 1);
+ @["m-oceanview"] = lquantize(2, 0, 10, 1, (1 << 63) - 1);
+ @["m-oceanview"] = lquantize(8, 0, 10, 1, 400000);
+}
+
+BEGIN
+{
+ @["n-judah"] = lquantize(1, 0, 10, 1, val);
+ @["n-judah"] = lquantize(2, 0, 10, 1, val);
+ @["n-judah"] = lquantize(2, 0, 10, 1, val);
+ @["n-judah"] = lquantize(2, 0, 10, 1);
+}
+
+BEGIN
+{
+ this->i = 1;
+ this->val = (1 << 63) - 1;
+
+ @["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+}
+
+BEGIN
+{
+ this->i = 1;
+
+ /*
+ * We want to test the ability to sort very large quantizations
+ * that differ by a small amount. Ideally, they would differ only
+ * by 1 -- but that is smaller than the precision of long doubles of
+ * this magnitude on x86. To assure that the same test works on x86
+ * just as it does on SPARC, we pick a value that is just larger than
+ * the precision at this magnitude. It should go without saying that
+ * this robustness on new ISAs very much depends on the precision
+ * of the long double representation.
+ */
+ this->val = (1 << 63) - 7;
+
+ @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+
+ @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
+ this->i++;
+ this->val = ((1 << 63) - 1) / this->i;
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d.out
new file mode 100644
index 00000000..3b7533b1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d.out
@@ -0,0 +1,64 @@
+
+ k-ingleside
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -123
+ 2 | 0
+
+ j-church
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 | 0
+ 1 | 0
+
+ l-taraval
+ value ------------- Distribution ------------- count
+ < 0 @@@@@| -123
+ 0 @@@@@| -123
+ 1 |@@@@@@@@@@ 246
+ 2 | 0
+
+ n-judah
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@ 123
+ 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 247
+ 3 | 0
+
+ m-oceanview
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@| -9223372036854775808
+ 2 |@@@@@@@@@@ 9223372036854775807
+ 3 | 0
+ 4 | 0
+ 5 | 0
+ 6 | 0
+ 7 | 0
+ 8 | 400000
+ 9 | 0
+
+ s-castro
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@ 9223372036854775801
+ 2 |@@@@@@@@ 4611686018427387903
+ 3 |@@@@@ 3074457345618258602
+ 4 |@@@@ 2305843009213693951
+ 5 |@@@ 1844674407370955161
+ 6 |@@@ 1537228672809129301
+ 7 |@@ 1317624576693539401
+ 8 | 0
+
+ f-market
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@ 9223372036854775807
+ 2 |@@@@@@@@ 4611686018427387903
+ 3 |@@@@@ 3074457345618258602
+ 4 |@@@@ 2305843009213693951
+ 5 |@@@ 1844674407370955161
+ 6 |@@@ 1537228672809129301
+ 7 |@@ 1317624576693539401
+ 8 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d
new file mode 100644
index 00000000..440c4839
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ a = 7;
+ b = 13;
+ val = (-a * b) + a;
+}
+
+tick-1ms
+{
+ incr = val % b;
+ val += a;
+}
+
+tick-1ms
+/val == 0/
+{
+ val += a;
+}
+
+tick-1ms
+/incr != 0/
+{
+ i++;
+ @quanty[i] = quantize(1, incr);
+ @lquanty[i] = lquantize(1, -10, 10, 1, incr);
+ @summy[i] = sum(incr);
+ @maxxy[i] = max(incr);
+ @minny[i] = min(incr);
+}
+
+tick-1ms
+/incr == 0/
+{
+ printf("Ordering of quantize() with some negative weights:\n");
+ printa(@quanty);
+ printf("\n");
+
+ printf("Ordering of lquantize() with some negative weights:\n");
+ printa(@lquanty);
+ printf("\n");
+
+ printf("Ordering of sum() with some negative weights:\n");
+ printa(@summy);
+ printf("\n");
+
+ printf("Ordering of max() with some negative weights:\n");
+ printa(@maxxy);
+ printf("\n");
+
+ printf("Ordering of min() with some negative weights:\n");
+ printa(@minny);
+ printf("\n");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d.out
new file mode 100644
index 00000000..a03b6850
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negorder.d.out
@@ -0,0 +1,376 @@
+Ordering of quantize() with some negative weights:
+
+ 2
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+ 2 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+ 2 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+ 2 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+ 2 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+ 2 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+ 2 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+ 2 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+ 2 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+ 2 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+ 2 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+ 2 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+ 2 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 2 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 2 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 2 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+ 2 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 2 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+ 2 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+ 2 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+ 2 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+ 2 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+ 2 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+ 2 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+ 2 | 0
+
+
+Ordering of lquantize() with some negative weights:
+
+ 2
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+ 2 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+ 2 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+ 2 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+ 2 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+ 2 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+ 2 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+ 2 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+ 2 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+ 2 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+ 2 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+ 2 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+ 2 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 2 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 2 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 2 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+ 2 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 2 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+ 2 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+ 2 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+ 2 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+ 2 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+ 2 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+ 2 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+ 2 | 0
+
+
+Ordering of sum() with some negative weights:
+
+ 2 -12
+ 4 -11
+ 6 -10
+ 8 -9
+ 10 -8
+ 12 -7
+ 1 -6
+ 3 -5
+ 5 -4
+ 7 -3
+ 9 -2
+ 11 -1
+ 14 1
+ 16 2
+ 18 3
+ 20 4
+ 22 5
+ 24 6
+ 13 7
+ 15 8
+ 17 9
+ 19 10
+ 21 11
+ 23 12
+
+Ordering of max() with some negative weights:
+
+ 2 -12
+ 4 -11
+ 6 -10
+ 8 -9
+ 10 -8
+ 12 -7
+ 1 -6
+ 3 -5
+ 5 -4
+ 7 -3
+ 9 -2
+ 11 -1
+ 14 1
+ 16 2
+ 18 3
+ 20 4
+ 22 5
+ 24 6
+ 13 7
+ 15 8
+ 17 9
+ 19 10
+ 21 11
+ 23 12
+
+Ordering of min() with some negative weights:
+
+ 2 -12
+ 4 -11
+ 6 -10
+ 8 -9
+ 10 -8
+ 12 -7
+ 1 -6
+ 3 -5
+ 5 -4
+ 7 -3
+ 9 -2
+ 11 -1
+ 14 1
+ 16 2
+ 18 3
+ 20 4
+ 22 5
+ 24 6
+ 13 7
+ 15 8
+ 17 9
+ 19 10
+ 21 11
+ 23 12
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d
new file mode 100644
index 00000000..bbc7263d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d
@@ -0,0 +1,115 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @["j-church"] = quantize(1, 100);
+ @["j-church"] = quantize(1, -99);
+ @["j-church"] = quantize(1, -1);
+ val = 123;
+}
+
+BEGIN
+{
+ @["k-ingleside"] = quantize(1, -val);
+}
+
+BEGIN
+{
+ @["l-taraval"] = quantize(0, -val);
+ @["l-taraval"] = quantize(-1, -val);
+ @["l-taraval"] = quantize(1, val);
+ @["l-taraval"] = quantize(1, val);
+}
+
+BEGIN
+{
+ @["m-oceanview"] = quantize(1, (1 << 63) - 1);
+ @["m-oceanview"] = quantize(1);
+ @["m-oceanview"] = quantize(2, (1 << 63) - 1);
+ @["m-oceanview"] = quantize(8, 400000);
+}
+
+BEGIN
+{
+ @["n-judah"] = quantize(1, val);
+ @["n-judah"] = quantize(2, val);
+ @["n-judah"] = quantize(2, val);
+ @["n-judah"] = quantize(2);
+}
+
+BEGIN
+{
+ this->i = 1;
+ this->val = (1 << 63) - 1;
+
+ @["f-market"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+
+ @["f-market"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+
+ @["f-market"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+
+ @["f-market"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+}
+
+BEGIN
+{
+ this->i = 1;
+ this->val = (1 << 63) - 4;
+
+ @["s-castro"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+
+ @["s-castro"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+
+ @["s-castro"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+
+ @["s-castro"] = quantize(this->i, this->val);
+ this->i <<= 1;
+ this->val >>= 1;
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d.out
new file mode 100644
index 00000000..f8466b33
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negquant.d.out
@@ -0,0 +1,55 @@
+
+ k-ingleside
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -123
+ 2 | 0
+
+ j-church
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ l-taraval
+ value ------------- Distribution ------------- count
+ -2 | 0
+ -1 @@@@@| -123
+ 0 @@@@@| -123
+ 1 |@@@@@@@@@@ 246
+ 2 | 0
+
+ n-judah
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@ 123
+ 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 247
+ 4 | 0
+
+ m-oceanview
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 @@@@@@@@@@| -9223372036854775808
+ 2 |@@@@@@@@@@ 9223372036854775807
+ 4 | 0
+ 8 | 400000
+ 16 | 0
+
+ s-castro
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@ 9223372036854775804
+ 2 |@@@@@@@@@@@ 4611686018427387902
+ 4 |@@@@@ 2305843009213693951
+ 8 |@@@ 1152921504606846975
+ 16 | 0
+
+ f-market
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@ 9223372036854775807
+ 2 |@@@@@@@@@@@ 4611686018427387903
+ 4 |@@@@@ 2305843009213693951
+ 8 |@@@ 1152921504606846975
+ 16 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d
new file mode 100644
index 00000000..f90eae13
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+int i;
+
+tick-10ms
+/i < 100/
+{
+ @[i] = sum(i);
+ i++;
+}
+
+tick-10ms
+/i == 100/
+{
+ exit(0);
+}
+
+END
+{
+ trunc(@, -10);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d.out
new file mode 100644
index 00000000..c1b07a6d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d.out
@@ -0,0 +1,11 @@
+
+ 0 0
+ 1 1
+ 2 2
+ 3 3
+ 4 4
+ 5 5
+ 6 6
+ 7 7
+ 8 8
+ 9 9
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d
new file mode 100644
index 00000000..2a13d659
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+int i;
+
+tick-10ms
+/i < 100/
+{
+ @[i] = lquantize(i, 0, 150);
+ @[i] = lquantize(i + 1, 0, 150);
+ @[i] = lquantize(i + 2, 0, 150);
+ @[i] = lquantize(i + 3, 0, 150);
+ i++;
+}
+
+tick-10ms
+/i == 100/
+{
+ exit(0);
+}
+
+END
+{
+ trunc(@, -5);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d.out
new file mode 100644
index 00000000..264aa392
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d.out
@@ -0,0 +1,46 @@
+
+ 0
+ value ------------- Distribution ------------- count
+ < 0 | 0
+ 0 |@@@@@@@@@@ 1
+ 1 |@@@@@@@@@@ 1
+ 2 |@@@@@@@@@@ 1
+ 3 |@@@@@@@@@@ 1
+ 4 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@ 1
+ 2 |@@@@@@@@@@ 1
+ 3 |@@@@@@@@@@ 1
+ 4 |@@@@@@@@@@ 1
+ 5 | 0
+
+ 2
+ value ------------- Distribution ------------- count
+ 1 | 0
+ 2 |@@@@@@@@@@ 1
+ 3 |@@@@@@@@@@ 1
+ 4 |@@@@@@@@@@ 1
+ 5 |@@@@@@@@@@ 1
+ 6 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ 2 | 0
+ 3 |@@@@@@@@@@ 1
+ 4 |@@@@@@@@@@ 1
+ 5 |@@@@@@@@@@ 1
+ 6 |@@@@@@@@@@ 1
+ 7 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ 3 | 0
+ 4 |@@@@@@@@@@ 1
+ 5 |@@@@@@@@@@ 1
+ 6 |@@@@@@@@@@ 1
+ 7 |@@@@@@@@@@ 1
+ 8 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d
new file mode 100644
index 00000000..0bcc0fe9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for normalization()
+ *
+ * SECTION: Aggregations/Normalization
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=50ms
+
+BEGIN
+{
+ i = 0;
+ start = timestamp;
+}
+
+tick-100ms
+/i < 20/
+{
+ @func[i % 5] = sum(i * 100);
+ i++;
+}
+
+tick-100ms
+/i == 20/
+{
+ printf("normalized data:\n");
+ normalize(@func, 5);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d.out
new file mode 100644
index 00000000..11193e65
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.normalize.d.out
@@ -0,0 +1,7 @@
+normalized data:
+
+ 0 600
+ 1 680
+ 2 760
+ 3 840
+ 4 920
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d
new file mode 100644
index 00000000..13900116
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @[8] = sum(1);
+ @[6] = sum(1);
+ @[7] = sum(1);
+ @[5] = sum(1);
+ @[3] = sum(1);
+ @[0] = sum(1);
+ @[9] = sum(1);
+
+ @tour["Ghent"] = sum(1);
+ @tour["Berlin"] = sum(1);
+ @tour["London"] = sum(1);
+ @tour["Dublin"] = sum(1);
+ @tour["Shanghai"] = sum(1);
+ @tour["Zurich"] = sum(1);
+ @tour["Regina"] = sum(1);
+ @tour["Winnipeg"] = sum(1);
+ @tour["Edmonton"] = sum(1);
+ @tour["Calgary"] = sum(1);
+
+ @ate[8, "Rice"] = sum(1);
+ @ate[8, "Oatmeal"] = sum(1);
+ @ate[8, "Barley"] = sum(1);
+ @ate[8, "Carrots"] = sum(1);
+ @ate[8, "Sweet potato"] = sum(1);
+ @ate[8, "Asparagus"] = sum(1);
+ @ate[8, "Squash"] = sum(1);
+
+ @chars['a'] = sum(1);
+ @chars['s'] = sum(1);
+ @chars['d'] = sum(1);
+ @chars['f'] = sum(1);
+
+ printa("%d\n", @);
+ printf("\n");
+
+ printa("%s\n", @tour);
+ printf("\n");
+
+ printa("%d %s\n", @ate);
+ printf("\n");
+
+ printa("%c\n", @chars);
+ printf("\n");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d.out
new file mode 100644
index 00000000..505b0f32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.order.d.out
@@ -0,0 +1,33 @@
+0
+3
+5
+6
+7
+8
+9
+
+Berlin
+Calgary
+Dublin
+Edmonton
+Ghent
+London
+Regina
+Shanghai
+Winnipeg
+Zurich
+
+8 Asparagus
+8 Barley
+8 Carrots
+8 Oatmeal
+8 Rice
+8 Squash
+8 Sweet potato
+
+a
+d
+f
+s
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d
new file mode 100644
index 00000000..fad472af
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive quantize() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is verifiable simple positive test of the quantize() function.
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a[i] = quantize(i);
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d.out
new file mode 100644
index 00000000..f4882ed2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantize.d.out
@@ -0,0 +1,61 @@
+
+ 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1 | 0
+
+ 100
+ value ------------- Distribution ------------- count
+ 32 | 0
+ 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 128 | 0
+
+ 200
+ value ------------- Distribution ------------- count
+ 64 | 0
+ 128 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 256 | 0
+
+ 300
+ value ------------- Distribution ------------- count
+ 128 | 0
+ 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 512 | 0
+
+ 400
+ value ------------- Distribution ------------- count
+ 128 | 0
+ 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 512 | 0
+
+ 500
+ value ------------- Distribution ------------- count
+ 128 | 0
+ 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 512 | 0
+
+ 600
+ value ------------- Distribution ------------- count
+ 256 | 0
+ 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1024 | 0
+
+ 700
+ value ------------- Distribution ------------- count
+ 256 | 0
+ 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1024 | 0
+
+ 800
+ value ------------- Distribution ------------- count
+ 256 | 0
+ 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1024 | 0
+
+ 900
+ value ------------- Distribution ------------- count
+ 256 | 0
+ 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1024 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d
new file mode 100644
index 00000000..e547b1ec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+int64_t val, shift;
+
+tick-1ms
+/val == 0/
+{
+ val = -(1 << shift);
+ shift++;
+}
+
+tick-1ms
+/shift == 32/
+{
+ exit(0);
+}
+
+tick-1ms
+/val == -1/
+{
+ val = (1 << shift);
+}
+
+tick-1ms
+{
+ @[shift] = quantize(val, val);
+ val >>= 1;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d.out
new file mode 100644
index 00000000..45df2491
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d.out
@@ -0,0 +1,1208 @@
+
+ 1
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@ 1
+ 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 4 | 0
+
+ 2
+ value ------------- Distribution ------------- count
+ -4 | 0
+ -2 @@@@| -2
+ -1 | 0
+ 0 | 0
+ 1 |@@ 1
+ 2 |@@@@ 2
+ 4 |@@@@@@@@@ 4
+ 8 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ -8 | 0
+ -4 @@@@| -4
+ -2 @@| -2
+ -1 | 0
+ 0 | 0
+ 1 |@ 1
+ 2 |@@ 2
+ 4 |@@@@ 4
+ 8 |@@@@@@@@ 8
+ 16 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ -16 | 0
+ -8 @@@@| -8
+ -4 @@| -4
+ -2 @| -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 |@ 2
+ 4 |@@ 4
+ 8 |@@@@ 8
+ 16 |@@@@@@@ 16
+ 32 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ -32 | 0
+ -16 @@@| -16
+ -8 @@| -8
+ -4 @| -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 |@ 4
+ 8 |@@ 8
+ 16 |@@@ 16
+ 32 |@@@@@@@ 32
+ 64 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ -64 | 0
+ -32 @@@| -32
+ -16 @@| -16
+ -8 @| -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 |@ 8
+ 16 |@@ 16
+ 32 |@@@ 32
+ 64 |@@@@@@@ 64
+ 128 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ -128 | 0
+ -64 @@@| -64
+ -32 @@| -32
+ -16 @| -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 |@ 16
+ 32 |@@ 32
+ 64 |@@@ 64
+ 128 |@@@@@@@ 128
+ 256 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ -256 | 0
+ -128 @@@| -128
+ -64 @@| -64
+ -32 @| -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 |@ 32
+ 64 |@@ 64
+ 128 |@@@ 128
+ 256 |@@@@@@@ 256
+ 512 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ -512 | 0
+ -256 @@@| -256
+ -128 @@| -128
+ -64 @| -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 |@ 64
+ 128 |@@ 128
+ 256 |@@@ 256
+ 512 |@@@@@@@ 512
+ 1024 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ -1024 | 0
+ -512 @@@| -512
+ -256 @@| -256
+ -128 @| -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 |@ 128
+ 256 |@@ 256
+ 512 |@@@ 512
+ 1024 |@@@@@@@ 1024
+ 2048 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ -2048 | 0
+ -1024 @@@| -1024
+ -512 @@| -512
+ -256 @| -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 |@ 256
+ 512 |@@ 512
+ 1024 |@@@ 1024
+ 2048 |@@@@@@@ 2048
+ 4096 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ -4096 | 0
+ -2048 @@@| -2048
+ -1024 @@| -1024
+ -512 @| -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 |@ 512
+ 1024 |@@ 1024
+ 2048 |@@@ 2048
+ 4096 |@@@@@@@ 4096
+ 8192 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ -8192 | 0
+ -4096 @@@| -4096
+ -2048 @@| -2048
+ -1024 @| -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 |@ 1024
+ 2048 |@@ 2048
+ 4096 |@@@ 4096
+ 8192 |@@@@@@@ 8192
+ 16384 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ -16384 | 0
+ -8192 @@@| -8192
+ -4096 @@| -4096
+ -2048 @| -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 |@ 2048
+ 4096 |@@ 4096
+ 8192 |@@@ 8192
+ 16384 |@@@@@@@ 16384
+ 32768 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ -32768 | 0
+ -16384 @@@| -16384
+ -8192 @@| -8192
+ -4096 @| -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 |@ 4096
+ 8192 |@@ 8192
+ 16384 |@@@ 16384
+ 32768 |@@@@@@@ 32768
+ 65536 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ -65536 | 0
+ -32768 @@@| -32768
+ -16384 @@| -16384
+ -8192 @| -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 |@ 8192
+ 16384 |@@ 16384
+ 32768 |@@@ 32768
+ 65536 |@@@@@@@ 65536
+ 131072 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ -131072 | 0
+ -65536 @@@| -65536
+ -32768 @@| -32768
+ -16384 @| -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 |@ 16384
+ 32768 |@@ 32768
+ 65536 |@@@ 65536
+ 131072 |@@@@@@@ 131072
+ 262144 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ -262144 | 0
+ -131072 @@@| -131072
+ -65536 @@| -65536
+ -32768 @| -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 |@ 32768
+ 65536 |@@ 65536
+ 131072 |@@@ 131072
+ 262144 |@@@@@@@ 262144
+ 524288 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ -524288 | 0
+ -262144 @@@| -262144
+ -131072 @@| -131072
+ -65536 @| -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 |@ 65536
+ 131072 |@@ 131072
+ 262144 |@@@ 262144
+ 524288 |@@@@@@@ 524288
+ 1048576 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ -1048576 | 0
+ -524288 @@@| -524288
+ -262144 @@| -262144
+ -131072 @| -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 |@ 131072
+ 262144 |@@ 262144
+ 524288 |@@@ 524288
+ 1048576 |@@@@@@@ 1048576
+ 2097152 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ -2097152 | 0
+ -1048576 @@@| -1048576
+ -524288 @@| -524288
+ -262144 @| -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 |@ 262144
+ 524288 |@@ 524288
+ 1048576 |@@@ 1048576
+ 2097152 |@@@@@@@ 2097152
+ 4194304 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ -4194304 | 0
+ -2097152 @@@| -2097152
+ -1048576 @@| -1048576
+ -524288 @| -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 |@ 524288
+ 1048576 |@@ 1048576
+ 2097152 |@@@ 2097152
+ 4194304 |@@@@@@@ 4194304
+ 8388608 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ -8388608 | 0
+ -4194304 @@@| -4194304
+ -2097152 @@| -2097152
+ -1048576 @| -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 |@ 1048576
+ 2097152 |@@ 2097152
+ 4194304 |@@@ 4194304
+ 8388608 |@@@@@@@ 8388608
+ 16777216 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ -16777216 | 0
+ -8388608 @@@| -8388608
+ -4194304 @@| -4194304
+ -2097152 @| -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 |@ 2097152
+ 4194304 |@@ 4194304
+ 8388608 |@@@ 8388608
+ 16777216 |@@@@@@@ 16777216
+ 33554432 | 0
+
+ 25
+ value ------------- Distribution ------------- count
+ -33554432 | 0
+ -16777216 @@@| -16777216
+ -8388608 @@| -8388608
+ -4194304 @| -4194304
+ -2097152 | -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 | 2097152
+ 4194304 |@ 4194304
+ 8388608 |@@ 8388608
+ 16777216 |@@@ 16777216
+ 33554432 |@@@@@@@ 33554432
+ 67108864 | 0
+
+ 26
+ value ------------- Distribution ------------- count
+ -67108864 | 0
+ -33554432 @@@| -33554432
+ -16777216 @@| -16777216
+ -8388608 @| -8388608
+ -4194304 | -4194304
+ -2097152 | -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 | 2097152
+ 4194304 | 4194304
+ 8388608 |@ 8388608
+ 16777216 |@@ 16777216
+ 33554432 |@@@ 33554432
+ 67108864 |@@@@@@@ 67108864
+ 134217728 | 0
+
+ 27
+ value ------------- Distribution ------------- count
+ -134217728 | 0
+ -67108864 @@@| -67108864
+ -33554432 @@| -33554432
+ -16777216 @| -16777216
+ -8388608 | -8388608
+ -4194304 | -4194304
+ -2097152 | -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 | 2097152
+ 4194304 | 4194304
+ 8388608 | 8388608
+ 16777216 |@ 16777216
+ 33554432 |@@ 33554432
+ 67108864 |@@@ 67108864
+ 134217728 |@@@@@@@ 134217728
+ 268435456 | 0
+
+ 28
+ value ------------- Distribution ------------- count
+ -268435456 | 0
+ -134217728 @@@| -134217728
+ -67108864 @@| -67108864
+ -33554432 @| -33554432
+ -16777216 | -16777216
+ -8388608 | -8388608
+ -4194304 | -4194304
+ -2097152 | -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 | 2097152
+ 4194304 | 4194304
+ 8388608 | 8388608
+ 16777216 | 16777216
+ 33554432 |@ 33554432
+ 67108864 |@@ 67108864
+ 134217728 |@@@ 134217728
+ 268435456 |@@@@@@@ 268435456
+ 536870912 | 0
+
+ 29
+ value ------------- Distribution ------------- count
+ -536870912 | 0
+ -268435456 @@@| -268435456
+ -134217728 @@| -134217728
+ -67108864 @| -67108864
+ -33554432 | -33554432
+ -16777216 | -16777216
+ -8388608 | -8388608
+ -4194304 | -4194304
+ -2097152 | -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 | 2097152
+ 4194304 | 4194304
+ 8388608 | 8388608
+ 16777216 | 16777216
+ 33554432 | 33554432
+ 67108864 |@ 67108864
+ 134217728 |@@ 134217728
+ 268435456 |@@@ 268435456
+ 536870912 |@@@@@@@ 536870912
+ 1073741824 | 0
+
+ 30
+ value ------------- Distribution ------------- count
+ -1073741824 | 0
+ -536870912 @@@| -536870912
+ -268435456 @@| -268435456
+ -134217728 @| -134217728
+ -67108864 | -67108864
+ -33554432 | -33554432
+ -16777216 | -16777216
+ -8388608 | -8388608
+ -4194304 | -4194304
+ -2097152 | -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 | 2097152
+ 4194304 | 4194304
+ 8388608 | 8388608
+ 16777216 | 16777216
+ 33554432 | 33554432
+ 67108864 | 67108864
+ 134217728 |@ 134217728
+ 268435456 |@@ 268435456
+ 536870912 |@@@ 536870912
+ 1073741824 |@@@@@@@ 1073741824
+ 2147483648 | 0
+
+ 31
+ value ------------- Distribution ------------- count
+ -2147483648 | 0
+ -1073741824 @@@| -1073741824
+ -536870912 @@| -536870912
+ -268435456 @| -268435456
+ -134217728 | -134217728
+ -67108864 | -67108864
+ -33554432 | -33554432
+ -16777216 | -16777216
+ -8388608 | -8388608
+ -4194304 | -4194304
+ -2097152 | -2097152
+ -1048576 | -1048576
+ -524288 | -524288
+ -262144 | -262144
+ -131072 | -131072
+ -65536 | -65536
+ -32768 | -32768
+ -16384 | -16384
+ -8192 | -8192
+ -4096 | -4096
+ -2048 | -2048
+ -1024 | -1024
+ -512 | -512
+ -256 | -256
+ -128 | -128
+ -64 | -64
+ -32 | -32
+ -16 | -16
+ -8 | -8
+ -4 | -4
+ -2 | -2
+ -1 | 0
+ 0 | 0
+ 1 | 1
+ 2 | 2
+ 4 | 4
+ 8 | 8
+ 16 | 16
+ 32 | 32
+ 64 | 64
+ 128 | 128
+ 256 | 256
+ 512 | 512
+ 1024 | 1024
+ 2048 | 2048
+ 4096 | 4096
+ 8192 | 8192
+ 16384 | 16384
+ 32768 | 32768
+ 65536 | 65536
+ 131072 | 131072
+ 262144 | 262144
+ 524288 | 524288
+ 1048576 | 1048576
+ 2097152 | 2097152
+ 4194304 | 4194304
+ 8388608 | 8388608
+ 16777216 | 16777216
+ 33554432 | 33554432
+ 67108864 | 67108864
+ 134217728 | 134217728
+ 268435456 |@ 268435456
+ 536870912 |@@ 536870912
+ 1073741824 |@@@ 1073741824
+ 2147483648 |@@@@@@@ 2147483648
+ 4294967296 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d
new file mode 100644
index 00000000..c40d69c0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+/*
+ * This test verifies that the height of the ASCII quantization bars is
+ * determined using rounding and not truncated integer arithmetic.
+ */
+tick-10ms
+/i++ >= 27/
+{
+ exit(0);
+}
+
+tick-10ms
+/i > 8/
+{
+ @ = quantize(2);
+}
+
+tick-10ms
+/i > 2 && i <= 8/
+{
+ @ = quantize(1);
+}
+
+tick-10ms
+/i <= 2/
+{
+ @ = quantize(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d.out
new file mode 100644
index 00000000..9b89ec14
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantround.d.out
@@ -0,0 +1,9 @@
+
+
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@ 2
+ 1 |@@@@@@@@@ 6
+ 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 19
+ 4 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d
new file mode 100644
index 00000000..bfa633cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ a = 7;
+ b = 13;
+ val = (-a * b) + a;
+}
+
+tick-1ms
+{
+ incr = val % b;
+ val += a;
+}
+
+tick-1ms
+/val == 0/
+{
+ val += a;
+}
+
+tick-1ms
+/incr != 0/
+{
+ i++;
+ @[i] = quantize(0, incr);
+}
+
+tick-1ms
+/incr == 0/
+{
+ printa(@);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d.out
new file mode 100644
index 00000000..c2c1cf02
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d.out
@@ -0,0 +1,146 @@
+
+ 2
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12
+ 1 | 0
+
+ 4
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11
+ 1 | 0
+
+ 6
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10
+ 1 | 0
+
+ 8
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9
+ 1 | 0
+
+ 10
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8
+ 1 | 0
+
+ 12
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7
+ 1 | 0
+
+ 1
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6
+ 1 | 0
+
+ 3
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5
+ 1 | 0
+
+ 5
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4
+ 1 | 0
+
+ 7
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3
+ 1 | 0
+
+ 9
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2
+ 1 | 0
+
+ 11
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1
+ 1 | 0
+
+ 14
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 1 | 0
+
+ 16
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
+ 1 | 0
+
+ 18
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
+ 1 | 0
+
+ 20
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4
+ 1 | 0
+
+ 22
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
+ 1 | 0
+
+ 24
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6
+ 1 | 0
+
+ 13
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7
+ 1 | 0
+
+ 15
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8
+ 1 | 0
+
+ 17
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
+ 1 | 0
+
+ 19
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
+ 1 | 0
+
+ 21
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
+ 1 | 0
+
+ 23
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12
+ 1 | 0
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signature.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signature.d
new file mode 100644
index 00000000..baa951a4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signature.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * This is a simple test to make sure that signature checking works properly
+ * for the fake-o types.
+ */
+BEGIN
+{
+ @stk[ustack()] = count();
+ @symmy[sym(0)] = count();
+ @usymmy[usym(0)] = count();
+ @funky[func(0)] = count();
+ @ufunky[ufunc(0)] = count();
+ @moddy[mod(0)] = count();
+ @umoddy[umod(0)] = count();
+}
+
+BEGIN
+{
+ @stk[ustack()] = count();
+ @symmy[sym(0)] = count();
+ @usymmy[usym(0)] = count();
+ @funky[func(0)] = count();
+ @ufunky[ufunc(0)] = count();
+ @moddy[mod(0)] = count();
+ @umoddy[umod(0)] = count();
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d
new file mode 100644
index 00000000..ed3d1314
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d
@@ -0,0 +1,120 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Signed integer keys print and sort as expected.
+ *
+ * SECTION: Aggregations, Printing Aggregations
+ *
+ * NOTES: DTrace sorts integer keys as unsigned values, yet prints 32-
+ * and 64-bit integers as signed values. Since the Java DTrace API is
+ * expected to emulate this behavior, this test was added to ensure that
+ * the behavior is preserved. Consistency with trace() output is also
+ * tested.
+ */
+
+#pragma D option quiet
+#pragma D option aggsortkey
+
+BEGIN
+{
+ trace((char)-2);
+ trace("\n");
+ trace((char)-1);
+ trace("\n");
+ trace((char)0);
+ trace("\n");
+ trace((char)1);
+ trace("\n");
+ trace((char)2);
+ trace("\n");
+ trace("\n");
+
+ trace((short)-2);
+ trace("\n");
+ trace((short)-1);
+ trace("\n");
+ trace((short)0);
+ trace("\n");
+ trace((short)1);
+ trace("\n");
+ trace((short)2);
+ trace("\n");
+ trace("\n");
+
+ trace(-2);
+ trace("\n");
+ trace(-1);
+ trace("\n");
+ trace(0);
+ trace("\n");
+ trace(1);
+ trace("\n");
+ trace(2);
+ trace("\n");
+ trace("\n");
+
+ trace((long long)-2);
+ trace("\n");
+ trace((long long)-1);
+ trace("\n");
+ trace((long long)0);
+ trace("\n");
+ trace((long long)1);
+ trace("\n");
+ trace((long long)2);
+ trace("\n");
+
+ @i8[(char)-2] = sum(-2);
+ @i8[(char)-1] = sum(-1);
+ @i8[(char)0] = sum(0);
+ @i8[(char)1] = sum(1);
+ @i8[(char)2] = sum(2);
+
+ @i16[(short)-2] = sum(-2);
+ @i16[(short)-1] = sum(-1);
+ @i16[(short)0] = sum(0);
+ @i16[(short)1] = sum(1);
+ @i16[(short)2] = sum(2);
+
+ @i32[-2] = sum(-2);
+ @i32[-1] = sum(-1);
+ @i32[0] = sum(0);
+ @i32[1] = sum(1);
+ @i32[2] = sum(2);
+
+ @i64[(long long)-2] = sum(-2);
+ @i64[(long long)-1] = sum(-1);
+ @i64[(long long)0] = sum(0);
+ @i64[(long long)1] = sum(1);
+ @i64[(long long)2] = sum(2);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d.out
new file mode 100644
index 00000000..42e619e0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d.out
@@ -0,0 +1,44 @@
+254
+255
+0
+1
+2
+
+65534
+65535
+0
+1
+2
+
+-2
+-1
+0
+1
+2
+
+-2
+-1
+0
+1
+2
+
+ 0 0
+ 1 1
+ 2 2
+ 254 -2
+ 255 -1
+ 0 0
+ 1 1
+ 2 2
+ 65534 -2
+ 65535 -1
+ 0 0
+ 1 1
+ 2 2
+ -2 -2
+ -1 -1
+ 0 0
+ 1 1
+ 2 2
+ -2 -2
+ -1 -1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d
new file mode 100644
index 00000000..5836c6a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d
@@ -0,0 +1,115 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Signed integer keys print and sort as expected using the
+ * aggsortkeypos and aggsortrev options
+ *
+ * SECTION: Aggregations, Printing Aggregations
+ *
+ * NOTES: DTrace sorts integer keys as unsigned values, yet prints 32-
+ * and 64-bit integers as signed values. Since the Java DTrace API is
+ * expected to emulate this behavior, this test was added to ensure that
+ * the behavior is preserved.
+ */
+
+#pragma D option quiet
+#pragma D option aggsortkey
+#pragma D option aggsortkeypos=1
+#pragma D option aggsortrev
+
+BEGIN
+{
+ @i8["cat", (char)-2] = sum(-2);
+ @i8["dog", (char)-2] = sum(-22);
+ @i8["mouse", (char)-2] = sum(-222);
+ @i8["cat", (char)-1] = sum(-1);
+ @i8["dog", (char)-1] = sum(-11);
+ @i8["mouse", (char)-1] = sum(-111);
+ @i8["cat", (char)0] = sum(0);
+ @i8["dog", (char)0] = sum(10);
+ @i8["mouse", (char)0] = sum(100);
+ @i8["cat", (char)1] = sum(1);
+ @i8["dog", (char)1] = sum(11);
+ @i8["mouse", (char)1] = sum(111);
+ @i8["cat", (char)2] = sum(2);
+ @i8["dog", (char)2] = sum(22);
+ @i8["mouse", (char)2] = sum(222);
+
+ @i16["mouse", (short)-2] = sum(-2);
+ @i16["dog", (short)-2] = sum(-22);
+ @i16["cat", (short)-2] = sum(-222);
+ @i16["mouse", (short)-1] = sum(-1);
+ @i16["dog", (short)-1] = sum(-11);
+ @i16["cat", (short)-1] = sum(-111);
+ @i16["mouse", (short)0] = sum(0);
+ @i16["dog", (short)0] = sum(10);
+ @i16["cat", (short)0] = sum(100);
+ @i16["mouse", (short)1] = sum(1);
+ @i16["dog", (short)1] = sum(11);
+ @i16["cat", (short)1] = sum(111);
+ @i16["mouse", (short)2] = sum(2);
+ @i16["dog", (short)2] = sum(22);
+ @i16["cat", (short)2] = sum(222);
+
+ @i32["mouse", -2] = sum(-2);
+ @i32["bear", -2] = sum(-22);
+ @i32["cat", -2] = sum(-222);
+ @i32["mouse", -1] = sum(-1);
+ @i32["bear", -1] = sum(-11);
+ @i32["cat", -1] = sum(-111);
+ @i32["mouse", 0] = sum(0);
+ @i32["bear", 0] = sum(10);
+ @i32["cat", 0] = sum(100);
+ @i32["mouse", 1] = sum(1);
+ @i32["bear", 1] = sum(11);
+ @i32["cat", 1] = sum(111);
+ @i32["mouse", 2] = sum(2);
+ @i32["bear", 2] = sum(22);
+ @i32["cat", 2] = sum(222);
+
+ @i64["cat", (long long)-2] = sum(-2);
+ @i64["bear", (long long)-2] = sum(-22);
+ @i64["dog", (long long)-2] = sum(-222);
+ @i64["cat", (long long)-1] = sum(-1);
+ @i64["bear", (long long)-1] = sum(-11);
+ @i64["dog", (long long)-1] = sum(-111);
+ @i64["cat", (long long)0] = sum(0);
+ @i64["bear", (long long)0] = sum(10);
+ @i64["dog", (long long)0] = sum(100);
+ @i64["cat", (long long)1] = sum(1);
+ @i64["bear", (long long)1] = sum(11);
+ @i64["dog", (long long)1] = sum(111);
+ @i64["cat", (long long)2] = sum(2);
+ @i64["bear", (long long)2] = sum(22);
+ @i64["dog", (long long)2] = sum(222);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d.out
new file mode 100644
index 00000000..28e95ac3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d.out
@@ -0,0 +1,61 @@
+
+ dog -1 -111
+ cat -1 -1
+ bear -1 -11
+ dog -2 -222
+ cat -2 -2
+ bear -2 -22
+ dog 2 222
+ cat 2 2
+ bear 2 22
+ dog 1 111
+ cat 1 1
+ bear 1 11
+ dog 0 100
+ cat 0 0
+ bear 0 10
+ mouse -1 -1
+ cat -1 -111
+ bear -1 -11
+ mouse -2 -2
+ cat -2 -222
+ bear -2 -22
+ mouse 2 2
+ cat 2 222
+ bear 2 22
+ mouse 1 1
+ cat 1 111
+ bear 1 11
+ mouse 0 0
+ cat 0 100
+ bear 0 10
+ mouse 65535 -1
+ dog 65535 -11
+ cat 65535 -111
+ mouse 65534 -2
+ dog 65534 -22
+ cat 65534 -222
+ mouse 2 2
+ dog 2 22
+ cat 2 222
+ mouse 1 1
+ dog 1 11
+ cat 1 111
+ mouse 0 0
+ dog 0 10
+ cat 0 100
+ mouse 255 -111
+ dog 255 -11
+ cat 255 -1
+ mouse 254 -222
+ dog 254 -22
+ cat 254 -2
+ mouse 2 222
+ dog 2 22
+ cat 2 2
+ mouse 1 111
+ dog 1 11
+ cat 1 1
+ mouse 0 100
+ dog 0 10
+ cat 0 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d
new file mode 100644
index 00000000..041b8207
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Positive stddev() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is a simple verifiable positive test of the stddev() function.
+ * printa() for one aggregation, default printing behavior for the other
+ * so that we exercise both code paths.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a = stddev(5000000000);
+ @a = stddev(5000000100);
+ @a = stddev(5000000200);
+ @a = stddev(5000000300);
+ @a = stddev(5000000400);
+ @a = stddev(5000000500);
+ @a = stddev(5000000600);
+ @a = stddev(5000000700);
+ @a = stddev(5000000800);
+ @a = stddev(5000000900);
+ @b = stddev(-5000000000);
+ @b = stddev(-5000000100);
+ @b = stddev(-5000000200);
+ @b = stddev(-5000000300);
+ @b = stddev(-5000000400);
+ @b = stddev(-5000000500);
+ @b = stddev(-5000000600);
+ @b = stddev(-5000000700);
+ @b = stddev(-5000000800);
+ @b = stddev(-5000000900);
+ printa("%@d\n", @a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out
new file mode 100644
index 00000000..0c02852e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out
@@ -0,0 +1,3 @@
+287
+
+ 287
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.subr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.subr.d
new file mode 100644
index 00000000..5ca1f1ef
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.subr.d
@@ -0,0 +1,112 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/dtrace.h>
+
+#define INTFUNC(x) \
+ BEGIN \
+ /*DSTYLED*/ \
+ { \
+ subr++; \
+ @[(long)x] = sum(1); \
+ /*DSTYLED*/ \
+ }
+
+#define STRFUNC(x) \
+ BEGIN \
+ /*DSTYLED*/ \
+ { \
+ subr++; \
+ @str[x] = sum(1); \
+ /*DSTYLED*/ \
+ }
+
+#define VOIDFUNC(x) \
+ BEGIN \
+ /*DSTYLED*/ \
+ { \
+ subr++; \
+ /*DSTYLED*/ \
+ }
+
+INTFUNC(rand())
+INTFUNC(mutex_owned(&`cpu_lock))
+INTFUNC(mutex_owner(&`cpu_lock))
+INTFUNC(mutex_type_adaptive(&`cpu_lock))
+INTFUNC(mutex_type_spin(&`cpu_lock))
+INTFUNC(rw_read_held(&`vfssw_lock))
+INTFUNC(rw_write_held(&`vfssw_lock))
+INTFUNC(rw_iswriter(&`vfssw_lock))
+INTFUNC(copyin(NULL, 1))
+STRFUNC(copyinstr(NULL, 1))
+INTFUNC(speculation())
+INTFUNC(progenyof($pid))
+INTFUNC(strlen("fooey"))
+VOIDFUNC(copyout)
+VOIDFUNC(copyoutstr)
+INTFUNC(alloca(10))
+VOIDFUNC(bcopy)
+VOIDFUNC(copyinto)
+INTFUNC(msgdsize(NULL))
+INTFUNC(msgsize(NULL))
+INTFUNC(getmajor(0))
+INTFUNC(getminor(0))
+STRFUNC(ddi_pathname(NULL, 0))
+STRFUNC(strjoin("foo", "bar"))
+STRFUNC(lltostr(12373))
+STRFUNC(basename("/var/crash/systemtap"))
+STRFUNC(dirname("/var/crash/systemtap"))
+STRFUNC(cleanpath("/var/crash/systemtap"))
+STRFUNC(strchr("The SystemTap, The.", 't'))
+STRFUNC(strrchr("The SystemTap, The.", 't'))
+STRFUNC(strstr("The SystemTap, The.", "The"))
+STRFUNC(strtok("The SystemTap, The.", "T"))
+STRFUNC(substr("The SystemTap, The.", 0))
+INTFUNC(index("The SystemTap, The.", "The"))
+INTFUNC(rindex("The SystemTap, The.", "The"))
+INTFUNC(htons(0x1234))
+INTFUNC(htonl(0x12345678))
+INTFUNC(htonll(0x1234567890abcdefL))
+INTFUNC(ntohs(0x1234))
+INTFUNC(ntohl(0x12345678))
+INTFUNC(ntohll(0x1234567890abcdefL))
+STRFUNC(inet_ntoa((ipaddr_t *)alloca(sizeof (ipaddr_t))))
+STRFUNC(inet_ntoa6((in6_addr_t *)alloca(sizeof (in6_addr_t))))
+STRFUNC(inet_ntop(AF_INET, (void *)alloca(sizeof (ipaddr_t))))
+
+BEGIN
+/subr == DIF_SUBR_MAX + 1/
+{
+ exit(0);
+}
+
+BEGIN
+{
+ printf("found %d subroutines, expected %d\n", subr, DIF_SUBR_MAX + 1);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d
new file mode 100644
index 00000000..1b9025af
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive sum() test
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ * NOTES: This is verifiable simple positive test of the sum() function.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 1000/
+{
+ @a = sum(i);
+ i += 100;
+}
+
+tick-10ms
+/i == 1000/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d.out
new file mode 100644
index 00000000..5d8b37b8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.sum.d.out
@@ -0,0 +1,2 @@
+
+ 4500
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d
new file mode 100644
index 00000000..d1c1b3cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+int i;
+
+tick-10ms
+/i < 100/
+{
+ @[i] = sum(i);
+ i++;
+}
+
+tick-10ms
+/i == 100/
+{
+ exit(0);
+}
+
+END
+{
+ trunc(@, 10);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d.out
new file mode 100644
index 00000000..2e18ef8b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc.d.out
@@ -0,0 +1,11 @@
+
+ 90 90
+ 91 91
+ 92 92
+ 93 93
+ 94 94
+ 95 95
+ 96 96
+ 97 97
+ 98 98
+ 99 99
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d
new file mode 100644
index 00000000..5c31069d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+#pragma D option aggrate=1ms
+#pragma D option switchrate=50ms
+
+int i;
+
+tick-100ms
+/i < 10/
+{
+ @[i] = sum(10 - i);
+ i++;
+}
+
+tick-100ms
+/i == 5/
+{
+ trunc(@);
+}
+
+tick-100ms
+/i == 10/
+{
+ exit(0);
+}
+
+END
+{
+ printa(@);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d.out
new file mode 100644
index 00000000..70dc7a02
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d.out
@@ -0,0 +1,7 @@
+
+ 9 1
+ 8 2
+ 7 3
+ 6 4
+ 5 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d
new file mode 100644
index 00000000..8baa56ab
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+int i;
+
+tick-10ms
+/i < 100/
+{
+ @[i] = lquantize(i, 0, 150);
+ @[i] = lquantize(i + 1, 0, 150);
+ @[i] = lquantize(i + 2, 0, 150);
+ @[i] = lquantize(i + 3, 0, 150);
+ i++;
+}
+
+tick-10ms
+/i == 100/
+{
+ exit(0);
+}
+
+END
+{
+ trunc(@, 5);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d.out
new file mode 100644
index 00000000..86975af3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d.out
@@ -0,0 +1,46 @@
+
+ 95
+ value ------------- Distribution ------------- count
+ 94 | 0
+ 95 |@@@@@@@@@@ 1
+ 96 |@@@@@@@@@@ 1
+ 97 |@@@@@@@@@@ 1
+ 98 |@@@@@@@@@@ 1
+ 99 | 0
+
+ 96
+ value ------------- Distribution ------------- count
+ 95 | 0
+ 96 |@@@@@@@@@@ 1
+ 97 |@@@@@@@@@@ 1
+ 98 |@@@@@@@@@@ 1
+ 99 |@@@@@@@@@@ 1
+ 100 | 0
+
+ 97
+ value ------------- Distribution ------------- count
+ 96 | 0
+ 97 |@@@@@@@@@@ 1
+ 98 |@@@@@@@@@@ 1
+ 99 |@@@@@@@@@@ 1
+ 100 |@@@@@@@@@@ 1
+ 101 | 0
+
+ 98
+ value ------------- Distribution ------------- count
+ 97 | 0
+ 98 |@@@@@@@@@@ 1
+ 99 |@@@@@@@@@@ 1
+ 100 |@@@@@@@@@@ 1
+ 101 |@@@@@@@@@@ 1
+ 102 | 0
+
+ 99
+ value ------------- Distribution ------------- count
+ 98 | 0
+ 99 |@@@@@@@@@@ 1
+ 100 |@@@@@@@@@@ 1
+ 101 |@@@@@@@@@@ 1
+ 102 |@@@@@@@@@@ 1
+ 103 | 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d
new file mode 100644
index 00000000..ec0bee32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * aggsortkeypos option works when sorting by values, values are
+ * equal, and keys are compared to break the tie
+ *
+ * SECTION: Aggregations, Printing Aggregations
+ *
+ */
+
+#pragma D option quiet
+#pragma D option aggsortkeypos=1
+
+BEGIN
+{
+ @[1, 3] = sum(0);
+ @[2, 2] = sum(0);
+ @[3, 1] = sum(0);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d.out
new file mode 100644
index 00000000..9b0acf92
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d.out
@@ -0,0 +1,4 @@
+
+ 3 1 0
+ 2 2 0
+ 1 3 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0.d
new file mode 100644
index 00000000..0b7b6610
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify that divide by 0 errors are caught
+ *
+ * SECTION:
+ * Types, Operators, and Expressions/Arithmetic Operators
+ */
+
+
+BEGIN
+{
+ c = 123/0;
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_1.d
new file mode 100644
index 00000000..11017951
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_1.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify that computed divide by 0 errors are caught
+ *
+ * SECTION:
+ * Types, Operators, and Expressions/Arithmetic Operators
+ */
+
+
+
+
+BEGIN
+{
+ c = 123/(7-7);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_2.d
new file mode 100644
index 00000000..45469614
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_2.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify that computed divide by 0 errors are caught
+ *
+ * SECTION:
+ * Types, Operators, and Expressions/Arithmetic Operators
+ */
+
+
+
+
+
+BEGIN
+{
+ c = 123/((7-7) * 999);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.modby0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.modby0.d
new file mode 100644
index 00000000..b2bf1462
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.modby0.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify that mod by 0 errors are caught
+ *
+ * SECTION:
+ * Types, Operators, and Expressions/Arithmetic Operators
+ */
+
+
+
+BEGIN
+{
+ c = 123%0;
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.addmin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.addmin.d
new file mode 100644
index 00000000..f20339c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.addmin.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call invalid / impossible arithmetic operations and make sure
+ * Test gives compilation error.
+ *
+ * SECTION: Types, Operators, and Expressions/Arithmetic Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ i+-;
+ printf("The value of i is %d\n", i);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.divmin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.divmin.d
new file mode 100644
index 00000000..c11e64fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.divmin.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call invalid / impossible arithmetic operations and make sure
+ * Test gives compilation error.
+ *
+ * SECTION: Types, Operators, and Expressions/Arithmetic Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 1;
+ i /-= i;
+ printf("The value of i is %d\n", i);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muladd.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muladd.d
new file mode 100644
index 00000000..bb107fb3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muladd.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call invalid / impossible arithmetic operations and make sure
+ * Test gives compilation error.
+ *
+ * SECTION: Types, Operators, and Expressions/Arithmetic Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 1;
+ i *+= i;
+ printf("The value of i is %d\n", i);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muldiv.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muldiv.d
new file mode 100644
index 00000000..7d44b6c7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muldiv.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call invalid / impossible arithmetic operations and make sure
+ * Test gives compilation error.
+ *
+ * SECTION: Types, Operators, and Expressions/Arithmetic Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 1;
+ i */= i;
+ printf("The value of i is %d\n", i);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d
new file mode 100644
index 00000000..435f09f6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple Arithmetic expressions.
+ * Call simple expressions and make sure test succeeds.
+ * Match expected output in tst.basics.d.out
+ *
+ * SECTION: Types, Operators, and Expressions/Arithmetic Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ i = 1 + 2 + 3;
+ printf("The value of i is %d\n", i);
+
+ i = i * 3;
+ printf("The value of i is %d\n", i);
+
+ i = (i * 3) + i;
+ printf("The value of i is %d\n", i);
+
+ i = (i + (i * 3) + i) * i;
+ printf("The value of i is %d\n", i);
+
+ i = i - (i + (i * 3) + i) * i / i * i;
+ printf("The value of i is %d\n", i);
+
+ i = i * (i - 3 + 5 / i * i ) / i * 6;
+ printf("The value of i is %d\n", i);
+
+ i = i ^ 5;
+ printf("The value of i is %d\n", i);
+
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d
new file mode 100644
index 00000000..2db1b635
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Complex expressions.
+ * Call complex expressions and make sure test succeeds.
+ * Match expected output in tst.complex.d.out
+ *
+ * SECTION: Types, Operators, and Expressions/Arithmetic Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ i = i++ + ++i;
+ printf("The value of i is %d\n", i);
+ i = i-- - --i;
+ printf("The value of i is %d\n", i);
+ i = i-- + ++i;
+ printf("The value of i is %d\n", i);
+ i += i++ + -- i + ++i - ++i * i ;
+ printf("The value of i is %d\n", i);
+ i -= i++ * 3;
+ printf("The value of i is %d\n", i);
+ i = i++/i--+i++-++i-++i;
+ printf("The value of i is %d\n", i);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_ARR_BADREF.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_ARR_BADREF.bad.d
new file mode 100644
index 00000000..d31b1f64
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_ARR_BADREF.bad.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Tuples can not be used in non-associative arrays.
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ */
+
+int x[5];
+
+BEGIN
+{
+ x[1, 2] = 1;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d
new file mode 100644
index 00000000..80422e88
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Array declarations with indexs over INT_MAX return a
+ * D_DECL_ARRBIG errtag.
+ *
+ * SECTION:
+ * Pointers and Arrays/Array Declarations and Storage
+ */
+
+int x[88294967295];
+
+BEGIN
+{
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRNULL.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRNULL.bad.d
new file mode 100644
index 00000000..6e7a34ff
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRNULL.bad.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Arrays must have array dimensions
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ */
+
+int a[];
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRSUB.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRSUB.bad.d
new file mode 100644
index 00000000..f4403677
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRSUB.bad.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Arrays declarations must have a positive constant as a
+ * subscription.
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ */
+
+int a[-7];
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_PROTO_TYPE.badtuple.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_PROTO_TYPE.badtuple.d
new file mode 100644
index 00000000..7e879dc6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_DECL_PROTO_TYPE.badtuple.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid tuple types result in a DT_DECL_ARRTYPE error.
+ *
+ * SECTION:
+ * Pointers and Arrays/Array Declarations and Storage
+ */
+
+
+int x[void, char];
+
+BEGIN
+{
+ x[trace(), 'a'] = 456;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_IDENT_UNDEF.badureg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_IDENT_UNDEF.badureg.d
new file mode 100644
index 00000000..e48541b6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/err.D_IDENT_UNDEF.badureg.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Arrays declarations must have a positive constant as a
+ * subscription.
+ *
+ * SECTION: User Process Tracing/uregs Array
+ */
+
+BEGIN
+{
+ printf("FOO = 0x%x\n", uregs[FOO]);
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic1.d
new file mode 100644
index 00000000..ba5b2cf0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic1.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple array test
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ a[1] = 0;
+}
+
+tick-1
+/a[1] == 0/
+{
+ exit(0);
+}
+
+tick-1
+/a[1] != 0/
+{
+ printf("Expected 0, got %d\n", a[1]);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic2.d
new file mode 100644
index 00000000..14e1c5cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic2.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple array test
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ a[1] = 0;
+ a[1]++;
+}
+
+tick-1
+/a[1] == 1/
+{
+ exit(0);
+}
+
+tick-1
+/a[1] != 1/
+{
+ printf("Expected 1, got %d\n", a[1]);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic3.d
new file mode 100644
index 00000000..897a12f2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic3.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple array test
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ a[1] = 0;
+ ++a[1];
+}
+
+tick-1
+/a[1] == 1/
+{
+ exit(0);
+}
+
+tick-1
+/a[1] != 1/
+{
+ printf("Expected 1, got %d\n", a[1]);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic4.d
new file mode 100644
index 00000000..3635a42d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic4.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple array test
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ a["test"] = 0;
+}
+
+tick-1
+/a["test"] == 0/
+{
+ exit(0);
+}
+
+tick-1
+/a["test"] != 0/
+{
+ printf("Expected 0, got %d\n", a["test"]);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic5.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic5.d
new file mode 100644
index 00000000..866a8c39
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic5.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple array test
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ a["test"] = 0;
+ b = ++a["test"];
+}
+
+tick-1
+/b == 1/
+{
+ exit(0);
+}
+
+tick-1
+/b != 1/
+{
+ printf("Expected b = 1, got %d\n", b);
+ exit(1);
+}
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic6.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic6.d
new file mode 100644
index 00000000..0371db30
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.basic6.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple array test
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ a["test", "test"] = 0;
+ b = ++a["test", "test"];
+}
+
+tick-1
+/b == 1/
+{
+ exit(0);
+}
+
+tick-1
+/b != 1/
+{
+ printf("Expected b = 1, got %d\n", b);
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.uregsarray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.uregsarray.d
new file mode 100644
index 00000000..b3fba0ca
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/arrays/tst.uregsarray.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive test to make sure that we can invoke common
+ * ureg[] aliases.
+ *
+ * SECTION: User Process Tracing/uregs Array
+ *
+ * NOTES: This test does no verification - the value of the output
+ * is not deterministic.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("R_PC = 0x%x\n", uregs[R_PC]);
+ printf("R_SP = 0x%x\n", uregs[R_SP]);
+ printf("R_R0 = 0x%x\n", uregs[R_R0]);
+ printf("R_R1 = 0x%x\n", uregs[R_R1]);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupgtype.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupgtype.d
new file mode 100644
index 00000000..6c4d0251
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupgtype.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test assigning a variable two different incompatible types. This should
+ * result in a compile-time error.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ */
+
+BEGIN
+{
+ x[123] = `kmem_flags;
+ x[456] = *`rootvp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupttype.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupttype.d
new file mode 100644
index 00000000..e1f17cbb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupttype.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test assigning a variable two different incompatible types. This should
+ * result in a compile-time error.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ */
+
+BEGIN
+{
+ self->x[123] = `kmem_flags;
+ self->x[456] = *`rootvp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.this.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.this.d
new file mode 100644
index 00000000..2af07ca5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.this.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ *
+ * Declare 'this int' variable and assign inappropriate data type.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ *
+ */
+
+#pragma D option quiet
+
+this int x;
+
+BEGIN
+{
+ this->x = "dummy";
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_ARG.badsig.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_ARG.badsig.d
new file mode 100644
index 00000000..d682fc68
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_ARG.badsig.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test an associative array reference that is invalid because of a type
+ * signature mismatch -- this should produce a syntax error at compile time.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ */
+
+BEGIN
+{
+ x[123, "foo"] = timestamp;
+}
+
+END
+{
+ x[123, 456] = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toofew.d
new file mode 100644
index 00000000..b4e82b85
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toofew.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test an associative array reference that is invalid because of too few
+ * arguments -- this should produce a syntax error at compile time.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ */
+
+BEGIN
+{
+ x[123, 456] = timestamp;
+}
+
+END
+{
+ x[123] = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toomany.d
new file mode 100644
index 00000000..3dc5f7dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toomany.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test an associative array reference that is invalid because of too many
+ * arguments -- this should produce a syntax error at compile time.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ */
+
+BEGIN
+{
+ x[123, 456] = timestamp;
+}
+
+END
+{
+ x[123, 456, 789] = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_SYNTAX.errassign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_SYNTAX.errassign.d
new file mode 100644
index 00000000..f31b66f1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.D_SYNTAX.errassign.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Assign one to 10 elements; make sure fails to compile.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ */
+
+BEGIN
+{
+ x[10]=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+}
+
+END
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.tupoflow.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.tupoflow.d
new file mode 100644
index 00000000..81042026
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/err.tupoflow.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Generates an associative array reference that should overflow the tuple
+ * register stack. We should detect and report this at compile time.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ */
+
+BEGIN
+{
+ a[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.cpyarray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.cpyarray.d
new file mode 100644
index 00000000..ca31cc35
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.cpyarray.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Copy value from associative arrays to local variables.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ *
+ */
+
+#pragma D option quiet
+
+this int x;
+
+BEGIN
+{
+ a["abc", 123] = 123;
+}
+
+tick-10ms
+{
+ this->x = a["abc", 123]++;
+ printf("The value of x is %d\n", this->x);
+}
+
+tick-10ms
+{
+ this->x = a["abc", 123]++;
+ printf("The value of x is %d\n", this->x);
+}
+
+tick-10ms
+{
+ this->x = a["abc", 123]++;
+ printf("The value of x is %d\n", this->x);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.diffprofile.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.diffprofile.d
new file mode 100644
index 00000000..ad5fb377
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.diffprofile.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * To test Clause Local Variables ' this' across different profiles.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ *
+ */
+
+#pragma D option quiet
+
+this int x;
+this char c;
+
+tick-10ms
+{
+ this->x = 123;
+ this->c = 'D';
+ printf("The value of x is %d\n", this->x);
+}
+
+tick-10ms
+{
+ this->x = 235;
+ printf("The value of x is %d\n", this->x);
+}
+
+tick-10ms
+{
+ this->x = 456;
+ printf("The value of x is %d\n", this->x);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.initialize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.initialize.d
new file mode 100644
index 00000000..1ab222b1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.initialize.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Clause local variables are not initialized to zero.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ *
+ */
+
+#pragma D option quiet
+
+this int x;
+
+BEGIN
+{
+ printf("the value of x is %d\n", this->x);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.invalidref.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.invalidref.d
new file mode 100644
index 00000000..446acfad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.invalidref.d
@@ -0,0 +1,75 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Test to ensure that invalid stores to a global associative array
+ * are caught correctly.
+ */
+
+#pragma D option quiet
+
+int last_cmds[int][4];
+
+BEGIN
+{
+ errors = 0;
+ forward = 0;
+ backward = 0;
+}
+
+tick-1s
+/!forward/
+{
+ forward = 1;
+ last_cmds[1][4] = 0xdeadbeef;
+}
+
+tick-1s
+/!backward/
+{
+ backward = 1;
+ last_cmds[1][-5] = 0xdeadbeef;
+}
+
+tick-1s
+/errors > 1/
+{
+ exit(0);
+}
+
+tick-1s
+/n++ > 5/
+{
+ exit(1);
+}
+
+ERROR
+/arg4 == DTRACEFLT_BADADDR/
+{
+ errors++;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.misc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.misc.d
new file mode 100644
index 00000000..43147dec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.misc.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the different kinds of associative scalar references.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ * NOTES:
+ * In particular, we test accessing a DTrace associative array
+ * defined with scalar type (first ref that forces creation as both global
+ * and TLS), and DTrace associative array scalar subsequent references
+ * (both global and TLS).
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i != 5/
+{
+ x[123, "foo"] = 123;
+ self->x[456, "bar"] = 456;
+ i++;
+}
+
+tick-10ms
+/i != 5/
+{
+ printf("x[] = %d\n", x[123, "foo"]);
+ printf("self->x[] = %d\n", self->x[456, "bar"]);
+}
+
+tick-10ms
+/i == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.orthogonality.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.orthogonality.d
new file mode 100644
index 00000000..f474a572
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.orthogonality.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * This test confirms the orthogonality of associative arrays and thread-local
+ * variables by intentionally deriving a matching key signature (based on
+ * t_did).
+ */
+uint64_t b[uint64_t];
+
+BEGIN
+{
+ self->a = 0xbad;
+}
+
+BEGIN
+/b[curthread->t_did] == 0/
+{
+ exit(0);
+}
+
+BEGIN
+{
+ printf("value should be 0; value is %x!", b[curthread->t_did]);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.this.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.this.d
new file mode 100644
index 00000000..c4d01fa3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.this.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * To test Clause Local Variables ' this'.
+ *
+ * SECTION: Variables/Associative Arrays
+ *
+ *
+ */
+
+#pragma D option quiet
+
+this int x;
+this char c;
+
+BEGIN
+{
+ this->x = 123;
+ this->c = 'D';
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.valassign.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.valassign.d.out
new file mode 100644
index 00000000..948d82e9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/assocs/tst.valassign.d.out
@@ -0,0 +1,2 @@
+The value of i is 123
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.begin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.begin.d
new file mode 100644
index 00000000..c2a60889
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.begin.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Arguments to BEGIN provider not allowed.
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN::read:entry
+{
+ printf("Begin fired first\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.tick.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.tick.d
new file mode 100644
index 00000000..44a363f8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.tick.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * concat of providers not allowed with BEGIN
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+
+BEGIN:tick-1
+{
+ printf("Begin fired first\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d
new file mode 100644
index 00000000..43e7744e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Order of provider flow, Begin, tick profile, and END.
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+END
+{
+ printf("End fired after exit\n");
+}
+
+BEGIN
+{
+ printf("Begin fired first\n");
+}
+
+tick-1ms
+{
+ printf("tick fired second\n");
+ printf("Call exit\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d.out
new file mode 100644
index 00000000..a9d8ee1e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.begin.d.out
@@ -0,0 +1,5 @@
+Begin fired first
+tick fired second
+Call exit
+End fired after exit
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d
new file mode 100644
index 00000000..3d5fd124
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Multiple BEGIN providers
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("Begin fired first\n");
+}
+BEGIN
+{
+ printf("Begin fired second\n");
+}
+BEGIN
+{
+ printf("Begin fired third\n");
+}
+BEGIN
+{
+ printf("Begin fired fourth\n");
+}
+BEGIN
+{
+ printf("Begin fired fifth\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d.out
new file mode 100644
index 00000000..e5bb9966
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/begin/tst.multibegin.d.out
@@ -0,0 +1,6 @@
+Begin fired first
+Begin fired second
+Begin fired third
+Begin fired fourth
+Begin fired fifth
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_ADDROF_BITFIELD.BitfieldAddress.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_ADDROF_BITFIELD.BitfieldAddress.d
new file mode 100644
index 00000000..9c5aca4c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_ADDROF_BITFIELD.BitfieldAddress.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Cannot take the address of a bit-field member using the &
+ * operator.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord{
+ int a : 1;
+ int b : 3;
+ int c : 12;
+} var;
+
+BEGIN
+{
+ printf("address of a: %d\naddress of b: %d\naddress of c: %dn",
+ &var.a, &var.b, &var.c);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.NegBitField.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.NegBitField.d
new file mode 100644
index 00000000..acb296f4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.NegBitField.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Bit-field width must be positive.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord{
+ int a : 1;
+ int b : -3;
+ int c : 12;
+} var;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.ZeroBitField.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.ZeroBitField.d
new file mode 100644
index 00000000..dfe24c59
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.ZeroBitField.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Bit-fields must be positive and non-zero.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord{
+ int a : 1;
+ int b : 0;
+ int c : 12;
+} var;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.ExceedBaseType.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.ExceedBaseType.d
new file mode 100644
index 00000000..d9abfd13
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.ExceedBaseType.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Bit-field width must be of a number of bits not larger than
+ * that of the corresponding base type.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord1{
+ char a : 10;
+} var1;
+
+struct bitRecord2{
+ short a : 33;
+} var2;
+
+struct bitRecord3{
+ long long a : 65;
+} var3;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.GreaterThan64.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.GreaterThan64.d
new file mode 100644
index 00000000..c1e359ed
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.GreaterThan64.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Bit-field width cannot be greater than 64 bits in D.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord{
+ int a : 1;
+ int b : 65;
+ int c : 12;
+} var;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFTYPE.badtype.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFTYPE.badtype.d
new file mode 100644
index 00000000..5e7b5233
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFTYPE.badtype.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Non-integer types used for bitfields will result in a D_DECL_BFTYPE
+ * error.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bits {
+ float : 1;
+} xyz;
+
+BEGIN
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_OFFSETOF_BITFIELD.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_OFFSETOF_BITFIELD.d
new file mode 100644
index 00000000..402a209d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_OFFSETOF_BITFIELD.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Cannot apply offsetof operator to a bit-field member.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ *
+ */
+#pragma D option quiet
+
+struct bitRecord{
+ int a : 17;
+ int b : 3;
+ int c : 12;
+} var;
+
+BEGIN
+{
+ printf("offsetof(struct bitRecord, a): %d\n",
+ offsetof(struct bitRecord, a));
+ printf("offsetof(struct bitRecord, b): %d\n",
+ offsetof(struct bitRecord, b));
+ printf("offsetof(struct bitRecord, c): %d\n",
+ offsetof(struct bitRecord, c));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_SIZEOF_BITFIELD.SizeofBitfield.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_SIZEOF_BITFIELD.SizeofBitfield.d
new file mode 100644
index 00000000..70c28340
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/err.D_SIZEOF_BITFIELD.SizeofBitfield.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Cannot apply sizeof operator to a bit-field member.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord{
+ int a : 1;
+ int b : 3;
+ int c : 12;
+} var;
+
+BEGIN
+{
+ printf("sizeof (a): %d\nsizeof (b): %d\nsizeof (c): %n",
+ sizeof (var.a), sizeof (var.b), sizeof (var.c));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.BitFieldPromotion.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.BitFieldPromotion.d
new file mode 100644
index 00000000..07ec728b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.BitFieldPromotion.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Bit-field will be automatically promoted to the next largest
+ * integer type for use in any expression and then the value assigned will
+ * warp around the maximum number assignable to the data type.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord{
+ int a : 1;
+ int b : 15;
+ int c : 31;
+} var;
+
+BEGIN
+{
+ var.a = 256;
+ var.b = 65536;
+ var.c = 4294967296;
+
+ printf("bitRecord.a: %d\nbitRecord.b: %d\nbitRecord.c: %d\n",
+ var.a, var.b, var.c);
+ exit(0);
+}
+
+END
+/(0 != var.a) || (0 != var.b) || (0 != var.c)/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.SizeofBitField.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.SizeofBitField.d
new file mode 100644
index 00000000..ce307de6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/bitfields/tst.SizeofBitField.d
@@ -0,0 +1,109 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: C and D compilers try to pack bits as efficiently as possible.
+ *
+ * SECTION: Structs and Unions/Bit-Fields
+ */
+
+#pragma D option quiet
+
+struct bitRecord1 {
+ int a : 1;
+} var1;
+
+struct bitRecord2 {
+ int a : 1;
+ int b : 3;
+} var2;
+
+struct bitRecord3 {
+ int a : 1;
+ int b : 3;
+ int c : 3;
+} var3;
+
+struct bitRecord4 {
+ int a : 1;
+ int b : 3;
+ int c : 3;
+ int d : 3;
+} var4;
+
+struct bitRecord5 {
+ int c : 12;
+ int a : 10;
+ int b : 3;
+} var5;
+
+struct bitRecord6 {
+ int a : 20;
+ int b : 3;
+ int c : 12;
+} var6;
+
+struct bitRecord7 {
+ long c : 32;
+ long long d: 9;
+ int e: 1;
+} var7;
+
+struct bitRecord8 {
+ char a : 2;
+ short b : 12;
+ long c : 32;
+} var8;
+
+struct bitRecord12 {
+ int a : 30;
+ int b : 30;
+ int c : 32;
+} var12;
+
+BEGIN
+{
+ printf("sizeof (bitRecord1): %d\n", sizeof (var1));
+ printf("sizeof (bitRecord2): %d\n", sizeof (var2));
+ printf("sizeof (bitRecord3): %d\n", sizeof (var3));
+ printf("sizeof (bitRecord4): %d\n", sizeof (var4));
+ printf("sizeof (bitRecord5): %d\n", sizeof (var5));
+ printf("sizeof (bitRecord6): %d\n", sizeof (var6));
+ printf("sizeof (bitRecord7): %d\n", sizeof (var7));
+ printf("sizeof (bitRecord8): %d\n", sizeof (var8));
+ printf("sizeof (bitRecord12): %d\n", sizeof (var12));
+ exit(0);
+}
+
+END
+/(1 != sizeof (var1)) || (2 != sizeof (var2)) || (3 != sizeof (var3)) ||
+ (4 != sizeof (var4)) || (5 != sizeof (var5)) || (6 != sizeof (var6))
+ || (7 != sizeof (var7)) || (8 != sizeof (var8)) || (12 != sizeof (var12))/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.end.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.end.d
new file mode 100644
index 00000000..a480d67a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.end.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Checks that buffer space for an END enabling is always reserved in a
+ * fill buffer. This will fail because the size of the END enabling
+ * (64 bytes) exceeds the size of the buffer (32 bytes).
+ *
+ * SECTION: Buffers and Buffering/fill Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/strsize
+ */
+
+#pragma D option bufpolicy=fill
+#pragma D option bufsize=32
+#pragma D option strsize=64
+
+BEGIN
+{
+ exit(0);
+}
+
+END
+{
+ trace(execname);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize1.d
new file mode 100644
index 00000000..4731bd1f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize1.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Checks that setting "bufresize" to "manual" will cause buffer
+ * allocation to fail for large principal buffer sizes.
+ *
+ * SECTION: Buffers and Buffering/Buffer Resizing Policy;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufresize
+ *
+ */
+
+#pragma D option bufresize=manual
+#pragma D option bufsize=100t
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize2.d
new file mode 100644
index 00000000..4dfe6b65
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize2.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Checks that setting "bufresize" to "manual" will cause buffer
+ * allocation to fail for large aggregation buffer sizes.
+ *
+ * SECTION: Buffers and Buffering/Buffer Resizing Policy;
+ * Options and Tunables/bufresize;
+ * Options and Tunables/aggsize
+ *
+ */
+
+#pragma D option bufresize=manual
+#pragma D option aggsize=100t
+
+BEGIN
+{
+ @a[probeprov] = count();
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize3.d
new file mode 100644
index 00000000..866a56c6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.resize3.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Checks that setting "bufresize" to "manual" will cause buffer
+ * allocation to fail for large speculative buffer sizes.
+ *
+ * SECTION: Buffers and Buffering/Buffer Resizing Policy;
+ * Options and Tunables/bufresize;
+ * Options and Tunables/specsize
+ *
+ */
+
+#pragma D option bufresize=manual
+#pragma D option specsize=100t
+
+BEGIN
+{
+ spec = speculation();
+}
+
+BEGIN
+{
+ speculate(spec);
+ trace(epid);
+}
+
+BEGIN
+{
+ commit(spec);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.zerobuf.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.zerobuf.d
new file mode 100644
index 00000000..a2e44350
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/err.zerobuf.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test with a bufsize of 0 - should return an error.
+ *
+ * SECTION:
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize
+ */
+
+#pragma D option bufsize=0
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.alignring.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.alignring.d
new file mode 100644
index 00000000..152acb61
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.alignring.d
@@ -0,0 +1,81 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for ring buffer policy.
+ *
+ * SECTION: Buffers and Buffering/ring Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy
+ */
+
+#pragma D option bufpolicy=ring
+#pragma D option bufsize=4k
+
+profile:::profile-1009hz
+{
+ printf("%x %x\n", (int)0xaaaa, (int)0xbbbb);
+}
+
+profile:::profile-1237hz
+{
+ printf("%x %x %x %x %x %x\n",
+ (int)0xcccc,
+ (int)0xdddd,
+ (int)0xeeee,
+ (int)0xffff,
+ (int)0xabab,
+ (int)0xacac);
+ printf("%x %x\n",
+ (uint64_t)0xaabbaabbaabbaabb,
+ (int)0xadad);
+}
+
+profile:::profile-1789hz
+{
+ printf("%x %x %x %x %x\n",
+ (int)0xaeae,
+ (int)0xafaf,
+ (unsigned char)0xaa,
+ (int)0xbcbc,
+ (int)0xbdbd);
+}
+
+profile-1543hz
+{}
+
+profile-1361hz
+{}
+
+tick-1sec
+/i++ >= 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.cputime.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.cputime.ksh
new file mode 100644
index 00000000..6ac0fa9e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.cputime.ksh
@@ -0,0 +1,90 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -s /dev/stdin -x bufpolicy=$1 $1 <<EOF
+
+ #pragma D option quiet
+ #pragma D option statusrate=1hz
+
+ uint64_t total;
+ int thresh;
+
+ BEGIN
+ {
+ start = timestamp;
+ thresh = 10;
+ }
+
+ sched:::on-cpu
+ /pid == \$pid/
+ {
+ self->on = vtimestamp;
+ }
+
+ sched:::off-cpu
+ /self->on/
+ {
+ total += vtimestamp - self->on;
+ }
+
+ tick-1sec
+ /i++ == 10/
+ {
+ exit(0);
+ }
+
+ END
+ /((total * 100) / (timestamp - start)) > thresh/
+ {
+ printf("'%s' buffering policy took %d%% of CPU; ",
+ \$\$1, ((total * 100) / (timestamp - start)));
+ printf("expected no more than %d%%!\n", thresh);
+ exit(1);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+for policy in "fill ring switch"; do
+ script $policy
+
+ status=$?
+
+ if [ "$status" -ne 0 ]; then
+ exit $status
+ fi
+done
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.dynvarsize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.dynvarsize.d
new file mode 100644
index 00000000..c8a07400
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.dynvarsize.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for dynamic variable size.
+ *
+ * SECTION: Buffers and Buffering/switch Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/switchrate
+ */
+
+#pragma D option dynvarsize=100
+#pragma D option quiet
+
+int n;
+
+tick-10ms
+/n++ < 100/
+{
+ a[n] = 1;
+}
+
+tick-10ms
+/n == 100/
+{
+ exit(2);
+}
+
+END
+/a[99]/
+{
+ exit(1);
+}
+
+END
+/!a[99]/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d
new file mode 100644
index 00000000..143ed641
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d
@@ -0,0 +1,115 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for fill buffer policy.
+ *
+ * SECTION: Buffers and Buffering/fill Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+/*
+ * This is a brute-force way of testing fill buffers. We assume that each
+ * printf() stores 8 bytes. Because each fill buffer is per-CPU, we must
+ * fill up our buffer in one series of enablings on a single CPU.
+ */
+#pragma D option bufpolicy=fill
+#pragma D option bufsize=64
+#pragma D option statusrate=10ms
+#pragma D option quiet
+
+int i;
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+{
+ printf("%d\n", i++);
+}
+
+tick-10ms
+/i >= 100/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d.out
new file mode 100644
index 00000000..fd8abec1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.fill1.d.out
@@ -0,0 +1,9 @@
+0
+1
+2
+3
+4
+5
+6
+7
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize1.d
new file mode 100644
index 00000000..396a8081
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize1.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Checks that setting "bufresize" to "auto" will cause buffer
+ * allocation to succeed, even for large principal buffer sizes.
+ *
+ * SECTION: Buffers and Buffering/Buffer Resizing Policy;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufresize
+ *
+ * NOTES:
+ * We use the undocumented "preallocate" option to make sure dtrace(1M)
+ * has enough space in its heap to allocate a buffer as large as the
+ * kernel's trace buffer.
+ */
+
+#pragma D option preallocate=100t
+#pragma D option bufresize=auto
+#pragma D option bufsize=100t
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize2.d
new file mode 100644
index 00000000..50b814b1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize2.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Checks that setting "bufresize" to "auto" will cause buffer
+ * allocation to succeed, even for large aggregation buffer sizes.
+ *
+ * SECTION: Buffers and Buffering/Buffer Resizing Policy;
+ * Options and Tunables/aggsize;
+ * Options and Tunables/bufresize
+ *
+ * NOTES:
+ * We use the undocumented "preallocate" option to make sure dtrace(1M)
+ * has enough space in its heap to allocate a buffer as large as the
+ * kernel's trace buffer.
+ */
+
+#pragma D option preallocate=100t
+#pragma D option bufresize=auto
+#pragma D option aggsize=100t
+
+BEGIN
+{
+ @a[probeprov] = count();
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize3.d
new file mode 100644
index 00000000..eb362fb3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.resize3.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Checks that setting "bufresize" to "auto" will cause buffer
+ * allocation to succeed, even for large speculative buffer sizes.
+ *
+ * SECTION: Buffers and Buffering/Buffer Resizing Policy;
+ * Options and Tunables/specsize;
+ * Options and Tunables/bufresize
+ *
+ * NOTES:
+ * On some small memory machines, this test may consume so much memory
+ * that it induces memory allocation failure in the dtrace library. This
+ * will manifest itself as an error like one of the following:
+ *
+ * dtrace: processing aborted: Memory allocation failure
+ * dtrace: could not enable tracing: Memory allocation failure
+ *
+ * These actually indicate that the test performed as expected; failures
+ * of the above nature should therefore be ignored.
+ *
+ */
+
+#pragma D option bufresize=auto
+#pragma D option specsize=100t
+
+BEGIN
+{
+ spec = speculation();
+}
+
+BEGIN
+{
+ speculate(spec);
+ trace(epid);
+}
+
+BEGIN
+{
+ commit(spec);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring1.d
new file mode 100644
index 00000000..67e7b875
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring1.d
@@ -0,0 +1,75 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for ring buffer policy.
+ *
+ * SECTION: Buffers and Buffering/ring Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/switchrate
+ */
+
+/*
+ * We assume that a trace() of an integer stores at least 8 bytes. If ring
+ * buffering is not working properly, this trace() will induce a drop, and the
+ * counter won't be incremented. We set the switchrate to one second just to
+ * sure that a high switchrate doesn't mask broken ring buffers.
+ */
+#pragma D option bufpolicy=ring
+#pragma D option bufsize=50
+#pragma D option switchrate=1sec
+
+int n;
+int i;
+
+tick-10msec
+/n < 300/
+{
+ trace(i);
+ i++;
+}
+
+tick-10msec
+/n < 300/
+{
+ n++;
+}
+
+tick-10msec
+/n == 300/
+{
+ exit(2);
+}
+
+END
+{
+ exit(i == 300 ? 0 : 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d
new file mode 100644
index 00000000..cbf48f2b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for ring buffer policy.
+ *
+ * SECTION: Buffers and Buffering/ring Policy;
+ * SECTION: Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy
+ */
+
+#pragma D option bufpolicy=ring
+#pragma D option bufsize=512k
+#pragma D option quiet
+
+tick-1sec
+/n < 5/
+{
+ printf("%d\n", n++);
+}
+
+tick-1sec
+/n == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d.out
new file mode 100644
index 00000000..cc4d41aa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring2.d.out
@@ -0,0 +1,6 @@
+0
+1
+2
+3
+4
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d
new file mode 100644
index 00000000..68e35889
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for ring buffer policy.
+ *
+ * SECTION: Buffers and Buffering/ring Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy
+ */
+
+/*
+ * We make some regrettable assumptions about the implementation in this test.
+ * First, we assume that each entry for the printf() of an int takes _exactly_
+ * eight bytes (four bytes for the EPID, four bytes for the payload). Second,
+ * we assume that by allocating storage for n + 1 records, we will get exactly
+ * n. Here is why: the final predicate that evaluates to false will reserve
+ * space that it won't use. This act of reservation will advance the wrapped
+ * offset. That record won't be subsequently used, but the wrapped offset has
+ * advanced. (And in this case, that old record is clobbered by the exit()
+ * anyway.) Thirdly: we rely on t_cpu/cpu_id. Finally: we rely on being
+ * able to run on the CPU that we first ran on.
+ */
+#pragma D option bufpolicy=ring
+#pragma D option bufsize=40
+#pragma D option quiet
+
+int n;
+
+BEGIN
+{
+ cpuid = -1;
+}
+
+tick-10msec
+/cpuid == -1/
+{
+ cpuid = curthread->t_cpu->cpu_id;
+}
+
+tick-10msec
+/curthread->t_cpu->cpu_id == cpuid && n < 100/
+{
+ printf("%d\n", n++);
+}
+
+tick-10msec
+/n == 100/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d.out
new file mode 100644
index 00000000..99fd231e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.ring3.d.out
@@ -0,0 +1,5 @@
+96
+97
+98
+99
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.smallring.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.smallring.d
new file mode 100644
index 00000000..2134a0b7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.smallring.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for ring buffer policy.
+ *
+ * SECTION: Buffers and Buffering/ring Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy
+ */
+
+#pragma D option bufpolicy=ring
+#pragma D option bufsize=16
+
+tick-10ms
+{
+ trace(0xbadbaddefec8d);
+}
+
+tick-10ms
+/0/
+{
+ trace((int)1);
+}
+
+tick-100ms
+/i++ > 2/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d
new file mode 100644
index 00000000..2840feef
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for switch buffer policy.
+ *
+ * SECTION: Buffers and Buffering/switch Policy;
+ * Buffers and Buffering/Buffer Sizes;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/switchrate
+ */
+
+/*
+ * We assume that a printf() of an integer stores at least 8 bytes, and no more
+ * than 16 bytes.
+ */
+#pragma D option bufpolicy=switch
+#pragma D option bufsize=32
+#pragma D option switchrate=500msec
+#pragma D option quiet
+
+int n;
+int i;
+
+tick-1sec
+/n < 10/
+{
+ printf("%d\n", i);
+ i++;
+}
+
+tick-1sec
+/n < 10/
+{
+ n++;
+}
+
+tick-1sec
+/n == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d.out
new file mode 100644
index 00000000..ce6c2bcb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/buffering/tst.switch1.d.out
@@ -0,0 +1,11 @@
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.cpuusage.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.cpuusage.d
new file mode 100644
index 00000000..e1e0dd83
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.cpuusage.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print non assigned value and make sure it fails.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The cpuusage = %d\n", curlwpsinfo->pr_cpu);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.nice.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.nice.d
new file mode 100644
index 00000000..c7a4ad21
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.nice.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * print non assigned value and make sure it fails.
+ *
+ * SECTION: Variables/Built-in Variables
+ *
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The nice for cpu usage %c\n", curlwpsinfo->pr_nice);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.priority.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.priority.d
new file mode 100644
index 00000000..6ebb3dfa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.priority.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Print non assigned variables and make sure it fails.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The low value is high priority field = %d\n",
+ curlwpsinfo->pr_nice);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.prsize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.prsize.d
new file mode 100644
index 00000000..f467f192
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.prsize.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print non assigned variables and make sure it fails.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("Size of process image in kbytes = %ld\n", curpsinfo->pr_size);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.rssize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.rssize.d
new file mode 100644
index 00000000..48057e14
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.rssize.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print non assigned variables and make sure it fails.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("Size of process image in kbytes = %ld\n", curpsinfo->pr_rssize);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0.d
new file mode 100644
index 00000000..ec3c277f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print arg0 and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The argument is %u\n", arg0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0clause.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0clause.d
new file mode 100644
index 00000000..4c782f83
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg0clause.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print arg0 from a profile and make sure it succeeds
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("Call probe read\n");
+}
+
+syscall:::entry
+{
+ printf("The argument is %u", arg0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1.d
new file mode 100644
index 00000000..993a3765
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print arg1 and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The argument is %u\n", arg1);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8.d
new file mode 100644
index 00000000..b696d7c2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print arg1 to arg8 and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The argument is %u %u %u %u %u %u %u %u\n", arg1, arg2,
+ arg3, arg4, arg5, arg6, arg7, arg8);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8clause.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8clause.d
new file mode 100644
index 00000000..fa62b03b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8clause.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print arg1 to arg8 from a profile and make sure it succeeds
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+syscall:::entry
+{
+ printf("The argument is %u %u %u %u %u %u %u %u\n", arg1, arg2,
+ arg3, arg4, arg5, arg6, arg7, arg8);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller.d
new file mode 100644
index 00000000..db1eabce
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print 'caller' and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The caller is %u\n", caller);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller1.d
new file mode 100644
index 00000000..f1bfeedf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.caller1.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print caller form profile and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("The caller is %u\n", caller);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid.d
new file mode 100644
index 00000000..4f04c656
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print 'epid'from profile and make sure it succeeds
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("epid of this probe = %d\n", epid);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid1.d
new file mode 100644
index 00000000..4cba65e6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.epid1.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * print epid and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("epid of this probe = %d\n", epid);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno.d
new file mode 100644
index 00000000..4d7a4ffc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print errno from profile and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("epid of this probe = %d\n", epid);
+ printf("the errno = %d\n", errno);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno1.d
new file mode 100644
index 00000000..ed233bf0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.errno1.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print errno and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("epid of this probe = %d\n", epid);
+ printf("the errno = %d\n", errno);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.execname.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.execname.d
new file mode 100644
index 00000000..b3007de3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.execname.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print execname and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+/execname == "dtrace" || execname == "java"/
+{
+ trace("execname matched");
+ exit(0);
+}
+
+BEGIN
+{
+ trace("execname didn't match");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.hpriority.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.hpriority.d
new file mode 100644
index 00000000..a0d88367
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.hpriority.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print hpriority and make sure it succeeds
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The high priority = %d\n", curlwpsinfo->pr_pri);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id.d
new file mode 100644
index 00000000..291d91d9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print 'id' from profile.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("id of this probe = %d\n", id);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id1.d
new file mode 100644
index 00000000..068cff65
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.id1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print id and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("id of this probe = %d\n", id);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl.d
new file mode 100644
index 00000000..2e6f349d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print variable ipl
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("The interrupt priority level = %u\n", ipl);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl1.d
new file mode 100644
index 00000000..ef9278d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.ipl1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print ipl and make sure it succeeds
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The interrupt priority level = %u\n", ipl);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo.d
new file mode 100644
index 00000000..f0e9d460
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print lwpsinfo_t structure values.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("The current thread's pr_flag is %d\n", curlwpsinfo->pr_flag);
+ printf("The current threads lwpid is %d\n", curlwpsinfo->pr_lwpid);
+ printf("The current thread's internal address is %u\n",
+ curlwpsinfo->pr_addr);
+ printf("The current thread's wait addr for sleeping lwp is %u\n",
+ curlwpsinfo->pr_wchan);
+ printf("The current lwp stat is %d\n", curlwpsinfo->pr_state);
+ printf("The printable character for pr_state %c\n",
+ curlwpsinfo->pr_sname);
+ printf("The syscall number = %d\n", curlwpsinfo->pr_syscall);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo1.d
new file mode 100644
index 00000000..aa11b07d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo1.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print lwpsinfo_t variables and make sure it succeeds
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("The current thread's pr_flag is %d\n", curlwpsinfo->pr_flag);
+ printf("The current threads lwpid is %d\n", curlwpsinfo->pr_lwpid);
+ printf("The current thread's internal address is %u\n",
+ curlwpsinfo->pr_addr);
+ printf("The current thread's wait addr for sleeping lwp is %u\n",
+ curlwpsinfo->pr_wchan);
+ printf("The current lwp stat is %d\n", curlwpsinfo->pr_state);
+ printf("The printable character for pr_state %c\n",
+ curlwpsinfo->pr_sname);
+ printf("The syscall number = %d\n", curlwpsinfo->pr_syscall);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid.d
new file mode 100644
index 00000000..2dd80d71
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print 'pid' from profile.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("process id = %d \n", pid);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid1.d
new file mode 100644
index 00000000..5cee07c5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.pid1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print 'pid' and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("process id = %d \n", pid);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo.d
new file mode 100644
index 00000000..c90f6e93
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print psinfo structure values from profile.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("number of lwps in process = %d\n", curpsinfo->pr_nlwp);
+ printf("unique process id = %d\n", curpsinfo->pr_pid);
+ printf("process id of parent = %d\n", curpsinfo->pr_ppid);
+ printf("pid of process group leader = %d\n", curpsinfo->pr_pgid);
+ printf("session id = %d\n", curpsinfo->pr_sid);
+ printf("real user id = %d\n", curpsinfo->pr_uid);
+ printf("effective user id = %d\n", curpsinfo->pr_euid);
+ printf("real group id = %d\n", curpsinfo->pr_gid);
+ printf("effective group id = %d\n", curpsinfo->pr_egid);
+ printf("address of process = %u\n", curpsinfo->pr_addr);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo1.d
new file mode 100644
index 00000000..098f38b6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo1.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print psinfo structure values.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("number of lwps in process = %d\n", curpsinfo->pr_nlwp);
+ printf("unique process id = %d\n", curpsinfo->pr_pid);
+ printf("process id of parent = %d\n", curpsinfo->pr_ppid);
+ printf("pid of process group leader = %d\n", curpsinfo->pr_pgid);
+ printf("session id = %d\n", curpsinfo->pr_sid);
+ printf("real user id = %d\n", curpsinfo->pr_uid);
+ printf("effective user id = %d\n", curpsinfo->pr_euid);
+ printf("real group id = %d\n", curpsinfo->pr_gid);
+ printf("effective group id = %d\n", curpsinfo->pr_egid);
+ printf("address of process = %u\n", curpsinfo->pr_addr);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid.d
new file mode 100644
index 00000000..1b16c8bb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print tid from profile
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+
+tick-10ms
+{
+ printf("Thread id = %d \n", tid);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid1.d
new file mode 100644
index 00000000..a0567e70
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.tid1.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * To print tid and make sure it succeeds.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("Thread id = %d \n", tid);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.timestamp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.timestamp.d
new file mode 100644
index 00000000..cd94eac8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.timestamp.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print build-in variable 'timestamp'
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ self->t = timestamp;
+ printf("The difftime = %d\n", timestamp - self->t);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.vtimestamp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.vtimestamp.d
new file mode 100644
index 00000000..cdbecfc7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/builtinvar/tst.vtimestamp.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To print build-in variable 'vtimestamp'
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ self->t = vtimestamp;
+ printf("The difftime = %d\n", vtimestamp - self->t);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d
new file mode 100644
index 00000000..f6877174
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause where an unknown identifier appears in a predicated
+ * clause inside an aggregating function.
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/1/
+{
+ @a = max(x);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d
new file mode 100644
index 00000000..1fa49747
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause where an unknown identifier appears in a predicated
+ * clause inside an aggregation tuple.
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/1/
+{
+ @a[x] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d
new file mode 100644
index 00000000..6c1cdffb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause where an unknown identifier appears in a predicated
+ * clause inside an associate array tuple.
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/1/
+{
+ a[x]++;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.body.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.body.d
new file mode 100644
index 00000000..da499cb5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.body.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause where an unknown identifier appears in a clause.
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+{
+ exit(x);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.both.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.both.d
new file mode 100644
index 00000000..00708273
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.both.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause where an unknown identifier appears in a predicate
+ * and in a clause body.
+ *
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/x != 0/
+{
+ exit(x);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.pred.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.pred.d
new file mode 100644
index 00000000..0bfc86f4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.pred.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause where an unknown identifier appears in a predicate.
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/x != 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.nopred.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.nopred.d
new file mode 100644
index 00000000..44d11675
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.nopred.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause that has a body but no predicate.
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.pred.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.pred.d
new file mode 100644
index 00000000..43bfedd8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.pred.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause that has a body and a predicate.
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/$pid != 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predfirst.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predfirst.d
new file mode 100644
index 00000000..c7f0b4eb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predfirst.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause that has a body and a predicate where the
+ * predicate must be cooked first because it creates a variable.
+ *
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/x++ == 0/
+{
+ exit(x - 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predlast.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predlast.d
new file mode 100644
index 00000000..9ed904f7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/clauses/tst.predlast.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test a clause that has a body and a predicate where the
+ * predicate must be cooked last because the clause creates
+ * a variable which is referenced in the predicate.
+ *
+ * SECTION: Program Structure / Probe Clauses and Declarations
+ *
+ */
+
+BEGIN
+/x == 0/
+{
+ exit(x++);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.lowfrequency.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.lowfrequency.d
new file mode 100644
index 00000000..1015a251
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.lowfrequency.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * Test to check that attempting to enable a valid event with a frequency
+ * lower than the default platform limit will fail.
+ *
+ * This test will fail if:
+ * 1) The system under test does not define the 'PAPI_tot_ins' event.
+ * 2) The 'dcpc-min-overflow' variable in dcpc.conf has been modified.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ exit(0);
+}
+
+cpc:::PAPI_tot_ins-all-100
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.malformedoverflow.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.malformedoverflow.d
new file mode 100644
index 00000000..f9b78094
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.malformedoverflow.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * Tests that specifying an overflow value containing extraneous characters
+ * (only digits are allowed) will fail.
+ */
+
+BEGIN
+{
+ exit(0);
+}
+
+cpc:::PAPI_tot_ins-all-10000bonehead
+{
+ @[probename] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.nonexistentevent.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.nonexistentevent.d
new file mode 100644
index 00000000..73f9575f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.nonexistentevent.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * Tests that attempting to enable a probe containing a non existent event
+ * will fail.
+ */
+
+BEGIN
+{
+ exit(0);
+}
+
+cpc:::PAPI_cpc_bad-all-10000
+{
+ @[probename] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart1.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart1.ksh
new file mode 100755
index 00000000..767d493a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart1.ksh
@@ -0,0 +1,78 @@
+#!/bin/ksh
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+
+#
+# This tests that cpustat(1) should fail to start if the cpc provider
+# is already calling the shots.
+#
+# This script will fail if:
+# 1) The system under test does not define the 'PAPI_tot_ins'
+# generic event.
+
+script()
+{
+ $dtrace -o $dtraceout -s /dev/stdin <<EOF
+ #pragma D option bufsize=128k
+
+ cpc:::PAPI_tot_ins-all-10000
+ {
+ @[probename] = count();
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+dtraceout=/tmp/dtrace.out.$$
+script 2>/dev/null &
+timeout=15
+
+#
+# Sleep while the above script fires into life. To guard against dtrace dying
+# and us sleeping forever we allow 15 secs for this to happen. This should be
+# enough for even the slowest systems.
+#
+while [ ! -f $dtraceout ]; do
+ sleep 1
+ timeout=$(($timeout-1))
+ if [ $timeout -eq 0 ]; then
+ echo "dtrace failed to start. Exiting."
+ exit 1
+ fi
+done
+
+cpustat -c PAPI_tot_ins 1 5
+status=$?
+
+rm $dtraceout
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart2.ksh
new file mode 100755
index 00000000..584469c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart2.ksh
@@ -0,0 +1,70 @@
+#!/bin/ksh -p
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+
+#
+# This tests that enablings from the cpc provider will fail if cpustat(1) is
+# already master of the universe.
+#
+# This script will fail if:
+# 1) The system under test does not define the 'PAPI_tot_ins'
+# generic event.
+
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ #pragma D option bufsize=128k
+
+ BEGIN
+ {
+ exit(0);
+ }
+
+ cpc:::PAPI_tot_ins-all-10000
+ {
+ @[probename] = count();
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+dtraceout=/tmp/dtrace.out.$$
+
+cpustat -c PAPI_tot_ins 1 20 &
+pid=$!
+sleep 5
+script 2>/dev/null
+
+status=$?
+
+kill $pid
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackfailtostart.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackfailtostart.ksh
new file mode 100755
index 00000000..f62b83d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackfailtostart.ksh
@@ -0,0 +1,77 @@
+#!/bin/ksh
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+
+#
+# This script ensures that cputrack(1M) will fail to start when the cpc
+# provider has active enablings.
+#
+# The script will fail if:
+# 1) The system under test does not define the 'PAPI_tot_ins' event.
+#
+
+script()
+{
+ $dtrace -o $dtraceout -s /dev/stdin <<EOF
+ #pragma D option bufsize=128k
+
+ cpc:::PAPI_tot_ins-all-10000
+ {
+ @[probename] = count();
+ }
+EOF
+}
+
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+dtraceout=/tmp/dtrace.out.$$
+script 2>/dev/null &
+timeout=15
+
+#
+# Sleep while the above script fires into life. To guard against dtrace dying
+# and us sleeping forever we allow 15 secs for this to happen. This should be
+# enough for even the slowest systems.
+#
+while [ ! -f $dtraceout ]; do
+ sleep 1
+ timeout=$(($timeout-1))
+ if [ $timeout -eq 0 ]; then
+ echo "dtrace failed to start. Exiting."
+ exit 1
+ fi
+done
+
+cputrack -c PAPI_tot_ins sleep 10
+status=$?
+
+rm $dtraceout
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackterminates.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackterminates.ksh
new file mode 100755
index 00000000..58d1e798
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.cputrackterminates.ksh
@@ -0,0 +1,70 @@
+#!/bin/ksh
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+
+#
+# This script ensures that cputrack(1) will terminate when the cpc provider
+# kicks into life.
+#
+# The script will fail if:
+# 1) The system under test does not define the 'PAPI_tot_ins' event.
+#
+
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ #pragma D option bufsize=128k
+
+ cpc:::PAPI_tot_ins-all-10000
+ {
+ @[probename] = count();
+ }
+
+ tick-1s
+ /n++ > 10/
+ {
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+cputrack -c PAPI_tot_ins sleep 20 &
+cputrack_pid=$!
+sleep 5
+script 2>/dev/null &
+
+wait $cputrack_pid
+status=$?
+
+rm $dtraceout
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.toomanyenablings.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.toomanyenablings.d
new file mode 100644
index 00000000..a50bd71a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/err.toomanyenablings.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * Test to check that attempting to enable too many probes will fail.
+ *
+ * This test will fail if:
+ * 1) We ever execute on a platform which is capable of programming 10
+ * 'PAPI_tot_ins' events simultaneously (which no current platforms are
+ * capable of doing).
+ * 2) The system under test does not define the 'PAPI_tot_ins' event.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ exit(0);
+}
+
+cpc:::PAPI_tot_ins-all-10000,
+cpc:::PAPI_tot_ins-all-10001,
+cpc:::PAPI_tot_ins-all-10002,
+cpc:::PAPI_tot_ins-all-10003,
+cpc:::PAPI_tot_ins-all-10004,
+cpc:::PAPI_tot_ins-all-10005,
+cpc:::PAPI_tot_ins-all-10006,
+cpc:::PAPI_tot_ins-all-10007,
+cpc:::PAPI_tot_ins-all-10008,
+cpc:::PAPI_tot_ins-all-10009
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.allcpus.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.allcpus.ksh
new file mode 100755
index 00000000..7f026c9e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.allcpus.ksh
@@ -0,0 +1,107 @@
+#!/bin/ksh
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# This script verifies that we can fire a probe on each CPU that is in
+# an online state.
+#
+# The script will fail if:
+# 1) The system under test does not define the 'PAPI_tot_ins' event.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+numproc=`psrinfo | tail -1 | cut -f1`
+cpu=0
+dtraceout=/var/tmp/dtrace.out.$$
+scriptout=/var/tmp/script.out.$$
+
+spin()
+{
+ while [ 1 ]; do
+ :
+ done
+}
+
+script()
+{
+ $dtrace -o $dtraceout -s /dev/stdin <<EOF
+ #pragma D option bufsize=128k
+ #pragma D option quiet
+
+ cpc:::PAPI_tot_ins-user-10000
+ /cpus[cpu] != 1/
+ {
+ cpus[cpu] = 1;
+ @a[cpu] = count();
+ }
+
+ tick-1s
+ /n++ > 10/
+ {
+ printa(@a);
+ exit(0);
+ }
+EOF
+}
+
+echo "" > $scriptout
+while [ $cpu -le $numproc ]
+do
+ if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then
+ printf "%9d %16d\n" $cpu 1 >> $scriptout
+ spin &
+ allpids[$cpu]=$!
+ pbind -b $cpu $!
+ fi
+ cpu=$(($cpu+1))
+done
+echo "" >> $scriptout
+
+script
+
+diff $dtraceout $scriptout >/dev/null 2>&1
+status=$?
+
+# kill off the spinner processes
+cpu=0
+while [ $cpu -le $numproc ]
+do
+ if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then
+ kill ${allpids[$cpu]}
+ fi
+ cpu=$(($cpu+1))
+done
+
+rm $dtraceout
+rm $scriptout
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.genericevent.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.genericevent.d
new file mode 100644
index 00000000..7ebf844e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.genericevent.d
@@ -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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * Test that we can successfully enable a probe using a generic event.
+ * Currently, all platforms implement 'PAPI_tot_ins' so we'll use that.
+ * Note that this test will fail if the system under test does not
+ * implement that event.
+ *
+ * This test will fail if:
+ * 1) The system under test does not define the 'PAPI_tot_ins' event.
+ */
+
+#pragma D option quiet
+#pragma D option bufsize=128k
+
+cpc:::PAPI_tot_ins-all-10000
+{
+ @[probename] = count();
+}
+
+tick-1s
+/n++ > 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.platformevent.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.platformevent.ksh
new file mode 100755
index 00000000..96d1ab8c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/cpc/tst.platformevent.ksh
@@ -0,0 +1,81 @@
+#!/bin/ksh
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# This script ensures that we can enable a probe which specifies a platform
+# specific event.
+#
+
+if [ $# != 1 ]; then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+
+get_event()
+{
+ perl /dev/stdin /dev/stdout << EOF
+ open CPUSTAT, '/usr/sbin/cpustat -h |'
+ or die "Couldn't run cpustat: \$!\n";
+ while (<CPUSTAT>) {
+ if (/(\s+)event\[*[0-9]-*[0-9]*\]*:/ && !/PAPI/) {
+ @a = split(/ /, \$_);
+ \$event = \$a[\$#a-1];
+ }
+ }
+
+ close CPUSTAT;
+ print "\$event\n";
+EOF
+}
+
+script()
+{
+ $dtrace -s /dev/stdin << EOD
+ #pragma D option quiet
+ #pragma D option bufsize=128k
+
+ cpc:::$1-all-10000
+ {
+ @[probename] = count();
+ }
+
+ tick-1s
+ /n++ > 5/
+ {
+ exit(0);
+ }
+EOD
+}
+
+event=$(get_event)
+script $event
+
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LOCASSC.NonLocalAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LOCASSC.NonLocalAssoc.d
new file mode 100644
index 00000000..4c8ee508
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LOCASSC.NonLocalAssoc.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * associative arrays may not be declared as local variables
+ *
+ * SECTION: Errtags/D_DECL_LOCASSC
+ *
+ */
+
+#pragma D option quiet
+
+this int a[int];
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LONGINT.LongStruct.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LONGINT.LongStruct.d
new file mode 100644
index 00000000..2c92bfdb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_LONGINT.LongStruct.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * long and long long may only be used with integer or floating-point type
+ *
+ * SECTION: Errtags/D_DECL_LONGINT
+ *
+ */
+
+#pragma D option quiet
+
+long struct mystruct
+{
+ int i;
+};
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PARMCLASS.BadStorageClass.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PARMCLASS.BadStorageClass.d
new file mode 100644
index 00000000..8278747e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PARMCLASS.BadStorageClass.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * inappropriate storage class for function or associative array parameter
+ * throws a D_DECL_PARMCLASS
+ *
+ * SECTION: Errtags/D_DECL_PARMCLASS
+ *
+ */
+
+#pragma D option quiet
+
+
+int foo(static int);
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_NAME.VoidName.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_NAME.VoidName.d
new file mode 100644
index 00000000..3676c21c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_NAME.VoidName.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Assert that a void parameter in a declaration where void is permitted
+ * may not have a parameter formal name associated with it.
+ */
+
+int a(void v);
+
+BEGIN,
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_TYPE.Dyn.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_TYPE.Dyn.d
new file mode 100644
index 00000000..aecf5499
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_TYPE.Dyn.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Assert that a function parameter in a declaration may not use a dynamic
+ * DTrace type such as an associative array type.
+ */
+
+int a(int a[int]);
+
+BEGIN,
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VARARGS.VarLenArgs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VARARGS.VarLenArgs.d
new file mode 100644
index 00000000..22dbbe9b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VARARGS.VarLenArgs.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * array tuples may not use variable-length argument lists
+ *
+ * SECTION: Errtags/ D_DECL_ARRVA
+ *
+ */
+
+#pragma D option quiet
+
+
+int a[...];
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VOID.NonSoleVoid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VOID.NonSoleVoid.d
new file mode 100644
index 00000000..620f0d7c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VOID.NonSoleVoid.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * void must be sole parameter in a function declaration.
+ *
+ * SECTION: Errtags/D_DECL_FUNCVOID
+ *
+ */
+
+#pragma D option quiet
+
+int foo(int, void);
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_SIGNINT.UnsignedStruct.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_SIGNINT.UnsignedStruct.d
new file mode 100644
index 00000000..db2e4510
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_SIGNINT.UnsignedStruct.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * signed and unsigned may only be used with integer type
+ *
+ * SECTION: Errtags/D_DECL_SIGNINT
+ *
+ */
+
+#pragma D option quiet
+
+/*DSTYLED*/
+unsigned struct mystruct {
+ int i;
+};
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_VOIDATTR.ShortVoidDecl.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_VOIDATTR.ShortVoidDecl.d
new file mode 100644
index 00000000..81f90814
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/err.D_DECL_VOIDATTR.ShortVoidDecl.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Attributes may not be used with void type.
+ *
+ * SECTION: Errtags/D_DECL_VOIDATTR
+ *
+ */
+
+#pragma D option quiet
+
+short void ptr;
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.arrays.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.arrays.d
new file mode 100644
index 00000000..34ddd5fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.arrays.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test various kinds of array declarations.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+extern int a1[];
+
+extern int a2[1];
+
+extern int a3[123][456];
+
+extern int a4[123][456][789];
+
+extern int a5[5], a6[6][6], a7[7][7][7];
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.basics.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.basics.d
new file mode 100644
index 00000000..4c1483e2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.basics.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test a variety of extern declarations that exercise the different
+ * kinds of declarations that we can process.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+extern void *e1;
+extern char e2;
+extern signed char e3;
+extern unsigned char e4;
+extern short e5;
+extern signed short e6;
+extern unsigned short e7;
+extern int e8;
+extern e9;
+extern signed int e10;
+extern unsigned int e11;
+extern long e12;
+extern signed long e13;
+extern unsigned long e14;
+extern long long e15;
+extern signed long long e16;
+extern unsigned long long e17;
+extern float e18;
+extern double e19;
+extern long double e20;
+extern vnode_t e21;
+extern struct vnode e22;
+extern union sigval e23;
+extern enum uio_rw e24;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.funcs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.funcs.d
new file mode 100644
index 00000000..3b691eb2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.funcs.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test various kinds of function declarations.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ */
+
+extern int getint(void);
+extern int *getptr(void);
+extern int *(*funcptr)(void);
+extern int **(**funcptrptr)(void);
+
+extern int noparms();
+extern int oneparm(int);
+extern int twoparms(int, int);
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.pointers.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.pointers.d
new file mode 100644
index 00000000..d0ab6087
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.pointers.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test multiple extern declarations in a single list which build
+ * up a chain of pointers to pointers to pointers ...
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ */
+
+extern int e0, *e1, **e2, ***e3, ****e4, *****e5;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.varargsfuncs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.varargsfuncs.d
new file mode 100644
index 00000000..c12363fb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/decls/tst.varargsfuncs.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test functions declarations with varargs
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ */
+
+#pragma D option quiet
+
+extern int varargs1(...);
+extern int varargs2(int, ...);
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/badptr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/badptr.d
new file mode 100644
index 00000000..c48c7294
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/badptr.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 5-1
+ *
+ * SECTION:
+ * DocExamples/badptr
+ */
+
+BEGIN
+{
+ x = (int *)NULL;
+ y = *x;
+ trace(y);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/countdown.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/countdown.d
new file mode 100644
index 00000000..56b98815
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/countdown.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example
+ *
+ * SECTION:
+ * DocExamples/other
+ */
+
+dtrace:::BEGIN
+{
+ i = 10;
+}
+
+profile:::tick-1sec
+/i > 0/
+{
+ trace(i--);
+}
+
+profile:::tick-1000
+/i == 0/
+{
+ trace("blastoff!");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/counter.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/counter.d
new file mode 100644
index 00000000..8b7b1b3b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/counter.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc
+ *
+ * SECTION:
+ * DocExamples/other
+ */
+
+
+dtrace:::BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ i = i + 1;
+ trace(i);
+}
+
+dtrace:::END
+{
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/errorpath.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/errorpath.d
new file mode 100644
index 00000000..76fd07c2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/errorpath.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 17-1
+ *
+ * SECTION:
+ * DocExamples/errorpath
+ */
+
+
+BEGIN
+{
+ *(char *)NULL;
+}
+
+ERROR
+{
+ printf("Hit an error!");
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/hello.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/hello.d
new file mode 100644
index 00000000..8e1ef8f7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/hello.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 1-1
+ *
+ * SECTION:
+ * DocExamples/hello
+ */
+
+
+BEGIN
+{
+ trace("hello, world");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/kstat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/kstat.d
new file mode 100644
index 00000000..49871497
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/kstat.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 7-3
+ *
+ * SECTION:
+ * DocExamples/kstat
+ */
+
+
+#pragma D option quiet
+
+pid$1:libkstat:kstat_data_lookup:entry
+{
+ self->ksname = arg1;
+}
+
+pid$1:libkstat:kstat_data_lookup:return
+/self->ksname != NULL && arg1 != NULL/
+{
+ this->str = copyinstr(self->ksname);
+ this->ksp = (kstat_named_t *)copyin(arg1, sizeof (kstat_named_t));
+ printf("%s has ui64 value %u\n", this->str, this->ksp->value.ui64);
+}
+
+pid$1:libkstat:kstat_data_lookup:return
+/self->ksname != NULL && arg1 == NULL/
+{
+ self->ksname = NULL;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/ksyms.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/ksyms.d
new file mode 100644
index 00000000..932262b0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/ksyms.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 7-2
+ *
+ * SECTION:
+ * DocExamples/ksyms
+ */
+
+
+/* Must run "strings -a /dev/ksyms in another shell on the system */
+
+
+#pragma D option quiet
+
+syscall::read:entry
+/curpsinfo->pr_psargs == "strings -a /dev/ksyms"/
+{
+ printf("read %u bytes to user address %x\n", arg2, arg1);
+ self->watched = 1;
+}
+
+syscall::read:return
+/self->watched/
+{
+ self->watched = 0;
+}
+
+fbt::uiomove:entry
+/self->watched/
+{
+ this->iov = args[3]->uio_iov;
+
+ printf("uiomove %u bytes to %p in pid %d\n", this->iov->iov_len,
+ this->iov->iov_base, pid);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/renormalize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/renormalize.d
new file mode 100644
index 00000000..7d2c6af7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/renormalize.d
@@ -0,0 +1,55 @@
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Verify doc example 9-1
+ *
+ * SECTION:
+ * DocExamples/renormalize
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ start = timestamp;
+}
+
+syscall:::entry
+{
+ @func[execname] = count();
+}
+
+tick-10sec
+{
+ normalize(@func, (timestamp - start) / 1000000000);
+ printa(@func);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rtime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rtime.d
new file mode 100644
index 00000000..087e8193
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rtime.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 3-1
+ *
+ * SECTION:
+ * DocExamples/rtime
+ */
+
+
+#pragma D option quiet
+
+syscall::read:entry
+{
+ self->t = timestamp;
+}
+
+syscall::read:return
+/self->t != 0/
+{
+ printf("%d/%d spent %d nsecs in read(2)\n", pid,
+ tid, timestamp - self->t);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rw.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rw.d
new file mode 100644
index 00000000..6358a7dc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rw.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example
+ *
+ * SECTION:
+ * DocExamples/other
+ */
+
+
+syscall::read:entry,
+syscall::write:entry
+/pid == 102429/
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwinfo.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwinfo.d
new file mode 100644
index 00000000..60f2b12a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwinfo.d
@@ -0,0 +1,74 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 7-1
+ *
+ * SECTION:
+ * DocExamples/rwinfo
+ */
+
+
+#pragma D option quiet
+
+struct callinfo {
+ uint64_t ts;
+ uint64_t elapsed;
+ uint64_t calls;
+ size_t maxbytes;
+};
+
+struct callinfo i[string];
+
+syscall::read:entry,
+syscall::write:entry
+/pid == 100551/
+{
+ i[probefunc].ts = timestamp;
+ i[probefunc].calls++;
+ i[probefunc].maxbytes = arg2 > i[probefunc].maxbytes ?
+ arg2 : i[probefunc].maxbytes;
+}
+
+syscall::read:return,
+syscall::write:return
+/i[probefunc].ts != 0 && pid == 100551/
+{
+ i[probefunc].elapsed += timestamp - i[probefunc].ts;
+}
+
+END
+{
+ printf(" calls max bytes elapsed nsecs\n");
+ printf("----- ----- --------- -------------\n");
+ printf(" read %5d %9d %d\n", i["read"].calls,
+ i["read"].maxbytes, i["read"].elapsed);
+ printf(" write %5d %9d %d\n", i["write"].calls,
+ i["write"].maxbytes, i["write"].elapsed);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwtime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwtime.d
new file mode 100644
index 00000000..2edffb90
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/rwtime.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 7-1
+ *
+ * SECTION:
+ * DocExamples/rwinfo
+ */
+
+
+syscall::read:entry,
+syscall::write:entry
+/pid == 100551/
+{
+ ts[probefunc] = timestamp;
+}
+
+syscall::read:return,
+syscall::write:return
+/(ts[probefunc] != 0) && (pid == 100551)/
+{
+ printf("%d nsecs\n", timestamp - ts[probefunc]);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/specopen.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/specopen.d
new file mode 100755
index 00000000..dff3e622
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/specopen.d
@@ -0,0 +1,79 @@
+#!/usr/sbin/dtrace -Fs
+
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 13-1
+ *
+ * SECTION:
+ * DocExamples/specopen
+ */
+
+syscall::open:entry,
+syscall::open64:entry
+{
+ self->spec = speculation();
+ speculate(self->spec);
+
+ printf("%s", stringof(copyinstr(arg0)));
+}
+
+fbt:::
+/self->spec/
+{
+ speculate(self->spec);
+}
+
+syscall::open:return,
+syscall::open64:return
+/self->spec/
+{
+ speculate(self->spec);
+ trace(errno);
+}
+
+syscall::open:return,
+syscall::open64:return
+/self->spec && errno != 0/
+{
+ commit(self->spec);
+ self->spec = 0;
+}
+
+syscall::open:return,
+syscall::open64:return
+/self->spec && errno == 0/
+{
+ discard(self->spec);
+ self->spec = 0;
+}
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/truss.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/truss.d
new file mode 100644
index 00000000..b7925205
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/truss.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc
+ *
+ * SECTION:
+ * DocExamples/truss
+ */
+
+
+
+dtrace:::BEGIN
+{
+ var = 30;
+ self->vaa = 24;
+}
+
+syscall::read:entry
+/pid == 102473/
+{
+ printf("var: %d, self->vaa: %d", var++, self->vaa++);
+}
+
+syscall::write:entry
+/pid == 102473/
+{
+ printf("var: %d, self->vaa: %d", var++, self->vaa++);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/trussrw.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/trussrw.d
new file mode 100644
index 00000000..9eb9bced
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/trussrw.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify doc example 1-2
+ *
+ * SECTION:
+ * DocExamples/trussrw
+ */
+
+
+#pragma D option quiet
+
+syscall::read:entry,
+syscall::write:entry
+/pid == 100551/
+{
+ printf("%s(%d, 0x%x, %4d)", probefunc, arg0, arg1, arg2);
+}
+
+syscall::read:return,
+syscall::write:return
+/pid == 100551/
+{
+ printf("\t\t = %d\n", arg1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/userfunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/userfunc.d
new file mode 100755
index 00000000..0d83465d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/docsExamples/userfunc.d
@@ -0,0 +1,61 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verifying doc example 21-1
+ *
+ * SECTION:
+ * DocExamples/userfunc
+ *
+ */
+
+pid$1::$2:entry
+{
+ self->trace = 1;
+}
+
+pid$1::$2:return
+/self->trace/
+{
+ self->trace = 0;
+}
+
+pid$1:::entry,
+pid$1:::return
+/self->trace/
+{
+}
+
+
+
+
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_AGGREGATION.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_AGGREGATION.d
new file mode 100644
index 00000000..02b32438
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_AGGREGATION.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+#pragma D option strsize=1024
+#pragma D option aggsize=512
+
+BEGIN
+{
+ @["Harding"] = count();
+ @["Hoover"] = count();
+ @["Nixon"] = count();
+ @["Bush"] = count();
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DBLERROR.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DBLERROR.d
new file mode 100644
index 00000000..face4c8c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DBLERROR.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ trace(*(int *)NULL);
+}
+
+ERROR
+{
+ trace(*(int *)NULL);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DYNAMIC.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DYNAMIC.d
new file mode 100644
index 00000000..f8a90f06
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DYNAMIC.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option strsize=1024
+#pragma D option dynvarsize=512
+
+BEGIN
+{
+ a["Harding"] = 1;
+ a["Hoover"] = 1;
+ a["Nixon"] = 1;
+ a["Bush"] = 1;
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.d
new file mode 100644
index 00000000..8389ce02
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option strsize=1024
+#pragma D option bufsize=512
+
+BEGIN
+{
+ trace("Harding");
+ trace("Hoover");
+ trace("Nixon");
+ trace("Bush");
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.end.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.end.d
new file mode 100644
index 00000000..a723019f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.end.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option strsize=1024
+#pragma D option bufsize=512
+
+BEGIN
+{
+ exit(0);
+}
+
+END
+{
+ trace("Harding");
+ trace("Hoover");
+ trace("Nixon");
+ trace("Bush");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPEC.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPEC.d
new file mode 100644
index 00000000..8f6df3c0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPEC.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option nspec=1
+#pragma D option specsize=32
+#pragma D option strsize=512
+
+BEGIN
+{
+ spec = speculation();
+ speculate(spec);
+ trace("The, SystemTap, The.");
+}
+
+BEGIN
+{
+ commit(spec);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPECUNAVAIL.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPECUNAVAIL.d
new file mode 100644
index 00000000..1fd39748
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPECUNAVAIL.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option nspec=1
+
+BEGIN,
+BEGIN,
+BEGIN,
+BEGIN
+{
+ spec = speculation();
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d
new file mode 100644
index 00000000..f5d6416b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option destructive
+#pragma D option jstackstrsize=1
+#pragma D option quiet
+
+BEGIN
+{
+ system("java -version");
+}
+
+syscall:::entry
+{
+ @[jstack()] = count();
+}
+
+proc:::exit
+/progenyof($pid) && execname == "java"/
+{
+ exit(0);
+}
+
+END
+{
+ printa("\r", @);
+ printf("\n");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/err.D_PDESC_ZERO.InvalidDescription1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/err.D_PDESC_ZERO.InvalidDescription1.d
new file mode 100644
index 00000000..a0d17676
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/err.D_PDESC_ZERO.InvalidDescription1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: An invalid probe description throws a D_PDESC_ZERO error.
+ *
+ * SECTION: Errtags/D_PDESC_ZERO
+ *
+ */
+
+#pragma D option quiet
+
+fbt:bippity:boppity:boo
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.APIVersion.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.APIVersion.d
new file mode 100644
index 00000000..21564897
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.APIVersion.d
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/* Assertion:
+ * Use the -V option to printout API version.
+ *
+ * SECTION:
+ * dtrace Utility/-V Option
+ *
+ * NOTES:
+ * Use /usr/sbin/dtrace -V on command line.
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.AddSearchPath.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.AddSearchPath.d
new file mode 100644
index 00000000..53fe67af
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.AddSearchPath.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * The -I option can be used to search path for #include files when used
+ * in conjunction with the -C option. The specified directory is inserted into
+ * the search path adhead of the default directory list.
+ *
+ * SECTION: dtrace Utility/-C Option;
+ * dtrace Utility/-I Option
+ *
+ * NOTES:
+ * Create a file <filename> and define the variable VALUE in it. Move it a
+ * directory <dirname> different from the current directory. Change the value
+ * of <filename> appropriately in the code below.
+ * Invoke: dtrace -C -I <dirname> -s man.AddSearchPath.d
+ * Verify VALUE.
+ */
+
+
+#pragma D option quiet
+
+#include "filename"
+
+BEGIN
+{
+ printf("Value of VALUE: %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d
new file mode 100755
index 00000000..3cd9d02a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d
@@ -0,0 +1,67 @@
+#!/bin/ksh -p
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ *
+ * ASSERTION:
+ * Testing -F option with several probes.
+ *
+ * SECTION: dtrace Utility/-F Option
+ *
+ * NOTES: Manually verify using:
+ * "/usr/sbin/dtrace -F -s man.CoalesceTrace.d" on command line.
+ *
+ * Verify that the for the indent characters are -> <- for non-syscall
+ * entry/return pairs (e.g. fbt ones) and => <= for syscall ones and
+ * | for profile ones.
+ *
+ */
+
+BEGIN
+{
+ i = 0;
+ j = 0;
+ k = 0;
+}
+
+syscall::read:
+{
+ printf("syscall: %d\n", i++);
+}
+
+fbt:genunix:read:
+{
+ printf("fbt: %d\n", j++);
+}
+
+profile:::tick-10sec
+{
+ printf("profile: %d\n", k++);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ELFGeneration.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ELFGeneration.d
new file mode 100644
index 00000000..a30a140e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ELFGeneration.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -G option with dtrace utility produces an ELF file containing a
+ * DTrace program. If the filename used with the -s option does ends
+ * with .d, and the -o option is not used, then the output ELF file is
+ * in filename.o
+ *
+ * SECTION: dtrace Utility/-G Option
+ *
+ * NOTES: Use this file as
+ * /usr/sbin/dtrace -G -s man.ELFGeneration.d
+ * Delete the file man.ELFGeneration.d.o
+ *
+ */
+
+BEGIN
+{
+ printf("This test should compile.\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.IncludedFilePath.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.IncludedFilePath.d
new file mode 100644
index 00000000..f4e4e4e1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.IncludedFilePath.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using the -CH option with dtrace invocation displays the list of
+ * pathnames of included files one per line to the stderr.
+ *
+ * SECTION: dtrace Utility/-C Option;
+ * dtrace Utility/-H Option
+ *
+ * NOTES: Use this file as
+ * /usr/sbin/dtrace -qCH -s man.IncludedFilePath.d
+ *
+ */
+
+#include "stdio.h"
+
+BEGIN
+{
+ printf("This test should compile.\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithFunctions b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithFunctions
new file mode 100644
index 00000000..e3db1270
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithFunctions
@@ -0,0 +1,99 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -l option with -f option.
+ *
+ * SECTION: dtrace Utility/-l Option;
+ * dtrace Utility/-f Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1)
+ * /usr/sbin/dtrace -lf profile
+ * RESULT: Silent output without any probes listed.
+ *
+ * 2)
+ * /usr/sbin/dtrace -lf genunix
+ * RESULT: Silent output without any probes listed.
+ *
+ * 3)
+ * /usr/sbin/dtrace -lf read
+ * RESULT: matching list of probes with function read.
+ *
+ * 4)
+ * /usr/sbin/dtrace -lf genunix:read
+ * RESULT: matching list of probes with module genunix and
+ * function read.
+ *
+ * 5)
+ * /usr/sbin/dtrace -lf sysinfo:genunix:read
+ * RESULT: matching list of probes with provider sysinfo, module
+ * genunix and function read.
+ *
+ * 6)
+ * /usr/sbin/dtrace -lf :genunix::
+ * RESULT: Silent output without any probes listed.
+ *
+ * 7)
+ * /usr/sbin/dtrace -lf ::read:
+ * RESULT: Silent output without any probes listed.
+ *
+ * 8)
+ * /usr/sbin/dtrace -lf profile:::profile-97
+ * RESULT: not a valid probe description.
+ *
+ * 9)
+ * /usr/sbin/dtrace -lf read -lf write
+ * RESULT: matching list of both read and write probes.
+ *
+ * 10)
+ * /usr/sbin/dtrace -lf read -lm fight
+ * RESULT: List of only read probes.
+ *
+ * 11)
+ * /usr/sbin/dtrace -lf fight -lf write
+ * RESULT: List of only write probes.
+ *
+ * 12) Has been automated.
+ * /usr/sbin/dtrace -lf fbt:des:des3_crunch_block:return
+ * RESULT: not a valid probe description.
+ *
+ * 13)
+ * /usr/sbin/dtrace -lf read'{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ *
+ * 14)
+ * /usr/sbin/dtrace -lf read '{printf("FOUND");}'
+ * RESULT: List of only read probes.
+ *
+ * 15)
+ * /usr/sbin/dtrace -lf read'/probename == "entry"/{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithIDs b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithIDs
new file mode 100644
index 00000000..2b46ce34
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithIDs
@@ -0,0 +1,77 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -l option with -i option.
+ *
+ * SECTION: dtrace Utility/-l Option;
+ * dtrace Utility/-i Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1)
+ * /usr/sbin/dtrace -l
+ * RESULT: List of all available probes.
+ *
+ * 2)
+ * /usr/sbin/dtrace -li 0
+ * RESULT: invalid probe identifier 0.
+ *
+ * 3) automated in tst.InvalidId1.d.ksh
+ * /usr/sbin/dtrace -li -3
+ * RESULT: not a valid id range
+ *
+ * 4)
+ * /usr/sbin/dtrace -li 0-2
+ * RESULT: List of probes including 1 and 2 or error.
+ *
+ * 5) automated in tst.InvalidId2.d.ksh
+ * /usr/sbin/dtrace -li 4-2
+ * RESULT: not a valid id range
+ *
+ * 6) automated in tst.InvalidId3.d.ksh
+ * /usr/sbin/dtrace -li 2-2
+ * RESULT: not a valid id range
+ *
+ * 7)
+ * /usr/sbin/dtrace -li 1 2 3 4
+ * RESULT: only the first probe id is listed and other extraneous
+ * charaters are not considered.
+ *
+ * 8)
+ * /usr/sbin/dtrace -li 0 - 2
+ * RESULT: only the first probe id is listed and other extraneous
+ * charaters are not considered.
+ *
+ * 9)
+ * /usr/sbin/dtrace -li 1 -li 2-4 -li 4 -li 5
+ * RESULT: Probe descriptions listed for all ids specified. Once
+ * for each specification on the command line.
+ *
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithModules b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithModules
new file mode 100644
index 00000000..167c72a0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithModules
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -l option with -m option.
+ *
+ * SECTION: dtrace Utility/-l Option;
+ * dtrace Utility/-m Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1)
+ * /usr/sbin/dtrace -lm profile
+ * RESULT: Silent output without any probes listed.
+ *
+ * 2)
+ * /usr/sbin/dtrace -lm genunix
+ * RESULT: matching list of probes with module name genunix.
+ *
+ * 3)
+ * /usr/sbin/dtrace -lm vtrace:genunix
+ * RESULT: matching list of probes with provider vtrace and module
+ * genunix.
+ *
+ * 4) automated in tst.InvalidModule1.d.ksh
+ * /usr/sbin/dtrace -lm :genunix::
+ * RESULT: not a valid probe description
+ *
+ * 5) automated in tst.InvalidModule2.d.ksh
+ * /usr/sbin/dtrace -lm profile:::profile-97
+ * RESULT: not a valid probe description.
+ *
+ * 6)
+ * /usr/sbin/dtrace -lm genunix -lm unix
+ * RESULT: matching list of both genunix and unix probes.
+ *
+ * 7)
+ * /usr/sbin/dtrace -lm genunix -lm foounix
+ * RESULT: List of only genunix probes.
+ *
+ * 8)
+ * /usr/sbin/dtrace -lm foounix -lm unix
+ * RESULT: List of only unix probes.
+ *
+ * 9) automated in tst.InvalidModule3.d.ksh
+ * /usr/sbin/dtrace -lm fbt:des:des3_crunch_block:return
+ * RESULT: not a valid probe description.
+ *
+ * 10)
+ * /usr/sbin/dtrace -lm fbt:genunix'{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ *
+ * 11)
+ * /usr/sbin/dtrace -lm genunix'{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ *
+ * 12)
+ * /usr/sbin/dtrace -lm unix '{printf("FOUND");}'
+ * RESULT: List of only unix probes.
+ *
+ * 13) automated in tst.InvalidModule4.d.ksh
+ * /usr/sbin/dtrace -lm
+ * unix'/probefunc == "preempt"/{printf("FOUND");}'
+ * RESULT: not a valid probe description.
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithNames b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithNames
new file mode 100644
index 00000000..aabf1b2d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithNames
@@ -0,0 +1,128 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -l option with -n option.
+ *
+ * SECTION: dtrace Utility/-l Option;
+ * dtrace Utility/-n Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1)
+ * /usr/sbin/dtrace -ln profile
+ * RESULT: Silent output without any probes listed.
+ *
+ * 2)
+ * /usr/sbin/dtrace -ln genunix
+ * RESULT: Silent output without any probes listed.
+ *
+ * 3)
+ * /usr/sbin/dtrace -ln read
+ * RESULT: Silent output without any probes listed.
+ *
+ * 4)
+ * /usr/sbin/dtrace -ln BEGIN
+ * RESULT: list of one probe with name BEGIN.
+ *
+ * 5)
+ * /usr/sbin/dtrace -ln begin
+ * RESULT: Silent output without any probes listed.
+ *
+ * 6)
+ * /usr/sbin/dtrace -ln genunix:read
+ * RESULT: Silent output without any probes listed.
+ *
+ * 7)
+ * /usr/sbin/dtrace -ln genunix:read:
+ * RESULT: matching list of probes with module genunix and
+ * function read.
+ *
+ * 8)
+ * /usr/sbin/dtrace -ln sysinfo:genunix:read
+ * RESULT: Silent output without any probes listed.
+ *
+ * 9)
+ * /usr/sbin/dtrace -ln sysinfo:genunix:read:
+ * RESULT: matching list of probes with provider sysinfo, module
+ * genunix and function read.
+ *
+ * 10) /usr/sbin/dtrace -ln :genunix::
+ * RESULT: matching list of probes with module genunix
+ *
+ * 11)
+ * /usr/sbin/dtrace -ln :genunix:
+ * RESULT: Silent output without any probes listed.
+ *
+ * 12)
+ * /usr/sbin/dtrace -ln ::read:
+ * RESULT: matching list of probes with and function read.
+ *
+ * 13)
+ * /usr/sbin/dtrace -ln profile:::profile-97
+ * RESULT: matching list of probes with provider profile and function
+ * profile-97
+ *
+ * 14)
+ * /usr/sbin/dtrace -ln read: -ln write:
+ * RESULT: matching list of both read and write probes.
+ *
+ * 15)
+ * /usr/sbin/dtrace -ln read: -ln fight:
+ * RESULT: List of only read probes.
+ *
+ * 16)
+ * /usr/sbin/dtrace -ln fight: -ln write:
+ * RESULT: List of only write probes.
+ *
+ * 17)
+ * /usr/sbin/dtrace -ln fbt:des:des3_crunch_block:return
+ * RESULT: Silent output of only the header.
+ *
+ * 18)
+ * /usr/sbin/dtrace -ln read:'{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ *
+ * 19)
+ * /usr/sbin/dtrace -ln read:entry'{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ *
+ * 20)
+ * /usr/sbin/dtrace -ln BEGIN'{Printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ *
+ * 21)
+ * /usr/sbin/dtrace -ln BEGIN '{printf("FOUND");}'
+ * RESULT: List of only BEGIN probe.
+ *
+ * 22)
+ * /usr/sbin/dtrace -ln
+ * BEGIN'/probename == "entry"/{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithProviders b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithProviders
new file mode 100644
index 00000000..961d4096
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithProviders
@@ -0,0 +1,82 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -l option with -P option.
+ *
+ * SECTION: dtrace Utility/-l Option;
+ * dtrace Utility/-P Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1)
+ * /usr/sbin/dtrace -lP profile
+ * RESULT: List of only profile probes.
+ *
+ * 2)
+ * /usr/sbin/dtrace -lP foofile
+ * RESULT: Silent output without any probes listed.
+ *
+ * 3) automated in tst.InvalidProvider2.d.ksh
+ * /usr/sbin/dtrace -lP profile:::
+ * RESULT: not a valid probe description
+ *
+ * 4) automated in tst.InvalidProvider1.d.ksh
+ * /usr/sbin/dtrace -lP profile:::profile-97
+ * RESULT: not a valid probe description.
+ *
+ * 5)
+ * /usr/sbin/dtrace -lP profile -lP syscall
+ * RESULT: matching list of both profile and syscall probes.
+ *
+ * 6)
+ * /usr/sbin/dtrace -lP profile -lP foofile
+ * RESULT: List of only profile probes.
+ *
+ * 7)
+ * /usr/sbin/dtrace -lP foofile -lP profile
+ * RESULT: List of only profile probes.
+ *
+ * 8) authomated in tst.InvalidProvider3.d.ksh
+ * /usr/sbin/dtrace -lP fbt:des:des3_crunch_block:return
+ * RESULT: not a valid probe description.
+ *
+ * 9)
+ * /usr/sbin/dtrace -lP profile'{printf("FOUND");}'
+ * RESULT: Silent output without any probes listed.
+ *
+ * 10)
+ * /usr/sbin/dtrace -lP profile '{printf("FOUND");}'
+ * RESULT: List of only profile probes.
+ *
+ * 11) automated in tst.InvalidProvider4.d.ksh
+ * /usr/sbin/dtrace -lP
+ * profile'/probename == "profile-199"/{printf("FOUND");}'
+ * RESULT: not a valid probe description.
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ShowCompilerCode.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ShowCompilerCode.d
new file mode 100644
index 00000000..556811d2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.ShowCompilerCode.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -S option with dtrace utility shows the intermediate compiler code.
+ *
+ * SECTION: dtrace Utility/-S Option
+ *
+ * NOTES: Use this file as
+ * /usr/sbin/dtrace -qSs man.ShowCompilerCode.d
+ *
+ */
+
+BEGIN
+{
+ printf("This test should compile %d\n", 1);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceFunctions b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceFunctions
new file mode 100644
index 00000000..4c9c1c56
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceFunctions
@@ -0,0 +1,115 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -f option.
+ *
+ * SECTION: dtrace Utility/-f Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1) automated in tst.InvalidTraceFunc1.d.ksh
+ * /usr/sbin/dtrace -f profile
+ * RESULT: invalid probe specifier
+ *
+ * 2) automated in tst.InvalidTraceFunc2.d.ksh
+ * /usr/sbin/dtrace -f genunix
+ * RESULT: invalid probe specifier
+ *
+ * 3)
+ * /usr/sbin/dtrace -f read
+ * RESULT: tracing of matching list of probes with function read.
+ *
+ * 4) automated in tst.InvalidTraceFunc3.d.ksh
+ * /usr/sbin/dtrace -f read:
+ * RESULT: invalid probe specifier
+ *
+ * 5)
+ * /usr/sbin/dtrace -f ::read
+ * RESULT: tracing of matching list of probes with function read.
+ *
+ * 6) automated in tst.InvalidTraceFunc4.d.ksh
+ * /usr/sbin/dtrace -f ::read:
+ * RESULT: invalid probe specifier
+ *
+ * 7)
+ * /usr/sbin/dtrace -f genunix:read
+ * RESULT: tracing of probes with module genunix and function read.
+ *
+ * 8)
+ * /usr/sbin/dtrace -f sysinfo:genunix:read
+ * RESULT: tracing of probes with provider sysinfo, module genunix
+ * and function read.
+ *
+ * 9)
+ * /usr/sbin/dtrace -f sysinfo::read
+ * RESULT: tracing of probes with provider sysinfo and function read.
+ *
+ * 10) automated in tst.InvalidTraceFunc5.d.ksh
+ * /usr/sbin/dtrace -f :genunix::
+ * RESULT: invalid probe specifier
+ *
+ * 11) automated in tst.InvalidTraceFunc6.d.ksh
+ * /usr/sbin/dtrace -f profile:::profile-97
+ * RESULT: invalid probe specifier.
+ *
+ * 12)
+ * /usr/sbin/dtrace -f read -f write
+ * RESULT: tracing of both read and write probes.
+ *
+ * 13)
+ * /usr/sbin/dtrace -f read -f fight
+ * RESULT: Count of matching read probes and invalid probe specifier
+ * for fight
+ *
+ * 14) automated in tst.InvalidTraceFunc8.d.ksh
+ * /usr/sbin/dtrace -f fight -f write
+ * RESULT: invalid probe specifier.
+ *
+ * 15) automated in tst.InvalidTraceFunc7.d.ksh
+ * /usr/sbin/dtrace -f fbt:des:des3_crunch_block:return
+ * RESULT: invalid probe specifier.
+ *
+ * 16)
+ * /usr/sbin/dtrace -f read'{printf("FOUND");}'
+ * RESULT: tracing of probes with function read and with message FOUND
+ *
+ * 17)
+ * /usr/sbin/dtrace -f ::read'{printf("FOUND");}'
+ * RESULT: tracing of probes with function read and with message FOUND
+ *
+ * 18) automated in tst.InvalidTraceFunc9.d.ksh
+ * /usr/sbin/dtrace -f read '{printf("FOUND");}'
+ * RESULT: invalid probe specifier.
+ *
+ * 19)
+ * /usr/sbin/dtrace -f read'/probename == "entry"/{printf("FOUND");}'
+ * RESULT: tracing of probes with function read, name entry and with
+ * message FOUND
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceIDs b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceIDs
new file mode 100644
index 00000000..d9615b5a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceIDs
@@ -0,0 +1,70 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -l option with -i option.
+ *
+ * SECTION: dtrace Utility/-l Option;
+ * dtrace Utility/-i Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1) automated in tst.InvalidTraceID1.d.ksh
+ * /usr/sbin/dtrace -i 0
+ * RESULT: invalid probe specifier.
+ *
+ * 2) automated in tst.InvalidTraceID2.d.ksh
+ * /usr/sbin/dtrace -i -3
+ * RESULT: not a valid id range
+ *
+ * 3) automated in tst.InvalidTraceID3.d.ksh
+ * /usr/sbin/dtrace -i 0-2
+ * RESULT: not a valid id range
+ *
+ * 4) automated in tst.InvalidTraceID4.d.ksh
+ * /usr/sbin/dtrace -i 4-2
+ * RESULT: not a valid id range
+ *
+ * 5) automated in tst.InvalidTraceID5.d.ksh
+ * /usr/sbin/dtrace -i 2-2
+ * RESULT: not a valid id range
+ *
+ * 6) automated in tst.InvalidTraceID6.d.ksh
+ * /usr/sbin/dtrace -i 1 2 3 4
+ * RESULT: invalid probe specifier.
+ *
+ * 7) automated in tst.InvalidTraceID7.d.ksh
+ * /usr/sbin/dtrace -i 0 - 2
+ * RESULT: invalid probe specifier.
+ *
+ * 8)
+ * /usr/sbin/dtrace -i 1 -i 2-4 -i 4 -i 5
+ * RESULT: Only the BEGIN probe is traced and the others are not.
+ *
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceModule b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceModule
new file mode 100644
index 00000000..9c4401ea
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceModule
@@ -0,0 +1,114 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Tracing a module using the -m option.
+ *
+ * SECTION: dtrace Utility/-m Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1) automated in tst.InvalidTraceModule1.d.ksh
+ * /usr/sbin/dtrace -m profile
+ * RESULT: invalid probe specifier
+ *
+ * 2)
+ * /usr/sbin/dtrace -m genunix
+ * RESULT: trace of all probes with module genunix.
+ *
+ * 3)
+ * /usr/sbin/dtrace -m vtrace:genunix
+ * RESULT: trace of probes with provider vtrace and module genunix.
+ *
+ * 4) automated in tst.InvalidTraceModule2.d.ksh
+ * /usr/sbin/dtrace -m :genunix::
+ * RESULT: invalid probe specifier
+ *
+ * 5)
+ * /usr/sbin/dtrace -m :genunix
+ * RESULT: trace of all probes with module genunix.
+ *
+ * 6) automated in tst.InvalidTraceModule3.d.ksh
+ * /usr/sbin/dtrace -m genunix::
+ * RESULT: invalid probe specifier
+ *
+ * 7) automated in tst.InvalidTraceModule4.d.ksh
+ * /usr/sbin/dtrace -m profile:::profile-97
+ * RESULT: not a valid probe description.
+ *
+ * 8)
+ * /usr/sbin/dtrace -m genunix -m unix
+ * RESULT: tracing of both genunix and unix probes.
+ *
+ * 9)
+ * /usr/sbin/dtrace -m genunix -m foounix
+ * RESULT: Number of probes matching the description genunix
+ * and an invalid probe specifier for foounix.
+ *
+ * 10) automated in tst.InvalidTraceModule5.d.ksh
+ * /usr/sbin/dtrace -m foounix -m unix
+ * RESULT: invalid probe specifier for foounix.
+ *
+ * 11) automated in tst.InvalidTraceModule6.d.ksh
+ * /usr/sbin/dtrace -m fbt:des:des3_crunch_block:return
+ * RESULT: invalid probe description.
+ *
+ * 12)
+ * /usr/sbin/dtrace -m fbt:genunix'{printf("FOUND");}'
+ * RESULT: tracing of all the probes matching provider fbt and module
+ * genunix.
+ *
+ * 13)
+ * /usr/sbin/dtrace -m genunix'{printf("FOUND");}'
+ * RESULT: tracing of all the probes matching module genunix with
+ * message FOUND
+ *
+ * 14)
+ * /usr/sbin/dtrace -m :genunix'{printf("FOUND");}'
+ * RESULT: tracing of all the probes matching module genunix with
+ * message FOUND
+ *
+ * 15) automated in tst.InvalidTraceModule7.d.ksh
+ * /usr/sbin/dtrace -m genunix::'{printf("FOUND");}'
+ * RESULT: invalid probe specifier.
+ *
+ * 16) automated in tst.InvalidTraceModule8.d.ksh
+ * /usr/sbin/dtrace -m genunix:'{printf("FOUND");}'
+ * RESULT: invalid probe specifier.
+ *
+ * 17)
+ * /usr/sbin/dtrace -m unix '{printf("FOUND");}'
+ * RESULT: invalid probe specifier.
+ *
+ * 18)
+ * /usr/sbin/dtrace -m
+ * unix'/probefunc == "preempt"/{printf("FOUND");}'
+ * RESULT: tracing of all the probes matching module genunix,
+ * probe function preempt with message FOUND.
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceNames b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceNames
new file mode 100644
index 00000000..c3e75554
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceNames
@@ -0,0 +1,129 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -n option.
+ *
+ * SECTION: dtrace Utility/-n Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1) automated in tst.InvalidTraceName1.d.ksh
+ * /usr/sbin/dtrace -n profile
+ * RESULT: invalid probe specifier
+ *
+ * 2) automated in tst.InvalidTraceName2.d.ksh
+ * /usr/sbin/dtrace -n genunix
+ * RESULT: invalid probe specifier
+ *
+ * 3) automated in tst.InvalidTraceName3.d.ksh
+ * /usr/sbin/dtrace -n read
+ * RESULT: invalid probe specifier
+ *
+ * 4)
+ * /usr/sbin/dtrace -n BEGIN
+ * RESULT: trace of one probe with name BEGIN.
+ *
+ * 5) automated in tst.InvalidTraceName4.d.ksh
+ * /usr/sbin/dtrace -n begin
+ * RESULT: invalid probe specifier
+ *
+ * 6) automated in tst.InvalidTraceName5.d.ksh
+ * /usr/sbin/dtrace -n genunix:read
+ * RESULT: invalid probe specifier
+ *
+ * 7)
+ * /usr/sbin/dtrace -n genunix:read:
+ * RESULT: trace of probes with module genunix and function read.
+ *
+ * 8) automated in tst.InvalidTraceName6.d.ksh
+ * /usr/sbin/dtrace -n sysinfo:genunix:read
+ * RESULT: invalid probe specifier
+ *
+ * 9)
+ * /usr/sbin/dtrace -n sysinfo:genunix:read:
+ * RESULT: tracing of probes with provider sysinfo, module genunix
+ * and function read.
+ *
+ * 10)
+ * /usr/sbin/dtrace -n :genunix::
+ * RESULT: tracing of probes with module genunix
+ *
+ * 11) automated in tst.InvalidTraceName7.d.ksh
+ * /usr/sbin/dtrace -n :genunix:
+ * RESULT: invalid probe specifier
+ *
+ * 12)
+ * /usr/sbin/dtrace -n ::read:
+ * RESULT: tracing of probes with function read.
+ *
+ * 13)
+ * /usr/sbin/dtrace -n profile:::profile-97
+ * RESULT: tracing of probes with provider profile and name
+ * profile-97
+ *
+ * 14)
+ * /usr/sbin/dtrace -n read: -n write:
+ * RESULT: tracing of both read and write probes.
+ *
+ * 15)
+ * /usr/sbin/dtrace -n read: -n fight:
+ * RESULT: Count of mathching read probes and invalid probe specifier
+ * for fight:
+ *
+ * 16) automated in tst.InvalidTraceName8.d.ksh
+ * /usr/sbin/dtrace -n fight: -n write:
+ * RESULT: invalid probe specifier
+ *
+ * 17)
+ * /usr/sbin/dtrace -n fbt:des:des3_crunch_block:return
+ * RESULT: trace of the specified probe.
+ *
+ * 18)
+ * /usr/sbin/dtrace -n read:'{printf("FOUND");}'
+ * RESULT: Trace of all the probes with module read and a message
+ * saying FOUND.
+ *
+ * 19)
+ * /usr/sbin/dtrace -n read:entry'{printf("FOUND");}'
+ * RESULT: Trace of all the probes with module read, name entry.Output
+ * of a message saying FOUND.
+ *
+ * 20)
+ * /usr/sbin/dtrace -n BEGIN'{printf("FOUND");}'
+ * RESULT: Trace of the BEGIN probe with the message FOUND.
+ *
+ * 21) automated in tst.InvalidTraceName9.d.ksh
+ * /usr/sbin/dtrace -n BEGIN '{printf("FOUND");}'
+ * RESULT: invalid probe specifier
+ *
+ * 22)
+ * /usr/sbin/dtrace -n BEGIN'/probename == "entry"/{printf("FOUND");}'
+ * RESULT: Tracing of BEGIN function but no message FOUND.
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceProvider b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceProvider
new file mode 100644
index 00000000..f52f395c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceProvider
@@ -0,0 +1,83 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -P option to trace all the probes provided by the particular
+ * provider.
+ *
+ * SECTION: dtrace Utility/-P Option
+ *
+ * NOTES: Manually check:
+ *
+ * 1)
+ * /usr/sbin/dtrace -P profile
+ * RESULT: Trace of all profile probes.
+ *
+ * 2) automated in tst.InvalidTraceProvider1.d.ksh
+ * /usr/sbin/dtrace -P foofile
+ * RESULT: invalid probe specifier
+ *
+ * 3) automated in tst.InvalidTraceProvider2.d.ksh
+ * /usr/sbin/dtrace -P profile:::
+ * RESULT: invalid probe specifier
+ *
+ * 4) automated in tst.InvalidTraceProvider3.d.ksh
+ * /usr/sbin/dtrace -P profile:::profile-97
+ * RESULT: invalid probe specifier
+ *
+ * 5)
+ * /usr/sbin/dtrace -P profile -P syscall
+ * RESULT: matching traces of both profile and syscall probes.
+ *
+ * 6)
+ * /usr/sbin/dtrace -P profile -P foofile
+ * RESULT: Count of profile probes that matched and invalid
+ * probe specifier for foofile and no tracing.
+ *
+ * 7) automated in tst.InvalidTraceProvider4.d.ksh
+ * /usr/sbin/dtrace -P fbt:des:des3_crunch_block:return
+ * RESULT: invalid probe specifier
+ *
+ * 8)
+ * /usr/sbin/dtrace -P profile'{printf("FOUND");}'
+ * RESULT: Traces of all the matching profile probes with the
+ * FOUND message.
+ *
+ * 9) automated in tst.InvalidTraceProvider5.d.ksh
+ * /usr/sbin/dtrace -P profile '{printf("FOUND");}'
+ * RESULT: invalid probe specifier
+ *
+ * 10)
+ * /usr/sbin/dtrace -P
+ * profile'/probename == "profile-199"/{printf("FOUND");}'
+ * RESULT: Traces of the matching profile probe with the
+ * FOUND message.
+ *
+ *
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.VerboseStabilityReport.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.VerboseStabilityReport.d
new file mode 100644
index 00000000..23742284
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/man.VerboseStabilityReport.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using -v option with dtrace utility produces a program stability report
+ * showing the minimum interface stability and dependency level for
+ * the specified D programs.
+ *
+ * SECTION: dtrace Utility/-s Option;
+ * dtrace Utility/-v Option
+ *
+ * NOTES: Use this file as
+ * /usr/sbin/dtrace -vs man.VerboseStabilityReport.d
+ *
+ */
+
+BEGIN
+{
+ printf("This test should compile: %d\n", 2);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.AddSearchPath.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.AddSearchPath.d.ksh
new file mode 100755
index 00000000..2f49f733
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.AddSearchPath.d.ksh
@@ -0,0 +1,82 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -I option can be used to search path for #include files when used
+# in conjunction with the -C option. The specified directory is inserted into
+# the search path adhead of the default directory list.
+#
+# SECTION: dtrace Utility/-C Option
+# SECTION: dtrace Utility/-I Option
+#
+##
+
+script()
+{
+ $dtrace -C -I /tmp -s /dev/stdin <<EOF
+ #pragma D option quiet
+#include "test.h"
+
+ BEGIN
+ /1520 != VALUE/
+ {
+ printf("VALUE: %d, Test should fail\n", VALUE);
+ exit(1);
+ }
+
+ BEGIN
+ /1520 == VALUE/
+ {
+ printf("VALUE: %d, Test should pass\n", VALUE);
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+tempfile=/tmp/test.h
+echo "#define VALUE 1520" > $tempfile
+
+dtrace=$1
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+/usr/bin/rm -f $tempfile
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeGiga.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeGiga.d.ksh
new file mode 100644
index 00000000..2f0c5673
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeGiga.d.ksh
@@ -0,0 +1,45 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# ASSERTION:
+# The trace buffer size can include any of the size suffixes k, m, g or t
+#
+# SECTION: dtrace Utility/-b Option
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -b 1g -b 2g -e
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeKilo.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeKilo.d.ksh
new file mode 100644
index 00000000..d969b481
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeKilo.d.ksh
@@ -0,0 +1,45 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# ASSERTION:
+# The trace buffer size can include any of the size suffixes k, m, g or t
+#
+# SECTION: dtrace Utility/-b Option
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -b 1k -b 2k -e
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeMega.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeMega.d.ksh
new file mode 100644
index 00000000..a08327a3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeMega.d.ksh
@@ -0,0 +1,45 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# ASSERTION:
+# The trace buffer size can include any of the size suffixes k, m, g or t
+#
+# SECTION: dtrace Utility/-b Option
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -b 1m -b 2m -e
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeTera.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeTera.d.ksh
new file mode 100644
index 00000000..00f2c662
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeTera.d.ksh
@@ -0,0 +1,45 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# ASSERTION:
+# The trace buffer size can include any of the size suffixes k, m, g or t
+#
+# SECTION: dtrace Utility/-b Option
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -b 1t -b 2t -e
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel32.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel32.d.ksh
new file mode 100755
index 00000000..e4ef38db
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel32.d.ksh
@@ -0,0 +1,73 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# If the -32 option is specified, dtrace will force the D compiler to
+# compile a program using the 32-bit data model.
+#
+# SECTION: dtrace Utility/-32 Option
+#
+##
+
+script()
+{
+ $dtrace -32 -s /dev/stdin <<EOF
+ BEGIN
+ /4 != sizeof(long)/
+ {
+ printf("Not targeted for 32 bit machine\n");
+ exit(1);
+ }
+
+ BEGIN
+ /4 == sizeof(long)/
+ {
+ printf("Targeted for 32 bit machine\n");
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel64.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel64.d.ksh
new file mode 100755
index 00000000..8a9de0c8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel64.d.ksh
@@ -0,0 +1,74 @@
+#!/bin/ksh
+
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# If the -64 option is specified, dtrace will force the D compiler to
+# compile a program using the 64-bit data model.
+#
+# SECTION: dtrace Utility/-64 Option
+#
+##
+
+script()
+{
+ $dtrace -64 -s /dev/stdin <<EOF
+ BEGIN
+ /8 != sizeof(long)/
+ {
+ printf("Not targeted for 64 bit machine\n");
+ exit(1);
+ }
+
+ BEGIN
+ /8 == sizeof(long)/
+ {
+ printf("Targeted for 64 bit machine\n");
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh
new file mode 100755
index 00000000..9be2b291
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh
@@ -0,0 +1,68 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -D option can be used to define a name when used in conjunction
+# with the -C option.
+#
+# SECTION: dtrace Utility/-C Option;
+# dtrace Utility/-D Option
+#
+##
+
+script()
+{
+ $dtrace -C -D VALUE=40 -s /dev/stdin <<EOF
+ #pragma D option quiet
+
+ BEGIN
+ {
+ printf("Value of VALUE: %d\n", VALUE);
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh.out
new file mode 100644
index 00000000..5f91ad16
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh.out
@@ -0,0 +1,2 @@
+Value of VALUE: 40
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh
new file mode 100755
index 00000000..0259db36
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh
@@ -0,0 +1,56 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -w option can be used to permit destructive actions in D programs.
+#
+# SECTION: dtrace Utility/-w Option;
+# dtrace Utility/-f Option
+#
+##
+
+
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qwf read'{chill(15); printf("Done chilling"); exit(0);}'
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh.out
new file mode 100644
index 00000000..8975980f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh.out
@@ -0,0 +1 @@
+Done chilling
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh
new file mode 100755
index 00000000..6d3913f8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -w option can be used to permit destructive actions in D programs.
+#
+# SECTION: dtrace Utility/-w Option;
+# dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qwi 1'{chill(15); printf("Done chilling"); exit(0);}'
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh.out
new file mode 100644
index 00000000..8975980f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh.out
@@ -0,0 +1 @@
+Done chilling
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh
new file mode 100755
index 00000000..923be51c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -w option can be used to permit destructive actions in D programs.
+#
+# SECTION: dtrace Utility/-w Option;
+# dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qwm unix'{chill(15); printf("Done chilling"); exit(0);}'
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh.out
new file mode 100644
index 00000000..8975980f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh.out
@@ -0,0 +1 @@
+Done chilling
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh
new file mode 100755
index 00000000..b21903fb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -w option can be used to permit destructive actions in D programs.
+#
+# SECTION: dtrace Utility/-w Option;
+# dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qwn BEGIN'{chill(15); printf("Done chilling"); exit(0);}'
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh.out
new file mode 100644
index 00000000..8975980f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh.out
@@ -0,0 +1 @@
+Done chilling
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh
new file mode 100755
index 00000000..09dafecb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -w option can be used to permit destructive actions in D programs.
+#
+# SECTION: dtrace Utility/-w Option;
+# dtrace Utility/-P Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qwP syscall'{chill(15); printf("Done chilling"); exit(0);}'
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh.out
new file mode 100644
index 00000000..8975980f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh.out
@@ -0,0 +1 @@
+Done chilling
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithoutW.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithoutW.d.ksh
new file mode 100755
index 00000000..9f051b4c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithoutW.d.ksh
@@ -0,0 +1,55 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Destructive actions will not compile or are not enabled without the
+# -w option in D programs.
+#
+# SECTION: dtrace Utility/-w Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qP syscall'{chill(15); printf("Done chilling"); exit(0);}'
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationOut.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationOut.d.ksh
new file mode 100755
index 00000000..b68fc138
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationOut.d.ksh
@@ -0,0 +1,73 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Using -G option with dtrace utility produces an ELF file containing a
+# DTrace program. If the filename used with the -s option does not end
+# with .d, and the -o option is not used, then the output ELF file is
+# in d.out.
+#
+# SECTION: dtrace Utility/-G Option
+#
+##
+
+script()
+{
+ $dtrace -G -s /dev/stdin <<EOF
+ BEGIN
+ {
+ printf("This test should compile.\n");
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+if [ ! -a "d.out" ]; then
+ echo $tst: file not generated
+ exit 1
+fi
+
+/usr/bin/rm -f "d.out"
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationWithO.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationWithO.d.ksh
new file mode 100755
index 00000000..ec38b502
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationWithO.d.ksh
@@ -0,0 +1,74 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Using -G option with dtrace utility produces an ELF file containing a
+# DTrace program. The output file can be named as required using the
+# -o option in conjunction with the -G option.
+#
+# SECTION: dtrace Utility/-G Option;
+# dtrace Utility/-o Option
+#
+##
+
+script()
+{
+ $dtrace -G -o outputFile -s /dev/stdin <<EOF
+ BEGIN
+ {
+ printf("This test should compile.\n");
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+if [ ! -a "outputFile" ]; then
+ echo $tst: file not generated
+ exit 1
+fi
+
+/usr/bin/rm -f "outputFile"
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus1.d.ksh
new file mode 100755
index 00000000..70a9f498
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus1.d.ksh
@@ -0,0 +1,56 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# When a fatal error occurs such that the program compilation fails or the
+# specified request cannot be satisfied, an exit status of 1 is returned.
+#
+#
+# SECTION: dtrace Utility/Exit Status
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -s wassup
+status=$?
+
+if [ "$status" -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus2.d.ksh
new file mode 100755
index 00000000..a058d3a3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus2.d.ksh
@@ -0,0 +1,55 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# When invalid command line options or arguments are specified an exit status
+# of 2 is returned.
+#
+# SECTION: dtrace Utility/Exit Status
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -9
+status=$?
+
+if [ "$status" -ne 2 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExtraneousProbeIds.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExtraneousProbeIds.d.ksh
new file mode 100755
index 00000000..090fc4a0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExtraneousProbeIds.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -i option with extraneous probe identifiers.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 12 10 -i 23
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName1.d.ksh
new file mode 100755
index 00000000..c28c7823
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName1.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f BEGIN
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName2.d.ksh
new file mode 100755
index 00000000..d431579d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName2.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f 4.56
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId1.d.ksh
new file mode 100755
index 00000000..814b88dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId1.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -li option can be used to list the probes from their ids. An id of
+# negative integer is invalid
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -li -3
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId2.d.ksh
new file mode 100755
index 00000000..f9f44078
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId2.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -li option can be used to list the probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -li 4-2
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId3.d.ksh
new file mode 100755
index 00000000..efb03ae2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId3.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -li option can be used to list the probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -li 2-2
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule1.d.ksh
new file mode 100755
index 00000000..a896ff3d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule1.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lm option can be used to list the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lm :genunix::
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule2.d.ksh
new file mode 100755
index 00000000..820cc64d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule2.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lm option can be used to list the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lm profile:::profile-97
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule3.d.ksh
new file mode 100755
index 00000000..b56e6c37
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule3.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lm option can be used to list the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lm fbt:des:des3_crunch_block:return
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule4.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule4.d.ksh
new file mode 100755
index 00000000..0ef9d956
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule4.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lm option can be used to list the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lm unix'/probefunc == "preempt"/{printf("FOUND");}'
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProbeIdentifier.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProbeIdentifier.d.ksh
new file mode 100755
index 00000000..66e0e1a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProbeIdentifier.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -i option with invalid probe identifier.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i i23
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider1.d.ksh
new file mode 100755
index 00000000..327e2d01
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider1.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lP option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-P Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lP profile:::profile-97
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider2.d.ksh
new file mode 100755
index 00000000..22624495
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider2.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lP option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-P Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lP profile:::
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider3.d.ksh
new file mode 100755
index 00000000..775b327c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider3.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lP option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-P Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lP fbt:des:des3_crunch_block:return
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider4.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider4.d.ksh
new file mode 100755
index 00000000..04343f3e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider4.d.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -lP option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-l Option;
+# dtrace Utility/-P Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -lP profile'/probename == "profile-199"/{printf("FOUND");}'
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc1.d.ksh
new file mode 100755
index 00000000..1395f3be
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc1.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f profile
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc2.d.ksh
new file mode 100755
index 00000000..4231e5c7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc2.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f genunix
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc3.d.ksh
new file mode 100755
index 00000000..3c5b1783
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc3.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f read:
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc4.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc4.d.ksh
new file mode 100755
index 00000000..bb8460d0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc4.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f ::read:
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc5.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc5.d.ksh
new file mode 100755
index 00000000..54466761
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc5.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f :genunix::
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc6.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc6.d.ksh
new file mode 100755
index 00000000..645e6d9f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc6.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f profile:::profile-97
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc7.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc7.d.ksh
new file mode 100755
index 00000000..a93d5c4b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc7.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f fbt:des:des3_crunch_block:return
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc8.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc8.d.ksh
new file mode 100755
index 00000000..22ab3b16
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc8.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f fight -f write
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc9.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc9.d.ksh
new file mode 100755
index 00000000..2af27a32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc9.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -f option with an invalid function name.
+#
+# SECTION: dtrace Utility/-f Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -f read '{printf("FOUND");}'
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID1.d.ksh
new file mode 100755
index 00000000..46096d21
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID1.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -i option can be used to enable the trace of probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 0
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID2.d.ksh
new file mode 100755
index 00000000..f406ce00
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID2.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -i option can be used to enable the trace of probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i -3
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID3.d.ksh
new file mode 100755
index 00000000..fc2a24d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID3.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -i option can be used to enable the trace of probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 0-2
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID4.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID4.d.ksh
new file mode 100755
index 00000000..5fd6fd6c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID4.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -i option can be used to enable the trace of probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 4-2
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID5.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID5.d.ksh
new file mode 100755
index 00000000..0ac46dbb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID5.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -i option can be used to enable the trace of probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 2-2
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID6.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID6.d.ksh
new file mode 100755
index 00000000..778d485a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID6.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -i option can be used to enable the trace of probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 1 2 3 4
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID7.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID7.d.ksh
new file mode 100755
index 00000000..8a0f2d4e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID7.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -i option can be used to enable the trace of probes from their ids. A
+# non-increasing range will not list any probes.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 0 - 2
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule1.d.ksh
new file mode 100755
index 00000000..56dee0dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule1.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m profile
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule2.d.ksh
new file mode 100755
index 00000000..a508fe10
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule2.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m :genunix::
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule3.d.ksh
new file mode 100755
index 00000000..599ce93e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule3.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m genunix::
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule4.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule4.d.ksh
new file mode 100755
index 00000000..e0e87861
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule4.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m profile:::profile-97
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule5.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule5.d.ksh
new file mode 100755
index 00000000..85830602
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule5.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m foounix -m unix
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule6.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule6.d.ksh
new file mode 100755
index 00000000..6125fb0f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule6.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m fbt:des:des3_crunch_block:return
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule7.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule7.d.ksh
new file mode 100755
index 00000000..e689627b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule7.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m genunix::'{printf("FOUND");}'
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule8.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule8.d.ksh
new file mode 100755
index 00000000..692821b5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule8.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -m option can be used to enable the probes from their module names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -m genunix:'{printf("FOUND");}'
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName1.d.ksh
new file mode 100755
index 00000000..43c61af3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName1.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n profile
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName2.d.ksh
new file mode 100755
index 00000000..70a52188
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName2.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n genunix
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName3.d.ksh
new file mode 100755
index 00000000..efb5ad08
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName3.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n not_a_valid_probe
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName4.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName4.d.ksh
new file mode 100755
index 00000000..04845b99
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName4.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n begin
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName5.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName5.d.ksh
new file mode 100755
index 00000000..df17231f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName5.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n genunix:read
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName6.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName6.d.ksh
new file mode 100755
index 00000000..10f13cb3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName6.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n sysinfo:genunix:read
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName7.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName7.d.ksh
new file mode 100755
index 00000000..b22561fa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName7.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n :genunix:
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName8.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName8.d.ksh
new file mode 100755
index 00000000..f66055e2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName8.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n fight: -n write:
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName9.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName9.d.ksh
new file mode 100755
index 00000000..a4239ff9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName9.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -n option can be used to enable the trace of probes from their names.
+#
+# SECTION: dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n BEGIN '{printf("FOUND");}'
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider1.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider1.d.ksh
new file mode 100755
index 00000000..0a792c59
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider1.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -P option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-P Option;
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -P foofile
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider2.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider2.d.ksh
new file mode 100755
index 00000000..1763142b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider2.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -P option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-P Option;
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -P profile:::
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider3.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider3.d.ksh
new file mode 100755
index 00000000..a8549329
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider3.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -P option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-P Option;
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -P profile:::profile-97
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider4.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider4.d.ksh
new file mode 100755
index 00000000..f8a1359c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider4.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -P option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-P Option;
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -P fbt:des:des3_crunch_block:return
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider5.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider5.d.ksh
new file mode 100755
index 00000000..cec4297c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider5.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -P option can be used to list the probes from their provider names.
+# Invalid module names result in error.
+#
+# SECTION: dtrace Utility/-P Option;
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -P profile '{printf("FOUND");}'
+
+status=$?
+
+echo $status
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.MultipleInvalidProbeId.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.MultipleInvalidProbeId.d.ksh
new file mode 100755
index 00000000..8f2ceefd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.MultipleInvalidProbeId.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -i option with multiple valid and invalid probe identifiers.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 12 -i 10 -i 0
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.PreprocessorStatement.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.PreprocessorStatement.d.ksh
new file mode 100755
index 00000000..182466f4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.PreprocessorStatement.d.ksh
@@ -0,0 +1,70 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -C option is used to run the C preprocessor over D programs before
+# compiling them. The -H option used in conjuction with the -C option
+# lists the pathnames of the included files to STDERR.
+#
+# SECTION: dtrace Utility/-C Option;
+# dtrace Utility/-H Option
+#
+##
+
+script()
+{
+ $dtrace -CH -s /dev/stdin <<EOF
+
+#include <stdio.h>
+
+ BEGIN
+ {
+ printf("This test should compile\n");
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh
new file mode 100755
index 00000000..4bfbf767
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh
@@ -0,0 +1,65 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Using the -q option suppresses the dtrace messages and prints only the
+# data traced by trace() and printf() to stdout.
+#
+# SECTION: dtrace Utility/-q Option
+#
+##
+
+script()
+{
+ $dtrace -q -s /dev/stdin <<EOF
+
+ BEGIN
+ {
+ printf("I am the only one.");
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh.out
new file mode 100644
index 00000000..20e31b50
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh.out
@@ -0,0 +1 @@
+I am the only one.
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh
new file mode 100755
index 00000000..16cd05f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh
@@ -0,0 +1,67 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Using the -e option exits after compiling any requests but before
+# enabling probes.
+#
+# SECTION: dtrace Utility/-e Option
+#
+##
+
+script()
+{
+ $dtrace -e -s /dev/stdin <<EOF
+ #pragma D option quiet
+ BEGIN
+ {
+ i = 100;
+ printf("Value of i: %d\n", i);
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh.out
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh.out
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.UnDefineNameWithCPP.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.UnDefineNameWithCPP.d.ksh
new file mode 100755
index 00000000..4c1eb507
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.UnDefineNameWithCPP.d.ksh
@@ -0,0 +1,71 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -D option can be used to define a name when used in conjunction
+# with the -C option. The -U option can be used to undefine a name in
+# conjunction with the -C option.
+#
+# SECTION: dtrace Utility/-C Option;
+# dtrace Utility/-D Option;
+# dtrace Utility/-U Option
+#
+##
+
+script()
+{
+ $dtrace -C -D VALUE=40 -U VALUE -s /dev/stdin <<EOF
+ #pragma D option quiet
+
+ BEGIN
+ {
+ printf("Value of VALUE: %d\n", VALUE);
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh
new file mode 100755
index 00000000..5e61f053
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -Z option can be used to permit descriptions that match
+# zero probes.
+#
+# SECTION: dtrace Utility/-Z Option;
+# dtrace Utility/-f Option
+#
+##
+
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qZf wassup'{printf("Iamkool");}' \
+-qf read'{printf("I am done"); exit(0);}'
+
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh.out
new file mode 100644
index 00000000..0f2e1aac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh.out
@@ -0,0 +1 @@
+I am done
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh
new file mode 100755
index 00000000..9d48f99b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -Z option can be used to permit descriptions that match
+# zero probes.
+#
+# SECTION: dtrace Utility/-Z Option;
+# dtrace Utility/-m Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qZm wassup'{printf("Iamkool");}' \
+-qm unix'{printf("I am done"); exit(0);}'
+
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh.out
new file mode 100644
index 00000000..0f2e1aac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh.out
@@ -0,0 +1 @@
+I am done
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh
new file mode 100755
index 00000000..90175a50
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh
@@ -0,0 +1,56 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -Z option can be used to permit descriptions that match
+# zero probes.
+#
+# SECTION: dtrace Utility/-Z Option;
+# dtrace Utility/-n Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qZn wassup'{printf("Iamkool");}' \
+-qn BEGIN'{printf("I am done"); exit(0);}'
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh.out
new file mode 100644
index 00000000..0f2e1aac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh.out
@@ -0,0 +1 @@
+I am done
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbeIdentfier.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbeIdentfier.d.ksh
new file mode 100755
index 00000000..9af4d2b8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbeIdentfier.d.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Testing -i option with zero probe identifier.
+#
+# SECTION: dtrace Utility/-i Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -i 0
+
+if [ $? -ne 1 ]; then
+ echo $tst: dtrace failed
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbesWithoutZ.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbesWithoutZ.d.ksh
new file mode 100755
index 00000000..afc7d76d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbesWithoutZ.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# Without the -Z option probe descriptions that do not match any known
+# probes will cause an error or will not be enabled.
+#
+# SECTION: dtrace Utility/-Z Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qP wassup'{printf("Iamkool");}' \
+-qP profile'{printf("I am done"); exit(0);}'
+
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo $tst: dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh
new file mode 100755
index 00000000..f2646bd5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+##
+#
+# ASSERTION:
+# The -Z option can be used to permit descriptions that match
+# zero probes.
+#
+# SECTION: dtrace Utility/-Z Option;
+# dtrace Utility/-P Option
+#
+##
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qZP wassup'{printf("Iamkool");}' \
+-qP profile'{printf("I am done"); exit(0);}'
+
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh.out
new file mode 100644
index 00000000..0f2e1aac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh.out
@@ -0,0 +1 @@
+I am done
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/err.D_IDENT_UNDEF.timespent.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/err.D_IDENT_UNDEF.timespent.d
new file mode 100644
index 00000000..04ccb726
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/err.D_IDENT_UNDEF.timespent.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Calculate timestamp between BEGIN and END.
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+END
+{
+ total = timestamp - start;
+}
+
+BEGIN
+{
+ start = timestamp;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.end.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.end.d
new file mode 100644
index 00000000..56c1a4c4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.end.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Sequence flow of END profile.
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+END
+{
+ printf("End fired after exit\n");
+}
+
+BEGIN
+{
+ printf("Begin fired first\n");
+}
+
+tick-1
+{
+ printf("tick fired second\n");
+ printf("Call exit\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.endwithoutbegin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.endwithoutbegin.d
new file mode 100644
index 00000000..62919607
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.endwithoutbegin.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * END without BEGIN profile
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+END
+{
+ printf("End fired after exit\n");
+}
+
+tick-1
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multibeginend.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multibeginend.d
new file mode 100644
index 00000000..4f6ec921
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multibeginend.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Tests multiple END profile.
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+END
+{
+ printf("End1 fired after exit\n");
+}
+END
+{
+ printf("End2 fired after exit\n");
+}
+END
+{
+ printf("End3 fired after exit\n");
+}
+END
+{
+ printf("End4 fired after exit\n");
+}
+
+BEGIN
+{
+ printf("Begin fired first\n");
+}
+BEGIN
+{
+ printf("Begin fired second\n");
+}
+BEGIN
+{
+ printf("Begin fired third\n");
+}
+BEGIN
+{
+ printf("Begin fired fourth\n");
+}
+BEGIN
+{
+ printf("Begin fired fifth\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multiend.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multiend.d
new file mode 100644
index 00000000..e6629fb5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/end/tst.multiend.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Tests Multiple END and single BEGIN
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+END
+{
+ printf("End1 fired after exit\n");
+}
+END
+{
+ printf("End2 fired after exit\n");
+}
+END
+{
+ printf("End3 fired after exit\n");
+}
+END
+{
+ printf("End4 fired after exit\n");
+}
+
+BEGIN
+{
+ printf("Begin fired first\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_DECL_IDRED.EnumSameName.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_DECL_IDRED.EnumSameName.d
new file mode 100644
index 00000000..7e5427a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_DECL_IDRED.EnumSameName.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Enumerations assigning same or different values to the same identifier in
+ * different enumerations should throw a compiler error.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ *
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+enum colors {
+ RED,
+ GREEN,
+ BLUE
+};
+
+enum shades {
+ RED,
+ ORANGE,
+ GREEN,
+ WHITE
+};
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d
new file mode 100644
index 00000000..2b4266d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Repeating the same identifier in the same enumeration will throw a compiler
+ * error.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ *
+ * NOTES:
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+enum colors {
+ RED,
+ GREEN,
+ GREEN = 2,
+ BLUE
+};
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumEquality.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumEquality.d
new file mode 100644
index 00000000..cbf9369a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumEquality.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the identifiers in different D enumerations at same position for
+ * equality.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ */
+
+#pragma D option quiet
+
+enum colors {
+ RED,
+ GREEN,
+ BLUE
+};
+
+enum shades {
+ WHITE,
+ BLACK,
+ YELLOW
+};
+
+
+profile:::tick-1sec
+/(WHITE == RED) && (YELLOW == BLUE) && (GREEN == BLACK)/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumSameValue.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumSameValue.d
new file mode 100644
index 00000000..26a4d504
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumSameValue.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Enumerations assigning the same value to different identifiers in the same
+ * enumeration should work okay.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ *
+ * NOTES:
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+enum colors {
+ RED = 2,
+ GREEN = 2,
+ BLUE = 2
+};
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumValAssign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumValAssign.d
new file mode 100644
index 00000000..f721c50a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/enum/tst.EnumValAssign.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Test the D enumerations with and without initilialization of the identifiers.
+ * Also test for values with negative integer assignments, expressions and
+ * fractions.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+enum colors {
+ RED,
+ ORANGE = 5 + 5,
+ YELLOW = 2,
+ GREEN,
+ BLUE = GREEN + ORANGE,
+ PINK = 5/4,
+ INDIGO = -2,
+ VIOLET
+};
+
+profile:::tick-1sec
+/(0 == RED) && (10 == ORANGE) && (2 == YELLOW) && (3 == GREEN) &&
+ (13 == BLUE) && (1 == PINK) && (-2 == INDIGO) && (-1 == VIOLET)/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_BADADDR.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_BADADDR.d
new file mode 100644
index 00000000..5eb3e94c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_BADADDR.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To test DTRACEFLT_BADADDR error
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+ERROR
+{
+ printf("The arguments are %u %u %u %u %u\n",
+ arg1, arg2, arg3, arg4, arg5);
+ printf("The value of arg4 = %u\n", DTRACEFLT_BADADDR);
+ exit(0);
+}
+
+BEGIN
+{
+ *(char *)NULL;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_DIVZERO.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_DIVZERO.d
new file mode 100644
index 00000000..5b93168a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_DIVZERO.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To test DTRACEFLT_DIVZERO error
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+ERROR
+{
+ printf("The arguments are %u %u %u %d %u\n",
+ arg1, arg2, arg3, arg4, arg5);
+ exit(0);
+}
+
+char *s;
+
+BEGIN
+{
+ i = 1;
+ j = 2;
+ j = i/(j-2);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_UNKNOWN.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_UNKNOWN.d
new file mode 100644
index 00000000..6de75bbc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_UNKNOWN.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To test DTRACEFLT_UNKNOWN error
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+ERROR
+{
+ printf("The arguments are %u %u %u %u %u\n",
+ arg1, arg2, arg3, arg4, arg5);
+ printf("The value of arg4 = %u\n", DTRACEFLT_UNKNOWN);
+ exit(0);
+}
+
+BEGIN
+{
+ x = (int *) 64;
+ y = *x;
+ trace(y);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.error.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.error.d
new file mode 100644
index 00000000..3b1d6539
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.error.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To fire ERROR probe
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+ERROR
+{
+ printf("Error fired\n");
+ exit(0);
+}
+
+BEGIN
+{
+ *(char *)NULL;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.errorend.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.errorend.d
new file mode 100644
index 00000000..0bb4a6ef
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/error/tst.errorend.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Flow of ERROR probe
+ *
+ * SECTION: dtrace Provider
+ *
+ */
+
+
+#pragma D option quiet
+
+ERROR
+{
+ printf("Error fired\n");
+ exit(0);
+}
+
+END
+{
+ printf("End fired after exit\n");
+}
+
+BEGIN
+{
+ *(char *)NULL;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.D_PROTO_LEN.noarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.D_PROTO_LEN.noarg.d
new file mode 100644
index 00000000..9a9a8f93
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.D_PROTO_LEN.noarg.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Call exit() without arguments.
+ *
+ * SECTION: Actions and Subroutines/exit()
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ exit()
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.exitarg1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.exitarg1.d
new file mode 100644
index 00000000..d3067d12
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/err.exitarg1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Basic test - call with 1
+ *
+ * SECTION: Actions and Subroutines/exit()
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/tst.basic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/tst.basic1.d
new file mode 100644
index 00000000..24f841c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/exit/tst.basic1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test
+ *
+ * SECTION: Actions and Subroutines/exit()
+ */
+
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/err.D_PDESC_ZERO.notreturn.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/err.D_PDESC_ZERO.notreturn.d
new file mode 100644
index 00000000..5e3d5fa7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/err.D_PDESC_ZERO.notreturn.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: Call fbt provider over non existent function and make
+ * sure it results in compilation error.
+ *
+ * SECTION: FBT Provider/Probes
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ self->traceme = 1;
+}
+
+void bar();
+
+fbt::bar:entry
+{
+ printf("Entering the function\n");
+}
+
+fbt::bar:return
+{
+ printf("Returning the function\n");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.basic.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.basic.d
new file mode 100644
index 00000000..ff6da26f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.basic.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: simple fbt arguments test.
+ *
+ * SECTION: FBT Provider/Probes
+ */
+
+#pragma D option quiet
+
+tick-1
+{
+ self->traceme = 1;
+}
+
+fbt:::
+/self->traceme/
+{
+ printf("The arguments are %u %u %u %u %u %u %u %u\n", arg0, arg1,
+ arg3, arg4, arg5, arg6, arg7, arg8);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionentry.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionentry.d
new file mode 100644
index 00000000..78e107ee
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionentry.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: FBT provider function entry and exit test.
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+#pragma D option statusrate=10ms
+
+fbt::ioctl:entry
+{
+ printf("Entering the ioctl function\n");
+}
+
+fbt::ioctl:return
+{
+ printf("Returning from ioctl function\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionreturnvalue.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionreturnvalue.d
new file mode 100644
index 00000000..6d1b8a8f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.functionreturnvalue.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: Fbt provider return value verify test.
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+#pragma D option statusrate=10ms
+
+fbt::ioctl:return
+{
+ printf("The function return value is stored in %u\n", arg1);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.ioctlargs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.ioctlargs.d
new file mode 100644
index 00000000..c2c7bf04
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.ioctlargs.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: FBT provider arguments scan test.
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+#pragma D option statusrate=10ms
+
+fbt::ioctl:entry
+{
+ printf("Entering the ioctl function\n");
+ printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
+}
+
+fbt::ioctl:return
+{
+ printf("Returning from ioctl function\n");
+ printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offset.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offset.d
new file mode 100644
index 00000000..be2c0d6a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offset.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: FBT provider return value offset verification test.
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+#pragma D option statusrate=10ms
+
+BEGIN
+{
+ self->traceme = 1;
+}
+
+fbt::ioctl:entry
+{
+ printf("Entering the function\n");
+}
+
+fbt::ioctl:return
+{
+ printf("The offset = %u\n", arg0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offsetzero.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offsetzero.d
new file mode 100644
index 00000000..240744bf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.offsetzero.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: FBT provider argument 0 test
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+#pragma D option statusrate=10ms
+
+fbt::ioctl:entry
+{
+ printf("Entering the ioctl function\n");
+ printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
+ exit(0);
+}
+
+fbt::ioctl:return
+{
+ printf("Returning from ioctl function\n");
+ printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return.d
new file mode 100644
index 00000000..b269710e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: simple fbt provider return test.
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ self->traceme = 1;
+}
+
+fbt:::entry
+{
+ printf("Entering the function\n");
+}
+
+fbt:::return
+{
+ printf("Returning the function\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return0.d
new file mode 100644
index 00000000..cadbaa00
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.return0.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: simple fbt provider arg0 and probfunc print test.
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+#pragma D option statusrate=10ms
+
+fbt::ioctl:return
+/arg1 == 0/
+{
+ printf("%s %x returned 0", probefunc, arg0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.tailcall.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.tailcall.d
new file mode 100644
index 00000000..67ef106f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/fbtprovider/tst.tailcall.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION: simple fbt provider tailcall test.
+ *
+ * SECTION: FBT Provider/Probe arguments
+ */
+
+#pragma D option quiet
+#pragma D option statusrate=10ms
+
+fbt::ioctl:entry
+{
+ self->traceme = 1;
+}
+
+fbt:::entry
+/self->traceme/
+{
+ printf("called %s\n", probefunc);
+}
+
+fbt::ioctl:return
+/self->traceme/
+{
+ self->traceme = 0;
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_FUNC_UNDEF.progenyofbad1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_FUNC_UNDEF.progenyofbad1.d
new file mode 100644
index 00000000..bfd1eedf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_FUNC_UNDEF.progenyofbad1.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * progenyof() should accept one argument - a pid
+ *
+ * SECTION: Actions and Subroutines/progenyof()
+ *
+ */
+
+
+BEGIN
+{
+ progencyof(1, 2);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_OP_VFPTR.badop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_OP_VFPTR.badop.d
new file mode 100644
index 00000000..d219bb1f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_OP_VFPTR.badop.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * +=, -= must handle invalid variables.
+ *
+ * SECTION: Types, Operators, and Expressions/Assignment Operators
+ *
+ */
+
+
+int p;
+
+BEGIN
+{
+ p = 1;
+ p -= alloca(10);
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.chillbadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.chillbadarg.d
new file mode 100644
index 00000000..08bd9819
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.chillbadarg.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * chill() should handle a bad argument.
+ *
+ * SECTION: Actions and Subroutines/chill()
+ *
+ */
+
+
+BEGIN
+{
+ chill("badarg");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d
new file mode 100644
index 00000000..5c02378f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * copyout() must handle invalid argument types.
+ *
+ * SECTION: Actions and Subroutines/copyout()
+ *
+ */
+
+
+BEGIN
+{
+ copyout("not_void_*", "not_uinptr_t", "not_size_t");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d
new file mode 100644
index 00000000..4df8d186
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_owned() should handle an invalid argument passed.
+ *
+ * SECTION: Actions and Subroutines/mutex_owned()
+ *
+ */
+
+BEGIN
+{
+ mutex_owned("badarg");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d
new file mode 100644
index 00000000..a3336efe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * raise() should generate an error if any arguments are sent.
+ *
+ * SECTION: Actions and Subroutines/raise()
+ *
+ */
+
+
+BEGIN
+{
+ raise("badarg");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d
new file mode 100644
index 00000000..a2af00f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * alloca() should handle no arguments as an error
+ *
+ * SECTION: Actions and Subroutines/alloca()
+ *
+ */
+
+#pragma D option quiet
+
+
+
+BEGIN
+{
+ ptr = alloca();
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d
new file mode 100644
index 00000000..0cb567a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * breakpoint() should handle arguments passed as an error.
+ *
+ * SECTION: Actions and Subroutines/breakpoint()
+ *
+ */
+
+
+BEGIN
+{
+ breakpoint(1, 2);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoofew.d
new file mode 100644
index 00000000..a0018fa8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoofew.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * chill() should handle no arguments.
+ *
+ * SECTION: Actions and Subroutines/chill()
+ *
+ */
+
+
+BEGIN
+{
+ chill();
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoomany.d
new file mode 100644
index 00000000..f24e9ef1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoomany.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * chill() should handle too many arguments.
+ *
+ * SECTION: Actions and Subroutines/chill()
+ *
+ */
+
+BEGIN
+{
+ chill(1000, 1000, 1000);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrbadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrbadarg.d
new file mode 100644
index 00000000..1f07814b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrbadarg.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * copyoutstr() must handle invalid argument types.
+ *
+ * SECTION: Actions and Subroutines/copyoutstr()
+ *
+ */
+
+
+BEGIN
+{
+ copyoutstr("string", "not_uintptr_t");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrtoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrtoofew.d
new file mode 100644
index 00000000..e01868c0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrtoofew.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Calling copyoutstr() with less than 2 arguments will generate an error
+ *
+ * SECTION: Actions and Subroutines/copyoutstr()
+ *
+ */
+
+
+BEGIN
+{
+ copyoutstr("string");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoofew.d
new file mode 100644
index 00000000..f3706f62
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoofew.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Calling copyout() with less than 3 arguments will generate an error
+ *
+ * SECTION: Actions and Subroutines/copyout()
+ *
+ */
+
+
+BEGIN
+{
+ copyout(0, 20);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoomany.d
new file mode 100644
index 00000000..6fab90d8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoomany.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * copyout() should handle too many arguments passed.
+ *
+ * SECTION: Actions and Subroutines/copyin();
+ * Actions and Subroutines/copyinstr()
+ *
+ */
+
+
+BEGIN
+{
+ copyout((void *)3, (uintptr_t)1000, (size_t)1000, "toomany");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d
new file mode 100644
index 00000000..e878713a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_owned() should handle too few args passed
+ *
+ * SECTION: Actions and Subroutines/mutex_owned()
+ *
+ */
+
+lockstat:genunix:mutex_enter:adaptive-acquire
+{
+ mutex_owned();
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d
new file mode 100644
index 00000000..d3b9ed48
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_owned() should handle too many args passed
+ *
+ * SECTION: Actions and Subroutines/mutex_owned()
+ *
+ */
+
+lockstat:genunix:mutex_enter:adaptive-acquire
+{
+ mutex_owned((kmutex_t *)arg0, 99);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtabadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtabadarg.d
new file mode 100644
index 00000000..6ad1e47b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtabadarg.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_type_adaptive() should handle an invalid argument passed.
+ *
+ * SECTION: Actions and Subroutines/mutex_type_adaptive()
+ *
+ */
+
+
+BEGIN
+{
+ mutex_type_adaptive(trace());
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d
new file mode 100644
index 00000000..98bc5c93
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * mutex_type_adaptive() should handle too few args passed
+ *
+ * SECTION: Actions and Subroutines/mutex_type_adaptive()
+ *
+ */
+
+
+lockstat:genunix:mutex_enter:adaptive-acquire
+{
+ mutex_type_adaptive();
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d
new file mode 100644
index 00000000..e4f259a7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_type_adaptive() should handle too many args passed
+ *
+ * SECTION: Actions and Subroutines/mutex_type_adaptive()
+ *
+ */
+
+
+lockstat:genunix:mutex_enter:adaptive-acquire
+{
+ mutex_type_adaptive((kmutex_t *)arg0, 99);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d
new file mode 100644
index 00000000..87589b48
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * panic() should handle any argument passed as an error.
+ *
+ * SECTION: Actions and Subroutines/panic()
+ *
+ */
+
+
+BEGIN
+{
+ panic("badarg");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d
new file mode 100644
index 00000000..51c8674d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * progenyof() should return an error if the argument is an
+ * incorrect type.
+ *
+ * SECTION: Actions and Subroutines/progenyof()
+ *
+ */
+
+
+BEGIN
+{
+ progenyof(trace());
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d
new file mode 100644
index 00000000..8b605071
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * stop() should generate an error if any arguments are sent.
+ *
+ * SECTION: Actions and Subroutines/stop()
+ *
+ */
+
+
+BEGIN
+{
+ stop("badarg");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d
new file mode 100644
index 00000000..fec5649b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * stringof() accepts a scalar, pointer, or string
+ *
+ * SECTION: Types, Operators, and Expressions/Precedence
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("%s", stringof (trace(0)));
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_VAR_UNDEF.badvar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_VAR_UNDEF.badvar.d
new file mode 100644
index 00000000..bb4fd2d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.D_VAR_UNDEF.badvar.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * +=, -= must handle invalid variables.
+ *
+ * SECTION: Types, Operators, and Expressions/Assignment Operators
+ *
+ */
+
+
+BEGIN
+{
+ p -= trace(0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca.d
new file mode 100644
index 00000000..572daa39
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * memory allocated by alloca() is only valid within the clause
+ * it is allocated.
+ *
+ * SECTION: Actions and Subroutines/alloca()
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ ptr = alloca(sizeof (int));
+}
+
+tick-1
+{
+ bcopy((void *)&`kmem_flags, ptr, sizeof (int));
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca2.d
new file mode 100644
index 00000000..fbbf8e2e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badalloca2.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * alloca() cannot be used to "unconsume" scratch space memory by
+ * accepting a negative offset.
+ *
+ * SECTION: Actions and Subroutines/alloca()
+ *
+ */
+
+BEGIN
+{
+ ptr = alloca(10);
+ ptr = alloca(0xffffffffffffffff);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy.d
new file mode 100644
index 00000000..d7184b0f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * bcopy should not allow a copy to memory that is not scratch memory.
+ *
+ * SECTION: Actions and Subroutines/alloca();
+ * Actions and Subroutines/bcopy()
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ ptr = alloca(sizeof (int));
+
+ /* Attempt a copy from scratch memory to a kernel address */
+
+ bcopy(ptr, (void *)&`kmem_flags, sizeof (int));
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy1.d
new file mode 100644
index 00000000..c29eb2bb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy1.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * bcopy should not copy from one memory location to another
+ * if the memory is not properly allocated
+ *
+ * SECTION: Actions and Subroutines/alloca();
+ * Actions and Subroutines/bcopy()
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ ptr = alloca(0);
+
+ /* Attempt to bcopy to scratch memory that isn't allocated */
+ bcopy((void *)&`kmem_flags, ptr, sizeof (int));
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy2.d
new file mode 100644
index 00000000..6d49e6ec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy2.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * bcopy should not copy from one memory location to another
+ * if the memory is not properly allocated
+ *
+ * SECTION: Actions and Subroutines/bcopy()
+ *
+ */
+
+#pragma D option quiet
+
+int *ptr;
+
+BEGIN
+{
+ /* Attempt to copy to non-scratch memory */
+
+ bcopy((void *)&`kmem_flags, ptr, sizeof (int));
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy3.d
new file mode 100644
index 00000000..c362caad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy3.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * bcopy should not copy from one memory location to another
+ * if the memory is not properly allocated
+ *
+ * SECTION: Actions and Subroutines/bcopy()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ /* Attempt to copy to a NULL address */
+ bcopy((void *)&`kmem_flags, (void *)NULL, sizeof (int));
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy4.d
new file mode 100644
index 00000000..4148ae7b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy4.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * bcopy should not copy from one memory location to another
+ * if the source memory location is not valid.
+ *
+ * SECTION: Actions and Subroutines/alloca();
+ * Actions and Subroutines/bcopy()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ ptr = alloca(sizeof (int));
+
+ /* Attempt to copy from a NULL address */
+ bcopy((void *)NULL, ptr, sizeof (int));
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy5.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy5.d
new file mode 100644
index 00000000..a0cbd5d4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy5.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * bcopy should not copy from one memory location to another
+ * if the source memory location is not valid.
+ *
+ * SECTION: Actions and Subroutines/alloca();
+ * Actions and Subroutines/bcopy()
+ *
+ */
+
+#pragma D option quiet
+
+int *badptr;
+
+BEGIN
+{
+ ptr = alloca(sizeof (int));
+
+ /* Attempt to copy from a invalid address */
+ bcopy(badptr, ptr, sizeof (int));
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy6.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy6.d
new file mode 100644
index 00000000..32770145
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badbcopy6.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ bcopy("bad news", alloca(1), -1);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badchill.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badchill.d
new file mode 100644
index 00000000..b394a88b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.badchill.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ chill(200);
+ chill(((hrtime_t)1 << 63) - 1);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.chillbadarg.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.chillbadarg.ksh
new file mode 100644
index 00000000..98f04dd2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.chillbadarg.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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+# ident "%Z%%M% %I% %E% SMI"
+
+dtrace_script()
+{
+
+ $dtrace -w -s /dev/stdin <<EOF
+
+ /*
+ * ASSERTION:
+ * Verify that chill() refuses args greater than
+ * 500 milliseconds.
+ *
+ * SECTION: Actions and Subroutines/chill()
+ *
+ */
+
+ BEGIN
+ {
+ chill(500000001);
+ exit(1);
+ }
+
+ ERROR
+ {
+ exit(1)
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+dtrace_script &
+child=$!
+
+wait $child
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyout.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyout.d
new file mode 100644
index 00000000..6b9db3b8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyout.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * copyout() should handle invalid args.
+ *
+ * SECTION: Actions and Subroutines/copyout()
+ *
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ i = 3;
+ copyout((void *)i, 0, 5);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutbadaddr.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutbadaddr.ksh
new file mode 100644
index 00000000..de5c47d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutbadaddr.ksh
@@ -0,0 +1,71 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+# ident "%Z%%M% %I% %E% SMI"
+
+
+dtrace_script()
+{
+
+ $dtrace -w -s /dev/stdin <<EOF
+
+ /*
+ * ASSERTION:
+ * Verify that copyout() handles bad addresses.
+ *
+ * SECTION: Actions and Subroutines/copyout()
+ *
+ */
+
+ BEGIN
+ {
+ ptr = alloca(sizeof (char *));
+ copyinto(curpsinfo->pr_envp, sizeof (char *), ptr);
+ copyout(ptr, 0, sizeof (char *));
+ }
+
+ ERROR
+ {
+ exit(1)
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+dtrace_script &
+child=$!
+
+wait $child
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutstrbadaddr.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutstrbadaddr.ksh
new file mode 100644
index 00000000..181702b8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.copyoutstrbadaddr.ksh
@@ -0,0 +1,70 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+# ident "%Z%%M% %I% %E% SMI"
+
+
+dtrace_script()
+{
+
+ $dtrace -w -s /dev/stdin <<EOF
+
+ /*
+ * ASSERTION:
+ * Verify that copyout() handles bad addresses.
+ *
+ * SECTION: Actions and Subroutines/copyout()
+ *
+ */
+
+ BEGIN
+ {
+ ptr = alloca(sizeof (char *));
+ copyinto(curpsinfo->pr_envp, sizeof (char *), ptr);
+ copyout(ptr, 0, sizeof (char *));
+ }
+
+ ERROR
+ {
+ exit(1)
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+dtrace_script &
+child=$!
+
+wait $child
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d
new file mode 100644
index 00000000..81ce643f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+struct in6_addr *ip6a;
+
+BEGIN
+{
+ ip6a = 0;
+
+ printf("%s\n", inet_ntop(AF_INET6, ip6a));
+
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d
new file mode 100644
index 00000000..3f0d8e45
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+
+BEGIN
+{
+ ip4a = 0;
+
+ printf("%s\n", inet_ntoa(ip4a));
+
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d
new file mode 100644
index 00000000..74ce760d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+
+BEGIN
+{
+ ip4a = 0;
+
+ printf("%s\n", inet_ntop(AF_INET, ip4a));
+
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d
new file mode 100644
index 00000000..2731385d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+
+BEGIN
+{
+ this->buf4a = alloca(sizeof (ipaddr_t));
+ ip4a = this->buf4a;
+ *ip4a = htonl(0xc0a80117);
+
+ printf("%s\n", inet_ntop(-1, ip4a));
+
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh
new file mode 100644
index 00000000..72f6b87f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh
@@ -0,0 +1,102 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -wq -o $tmpfile -s /dev/stdin 2> $errfile <<EOF
+ BEGIN
+ {
+ /*
+ * All of these should fail...
+ */
+ freopen("..");
+ freopen("%s", ".");
+ freopen("%c%c", '.', '.');
+ freopen("%c", '.');
+
+ /*
+ * ...so stdout should still be open here.
+ */
+ printf("%d", ++i);
+
+ freopen("%s%s", ".", ".");
+ freopen("%s%s", ".", ".");
+
+ printf("%d", ++i);
+ }
+
+ BEGIN
+ /i == 2/
+ {
+ /*
+ * ...and here.
+ */
+ printf("%d\n", ++i);
+ exit(0);
+ }
+
+ BEGIN
+ {
+ exit(1);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+tmpfile=/tmp/tst.badfreopen.$$
+errfile=/tmp/tst.badfreopen.$$.stderr
+
+script
+status=$?
+
+if [ "$status" -eq 0 ]; then
+ i=`cat $tmpfile`
+
+ if [[ $i != "123" ]]; then
+ echo "$0: unexpected contents in $tmpfile: " \
+ "expected 123, found $i"
+ status=100
+ fi
+
+ i=`wc -l $errfile | nawk '{ print $1 }'`
+
+ if [ "$i" -lt 6 ]; then
+ echo "$0: expected at least 6 lines of stderr, found $i lines"
+ status=101
+ fi
+else
+ cat $errfile > /dev/fd/2
+fi
+
+rm $tmpfile $errfile
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d
new file mode 100644
index 00000000..6fb996c9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d
@@ -0,0 +1,87 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+/*
+ * This test verifies that the basename() and dirname() functions are working
+ * properly. Note that the output of this is a ksh script. When run,
+ * it will give no output if the output is correct.
+ */
+BEGIN
+{
+ dir[i++] = "/foo/bar/baz";
+ dir[i++] = "/foo/bar///baz/";
+ dir[i++] = "/foo/bar/baz/";
+ dir[i++] = "/foo/bar/baz//";
+ dir[i++] = "/foo/bar/baz/.";
+ dir[i++] = "/foo/bar/baz/./";
+ dir[i++] = "/foo/bar/baz/.//";
+ dir[i++] = "foo/bar/baz/";
+ dir[i++] = "/";
+ dir[i++] = "./";
+ dir[i++] = "//";
+ dir[i++] = "/.";
+ dir[i++] = "/./";
+ dir[i++] = "/./.";
+ dir[i++] = "/.//";
+ dir[i++] = ".";
+ dir[i++] = "f";
+ dir[i++] = "f/";
+ dir[i++] = "/////";
+ dir[i++] = "";
+
+ end = i;
+ i = 0;
+
+ printf("#!/usr/bin/ksh\n\n");
+}
+
+tick-1ms
+/i < end/
+{
+ printf("if [ `basename \"%s\"` != \"%s\" ]; then\n",
+ dir[i], basename(dir[i]));
+ printf(" echo \"basename(\\\"%s\\\") is \\\"%s\\\"; ",
+ dir[i], basename(dir[i]));
+ printf("expected \\\"`basename \"%s\"`\"\\\"\n", dir[i]);
+ printf("fi\n\n");
+ printf("if [ `dirname \"%s\"` != \"%s\" ]; then\n",
+ dir[i], dirname(dir[i]));
+ printf(" echo \"dirname(\\\"%s\\\") is \\\"%s\\\"; ",
+ dir[i], dirname(dir[i]));
+ printf("expected \\\"`dirname \"%s\"`\"\\\"\n", dir[i]);
+ printf("fi\n\n");
+ i++;
+}
+
+tick-1ms
+/i == end/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out
new file mode 100755
index 00000000..e16541ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out
@@ -0,0 +1,163 @@
+#!/usr/bin/ksh
+
+if [ `basename "/foo/bar/baz"` != "baz" ]; then
+ echo "basename(\"/foo/bar/baz\") is \"baz\"; expected \"`basename "/foo/bar/baz"`"\"
+fi
+
+if [ `dirname "/foo/bar/baz"` != "/foo/bar" ]; then
+ echo "dirname(\"/foo/bar/baz\") is \"/foo/bar\"; expected \"`dirname "/foo/bar/baz"`"\"
+fi
+
+if [ `basename "/foo/bar///baz/"` != "baz" ]; then
+ echo "basename(\"/foo/bar///baz/\") is \"baz\"; expected \"`basename "/foo/bar///baz/"`"\"
+fi
+
+if [ `dirname "/foo/bar///baz/"` != "/foo/bar" ]; then
+ echo "dirname(\"/foo/bar///baz/\") is \"/foo/bar\"; expected \"`dirname "/foo/bar///baz/"`"\"
+fi
+
+if [ `basename "/foo/bar/baz/"` != "baz" ]; then
+ echo "basename(\"/foo/bar/baz/\") is \"baz\"; expected \"`basename "/foo/bar/baz/"`"\"
+fi
+
+if [ `dirname "/foo/bar/baz/"` != "/foo/bar" ]; then
+ echo "dirname(\"/foo/bar/baz/\") is \"/foo/bar\"; expected \"`dirname "/foo/bar/baz/"`"\"
+fi
+
+if [ `basename "/foo/bar/baz//"` != "baz" ]; then
+ echo "basename(\"/foo/bar/baz//\") is \"baz\"; expected \"`basename "/foo/bar/baz//"`"\"
+fi
+
+if [ `dirname "/foo/bar/baz//"` != "/foo/bar" ]; then
+ echo "dirname(\"/foo/bar/baz//\") is \"/foo/bar\"; expected \"`dirname "/foo/bar/baz//"`"\"
+fi
+
+if [ `basename "/foo/bar/baz/."` != "." ]; then
+ echo "basename(\"/foo/bar/baz/.\") is \".\"; expected \"`basename "/foo/bar/baz/."`"\"
+fi
+
+if [ `dirname "/foo/bar/baz/."` != "/foo/bar/baz" ]; then
+ echo "dirname(\"/foo/bar/baz/.\") is \"/foo/bar/baz\"; expected \"`dirname "/foo/bar/baz/."`"\"
+fi
+
+if [ `basename "/foo/bar/baz/./"` != "." ]; then
+ echo "basename(\"/foo/bar/baz/./\") is \".\"; expected \"`basename "/foo/bar/baz/./"`"\"
+fi
+
+if [ `dirname "/foo/bar/baz/./"` != "/foo/bar/baz" ]; then
+ echo "dirname(\"/foo/bar/baz/./\") is \"/foo/bar/baz\"; expected \"`dirname "/foo/bar/baz/./"`"\"
+fi
+
+if [ `basename "/foo/bar/baz/.//"` != "." ]; then
+ echo "basename(\"/foo/bar/baz/.//\") is \".\"; expected \"`basename "/foo/bar/baz/.//"`"\"
+fi
+
+if [ `dirname "/foo/bar/baz/.//"` != "/foo/bar/baz" ]; then
+ echo "dirname(\"/foo/bar/baz/.//\") is \"/foo/bar/baz\"; expected \"`dirname "/foo/bar/baz/.//"`"\"
+fi
+
+if [ `basename "foo/bar/baz/"` != "baz" ]; then
+ echo "basename(\"foo/bar/baz/\") is \"baz\"; expected \"`basename "foo/bar/baz/"`"\"
+fi
+
+if [ `dirname "foo/bar/baz/"` != "foo/bar" ]; then
+ echo "dirname(\"foo/bar/baz/\") is \"foo/bar\"; expected \"`dirname "foo/bar/baz/"`"\"
+fi
+
+if [ `basename "/"` != "/" ]; then
+ echo "basename(\"/\") is \"/\"; expected \"`basename "/"`"\"
+fi
+
+if [ `dirname "/"` != "/" ]; then
+ echo "dirname(\"/\") is \"/\"; expected \"`dirname "/"`"\"
+fi
+
+if [ `basename "./"` != "." ]; then
+ echo "basename(\"./\") is \".\"; expected \"`basename "./"`"\"
+fi
+
+if [ `dirname "./"` != "." ]; then
+ echo "dirname(\"./\") is \".\"; expected \"`dirname "./"`"\"
+fi
+
+if [ `basename "//"` != "/" ]; then
+ echo "basename(\"//\") is \"/\"; expected \"`basename "//"`"\"
+fi
+
+if [ `dirname "//"` != "/" ]; then
+ echo "dirname(\"//\") is \"/\"; expected \"`dirname "//"`"\"
+fi
+
+if [ `basename "/."` != "." ]; then
+ echo "basename(\"/.\") is \".\"; expected \"`basename "/."`"\"
+fi
+
+if [ `dirname "/."` != "/" ]; then
+ echo "dirname(\"/.\") is \"/\"; expected \"`dirname "/."`"\"
+fi
+
+if [ `basename "/./"` != "." ]; then
+ echo "basename(\"/./\") is \".\"; expected \"`basename "/./"`"\"
+fi
+
+if [ `dirname "/./"` != "/" ]; then
+ echo "dirname(\"/./\") is \"/\"; expected \"`dirname "/./"`"\"
+fi
+
+if [ `basename "/./."` != "." ]; then
+ echo "basename(\"/./.\") is \".\"; expected \"`basename "/./."`"\"
+fi
+
+if [ `dirname "/./."` != "/." ]; then
+ echo "dirname(\"/./.\") is \"/.\"; expected \"`dirname "/./."`"\"
+fi
+
+if [ `basename "/.//"` != "." ]; then
+ echo "basename(\"/.//\") is \".\"; expected \"`basename "/.//"`"\"
+fi
+
+if [ `dirname "/.//"` != "/" ]; then
+ echo "dirname(\"/.//\") is \"/\"; expected \"`dirname "/.//"`"\"
+fi
+
+if [ `basename "."` != "." ]; then
+ echo "basename(\".\") is \".\"; expected \"`basename "."`"\"
+fi
+
+if [ `dirname "."` != "." ]; then
+ echo "dirname(\".\") is \".\"; expected \"`dirname "."`"\"
+fi
+
+if [ `basename "f"` != "f" ]; then
+ echo "basename(\"f\") is \"f\"; expected \"`basename "f"`"\"
+fi
+
+if [ `dirname "f"` != "." ]; then
+ echo "dirname(\"f\") is \".\"; expected \"`dirname "f"`"\"
+fi
+
+if [ `basename "f/"` != "f" ]; then
+ echo "basename(\"f/\") is \"f\"; expected \"`basename "f/"`"\"
+fi
+
+if [ `dirname "f/"` != "." ]; then
+ echo "dirname(\"f/\") is \".\"; expected \"`dirname "f/"`"\"
+fi
+
+if [ `basename "/////"` != "/" ]; then
+ echo "basename(\"/////\") is \"/\"; expected \"`basename "/////"`"\"
+fi
+
+if [ `dirname "/////"` != "/" ]; then
+ echo "dirname(\"/////\") is \"/\"; expected \"`dirname "/////"`"\"
+fi
+
+if [ `basename ""` != "." ]; then
+ echo "basename(\"\") is \".\"; expected \"`basename ""`"\"
+fi
+
+if [ `dirname ""` != "." ]; then
+ echo "dirname(\"\") is \".\"; expected \"`dirname ""`"\"
+fi
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.bcopy.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.bcopy.d
new file mode 100644
index 00000000..8501ff44
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.bcopy.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * bcopy should copy from one memory location to another
+ *
+ * SECTION: Actions and Subroutines/alloca();
+ * Actions and Subroutines/bcopy()
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ ptr = alloca(sizeof (int));
+ bcopy((void *)&`kmem_flags, ptr, sizeof (int));
+ intp = (int *)ptr;
+ ret = (`kmem_flags == *intp) ? 0 : 1;
+}
+
+tick-1
+/ret == 0/
+{
+ exit(0);
+}
+
+tick-1
+/ret == 1/
+{
+ printf("memory address contained 0x%x, expected 0x%x\n",
+ *intp, `kmem_flags);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.chill.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.chill.ksh
new file mode 100644
index 00000000..aae1c688
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.chill.ksh
@@ -0,0 +1,77 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+dtrace_script()
+{
+
+ $dtrace -w -s /dev/stdin <<EOF
+
+ /*
+ * ASSERTION:
+ * Positive test of chill()
+ *
+ * SECTION: Actions and Subroutines/chill()
+ *
+ * NOTES: This test does no verification - it's not possible. So,
+ * we just run this and make sure it runs.
+ */
+
+ BEGIN
+ {
+ i = 0;
+ }
+
+ syscall:::entry
+ /i <= 5/
+ {
+ chill(100000000);
+ i++;
+ }
+
+ syscall:::entry
+ /i > 5/
+ {
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+dtrace_script &
+child=$!
+
+wait $child
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d
new file mode 100644
index 00000000..2f054185
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ path[i++] = "/foo/bar/baz";
+ path[i++] = "/foo/bar///baz/";
+ path[i++] = "/foo/bar/baz/";
+ path[i++] = "/foo/bar/baz//";
+ path[i++] = "/foo/bar/baz/.";
+ path[i++] = "/foo/bar/baz/./";
+ path[i++] = "/foo/bar/../../baz/.//";
+ path[i++] = "foo/bar/./././././baz/";
+ path[i++] = "/foo/bar/baz/../../../../../../";
+ path[i++] = "/../../../../../../";
+ path[i++] = "/./";
+ path[i++] = "/foo/bar/baz/../../bop/bang/../../bar/baz/";
+ path[i++] = "./";
+ path[i++] = "//";
+ path[i++] = "/.";
+ path[i++] = "/./";
+ path[i++] = "/./.";
+ path[i++] = "/.//";
+ path[i++] = ".";
+ path[i++] = "/////";
+ path[i++] = "";
+
+ end = i;
+ i = 0;
+}
+
+tick-1ms
+/i < end/
+{
+ printf("cleanpath(\"%s\") = \"%s\"\n", path[i], cleanpath(path[i]));
+ i++;
+}
+
+tick-1ms
+/i == end/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d.out
new file mode 100644
index 00000000..b8bdc099
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d.out
@@ -0,0 +1,22 @@
+cleanpath("/foo/bar/baz") = "/foo/bar/baz"
+cleanpath("/foo/bar///baz/") = "/foo/bar/baz/"
+cleanpath("/foo/bar/baz/") = "/foo/bar/baz/"
+cleanpath("/foo/bar/baz//") = "/foo/bar/baz/"
+cleanpath("/foo/bar/baz/.") = "/foo/bar/baz/."
+cleanpath("/foo/bar/baz/./") = "/foo/bar/baz/"
+cleanpath("/foo/bar/../../baz/.//") = "/baz/"
+cleanpath("foo/bar/./././././baz/") = "foo/bar/baz/"
+cleanpath("/foo/bar/baz/../../../../../../") = "/"
+cleanpath("/../../../../../../") = "/"
+cleanpath("/./") = "/"
+cleanpath("/foo/bar/baz/../../bop/bang/../../bar/baz/") = "/foo/bar/baz/"
+cleanpath("./") = "./"
+cleanpath("//") = "/"
+cleanpath("/.") = "/."
+cleanpath("/./") = "/"
+cleanpath("/./.") = "/."
+cleanpath("/.//") = "/"
+cleanpath(".") = "."
+cleanpath("/////") = "/"
+cleanpath("") = ""
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyin.d
new file mode 100644
index 00000000..186b9741
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyin.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * This D ditty tests the ability to perform both copyin and copyinstr. We
+ * grab the value or pr_envp, read the first pointer from the user stack,
+ * and then copyinstr the first environment variable and print it.
+ *
+ * SECTION: Actions and Subroutines/copyin();
+ * Actions and Subroutines/copyinstr();
+ * User Process Tracing/copyin() and copyinstr()
+ */
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_ILP32/
+{
+ envp = *(uint32_t *)copyin(curpsinfo->pr_envp, sizeof (uint32_t));
+ printf("envp[0] = \"%s\"", copyinstr(envp));
+ exit(0);
+}
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_LP64/
+{
+ envp = *(uint64_t *)copyin(curpsinfo->pr_envp, sizeof (uint64_t));
+ printf("envp[0] = \"%s\"", copyinstr(envp));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyinto.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyinto.d
new file mode 100644
index 00000000..c282e61d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.copyinto.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * test copyinto by copying the first string of the user's
+ * environment.
+ *
+ * SECTION: Actions and Subroutines/copyinto()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_ILP32/
+{
+ envp = alloca(sizeof (uint32_t));
+ copyinto(curpsinfo->pr_envp, sizeof (uint32_t), envp);
+ printf("envp[0] = \"%s\"", copyinstr(*(uint32_t *)envp));
+ exit(0);
+}
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_LP64/
+{
+ envp = alloca(sizeof (uint64_t));
+ copyinto(curpsinfo->pr_envp, sizeof (uint64_t), envp);
+ printf("envp[0] = \"%s\"", copyinstr(*(uint64_t *)envp));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ddi_pathname.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ddi_pathname.d
new file mode 100644
index 00000000..3716d0ce
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ddi_pathname.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ this->dev = (struct dev_info *)alloca(sizeof (struct dev_info));
+ this->minor1 =
+ (struct ddi_minor_data *)alloca(sizeof (struct ddi_minor_data));
+ this->minor2 =
+ (struct ddi_minor_data *)alloca(sizeof (struct ddi_minor_data));
+ this->minor3 =
+ (struct ddi_minor_data *)alloca(sizeof (struct ddi_minor_data));
+
+ this->minor1->d_minor.dev = 0;
+ this->minor1->next = this->minor2;
+
+ this->minor2->d_minor.dev = 0;
+ this->minor2->next = this->minor3;
+
+ this->minor3->d_minor.dev = 0;
+ this->minor3->next = this->minor1;
+
+ this->dev->devi_minor = this->minor1;
+ trace(ddi_pathname(this->dev, 1));
+}
+
+ERROR
+/arg4 == DTRACEFLT_ILLOP/
+{
+ exit(0);
+}
+
+ERROR
+/arg4 != DTRACEFLT_ILLOP/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.default.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.default.d
new file mode 100644
index 00000000..c4a4e4f3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.default.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Verify that empty clauses are OK.
+ *
+ * SECTION: Actions and Subroutines/Default Action
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 1;
+
+}
+
+syscall:::entry
+{
+
+
+}
+
+tick-1
+/i != 0/
+{
+ exit(0);
+}
+
+
+END
+{
+
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.freopen.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.freopen.ksh
new file mode 100644
index 00000000..f87d6e18
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.freopen.ksh
@@ -0,0 +1,111 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -wq -o $tmpfile -s /dev/stdin $tmpfile <<EOF
+ BEGIN
+ {
+ i = 0;
+ }
+
+ tick-10ms
+ {
+ freopen("%s.%d", \$\$1, i);
+ printf("%d\n", i)
+ }
+
+ tick-10ms
+ /++i == $iter/
+ {
+ freopen("");
+ printf("%d\n", i);
+ exit(0);
+ }
+EOF
+}
+
+cleanup()
+{
+ let i=0
+
+ if [ -f $tmpfile ]; then
+ rm $tmpfile
+ fi
+
+ while [ "$i" -lt "$iter" ]; do
+ if [ -f $tmpfile.$i ]; then
+ rm $tmpfile.$i
+ fi
+ let i=i+1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+tmpfile=/tmp/tst.freopen.$$
+iter=20
+
+script
+status=$?
+
+let i=0
+
+if [ -f $tmpfile.$iter ]; then
+ echo "$0: did not expect to find file: $tmpfile.$iter"
+ cleanup
+ exit 100
+fi
+
+mv $tmpfile $tmpfile.$iter
+let iter=iter+1
+
+while [ "$i" -lt "$iter" ]; do
+ if [ ! -f $tmpfile.$i ]; then
+ echo "$0: did not find expected file: $tmpfile.$i"
+ cleanup
+ exit 101
+ fi
+
+ j=`cat $tmpfile.$i`
+
+ if [ "$i" -ne "$j" ]; then
+ echo "$0: unexpected contents in $tmpfile.$i: " \
+ "expected $i, found $j"
+ cleanup
+ exit 102
+ fi
+
+ rm $tmpfile.$i
+ let i=i+1
+done
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh
new file mode 100644
index 00000000..b02af07b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh
@@ -0,0 +1,64 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -q -o $tmpfile -s /dev/stdin <<EOF
+ tick-10ms
+ {
+ printf("%d\n", i++);
+ }
+
+ tick-10ms
+ /i == 10/
+ {
+ ftruncate();
+ }
+
+ tick-10ms
+ /i == 20/
+ {
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+tmpfile=/tmp/tst.ftruncate.$$
+
+script
+status=$?
+
+cat $tmpfile
+rm $tmpfile
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh.out
new file mode 100644
index 00000000..3360fd26
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh.out
@@ -0,0 +1,11 @@
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.hton.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.hton.d
new file mode 100644
index 00000000..f0118838
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.hton.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test network byte-ordering routines.
+ */
+
+#include <sys/isa_defs.h>
+
+BEGIN
+{
+ before[0] = 0x1122LL;
+ before[1] = 0x11223344LL;
+ before[2] = 0x1122334455667788LL;
+
+#ifdef _LITTLE_ENDIAN
+ after[0] = 0x2211LL;
+ after[1] = 0x44332211LL;
+ after[2] = 0x8877665544332211LL;
+#else
+ after[0] = 0x1122LL;
+ after[1] = 0x11223344LL;
+ after[2] = 0x1122334455667788LL;
+#endif
+}
+
+BEGIN
+/after[0] != htons(before[0])/
+{
+ printf("%x rather than %x", htons(before[0]), after[0]);
+ exit(1);
+}
+
+BEGIN
+/after[0] != ntohs(before[0])/
+{
+ printf("%x rather than %x", ntohs(before[0]), after[0]);
+ exit(1);
+}
+
+BEGIN
+/after[1] != htonl(before[1])/
+{
+ printf("%x rather than %x", htonl(before[1]), after[1]);
+ exit(1);
+}
+
+BEGIN
+/after[1] != ntohl(before[1])/
+{
+ printf("%x rather than %x", ntohl(before[1]), after[1]);
+ exit(1);
+}
+
+BEGIN
+/after[2] != htonll(before[2])/
+{
+ printf("%x rather than %x", htonll(before[2]), after[2]);
+ exit(1);
+}
+
+BEGIN
+/after[2] != ntohll(before[2])/
+{
+ printf("%x rather than %x", ntohll(before[2]), after[2]);
+ exit(1);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d
new file mode 100644
index 00000000..547730a1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d
@@ -0,0 +1,226 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+struct {
+ string str;
+ string substr;
+ int haspos;
+ int position;
+} command[int];
+
+int i;
+
+BEGIN
+{
+ command[i].str = "foobarbaz";
+ command[i].substr = "barbaz";
+ i++;
+
+ command[i].str = "foofoofoo";
+ command[i].substr = "foo";
+ i++;
+
+ command[i].str = "boofoofoo";
+ command[i].substr = "foo";
+ i++;
+
+ command[i].str = "foobarbaz";
+ command[i].substr = "barbazzy";
+ i++;
+
+ command[i].str = "foobar";
+ command[i].substr = "foobar";
+ i++;
+
+ command[i].str = "foobar";
+ command[i].substr = "foobarbaz";
+ i++;
+
+ command[i].str = "";
+ command[i].substr = "foobar";
+ i++;
+
+ command[i].str = "foobar";
+ command[i].substr = "";
+ i++;
+
+ command[i].str = "";
+ command[i].substr = "";
+ i++;
+
+ command[i].str = "foo";
+ command[i].substr = "";
+ i++;
+
+ end = j = k = 0;
+ printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n");
+}
+
+tick-1ms
+/j < i && end == 0/
+{
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = -400;
+ k++;
+
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = -1;
+ k++;
+
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = 0;
+ k++;
+
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = strlen(command[j].str) / 2;
+ k++;
+
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = strlen(command[j].str);
+ k++;
+
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = strlen(command[j].str) + 1;
+ k++;
+
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = strlen(command[j].str) + 2;
+ k++;
+
+ command[i + k].str = command[j].str;
+ command[i + k].substr = command[j].substr;
+ command[i + k].haspos = 1;
+ command[i + k].position = 400;
+ k++;
+
+ j++;
+}
+
+tick-1ms
+/j == i && end == 0/
+{
+ end = k;
+ i = 0;
+}
+
+tick-1ms
+/end != 0 && i < end && !command[i].haspos/
+{
+ this->result = index(command[i].str, command[i].substr);
+
+ printf("\tif (index(\"%s\", \"%s\") != %d) {\n",
+ command[i].str, command[i].substr, this->result);
+ printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\") = ",
+ command[i].str, command[i].substr);
+ printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\"));\n",
+ command[i].str, command[i].substr);
+ printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\") = ",
+ command[i].str, command[i].substr);
+ printf("%d\\n\");\n", this->result);
+ printf("\t\t$failed++;\n");
+ printf("\t}\n\n");
+}
+
+tick-1ms
+/end != 0 && i < end && !command[i].haspos/
+{
+ this->result = rindex(command[i].str, command[i].substr);
+
+ printf("\tif (rindex(\"%s\", \"%s\") != %d) {\n",
+ command[i].str, command[i].substr, this->result);
+ printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\") = ",
+ command[i].str, command[i].substr);
+ printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\"));\n",
+ command[i].str, command[i].substr);
+ printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\") = ",
+ command[i].str, command[i].substr);
+ printf("%d\\n\");\n", this->result);
+ printf("\t\t$failed++;\n");
+ printf("\t}\n\n");
+}
+
+tick-1ms
+/end != 0 && i < end && command[i].haspos/
+{
+ this->result = index(command[i].str,
+ command[i].substr, command[i].position);
+
+ printf("\tif (index(\"%s\", \"%s\", %d) != %d) {\n", command[i].str,
+ command[i].substr, command[i].position, this->result);
+ printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\", %d) = ",
+ command[i].str, command[i].substr, command[i].position);
+ printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\", %d));\n",
+ command[i].str, command[i].substr, command[i].position);
+ printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\", %d) = ",
+ command[i].str, command[i].substr, command[i].position);
+ printf("%d\\n\");\n", this->result);
+ printf("\t\t$failed++;\n");
+ printf("\t}\n\n");
+}
+
+tick-1ms
+/end != 0 && i < end && command[i].haspos/
+{
+ this->result = rindex(command[i].str,
+ command[i].substr, command[i].position);
+
+ printf("\tif (rindex(\"%s\", \"%s\", %d) != %d) {\n", command[i].str,
+ command[i].substr, command[i].position, this->result);
+ printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ",
+ command[i].str, command[i].substr, command[i].position);
+ printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\", %d));\n",
+ command[i].str, command[i].substr, command[i].position);
+ printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ",
+ command[i].str, command[i].substr, command[i].position);
+ printf("%d\\n\");\n", this->result);
+ printf("\t\t$failed++;\n");
+ printf("\t}\n\n");
+}
+
+tick-1ms
+/end != 0 && ++i == end/
+{
+ printf("\texit($failed);\n}\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d.out
new file mode 100755
index 00000000..276576c2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.index.d.out
@@ -0,0 +1,1126 @@
+#!/usr/perl5/bin/perl
+
+BEGIN {
+ if (index("foobarbaz", "barbaz") != 3) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\") = %d\n",
+ index("foobarbaz", "barbaz"));
+ printf(" D => index(\"foobarbaz\", \"barbaz\") = 3\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz") != 3) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\") = %d\n",
+ rindex("foobarbaz", "barbaz"));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\") = 3\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo") != 0) {
+ printf("perl => index(\"foofoofoo\", \"foo\") = %d\n",
+ index("foofoofoo", "foo"));
+ printf(" D => index(\"foofoofoo\", \"foo\") = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo") != 6) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\") = %d\n",
+ rindex("foofoofoo", "foo"));
+ printf(" D => rindex(\"foofoofoo\", \"foo\") = 6\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo") != 3) {
+ printf("perl => index(\"boofoofoo\", \"foo\") = %d\n",
+ index("boofoofoo", "foo"));
+ printf(" D => index(\"boofoofoo\", \"foo\") = 3\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo") != 6) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\") = %d\n",
+ rindex("boofoofoo", "foo"));
+ printf(" D => rindex(\"boofoofoo\", \"foo\") = 6\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy") != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\") = %d\n",
+ index("foobarbaz", "barbazzy"));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\") = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy") != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\") = %d\n",
+ rindex("foobarbaz", "barbazzy"));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\") = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar") != 0) {
+ printf("perl => index(\"foobar\", \"foobar\") = %d\n",
+ index("foobar", "foobar"));
+ printf(" D => index(\"foobar\", \"foobar\") = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar") != 0) {
+ printf("perl => rindex(\"foobar\", \"foobar\") = %d\n",
+ rindex("foobar", "foobar"));
+ printf(" D => rindex(\"foobar\", \"foobar\") = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz") != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\") = %d\n",
+ index("foobar", "foobarbaz"));
+ printf(" D => index(\"foobar\", \"foobarbaz\") = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz") != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\") = %d\n",
+ rindex("foobar", "foobarbaz"));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\") = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar") != -1) {
+ printf("perl => index(\"\", \"foobar\") = %d\n",
+ index("", "foobar"));
+ printf(" D => index(\"\", \"foobar\") = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar") != -1) {
+ printf("perl => rindex(\"\", \"foobar\") = %d\n",
+ rindex("", "foobar"));
+ printf(" D => rindex(\"\", \"foobar\") = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "") != 0) {
+ printf("perl => index(\"foobar\", \"\") = %d\n",
+ index("foobar", ""));
+ printf(" D => index(\"foobar\", \"\") = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "") != 6) {
+ printf("perl => rindex(\"foobar\", \"\") = %d\n",
+ rindex("foobar", ""));
+ printf(" D => rindex(\"foobar\", \"\") = 6\n");
+ $failed++;
+ }
+
+ if (index("", "") != 0) {
+ printf("perl => index(\"\", \"\") = %d\n",
+ index("", ""));
+ printf(" D => index(\"\", \"\") = 0\n");
+ $failed++;
+ }
+
+ if (rindex("", "") != 0) {
+ printf("perl => rindex(\"\", \"\") = %d\n",
+ rindex("", ""));
+ printf(" D => rindex(\"\", \"\") = 0\n");
+ $failed++;
+ }
+
+ if (index("foo", "") != 0) {
+ printf("perl => index(\"foo\", \"\") = %d\n",
+ index("foo", ""));
+ printf(" D => index(\"foo\", \"\") = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foo", "") != 3) {
+ printf("perl => rindex(\"foo\", \"\") = %d\n",
+ rindex("foo", ""));
+ printf(" D => rindex(\"foo\", \"\") = 3\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", -400) != 3) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", -400) = %d\n",
+ index("foobarbaz", "barbaz", -400));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", -400) = 3\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", -400) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", -400) = %d\n",
+ rindex("foobarbaz", "barbaz", -400));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", -1) != 3) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", -1) = %d\n",
+ index("foobarbaz", "barbaz", -1));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", -1) = 3\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", -1) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", -1) = %d\n",
+ rindex("foobarbaz", "barbaz", -1));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", 0) != 3) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", 0) = %d\n",
+ index("foobarbaz", "barbaz", 0));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", 0) = 3\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", 0) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", 0) = %d\n",
+ rindex("foobarbaz", "barbaz", 0));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", 4) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", 4) = %d\n",
+ index("foobarbaz", "barbaz", 4));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", 4) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", 4) != 3) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", 4) = %d\n",
+ rindex("foobarbaz", "barbaz", 4));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", 4) = 3\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", 9) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", 9) = %d\n",
+ index("foobarbaz", "barbaz", 9));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", 9) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", 9) != 3) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", 9) = %d\n",
+ rindex("foobarbaz", "barbaz", 9));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", 9) = 3\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", 10) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", 10) = %d\n",
+ index("foobarbaz", "barbaz", 10));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", 10) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", 10) != 3) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", 10) = %d\n",
+ rindex("foobarbaz", "barbaz", 10));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", 10) = 3\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", 11) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", 11) = %d\n",
+ index("foobarbaz", "barbaz", 11));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", 11) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", 11) != 3) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", 11) = %d\n",
+ rindex("foobarbaz", "barbaz", 11));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", 11) = 3\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbaz", 400) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbaz\", 400) = %d\n",
+ index("foobarbaz", "barbaz", 400));
+ printf(" D => index(\"foobarbaz\", \"barbaz\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbaz", 400) != 3) {
+ printf("perl => rindex(\"foobarbaz\", \"barbaz\", 400) = %d\n",
+ rindex("foobarbaz", "barbaz", 400));
+ printf(" D => rindex(\"foobarbaz\", \"barbaz\", 400) = 3\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", -400) != 0) {
+ printf("perl => index(\"foofoofoo\", \"foo\", -400) = %d\n",
+ index("foofoofoo", "foo", -400));
+ printf(" D => index(\"foofoofoo\", \"foo\", -400) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", -400) != -1) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", -400) = %d\n",
+ rindex("foofoofoo", "foo", -400));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", -1) != 0) {
+ printf("perl => index(\"foofoofoo\", \"foo\", -1) = %d\n",
+ index("foofoofoo", "foo", -1));
+ printf(" D => index(\"foofoofoo\", \"foo\", -1) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", -1) != -1) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", -1) = %d\n",
+ rindex("foofoofoo", "foo", -1));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", 0) != 0) {
+ printf("perl => index(\"foofoofoo\", \"foo\", 0) = %d\n",
+ index("foofoofoo", "foo", 0));
+ printf(" D => index(\"foofoofoo\", \"foo\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", 0) != 0) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", 0) = %d\n",
+ rindex("foofoofoo", "foo", 0));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", 4) != 6) {
+ printf("perl => index(\"foofoofoo\", \"foo\", 4) = %d\n",
+ index("foofoofoo", "foo", 4));
+ printf(" D => index(\"foofoofoo\", \"foo\", 4) = 6\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", 4) != 3) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", 4) = %d\n",
+ rindex("foofoofoo", "foo", 4));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", 4) = 3\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", 9) != -1) {
+ printf("perl => index(\"foofoofoo\", \"foo\", 9) = %d\n",
+ index("foofoofoo", "foo", 9));
+ printf(" D => index(\"foofoofoo\", \"foo\", 9) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", 9) != 6) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", 9) = %d\n",
+ rindex("foofoofoo", "foo", 9));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", 9) = 6\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", 10) != -1) {
+ printf("perl => index(\"foofoofoo\", \"foo\", 10) = %d\n",
+ index("foofoofoo", "foo", 10));
+ printf(" D => index(\"foofoofoo\", \"foo\", 10) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", 10) != 6) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", 10) = %d\n",
+ rindex("foofoofoo", "foo", 10));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", 10) = 6\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", 11) != -1) {
+ printf("perl => index(\"foofoofoo\", \"foo\", 11) = %d\n",
+ index("foofoofoo", "foo", 11));
+ printf(" D => index(\"foofoofoo\", \"foo\", 11) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", 11) != 6) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", 11) = %d\n",
+ rindex("foofoofoo", "foo", 11));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", 11) = 6\n");
+ $failed++;
+ }
+
+ if (index("foofoofoo", "foo", 400) != -1) {
+ printf("perl => index(\"foofoofoo\", \"foo\", 400) = %d\n",
+ index("foofoofoo", "foo", 400));
+ printf(" D => index(\"foofoofoo\", \"foo\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foofoofoo", "foo", 400) != 6) {
+ printf("perl => rindex(\"foofoofoo\", \"foo\", 400) = %d\n",
+ rindex("foofoofoo", "foo", 400));
+ printf(" D => rindex(\"foofoofoo\", \"foo\", 400) = 6\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", -400) != 3) {
+ printf("perl => index(\"boofoofoo\", \"foo\", -400) = %d\n",
+ index("boofoofoo", "foo", -400));
+ printf(" D => index(\"boofoofoo\", \"foo\", -400) = 3\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", -400) != -1) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", -400) = %d\n",
+ rindex("boofoofoo", "foo", -400));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", -1) != 3) {
+ printf("perl => index(\"boofoofoo\", \"foo\", -1) = %d\n",
+ index("boofoofoo", "foo", -1));
+ printf(" D => index(\"boofoofoo\", \"foo\", -1) = 3\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", -1) != -1) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", -1) = %d\n",
+ rindex("boofoofoo", "foo", -1));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", 0) != 3) {
+ printf("perl => index(\"boofoofoo\", \"foo\", 0) = %d\n",
+ index("boofoofoo", "foo", 0));
+ printf(" D => index(\"boofoofoo\", \"foo\", 0) = 3\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", 0) != -1) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", 0) = %d\n",
+ rindex("boofoofoo", "foo", 0));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", 4) != 6) {
+ printf("perl => index(\"boofoofoo\", \"foo\", 4) = %d\n",
+ index("boofoofoo", "foo", 4));
+ printf(" D => index(\"boofoofoo\", \"foo\", 4) = 6\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", 4) != 3) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", 4) = %d\n",
+ rindex("boofoofoo", "foo", 4));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", 4) = 3\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", 9) != -1) {
+ printf("perl => index(\"boofoofoo\", \"foo\", 9) = %d\n",
+ index("boofoofoo", "foo", 9));
+ printf(" D => index(\"boofoofoo\", \"foo\", 9) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", 9) != 6) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", 9) = %d\n",
+ rindex("boofoofoo", "foo", 9));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", 9) = 6\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", 10) != -1) {
+ printf("perl => index(\"boofoofoo\", \"foo\", 10) = %d\n",
+ index("boofoofoo", "foo", 10));
+ printf(" D => index(\"boofoofoo\", \"foo\", 10) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", 10) != 6) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", 10) = %d\n",
+ rindex("boofoofoo", "foo", 10));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", 10) = 6\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", 11) != -1) {
+ printf("perl => index(\"boofoofoo\", \"foo\", 11) = %d\n",
+ index("boofoofoo", "foo", 11));
+ printf(" D => index(\"boofoofoo\", \"foo\", 11) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", 11) != 6) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", 11) = %d\n",
+ rindex("boofoofoo", "foo", 11));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", 11) = 6\n");
+ $failed++;
+ }
+
+ if (index("boofoofoo", "foo", 400) != -1) {
+ printf("perl => index(\"boofoofoo\", \"foo\", 400) = %d\n",
+ index("boofoofoo", "foo", 400));
+ printf(" D => index(\"boofoofoo\", \"foo\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("boofoofoo", "foo", 400) != 6) {
+ printf("perl => rindex(\"boofoofoo\", \"foo\", 400) = %d\n",
+ rindex("boofoofoo", "foo", 400));
+ printf(" D => rindex(\"boofoofoo\", \"foo\", 400) = 6\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", -400) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", -400) = %d\n",
+ index("foobarbaz", "barbazzy", -400));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", -400) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", -400) = %d\n",
+ rindex("foobarbaz", "barbazzy", -400));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", -1) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", -1) = %d\n",
+ index("foobarbaz", "barbazzy", -1));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", -1) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", -1) = %d\n",
+ rindex("foobarbaz", "barbazzy", -1));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", 0) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", 0) = %d\n",
+ index("foobarbaz", "barbazzy", 0));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", 0) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 0) = %d\n",
+ rindex("foobarbaz", "barbazzy", 0));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", 4) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", 4) = %d\n",
+ index("foobarbaz", "barbazzy", 4));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", 4) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", 4) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 4) = %d\n",
+ rindex("foobarbaz", "barbazzy", 4));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 4) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", 9) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", 9) = %d\n",
+ index("foobarbaz", "barbazzy", 9));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", 9) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", 9) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 9) = %d\n",
+ rindex("foobarbaz", "barbazzy", 9));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 9) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", 10) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", 10) = %d\n",
+ index("foobarbaz", "barbazzy", 10));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", 10) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", 10) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 10) = %d\n",
+ rindex("foobarbaz", "barbazzy", 10));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 10) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", 11) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", 11) = %d\n",
+ index("foobarbaz", "barbazzy", 11));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", 11) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", 11) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 11) = %d\n",
+ rindex("foobarbaz", "barbazzy", 11));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 11) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobarbaz", "barbazzy", 400) != -1) {
+ printf("perl => index(\"foobarbaz\", \"barbazzy\", 400) = %d\n",
+ index("foobarbaz", "barbazzy", 400));
+ printf(" D => index(\"foobarbaz\", \"barbazzy\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobarbaz", "barbazzy", 400) != -1) {
+ printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 400) = %d\n",
+ rindex("foobarbaz", "barbazzy", 400));
+ printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", -400) != 0) {
+ printf("perl => index(\"foobar\", \"foobar\", -400) = %d\n",
+ index("foobar", "foobar", -400));
+ printf(" D => index(\"foobar\", \"foobar\", -400) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", -400) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobar\", -400) = %d\n",
+ rindex("foobar", "foobar", -400));
+ printf(" D => rindex(\"foobar\", \"foobar\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", -1) != 0) {
+ printf("perl => index(\"foobar\", \"foobar\", -1) = %d\n",
+ index("foobar", "foobar", -1));
+ printf(" D => index(\"foobar\", \"foobar\", -1) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", -1) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobar\", -1) = %d\n",
+ rindex("foobar", "foobar", -1));
+ printf(" D => rindex(\"foobar\", \"foobar\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", 0) != 0) {
+ printf("perl => index(\"foobar\", \"foobar\", 0) = %d\n",
+ index("foobar", "foobar", 0));
+ printf(" D => index(\"foobar\", \"foobar\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", 0) != 0) {
+ printf("perl => rindex(\"foobar\", \"foobar\", 0) = %d\n",
+ rindex("foobar", "foobar", 0));
+ printf(" D => rindex(\"foobar\", \"foobar\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", 3) != -1) {
+ printf("perl => index(\"foobar\", \"foobar\", 3) = %d\n",
+ index("foobar", "foobar", 3));
+ printf(" D => index(\"foobar\", \"foobar\", 3) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", 3) != 0) {
+ printf("perl => rindex(\"foobar\", \"foobar\", 3) = %d\n",
+ rindex("foobar", "foobar", 3));
+ printf(" D => rindex(\"foobar\", \"foobar\", 3) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", 6) != -1) {
+ printf("perl => index(\"foobar\", \"foobar\", 6) = %d\n",
+ index("foobar", "foobar", 6));
+ printf(" D => index(\"foobar\", \"foobar\", 6) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", 6) != 0) {
+ printf("perl => rindex(\"foobar\", \"foobar\", 6) = %d\n",
+ rindex("foobar", "foobar", 6));
+ printf(" D => rindex(\"foobar\", \"foobar\", 6) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", 7) != -1) {
+ printf("perl => index(\"foobar\", \"foobar\", 7) = %d\n",
+ index("foobar", "foobar", 7));
+ printf(" D => index(\"foobar\", \"foobar\", 7) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", 7) != 0) {
+ printf("perl => rindex(\"foobar\", \"foobar\", 7) = %d\n",
+ rindex("foobar", "foobar", 7));
+ printf(" D => rindex(\"foobar\", \"foobar\", 7) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", 8) != -1) {
+ printf("perl => index(\"foobar\", \"foobar\", 8) = %d\n",
+ index("foobar", "foobar", 8));
+ printf(" D => index(\"foobar\", \"foobar\", 8) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", 8) != 0) {
+ printf("perl => rindex(\"foobar\", \"foobar\", 8) = %d\n",
+ rindex("foobar", "foobar", 8));
+ printf(" D => rindex(\"foobar\", \"foobar\", 8) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobar", 400) != -1) {
+ printf("perl => index(\"foobar\", \"foobar\", 400) = %d\n",
+ index("foobar", "foobar", 400));
+ printf(" D => index(\"foobar\", \"foobar\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobar", 400) != 0) {
+ printf("perl => rindex(\"foobar\", \"foobar\", 400) = %d\n",
+ rindex("foobar", "foobar", 400));
+ printf(" D => rindex(\"foobar\", \"foobar\", 400) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", -400) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", -400) = %d\n",
+ index("foobar", "foobarbaz", -400));
+ printf(" D => index(\"foobar\", \"foobarbaz\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", -400) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", -400) = %d\n",
+ rindex("foobar", "foobarbaz", -400));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", -1) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", -1) = %d\n",
+ index("foobar", "foobarbaz", -1));
+ printf(" D => index(\"foobar\", \"foobarbaz\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", -1) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", -1) = %d\n",
+ rindex("foobar", "foobarbaz", -1));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", 0) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", 0) = %d\n",
+ index("foobar", "foobarbaz", 0));
+ printf(" D => index(\"foobar\", \"foobarbaz\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", 0) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", 0) = %d\n",
+ rindex("foobar", "foobarbaz", 0));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", 3) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", 3) = %d\n",
+ index("foobar", "foobarbaz", 3));
+ printf(" D => index(\"foobar\", \"foobarbaz\", 3) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", 3) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", 3) = %d\n",
+ rindex("foobar", "foobarbaz", 3));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", 3) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", 6) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", 6) = %d\n",
+ index("foobar", "foobarbaz", 6));
+ printf(" D => index(\"foobar\", \"foobarbaz\", 6) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", 6) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", 6) = %d\n",
+ rindex("foobar", "foobarbaz", 6));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", 6) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", 7) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", 7) = %d\n",
+ index("foobar", "foobarbaz", 7));
+ printf(" D => index(\"foobar\", \"foobarbaz\", 7) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", 7) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", 7) = %d\n",
+ rindex("foobar", "foobarbaz", 7));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", 7) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", 8) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", 8) = %d\n",
+ index("foobar", "foobarbaz", 8));
+ printf(" D => index(\"foobar\", \"foobarbaz\", 8) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", 8) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", 8) = %d\n",
+ rindex("foobar", "foobarbaz", 8));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", 8) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "foobarbaz", 400) != -1) {
+ printf("perl => index(\"foobar\", \"foobarbaz\", 400) = %d\n",
+ index("foobar", "foobarbaz", 400));
+ printf(" D => index(\"foobar\", \"foobarbaz\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "foobarbaz", 400) != -1) {
+ printf("perl => rindex(\"foobar\", \"foobarbaz\", 400) = %d\n",
+ rindex("foobar", "foobarbaz", 400));
+ printf(" D => rindex(\"foobar\", \"foobarbaz\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", -400) != -1) {
+ printf("perl => index(\"\", \"foobar\", -400) = %d\n",
+ index("", "foobar", -400));
+ printf(" D => index(\"\", \"foobar\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", -400) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", -400) = %d\n",
+ rindex("", "foobar", -400));
+ printf(" D => rindex(\"\", \"foobar\", -400) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", -1) != -1) {
+ printf("perl => index(\"\", \"foobar\", -1) = %d\n",
+ index("", "foobar", -1));
+ printf(" D => index(\"\", \"foobar\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", -1) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", -1) = %d\n",
+ rindex("", "foobar", -1));
+ printf(" D => rindex(\"\", \"foobar\", -1) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", 0) != -1) {
+ printf("perl => index(\"\", \"foobar\", 0) = %d\n",
+ index("", "foobar", 0));
+ printf(" D => index(\"\", \"foobar\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", 0) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", 0) = %d\n",
+ rindex("", "foobar", 0));
+ printf(" D => rindex(\"\", \"foobar\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", 0) != -1) {
+ printf("perl => index(\"\", \"foobar\", 0) = %d\n",
+ index("", "foobar", 0));
+ printf(" D => index(\"\", \"foobar\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", 0) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", 0) = %d\n",
+ rindex("", "foobar", 0));
+ printf(" D => rindex(\"\", \"foobar\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", 0) != -1) {
+ printf("perl => index(\"\", \"foobar\", 0) = %d\n",
+ index("", "foobar", 0));
+ printf(" D => index(\"\", \"foobar\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", 0) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", 0) = %d\n",
+ rindex("", "foobar", 0));
+ printf(" D => rindex(\"\", \"foobar\", 0) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", 1) != -1) {
+ printf("perl => index(\"\", \"foobar\", 1) = %d\n",
+ index("", "foobar", 1));
+ printf(" D => index(\"\", \"foobar\", 1) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", 1) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", 1) = %d\n",
+ rindex("", "foobar", 1));
+ printf(" D => rindex(\"\", \"foobar\", 1) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", 2) != -1) {
+ printf("perl => index(\"\", \"foobar\", 2) = %d\n",
+ index("", "foobar", 2));
+ printf(" D => index(\"\", \"foobar\", 2) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", 2) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", 2) = %d\n",
+ rindex("", "foobar", 2));
+ printf(" D => rindex(\"\", \"foobar\", 2) = -1\n");
+ $failed++;
+ }
+
+ if (index("", "foobar", 400) != -1) {
+ printf("perl => index(\"\", \"foobar\", 400) = %d\n",
+ index("", "foobar", 400));
+ printf(" D => index(\"\", \"foobar\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (rindex("", "foobar", 400) != -1) {
+ printf("perl => rindex(\"\", \"foobar\", 400) = %d\n",
+ rindex("", "foobar", 400));
+ printf(" D => rindex(\"\", \"foobar\", 400) = -1\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", -400) != 0) {
+ printf("perl => index(\"foobar\", \"\", -400) = %d\n",
+ index("foobar", "", -400));
+ printf(" D => index(\"foobar\", \"\", -400) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", -400) != 0) {
+ printf("perl => rindex(\"foobar\", \"\", -400) = %d\n",
+ rindex("foobar", "", -400));
+ printf(" D => rindex(\"foobar\", \"\", -400) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", -1) != 0) {
+ printf("perl => index(\"foobar\", \"\", -1) = %d\n",
+ index("foobar", "", -1));
+ printf(" D => index(\"foobar\", \"\", -1) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", -1) != 0) {
+ printf("perl => rindex(\"foobar\", \"\", -1) = %d\n",
+ rindex("foobar", "", -1));
+ printf(" D => rindex(\"foobar\", \"\", -1) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", 0) != 0) {
+ printf("perl => index(\"foobar\", \"\", 0) = %d\n",
+ index("foobar", "", 0));
+ printf(" D => index(\"foobar\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", 0) != 0) {
+ printf("perl => rindex(\"foobar\", \"\", 0) = %d\n",
+ rindex("foobar", "", 0));
+ printf(" D => rindex(\"foobar\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", 3) != 3) {
+ printf("perl => index(\"foobar\", \"\", 3) = %d\n",
+ index("foobar", "", 3));
+ printf(" D => index(\"foobar\", \"\", 3) = 3\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", 3) != 3) {
+ printf("perl => rindex(\"foobar\", \"\", 3) = %d\n",
+ rindex("foobar", "", 3));
+ printf(" D => rindex(\"foobar\", \"\", 3) = 3\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", 6) != 6) {
+ printf("perl => index(\"foobar\", \"\", 6) = %d\n",
+ index("foobar", "", 6));
+ printf(" D => index(\"foobar\", \"\", 6) = 6\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", 6) != 6) {
+ printf("perl => rindex(\"foobar\", \"\", 6) = %d\n",
+ rindex("foobar", "", 6));
+ printf(" D => rindex(\"foobar\", \"\", 6) = 6\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", 7) != 6) {
+ printf("perl => index(\"foobar\", \"\", 7) = %d\n",
+ index("foobar", "", 7));
+ printf(" D => index(\"foobar\", \"\", 7) = 6\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", 7) != 6) {
+ printf("perl => rindex(\"foobar\", \"\", 7) = %d\n",
+ rindex("foobar", "", 7));
+ printf(" D => rindex(\"foobar\", \"\", 7) = 6\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", 8) != 6) {
+ printf("perl => index(\"foobar\", \"\", 8) = %d\n",
+ index("foobar", "", 8));
+ printf(" D => index(\"foobar\", \"\", 8) = 6\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", 8) != 6) {
+ printf("perl => rindex(\"foobar\", \"\", 8) = %d\n",
+ rindex("foobar", "", 8));
+ printf(" D => rindex(\"foobar\", \"\", 8) = 6\n");
+ $failed++;
+ }
+
+ if (index("foobar", "", 400) != 6) {
+ printf("perl => index(\"foobar\", \"\", 400) = %d\n",
+ index("foobar", "", 400));
+ printf(" D => index(\"foobar\", \"\", 400) = 6\n");
+ $failed++;
+ }
+
+ if (rindex("foobar", "", 400) != 6) {
+ printf("perl => rindex(\"foobar\", \"\", 400) = %d\n",
+ rindex("foobar", "", 400));
+ printf(" D => rindex(\"foobar\", \"\", 400) = 6\n");
+ $failed++;
+ }
+
+ if (index("", "", -400) != 0) {
+ printf("perl => index(\"\", \"\", -400) = %d\n",
+ index("", "", -400));
+ printf(" D => index(\"\", \"\", -400) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("", "", -400) != 0) {
+ printf("perl => rindex(\"\", \"\", -400) = %d\n",
+ rindex("", "", -400));
+ printf(" D => rindex(\"\", \"\", -400) = 0\n");
+ $failed++;
+ }
+
+ if (index("", "", -1) != 0) {
+ printf("perl => index(\"\", \"\", -1) = %d\n",
+ index("", "", -1));
+ printf(" D => index(\"\", \"\", -1) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("", "", -1) != 0) {
+ printf("perl => rindex(\"\", \"\", -1) = %d\n",
+ rindex("", "", -1));
+ printf(" D => rindex(\"\", \"\", -1) = 0\n");
+ $failed++;
+ }
+
+ if (index("", "", 0) != 0) {
+ printf("perl => index(\"\", \"\", 0) = %d\n",
+ index("", "", 0));
+ printf(" D => index(\"\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("", "", 0) != 0) {
+ printf("perl => rindex(\"\", \"\", 0) = %d\n",
+ rindex("", "", 0));
+ printf(" D => rindex(\"\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (index("", "", 0) != 0) {
+ printf("perl => index(\"\", \"\", 0) = %d\n",
+ index("", "", 0));
+ printf(" D => index(\"\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("", "", 0) != 0) {
+ printf("perl => rindex(\"\", \"\", 0) = %d\n",
+ rindex("", "", 0));
+ printf(" D => rindex(\"\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (index("", "", 0) != 0) {
+ printf("perl => index(\"\", \"\", 0) = %d\n",
+ index("", "", 0));
+ printf(" D => index(\"\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("", "", 0) != 0) {
+ printf("perl => rindex(\"\", \"\", 0) = %d\n",
+ rindex("", "", 0));
+ printf(" D => rindex(\"\", \"\", 0) = 0\n");
+ $failed++;
+ }
+
+ if (index("", "", 1) != 0) {
+ printf("perl => index(\"\", \"\", 1) = %d\n",
+ index("", "", 1));
+ printf(" D => index(\"\", \"\", 1) = 0\n");
+ $failed++;
+ }
+
+ if (rindex("", "", 1) != 0) {
+ printf("perl => rindex(\"\", \"\", 1) = %d\n",
+ rindex("", "", 1));
+ printf(" D => rindex(\"\", \"\", 1) = 0\n");
+ $failed++;
+ }
+
+ exit($failed);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d
new file mode 100644
index 00000000..cf7459d3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+ipaddr_t *ip4b;
+ipaddr_t *ip4c;
+ipaddr_t *ip4d;
+
+BEGIN
+{
+ this->buf4a = alloca(sizeof (ipaddr_t));
+ this->buf4b = alloca(sizeof (ipaddr_t));
+ this->buf4c = alloca(sizeof (ipaddr_t));
+ this->buf4d = alloca(sizeof (ipaddr_t));
+ ip4a = this->buf4a;
+ ip4b = this->buf4b;
+ ip4c = this->buf4c;
+ ip4d = this->buf4d;
+
+ *ip4a = htonl(0xc0a80117);
+ *ip4b = htonl(0x7f000001);
+ *ip4c = htonl(0xffffffff);
+ *ip4d = htonl(0x00000000);
+
+ printf("%s\n", inet_ntoa(ip4a));
+ printf("%s\n", inet_ntoa(ip4b));
+ printf("%s\n", inet_ntoa(ip4c));
+ printf("%s\n", inet_ntoa(ip4d));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out
new file mode 100644
index 00000000..ab535e78
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out
@@ -0,0 +1,5 @@
+192.168.1.23
+127.0.0.1
+255.255.255.255
+0.0.0.0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d
new file mode 100644
index 00000000..9a00eb78
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d
@@ -0,0 +1,95 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+struct in6_addr *ip6a;
+struct in6_addr *ip6b;
+struct in6_addr *ip6c;
+struct in6_addr *ip6d;
+struct in6_addr *ip6e;
+struct in6_addr *ip6f;
+struct in6_addr *ip6g;
+
+BEGIN
+{
+ this->buf6a = alloca(sizeof (struct in6_addr));
+ this->buf6b = alloca(sizeof (struct in6_addr));
+ this->buf6c = alloca(sizeof (struct in6_addr));
+ this->buf6d = alloca(sizeof (struct in6_addr));
+ this->buf6e = alloca(sizeof (struct in6_addr));
+ this->buf6f = alloca(sizeof (struct in6_addr));
+ this->buf6g = alloca(sizeof (struct in6_addr));
+ ip6a = this->buf6a;
+ ip6b = this->buf6b;
+ ip6c = this->buf6c;
+ ip6d = this->buf6d;
+ ip6e = this->buf6e;
+ ip6f = this->buf6f;
+ ip6g = this->buf6g;
+
+ ip6a->_S6_un._S6_u8[0] = 0xfe;
+ ip6a->_S6_un._S6_u8[1] = 0x80;
+ ip6a->_S6_un._S6_u8[8] = 0x02;
+ ip6a->_S6_un._S6_u8[9] = 0x14;
+ ip6a->_S6_un._S6_u8[10] = 0x4f;
+ ip6a->_S6_un._S6_u8[11] = 0xff;
+ ip6a->_S6_un._S6_u8[12] = 0xfe;
+ ip6a->_S6_un._S6_u8[13] = 0x0b;
+ ip6a->_S6_un._S6_u8[14] = 0x76;
+ ip6a->_S6_un._S6_u8[15] = 0xc8;
+ ip6b->_S6_un._S6_u8[0] = 0x10;
+ ip6b->_S6_un._S6_u8[1] = 0x80;
+ ip6b->_S6_un._S6_u8[10] = 0x08;
+ ip6b->_S6_un._S6_u8[11] = 0x08;
+ ip6b->_S6_un._S6_u8[13] = 0x20;
+ ip6b->_S6_un._S6_u8[13] = 0x0c;
+ ip6b->_S6_un._S6_u8[14] = 0x41;
+ ip6b->_S6_un._S6_u8[15] = 0x7a;
+ ip6c->_S6_un._S6_u8[15] = 0x01;
+ ip6e->_S6_un._S6_u8[12] = 0x7f;
+ ip6e->_S6_un._S6_u8[15] = 0x01;
+ ip6f->_S6_un._S6_u8[10] = 0xff;
+ ip6f->_S6_un._S6_u8[11] = 0xff;
+ ip6f->_S6_un._S6_u8[12] = 0x7f;
+ ip6f->_S6_un._S6_u8[15] = 0x01;
+ ip6g->_S6_un._S6_u8[10] = 0xff;
+ ip6g->_S6_un._S6_u8[11] = 0xfe;
+ ip6g->_S6_un._S6_u8[12] = 0x7f;
+ ip6g->_S6_un._S6_u8[15] = 0x01;
+
+ printf("%s\n", inet_ntoa6(ip6a));
+ printf("%s\n", inet_ntoa6(ip6b));
+ printf("%s\n", inet_ntoa6(ip6c));
+ printf("%s\n", inet_ntoa6(ip6d));
+ printf("%s\n", inet_ntoa6(ip6e));
+ printf("%s\n", inet_ntoa6(ip6f));
+ printf("%s\n", inet_ntoa6(ip6g));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out
new file mode 100644
index 00000000..d87c1f61
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out
@@ -0,0 +1,8 @@
+fe80::214:4fff:fe0b:76c8
+1080::808:c:417a
+::1
+::
+127.0.0.1
+127.0.0.1
+::fffe:7f00:1
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d
new file mode 100644
index 00000000..c1e4b1bb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d
@@ -0,0 +1,135 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+ipaddr_t *ip4b;
+ipaddr_t *ip4c;
+ipaddr_t *ip4d;
+struct in6_addr *ip6a;
+struct in6_addr *ip6b;
+struct in6_addr *ip6c;
+struct in6_addr *ip6d;
+struct in6_addr *ip6e;
+struct in6_addr *ip6f;
+struct in6_addr *ip6g;
+struct in6_addr *ip6h;
+
+BEGIN
+{
+ this->buf4a = alloca(sizeof (ipaddr_t));
+ this->buf4b = alloca(sizeof (ipaddr_t));
+ this->buf4c = alloca(sizeof (ipaddr_t));
+ this->buf4d = alloca(sizeof (ipaddr_t));
+ this->buf6a = alloca(sizeof (struct in6_addr));
+ this->buf6b = alloca(sizeof (struct in6_addr));
+ this->buf6c = alloca(sizeof (struct in6_addr));
+ this->buf6d = alloca(sizeof (struct in6_addr));
+ this->buf6e = alloca(sizeof (struct in6_addr));
+ this->buf6f = alloca(sizeof (struct in6_addr));
+ this->buf6g = alloca(sizeof (struct in6_addr));
+ this->buf6h = alloca(sizeof (struct in6_addr));
+ ip4a = this->buf4a;
+ ip4b = this->buf4b;
+ ip4c = this->buf4c;
+ ip4d = this->buf4d;
+ ip6a = this->buf6a;
+ ip6b = this->buf6b;
+ ip6c = this->buf6c;
+ ip6d = this->buf6d;
+ ip6e = this->buf6e;
+ ip6f = this->buf6f;
+ ip6g = this->buf6g;
+ ip6h = this->buf6h;
+
+ *ip4a = htonl(0xc0a80117);
+ *ip4b = htonl(0x7f000001);
+ *ip4c = htonl(0xffffffff);
+ *ip4d = htonl(0x00000000);
+ ip6a->_S6_un._S6_u8[0] = 0xfe;
+ ip6a->_S6_un._S6_u8[1] = 0x80;
+ ip6a->_S6_un._S6_u8[8] = 0x02;
+ ip6a->_S6_un._S6_u8[9] = 0x14;
+ ip6a->_S6_un._S6_u8[10] = 0x4f;
+ ip6a->_S6_un._S6_u8[11] = 0xff;
+ ip6a->_S6_un._S6_u8[12] = 0xfe;
+ ip6a->_S6_un._S6_u8[13] = 0x0b;
+ ip6a->_S6_un._S6_u8[14] = 0x76;
+ ip6a->_S6_un._S6_u8[15] = 0xc8;
+ ip6b->_S6_un._S6_u8[0] = 0x10;
+ ip6b->_S6_un._S6_u8[1] = 0x80;
+ ip6b->_S6_un._S6_u8[10] = 0x08;
+ ip6b->_S6_un._S6_u8[11] = 0x08;
+ ip6b->_S6_un._S6_u8[13] = 0x20;
+ ip6b->_S6_un._S6_u8[13] = 0x0c;
+ ip6b->_S6_un._S6_u8[14] = 0x41;
+ ip6b->_S6_un._S6_u8[15] = 0x7a;
+ ip6c->_S6_un._S6_u8[15] = 0x01;
+ ip6e->_S6_un._S6_u8[12] = 0x7f;
+ ip6e->_S6_un._S6_u8[15] = 0x01;
+ ip6f->_S6_un._S6_u8[10] = 0xff;
+ ip6f->_S6_un._S6_u8[11] = 0xff;
+ ip6f->_S6_un._S6_u8[12] = 0x7f;
+ ip6f->_S6_un._S6_u8[15] = 0x01;
+ ip6g->_S6_un._S6_u8[10] = 0xff;
+ ip6g->_S6_un._S6_u8[11] = 0xfe;
+ ip6g->_S6_un._S6_u8[12] = 0x7f;
+ ip6g->_S6_un._S6_u8[15] = 0x01;
+ ip6h->_S6_un._S6_u8[0] = 0xff;
+ ip6h->_S6_un._S6_u8[1] = 0xff;
+ ip6h->_S6_un._S6_u8[2] = 0xff;
+ ip6h->_S6_un._S6_u8[3] = 0xff;
+ ip6h->_S6_un._S6_u8[4] = 0xff;
+ ip6h->_S6_un._S6_u8[5] = 0xff;
+ ip6h->_S6_un._S6_u8[6] = 0xff;
+ ip6h->_S6_un._S6_u8[7] = 0xff;
+ ip6h->_S6_un._S6_u8[8] = 0xff;
+ ip6h->_S6_un._S6_u8[9] = 0xff;
+ ip6h->_S6_un._S6_u8[10] = 0xff;
+ ip6h->_S6_un._S6_u8[11] = 0xff;
+ ip6h->_S6_un._S6_u8[12] = 0xff;
+ ip6h->_S6_un._S6_u8[13] = 0xff;
+ ip6h->_S6_un._S6_u8[14] = 0xff;
+ ip6h->_S6_un._S6_u8[15] = 0xff;
+
+ printf("%s\n", inet_ntop(AF_INET, ip4a));
+ printf("%s\n", inet_ntop(AF_INET, ip4b));
+ printf("%s\n", inet_ntop(AF_INET, ip4c));
+ printf("%s\n", inet_ntop(AF_INET, ip4d));
+ printf("%s\n", inet_ntop(AF_INET6, ip6a));
+ printf("%s\n", inet_ntop(AF_INET6, ip6b));
+ printf("%s\n", inet_ntop(AF_INET6, ip6c));
+ printf("%s\n", inet_ntop(AF_INET6, ip6d));
+ printf("%s\n", inet_ntop(AF_INET6, ip6e));
+ printf("%s\n", inet_ntop(AF_INET6, ip6f));
+ printf("%s\n", inet_ntop(AF_INET6, ip6g));
+ printf("%s\n", inet_ntop(AF_INET6, ip6h));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out
new file mode 100644
index 00000000..7c8311c2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out
@@ -0,0 +1,13 @@
+192.168.1.23
+127.0.0.1
+255.255.255.255
+0.0.0.0
+fe80::214:4fff:fe0b:76c8
+1080::808:c:417a
+::1
+::
+::127.0.0.1
+::ffff:127.0.0.1
+::fffe:7f00:1
+ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d
new file mode 100644
index 00000000..03e295a7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("%s\n", lltostr(0));
+ printf("%s\n", lltostr(1));
+ printf("%s\n", lltostr(-1));
+ printf("%s\n", lltostr(123456789));
+ printf("%s\n", lltostr(-123456789));
+ printf("%s\n", lltostr(1LL << 62));
+ printf("%s\n", lltostr(-(1LL << 62)));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d.out
new file mode 100644
index 00000000..e007c648
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d.out
@@ -0,0 +1,8 @@
+0
+1
+-1
+123456789
+-123456789
+4611686018427387904
+-4611686018427387904
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owned.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owned.d
new file mode 100644
index 00000000..b4aa84f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owned.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_owned() should return a non-zero value if the calling
+ * thread currently holds the mutex.
+ *
+ * SECTION: Actions and Subroutines/mutex_owned()
+ */
+
+#pragma D option quiet
+
+lockstat:::adaptive-acquire
+{
+ this->owned = mutex_owned((kmutex_t *)arg0);
+ this->owner = mutex_owner((kmutex_t *)arg0);
+}
+
+lockstat:::adaptive-acquire
+/!this->owned/
+{
+ printf("mutex_owned() returned 0, expected non-zero\n");
+ exit(1);
+}
+
+lockstat:::adaptive-acquire
+/this->owner != curthread/
+{
+ printf("current thread is not current owner of owned lock\n");
+ exit(1);
+}
+
+lockstat:::adaptive-acquire
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d
new file mode 100644
index 00000000..a021d502
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_owner() should return a pointer to the kernel thread holding
+ * the mutex.
+ *
+ * SECTION: Actions and Subroutines/mutex_owner()
+ *
+ * NOTES: This assertion can't be verified so we'll just call it.
+ */
+
+
+
+
+#pragma D option quiet
+
+kthread_t *ptr;
+
+BEGIN
+{
+ i = 0;
+}
+
+lockstat:genunix:mutex_enter:adaptive-acquire
+{
+
+ ptr = mutex_owner((kmutex_t *)arg0);
+ i++;
+}
+
+tick-1
+/i > 5/
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d
new file mode 100644
index 00000000..c13abab2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * mutex_type_adaptive() should return a non-zero value if the
+ * mutex is an adaptive one.
+ *
+ * SECTION: Actions and Subroutines/mutex_type_adaptive()
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ ret = -99;
+}
+
+mutex_enter:adaptive-acquire
+{
+ ret = mutex_type_adaptive((kmutex_t *)arg0);
+ i++;
+}
+
+tick-1
+/ret == 1/
+{
+ exit(0);
+}
+
+tick-1
+/i == 100 && ret == 0/
+{
+ printf("mutex_type_adaptive returned 0, expected non-zero\n");
+ exit(1);
+}
+
+tick-1
+/i == 100 && ret == -99/
+{
+ printf("No adaptive_mutexs called in the time this test was run.\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.progenyof.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.progenyof.d
new file mode 100644
index 00000000..02911580
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.progenyof.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * progenyof() should return non-zero if the pid passed is in the
+ # progeny of the calling process.
+ *
+ * SECTION: Actions and Subroutines/progenyof()
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ res_1 = -1;
+ res_2 = -1;
+ res_3 = -1;
+
+ res_1 = progenyof($ppid); /* this will always be true */
+ res_2 = progenyof($ppid + 1); /* this will always be false */
+ res_3 = progenyof(1); /* this will always be true */
+}
+
+
+tick-1
+/res_1 > 0 && res_2 == 0 && res_3 > 0/
+{
+ exit(0);
+}
+
+tick-1
+/res_1 <= 0 || res_2 != 0 || res_3 <= 0/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.rand.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.rand.d
new file mode 100644
index 00000000..51f44911
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.rand.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test rand()
+ *
+ * SECTION: Actions and Subroutines/rand()
+ */
+
+
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-1
+/i != 10/
+{
+ i++;
+ trace(rand());
+}
+
+tick-1
+/i == 10/
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d
new file mode 100644
index 00000000..8dc8f89b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ str = "fooeyfooeyfoo";
+ this->success = 0;
+
+ c = 'f';
+ printf("strchr(\"%s\", '%c') = \"%s\"\n", str, c, strchr(str, c));
+ printf("strrchr(\"%s\", '%c') = \"%s\"\n", str, c, strrchr(str, c));
+
+ c = 'y';
+ printf("strchr(\"%s\", '%c') = \"%s\"\n", str, c, strchr(str, c));
+ printf("strrchr(\"%s\", '%c') = \"%s\"\n", str, c, strrchr(str, c));
+
+ printf("strrchr(\"%s\", '%c') = \"%s\"\n", strchr(str, c), c,
+ strrchr(strchr(str, c), c));
+
+ this->success = 1;
+}
+
+BEGIN
+/!this->success/
+{
+ exit(1);
+}
+
+BEGIN
+/strchr(str, 'a') != NULL/
+{
+ exit(2);
+}
+
+BEGIN
+/strrchr(str, 'a') != NULL/
+{
+ exit(3);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d.out
new file mode 100644
index 00000000..328b5318
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strchr.d.out
@@ -0,0 +1,6 @@
+strchr("fooeyfooeyfoo", 'f') = "fooeyfooeyfoo"
+strrchr("fooeyfooeyfoo", 'f') = "foo"
+strchr("fooeyfooeyfoo", 'y') = "yfooeyfoo"
+strrchr("fooeyfooeyfoo", 'y') = "yfoo"
+strrchr("yfooeyfoo", 'y') = "yfoo"
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d
new file mode 100644
index 00000000..392c18a6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("%s\n", strjoin("foo", "baz"));
+ printf("%s\n", strjoin("foo", ""));
+ printf("%s\n", strjoin("", "baz"));
+ printf("%s\n", strjoin("", ""));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d.out
new file mode 100644
index 00000000..65728694
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d.out
@@ -0,0 +1,5 @@
+foobaz
+foo
+baz
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d
new file mode 100644
index 00000000..0c81b7a8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d
@@ -0,0 +1,89 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ str = "foobarbarbazbarbop";
+ this->success = 0;
+
+ c = str;
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ c = "baz";
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ c = "bar";
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ c = "bazbarbop";
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ c = "barba";
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n",
+ strstr(str, "baz"), strstr(str, "zba"),
+ strstr(strstr(str, "baz"), strstr(str, "zba")));
+
+ c = "";
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ str = "";
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ str = "f";
+ c = "f";
+ printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c));
+
+ this->success = 1;
+}
+
+BEGIN
+/!this->success/
+{
+ exit(1);
+}
+
+BEGIN
+/strstr(str, "barbarf") != NULL/
+{
+ exit(2);
+}
+
+BEGIN
+/strstr(str, "foobarbarbazbarbopp") != NULL/
+{
+ exit(3);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d.out
new file mode 100644
index 00000000..f9121dbc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strstr.d.out
@@ -0,0 +1,10 @@
+strstr("foobarbarbazbarbop", "foobarbarbazbarbop") = "foobarbarbazbarbop"
+strstr("foobarbarbazbarbop", "baz") = "bazbarbop"
+strstr("foobarbarbazbarbop", "bar") = "barbarbazbarbop"
+strstr("foobarbarbazbarbop", "bazbarbop") = "bazbarbop"
+strstr("foobarbarbazbarbop", "barba") = "barbarbazbarbop"
+strstr("bazbarbop", "zbarbop") = "zbarbop"
+strstr("foobarbarbazbarbop", "") = "foobarbarbazbarbop"
+strstr("", "") = ""
+strstr("f", "f") = "f"
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d
new file mode 100644
index 00000000..47092ba4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d
@@ -0,0 +1,146 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ this->str = ",,,Carrots,,Barley,Oatmeal,,,Beans,";
+}
+
+BEGIN
+/(this->field = strtok(this->str, ",")) == NULL/
+{
+ exit(1);
+}
+
+BEGIN
+{
+ printf("%s\n", this->field);
+}
+
+BEGIN
+/(this->field = strtok(NULL, ",")) == NULL/
+{
+ exit(2);
+}
+
+BEGIN
+{
+ printf("%s\n", this->field);
+}
+
+BEGIN
+/(this->field = strtok(NULL, ",")) == NULL/
+{
+ exit(3);
+}
+
+BEGIN
+{
+ printf("%s\n", this->field);
+}
+
+BEGIN
+/(this->field = strtok(NULL, ",")) == NULL/
+{
+ exit(4);
+}
+
+BEGIN
+{
+ printf("%s\n", this->field);
+}
+
+BEGIN
+/(self->a = strtok(NULL, ",")) != NULL/
+{
+ printf("unexpected field: %s\n", this->field);
+ exit(5);
+}
+
+struct {
+ string s1;
+ string s2;
+ string result;
+} command[int];
+
+int i;
+
+BEGIN
+{
+ command[i].s1 = "";
+ command[i].s2 = "";
+ command[i].result = "";
+ i++;
+
+ command[i].s1 = "foo";
+ command[i].s2 = "";
+ command[i].result = command[i].s1;
+ i++;
+
+ command[i].s1 = "foobar";
+ command[i].s2 = "o";
+ command[i].result = "f";
+ i++;
+
+ command[i].s1 = "oobar";
+ command[i].s2 = "o";
+ command[i].result = "bar";
+ i++;
+
+ command[i].s1 = "foo";
+ command[i].s2 = "bar";
+ command[i].result = command[i].s1;
+ i++;
+
+ command[i].s1 = "";
+ command[i].s2 = "foo";
+ command[i].result = "";
+ i++;
+
+ end = i;
+ i = 0;
+}
+
+tick-1ms
+/i < end &&
+ (this->result = strtok(command[i].s1, command[i].s2)) != command[i].result/
+{
+ printf("strtok(\"%s\", \"%s\") = \"%s\", expected \"%s\"",
+ command[i].s1, command[i].s2,
+ this->result != NULL ? this->result : "<null>",
+ command[i].result != NULL ? command[i].result : "<null>");
+ exit(6 + i);
+}
+
+tick-1ms
+/++i == end/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d.out
new file mode 100644
index 00000000..4bc37274
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok.d.out
@@ -0,0 +1,5 @@
+Carrots
+Barley
+Oatmeal
+Beans
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok_null.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok_null.d
new file mode 100644
index 00000000..6de4f97d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.strtok_null.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Test that a strtok(NULL, ...) without first calling strtok(string, ...)
+ * produces an error
+ */
+
+BEGIN
+{
+ trace(strtok(NULL, "!"));
+ exit(1);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d
new file mode 100644
index 00000000..edee6442
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d
@@ -0,0 +1,231 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+#pragma D option strsize=32
+
+struct {
+ int index;
+ int length;
+ int nolen;
+ int alt;
+} command[int];
+
+int i;
+
+BEGIN
+{
+ str = "foobarbazbop";
+ str2 = "";
+ altstr = "CRAIG: Positioned them, I don't ";
+ altstr2 = "know... I'm fairly wide guy.";
+
+ command[i].index = 3;
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = 300;
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = -10;
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = 0;
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = 1;
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = strlen(str) - 1;
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = strlen(str);
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = strlen(str) + 1;
+ command[i].nolen = 1;
+ i++;
+
+ command[i].index = 8;
+ command[i].length = 20;
+ i++;
+
+ command[i].index = 4;
+ command[i].length = 4;
+ i++;
+
+ command[i].index = 5;
+ command[i].length = strlen(str) - command[i].index + 1;
+ i++;
+
+ command[i].index = 5;
+ command[i].length = strlen(str) - command[i].index + 2;
+ i++;
+
+ command[i].index = 400;
+ command[i].length = 20;
+ i++;
+
+ command[i].index = 400;
+ command[i].length = 0;
+ i++;
+
+ command[i].index = 400;
+ command[i].length = -1;
+ i++;
+
+ command[i].index = 3;
+ command[i].length = 0;
+ i++;
+
+ command[i].index = 3;
+ command[i].length = -1;
+ i++;
+
+ command[i].index = 3;
+ command[i].length = -4;
+ i++;
+
+ command[i].index = 3;
+ command[i].length = -20;
+ i++;
+
+ command[i].index = -10;
+ command[i].length = -5;
+ i++;
+
+ command[i].index = 0;
+ command[i].length = 400;
+ i++;
+
+ command[i].index = -1;
+ command[i].length = 400;
+ i++;
+
+ command[i].index = -1;
+ command[i].length = 0;
+ i++;
+
+ command[i].index = -1;
+ command[i].length = -1;
+ i++;
+
+ command[i].index = -2 * strlen(str);
+ command[i].length = 2 * strlen(str);
+ i++;
+
+ command[i].index = -2 * strlen(str);
+ command[i].length = strlen(str);
+ i++;
+
+ command[i].index = -2 * strlen(str);
+ command[i].length = strlen(str) + 1;
+ i++;
+
+ command[i].index = -1 * strlen(str);
+ command[i].length = strlen(str);
+ i++;
+
+ command[i].index = -1 * strlen(str);
+ command[i].length = strlen(str) - 1;
+ i++;
+
+ command[i].index = 100;
+ command[i].length = 10;
+ command[i].alt = 1;
+ i++;
+
+ command[i].index = 100;
+ command[i].nolen = 1;
+ command[i].alt = 1;
+ i++;
+
+ end = i;
+ i = 0;
+ printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n");
+
+}
+
+tick-1ms
+/i < end && command[i].nolen/
+{
+ this->str = command[i].alt ? altstr : str;
+ this->str2 = command[i].alt ? altstr2 : str2;
+ this->result = substr(command[i].alt ?
+ "CRAIG: Positioned them, I don't know... I'm fairly wide guy." :
+ str, command[i].index);
+
+ printf("\tif (substr(\"%s%s\", %d) ne \"%s\") {\n",
+ this->str, this->str2, command[i].index, this->result);
+
+ printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d) = ",
+ this->str, this->str2, command[i].index);
+ printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d));\n",
+ this->str, this->str2, command[i].index);
+ printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d) = ",
+ this->str, this->str2, command[i].index);
+ printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result);
+ printf("\t\t$failed++;\n");
+ printf("\t}\n\n");
+}
+
+tick-1ms
+/i < end && !command[i].nolen/
+{
+ this->str = command[i].alt ? altstr : str;
+ this->str2 = command[i].alt ? altstr2 : str2;
+ this->result = substr(command[i].alt ?
+ "CRAIG: Positioned them, I don't know... I'm fairly wide guy." :
+ str, command[i].index, command[i].length);
+
+ printf("\tif (substr(\"%s%s\", %d, %d) ne \"%s\") {\n",
+ this->str, this->str2, command[i].index, command[i].length,
+ this->result);
+ printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d, %d) = ",
+ this->str, this->str2, command[i].index, command[i].length);
+ printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d, %d));\n",
+ this->str, this->str2, command[i].index, command[i].length);
+ printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d, %d) = ",
+ this->str, this->str2, command[i].index, command[i].length);
+ printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result);
+ printf("\t\t$failed++;\n");
+ printf("\t}\n\n");
+}
+
+tick-1ms
+/++i == end/
+{
+ printf("\texit($failed);\n}\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d.out
new file mode 100755
index 00000000..5b498ef3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substr.d.out
@@ -0,0 +1,254 @@
+#!/usr/perl5/bin/perl
+
+BEGIN {
+ if (substr("foobarbazbop", 3) ne "barbazbop") {
+ printf("perl => substr(\"foobarbazbop\", 3) = \"%s\"\n",
+ substr("foobarbazbop", 3));
+ printf(" D => substr(\"foobarbazbop\", 3) = \"%s\"\n",
+ "barbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 300) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 300) = \"%s\"\n",
+ substr("foobarbazbop", 300));
+ printf(" D => substr(\"foobarbazbop\", 300) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -10) ne "obarbazbop") {
+ printf("perl => substr(\"foobarbazbop\", -10) = \"%s\"\n",
+ substr("foobarbazbop", -10));
+ printf(" D => substr(\"foobarbazbop\", -10) = \"%s\"\n",
+ "obarbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 0) ne "foobarbazbop") {
+ printf("perl => substr(\"foobarbazbop\", 0) = \"%s\"\n",
+ substr("foobarbazbop", 0));
+ printf(" D => substr(\"foobarbazbop\", 0) = \"%s\"\n",
+ "foobarbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 1) ne "oobarbazbop") {
+ printf("perl => substr(\"foobarbazbop\", 1) = \"%s\"\n",
+ substr("foobarbazbop", 1));
+ printf(" D => substr(\"foobarbazbop\", 1) = \"%s\"\n",
+ "oobarbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 11) ne "p") {
+ printf("perl => substr(\"foobarbazbop\", 11) = \"%s\"\n",
+ substr("foobarbazbop", 11));
+ printf(" D => substr(\"foobarbazbop\", 11) = \"%s\"\n",
+ "p");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 12) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 12) = \"%s\"\n",
+ substr("foobarbazbop", 12));
+ printf(" D => substr(\"foobarbazbop\", 12) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 13) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 13) = \"%s\"\n",
+ substr("foobarbazbop", 13));
+ printf(" D => substr(\"foobarbazbop\", 13) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 8, 20) ne "zbop") {
+ printf("perl => substr(\"foobarbazbop\", 8, 20) = \"%s\"\n",
+ substr("foobarbazbop", 8, 20));
+ printf(" D => substr(\"foobarbazbop\", 8, 20) = \"%s\"\n",
+ "zbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 4, 4) ne "arba") {
+ printf("perl => substr(\"foobarbazbop\", 4, 4) = \"%s\"\n",
+ substr("foobarbazbop", 4, 4));
+ printf(" D => substr(\"foobarbazbop\", 4, 4) = \"%s\"\n",
+ "arba");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 5, 8) ne "rbazbop") {
+ printf("perl => substr(\"foobarbazbop\", 5, 8) = \"%s\"\n",
+ substr("foobarbazbop", 5, 8));
+ printf(" D => substr(\"foobarbazbop\", 5, 8) = \"%s\"\n",
+ "rbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 5, 9) ne "rbazbop") {
+ printf("perl => substr(\"foobarbazbop\", 5, 9) = \"%s\"\n",
+ substr("foobarbazbop", 5, 9));
+ printf(" D => substr(\"foobarbazbop\", 5, 9) = \"%s\"\n",
+ "rbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 400, 20) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 400, 20) = \"%s\"\n",
+ substr("foobarbazbop", 400, 20));
+ printf(" D => substr(\"foobarbazbop\", 400, 20) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 400, 0) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 400, 0) = \"%s\"\n",
+ substr("foobarbazbop", 400, 0));
+ printf(" D => substr(\"foobarbazbop\", 400, 0) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 400, -1) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 400, -1) = \"%s\"\n",
+ substr("foobarbazbop", 400, -1));
+ printf(" D => substr(\"foobarbazbop\", 400, -1) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 3, 0) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 3, 0) = \"%s\"\n",
+ substr("foobarbazbop", 3, 0));
+ printf(" D => substr(\"foobarbazbop\", 3, 0) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 3, -1) ne "barbazbo") {
+ printf("perl => substr(\"foobarbazbop\", 3, -1) = \"%s\"\n",
+ substr("foobarbazbop", 3, -1));
+ printf(" D => substr(\"foobarbazbop\", 3, -1) = \"%s\"\n",
+ "barbazbo");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 3, -4) ne "barba") {
+ printf("perl => substr(\"foobarbazbop\", 3, -4) = \"%s\"\n",
+ substr("foobarbazbop", 3, -4));
+ printf(" D => substr(\"foobarbazbop\", 3, -4) = \"%s\"\n",
+ "barba");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 3, -20) ne "") {
+ printf("perl => substr(\"foobarbazbop\", 3, -20) = \"%s\"\n",
+ substr("foobarbazbop", 3, -20));
+ printf(" D => substr(\"foobarbazbop\", 3, -20) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -10, -5) ne "obarb") {
+ printf("perl => substr(\"foobarbazbop\", -10, -5) = \"%s\"\n",
+ substr("foobarbazbop", -10, -5));
+ printf(" D => substr(\"foobarbazbop\", -10, -5) = \"%s\"\n",
+ "obarb");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", 0, 400) ne "foobarbazbop") {
+ printf("perl => substr(\"foobarbazbop\", 0, 400) = \"%s\"\n",
+ substr("foobarbazbop", 0, 400));
+ printf(" D => substr(\"foobarbazbop\", 0, 400) = \"%s\"\n",
+ "foobarbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -1, 400) ne "p") {
+ printf("perl => substr(\"foobarbazbop\", -1, 400) = \"%s\"\n",
+ substr("foobarbazbop", -1, 400));
+ printf(" D => substr(\"foobarbazbop\", -1, 400) = \"%s\"\n",
+ "p");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -1, 0) ne "") {
+ printf("perl => substr(\"foobarbazbop\", -1, 0) = \"%s\"\n",
+ substr("foobarbazbop", -1, 0));
+ printf(" D => substr(\"foobarbazbop\", -1, 0) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -1, -1) ne "") {
+ printf("perl => substr(\"foobarbazbop\", -1, -1) = \"%s\"\n",
+ substr("foobarbazbop", -1, -1));
+ printf(" D => substr(\"foobarbazbop\", -1, -1) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -24, 24) ne "foobarbazbop") {
+ printf("perl => substr(\"foobarbazbop\", -24, 24) = \"%s\"\n",
+ substr("foobarbazbop", -24, 24));
+ printf(" D => substr(\"foobarbazbop\", -24, 24) = \"%s\"\n",
+ "foobarbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -24, 12) ne "") {
+ printf("perl => substr(\"foobarbazbop\", -24, 12) = \"%s\"\n",
+ substr("foobarbazbop", -24, 12));
+ printf(" D => substr(\"foobarbazbop\", -24, 12) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -24, 13) ne "f") {
+ printf("perl => substr(\"foobarbazbop\", -24, 13) = \"%s\"\n",
+ substr("foobarbazbop", -24, 13));
+ printf(" D => substr(\"foobarbazbop\", -24, 13) = \"%s\"\n",
+ "f");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -12, 12) ne "foobarbazbop") {
+ printf("perl => substr(\"foobarbazbop\", -12, 12) = \"%s\"\n",
+ substr("foobarbazbop", -12, 12));
+ printf(" D => substr(\"foobarbazbop\", -12, 12) = \"%s\"\n",
+ "foobarbazbop");
+ $failed++;
+ }
+
+ if (substr("foobarbazbop", -12, 11) ne "foobarbazbo") {
+ printf("perl => substr(\"foobarbazbop\", -12, 11) = \"%s\"\n",
+ substr("foobarbazbop", -12, 11));
+ printf(" D => substr(\"foobarbazbop\", -12, 11) = \"%s\"\n",
+ "foobarbazbo");
+ $failed++;
+ }
+
+ if (substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100, 10) ne "") {
+ printf("perl => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100, 10) = \"%s\"\n",
+ substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100, 10));
+ printf(" D => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100, 10) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ if (substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100) ne "") {
+ printf("perl => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100) = \"%s\"\n",
+ substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100));
+ printf(" D => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100) = \"%s\"\n",
+ "");
+ $failed++;
+ }
+
+ exit($failed);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d
new file mode 100644
index 00000000..2c025410
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+#pragma D option aggsortkey
+
+/*
+ * This is to check that we're correctly null-terminating the result of the
+ * substr() subroutine.
+ */
+
+tick-1ms
+/i++ > 1000/
+{
+ exit(0);
+}
+
+tick-1ms
+{
+ @[substr((i & 1) ? "Bryan is smart" : "he's not a dummy", 0,
+ (i & 1) ? 8 : 18)] = count();
+}
+
+END
+{
+ printa("%s\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d.out
new file mode 100644
index 00000000..26c19aa2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d.out
@@ -0,0 +1,3 @@
+Bryan is
+he's not a dummy
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d
new file mode 100644
index 00000000..b7ffbfa4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+#pragma D option destructive
+
+BEGIN
+{
+ this->a = 9;
+ this->b = -2;
+
+ system("echo %s %d %d", "foo", this->a, this->b);
+ system("ping localhost");
+ system("echo %d", ++this->a);
+ system("ping localhost");
+ system("echo %d", ++this->a);
+ system("ping localhost");
+ system("echo %d", ++this->a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d.out
new file mode 100644
index 00000000..cd0d735f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/funcs/tst.system.d.out
@@ -0,0 +1,8 @@
+foo 9 -2
+localhost is alive
+10
+localhost is alive
+11
+localhost is alive
+12
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_ADDROF_LVAL.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_ADDROF_LVAL.d
new file mode 100644
index 00000000..8f5d694a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_ADDROF_LVAL.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * & can not be applied to a non-lvalue
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ *
+ */
+
+BEGIN
+{
+ trace(&1);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_EMPTY.empty.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_EMPTY.empty.d
new file mode 100644
index 00000000..929ccc69
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/err.D_EMPTY.empty.d
@@ -0,0 +1,34 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test the "empty translation unit" error path.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.clauses.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.clauses.d
new file mode 100644
index 00000000..a9930292
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.clauses.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test the kinds of probe definition clause grammar rules.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations;
+ * Program Structure/Actions
+ */
+
+
+BEGIN
+{}
+
+BEGIN
+/1/
+{}
+
+tick-1
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.stmts.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.stmts.d
new file mode 100644
index 00000000..03a015ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/grammar/tst.stmts.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test the various kinds of D probe description statement
+ * rules in the grammar.
+ *
+ * SECTION: Program Structure/Probe Descriptions
+ *
+ */
+
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-1
+/i != 20/
+{
+ i++;
+ x = 0;
+ stack();
+ @a = count();
+ @b = max(x);
+ @c[x] = count();
+ @d[x] = max(x);
+}
+
+tick-1
+/i = 20/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef1.d
new file mode 100644
index 00000000..39f2996a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef1.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Test handling of an inline definition that overrides a previous
+ * definition of an inline definition.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES:
+ *
+ */
+
+inline int foo = timestamp;
+inline int foo = 8;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef2.d
new file mode 100644
index 00000000..1df59080
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef2.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Test handling of an inline definition that overrides a previous
+ * definition of a dtrace built-in function.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES:
+ *
+ */
+
+inline int rand = 7;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_IDENT_UNDEF.recur.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_IDENT_UNDEF.recur.d
new file mode 100644
index 00000000..95522d0e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_IDENT_UNDEF.recur.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * D program to test recursive inline definitions. This script should
+ * properly detect that foo is undefined on the right-hand side and fail.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES:
+ *
+ */
+
+inline int foo = foo + 3;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef1.d
new file mode 100644
index 00000000..a42afb74
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef1.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Attempt to create an invalid inline definition by creating an
+ * inline of a function type. This should fail to compile.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES:
+ *
+ */
+
+inline cyc_func_t i = "i am a cyclic function";
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef2.d
new file mode 100644
index 00000000..9a246b4b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef2.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Attempt to create an invalid inline definition by creating an
+ * inline of incompatible types. This should fail to compile.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES:
+ *
+ */
+
+inline int i = "i am a string";
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.badxlate.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.badxlate.d
new file mode 100644
index 00000000..963b6048
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.badxlate.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Test an invalid inline definition of a translator. An inlined translation
+ * must have the same type as the translator output.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES:
+ *
+ */
+
+inline vfs_t *invalid = xlate<psinfo_t>(curthread->t_procp);
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineDataAssign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineDataAssign.d
new file mode 100644
index 00000000..c7ab62fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineDataAssign.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Declare different types of inline data types.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES: The commented lines defining floats and doubles should be uncommented
+ * once the functionality is provided.
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+inline char new_char = 'c';
+inline short new_short = 10;
+inline int new_int = 100;
+inline long new_long = 1234567890;
+inline long long new_long_long = 1234512345;
+inline int8_t new_int8 = 'p';
+inline int16_t new_int16 = 20;
+inline int32_t new_int32 = 200;
+inline int64_t new_int64 = 2000000;
+inline intptr_t new_intptr = 0x12345;
+inline uint8_t new_uint8 = 'q';
+inline uint16_t new_uint16 = 30;
+inline uint32_t new_uint32 = 300;
+inline uint64_t new_uint64 = 3000000;
+inline uintptr_t new_uintptr = 0x67890;
+/* inline float new_float = 1.23456;
+inline double new_double = 2.34567890;
+inline long double new_long_double = 3.567890123;
+*/
+
+inline int * pointer = &`kmem_flags;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineExpression.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineExpression.d
new file mode 100644
index 00000000..d67d3f27
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineExpression.d
@@ -0,0 +1,80 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ *
+ * Test different inline assignments by various expressions.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES: The commented lines for the floats and doubles should be uncommented
+ * once the functionality is implemented.
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+inline char new_char = 'c' + 2;
+inline short new_short = 10 * new_char;
+inline int new_int = 100 + new_short;
+inline long new_long = 1234567890;
+inline long long new_long_long = 1234512345 * new_long;
+inline int8_t new_int8 = 'p';
+inline int16_t new_int16 = 20 / new_int8;
+inline int32_t new_int32 = 200;
+inline int64_t new_int64 = 2000000 * (-new_int16);
+inline intptr_t new_intptr = 0x12345 - 129;
+inline uint8_t new_uint8 = 'q';
+inline uint16_t new_uint16 = 30 - new_uint8;
+inline uint32_t new_uint32 = 300 - 0;
+inline uint64_t new_uint64 = 3000000;
+inline uintptr_t new_uintptr = 0x67890 / new_uint64;
+
+/* inline float new_float = 1.23456;
+inline double new_double = 2.34567890;
+inline long double new_long_double = 3.567890123;
+*/
+
+inline int * pointer = &`kmem_flags;
+inline int result = 3 > 2 ? 3 : 2;
+
+BEGIN
+{
+ printf("new_char: %c\nnew_short: %d\nnew_int: %d\nnew_long: %d\n",
+ new_char, new_short, new_int, new_long);
+ printf("new_long_long: %d\nnew_int8: %d\nnew_int16: %d\n",
+ new_long_long, new_int8, new_int16);
+ printf("new_int32: %d\nnew_int64: %d\n", new_int32, new_int64);
+ printf("new_intptr: %d\nnew_uint8: %d\nnew_uint16: %d\n",
+ new_intptr, new_uint8, new_uint16);
+ printf("new_uint32:%d\nnew_uint64: %d\nnew_uintptr:%d\nresult:%d",
+ new_uint32, new_uint64, new_uintptr, result);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d
new file mode 100644
index 00000000..7f188fb0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Test the code generation and results of the various kinds of inlines.
+ * In particular, we test constant and expression-based scalar inlines,
+ * associative array inlines, and inlines using translators.
+ */
+
+#pragma D option quiet
+
+inline int i0 = 100 + 23; /* constant-folded integer constant */
+inline string i1 = probename; /* string variable reference */
+inline int i2 = pid != 0; /* expression involving a variable */
+
+struct s {
+ int s_x;
+};
+
+translator struct s < int T > {
+ s_x = T + 1;
+};
+
+inline struct s i3 = xlate < struct s > (i0); /* translator */
+inline int i4[int x, int y] = x + y; /* associative array */
+inline int i5[int x] = (xlate < struct s > (x)).s_x; /* array by xlate */
+
+BEGIN
+{
+ printf("i0 = %d\n", i0);
+ printf("i1 = %s\n", i1);
+ printf("i2 = %d\n", i2);
+
+ printf("i3.s_x = %d\n", i3.s_x);
+ printf("i4[10, 20] = %d\n", i4[10, 20]);
+ printf("i5[123] = %d\n", i5[123]);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d.out
new file mode 100644
index 00000000..c9a603b2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d.out
@@ -0,0 +1,7 @@
+i0 = 123
+i1 = BEGIN
+i2 = 1
+i3.s_x = 124
+i4[10, 20] = 30
+i5[123] = 124
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineTypedef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineTypedef.d
new file mode 100644
index 00000000..a6247659
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineTypedef.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Create inline names from aliases created using typedef.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ *
+ * NOTES:
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+typedef char new_char;
+inline new_char char_var = 'c';
+
+typedef int * pointer;
+inline pointer p = &`kmem_flags;
+
+BEGIN
+{
+ printf("char_var: %c\npointer p: %d", char_var, *p);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineWritableAssign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineWritableAssign.d
new file mode 100644
index 00000000..a7842a33
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/inline/tst.InlineWritableAssign.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Create inline names from aliases created using typedef.
+ *
+ * SECTION: Type and Constant Definitions/Inlines
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+struct record {
+ char c;
+ int i;
+};
+
+struct record rec1;
+inline struct record rec2 = rec1;
+
+union var {
+ char c;
+ int i;
+};
+
+union var un1;
+inline union var un2 = un1;
+
+
+BEGIN
+{
+ rec1.c = 'c';
+ rec1.i = 10;
+
+ un1.c = 'd';
+
+ printf("rec1.c: %c\nrec1.i:%d\nun1.c: %c\n", rec1.c, rec1.i, un1.c);
+ printf("rec2.c: %c\nrec2.i:%d\nun2.c: %c\n", rec2.c, rec2.i, un2.c);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.c
new file mode 100644
index 00000000..2785b51f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.c
@@ -0,0 +1,100 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <assert.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+static sigjmp_buf env;
+
+static void
+interrupt(int sig)
+{
+ siglongjmp(env, sig);
+}
+
+int
+main(int argc, char *argv[])
+{
+ const char *file = "/dev/null";
+ int i, n, fds[10];
+ struct sigaction act;
+
+ if (argc > 1) {
+ (void) fprintf(stderr, "Usage: %s\n", argv[0]);
+ return (EXIT_FAILURE);
+ }
+
+ act.sa_handler = interrupt;
+ act.sa_flags = 0;
+
+ (void) sigemptyset(&act.sa_mask);
+ (void) sigaction(SIGUSR1, &act, NULL);
+
+ closefrom(0);
+ n = 0;
+
+ /*
+ * With all of our file descriptors closed, wait here spinning in bogus
+ * ioctl() calls until DTrace hits us with a SIGUSR1 to start the test.
+ */
+ if (sigsetjmp(env, 1) == 0) {
+ for (;;)
+ (void) ioctl(-1, -1, NULL);
+ }
+
+ /*
+ * To test the fds[] array, we open /dev/null (a file with reliable
+ * pathname and properties) using various flags and seek offsets.
+ */
+ fds[n++] = open(file, O_RDONLY);
+ fds[n++] = open(file, O_WRONLY);
+ fds[n++] = open(file, O_RDWR);
+
+ fds[n++] = open(file, O_RDWR | O_APPEND | O_CREAT | O_DSYNC |
+ O_LARGEFILE | O_NOCTTY | O_NONBLOCK | O_NDELAY | O_RSYNC |
+ O_SYNC | O_TRUNC | O_XATTR);
+
+ fds[n++] = open(file, O_RDWR);
+ (void) lseek(fds[n - 1], 123, SEEK_SET);
+
+ /*
+ * Once we have all the file descriptors in the state we want to test,
+ * issue a bogus ioctl() on each fd with cmd -1 and arg NULL to whack
+ * our DTrace script into recording the content of the fds[] array.
+ */
+ for (i = 0; i < n; i++)
+ (void) ioctl(fds[i], -1, NULL);
+
+ assert(n <= sizeof (fds) / sizeof (fds[0]));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d
new file mode 100644
index 00000000..52a3312d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option destructive
+#pragma D option quiet
+
+syscall::ioctl:entry
+/pid == $1 && arg0 == -1u/
+{
+ raise(SIGUSR1); /* kick tst.fds.c out of its busy-wait loop */
+}
+
+syscall::ioctl:entry
+/pid == $1 && arg0 != -1u && arg1 == -1u && arg2 == NULL/
+{
+ printf("fds[%d] fi_name = %s\n", arg0, fds[arg0].fi_name);
+ printf("fds[%d] fi_dirname = %s\n", arg0, fds[arg0].fi_dirname);
+ printf("fds[%d] fi_pathname = %s\n", arg0, fds[arg0].fi_pathname);
+ printf("fds[%d] fi_fs = %s\n", arg0, fds[arg0].fi_fs);
+ printf("fds[%d] fi_mount = %s\n", arg0, fds[arg0].fi_mount);
+ printf("fds[%d] fi_offset = %d\n", arg0, fds[arg0].fi_offset);
+ printf("fds[%d] fi_oflags = 0x%x\n", arg0, fds[arg0].fi_oflags);
+}
+
+proc:::exit
+/pid == $1/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d.out
new file mode 100644
index 00000000..9d268268
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/io/tst.fds.d.out
@@ -0,0 +1,36 @@
+fds[0] fi_name = mm@0:null
+fds[0] fi_dirname = /devices/pseudo
+fds[0] fi_pathname = /devices/pseudo/mm@0:null
+fds[0] fi_fs = specfs
+fds[0] fi_mount = /devices
+fds[0] fi_offset = 0
+fds[0] fi_oflags = 0x0
+fds[1] fi_name = mm@0:null
+fds[1] fi_dirname = /devices/pseudo
+fds[1] fi_pathname = /devices/pseudo/mm@0:null
+fds[1] fi_fs = specfs
+fds[1] fi_mount = /devices
+fds[1] fi_offset = 0
+fds[1] fi_oflags = 0x1
+fds[2] fi_name = mm@0:null
+fds[2] fi_dirname = /devices/pseudo
+fds[2] fi_pathname = /devices/pseudo/mm@0:null
+fds[2] fi_fs = specfs
+fds[2] fi_mount = /devices
+fds[2] fi_offset = 0
+fds[2] fi_oflags = 0x2
+fds[3] fi_name = mm@0:null
+fds[3] fi_dirname = /devices/pseudo
+fds[3] fi_pathname = /devices/pseudo/mm@0:null
+fds[3] fi_fs = specfs
+fds[3] fi_mount = /devices
+fds[3] fi_offset = 0
+fds[3] fi_oflags = 0xebda
+fds[4] fi_name = mm@0:null
+fds[4] fi_dirname = /devices/pseudo
+fds[4] fi_pathname = /devices/pseudo/mm@0:null
+fds[4] fi_fs = specfs
+fds[4] fi_mount = /devices
+fds[4] fi_offset = 123
+fds[4] fi_oflags = 0x2
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl
new file mode 100755
index 00000000..fb412554
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl
@@ -0,0 +1,104 @@
+#!/usr/bin/perl -w
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# get.ipv4remote.pl [tcpport]
+#
+# Find an IPv4 reachable remote host using both ifconfig(1M) and ping(1M).
+# If a tcpport is specified, return a host that is also listening on this
+# TCP port. Print the local address and the remote address, or an
+# error message if no suitable remote host was found. Exit status is 0 if
+# a host was found.
+#
+
+use strict;
+use IO::Socket;
+
+my $MAXHOSTS = 32; # max hosts to port scan
+my $TIMEOUT = 3; # connection timeout
+my $tcpport = @ARGV == 1 ? $ARGV[0] : 0;
+
+#
+# Determine local IP address
+#
+my $local = "";
+my $remote = "";
+my %Broadcast;
+my $up;
+open IFCONFIG, '/usr/sbin/ifconfig -a |' or die "Couldn't run ifconfig: $!\n";
+while (<IFCONFIG>) {
+ next if /^lo/;
+
+ # "UP" is always printed first (see print_flags() in ifconfig.c):
+ $up = 1 if /^[a-z].*<UP,/;
+ $up = 0 if /^[a-z].*<,/;
+
+ # assume output is "inet X ... broadcast Z":
+ if (/inet (\S+) .* broadcast (\S+)/) {
+ my ($addr, $bcast) = ($1, $2);
+ $Broadcast{$addr} = $bcast;
+ $local = $addr if $up and $local eq "";
+ $up = 0;
+ }
+}
+close IFCONFIG;
+die "Could not determine local IP address" if $local eq "";
+
+#
+# Find the first remote host that responds to an icmp echo,
+# which isn't a local address.
+#
+open PING, "/usr/sbin/ping -ns $Broadcast{$local} 56 $MAXHOSTS |" or
+ die "Couldn't run ping: $!\n";
+while (<PING>) {
+ if (/bytes from (.*): / and not defined $Broadcast{$1}) {
+ my $addr = $1;
+
+ if ($tcpport != 0) {
+ #
+ # Test TCP
+ #
+ my $socket = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => $addr,
+ PeerPort => $tcpport,
+ Timeout => $TIMEOUT,
+ );
+ next unless $socket;
+ close $socket;
+ }
+
+ $remote = $addr;
+ last;
+ }
+}
+close PING;
+die "Can't find a remote host for testing: No suitable response from " .
+ "$Broadcast{$local}\n" if $remote eq "";
+
+print "$local $remote\n";
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl
new file mode 100755
index 00000000..051ab8c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/perl -w
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# get.ipv6remote.pl
+#
+# Find an IPv6 reachable remote host using both ifconfig(1M) and ping(1M).
+# Print the local address and the remote address, or print nothing if either
+# no IPv6 interfaces or remote hosts were found. (Remote IPv6 testing is
+# considered optional, and so not finding another IPv6 host is not an error
+# state we need to log.) Exit status is 0 if a host was found.
+#
+
+use strict;
+use IO::Socket;
+
+my $MAXHOSTS = 32; # max hosts to scan
+my $TIMEOUT = 3; # connection timeout
+my $MULTICAST = "FF02::1"; # IPv6 multicast address
+
+#
+# Determine local IP address
+#
+my $local = "";
+my $remote = "";
+my %Local;
+my $up;
+open IFCONFIG, '/usr/sbin/ifconfig -a inet6 |'
+ or die "Couldn't run ifconfig: $!\n";
+while (<IFCONFIG>) {
+ next if /^lo/;
+
+ # "UP" is always printed first (see print_flags() in ifconfig.c):
+ $up = 1 if /^[a-z].*<UP,/;
+ $up = 0 if /^[a-z].*<,/;
+
+ # assume output is "inet6 ...":
+ if (m:inet6 (\S+)/:) {
+ my $addr = $1;
+ $Local{$addr} = 1;
+ $local = $addr if $up and $local eq "";
+ $up = 0;
+ }
+}
+close IFCONFIG;
+exit 1 if $local eq "";
+
+#
+# Find the first remote host that responds to an icmp echo,
+# which isn't a local address.
+#
+open PING, "/usr/sbin/ping -ns -A inet6 $MULTICAST 56 $MAXHOSTS |" or
+ die "Couldn't run ping: $!\n";
+while (<PING>) {
+ if (/bytes from (.*): / and not defined $Local{$1}) {
+ $remote = $1;
+ last;
+ }
+}
+close PING;
+exit 2 if $remote eq "";
+
+print "$local $remote\n";
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh
new file mode 100755
index 00000000..0965040e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh
@@ -0,0 +1,70 @@
+#!/usr/bin/ksh
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv4 ICMP to a local address.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. Unrelated ICMP on lo0 traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+
+$dtrace -c "/usr/sbin/ping $local 3" -qs /dev/stdin <<EOF | sort -n
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("1 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("2 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+EOF
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out
new file mode 100644
index 00000000..41d6e0c8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out
@@ -0,0 +1,6 @@
+
+1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
+1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
+2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255)
+2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255)
+127.0.0.1 is alive
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
new file mode 100644
index 00000000..6fa8c35b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
@@ -0,0 +1,125 @@
+#!/usr/bin/ksh
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {ip,tcp}:::{send,receive} of IPv4 TCP to local host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. The local ssh service is not online.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection and checks that at least the
+# following packet counts were traced:
+#
+# 3 x ip:::send (2 during the TCP handshake, then a FIN)
+# 3 x tcp:::send (2 during the TCP handshake, then a FIN)
+# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK)
+# 2 x tcp:::receive (1 during the TCP handshake, then the FIN ACK)
+
+# The actual count tested is 5 each way, since we are tracing both
+# source and destination events.
+#
+# For this test to work, we are assuming that the TCP handshake and
+# TCP close will enter the IP code path and not use tcp fusion.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+tcpport=22
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$local",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $local port $tcpport" unless \$s;
+ close \$s;
+EOPERL
+
+$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ tcpreceive++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 5 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 5 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 5 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out
new file mode 100644
index 00000000..2a85b98b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out
@@ -0,0 +1,7 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
new file mode 100644
index 00000000..fa8f7acf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh
@@ -0,0 +1,93 @@
+#!/usr/bin/ksh
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test ip:::{send,receive} of IPv4 UDP to a local address.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on rpcbind.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test sends a UDP message using ping and checks that at least the
+# following counts were traced:
+#
+# 1 x ip:::send (UDP sent to ping's base UDP port)
+# 1 x udp:::send (UDP sent to ping's base UDP port)
+# 1 x ip:::receive (UDP received)
+#
+# No udp:::receive event is expected as the response ping -U elicits is
+# an ICMP PORT_UNREACHABLE response rather than a UDP packet, and locally
+# the echo request UDP packet only reaches IP, so the udp:::receive probe
+# is not triggered by it.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+
+$dtrace -c "/usr/sbin/ping -U $local" -qs /dev/stdin <<EOF | grep -v 'is alive'
+BEGIN
+{
+ ipsend = udpsend = ipreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_UDP/
+{
+ ipsend++;
+}
+
+udp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
+{
+ udpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_UDP/
+{
+ ipreceive++;
+}
+
+END
+{
+ printf("Minimum UDP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 1 ? "yes" : "no");
+ printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no");
+}
+EOF
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out
new file mode 100644
index 00000000..bca55327
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out
@@ -0,0 +1,6 @@
+Minimum UDP events seen
+
+ip:::send - yes
+ip:::receive - yes
+udp:::send - yes
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh
new file mode 100755
index 00000000..efe0d30f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh
@@ -0,0 +1,81 @@
+#!/usr/bin/ksh
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv4 ICMP to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable.
+# 4. An unrelated ICMP between these hosts was traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
+ grep -v 'is alive' | sort -n
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("1 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_ICMP/
+{
+ printf("2 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[4]: %d %d %d %d %d)\n",
+ args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
+ args[4]->ipv4_offset, args[4]->ipv4_ttl);
+}
+EOF
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out
new file mode 100644
index 00000000..b5915f8d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out
@@ -0,0 +1,3 @@
+
+1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
+2 ip:::receive (args[2]: 4 64, args[4]: 4 84 4 0 255)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
new file mode 100644
index 00000000..89a0cdb9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
@@ -0,0 +1,128 @@
+#!/usr/bin/ksh
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {tcp,ip}:::{send,receive} of IPv4 TCP to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on ssh.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection and checks that at least the
+# following packet counts were traced:
+#
+# 3 x ip:::send (2 during the TCP handshake, then a FIN)
+# 3 x tcp:::send (2 during the TCP handshake, then a FIN)
+# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK)
+# 2 x tcp:::receive (1 during the TCP handshake, then the FIN ACK)
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+tcpport=22
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr $tcpport | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$dest",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $dest port $tcpport" unless \$s;
+ close \$s;
+EOPERL
+
+$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source"/
+{
+ tcpreceive++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 3 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 2 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 3 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 2 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out
new file mode 100644
index 00000000..2a85b98b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out
@@ -0,0 +1,7 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
new file mode 100644
index 00000000..b0893c81
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh
@@ -0,0 +1,88 @@
+#!/usr/bin/ksh
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test {udp,ip}:::{send,receive} of IPv4 UDP to a remote host.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. No physical network interface is plumbed and up.
+# 3. No other hosts on this subnet are reachable and listening on rpcbind.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test sends a UDP message using ping and checks that at least the
+# following counts were traced:
+#
+# 1 x ip:::send (UDP sent to ping's base UDP port)
+# 1 x udp:::send (UDP sent to ping's base UDP port)
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+$dtrace -c "/usr/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive'
+BEGIN
+{
+ ipsend = udpsend = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_UDP/
+{
+ ipsend++;
+}
+
+udp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
+{
+ udpsend++;
+}
+
+END
+{
+ printf("Minimum UDP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
+ printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no");
+}
+EOF
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out
new file mode 100644
index 00000000..bdbbe1fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out
@@ -0,0 +1,5 @@
+Minimum UDP events seen
+
+ip:::send - yes
+udp:::send - yes
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh
new file mode 100755
index 00000000..5912ee7c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh
@@ -0,0 +1,82 @@
+#!/usr/bin/ksh
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv6 ICMP to a local address. This creates a
+# temporary lo0/inet6 interface if one doesn't already exist.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. Unrelated ICMPv6 on lo0 traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=::1
+
+if ! ifconfig lo0 inet6 > /dev/null 2>&1; then
+ if ! ifconfig lo0 inet6 plumb up; then
+ print -u2 "could not plumb lo0 inet6 for testing"
+ exit 3
+ fi
+ removeinet6=1
+else
+ removeinet6=0
+fi
+
+$dtrace -c "/usr/sbin/ping -A inet6 $local 3" -qs /dev/stdin <<EOF | sort -n
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("1 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("2 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+EOF
+
+if (( removeinet6 )); then
+ ifconfig lo0 inet6 unplumb
+fi
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out
new file mode 100644
index 00000000..529d251f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out
@@ -0,0 +1,6 @@
+
+::1 is alive
+1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
+1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
+2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)
+2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh
new file mode 100755
index 00000000..b94b7843
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh
@@ -0,0 +1,88 @@
+#!/usr/bin/ksh
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#
+# Test ip:::{send,receive} of IPv6 ICMP to a remote host. This test is
+# skipped if there are no physical interfaces configured with IPv6, or no
+# other IPv6 hosts are reachable.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. An unrelated ICMPv6 between these hosts was traced by accident.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv6remote.pl
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr | read source dest
+if (( $? != 0 )); then
+ print -nu2 "Could not find a local IPv6 interface and a remote IPv6 "
+ print -u2 "host. Aborting test.\n"
+ print -nu2 "For this test to continue, a \"ping -ns -A inet6 FF02::1\" "
+ print -u2 "must respond with a\nremote IPv6 host."
+ exit 3
+fi
+
+#
+# Shake loose any ICMPv6 Neighbor advertisement messages before tracing.
+#
+/usr/sbin/ping $dest 3 > /dev/null 2>&1
+
+$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
+ grep -v 'is alive' | sort -n
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("1 ip:::send (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
+{
+ printf("2 ip:::receive (");
+ printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
+ printf("args[5]: %d %d %d)\n",
+ args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
+}
+EOF
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out
new file mode 100644
index 00000000..1ddcd07b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out
@@ -0,0 +1,3 @@
+
+1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
+2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
new file mode 100644
index 00000000..8a65ce6f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
@@ -0,0 +1,182 @@
+#!/usr/bin/ksh
+#
+# 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) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test tcp:::state-change and tcp:::{send,receive} by connecting to
+# the local ssh service and sending a test message. This should result
+# in a "Protocol mismatch" response and a close of the connection.
+# A number of state transition events along with tcp fusion send and
+# receive events for the message should result.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. The local ssh service is not online.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection to the ssh service (port 22) and
+# checks that at least the following packet counts were traced:
+#
+# 3 x ip:::send (2 during the TCP handshake, then a FIN)
+# 4 x tcp:::send (2 during the TCP handshake, 1 message then a FIN)
+# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK)
+# 3 x tcp:::receive (1 during the TCP handshake, 1 message then the FIN ACK)
+#
+# The actual ip count tested is 5 each way, since we are tracing both
+# source and destination events. The actual tcp count tested is 7
+# each way, since the TCP fusion send/receive events will not reach IP.
+#
+# For this test to work, we are assuming that the TCP handshake and
+# TCP close will enter the IP code path and not use tcp fusion.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+local=127.0.0.1
+tcpport=22
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$local",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $local port $tcpport" unless \$s;
+ print \$s "testing state machine transitions";
+ close \$s;
+EOPERL
+
+$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+ connreq = connest = connaccept = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ (args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ (args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/
+{
+ tcpreceive++;
+}
+
+tcp:::state-change
+{
+ state_event[args[3]->tcps_state]++;
+}
+
+tcp:::connect-request
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ connreq++;
+}
+
+tcp:::connect-established
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->tcp_sport == $tcpport/
+{
+ connest++;
+}
+
+tcp:::accept-established
+/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ connaccept++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 5 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 7 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 7 ? "yes" : "no");
+ printf("tcp:::state-change to syn-sent - %s\n",
+ state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no");
+ printf("tcp:::state-change to syn-received - %s\n",
+ state_event[TCP_STATE_SYN_RECEIVED] >=1 ? "yes" : "no");
+ printf("tcp:::state-change to established - %s\n",
+ state_event[TCP_STATE_ESTABLISHED] >= 2 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-1 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to close-wait - %s\n",
+ state_event[TCP_STATE_CLOSE_WAIT] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-2 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to last-ack - %s\n",
+ state_event[TCP_STATE_LAST_ACK] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to time-wait - %s\n",
+ state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no");
+ printf("tcp:::connect-request - %s\n",
+ connreq >=1 ? "yes" : "no");
+ printf("tcp:::connect-established - %s\n",
+ connest >=1 ? "yes" : "no");
+ printf("tcp:::accept-established - %s\n",
+ connaccept >=1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out
new file mode 100644
index 00000000..ea1c27e5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out
@@ -0,0 +1,18 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+tcp:::state-change to syn-sent - yes
+tcp:::state-change to syn-received - yes
+tcp:::state-change to established - yes
+tcp:::state-change to fin-wait-1 - yes
+tcp:::state-change to close-wait - yes
+tcp:::state-change to fin-wait-2 - yes
+tcp:::state-change to last-ack - yes
+tcp:::state-change to time-wait - yes
+tcp:::connect-request - yes
+tcp:::connect-established - yes
+tcp:::accept-established - yes
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh
new file mode 100644
index 00000000..b6b9545d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh
@@ -0,0 +1,172 @@
+#!/usr/bin/ksh
+#
+# 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) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Test tcp:::state-change and tcp:::{send,receive} by connecting to
+# the remote ssh service and sending a test message. This should result
+# in a "Protocol mismatch" response and a close of the connection.
+# A number of state transition events along with tcp send and receive
+# events for the message should result.
+#
+# This may fail due to:
+#
+# 1. A change to the ip stack breaking expected probe behavior,
+# which is the reason we are testing.
+# 2. The lo0 interface missing or not up.
+# 3. The remote ssh service is not online.
+# 4. An unlikely race causes the unlocked global send/receive
+# variables to be corrupted.
+#
+# This test performs a TCP connection to the ssh service (port 22) and
+# checks that at least the following packet counts were traced:
+#
+# 4 x ip:::send (2 during the TCP handshake, the message, then a FIN)
+# 4 x tcp:::send (2 during the TCP handshake, the messages, then a FIN)
+# 3 x ip:::receive (1 during the TCP handshake, the response, then the FIN ACK)
+# 3 x tcp:::receive (1 during the TCP handshake, the response, then the FIN ACK)
+#
+# For this test to work, we are assuming that the TCP handshake and
+# TCP close will enter the IP code path and not use tcp fusion.
+#
+
+if (( $# != 1 )); then
+ print -u2 "expected one argument: <dtrace-path>"
+ exit 2
+fi
+
+dtrace=$1
+getaddr=./get.ipv4remote.pl
+tcpport=22
+DIR=/var/tmp/dtest.$$
+
+if [[ ! -x $getaddr ]]; then
+ print -u2 "could not find or execute sub program: $getaddr"
+ exit 3
+fi
+$getaddr $tcpport | read source dest
+if (( $? != 0 )); then
+ exit 4
+fi
+
+mkdir $DIR
+cd $DIR
+
+cat > test.pl <<-EOPERL
+ use IO::Socket;
+ my \$s = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "$dest",
+ PeerPort => $tcpport,
+ Timeout => 3);
+ die "Could not connect to host $dest port $tcpport" unless \$s;
+ print \$s "testing state machine transitions";
+ close \$s;
+EOPERL
+
+$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+BEGIN
+{
+ ipsend = tcpsend = ipreceive = tcpreceive = 0;
+ connreq = connest = 0;
+}
+
+ip:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipsend++;
+}
+
+tcp:::send
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ tcpsend++;
+}
+
+ip:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->ipv4_protocol == IPPROTO_TCP/
+{
+ ipreceive++;
+}
+
+tcp:::receive
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->tcp_sport == $tcpport/
+{
+ tcpreceive++;
+}
+
+tcp:::state-change
+{
+ state_event[args[3]->tcps_state]++;
+}
+
+tcp:::connect-request
+/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
+ args[4]->tcp_dport == $tcpport/
+{
+ connreq++;
+}
+
+tcp:::connect-established
+/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
+ args[4]->tcp_sport == $tcpport/
+{
+ connest++;
+}
+
+END
+{
+ printf("Minimum TCP events seen\n\n");
+ printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no");
+ printf("ip:::receive - %s\n", ipreceive >= 3 ? "yes" : "no");
+ printf("tcp:::send - %s\n", tcpsend >= 4 ? "yes" : "no");
+ printf("tcp:::receive - %s\n", tcpreceive >= 3 ? "yes" : "no");
+ printf("tcp:::state-change to syn-sent - %s\n",
+ state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no");
+ printf("tcp:::state-change to established - %s\n",
+ state_event[TCP_STATE_ESTABLISHED] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-1 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to fin-wait-2 - %s\n",
+ state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no");
+ printf("tcp:::state-change to time-wait - %s\n",
+ state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no");
+ printf("tcp:::connect-request - %s\n",
+ connreq >=1 ? "yes" : "no");
+ printf("tcp:::connect-established - %s\n",
+ connest >=1 ? "yes" : "no");
+}
+EODTRACE
+
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out
new file mode 100644
index 00000000..27388fba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out
@@ -0,0 +1,15 @@
+Minimum TCP events seen
+
+ip:::send - yes
+ip:::receive - yes
+tcp:::send - yes
+tcp:::receive - yes
+tcp:::state-change to syn-sent - yes
+tcp:::state-change to established - yes
+tcp:::state-change to fin-wait-1 - yes
+tcp:::state-change to close-wait - yes
+tcp:::state-change to fin-wait-2 - yes
+tcp:::state-change to time-wait - yes
+tcp:::connect-request - yes
+tcp:::connect-established - yes
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile
new file mode 100644
index 00000000..fe213dd2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile
@@ -0,0 +1,79 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/SUNWdtrt
+JAR_DSTDIR = $(ROOTOPTPKG)/tst/common/java_api
+JAR_SRCDIR = $(SRC)/cmd/dtrace/test/tst/common/java_api
+
+# Use the proto dtrace.jar if it exists, otherwise use whatever is
+# installed on the system. It should be possible to build
+# usr/src/cmd/dtrace/test independently, even if only on systems that
+# have a compatible dtrace.jar installed.
+DTRACE_JAR=usr/share/lib/java/dtrace.jar
+PROTO_DTRACE_JAR=$(ROOT)/$(DTRACE_JAR)
+INSTALLED_DTRACE_JAR=/$(DTRACE_JAR)
+CLASSPATH=$(PROTO_DTRACE_JAR):$(INSTALLED_DTRACE_JAR)
+SRCDIR=src
+CLASSDIR=classes
+MANIFESTDIR=manifest
+MANIFEST=$(MANIFESTDIR)/test.jar-manifest
+TEST_JAR=$(JAR_SRCDIR)/test.jar
+PROTO_TEST_JAR=$(JAR_DSTDIR)/test.jar
+
+default: $(TEST_JAR)
+
+clean:
+ $(RM) $(CLASSDIR)/*.class
+
+clobber: clean
+ $(RM) $(TEST_JAR)
+
+all: default
+
+lint:
+
+install: all $(PROTO_TEST_JAR)
+
+JFLAGS= -g -cp $(CLASSPATH) -d $(CLASSDIR) -deprecation
+JFLAGS += -target 1.5
+JFLAGS += -Xlint
+COMPILE.java=$(JAVAC) $(JFLAGS)
+
+$(TEST_JAR): $(SRCDIR)/*.java
+ @mkdir -p $(CLASSDIR)
+ $(COMPILE.java) $(SRCDIR)/*.java
+ $(JAR) -cmf $(MANIFEST) $(TEST_JAR) -C $(CLASSDIR) .
+
+$(PROTO_TEST_JAR): $(JAR_DSTDIR)
+
+$(JAR_DSTDIR):
+ $(INS.dir)
+
+$(JAR_DSTDIR)/%: $(JAR_SRCDIR)/%
+ $(INS.file)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/test.jar-manifest b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/test.jar-manifest
new file mode 100644
index 00000000..7e454ad8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/manifest/test.jar-manifest
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+Class-Path: /usr/share/lib/java/dtrace.jar
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java
new file mode 100644
index 00000000..310dd184
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java
@@ -0,0 +1,158 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+import java.util.NoSuchElementException;
+
+/**
+ * Regression for 6426129 abort() after close() throws
+ * NoSuchElementException.
+ */
+public class TestAbort {
+ static boolean aborted = false;
+
+ public static void
+ main(String[] args)
+ {
+ Consumer consumer = new LocalConsumer();
+
+ // Test for deadlock (bug 6419880)
+ try {
+ consumer.open();
+ consumer.compile("syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ consumer.enable();
+ consumer.go();
+ try {
+ Thread.currentThread().sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ consumer.close();
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ consumer = new LocalConsumer();
+
+ // Should be able to abort an unopened consumer
+ try {
+ aborted = false;
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ public void consumerStopped(ConsumerEvent e) {
+ aborted = true;
+ }
+ });
+ consumer.abort();
+ consumer.open();
+ consumer.compile("syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ consumer.enable();
+ consumer.go();
+ try {
+ Thread.currentThread().sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ if (!aborted) {
+ throw new IllegalStateException("consumer not aborted");
+ }
+ consumer.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ consumer = new LocalConsumer();
+
+ // Should be safe to call abort() in any state
+ try {
+ consumer.abort();
+ consumer.open();
+ consumer.abort();
+ consumer.compile("syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ consumer.abort();
+ consumer.enable();
+ consumer.abort();
+ consumer.go();
+ consumer.abort();
+ consumer.close();
+ // Should be safe to call after close()
+ try {
+ consumer.abort();
+ } catch (NoSuchElementException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ consumer = new LocalConsumer();
+
+ // Tests that close() throws expected exception when called on
+ // synchronized consumer.
+ try {
+ consumer.open();
+ consumer.compile("syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ consumer.enable();
+ consumer.go();
+ try {
+ Thread.currentThread().sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ try {
+ synchronized (consumer) {
+ consumer.close();
+ }
+ } catch (IllegalThreadStateException e) {
+ try {
+ consumer.close();
+ System.out.println("Successful");
+ System.exit(0);
+ } catch (NoSuchElementException x) {
+ x.printStackTrace();
+ System.exit(1);
+ }
+ }
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ System.err.println("Failed");
+ System.exit(1);
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestBean.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestBean.java
new file mode 100644
index 00000000..dd4a969d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestBean.java
@@ -0,0 +1,706 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+import java.util.*;
+import java.io.*;
+import java.beans.*;
+import java.lang.reflect.*;
+
+/**
+ * Regression test for serialization and XML encoding/decoding. Tests
+ * every Serializable class in the Java DTrace API by creating a dummy
+ * instance, writing it to a file, then reading it back in and comparing
+ * the string values of the object before and after, as well as
+ * verifying object equality before and after if the class overrides the
+ * equals() method.
+ */
+public class TestBean {
+ public static final String[] TESTS = new String[] {
+ "ExitRecord",
+ "AggregationRecord",
+ "Aggregation",
+ "Tuple",
+ "ScalarRecord",
+ "KernelStackRecord",
+ "LogDistribution",
+ "LinearDistribution",
+ "Option",
+ "ProcessState",
+ "ProbeDescription",
+ "PrintaRecord",
+ "PrintfRecord",
+ "ProbeData",
+ "Aggregate",
+ "UserStackRecord",
+ "AvgValue",
+ "CountValue",
+ "SumValue",
+ "MinValue",
+ "MaxValue",
+ "Error",
+ "Drop",
+ "InterfaceAttributes",
+ "ProgramInfo",
+ "ProbeInfo",
+ "Probe",
+ "Flow",
+ "KernelSymbolRecord",
+ "UserSymbolRecord",
+ "UserSymbolRecord$Value",
+ "Program",
+ "Program$File",
+ "StddevValue"
+ };
+
+ static File file;
+
+ static void
+ exit(int status)
+ {
+ System.out.flush();
+ System.err.flush();
+ System.exit(status);
+ }
+
+ public static XMLEncoder
+ getXMLEncoder(File file)
+ {
+ XMLEncoder encoder = null;
+ try {
+ OutputStream out = new BufferedOutputStream
+ (new FileOutputStream(file));
+ encoder = new XMLEncoder(out);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ return encoder;
+ }
+
+ public static XMLDecoder
+ getXMLDecoder(File file)
+ {
+ return getXMLDecoder(file, null);
+ }
+
+ public static XMLDecoder
+ getXMLDecoder(File file, ExceptionListener exceptionListener)
+ {
+ XMLDecoder decoder = null;
+ try {
+ InputStream in = new BufferedInputStream
+ (new FileInputStream(file));
+ decoder = new XMLDecoder(in, null, exceptionListener);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ return decoder;
+ }
+
+ public static ExitRecord
+ getExitRecord()
+ {
+ ExitRecord r = new ExitRecord(1);
+ return r;
+ }
+
+ public static AggregationRecord
+ getAggregationRecord()
+ {
+ Tuple tuple = getTuple();
+ AggregationValue value = new CountValue(7);
+ AggregationRecord r = new AggregationRecord(tuple, value);
+ return r;
+ }
+
+ public static Aggregation
+ getAggregation()
+ {
+ List < AggregationRecord > list =
+ new ArrayList < AggregationRecord > ();
+ AggregationRecord r;
+ r = getAggregationRecord();
+ list.add(r);
+
+ ValueRecord v1 = new ScalarRecord(new byte[] {(byte)1, (byte)2,
+ (byte)3}, 3);
+ ValueRecord v2 = new ScalarRecord("shebang!", 256);
+ Tuple tuple = new Tuple(v1, v2);
+ AggregationValue value = getLinearDistribution();
+ r = new AggregationRecord(tuple, value);
+ list.add(r);
+
+ Aggregation a = new Aggregation("counts", 2, list);
+ return a;
+ }
+
+ public static Tuple
+ getTuple()
+ {
+ ValueRecord r1 = new ScalarRecord("cat", 256);
+ ValueRecord r2 = new ScalarRecord(new Integer(9), 2);
+ ValueRecord r3 = new KernelStackRecord(
+ new StackFrame[] {
+ new StackFrame("has"),
+ new StackFrame("nine"),
+ new StackFrame("lives")},
+ new byte[] { (byte)0, (byte)1, (byte)2 });
+ ValueRecord r4 = new ScalarRecord(new byte[] {(byte)1, (byte)2,
+ (byte)3}, 3);
+
+ Tuple tuple = new Tuple(r1, r2, r3, r4);
+ return tuple;
+ }
+
+ public static ScalarRecord
+ getScalarRecord()
+ {
+ Object v = new byte[] {(byte)1, (byte)2, (byte)3};
+ ScalarRecord r = new ScalarRecord(v, 3);
+ return r;
+ }
+
+ public static KernelStackRecord
+ getKernelStackRecord()
+ {
+ StackFrame[] stackFrames = new StackFrame[] {
+ new StackFrame("Frame 1"),
+ new StackFrame("Frame 2"),
+ new StackFrame("Frame 3")
+ };
+ KernelStackRecord r = new KernelStackRecord(stackFrames,
+ new byte[] { (byte)0, (byte)1, (byte)2 });
+ return r;
+ }
+
+ public static LogDistribution
+ getLogDistribution()
+ {
+ List < Distribution.Bucket > buckets =
+ new ArrayList < Distribution.Bucket > ();
+ Distribution.Bucket bucket;
+ int n = 0;
+ long base = 0;
+ long i;
+ long sign;
+ long nextSign;
+ long power;
+ long nextPower;
+ long lowerBound;
+ long upperBound;
+ for (i = -62; i <= 62; ++i) {
+ if (i == 0) {
+ bucket = new Distribution.Bucket(-1, -1, n++);
+ buckets.add(bucket);
+ bucket = new Distribution.Bucket(0, 0, n++);
+ buckets.add(bucket);
+ bucket = new Distribution.Bucket(1, 1, n++);
+ buckets.add(bucket);
+ continue;
+ }
+ sign = ((i < 0) ? -1L : 1L);
+ power = (sign * i);
+ nextSign = (((i + 1) < 0) ? -1L : 1L);
+ nextPower = (nextSign * (i + 1));
+ lowerBound = sign * ((long) Math.pow(2L, power));
+ upperBound = (nextPower == 0 ? -2L :
+ (nextSign * ((long) Math.pow(2L, nextPower))) - 1);
+ if ((upperBound > 0) && ((upperBound * 2L) < 0)) {
+ upperBound = Long.MAX_VALUE;
+ }
+ bucket = new Distribution.Bucket(lowerBound, upperBound, n++);
+ buckets.add(bucket);
+ }
+ LogDistribution d = new LogDistribution(buckets);
+ return d;
+ }
+
+ public static LinearDistribution
+ getLinearDistribution()
+ {
+ List < Distribution.Bucket > buckets =
+ new ArrayList < Distribution.Bucket > ();
+ Distribution.Bucket bucket;
+ int n = 10; // number of buckets
+ int base = 1;
+ int step = 10;
+ bucket = new Distribution.Bucket(Long.MIN_VALUE, (base - 1), 0);
+ buckets.add(bucket);
+ for (int i = base; i < (n * step); i += step) {
+ bucket = new Distribution.Bucket(i, (i + (step - 1)),
+ ((i - 1) / step));
+ buckets.add(bucket);
+ }
+ bucket = new Distribution.Bucket((n * step) + 1, Long.MAX_VALUE, 0);
+ buckets.add(bucket);
+ LinearDistribution d = new LinearDistribution(base, step, buckets);
+ return d;
+ }
+
+ public static Option
+ getOption()
+ {
+ Option option = new Option("aggrate", "1s");
+ return option;
+ }
+
+ public static ProcessState
+ getProcessState()
+ {
+ ProcessState p = new ProcessState(123456, "UNDEAD",
+ 3, "SIGSTOP",
+ -2, "Process stopped on dime");
+ return p;
+ }
+
+ public static ProbeDescription
+ getProbeDescription()
+ {
+ ProbeDescription d = new ProbeDescription(256, "syscall", null,
+ "malloc", "entry");
+ return d;
+ }
+
+ public static PrintaRecord
+ getPrintaRecord()
+ {
+ List < Aggregation > aggregations = new ArrayList < Aggregation > ();
+ Aggregation a = getAggregation();
+ aggregations.add(a);
+ aggregations.add(a);
+ Map < Tuple, String > formattedOutput =
+ new HashMap < Tuple, String > ();
+ for (Tuple t : a.asMap().keySet()) {
+ formattedOutput.put(t, "cat");
+ }
+ List < Tuple > tuples = new ArrayList < Tuple > ();
+ for (Tuple t : a.asMap().keySet()) {
+ tuples.add(t);
+ }
+ Collections.sort(tuples);
+ PrintaRecord r = new PrintaRecord(1234567890L,
+ aggregations, formattedOutput, tuples,
+ "Yes, this is the formatted printa() output");
+ return r;
+ }
+
+ public static PrintfRecord
+ getPrintfRecord()
+ {
+ List < ValueRecord > list = new ArrayList < ValueRecord > ();
+ ValueRecord v1 = getScalarRecord();
+ ValueRecord v2 = new ScalarRecord(new Integer(7), 4);
+ list.add(v1);
+ list.add(v2);
+ PrintfRecord r = new PrintfRecord(list,
+ "long formatted string");
+ return r;
+ }
+
+ public static ProbeData
+ getProbeData()
+ {
+ List < Record > list = new ArrayList < Record > ();
+ list.add(getPrintaRecord());
+ list.add(getPrintfRecord());
+ list.add(getScalarRecord());
+ list.add(getUserSymbolRecord());
+ list.add(getUserStackRecord());
+ list.add(getExitRecord());
+ ProbeData d = new ProbeData(7, 1, getProbeDescription(),
+ getFlow(), list);
+ return d;
+ }
+
+ public static Aggregate
+ getAggregate()
+ {
+ List < Aggregation > list = new ArrayList < Aggregation > ();
+ list.add(getAggregation());
+
+ List < AggregationRecord > reclist =
+ new ArrayList < AggregationRecord > ();
+ AggregationRecord r;
+ ValueRecord v1 = new ScalarRecord("cat", 256);
+ ValueRecord v2 = new ScalarRecord("dog", 256);
+ ValueRecord v3 = new ScalarRecord("mouse", 256);
+ ValueRecord v4 = new ScalarRecord("mouse", 256);
+ ValueRecord v5 = new ScalarRecord(new Byte((byte) 'C'), 1);
+ ValueRecord v6 = new ScalarRecord(new Short((short) 7), 2);
+ Tuple tuple = new Tuple(v1, v2, v3, v4, v5, v6);
+ AggregationValue value = getCountValue();
+ r = new AggregationRecord(tuple, value);
+ reclist.add(r);
+ list.add(new Aggregation("times", 1, reclist));
+
+ Aggregate a = new Aggregate(1234567890L, list);
+ return a;
+ }
+
+ public static UserStackRecord
+ getUserStackRecord()
+ {
+ StackFrame[] frames = new StackFrame[] {
+ new StackFrame("User Stack Frame 1"),
+ new StackFrame("User Stack Frame 2"),
+ new StackFrame("User Stack Frame 3")
+ };
+ UserStackRecord r = new UserStackRecord(123456, frames,
+ new byte[] { (byte)0, (byte)1, (byte)2 });
+ return r;
+ }
+
+ public static AvgValue
+ getAvgValue()
+ {
+ AvgValue v = new AvgValue(5, 20, 4);
+ return v;
+ }
+
+ public static CountValue
+ getCountValue()
+ {
+ CountValue v = new CountValue(9);
+ return v;
+ }
+
+ public static MinValue
+ getMinValue()
+ {
+ MinValue v = new MinValue(101);
+ return v;
+ }
+
+ public static MaxValue
+ getMaxValue()
+ {
+ MaxValue v = new MaxValue(101);
+ return v;
+ }
+
+ public static SumValue
+ getSumValue()
+ {
+ SumValue v = new SumValue(25);
+ return v;
+ }
+
+ public static org.opensolaris.os.dtrace.Error
+ getError()
+ {
+ ProbeDescription probe = getProbeDescription();
+ org.opensolaris.os.dtrace.Error e =
+ new org.opensolaris.os.dtrace.Error(probe, 8, 3,
+ 1, 20, "DTRACEFLT_BADALIGN", -1, "error on enabled probe ID 8 " +
+ "(ID " + probe.getID() + ": " + probe + "): Bad alignment " +
+ "(0x33ef) in action #1 at DIF offset 20");
+ return e;
+ }
+
+ public static Drop
+ getDrop()
+ {
+ Drop drop = new Drop(2, "SPECBUSY", 72, 1041,
+ "Guess we dropped stuff all over the place.");
+ return drop;
+ }
+
+ public static InterfaceAttributes
+ getInterfaceAttributes()
+ {
+ InterfaceAttributes a = new InterfaceAttributes(
+ InterfaceAttributes.Stability.UNSTABLE,
+ InterfaceAttributes.Stability.EVOLVING,
+ InterfaceAttributes.DependencyClass.ISA);
+ return a;
+ }
+
+ public static ProgramInfo
+ getProgramInfo()
+ {
+ ProgramInfo info = new ProgramInfo(getInterfaceAttributes(),
+ getInterfaceAttributes(), 256);
+ return info;
+ }
+
+ public static ProbeInfo
+ getProbeInfo()
+ {
+ ProbeInfo info = new ProbeInfo(getInterfaceAttributes(),
+ getInterfaceAttributes());
+ return info;
+ }
+
+ public static Probe
+ getProbe()
+ {
+ Probe p = new Probe(getProbeDescription(), getProbeInfo());
+ return p;
+ }
+
+ public static Flow
+ getFlow()
+ {
+ Flow f = new Flow(Flow.Kind.RETURN.name(), 3);
+ return f;
+ }
+
+ public static KernelSymbolRecord
+ getKernelSymbolRecord()
+ {
+ KernelSymbolRecord r = new KernelSymbolRecord("mod`func+0x4", -1L);
+ return r;
+ }
+
+ public static UserSymbolRecord
+ getUserSymbolRecord()
+ {
+ UserSymbolRecord r = new UserSymbolRecord(7, "mod`func+0x4", -1L);
+ return r;
+ }
+
+ public static UserSymbolRecord.Value
+ getUserSymbolRecord$Value()
+ {
+ UserSymbolRecord.Value v = new UserSymbolRecord.Value(7, -1L);
+ return v;
+ }
+
+ public static Program
+ getProgram()
+ {
+ final String PROGRAM = "syscall:::entry { @[execname] = count(); }";
+ Consumer consumer = new LocalConsumer();
+ Program p;
+ try {
+ consumer.open();
+ p = consumer.compile(PROGRAM);
+ consumer.close();
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ p = null;
+ }
+ return p;
+ }
+
+ public static Program.File
+ getProgram$File()
+ {
+ final String PROGRAM = "syscall:::entry { @[execname] = count(); }";
+ Consumer consumer = new LocalConsumer();
+ Program p;
+ try {
+ OutputStream out = new FileOutputStream(file);
+ out.write(PROGRAM.getBytes(), 0, PROGRAM.length());
+ out.flush();
+ out.close();
+ consumer.open();
+ p = consumer.compile(file);
+ consumer.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ p = null;
+ }
+ return Program.File.class.cast(p);
+ }
+
+ public static StddevValue
+ getStddevValue()
+ {
+ StddevValue v = new StddevValue(37, 114, 5, Integer.toString(9544));
+ return v;
+ }
+
+ @SuppressWarnings("unchecked")
+ static String
+ getString(Object o)
+ {
+ String s;
+ if (o instanceof ScalarRecord) {
+ o = ((ScalarRecord)o).getValue();
+ }
+
+ if (o instanceof byte[]) {
+ s = Arrays.toString((byte[])o);
+ } else if (o instanceof Object[]) {
+ s = Arrays.toString((Object[])o);
+ } else {
+ Class c = o.getClass();
+ try {
+ Method m = c.getDeclaredMethod("toLogString");
+ s = (String)m.invoke(o);
+ } catch (Exception e) {
+ s = o.toString();
+ }
+ }
+ return s;
+ }
+
+ static void
+ checkEquality(Object obj, Object newobj)
+ {
+ // If the class overrides equals(), make sure the re-created
+ // object still equals the original object
+ try {
+ Method eq = obj.getClass().getDeclaredMethod("equals",
+ Object.class);
+ Boolean ret = (Boolean) eq.invoke(obj, newobj);
+ if (ret != true) {
+ System.err.println("serialization failed: " +
+ obj.getClass().getName());
+ exit(1);
+ }
+ } catch (Exception e) {
+ // Does not override equals(), although a super-class might.
+ // A better test would check for any superclass other than
+ // Object.class.
+ }
+ }
+
+ static void
+ performSerializationTest(File file, String classname)
+ throws IOException, ClassNotFoundException
+ {
+ String methodName = "get" + classname;
+ Object obj = null;
+ Object newobj = null;
+ try {
+ Method method = TestBean.class.getDeclaredMethod(methodName);
+ obj = method.invoke(null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+
+ System.out.println(classname + ":");
+ String serialized = getString(obj);
+ System.out.println(" serialized: " + serialized);
+ FileOutputStream fos = new FileOutputStream(file);
+ ObjectOutputStream out = new ObjectOutputStream(fos);
+ out.writeObject(obj);
+ out.close();
+ FileInputStream fis = new FileInputStream(file);
+ ObjectInputStream in = new ObjectInputStream(fis);
+ newobj = in.readObject();
+ in.close();
+ String deserialized = getString(newobj);
+ System.out.println(" deserialized: " + deserialized);
+
+ if (!serialized.equals(deserialized)) {
+ System.err.println("serialization failed: " + classname);
+ exit(1);
+ }
+ checkEquality(obj, newobj);
+ }
+
+ static void
+ performBeanTest(File file, String classname)
+ {
+ String methodName = "get" + classname;
+ Object obj = null;
+ Object newobj = null;
+ try {
+ Method method = TestBean.class.getDeclaredMethod(methodName);
+ obj = method.invoke(null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+
+ Class c = obj.getClass();
+ if (c.getConstructors().length == 0) {
+ return;
+ }
+
+ System.out.println(classname + ":");
+ XMLEncoder encoder = getXMLEncoder(file);
+ String encoded = getString(obj);
+ System.out.println(" encoded: " + encoded);
+ encoder.writeObject(obj);
+ encoder.close();
+ XMLDecoder decoder = getXMLDecoder(file);
+ newobj = decoder.readObject();
+ String decoded = getString(newobj);
+ System.out.println(" decoded: " + decoded);
+ decoder.close();
+
+ if (!encoded.equals(decoded)) {
+ System.err.println("bean persistence failed: " + classname);
+ exit(1);
+ }
+ checkEquality(obj, newobj);
+ }
+
+ public static void
+ main(String[] args)
+ {
+ if ((args.length != 1) && (args.length != 2)) {
+ System.err.println("usage: java TestBean < filename > " +
+ "[ < classname > ]");
+ exit(1);
+ }
+
+ String filename = args[0];
+ String classname = null;
+ if (args.length >= 2) {
+ classname = args[1];
+ }
+
+ file = new File(filename);
+ try {
+ if (!file.canRead()) {
+ try {
+ file.createNewFile();
+ } catch (Exception e) {
+ System.err.println("failed to create " + filename);
+ exit(1);
+ }
+ }
+ } catch (SecurityException e) {
+ System.err.println("failed to open " + filename);
+ exit(1);
+ }
+
+ String[] tests = (classname == null ? TESTS:
+ new String[] { classname });
+ try {
+ for (int i = 0; i < tests.length; ++i) {
+ performSerializationTest(file, tests[i]);
+ performBeanTest(file, tests[i]);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ exit(1);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestClose.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestClose.java
new file mode 100644
index 00000000..c7a9e89d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestClose.java
@@ -0,0 +1,90 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Regression for bug 6419880 close() hangs running consumer.
+ */
+public class TestClose {
+ public static void
+ main(String[] args)
+ {
+ Consumer consumer = new LocalConsumer();
+
+ try {
+ consumer.open();
+ consumer.compile("syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ consumer.enable();
+ consumer.go();
+ try {
+ Thread.currentThread().sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ consumer.close();
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ consumer = new LocalConsumer();
+
+ try {
+ consumer.open();
+ consumer.compile("syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ consumer.enable();
+ consumer.go();
+ try {
+ Thread.currentThread().sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ try {
+ // Test new rule that close() is illegal while holding
+ // lock on consumer.
+ synchronized (consumer) {
+ consumer.close();
+ }
+ } catch (IllegalThreadStateException e) {
+ consumer.close();
+ System.out.println("Successful");
+ System.exit(0);
+ }
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ System.err.println("Failed");
+ System.exit(1);
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestDrop.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestDrop.java
new file mode 100644
index 00000000..b5ace25b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestDrop.java
@@ -0,0 +1,169 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+import java.util.*;
+import java.util.concurrent.atomic.*;
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Regression test for 6521523 aggregation drops can hang the Java
+ * DTrace API.
+ */
+public class TestDrop {
+ static final String PROGRAM =
+ "fbt:genunix::entry { @[execname, pid] = count(); }";
+
+ static AtomicLong consumerThreadID = new AtomicLong();
+ static AtomicLong getAggregateThreadID = new AtomicLong();
+ static AtomicBoolean done = new AtomicBoolean();
+ static int seconds;
+
+ private static void
+ startTimer()
+ {
+ if (seconds <= 0) {
+ return;
+ }
+
+ final Timer timer = new Timer();
+ timer.schedule(new TimerTask() {
+ public void run() {
+ done.set(true);
+ timer.cancel();
+ }
+ }, seconds * 1000L);
+ }
+
+ private static void
+ sampleAggregate(Consumer consumer) throws DTraceException
+ {
+ while (consumer.isRunning() && !done.get()) {
+ try {
+ Thread.currentThread().sleep(50);
+ } catch (InterruptedException e) {
+ }
+
+ consumer.getAggregate(Collections. <String> emptySet());
+ }
+ }
+
+ private static void
+ startAggregateThread(final Consumer consumer)
+ {
+ Runnable aggregateSampler = new Runnable() {
+ public void run() {
+ Thread t = Thread.currentThread();
+ getAggregateThreadID.set(t.getId());
+ Throwable x = null;
+ try {
+ sampleAggregate(consumer);
+ } catch (Throwable e) {
+ x = e;
+ }
+
+ if (Thread.holdsLock(LocalConsumer.class)) {
+ if (x != null) {
+ x.printStackTrace();
+ }
+ System.out.println("Lock held");
+ System.exit(1);
+ } else {
+ System.out.println("Lock released");
+ consumer.close(); // blocks if lock held
+ }
+ }
+ };
+
+ Thread t = new Thread(aggregateSampler, "Aggregate Sampler");
+ t.start();
+ }
+
+ static void
+ usage()
+ {
+ System.err.println("usage: java TestDrop [ seconds ]");
+ System.exit(2);
+ }
+
+ public static void
+ main(String[] args)
+ {
+ if (args.length == 1) {
+ try {
+ seconds = Integer.parseInt(args[0]);
+ } catch (NumberFormatException e) {
+ usage();
+ }
+ } else if (args.length > 1) {
+ usage();
+ }
+
+ final Consumer consumer = new LocalConsumer() {
+ protected Thread createThread() {
+ Runnable worker = new Runnable() {
+ public void run() {
+ Thread t = Thread.currentThread();
+ consumerThreadID.set(t.getId());
+ work();
+ }
+ };
+ Thread t = new Thread(worker);
+ return t;
+ }
+ };
+
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ public void consumerStarted(ConsumerEvent e) {
+ startAggregateThread(consumer);
+ startTimer();
+ }
+ public void dataDropped(DropEvent e) throws ConsumerException {
+ Thread t = Thread.currentThread();
+ if (t.getId() == getAggregateThreadID.get()) {
+ Drop drop = e.getDrop();
+ throw new ConsumerException(drop.getDefaultMessage(),
+ drop);
+ }
+ }
+ });
+
+ try {
+ consumer.open();
+ consumer.setOption(Option.aggsize, Option.kb(1));
+ consumer.setOption(Option.aggrate, Option.millis(101));
+ consumer.compile(PROGRAM);
+ consumer.enable();
+ consumer.go(new ExceptionHandler() {
+ public void handleException(Throwable e) {
+ e.printStackTrace();
+ }
+ });
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestEnable.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestEnable.java
new file mode 100644
index 00000000..0e5a6086
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestEnable.java
@@ -0,0 +1,151 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Prove that enable() handles multiple programs, recognizing programs
+ * that are already enabled and programs that were compiled by another
+ * consumer.
+ */
+public class TestEnable {
+ static void
+ exit(int status)
+ {
+ System.out.flush();
+ System.err.flush();
+ System.exit(status);
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Consumer consumer = new LocalConsumer();
+
+ try {
+ consumer.open();
+ Program p0 = consumer.compile("dtrace:::BEGIN");
+ Program p1 = consumer.compile("syscall:::entry");
+ Program p2 = consumer.compile("dtrace:::END");
+ consumer.enable(p0);
+ consumer.enable(p1);
+ try {
+ consumer.go();
+ System.err.println("go() illegal, not all programs " +
+ "enabled (p0, p1)");
+ exit(1);
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ try {
+ consumer.enable();
+ System.err.println("enable() illegal, some programs " +
+ "already enabled (p0, p1)");
+ exit(1);
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ try {
+ consumer.enable(p0);
+ System.err.println("cannot enable a program that " +
+ "has already been enabled (p0)");
+ exit(1);
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ consumer.enable(p2);
+ Program p3 = consumer.compile("syscall:::return");
+ try {
+ consumer.go();
+ System.err.println("go() illegal, not all programs " +
+ "enabled (p0, p1, p2)");
+ exit(1);
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ try {
+ consumer.enable();
+ System.err.println("enable() illegal, some programs " +
+ "already enabled (p0, p1, p2)");
+ exit(1);
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ // Try to fool the consumer with a program compiled by
+ // another consumer
+ Consumer consumer2 = new LocalConsumer();
+ consumer2.open();
+ Program p3x = consumer2.compile("syscall:::return");
+ try {
+ consumer.enable(p3x);
+ System.err.println("cannot enable program compiled " +
+ "by another consumer");
+ exit(1);
+ } catch (IllegalArgumentException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1);
+ } finally {
+ consumer2.close();
+ }
+ consumer.enable(p3);
+ consumer.go();
+ consumer.close();
+
+ // Enable all compiled programs at once
+ consumer = new LocalConsumer();
+ consumer.open();
+ consumer.compile("dtrace:::BEGIN");
+ consumer.compile("syscall:::entry");
+ consumer.compile("dtrace:::END");
+ consumer.enable();
+ consumer.go();
+ consumer.close();
+ exit(0);
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java
new file mode 100644
index 00000000..2bc43ea6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java
@@ -0,0 +1,114 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Regression for bug 6413280 lookupKernelFunction() and
+ * lookupUserFunction() truncate last character.
+ */
+public class TestFunctionLookup {
+ static final String kernelLookupProgram = "sdt:::callout-start { " +
+ "@[((callout_t *)arg0)->c_func] = count(); }";
+ static final String userLookupProgram = "pid$target::f2:entry { " +
+ "@[arg0] = count(); }";
+
+ public static void
+ main(String[] args)
+ {
+ if (args.length != 1) {
+ System.err.println("usage: java TestFunctionLookup <command>");
+ System.exit(1);
+ }
+ String cmd = args[0];
+
+ Consumer consumer = new LocalConsumer();
+ try {
+ consumer.open();
+ consumer.compile(kernelLookupProgram);
+ consumer.enable();
+ consumer.go();
+ Aggregate a;
+ Number address;
+ String f;
+ boolean done = false;
+ for (int i = 0; (i < 20) && !done; ++i) {
+ Thread.currentThread().sleep(100);
+ a = consumer.getAggregate();
+ for (Aggregation agg : a.getAggregations()) {
+ for (Tuple tuple : agg.asMap().keySet()) {
+ address = (Number)tuple.get(0).getValue();
+ if (address instanceof Integer) {
+ int addr = (Integer)address;
+ f = consumer.lookupKernelFunction(addr);
+ } else {
+ long addr = (Long)address;
+ f = consumer.lookupKernelFunction(addr);
+ }
+ if (f.equals("genunix`cv_wakeup")) {
+ System.out.println(f);
+ done = true;
+ }
+ }
+ }
+ }
+ consumer.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ consumer = new LocalConsumer();
+ try {
+ consumer.open();
+ int pid = consumer.createProcess(cmd);
+ consumer.compile(userLookupProgram);
+ consumer.enable();
+ consumer.go();
+ Thread.currentThread().sleep(500);
+ Aggregate a = consumer.getAggregate();
+ Number address;
+ String f;
+ for (Aggregation agg : a.getAggregations()) {
+ for (Tuple tuple : agg.asMap().keySet()) {
+ address = (Number)tuple.get(0).getValue();
+ if (address instanceof Integer) {
+ int addr = (Integer)address;
+ f = consumer.lookupUserFunction(pid, addr);
+ } else {
+ long addr = (Long)address;
+ f = consumer.lookupUserFunction(pid, addr);
+ }
+ System.out.println(f);
+ }
+ }
+ consumer.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestGetAggregate.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestGetAggregate.java
new file mode 100644
index 00000000..e02df858
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestGetAggregate.java
@@ -0,0 +1,252 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+import org.opensolaris.os.dtrace.*;
+import java.util.*;
+
+/**
+ * Assert getAggregate() can explicitly specify the anonymous aggregation.
+ */
+public class TestGetAggregate {
+ static final String programString =
+ "profile:::tick-50ms" +
+ "{" +
+ " @ = count();" +
+ " @a = count();" +
+ "}";
+
+ static final String ANONYMOUS_AGGREGATION = "";
+ static final int TICK = 50;
+ static final int EXPECTED_TICKS = 3;
+ static final int INTERVALS = 4;
+
+ static void
+ testIncluded(Consumer consumer, String ... aggregationNames)
+ throws DTraceException, InterruptedException
+ {
+ Aggregate aggregate;
+ Set <String> included = new HashSet <String> ();
+ int n = 1;
+
+ for (String name : aggregationNames) {
+ included.add(name);
+ }
+
+ // Wait up to a full second to obtain aggregate data. Without a
+ // time limit, we'll loop forever if no aggregation was
+ // successfully included.
+ do {
+ Thread.sleep(TICK);
+ aggregate = consumer.getAggregate(included, null);
+ } while (aggregate.asMap().isEmpty() && n++ < (1000 / TICK));
+
+ for (String name : included) {
+ if (aggregate.getAggregation(name) == null) {
+ throw new IllegalStateException("@" + name +
+ " was explicitly included but did not appear " +
+ "in the aggregate");
+ }
+ }
+ for (Aggregation a : aggregate.getAggregations()) {
+ if (!included.contains(a.getName())) {
+ throw new IllegalStateException("@" + a.getName() +
+ " was not explicitly included but appeared " +
+ "in the aggregate anyway");
+ }
+ }
+
+ if (!consumer.isRunning()) {
+ throw new IllegalStateException("consumer exited");
+ }
+ }
+
+ static void
+ testCleared(Consumer consumer, String ... aggregationNames)
+ throws DTraceException, InterruptedException
+ {
+ Aggregate aggregate;
+ AggregationRecord rec;
+ long value;
+ Long firstValue;
+ int n = 1;
+ Map <String, Long> firstValues = new HashMap <String, Long> ();
+ Set <String> cleared = new HashSet <String> ();
+
+ for (String name : aggregationNames) {
+ cleared.add(name);
+ }
+
+ do {
+ Thread.sleep(TICK);
+ aggregate = consumer.getAggregate(null, cleared);
+ } while (aggregate.asMap().isEmpty() && n++ < (1000 / TICK));
+ n = 1;
+
+ do {
+ Thread.sleep(TICK * EXPECTED_TICKS);
+ aggregate = consumer.getAggregate(null, cleared);
+
+ for (Aggregation a : aggregate.getAggregations()) {
+ if (!firstValues.containsKey(a.getName())) {
+ rec = a.getRecord(Tuple.EMPTY);
+ value = rec.getValue().getValue().longValue();
+ firstValues.put(a.getName(), value);
+ }
+ }
+ } while (consumer.isRunning() && n++ < INTERVALS);
+
+ for (Aggregation a : aggregate.getAggregations()) {
+ rec = a.getRecord(Tuple.EMPTY);
+ value = rec.getValue().getValue().longValue();
+ firstValue = firstValues.get(a.getName());
+
+ if (cleared.contains(a.getName())) {
+ // last value should be about the same as first value
+ if (value > (firstValue * 2)) {
+ throw new IllegalStateException(
+ "@" + a.getName() + " should have " +
+ "been cleared but instead grew from " +
+ firstValue + " to " + value);
+ }
+ } else {
+ // last value should be about (INTERVALS * firstValue)
+ if (value < (firstValue * 2)) {
+ throw new IllegalStateException(
+ "@" + a.getName() + " should have " +
+ "accumulated a running total but " +
+ "instead went from " +
+ firstValue + " to " + value);
+ }
+ }
+ }
+
+ if (!consumer.isRunning()) {
+ throw new IllegalStateException("consumer exited");
+ }
+ }
+
+ static Integer includedStatus;
+ static Integer clearedStatus;
+
+ static void
+ startIncludedTest()
+ {
+ final Consumer consumer = new LocalConsumer();
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ public void consumerStarted(ConsumerEvent e) {
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ testIncluded(consumer, ANONYMOUS_AGGREGATION);
+ includedStatus = 0;
+ } catch (Exception e) {
+ includedStatus = 1;
+ e.printStackTrace();
+ } finally {
+ consumer.abort();
+ }
+ }
+ }).start();
+ }
+ });
+
+ try {
+ consumer.open();
+ consumer.setOption(Option.aggrate, Option.millis(TICK));
+ consumer.compile(programString);
+ consumer.enable();
+ consumer.go();
+ } catch (Exception e) {
+ includedStatus = 1;
+ e.printStackTrace();
+ }
+ }
+
+ static void
+ startClearedTest()
+ {
+ final Consumer consumer = new LocalConsumer();
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ public void consumerStarted(ConsumerEvent e) {
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ testCleared(consumer, ANONYMOUS_AGGREGATION);
+ clearedStatus = 0;
+ } catch (Exception e) {
+ clearedStatus = 1;
+ e.printStackTrace();
+ } finally {
+ consumer.abort();
+ }
+ }
+ }).start();
+ }
+ });
+
+ try {
+ consumer.open();
+ consumer.setOption(Option.aggrate, Option.millis(TICK));
+ consumer.compile(programString);
+ consumer.enable();
+ consumer.go();
+ } catch (Exception e) {
+ clearedStatus = 1;
+ e.printStackTrace();
+ }
+ }
+
+ public static void
+ main(String[] args)
+ {
+ startIncludedTest();
+
+ do {
+ try {
+ Thread.sleep(TICK);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ } while (includedStatus == null);
+
+ startClearedTest();
+
+ do {
+ try {
+ Thread.sleep(TICK);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ } while (clearedStatus == null);
+
+ if (includedStatus != 0 || clearedStatus != 0) {
+ System.out.println("Failure");
+ System.exit(1);
+ }
+
+ System.out.println("Success");
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMaxConsumers.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMaxConsumers.java
new file mode 100644
index 00000000..50eeac23
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMaxConsumers.java
@@ -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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Regression for 6506495 -DJAVA_DTRACE_MAX_CONSUMERS=N for any N &lt; 8
+ * is treated as if it were 8.
+ */
+public class TestMaxConsumers {
+ static final String MAX_CONSUMERS_PROPERTY_NAME =
+ "JAVA_DTRACE_MAX_CONSUMERS";
+
+ static Integer
+ getIntegerProperty(String name)
+ {
+ Integer value = null;
+ String property = System.getProperty(name);
+ if (property != null && property.length() != 0) {
+ try {
+ value = Integer.parseInt(property);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
+ return value;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Integer property = getIntegerProperty(MAX_CONSUMERS_PROPERTY_NAME);
+ int max = (property == null ? 0 : property);
+ int n = (property == null ? 11 : (max < 1 ? 1 : max));
+
+ Consumer[] consumers = new Consumer[n];
+ try {
+ for (int i = 0; i < n; ++i) {
+ consumers[i] = new LocalConsumer();
+ consumers[i].open();
+ }
+ for (int i = 0; i < n; ++i) {
+ consumers[i].close();
+ }
+ for (int i = 0; i < n; ++i) {
+ consumers[i] = new LocalConsumer();
+ consumers[i].open();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ try {
+ Consumer consumer = new LocalConsumer();
+ consumer.open();
+ if (max > 0) {
+ System.out.println("Error: " + (max + 1) + " > " +
+ MAX_CONSUMERS_PROPERTY_NAME);
+ } else {
+ System.out.println("Success");
+ }
+ consumer.close();
+ } catch (Exception e) {
+ System.out.println("Success");
+ } finally {
+ for (int i = 0; i < n; ++i) {
+ consumers[i].close();
+ }
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMultiAggPrinta.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMultiAggPrinta.java
new file mode 100644
index 00000000..facdf7fa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestMultiAggPrinta.java
@@ -0,0 +1,144 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Regression for multi-aggregation printa() corner cases.
+ */
+public class TestMultiAggPrinta {
+ static int exitStatus;
+
+ // Gets a string representation of the given PrintaRecord minus the
+ // timestamp of the aggregate snapshot, so that the output is
+ // comparable across multiple test runs.
+ static String
+ printaRecordString(PrintaRecord rec)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append(PrintaRecord.class.getName());
+ buf.append("[aggregations = ");
+ buf.append(rec.getAggregations());
+ buf.append(", formattedStrings = ");
+ buf.append(rec.getFormattedStrings());
+ buf.append(", tuples = ");
+ buf.append(rec.getTuples());
+ buf.append(", output = ");
+ buf.append(rec.getOutput());
+ buf.append(']');
+ return buf.toString();
+ }
+
+ static String
+ probeDataString(ProbeData data)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append(ProbeData.class.getName());
+ buf.append("[epid = ");
+ buf.append(data.getEnabledProbeID());
+ // Do not include cpu, since it can change across test runs
+ buf.append(", enabledProbeDescription = ");
+ buf.append(data.getEnabledProbeDescription());
+ buf.append(", flow = ");
+ buf.append(data.getFlow());
+ buf.append(", records = ");
+
+ List <Record> records = data.getRecords();
+ Record record;
+ Object value;
+ buf.append('[');
+ for (int i = 0; i < records.size(); ++i) {
+ if (i > 0) {
+ buf.append(", ");
+ }
+ record = records.get(i);
+ if (record instanceof ValueRecord) {
+ value = ((ValueRecord)record).getValue();
+ if (value instanceof String) {
+ buf.append("\"");
+ buf.append((String)value);
+ buf.append("\"");
+ } else {
+ buf.append(record);
+ }
+ } else if (record instanceof PrintaRecord) {
+ PrintaRecord printa = (PrintaRecord)record;
+ buf.append(printaRecordString(printa));
+ } else {
+ buf.append(record);
+ }
+ }
+ buf.append(']');
+ return buf.toString();
+ }
+
+ public static void
+ main(String[] args)
+ {
+ if (args.length != 1) {
+ System.err.println("usage: java TestMultiAggPrinta <script>");
+ System.exit(2);
+ }
+
+ final Consumer consumer = new LocalConsumer();
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ public void dataReceived(DataEvent e) {
+ ProbeData data = e.getProbeData();
+ List <Record> records = data.getRecords();
+ for (Record r : records) {
+ if (r instanceof ExitRecord) {
+ ExitRecord exitRecord = (ExitRecord)r;
+ exitStatus = exitRecord.getStatus();
+ }
+ }
+ System.out.println(probeDataString(e.getProbeData()));
+ }
+ public void consumerStopped(ConsumerEvent e) {
+ consumer.close();
+ System.exit(exitStatus);
+ }
+ });
+
+ File file = new File(args[0]);
+ try {
+ consumer.open();
+ consumer.compile(file);
+ consumer.enable();
+ consumer.go();
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeData.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeData.java
new file mode 100644
index 00000000..78a65f9e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeData.java
@@ -0,0 +1,110 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import java.util.*;
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Regression test verifies that ProbeData instances sort as expected
+ * with multiple enabled probe IDs and multiple records including byte
+ * array (sorted as unsigned bytes), stand-alone ufunc() action, and
+ * signed integer.
+ */
+public class TestProbeData {
+ public static final String PROGRAM =
+ "pid$target::fN:entry\n" +
+ "{\n" +
+ " tracemem(copyin(arg1, 6), 6);\n" +
+ " ufunc(arg0);\n" +
+ " trace((int)arg2);\n" +
+ "}" +
+ "" +
+ "pid$target::fN2:entry\n" +
+ "{\n" +
+ " tracemem(copyin(arg1, 6), 6);\n" +
+ " ufunc(arg0);\n" +
+ " trace((int)arg2);\n" +
+ "}";
+
+ static String
+ getString(ProbeData p)
+ {
+ StringBuilder buf = new StringBuilder();
+ buf.append("[probe ");
+ buf.append(p.getEnabledProbeID());
+ buf.append(' ');
+ ProbeDescription d = p.getEnabledProbeDescription();
+ buf.append("pid$target");
+ buf.append(':');
+ buf.append(d.getModule());
+ buf.append(':');
+ buf.append(d.getFunction());
+ buf.append(':');
+ buf.append(d.getName());
+ buf.append(' ');
+ buf.append(p.getRecords());
+ buf.append("]");
+ return buf.toString();
+ }
+
+ public static void
+ main(String[] args)
+ {
+ if (args.length != 1) {
+ System.err.println("usage: java TestProbedata <command>");
+ System.exit(2);
+ }
+
+ String command = args[0];
+ final Consumer consumer = new LocalConsumer();
+ final List <ProbeData> list = new ArrayList <ProbeData> ();
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ public void dataReceived(DataEvent e) {
+ list.add(e.getProbeData());
+ }
+ public void consumerStopped(ConsumerEvent e) {
+ Collections.sort(list);
+ for (ProbeData p : list) {
+ System.out.println(getString(p));
+ System.out.println();
+ }
+ consumer.close();
+ }
+ });
+
+ try {
+ consumer.open();
+ consumer.createProcess(command);
+ consumer.compile(PROGRAM);
+ consumer.enable();
+ consumer.go();
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeDescription.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeDescription.java
new file mode 100644
index 00000000..b9e95700
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestProbeDescription.java
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+import java.util.logging.*;
+
+/**
+ * Regression for 6399915 ProbeDescription single arg constructor should
+ * parse probe descriptions.
+ */
+public class TestProbeDescription {
+ public static void
+ main(String[] args)
+ {
+ ProbeDescription p = null;
+ int len = args.length;
+ if (len == 0) {
+ p = new ProbeDescription("syscall:::entry");
+ } else if (len == 1) {
+ p = new ProbeDescription(args[0]);
+ } else if (len == 2) {
+ p = new ProbeDescription(args[0], args[1]);
+ } else if (len == 3) {
+ p = new ProbeDescription(args[0], args[1], args[2]);
+ } else if (len == 4) {
+ p = new ProbeDescription(args[0], args[1], args[2], args[3]);
+ }
+ System.out.println(p);
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStateMachine.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStateMachine.java
new file mode 100644
index 00000000..8875d066
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStateMachine.java
@@ -0,0 +1,627 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Regression test for the LocalConsumer state machine. Calls Consumer
+ * methods before and after open(), compile(), enable(), go(), stop(),
+ * and close() to verify that the calls succeed as expected or fail with
+ * the expected Java exception.
+ */
+public class TestStateMachine {
+ static Program program;
+
+ static void
+ exit(int status)
+ {
+ exit(status, null);
+ }
+
+ static void
+ exit(int status, String msg)
+ {
+ if (msg != null) {
+ System.out.println(msg);
+ }
+ System.out.flush();
+ System.err.flush();
+ System.exit(status);
+ }
+
+ static void
+ printState(Consumer consumer)
+ {
+ System.out.println("open: " + consumer.isOpen());
+ System.out.println("enabled: " + consumer.isEnabled());
+ System.out.println("closed: " + consumer.isClosed());
+ }
+
+ static void
+ beforeOpen(Consumer consumer)
+ {
+ System.out.println("before open");
+ printState(consumer);
+
+ // compile
+ try {
+ consumer.compile("syscall:::entry");
+ exit(1, "compile before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "compile before open");
+ }
+
+ // enable
+ try {
+ consumer.enable();
+ exit(1, "enable before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "enable before open");
+ }
+
+ // getOption, setOption, unsetOption
+ try {
+ consumer.getOption(Option.bufsize);
+ exit(1, "getOption before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getOption before open");
+ }
+ try {
+ consumer.setOption(Option.bufsize, Option.mb(1));
+ exit(1, "setOption before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "setOption before open");
+ }
+ try {
+ consumer.unsetOption(Option.quiet);
+ exit(1, "unsetOption before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "unsetOption before open");
+ }
+
+ // createProcess, grabProcess
+ try {
+ consumer.createProcess("date");
+ exit(1, "createProcess before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "createProcess before open");
+ }
+ try {
+ consumer.grabProcess(1);
+ exit(1, "grabProcess before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "grabProcess before open");
+ }
+
+ // listProbes
+ try {
+ consumer.listProbes(ProbeDescription.EMPTY);
+ exit(1, "listProbes before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "listProbes before open");
+ }
+
+ // getAggregate
+ try {
+ consumer.getAggregate();
+ exit(1, "getAggregate before open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getAggregate before open");
+ }
+
+ // getVersion
+ try {
+ consumer.getVersion(); // allowed
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getVersion before open");
+ }
+ }
+
+ static void
+ beforeCompile(Consumer consumer)
+ {
+ System.out.println("before compile");
+ printState(consumer);
+
+ // open
+ try {
+ consumer.open();
+ exit(1, "open after open");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "open after open");
+ }
+
+ // enable
+ try {
+ consumer.enable();
+ exit(1, "enable before compile");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "enable before compile");
+ }
+ }
+
+ static void
+ beforeEnable(Consumer consumer)
+ {
+ System.out.println("before enable");
+ printState(consumer);
+
+ // go
+ try {
+ consumer.go();
+ exit(1, "go before enable");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "go before enable");
+ }
+ }
+
+ static void
+ beforeGo(Consumer consumer)
+ {
+ System.out.println("before go");
+ printState(consumer);
+
+ // getAggregate
+ try {
+ consumer.getAggregate();
+ exit(1, "getAggregate before go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getAggregate before go");
+ }
+
+ // lookupKernelFunction, lookupUserFunction
+ try {
+ consumer.lookupKernelFunction(1);
+ exit(1, "lookupKernelFunction before go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "lookupKernelFunction before go");
+ }
+ try {
+ consumer.lookupUserFunction(1, 1);
+ exit(1, "lookupUserFunction before go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "lookupUserFunction before go");
+ }
+
+ // stop
+ try {
+ consumer.stop();
+ exit(1, "stop before go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "stop before go");
+ }
+ }
+
+ static void
+ afterGo(Consumer consumer, Program program)
+ {
+ System.out.println("after go");
+ printState(consumer);
+
+ // go
+ try {
+ consumer.go();
+ exit(1, "go after go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "go after go");
+ }
+
+ // createProcess, grabProcess
+ try {
+ consumer.createProcess("date");
+ exit(1, "createProcess after go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "createProcess after go");
+ }
+ try {
+ consumer.grabProcess(1);
+ exit(1, "grabProcess after go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "grabProcess after go");
+ }
+
+ // listProbes
+ try {
+ consumer.listProbes(ProbeDescription.EMPTY);
+ exit(1, "listProbes after go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "listProbes after go");
+ }
+
+ // compile
+ try {
+ consumer.compile("syscall:::entry");
+ exit(1, "compile after go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "compile after go");
+ }
+
+ // enable
+ try {
+ consumer.enable();
+ exit(1, "enable after go");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "enable after go");
+ }
+
+ // getAggregate
+ try {
+ consumer.getAggregate();
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getAggregate after go");
+ }
+
+ // getProgramInfo
+ try {
+ consumer.getProgramInfo(program);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getProgramInfo after go");
+ }
+
+ // getOption, setOption, unsetOption
+ try {
+ consumer.getOption(Option.quiet);
+ consumer.setOption(Option.quiet);
+ consumer.unsetOption(Option.quiet);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "get, set, unset option after go");
+ }
+ }
+
+ static void
+ afterStop(Consumer consumer, Program program)
+ {
+ System.out.println("after stop");
+ printState(consumer);
+
+ // stop
+ try {
+ consumer.stop();
+ exit(1, "stop after stop");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "stop after stop");
+ }
+
+ // getAggregate
+ try {
+ consumer.getAggregate();
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getAggregate after stop");
+ }
+
+ // getProgramInfo
+ try {
+ consumer.getProgramInfo(program);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getProgramInfo after stop");
+ }
+
+ // getOption, setOption, unsetOption
+ try {
+ consumer.getOption(Option.quiet);
+ consumer.setOption(Option.quiet);
+ consumer.unsetOption(Option.quiet);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "get, set, unset option after stop");
+ }
+ }
+
+ static void
+ afterClose(Consumer consumer, Program program)
+ {
+ System.out.println("after close");
+ printState(consumer);
+
+ // open
+ try {
+ consumer.open();
+ exit(1, "open after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "open after close");
+ }
+
+ // compile
+ try {
+ consumer.compile("syscall:::entry");
+ exit(1, "compile after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "compile after close");
+ }
+
+ // enable
+ try {
+ consumer.enable();
+ exit(1, "enable after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "enable after close");
+ }
+
+ // getOption, setOption, unsetOption
+ try {
+ consumer.getOption(Option.bufsize);
+ exit(1, "getOption after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getOption after close");
+ }
+ try {
+ consumer.setOption(Option.bufsize, Option.mb(1));
+ exit(1, "setOption after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "setOption after close");
+ }
+ try {
+ consumer.unsetOption(Option.quiet);
+ exit(1, "unsetOption after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "unsetOption after close");
+ }
+
+ // createProcess, grabProcess
+ try {
+ consumer.createProcess("date");
+ exit(1, "createProcess after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "createProcess after close");
+ }
+ try {
+ consumer.grabProcess(1);
+ exit(1, "grabProcess after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "grabProcess after close");
+ }
+
+ // listProbes
+ try {
+ consumer.listProbes(ProbeDescription.EMPTY);
+ exit(1, "listProbes after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "listProbes after close");
+ }
+
+ // getAggregate
+ try {
+ consumer.getAggregate();
+ exit(1, "getAggregate after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getAggregate after close");
+ }
+
+ // getVersion
+ try {
+ consumer.getVersion(); // allowed
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getVersion after close");
+ }
+
+ // go
+ try {
+ consumer.go();
+ exit(1, "go after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "go after close");
+ }
+
+ // lookupKernelFunction, lookupUserFunction
+ try {
+ consumer.lookupKernelFunction(1);
+ exit(1, "lookupKernelFunction after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "lookupKernelFunction after close");
+ }
+ try {
+ consumer.lookupUserFunction(1, 1);
+ exit(1, "lookupUserFunction after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "lookupUserFunction after close");
+ }
+
+ // stop
+ try {
+ consumer.stop();
+ exit(1, "stop after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "stop after close");
+ }
+
+ // getProgramInfo
+ try {
+ consumer.getProgramInfo(program);
+ exit(1, "getProgramInfo after close");
+ } catch (IllegalStateException e) {
+ System.out.println(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exit(1, "getProgramInfo after close");
+ }
+ }
+
+ public static void
+ main(String[] args)
+ {
+ final Consumer consumer = new LocalConsumer();
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ public void consumerStarted(ConsumerEvent e) {
+ System.out.println("consumerStarted, running: " +
+ consumer.isRunning());
+ afterGo(consumer, program);
+ }
+ public void consumerStopped(ConsumerEvent e) {
+ System.out.println("consumerStopped, running: " +
+ consumer.isRunning());
+ }
+ });
+
+ try {
+ beforeOpen(consumer);
+ consumer.open();
+ beforeCompile(consumer);
+ program = consumer.compile(
+ "syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ beforeEnable(consumer);
+ consumer.enable();
+ beforeGo(consumer);
+ System.out.println("before go, running: " + consumer.isRunning());
+ consumer.go();
+ // Avoid race, call afterGo() in ConsumerListener
+ try {
+ Thread.currentThread().sleep(300);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ consumer.stop();
+ System.out.println("after stop, running: " + consumer.isRunning());
+ afterStop(consumer, program);
+ consumer.close();
+ afterClose(consumer, program);
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ exit(1);
+ }
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStopLock.java b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStopLock.java
new file mode 100644
index 00000000..f37c9cf1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/src/TestStopLock.java
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * ident "%Z%%M% %I% %E% SMI"
+ */
+
+import org.opensolaris.os.dtrace.*;
+
+/**
+ * Test for bug 6399888 stop() hangs if ConsumerListener calls
+ * synchronized Consumer method
+ */
+public class TestStopLock {
+ public static void
+ main(String[] args)
+ {
+ final Consumer consumer = new LocalConsumer();
+ consumer.addConsumerListener(new ConsumerAdapter() {
+ @Override
+ public void intervalBegan(ConsumerEvent e) {
+ consumer.isRunning();
+ }
+ });
+
+ try {
+ consumer.open();
+ consumer.compile("syscall:::entry { @[execname] = count(); } " +
+ "tick-101ms { printa(@); }");
+ consumer.enable();
+ consumer.go();
+ try {
+ Thread.currentThread().sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ consumer.stop();
+ consumer.close();
+ } catch (DTraceException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ System.out.println("Successful");
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh
new file mode 100755
index 00000000..85c2c706
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh
@@ -0,0 +1,39 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Fixed bug 6426129 abort() after close() throws
+# NoSuchElementException.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestAbort
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh.out
new file mode 100644
index 00000000..628d7870
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Abort.ksh.out
@@ -0,0 +1 @@
+Successful
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh
new file mode 100755
index 00000000..99b232eb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh
@@ -0,0 +1,41 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# All Serializable classes can be serializaed and deserialized,
+# also encoded in XML and decoded, and still remain equal and have
+# equal string values.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestBean TestBean.out
+rm -f TestBean.out
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh.out
new file mode 100644
index 00000000..cf24c672
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Bean.ksh.out
@@ -0,0 +1,722 @@
+ExitRecord:
+ serialized: 1
+ deserialized: 1
+ExitRecord:
+ encoded: 1
+ decoded: 1
+AggregationRecord:
+ serialized: org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]
+ deserialized: org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]
+AggregationRecord:
+ encoded: org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]
+ decoded: org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]
+Aggregation:
+ serialized: org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]
+ deserialized: org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]
+Aggregation:
+ encoded: org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]
+ decoded: org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]
+Tuple:
+ serialized: [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]
+ deserialized: [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]
+Tuple:
+ encoded: [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]
+ decoded: [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]
+ScalarRecord:
+ serialized: [1, 2, 3]
+ deserialized: [1, 2, 3]
+ScalarRecord:
+ encoded: [1, 2, 3]
+ decoded: [1, 2, 3]
+KernelStackRecord:
+ serialized:
+ Frame 1
+ Frame 2
+ Frame 3
+
+ deserialized:
+ Frame 1
+ Frame 2
+ Frame 3
+
+KernelStackRecord:
+ encoded:
+ Frame 1
+ Frame 2
+ Frame 3
+
+ decoded:
+ Frame 1
+ Frame 2
+ Frame 3
+
+LogDistribution:
+ serialized: org.opensolaris.os.dtrace.Distribution[buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = -4611686018427387904, max = -2305843009213693953, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2305843009213693952, max = -1152921504606846977, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1152921504606846976, max = -576460752303423489, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = -576460752303423488, max = -288230376151711745, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = -288230376151711744, max = -144115188075855873, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = -144115188075855872, max = -72057594037927937, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = -72057594037927936, max = -36028797018963969, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = -36028797018963968, max = -18014398509481985, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = -18014398509481984, max = -9007199254740993, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = -9007199254740992, max = -4503599627370497, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4503599627370496, max = -2251799813685249, frequency = 10], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2251799813685248, max = -1125899906842625, frequency = 11], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1125899906842624, max = -562949953421313, frequency = 12], org.opensolaris.os.dtrace.Distribution$Bucket[min = -562949953421312, max = -281474976710657, frequency = 13], org.opensolaris.os.dtrace.Distribution$Bucket[min = -281474976710656, max = -140737488355329, frequency = 14], org.opensolaris.os.dtrace.Distribution$Bucket[min = -140737488355328, max = -70368744177665, frequency = 15], org.opensolaris.os.dtrace.Distribution$Bucket[min = -70368744177664, max = -35184372088833, frequency = 16], org.opensolaris.os.dtrace.Distribution$Bucket[min = -35184372088832, max = -17592186044417, frequency = 17], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17592186044416, max = -8796093022209, frequency = 18], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8796093022208, max = -4398046511105, frequency = 19], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4398046511104, max = -2199023255553, frequency = 20], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2199023255552, max = -1099511627777, frequency = 21], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1099511627776, max = -549755813889, frequency = 22], org.opensolaris.os.dtrace.Distribution$Bucket[min = -549755813888, max = -274877906945, frequency = 23], org.opensolaris.os.dtrace.Distribution$Bucket[min = -274877906944, max = -137438953473, frequency = 24], org.opensolaris.os.dtrace.Distribution$Bucket[min = -137438953472, max = -68719476737, frequency = 25], org.opensolaris.os.dtrace.Distribution$Bucket[min = -68719476736, max = -34359738369, frequency = 26], org.opensolaris.os.dtrace.Distribution$Bucket[min = -34359738368, max = -17179869185, frequency = 27], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17179869184, max = -8589934593, frequency = 28], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8589934592, max = -4294967297, frequency = 29], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4294967296, max = -2147483649, frequency = 30], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2147483648, max = -1073741825, frequency = 31], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1073741824, max = -536870913, frequency = 32], org.opensolaris.os.dtrace.Distribution$Bucket[min = -536870912, max = -268435457, frequency = 33], org.opensolaris.os.dtrace.Distribution$Bucket[min = -268435456, max = -134217729, frequency = 34], org.opensolaris.os.dtrace.Distribution$Bucket[min = -134217728, max = -67108865, frequency = 35], org.opensolaris.os.dtrace.Distribution$Bucket[min = -67108864, max = -33554433, frequency = 36], org.opensolaris.os.dtrace.Distribution$Bucket[min = -33554432, max = -16777217, frequency = 37], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16777216, max = -8388609, frequency = 38], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8388608, max = -4194305, frequency = 39], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4194304, max = -2097153, frequency = 40], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2097152, max = -1048577, frequency = 41], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1048576, max = -524289, frequency = 42], org.opensolaris.os.dtrace.Distribution$Bucket[min = -524288, max = -262145, frequency = 43], org.opensolaris.os.dtrace.Distribution$Bucket[min = -262144, max = -131073, frequency = 44], org.opensolaris.os.dtrace.Distribution$Bucket[min = -131072, max = -65537, frequency = 45], org.opensolaris.os.dtrace.Distribution$Bucket[min = -65536, max = -32769, frequency = 46], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32768, max = -16385, frequency = 47], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16384, max = -8193, frequency = 48], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8192, max = -4097, frequency = 49], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4096, max = -2049, frequency = 50], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2048, max = -1025, frequency = 51], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1024, max = -513, frequency = 52], org.opensolaris.os.dtrace.Distribution$Bucket[min = -512, max = -257, frequency = 53], org.opensolaris.os.dtrace.Distribution$Bucket[min = -256, max = -129, frequency = 54], org.opensolaris.os.dtrace.Distribution$Bucket[min = -128, max = -65, frequency = 55], org.opensolaris.os.dtrace.Distribution$Bucket[min = -64, max = -33, frequency = 56], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32, max = -17, frequency = 57], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16, max = -9, frequency = 58], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8, max = -5, frequency = 59], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4, max = -3, frequency = 60], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2, max = -2, frequency = 61], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1, max = -1, frequency = 62], org.opensolaris.os.dtrace.Distribution$Bucket[min = 0, max = 0, frequency = 63], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 1, frequency = 64], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2, max = 3, frequency = 65], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4, max = 7, frequency = 66], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8, max = 15, frequency = 67], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16, max = 31, frequency = 68], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32, max = 63, frequency = 69], org.opensolaris.os.dtrace.Distribution$Bucket[min = 64, max = 127, frequency = 70], org.opensolaris.os.dtrace.Distribution$Bucket[min = 128, max = 255, frequency = 71], org.opensolaris.os.dtrace.Distribution$Bucket[min = 256, max = 511, frequency = 72], org.opensolaris.os.dtrace.Distribution$Bucket[min = 512, max = 1023, frequency = 73], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1024, max = 2047, frequency = 74], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2048, max = 4095, frequency = 75], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4096, max = 8191, frequency = 76], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8192, max = 16383, frequency = 77], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16384, max = 32767, frequency = 78], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32768, max = 65535, frequency = 79], org.opensolaris.os.dtrace.Distribution$Bucket[min = 65536, max = 131071, frequency = 80], org.opensolaris.os.dtrace.Distribution$Bucket[min = 131072, max = 262143, frequency = 81], org.opensolaris.os.dtrace.Distribution$Bucket[min = 262144, max = 524287, frequency = 82], org.opensolaris.os.dtrace.Distribution$Bucket[min = 524288, max = 1048575, frequency = 83], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1048576, max = 2097151, frequency = 84], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2097152, max = 4194303, frequency = 85], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4194304, max = 8388607, frequency = 86], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8388608, max = 16777215, frequency = 87], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16777216, max = 33554431, frequency = 88], org.opensolaris.os.dtrace.Distribution$Bucket[min = 33554432, max = 67108863, frequency = 89], org.opensolaris.os.dtrace.Distribution$Bucket[min = 67108864, max = 134217727, frequency = 90], org.opensolaris.os.dtrace.Distribution$Bucket[min = 134217728, max = 268435455, frequency = 91], org.opensolaris.os.dtrace.Distribution$Bucket[min = 268435456, max = 536870911, frequency = 92], org.opensolaris.os.dtrace.Distribution$Bucket[min = 536870912, max = 1073741823, frequency = 93], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1073741824, max = 2147483647, frequency = 94], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2147483648, max = 4294967295, frequency = 95], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4294967296, max = 8589934591, frequency = 96], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8589934592, max = 17179869183, frequency = 97], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17179869184, max = 34359738367, frequency = 98], org.opensolaris.os.dtrace.Distribution$Bucket[min = 34359738368, max = 68719476735, frequency = 99], org.opensolaris.os.dtrace.Distribution$Bucket[min = 68719476736, max = 137438953471, frequency = 100], org.opensolaris.os.dtrace.Distribution$Bucket[min = 137438953472, max = 274877906943, frequency = 101], org.opensolaris.os.dtrace.Distribution$Bucket[min = 274877906944, max = 549755813887, frequency = 102], org.opensolaris.os.dtrace.Distribution$Bucket[min = 549755813888, max = 1099511627775, frequency = 103], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1099511627776, max = 2199023255551, frequency = 104], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2199023255552, max = 4398046511103, frequency = 105], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4398046511104, max = 8796093022207, frequency = 106], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8796093022208, max = 17592186044415, frequency = 107], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17592186044416, max = 35184372088831, frequency = 108], org.opensolaris.os.dtrace.Distribution$Bucket[min = 35184372088832, max = 70368744177663, frequency = 109], org.opensolaris.os.dtrace.Distribution$Bucket[min = 70368744177664, max = 140737488355327, frequency = 110], org.opensolaris.os.dtrace.Distribution$Bucket[min = 140737488355328, max = 281474976710655, frequency = 111], org.opensolaris.os.dtrace.Distribution$Bucket[min = 281474976710656, max = 562949953421311, frequency = 112], org.opensolaris.os.dtrace.Distribution$Bucket[min = 562949953421312, max = 1125899906842623, frequency = 113], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1125899906842624, max = 2251799813685247, frequency = 114], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2251799813685248, max = 4503599627370495, frequency = 115], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4503599627370496, max = 9007199254740991, frequency = 116], org.opensolaris.os.dtrace.Distribution$Bucket[min = 9007199254740992, max = 18014398509481983, frequency = 117], org.opensolaris.os.dtrace.Distribution$Bucket[min = 18014398509481984, max = 36028797018963967, frequency = 118], org.opensolaris.os.dtrace.Distribution$Bucket[min = 36028797018963968, max = 72057594037927935, frequency = 119], org.opensolaris.os.dtrace.Distribution$Bucket[min = 72057594037927936, max = 144115188075855871, frequency = 120], org.opensolaris.os.dtrace.Distribution$Bucket[min = 144115188075855872, max = 288230376151711743, frequency = 121], org.opensolaris.os.dtrace.Distribution$Bucket[min = 288230376151711744, max = 576460752303423487, frequency = 122], org.opensolaris.os.dtrace.Distribution$Bucket[min = 576460752303423488, max = 1152921504606846975, frequency = 123], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1152921504606846976, max = 2305843009213693951, frequency = 124], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2305843009213693952, max = 4611686018427387903, frequency = 125], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4611686018427387904, max = 9223372036854775807, frequency = 126]], total = 8001.0]
+ deserialized: org.opensolaris.os.dtrace.Distribution[buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = -4611686018427387904, max = -2305843009213693953, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2305843009213693952, max = -1152921504606846977, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1152921504606846976, max = -576460752303423489, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = -576460752303423488, max = -288230376151711745, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = -288230376151711744, max = -144115188075855873, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = -144115188075855872, max = -72057594037927937, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = -72057594037927936, max = -36028797018963969, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = -36028797018963968, max = -18014398509481985, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = -18014398509481984, max = -9007199254740993, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = -9007199254740992, max = -4503599627370497, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4503599627370496, max = -2251799813685249, frequency = 10], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2251799813685248, max = -1125899906842625, frequency = 11], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1125899906842624, max = -562949953421313, frequency = 12], org.opensolaris.os.dtrace.Distribution$Bucket[min = -562949953421312, max = -281474976710657, frequency = 13], org.opensolaris.os.dtrace.Distribution$Bucket[min = -281474976710656, max = -140737488355329, frequency = 14], org.opensolaris.os.dtrace.Distribution$Bucket[min = -140737488355328, max = -70368744177665, frequency = 15], org.opensolaris.os.dtrace.Distribution$Bucket[min = -70368744177664, max = -35184372088833, frequency = 16], org.opensolaris.os.dtrace.Distribution$Bucket[min = -35184372088832, max = -17592186044417, frequency = 17], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17592186044416, max = -8796093022209, frequency = 18], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8796093022208, max = -4398046511105, frequency = 19], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4398046511104, max = -2199023255553, frequency = 20], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2199023255552, max = -1099511627777, frequency = 21], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1099511627776, max = -549755813889, frequency = 22], org.opensolaris.os.dtrace.Distribution$Bucket[min = -549755813888, max = -274877906945, frequency = 23], org.opensolaris.os.dtrace.Distribution$Bucket[min = -274877906944, max = -137438953473, frequency = 24], org.opensolaris.os.dtrace.Distribution$Bucket[min = -137438953472, max = -68719476737, frequency = 25], org.opensolaris.os.dtrace.Distribution$Bucket[min = -68719476736, max = -34359738369, frequency = 26], org.opensolaris.os.dtrace.Distribution$Bucket[min = -34359738368, max = -17179869185, frequency = 27], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17179869184, max = -8589934593, frequency = 28], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8589934592, max = -4294967297, frequency = 29], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4294967296, max = -2147483649, frequency = 30], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2147483648, max = -1073741825, frequency = 31], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1073741824, max = -536870913, frequency = 32], org.opensolaris.os.dtrace.Distribution$Bucket[min = -536870912, max = -268435457, frequency = 33], org.opensolaris.os.dtrace.Distribution$Bucket[min = -268435456, max = -134217729, frequency = 34], org.opensolaris.os.dtrace.Distribution$Bucket[min = -134217728, max = -67108865, frequency = 35], org.opensolaris.os.dtrace.Distribution$Bucket[min = -67108864, max = -33554433, frequency = 36], org.opensolaris.os.dtrace.Distribution$Bucket[min = -33554432, max = -16777217, frequency = 37], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16777216, max = -8388609, frequency = 38], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8388608, max = -4194305, frequency = 39], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4194304, max = -2097153, frequency = 40], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2097152, max = -1048577, frequency = 41], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1048576, max = -524289, frequency = 42], org.opensolaris.os.dtrace.Distribution$Bucket[min = -524288, max = -262145, frequency = 43], org.opensolaris.os.dtrace.Distribution$Bucket[min = -262144, max = -131073, frequency = 44], org.opensolaris.os.dtrace.Distribution$Bucket[min = -131072, max = -65537, frequency = 45], org.opensolaris.os.dtrace.Distribution$Bucket[min = -65536, max = -32769, frequency = 46], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32768, max = -16385, frequency = 47], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16384, max = -8193, frequency = 48], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8192, max = -4097, frequency = 49], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4096, max = -2049, frequency = 50], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2048, max = -1025, frequency = 51], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1024, max = -513, frequency = 52], org.opensolaris.os.dtrace.Distribution$Bucket[min = -512, max = -257, frequency = 53], org.opensolaris.os.dtrace.Distribution$Bucket[min = -256, max = -129, frequency = 54], org.opensolaris.os.dtrace.Distribution$Bucket[min = -128, max = -65, frequency = 55], org.opensolaris.os.dtrace.Distribution$Bucket[min = -64, max = -33, frequency = 56], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32, max = -17, frequency = 57], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16, max = -9, frequency = 58], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8, max = -5, frequency = 59], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4, max = -3, frequency = 60], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2, max = -2, frequency = 61], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1, max = -1, frequency = 62], org.opensolaris.os.dtrace.Distribution$Bucket[min = 0, max = 0, frequency = 63], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 1, frequency = 64], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2, max = 3, frequency = 65], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4, max = 7, frequency = 66], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8, max = 15, frequency = 67], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16, max = 31, frequency = 68], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32, max = 63, frequency = 69], org.opensolaris.os.dtrace.Distribution$Bucket[min = 64, max = 127, frequency = 70], org.opensolaris.os.dtrace.Distribution$Bucket[min = 128, max = 255, frequency = 71], org.opensolaris.os.dtrace.Distribution$Bucket[min = 256, max = 511, frequency = 72], org.opensolaris.os.dtrace.Distribution$Bucket[min = 512, max = 1023, frequency = 73], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1024, max = 2047, frequency = 74], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2048, max = 4095, frequency = 75], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4096, max = 8191, frequency = 76], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8192, max = 16383, frequency = 77], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16384, max = 32767, frequency = 78], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32768, max = 65535, frequency = 79], org.opensolaris.os.dtrace.Distribution$Bucket[min = 65536, max = 131071, frequency = 80], org.opensolaris.os.dtrace.Distribution$Bucket[min = 131072, max = 262143, frequency = 81], org.opensolaris.os.dtrace.Distribution$Bucket[min = 262144, max = 524287, frequency = 82], org.opensolaris.os.dtrace.Distribution$Bucket[min = 524288, max = 1048575, frequency = 83], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1048576, max = 2097151, frequency = 84], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2097152, max = 4194303, frequency = 85], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4194304, max = 8388607, frequency = 86], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8388608, max = 16777215, frequency = 87], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16777216, max = 33554431, frequency = 88], org.opensolaris.os.dtrace.Distribution$Bucket[min = 33554432, max = 67108863, frequency = 89], org.opensolaris.os.dtrace.Distribution$Bucket[min = 67108864, max = 134217727, frequency = 90], org.opensolaris.os.dtrace.Distribution$Bucket[min = 134217728, max = 268435455, frequency = 91], org.opensolaris.os.dtrace.Distribution$Bucket[min = 268435456, max = 536870911, frequency = 92], org.opensolaris.os.dtrace.Distribution$Bucket[min = 536870912, max = 1073741823, frequency = 93], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1073741824, max = 2147483647, frequency = 94], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2147483648, max = 4294967295, frequency = 95], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4294967296, max = 8589934591, frequency = 96], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8589934592, max = 17179869183, frequency = 97], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17179869184, max = 34359738367, frequency = 98], org.opensolaris.os.dtrace.Distribution$Bucket[min = 34359738368, max = 68719476735, frequency = 99], org.opensolaris.os.dtrace.Distribution$Bucket[min = 68719476736, max = 137438953471, frequency = 100], org.opensolaris.os.dtrace.Distribution$Bucket[min = 137438953472, max = 274877906943, frequency = 101], org.opensolaris.os.dtrace.Distribution$Bucket[min = 274877906944, max = 549755813887, frequency = 102], org.opensolaris.os.dtrace.Distribution$Bucket[min = 549755813888, max = 1099511627775, frequency = 103], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1099511627776, max = 2199023255551, frequency = 104], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2199023255552, max = 4398046511103, frequency = 105], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4398046511104, max = 8796093022207, frequency = 106], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8796093022208, max = 17592186044415, frequency = 107], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17592186044416, max = 35184372088831, frequency = 108], org.opensolaris.os.dtrace.Distribution$Bucket[min = 35184372088832, max = 70368744177663, frequency = 109], org.opensolaris.os.dtrace.Distribution$Bucket[min = 70368744177664, max = 140737488355327, frequency = 110], org.opensolaris.os.dtrace.Distribution$Bucket[min = 140737488355328, max = 281474976710655, frequency = 111], org.opensolaris.os.dtrace.Distribution$Bucket[min = 281474976710656, max = 562949953421311, frequency = 112], org.opensolaris.os.dtrace.Distribution$Bucket[min = 562949953421312, max = 1125899906842623, frequency = 113], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1125899906842624, max = 2251799813685247, frequency = 114], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2251799813685248, max = 4503599627370495, frequency = 115], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4503599627370496, max = 9007199254740991, frequency = 116], org.opensolaris.os.dtrace.Distribution$Bucket[min = 9007199254740992, max = 18014398509481983, frequency = 117], org.opensolaris.os.dtrace.Distribution$Bucket[min = 18014398509481984, max = 36028797018963967, frequency = 118], org.opensolaris.os.dtrace.Distribution$Bucket[min = 36028797018963968, max = 72057594037927935, frequency = 119], org.opensolaris.os.dtrace.Distribution$Bucket[min = 72057594037927936, max = 144115188075855871, frequency = 120], org.opensolaris.os.dtrace.Distribution$Bucket[min = 144115188075855872, max = 288230376151711743, frequency = 121], org.opensolaris.os.dtrace.Distribution$Bucket[min = 288230376151711744, max = 576460752303423487, frequency = 122], org.opensolaris.os.dtrace.Distribution$Bucket[min = 576460752303423488, max = 1152921504606846975, frequency = 123], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1152921504606846976, max = 2305843009213693951, frequency = 124], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2305843009213693952, max = 4611686018427387903, frequency = 125], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4611686018427387904, max = 9223372036854775807, frequency = 126]], total = 8001.0]
+LogDistribution:
+ encoded: org.opensolaris.os.dtrace.Distribution[buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = -4611686018427387904, max = -2305843009213693953, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2305843009213693952, max = -1152921504606846977, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1152921504606846976, max = -576460752303423489, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = -576460752303423488, max = -288230376151711745, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = -288230376151711744, max = -144115188075855873, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = -144115188075855872, max = -72057594037927937, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = -72057594037927936, max = -36028797018963969, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = -36028797018963968, max = -18014398509481985, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = -18014398509481984, max = -9007199254740993, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = -9007199254740992, max = -4503599627370497, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4503599627370496, max = -2251799813685249, frequency = 10], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2251799813685248, max = -1125899906842625, frequency = 11], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1125899906842624, max = -562949953421313, frequency = 12], org.opensolaris.os.dtrace.Distribution$Bucket[min = -562949953421312, max = -281474976710657, frequency = 13], org.opensolaris.os.dtrace.Distribution$Bucket[min = -281474976710656, max = -140737488355329, frequency = 14], org.opensolaris.os.dtrace.Distribution$Bucket[min = -140737488355328, max = -70368744177665, frequency = 15], org.opensolaris.os.dtrace.Distribution$Bucket[min = -70368744177664, max = -35184372088833, frequency = 16], org.opensolaris.os.dtrace.Distribution$Bucket[min = -35184372088832, max = -17592186044417, frequency = 17], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17592186044416, max = -8796093022209, frequency = 18], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8796093022208, max = -4398046511105, frequency = 19], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4398046511104, max = -2199023255553, frequency = 20], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2199023255552, max = -1099511627777, frequency = 21], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1099511627776, max = -549755813889, frequency = 22], org.opensolaris.os.dtrace.Distribution$Bucket[min = -549755813888, max = -274877906945, frequency = 23], org.opensolaris.os.dtrace.Distribution$Bucket[min = -274877906944, max = -137438953473, frequency = 24], org.opensolaris.os.dtrace.Distribution$Bucket[min = -137438953472, max = -68719476737, frequency = 25], org.opensolaris.os.dtrace.Distribution$Bucket[min = -68719476736, max = -34359738369, frequency = 26], org.opensolaris.os.dtrace.Distribution$Bucket[min = -34359738368, max = -17179869185, frequency = 27], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17179869184, max = -8589934593, frequency = 28], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8589934592, max = -4294967297, frequency = 29], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4294967296, max = -2147483649, frequency = 30], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2147483648, max = -1073741825, frequency = 31], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1073741824, max = -536870913, frequency = 32], org.opensolaris.os.dtrace.Distribution$Bucket[min = -536870912, max = -268435457, frequency = 33], org.opensolaris.os.dtrace.Distribution$Bucket[min = -268435456, max = -134217729, frequency = 34], org.opensolaris.os.dtrace.Distribution$Bucket[min = -134217728, max = -67108865, frequency = 35], org.opensolaris.os.dtrace.Distribution$Bucket[min = -67108864, max = -33554433, frequency = 36], org.opensolaris.os.dtrace.Distribution$Bucket[min = -33554432, max = -16777217, frequency = 37], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16777216, max = -8388609, frequency = 38], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8388608, max = -4194305, frequency = 39], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4194304, max = -2097153, frequency = 40], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2097152, max = -1048577, frequency = 41], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1048576, max = -524289, frequency = 42], org.opensolaris.os.dtrace.Distribution$Bucket[min = -524288, max = -262145, frequency = 43], org.opensolaris.os.dtrace.Distribution$Bucket[min = -262144, max = -131073, frequency = 44], org.opensolaris.os.dtrace.Distribution$Bucket[min = -131072, max = -65537, frequency = 45], org.opensolaris.os.dtrace.Distribution$Bucket[min = -65536, max = -32769, frequency = 46], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32768, max = -16385, frequency = 47], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16384, max = -8193, frequency = 48], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8192, max = -4097, frequency = 49], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4096, max = -2049, frequency = 50], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2048, max = -1025, frequency = 51], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1024, max = -513, frequency = 52], org.opensolaris.os.dtrace.Distribution$Bucket[min = -512, max = -257, frequency = 53], org.opensolaris.os.dtrace.Distribution$Bucket[min = -256, max = -129, frequency = 54], org.opensolaris.os.dtrace.Distribution$Bucket[min = -128, max = -65, frequency = 55], org.opensolaris.os.dtrace.Distribution$Bucket[min = -64, max = -33, frequency = 56], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32, max = -17, frequency = 57], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16, max = -9, frequency = 58], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8, max = -5, frequency = 59], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4, max = -3, frequency = 60], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2, max = -2, frequency = 61], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1, max = -1, frequency = 62], org.opensolaris.os.dtrace.Distribution$Bucket[min = 0, max = 0, frequency = 63], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 1, frequency = 64], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2, max = 3, frequency = 65], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4, max = 7, frequency = 66], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8, max = 15, frequency = 67], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16, max = 31, frequency = 68], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32, max = 63, frequency = 69], org.opensolaris.os.dtrace.Distribution$Bucket[min = 64, max = 127, frequency = 70], org.opensolaris.os.dtrace.Distribution$Bucket[min = 128, max = 255, frequency = 71], org.opensolaris.os.dtrace.Distribution$Bucket[min = 256, max = 511, frequency = 72], org.opensolaris.os.dtrace.Distribution$Bucket[min = 512, max = 1023, frequency = 73], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1024, max = 2047, frequency = 74], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2048, max = 4095, frequency = 75], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4096, max = 8191, frequency = 76], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8192, max = 16383, frequency = 77], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16384, max = 32767, frequency = 78], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32768, max = 65535, frequency = 79], org.opensolaris.os.dtrace.Distribution$Bucket[min = 65536, max = 131071, frequency = 80], org.opensolaris.os.dtrace.Distribution$Bucket[min = 131072, max = 262143, frequency = 81], org.opensolaris.os.dtrace.Distribution$Bucket[min = 262144, max = 524287, frequency = 82], org.opensolaris.os.dtrace.Distribution$Bucket[min = 524288, max = 1048575, frequency = 83], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1048576, max = 2097151, frequency = 84], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2097152, max = 4194303, frequency = 85], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4194304, max = 8388607, frequency = 86], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8388608, max = 16777215, frequency = 87], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16777216, max = 33554431, frequency = 88], org.opensolaris.os.dtrace.Distribution$Bucket[min = 33554432, max = 67108863, frequency = 89], org.opensolaris.os.dtrace.Distribution$Bucket[min = 67108864, max = 134217727, frequency = 90], org.opensolaris.os.dtrace.Distribution$Bucket[min = 134217728, max = 268435455, frequency = 91], org.opensolaris.os.dtrace.Distribution$Bucket[min = 268435456, max = 536870911, frequency = 92], org.opensolaris.os.dtrace.Distribution$Bucket[min = 536870912, max = 1073741823, frequency = 93], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1073741824, max = 2147483647, frequency = 94], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2147483648, max = 4294967295, frequency = 95], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4294967296, max = 8589934591, frequency = 96], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8589934592, max = 17179869183, frequency = 97], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17179869184, max = 34359738367, frequency = 98], org.opensolaris.os.dtrace.Distribution$Bucket[min = 34359738368, max = 68719476735, frequency = 99], org.opensolaris.os.dtrace.Distribution$Bucket[min = 68719476736, max = 137438953471, frequency = 100], org.opensolaris.os.dtrace.Distribution$Bucket[min = 137438953472, max = 274877906943, frequency = 101], org.opensolaris.os.dtrace.Distribution$Bucket[min = 274877906944, max = 549755813887, frequency = 102], org.opensolaris.os.dtrace.Distribution$Bucket[min = 549755813888, max = 1099511627775, frequency = 103], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1099511627776, max = 2199023255551, frequency = 104], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2199023255552, max = 4398046511103, frequency = 105], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4398046511104, max = 8796093022207, frequency = 106], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8796093022208, max = 17592186044415, frequency = 107], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17592186044416, max = 35184372088831, frequency = 108], org.opensolaris.os.dtrace.Distribution$Bucket[min = 35184372088832, max = 70368744177663, frequency = 109], org.opensolaris.os.dtrace.Distribution$Bucket[min = 70368744177664, max = 140737488355327, frequency = 110], org.opensolaris.os.dtrace.Distribution$Bucket[min = 140737488355328, max = 281474976710655, frequency = 111], org.opensolaris.os.dtrace.Distribution$Bucket[min = 281474976710656, max = 562949953421311, frequency = 112], org.opensolaris.os.dtrace.Distribution$Bucket[min = 562949953421312, max = 1125899906842623, frequency = 113], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1125899906842624, max = 2251799813685247, frequency = 114], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2251799813685248, max = 4503599627370495, frequency = 115], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4503599627370496, max = 9007199254740991, frequency = 116], org.opensolaris.os.dtrace.Distribution$Bucket[min = 9007199254740992, max = 18014398509481983, frequency = 117], org.opensolaris.os.dtrace.Distribution$Bucket[min = 18014398509481984, max = 36028797018963967, frequency = 118], org.opensolaris.os.dtrace.Distribution$Bucket[min = 36028797018963968, max = 72057594037927935, frequency = 119], org.opensolaris.os.dtrace.Distribution$Bucket[min = 72057594037927936, max = 144115188075855871, frequency = 120], org.opensolaris.os.dtrace.Distribution$Bucket[min = 144115188075855872, max = 288230376151711743, frequency = 121], org.opensolaris.os.dtrace.Distribution$Bucket[min = 288230376151711744, max = 576460752303423487, frequency = 122], org.opensolaris.os.dtrace.Distribution$Bucket[min = 576460752303423488, max = 1152921504606846975, frequency = 123], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1152921504606846976, max = 2305843009213693951, frequency = 124], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2305843009213693952, max = 4611686018427387903, frequency = 125], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4611686018427387904, max = 9223372036854775807, frequency = 126]], total = 8001.0]
+ decoded: org.opensolaris.os.dtrace.Distribution[buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = -4611686018427387904, max = -2305843009213693953, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2305843009213693952, max = -1152921504606846977, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1152921504606846976, max = -576460752303423489, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = -576460752303423488, max = -288230376151711745, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = -288230376151711744, max = -144115188075855873, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = -144115188075855872, max = -72057594037927937, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = -72057594037927936, max = -36028797018963969, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = -36028797018963968, max = -18014398509481985, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = -18014398509481984, max = -9007199254740993, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = -9007199254740992, max = -4503599627370497, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4503599627370496, max = -2251799813685249, frequency = 10], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2251799813685248, max = -1125899906842625, frequency = 11], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1125899906842624, max = -562949953421313, frequency = 12], org.opensolaris.os.dtrace.Distribution$Bucket[min = -562949953421312, max = -281474976710657, frequency = 13], org.opensolaris.os.dtrace.Distribution$Bucket[min = -281474976710656, max = -140737488355329, frequency = 14], org.opensolaris.os.dtrace.Distribution$Bucket[min = -140737488355328, max = -70368744177665, frequency = 15], org.opensolaris.os.dtrace.Distribution$Bucket[min = -70368744177664, max = -35184372088833, frequency = 16], org.opensolaris.os.dtrace.Distribution$Bucket[min = -35184372088832, max = -17592186044417, frequency = 17], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17592186044416, max = -8796093022209, frequency = 18], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8796093022208, max = -4398046511105, frequency = 19], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4398046511104, max = -2199023255553, frequency = 20], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2199023255552, max = -1099511627777, frequency = 21], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1099511627776, max = -549755813889, frequency = 22], org.opensolaris.os.dtrace.Distribution$Bucket[min = -549755813888, max = -274877906945, frequency = 23], org.opensolaris.os.dtrace.Distribution$Bucket[min = -274877906944, max = -137438953473, frequency = 24], org.opensolaris.os.dtrace.Distribution$Bucket[min = -137438953472, max = -68719476737, frequency = 25], org.opensolaris.os.dtrace.Distribution$Bucket[min = -68719476736, max = -34359738369, frequency = 26], org.opensolaris.os.dtrace.Distribution$Bucket[min = -34359738368, max = -17179869185, frequency = 27], org.opensolaris.os.dtrace.Distribution$Bucket[min = -17179869184, max = -8589934593, frequency = 28], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8589934592, max = -4294967297, frequency = 29], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4294967296, max = -2147483649, frequency = 30], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2147483648, max = -1073741825, frequency = 31], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1073741824, max = -536870913, frequency = 32], org.opensolaris.os.dtrace.Distribution$Bucket[min = -536870912, max = -268435457, frequency = 33], org.opensolaris.os.dtrace.Distribution$Bucket[min = -268435456, max = -134217729, frequency = 34], org.opensolaris.os.dtrace.Distribution$Bucket[min = -134217728, max = -67108865, frequency = 35], org.opensolaris.os.dtrace.Distribution$Bucket[min = -67108864, max = -33554433, frequency = 36], org.opensolaris.os.dtrace.Distribution$Bucket[min = -33554432, max = -16777217, frequency = 37], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16777216, max = -8388609, frequency = 38], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8388608, max = -4194305, frequency = 39], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4194304, max = -2097153, frequency = 40], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2097152, max = -1048577, frequency = 41], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1048576, max = -524289, frequency = 42], org.opensolaris.os.dtrace.Distribution$Bucket[min = -524288, max = -262145, frequency = 43], org.opensolaris.os.dtrace.Distribution$Bucket[min = -262144, max = -131073, frequency = 44], org.opensolaris.os.dtrace.Distribution$Bucket[min = -131072, max = -65537, frequency = 45], org.opensolaris.os.dtrace.Distribution$Bucket[min = -65536, max = -32769, frequency = 46], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32768, max = -16385, frequency = 47], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16384, max = -8193, frequency = 48], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8192, max = -4097, frequency = 49], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4096, max = -2049, frequency = 50], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2048, max = -1025, frequency = 51], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1024, max = -513, frequency = 52], org.opensolaris.os.dtrace.Distribution$Bucket[min = -512, max = -257, frequency = 53], org.opensolaris.os.dtrace.Distribution$Bucket[min = -256, max = -129, frequency = 54], org.opensolaris.os.dtrace.Distribution$Bucket[min = -128, max = -65, frequency = 55], org.opensolaris.os.dtrace.Distribution$Bucket[min = -64, max = -33, frequency = 56], org.opensolaris.os.dtrace.Distribution$Bucket[min = -32, max = -17, frequency = 57], org.opensolaris.os.dtrace.Distribution$Bucket[min = -16, max = -9, frequency = 58], org.opensolaris.os.dtrace.Distribution$Bucket[min = -8, max = -5, frequency = 59], org.opensolaris.os.dtrace.Distribution$Bucket[min = -4, max = -3, frequency = 60], org.opensolaris.os.dtrace.Distribution$Bucket[min = -2, max = -2, frequency = 61], org.opensolaris.os.dtrace.Distribution$Bucket[min = -1, max = -1, frequency = 62], org.opensolaris.os.dtrace.Distribution$Bucket[min = 0, max = 0, frequency = 63], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 1, frequency = 64], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2, max = 3, frequency = 65], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4, max = 7, frequency = 66], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8, max = 15, frequency = 67], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16, max = 31, frequency = 68], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32, max = 63, frequency = 69], org.opensolaris.os.dtrace.Distribution$Bucket[min = 64, max = 127, frequency = 70], org.opensolaris.os.dtrace.Distribution$Bucket[min = 128, max = 255, frequency = 71], org.opensolaris.os.dtrace.Distribution$Bucket[min = 256, max = 511, frequency = 72], org.opensolaris.os.dtrace.Distribution$Bucket[min = 512, max = 1023, frequency = 73], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1024, max = 2047, frequency = 74], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2048, max = 4095, frequency = 75], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4096, max = 8191, frequency = 76], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8192, max = 16383, frequency = 77], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16384, max = 32767, frequency = 78], org.opensolaris.os.dtrace.Distribution$Bucket[min = 32768, max = 65535, frequency = 79], org.opensolaris.os.dtrace.Distribution$Bucket[min = 65536, max = 131071, frequency = 80], org.opensolaris.os.dtrace.Distribution$Bucket[min = 131072, max = 262143, frequency = 81], org.opensolaris.os.dtrace.Distribution$Bucket[min = 262144, max = 524287, frequency = 82], org.opensolaris.os.dtrace.Distribution$Bucket[min = 524288, max = 1048575, frequency = 83], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1048576, max = 2097151, frequency = 84], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2097152, max = 4194303, frequency = 85], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4194304, max = 8388607, frequency = 86], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8388608, max = 16777215, frequency = 87], org.opensolaris.os.dtrace.Distribution$Bucket[min = 16777216, max = 33554431, frequency = 88], org.opensolaris.os.dtrace.Distribution$Bucket[min = 33554432, max = 67108863, frequency = 89], org.opensolaris.os.dtrace.Distribution$Bucket[min = 67108864, max = 134217727, frequency = 90], org.opensolaris.os.dtrace.Distribution$Bucket[min = 134217728, max = 268435455, frequency = 91], org.opensolaris.os.dtrace.Distribution$Bucket[min = 268435456, max = 536870911, frequency = 92], org.opensolaris.os.dtrace.Distribution$Bucket[min = 536870912, max = 1073741823, frequency = 93], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1073741824, max = 2147483647, frequency = 94], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2147483648, max = 4294967295, frequency = 95], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4294967296, max = 8589934591, frequency = 96], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8589934592, max = 17179869183, frequency = 97], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17179869184, max = 34359738367, frequency = 98], org.opensolaris.os.dtrace.Distribution$Bucket[min = 34359738368, max = 68719476735, frequency = 99], org.opensolaris.os.dtrace.Distribution$Bucket[min = 68719476736, max = 137438953471, frequency = 100], org.opensolaris.os.dtrace.Distribution$Bucket[min = 137438953472, max = 274877906943, frequency = 101], org.opensolaris.os.dtrace.Distribution$Bucket[min = 274877906944, max = 549755813887, frequency = 102], org.opensolaris.os.dtrace.Distribution$Bucket[min = 549755813888, max = 1099511627775, frequency = 103], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1099511627776, max = 2199023255551, frequency = 104], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2199023255552, max = 4398046511103, frequency = 105], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4398046511104, max = 8796093022207, frequency = 106], org.opensolaris.os.dtrace.Distribution$Bucket[min = 8796093022208, max = 17592186044415, frequency = 107], org.opensolaris.os.dtrace.Distribution$Bucket[min = 17592186044416, max = 35184372088831, frequency = 108], org.opensolaris.os.dtrace.Distribution$Bucket[min = 35184372088832, max = 70368744177663, frequency = 109], org.opensolaris.os.dtrace.Distribution$Bucket[min = 70368744177664, max = 140737488355327, frequency = 110], org.opensolaris.os.dtrace.Distribution$Bucket[min = 140737488355328, max = 281474976710655, frequency = 111], org.opensolaris.os.dtrace.Distribution$Bucket[min = 281474976710656, max = 562949953421311, frequency = 112], org.opensolaris.os.dtrace.Distribution$Bucket[min = 562949953421312, max = 1125899906842623, frequency = 113], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1125899906842624, max = 2251799813685247, frequency = 114], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2251799813685248, max = 4503599627370495, frequency = 115], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4503599627370496, max = 9007199254740991, frequency = 116], org.opensolaris.os.dtrace.Distribution$Bucket[min = 9007199254740992, max = 18014398509481983, frequency = 117], org.opensolaris.os.dtrace.Distribution$Bucket[min = 18014398509481984, max = 36028797018963967, frequency = 118], org.opensolaris.os.dtrace.Distribution$Bucket[min = 36028797018963968, max = 72057594037927935, frequency = 119], org.opensolaris.os.dtrace.Distribution$Bucket[min = 72057594037927936, max = 144115188075855871, frequency = 120], org.opensolaris.os.dtrace.Distribution$Bucket[min = 144115188075855872, max = 288230376151711743, frequency = 121], org.opensolaris.os.dtrace.Distribution$Bucket[min = 288230376151711744, max = 576460752303423487, frequency = 122], org.opensolaris.os.dtrace.Distribution$Bucket[min = 576460752303423488, max = 1152921504606846975, frequency = 123], org.opensolaris.os.dtrace.Distribution$Bucket[min = 1152921504606846976, max = 2305843009213693951, frequency = 124], org.opensolaris.os.dtrace.Distribution$Bucket[min = 2305843009213693952, max = 4611686018427387903, frequency = 125], org.opensolaris.os.dtrace.Distribution$Bucket[min = 4611686018427387904, max = 9223372036854775807, frequency = 126]], total = 8001.0]
+LinearDistribution:
+ serialized: class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]
+ deserialized: class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]
+LinearDistribution:
+ encoded: class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]
+ decoded: class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]
+Option:
+ serialized: org.opensolaris.os.dtrace.Option[name = aggrate, value = 1s]
+ deserialized: org.opensolaris.os.dtrace.Option[name = aggrate, value = 1s]
+Option:
+ encoded: org.opensolaris.os.dtrace.Option[name = aggrate, value = 1s]
+ decoded: org.opensolaris.os.dtrace.Option[name = aggrate, value = 1s]
+ProcessState:
+ serialized: org.opensolaris.os.dtrace.ProcessState[pid = 123456, state = UNDEAD, terminationSignal = 3, terminationSignalName = SIGSTOP, exitStatus = -2, message = Process stopped on dime]
+ deserialized: org.opensolaris.os.dtrace.ProcessState[pid = 123456, state = UNDEAD, terminationSignal = 3, terminationSignalName = SIGSTOP, exitStatus = -2, message = Process stopped on dime]
+ProcessState:
+ encoded: org.opensolaris.os.dtrace.ProcessState[pid = 123456, state = UNDEAD, terminationSignal = 3, terminationSignalName = SIGSTOP, exitStatus = -2, message = Process stopped on dime]
+ decoded: org.opensolaris.os.dtrace.ProcessState[pid = 123456, state = UNDEAD, terminationSignal = 3, terminationSignalName = SIGSTOP, exitStatus = -2, message = Process stopped on dime]
+ProbeDescription:
+ serialized: syscall::malloc:entry
+ deserialized: syscall::malloc:entry
+ProbeDescription:
+ encoded: syscall::malloc:entry
+ decoded: syscall::malloc:entry
+PrintaRecord:
+ serialized: org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output]
+ deserialized: org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output]
+PrintaRecord:
+ encoded: org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output]
+ decoded: org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output]
+PrintfRecord:
+ serialized: long formatted string
+ deserialized: long formatted string
+PrintfRecord:
+ encoded: long formatted string
+ decoded: long formatted string
+ProbeData:
+ serialized: org.opensolaris.os.dtrace.ProbeData[epid = 7, cpu = 1, enabledProbeDescription = syscall::malloc:entry, flow = org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3], records = [org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output], long formatted string,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, mod`func+0x4,
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+, 1]]
+ deserialized: org.opensolaris.os.dtrace.ProbeData[epid = 7, cpu = 1, enabledProbeDescription = syscall::malloc:entry, flow = org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3], records = [org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output], long formatted string,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, mod`func+0x4,
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+, 1]]
+ProbeData:
+ encoded: org.opensolaris.os.dtrace.ProbeData[epid = 7, cpu = 1, enabledProbeDescription = syscall::malloc:entry, flow = org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3], records = [org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output], long formatted string,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, mod`func+0x4,
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+, 1]]
+ decoded: org.opensolaris.os.dtrace.ProbeData[epid = 7, cpu = 1, enabledProbeDescription = syscall::malloc:entry, flow = org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3], records = [org.opensolaris.os.dtrace.PrintaRecord[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]]], formattedStrings = {[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!]=cat, [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]=cat}, tuples = [[
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+]], output = Yes, this is the formatted printa() output], long formatted string,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, mod`func+0x4,
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+, 1]]
+Aggregate:
+ serialized: org.opensolaris.os.dtrace.Aggregate[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = times, id = 1, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, dog, mouse, mouse, 67, 7], value = 9]]]]
+ deserialized: org.opensolaris.os.dtrace.Aggregate[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = times, id = 1, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, dog, mouse, mouse, 67, 7], value = 9]]]]
+Aggregate:
+ encoded: org.opensolaris.os.dtrace.Aggregate[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = times, id = 1, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, dog, mouse, mouse, 67, 7], value = 9]]]]
+ decoded: org.opensolaris.os.dtrace.Aggregate[snaptime = 1234567890, aggregations = [org.opensolaris.os.dtrace.Aggregation[name = counts, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+, shebang!], value = class org.opensolaris.os.dtrace.LinearDistribution[base = 1, step = 10, buckets = [org.opensolaris.os.dtrace.Distribution$Bucket[min = 1, max = 10, frequency = 0], org.opensolaris.os.dtrace.Distribution$Bucket[min = 11, max = 20, frequency = 1], org.opensolaris.os.dtrace.Distribution$Bucket[min = 21, max = 30, frequency = 2], org.opensolaris.os.dtrace.Distribution$Bucket[min = 31, max = 40, frequency = 3], org.opensolaris.os.dtrace.Distribution$Bucket[min = 41, max = 50, frequency = 4], org.opensolaris.os.dtrace.Distribution$Bucket[min = 51, max = 60, frequency = 5], org.opensolaris.os.dtrace.Distribution$Bucket[min = 61, max = 70, frequency = 6], org.opensolaris.os.dtrace.Distribution$Bucket[min = 71, max = 80, frequency = 7], org.opensolaris.os.dtrace.Distribution$Bucket[min = 81, max = 90, frequency = 8], org.opensolaris.os.dtrace.Distribution$Bucket[min = 91, max = 100, frequency = 9], org.opensolaris.os.dtrace.Distribution$Bucket[min = 101, max = 9223372036854775807, frequency = 0]], total = 45.0]], org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, 9,
+ has
+ nine
+ lives
+,
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 1 2 3 ...
+], value = 7]], org.opensolaris.os.dtrace.Aggregation[name = times, id = 1, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [cat, dog, mouse, mouse, 67, 7], value = 9]]]]
+UserStackRecord:
+ serialized:
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+
+ deserialized:
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+
+UserStackRecord:
+ encoded:
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+
+ decoded:
+ process ID: 123456
+ User Stack Frame 1
+ User Stack Frame 2
+ User Stack Frame 3
+
+AvgValue:
+ serialized: 5
+ deserialized: 5
+AvgValue:
+ encoded: 5
+ decoded: 5
+CountValue:
+ serialized: 9
+ deserialized: 9
+CountValue:
+ encoded: 9
+ decoded: 9
+SumValue:
+ serialized: 25
+ deserialized: 25
+SumValue:
+ encoded: 25
+ decoded: 25
+MinValue:
+ serialized: 101
+ deserialized: 101
+MinValue:
+ encoded: 101
+ decoded: 101
+MaxValue:
+ serialized: 101
+ deserialized: 101
+MaxValue:
+ encoded: 101
+ decoded: 101
+Error:
+ serialized: org.opensolaris.os.dtrace.Error[probeDescription = syscall::malloc:entry, epid = 8, cpu = 3, action = 1, offset = 20, fault = DTRACEFLT_BADALIGN, address = -1, defaultMessage = error on enabled probe ID 8 (ID 256: syscall::malloc:entry): Bad alignment (0x33ef) in action #1 at DIF offset 20]
+ deserialized: org.opensolaris.os.dtrace.Error[probeDescription = syscall::malloc:entry, epid = 8, cpu = 3, action = 1, offset = 20, fault = DTRACEFLT_BADALIGN, address = -1, defaultMessage = error on enabled probe ID 8 (ID 256: syscall::malloc:entry): Bad alignment (0x33ef) in action #1 at DIF offset 20]
+Error:
+ encoded: org.opensolaris.os.dtrace.Error[probeDescription = syscall::malloc:entry, epid = 8, cpu = 3, action = 1, offset = 20, fault = DTRACEFLT_BADALIGN, address = -1, defaultMessage = error on enabled probe ID 8 (ID 256: syscall::malloc:entry): Bad alignment (0x33ef) in action #1 at DIF offset 20]
+ decoded: org.opensolaris.os.dtrace.Error[probeDescription = syscall::malloc:entry, epid = 8, cpu = 3, action = 1, offset = 20, fault = DTRACEFLT_BADALIGN, address = -1, defaultMessage = error on enabled probe ID 8 (ID 256: syscall::malloc:entry): Bad alignment (0x33ef) in action #1 at DIF offset 20]
+Drop:
+ serialized: org.opensolaris.os.dtrace.Drop[cpu = 2, kind = Speculation (busy), count = 72, total = 1041, defaultMessage = Guess we dropped stuff all over the place.]
+ deserialized: org.opensolaris.os.dtrace.Drop[cpu = 2, kind = Speculation (busy), count = 72, total = 1041, defaultMessage = Guess we dropped stuff all over the place.]
+Drop:
+ encoded: org.opensolaris.os.dtrace.Drop[cpu = 2, kind = Speculation (busy), count = 72, total = 1041, defaultMessage = Guess we dropped stuff all over the place.]
+ decoded: org.opensolaris.os.dtrace.Drop[cpu = 2, kind = Speculation (busy), count = 72, total = 1041, defaultMessage = Guess we dropped stuff all over the place.]
+InterfaceAttributes:
+ serialized: Unstable / Evolving / ISA
+ deserialized: Unstable / Evolving / ISA
+InterfaceAttributes:
+ encoded: Unstable / Evolving / ISA
+ decoded: Unstable / Evolving / ISA
+ProgramInfo:
+ serialized: org.opensolaris.os.dtrace.ProgramInfo[minimumProbeAttributes = Unstable / Evolving / ISA, minimumStatementAttributes = Unstable / Evolving / ISA, matchingProbeCount = 256]
+ deserialized: org.opensolaris.os.dtrace.ProgramInfo[minimumProbeAttributes = Unstable / Evolving / ISA, minimumStatementAttributes = Unstable / Evolving / ISA, matchingProbeCount = 256]
+ProgramInfo:
+ encoded: org.opensolaris.os.dtrace.ProgramInfo[minimumProbeAttributes = Unstable / Evolving / ISA, minimumStatementAttributes = Unstable / Evolving / ISA, matchingProbeCount = 256]
+ decoded: org.opensolaris.os.dtrace.ProgramInfo[minimumProbeAttributes = Unstable / Evolving / ISA, minimumStatementAttributes = Unstable / Evolving / ISA, matchingProbeCount = 256]
+ProbeInfo:
+ serialized: org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]
+ deserialized: org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]
+ProbeInfo:
+ encoded: org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]
+ decoded: org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]
+Probe:
+ serialized: org.opensolaris.os.dtrace.Probe[description = syscall::malloc:entry, info = org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]]
+ deserialized: org.opensolaris.os.dtrace.Probe[description = syscall::malloc:entry, info = org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]]
+Probe:
+ encoded: org.opensolaris.os.dtrace.Probe[description = syscall::malloc:entry, info = org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]]
+ decoded: org.opensolaris.os.dtrace.Probe[description = syscall::malloc:entry, info = org.opensolaris.os.dtrace.ProbeInfo[probeAttributes = Unstable / Evolving / ISA, argumentAttributes = Unstable / Evolving / ISA]]
+Flow:
+ serialized: org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3]
+ deserialized: org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3]
+Flow:
+ encoded: org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3]
+ decoded: org.opensolaris.os.dtrace.Flow[kind = RETURN, depth = 3]
+KernelSymbolRecord:
+ serialized: mod`func+0x4
+ deserialized: mod`func+0x4
+KernelSymbolRecord:
+ encoded: mod`func+0x4
+ decoded: mod`func+0x4
+UserSymbolRecord:
+ serialized: mod`func+0x4
+ deserialized: mod`func+0x4
+UserSymbolRecord:
+ encoded: mod`func+0x4
+ decoded: mod`func+0x4
+UserSymbolRecord$Value:
+ serialized: org.opensolaris.os.dtrace.UserSymbolRecord$Value[processID = 7, address = -1]
+ deserialized: org.opensolaris.os.dtrace.UserSymbolRecord$Value[processID = 7, address = -1]
+UserSymbolRecord$Value:
+ encoded: org.opensolaris.os.dtrace.UserSymbolRecord$Value[processID = 7, address = -1]
+ decoded: org.opensolaris.os.dtrace.UserSymbolRecord$Value[processID = 7, address = -1]
+Program:
+ serialized: org.opensolaris.os.dtrace.Program[contents = syscall:::entry { @[execname] = count(); }, info = null]
+ deserialized: org.opensolaris.os.dtrace.Program[contents = syscall:::entry { @[execname] = count(); }, info = null]
+Program$File:
+ serialized: org.opensolaris.os.dtrace.Program$File[super = org.opensolaris.os.dtrace.Program[contents = syscall:::entry { @[execname] = count(); }, info = null], file = TestBean.out]
+ deserialized: org.opensolaris.os.dtrace.Program$File[super = org.opensolaris.os.dtrace.Program[contents = syscall:::entry { @[execname] = count(); }, info = null], file = TestBean.out]
+StddevValue:
+ serialized: 37
+ deserialized: 37
+StddevValue:
+ encoded: 37
+ decoded: 37
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh
new file mode 100755
index 00000000..299755c6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh
@@ -0,0 +1,38 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Fixed bug 6419880 close() hangs running consumer.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestClose
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh.out
new file mode 100644
index 00000000..628d7870
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Close.ksh.out
@@ -0,0 +1 @@
+Successful
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh
new file mode 100755
index 00000000..a03de953
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh
@@ -0,0 +1,38 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Fixed bug 6521523 aggregation drops can hang the Java DTrace API.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestDrop 3
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh.out
new file mode 100644
index 00000000..266c4d46
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Drop.ksh.out
@@ -0,0 +1 @@
+Lock released
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh
new file mode 100755
index 00000000..df1c11f0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh
@@ -0,0 +1,40 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Consumer enable() correctly handles multiple programs,
+# recognizing programs that have already been enabled or that were
+# compiled by another consumer.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestEnable
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh.out
new file mode 100644
index 00000000..a13fb709
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.Enable.ksh.out
@@ -0,0 +1,6 @@
+java.lang.IllegalStateException: Not all compiled probes are enabled. Compiled description dtrace:::END not enabled.
+java.lang.IllegalStateException: program already enabled
+java.lang.IllegalStateException: program already enabled
+java.lang.IllegalStateException: Not all compiled probes are enabled. Compiled description syscall:::return not enabled.
+java.lang.IllegalStateException: program already enabled
+java.lang.IllegalArgumentException: program not compiled by this consumer
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.c
new file mode 100644
index 00000000..0e6291f6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.c
@@ -0,0 +1,51 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdio.h>
+
+typedef void f(int x);
+
+static void
+f1(int i)
+{
+ printf("%d\n", i);
+}
+
+static void
+f2(f func, int i)
+{
+ func(i);
+}
+
+int
+main()
+{
+ f2(f1, 3);
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh
new file mode 100755
index 00000000..e1ffbdfa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh
@@ -0,0 +1,39 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Fixed bug 6413280 lookupKernelFunction() and
+# lookupUserFunction() truncate last character.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestFunctionLookup ./tst.FunctionLookup.exe
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out
new file mode 100644
index 00000000..d42e9b59
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out
@@ -0,0 +1,3 @@
+genunix`cv_wakeup
+3
+tst.FunctionLookup.exe`f1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.GetAggregate.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.GetAggregate.ksh
new file mode 100755
index 00000000..2fdd5a9e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.GetAggregate.ksh
@@ -0,0 +1,36 @@
+#!/bin/ksh -p
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+############################################################################
+# ASSERTION:
+# getAggregate() can explicitly specify the anonymous aggregation
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestGetAggregate
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh
new file mode 100755
index 00000000..992fcb5e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh
@@ -0,0 +1,47 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+# ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Fixed bug 6506495 -DJAVA_DTRACE_MAX_CONSUMERS=N for any N < 8 is
+# treated as if it were 8.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=-1 -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=0 -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=1 -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=2 -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=7 -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=8 -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=9 -cp test.jar TestMaxConsumers
+java -DJAVA_DTRACE_MAX_CONSUMERS=19 -cp test.jar TestMaxConsumers
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh.out
new file mode 100644
index 00000000..f68fc4ea
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MaxConsumers.ksh.out
@@ -0,0 +1,17 @@
+Success
+JAVA_DTRACE_MAX_CONSUMERS=-1
+Success
+JAVA_DTRACE_MAX_CONSUMERS=0
+Success
+JAVA_DTRACE_MAX_CONSUMERS=1
+Success
+JAVA_DTRACE_MAX_CONSUMERS=2
+Success
+JAVA_DTRACE_MAX_CONSUMERS=7
+Success
+JAVA_DTRACE_MAX_CONSUMERS=8
+Success
+JAVA_DTRACE_MAX_CONSUMERS=9
+Success
+JAVA_DTRACE_MAX_CONSUMERS=19
+Success
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh
new file mode 100755
index 00000000..6bb864a6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh
@@ -0,0 +1,38 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Regression for multi-aggregation printa() corner cases.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestMultiAggPrinta tst.printa.d
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh.out
new file mode 100644
index 00000000..8b8fd6ef
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.MultiAggPrinta.ksh.out
@@ -0,0 +1,78 @@
+org.opensolaris.os.dtrace.ProbeData[epid = 1, enabledProbeDescription = dtrace:::BEGIN, flow = null, records = [org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = , id = 1, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [], value = 1]]], formattedStrings = {[]=
+ 1
+}, tuples = [[]], output =
+ 1
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = , id = 1, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [], value = 1]]], formattedStrings = {[]=count: 1
+}, tuples = [[]], output = count: 1
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [], formattedStrings = {[]= }, tuples = [[]], output = ], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = a, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 1], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 3]]], formattedStrings = {[1, 3]=
+ 1 3 3
+, [1, 2]= 1 2 1
+}, tuples = [[1, 3], [1, 2]], output =
+ 1 3 3
+ 1 2 1
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = a, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 1], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 3], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 0]], org.opensolaris.os.dtrace.Aggregation[name = b, id = 3, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 2], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 0], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 4]]], formattedStrings = {[2, 3]=
+ 2 3 0 4
+, [1, 3]= 1 3 3 0
+, [1, 2]= 1 2 1 2
+}, tuples = [[2, 3], [1, 2], [1, 3]], output =
+ 2 3 0 4
+ 1 2 1 2
+ 1 3 3 0
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = c, id = 4, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [], value = 3]], org.opensolaris.os.dtrace.Aggregation[name = d, id = 5, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [], value = 4]]], formattedStrings = {[]=3 4
+}, tuples = [[]], output = 3 4
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = c, id = 4, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [], value = 3]], org.opensolaris.os.dtrace.Aggregation[name = d, id = 5, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [], value = 4]]], formattedStrings = {[]=3 4
+}, tuples = [[]], output = 3 4
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = c, id = 4, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [], value = 3]]], formattedStrings = {[]=3
+}, tuples = [[]], output = 3
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = a, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 1], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 3], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 0]], org.opensolaris.os.dtrace.Aggregation[name = b, id = 3, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 2], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 0], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 4]]], formattedStrings = {[2, 3]=[2, 3] 0 4
+, [1, 3]=[1, 3] 3 0
+, [1, 2]=[1, 2] 1 2
+}, tuples = [[2, 3], [1, 2], [1, 3]], output = [2, 3] 0 4
+[1, 2] 1 2
+[1, 3] 3 0
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = a, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 1], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 3], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 0]], org.opensolaris.os.dtrace.Aggregation[name = b, id = 3, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 2], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 0], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 4]]], formattedStrings = {[2, 3]=[2, 3] 0 4
+, [1, 3]=[1, 3] 3 0
+, [1, 2]=[1, 2] 1 2
+}, tuples = [[2, 3], [1, 3], [1, 2]], output = [2, 3] 0 4
+[1, 3] 3 0
+[1, 2] 1 2
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = a, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 1], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 3], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 0]], org.opensolaris.os.dtrace.Aggregation[name = b, id = 3, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 2], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 0], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 4]]], formattedStrings = {[2, 3]=[2, 3] 0 4
+, [1, 3]=[1, 3] 3 0
+, [1, 2]=[1, 2] 1 2
+}, tuples = [[2, 3], [1, 3], [1, 2]], output = [2, 3] 0 4
+[1, 3] 3 0
+[1, 2] 1 2
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = a, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 1], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 3], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 0]], org.opensolaris.os.dtrace.Aggregation[name = b, id = 3, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 2], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 0], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 4]]], formattedStrings = {[2, 3]=0 4 [2, 3]
+, [1, 3]=3 0 [1, 3]
+, [1, 2]=1 2 [1, 2]
+}, tuples = [[2, 3], [1, 3], [1, 2]], output = 0 4 [2, 3]
+3 0 [1, 3]
+1 2 [1, 2]
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [], formattedStrings = {[2, 3]=[2, 3]
+, [1, 3]=[1, 3]
+, [1, 2]=[1, 2]
+}, tuples = [[2, 3], [1, 3], [1, 2]], output = [2, 3]
+[1, 3]
+[1, 2]
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [], formattedStrings = {}, tuples = [], output = [2]
+[1]
+[1]
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [], formattedStrings = {}, tuples = [], output = [2] 0 4
+[1] 3 0
+[1] 1 2
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [], formattedStrings = {}, tuples = [], output = 0 4
+3 0
+1 2
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [], formattedStrings = {}, tuples = [], output = 0 4 4
+3 0 0
+1 2 2
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [], formattedStrings = {}, tuples = [], output = [2] 0 4 4
+[1] 3 0 0
+[1] 1 2 2
+], org.opensolaris.os.dtrace.PrintaRecord[aggregations = [org.opensolaris.os.dtrace.Aggregation[name = a, id = 2, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 1], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 3], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 0]], org.opensolaris.os.dtrace.Aggregation[name = b, id = 3, records = [org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 2], value = 2], org.opensolaris.os.dtrace.AggregationRecord[tuple = [1, 3], value = 0], org.opensolaris.os.dtrace.AggregationRecord[tuple = [2, 3], value = 4]]], formattedStrings = {[2, 3]=[2, 3] 0 4 4
+, [1, 3]=[1, 3] 3 0 0
+, [1, 2]=[1, 2] 1 2 2
+}, tuples = [[2, 3], [1, 3], [1, 2]], output = [2, 3] 0 4 4
+[1, 3] 3 0 0
+[1, 2] 1 2 2
+], 0]
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.c
new file mode 100644
index 00000000..0833912a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.c
@@ -0,0 +1,93 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+typedef void f(char *);
+
+static void
+f_a(char *a)
+{
+}
+
+static void
+f_b(char *a)
+{
+}
+
+static void
+f_c(char *a)
+{
+}
+
+static void
+f_d(char *a)
+{
+}
+
+static void
+f_e(char *a)
+{
+}
+
+static void
+fN(f func, char *a, int i)
+{
+ func(a);
+}
+
+static void
+fN2(f func, char *a, int i)
+{
+ func(a);
+}
+
+int
+main()
+{
+ /*
+ * Avoid length of 1, 2, 4, or 8 bytes so DTrace will treat the data as
+ * a byte array.
+ */
+ char a[] = {(char)-7, (char)201, (char)0, (char)0, (char)28, (char)1};
+ char b[] = {(char)84, (char)69, (char)0, (char)0, (char)28, (char)0};
+ char c[] = {(char)84, (char)69, (char)0, (char)0, (char)28, (char)1};
+ char d[] = {(char)-7, (char)201, (char)0, (char)0, (char)29, (char)0};
+ char e[] = {(char)84, (char)69, (char)0, (char)0, (char)28, (char)0};
+
+ fN(f_a, a, 1);
+ fN(f_b, b, 0);
+ fN(f_d, d, 102);
+ fN2(f_e, e, -2);
+ fN(f_c, c, 0);
+ fN(f_a, a, -1);
+ fN(f_d, d, 101);
+ fN(f_e, e, -2);
+ fN(f_e, e, 2);
+ fN2(f_e, e, 2);
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh
new file mode 100755
index 00000000..97f49454
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh
@@ -0,0 +1,38 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# ProbeData instances sort as expected with multiple enabled probe
+# IDs and multiple records including byte array (sorted as
+# unsigned bytes), stand-alone ufunc() action, and signed integer.
+#
+############################################################################
+
+java -cp test.jar TestProbeData ./tst.ProbeData.exe
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh.out
new file mode 100644
index 00000000..6789514f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeData.ksh.out
@@ -0,0 +1,50 @@
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 54 45 0 0 1c 0 TE....
+, tst.ProbeData.exe`f_b , 0]]
+
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 54 45 0 0 1c 0 TE....
+, tst.ProbeData.exe`f_e , -2]]
+
+[probe 2 pid$target:tst.ProbeData.exe:fN2:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 54 45 0 0 1c 0 TE....
+, tst.ProbeData.exe`f_e , -2]]
+
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 54 45 0 0 1c 0 TE....
+, tst.ProbeData.exe`f_e , 2]]
+
+[probe 2 pid$target:tst.ProbeData.exe:fN2:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 54 45 0 0 1c 0 TE....
+, tst.ProbeData.exe`f_e , 2]]
+
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: 54 45 0 0 1c 1 TE....
+, tst.ProbeData.exe`f_c , 0]]
+
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: f9 c9 0 0 1c 1 ......
+, tst.ProbeData.exe`f_a , -1]]
+
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: f9 c9 0 0 1c 1 ......
+, tst.ProbeData.exe`f_a , 1]]
+
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: f9 c9 0 0 1d 0 ......
+, tst.ProbeData.exe`f_d , 101]]
+
+[probe 1 pid$target:tst.ProbeData.exe:fN:entry [
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ 0: f9 c9 0 0 1d 0 ......
+, tst.ProbeData.exe`f_d , 102]]
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh
new file mode 100755
index 00000000..bee1cca6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh
@@ -0,0 +1,45 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# ProbeDescription constructors function as expected.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestProbeDescription syscall:::entry
+java -cp test.jar TestProbeDescription BEGIN
+java -cp test.jar TestProbeDescription isdigit entry
+java -cp test.jar TestProbeDescription genunix isdigit entry
+java -cp test.jar TestProbeDescription fbt genunix isdigit entry
+java -cp test.jar TestProbeDescription fbt:genunix:isdigit:entry
+java -cp test.jar TestProbeDescription syscall::entry
+java -cp test.jar TestProbeDescription syscall:entry
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh.out
new file mode 100644
index 00000000..326018a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.ProbeDescription.ksh.out
@@ -0,0 +1,8 @@
+syscall:::entry
+:::BEGIN
+::isdigit:entry
+:genunix:isdigit:entry
+fbt:genunix:isdigit:entry
+fbt:genunix:isdigit:entry
+:syscall::entry
+::syscall:entry
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh
new file mode 100755
index 00000000..638ce7ac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh
@@ -0,0 +1,40 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Consumer state machine prevents illegal calls, allows legal
+# ones; consumer behaves predictably when methods called out of
+# order.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestStateMachine
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh.out
new file mode 100644
index 00000000..5ddb528f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StateMachine.ksh.out
@@ -0,0 +1,70 @@
+before open
+open: false
+enabled: false
+closed: false
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+java.lang.IllegalStateException: consumer not open
+before compile
+open: true
+enabled: false
+closed: false
+java.lang.IllegalStateException: consumer already open
+java.lang.IllegalStateException: no compiled program
+before enable
+open: true
+enabled: false
+closed: false
+java.lang.IllegalStateException: Not all compiled probes are enabled. Compiled description syscall:::entry { @[execname] = count(); } tick-101ms { printa(@); } not enabled.
+before go
+open: true
+enabled: true
+closed: false
+java.lang.IllegalStateException: go() not called
+java.lang.IllegalStateException: go() not called
+java.lang.IllegalStateException: go() not called
+java.lang.IllegalStateException: go() not called
+before go, running: false
+consumerStarted, running: true
+after go
+open: true
+enabled: false
+closed: false
+java.lang.IllegalStateException: go() already called
+java.lang.IllegalStateException: go() already called
+java.lang.IllegalStateException: go() already called
+java.lang.IllegalStateException: go() already called
+java.lang.IllegalStateException: go() already called
+java.lang.IllegalStateException: go() already called
+consumerStopped, running: false
+after stop, running: false
+after stop
+open: true
+enabled: false
+closed: false
+java.lang.IllegalStateException: consumer already stopped
+after close
+open: false
+enabled: false
+closed: true
+java.lang.IllegalStateException: cannot reopen a closed consumer
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
+java.lang.IllegalStateException: consumer closed
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh
new file mode 100755
index 00000000..4637a7ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh
@@ -0,0 +1,39 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Fixed bug 6399888 stop() hangs if ConsumerListener calls
+# synchronized Consumer method.
+#
+# SECTION: Java API
+#
+############################################################################
+
+java -cp test.jar TestStopLock
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh.out
new file mode 100644
index 00000000..628d7870
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.StopLock.ksh.out
@@ -0,0 +1 @@
+Successful
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d
new file mode 100644
index 00000000..574a9eab
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * printa() test with/without tuple, with multiple aggregations and
+ * mismatched format strings, and sorting options.
+ *
+ * SECTION: Aggregations/Aggregations; Output Formatting, printa()
+ *
+ * NOTES: This test attempts to cover all multi-agg printa() corner cases.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @ = count();
+ @a[1, 2] = sum(1);
+ @b[1, 2] = sum(2);
+ @a[1, 3] = sum(3);
+ @b[2, 3] = sum(4);
+ @c = sum(3);
+ @d = sum(4);
+ setopt("aggsortpos", "1");
+ setopt("aggsortrev");
+ printa(@);
+ printa("count: %@d\n", @);
+ printa(" ", @);
+ printa(@a);
+ printa(@a, @b);
+ printa("%@d %@d\n", @c, @d);
+ printa("%@d %@d\n", @c, @d);
+ printa("%@d\n", @c, @d);
+
+ printa("[%d, %d] %@d %@d\n", @a, @b);
+ setopt("aggsortkey");
+ printa("[%d, %d] %@d %@d\n", @a, @b);
+ setopt("aggsortpos", "0");
+ setopt("aggsortkeypos", "1");
+ printa("[%d, %d] %@d %@d\n", @a, @b);
+
+ printa("%@d %@d [%d, %d]\n", @a, @b);
+ printa("[%d, %d]\n", @a, @b);
+ printa("[%d]\n", @a, @b);
+ printa("[%d] %@d %@d\n", @a, @b);
+ printa("%@d %@d\n", @a, @b);
+ printa("%@d %@d %@d\n", @a, @b);
+ printa("[%d] %@d %@d %@d\n", @a, @b);
+ printa("[%d, %d] %@d %@d %@d\n", @a, @b);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d.out
new file mode 100644
index 00000000..10b90b3c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/java_api/tst.printa.d.out
@@ -0,0 +1,47 @@
+
+ 1
+count: 1
+
+ 1 3 3
+ 1 2 1
+
+ 2 3 0 4
+ 1 2 1 2
+ 1 3 3 0
+3 4
+3 4
+3
+[2, 3] 0 4
+[1, 2] 1 2
+[1, 3] 3 0
+[2, 3] 0 4
+[1, 3] 3 0
+[1, 2] 1 2
+[2, 3] 0 4
+[1, 3] 3 0
+[1, 2] 1 2
+0 4 [2, 3]
+3 0 [1, 3]
+1 2 [1, 2]
+[2, 3]
+[1, 3]
+[1, 2]
+[2]
+[1]
+[1]
+[2] 0 4
+[1] 3 0
+[1] 1 2
+0 4
+3 0
+1 2
+0 4 4
+3 0 0
+1 2 2
+[2] 0 4 4
+[1] 3 0 0
+[1] 1 2 2
+[2, 3] 0 4 4
+[1, 3] 3 0 0
+[1, 2] 1 2 2
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NL.char.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NL.char.d
new file mode 100644
index 00000000..9c0280c9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NL.char.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Newlines may not be embedded in character constants..
+ *
+ * SECTION: Lexer
+ */
+
+
+BEGIN
+{
+
+ h = '
+ ';
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NULL.char.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NULL.char.d
new file mode 100644
index 00000000..aef5dab6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_CHR_NULL.char.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Char constants may not be empty
+ *
+ * SECTION: Lexer
+ */
+
+
+BEGIN
+{
+
+ h = '';
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_DIGIT.InvalidDigit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_DIGIT.InvalidDigit.d
new file mode 100644
index 00000000..4fac03bc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_DIGIT.InvalidDigit.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: If an integer representation contains an invalid digit
+ * a D_INT_DIGIT is thrown.
+ *
+ * SECTION: Errtags/D_INT_DIGIT
+ */
+
+BEGIN
+{
+ 0128;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_OFLOW.BigInt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_OFLOW.BigInt.d
new file mode 100644
index 00000000..1ec8be8f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_INT_OFLOW.BigInt.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Using an integer constant that cannot be represented in any of the
+ * builtin integral types throws a D_INT_OFLOW error.
+ *
+ * SECTION: Errtags/D_INT_OFLOW
+ */
+
+BEGIN
+{
+ 0x12345678123456781;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_STR_NL.string.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_STR_NL.string.d
new file mode 100644
index 00000000..68b4cd42
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_STR_NL.string.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Newlines may not be embedded in string literals.
+ *
+ * SECTION: Lexer
+ */
+
+
+BEGIN
+{
+
+ h = "hello
+
+ there";
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace1.d
new file mode 100644
index 00000000..ae6dc6ce
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace1.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test detection of extra curly braces.
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+{
+ trace(epid);
+}
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace2.d
new file mode 100644
index 00000000..196f7d7c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brace2.d
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: * Test detection of missing curly braces.
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+{
+ trace(epid);
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack1.d
new file mode 100644
index 00000000..8e4c97da
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack1.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test detection of extra square brackets
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+{
+ trace(args[0]]);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack2.d
new file mode 100644
index 00000000..307bd08d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack2.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test detection of missing square brackets
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+{
+ args[0
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack3.d
new file mode 100644
index 00000000..2d66828c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.brack3.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test detection of missing square brackets
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+/args[0/
+{
+ trace(epid);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren1.d
new file mode 100644
index 00000000..812dbb7d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren1.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test detection of extra parentheses
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+{
+ trace(epid));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren2.d
new file mode 100644
index 00000000..078d08c6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren2.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test detection of missing parentheses
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+{
+ rand(
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren3.d
new file mode 100644
index 00000000..38cdb7e8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/err.D_SYNTAX.paren3.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test detection of missing parentheses
+ *
+ * SECTION: Lexer
+ */
+
+BEGIN
+/rand(/
+{
+ trace(epid);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/tst.D_MACRO_OFLOW.ParIntOvflow.d.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/tst.D_MACRO_OFLOW.ParIntOvflow.d.ksh
new file mode 100755
index 00000000..ad124ea9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/lexer/tst.D_MACRO_OFLOW.ParIntOvflow.d.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+#
+# ASSERTION:
+# If a macro argument results in an integer overflow, a D_MACRO_OFLOW is
+# thrown.
+#
+# SECTION: Errtags/D_MACRO_OFLOW
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -n 'BEGIN { $1; }' 0x12345678123456781
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ exit 0
+fi
+
+echo dtrace failed
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/tst.dtracedcmd.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/tst.dtracedcmd.ksh
new file mode 100755
index 00000000..561f8549
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mdb/tst.dtracedcmd.ksh
@@ -0,0 +1,85 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# This script primarily tests that the ::dtrace dcmd is not dumping
+# core. We don't try to make sense of the output of the dcmd nor
+# do we check to see if any output is produced. We merely see if
+# mdb fails with a fatal failure.
+#
+
+script()
+{
+ $dtrace -o $dtraceout -s /dev/stdin <<EOF
+ syscall:::entry
+ {
+ @[probefunc] = count();
+ }
+EOF
+}
+
+mdbdoit()
+{
+ mdb -k <<EOF
+ ::walk dtrace_state | ::dtrace
+EOF
+ status=$?
+ kill $script
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+dtraceout=/tmp/dtrace.out.$$
+script &
+script=$!
+timeout=15
+
+#
+# Sleep while the above script fires into life. To guard against dtrace dying
+# and us sleeping forever we allow 15 secs for this to happen. This should be
+# enough for even the slowest systems.
+#
+while [ ! -f $dtraceout ]; do
+ sleep 1
+ timeout=$(($timeout-1))
+ if [ $timeout -eq 0 ]; then
+ echo "dtrace failed to start. Exiting."
+ exit 1
+ fi
+done
+
+mdbdoit
+
+rm $dtraceout
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh
new file mode 100644
index 00000000..b1cac20f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh
@@ -0,0 +1,79 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that several of the the mib:::icmp* probes fire and fire
+# with a valid args[0].
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ mib:::icmpInEchos
+ {
+ in = args[0];
+ }
+
+ mib:::icmpOutEchoReps
+ {
+ reps = args[0];
+ }
+
+ mib:::icmpOutMsgs
+ {
+ msgs = args[0];
+ }
+
+ profile:::tick-10msec
+ /in && reps && msgs/
+ {
+ exit(0);
+ }
+EOF
+}
+
+pinger()
+{
+ while true; do
+ ping -A inet localhost
+ /usr/bin/sleep 1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+pinger &
+pinger=$!
+script
+status=$?
+
+kill $pinger
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.tcp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.tcp.ksh
new file mode 100644
index 00000000..ee602e86
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.tcp.ksh
@@ -0,0 +1,155 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that several of the the mib:::tcp* probes fire and fire
+# with a valid args[0].
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+dtraceout=/tmp/dtrace.out.$$
+timeout=15
+port=2000
+
+if [ -f $dtraceout ]; then
+ rm -f $dtraceout
+fi
+
+script()
+{
+ $dtrace -o $dtraceout -s /dev/stdin <<EOF
+ mib:::tcpActiveOpens
+ {
+ opens = args[0];
+ }
+
+ mib:::tcpOutDataBytes
+ {
+ bytes = args[0];
+ }
+
+ mib:::tcpOutDataSegs
+ {
+ segs = args[0];
+ }
+
+ profile:::tick-10msec
+ /opens && bytes && segs/
+ {
+ exit(0);
+ }
+
+ profile:::tick-1s
+ /n++ >= 10/
+ {
+ exit(1);
+ }
+EOF
+}
+
+server()
+{
+ perl /dev/stdin /dev/stdout << EOF
+ use strict;
+ use Socket;
+
+ socket(S, AF_INET, SOCK_STREAM, getprotobyname('tcp'))
+ or die "socket() failed: \$!";
+
+ setsockopt(S, SOL_SOCKET, SO_REUSEADDR, 1)
+ or die "setsockopt() failed: \$!";
+
+ my \$addr = sockaddr_in($port, INADDR_ANY);
+ bind(S, \$addr) or die "bind() failed: \$!";
+ listen(S, SOMAXCONN) or die "listen() failed: \$!";
+
+ while (1) {
+ next unless my \$raddr = accept(SESSION, S);
+
+ while (<SESSION>) {
+ }
+
+ close SESSION;
+ }
+EOF
+}
+
+client()
+{
+ perl /dev/stdin /dev/stdout <<EOF
+ use strict;
+ use Socket;
+
+ my \$peer = sockaddr_in($port, INADDR_ANY);
+
+ socket(S, AF_INET, SOCK_STREAM, getprotobyname('tcp'))
+ or die "socket() failed: \$!";
+
+ connect(S, \$peer) or die "connect failed: \$!";
+
+ for (my \$i = 0; \$i < 10; \$i++) {
+ send(S, "There!", 0) or die "send() failed: \$!";
+ sleep (1);
+ }
+EOF
+}
+
+script &
+dtrace_pid=$!
+
+#
+# Sleep while the above script fires into life. To guard against dtrace dying
+# and us sleeping forever we allow 15 secs for this to happen. This should be
+# enough for even the slowest systems.
+#
+while [ ! -f $dtraceout ]; do
+ sleep 1
+ timeout=$(($timeout-1))
+ if [ $timeout -eq 0 ]; then
+ echo "dtrace failed to start. Exiting."
+ exit 1
+ fi
+done
+
+server &
+server_pid=$!
+sleep 2
+client &
+client_pid=$!
+
+wait $dtrace_pid
+status=$?
+
+kill $server_pid
+kill $client_pid
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.udp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.udp.ksh
new file mode 100644
index 00000000..a492124c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/mib/tst.udp.ksh
@@ -0,0 +1,74 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that several of the the mib:::udp* probes fire and fire
+# with a valid args[0].
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ mib:::udpHCOutDatagrams
+ {
+ out = args[0];
+ }
+
+ mib:::udpHCInDatagrams
+ {
+ in = args[0];
+ }
+
+ profile:::tick-10msec
+ /in && out/
+ {
+ exit(0);
+ }
+EOF
+}
+
+rupper()
+{
+ while true; do
+ rup localhost
+ /usr/bin/sleep 1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+rupper &
+rupper=$!
+script
+status=$?
+
+kill $rupper
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/err.D_PRAGMA_OPTSET.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/err.D_PRAGMA_OPTSET.d
new file mode 100644
index 00000000..5238e3f3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/err.D_PRAGMA_OPTSET.d
@@ -0,0 +1,34 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet=please
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.badopt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.badopt.d
new file mode 100644
index 00000000..868b756f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.badopt.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ setopt("Nixon");
+ setopt("Harding");
+ setopt("Hoover");
+ setopt("Bush");
+ setopt("quiet", "hell no");
+ setopt("aggrate", "0.5hz");
+ setopt("bufsize", "1m");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d
new file mode 100644
index 00000000..0755271f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet=yes
+#pragma D option quiet=YES
+#pragma D option quiet=true
+#pragma D option quiet=enable
+#pragma D option quiet=enabled
+#pragma D option quiet=on
+#pragma D option quiet=set
+#pragma D option quiet=SeT
+
+#pragma D option flowindent=no
+#pragma D option flowindent=NO
+#pragma D option flowindent=false
+#pragma D option flowindent=disable
+#pragma D option flowindent=disabled
+#pragma D option flowindent=off
+#pragma D option flowindent=UnSeT
+
+BEGIN
+{
+ printf(".lived eht si paTmetsyS, lived eht si paTmetsyS\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d.out
new file mode 100644
index 00000000..2554be5c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.boolopt.d.out
@@ -0,0 +1,2 @@
+.lived eht si paTmetsyS, lived eht si paTmetsyS
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d
new file mode 100644
index 00000000..cb98d733
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+#pragma D option switchrate=1ms
+#pragma D option aggrate=1ms
+
+tick-100ms
+{
+ i++;
+}
+
+tick-100ms
+/i > 1/
+{
+ setopt("quiet", "no");
+ setopt("quiet");
+ setopt("quiet");
+ setopt("quiet", "yes");
+ @["abc"] = count();
+ printa("%@d\n", @);
+}
+
+tick-100ms
+/i == 5/
+{
+ setopt("switchrate", "5sec");
+ setopt("aggrate", "5sec");
+}
+
+tick-100ms
+/i == 31/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d.out
new file mode 100644
index 00000000..092a0426
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.dynopt.d.out
@@ -0,0 +1,31 @@
+1
+2
+3
+4
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+30
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.enablerace.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.enablerace.ksh
new file mode 100644
index 00000000..b4d56bb6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.enablerace.ksh
@@ -0,0 +1,89 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script attempts to tease out a race when probes are initially enabled.
+#
+script()
+{
+ #
+ # Nauseatingly, the #defines below must be in the 0th column to
+ # satisfy the ancient cpp that -C defaults to.
+ #
+ $dtrace -C -s /dev/stdin <<EOF
+#define PROF1 profile:::profile-4000hz
+#define PROF4 PROF1, PROF1, PROF1, PROF1
+#define PROF16 PROF4, PROF4, PROF4, PROF4
+#define PROF64 PROF16, PROF16, PROF16, PROF16
+#define PROF256 PROF64, PROF64, PROF64, PROF64
+#define PROF512 PROF256, PROF256
+
+ PROF1
+ {
+ this->x = 0;
+ }
+
+ PROF512
+ {
+ this->x++;
+ }
+
+ PROF1
+ /this->x != 512/
+ {
+ printf("failed! x is %d (expected 512)", this->x);
+ exit(1);
+ }
+
+ tick-1sec
+ /secs++/
+ {
+ exit(0);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+let i=0
+
+while [ "$i" -lt 20 ]; do
+ script
+ status=$?
+
+ if [ "$status" -ne 0 ]; then
+ exit $status
+ fi
+
+ let i=i+1
+done
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.haslam.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.haslam.d
new file mode 100644
index 00000000..a0b437b4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.haslam.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test for off-by-one error in the format lookup code
+ *
+ * SECTION: Aggregations/Aggregations; Misc
+ */
+
+/*
+ * A script from Jon Haslam that induced an off-by-one error in the
+ * format lookup code.
+ */
+BEGIN
+{
+ start = timestamp;
+ allocd = 0;
+ numallocs = 0;
+ numfrees = 0;
+ numtids = 0;
+}
+
+syscall:::entry
+{
+ @sys[tid] = sum(tid);
+}
+
+END
+{
+ printf("%s, %s, %s, %d numtids", "hhh", "jjj", "ggg", numtids );
+ printa(@sys);
+}
+
+tick-1sec
+/n++ == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.include.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.include.ksh
new file mode 100644
index 00000000..ec328021
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.include.ksh
@@ -0,0 +1,135 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/sfw/bin/gcc
+CFLAGS=
+
+doit()
+{
+ file=$1
+ ofile=$2
+ errfile=$3
+ cfile=${TMPDIR:-/tmp}/inc.$$.$file.c
+ cofile=${TMPDIR:-/tmp}/inc.$$.$file
+ cat > $cfile <<EOF
+#include <sys/$file>
+void
+main()
+{}
+EOF
+ if $CC $CFLAGS -o $cofile $cfile >/dev/null 2>&1; then
+ $dtrace -xerrtags -C -s /dev/stdin \
+ >/dev/null 2>$errfile <<EOF
+#include <sys/$file>
+BEGIN
+{
+ exit(0);
+}
+EOF
+ if [ $? -ne 0 ]; then
+ echo $inc failed: `cat $errfile | head -1` > $ofile
+ else
+ echo $inc succeeded > $ofile
+ fi
+ rm -f $errfile
+ fi
+
+ rm -f $cofile $cfile 2>/dev/null
+}
+
+if [ ! -x $CC ]; then
+ echo "$0: bad compiler: $CC" >& 2
+ exit 1
+fi
+
+concurrency=`psrinfo | wc -l`
+let concurrency=concurrency*4
+let i=0
+
+files=/usr/include/sys/*.h
+
+#
+# There are a few files in /usr/include/sys that are known to be bad -- usually
+# because they include static globals (!) or function bodies (!!) in the header
+# file. Hopefully these remain sufficiently few that the O(#files * #badfiles)
+# algorithm, below, doesn't become a problem. (And yes, writing scripts in
+# something other than ksh1888 would probably be a good idea.) If this script
+# becomes a problem, kindly fix it by reducing the number of bad files! (That
+# is, fix it by fixing the broken file, not the broken script.)
+#
+badfiles="ctype.h eri_msg.h ser_sync.h sbpro.h neti.h hook_event.h \
+ bootconf.h bootstat.h dtrace.h dumphdr.h exacct_impl.h fasttrap.h \
+ kobj.h kobj_impl.h ksyms.h lockstat.h smedia.h stat.h utsname.h"
+
+for inc in $files; do
+ file=`basename $inc`
+ for bad in $badfiles; do
+ if [ "$file" = "$bad" ]; then
+ continue 2
+ fi
+ done
+
+ ofile=${TMPDIR:-/tmp}/inc.$file.$$.out
+ errfile=${TMPDIR:-/tmp}/inc.$file.$$.err
+ doit $file $ofile $errfile &
+ let i=i+1
+
+ if [ $i -eq $concurrency ]; then
+ #
+ # This isn't optimal -- it creates a highly fluctuating load
+ # as we wait for all work to complete -- but it's an easy
+ # way of parallelizing work.
+ #
+ wait
+ let i=0
+ fi
+done
+
+wait
+
+bigofile=${TMPDIR:-/tmp}/inc.$$.out
+
+for inc in $files; do
+ file=`basename $inc`
+ ofile=${TMPDIR:-/tmp}/inc.$file.$$.out
+
+ if [ -f $ofile ]; then
+ cat $ofile >> $bigofile
+ rm $ofile
+ fi
+done
+
+status=$(grep "failed:" $bigofile | wc -l)
+cat $bigofile
+rm -f $bigofile
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh
new file mode 100644
index 00000000..a5114f49
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh
@@ -0,0 +1,41 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -ln 'syscall::*$1:entry' read | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::$1*:entry' read | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::re$1*:entry' ad | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::$1l*:entry' read | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::p$1[0-9][0-9]:entry' read | awk '{print $(NF-1),$NF}' | \
+ sort
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out
new file mode 100644
index 00000000..8a9ac6d9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out
@@ -0,0 +1,15 @@
+FUNCTION NAME
+pread entry
+read entry
+FUNCTION NAME
+read entry
+readlink entry
+readv entry
+FUNCTION NAME
+read entry
+readlink entry
+readv entry
+FUNCTION NAME
+readlink entry
+FUNCTION NAME
+pread64 entry
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.roch.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.roch.d
new file mode 100644
index 00000000..67f44622
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.roch.d
@@ -0,0 +1,93 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test for assertion failure in the ring buffer code
+ *
+ * SECTION: Buffers and Buffering/ring Policy; Misc
+ */
+
+#pragma ident "@(#)tst.roch.d 1.2 03/08/11 SMI"
+
+/*
+ * A script from Roch Bourbonnais that induced an assertion failure in the
+ * ring buffer code.
+ */
+#pragma D option strsize=16
+#pragma D option bufsize=10K
+#pragma D option bufpolicy=ring
+
+fbt:::entry
+/(self->done == 0) && (curthread->t_cpu->cpu_intr_actv == 0) /
+{
+ self->done = 1;
+ printf(" %u 0x%llX %d %d comm:%s csathr:%lld", timestamp,
+ (long long)curthread, pid, tid,
+ execname, (long long)stackdepth);
+ stack(20);
+}
+
+fbt:::return
+/(self->done == 0) && (curthread->t_cpu->cpu_intr_actv == 0) /
+{
+ self->done = 1;
+ printf(" %u 0x%llX %d %d comm:%s csathr:%lld", timestamp,
+ (long long) curthread, pid, tid,
+ execname, (long long) stackdepth);
+ stack(20);
+}
+
+fbt:::entry
+{
+ printf(" %u 0x%llX %d %d ", timestamp,
+ (long long)curthread, pid, tid);
+}
+
+fbt:::return
+{
+ printf(" %u 0x%llX %d %d tag:%d off:%d ", timestamp,
+ (long long)curthread, pid, tid, (int)arg1, (int)arg0);
+}
+
+mutex_enter:adaptive-acquire
+{
+ printf(" %u 0x%llX %d %d lock:0x%llX", timestamp,
+ (long long)curthread, pid, tid, arg0);
+}
+
+mutex_exit:adaptive-release
+{
+ printf(" %u 0x%llX %d %d lock:0x%llX", timestamp,
+ (long long) curthread, pid, tid, arg0);
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.schrock.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.schrock.ksh
new file mode 100644
index 00000000..494f6f8e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/misc/tst.schrock.ksh
@@ -0,0 +1,79 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+#
+# /usr/ccs/bin/nm execs a 64-bit version of itself. DTrace uses libproc
+# (which uses /proc) to find out when the traced process exits, but a
+# 32-bit process can't examine a 64-bit one with libproc. The
+# LD_NOEXEC_64 variable prevents nm from re-execing itself.
+#
+LD_NOEXEC_64=tomeeisrad $dtrace -F -s /dev/stdin -c \
+ '/usr/ccs/bin/nm /bin/ls' stat <<EOF
+
+pid\$target::\$1:entry
+{
+ self->start = vtimestamp;
+}
+
+pid\$target:::entry
+/self->start/
+{
+ trace(vtimestamp - self->start);
+}
+
+pid\$target:::return
+/self->start/
+{
+ trace(vtimestamp - self->start);
+}
+
+pid\$target::\$1:return
+/self->start/
+{
+ self->start = 0;
+ exit(0);
+}
+
+syscall:::
+/self->start/
+{
+ trace(vtimestamp - self->start);
+}
+
+fbt:::
+/self->start/
+{
+ trace(vtimestamp - self->start);
+}
+EOF
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGKEY.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGKEY.d
new file mode 100644
index 00000000..8074e6e3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGKEY.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @foo[123] = sum(123);
+ @bar = sum(456);
+
+ printa("%10d %@10d %@10d\n", @foo, @bar);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGPROTO.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGPROTO.d
new file mode 100644
index 00000000..dc65947a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/err.D_PRINTA_AGGPROTO.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @foo[123] = sum(123);
+ @bar["fooey"] = sum(456);
+
+ printa("%10d %@10d %@10d\n", @foo, @bar);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d
new file mode 100644
index 00000000..00588c66
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d
@@ -0,0 +1,311 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option destructive
+#pragma D option quiet
+
+BEGIN
+/0/
+{
+ @agg996[996] = quantize(998);
+ @agg997[997] = count();
+ @agg998[998] = min(998);
+ @agg999[999] = lquantize(0, -10, 10, 1);
+}
+
+BEGIN
+{
+ @agg0[0] = sum(0);
+ @agg1[1] = sum(1);
+ @agg2[2] = sum(2);
+ @agg3[3] = sum(3);
+ @agg4[4] = sum(4);
+ @agg5[5] = sum(5);
+ @agg6[6] = sum(6);
+ @agg7[7] = sum(7);
+ @agg8[8] = sum(8);
+ @agg9[9] = sum(9);
+ @agg10[10] = sum(10);
+ @agg11[11] = sum(11);
+ @agg12[12] = sum(12);
+ @agg13[13] = sum(13);
+ @agg14[14] = sum(14);
+ @agg15[15] = sum(15);
+ @agg16[16] = sum(16);
+ @agg17[17] = sum(17);
+ @agg18[18] = sum(18);
+ @agg19[19] = sum(19);
+ @agg20[20] = sum(20);
+ @agg21[21] = sum(21);
+ @agg22[22] = sum(22);
+ @agg23[23] = sum(23);
+ @agg24[24] = sum(24);
+ @agg25[25] = sum(25);
+ @agg26[26] = sum(26);
+ @agg27[27] = sum(27);
+ @agg28[28] = sum(28);
+ @agg29[29] = sum(29);
+ @agg30[30] = sum(30);
+ @agg31[31] = sum(31);
+ @agg32[32] = sum(32);
+ @agg33[33] = sum(33);
+ @agg34[34] = sum(34);
+ @agg35[35] = sum(35);
+ @agg36[36] = sum(36);
+ @agg37[37] = sum(37);
+ @agg38[38] = sum(38);
+ @agg39[39] = sum(39);
+ @agg40[40] = sum(40);
+ @agg41[41] = sum(41);
+ @agg42[42] = sum(42);
+ @agg43[43] = sum(43);
+ @agg44[44] = sum(44);
+ @agg45[45] = sum(45);
+ @agg46[46] = sum(46);
+ @agg47[47] = sum(47);
+ @agg48[48] = sum(48);
+ @agg49[49] = sum(49);
+ @agg50[50] = sum(50);
+ @agg51[51] = sum(51);
+ @agg52[52] = sum(52);
+ @agg53[53] = sum(53);
+ @agg54[54] = sum(54);
+ @agg55[55] = sum(55);
+ @agg56[56] = sum(56);
+ @agg57[57] = sum(57);
+ @agg58[58] = sum(58);
+ @agg59[59] = sum(59);
+ @agg60[60] = sum(60);
+ @agg61[61] = sum(61);
+ @agg62[62] = sum(62);
+ @agg63[63] = sum(63);
+ @agg64[64] = sum(64);
+ @agg65[65] = sum(65);
+ @agg66[66] = sum(66);
+ @agg67[67] = sum(67);
+ @agg68[68] = sum(68);
+ @agg69[69] = sum(69);
+ @agg70[70] = sum(70);
+ @agg71[71] = sum(71);
+ @agg72[72] = sum(72);
+ @agg73[73] = sum(73);
+ @agg74[74] = sum(74);
+ @agg75[75] = sum(75);
+ @agg76[76] = sum(76);
+ @agg77[77] = sum(77);
+ @agg78[78] = sum(78);
+ @agg79[79] = sum(79);
+ @agg80[80] = sum(80);
+ @agg81[81] = sum(81);
+ @agg82[82] = sum(82);
+ @agg83[83] = sum(83);
+ @agg84[84] = sum(84);
+ @agg85[85] = sum(85);
+ @agg86[86] = sum(86);
+ @agg87[87] = sum(87);
+ @agg88[88] = sum(88);
+ @agg89[89] = sum(89);
+ @agg90[90] = sum(90);
+ @agg91[91] = sum(91);
+ @agg92[92] = sum(92);
+ @agg93[93] = sum(93);
+ @agg94[94] = sum(94);
+ @agg95[95] = sum(95);
+ @agg96[96] = sum(96);
+ @agg97[97] = sum(97);
+ @agg98[98] = sum(98);
+ @agg99[99] = sum(99);
+ @agg100[100] = sum(100);
+ @agg101[101] = sum(101);
+ @agg102[102] = sum(102);
+ @agg103[103] = sum(103);
+ @agg104[104] = sum(104);
+ @agg105[105] = sum(105);
+ @agg106[106] = sum(106);
+ @agg107[107] = sum(107);
+ @agg108[108] = sum(108);
+ @agg109[109] = sum(109);
+ @agg110[110] = sum(110);
+ @agg111[111] = sum(111);
+ @agg112[112] = sum(112);
+ @agg113[113] = sum(113);
+ @agg114[114] = sum(114);
+ @agg115[115] = sum(115);
+ @agg116[116] = sum(116);
+ @agg117[117] = sum(117);
+ @agg118[118] = sum(118);
+ @agg119[119] = sum(119);
+ @agg120[120] = sum(120);
+ @agg121[121] = sum(121);
+ @agg122[122] = sum(122);
+ @agg123[123] = sum(123);
+ @agg124[124] = sum(124);
+ @agg125[125] = sum(125);
+ @agg126[126] = sum(126);
+ @agg127[127] = sum(127);
+ @agg128[128] = sum(128);
+ @agg129[129] = sum(129);
+ @agg130[130] = sum(130);
+ @agg131[131] = sum(131);
+ @agg132[132] = sum(132);
+ @agg133[133] = sum(133);
+ @agg134[134] = sum(134);
+ @agg135[135] = sum(135);
+ @agg136[136] = sum(136);
+ @agg137[137] = sum(137);
+ @agg138[138] = sum(138);
+ @agg139[139] = sum(139);
+ @agg140[140] = sum(140);
+ @agg141[141] = sum(141);
+ @agg142[142] = sum(142);
+ @agg143[143] = sum(143);
+ @agg144[144] = sum(144);
+ @agg145[145] = sum(145);
+ @agg146[146] = sum(146);
+ @agg147[147] = sum(147);
+ @agg148[148] = sum(148);
+ @agg149[149] = sum(149);
+ @agg150[150] = sum(150);
+ @agg151[151] = sum(151);
+ @agg152[152] = sum(152);
+ @agg153[153] = sum(153);
+ @agg154[154] = sum(154);
+ @agg155[155] = sum(155);
+ @agg156[156] = sum(156);
+ @agg157[157] = sum(157);
+ @agg158[158] = sum(158);
+ @agg159[159] = sum(159);
+ @agg160[160] = sum(160);
+ @agg161[161] = sum(161);
+ @agg162[162] = sum(162);
+ @agg163[163] = sum(163);
+ @agg164[164] = sum(164);
+ @agg165[165] = sum(165);
+ @agg166[166] = sum(166);
+ @agg167[167] = sum(167);
+ @agg168[168] = sum(168);
+ @agg169[169] = sum(169);
+ @agg170[170] = sum(170);
+ @agg171[171] = sum(171);
+ @agg172[172] = sum(172);
+ @agg173[173] = sum(173);
+ @agg174[174] = sum(174);
+ @agg175[175] = sum(175);
+ @agg176[176] = sum(176);
+ @agg177[177] = sum(177);
+ @agg178[178] = sum(178);
+ @agg179[179] = sum(179);
+ @agg180[180] = sum(180);
+ @agg181[181] = sum(181);
+ @agg182[182] = sum(182);
+ @agg183[183] = sum(183);
+ @agg184[184] = sum(184);
+ @agg185[185] = sum(185);
+ @agg186[186] = sum(186);
+ @agg187[187] = sum(187);
+ @agg188[188] = sum(188);
+ @agg189[189] = sum(189);
+ @agg190[190] = sum(190);
+ @agg191[191] = sum(191);
+ @agg192[192] = sum(192);
+ @agg193[193] = sum(193);
+ @agg194[194] = sum(194);
+ @agg195[195] = sum(195);
+ @agg196[196] = sum(196);
+ @agg197[197] = sum(197);
+ @agg198[198] = sum(198);
+ @agg199[199] = sum(199);
+ @agg200[200] = sum(200);
+ @agg201[201] = sum(201);
+ @agg202[202] = sum(202);
+ @agg203[203] = sum(203);
+ @agg204[204] = sum(204);
+ @agg205[205] = sum(205);
+ @agg206[206] = sum(206);
+ @agg207[207] = sum(207);
+ @agg208[208] = sum(208);
+ @agg209[209] = sum(209);
+ @agg210[210] = sum(210);
+ @agg211[211] = sum(211);
+ @agg212[212] = sum(212);
+ @agg213[213] = sum(213);
+ @agg214[214] = sum(214);
+ @agg215[215] = sum(215);
+ @agg216[216] = sum(216);
+ @agg217[217] = sum(217);
+ @agg218[218] = sum(218);
+ @agg219[219] = sum(219);
+ @agg220[220] = sum(220);
+ @agg221[221] = sum(221);
+ @agg222[222] = sum(222);
+ @agg223[223] = sum(223);
+ @agg224[224] = sum(224);
+ @agg225[225] = sum(225);
+ @agg226[226] = sum(226);
+ @agg227[227] = sum(227);
+ @agg228[228] = sum(228);
+ @agg229[229] = sum(229);
+ @agg230[230] = sum(230);
+ @agg231[231] = sum(231);
+ @agg232[232] = sum(232);
+ @agg233[233] = sum(233);
+ @agg234[234] = sum(234);
+ @agg235[235] = sum(235);
+ @agg236[236] = sum(236);
+ @agg237[237] = sum(237);
+ @agg238[238] = sum(238);
+ @agg239[239] = sum(239);
+ @agg240[240] = sum(240);
+ @agg241[241] = sum(241);
+ @agg242[242] = sum(242);
+ @agg243[243] = sum(243);
+ @agg244[244] = sum(244);
+ @agg245[245] = sum(245);
+ @agg246[246] = sum(246);
+
+ printa("%8d %8@d %8@d\n", @agg0, @agg1);
+ printf("\n");
+
+ printa("%8d %8@d %8@d\n", @agg0, @agg996);
+ printf("\n");
+
+ printa("%4d %4@d %4@d %4@d %4@d %4@d %4@d %4@d %4@d %4@d %4@d %4@d\n",
+ @agg12, @agg3, @agg73, @agg997,
+ @agg9, @agg9, @agg4, @agg998,
+ @agg11, @agg23, @agg69);
+
+ printf("\n");
+
+ printa("%8d %8@d %8@d\n", @agg245, @agg246);
+ printf("\n");
+
+ printa("%8d %8@d %8@d\n", @agg999, @agg246);
+ printf("\n");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d.out
new file mode 100644
index 00000000..e048d432
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.many.d.out
@@ -0,0 +1,265 @@
+ 0 0 0
+ 1 0 1
+
+ 0 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+
+ 69 0 0 0 0 0 0 0 0 0 0 69
+ 23 0 0 0 0 0 0 0 0 0 23 0
+ 11 0 0 0 0 0 0 0 0 11 0 0
+ 4 0 0 0 0 0 0 4 0 0 0 0
+ 9 0 0 0 0 9 9 0 0 0 0 0
+ 73 0 0 73 0 0 0 0 0 0 0 0
+ 3 0 3 0 0 0 0 0 0 0 0 0
+ 12 12 0 0 0 0 0 0 0 0 0 0
+
+ 246 0 246
+ 245 245 0
+
+ 246
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+ 246
+
+
+ 2 2
+ 5 5
+ 6 6
+ 7 7
+ 8 8
+ 10 10
+ 13 13
+ 14 14
+ 15 15
+ 16 16
+ 17 17
+ 18 18
+ 19 19
+ 20 20
+ 21 21
+ 22 22
+ 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
+ 70 70
+ 71 71
+ 72 72
+ 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
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d
new file mode 100644
index 00000000..0e675579
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @ = sum(90904);
+ printa("%@d %@d %@d\n", @, @, @);
+ printa("%@d %@d %@d\n", @);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d.out
new file mode 100644
index 00000000..b382c35a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.same.d.out
@@ -0,0 +1,3 @@
+90904 90904 90904
+90904 90904 90904
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d
new file mode 100644
index 00000000..7bfd9e57
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+tick-1ms
+{
+ i++;
+ @a[i] = sum(100 - (i / 2));
+ @b[i] = sum(100 - (i / 4));
+ @c[i] = sum(100 - (i / 8));
+ @d[i] = sum(100 - (i / 16));
+}
+
+tick-1ms
+/i == 100/
+{
+ printa("%10d %@10d %@10d %@10d %@10d\n", @a, @b, @c, @d);
+ printa("%10d %@10d %@10d %@10d %@10d\n", @d, @c, @b, @a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d.out
new file mode 100644
index 00000000..8c79190f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sort.d.out
@@ -0,0 +1,201 @@
+ 100 50 75 88 94
+ 98 51 76 88 94
+ 99 51 76 88 94
+ 96 52 76 88 94
+ 97 52 76 88 94
+ 94 53 77 89 95
+ 95 53 77 89 95
+ 92 54 77 89 95
+ 93 54 77 89 95
+ 90 55 78 89 95
+ 91 55 78 89 95
+ 88 56 78 89 95
+ 89 56 78 89 95
+ 86 57 79 90 95
+ 87 57 79 90 95
+ 84 58 79 90 95
+ 85 58 79 90 95
+ 82 59 80 90 95
+ 83 59 80 90 95
+ 80 60 80 90 95
+ 81 60 80 90 95
+ 78 61 81 91 96
+ 79 61 81 91 96
+ 76 62 81 91 96
+ 77 62 81 91 96
+ 74 63 82 91 96
+ 75 63 82 91 96
+ 72 64 82 91 96
+ 73 64 82 91 96
+ 70 65 83 92 96
+ 71 65 83 92 96
+ 68 66 83 92 96
+ 69 66 83 92 96
+ 66 67 84 92 96
+ 67 67 84 92 96
+ 64 68 84 92 96
+ 65 68 84 92 96
+ 62 69 85 93 97
+ 63 69 85 93 97
+ 60 70 85 93 97
+ 61 70 85 93 97
+ 58 71 86 93 97
+ 59 71 86 93 97
+ 56 72 86 93 97
+ 57 72 86 93 97
+ 54 73 87 94 97
+ 55 73 87 94 97
+ 52 74 87 94 97
+ 53 74 87 94 97
+ 50 75 88 94 97
+ 51 75 88 94 97
+ 48 76 88 94 97
+ 49 76 88 94 97
+ 46 77 89 95 98
+ 47 77 89 95 98
+ 44 78 89 95 98
+ 45 78 89 95 98
+ 42 79 90 95 98
+ 43 79 90 95 98
+ 40 80 90 95 98
+ 41 80 90 95 98
+ 38 81 91 96 98
+ 39 81 91 96 98
+ 36 82 91 96 98
+ 37 82 91 96 98
+ 34 83 92 96 98
+ 35 83 92 96 98
+ 32 84 92 96 98
+ 33 84 92 96 98
+ 30 85 93 97 99
+ 31 85 93 97 99
+ 28 86 93 97 99
+ 29 86 93 97 99
+ 26 87 94 97 99
+ 27 87 94 97 99
+ 24 88 94 97 99
+ 25 88 94 97 99
+ 22 89 95 98 99
+ 23 89 95 98 99
+ 20 90 95 98 99
+ 21 90 95 98 99
+ 18 91 96 98 99
+ 19 91 96 98 99
+ 16 92 96 98 99
+ 17 92 96 98 99
+ 14 93 97 99 100
+ 15 93 97 99 100
+ 12 94 97 99 100
+ 13 94 97 99 100
+ 10 95 98 99 100
+ 11 95 98 99 100
+ 8 96 98 99 100
+ 9 96 98 99 100
+ 6 97 99 100 100
+ 7 97 99 100 100
+ 4 98 99 100 100
+ 5 98 99 100 100
+ 2 99 100 100 100
+ 3 99 100 100 100
+ 1 100 100 100 100
+ 100 94 88 75 50
+ 98 94 88 76 51
+ 99 94 88 76 51
+ 96 94 88 76 52
+ 97 94 88 76 52
+ 94 95 89 77 53
+ 95 95 89 77 53
+ 92 95 89 77 54
+ 93 95 89 77 54
+ 90 95 89 78 55
+ 91 95 89 78 55
+ 88 95 89 78 56
+ 89 95 89 78 56
+ 86 95 90 79 57
+ 87 95 90 79 57
+ 84 95 90 79 58
+ 85 95 90 79 58
+ 82 95 90 80 59
+ 83 95 90 80 59
+ 80 95 90 80 60
+ 81 95 90 80 60
+ 78 96 91 81 61
+ 79 96 91 81 61
+ 76 96 91 81 62
+ 77 96 91 81 62
+ 74 96 91 82 63
+ 75 96 91 82 63
+ 72 96 91 82 64
+ 73 96 91 82 64
+ 70 96 92 83 65
+ 71 96 92 83 65
+ 68 96 92 83 66
+ 69 96 92 83 66
+ 66 96 92 84 67
+ 67 96 92 84 67
+ 64 96 92 84 68
+ 65 96 92 84 68
+ 62 97 93 85 69
+ 63 97 93 85 69
+ 60 97 93 85 70
+ 61 97 93 85 70
+ 58 97 93 86 71
+ 59 97 93 86 71
+ 56 97 93 86 72
+ 57 97 93 86 72
+ 54 97 94 87 73
+ 55 97 94 87 73
+ 52 97 94 87 74
+ 53 97 94 87 74
+ 50 97 94 88 75
+ 51 97 94 88 75
+ 48 97 94 88 76
+ 49 97 94 88 76
+ 46 98 95 89 77
+ 47 98 95 89 77
+ 44 98 95 89 78
+ 45 98 95 89 78
+ 42 98 95 90 79
+ 43 98 95 90 79
+ 40 98 95 90 80
+ 41 98 95 90 80
+ 38 98 96 91 81
+ 39 98 96 91 81
+ 36 98 96 91 82
+ 37 98 96 91 82
+ 34 98 96 92 83
+ 35 98 96 92 83
+ 32 98 96 92 84
+ 33 98 96 92 84
+ 30 99 97 93 85
+ 31 99 97 93 85
+ 28 99 97 93 86
+ 29 99 97 93 86
+ 26 99 97 94 87
+ 27 99 97 94 87
+ 24 99 97 94 88
+ 25 99 97 94 88
+ 22 99 98 95 89
+ 23 99 98 95 89
+ 20 99 98 95 90
+ 21 99 98 95 90
+ 18 99 98 96 91
+ 19 99 98 96 91
+ 16 99 98 96 92
+ 17 99 98 96 92
+ 14 100 99 97 93
+ 15 100 99 97 93
+ 12 100 99 97 94
+ 13 100 99 97 94
+ 10 100 99 98 95
+ 11 100 99 98 95
+ 8 100 99 98 96
+ 9 100 99 98 96
+ 6 100 100 99 97
+ 7 100 100 99 97
+ 4 100 100 99 98
+ 5 100 100 99 98
+ 2 100 100 100 99
+ 3 100 100 100 99
+ 1 100 100 100 100
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d
new file mode 100644
index 00000000..ddb297f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ j = 0;
+}
+
+tick-1ms
+/i < 100/
+{
+ i++;
+ @a[i] = sum(i);
+ @b[i] = sum((25 + i) % 100);
+ @c[i] = sum((50 + i) % 100);
+ @d[i] = sum((75 + i) % 100);
+}
+
+tick-1ms
+/i == 100 && j < 10/
+{
+ printf("Sorted at position %d:\n", j);
+ setopt("aggsortpos", lltostr(j));
+ printa("%9d %@9d %@9d %@9d %@9d %@9d %@9d\n", @a, @b, @c, @a, @d, @a);
+ printf("\n");
+ j++;
+}
+
+tick-1ms
+/i == 100 && j == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d.out
new file mode 100644
index 00000000..ce175391
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.sortpos.d.out
@@ -0,0 +1,1021 @@
+Sorted at position 0:
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+
+Sorted at position 1:
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+
+Sorted at position 2:
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+
+Sorted at position 3:
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+
+Sorted at position 4:
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+
+Sorted at position 5:
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+
+Sorted at position 6:
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+
+Sorted at position 7:
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+
+Sorted at position 8:
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+
+Sorted at position 9:
+ 1 1 26 51 1 76 1
+ 2 2 27 52 2 77 2
+ 3 3 28 53 3 78 3
+ 4 4 29 54 4 79 4
+ 5 5 30 55 5 80 5
+ 6 6 31 56 6 81 6
+ 7 7 32 57 7 82 7
+ 8 8 33 58 8 83 8
+ 9 9 34 59 9 84 9
+ 10 10 35 60 10 85 10
+ 11 11 36 61 11 86 11
+ 12 12 37 62 12 87 12
+ 13 13 38 63 13 88 13
+ 14 14 39 64 14 89 14
+ 15 15 40 65 15 90 15
+ 16 16 41 66 16 91 16
+ 17 17 42 67 17 92 17
+ 18 18 43 68 18 93 18
+ 19 19 44 69 19 94 19
+ 20 20 45 70 20 95 20
+ 21 21 46 71 21 96 21
+ 22 22 47 72 22 97 22
+ 23 23 48 73 23 98 23
+ 24 24 49 74 24 99 24
+ 25 25 50 75 25 0 25
+ 26 26 51 76 26 1 26
+ 27 27 52 77 27 2 27
+ 28 28 53 78 28 3 28
+ 29 29 54 79 29 4 29
+ 30 30 55 80 30 5 30
+ 31 31 56 81 31 6 31
+ 32 32 57 82 32 7 32
+ 33 33 58 83 33 8 33
+ 34 34 59 84 34 9 34
+ 35 35 60 85 35 10 35
+ 36 36 61 86 36 11 36
+ 37 37 62 87 37 12 37
+ 38 38 63 88 38 13 38
+ 39 39 64 89 39 14 39
+ 40 40 65 90 40 15 40
+ 41 41 66 91 41 16 41
+ 42 42 67 92 42 17 42
+ 43 43 68 93 43 18 43
+ 44 44 69 94 44 19 44
+ 45 45 70 95 45 20 45
+ 46 46 71 96 46 21 46
+ 47 47 72 97 47 22 47
+ 48 48 73 98 48 23 48
+ 49 49 74 99 49 24 49
+ 50 50 75 0 50 25 50
+ 51 51 76 1 51 26 51
+ 52 52 77 2 52 27 52
+ 53 53 78 3 53 28 53
+ 54 54 79 4 54 29 54
+ 55 55 80 5 55 30 55
+ 56 56 81 6 56 31 56
+ 57 57 82 7 57 32 57
+ 58 58 83 8 58 33 58
+ 59 59 84 9 59 34 59
+ 60 60 85 10 60 35 60
+ 61 61 86 11 61 36 61
+ 62 62 87 12 62 37 62
+ 63 63 88 13 63 38 63
+ 64 64 89 14 64 39 64
+ 65 65 90 15 65 40 65
+ 66 66 91 16 66 41 66
+ 67 67 92 17 67 42 67
+ 68 68 93 18 68 43 68
+ 69 69 94 19 69 44 69
+ 70 70 95 20 70 45 70
+ 71 71 96 21 71 46 71
+ 72 72 97 22 72 47 72
+ 73 73 98 23 73 48 73
+ 74 74 99 24 74 49 74
+ 75 75 0 25 75 50 75
+ 76 76 1 26 76 51 76
+ 77 77 2 27 77 52 77
+ 78 78 3 28 78 53 78
+ 79 79 4 29 79 54 79
+ 80 80 5 30 80 55 80
+ 81 81 6 31 81 56 81
+ 82 82 7 32 82 57 82
+ 83 83 8 33 83 58 83
+ 84 84 9 34 84 59 84
+ 85 85 10 35 85 60 85
+ 86 86 11 36 86 61 86
+ 87 87 12 37 87 62 87
+ 88 88 13 38 88 63 88
+ 89 89 14 39 89 64 89
+ 90 90 15 40 90 65 90
+ 91 91 16 41 91 66 91
+ 92 92 17 42 92 67 92
+ 93 93 18 43 93 68 93
+ 94 94 19 44 94 69 94
+ 95 95 20 45 95 70 95
+ 96 96 21 46 96 71 96
+ 97 97 22 47 97 72 97
+ 98 98 23 48 98 73 98
+ 99 99 24 49 99 74 99
+ 100 100 25 50 100 75 100
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d
new file mode 100644
index 00000000..ebb916a0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @one["foo", 789, "bar", curthread] = sum(123);
+ @two["foo", 789, "bar", curthread] = sum(456);
+ printa("%10s %10d %10s %@10d %@10d\n", @one, @two);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d.out
new file mode 100644
index 00000000..002f5aa1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.tuplecompat.d.out
@@ -0,0 +1,2 @@
+ foo 789 bar 123 456
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d
new file mode 100644
index 00000000..5a57b2b0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+/0/
+{
+ @bop[345] = quantize(0);
+ @baz[345] = lquantize(0, -10, 10, 1);
+}
+
+BEGIN
+{
+ @foo[123] = sum(123);
+ @bar[456] = sum(456);
+
+ @foo[789] = sum(789);
+ @bar[789] = sum(789);
+
+ printa("%10d %@10d %@10d\n", @foo, @bar);
+ printa("%10d %@10d %@10d %@10d\n", @foo, @bar, @bop);
+ printa("%10d %@10d %@10d %@10d %@10d\n", @foo, @bar, @bop, @baz);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d.out
new file mode 100644
index 00000000..dde9e41c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero.d.out
@@ -0,0 +1,55 @@
+ 456 0 456
+ 123 123 0
+ 789 789 789
+ 456 0 456
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ 123 123 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ 789 789 789
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ 456 0 456
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+
+ 123 123 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+
+ 789 789 789
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d
new file mode 100644
index 00000000..79e756bd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ @bop[345] = quantize(0, 0);
+ @baz[345] = lquantize(0, -10, 10, 1, 0);
+}
+
+BEGIN
+{
+ @foo[123] = sum(123);
+ @bar[456] = sum(456);
+
+ @foo[789] = sum(789);
+ @bar[789] = sum(789);
+
+ printa("%10d %@10d %@10d\n", @foo, @bar);
+ printa("%10d %@10d %@10d %@10d\n", @foo, @bar, @bop);
+ printa("%10d %@10d %@10d %@10d %@10d\n", @foo, @bar, @bop, @baz);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d.out
new file mode 100644
index 00000000..9b28d8e7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero2.d.out
@@ -0,0 +1,72 @@
+ 456 0 456
+ 123 123 0
+ 789 789 789
+ 345 0 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ 456 0 456
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ 123 123 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ 789 789 789
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ 345 0 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+
+ 456 0 456
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+
+ 123 123 0
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+
+ 789 789 789
+ value ------------- Distribution ------------- count
+ -1 | 0
+ 0 | 0
+ 1 | 0
+
+ value ------------- Distribution ------------- count
+ < -10 | 0
+ -10 | 0
+ -9 | 0
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d
new file mode 100644
index 00000000..bc17bc96
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+/0/
+{
+ @bop[345] = quantize(0, 0);
+ @baz[345] = lquantize(0, -10, 10, 1, 0);
+}
+
+BEGIN
+{
+ printa(@bop);
+ printa(@baz);
+ printa("%@10d %@10d\n", @bop, @baz);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d.out
new file mode 100644
index 00000000..b28b04f6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/multiaggs/tst.zero3.d.out
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.c
new file mode 100644
index 00000000..6194c580
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.c
@@ -0,0 +1,120 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <strings.h>
+#include <rpc/rpc.h>
+
+#include "rpcsvc/nfs4_prot.h"
+
+int nfs4_skip_bytes;
+
+/*
+ * The waiting() function returns the value passed in, until something
+ * external modifies it. In this case, the D script tst.call.d will
+ * modify the value of *a, and thus break the while loop in dotest().
+ *
+ * This serves the purpose of not making the RPC calls until tst.call.d
+ * is active. Thus, the probes in tst.call.d can fire as a result of
+ * the RPC call in dotest().
+ */
+
+int
+waiting(volatile int *a)
+{
+ return (*a);
+}
+
+int
+dotest(void)
+{
+ CLIENT *client;
+ AUTH *auth;
+ COMPOUND4args args;
+ COMPOUND4res res;
+ enum clnt_stat status;
+ struct timeval timeout;
+ nfs_argop4 arg[1];
+ char *tag = "dtrace test";
+ volatile int a = 0;
+
+ while (waiting(&a) == 0)
+ continue;
+
+ timeout.tv_sec = 30;
+ timeout.tv_usec = 0;
+
+ client = clnt_create("localhost", NFS4_PROGRAM, NFS_V4, "tcp");
+ if (client == NULL) {
+ clnt_pcreateerror("test");
+ return (1);
+ }
+ auth = authsys_create_default();
+ client->cl_auth = auth;
+ args.minorversion = 0;
+ args.tag.utf8string_len = strlen(tag);
+ args.tag.utf8string_val = tag;
+ args.argarray.argarray_len = sizeof (arg) / sizeof (nfs_argop4);
+ args.argarray.argarray_val = arg;
+
+ arg[0].argop = OP_PUTROOTFH;
+ /* no need to manipulate nfs_argop4_u */
+
+ bzero(&res, sizeof (res));
+
+ status = clnt_call(client, NFSPROC4_COMPOUND,
+ xdr_COMPOUND4args, (caddr_t)&args,
+ xdr_COMPOUND4res, (caddr_t)&res,
+ timeout);
+ if (status != RPC_SUCCESS) {
+ clnt_perror(client, "test");
+ return (2);
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+int
+main(int argc, char **argv)
+{
+ char shareline[BUFSIZ], unshareline[BUFSIZ];
+ int rc;
+
+ (void) snprintf(shareline, sizeof (shareline),
+ "mkdir /tmp/nfsv4test.%d ; share /tmp/nfsv4test.%d", getpid(),
+ getpid());
+ (void) snprintf(unshareline, sizeof (unshareline),
+ "unshare /tmp/nfsv4test.%d ; rmdir /tmp/nfsv4test.%d", getpid(),
+ getpid());
+
+ (void) system(shareline);
+ rc = dotest();
+ (void) system(unshareline);
+
+ return (rc);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.d
new file mode 100644
index 00000000..15cf8bc0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure nfs provider probes are firing
+ *
+ * SECTION: nfs4 provider
+ */
+
+#pragma D option destructive
+#pragma D option quiet
+
+pid$1:a.out:waiting:entry
+{
+ this->value = (int *)alloca(sizeof (int));
+ *this->value = 1;
+ copyout(this->value, arg0, sizeof (int));
+}
+
+nfsv4:::compound-start
+{
+ cstart++;
+}
+
+nfsv4:::op-putrootfh-start
+{
+ opstart++;
+}
+
+nfsv4:::op-putrootfh-done
+{
+ opdone++;
+}
+
+nfsv4:::compound-done
+/cstart && opstart && opdone/
+{
+ exit(0);
+}
+
+tick-1s
+/tick++ == 3/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.c
new file mode 100644
index 00000000..bd89fffc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.c
@@ -0,0 +1,441 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <strings.h>
+#include <rpc/rpc.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <rpcsvc/mount.h>
+
+#include "rpcsvc/nfs_prot.h"
+
+char sharedpath[MAXPATHLEN];
+fhandle3 *rootfh;
+
+/*
+ * The waiting() function returns the value passed in, until something
+ * external modifies it. In this case, the D script tst.call.d will
+ * modify the value of *a, and thus break the while loop in dotest().
+ *
+ * This serves the purpose of not making the RPC calls until tst.call.d
+ * is active. Thus, the probes in tst.call.d can fire as a result of
+ * the RPC call in dotest().
+ */
+
+int
+waiting(volatile int *a)
+{
+ return (*a);
+}
+
+static void
+getattr_arginit(void *argp)
+{
+ GETATTR3args *args = argp;
+
+ args->object.data.data_len = rootfh->fhandle3_len;
+ args->object.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+setattr_arginit(void *argp)
+{
+ SETATTR3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->object.data.data_len = rootfh->fhandle3_len;
+ args->object.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+lookup_arginit(void *argp)
+{
+ LOOKUP3args *args = argp;
+
+ args->what.name = "giant-skunk";
+ args->what.dir.data.data_len = rootfh->fhandle3_len;
+ args->what.dir.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+access_arginit(void *argp)
+{
+ ACCESS3args *args = argp;
+
+ args->object.data.data_len = rootfh->fhandle3_len;
+ args->object.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+commit_arginit(void *argp)
+{
+ COMMIT3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->file.data.data_len = rootfh->fhandle3_len;
+ args->file.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+create_arginit(void *argp)
+{
+ CREATE3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->where.name = "pinky-blue";
+ args->where.dir.data.data_len = rootfh->fhandle3_len;
+ args->where.dir.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+fsinfo_arginit(void *argp)
+{
+ FSINFO3args *args = argp;
+
+ args->fsroot.data.data_len = rootfh->fhandle3_len;
+ args->fsroot.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+fsstat_arginit(void *argp)
+{
+ FSSTAT3args *args = argp;
+
+ args->fsroot.data.data_len = rootfh->fhandle3_len;
+ args->fsroot.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+link_arginit(void *argp)
+{
+ LINK3args *args = argp;
+
+ args->file.data.data_len = rootfh->fhandle3_len;
+ args->file.data.data_val = rootfh->fhandle3_val;
+ args->link.dir.data.data_len = rootfh->fhandle3_len;
+ args->link.dir.data.data_val = rootfh->fhandle3_val;
+ args->link.name = "samf";
+}
+
+static void
+mkdir_arginit(void *argp)
+{
+ MKDIR3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->where.dir.data.data_len = rootfh->fhandle3_len;
+ args->where.dir.data.data_val = rootfh->fhandle3_val;
+ args->where.name = "cookie";
+}
+
+static void
+mknod_arginit(void *argp)
+{
+ MKNOD3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->where.dir.data.data_len = rootfh->fhandle3_len;
+ args->where.dir.data.data_val = rootfh->fhandle3_val;
+ args->where.name = "pookie";
+}
+
+static void
+null_arginit(void *argp)
+{
+}
+
+static void
+pathconf_arginit(void *argp)
+{
+ PATHCONF3args *args = argp;
+
+ args->object.data.data_len = rootfh->fhandle3_len;
+ args->object.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+read_arginit(void *argp)
+{
+ READ3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->file.data.data_len = rootfh->fhandle3_len;
+ args->file.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+readdir_arginit(void *argp)
+{
+ READDIR3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->dir.data.data_len = rootfh->fhandle3_len;
+ args->dir.data.data_val = rootfh->fhandle3_val;
+ args->count = 1024;
+}
+
+static void
+readdirplus_arginit(void *argp)
+{
+ READDIRPLUS3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->dir.data.data_len = rootfh->fhandle3_len;
+ args->dir.data.data_val = rootfh->fhandle3_val;
+ args->dircount = 1024;
+ args->maxcount = 1024;
+}
+
+static void
+readlink_arginit(void *argp)
+{
+ READLINK3args *args = argp;
+
+ args->symlink.data.data_len = rootfh->fhandle3_len;
+ args->symlink.data.data_val = rootfh->fhandle3_val;
+}
+
+static void
+remove_arginit(void *argp)
+{
+ REMOVE3args *args = argp;
+
+ args->object.dir.data.data_len = rootfh->fhandle3_len;
+ args->object.dir.data.data_val = rootfh->fhandle3_val;
+ args->object.name = "antelope";
+}
+
+static void
+rename_arginit(void *argp)
+{
+ RENAME3args *args = argp;
+
+ args->from.dir.data.data_len = rootfh->fhandle3_len;
+ args->from.dir.data.data_val = rootfh->fhandle3_val;
+ args->from.name = "walter";
+ args->to.dir.data.data_len = rootfh->fhandle3_len;
+ args->to.dir.data.data_val = rootfh->fhandle3_val;
+ args->to.name = "wendy";
+}
+
+static void
+rmdir_arginit(void *argp)
+{
+ RMDIR3args *args = argp;
+
+ args->object.dir.data.data_len = rootfh->fhandle3_len;
+ args->object.dir.data.data_val = rootfh->fhandle3_val;
+ args->object.name = "bunny";
+}
+
+static void
+symlink_arginit(void *argp)
+{
+ SYMLINK3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->where.dir.data.data_len = rootfh->fhandle3_len;
+ args->where.dir.data.data_val = rootfh->fhandle3_val;
+ args->where.name = "parlor";
+ args->symlink.symlink_data = "interior";
+}
+
+static void
+write_arginit(void *argp)
+{
+ WRITE3args *args = argp;
+
+ bzero(args, sizeof (*args));
+ args->file.data.data_len = rootfh->fhandle3_len;
+ args->file.data.data_val = rootfh->fhandle3_val;
+}
+
+typedef void (*call3_arginit_t)(void *);
+
+typedef struct {
+ call3_arginit_t arginit;
+ rpcproc_t proc;
+ xdrproc_t xdrargs;
+ size_t argsize;
+ xdrproc_t xdrres;
+ size_t ressize;
+} call3_test_t;
+call3_test_t call3_tests[] = {
+ {getattr_arginit, NFSPROC3_GETATTR, xdr_GETATTR3args,
+ sizeof (GETATTR3args), xdr_GETATTR3res, sizeof (GETATTR3res)},
+ {setattr_arginit, NFSPROC3_SETATTR, xdr_SETATTR3args,
+ sizeof (SETATTR3args), xdr_SETATTR3res, sizeof (SETATTR3res)},
+ {lookup_arginit, NFSPROC3_LOOKUP, xdr_LOOKUP3args,
+ sizeof (LOOKUP3args), xdr_LOOKUP3res, sizeof (LOOKUP3res)},
+ {access_arginit, NFSPROC3_ACCESS, xdr_ACCESS3args,
+ sizeof (ACCESS3args), xdr_ACCESS3res, sizeof (ACCESS3res)},
+ {commit_arginit, NFSPROC3_COMMIT, xdr_COMMIT3args,
+ sizeof (COMMIT3args), xdr_COMMIT3res, sizeof (COMMIT3res)},
+ {create_arginit, NFSPROC3_CREATE, xdr_CREATE3args,
+ sizeof (CREATE3args), xdr_CREATE3res, sizeof (CREATE3res)},
+ {fsinfo_arginit, NFSPROC3_FSINFO, xdr_FSINFO3args,
+ sizeof (FSINFO3args), xdr_FSINFO3res, sizeof (FSINFO3res)},
+ {fsstat_arginit, NFSPROC3_FSSTAT, xdr_FSSTAT3args,
+ sizeof (FSSTAT3args), xdr_FSSTAT3res, sizeof (FSSTAT3res)},
+ {link_arginit, NFSPROC3_LINK, xdr_LINK3args,
+ sizeof (LINK3args), xdr_LINK3res, sizeof (LINK3res)},
+ {mkdir_arginit, NFSPROC3_MKDIR, xdr_MKDIR3args,
+ sizeof (MKDIR3args), xdr_MKDIR3res, sizeof (MKDIR3res)},
+ {mknod_arginit, NFSPROC3_MKNOD, xdr_MKNOD3args,
+ sizeof (MKNOD3args), xdr_MKNOD3res, sizeof (MKNOD3res)},
+ /*
+ * NULL proc is special. Rather than special case its zero-sized
+ * args/results, we give it a small nonzero size, so as to not
+ * make realloc() do the wrong thing.
+ */
+ {null_arginit, NFSPROC3_NULL, xdr_void, sizeof (int), xdr_void,
+ sizeof (int)},
+ {pathconf_arginit, NFSPROC3_PATHCONF, xdr_PATHCONF3args,
+ sizeof (PATHCONF3args), xdr_PATHCONF3res, sizeof (PATHCONF3res)},
+ {read_arginit, NFSPROC3_READ, xdr_READ3args,
+ sizeof (READ3args), xdr_READ3res, sizeof (READ3res)},
+ {readdir_arginit, NFSPROC3_READDIR, xdr_READDIR3args,
+ sizeof (READDIR3args), xdr_READDIR3res, sizeof (READDIR3res)},
+ {readdirplus_arginit, NFSPROC3_READDIRPLUS, xdr_READDIRPLUS3args,
+ sizeof (READDIRPLUS3args), xdr_READDIRPLUS3res,
+ sizeof (READDIRPLUS3res)},
+ {readlink_arginit, NFSPROC3_READLINK, xdr_READLINK3args,
+ sizeof (READLINK3args), xdr_READLINK3res, sizeof (READLINK3res)},
+ {remove_arginit, NFSPROC3_REMOVE, xdr_REMOVE3args,
+ sizeof (REMOVE3args), xdr_REMOVE3res, sizeof (REMOVE3res)},
+ {rename_arginit, NFSPROC3_RENAME, xdr_RENAME3args,
+ sizeof (RENAME3args), xdr_RENAME3res, sizeof (RENAME3res)},
+ {rmdir_arginit, NFSPROC3_RMDIR, xdr_RMDIR3args,
+ sizeof (RMDIR3args), xdr_RMDIR3res, sizeof (RMDIR3res)},
+ {symlink_arginit, NFSPROC3_SYMLINK, xdr_SYMLINK3args,
+ sizeof (SYMLINK3args), xdr_SYMLINK3res, sizeof (SYMLINK3res)},
+ {write_arginit, NFSPROC3_WRITE, xdr_WRITE3args,
+ sizeof (WRITE3args), xdr_WRITE3res, sizeof (WRITE3res)},
+ {NULL}
+};
+
+int
+dotest(void)
+{
+ CLIENT *client, *mountclient;
+ AUTH *auth;
+ struct timeval timeout;
+ caddr_t args, res;
+ enum clnt_stat status;
+ rpcproc_t proc;
+ call3_test_t *test;
+ void *argbuf = NULL;
+ void *resbuf = NULL;
+ struct mountres3 mountres3;
+ char *sp;
+ volatile int a = 0;
+
+ while (waiting(&a) == 0)
+ continue;
+
+ timeout.tv_sec = 30;
+ timeout.tv_usec = 0;
+
+ mountclient = clnt_create("localhost", MOUNTPROG, MOUNTVERS3, "tcp");
+ if (mountclient == NULL) {
+ clnt_pcreateerror("clnt_create mount");
+ return (1);
+ }
+ auth = authsys_create_default();
+ mountclient->cl_auth = auth;
+ sp = sharedpath;
+ bzero(&mountres3, sizeof (mountres3));
+ status = clnt_call(mountclient, MOUNTPROC_MNT,
+ xdr_dirpath, (char *)&sp,
+ xdr_mountres3, (char *)&mountres3,
+ timeout);
+ if (status != RPC_SUCCESS) {
+ clnt_perror(mountclient, "mnt");
+ return (1);
+ }
+ if (mountres3.fhs_status != 0) {
+ fprintf(stderr, "MOUNTPROG/MOUNTVERS3 failed %d\n",
+ mountres3.fhs_status);
+ return (1);
+ }
+ rootfh = &mountres3.mountres3_u.mountinfo.fhandle;
+
+ client = clnt_create("localhost", NFS3_PROGRAM, NFS_V3, "tcp");
+ if (client == NULL) {
+ clnt_pcreateerror("clnt_create");
+ return (1);
+ }
+ client->cl_auth = auth;
+
+ for (test = call3_tests; test->arginit; ++test) {
+ argbuf = realloc(argbuf, test->argsize);
+ resbuf = realloc(resbuf, test->ressize);
+ if ((argbuf == NULL) || (resbuf == NULL)) {
+ perror("realloc() failed");
+ return (1);
+ }
+ (test->arginit)(argbuf);
+ bzero(resbuf, test->ressize);
+ status = clnt_call(client, test->proc,
+ test->xdrargs, argbuf,
+ test->xdrres, resbuf,
+ timeout);
+ if (status != RPC_SUCCESS)
+ clnt_perror(client, "call");
+ }
+
+ status = clnt_call(mountclient, MOUNTPROC_UMNT,
+ xdr_dirpath, (char *)&sp,
+ xdr_void, NULL,
+ timeout);
+ if (status != RPC_SUCCESS)
+ clnt_perror(mountclient, "umnt");
+
+ return (0);
+}
+
+/*ARGSUSED*/
+int
+main(int argc, char **argv)
+{
+ char shareline[BUFSIZ], unshareline[BUFSIZ];
+ int rc;
+
+ (void) snprintf(sharedpath, sizeof (sharedpath),
+ "/tmp/nfsv3test.%d", getpid());
+ (void) snprintf(shareline, sizeof (shareline),
+ "mkdir %s ; share %s", sharedpath, sharedpath);
+ (void) snprintf(unshareline, sizeof (unshareline),
+ "unshare %s ; rmdir %s", sharedpath, sharedpath);
+
+ (void) system(shareline);
+ rc = dotest();
+ (void) system(unshareline);
+
+ return (rc);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.d
new file mode 100644
index 00000000..b635b166
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/nfs/tst.call3.d
@@ -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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure nfsv3 provider probes are firing, and that the
+ * arguments are properly visible.
+ *
+ * SECTION: nfs3 provider
+ */
+
+#pragma D option destructive
+#pragma D option quiet
+
+pid$1:a.out:waiting:entry
+{
+ this->value = (int *)alloca(sizeof (int));
+ *this->value = 1;
+ copyout(this->value, arg0, sizeof (int));
+}
+
+nfsv3:::op-getattr-start
+{
+ printf("ci_local: %s\n", args[0]->ci_local);
+ printf("ci_remote: %s\n", args[0]->ci_remote);
+ printf("ci_protocol: %s\n", args[0]->ci_protocol);
+
+ printf("noi_xid: %d\n", args[1]->noi_xid);
+ printf("noi_cred->cr_uid: %d\n", args[1]->noi_cred->cr_uid);
+ printf("noi_curpath: %s\n", args[1]->noi_curpath);
+
+ printf("fh3_flags: %d\n", args[2]->object.fh3_flags);
+}
+
+nfsv3:::op-getattr-done
+{
+ printf("ci_local: %s\n", args[0]->ci_local);
+ printf("ci_remote: %s\n", args[0]->ci_remote);
+ printf("ci_protocol: %s\n", args[0]->ci_protocol);
+
+ printf("noi_xid: %d\n", args[1]->noi_xid);
+ printf("noi_cred->cr_uid: %d\n", args[1]->noi_cred->cr_uid);
+ printf("noi_curpath: %s\n", args[1]->noi_curpath);
+
+ printf("status: %d\n", args[2]->status);
+}
+
+nfsv3:::*-done
+/seen[probename] == 0/
+{
+ ++numberseen;
+ seen[probename] = 1;
+ printf("%d ops seen, latest op is %s\n", numberseen, probename);
+}
+
+nfsv3:::*-done
+/numberseen == 22/
+{
+ exit(0);
+}
+
+tick-1s
+/tick++ == 10/
+{
+ printf("%d nfsv3 ops seen; should be 22\n", numberseen);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_BITFIELD.bitfield.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_BITFIELD.bitfield.d
new file mode 100644
index 00000000..cc488463
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_BITFIELD.bitfield.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Test invocation of offsetof() with a member that is a bit-field.
+ * This should fail at compile time.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+struct foo {
+ int a:1;
+ int b:3;
+};
+
+BEGIN
+{
+ trace(offsetof(struct foo, b));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.badtype.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.badtype.d
new file mode 100644
index 00000000..4e8a8858
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.badtype.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Test invocation of offsetof() with an invalid type.
+ * This should fail at compile time.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+BEGIN
+{
+ trace(offsetof(struct no_such_type, x));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.notsou.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.notsou.d
new file mode 100644
index 00000000..84209530
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_OFFSETOF_TYPE.notsou.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ *
+ * Test invocation of offsetof() with a type that is not a struct or union.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+BEGIN
+{
+ trace(offsetof(int, x));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.OffsetofNULL.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.OffsetofNULL.d
new file mode 100644
index 00000000..5a341a33
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.OffsetofNULL.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Querying the offsetof an non-member variable of a struct throws
+ * a D_UNKNOWN error.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+#pragma D option quiet
+
+struct record {
+ int a;
+ int b;
+ int c : 4;
+};
+
+BEGIN
+{
+ printf("offsetof (struct record, NULL): %d\n",
+ offsetof (struct record, NULL));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.badmemb.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.badmemb.d
new file mode 100644
index 00000000..caf0a1d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/err.D_UNKNOWN.badmemb.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Test invocation of offsetof() with an invalid member.
+ * This should fail at compile time.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+BEGIN
+{
+ trace(offsetof(vnode_t, v_no_such_member));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofAlias.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofAlias.d
new file mode 100644
index 00000000..c7494d20
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofAlias.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test invocation of offsetof() with a struct type alias.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+typedef struct record {
+ char c;
+ int x;
+ int y;
+} record_t;
+
+BEGIN
+{
+ printf("offsetof(record_t, c) = %d\n", offsetof(record_t, c));
+ printf("offsetof(record_t, x) = %d\n", offsetof(record_t, x));
+ printf("offsetof(record_t, y) = %d\n", offsetof(record_t, y));
+ exit(0);
+}
+
+END
+/(8 != offsetof(record_t, y)) || (4 != offsetof(record_t, x)) ||
+ (0 != offsetof(record_t, c))/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofArith.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofArith.d
new file mode 100644
index 00000000..7e2b3308
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofArith.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: offsetof can be used anywhere in a D program that an integer
+ * constant can be used.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+typedef struct record {
+ char c;
+ int x;
+ int y;
+} record_t;
+
+BEGIN
+{
+
+ add = offsetof(record_t, c) + offsetof(record_t, x) +
+ offsetof(record_t, y);
+ sub = offsetof(record_t, y) - offsetof(record_t, x);
+ mul = offsetof(record_t, x) * offsetof(record_t, c);
+ div = offsetof(record_t, y) / offsetof(record_t, x);
+
+ printf("offsetof(record_t, c) = %d\n", offsetof(record_t, c));
+ printf("offsetof(record_t, x) = %d\n", offsetof(record_t, x));
+ printf("offsetof(record_t, y) = %d\n", offsetof(record_t, y));
+
+ printf("Addition of offsets (c+x+y)= %d\n", add);
+ printf("Subtraction of offsets (y-x)= %d\n", sub);
+ printf("Multiplication of offsets (x*c) = %d\n", mul);
+ printf("Division of offsets (y/x) = %d\n", div);
+
+ exit(0);
+}
+
+END
+/(8 != offsetof(record_t, y)) || (4 != offsetof(record_t, x)) ||
+ (0 != offsetof(record_t, c)) || (12 != add) || (4 != sub) || (0 != mul)
+ || (2 != div)/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofUnion.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofUnion.d
new file mode 100644
index 00000000..de1a5fab
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.OffsetofUnion.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test invocation of offsetof() with a union type alias.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ int x;
+ int y;
+ char c;
+};
+
+BEGIN
+{
+ printf("offsetof(record, x) = %d\n", offsetof(union D`record, x));
+ printf("offsetof(record, y) = %d\n", offsetof(union D`record, y));
+ printf("offsetof(record, c) = %d\n", offsetof(union D`record, c));
+ exit(0);
+}
+
+END
+/(0 != offsetof(union D`record, y)) && (0 != offsetof(union D`record, x)) &&
+ (0 != offsetof(union D`record, c))/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d
new file mode 100644
index 00000000..60b88637
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test invocation of offsetof() with a struct type.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+struct s {
+ int x;
+ int y;
+};
+
+BEGIN
+{
+ printf("offsetof(s, y) = %d\n", offsetof(struct D`s, y));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d.out
new file mode 100644
index 00000000..04b666e2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.struct.d.out
@@ -0,0 +1,2 @@
+offsetof(s, y) = 4
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d
new file mode 100644
index 00000000..1b37c4c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test invocation of offsetof() with a union type.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+union s {
+ int x;
+ int y;
+};
+
+BEGIN
+{
+ printf("offsetof(s, y) = %d\n", offsetof(union D`s, y));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d.out
new file mode 100644
index 00000000..e3918bef
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/offsetof/tst.union.d.out
@@ -0,0 +1,2 @@
+offsetof(s, y) = 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d
new file mode 100644
index 00000000..cd375195
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the ternary operator. Test left-hand side true, right-hand side true,
+ * and multiple nested instances of the ternary operator.
+ *
+ * SECTION: Types, Operators, and Expressions/Conditional Expressions
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ x = 0;
+ printf("x is %s\n", x == 0 ? "zero" : "one");
+ x = 1;
+ printf("x is %s\n", x == 0 ? "zero" : "one");
+ x = 2;
+ printf("x is %s\n", x == 0 ? "zero" : x == 1 ? "one" : "two");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d.out
new file mode 100644
index 00000000..ec30800e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/operators/tst.ternary.d.out
@@ -0,0 +1,4 @@
+x is zero
+x is one
+x is two
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.d
new file mode 100644
index 00000000..a3fa24ff
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: can't specify a bogus library name
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ */
+
+pid$1:libbmc_sucks.so.1::entry
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badproc1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badproc1.d
new file mode 100644
index 00000000..3f3ca22d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badproc1.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Verify that we don't grab bogus process IDs.
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ */
+
+pidgin:::entry
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_BADPID.badproc2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_BADPID.badproc2.d
new file mode 100644
index 00000000..8e01b060
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_BADPID.badproc2.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure we can't grab pid 0
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ */
+
+pid0:::entry
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.d
new file mode 100644
index 00000000..dabcd9c6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.d
@@ -0,0 +1,36 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+pid$1:::
+{
+}
+
+BEGIN
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe
new file mode 100755
index 00000000..25b4ff14
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.d
new file mode 100644
index 00000000..f1c44e86
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Can't specify a bogus function name (if the module is specified)
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ * NOTES:
+ *
+ */
+
+pid$1:a.out:ahl_r00lz:entry
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.d
new file mode 100644
index 00000000..dd905303
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test that the '-' function doesn't work with random modules
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ */
+
+pid$1:libc:-:800
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.d
new file mode 100644
index 00000000..6acf8aa0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Verify that you can't enable "all" '-' function probes
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ */
+
+pid$1::-:
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.d
new file mode 100644
index 00000000..829c002c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Only entry, return and offsets are valid names
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ */
+
+pid$1:a.out:main:beginning
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.d
new file mode 100644
index 00000000..36bf9d6e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Verify that you can't glob the probe name with the '-' function
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ */
+
+pid$1::-:10*
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.d
new file mode 100644
index 00000000..60e5a8c6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Can't have an offset that's outside of a function
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ * NOTES: If _exit(2) becomes _way_ more complex this could fail...
+ *
+ */
+
+pid$1::_exit:100
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.addprobes.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.addprobes.ksh
new file mode 100755
index 00000000..6c269ca2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.addprobes.ksh
@@ -0,0 +1,61 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# This test verifies that it's possible to add new pid probes to an existing
+# pid provider.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+sleep 60 &
+pid=$!
+
+$dtrace -n pid$pid:libc::entry -n 'tick-1s{exit(0);}'
+status=$?
+
+if [ $status -gt 0 ]; then
+ exit $status;
+fi
+
+$dtrace -n pid$pid:libc::return -n 'tick-1s{exit(0);}'
+status=$?
+
+if [ $status -gt 0 ]; then
+ exit $status;
+fi
+
+kill $pid
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.c
new file mode 100644
index 00000000..23bbab22
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.c
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <signal.h>
+#include <unistd.h>
+
+int
+go(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6,
+ int arg7, int arg8, int arg9)
+{
+ return (arg1);
+}
+
+static void
+handle(int sig)
+{
+ go(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ exit(0);
+}
+
+int
+main(int argc, char **argv)
+{
+ (void) signal(SIGUSR1, handle);
+ for (;;)
+ getpid();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.d
new file mode 100644
index 00000000..a3ad6c9a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.args1.d
@@ -0,0 +1,75 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test that all 10 arguments are what we expect them to be.
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the first call to getpid(2).
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:return
+/pid == $1/
+{
+ i = 0;
+ raise(SIGUSR1);
+ /*
+ * Wait half a second after raising the signal.
+ */
+ timeout = timestamp + 500000000;
+}
+
+pid$1:a.out:go:entry
+/arg0 == 0 && arg1 == 1 && arg2 == 2 && arg3 == 3 && arg4 == 4 &&
+arg5 == 5 && arg6 == 6 && arg7 == 7 && arg8 == 8 && arg9 == 9/
+{
+ exit(0);
+}
+
+pid$1:a.out:go:entry
+{
+ printf("wrong args: %d %d %d %d %d %d %d %d %d %d", arg0, arg1, arg2,
+ arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+ exit(1);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.d
new file mode 100644
index 00000000..d3d568e7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test that we can trace every instruction safely
+ *
+ * SECTION: pid provider
+ *
+ */
+
+BEGIN
+{
+ /*
+ * Let's just do this for 2 seconds.
+ */
+ timeout = timestamp + 2000000000;
+}
+
+pid$1:a.out::
+{}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.exe
new file mode 100755
index 00000000..07e84583
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.coverage.exe
@@ -0,0 +1,29 @@
+#!/usr/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+while true; do env > /dev/null; done
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d
new file mode 100644
index 00000000..e0fada86
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: the stack() action should be empty for all pid probes
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ /*
+ * Monitor the program for two seconds.
+ */
+ timeout = timestamp + 1000000000 * 2;
+}
+
+pid$1:::return
+{
+ @[stack()] = sum(0);
+}
+
+pid$1:a.out::
+{
+ @[stack()] = sum(0);
+}
+
+pid$1:::entry
+{
+ @[stack()] = sum(0);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d.out
new file mode 100644
index 00000000..2304a615
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.d.out
@@ -0,0 +1,3 @@
+
+
+ 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe
new file mode 100755
index 00000000..a8bc8cb3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe
@@ -0,0 +1,29 @@
+#!/usr/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+exec find / > /dev/null 2>&1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.c
new file mode 100644
index 00000000..450c6aae
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.c
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+
+volatile double c = 1.2;
+
+int
+main(int argc, char **argv)
+{
+ double a = 1.56;
+ double b = (double)argc;
+
+ for (;;) {
+ c *= a;
+ c += b;
+ (void) usleep(1000);
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.d
new file mode 100644
index 00000000..4e11ee33
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.float.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure we can work on processes that use the FPU
+ *
+ * SECTION: pid provider
+ */
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+pid$1:a.out:main:
+{}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.c
new file mode 100644
index 00000000..d5e90dbc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.c
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+
+int
+waiting(volatile int *a)
+{
+ return (*a);
+}
+
+int
+go(void)
+{
+ int i, j, total = 0;
+
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 10; j++) {
+ total += i * j;
+ }
+ }
+
+ return (total);
+}
+
+int
+main(int argc, char **argv)
+{
+ volatile int a = 0;
+
+ while (waiting(&a) == 0)
+ continue;
+
+ (void) forkall();
+ (void) go();
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.d
new file mode 100644
index 00000000..f1b11978
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.fork.d
@@ -0,0 +1,86 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: make sure fork(2) is okay
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option destructive
+
+pid$1:a.out:waiting:entry
+{
+ this->value = (int *)alloca(sizeof (int));
+ *this->value = 1;
+ copyout(this->value, arg0, sizeof (int));
+}
+
+proc:::create
+/pid == $1/
+{
+ child = args[0]->pr_pid;
+ trace(pid);
+}
+
+pid$1:a.out:go:
+/pid == child/
+{
+ trace("wrong pid");
+ exit(1);
+}
+
+proc:::exit
+/pid == $1 || pid == child/
+{
+ out++;
+ trace(pid);
+}
+
+proc:::exit
+/out == 2/
+{
+ exit(0);
+}
+
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.c
new file mode 100644
index 00000000..b97fa9d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.c
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <spawn.h>
+#include <signal.h>
+
+void
+go(void)
+{
+ pid_t pid;
+
+ (void) posix_spawn(&pid, "/usr/bin/ls", NULL, NULL, NULL, NULL);
+
+ (void) waitpid(pid, NULL, 0);
+}
+
+void
+intr(int sig)
+{
+}
+
+int
+main(int argc, char **argv)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = intr;
+ sigfillset(&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ (void) sigaction(SIGUSR1, &sa, NULL);
+
+ for (;;) {
+ go();
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.d
new file mode 100644
index 00000000..f119098f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.gcc.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test that we can trace every instruction safely for gcc
+ * compiled apps.
+ *
+ * SECTION: pid provider
+ *
+ */
+
+BEGIN
+{
+ /*
+ * Let's just do this for 2 seconds.
+ */
+ timeout = timestamp + 2000000000;
+}
+
+pid$1:a.out::
+{}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh
new file mode 100755
index 00000000..587878c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh
@@ -0,0 +1,41 @@
+#!/bin/ksh -p
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+#
+# Make sure we kill a process if the dtrace(1M) command fails.
+#
+
+rc=`$dtrace -c date -n jarod 2>/dev/null | /usr/bin/wc -l`
+
+exit $rc
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.main.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.main.ksh
new file mode 100755
index 00000000..b3b99601
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.main.ksh
@@ -0,0 +1,59 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+#
+# Make sure we can trace main:entry properly -- this was problematic because
+# we also set a breakpoint on the same spot in libdtrace.
+#
+
+$dtrace -c date -s /dev/stdin <<EOF
+ BEGIN
+ {
+ status = 1;
+ }
+
+ pid\$target::main:entry
+ {
+ status = 0;
+ }
+
+ END
+ {
+ exit(status);
+ }
+EOF
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh
new file mode 100644
index 00000000..869339ba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh
@@ -0,0 +1,70 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+set -A pids
+
+for lib in `ls -1 /lib/lib*.so.1 | grep -v ld.so.1`; do
+ preload=$lib:${preload}
+done
+
+export LD_PRELOAD=$preload
+
+let numkids=100
+let i=0
+
+tmpfile=/tmp/dtest.$$
+
+while [ "$i" -lt "$numkids" ]; do
+ sleep 500 &
+ pids[$i]=$!
+ let i=i+1
+done
+
+export LD_PRELOAD=
+
+let i=0
+
+echo "tick-1sec\n{\n\texit(0);\n}\n" > $tmpfile
+
+while [ "$i" -lt "$numkids" ]; do
+ echo "pid${pids[$i]}::malloc:entry\n{}\n" >> $tmpfile
+ let i=i+1
+done
+
+$dtrace -s $tmpfile
+status=$?
+
+rm $tmpfile
+pkill sleep
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh
new file mode 100755
index 00000000..35f0391b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh
@@ -0,0 +1,62 @@
+#!/bin/ksh -p
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -wZq -x switchrate=100ms -s /dev/stdin <<EOF
+pid*:date::
+{
+ printf("%s:%s\n", probefunc, probename);
+}
+
+tick-1s
+/i++ > 5/
+{
+ exit(0);
+}
+
+tick-1s
+/(i % 2) == 0/
+{
+ system("dtrace -c date -ln 'pid\$target::main:entry' >/dev/null");
+}
+
+tick-1s
+/(i % 2) == 1/
+{
+ system("dtrace -c date -ln 'pid\$target::main:return' >/dev/null");
+}
+EOF
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh.out
new file mode 100644
index 00000000..b2742c47
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh.out
@@ -0,0 +1,7 @@
+main:return
+main:entry
+main:return
+main:entry
+main:return
+main:entry
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh
new file mode 100755
index 00000000..326fd1ab
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+#
+# Let's see if we can successfully specify a module using partial
+# matches as well as the full module name. We'll use 'libc.so.1'
+# (and therefore 'libc' and 'libc.so') as it's definitely there.
+#
+
+for lib in libc libc.so libc.so.1 'lib[c]*'; do
+ sleep 60 &
+ pid=$!
+ dtrace -n "pid$pid:$lib::entry" -n 'tick-2s{exit(0);}'
+ status=$?
+
+ kill $pid
+
+ if [ $status -gt 0 ]; then
+ exit $status
+ fi
+done
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh
new file mode 100755
index 00000000..892ff3e2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex1.ksh
@@ -0,0 +1,93 @@
+#!/bin/ksh -p
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test verifies that specifying a glob in a pid provider name
+# (e.g., p*d$target) works.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=${TMPDIR:-/tmp}/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > Makefile <<EOF
+all: main
+
+main: main.o
+ cc -o main main.o
+
+main.o: main.c
+ cc -c main.c
+EOF
+
+cat > main.c <<EOF
+void
+go(void)
+{
+}
+
+int
+main(int argc, char **argv)
+{
+ go();
+
+ return (0);
+}
+EOF
+
+make > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "failed to build"
+ exit 1
+fi
+
+cat > main.d <<'EOF'
+p*d$target::go:entry
+{
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+}
+EOF
+
+script() {
+ $dtrace -q -s ./main.d -c ./main
+}
+
+script
+status=$?
+
+cd /tmp
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh
new file mode 100755
index 00000000..8d83bddd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh
@@ -0,0 +1,131 @@
+#!/bin/ksh -p
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test verifies that probes will be picked up after a dlopen(3C)
+# when the pid provider is specified as a glob (e.g., p*d$target.)
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=${TMPDIR:-/tmp}/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > Makefile <<EOF
+all: main altlib.so
+
+main: main.o
+ cc -o main main.o
+
+main.o: main.c
+ cc -c main.c
+
+altlib.so: altlib.o
+ cc -z defs -G -o altlib.so altlib.o -lc
+
+altlib.o: altlib.c
+ cc -c altlib.c
+EOF
+
+cat > altlib.c <<EOF
+void
+go(void)
+{
+}
+EOF
+
+cat > main.c <<EOF
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+
+void
+go(void)
+{
+}
+
+int
+main(int argc, char **argv)
+{
+ void *alt;
+ void *alt_go;
+
+ go();
+
+ if ((alt = dlopen("./altlib.so", RTLD_LAZY | RTLD_LOCAL))
+ == NULL) {
+ printf("dlopen of altlib.so failed: %s\n", dlerror());
+ return (1);
+ }
+
+ if ((alt_go = dlsym(alt, "go")) == NULL) {
+ printf("failed to lookup 'go' in altlib.so\n");
+ return (1);
+ }
+
+ ((void (*)(void))alt_go)();
+
+ return (0);
+}
+EOF
+
+make > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "failed to build"
+ exit 1
+fi
+
+cat > main.d <<'EOF'
+p*d$target::go:entry
+{
+ @foo[probemod, probefunc, probename] = count();
+}
+
+END
+{
+ printa("%s:%s:%s %@u\n",@foo);
+}
+EOF
+
+script() {
+ $dtrace -q -s ./main.d -c ./main
+}
+
+script
+status=$?
+
+cd /tmp
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh.out
new file mode 100644
index 00000000..824d8985
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh.out
@@ -0,0 +1,3 @@
+altlib.so:go:entry 1
+main:go:entry 1
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh
new file mode 100755
index 00000000..c9ac6b1d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh
@@ -0,0 +1,102 @@
+#!/bin/ksh -p
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test verifies that a regex in the provider name will match
+# USDT probes as well as pid probes (e.g., p*d$target matches both
+# pid$target and pyramid$target.)
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=${TMPDIR:-/tmp}/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > Makefile <<EOF
+ all: main
+
+main: main.o prov.o
+ cc -o main main.o prov.o
+
+main.o: main.c prov.h
+ cc -c main.c
+
+prov.h: prov.d
+ $dtrace -h -s prov.d
+
+prov.o: prov.d main.o
+ $dtrace -G -32 -s prov.d main.o
+EOF
+
+cat > prov.d <<EOF
+provider pyramid {
+ probe entry();
+};
+EOF
+
+cat > main.c <<EOF
+#include <sys/sdt.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ PYRAMID_ENTRY();
+}
+EOF
+
+make > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "failed to build"
+ exit 1
+fi
+
+cat > main.d <<'EOF'
+p*d$target::main:entry
+{
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+}
+EOF
+
+script() {
+ $dtrace -q -s ./main.d -c ./main
+}
+
+script
+status=$?
+
+cd /tmp
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh.out
new file mode 100644
index 00000000..5a8938fe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh.out
@@ -0,0 +1,3 @@
+main:main:entry
+main:main:entry
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh
new file mode 100755
index 00000000..278ec128
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh
@@ -0,0 +1,154 @@
+#!/bin/ksh -p
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test verifies that USDT probes will be picked up after a dlopen(3C)
+# when a regex in the provider name matches both USDT probes and pid probes
+# (e.g., p*d$target matches both pid$target and pyramid$target.)
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=${TMPDIR:-/tmp}/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > Makefile <<EOF
+all: main altlib.so
+
+main: main.o provmain.o
+ cc -o main main.o provmain.o
+
+main.o: main.c prov.h
+ cc -c main.c
+
+prov.h: prov.d
+ $dtrace -h -s prov.d
+
+provmain.o: prov.d main.o
+ $dtrace -G -32 -o provmain.o -s prov.d main.o
+
+altlib.so: altlib.o provalt.o
+ cc -z defs -G -o altlib.so altlib.o provalt.o -lc
+
+altlib.o: altlib.c prov.h
+ cc -c altlib.c
+
+provalt.o: prov.d altlib.o
+ $dtrace -G -32 -o provalt.o -s prov.d altlib.o
+EOF
+
+cat > prov.d <<EOF
+provider pyramid {
+ probe entry();
+};
+EOF
+
+cat > altlib.c <<EOF
+#include <sys/sdt.h>
+#include "prov.h"
+
+void
+go(void)
+{
+ PYRAMID_ENTRY();
+}
+EOF
+
+cat > main.c <<EOF
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/sdt.h>
+#include "prov.h"
+
+void
+go(void)
+{
+ PYRAMID_ENTRY();
+}
+
+int
+main(int argc, char **argv)
+{
+ void *alt;
+ void *alt_go;
+
+ go();
+
+ if ((alt = dlopen("./altlib.so", RTLD_LAZY | RTLD_LOCAL))
+ == NULL) {
+ printf("dlopen of altlib.so failed: %s\n", dlerror());
+ return (1);
+ }
+
+ if ((alt_go = dlsym(alt, "go")) == NULL) {
+ printf("failed to lookup 'go' in altlib.so\n");
+ return (1);
+ }
+
+ ((void (*)(void))alt_go)();
+
+ return (0);
+}
+EOF
+
+make > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "failed to build"
+ exit 1
+fi
+
+cat > main.d <<'EOF'
+p*d$target::go:entry
+{
+ @foo[probemod, probefunc, probename] = count();
+}
+
+END
+{
+ printa("%s:%s:%s %@u\n",@foo);
+}
+EOF
+
+script() {
+ $dtrace -q -s ./main.d -c ./main
+}
+
+script
+status=$?
+
+cd /tmp
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh.out
new file mode 100644
index 00000000..f4715384
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh.out
@@ -0,0 +1,3 @@
+altlib.so:go:entry 2
+main:go:entry 2
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.c
new file mode 100644
index 00000000..cfb88a83
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.c
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * The canonical name should be 'go' since we prefer symbol names with fewer
+ * leading underscores.
+ */
+
+int a = 100;
+
+int
+help(void)
+{
+ return (a);
+}
+
+int
+go(void)
+{
+ return (help() + 1);
+}
+
+static void
+handle(int sig)
+{
+ go();
+ exit(0);
+}
+
+int
+main(int argc, char **argv)
+{
+ (void) signal(SIGUSR1, handle);
+ for (;;)
+ getpid();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.d
new file mode 100644
index 00000000..0305d098
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret1.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test that we get the right return value from non-leaf returns
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the first call to getpid(2).
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:return
+/pid == $1/
+{
+ i = 0;
+ raise(SIGUSR1);
+ /*
+ * Wait half a second after raising the signal.
+ */
+ timeout = timestamp + 500000000;
+}
+
+pid$1:a.out:go:return
+/arg1 == 101/
+{
+ exit(0);
+}
+
+pid$1:a.out:go:return
+{
+ printf("wrong return value: %d", arg1);
+ exit(1);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.c
new file mode 100644
index 00000000..b64aa051
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.c
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * The canonical name should be 'go' since we prefer symbol names with fewer
+ * leading underscores.
+ */
+
+int a = 100;
+
+int
+go(void)
+{
+ return (a);
+}
+
+static void
+handle(int sig)
+{
+ go();
+ exit(0);
+}
+
+int
+main(int argc, char **argv)
+{
+ (void) signal(SIGUSR1, handle);
+ for (;;)
+ getpid();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.d
new file mode 100644
index 00000000..0232948c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.ret2.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test that we get the right return value from leaf returns
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the first call to getpid(2).
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:return
+/pid == $1/
+{
+ i = 0;
+ raise(SIGUSR1);
+ /*
+ * Wait half a second after raising the signal.
+ */
+ timeout = timestamp + 500000000;
+}
+
+pid$1:a.out:go:return
+/arg1 == 100/
+{
+ exit(0);
+}
+
+pid$1:a.out:go:return
+{
+ printf("wrong return value: %d", arg1);
+ exit(1);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.c
new file mode 100644
index 00000000..76fa711a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.c
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+
+int
+waiting(volatile int *a)
+{
+ return (*a);
+}
+
+int
+go(void)
+{
+ int i, j, total = 0;
+
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 10; j++) {
+ total += i * j;
+ }
+ }
+
+ return (total);
+}
+
+int
+main(int argc, char **argv)
+{
+ volatile int a = 0;
+
+ while (waiting(&a) == 0)
+ continue;
+
+ if (vfork() == 0) {
+ int ret = go();
+ (void) _exit(ret);
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.d
new file mode 100644
index 00000000..b31bb7f3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.vfork.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: make sure probes called from a vfork(2) child fire in the parent
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option destructive
+
+pid$1:a.out:waiting:entry
+{
+ this->value = (int *)alloca(sizeof (int));
+ *this->value = 1;
+ copyout(this->value, arg0, sizeof (int));
+}
+
+proc:::create
+/pid == $1/
+{
+ child = args[0]->pr_pid;
+}
+
+pid$1:a.out:go:
+/child != pid/
+{
+ printf("wrong pid (%d %d)", pid, child);
+ exit(1);
+}
+
+syscall::rexit:entry
+/pid == $1/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.c
new file mode 100644
index 00000000..1418f2a3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.c
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * The canonical name should be 'go' since we prefer symbol names with fewer
+ * leading underscores.
+ */
+
+#pragma weak _go = go
+
+int
+go(int a)
+{
+ return (a + 1);
+}
+
+static void
+handle(int sig)
+{
+ _go(1);
+ exit(0);
+}
+
+int
+main(int argc, char **argv)
+{
+ (void) signal(SIGUSR1, handle);
+ for (;;)
+ getpid();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.d
new file mode 100644
index 00000000..458eada0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak1.d
@@ -0,0 +1,83 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: test that we prefer symbols with fewer underscores
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the first call to getpid(2).
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:return
+/pid == $1/
+{
+ i = 0;
+ raise(SIGUSR1);
+ /*
+ * Wait half a second after raising the signal.
+ */
+ timeout = timestamp + 500000000;
+}
+
+pid$1:a.out:go:entry,
+pid$1:a.out:_go:entry
+/probefunc == "go"/
+{
+ i++;
+}
+
+pid$1:a.out:go:entry,
+pid$1:a.out:_go:entry
+/probefunc == "_go"/
+{
+ trace("resolved to '_go' rather than 'go'");
+ exit(1);
+}
+
+pid$1:a.out:go:entry,
+pid$1:a.out:_go:entry
+/i == 2/
+{
+ exit(0);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.c
new file mode 100644
index 00000000..8dabbe6e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.c
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * The canonical name should be 'go' since we prefer symbol names with fewer
+ * leading underscores.
+ */
+
+#pragma weak _go = go
+
+static int
+go(int a)
+{
+ return (a + 1);
+}
+
+static void
+handle(int sig)
+{
+ _go(1);
+ exit(0);
+}
+
+int
+main(int argc, char **argv)
+{
+ (void) signal(SIGUSR1, handle);
+ for (;;)
+ getpid();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.d
new file mode 100644
index 00000000..e3688b56
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pid/tst.weak2.d
@@ -0,0 +1,83 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: check that we prefer weak symbols to local ones
+ *
+ * SECTION: pid provider
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the first call to getpid(2).
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:return
+/pid == $1/
+{
+ i = 0;
+ raise(SIGUSR1);
+ /*
+ * Wait half a second after raising the signal.
+ */
+ timeout = timestamp + 500000000;
+}
+
+pid$1:a.out:go:entry,
+pid$1:a.out:_go:entry
+/probefunc == "_go"/
+{
+ i++;
+}
+
+pid$1:a.out:go:entry,
+pid$1:a.out:_go:entry
+/probefunc == "go"/
+{
+ trace("resolved to '_go' rather than 'go'");
+ exit(1);
+}
+
+pid$1:a.out:go:entry,
+pid$1:a.out:_go:entry
+/i == 2/
+{
+ exit(0);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.d
new file mode 100644
index 00000000..6fc9f2ff
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: make sure the plockstat probes are present in libc.
+ */
+
+plockstat$1:libc.so.1::
+{}
+
+profile:::tick-1
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.exe
new file mode 100755
index 00000000..221e8b1d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.available.exe
@@ -0,0 +1,29 @@
+#!/usr/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 100000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.d
new file mode 100644
index 00000000..5f755b3f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: make sure the plockstat probes are present in libc.
+ */
+
+plockstat$1:libc::
+{}
+
+profile:::tick-1
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.exe
new file mode 100755
index 00000000..221e8b1d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/plockstat/tst.libmap.exe
@@ -0,0 +1,29 @@
+#!/usr/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 100000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d
new file mode 100644
index 00000000..ab4106db
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: This test reproduces the alignment error.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ x = (int *) 64;
+ y = *x;
+ trace(y);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d
new file mode 100644
index 00000000..b6832087
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Trying to access the address of a user defined array variable should throw
+ * a D_ADDROF_VAR error.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Address Spaces
+ */
+
+#pragma D option quiet
+
+int a[5];
+int *p;
+
+BEGIN
+{
+ p = &a;
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d
new file mode 100644
index 00000000..028a30a4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Trying to access the address of a user defined dynamic variable should throw
+ * a D_ADDROF_VAR error.
+ *
+ * SECTION: Pointers and Arrays/Generic Pointers
+ * SECTION: Pointers and Arrays/Pointers to Dtrace Objects
+ */
+
+#pragma D option quiet
+
+int i;
+int *p;
+
+BEGIN
+{
+ i = 10;
+ p = &i;
+
+ printf("Integer: %d, Pointer: %d\n", i, *p);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d
new file mode 100644
index 00000000..8b592620
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test that the & operator fails with D_ADDROF_VAR if its operand
+ * is a dynamic variable such as an aggregation.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ * SECTION: Pointers and Arrays/Pointers to Dtrace Objects
+ */
+
+BEGIN
+{
+ @a = count();
+ trace(&@a);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d
new file mode 100644
index 00000000..96d25b40
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Can not dereference non-pointers
+ *
+ * SECTION: Pointers and Arrays/Pointer Safety
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int x;
+
+BEGIN
+{
+ b = *x;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d
new file mode 100644
index 00000000..f2fa5b31
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Cannot dereference a void * pointer.
+ *
+ * SECTION: Pointers and Arrays/Generic Pointers
+ */
+
+#pragma D option quiet
+
+void *p;
+
+int array[3];
+
+BEGIN
+{
+ array[0] = 234;
+ array[1] = 334;
+ array[2] = 434;
+
+ p = &array[0];
+
+ printf("array[0]: %d, p: %d\n", array[0], *p);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d
new file mode 100644
index 00000000..94814a7b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Arrays may not be assigned as a whole in D.
+ *
+ * SECTION: Pointers and Arrays/Pointer and Array Relationship
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int array1[3];
+int array2[3];
+
+BEGIN
+{
+ array1[0] = 200;
+ array1[1] = 400;
+ array1[2] = 600;
+
+ array2[0] = 300;
+ array2[1] = 500;
+ array2[2] = 700;
+
+ array2 = array1;
+
+ printf("array1[0]: %d\tarray2[0]: %d\n", array1[0], array2[0]);
+ printf("array1[1]: %d\tarray2[1]: %d\n", array1[1], array2[1]);
+ printf("array1[2]: %d\tarray2[2]: %d\n", array1[2], array2[2]);
+
+ exit(0);
+
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d
new file mode 100644
index 00000000..e81c2bd8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * May not apply pointer arithmetic to an object of type void *
+ *
+ * SECTION: Pointers and Arrays/Generic Pointers
+ */
+
+#pragma D option quiet
+
+void *p;
+
+BEGIN
+{
+ printf("p: %d\n", (int) p);
+ printf("p+1: %d\n", (int) (p+1));
+ printf("p+2: %d\n", (int) (p+2));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d
new file mode 100644
index 00000000..98282402
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: D pointers do not allow invalid address changes.
+ *
+ * SECTION: Pointers and Arrays/Pointer Safety
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ &`kmem_flags = (int *) 0x185ede4;
+ printf("Address of kmem_flags: %d\n", (int) kmemAddress);
+ printf("Value of kmem_flags: %d\n", `kmem_flags);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d
new file mode 100644
index 00000000..6f253277
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Accessing the members of a struct using the pointer notation using a
+ * nonpointer variable throws a D_OP_PTR error.
+ *
+ * SECTION: Structs and Unions/Pointers to Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct myinput_struct {
+ int i;
+ char c;
+};
+
+struct myinput_struct f;
+
+BEGIN
+{
+ f.i = 10;
+ f.c = 'c';
+
+ printf("f->i: %d\tf->c: %c\n", f->i, f->c);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d
new file mode 100644
index 00000000..b1524e53
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * -> can only be used with pointer operands.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Address Spaces
+ */
+
+#pragma D option quiet
+
+struct teststruct {
+ int a;
+ int b;
+};
+
+struct teststruct xyz;
+
+BEGIN
+{
+ xyz->a = 1;
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d
new file mode 100644
index 00000000..75635773
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Accessing a pointer to a struct like a non pointer throws a D_OP_SOU.
+ *
+ * SECTION: Structs and Unions/Pointers to Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct myinput_struct {
+ int i;
+ char c;
+};
+
+struct myinput_struct *f;
+BEGIN
+{
+ f.i = 10;
+ f.c = 'c';
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d
new file mode 100644
index 00000000..1b351f34
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * -> can only be used with pointer to structs and unions.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Address Spaces
+ */
+
+#pragma D option quiet
+
+int *abc;
+
+BEGIN
+{
+ abc->a = 1;
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d
new file mode 100644
index 00000000..9c9d2f0f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: D pointers do not allow invalid pointer accesses.
+ *
+ * SECTION: Pointers and Arrays/Pointer Safety
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ kmemAddress = &`kmem_flags;
+ *kmemAddress = 20;
+ printf("Address of kmem_flags: %d\n", (int) kmemAddress);
+ printf("Value of kmem_flags: %d\n", `kmem_flags);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d
new file mode 100644
index 00000000..324f4011
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: D pointers do not allow invalid pointer accesses.
+ *
+ * SECTION: Pointers and Arrays/Pointer Safety
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ x = (int *)alloca(sizeof (int));
+ trace(x);
+ y = (int *) (x - 3300778156056);
+ *y = 3;
+ trace(*y);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d
new file mode 100644
index 00000000..39bd1140
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: D pointers do not allow invalid pointer accesses.
+ *
+ * SECTION: Pointers and Arrays/Pointer Safety
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ y = (int *) (-33007);
+ *y = 3;
+ trace(*y);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d
new file mode 100644
index 00000000..9d6b1440
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Demonstrating valid memory access.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ x = (int *)alloca(sizeof (int));
+ printf("Address x: %x\n", (int) x);
+ y = (int *) (x - 2);
+ *y = 3;
+ printf("Address y: %x\tValue: %d\n", (int) y, *y);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d
new file mode 100644
index 00000000..64b77289
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d
@@ -0,0 +1,75 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using integer arithmetic providing a non-aligned memory address will throw
+ * a runtime error.
+ *
+ * SECTION: Pointers and Arrays/Generic Pointers
+ *
+ * NOTES:
+ * This test doesn't apply to x86; for the time being, we're working
+ * around this with the preprocessor.
+ */
+
+#pragma D option quiet
+
+int array[3];
+uintptr_t uptr;
+int *p;
+int *q;
+int *r;
+
+BEGIN
+{
+#ifdef __i386
+ exit(1);
+#else
+ array[0] = 20;
+ array[1] = 40;
+ array[2] = 80;
+
+ uptr = (uintptr_t) &array[0];
+
+ p = (int *) (uptr);
+ q = (int *) (uptr + 2);
+ r = (int *) (uptr + 3);
+
+ printf("array[0]: %d\t*p: %d\n", array[0], *p);
+ printf("array[1]: %d\t*q: %d\n", array[1], *q);
+ printf("array[2]: %d\t*r: %d\n", array[2], *r);
+
+ exit(0);
+#endif
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d
new file mode 100644
index 00000000..fb9db752
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d
@@ -0,0 +1,174 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Declare arrays of different data types and verify that the
+ * addresses of the individual elements differ by an amount equal to the number
+ * elements separating them multiplied by the size of each element.
+ *
+ * SECTION: Pointers and Arrays/Array Declarations and Storage;
+ * Pointers and Arrays/Pointer Arithmetic
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+char char_array[5];
+short short_array[5];
+int int_array[5];
+long long_array[5];
+long long long_long_array[5];
+int8_t int8_array[5];
+int16_t int16_array[5];
+int32_t int32_array[5];
+int64_t int64_array[5];
+intptr_t intptr_array[5];
+uint8_t uint8_array[5];
+uint16_t uint16_array[5];
+uint32_t uint32_array[5];
+uint64_t uint64_array[5];
+uintptr_t uintptr_array[5];
+
+/*
+float float_array[5];
+double double_array[5];
+long double long_double_array[5];
+
+string string_array[5];
+*/
+
+struct record {
+ char ch;
+ int in;
+} struct_array[5];
+
+struct {
+ char ch;
+ int in;
+} anon_struct_array[5];
+
+union record {
+ char ch;
+ int in;
+} union_array[5];
+
+union {
+ char ch;
+ int in;
+} anon_union_array[5];
+
+enum colors {
+ RED,
+ GREEN,
+ BLUE
+} enum_array[5];
+
+BEGIN
+{
+ char_var0 = &char_array[0]; char_var2 = &char_array[2];
+ short_var0 = &short_array[0]; short_var3 = &short_array[3];
+ int_var3 = &int_array[3]; int_var5 = &int_array[5];
+
+ long_var0 = &long_array[0]; long_var4 = &long_array[4];
+ long_long_var0 = &long_long_array[0];
+ long_long_var2 = &long_long_array[2];
+ int8_var3 = &int8_array[3]; int8_var5 = &int8_array[5];
+
+ int16_var0 = &int16_array[0]; int16_var4 = &int16_array[4];
+ int32_var0 = &int32_array[0]; int32_var3 = &int32_array[3];
+ int64_var0 = &int64_array[0]; int64_var1 = &int64_array[1];
+
+ uintptr_var0 = &uintptr_array[0]; uintptr_var2 = &uintptr_array[2];
+ struct_var0 = &struct_array[0]; struct_var2 = &struct_array[2];
+ anon_struct_var3 = &anon_struct_array[3];
+ anon_struct_var5 = &anon_struct_array[5];
+
+ union_var0 = &union_array[0]; union_var3 = &union_array[3];
+ anon_union_var0 = &anon_union_array[0];
+ anon_union_var4 = &anon_union_array[4];
+ enum_var0 = &enum_array[0]; enum_var2 = &enum_array[2];
+
+ printf("char_var2 - char_var0: %d\n",
+ (int) char_var2 - (int) char_var0);
+ printf("short_var3 - short_var0: %d\n",
+ (int) short_var3 - (int) short_var0);
+ printf("int_var5 - int_var3: %d\n", (int) int_var5 - (int) int_var3);
+
+ printf("long_var4 - long_var0: %d\n",
+ (int) long_var4 - (int) long_var0);
+ printf("long_long_var2 - long_long_var0: %d\n",
+ (int) long_long_var2 - (int) long_long_var0);
+ printf("int8_var5 - int8_var3: %d\n",
+ (int) int8_var5 - (int) int8_var3);
+
+ printf("int16_var4 - int16_var0: %d\n",
+ (int) int16_var4 - (int) int16_var0);
+ printf("int32_var3 - int32_var0: %d\n",
+ (int) int32_var3 - (int) int32_var0);
+ printf("int64_var1 - int64_var0: %d\n",
+ (int) int64_var1 - (int) int64_var0);
+
+ printf("uintptr_var2 - uintptr_var0: %d\n",
+ (int) uintptr_var2 - (int) uintptr_var0);
+ printf("struct_var2 - struct_var0: %d\n",
+ (int) struct_var2 - (int) struct_var0);
+ printf("anon_struct_var5 - anon_struct_var3: %d\n",
+ (int) anon_struct_var5 - (int) anon_struct_var3);
+
+ printf("union_var3 - union_var0: %d\n",
+ (int) union_var3 - (int) union_var0);
+ printf("anon_union_var4 - anon_union_var0: %d\n",
+ (int) anon_union_var4 - (int) anon_union_var0);
+ printf("enum_var2 - enum_var0: %d\n",
+ (int) enum_var2 - (int) enum_var0);
+ exit(0);
+}
+
+END
+/(2 != ((int) char_var2 - (int) char_var0)) ||
+ (6 != ((int) short_var3 - (int) short_var0)) ||
+ (8 != ((int) int_var5 - (int) int_var3)) ||
+ ((32 != ((int) long_var4 - (int) long_var0)) &&
+ (16 != ((int) long_var4 - (int) long_var0))) ||
+ (16 != ((int) long_long_var2 - (int) long_long_var0)) ||
+ (2 != ((int) int8_var5 - (int) int8_var3))
+ || (8 != ((int) int16_var4 - (int) int16_var0)) ||
+ (12 != ((int) int32_var3 - (int) int32_var0)) ||
+ (8 != ((int) int64_var1 - (int) int64_var0)) ||
+ ((16 != ((int) uintptr_var2 - (int) uintptr_var0))
+ && (8 != ((int) uintptr_var2 - (int) uintptr_var0))) ||
+ (16 != ((int) struct_var2 - (int) struct_var0)) ||
+ (16 != ((int) anon_struct_var5 - (int) anon_struct_var3))
+ || (12 != ((int) union_var3 - (int) union_var0)) ||
+ (16 != ((int) anon_union_var4 - (int) anon_union_var0)) ||
+ (8 != ((int) enum_var2 - (int) enum_var0))/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d
new file mode 100644
index 00000000..bf645398
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: D permits the use of array [] index notation with both pointer
+ * variables and array variables.
+ *
+ * SECTION: Pointers and Arrays/Pointer and Array Relationship
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int array[5];
+BEGIN
+{
+ array[0] = 100;
+ array[1] = 200;
+ array[2] = 300;
+ array[3] = 400;
+ array[4] = 500;
+
+ p = &array[0];
+
+ printf("array[0]: %d\tp[0]: %d\n", array[0], p[0]);
+ printf("array[1]: %d\tp[1]: %d\n", array[1], p[1]);
+ printf("array[2]: %d\tp[2]: %d\n", array[2], p[2]);
+ printf("array[3]: %d\tp[3]: %d\n", array[3], p[3]);
+ printf("array[4]: %d\tp[4]: %d\n", array[4], p[4]);
+
+ exit(0);
+
+}
+
+END
+/(array[0] != p[0]) || (array[1] != p[1]) || (array[2] != p[2]) ||
+ (array[3] != p[3]) || (array[4] != p[4])/
+{
+ printf("Error");
+ exit(1);
+}
+
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d
new file mode 100644
index 00000000..a0be1306
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: In D, the an array variable can be assigned to a pointer.
+ *
+ * SECTION: Pointers and Arrays/Pointer and Array Relationship
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int array[5];
+int *p;
+
+BEGIN
+{
+ array[0] = 100;
+ array[1] = 200;
+ array[2] = 300;
+ array[3] = 400;
+ array[4] = 500;
+
+ p = array;
+
+ printf("array[0]: %d\tp[0]: %d\n", array[0], p[0]);
+ printf("array[1]: %d\tp[1]: %d\n", array[1], p[1]);
+ printf("array[2]: %d\tp[2]: %d\n", array[2], p[2]);
+ printf("array[3]: %d\tp[3]: %d\n", array[3], p[3]);
+ printf("array[4]: %d\tp[4]: %d\n", array[4], p[4]);
+
+ exit(0);
+
+}
+
+END
+/(array[0] != p[0]) || (array[1] != p[1]) || (array[2] != p[2]) ||
+ (array[3] != p[3]) || (array[4] != p[4])/
+{
+ printf("Error");
+ exit(1);
+}
+
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d
new file mode 100644
index 00000000..8b7f36e3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Pointer declarations are global.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ kmemAddress = &`kmem_flags;
+ kmemValue = *kmemAddress;
+ printf("Address of kmem_flags: %x\n", (int) kmemAddress);
+ printf("Value of kmem_flags: %d\n", kmemValue);
+}
+
+profile:::tick-1sec
+/(i < 1) && (&`kmem_flags == kmemAddress) && (*kmemAddress == kmemValue)/
+{
+ exit(1);
+}
+
+END
+/(&`kmem_flags == kmemAddress) && (*kmemAddress == kmemValue)/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d
new file mode 100644
index 00000000..99cbd7e5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Integer arithmetic can be performed on pointers by casting to uintptr_t.
+ *
+ * SECTION: Pointers and Arrays/Generic Pointers
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int array[3];
+uintptr_t uptr;
+int *p;
+int *q;
+int *r;
+
+BEGIN
+{
+ array[0] = 20;
+ array[1] = 40;
+ array[2] = 80;
+
+ uptr = (uintptr_t) &array[0];
+
+ p = (int *) (uptr);
+ q = (int *) (uptr + 4);
+ r = (int *) (uptr + 8);
+
+ printf("array[0]: %d\t*p: %d\n", array[0], *p);
+ printf("array[1]: %d\t*q: %d\n", array[1], *q);
+ printf("array[2]: %d\t*r: %d\n", array[2], *r);
+
+ exit(0);
+}
+
+END
+/(20 != *p) || (40 != *q) || (80 != *r)/
+{
+ printf("Error");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d
new file mode 100644
index 00000000..3a968325
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Pointer arithmetic implicitly adjusts the underlying address by
+ * multiplying or dividing the operands by the size of the type referenced
+ * by the pointer.
+ *
+ * SECTION: Pointers and Arrays/Pointer Arithmetic
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int *x;
+
+BEGIN
+{
+ printf("x: %x\n", (int) x);
+ printf("x + 1: %x\n", (int) (x+1));
+ printf("x + 2: %x\n", (int) (x+2));
+ exit(0);
+}
+
+END
+/(0 != (int) x) || (4 != (int) (x+1)) || (8 != (int) (x+2))/
+{
+ printf("Error");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d
new file mode 100644
index 00000000..ac55eb44
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * D pointers can be used to refer to consecutive storage locations like
+ * arrays.
+ *
+ * SECTION: Pointers and Arrays/Pointer and Array Relationship
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int array[5];
+BEGIN
+{
+ array[0] = 100;
+ array[1] = 200;
+ array[2] = 300;
+ array[3] = 400;
+ array[4] = 500;
+
+ p = &array[0];
+
+ printf("array[0]: %d\t*p: %d\n", array[0], *p);
+ printf("array[1]: %d\t*(p+1): %d\n", array[1], *(p+1));
+ printf("array[2]: %d\t*(p+2): %d\n", array[2], *(p+2));
+ printf("array[3]: %d\t*(p+3): %d\n", array[3], *(p+3));
+ printf("array[4]: %d\t*(p+4): %d\n", array[4], *(p+4));
+
+ exit(0);
+
+}
+
+END
+/(array[0] != *p) || (array[1] != *(p+1)) || (array[2] != *(p+2))
+ || (array[3] != *(p+3)) || (array[4] != *(p+4))/
+{
+ printf("Error");
+ exit(1);
+}
+
+
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d
new file mode 100644
index 00000000..a4f4bfc4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Pointer arithmetic implicitly adjusts the underlying address by
+ * multiplying or dividing the operands by the size of the type referenced
+ * by the pointer.
+ *
+ * SECTION: Pointers and Arrays/Pointer Arithmetic
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int *x;
+int *y;
+int a[5];
+
+BEGIN
+{
+ x = &a[0];
+ y = &a[2];
+
+ printf("y-x: %x\n", (int) (y-x));
+ exit(0);
+}
+
+END
+/(2 != (int) (y-x)) /
+{
+ printf("Error");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d
new file mode 100644
index 00000000..3a496869
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Pointers assignment simply copies over the pointer address in the
+ * variable on the right hand side into the variable on the left hand side.
+ *
+ * SECTION: Pointers and Arrays/Pointer and Array Relationship
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+int array[3];
+int *ptr1;
+int *ptr2;
+
+BEGIN
+{
+ array[0] = 200;
+ array[1] = 400;
+ array[2] = 600;
+
+ ptr1 = array;
+ ptr2 = ptr1;
+
+ ptr2[0] = 400;
+ ptr2[1] = 800;
+ ptr2[2] = 1200;
+
+ printf("array[0]: %d\tptr2[0]: %d\n", array[0], ptr2[0]);
+ printf("array[1]: %d\tptr2[1]: %d\n", array[1], ptr2[1]);
+ printf("array[2]: %d\tptr2[2]: %d\n", array[2], ptr2[2]);
+
+ exit(0);
+
+}
+
+END
+/(array[0] != 400) || (array[1] != 800) || (array[2] != 1200)/
+{
+ printf("Error");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d
new file mode 100644
index 00000000..5d9db388
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Demonstrating valid memory access.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ x = (int *)alloca(sizeof (int));
+ printf("Address x: %x\n", (int) x);
+ y = (int *) (x);
+ *y = 3;
+ printf("Address y: %x\tValue: %d\n", (int) y, *y);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d
new file mode 100644
index 00000000..26d698ae
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Demonstrating valid memory access.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ x = (int *)alloca(sizeof (int));
+ printf("Address x: %x\n", (int) x);
+ y = (int *) (x + 2);
+ *y = 3;
+ printf("Address y: %x\tValue: %d\n", (int) y, *y);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d
new file mode 100644
index 00000000..296fdf40
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Can dereference a void * pointer only by casting it to another type.
+ *
+ * SECTION: Pointers and Arrays/Generic Pointers
+ */
+
+#pragma D option quiet
+
+void *p;
+
+int array[3];
+
+BEGIN
+{
+ array[0] = 234;
+ array[1] = 334;
+ array[2] = 434;
+
+ p = &array[0];
+ newp = (int *) p;
+
+ printf("array[0]: %d, newp: %d\n", array[0], *newp);
+ exit(0);
+}
+
+END
+/234 != *newp/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d
new file mode 100644
index 00000000..bf3154a0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Pointers can be stored in variables.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ kmemAddress = &`kmem_flags;
+ kmemValue = *kmemAddress;
+ printf("Address of kmem_flags: %x\n", (int) kmemAddress);
+ printf("Value of kmem_flags: %d\n", kmemValue);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d
new file mode 100644
index 00000000..6b72b632
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Pointers can be stored in associative arrays.
+ *
+ * SECTION: Pointers and Arrays/Pointers and Addresses
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ assoc_array["kmemAddress"] = &`kmem_flags;
+ kmemValue = *(assoc_array["kmemAddress"]);
+ printf("Address of kmem_flags: %x\n", (int) assoc_array["kmemAddress"]);
+ printf("Value of kmem_flags: %d\n", kmemValue);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGERR.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGERR.d
new file mode 100644
index 00000000..863ddc86
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGERR.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify pragma errors
+ *
+ * SECTION: Pragmas
+ */
+
+
+#pragma D error "this is an error message"
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_DEPEND.main.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_DEPEND.main.d
new file mode 100644
index 00000000..0b5a3402
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_DEPEND.main.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * It isn't permitted for a main program to contain a depends_on imperative.
+ */
+
+#pragma D depends_on library net.d
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_INVAL.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_INVAL.d
new file mode 100644
index 00000000..c6fd1471
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_INVAL.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify invalid attributes
+ *
+ * SECTION: Pragmas;
+ * Stabilty/Interface Attributes
+ */
+
+
+inline int foo
+
+#pragma D attributes incorrect_attr foo
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_MALFORM.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_MALFORM.d
new file mode 100644
index 00000000..7f0ba232
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_MALFORM.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify malformed pragma argument list
+ *
+ * SECTION: Pragmas
+ */
+
+
+#pragma D attributes incorrect_attr
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_UNUSED.UnusedPragma.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_UNUSED.UnusedPragma.d
new file mode 100644
index 00000000..da2336bc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.D_PRAGMA_UNUSED.UnusedPragma.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Unused pragmas throw error D_PRAGMA_UNUSED
+ *
+ * SECTION: Errtags/D_PRAGMA_UNUSED
+ *
+ */
+
+void func(int, int);
+
+#pragma D option quiet
+#pragma D attributes Stable/Stable/Common func;
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.circlibdep.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.circlibdep.ksh
new file mode 100644
index 00000000..6fbace8d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.circlibdep.ksh
@@ -0,0 +1,58 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+libdir=${TMPDIR:-/tmp}/libdep.$$
+dtrace=$1
+
+setup_libs()
+{
+ mkdir $libdir
+ cat > $libdir/liba.$$.d <<EOF
+#pragma D depends_on library libb.$$.d
+EOF
+ cat > $libdir/libb.$$.d <<EOF
+#pragma D depends_on library libc.$$.d
+EOF
+ cat > $libdir/libc.$$.d <<EOF
+#pragma D depends_on library liba.$$.d
+EOF
+}
+
+
+setup_libs
+
+$dtrace -L$libdir -e
+
+status=$?
+rm -rf $libdir
+return $status
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.invalidlibdep.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.invalidlibdep.ksh
new file mode 100644
index 00000000..b05ae3dc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/err.invalidlibdep.ksh
@@ -0,0 +1,57 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+libdir=${TMPDIR:-/tmp}/libdep.$$
+dtrace=$1
+
+setup_libs()
+{
+ mkdir $libdir
+ cat > $libdir/liba.$$.d <<EOF
+#pragma D depends_on library libnotthere.$$.d
+EOF
+ cat > $libdir/libb.$$.d <<EOF
+#pragma D depends_on library libc.$$.d
+EOF
+ cat > $libdir/libc.$$.d <<EOF
+#pragma D depends_on library liba.$$.d
+EOF
+}
+
+
+setup_libs
+
+$dtrace -L$libdir -e
+
+status=$?
+rm -rf $libdir
+return $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libchain.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libchain.ksh
new file mode 100644
index 00000000..7c92243f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libchain.ksh
@@ -0,0 +1,58 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+libdir=${TMPDIR:-/tmp}/libdep.$$
+dtrace=$1
+
+setup_libs()
+{
+ mkdir $libdir
+ cat > $libdir/liba.$$.d <<EOF
+#pragma D depends_on library libb.$$.d
+
+inline int foo = bar;
+EOF
+ cat > $libdir/libb.$$.d <<EOF
+#pragma D depends_on module doogle_knows_all_probes
+
+inline int bar = 0xd0061e;
+EOF
+}
+
+
+setup_libs
+
+$dtrace -L$libdir -e
+
+status=$?
+rm -rf $libdir
+return $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdep.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdep.ksh
new file mode 100644
index 00000000..38b34606
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdep.ksh
@@ -0,0 +1,66 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+libdir=${TMPDIR:-/tmp}/libdep.$$
+dtrace=$1
+
+setup_libs()
+{
+ mkdir $libdir
+ cat > $libdir/liba.$$.d <<EOF
+#pragma D depends_on library libb.$$.d
+#pragma D depends_on library libc.$$.d
+#pragma D depends_on library libd.$$.d
+EOF
+ cat > $libdir/libb.$$.d <<EOF
+#pragma D depends_on library libc.$$.d
+EOF
+ cat > $libdir/libc.$$.d <<EOF
+EOF
+ cat > $libdir/libd.$$.d <<EOF
+EOF
+ cat > $libdir/libe.$$.d <<EOF
+#pragma D depends_on library liba.$$.d
+EOF
+ cat > $libdir/libf.$$.d <<EOF
+EOF
+}
+
+
+setup_libs
+
+$dtrace -L$libdir -e
+
+status=$?
+rm -rf $libdir
+return $status
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdepfullyconnected.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdepfullyconnected.ksh
new file mode 100644
index 00000000..e95de696
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pragma/tst.libdepfullyconnected.ksh
@@ -0,0 +1,100 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test verifies that we can generate the correct ordering for
+# a given dependency specification. All files either have a dependency
+# on another file or are the dependent of another file. In this way we
+# guarantee consistent ordering as no nodes in the dependency graph will
+# be isolated.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+tmpfile=/tmp/libdeporder.$$
+libdir=${TMPDIR:-/tmp}/libdep.$$
+dtrace=$1
+
+setup_libs()
+{
+ mkdir $libdir
+ cat > $libdir/liba.$$.d <<EOF
+#pragma D depends_on library libd.$$.d
+EOF
+ cat > $libdir/libb.$$.d <<EOF
+EOF
+ cat > $libdir/libc.$$.d <<EOF
+#pragma D depends_on library libe.$$.d
+EOF
+ cat > $libdir/libd.$$.d <<EOF
+#pragma D depends_on library libb.$$.d
+EOF
+ cat > $libdir/libe.$$.d <<EOF
+#pragma D depends_on library liba.$$.d
+EOF
+}
+
+
+setup_libs
+
+DTRACE_DEBUG=1 $dtrace -L$libdir -e >$tmpfile 2>&1
+
+perl /dev/stdin $tmpfile <<EOF
+
+ @order = qw(libc libe liba libd libb);
+
+ while (<>) {
+ if (\$_ =~ /lib[a-e]\.[0-9]+.d/) {
+ \$pos = length \$_;
+ for (\$i=0; \$i<=1;\$i++) {
+ \$pos = rindex(\$_, "/", \$pos);
+ \$pos--;
+ }
+
+ push(@new, substr(\$_, \$pos+2, 4));
+ next;
+ }
+ next;
+ }
+
+ exit 1 if @new != @order;
+
+ while (@new) {
+ exit 1 if pop(@new) ne pop(@order);
+ }
+
+ exit 0;
+EOF
+
+
+status=$?
+rm -rf $libdir
+rm $tmpfile
+return $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_PRED_SCALAR.NonScalarPred.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_PRED_SCALAR.NonScalarPred.d
new file mode 100644
index 00000000..5f02b7a4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_PRED_SCALAR.NonScalarPred.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Predicate result must be of scalar type.
+ *
+ * SECTION: Errtags/ D_PRED_SCALAR
+ *
+ */
+
+#pragma D option quiet
+int a[4];
+
+BEGIN
+/a/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.invalid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.invalid.d
new file mode 100644
index 00000000..391d4256
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.invalid.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple if,then operation test.
+ * Call invalid conditions and make sure it gives compilation error.
+ *
+ * SECTION: Program Structure/Predicates
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile-1
+/i < != > 10/
+{
+ i++;
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.operr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.operr.d
new file mode 100644
index 00000000..8ffab279
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/err.D_SYNTAX.operr.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple if,then operations test.
+ * Call impossible conditions and make sure compilation fails.
+ *
+ * SECTION: Program Structure/Predicates
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile-1
+/i != 0 && >= 5 || <= 10/
+{
+ i++;
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.argsnotcached.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.argsnotcached.d
new file mode 100644
index 00000000..f461c5dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.argsnotcached.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+int schedules;
+int executes;
+
+/*
+ * This script is a bit naughty: it's assuming the implementation of the
+ * VM system's page scanning. If this implementation changes -- either by
+ * changing the function that scans pages or by making that scanning
+ * multithreaded -- this script will break.
+ */
+fbt::timeout:entry
+/args[0] == (void *)&genunix`schedpaging/
+{
+ schedules++;
+}
+
+fbt::schedpaging:entry
+/executes == 10/
+{
+ printf("%d schedules, %d executes\n", schedules, executes);
+ exit(executes == schedules ? 0 : 1);
+}
+
+fbt::schedpaging:entry
+{
+ executes++;
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d
new file mode 100644
index 00000000..9b43b619
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple if,then operations test.
+ * Call simple expressions and make sure test satisfy conditions.
+ * Match expected output in tst.basics.d.out
+ *
+ * SECTION: Program Structure/Predicates
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i < 10/
+{
+ i++;
+ trace(i);
+}
+
+tick-10ms
+/i == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d.out
new file mode 100644
index 00000000..2a5b99aa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.basics.d.out
@@ -0,0 +1 @@
+12345678910
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d
new file mode 100644
index 00000000..d08543f0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Complex operations and if,then test.
+ * Call 'n' permutation and combination of operations over if,then.
+ * Match expected output in tst.complex.d.out
+ *
+ * SECTION: Program Structure/Predicates
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ j = 0;
+}
+
+tick-10ms
+/i < 10/
+{
+ i++;
+ j++;
+ printf("\n\n%d\n------\n", i);
+}
+
+tick-10ms
+/i == 5 || i == 10/
+{
+ printf("i == 5 (or) i == 10\n");
+}
+
+tick-10ms
+/i <= 5/
+{
+ printf("i <= 5\n");
+}
+
+tick-10ms
+/j >= 5/
+{
+ printf("j >= 5\n");
+}
+
+tick-10ms
+/j >= 5 || i <= 5/
+{
+ printf("i >= 5 || j >= 5\n");
+}
+
+tick-10ms
+/j >= 5 && i <= 5/
+{
+ printf("j >= 5 && i <= 55\n");
+}
+
+tick-10ms
+/i < 5/
+{
+ printf("i < 5\n");
+}
+
+tick-10ms
+/i == 2 || j == 2/
+{
+ printf("i == 2 (or) j == 2\n");
+}
+
+tick-10ms
+/i == 2 && j == 2/
+{
+ printf("i == 2 (and) j == 2\n");
+}
+
+tick-10ms
+/j != 10/
+{
+ printf("j != 10\n");
+}
+
+tick-10ms
+/j == 5 || i == 2/
+{
+ printf("j == 5 || i == 2\n");
+}
+
+tick-10ms
+/j == 5 && i == 2/
+{
+ printf("j == 5 && i == 2\n");
+}
+
+tick-10ms
+/i == 10/
+{
+ printf("i == 10\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d.out
new file mode 100644
index 00000000..5f16dbdb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.complex.d.out
@@ -0,0 +1,83 @@
+
+
+1
+------
+i <= 5
+i >= 5 || j >= 5
+i < 5
+j != 10
+
+
+2
+------
+i <= 5
+i >= 5 || j >= 5
+i < 5
+i == 2 (or) j == 2
+i == 2 (and) j == 2
+j != 10
+j == 5 || i == 2
+
+
+3
+------
+i <= 5
+i >= 5 || j >= 5
+i < 5
+j != 10
+
+
+4
+------
+i <= 5
+i >= 5 || j >= 5
+i < 5
+j != 10
+
+
+5
+------
+i == 5 (or) i == 10
+i <= 5
+j >= 5
+i >= 5 || j >= 5
+j >= 5 && i <= 55
+j != 10
+j == 5 || i == 2
+
+
+6
+------
+j >= 5
+i >= 5 || j >= 5
+j != 10
+
+
+7
+------
+j >= 5
+i >= 5 || j >= 5
+j != 10
+
+
+8
+------
+j >= 5
+i >= 5 || j >= 5
+j != 10
+
+
+9
+------
+j >= 5
+i >= 5 || j >= 5
+j != 10
+
+
+10
+------
+i == 5 (or) i == 10
+j >= 5
+i >= 5 || j >= 5
+i == 10
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh
new file mode 100644
index 00000000..f06edcb5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh
@@ -0,0 +1,197 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+unload()
+{
+ #
+ # Get the list of services whose processes have USDT probes. Ideally
+ # it would be possible to unload the fasttrap provider while USDT
+ # probes exist -- once that fix is integrated, this hack can go away
+ # We create two lists -- one of regular SMF services and one of legacy
+ # services -- since each must be enabled and disabled using a specific
+ # mechanism.
+ #
+ pids=$(dtrace -l | \
+ perl -ne 'print "$1\n" if (/^\s*\S+\s+\S*\D(\d+)\s+/);' | \
+ sort | uniq | tr '\n' ',')
+
+ ctids=$(ps -p $pids -o ctid | tail +2 | sort | uniq)
+ svcs=
+ lrcs=
+
+ for ct in $ctids
+ do
+ line=$(svcs -o fmri,ctid | grep " $ct\$")
+ svc=$(echo $line | cut -d' ' -f1)
+
+ if [[ $(svcs -Ho STA $svc) == "LRC" ]]; then
+ lrc=$(svcs -Ho SVC $svc | tr _ '?')
+ lrcs="$lrcs $lrc"
+ else
+ svcs="$svcs $svc"
+ fi
+ done
+
+ for svc in $svcs
+ do
+ svcadm disable -ts $svc
+ done
+
+ for lrc in $lrcs
+ do
+ #
+ # Does it seem a little paternalistic that lsvcrun requires
+ # this environment variable to be set? I'd say so...
+ #
+ SMF_RESTARTER=svc:/system/svc/restarter:default \
+ /lib/svc/bin/lsvcrun $lrc stop
+ done
+
+ modunload -i 0
+ modunload -i 0
+ modunload -i 0
+ modinfo | grep dtrace
+ success=$?
+
+ for svc in $svcs
+ do
+ svcadm enable -ts $svc
+ done
+
+ for lrc in $lrcs
+ do
+ SMF_RESTARTER=svc:/system/svc/restarter:default \
+ /lib/svc/bin/lsvcrun $lrc start
+ done
+
+ if [ ! $success ]; then
+ echo $tst: could not unload dtrace
+ exit 1
+ fi
+}
+
+script1()
+{
+ $dtrace -s /dev/stdin <<EOF
+ syscall:::entry
+ /pid != $ppid/
+ {
+ @a[probefunc] = count();
+ }
+
+ tick-1sec
+ /i++ == 5/
+ {
+ exit(0);
+ }
+EOF
+}
+
+script2()
+{
+ $dtrace -s /dev/stdin <<EOF
+
+ #pragma D option statusrate=1ms
+
+ syscall:::entry
+ /pid == $ppid/
+ {
+ ttl++;
+ }
+
+ tick-1sec
+ /i++ == 5/
+ {
+ exit(2);
+ }
+
+ END
+ /ttl/
+ {
+ printf("success; ttl is %d", ttl);
+ exit(0);
+ }
+
+ END
+ /ttl == 0/
+ {
+ printf("error -- total should be non-zero");
+ exit(1);
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+ppid=$$
+dtrace=$1
+
+unload
+script1 &
+child=$!
+
+let waited=0
+
+while [ "$waited" -lt 5 ]; do
+ seconds=`date +%S`
+
+ if [ "$seconds" -ne "$last" ]; then
+ last=$seconds
+ let waited=waited+1
+ fi
+done
+
+wait $child
+status=$?
+
+if [ "$status" -ne 0 ]; then
+ echo $tst: first dtrace failed
+ exit $status
+fi
+
+unload
+script2 &
+child=$!
+
+let waited=0
+
+while [ "$waited" -lt 10 ]; do
+ seconds=`date +%S`
+
+ if [ "$seconds" -ne "$last" ]; then
+ last=$seconds
+ let waited=waited+1
+ fi
+done
+
+wait $child
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_IDENT_UNDEF.afterprobe.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_IDENT_UNDEF.afterprobe.d
new file mode 100644
index 00000000..ac63b43e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_IDENT_UNDEF.afterprobe.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ *
+ * Declare 'ifdef' statements after probe clause definition and
+ * attempt to print the value before that.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
+#if !defined (FLAG)
+#define VALUE 5
+#endif
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_PRAGCTL_INVAL.tabdefine.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_PRAGCTL_INVAL.tabdefine.d
new file mode 100644
index 00000000..e79ad2e5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_PRAGCTL_INVAL.tabdefine.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call #define statement not in first column, just after a tab.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+ #define VALUE 5
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The VALUE is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_SYNTAX.withoutpound.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_SYNTAX.withoutpound.d
new file mode 100644
index 00000000..aac2bcf9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.D_SYNTAX.withoutpound.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Just call a 'define' statement without '#'
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+define VALUE 5
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.defincomp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.defincomp.d
new file mode 100644
index 00000000..750ce6dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.defincomp.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a incomplete #define statement
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#define
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefelsenotendif.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefelsenotendif.d
new file mode 100644
index 00000000..6ad696a7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefelsenotendif.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call ifdef statement without endif statement.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG)
+#define RETURN 5
+#else
+#define RETURN 10
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", RETURN);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefincomp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefincomp.d
new file mode 100644
index 00000000..37c637c9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefincomp.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call a 'if !defined' incomplete statement.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined
+#define VALUE 5
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefnotendif.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefnotendif.d
new file mode 100644
index 00000000..09fdb170
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.ifdefnotendif.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call a complete '!ifdefine' statement but without 'endif' statement.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG)
+#define VALUE 5
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.incompelse.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.incompelse.d
new file mode 100644
index 00000000..ee92f69c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.incompelse.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Just call a #else statement
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#else
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.mulelse.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.mulelse.d
new file mode 100644
index 00000000..958f4e2b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/err.mulelse.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Attempt to declare a multiple else 'ifdef' declarations.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG)
+#define VALUE 5
+#else
+#define VALUE 10
+#else
+#define VALUE 15
+#else
+#define VALUE 20
+#endif
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d
new file mode 100644
index 00000000..a17ee0e2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple test to test 'if defined' 'defined' 'else' 'endif'
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if defined (FLAG)
+#define VALUE 5
+#else
+#define VALUE 10
+#endif
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d.out
new file mode 100644
index 00000000..2bde5e93
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifdef.d.out
@@ -0,0 +1,2 @@
+The value is 10
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d
new file mode 100644
index 00000000..b40cf012
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple test for 'ifndef'.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#ifndef FLAG
+#define FLAG
+#endif
+
+#if defined (FLAG)
+#define VALUE 5
+#else
+#define VALUE 10
+#endif
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d.out
new file mode 100644
index 00000000..d51d19fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifndef.d.out
@@ -0,0 +1,2 @@
+The value is 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d
new file mode 100644
index 00000000..345a82f7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple if !defined, define, else and endif test
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG)
+#define VALUE 5
+#else
+#define VALUE 10
+#endif
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d.out
new file mode 100644
index 00000000..d51d19fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.ifnotdef.d.out
@@ -0,0 +1,2 @@
+The value is 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d
new file mode 100644
index 00000000..c8ea3481
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple !defined, logical 'and' (&&) test.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG) && !defined(STATUS)
+#define VALUE 0
+#else
+#define VALUE 1
+#endif
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d.out
new file mode 100644
index 00000000..350295cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicaland.d.out
@@ -0,0 +1,2 @@
+The value is 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d
new file mode 100644
index 00000000..63637d3c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple !defined logical-or(||) and logical-and(&&) test.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG) || !defined(STATUS) && !defined(STATE)
+#define VALUE 0
+#else
+#define VALUE 1
+#endif
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d.out
new file mode 100644
index 00000000..350295cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalandor.d.out
@@ -0,0 +1,2 @@
+The value is 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d
new file mode 100644
index 00000000..b99ee1dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * if !defined (logical-or) usage.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG) || !defined(STATUS)
+#define VALUE 0
+#else
+#define VALUE 1
+#endif
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d.out
new file mode 100644
index 00000000..350295cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.logicalor.d.out
@@ -0,0 +1,2 @@
+The value is 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d
new file mode 100644
index 00000000..9bca2cb0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * if !defined multiple logical-and(&&) usage.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG) && !defined(STATUS) && !defined(STATE)
+#define VALUE 0
+#else
+#define VALUE 1
+#endif
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d.out
new file mode 100644
index 00000000..350295cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.muland.d.out
@@ -0,0 +1,2 @@
+The value is 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d
new file mode 100644
index 00000000..1d0c4d97
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple multiple ifdefined logical-or(||) test.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if !defined (FLAG) || !defined(STATUS) || !defined(STATE)
+#define VALUE 0
+#else
+#define VALUE 1
+#endif
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d.out
new file mode 100644
index 00000000..350295cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.mulor.d.out
@@ -0,0 +1,2 @@
+The value is 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d
new file mode 100644
index 00000000..1d21d472
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple #define test.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#define value 5
+
+
+#pragma D option quiet
+
+tick-10ms
+/value == 5/
+{
+ printf("The value is %d\n", value);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d.out
new file mode 100644
index 00000000..d51d19fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.precondi.d.out
@@ -0,0 +1,2 @@
+The value is 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.predicatedeclare.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.predicatedeclare.d
new file mode 100644
index 00000000..db5e94bb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.predicatedeclare.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Attempt to declare 'ifdef' statement inbetween probe declaration
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-10ms
+#if !defined (FLAG)
+#define VALUE 5
+#endif
+{
+
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d
new file mode 100644
index 00000000..044e5a1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple #define and predicates test.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#define MAXVAL 10 * 15
+
+
+#pragma D option quiet
+
+tick-10ms
+/MAXVAL > 5/
+{
+ printf("The value is %d\n", MAXVAL);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d.out
new file mode 100644
index 00000000..7ae49795
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexp.d.out
@@ -0,0 +1,2 @@
+The value is 150
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d
new file mode 100644
index 00000000..d917d334
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple ifdefined, define, else, endif test.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#if defined (FLAG)
+#define VALUE 5
+#else
+#define VALUE 10
+#endif
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d.out
new file mode 100644
index 00000000..2bde5e93
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpelse.d.out
@@ -0,0 +1,2 @@
+The value is 10
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d
new file mode 100644
index 00000000..b0ae3953
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple define, if defined, define and endif tests.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#define FLAG 1
+#if defined (FLAG)
+#define VALUE 5
+#endif
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d.out
new file mode 100644
index 00000000..d51d19fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpif.d.out
@@ -0,0 +1,2 @@
+The value is 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d
new file mode 100644
index 00000000..c6210d09
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple define, if defined, else, endif test.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+#define FLAG 1
+#if defined (FLAG)
+#define VALUE 5
+#else
+#define VALUE 10
+#endif
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d.out
new file mode 100644
index 00000000..d51d19fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.preexpifelse.d.out
@@ -0,0 +1,2 @@
+The value is 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.withinprobe.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.withinprobe.d
new file mode 100644
index 00000000..83a2445b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/preprocessor/tst.withinprobe.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a 'ifdef' section inside a probe clause.
+ *
+ * SECTION: Program Structure/Use of the C Preprocessor
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+
+#if !defined (FLAG)
+#define VALUE 5
+#endif
+
+ printf("The value is %d\n", VALUE);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badagg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badagg.d
new file mode 100644
index 00000000..817d9ac0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badagg.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invokes printa() with a bad aggregation argument.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ */
+
+BEGIN
+{
+ printa("%d", 123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badfmt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badfmt.d
new file mode 100644
index 00000000..5a419822
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badfmt.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invokes printa() with a bad format string.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ */
+
+BEGIN
+{
+ printa(123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badval.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badval.d
new file mode 100644
index 00000000..e8663ab7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_AGGARG.badval.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invokes printa() with an argument that does not match the aggregation
+ * convertion.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ */
+
+BEGIN
+{
+ printa("%@d\n", 123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_PROTO.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_PROTO.bad.d
new file mode 100644
index 00000000..8e202f6d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTA_PROTO.bad.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invokes printa() with a bad aggregation argument.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ */
+
+BEGIN
+{
+ printa("%d");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.jstack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.jstack.d
new file mode 100644
index 00000000..09b4b27f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.jstack.d
@@ -0,0 +1,36 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @[jstack()] = count();
+
+ printa("%p\n", @);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.stack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.stack.d
new file mode 100644
index 00000000..8815ad68
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.stack.d
@@ -0,0 +1,36 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @[stack()] = count();
+
+ printa("%p\n", @);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.ustack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.ustack.d
new file mode 100644
index 00000000..bce1b673
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/err.D_PRINTF_ARG_TYPE.ustack.d
@@ -0,0 +1,36 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @[ustack()] = count();
+
+ printa("%p\n", @);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d
new file mode 100644
index 00000000..f5353870
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Test the basic formatting of all the supported kinds of aggregations.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a = avg(1);
+ @b = count();
+ @c = lquantize(1, 1, 10);
+ @d = max(1);
+ @e = min(1);
+ @f = sum(1);
+ @g = quantize(1);
+ @h = stddev(1);
+
+ printa("@a = %@u\n", @a);
+ printa("@b = %@u\n", @b);
+ printa("@c = %@d\n", @c);
+ printa("@d = %@u\n", @d);
+ printa("@e = %@u\n", @e);
+ printa("@f = %@u\n", @f);
+ printa("@g = %@d\n", @g);
+ printa("@h = %@d\n", @h);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d.out
new file mode 100644
index 00000000..ddad2134
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.basics.d.out
@@ -0,0 +1,19 @@
+@a = 1
+@b = 1
+@c =
+ value ------------- Distribution ------------- count
+ < 1 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 2 | 0
+
+@d = 1
+@e = 1
+@f = 1
+@g =
+ value ------------- Distribution ------------- count
+ 0 | 0
+ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
+ 2 | 0
+
+@h = 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d
new file mode 100644
index 00000000..50011e3f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the printa() default output format.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a = count();
+ printa(@a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d.out
new file mode 100644
index 00000000..7cf67012
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.def.d.out
@@ -0,0 +1,3 @@
+
+ 1
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d
new file mode 100644
index 00000000..f3379c98
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ /*
+ * Yes, this works. But is it useful? And is it useful to someone
+ * other than jwadams and/or dep?
+ */
+ @[10, 100] = sum(1);
+ @[-10, 200] = sum(2);
+
+ printa("-->%-*d<--\n", @);
+ printa("-->%*d<--\n", @);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d.out
new file mode 100644
index 00000000..f6c53eb9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.dynwidth.d.out
@@ -0,0 +1,5 @@
+-->100 <--
+-->200 <--
+--> 100<--
+-->200 <--
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d
new file mode 100644
index 00000000..8f8cd41b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the printa() format string in its simplest form.
+ *
+ * SECTION: Output Formatting/printa()
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a = count();
+ printa("%@u", @a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d.out
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.fmt.d.out
@@ -0,0 +1 @@
+1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.largeusersym.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.largeusersym.ksh
new file mode 100644
index 00000000..ed375fdb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.largeusersym.ksh
@@ -0,0 +1,83 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+void
+thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog(void)
+{
+ while (1)
+ ;
+}
+
+int
+main(int argc, char *argv[])
+{
+ thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog();
+}
+EOF
+
+cc -o test test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ profile:::profile-1001hz
+ /pid == \$target/
+ {
+ @[arg1] = count();
+ }
+
+ tick-1s
+ /n++ > 10/
+ {
+ printa("%A %@d\n", @);
+ exit(0);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.many.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.many.d
new file mode 100644
index 00000000..5bd3eae7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.many.d
@@ -0,0 +1,76 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=32m
+#pragma D option bufpolicy=fill
+#pragma D option destructive
+#pragma D option quiet
+
+BEGIN
+/0 == 1/
+{
+ @ = count();
+}
+
+BEGIN
+{
+ freopen("/dev/null");
+}
+
+profile-4000hz
+{
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+ printa(@);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d
new file mode 100644
index 00000000..c9fae843
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the use of many aggregation results in the same format string.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a = count();
+ printa("%@u %@u %@u %@u %@u %@u %@u\n", @a);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d.out
new file mode 100644
index 00000000..f08b797e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.manyval.d.out
@@ -0,0 +1,2 @@
+1 1 1 1 1 1 1
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.stack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.stack.d
new file mode 100644
index 00000000..88dbb1a7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.stack.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ @[stack()] = count();
+ @[ustack()] = count();
+ @[jstack()] = count();
+
+ printa("%k\n", @);
+ printa("%-20k\n", @);
+ printa("%60k\n", @);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d
new file mode 100644
index 00000000..0eea887b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the use of tuple arguments in the printa() format.
+ *
+ * SECTION: Output Formatting/printa()
+ *
+ * NOTES:
+ * We confirm that we can consume fewer arguments than in the tuple, all
+ * the way up to the exact number.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ @a[1, 2, 3, 4, 5] = count();
+ printf("\n");
+
+ printa("%@u: -\n", @a);
+ printa("%@u: %d\n", @a);
+ printa("%@u: %d %d\n", @a);
+ printa("%@u: %d %d %d\n", @a);
+ printa("%@u: %d %d %d %d\n", @a);
+ printa("%@u: %d %d %d %d %d\n", @a);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d.out
new file mode 100644
index 00000000..928119c9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.tuple.d.out
@@ -0,0 +1,8 @@
+
+1: -
+1: 1
+1: 1 2
+1: 1 2 3
+1: 1 2 3 4
+1: 1 2 3 4 5
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh
new file mode 100644
index 00000000..bb0d5a0f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh
@@ -0,0 +1,62 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+# The output files assumes the timezone is US/Pacific
+TZ=US/Pacific
+
+$dtrace -s /dev/stdin <<EOF
+#pragma D option quiet
+#pragma D option destructive
+
+BEGIN
+{
+ @foo = min(1075064400 * (hrtime_t)1000000000);
+ @bar = max(walltimestamp);
+ printa("%@T\n", @foo);
+ printa("%@Y\n", @foo);
+
+ freopen("/dev/null");
+ printa("%@T\n", @bar);
+ printa("%@Y\n", @bar);
+
+ exit(0);
+}
+EOF
+
+if [ $? -ne 0 ]; then
+ print -u2 "dtrace failed"
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out
new file mode 100644
index 00000000..7462cf8e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out
@@ -0,0 +1,2 @@
+Sun, 25 Jan 2004 13:00:00 PST
+2004 Jan 25 13:00:00
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_AGG_CONV.aggfmt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_AGG_CONV.aggfmt.d
new file mode 100644
index 00000000..9cac625d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_AGG_CONV.aggfmt.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with a bad aggregation format.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("hello %@d", 123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.toomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.toomany.d
new file mode 100644
index 00000000..de87e8d7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.toomany.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with too many arguments.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("x = %d y = %d\n", 123, 456, 789);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.widths.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.widths.d
new file mode 100644
index 00000000..93812800
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_EXTRA.widths.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Negative test to test variety of fixed width formats.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n");
+ x = 0;
+
+ printf("%?d\n", x++, 1);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_FMT.badfmt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_FMT.badfmt.d
new file mode 100644
index 00000000..bf4dc72c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_FMT.badfmt.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with a bad format string arg.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf(123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_PROTO.novalue.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_PROTO.novalue.d
new file mode 100644
index 00000000..68f8cf02
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_PROTO.novalue.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with a missing value argument.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%s");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.aggarg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.aggarg.d
new file mode 100644
index 00000000..99bb0395
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.aggarg.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test printf() with a bad aggregation arg.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ @a = count();
+ printf("hello %d %d", 123, @a);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.recursive.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.recursive.d
new file mode 100644
index 00000000..3b94ba73
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_ARG_TYPE.recursive.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid recursive printf test.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+ printf("%s\n", printf("test"));
+
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.noprec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.noprec.d
new file mode 100644
index 00000000..ba8a1a46
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.noprec.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with a missing dynamic precision argument.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%s %.*d\n", "foo");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.nowidth.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.nowidth.d
new file mode 100644
index 00000000..4d72c819
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_PROTO.nowidth.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with a missing dynamic width argument.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%s %*d\n", "foo");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badprec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badprec.d
new file mode 100644
index 00000000..64cf9125
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badprec.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test a dynamic precision argument of non-integer type.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%.*d\n", "foo", 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badwidth.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badwidth.d
new file mode 100644
index 00000000..badc95ee
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PRINTF_DYN_TYPE.badwidth.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Tet dynamic width argument of non-integer type.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%*d\n", "foo", 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PROTO_LEN.toofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PROTO_LEN.toofew.d
new file mode 100644
index 00000000..32c877ba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_PROTO_LEN.toofew.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with too few arguments.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv1.d
new file mode 100644
index 00000000..7add3319
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv1.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the unsupported %n$ conversion syntax.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%3$d", 123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv2.d
new file mode 100644
index 00000000..5cc32e27
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv2.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test an incomplete conversion.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%3", 123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv3.d
new file mode 100644
index 00000000..0dedea3d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/err.D_SYNTAX.badconv3.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test an undefined conversion.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ printf("%Z", 123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d
new file mode 100644
index 00000000..8d4bb819
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the basics of all the format conversions in the printf dictionary.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ * NOTES:
+ * floats and wchar_t strings missing
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = (int)'a';
+
+ printf("\n");
+
+ printf("%%a = %a\n", &`kmem_alloc);
+ printf("%%c = %c\n", i);
+ printf("%%d = %d\n", i);
+ printf("%%hd = %hd\n", (short)i);
+ printf("%%hi = %hi\n", (short)i);
+ printf("%%ho = %ho\n", (ushort_t)i);
+ printf("%%hu = %hu\n", (ushort_t)i);
+ printf("%%hx = %hx\n", (ushort_t)i);
+ printf("%%hX = %hX\n", (ushort_t)i);
+ printf("%%i = %i\n", i);
+ printf("%%lc = %lc\n", i);
+ printf("%%ld = %ld\n", (long)i);
+ printf("%%li = %li\n", (long)i);
+ printf("%%lo = %lo\n", (ulong_t)i);
+ printf("%%lu = %lu\n", (ulong_t)i);
+ printf("%%lx = %lx\n", (ulong_t)i);
+ printf("%%lX = %lX\n", (ulong_t)i);
+ printf("%%o = %o\n", (uint_t)i);
+ printf("%%p = %p\n", (void *)i);
+ printf("%%s = %s\n", "hello");
+ printf("%%u = %u\n", (uint_t)i);
+ printf("%%wc = %wc\n", i);
+ printf("%%x = %x\n", (uint_t)i);
+ printf("%%X = %X\n", (uint_t)i);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d.out
new file mode 100644
index 00000000..55c12222
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.basics.d.out
@@ -0,0 +1,26 @@
+
+%a = genunix`kmem_alloc
+%c = a
+%d = 97
+%hd = 97
+%hi = 97
+%ho = 141
+%hu = 97
+%hx = 61
+%hX = 61
+%i = 97
+%lc = a
+%ld = 97
+%li = 97
+%lo = 141
+%lu = 97
+%lx = 61
+%lX = 61
+%o = 141
+%p = 61
+%s = hello
+%u = 97
+%wc = a
+%x = 61
+%X = 61
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d
new file mode 100644
index 00000000..0b653151
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test all of the various formatting flags (except %' because that
+ * requires locale support).
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n");
+ printf("# %#8x\n", 0x123);
+ printf("0 %08x\n", 0x123);
+ printf("- %-8x\n", 0x123);
+ printf("+ %+8d\n", 123);
+ printf(" % 8d\n", 123);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d.out
new file mode 100644
index 00000000..4e5344ee
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.flags.d.out
@@ -0,0 +1,7 @@
+
+# 0x123
+0 00000123
+- 123
++ +123
+ 123
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d
new file mode 100644
index 00000000..d58f6cd7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple printf() test.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("hello");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d.out
new file mode 100644
index 00000000..ce013625
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.hello.d.out
@@ -0,0 +1 @@
+hello
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d
new file mode 100644
index 00000000..d15236ba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d
@@ -0,0 +1,87 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with simple integer arguments, using a variety of
+ * sizes and thereby exercise the automatic size extension feature.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n%d\n", (char)0x1234567890abcdef);
+ printf("%d\n", (short)0x1234567890abcdef);
+ printf("%d\n", (int)0x1234567890abcdef);
+ printf("%d\n", (long long)0x1234567890abcdef);
+
+ printf("\n%d\n", (unsigned char)0x1234567890abcdef);
+ printf("%d\n", (unsigned short)0x1234567890abcdef);
+ printf("%d\n", (unsigned int)0x1234567890abcdef);
+ printf("%d\n", (unsigned long long)0x1234567890abcdef);
+
+ printf("\n%u\n", (char)0x1234567890abcdef);
+ printf("%u\n", (short)0x1234567890abcdef);
+ printf("%u\n", (int)0x1234567890abcdef);
+ printf("%u\n", (long long)0x1234567890abcdef);
+
+ printf("\n%u\n", (unsigned char)0x1234567890abcdef);
+ printf("%u\n", (unsigned short)0x1234567890abcdef);
+ printf("%u\n", (unsigned int)0x1234567890abcdef);
+ printf("%u\n", (unsigned long long)0x1234567890abcdef);
+
+ printf("\n%x\n", (unsigned char)0x1234567890abcdef);
+ printf("%x\n", (unsigned short)0x1234567890abcdef);
+ printf("%x\n", (unsigned int)0x1234567890abcdef);
+ printf("%x\n", (unsigned long long)0x1234567890abcdef);
+
+ printf("\n%x\n", (char)0x1234567890abcdef);
+ printf("%x\n", (short)0x1234567890abcdef);
+ printf("%x\n", (int)0x1234567890abcdef);
+ printf("%x\n", (long long)0x1234567890abcdef);
+
+ printf("\n%o\n", (unsigned char)0x1234567890abcdef);
+ printf("%o\n", (unsigned short)0x1234567890abcdef);
+ printf("%o\n", (unsigned int)0x1234567890abcdef);
+ printf("%o\n", (unsigned long long)0x1234567890abcdef);
+
+ printf("\n%o\n", (char)0x1234567890abcdef);
+ printf("%o\n", (short)0x1234567890abcdef);
+ printf("%o\n", (int)0x1234567890abcdef);
+ printf("%o\n", (long long)0x1234567890abcdef);
+
+ printf("\n%p\n", (void *)0x12345678);
+ printf("%p\n", (int *)0x90abcdef);
+ printf("%p\n", (uintptr_t)0x67890abc);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d.out
new file mode 100644
index 00000000..4d2bb112
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.ints.d.out
@@ -0,0 +1,45 @@
+
+239
+52719
+-1867788817
+1311768467294899695
+
+239
+52719
+2427178479
+1311768467294899695
+
+239
+52719
+2427178479
+1311768467294899695
+
+239
+52719
+2427178479
+1311768467294899695
+
+ef
+cdef
+90abcdef
+1234567890abcdef
+
+ef
+cdef
+90abcdef
+1234567890abcdef
+
+357
+146757
+22052746757
+110642547422052746757
+
+357
+146757
+22052746757
+110642547422052746757
+
+12345678
+90abcdef
+67890abc
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d
new file mode 100644
index 00000000..2bfff9ff
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test a variety of fixed and dynamic format precisions.
+ *
+ * SECTION: Output Formatting/printf()
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n");
+ x = 0;
+
+ printf("%.0s\n", "hello");
+ printf("%.1s\n", "hello");
+ printf("%.2s\n", "hello");
+ printf("%.3s\n", "hello");
+ printf("%.4s\n", "hello");
+ printf("%.5s\n", "hello");
+
+ printf("%.*s\n", x++, "hello");
+ printf("%.*s\n", x++, "hello");
+ printf("%.*s\n", x++, "hello");
+ printf("%.*s\n", x++, "hello");
+ printf("%.*s\n", x++, "hello");
+ printf("%.*s\n", x++, "hello");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d.out
new file mode 100644
index 00000000..11a969de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.precs.d.out
@@ -0,0 +1,14 @@
+
+hello
+h
+he
+hel
+hell
+hello
+hello
+h
+he
+hel
+hell
+hello
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d
new file mode 100644
index 00000000..3fe0bac4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test %f format printing.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+float f;
+double d;
+
+BEGIN
+{
+ printf("\n");
+
+ printf("%%f = %f\n", f);
+ printf("%%f = %f\n", d);
+
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d.out
new file mode 100644
index 00000000..4d4b8641
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.print-f.d.out
@@ -0,0 +1,4 @@
+
+%f = 0.000000
+%f = 0.000000
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh
new file mode 100644
index 00000000..51625380
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh
@@ -0,0 +1,56 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+# The output files assumes the timezone is US/Pacific
+TZ=US/Pacific
+
+$dtrace -s /dev/stdin <<EOF
+#pragma D option quiet
+
+inline uint64_t NANOSEC = 1000000000;
+
+BEGIN
+{
+ printf("%T\n%T\n%T", (uint64_t)0, (uint64_t)1062609821 * NANOSEC,
+ (uint64_t)0x7fffffff * NANOSEC);
+ exit(0);
+}
+EOF
+
+if [ $? -ne 0 ]; then
+ print -u2 "dtrace failed"
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh.out
new file mode 100644
index 00000000..51c84373
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printT.ksh.out
@@ -0,0 +1,3 @@
+Wed, 31 Dec 1970 16:00:00 PST
+Wed, 03 Sep 2003 10:23:41 PDT
+Mon, 18 Jan 2038 19:14:07 PST
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh
new file mode 100644
index 00000000..2dc3a4c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh
@@ -0,0 +1,56 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+# The output files assumes the timezone is US/Pacific
+TZ=US/Pacific
+
+$dtrace -s /dev/stdin <<EOF
+#pragma D option quiet
+
+inline uint64_t NANOSEC = 1000000000;
+
+BEGIN
+{
+ printf("%Y\n%Y\n%Y", (uint64_t)0, (uint64_t)1062609821 * NANOSEC,
+ (uint64_t)0x7fffffff * NANOSEC);
+ exit(0);
+}
+EOF
+
+if [ $? -ne 0 ]; then
+ print -u2 "dtrace failed"
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh.out
new file mode 100644
index 00000000..ae8d82f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printY.ksh.out
@@ -0,0 +1,3 @@
+1969 Dec 31 16:00:00
+2003 Sep 3 10:23:41
+2038 Jan 18 19:14:07
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d
new file mode 100644
index 00000000..ca7e1a93
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test 'uint' continously; like kinda stress.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+uint64_t ts;
+
+BEGIN
+{
+ ts = 53114233149441;
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ printf("%u\n", ts);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d.out
new file mode 100644
index 00000000..ce33b729
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printcont.d.out
@@ -0,0 +1,16 @@
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+53114233149441
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d
new file mode 100644
index 00000000..7aaee2a4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test %e, %E format printing.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+float f;
+double d;
+
+BEGIN
+{
+ printf("\n");
+
+ printf("%%e = %e\n", f);
+ printf("%%E = %E\n", f);
+
+ printf("%%e = %e\n", d);
+ printf("%%E = %E\n", d);
+
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d.out
new file mode 100644
index 00000000..3fa96bc2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printeE.d.out
@@ -0,0 +1,6 @@
+
+%e = 0.000000e+00
+%E = 0.000000E+00
+%e = 0.000000e+00
+%E = 0.000000E+00
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d
new file mode 100644
index 00000000..9e7e019b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test %g, %G format printing.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+float f;
+double d;
+
+BEGIN
+{
+ printf("\n");
+
+ printf("%%g = %g\n", f);
+ printf("%%g = %g\n", d);
+
+ printf("%%G = %G\n", f);
+ printf("%%G = %G\n", d);
+
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d.out
new file mode 100644
index 00000000..e4175e64
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.printgG.d.out
@@ -0,0 +1,6 @@
+
+%g = 0
+%g = 0
+%G = 0
+%G = 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d
new file mode 100644
index 00000000..deb4f817
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with a fixed string and no actual tracing arguments.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("hello world from BEGIN");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d.out
new file mode 100644
index 00000000..cb7c7e94
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.rawfmt.d.out
@@ -0,0 +1 @@
+hello world from BEGIN
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d
new file mode 100644
index 00000000..a7404139
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Test printf() with a simple string argument.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("sysname = %s", `utsname.sysname);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d.out
new file mode 100644
index 00000000..ba319817
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.str.d.out
@@ -0,0 +1 @@
+sysname = SunOS
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d
new file mode 100644
index 00000000..55f89f99
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with a simple string argument.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("symbol = %a", &`kmem_flags);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d.out
new file mode 100644
index 00000000..14f1e825
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.sym.d.out
@@ -0,0 +1 @@
+symbol = genunix`kmem_flags
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d
new file mode 100644
index 00000000..caa326e8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test printf() with simple unsigned integer arguments.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n");
+ printf("%u\n", (uchar_t)123);
+ printf("%u\n", (ushort_t)123);
+ printf("%u\n", (ulong_t)123);
+ printf("%u\n", (u_longlong_t)123);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d.out
new file mode 100644
index 00000000..d800e916
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.uints.d.out
@@ -0,0 +1,6 @@
+
+123
+123
+123
+123
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d
new file mode 100644
index 00000000..21595c02
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test a variety of fixed and dynamic format widths.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n");
+ x = 0;
+
+ printf("%0d\n", 1);
+ printf("%1d\n", 1);
+ printf("%2d\n", 1);
+ printf("%3d\n", 1);
+ printf("%4d\n", 1);
+ printf("%5d\n", 1);
+
+ printf("%*d\n", x++, 1);
+ printf("%*d\n", x++, 1);
+ printf("%*d\n", x++, 1);
+ printf("%*d\n", x++, 1);
+ printf("%*d\n", x++, 1);
+ printf("%*d\n", x++, 1);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d.out
new file mode 100644
index 00000000..39fc7a8a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths.d.out
@@ -0,0 +1,14 @@
+
+1
+1
+ 1
+ 1
+ 1
+ 1
+1
+1
+ 1
+ 1
+ 1
+ 1
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths1.d
new file mode 100644
index 00000000..b5410ab8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.widths1.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Try to print charecter wide width using '?'
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n");
+ x = 0;
+
+ printf("%?d\n", x++);
+ printf("%?d\n", x++);
+ printf("%?d\n", x++);
+ printf("%?d\n", x++);
+ printf("%?d\n", x++);
+ printf("%?d\n", x++);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d
new file mode 100644
index 00000000..b6745e14
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test a variety of fixed and dynamic format widths combined with precisions.
+ *
+ * SECTION: Output Formatting/printf()
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\n");
+ x = 0;
+
+ printf("%0.0s\n", "hello");
+ printf("%1.1s\n", "hello");
+ printf("%2.2s\n", "hello");
+ printf("%3.3s\n", "hello");
+ printf("%4.4s\n", "hello");
+ printf("%5.5s\n", "hello");
+ printf("%6.6s\n", "hello");
+ printf("%7.7s\n", "hello");
+ printf("%8.8s\n", "hello");
+ printf("%9.9s\n", "hello");
+
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+ printf("%*.*s\n", x, x++, "hello");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d.out
new file mode 100644
index 00000000..2f1fd9de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/printf/tst.wp.d.out
@@ -0,0 +1,22 @@
+
+hello
+h
+he
+hel
+hell
+hello
+ hello
+ hello
+ hello
+ hello
+hello
+h
+he
+hel
+hell
+hello
+ hello
+ hello
+ hello
+ hello
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh
new file mode 100644
index 00000000..ae4934cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh
@@ -0,0 +1,82 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+ppriv -s A=basic,dtrace_proc,dtrace_user $$
+
+/usr/sbin/dtrace -q -s /dev/stdin <<"EOF"
+
+BEGIN {
+ errorcount = 0;
+ expected_errorcount = 23;
+}
+
+BEGIN { trace(mutex_owned(&`pidlock)); }
+BEGIN { trace(mutex_owner(&`pidlock)); }
+BEGIN { trace(mutex_type_adaptive(&`pidlock)); }
+BEGIN { trace(mutex_type_spin(&`pidlock)); }
+
+BEGIN { trace(rw_read_held(&`ksyms_lock)); }
+BEGIN { trace(rw_write_held(&`ksyms_lock)); }
+BEGIN { trace(rw_iswriter(&`ksyms_lock)); }
+
+BEGIN { x = alloca(10); bcopy(`initname, x, 10); trace(stringof(x)); }
+/* We have no reliable way to test msgsize */
+
+BEGIN { trace(strlen(`initname)); }
+BEGIN { trace(strchr(`initname, 0x69)); }
+BEGIN { trace(strrchr(`initname, 0x69)); }
+BEGIN { trace(strstr("/sbin/init/foo", `initname)); }
+BEGIN { trace(strstr(`initname, "in")); }
+BEGIN { trace(strtok(`initname, "/")); }
+BEGIN { trace(strtok(NULL, "/")); }
+BEGIN { trace(strtok("foo/bar", `initname)); }
+BEGIN { trace(strtok(NULL, `initname)); }
+BEGIN { trace(substr(`initname, 2, 3)); }
+
+BEGIN { trace(ddi_pathname(`top_devinfo, 1)); }
+BEGIN { trace(strjoin(`initname, "foo")); }
+BEGIN { trace(strjoin("foo", `initname)); }
+BEGIN { trace(dirname(`initname)); }
+BEGIN { trace(cleanpath(`initname)); }
+
+ERROR {
+ errorcount++;
+}
+
+BEGIN /errorcount == expected_errorcount/ {
+ trace("test passed");
+ exit(0);
+}
+
+BEGIN /errorcount != expected_errorcount/ {
+ printf("fail: expected %d. saw %d.", expected_errorcount, errorcount);
+ exit(1);
+}
+EOF
+
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.op_access.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.op_access.ksh
new file mode 100644
index 00000000..08964c49
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.op_access.ksh
@@ -0,0 +1,70 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+ppriv -s A=basic,dtrace_proc,dtrace_user $$
+
+/usr/sbin/dtrace -q -s /dev/stdin <<"EOF"
+BEGIN {
+ errorcount = 0;
+ expected_errorcount = 7;
+}
+
+/* BYREF */
+BEGIN { trace(`utsname); }
+BEGIN { trace(`kmem_flags); }
+
+/* DIF_OP_SCMP */
+BEGIN /`initname == "/sbin/init"/ { trace("bad"); }
+
+/* DIF_OP_COPYS */
+BEGIN { p = `p0; trace(p); }
+
+/* DIF_OP_STTS */
+BEGIN { self->p = `p0; trace(self->p); }
+
+/* DIF_OP_STGAA */
+BEGIN { a[stringof(`initname)] = 42; trace(a["/sbin/init"]); }
+
+/* DIF_OP_STTAA */
+BEGIN { self->a[stringof(`initname)] = 42; trace(self->a["/sbin/init"]); }
+
+ERROR {
+ errorcount++;
+}
+
+BEGIN /errorcount == expected_errorcount/ {
+ trace("pass");
+ exit(0);
+}
+
+BEGIN /errorcount != expected_errorcount/ {
+ printf("fail: expected %d. saw %d.", expected_errorcount, errorcount);
+ exit(1);
+}
+EOF
+
+exit $?
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.unpriv_funcs.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.unpriv_funcs.ksh
new file mode 100644
index 00000000..c9da0ce6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/privs/tst.unpriv_funcs.ksh
@@ -0,0 +1,79 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+#
+# Affirmative test of less privileged user operation. We do so by running
+# this test case as root, then as a less privileged user. The output should
+# be exactly the same.
+#
+
+script()
+{
+ cat <<"EOF"
+
+ BEGIN { trace("trace\n"); }
+ BEGIN { printf("%s\n", "printf"); }
+ BEGIN { printf("strlen(\"strlen\") = %d\n", strlen("strlen")); }
+ BEGIN { x = alloca(10);
+ bcopy("alloca\n", x, 7);
+ trace(stringof(x)); }
+
+ BEGIN { printf("index(\"index\", \"x\") = %d\n",
+ index("index", "x")); }
+ BEGIN { printf("strchr(\"strchr\", \'t\') = %s\n",
+ strchr("strchr", 't')); }
+
+ BEGIN { printf("strtok(\"strtok\", \"t\") = %s\n",
+ strtok("strtok", "t")); }
+ BEGIN { printf("strtok(NULL, \"t\") = %s\n",
+ strtok(NULL, "t")); }
+ BEGIN { printf("strtok(NULL, \"t\") = %s\n",
+ strtok(NULL, "t")); }
+ BEGIN { printf("substr(\"substr\", 2, 2) = %s\n",
+ substr("substr", 2, 2)); }
+ BEGIN { trace(strjoin("str", "join\n")); }
+ BEGIN { trace(basename("dirname/basename")); trace("/"); }
+ BEGIN { trace(dirname("dirname/basename")); }
+
+ BEGIN { exit(0); }
+ ERROR { exit(1); }
+EOF
+}
+
+privout=/tmp/$$.priv_output
+unprivout=/tmp/$$.unpriv_output
+
+script | /usr/sbin/dtrace -q -s /dev/stdin > $privout
+ppriv -s A=basic,dtrace_user $$
+script | /usr/sbin/dtrace -q -s /dev/stdin > $unprivout
+
+diff $privout $unprivout
+res=$?
+
+/bin/rm -f $privout $unprivout
+
+exit $res
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probeqtn.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probeqtn.d
new file mode 100644
index 00000000..35604278
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probeqtn.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call probes with mismatch "?" and make sure it results in compilation
+ * error
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+int i;
+BEGIN
+{
+ i = 0;
+}
+
+syscall::?lwp?:entry
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probestar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probestar.d
new file mode 100644
index 00000000..6103f486
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.probestar.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call an undefined probe with matching character "*" and make
+ * sure it results in compilation error.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+no_such_dtrace_probe*
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.tickstar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.tickstar.d
new file mode 100644
index 00000000..391b18c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_PDESC_ZERO.tickstar.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call a probe with matching charecters "*" but does not have
+ * any matching probes.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+int i;
+BEGIN
+{
+ i = 0;
+}
+
+syscall::*tick*:entry
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.assign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.assign.d
new file mode 100644
index 00000000..e4f7dcb6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.assign.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a predicate with no spaces and make sure it results in
+ * compilation error.
+
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+int i = 0;
+
+profile-1
+/i == 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declare.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declare.d
new file mode 100644
index 00000000..30aa2667
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declare.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare variables inside probe clause and make sure it results
+ * in compilation error.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1
+{
+ int i = 0;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declarein.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declarein.d
new file mode 100644
index 00000000..9ef8590a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.declarein.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a Variable in between definition and first brace, and make
+ * sure it results in compilation error.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1
+int i;
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.lbraces.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.lbraces.d
new file mode 100644
index 00000000..b4a4315d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.lbraces.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a probe with one missing braces.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1
+{
+ exit(0);
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.probespec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.probespec.d
new file mode 100644
index 00000000..67c44872
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.probespec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Try Declaring Datatypes and variables next to profile declaration and
+ * Make sure it results in compilation error.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1:int i
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.rbraces.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.rbraces.d
new file mode 100644
index 00000000..4f889d57
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.rbraces.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a probe with one missing braces.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.recdec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.recdec.d
new file mode 100644
index 00000000..5db21ea9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/err.D_SYNTAX.recdec.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a probe clause within another probe clause.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1
+{
+ tick-10ms
+{
+}
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.basic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.basic1.d
new file mode 100644
index 00000000..df2b1147
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.basic1.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple probe clause test; just a empty probe.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.check.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.check.d
new file mode 100644
index 00000000..d3f2535d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.check.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a Variable in BEGIN and use that in another probe.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+int i;
+BEGIN
+{
+ i = 0;
+}
+
+tick-10ms
+/i == 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declare.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declare.d
new file mode 100644
index 00000000..845b3fa4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declare.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declaration of variable outside probe clause
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+int i;
+tick-10ms
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declareafter.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declareafter.d
new file mode 100644
index 00000000..1c1e2eae
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.declareafter.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declaration of a variable after probe clause definition.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ exit(0);
+}
+int i;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.emptyprobe.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.emptyprobe.d
new file mode 100644
index 00000000..e23a8dbb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.emptyprobe.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Multiple probe clause declarations.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+}
+tick-10ms
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragma.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragma.d
new file mode 100644
index 00000000..035079d0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragma.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Test to Declare pragma in right place.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-10ms
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaaftertab.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaaftertab.d
new file mode 100644
index 00000000..be725f9d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaaftertab.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare pragma after a tab and make sure it results in compilation error.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+ #pragma D option quiet
+
+tick-10ms
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmainside.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmainside.d
new file mode 100644
index 00000000..e602a414
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmainside.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare pragma inside probe clause.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+
+tick-10ms
+{
+#pragma D option quiet
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaoutside.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaoutside.d
new file mode 100644
index 00000000..7d2ea61c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.pragmaoutside.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare pragma outside probe clause.
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+
+tick-10ms
+{
+ exit(0);
+}
+#pragma D option quiet
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.probestar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.probestar.d
new file mode 100644
index 00000000..3f54321d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/probes/tst.probestar.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call matching probe clauses with given name using "*"
+ *
+ * SECTION: Program Structure/Probe Clauses and Declarations
+ *
+ */
+
+
+#pragma D option quiet
+
+int i;
+BEGIN
+{
+ i = 0;
+}
+
+syscall::*lwp*:entry
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.create.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.create.ksh
new file mode 100644
index 00000000..5b484cf0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.create.ksh
@@ -0,0 +1,67 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the proc:::create probe fires with the proper
+# arguments.
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::create
+ /args[0]->pr_ppid == $child && pid == $child/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ /usr/bin/sleep 1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.discard.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.discard.ksh
new file mode 100644
index 00000000..5595c24a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.discard.ksh
@@ -0,0 +1,74 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the proc:::signal-discard probe fires correctly
+# and with the correct arguments.
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::signal-discard
+ /args[1]->pr_pid == $child &&
+ args[1]->pr_psargs == "$longsleep" && args[2] == SIGHUP/
+ {
+ exit(0);
+ }
+EOF
+}
+
+killer()
+{
+ while true; do
+ sleep 1
+ /usr/bin/kill -HUP $child
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+longsleep="/usr/bin/sleep 10000"
+
+/usr/bin/nohup $longsleep &
+child=$!
+
+killer &
+killer=$!
+script
+status=$?
+
+kill $child
+kill $killer
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exec.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exec.ksh
new file mode 100644
index 00000000..0318ae6d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exec.ksh
@@ -0,0 +1,73 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the proc:::exec probe fires, followed by the
+# proc:::exec-success probe (in a successful exec(2)).
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::exec
+ /curpsinfo->pr_ppid == $child && args[0] == "/usr/bin/sleep"/
+ {
+ self->exec = 1;
+ }
+
+ proc:::exec-success
+ /self->exec/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ /usr/bin/sleep 1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ENOENT.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ENOENT.ksh
new file mode 100644
index 00000000..fb1efc54
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ENOENT.ksh
@@ -0,0 +1,84 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script is identical to tst.execfail.ksh -- but it additionally checks
+# that errno is set to ENOENT in the case that an interpreter can't be
+# found.
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::exec
+ /curpsinfo->pr_ppid == $child && args[0] == "$badexec"/
+ {
+ self->exec = 1;
+ }
+
+ proc:::exec-failure
+ /self->exec && args[0] == ENOENT/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ /usr/bin/sleep 1
+ $badexec
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+badexec=/tmp/execfail.ENOENT.ksh.$$
+dtrace=$1
+
+cat > $badexec <<EOF
+#!/this_is_a_bogus_interpreter
+EOF
+
+chmod +x $badexec
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+kill $child
+rm $badexec
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ksh
new file mode 100644
index 00000000..d2241e1e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.execfail.ksh
@@ -0,0 +1,86 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that -- if a exec(2) fails -- the proc:::exec probe fires,
+# followed by the proc:::exec-success probe (in a successful exec(2)). To
+# circumvent any potential shell cleverness, this script generates exec
+# failure by generating a file with a bogus interpreter. (It seems unlikely
+# that a shell -- regardless of how clever it claims to be -- would bother to
+# validate the interpreter before exec'ing.)
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::exec
+ /curpsinfo->pr_ppid == $child && args[0] == "$badexec"/
+ {
+ self->exec = 1;
+ }
+
+ proc:::exec-failure
+ /self->exec/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ /usr/bin/sleep 1
+ $badexec
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+badexec=/tmp/execfail.ksh.$$
+dtrace=$1
+
+cat > $badexec <<EOF
+#!/this_is_a_bogus_interpreter
+EOF
+
+chmod +x $badexec
+
+sleeper &
+child=$!
+script
+status=$?
+
+kill $child
+rm $badexec
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh
new file mode 100644
index 00000000..df3fdb3d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh
@@ -0,0 +1,95 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the proc:::exit probe fires with the correct argument
+# when the process core dumps. The problematic bit here is making sure that
+# a process _can_ dump core -- if core dumps are disabled on both a global
+# and per-process basis, this test will fail. Rather than having this test
+# muck with coreadm(1M) settings, it will fail explicitly in this case and
+# provide a hint as to the problem. In general, machines should never be
+# running with both per-process and global core dumps disabled -- so this
+# should be a non-issue in practice.
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::exit
+ /curpsinfo->pr_ppid == $child &&
+ curpsinfo->pr_psargs == "$longsleep" && args[0] == CLD_DUMPED/
+ {
+ exit(0);
+ }
+
+ proc:::exit
+ /curpsinfo->pr_ppid == $child &&
+ curpsinfo->pr_psargs == "$longsleep" && args[0] != CLD_DUMPED/
+ {
+ printf("Child process could not dump core. Check coreadm(1M)");
+ printf(" settings; either per-process or global core dumps ");
+ printf("must be enabled for this test to work properly.");
+ exit(1);
+ }
+EOF
+}
+
+sleeper()
+{
+ /usr/bin/coreadm -p $corefile
+ while true; do
+ $longsleep &
+ /usr/bin/sleep 1
+ kill -SEGV $!
+ done
+ /usr/bin/rm -f $corefile
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+longsleep="/usr/bin/sleep 10000"
+corefile=/tmp/core.$$
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+pstop $child
+pkill -P $child
+kill $child
+prun $child
+
+/usr/bin/rm -f $corefile
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitexit.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitexit.ksh
new file mode 100644
index 00000000..13af911c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitexit.ksh
@@ -0,0 +1,67 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the proc:::exit probe fires with the correct argument
+# when the process explicitly exits.
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::exit
+ /curpsinfo->pr_ppid == $child && args[0] == CLD_EXITED/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ /usr/bin/sleep 1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitkilled.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitkilled.ksh
new file mode 100644
index 00000000..8040ade6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.exitkilled.ksh
@@ -0,0 +1,75 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the proc:::exit probe fires with the correct argument
+# when the process is killed.
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::exit
+ /curpsinfo->pr_ppid == $child &&
+ curpsinfo->pr_psargs == "$longsleep" && args[0] == CLD_KILLED/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ $longsleep &
+ /usr/bin/sleep 1
+ kill -9 $!
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+longsleep="/usr/bin/sleep 10000"
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+pstop $child
+pkill -P $child
+kill $child
+prun $child
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.signal.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.signal.ksh
new file mode 100644
index 00000000..cd3c7918
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.signal.ksh
@@ -0,0 +1,84 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the proc:::signal-send and proc:::signal-handle
+# probes fire correctly and with the correct arguments.
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::signal-send
+ /execname == "kill" && curpsinfo->pr_ppid == $child &&
+ args[1]->pr_psargs == "$longsleep" && args[2] == SIGUSR1/
+ {
+ /*
+ * This is guaranteed to not race with signal-handle.
+ */
+ target = args[1]->pr_pid;
+ }
+
+ proc:::signal-handle
+ /target == pid && args[0] == SIGUSR1/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ $longsleep &
+ sleep 1
+ /usr/bin/kill -USR1 $!
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+longsleep="/usr/bin/sleep 10000"
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+pstop $child
+pkill -P $child
+kill $child
+prun $child
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.c
new file mode 100644
index 00000000..8f6231bd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.c
@@ -0,0 +1,75 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <signal.h>
+#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ struct sigevent ev;
+ struct itimerspec ts;
+ sigset_t set;
+ timer_t tid;
+ char *cmd = argv[0];
+
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGUSR1;
+
+ if (timer_create(CLOCK_REALTIME, &ev, &tid) == -1) {
+ (void) fprintf(stderr, "%s: cannot create CLOCK_HIGHRES "
+ "timer: %s\n", cmd, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ (void) sigemptyset(&set);
+ (void) sigaddset(&set, SIGUSR1);
+ (void) sigprocmask(SIG_BLOCK, &set, NULL);
+
+ ts.it_value.tv_sec = 1;
+ ts.it_value.tv_nsec = 0;
+ ts.it_interval.tv_sec = 0;
+ ts.it_interval.tv_nsec = NANOSEC / 2;
+
+ if (timer_settime(tid, TIMER_RELTIME, &ts, NULL) == -1) {
+ (void) fprintf(stderr, "%s: timer_settime() failed: %s\n",
+ cmd, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ for (;;) {
+ (void) sigwait(&set);
+ }
+
+ /*NOTREACHED*/
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.d
new file mode 100644
index 00000000..851fa262
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.sigwait.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option destructive
+
+proc:::signal-send
+/pid == 0 && args[1]->pr_pid == $1 && args[2] == SIGUSR1/
+{
+ sent = 1;
+}
+
+proc:::signal-clear
+/pid == $1 && args[0] == SIGUSR1 && sent/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh
new file mode 100644
index 00000000..42917380
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh
@@ -0,0 +1,89 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script tests that the firing order of probes in a process is:
+#
+# 1. proc:::start
+# 2. proc:::lwp-start
+# 3. proc:::lwp-exit
+# 4. proc:::exit
+#
+# If this fails, the script will run indefinitely; it relies on the harness
+# to time it out.
+#
+script()
+{
+ $dtrace -s /dev/stdin <<EOF
+ proc:::start
+ /curpsinfo->pr_ppid == $child/
+ {
+ self->start = 1;
+ }
+
+ proc:::lwp-start
+ /self->start/
+ {
+ self->lwp_start = 1;
+ }
+
+ proc:::lwp-exit
+ /self->lwp_start/
+ {
+ self->lwp_exit = 1;
+ }
+
+ proc:::exit
+ /self->lwp_exit == 1/
+ {
+ exit(0);
+ }
+EOF
+}
+
+sleeper()
+{
+ while true; do
+ /usr/bin/sleep 1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+sleeper &
+child=$!
+
+script
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZERO.profile.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZERO.profile.d
new file mode 100644
index 00000000..e4e031ba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZERO.profile.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * profile without valid value keyword just call with 'n'.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-n
+{
+ printf("This test should fail\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonens.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonens.d
new file mode 100644
index 00000000..3ed28b1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonens.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call profile-'ns' less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1ns
+{
+ printf("Calls 'ns' less than 200 micro seconds\n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonensec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonensec.d
new file mode 100644
index 00000000..7b4df199
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROonensec.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call profile-1nsec; less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1nsec
+{
+ printf("Call profile-1nsec; less than 200 micro seconds\n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneus.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneus.d
new file mode 100644
index 00000000..6a64a3a2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneus.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call profile-us; less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1us
+{
+ printf(" Calling profile-us less than 200 micro seconds should fail\n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneusec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneusec.d
new file mode 100644
index 00000000..b6b80bea
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/err.D_PDESC_ZEROoneusec.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * profile-usec; less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1usec
+{
+ printf("profile-usec; less than 200 micro seconds \n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d
new file mode 100644
index 00000000..26a40b41
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Either one of arg0 (or) arg1 should be 0 and non-zero.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-1
+/(arg0 != 0 && arg1 == 0) || (arg0 == 0 && arg1 != 0)/
+{
+ printf("Test passed; either arg0/arg1 is zero\n");
+ exit(0);
+}
+
+tick-1
+/(arg0 == 0 && arg1 == 0) || (arg0 != 0 && arg1 != 0)/
+{
+ printf("Test failed; either arg0 (or) arg1 should be non zero\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d.out
new file mode 100644
index 00000000..0bd33539
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.argtest.d.out
@@ -0,0 +1,2 @@
+Test passed; either arg0/arg1 is zero
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d
new file mode 100644
index 00000000..df8bf988
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * profile-n simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1
+{
+ printf("This test is a simple profile-n provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d.out
new file mode 100644
index 00000000..09005bbb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.basic.d.out
@@ -0,0 +1,2 @@
+This test is a simple profile-n provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.func.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.func.ksh
new file mode 100644
index 00000000..358d3625
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.func.ksh
@@ -0,0 +1,74 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ profile-1234hz
+ /arg0 != 0/
+ {
+ @[func(arg0)] = count();
+ }
+
+ tick-100ms
+ /i++ == 50/
+ {
+ exit(0);
+ }
+EOF
+}
+
+spinny()
+{
+ while true; do
+ /usr/bin/date > /dev/null
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+spinny &
+child=$!
+
+#
+# This is gutsy -- we're assuming that mutex_enter(9F) will show up in the
+# output. This is most likely _not_ to show up in the output if the
+# platform does not support arbitrary resolution interval timers -- but
+# the above script was stress-tested down to 100 hertz and still ran
+# successfully on all platforms, so one is hopeful that this test will pass
+# even in that case.
+#
+script | tee /dev/fd/2 | grep mutex_enter > /dev/null
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.mod.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.mod.ksh
new file mode 100644
index 00000000..4652ff32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.mod.ksh
@@ -0,0 +1,70 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ profile-1234hz
+ /arg0 != 0/
+ {
+ @[mod(arg0)] = count();
+ }
+
+ tick-100ms
+ /i++ == 20/
+ {
+ exit(0);
+ }
+EOF
+}
+
+spinny()
+{
+ while true; do
+ /usr/bin/date > /dev/null
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+spinny &
+child=$!
+
+#
+# The only thing we can be sure of is that some module named "unix" (or
+# "genunix") did some work -- so that's all we'll check.
+#
+script | tee /dev/fd/2 | grep unix > /dev/null
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d
new file mode 100644
index 00000000..ba69def5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-hz test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-100hz
+{
+ printf("This test is a simple profile-hz provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d.out
new file mode 100644
index 00000000..711f635b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilehz.d.out
@@ -0,0 +1 @@
+This test is a simple profile-hz provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d
new file mode 100644
index 00000000..7ec573e3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-ms simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1ms
+{
+ printf("This test is a simple profile-ms provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d.out
new file mode 100644
index 00000000..1fe17e7c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilems.d.out
@@ -0,0 +1 @@
+This test is a simple profile-ms provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d
new file mode 100644
index 00000000..80451e85
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-msec simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1msec
+{
+ printf("This test is a simple profile-msec provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d.out
new file mode 100644
index 00000000..c3fb4a3b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilemsec.d.out
@@ -0,0 +1 @@
+This test is a simple profile-msec provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d
new file mode 100644
index 00000000..37b20907
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * profile-<number> simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-100
+{
+ printf("This test is a simple profile implicit hz test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d.out
new file mode 100644
index 00000000..c9409ce5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilenhz.d.out
@@ -0,0 +1 @@
+This test is a simple profile implicit hz test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d
new file mode 100644
index 00000000..72f95ad3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-2000000000ns simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-2000000000ns
+{
+ printf("This test is a simple profile-ns provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d.out
new file mode 100644
index 00000000..86251d01
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilens.d.out
@@ -0,0 +1 @@
+This test is a simple profile-ns provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d
new file mode 100644
index 00000000..d0236e9a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-nsec simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-2000000000nsec
+{
+ printf("This test is a simple profile-nsec provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d.out
new file mode 100644
index 00000000..890b769d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilensec.d.out
@@ -0,0 +1 @@
+This test is a simple profile-nsec provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d
new file mode 100644
index 00000000..65201fc8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-s simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1s
+{
+ printf("This test is a simple profile-s provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d.out
new file mode 100644
index 00000000..03a0cf22
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profiles.d.out
@@ -0,0 +1 @@
+This test is a simple profile-s provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d
new file mode 100644
index 00000000..3e52ac5c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-sec simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-1sec
+{
+ printf("This test is a simple profile-sec provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d.out
new file mode 100644
index 00000000..9091592d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profilesec.d.out
@@ -0,0 +1 @@
+This test is a simple profile-sec provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d
new file mode 100644
index 00000000..32ab4155
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-us simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-200us
+{
+ printf("This test is a simple profile-us provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d.out
new file mode 100644
index 00000000..aa270642
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileus.d.out
@@ -0,0 +1 @@
+This test is a simple profile-us provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d
new file mode 100644
index 00000000..78df000b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple profile-usec simple test.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+profile-200usec
+{
+ printf("This test is a simple profile-usec provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d.out
new file mode 100644
index 00000000..96dfef1c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.profileusec.d.out
@@ -0,0 +1 @@
+This test is a simple profile-usec provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.sym.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.sym.ksh
new file mode 100644
index 00000000..218a651c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.sym.ksh
@@ -0,0 +1,70 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ profile-1234hz
+ /arg0 != 0/
+ {
+ @[sym(arg0)] = count();
+ }
+
+ tick-100ms
+ /i++ == 50/
+ {
+ exit(0);
+ }
+EOF
+}
+
+spinny()
+{
+ while true; do
+ /usr/bin/date > /dev/null
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+spinny &
+child=$!
+
+#
+# This is the same gutsy test as that found in the func() test; see that
+# test for the rationale.
+#
+script | tee /dev/fd/2 | grep mutex_enter > /dev/null
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh
new file mode 100644
index 00000000..69c0f84a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh
@@ -0,0 +1,71 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ profile-1234hz
+ /arg1 != 0/
+ {
+ @[ufunc(arg1)] = count();
+ }
+
+ tick-100ms
+ /i++ == 20/
+ {
+ exit(0);
+ }
+EOF
+}
+
+spinny()
+{
+ while true; do
+ let i=i+1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+spinny &
+child=$!
+
+#
+# The only thing we can be sure of here is that we caught some function in
+# ksh doing work. (This actually goes one step further and assumes that we
+# catch some non-static function in ksh.)
+#
+script | tee /dev/fd/2 | grep 'ksh`[a-zA-Z_]' > /dev/null
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.c
new file mode 100644
index 00000000..96d78a43
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.c
@@ -0,0 +1,78 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+typedef void f(int x);
+
+static void
+f_a(int i)
+{
+}
+
+static void
+f_b(int i)
+{
+}
+
+static void
+f_c(int i)
+{
+}
+
+static void
+f_d(int i)
+{
+}
+
+static void
+f_e(int i)
+{
+}
+
+static void
+fN(f func, int i)
+{
+ func(i);
+}
+
+int
+main()
+{
+ fN(f_a, 1);
+ fN(f_b, 2);
+ fN(f_c, 3);
+ fN(f_d, 4);
+ fN(f_e, 5);
+ fN(f_a, 11);
+ fN(f_c, 13);
+ fN(f_d, 14);
+ fN(f_a, 101);
+ fN(f_c, 103);
+ fN(f_c, 1003);
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh
new file mode 100755
index 00000000..4689355a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh
@@ -0,0 +1,66 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# ufunc() values sort as expected
+#
+# SECTION: Aggregations, Printing Aggregations
+#
+# NOTES: Assumes that the order of user function addresses will follow
+# the function declaration order.
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -c ./tst.ufuncsort.exe -s /dev/stdin <<EOF
+
+
+ #pragma D option quiet
+ #pragma D option aggsortkey
+
+ pid\$target::fN:entry
+ {
+ @[ufunc(arg0)] = count();
+ }
+EOF
+
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh.out
new file mode 100644
index 00000000..a364322b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.ufuncsort.ksh.out
@@ -0,0 +1,6 @@
+
+ tst.ufuncsort.exe`f_a 3
+ tst.ufuncsort.exe`f_b 1
+ tst.ufuncsort.exe`f_c 4
+ tst.ufuncsort.exe`f_d 2
+ tst.ufuncsort.exe`f_e 1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh
new file mode 100644
index 00000000..6ca823f5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.umod.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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ profile-1234hz
+ /arg1 != 0/
+ {
+ @[umod(arg1)] = count();
+ }
+
+ tick-100ms
+ /i++ == 20/
+ {
+ exit(0);
+ }
+EOF
+}
+
+spinny()
+{
+ while true; do
+ let i=i+1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+spinny &
+child=$!
+
+#
+# The only thing we can be sure of here is that ksh is doing some work.
+#
+script | tee /dev/fd/2 | grep -w ksh > /dev/null
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh
new file mode 100644
index 00000000..b1a3ab9d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh
@@ -0,0 +1,70 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ profile-1234hz
+ /arg1 != 0/
+ {
+ @[usym(arg1)] = count();
+ }
+
+ tick-100ms
+ /i++ == 20/
+ {
+ exit(0);
+ }
+EOF
+}
+
+spinny()
+{
+ while true; do
+ let i=i+1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+spinny &
+child=$!
+
+#
+# This test is essentially the same as that in the ufunc test; see that
+# test for the rationale.
+#
+script | tee /dev/fd/2 | grep 'ksh`[a-zA-Z_]' > /dev/null
+status=$?
+
+kill $child
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_INVAL.wrongdec4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_INVAL.wrongdec4.d
new file mode 100644
index 00000000..0a7aa14a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_INVAL.wrongdec4.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * call profile<provider name>; called with no "::::".
+ * should fail with compilation error.
+ *
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile::::tick-1sec
+{
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.nonprofile.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.nonprofile.d
new file mode 100644
index 00000000..1356a896
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.nonprofile.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test;
+ * Call user created provider. Make sure it gives compilation error.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::test
+/i < 3/
+{
+ i++;
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec1.d
new file mode 100644
index 00000000..e06edee5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec1.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * call profile::<provider name>; called with two "::".
+ * should fail with compilation error.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile::tick-1sec
+{
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec2.d
new file mode 100644
index 00000000..ea8909ca
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec2.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * call profile:<provider name>; called with one ":".
+ * should fail with compilation error.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:tick-1sec
+{
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec3.d
new file mode 100644
index 00000000..edea0b92
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/err.D_PDESC_ZERO.wrongdec3.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * call profile<provider name>; called with no ":".
+ * should fail with compilation error.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profiletick-1sec
+{
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d
new file mode 100644
index 00000000..6b6e5269
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test;
+ * Call same profile provider two times
+ * Match expected output in tst.basics.d.out
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 3/
+{
+ i++;
+ trace(i);
+}
+
+profile:::tick-1sec
+/i == 3/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d.out
new file mode 100644
index 00000000..190a1803
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.basics.d.out
@@ -0,0 +1 @@
+123
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginexit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginexit.d
new file mode 100644
index 00000000..202abe67
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginexit.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ exit(0);
+}
+
+BEGIN
+{
+ printf("shouldn't be here...");
+ here++;
+}
+
+END
+{
+ exit(here);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d
new file mode 100644
index 00000000..99989d94
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * print the 'probeprov, probemod, probefunc, probename' from
+ * BEGIN
+ * Match the output from tst.beginprof.d.out
+ *
+ * SECTION: profile Provider/profile-n probes;
+ * Variables/Built-in Variables
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("%s %s %s %s", probeprov, probemod, probefunc, probename);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d.out
new file mode 100644
index 00000000..d28a0572
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.beginprof.d.out
@@ -0,0 +1 @@
+dtrace BEGIN
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d
new file mode 100644
index 00000000..bd24ca01
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * print the 'probeprov, probemod, probefunc, probename' at once.
+ * Match expected output in tst.probattrs.d.out
+ *
+ *
+ * SECTION: profile Provider/tick-n probes;
+ * Variables/Built-in Variables
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ printf("%s %s %s %s", probeprov, probemod, probefunc, probename);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d.out
new file mode 100644
index 00000000..2a13979c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probattrs.d.out
@@ -0,0 +1 @@
+profile tick-1sec
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d
new file mode 100644
index 00000000..fa7c47c5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * print the 'probefunc' field i.e. Current probe description's function
+ * field.
+ * Match expected output in tst.probefunc.d.out
+ *
+ * SECTION: profile Provider/tick-n probes;
+ * Variables/Built-in Variables
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ printf("probe funct = %s", probefunc);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d.out
new file mode 100644
index 00000000..de191dd6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probefunc.d.out
@@ -0,0 +1 @@
+probe funct =
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d
new file mode 100644
index 00000000..89fd8b2a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * print the 'probemod' field i.e. Current probe description's module
+ * field.
+ * Match expected output in tst.probemod.d.out
+ *
+ * SECTION: profile Provider/tick-n probes;
+ * Variables/Built-in Variables
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ printf("probe description module field = %s", probemod);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d.out
new file mode 100644
index 00000000..1c95a770
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probemod.d.out
@@ -0,0 +1 @@
+probe description module field =
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d
new file mode 100644
index 00000000..c58097f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * print the 'probename' field i.e. Current probe description's name
+ * field.
+ * Match expected output in tst.probename.d.out
+ *
+ * SECTION: profile Provider/tick-n probes;
+ * Variables/Built-in Variables
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ printf("probe name = %s", probename);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d.out
new file mode 100644
index 00000000..e5ff3e04
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probename.d.out
@@ -0,0 +1 @@
+probe name = tick-1sec
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d
new file mode 100644
index 00000000..3c3ccef8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * print the 'probeprov' field i.e. Current probe description's provider
+ * field.
+ * Match expected output in tst.probeprov.d.out
+ *
+ * SECTION: profile Provider/tick-n probes;
+ * Variables/Built-in Variables
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ printf("probe description provider = %s", probeprov);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d.out
new file mode 100644
index 00000000..d8ca594f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.probprov.d.out
@@ -0,0 +1 @@
+probe description provider = profile
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d
new file mode 100644
index 00000000..9ab438a4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * Call simple profile with END profile.
+ * Match expected output in tst.profend.d.out
+ *
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ i++;
+ trace(i);
+ exit(0);
+}
+
+dtrace:::END
+{
+ printf("\nI'm at END");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d.out
new file mode 100644
index 00000000..42e30052
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profend.d.out
@@ -0,0 +1,2 @@
+1
+I'm at END
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d
new file mode 100644
index 00000000..884053f1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test;
+ * Call simple profile
+ * Match expected output in tst.profexit.d.out
+ *
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ i++;
+ trace(i);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d.out
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.profexit.d.out
@@ -0,0 +1 @@
+1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d
new file mode 100644
index 00000000..ec7053d3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * Call simple profile with trace() in END profile
+ * Match expected output in tst.trace.d.out
+ *
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+{
+ i++;
+ exit(0);
+}
+
+dtrace:::END
+{
+ trace(i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d.out
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.trace.d.out
@@ -0,0 +1 @@
+1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d
new file mode 100644
index 00000000..352ed0b8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Simple profile provider test.
+ * Call two different profile provider
+ * Match expected output in tst.twoprof.d.out
+ *
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 3/
+{
+ i++;
+ trace(i);
+}
+
+profile:::tick-100msec
+/i == 3/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d.out
new file mode 100644
index 00000000..190a1803
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/providers/tst.twoprof.d.out
@@ -0,0 +1 @@
+123
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.c
new file mode 100644
index 00000000..e3910836
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.c
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+#include <signal.h>
+
+int
+main(int argc, char **argv)
+{
+ sigset_t ss;
+
+ (void) sigemptyset(&ss);
+ (void) sigaddset(&ss, SIGINT);
+ (void) sigprocmask(SIG_BLOCK, &ss, NULL);
+
+ do {
+ (void) getpid();
+ (void) sigpending(&ss);
+ } while (!sigismember(&ss, SIGINT));
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.d
new file mode 100644
index 00000000..b3b70f24
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise1.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for raise
+ *
+ * SECTION: Actions and Subroutines/raise()
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the process to call getpid().
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:entry
+/pid == $1/
+{
+ trace("raised");
+ raise(SIGINT);
+ /*
+ * Wait no more than half a second for the process to die.
+ */
+ timeout = timestamp + 500000000;
+}
+
+syscall::rexit:entry
+{
+ exit(0);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.c
new file mode 100644
index 00000000..be0d9820
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.c
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+#include <signal.h>
+
+static void
+handle(int sig)
+{
+ exit(0);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = handle;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ (void) sigaction(SIGINT, &sa, NULL);
+
+ for (;;) {
+ (void) getpid();
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.d
new file mode 100644
index 00000000..1f967a3d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise2.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for raise
+ *
+ * SECTION: Actions and Subroutines/raise()
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the process to call getpid().
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:return
+/pid == $1/
+{
+ trace("raised");
+ raise(SIGINT);
+ /*
+ * Wait no more than half a second for the process to die.
+ */
+ timeout = timestamp + 500000000;
+}
+
+syscall::rexit:entry
+{
+ exit(0);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.c
new file mode 100644
index 00000000..be0d9820
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.c
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+#include <signal.h>
+
+static void
+handle(int sig)
+{
+ exit(0);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = handle;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ (void) sigaction(SIGINT, &sa, NULL);
+
+ for (;;) {
+ (void) getpid();
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.d
new file mode 100644
index 00000000..b3b70f24
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/raise/tst.raise3.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for raise
+ *
+ * SECTION: Actions and Subroutines/raise()
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the process to call getpid().
+ */
+ timeout = timestamp + 1000000000;
+}
+
+syscall::getpid:entry
+/pid == $1/
+{
+ trace("raised");
+ raise(SIGINT);
+ /*
+ * Wait no more than half a second for the process to die.
+ */
+ timeout = timestamp + 500000000;
+}
+
+syscall::rexit:entry
+{
+ exit(0);
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d
new file mode 100644
index 00000000..513cd312
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * If the aggregation rate is set properly, there should be no aggregation
+ * drops.
+ *
+ * SECTION: Aggregations/Minimizing drops;
+ * Options and Tunables/aggrate;
+ * Options and Tunables/aggsize
+ */
+
+/*
+ * We rely on the fact that at least 30 bytes must be stored per aggregation
+ * iteration, but that no more than 300 bytes are stored per iteration.
+ * We are going to let this run for ten seconds. If the aggregation rate
+ * is being set properly, there should be no aggregation drops. Note that
+ * this test (regrettably) may be scheduling sensitive -- but it should only
+ * fail on the most pathological systems.
+ */
+#pragma D option aggsize=300
+#pragma D option aggrate=10msec
+#pragma D option quiet
+
+int n;
+
+tick-100msec
+/n < 100/
+{
+ @a[n++] = sum(n);
+}
+
+tick-100msec
+/n == 100/
+{
+ exit(0);
+}
+
+END
+{
+ printa("%10d\n", @a);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d.out
new file mode 100644
index 00000000..c45f9296
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.aggrate.d.out
@@ -0,0 +1,101 @@
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.statusrate.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.statusrate.d
new file mode 100644
index 00000000..43c23bfd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.statusrate.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test of statusrate option.
+ *
+ * SECTION: Options and Tunables/statusrate
+ */
+
+/*
+ * Tests the statusrate option, by checking that the time delta between
+ * exit() and END is at least as long as mandated by the statusrate.
+ */
+
+#pragma D option statusrate=10sec
+
+inline uint64_t NANOSEC = 1000000000;
+
+tick-1sec
+/n++ > 5/
+{
+ exit(2);
+ ts = timestamp;
+}
+
+END
+/(this->delta = timestamp - ts) > 2 * NANOSEC/
+{
+ exit(0);
+}
+
+END
+/this->delta <= 2 * NANOSEC/
+{
+ printf("delta between exit() and END (%u nanos) too small",
+ this->delta);
+ exit(1);
+}
+
+END
+/this->delta > 20 * NANOSEC/
+{
+ printf("delta between exit() and END (%u nanos) too large",
+ this->delta);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d
new file mode 100644
index 00000000..691b31cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * If the switch rate is set properly, there should be no drops.
+ *
+ * SECTION: Buffers and Buffering/switch Policy;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/switchrate
+ */
+
+/*
+ * We rely on the fact that at least 8 bytes must be stored per iteration
+ * (EPID plus data), but that no more than 40 bytes are stored per iteration.
+ * We are going to let this run for ten seconds. If the switch rate
+ * is being set properly, there should be no drops. Note that this test
+ * (regrettably) may be scheduling sensitive -- but it should only fail on
+ * the most pathological systems.
+ */
+#pragma D option bufsize=40
+#pragma D option switchrate=10msec
+#pragma D option quiet
+
+int n;
+
+tick-100msec
+/n < 100/
+{
+ printf("%10d\n", n++);
+}
+
+tick-100msec
+/n == 100/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d.out
new file mode 100644
index 00000000..c45f9296
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/rates/tst.switchrate.d.out
@@ -0,0 +1,101 @@
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.basename.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.basename.d
new file mode 100644
index 00000000..3def9649
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.basename.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::entry
+/on/
+{
+ trace(basename((char *)rand()));
+}
+
+fbt:::entry
+/on/
+{
+ trace(basename((char *)arg1));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.caller.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.caller.d
new file mode 100644
index 00000000..b9777c1d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.caller.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Make sure that the caller variable is safe to use at every fbt probe
+ * point.
+ *
+ * SECTION: Variables/Built-in Variables;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ trace(caller);
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.cleanpath.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.cleanpath.d
new file mode 100644
index 00000000..729f320b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.cleanpath.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(cleanpath((char *)rand()));
+}
+
+fbt:::entry
+/on/
+{
+ trace(cleanpath((char *)arg1));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin.d
new file mode 100644
index 00000000..7426d19e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin.d
@@ -0,0 +1,83 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * We set our buffer size absurdly low to prevent a flood of errors that we
+ * don't care about. We set our statusrate to be infinitely short to cause
+ * lots of activity by the DTrace process.
+ *
+ * SECTION: Actions and Subroutines/copyin();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+
+#pragma D option bufsize=16
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=1nsec
+
+syscall:::entry
+{
+ n++;
+ trace(copyin(rand(), 1));
+}
+
+syscall:::entry
+{
+ trace(copyin(rand() | 1, 1));
+}
+
+syscall:::entry
+{
+ trace(copyin(NULL, 1));
+}
+
+dtrace:::ERROR
+{
+ err++;
+}
+
+tick-1sec
+/sec++ == 10/
+{
+ exit(2);
+}
+
+END
+/n == 0 || err == 0/
+{
+ exit(1);
+}
+
+END
+/n != 0 && err != 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin2.d
new file mode 100644
index 00000000..aef09440
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.copyin2.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Test that there is no value of 'size' which can be passed to copyin
+ * to cause mischief. The somewhat odd order of operations ensures
+ * that we test both size = 0 and size = 0xfff...fff
+ */
+#include <sys/types.h>
+
+
+#if defined(_LP64)
+#define MAX_BITS 63
+size_t size;
+#else
+#define MAX_BITS 31
+size_t size;
+#endif
+
+syscall:::
+/pid == $pid/
+{
+ printf("size = 0x%lx\n", (ulong_t)size);
+}
+
+syscall:::
+/pid == $pid/
+{
+ tracemem(copyin(curthread->t_procp->p_user.u_envp, size), 10);
+}
+
+syscall:::
+/pid == $pid && size > (1 << MAX_BITS)/
+{
+ exit(0);
+}
+
+syscall:::
+/pid == $pid/
+{
+ size = (size << 1ULL) | 1ULL;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ddi_pathname.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ddi_pathname.d
new file mode 100644
index 00000000..74275685
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ddi_pathname.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(ddi_pathname((struct dev_info *)rand(), rand()));
+}
+
+fbt:::entry
+/on/
+{
+ trace(ddi_pathname((struct dev_info *)arg1, rand()));
+}
+
+tick-1sec
+/n++ == 20/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.dirname.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.dirname.d
new file mode 100644
index 00000000..791d9b5f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.dirname.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(dirname((char *)rand()));
+}
+
+fbt:::entry
+/on/
+{
+ trace(dirname((char *)arg1));
+}
+
+tick-1sec
+/n++ == 20/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.errno.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.errno.d
new file mode 100644
index 00000000..d3f238b7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.errno.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect errno at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[errno] = count();
+}
+
+profile-4999hz
+{
+ @a[errno] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.execname.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.execname.d
new file mode 100644
index 00000000..cd9ca211
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.execname.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect execname at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[execname] = count();
+}
+
+profile-4999hz
+{
+ @a[execname] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.gid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.gid.d
new file mode 100644
index 00000000..f8f90e73
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.gid.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect gid at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[gid] = count();
+}
+
+profile-4999hz
+{
+ @a[gid] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.hton.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.hton.d
new file mode 100644
index 00000000..d573bfd1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.hton.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(htons(0x1122));
+}
+
+fbt:::
+/on/
+{
+ trace(htonl(0x11223344));
+}
+
+fbt:::
+/on/
+{
+ trace(htonll(0x1122334455667788));
+}
+
+fbt:::
+/on/
+{
+ trace(ntohs(0x1122));
+}
+
+fbt:::
+/on/
+{
+ trace(ntohl(0x11223344));
+}
+
+fbt:::
+/on/
+{
+ trace(ntohll(0x1122334455667788));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.index.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.index.d
new file mode 100644
index 00000000..22b0b5bc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.index.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(index((char *)rand(), (char *)(rand() ^ vtimestamp)));
+}
+
+fbt:::
+/on/
+{
+ trace(rindex((char *)rand(), (char *)(rand() ^ vtimestamp,
+ timestamp)));
+}
+
+fbt:::entry
+/on/
+{
+ trace(index((char *)arg0, (char *)arg1, rand()));
+}
+
+fbt:::entry
+/on/
+{
+ trace(rindex((char *)arg0, (char *)arg1));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgdsize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgdsize.d
new file mode 100644
index 00000000..c4e7c348
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgdsize.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Make sure that the msgdsize safe to use at every fbt probe
+ *
+ * SECTION: Actions and Subroutines/msgdsize();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(msgdsize((mblk_t *)rand()));
+}
+
+fbt:::entry
+/on/
+{
+ trace(msgdsize((mblk_t *)arg1));
+}
+
+tick-1sec
+/n++ == 20/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgsize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgsize.d
new file mode 100644
index 00000000..42aebe4c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.msgsize.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Make sure that the msgsize safe to use at every fbt probe
+ *
+ * SECTION: Actions and Subroutines/msgsize();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(msgsize((mblk_t *)rand()));
+}
+
+fbt:::
+/on/
+{
+ trace(msgdsize((mblk_t *)rand()));
+}
+
+tick-1sec
+/n++ == 20/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.null.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.null.d
new file mode 100644
index 00000000..cafa3af7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.null.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * trace with NULL argument - generate a bunch of errors
+ *
+ * SECTION: Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy
+ */
+
+/*
+ * We set our buffer size absurdly low to prevent a flood of errors that we
+ * don't care about.
+ */
+
+#pragma D option bufsize=16
+#pragma D option bufpolicy=ring
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ n++;
+ trace(*(int *)NULL);
+}
+
+dtrace:::ERROR
+{
+ err++;
+}
+
+tick-1sec
+/sec++ == 10/
+{
+ exit(2);
+}
+
+END
+/n == 0 || err == 0/
+{
+ exit(1);
+}
+
+END
+/n != 0 && err != 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.pid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.pid.d
new file mode 100644
index 00000000..2b7a92e1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.pid.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect pid at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[pid] = count();
+}
+
+profile-4999hz
+{
+ @a[pid] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ppid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ppid.d
new file mode 100644
index 00000000..faf07dc4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ppid.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect ppid at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[ppid] = count();
+}
+
+profile-4999hz
+{
+ @a[ppid] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.progenyof.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.progenyof.d
new file mode 100644
index 00000000..d488fe2e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.progenyof.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * trace progenyof() at every fbt probe point.
+ *
+ * SECTION: Actions and Subroutines/progenyof();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ trace(progenyof(rand()));
+}
+
+profile-4999hz
+{
+ trace(progenyof(rand()));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.random.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.random.d
new file mode 100644
index 00000000..8d157efd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.random.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * trace rand() at every fbt probe point.
+ *
+ * SECTION: Actions and Subroutines/rand();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy
+ */
+
+/*
+ * We set our buffer size absurdly low to prevent a flood of errors that we
+ * don't care about.
+ */
+
+#pragma D option bufsize=16
+#pragma D option bufpolicy=ring
+
+fbt:::
+{
+ n++;
+ trace(*(int *)rand());
+}
+
+dtrace:::ERROR
+{
+ err++;
+}
+
+tick-1sec
+/sec++ == 10/
+{
+ exit(2);
+}
+
+END
+/n == 0 || err == 0/
+{
+ exit(1);
+}
+
+END
+/n != 0 && err != 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.rw.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.rw.d
new file mode 100644
index 00000000..0df97877
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.rw.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ @[rw_read_held((krwlock_t *)&`clock)] = count();
+ @[rw_read_held((krwlock_t *)rand())] = count();
+}
+
+fbt:::
+/on/
+{
+ @[rw_write_held((krwlock_t *)&`clock)] = count();
+ @[rw_write_held((krwlock_t *)rand())] = count();
+}
+
+fbt:::
+/on/
+{
+ @[rw_iswriter((krwlock_t *)&`clock)] = count();
+ @[rw_iswriter((krwlock_t *)rand())] = count();
+}
+
+tick-1sec
+/n++ == 20/
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.shortstr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.shortstr.d
new file mode 100644
index 00000000..188f705c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.shortstr.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+#pragma D option strsize=16
+
+BEGIN
+{
+ this->str = ",,,Carrots,,Barley,Oatmeal,,,,,,,,,,,,,,,,,,Beans,";
+}
+
+BEGIN
+{
+ strtok(this->str, ",");
+}
+
+BEGIN
+{
+ this->str = ",,,,,,,,,,,,,,,,,,,,,,Carrots,";
+ strtok(this->str, ",");
+}
+
+BEGIN
+{
+ strtok(this->str, "a");
+}
+
+BEGIN
+{
+ printf("%s\n", substr(this->str, 1, 40));
+}
+
+BEGIN
+{
+ printf("%s\n", strjoin(this->str, this->str));
+}
+
+BEGIN
+{
+ this->str1 = ".........................................";
+ printf("%d\n", index(this->str, this->str1));
+}
+
+BEGIN
+{
+ printf("%d\n", rindex(this->str, this->str1));
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stack.d
new file mode 100644
index 00000000..57588b4d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stack.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call stack() at every fbt probe point.
+ *
+ * SECTION: Actions and Subroutines/stack();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ stack();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stackdepth.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stackdepth.d
new file mode 100644
index 00000000..a39387fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stackdepth.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test that the stackdepth variable is safe to use at every fbt probe
+ * point.
+ *
+ * SECTION: Variables/Built-in Variables;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ trace(stackdepth);
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stddev.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stddev.d
new file mode 100644
index 00000000..927930d0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.stddev.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call stddev() at every fbt probe point.
+ *
+ * SECTION: Actions and Subroutines/stddev();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ @a = stddev(1);
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strchr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strchr.d
new file mode 100644
index 00000000..bc95c486
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strchr.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(strchr((char *)(rand() ^ timestamp), rand()));
+}
+
+fbt:::
+/on/
+{
+ trace(strrchr((char *)(rand() ^ timestamp), rand()));
+}
+
+fbt:::entry
+/on/
+{
+ trace(strchr((char *)arg0, '!'));
+}
+
+fbt:::entry
+/on/
+{
+ trace(strrchr((char *)arg0, '!'));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strjoin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strjoin.d
new file mode 100644
index 00000000..5ed2935d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strjoin.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(strjoin((char *)rand(), (char *)(rand() ^ vtimestamp)));
+}
+
+fbt:::entry
+/on/
+{
+ trace(strjoin((char *)arg0, (char *)arg1));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strstr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strstr.d
new file mode 100644
index 00000000..025e5472
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strstr.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(strstr((char *)rand(), (char *)(rand() ^ vtimestamp)));
+}
+
+fbt:::entry
+/on/
+{
+ trace(strstr((char *)arg0, (char *)arg1));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strtok.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strtok.d
new file mode 100644
index 00000000..1027d2ed
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.strtok.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(strtok((char *)rand(), (char *)(rand() ^ vtimestamp)));
+}
+
+fbt:::entry
+/on/
+{
+ trace(strtok((char *)arg0, (char *)arg1));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.substr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.substr.d
new file mode 100644
index 00000000..d5ed9a48
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.substr.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(substr((char *)rand(), rand() ^ vtimestamp));
+}
+
+fbt:::
+/on/
+{
+ trace(substr((char *)rand(), -rand() ^ vtimestamp));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ucaller.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ucaller.d
new file mode 100644
index 00000000..524c88b7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ucaller.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect ucaller at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[ucaller] = count();
+}
+
+profile-4999hz
+{
+ @a[ucaller] = count();
+}
+
+tick-1sec
+/n++ == 30/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uid.d
new file mode 100644
index 00000000..b546457e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uid.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect uid at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[uid] = count();
+}
+
+profile-4999hz
+{
+ @a[uid] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.unalign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.unalign.d
new file mode 100644
index 00000000..e996cbd8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.unalign.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * We set our buffer size absurdly low to prevent a flood of errors that we
+ * don't care about. Note that this test (unlike some other safety tests)
+ * doesn't check the error count -- some architectures have no notion of
+ * alignment.
+ */
+#pragma D option bufsize=16
+#pragma D option bufpolicy=ring
+
+fbt:::
+{
+ n++;
+ trace(*(int *)(rand() | 1));
+}
+
+tick-1sec
+/sec++ == 10/
+{
+ exit(2);
+}
+
+END
+/n == 0/
+{
+ exit(1);
+}
+
+END
+/n != 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uregs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uregs.d
new file mode 100644
index 00000000..b13434db
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.uregs.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Trace uregs[0] at every fbt probe point.
+ * SECTION: Variables/Built-in Variables;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ trace(uregs[0]);
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustack.d
new file mode 100644
index 00000000..a286382a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustack.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call ustack() at every fbt probe point.
+ *
+ * SECTION: Actions and Subroutines/ustack();
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ ustack();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustackdepth.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustackdepth.d
new file mode 100644
index 00000000..942913c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.ustackdepth.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test that the ustackdepth variable is safe to use at every fbt probe
+ * point.
+ *
+ * SECTION: Variables/Built-in Variables;
+ * Options and Tunables/bufsize;
+ * Options and Tunables/bufpolicy;
+ * Options and Tunables/statusrate
+ */
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ trace(ustackdepth);
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.vahole.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.vahole.d
new file mode 100755
index 00000000..2ef40a5a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.vahole.d
@@ -0,0 +1,69 @@
+#!/usr/sbin/dtrace -Cs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * We set our buffer size absurdly low to prevent a flood of errors that we
+ * don't care about.
+ */
+#pragma D option bufsize=16
+#pragma D option bufpolicy=ring
+
+fbt:::
+{
+ n++;
+#ifdef __sparc
+ trace(*(int *)0x8000000000000000 ^ rand());
+#else
+ trace(*(int *)(`kernelbase - 1));
+#endif
+}
+
+dtrace:::ERROR
+{
+ err++;
+}
+
+tick-1sec
+/sec++ == 10/
+{
+ exit(2);
+}
+
+END
+/n == 0 || err == 0/
+{
+ exit(1);
+}
+
+END
+/n != 0 && err != 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.violentdeath.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.violentdeath.ksh
new file mode 100644
index 00000000..879774a4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.violentdeath.ksh
@@ -0,0 +1,51 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+script()
+{
+ $dtrace -x bufpolicy=ring -x bufsize=1k -s /dev/stdin <<EOF
+ fbt:::
+ {}
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+let i=0
+
+while [ "$i" -lt 10 ]; do
+ script &
+ child=$!
+ sleep 1
+ kill -9 $child
+ let i=i+1
+done
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.zonename.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.zonename.d
new file mode 100644
index 00000000..5fc025f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/safety/tst.zonename.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect zonename at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+ @a[zonename] = count();
+}
+
+profile-4999hz
+{
+ @a[zonename] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_ARR_LOCAL.thisarray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_ARR_LOCAL.thisarray.d
new file mode 100644
index 00000000..289d164d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_ARR_LOCAL.thisarray.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Use 'this' variables in associative array.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+
+this int y;
+this int z;
+this int res;
+
+BEGIN
+{
+ this->x[this->y, this->z] = 123;
+ this->res = this->x[this->y, this->z]++;
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.selfthis.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.selfthis.d
new file mode 100644
index 00000000..eda1151b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.selfthis.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declare a variable and assign inappropriate value.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+self this int x;
+
+BEGIN
+{
+ x = "dummy";
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.thisself.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.thisself.d
new file mode 100644
index 00000000..f9c596b6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_CLASS.thisself.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Multiple storage declarations.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+this self int x;
+
+BEGIN
+{
+ x = "dummy";
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_IDRED.errval.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_IDRED.errval.d
new file mode 100644
index 00000000..3130fbfe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_DECL_IDRED.errval.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declare a variable with different data types.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+int x;
+char x;
+double x;
+long x;
+
+BEGIN
+{
+ x = 123;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dec.err.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dec.err.d
new file mode 100644
index 00000000..4261e072
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dec.err.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a variable and assign inappropriate value.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+int x;
+
+BEGIN
+{
+ x = "dummy";
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupgtype.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupgtype.d
new file mode 100644
index 00000000..71f9c0b4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupgtype.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test assigning a variable two different incompatible types.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+
+BEGIN
+{
+ x = `kmem_flags;
+ x = *`rootvp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupltype.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupltype.d
new file mode 100644
index 00000000..c316441e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupltype.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test assigning a variable two different incompatible types.
+ *
+ * SECTION: Variables/Clause-Local Variables
+ *
+ */
+
+BEGIN
+{
+ this->x = `kmem_flags;
+ this->x = *`rootvp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupttype.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupttype.d
new file mode 100644
index 00000000..23f26f7f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_OP_INCOMPAT.dupttype.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test assigning a variable two different incompatible types.
+ * Test assigning a variable two different incompatible types.
+ *
+ * SECTION: Variables/Thread-Local Variables
+ *
+ */
+
+BEGIN
+{
+ self->x = `kmem_flags;
+ self->x = *`rootvp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_SYNTAX.declare.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_SYNTAX.declare.d
new file mode 100644
index 00000000..246236a9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/err.D_SYNTAX.declare.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a variable Inside Begin and make sure compilation fails.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+
+BEGIN
+{
+ int x = 123;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d
new file mode 100644
index 00000000..55616314
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d
@@ -0,0 +1,57 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Global variables defined once, is visible in every clause of
+ * D program
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+
+#pragma D option quiet
+
+int x;
+
+BEGIN
+{
+ x = 123;
+}
+
+profile:::tick-1sec
+{
+ printf("The value of x is %d\n", x);
+}
+
+profile:::tick-100msec
+{
+ printf("The value of x is %d\n", x);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d.out
new file mode 100644
index 00000000..2b8999e4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.basicvar.d.out
@@ -0,0 +1,2 @@
+The value of x is 123
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.localvar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.localvar.d
new file mode 100644
index 00000000..9a89a048
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.localvar.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Assign a value to a variable in a local clause.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+}
+int i;
+
+profile:::tick-1sec
+{
+ i = 0;
+}
+
+profile:::tick-100msec
+{
+ printf("The value of int i is %d\n", i);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.misc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.misc.d
new file mode 100644
index 00000000..3b6eb7a7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.misc.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the different kinds of integer scalar references. In particular, we
+ * test accessing a kernel executable scalar, kernel scoped scalar, DTrace
+ * scalar first ref that forces creation (both global and TLS), and DTrace
+ * scalar subsequent reference (both global and TLS).
+ *
+ * SECTION: Variables/External Variables
+ *
+ */
+
+BEGIN
+{
+ printf("\nkmem_flags = 0x%x\n", `kmem_flags);
+ printf("ufs`ufs_allow_shared_writes = %d\n",
+ ufs`ufs_allow_shared_writes);
+ x = 123;
+ printf("x = %u\n", x);
+ self->x = 456;
+ printf("self->x = %u\n", self->x);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.self.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.self.d
new file mode 100644
index 00000000..514f3859
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.self.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declare self a variable and assign appropriate value.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+self x;
+
+BEGIN
+{
+ x = "dummy";
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray.d
new file mode 100644
index 00000000..410e8def
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a self variable and assign appropriate value.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+
+self int y;
+self int z;
+self int res;
+
+BEGIN
+{
+ self->x[self->y, self->z] = 123;
+ self->res = self->x[self->y, self->z]++;
+ printf("The result = %d\n", self->res);
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray2.d
new file mode 100644
index 00000000..2fd69c69
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfarray2.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+#pragma D option destructive
+#pragma D option dynvarsize=1m
+
+struct bar {
+ int pid;
+ kthread_t *curthread;
+};
+
+self struct bar foo[int];
+
+syscall:::entry
+/!self->foo[0].pid/
+{
+ self->foo[0].pid = pid;
+ self->foo[0].curthread = curthread;
+}
+
+syscall:::entry
+/self->foo[0].pid != pid/
+{
+ printf("expected %d, found %d (found curthread %p, curthread is %p)\n",
+ pid, self->foo[0].pid, self->foo[0].curthread, curthread);
+ exit(1);
+}
+
+tick-100hz
+{
+ system("date > /dev/null")
+}
+
+tick-1sec
+/i++ == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfthis.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfthis.d
new file mode 100644
index 00000000..7bbfaf76
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.selfthis.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Declare a this variable and assign value of self variable to it.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+self int x;
+this int y;
+
+BEGIN
+{
+ this->x = 123;
+ self->y = this->x;
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.this.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.this.d
new file mode 100644
index 00000000..01ea89f4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.this.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple 'this' declaration.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+this x;
+
+BEGIN
+{
+ x = "dummy";
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.thisself.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.thisself.d
new file mode 100644
index 00000000..925dff2b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scalars/tst.thisself.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declare a self value and assign value of 'this' variable to that.
+ *
+ * SECTION: Variables/Scalar Variables
+ *
+ */
+self int x;
+this int y;
+
+BEGIN
+{
+ self->x = 123;
+ this->y = self->x;
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.enqueue.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.enqueue.d
new file mode 100644
index 00000000..77105c1e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.enqueue.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option switchrate=100hz
+#pragma D option destructive
+
+sched:::enqueue
+/pid == 0 && args[1]->pr_pid == $pid/
+{
+ self->one = 1;
+}
+
+sched:::enqueue
+/self->one && args[2]->cpu_id >= 0 && args[2]->cpu_id <= `max_cpuid/
+{
+ self->two = 1;
+}
+
+sched:::enqueue
+/self->two && args[0]->pr_lwpid > 0/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.oncpu.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.oncpu.d
new file mode 100644
index 00000000..25717671
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.oncpu.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option switchrate=100hz
+#pragma D option destructive
+
+sched:::on-cpu
+/pid == $pid/
+{
+ self->on++;
+}
+
+sched:::off-cpu
+/pid == $pid && self->on/
+{
+ self->off++;
+}
+
+sched:::off-cpu
+/self->on > 50 && self->off > 50/
+{
+ exit(0);
+}
+
+profile:::tick-1sec
+/n++ > 10/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.stackdepth.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.stackdepth.d
new file mode 100644
index 00000000..b4251270
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sched/tst.stackdepth.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option switchrate=100hz
+
+sched:::on-cpu
+/stackdepth > 0/
+{
+ exit(0);
+}
+
+tick-1s
+/i++ == 3/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_MACRO_UNDEF.invalidargs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_MACRO_UNDEF.invalidargs.d
new file mode 100644
index 00000000..27d969e7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_MACRO_UNDEF.invalidargs.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Try to print arguments not provided.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ print("The arguments are %d %d\n", $1, $2);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_LVAL.rdonly.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_LVAL.rdonly.d
new file mode 100644
index 00000000..5bf46751
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_LVAL.rdonly.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Try to update a read-only macro.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ $pid++;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_WRITE.usepidmacro.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_WRITE.usepidmacro.d
new file mode 100644
index 00000000..649cbdbc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_OP_WRITE.usepidmacro.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Try to assign value to Macro.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ pid = 1;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.concat.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.concat.d
new file mode 100755
index 00000000..00a29969
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.concat.d
@@ -0,0 +1,45 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Try to concat macro with user variables in provider description
+ * section.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+/i = 123$pid/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.desc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.desc.d
new file mode 100755
index 00000000..3dfa2b26
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.desc.d
@@ -0,0 +1,49 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Try to call providers using macro variables.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+/i = 123$pid/
+{
+ exit(0);
+}
+
+pid$pid
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.inval.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.inval.d
new file mode 100644
index 00000000..28b251cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.inval.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Attempt to print invalid arguments.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ print("The arguments are %d %d\n", $-1);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.pid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.pid.d
new file mode 100644
index 00000000..d9711d2a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/err.D_SYNTAX.pid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Attempt to concat and assign a macro to a variable
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ i = 123$pid;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.D_MACRO_UNUSED.overflow.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.D_MACRO_UNUSED.overflow.ksh
new file mode 100755
index 00000000..0f4e1455
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.D_MACRO_UNUSED.overflow.ksh
@@ -0,0 +1,80 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Attempt to pass some arguments and try not to print it.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$.d
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+BEGIN
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+$dtrace -x errtags -s $dfilename "this is test" 1>/dev/null \
+ 2>/var/tmp/err.$$.txt
+
+if [ $? -ne 1 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+grep "D_MACRO_UNUSED" /var/tmp/err.$$.txt >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ print -u2 "Expected error D_MACRO_UNUSED not returned"
+ /usr/bin/rm -f /var/tmp/err.$$.txt
+ exit 1
+fi
+
+/usr/bin/rm -f $dfilename
+/usr/bin/rm -f /var/tmp/err.$$.txt
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arg0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arg0.d
new file mode 100644
index 00000000..999dbc32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arg0.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print argument 0 I mean "$0"
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The arg0 is %s\n", $0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arguments.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arguments.ksh
new file mode 100755
index 00000000..deb644a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.arguments.ksh
@@ -0,0 +1,90 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Pass 10 arguments and try to print them.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+bname=`/bin/basename $0`
+
+dfilename=/var/tmp/$bname.$$
+
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+{
+ printf("%d %d %d %d %d %d %d %d %d %d", \$1, \$2, \$3, \$4, \$5, \$6,
+ \$7, \$8, \$9, \$10);
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+
+output=`$dfilename 1 2 3 4 5 6 7 8 9 10 2>/dev/null`
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+set -A outarray $output
+
+if [[ ${outarray[0]} != 1 || ${outarray[1]} != 2 || ${outarray[2]} != 3 || \
+ ${outarray[3]} != 4 || ${outarray[4]} != 5 || ${outarray[5]} != 6 || \
+ ${outarray[6]} != 7 || ${outarray[7]} != 8 || ${outarray[8]} != 9 || \
+ ${outarray[9]} != 10 ]]; then
+ print -u2 "Error in output by $dfilename"
+ exit 1
+fi
+
+/usr/bin/rm -f $dfilename
+exit 0
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.assign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.assign.d
new file mode 100644
index 00000000..5dd17407
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.assign.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Assign macros to variables
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ processid = $pid;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.basic.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.basic.d
new file mode 100644
index 00000000..a407f839
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.basic.d
@@ -0,0 +1,42 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Basic script which uses exit(0) to exit.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.d
new file mode 100644
index 00000000..3899d2ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints effective group id.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The egid is %d\n", $egid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.ksh
new file mode 100755
index 00000000..9e1955f2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.egid.ksh
@@ -0,0 +1,97 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+#
+# To verify egid of current process
+#
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$.d
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$egid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$egid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#chmod 555 the .d file
+
+chmod 555 $dfilename >/dev/null 2>&1
+if [ &? -ne 0 ]; then
+ print -u2 "chmod $dfilename failed"
+ exit 1
+fi
+
+#Get the groupid of the calling process using ps
+
+groupid=`ps -o pid,gid | grep "$$ " | awk '{print $2}' 2>/dev/null`
+if [ $? -ne 0 ]; then
+ print -u2 "unable to get uid of the current process with pid = $$"
+ exit 1
+fi
+
+#Pass groupid as argument to .d file
+$dfilename $groupid >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#Cleanup leftovers
+
+/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.d
new file mode 100644
index 00000000..e4cdaa6b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.d
@@ -0,0 +1,44 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Script which prints effective user id.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The euid is %d\n", $euid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.ksh
new file mode 100755
index 00000000..7112b257
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.euid.ksh
@@ -0,0 +1,86 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# To verify euid of current process
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$euid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$euid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+userid=`ps -o pid,uid | grep "$$ " | awk '{print $2}' 2>/dev/null`
+if [ $? -ne 0 ]; then
+ print -u2 "unable to get uid of the current process with pid = $$"
+ exit 1
+fi
+
+$dfilename $userid >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.d
new file mode 100644
index 00000000..c3329ce1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints group id.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The gid is %d\n", $gid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.ksh
new file mode 100755
index 00000000..83955db1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.gid.ksh
@@ -0,0 +1,86 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# To verify gid of the child process.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$gid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$gid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+groupid=`ps -o pid,gid | grep "$$ " | awk '{print $2}' 2>/dev/null`
+if [ $? -ne 0 ]; then
+ print -u2 "unable to get uid of the current process with pid = $$"
+ exit 1
+fi
+
+$dfilename $groupid >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pgid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pgid.d
new file mode 100644
index 00000000..e01b9968
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pgid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints effective process group id.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The pgid is %d\n", $pgid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pid.d
new file mode 100644
index 00000000..1364366c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.pid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints pid.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The pid is %d\n", $pid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.d
new file mode 100644
index 00000000..8712cd96
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints parent processid
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The ppid is %d\n", $ppid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.ksh
new file mode 100755
index 00000000..4a74ee42
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.ppid.ksh
@@ -0,0 +1,86 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# To verify ppid of child process.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$.d
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$ppid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$ppid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#chmod the .d file to 555
+
+chmod 555 $dfilename >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ print -u2 "chmod 555 $dfilename failed"
+ exit 1
+fi
+
+#Pass current pid (I mean parent pid for .d script).
+
+$dfilename $$ >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.d
new file mode 100644
index 00000000..a81ab8ee
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints current project id.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The projid is %d\n", $projid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.ksh
new file mode 100755
index 00000000..da60ea1d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.projid.ksh
@@ -0,0 +1,86 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# To verify projid of child process.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$projid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$projid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+projectid=`ps -o pid,projid | grep "$$ " | awk '{print $2}' 2>/dev/null`
+if [ $? -ne 0 ]; then
+ print -u2 "unable to get uid of the current process with pid = $$"
+ exit 1
+fi
+
+$dfilename $projectid >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.quite.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.quite.d
new file mode 100644
index 00000000..c61debed
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.quite.d
@@ -0,0 +1,42 @@
+#!/usr/sbin/dtrace -qs
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which uses -qs in scripting line
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.d
new file mode 100644
index 00000000..87bab536
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints session id.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The sid is %d\n", $sid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.ksh
new file mode 100755
index 00000000..d1e122c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.sid.ksh
@@ -0,0 +1,86 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# To verify sid of current process.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$sid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$sid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+sessionid=`ps -o pid,sid | grep "$$ " | awk '{print $2}' 2>/dev/null`
+if [ $? -ne 0 ]; then
+ print -u2 "unable to get sid of the current process with pid = $$"
+ exit 1
+fi
+
+$dfilename $sessionid >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.stringmacro.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.stringmacro.ksh
new file mode 100755
index 00000000..6903cb1c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.stringmacro.ksh
@@ -0,0 +1,78 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# Pass a bunch of strings as a sentence and print them
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$.d
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+BEGIN
+{
+ printf("%s", \$\$1);
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+output=`$dfilename 'this is test' 2>/dev/null`
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+if [ "$output" != "this is test" ]; then
+ print -u2 "Expected output not returned"
+ exit 1
+fi
+
+/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.d
new file mode 100644
index 00000000..617827c8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Script which prints taskid.
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The taskid is %d\n", $taskid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.ksh
new file mode 100755
index 00000000..54392d23
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.taskid.ksh
@@ -0,0 +1,86 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# To verify taskid of current process.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$taskid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$taskid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+taskidval=`ps -o pid,taskid | grep "$$ " | awk '{print $2}' 2>/dev/null`
+if [ $? -ne 0 ]; then
+ print -u2 "unable to get uid of the current process with pid = $$"
+ exit 1
+fi
+
+$dfilename $taskidval >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.trace.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.trace.d
new file mode 100644
index 00000000..34ba243e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.trace.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * To use trace in a script
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ trace("hello");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.d
new file mode 100644
index 00000000..f3ebca61
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.d
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -s
+
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * print uid in a script
+ *
+ * SECTION: Scripting
+ *
+ */
+
+BEGIN
+{
+ printf("The uid is %d\n", $uid);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.ksh
new file mode 100755
index 00000000..2630f2f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/scripting/tst.uid.ksh
@@ -0,0 +1,86 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
+
+############################################################################
+# ASSERTION:
+# To verify uid of current process.
+#
+# SECTION: Scripting
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+bname=`/bin/basename $0`
+dfilename=/var/tmp/$bname.$$
+
+## Create .d file
+##########################################################################
+cat > $dfilename <<-EOF
+#!$dtrace -qs
+
+
+BEGIN
+/\$uid != \$1/
+{
+ exit(1);
+}
+
+BEGIN
+/\$uid == \$1/
+{
+ exit(0);
+}
+EOF
+##########################################################################
+
+
+#Call dtrace -C -s <.d>
+
+chmod 555 $dfilename
+
+userid=`ps -o pid,uid | grep "$$ " | awk '{print $2}' 2>/dev/null`
+if [ $? -ne 0 ]; then
+ print -u2 "unable to get uid of the current process with pid = $$"
+ exit 1
+fi
+
+$dfilename $userid >/dev/null 2>&1
+
+if [ $? -ne 0 ]; then
+ print -u2 "Error in executing $dfilename"
+ exit 1
+fi
+
+#/usr/bin/rm -f $dfilename
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c
new file mode 100644
index 00000000..07635502
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c
@@ -0,0 +1,45 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+#include <sys/uadmin.h>
+
+int
+main(int argc, char **argv)
+{
+ while (1) {
+ if (uadmin(A_SDTTEST, 0, 0) < 0) {
+ perror("uadmin");
+ return (1);
+ }
+
+ sleep(1);
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d
new file mode 100644
index 00000000..0523de09
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Verify that argN (1..7) variables are properly remapped.
+ */
+
+BEGIN
+{
+ /* Timeout after 5 seconds */
+ timeout = timestamp + 5000000000;
+ ignore = $1;
+}
+
+ERROR
+{
+ printf("sdt:::test failed.\n");
+ exit(1);
+}
+
+sdt:::test
+/arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6 ||
+ arg6 != 7/
+{
+ printf("sdt arg mismatch\n\n");
+ printf("args are : %d, %d, %d, %d, %d, %d, %d\n", arg0, arg1, arg2,
+ arg3, arg4, arg5, arg6);
+ printf("should be : 1, 2, 3, 4, 5, 6, 7\n");
+ exit(1);
+}
+
+sdt:::test
+{
+ exit(0);
+}
+
+profile:::tick-1
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d
new file mode 100644
index 00000000..9ace4197
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: sizeof returns the size in bytes of any D expression or data
+ * type. For an associative array, the D compiler should throw an error since
+ * an associative array does not have a fixed size.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ assoc_array[0] = 010;
+ assoc_array[1] = 100;
+ assoc_array[2] = 210;
+
+ printf("sizeof (assoc_array): %d\n", sizeof (assoc_array));
+ printf("sizeof (assoc_array[0]): %d\n", sizeof (assoc_array[0]));
+ printf("sizeof (assoc_array[1]): %d\n", sizeof (assoc_array[1]));
+ printf("sizeof (assoc_array[2]): %d\n", sizeof (assoc_array[2]));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d
new file mode 100644
index 00000000..f2dcdfab
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: The D compiler throws a D_IDENT_UNDEF error when sizeof is passed
+ * an unknown symbol.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ printf("sizeof (`): %d\n", sizeof (`));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d
new file mode 100644
index 00000000..43c493a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * sizeof() should handle invalid types
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+
+BEGIN
+{
+ trace(sizeof (void));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d
new file mode 100644
index 00000000..85519e6d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: sizeof returns the size in bytes of any D expression or data
+ * type. When an operator or non-symbol is passed as an argument to sizeof
+ * operator, the D_SYNTAX error is thrown by the compiler.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ printf("sizeof (*): %d\n", sizeof (*));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d
new file mode 100644
index 00000000..8843728c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: sizeof returns the size in bytes of any D expression or data
+ * type. For a simpler array, the sizeof on the array variable itself gives
+ * the sum total of memory allocated to the array in bytes. With individual
+ * members of the array it gives their respective sizes.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+#pragma D option quiet
+
+int array[5];
+
+BEGIN
+{
+ array[0] = 010;
+ array[1] = 100;
+ array[2] = 210;
+
+ printf("sizeof (array): %d\n", sizeof (array));
+ printf("sizeof (array[0]): %d\n", sizeof (array[0]));
+ printf("sizeof (array[1]): %d\n", sizeof (array[1]));
+ printf("sizeof (array[2]): %d\n", sizeof (array[2]));
+
+ exit(0);
+}
+
+END
+/(20 != sizeof (array)) || (4 != sizeof (array[0])) || (4 != sizeof (array[1]))
+ || (4 != sizeof (array[2]))/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d
new file mode 100644
index 00000000..fe558e8e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d
@@ -0,0 +1,122 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: sizeof returns the size in bytes of any D expression or data
+ * type.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ */
+#pragma D option quiet
+
+char new_char;
+short new_short;
+int new_int;
+long new_long;
+long long new_long_long;
+int8_t new_int8;
+int16_t new_int16;
+int32_t new_int32;
+int64_t new_int64;
+intptr_t new_intptr;
+uint8_t new_uint8;
+uint16_t new_uint16;
+uint32_t new_uint32;
+uint64_t new_uint64;
+uintptr_t new_uintptr;
+
+/*
+float new_float;
+double new_double;
+long double new_long_double;
+
+string new_string;
+*/
+
+struct record {
+ char ch;
+ int in;
+} new_struct;
+
+struct {
+ char ch;
+ int in;
+} anon_struct;
+
+union record {
+ char ch;
+ int in;
+} new_union;
+
+union {
+ char ch;
+ int in;
+} anon_union;
+
+enum colors {
+ RED,
+ GREEN,
+ BLUE
+} new_enum;
+
+
+int *pointer;
+
+BEGIN
+{
+ printf("sizeof (new_char): %d\n", sizeof (new_char));
+ printf("sizeof (new_short): %d\n", sizeof (new_short));
+ printf("sizeof (new_int): %d\n", sizeof (new_int));
+ printf("sizeof (new_long): %d\n", sizeof (new_long));
+ printf("sizeof (new_long_long): %d\n", sizeof (new_long_long));
+ printf("sizeof (new_int8): %d\n", sizeof (new_int8));
+ printf("sizeof (new_int16): %d\n", sizeof (new_int16));
+ printf("sizeof (new_int32): %d\n", sizeof (new_int32));
+ printf("sizeof (new_int64): %d\n", sizeof (new_int64));
+ printf("sizeof (pointer): %d\n", sizeof (pointer));
+ printf("sizeof (intptr_t): %d\n", sizeof (intptr_t));
+ printf("sizeof (new_struct): %d\n", sizeof (new_struct));
+ printf("sizeof (anon_struct): %d\n", sizeof (anon_struct));
+ printf("sizeof (new_union): %d\n", sizeof (new_union));
+ printf("sizeof (anon_union): %d\n", sizeof (anon_union));
+ printf("sizeof (new_enum): %d\n", sizeof (new_enum));
+ exit(0);
+}
+
+END
+/(1 != sizeof (new_char)) || (2 != sizeof (new_short)) ||
+ (4 != sizeof (new_int)) ||
+ ((4 != sizeof (new_long)) && (8 != sizeof (new_long))) ||
+ (8 != sizeof (new_long_long)) ||
+ (1 != sizeof (new_int8)) || (2 != sizeof (new_int16)) ||
+ (4 != sizeof (new_int32)) || (8 != sizeof (new_int64)) ||
+ (sizeof (pointer) != sizeof (new_intptr)) || (8 != sizeof (new_struct)) ||
+ (4 != sizeof (new_union)) || (4 != sizeof (new_enum))/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d
new file mode 100644
index 00000000..0bb7f686
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the use of sizeof with expressions.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("sizeof ('c') : %d\n", sizeof ('c'));
+ printf("sizeof (10 * 'c') : %d\n", sizeof (10 * 'c'));
+ printf("sizeof (100 + 12345) : %d\n", sizeof (100 + 12345));
+ printf("sizeof (1234567890) : %d\n", sizeof (1234567890));
+
+ printf("sizeof (1234512345 * 1234512345 * 12345678 * 1ULL) : %d\n",
+ sizeof (1234512345 * 1234512345 * 12345678 * 1ULL));
+ printf("sizeof (-129) : %d\n", sizeof (-129));
+ printf("sizeof (0x67890/0x77000) : %d\n", sizeof (0x67890/0x77000));
+
+ printf("sizeof (3 > 2 ? 3 : 2) : %d\n", sizeof (3 > 2 ? 3 : 2));
+
+ exit(0);
+}
+
+END
+/(4 != sizeof ('c')) || (4 != sizeof (10 * 'c')) ||
+ (4 != sizeof (100 + 12345)) || (4 != sizeof (1234567890)) ||
+ (8 != sizeof (1234512345 * 1234512345 * 12345678 * 1ULL)) ||
+ (4 != sizeof (-129)) || (4 != sizeof (0x67890/0x77000)) ||
+ (4 != sizeof (3 > 2 ? 3 : 2))/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d
new file mode 100644
index 00000000..4bd8a484
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: The size of the inbuilt variable NULL is the same as that of an
+ * integer.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ printf("sizeof (NULL): %d\n", sizeof (NULL));
+ exit(0);
+}
+
+END
+/4 != sizeof (NULL)/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d
new file mode 100644
index 00000000..51f72505
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d
@@ -0,0 +1,42 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: sizeof returns the size in bytes of any D expression or data
+ * type. When a raw string is passed to the sizeof operator, the compiler
+ * throws a D_SYNTAX error.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ printf("sizeof \"hi\": %d\n", sizeof ("hi"));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out
new file mode 100644
index 00000000..3fe02aaf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out
@@ -0,0 +1,2 @@
+sizeof "hi": 3
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d
new file mode 100644
index 00000000..0be9e457
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: sizeof returns the size in bytes of any D expression or data
+ * type. For sizeof strings the D compiler throws D_SIZEOF_TYPE.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+#pragma D option quiet
+#pragma D option strsize=256
+
+BEGIN
+{
+ assoc_array["hello"] = "hello";
+ assoc_array["hi"] = "hi";
+ assoc_array["hello"] = "hello, world";
+
+ printf("sizeof (assoc_array[\"hello\"]): %d\n",
+ sizeof (assoc_array["hello"]));
+ printf("sizeof (assoc_array[\"hi\"]): %d\n",
+ sizeof (assoc_array["hi"]));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out
new file mode 100644
index 00000000..9c43b1e3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out
@@ -0,0 +1,3 @@
+sizeof (assoc_array["hello"]): 256
+sizeof (assoc_array["hi"]): 256
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d
new file mode 100644
index 00000000..f12a6003
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: sizeof returns the size in bytes of any D expression or data
+ * type. For a string variable, the D compiler throws a D_SIZEOF_TYPE.
+ *
+ * SECTION: Structs and Unions/Member Sizes and Offsets
+ *
+ */
+#pragma D option quiet
+#pragma D option strsize=256
+
+BEGIN
+{
+ var = "hello";
+ printf("sizeof (var): %d\n", sizeof (var));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out
new file mode 100644
index 00000000..fdeca699
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out
@@ -0,0 +1,2 @@
+sizeof (var): 256
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/bug.1001148.SpecSizeVariations.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/bug.1001148.SpecSizeVariations.d
new file mode 100644
index 00000000..318a2d05
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/bug.1001148.SpecSizeVariations.d
@@ -0,0 +1,87 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify the behavior of variations in specsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ * BUG: 1001148
+ *
+ * NOTES: This code has four different behaviors.
+ * 1. 0 < specsize < 8
+ * 2. 8 <= specsize <= 39 || 0 == specsize
+ * 3. 40 <= specsize
+ * 4. 0 > specsize
+ *
+ */
+
+#pragma D option quiet
+#pragma D option specsize=10
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d
new file mode 100644
index 00000000..e97506e1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d
@@ -0,0 +1,88 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify the behavior of variations in bufsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/bufsize
+ *
+ * NOTES: This test behaves differently depending on the values
+ * assigned to bufsize.
+ * 1. 0 > bufsize.
+ * 2. 0 == bufsize.
+ * 3. 0 < bufsize <= 7
+ * 4. 8 <= bufsize <= 31
+ * 5. 32 <= bufsize <= 47
+ * 6. 48 <= bufsize <= 71
+ * 7. 72 <= bufsize
+ */
+
+#pragma D option quiet
+#pragma D option bufsize=41
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations2.d
new file mode 100644
index 00000000..f660e9a8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations2.d
@@ -0,0 +1,88 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify the behavior of variations in bufsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/bufsize
+ *
+ * NOTES: This test behaves differently depending on the values
+ * assigned to bufsize.
+ * 1. 0 > bufsize.
+ * 2. 0 == bufsize.
+ * 3. 0 < bufsize <= 7
+ * 4. 8 <= bufsize <= 31
+ * 5. 32 <= bufsize <= 47
+ * 6. 48 <= bufsize <= 71
+ * 7. 72 <= bufsize
+ */
+
+#pragma D option quiet
+#pragma D option bufsize=4
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d
new file mode 100644
index 00000000..958ce686
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d
@@ -0,0 +1,69 @@
+#!/usr/sbin/dtrace -ws
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Destructive actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ * SECTION: dtrace(1M) Utility/ -w option
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+syscall:::
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ breakpoint();
+ i++;
+}
+
+syscall:::
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithChill.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithChill.d
new file mode 100644
index 00000000..ebb3b016
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithChill.d
@@ -0,0 +1,69 @@
+#!/usr/sbin/dtrace -ws
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Destructive actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ * SECTION: dtrace (1M) Utility/ -w option
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ chill(10);
+ i++;
+}
+
+profile:::tick-1sec
+/1 == 1/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d
new file mode 100644
index 00000000..9c14bb5a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d
@@ -0,0 +1,69 @@
+#!/usr/sbin/dtrace -ws
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Destructive actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ * SECTION: dtrace(1M) Utility/ -w option
+ *
+ */
+#pragma D option quiet
+
+char a[2];
+void *buf;
+uintptr_t addr;
+size_t nbytes;
+BEGIN
+{
+ self->i = 0;
+ addr = (uintptr_t) &a[0];
+ nbytes = 10;
+ var = speculation();
+}
+
+BEGIN
+{
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ self->i++;
+ copyout(buf, addr, nbytes);
+}
+
+BEGIN
+{
+ printf("This test should not have compiled\n");
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d
new file mode 100644
index 00000000..695eb8c8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d
@@ -0,0 +1,68 @@
+#!/usr/sbin/dtrace -ws
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Destructive actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ * SECTION: dtrace(1M) Utility/ -w option
+ */
+#pragma D option quiet
+
+string str;
+char a[2];
+uintptr_t addr;
+size_t maxlen;
+BEGIN
+{
+ self->i = 0;
+ addr = (uintptr_t) &a[0];
+ maxlen = 10;
+ var = speculation();
+}
+
+BEGIN
+{
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ self->i++;
+ copyoutstr(str, addr, maxlen);
+}
+
+BEGIN
+{
+ printf("This test should not have compiled\n");
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d
new file mode 100644
index 00000000..dcba0801
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d
@@ -0,0 +1,69 @@
+#!/usr/sbin/dtrace -ws
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Destructive actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ * SECTION: dtrace(1M) Utility/ -w option
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ panic();
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d
new file mode 100644
index 00000000..e4fe06b6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d
@@ -0,0 +1,68 @@
+#!/usr/sbin/dtrace -ws
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Destructive actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ * SECTION: dtrace(1M) Utility/ -w option
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ raise(9);
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithStop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithStop.d
new file mode 100644
index 00000000..468e8f20
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_ACT_SPEC.SpeculateWithStop.d
@@ -0,0 +1,68 @@
+#!/usr/sbin/dtrace -ws
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Destructive actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ * SECTION: dtrace(1M) Utility/ -w option
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ stop();
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_COMM.AggAftCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_COMM.AggAftCommit.d
new file mode 100644
index 00000000..89a15c03
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_COMM.AggAftCommit.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * A clause cannot contain a commit() followed by an aggregating action.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation;
+ */
+
+BEGIN
+{
+ commit(1);
+ @a["foo"] = count();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d
new file mode 100644
index 00000000..a7635434
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Aggregating actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @avrg["speculate"] = avg(i);
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithCount.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithCount.d
new file mode 100644
index 00000000..57d0d03c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithCount.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Aggregating functions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @counts["speculate"] = count();
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d
new file mode 100644
index 00000000..90a899d2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Aggregating functions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+syscall:::entry
+{
+ self->ts = timestamp;
+}
+
+syscall:::return
+/self->ts/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @Lqauntus[execname] = lquantize(timestamp - self->ts, 0, 100, 1);
+ i++;
+}
+
+syscall:::
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMax.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMax.d
new file mode 100644
index 00000000..a10fff1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMax.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Aggregating functions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @Maximus["speculate"] = max(i);
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMin.d
new file mode 100644
index 00000000..4ad8dee3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithMin.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Aggregating functions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @Minimus["speculate"] = min(i);
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d
new file mode 100644
index 00000000..38e816ec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Aggregating functions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+syscall:::entry
+{
+ self->ts = timestamp;
+}
+
+syscall:::return
+/self->ts/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @Qauntus[execname] = quantize(timestamp - self->ts);
+ i++;
+}
+
+syscall:::
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithStddev.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithStddev.d
new file mode 100644
index 00000000..22953c2a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithStddev.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Aggregating actions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @sdev["speculate"] = stddev(i);
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithSum.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithSum.d
new file mode 100644
index 00000000..620a0768
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithSum.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Aggregating functions may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+profile:::tick-1sec
+/i < 1/
+{
+ var = speculation();
+ speculate(var);
+ printf("Speculation ID: %d", var);
+ @sums["speculate"] = sum(i);
+ i++;
+}
+
+profile:::tick-1sec
+/1 == i/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.CommitAftCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.CommitAftCommit.d
new file mode 100644
index 00000000..ebc316a9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.CommitAftCommit.d
@@ -0,0 +1,82 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * A clause cannot contain multiple commit() calls to same buffer.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation;
+ * Options and Tunables/cleanrate
+ */
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+
+BEGIN
+{
+ self->i = 0;
+ var1 = 0;
+}
+
+profile:::tick-1sec
+/!var1/
+{
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+}
+
+profile:::tick-1sec
+/var1/
+{
+ speculate(var1);
+ printf("Speculating on id: %d\n", var1);
+ self->i++;
+}
+
+profile:::tick-1sec
+/(!self->i)/
+{
+}
+
+profile:::tick-1sec
+/(self->i)/
+{
+ commit(var1);
+ commit(var1);
+ exit(0);
+}
+
+END
+{
+ printf("Succesfully commited both buffers");
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.DisjointCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.DisjointCommit.d
new file mode 100644
index 00000000..e482d07e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_COMM.DisjointCommit.d
@@ -0,0 +1,102 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * A clause cannot contain multiple commit() calls to disjoint buffers.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation;
+ * Options and Tunables/cleanrate
+ */
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+
+BEGIN
+{
+ self->i = 0;
+ self->j = 0;
+ self->commit = 0;
+ var1 = 0;
+ var2 = 0;
+}
+
+BEGIN
+{
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+}
+
+BEGIN
+{
+ var2 = speculation();
+ printf("Speculation ID: %d\n", var2);
+}
+
+BEGIN
+/var1/
+{
+ speculate(var1);
+ printf("Speculating on id: %d\n", var1);
+ self->i++;
+}
+
+BEGIN
+/var2/
+{
+ speculate(var2);
+ printf("Speculating on id: %d", var2);
+ self->j++;
+
+}
+
+BEGIN
+/(self->i) && (self->j)/
+{
+ commit(var1);
+ commit(var2);
+ self->commit++;
+}
+
+BEGIN
+/self->commit/
+{
+ printf("Succesfully commited both buffers");
+ exit(0);
+}
+
+BEGIN
+/!self->commit/
+{
+ printf("Couldnt commit both buffers");
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_DREC.CommitAftDataRec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_DREC.CommitAftDataRec.d
new file mode 100644
index 00000000..268b68fb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_COMM_DREC.CommitAftDataRec.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Commit may not follow data recording actions.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+ exit(0);
+}
+
+END
+{
+ printf("This test shouldnt have compiled\n");
+ commit(self->spec);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.DataRecAftCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.DataRecAftCommit.d
new file mode 100644
index 00000000..75560d83
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.DataRecAftCommit.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Data recording actions may not follow commit.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation;
+ * Options and Tunables/cleanrate
+ *
+ */
+#pragma D option quiet
+#pragma D option cleanrate=2000hz
+
+BEGIN
+{
+ self->speculateFlag = 0;
+}
+
+syscall:::entry
+{
+ self->spec = speculation();
+}
+
+syscall:::
+/self->spec/
+{
+ speculate(self->spec);
+ printf("Called speculate with id: %d\n", self->spec);
+ self->speculateFlag++;
+}
+
+syscall:::
+/(self->spec) && (self->speculateFlag)/
+{
+ commit(self->spec);
+ printf("Data recording after commit\n");
+}
+
+END
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.ExitAfterCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.ExitAfterCommit.d
new file mode 100644
index 00000000..c190740b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_DREC_COMM.ExitAfterCommit.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Exit after commit should throw a D_DREC_COMM.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ self->i = 0;
+ self->spec = speculation();
+}
+
+BEGIN
+/self->spec/
+{
+ speculate(self->spec);
+ self->i++;
+ printf("self->i: %d\n", self->i);
+}
+
+BEGIN
+/self->i/
+{
+ commit(self->spec);
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_EXIT_SPEC.ExitAftSpec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_EXIT_SPEC.ExitAftSpec.d
new file mode 100644
index 00000000..70964f91
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_EXIT_SPEC.ExitAftSpec.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Exit action may never be speculative.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+BEGIN
+{
+ i = 0;
+}
+
+syscall:::entry
+{
+ self->spec = speculation();
+}
+
+syscall:::
+/self->spec/
+{
+ speculate(self->spec);
+ i++;
+ printf("i: %d\n", i);
+ exit(0);
+}
+
+syscall:::
+/1 == i/
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_MALFORM.NspecExpr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_MALFORM.NspecExpr.d
new file mode 100644
index 00000000..91168e30
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_MALFORM.NspecExpr.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using an expression in the pragma for nspec throws a D_PRAGMA_MALFORM
+ * error.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/nspec
+ *
+ */
+
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+#pragma D option nspec=24 * 44
+
+BEGIN
+{
+ var1 = 0;
+ var2 = 0;
+ var3 = 0;
+}
+
+BEGIN
+{
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+ var2 = speculation();
+ printf("Speculation ID: %d\n", var2);
+ var3 = speculation();
+ printf("Speculation ID: %d\n", var3);
+}
+
+BEGIN
+/var1 && var2 && (!var3)/
+{
+ printf("Succesfully got two speculative buffers");
+ exit(0);
+}
+
+BEGIN
+/(!var1) || (!var2) || var3/
+{
+ printf("Test failed");
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.HugeNspecValue.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.HugeNspecValue.d
new file mode 100644
index 00000000..d13132ef
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.HugeNspecValue.d
@@ -0,0 +1,76 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Setting the nspec option to a huge integer throws a D_PRAGMA_OPTSET error.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/nspec
+ *
+ */
+
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+#pragma D option nspec=245566729809009887663
+
+BEGIN
+{
+ var1 = 0;
+ var2 = 0;
+ var3 = 0;
+}
+
+BEGIN
+{
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+ var2 = speculation();
+ printf("Speculation ID: %d\n", var2);
+ var3 = speculation();
+ printf("Speculation ID: %d\n", var3);
+}
+
+BEGIN
+/var1 && var2 && (!var3)/
+{
+ printf("Succesfully got two speculative buffers");
+ exit(0);
+}
+
+BEGIN
+/(!var1) || (!var2) || var3/
+{
+ printf("Test failed");
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.InvalidSpecSize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.InvalidSpecSize.d
new file mode 100644
index 00000000..d957f678
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.InvalidSpecSize.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Setting the specsize option to an illegal value throws the compiler error
+ * D_PRAGMA_OPTSET.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ */
+
+#pragma D option quiet
+#pragma D option specsize=1b
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+ exit(0);
+}
+
+END
+{
+ printf("This shouldnt have compiled\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.NegSpecSize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.NegSpecSize.d
new file mode 100644
index 00000000..c5fa9f50
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PRAGMA_OPTSET.NegSpecSize.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * ASSERTION:
+ * Verify the behavior of speculations with changes in specsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ */
+
+#pragma D option quiet
+#pragma D option specsize=-40
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PROTO_LEN.SpecNoId.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PROTO_LEN.SpecNoId.d
new file mode 100644
index 00000000..65d53ba6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_PROTO_LEN.SpecNoId.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * An identifier returned from speculation must be passed to the speculate()
+ * function.
+ *
+ * SECTION: Speculative Tracing/Creating a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ var = speculation();
+ printf("Speculation ID: %d", var);
+ self->i = 0;
+}
+
+profile:::tick-1sec
+{
+ speculate();
+ self->i++;
+}
+
+profile:::tick-1sec
+/1 <= self->i/
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_COMM.SpecAftCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_COMM.SpecAftCommit.d
new file mode 100644
index 00000000..ec4b22b8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_COMM.SpecAftCommit.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * A clause cannot contain a speculate after a commit.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation;
+ * Options and Tunables/cleanrate
+ *
+ */
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+
+BEGIN
+{
+ self->i = 0;
+ var1 = 0;
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+}
+
+profile:::tick-1sec
+/var1/
+{
+ speculate(var1);
+ printf("Speculating on id: %d\n", var1);
+ self->i++;
+}
+
+profile:::tick-1sec
+/(!self->i)/
+{
+}
+
+profile:::tick-1sec
+/(self->i)/
+{
+ commit(var1);
+ speculate(var1);
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_DREC.SpecAftDataRec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_DREC.SpecAftDataRec.d
new file mode 100644
index 00000000..80f1fdd2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_DREC.SpecAftDataRec.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * speculate() may not follow data recording actions.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+BEGIN
+{
+ i = 0;
+}
+
+syscall:::entry
+{
+ self->spec = speculation();
+}
+
+syscall:::
+/self->spec/
+{
+ printf("Entering syscall clause\n");
+ speculate(self->spec);
+ i++;
+ printf("i: %d\n", i);
+}
+
+syscall:::
+/1 == i/
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_SPEC.SpecAftSpec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_SPEC.SpecAftSpec.d
new file mode 100644
index 00000000..67af53b9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.D_SPEC_SPEC.SpecAftSpec.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * A clause can contain only one speculate() call.
+ *
+ * SECTION: Speculative Tracing/Using a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ self->i = 0;
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+ var2 = speculation();
+ printf("Speculation ID: %d\n", var2);
+}
+
+profile:::tick-1sec
+{
+ speculate(var1);
+ printf("Speculating on id: %d\n", var1);
+ speculate(var2);
+ printf("Speculating on id: %d", var2);
+ self->i++;
+
+}
+
+profile:::tick-1sec
+/1 > self->i/
+{
+ exit(0);
+}
+
+END
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeBufSize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeBufSize.d
new file mode 100644
index 00000000..7d2f4b36
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeBufSize.d
@@ -0,0 +1,88 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify the behavior of variations in bufsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/bufsize
+ *
+ * NOTES: This test behaves differently depending on the values
+ * assigned to bufsize.
+ * 1. 0 > bufsize.
+ * 2. 0 == bufsize.
+ * 3. 0 < bufsize <= 7
+ * 4. 8 <= bufsize <= 31
+ * 5. 32 <= bufsize <= 47
+ * 6. 48 <= bufsize <= 71
+ * 7. 72 <= bufsize
+ */
+
+#pragma D option quiet
+#pragma D option bufsize=-72
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeNspec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeNspec.d
new file mode 100644
index 00000000..9e1d063d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeNspec.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using a negative value for nspec throws a compiler error.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/nspec
+ */
+
+#pragma D option quiet
+#pragma D option nspec=-72
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+ printf("This test shouldnt have compiled\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeSpecSize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeSpecSize.d
new file mode 100644
index 00000000..233257a4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.NegativeSpecSize.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Setting the specsize to a negative number should throw a compiler error.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ * NOTES: Why dont we have an error tag for this error?
+ */
+
+#pragma D option quiet
+#pragma D option specsize=-10
+
+BEGIN
+{
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations1.d
new file mode 100644
index 00000000..c42029c3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations1.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * ASSERTION:
+ * Verify the behavior of variations in specsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ */
+
+#pragma D option quiet
+#pragma D option specsize=2
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations2.d
new file mode 100644
index 00000000..8a572807
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/err.SpecSizeVariations2.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * ASSERTION:
+ * Verify the behavior of variations in specsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ */
+
+#pragma D option quiet
+#pragma D option specsize=0
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitAfterDiscard.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitAfterDiscard.d
new file mode 100644
index 00000000..a874ab5b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitAfterDiscard.d
@@ -0,0 +1,86 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Call to commit() on a buffer after it has been discarded is silently
+ * ignored.
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation;
+ * Options and Tunables/cleanrate
+ *
+ */
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+
+BEGIN
+{
+ self->i = 0;
+ self->commit = 0;
+ self->discard = 0;
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+}
+
+BEGIN
+/var1/
+{
+ speculate(var1);
+ printf("This statement and the following are speculative!!\n");
+ printf("Speculating on id: %d\n", var1);
+ self->i++;
+}
+
+BEGIN
+/(self->i)/
+{
+ discard(var1);
+ self->discard++;
+ commit(var1);
+ self->commit++;
+}
+
+BEGIN
+/self->commit/
+{
+ printf("Commited a discarded buffer\n");
+ exit(0);
+}
+
+
+BEGIN
+/!self->commit/
+{
+ printf("Couldnt commit a discarded buffer\n");
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitWithZero.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitWithZero.d
new file mode 100644
index 00000000..647552fb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.CommitWithZero.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: An Id of zero though invalid may be passed to speculate(),
+ * commit() and discard() without any ill effects.
+ *
+ * SECTION: Speculative Tracing/Creating a Speculation;
+ * Options and Tunables/cleanrate
+ */
+#pragma D option quiet
+#pragma D option cleanrate=4000hz
+
+BEGIN
+{
+ self->commitFlag = 0;
+ self->var1 = speculation();
+ printf("Speculative buffer ID: %d\n", self->var1);
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/0 < self->commitFlag/
+{
+ printf("commit(), self->commitFlag = %d\n", self->commitFlag);
+ exit(0);
+}
+
+BEGIN
+/0 == self->commitFlag/
+{
+ printf("commit(), self->commitFlag = %d\n", self->commitFlag);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DataRecAftDiscard.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DataRecAftDiscard.d
new file mode 100644
index 00000000..03ae1b5f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DataRecAftDiscard.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Data recording actions may follow discard.
+ *
+ * SECTION: Speculative Tracing/Discarding a Speculation;
+ * Options and Tunables/cleanrate
+ */
+#pragma D option quiet
+#pragma D option cleanrate=2000hz
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->discardFlag = 0;
+ self->spec = speculation();
+}
+
+BEGIN
+/self->spec/
+{
+ speculate(self->spec);
+ printf("Called speculate with id: %d\n", self->spec);
+ self->speculateFlag++;
+}
+
+BEGIN
+/(self->spec) && (self->speculateFlag)/
+{
+ discard(self->spec);
+ self->discardFlag++;
+ printf("Data recording after discard\n");
+}
+
+BEGIN
+/self->discardFlag/
+{
+ exit(0);
+}
+
+BEGIN
+/!self->discardFlag/
+{
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftCommit.d
new file mode 100644
index 00000000..25fcfc54
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftCommit.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Can call discard() on a buffer after it has been commited.
+ *
+ * SECTION: Speculative Tracing/Discarding a Speculation;
+ * Options and Tunables/cleanrate
+ *
+ */
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+
+BEGIN
+{
+ self->i = 0;
+ self->commit = 0;
+ self->discard = 0;
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+}
+
+BEGIN
+/var1/
+{
+ speculate(var1);
+ printf("This statement and the following are speculative!!\n");
+ printf("Speculating on id: %d\n", var1);
+ self->i++;
+}
+
+BEGIN
+/(self->i)/
+{
+ commit(var1);
+ self->commit++;
+ discard(var1);
+ self->discard++;
+}
+
+BEGIN
+/self->discard/
+{
+ printf("Discarded a commited buffer\n");
+ exit(0);
+}
+
+
+BEGIN
+/!self->discard/
+{
+ printf("Couldnt discard a commited buffer\n");
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDataRec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDataRec.d
new file mode 100644
index 00000000..d5c573f9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDataRec.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Discard may not follow data recording actions.
+ *
+ * SECTION: Speculative Tracing/Discarding a Speculation
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ printf("Can have data recording before discarding\n");
+ discard(self->spec);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDiscard.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDiscard.d
new file mode 100644
index 00000000..8c95cee7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardAftDiscard.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Can call discard on an already discarded buffer.
+ *
+ * SECTION: Speculative Tracing/Discarding a Speculation;
+ * Options and Tunables/cleanrate
+ *
+ */
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+
+BEGIN
+{
+ self->i = 0;
+ self->discard1 = 0;
+ self->discard2 = 0;
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+}
+
+BEGIN
+/var1/
+{
+ speculate(var1);
+ printf("This statement and the following are speculative!!\n");
+ printf("Speculating on id: %d\n", var1);
+ self->i++;
+}
+
+BEGIN
+/(self->i)/
+{
+ discard(var1);
+ self->discard1++;
+ discard(var1);
+ self->discard2++;
+}
+
+BEGIN
+/(self->discard2) && (self->discard1)/
+{
+ printf("Discarded a discarded buffer\n");
+ exit(0);
+}
+
+
+BEGIN
+/(!self->discard2) || (!self->discard1)/
+{
+ printf("Couldnt discard a discarded buffer\n");
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardWithZero.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardWithZero.d
new file mode 100644
index 00000000..1a785613
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.DiscardWithZero.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: An Id of zero though invalid may be passed to speculate(),
+ * commit() and discard() without any ill effects.
+ *
+ * SECTION: Speculative Tracing/Creating a Speculation;
+ * Options and Tunables/cleanrate
+ */
+#pragma D option quiet
+#pragma D option cleanrate=4000hz
+
+BEGIN
+{
+ self->discardFlag = 0;
+ self->var1 = speculation();
+ printf("Speculative buffer ID: %d\n", self->var1);
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+/0 == self->spec/
+{
+ discard(self->spec);
+ self->discardFlag++;
+}
+
+BEGIN
+/0 < self->discardFlag/
+{
+ printf("discard(), self->discardFlag = %d\n", self->discardFlag);
+ exit(0);
+}
+
+BEGIN
+/0 == self->discardFlag/
+{
+ printf("discard(), self->discardFlag = %d\n", self->discardFlag);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.ExitAftDiscard.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.ExitAftDiscard.d
new file mode 100644
index 00000000..f5bcd662
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.ExitAftDiscard.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Using exit after discard should work fine.
+ *
+ * SECTION: Speculative Tracing/Discarding a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ self->i = 0;
+ self->spec = speculation();
+}
+
+BEGIN
+/self->spec/
+{
+ speculate(self->spec);
+ self->i++;
+ printf("self->i: %d\n", self->i);
+}
+
+BEGIN
+/self->i/
+{
+ discard(self->spec);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.d
new file mode 100644
index 00000000..8fe3a19d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * The number of speculative buffers defaults to one. If no speculative buffer
+ * is available when speculation is called, an ID of zero is returned.
+ *
+ * SECTION: Speculative Tracing/Creating a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+syscall::open:entry
+/i < 2/
+{
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+ i++;
+}
+
+syscall:::
+/(2 == i) && (0 == self->spec)/
+{
+ printf("i: %d\tself->spec: %d", i, self->spec);
+ exit(0);
+}
+
+syscall:::
+/(2 == i) && (0 != self->spec)/
+{
+ printf("i: %d\tself->spec: %d", i, self->spec);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations1.d
new file mode 100644
index 00000000..17df6b54
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations1.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * ASSERTION:
+ * Verify the behavior of speculations with changes in specsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ */
+
+#pragma D option quiet
+#pragma D option specsize=8
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(1);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations2.d
new file mode 100644
index 00000000..bcd2f2ea
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations2.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * ASSERTION:
+ * Verify the behavior of speculations with changes in specsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ */
+
+#pragma D option quiet
+#pragma D option specsize=10
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(1);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d
new file mode 100644
index 00000000..6b91efd9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * ASSERTION:
+ * Verify the behavior of speculations with changes in specsize.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/specsize
+ *
+ */
+
+#pragma D option quiet
+#pragma D option specsize=40
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->commitFlag = 0;
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ printf("Lots of data\n");
+ printf("Has to be crammed into this buffer\n");
+ printf("Until it overflows\n");
+ printf("And causes flops\n");
+ self->speculateFlag++;
+
+}
+
+BEGIN
+/1 <= self->speculateFlag/
+{
+ commit(self->spec);
+ self->commitFlag++;
+}
+
+BEGIN
+/1 <= self->commitFlag/
+{
+ printf("Statement was executed\n");
+ exit(0);
+}
+
+BEGIN
+/1 > self->commitFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculateWithRandom.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculateWithRandom.d
new file mode 100644
index 00000000..24f1ff4b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculateWithRandom.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When speculate() is called with an inactive buffer number, it is
+ * ignored.
+ *
+ * SECTION: Speculative Tracing/Creating a Speculation
+ *
+ */
+#pragma D option quiet
+BEGIN
+{
+ self->i = 0;
+}
+
+BEGIN
+{
+ speculate(3456710);
+ self->i++;
+ printf("self->i: %d\n", self->i);
+
+}
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationCommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationCommit.d
new file mode 100644
index 00000000..744ba676
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationCommit.d
@@ -0,0 +1,75 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test the normal behavior of speculate() and commit().
+ *
+ * SECTION: Speculative Tracing/Committing a Speculation;
+ * Actions and Subroutines/speculation();
+ * Options and Tunables/cleanrate
+ *
+ */
+#pragma D option quiet
+#pragma D option cleanrate=2000hz
+
+BEGIN
+{
+ self->var = speculation();
+ printf("Speculation ID: %d\n", self->var);
+ self->speculate = 0;
+ self->commit = 0;
+}
+
+BEGIN
+/1 > self->speculate/
+{
+ speculate(self->var);
+ self->speculate++;
+ printf("Called speculate on id: %d\n", self->var);
+}
+
+BEGIN
+/1 <= self->speculate/
+{
+ commit(self->var);
+ self->commit++;
+}
+
+BEGIN
+/(1 == self->commit)/
+{
+ printf("Succesfully tested buffer commit\n");
+ exit(0);
+}
+
+BEGIN
+/(0 == self->commit)/
+{
+ printf("Failed to commit buffer\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationDiscard.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationDiscard.d
new file mode 100644
index 00000000..4ac0e236
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationDiscard.d
@@ -0,0 +1,74 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test the normal behavior of speculate() and discard().
+ *
+ * SECTION: Speculative Tracing/Discarding a Speculation;
+ * Options and Tunables/cleanrate
+ *
+ */
+#pragma D option quiet
+#pragma D option cleanrate=2000hz
+
+BEGIN
+{
+ self->var = speculation();
+ printf("Speculation ID: %d\n", self->var);
+ self->speculate = 0;
+ self->discard = 0;
+}
+
+BEGIN
+/1 > self->speculate/
+{
+ speculate(self->var);
+ self->speculate++;
+ printf("Called speculate on id: %d\n", self->var);
+}
+
+BEGIN
+/1 <= self->speculate/
+{
+ discard(self->var);
+ self->discard++;
+}
+
+BEGIN
+/(1 == self->discard)/
+{
+ printf("Succesfully tested buffer discard\n");
+ exit(0);
+}
+
+BEGIN
+/(0 == self->discard)/
+{
+ printf("Failed to discard buffer\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationID.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationID.d
new file mode 100644
index 00000000..b2e3678a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationID.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * The speculation() function returns a speculative identifier when a
+ * speculative buffer is available.
+ *
+ * SECTION: Speculative Tracing/Creating a Speculation
+ *
+ */
+#pragma D option quiet
+
+BEGIN
+{
+ var = speculation();
+ printf("Speculation ID: %d", var);
+ exit(0);
+}
+
+END
+/0 == var/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationWithZero.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationWithZero.d
new file mode 100644
index 00000000..76600dba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.SpeculationWithZero.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Calling speculate() with zero does not have any ill effects.
+ * Statement after speculate does not execute.
+ *
+ * SECTION: Speculative Tracing/Creating a Speculation
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ self->speculateFlag = 0;
+ self->spec = speculation();
+ self->spec = speculation();
+ printf("Speculative buffer ID: %d\n", self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+ self->speculateFlag++;
+}
+
+BEGIN
+/1 == self->speculateFlag/
+{
+ printf("Statement was executed\n");
+ exit(1);
+}
+
+BEGIN
+/1 != self->speculateFlag/
+{
+ printf("Statement wasn't executed\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.TwoSpecBuffers.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.TwoSpecBuffers.d
new file mode 100644
index 00000000..8016b200
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.TwoSpecBuffers.d
@@ -0,0 +1,77 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Increasing the value of nspec to two should will increase the number of
+ * speculative buffers to two.
+ *
+ * SECTION: Speculative Tracing/Options and Tuning;
+ * Options and Tunables/nspec
+ *
+ */
+
+#pragma D option quiet
+#pragma D option cleanrate=3000hz
+#pragma D option nspec=2
+
+BEGIN
+{
+ var1 = 0;
+ var2 = 0;
+ var3 = 0;
+}
+
+BEGIN
+{
+ var1 = speculation();
+ printf("Speculation ID: %d\n", var1);
+ var2 = speculation();
+ printf("Speculation ID: %d\n", var2);
+ var3 = speculation();
+ printf("Speculation ID: %d\n", var3);
+}
+
+BEGIN
+/var1 && var2 && (!var3)/
+{
+ printf("Succesfully got two speculative buffers");
+ exit(0);
+}
+
+BEGIN
+/(!var1) || (!var2) || var3/
+{
+ printf("Test failed");
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negcommit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negcommit.d
new file mode 100644
index 00000000..cf17c71e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negcommit.d
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ commit(-1);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negspec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negspec.d
new file mode 100644
index 00000000..72965c7d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.negspec.d
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+BEGIN
+{
+ speculate(-1);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.zerosize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.zerosize.d
new file mode 100644
index 00000000..a4b40014
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/speculation/tst.zerosize.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option destructive
+
+BEGIN
+{
+ self->spec = speculation();
+ speculate(self->spec);
+}
+
+BEGIN
+{
+ this->one = 1;
+ this->two = 2;
+ chill(1);
+ speculate(self->spec);
+}
+
+BEGIN
+{
+ speculate(self->spec);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/err.D_ATTR_MIN.MinAttributes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/err.D_ATTR_MIN.MinAttributes.d
new file mode 100644
index 00000000..99fcede7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stability/err.D_ATTR_MIN.MinAttributes.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: If a program has a set of attributes less than the predefined
+ * minimum a D_ATTR_MIN is thrown
+ *
+ * SECTION: Stability/Stability Enforcement
+ * SECTION: Errtags/D_ATTR_MIN
+ *
+ */
+
+#pragma D option quiet
+#pragma D option amin=Evolving/Evolving/Common
+
+BEGIN
+{
+ trace(curthread->t_procp);
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_PROTO.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_PROTO.bad.d
new file mode 100644
index 00000000..0af06e6c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_PROTO.bad.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * stack() accepts one argument
+ *
+ * SECTION: Actions and Subroutines/stack()
+ *
+ */
+
+
+BEGIN
+{
+ stack(1, 2);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_SIZE.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_SIZE.d
new file mode 100644
index 00000000..8344e5c2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_STACK_SIZE.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test stack() with an invalid argument.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ stack("i'm not an integer constant");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_FRAMES.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_FRAMES.bad.d
new file mode 100644
index 00000000..bfd73763
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_FRAMES.bad.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * ustack() first argument must be a non-zero positive integer constant
+ *
+ * SECTION: User Process Tracing/ustack();
+ * Actions and Subroutines/ustack()
+ *
+ */
+
+
+BEGIN
+{
+ ustack(0, 200);
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_PROTO.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_PROTO.bad.d
new file mode 100644
index 00000000..5360d982
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_PROTO.bad.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * ustack() accepts two arguments
+ *
+ * SECTION: User Process Tracing/ustack();
+ * Actions and Subroutines/ustack()
+ *
+ */
+
+
+BEGIN
+{
+ ustack(1, 10, "badarg");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_STRSIZE.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_STRSIZE.bad.d
new file mode 100644
index 00000000..4c89ed5d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/err.D_USTACK_STRSIZE.bad.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * ustack() second argument must be a positive integer constant.
+ *
+ * SECTION: User Process Tracing/ustack();
+ * Actions and Subroutines/ustack()
+ *
+ */
+
+
+BEGIN
+{
+ ustack(1, "badarg");
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/tst.default.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/tst.default.d
new file mode 100644
index 00000000..f7a4f06b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stack/tst.default.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the stack action with the default stack depth.
+ *
+ * SECTION: Output Formatting/printf()
+ *
+ */
+
+BEGIN
+{
+ stack();
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/tst.default.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/tst.default.d
new file mode 100644
index 00000000..c37380d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stackdepth/tst.default.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the stackdepth variable.
+ *
+ * SECTION: Variables/Built-in Variables
+ *
+ */
+
+BEGIN
+{
+ trace(stackdepth);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.c
new file mode 100644
index 00000000..28ce1b87
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.c
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ getpid();
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.d
new file mode 100644
index 00000000..dd5a4b99
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop1.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for stop
+ *
+ * SECTION: Actions and Subroutines/stop()
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the process to call getpid().
+ */
+ timeout = timestamp + 1000000000;
+ stopped = 0;
+}
+
+syscall::getpid:entry
+/pid == $1 && stopped == 1/
+{
+ trace("looks like it's still going");
+ exit(1);
+}
+
+syscall::getpid:entry
+/pid == $1 && stopped == 0/
+{
+ stop();
+ trace("stopped");
+ stopped = 1;
+ /*
+ * Wait for a quarter second before declaring victory.
+ */
+ timeout = timestamp + 1000000000 / 4;
+}
+
+profile:::tick-8
+/timestamp > timeout && stopped == 1/
+{
+ trace("looks like it really stopped");
+ exit(0);
+}
+
+profile:::tick-8
+/timestamp > timeout/
+{
+ trace("timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.c
new file mode 100644
index 00000000..28ce1b87
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.c
@@ -0,0 +1,37 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ getpid();
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.d
new file mode 100644
index 00000000..4c79cd84
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/stop/tst.stop2.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive test for stop
+ *
+ * SECTION: Actions and Subroutines/stop()
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ /*
+ * Wait no more than a second for the process to call getpid().
+ */
+ timeout = timestamp + 1000000000;
+ stopped = 0;
+}
+
+syscall::getpid:entry
+/pid == $1 && stopped == 1/
+{
+ trace("looks like it's still going");
+ exit(1);
+}
+
+syscall::getpid:return
+/pid == $1 && stopped == 0/
+{
+ stop();
+ trace("stopped");
+ stopped = 1;
+ /*
+ * Wait for a quarter second before declaring victory.
+ */
+ timeout = timestamp + 1000000000 / 4;
+}
+
+profile:::tick-8
+/timestamp > timeout && stopped == 1/
+{
+ trace("looks like it really stopped");
+ exit(0);
+}
+
+profile:::tick-8
+/timestamp > timeout/
+{
+ trace("timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/tst.strlen1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/tst.strlen1.d
new file mode 100644
index 00000000..7775395b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/strlen/tst.strlen1.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the strlen() subroutine.
+ *
+ * SECTION: Actions and Subroutines/strlen()
+ *
+ */
+
+BEGIN
+/strlen("I like DTrace") == 13/
+{
+ correct = 1;
+}
+
+BEGIN
+{
+ exit(correct ? 0 : 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_ADDROF_VAR.StructPointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_ADDROF_VAR.StructPointer.d
new file mode 100644
index 00000000..85e49fa0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_ADDROF_VAR.StructPointer.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Trying to access the members of a user defined struct by means of
+ * a pointer to it should throw a D_ADDROF_VAR compiler error.
+ *
+ * SECTION: Structs and Unions/Pointers to Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct record {
+ int position;
+ int content;
+
+};
+
+struct record var;
+struct record *ptr;
+BEGIN
+{
+
+ var.position = 1;
+ var.content = 'a';
+
+ ptr = &var;
+
+ printf("ptr->position: %d\tptr->content: %c\n",
+ ptr->position, ptr->content);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon.d
new file mode 100644
index 00000000..004e9019
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon.d
@@ -0,0 +1,74 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Combining multiple struct definitions in a single line should throw a
+ * compiler error.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+#pragma D option quiet
+
+struct superStruct {
+ int position;
+ char content;
+}
+
+struct record {
+ int position;
+ char content;
+}
+
+
+struct pirate {
+ int position;
+ char content;
+};
+
+struct superStruct super;
+struct record rec;
+struct pirate pir;
+
+BEGIN
+{
+ rec.content = 'a';
+ rec.position = 1;
+
+ pir.content = 'b';
+ pir.position = 2;
+
+ printf(
+ "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d",
+ rec.content, rec.position, pir.content, pir.position);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon1.d
new file mode 100644
index 00000000..1c403b67
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_COMBO.StructWithoutColon1.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Combining multiple struct definitions in a single line should throw a
+ * compiler error.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct record {
+ int position;
+ char content;
+};
+
+
+struct pirate {
+ int position;
+ char content;
+}
+
+struct record rec;
+struct pirate pir;
+
+BEGIN
+{
+ rec.content = 'a';
+ rec.position = 1;
+
+ pir.content = 'b';
+ pir.position = 2;
+
+ printf(
+ "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d",
+ rec.content, rec.position, pir.content, pir.position);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.circular.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.circular.d
new file mode 100644
index 00000000..dcbc8ee2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.circular.d
@@ -0,0 +1,66 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * A circular definition of structs (two structs defining each other as
+ * members) should throw an error at compile time.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+#pragma D option quiet
+
+
+struct record {
+ struct pirate p;
+ int position;
+ char content;
+};
+
+
+struct pirate {
+ struct record r;
+ int position;
+ char content;
+};
+
+struct record rec;
+struct pirate pir;
+
+BEGIN
+{
+ rec.position = 0;
+ rec.content = 'a';
+ printf("rec.position: %d\nrec.content: %c\n",
+ rec.position, rec.content);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order.d
new file mode 100644
index 00000000..932f4dc9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When two struct are defined such that one of them contains the other, the
+ * inner struct has to be defined first.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+#pragma D option quiet
+
+
+struct record {
+ struct pirate p;
+ int position;
+ char content;
+};
+
+struct pirate {
+ int position;
+ char content;
+};
+
+struct record rec;
+struct pirate pir;
+
+BEGIN
+{
+ rec.content = 'y';
+ rec.position = 2;
+
+ pir.content = 'z';
+ pir.position = 26;
+
+ printf(
+ "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d",
+ rec.content, rec.position, pir.content, pir.position);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order2.d
new file mode 100644
index 00000000..807b6186
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.order2.d
@@ -0,0 +1,108 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When struct definitions are nested inside one another, the inner struct
+ * should be defined before the outer one can declare it as a variable.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct InnerMore {
+ struct InnerMost IMost;
+ int dummy_More;
+};
+
+struct InnerMost {
+ int position;
+ char content;
+};
+
+struct Inner {
+ struct InnerMore IMore;
+ int dummy_More;
+};
+
+struct Outer {
+ struct Inner I;
+ int dummy_More;
+};
+
+struct OuterMore {
+ struct Outer O;
+ int dummy_More;
+};
+
+struct OuterMost {
+ struct OuterMore OMore;
+ int dummy_More;
+} OMost;
+
+
+BEGIN
+{
+
+ OMost.dummy_More = 0;
+ OMost.OMore.dummy_More = 1;
+ OMost.OMore.O.dummy_More = 2;
+ OMost.OMore.O.I.dummy_More = 3;
+ OMost.OMore.O.I.IMore.dummy_More = 4;
+ OMost.OMore.O.I.IMore.IMost.position = 5;
+ OMost.OMore.O.I.IMore.IMost.content = 'e';
+
+ printf("OMost.dummy_More: %d\nOMost.OMore.dummy_More: %d\n",
+ OMost.dummy_More, OMost.OMore.dummy_More);
+
+ printf("OMost.OMore.O.dummy_More: %d\nOMost.OMore.O.I.dummy_More: %d\n",
+ OMost.OMore.O.dummy_More, OMost.OMore.O.I.dummy_More);
+
+ printf("OMost.OMore.O.I.IMore.dummy_More:%d\n",
+ OMost.OMore.O.I.IMore.dummy_More);
+
+ printf("OMost.OMore.O.I.IMore.IMost.position: %d\n",
+ OMost.OMore.O.I.IMore.IMost.position);
+
+ printf("OMost.OMore.O.I.IMore.IMost.content: %c\n",
+ OMost.OMore.O.I.IMore.IMost.content);
+
+ exit(0);
+}
+
+END
+/(0 != OMost.dummy_More) || (1 != OMost.OMore.dummy_More)
+ (2 != OMost.OMore.O.dummy_More) || (3 != OMost.OMore.O.I.dummy_More)
+ (4 != OMost.OMore.O.I.IMore.dummy_More)
+ (5 != OMost.OMore.O.I.IMore.IMost.position)
+ ('e' != OMost.OMore.O.I.IMore.IMost.content)/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.recursive.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.recursive.d
new file mode 100644
index 00000000..011fbdd3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.recursive.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION: Recursive naming of structures should produce compiler error.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+#pragma D option quiet
+
+struct record {
+ struct record rec;
+ int position;
+ char content;
+};
+
+struct record r1;
+struct record r2;
+
+BEGIN
+{
+ r1.position = 1;
+ r1.content = 'a';
+
+ r2.position = 2;
+ r2.content = 'b';
+
+ printf("r1.position: %d\nr1.content: %c\n", r1.position, r1.content);
+ printf("r2.position: %d\nr2.content: %c\n", r2.position, r2.content);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.simple.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.simple.d
new file mode 100644
index 00000000..7fc54ff0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_INCOMPLETE.simple.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Declaring an inner struct within another struct and not defining it should
+ * throw a compiler error.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+#pragma D option quiet
+
+
+struct record {
+ struct pirate p;
+ int position;
+ char content;
+};
+
+
+struct record rec;
+
+BEGIN
+{
+ rec.position = 0;
+ rec.content = 'a';
+ printf("rec.position: %d\nrec.content: %c\n",
+ rec.position, rec.content);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_VOIDOBJ.baddec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_VOIDOBJ.baddec.d
new file mode 100644
index 00000000..bba126fe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_DECL_VOIDOBJ.baddec.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declaring void objects will result in a D_DECL_VOIDOBJ error
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct {
+ int trace();
+};
+
+BEGIN
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_PROTO_ARG.DupStructAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_PROTO_ARG.DupStructAssoc.d
new file mode 100644
index 00000000..0eea2d8d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/err.D_PROTO_ARG.DupStructAssoc.d
@@ -0,0 +1,80 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declaring an associative array with a struct to be its key type and trying to
+ * index with another struct having the same composition throws an error.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct record {
+ int position;
+ char content;
+};
+
+struct pirate {
+ int position;
+ char content;
+};
+
+struct record r1;
+struct record r2;
+struct pirate p1;
+struct pirate p2;
+
+BEGIN
+{
+ r1.position = 1;
+ r1.content = 'a';
+
+ r2.position = 2;
+ r2.content = 'b';
+
+ p1.position = 1;
+ p1.content = 'a';
+
+ p2.position = 2;
+ p2.content = 'b';
+
+ assoc_array[r1] = 1000;
+ assoc_array[r2] = 2000;
+ assoc_array[p1] = 3333;
+ assoc_array[p2] = 4444;
+
+ printf("assoc_array[r1]: %d\n", assoc_array[r1]);
+ printf("assoc_array[r2]: %d\n", assoc_array[r2]);
+ printf("assoc_array[p1]: %d\n", assoc_array[p1]);
+ printf("assoc_array[p2]: %d\n", assoc_array[p2]);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructAssoc.d
new file mode 100644
index 00000000..ead235da
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructAssoc.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When a struct is used as a key for an associative array, the key is formed
+ * by using the values of the members of the struct variable and not the
+ * address of the struct variable.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct record {
+ int position;
+ char content;
+};
+
+struct record r1;
+struct record r2;
+
+BEGIN
+{
+ r1.position = 1;
+ r1.content = 'a';
+
+ r2.position = 1;
+ r2.content = 'a';
+
+ assoc_array[r1] = 1000;
+ assoc_array[r2] = 2000;
+
+ printf("assoc_array[r1]: %d\n", assoc_array[r1]);
+ printf("assoc_array[r2]: %d\n", assoc_array[r2]);
+
+ exit(0);
+}
+
+END
+/assoc_array[r1] != assoc_array[r2]/
+{
+ printf("Error");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructDataTypes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructDataTypes.d
new file mode 100644
index 00000000..5cfdc325
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructDataTypes.d
@@ -0,0 +1,133 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Declaration of the different data types within a struct and
+ * their definitions in a later clause should work fine.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ * NOTES: The floats, doubles and strings have not been implemented yet.
+ * When they do, appropriate lines in the code below should be uncommented.
+ * Similarly, the lines with the kmem_flags pointer assignment should be
+ * uncommented when the issues pertaining to it are clarified.
+ *
+ */
+#pragma D option quiet
+
+struct record {
+ char new_char;
+ short new_short;
+ int new_int;
+ long new_long;
+ long long new_long_long;
+ int8_t new_int8;
+ int16_t new_int16;
+ int32_t new_int32;
+ int64_t new_int64;
+ intptr_t new_intptr;
+ uint8_t new_uint8;
+ uint16_t new_uint16;
+ uint32_t new_uint32;
+ uint64_t new_uint64;
+ uintptr_t new_uintptr;
+
+ /*
+ float new_float;
+ double new_double;
+ long double new_long_double;
+
+ string new_string;
+ */
+
+ struct {
+ char ch;
+ int in;
+ long lg;
+ } new_struct;
+
+ union {
+ char ch;
+ int in;
+ long lg;
+ } new_union;
+
+enum colors {
+ RED,
+ GREEN,
+ BLUE
+} new_enum;
+
+
+ int *pointer;
+} var;
+
+/*
+ var.pointer = &`kmem_flags;
+*/
+BEGIN
+{
+ var.new_char = 'c';
+ var.new_short = 10;
+ var.new_int = 100;
+ var.new_long = 1234567890;
+ var.new_long_long = 1234512345;
+ var.new_int8 = 'p';
+ var.new_int16 = 20;
+ var.new_int32 = 200;
+ var.new_int64 = 2000000;
+ var.new_intptr = 0x12345;
+ var.new_uint8 = 'q';
+ var.new_uint16 = 30;
+ var.new_uint32 = 300;
+ var.new_uint64 = 3000000;
+ var.new_uintptr = 0x67890;
+
+/* var.new_float = 1.23456;
+ var.new_double = 2.34567890;
+ var.new_long_double = 3.567890123;
+
+ var.new_string = "hello";
+*/
+
+/*
+ var.pointer = &`kmem_flags;
+*/
+
+ var.new_struct.ch = 'c';
+ var.new_struct.in = 4;
+ var.new_struct.lg = 4;
+
+ var.new_union.ch = 'd';
+ var.new_union.in = 5;
+ var.new_union.lg = 5;
+
+ this->var = var;
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructInside.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructInside.d
new file mode 100644
index 00000000..159accc4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.StructInside.d
@@ -0,0 +1,124 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify the nested behavior of structs.
+ *
+ * SECTION: Structs and Unions/Structs
+ *
+ */
+
+#pragma D option quiet
+
+struct InnerMost {
+ int position;
+ char content;
+};
+
+struct InnerMore {
+ struct InnerMost IMost;
+ int dummy_More;
+};
+
+struct Inner {
+ struct InnerMore IMore;
+ int dummy_More;
+};
+
+struct Outer {
+ struct Inner I;
+ int dummy_More;
+};
+
+struct OuterMore {
+ struct Outer O;
+ int dummy_More;
+};
+
+struct OuterMost {
+ struct OuterMore OMore;
+ int dummy_More;
+} OMost;
+
+struct OuterMost OMostCopy;
+
+BEGIN
+{
+
+ OMost.dummy_More = 0;
+ OMost.OMore.dummy_More = 1;
+ OMost.OMore.O.dummy_More = 2;
+ OMost.OMore.O.I.dummy_More = 3;
+ OMost.OMore.O.I.IMore.dummy_More = 4;
+ OMost.OMore.O.I.IMore.IMost.position = 5;
+ OMost.OMore.O.I.IMore.IMost.content = 'e';
+
+ printf("OMost.dummy_More: %d\nOMost.OMore.dummy_More: %d\n",
+ OMost.dummy_More, OMost.OMore.dummy_More);
+
+ printf("OMost.OMore.O.dummy_More: %d\n",
+ OMost.OMore.O.dummy_More);
+
+ printf("OMost.OMore.O.I.dummy_More: %d\n",
+ OMost.OMore.O.I.dummy_More);
+
+ printf("OMost.OMore.O.I.IMore.dummy_More:%d\n",
+ OMost.OMore.O.I.IMore.dummy_More);
+
+ printf("OMost.OMore.O.I.IMore.IMost.position: %d\n",
+ OMost.OMore.O.I.IMore.IMost.position);
+
+ printf("OMost.OMore.O.I.IMore.IMost.content: %c\n",
+ OMost.OMore.O.I.IMore.IMost.content);
+
+ OMostCopy = OMost;
+
+ exit(0);
+}
+
+END
+/(0 != OMost.dummy_More) || (1 != OMost.OMore.dummy_More) ||
+ (2 != OMost.OMore.O.dummy_More) || (3 != OMost.OMore.O.I.dummy_More) ||
+ (4 != OMost.OMore.O.I.IMore.dummy_More) ||
+ (5 != OMost.OMore.O.I.IMore.IMost.position) ||
+ ('e' != OMost.OMore.O.I.IMore.IMost.content)/
+{
+ exit(1);
+}
+
+END
+/(0 != OMostCopy.dummy_More) || (1 != OMostCopy.OMore.dummy_More) ||
+ (2 != OMostCopy.OMore.O.dummy_More) ||
+ (3 != OMostCopy.OMore.O.I.dummy_More) ||
+ (4 != OMostCopy.OMore.O.I.IMore.dummy_More) ||
+ (5 != OMostCopy.OMore.O.I.IMore.IMost.position) ||
+ ('e' != OMostCopy.OMore.O.I.IMore.IMost.content)/
+{
+ exit(2);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d
new file mode 100644
index 00000000..0a7e80e4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+struct foo {
+ int x;
+ char y;
+ short z;
+};
+
+this struct foo bar;
+long bignum;
+
+BEGIN
+{
+ this->bar.x = 1;
+ this->bar.y = ',';
+ this->bar.z = 1234;
+}
+
+BEGIN
+{
+ printf("Die %s%c %s.\n", this->bar.x == 1 ? "SystemTap" : "DTrace",
+ this->bar.y, this->bar.z == 1234 ? "Die" : "The");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d.out
new file mode 100644
index 00000000..c3fbf224
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/struct/tst.clauselocal.d.out
@@ -0,0 +1,2 @@
+Die SystemTap, Die.
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.c
new file mode 100644
index 00000000..209160bd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.c
@@ -0,0 +1,41 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdio.h>
+#include <sys/syscall.h>
+
+/*ARGSUSED*/
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ (void) syscall(SYS_mmap, NULL, 1, 2, 3, -1, 0x12345678);
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.d
new file mode 100644
index 00000000..8e473b46
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.args.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure we're correctly reporting arguments to syscall probes.
+ */
+
+#pragma D option quiet
+
+syscall::mmap*:entry
+/pid == $1 && arg0 == 0 && arg1 == 1 && arg2 == 2 && arg3 == 3 &&
+ (int)arg4 == -1 && arg5 == 0x12345678/
+{
+ exit(0);
+}
+
+tick-1s
+/i++ == 3/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.openret.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.openret.ksh
new file mode 100755
index 00000000..6469db77
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/syscall/tst.openret.ksh
@@ -0,0 +1,75 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+script() {
+ $dtrace -c 'cat shajirosan' -qs /dev/stdin <<EOF
+ syscall::open*:entry
+ /pid == \$target/
+ {
+ self->p = arg0;
+ }
+
+ syscall::open*:return
+ /self->p && copyinstr(self->p) == "shajirosan"/
+ {
+ self->err = 1;
+ self->p = 0;
+ }
+
+ syscall::open*:return
+ /self->err && (int)arg0 == -1 && (int)arg1 == -1/
+ {
+ exit(0);
+ }
+
+ syscall::open*:return
+ /self->err/
+ {
+ printf("a failed open(2) returned %d\n", (int)arg0);
+ exit(1);
+ }
+
+ syscall::open*:return
+ /self->p/
+ {
+ self->p = 0;
+ }
+EOF
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+script
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.c
new file mode 100644
index 00000000..1e7f957f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.c
@@ -0,0 +1,45 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <libsysevent.h>
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ sysevent_id_t id;
+
+ for (;;) {
+ if (sysevent_post_event("class_dtest", "subclass_dtest",
+ "vendor_dtest", "publisher_dtest", NULL, &id) != 0) {
+ (void) fprintf(stderr, "failed to post sysevent\n");
+ return (1);
+ }
+
+ sleep(1);
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.d
new file mode 100644
index 00000000..e547a261
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post.d
@@ -0,0 +1,88 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ $1 + 0; /* make sure pid is referenced */
+
+ /*
+ * Wait no more than a five seconds for the sysevent to be posted
+ */
+ timeout = timestamp + 5000000000;
+}
+
+sysevent:::post
+/args[0]->ec_name != NULL/
+{
+ printf("channel name is non-NULL (%s)\n",
+ args[0]->ec_name);
+ exit(1);
+}
+
+sysevent:::post
+/strstr(args[1]->se_publisher, "vendor_dtest") == NULL/
+{
+ printf("missing vendor name from publisher (%s)\n",
+ args[1]->se_publisher);
+ exit(1);
+}
+
+sysevent:::post
+/strstr(args[1]->se_publisher, "publisher_dtest") == NULL/
+{
+ printf("missing publisher name from publisher (%s)\n",
+ args[1]->se_publisher);
+ exit(1);
+}
+
+sysevent:::post
+/args[1]->se_class != "class_dtest"/
+{
+ printf("unexpected class name (%s)\n", args[1]->se_class);
+ exit(1);
+}
+
+sysevent:::post
+/args[1]->se_subclass != "subclass_dtest"/
+{
+ printf("unexpected subclass name (%s)\n", args[1]->se_subclass);
+ exit(1);
+}
+
+sysevent:::post
+{
+ exit(0);
+}
+
+profile:::tick-8
+/timestamp > timeout/
+{
+ printf("timed out\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c
new file mode 100644
index 00000000..4a452a7a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c
@@ -0,0 +1,49 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <libsysevent.h>
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ evchan_t *ch;
+
+ if (sysevent_evc_bind("channel_dtest", &ch,
+ EVCH_CREAT | EVCH_HOLD_PEND) != 0) {
+ (void) fprintf(stderr, "failed to bind to sysevent channel\n");
+ return (1);
+ }
+
+ for (;;) {
+ if (sysevent_evc_publish(ch, "class_dtest", "subclass_dtest",
+ "vendor_dtest", "publisher_dtest", NULL, EVCH_SLEEP) != 0) {
+ (void) sysevent_evc_unbind(ch);
+ (void) fprintf(stderr, "failed to publisth sysevent\n");
+ return (1);
+ }
+ sleep(1);
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.d
new file mode 100644
index 00000000..9d12e1ec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.d
@@ -0,0 +1,87 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ $1 + 0; /* make sure pid is referenced */
+
+ /*
+ * Wait no more than five seconds for the sysevent to be posted
+ */
+ timeout = timestamp + 5000000000;
+}
+
+sysevent:::post
+/args[0]->ec_name != "channel_dtest"/
+{
+ printf("unexpected channel name (%s)\n", args[0]->ec_name);
+ exit(1);
+}
+
+sysevent:::post
+/strstr(args[1]->se_publisher, "vendor_dtest") == NULL/
+{
+ printf("missing vendor name from publisher (%s)\n",
+ args[1]->se_publisher);
+ exit(1);
+}
+
+sysevent:::post
+/strstr(args[1]->se_publisher, "publisher_dtest") == NULL/
+{
+ printf("missing publisher name from publisher (%s)\n",
+ args[1]->se_publisher);
+ exit(1);
+}
+
+sysevent:::post
+/args[1]->se_class != "class_dtest"/
+{
+ printf("unexpected class name (%s)\n", args[1]->se_class);
+ exit(1);
+}
+
+sysevent:::post
+/args[1]->se_subclass != "subclass_dtest"/
+{
+ printf("unexpected subclass name (%s)\n", args[1]->se_subclass);
+ exit(1);
+}
+
+sysevent:::post
+{
+ exit(0);
+}
+
+profile:::tick-8
+/timestamp > timeout/
+{
+ printf("timed out\n");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZERO.tick.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZERO.tick.d
new file mode 100644
index 00000000..015ae2b0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZERO.tick.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Negative test; calls tick without valid value.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-n
+{
+ printf("This test is a simple tick-n negative test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonens.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonens.d
new file mode 100644
index 00000000..3ed28b1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonens.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call profile-'ns' less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1ns
+{
+ printf("Calls 'ns' less than 200 micro seconds\n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonensec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonensec.d
new file mode 100644
index 00000000..7b4df199
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROonensec.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call profile-1nsec; less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1nsec
+{
+ printf("Call profile-1nsec; less than 200 micro seconds\n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneus.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneus.d
new file mode 100644
index 00000000..6a64a3a2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneus.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Call profile-us; less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1us
+{
+ printf(" Calling profile-us less than 200 micro seconds should fail\n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneusec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneusec.d
new file mode 100644
index 00000000..b6b80bea
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/err.D_PDESC_ZEROoneusec.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * profile-usec; less than 200 micro seconds.
+ *
+ * SECTION: profile Provider/profile-n probes
+ *
+ */
+
+#pragma D option quiet
+
+profile-1usec
+{
+ printf("profile-usec; less than 200 micro seconds \n");
+ exit (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickarg0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickarg0.d
new file mode 100644
index 00000000..4dda358c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickarg0.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * Simple tick-n 'arg0' test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-1
+{
+ printf("The arg0 is %d\n", (int)arg0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d
new file mode 100644
index 00000000..602f3a91
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-ms simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-1ms
+{
+ printf("This test is a simple tick-ms provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d.out
new file mode 100644
index 00000000..1e267598
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickms.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-ms provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d
new file mode 100644
index 00000000..1cf3b742
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-msec simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-1msec
+{
+ printf("This test is a simple tick-msec provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d.out
new file mode 100644
index 00000000..286bb14b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickmsec.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-msec provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d
new file mode 100644
index 00000000..917139ca
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-ns simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-20000000ns
+{
+ printf("This test is a simple tick-ns provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d.out
new file mode 100644
index 00000000..26adddeb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickns.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-ns provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d
new file mode 100644
index 00000000..3eedead2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-nsec simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-20000000nsec
+{
+ printf("This test is a simple tick-nsec provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d.out
new file mode 100644
index 00000000..4ad77b58
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticknsec.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-nsec provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d
new file mode 100644
index 00000000..05f2657d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-1s simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-1s
+{
+ printf("This test is a simple tick-s provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d.out
new file mode 100644
index 00000000..b0631218
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticks.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-s provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d
new file mode 100644
index 00000000..703af4d5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-1sec simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-1sec
+{
+ printf("This test is a simple tick-sec provider test\n");
+}
+tick-1sec
+{
+ printf("This test is a simple tick-sec provider test");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d.out
new file mode 100644
index 00000000..d9d4f45a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.ticksec.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-sec provider test
+This test is a simple tick-sec provider test
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d
new file mode 100644
index 00000000..aa10cbb5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-2000us simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-2000us
+{
+ printf("This test is a simple tick-us provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d.out
new file mode 100644
index 00000000..00baa3dc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickus.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-us provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d
new file mode 100644
index 00000000..9deb8f4c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * tick-2000usec simple test.
+ *
+ * SECTION: profile Provider/tick-n probes
+ *
+ */
+
+
+#pragma D option quiet
+
+tick-2000usec
+{
+ printf("This test is a simple tick-usec provider test\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d.out
new file mode 100644
index 00000000..40987e32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tick-n/tst.tickusec.d.out
@@ -0,0 +1,2 @@
+This test is a simple tick-usec provider test
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_PROTO_LEN.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_PROTO_LEN.bad.d
new file mode 100644
index 00000000..a1ec95cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_PROTO_LEN.bad.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test trace() with no arguments.
+ *
+ * SECTION: Actions and Subroutines/trace()
+ */
+
+BEGIN
+{
+
+ trace();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_TRACE_VOID.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_TRACE_VOID.bad.d
new file mode 100644
index 00000000..eb9f194a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/err.D_TRACE_VOID.bad.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test an invalid specification of trace() with a void argument.
+ *
+ * SECTION: Actions and Subroutines/trace()
+ */
+
+BEGIN
+{
+ trace((void)`kmem_flags);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.misc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.misc.d
new file mode 100644
index 00000000..179d7602
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.misc.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test a variety of trace() action invocations.
+ *
+ * SECTION: Actions and Subroutines/trace();
+ * Output Formatting/trace()
+ *
+ * NOTES:
+ * We test things that exercise different kinds of DIFO return types
+ * to ensure each one can be traced.
+ */
+
+BEGIN
+{
+ i = 1;
+}
+
+
+tick-1
+/i != 5/
+{
+ trace("test trace"); /* DT_TYPE_STRING */
+ trace(12345); /* DT_TYPE_INT (constant) */
+ trace(x++); /* DT_TYPE_INT (derived) */
+ trace(timestamp); /* DT_TYPE_INT (variable) */
+ trace(`kmem_flags); /* CTF type (by value) */
+ trace(*`rootvp); /* CTF type (by ref) */
+ i++;
+}
+
+tick-1
+/i == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d
new file mode 100644
index 00000000..a81d147b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+/*
+ * ASSERTION:
+ * Positive trace tests - trace with strings, using quiet option
+ *
+ * SECTION: Actions and Subroutines/trace()
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace("this");
+ trace(" %should work.\n");
+ trace("%don't w%orry -- this won't cause a %segfault.\n");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d.out
new file mode 100644
index 00000000..908ffb2a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.qstring.d.out
@@ -0,0 +1,3 @@
+this %should work.
+%don't w%orry -- this won't cause a %segfault.
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.string.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.string.d
new file mode 100644
index 00000000..c5e7c2cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/trace/tst.string.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive trace tests - trace with strings
+ *
+ * SECTION: Actions and Subroutines/trace()
+ */
+
+BEGIN
+{
+ trace("this");
+ trace(" %should work.\n");
+ trace("%don't w%orry -- this won't cause a %segfault.\n");
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_ARG.badsize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_ARG.badsize.d
new file mode 100644
index 00000000..4e137cec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_ARG.badsize.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test tracemem() with an invalid size argument.
+ *
+ * SECTION: Actions and Subroutines/tracemem()
+ */
+
+BEGIN
+{
+ tracemem(123, "i'm a string");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toofew.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toofew.d
new file mode 100644
index 00000000..91c4f77b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toofew.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test tracemem() with too few arguments.
+ *
+ * SECTION: Actions and Subroutines/tracemem()
+ */
+
+
+BEGIN
+{
+ tracemem(123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toomany.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toomany.d
new file mode 100644
index 00000000..dfe8e4d2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toomany.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test tracemem() with too many arguments.
+ *
+ * SECTION: Actions and Subroutines/tracemem()
+ */
+
+BEGIN
+{
+ tracemem(123, 456, 789);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ADDR.badaddr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ADDR.badaddr.d
new file mode 100644
index 00000000..68145774
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ADDR.badaddr.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test tracemem() with an invalid address argument.
+ *
+ * SECTION: Actions and Subroutines/tracemem()
+ */
+
+BEGIN
+{
+ tracemem(`v, 123);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.negsize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.negsize.d
new file mode 100644
index 00000000..b3dd4381
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.negsize.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test tracemem() with a negative size argument.
+ *
+ * SECTION: Actions and Subroutines/tracemem()
+ */
+
+BEGIN
+{
+ tracemem(123, -456);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.zerosize.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.zerosize.d
new file mode 100644
index 00000000..595bfcc0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_SIZE.zerosize.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test tracemem() with a zero size argument.
+ *
+ * SECTION: Actions and Subroutines/tracemem()
+ */
+
+BEGIN
+{
+ tracemem(123, 0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/tst.rootvp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/tst.rootvp.d
new file mode 100644
index 00000000..afa1570d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/tracemem/tst.rootvp.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test tracemem() by tracing out the contents of the root vnode
+ * as a raw stream of bytes.
+ *
+ * SECTION: Actions and Subroutines/tracemem()
+ */
+
+
+BEGIN
+{
+ i = 1;
+}
+
+tick-1
+/i != 5/
+{
+ tracemem(`rootvp, 20);
+ i++;
+}
+
+tick-1
+/i == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_DECL_TYPERED.BadTransDecl.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_DECL_TYPERED.BadTransDecl.d
new file mode 100644
index 00000000..2a44778e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_DECL_TYPERED.BadTransDecl.d
@@ -0,0 +1,64 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator with the input type enclosed in
+ * between braces rather than angle brackets.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct
+{
+ struct input_struct *uvar
+}
+{
+ myi = ((struct input_struct *) uvar)->i;
+ myc = ((struct input_struct *) uvar)->c;
+}
+
+BEGIN
+{
+ printf("Using braces instead of angle brackets for translator input");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_OP_INCOMPLETE.NonExistentInput1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_OP_INCOMPLETE.NonExistentInput1.d
new file mode 100644
index 00000000..0c8c84d3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_OP_INCOMPLETE.NonExistentInput1.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator with a non-existent input type.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ */
+
+#pragma D option quiet
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct input_struct *ivar >
+{
+ myi = ((struct input_struct *) ivar)->nonexistentI;
+ myc = ((struct input_struct *) ivar)->nonexistentC;
+};
+
+BEGIN
+{
+ printf("Test the translation of a non existing input type");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl1.d
new file mode 100644
index 00000000..52e5c9ae
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl1.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator with the input type enclosed in
+ * between parantheses rather than angle brackets.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct ( struct input_struct *uvar )
+{
+ myi = ((struct input_struct *) uvar)->i;
+ myc = ((struct input_struct *) uvar)->c;
+}
+
+BEGIN
+{
+ printf("Test translator with input type in parantheses");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl3.d
new file mode 100644
index 00000000..6be8128a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl3.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator without enclosing braces { }.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct input_struct *uvar >
+ myi = ((struct input_struct *) uvar)->i;
+ myc = ((struct input_struct *) uvar)->c;
+;
+
+BEGIN
+{
+ printf("Test the translator definition without enclosing braces");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl4.d
new file mode 100644
index 00000000..926f74c7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_SYNTAX.BadTransDecl4.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator without terminating semi-colon (;).
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct input_struct *uvar >
+{
+ myi = ((struct input_struct *) uvar)->i;
+ myc = ((struct input_struct *) uvar)->c;
+}
+
+translator struct output_struct < struct new_struct *newvar >
+{
+};
+
+
+BEGIN
+{
+ printf("Test translator declaration without terminating semi-colon");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_TYPE_MEMBER.NonExistentInput2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_TYPE_MEMBER.NonExistentInput2.d
new file mode 100644
index 00000000..16deff89
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_TYPE_MEMBER.NonExistentInput2.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator with a non-existent member
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *ivar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct input_struct *ivar >
+{
+ myi = ((struct input_struct *) ivar)->i;
+ myc = ((struct input_struct *) ivar)->nonexistent;
+};
+
+BEGIN
+{
+ printf("Testing the assignment of a non-existent input member");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_INCOMPAT.BadInputType1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_INCOMPAT.BadInputType1.d
new file mode 100644
index 00000000..26cab458
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_INCOMPAT.BadInputType1.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator with a mismatch in types.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char *myc;
+};
+
+translator struct output_struct < struct input_struct *uvar >
+{
+ myi = ((struct input_struct *) uvar)->i;
+ myc = ((struct input_struct *) uvar)->c;
+};
+
+BEGIN
+{
+ printf("Translating against the rules of assignment operator");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_MEMB.NonExistentOutput2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_MEMB.NonExistentOutput2.d
new file mode 100644
index 00000000..6d6eba1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_MEMB.NonExistentOutput2.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator with a non-existent output member.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *ivar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct input_struct *ivar >
+{
+ myi = ((struct input_struct *) ivar)->i;
+ yourc = ((struct input_struct *) ivar)->nonexistent;
+};
+
+BEGIN
+{
+ printf("Testing translation with non existent output member");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_NONE.BadTransDecl6.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_NONE.BadTransDecl6.d
new file mode 100644
index 00000000..4cfabcea
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_NONE.BadTransDecl6.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When xlate is used on a variable for which no translation exists a
+ * D_XLATE_NONE is thrown
+ *
+ * SECTION: Translators/Translate Operator
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct myinput_struct {
+ int i;
+ char c;
+};
+
+struct myoutput_struct {
+ int myi;
+ char myc;
+};
+
+translator struct myoutput_struct < struct myinput_struct *ivar >
+{
+ myi = ((struct myinput_struct *) ivar)->i;
+ myc = ((struct myinput_struct *) ivar)->c;
+
+};
+
+struct myinput_struct f;
+BEGIN
+{
+ f.i = 10;
+ f.c = 'c';
+
+ xlate < struct myoutput_struct >(f)->myi;
+ printf("Translate operator used without correct translator decl\n");
+ exit(0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_REDECL.RepeatTransDecl.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_REDECL.RepeatTransDecl.d
new file mode 100644
index 00000000..62f8482e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_REDECL.RepeatTransDecl.d
@@ -0,0 +1,67 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Redeclaring the same translation twice throws a D_XLATE_REDECL error.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii1;
+ char ic1;
+} *ivar1;
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+
+translator struct output_struct < struct input_struct *ivar1 >
+{
+ oi = ((struct input_struct *) ivar1)->ii1;
+ oc = ((struct input_struct *) ivar1)->ic1;
+};
+
+translator struct output_struct < struct input_struct *ivar1 >
+{
+ oi = ((struct input_struct *) ivar1)->ii1;
+ oc = ((struct input_struct *) ivar1)->ic1;
+};
+
+
+BEGIN
+{
+ printf("Redeclaration of the same translation");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransDecl8.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransDecl8.d
new file mode 100644
index 00000000..63786c7d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransDecl8.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When the output type of the translator declaration is not a struct or
+ * union a D_XLATE_SOU is thrown.
+ *
+ * SECTION: Translators/Translator Declarations
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii;
+ char ic;
+};
+
+enum colors
+{
+ RED,
+ BLUE
+};
+
+translator enum colors < struct input_struct *ivar >
+{
+};
+
+BEGIN
+{
+ printf("Output type of translation is an enum");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransInt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransInt.d
new file mode 100644
index 00000000..65455697
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.BadTransInt.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When the output type of the translator declaration is not a struct or
+ * union a D_XLATE_SOU is thrown.
+ *
+ * SECTION: Translators/Translator Declarations
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii;
+ char ic;
+};
+
+translator int < struct input_struct *ivar >
+{
+};
+
+BEGIN
+{
+ printf("Output type of translation is an int");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.NonExistentOutput1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.NonExistentOutput1.d
new file mode 100644
index 00000000..1ebb94cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/err.D_XLATE_SOU.NonExistentOutput1.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator with a non-existent output type.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *ivar;
+
+translator struct output_struct < struct input_struct *ivar >
+{
+ myi = ((struct input_struct *) ivar)->i;
+ myc = ((struct input_struct *) ivar)->nonexistent;
+};
+
+BEGIN
+{
+ printf("Translation with non existent output type struct");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d
new file mode 100644
index 00000000..c664188f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * The D inline translation mechanism can be used to facilitate stable
+ * translations.
+ *
+ * SECTION: Translators/ Translator Declarations
+ * SECTION: Translators/ Translate Operator
+ * SECTION: Translators/Stable Translations
+ *
+ * NOTES: Uncomment the pragma that explicitly resets the attributes of
+ * myinfo identifier to Stable/Stable/Common from Private/Private/Unknown.
+ * Run the program with and without the comments as:
+ * /usr/sbin/dtrace -vs man.TestTransStability.d
+ */
+
+#pragma D option quiet
+
+inline lwpsinfo_t *myinfo = xlate < lwpsinfo_t *> (curthread);
+
+/*
+#pragma D attributes Stable/Stable/Common myinfo
+*/
+
+BEGIN
+{
+ trace(myinfo->pr_flag);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.CircularTransDecl.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.CircularTransDecl.d
new file mode 100644
index 00000000..58466f70
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.CircularTransDecl.d
@@ -0,0 +1,100 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test circular declaration of translations
+ *
+ * SECTION: Translators/ Translator Declarations
+ * SECTION: Translators/ Translate Operator
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+};
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct input_struct ivar >
+{
+ myi = ((struct input_struct ) ivar).i;
+ myc = ((struct input_struct ) ivar).c;
+};
+
+translator struct input_struct < struct output_struct uvar >
+{
+ i = ((struct output_struct ) uvar).myi;
+ c = ((struct output_struct ) uvar).myc;
+};
+
+struct input_struct f1;
+struct output_struct f2;
+
+BEGIN
+{
+ f1.i = 10;
+ f1.c = 'c';
+
+ f2.myi = 100;
+ f2.myc = 'd';
+
+ printf("Testing circular translations\n");
+ forwardi = xlate < struct output_struct > (f1).myi;
+ forwardc = xlate < struct output_struct > (f1).myc;
+ backwardi = xlate < struct input_struct > (f2).i;
+ backwardc = xlate < struct input_struct > (f2).c;
+
+ printf("forwardi: %d\tforwardc: %c\n", forwardi, forwardc);
+ printf("backwardi: %d\tbackwardc: %c", backwardi, backwardc);
+ exit(0);
+}
+
+BEGIN
+/(10 == forwardi) && ('c' == forwardc) && (100 == backwardi) &&
+ ('d' == backwardc)/
+{
+ exit(0);
+}
+
+BEGIN
+/(10 != forwardi) || ('c' != forwardc) || (100 != backwardi) ||
+ ('d' != backwardc)/
+{
+ exit(1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.EmptyTransDecl.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.EmptyTransDecl.d
new file mode 100644
index 00000000..5a292071
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.EmptyTransDecl.d
@@ -0,0 +1,79 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the empty declaration of a translator
+ *
+ * SECTION: Translators/ Translator Declarations
+ * SECTION: Translators/ Translate Operator
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct input_struct uvar >
+{
+};
+
+struct input_struct in;
+struct output_struct ou;
+
+BEGIN
+{
+ in.i = 10;
+ in.c = 'c';
+
+ ou = xlate < struct output_struct > (in);
+
+ printf("ou.myi: %d\tou.myc: %c\n", ou.myi, ou.myc);
+}
+
+BEGIN
+/(0 != ou.myi) || (0 != ou.myc)/
+{
+ printf("Failed\n");
+ exit(1);
+}
+
+BEGIN
+/(0 == ou.myi) || (0 == ou.myc)/
+{
+ printf("Passed\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ForwardTag.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ForwardTag.d
new file mode 100644
index 00000000..246a8d2b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ForwardTag.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a forward tag using a translator definition.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct callmewhatever *idontcare >
+{
+ myi = ((struct input_struct *) uvar)->i;
+ myc = ((struct input_struct *) uvar)->c;
+};
+
+BEGIN
+{
+ printf("This test defines a forward tag");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputAliasTrans.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputAliasTrans.d
new file mode 100644
index 00000000..a562b394
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputAliasTrans.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * The input type of the tranlator declaration is an alias.
+ *
+ * SECTION: Translators/ Translator Declarations.
+ *
+ */
+
+#pragma D option quiet
+
+typedef struct input_struct {
+ int ii;
+ char ic;
+} input_t;
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+
+translator struct output_struct < input_t *ivar >
+{
+ oi = ((input_t *) ivar)->ii;
+ oc = ((input_t *) ivar)->ic;
+};
+
+BEGIN
+{
+ printf("Input type is an alias");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputIntTrans.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputIntTrans.d
new file mode 100644
index 00000000..e5159ed6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.InputIntTrans.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of a translator the input type in the translator
+ * declaration being different from the values being assigned inside.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int i;
+ char c;
+} *uvar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < int idontcare >
+{
+ myi = ((struct input_struct *) uvar)->i;
+ myi = ((struct input_struct *) uvar)->c;
+};
+
+BEGIN
+{
+ printf("Input type to the translator decl is different from members");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d
new file mode 100644
index 00000000..cd471531
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * The output type is an alias.
+ *
+ * SECTION: Translators/ Translator Declarations.
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii;
+ char ic;
+};
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+typedef struct output_struct output_t;
+
+
+translator output_t < struct input_struct *ivar >
+{
+ oi = ((struct input_struct *) ivar)->ii;
+ oc = ((struct input_struct *) ivar)->ic;
+};
+
+BEGIN
+{
+ printf("Output type is an alias");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialDereferencing.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialDereferencing.d
new file mode 100644
index 00000000..ae532cc4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialDereferencing.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * If you dereference a single member of the translation input, then the
+ * compiler will generate the code corresponding to that member
+ *
+ * SECTION: Translators/ Translate Operator
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii;
+ char ic;
+};
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+
+translator struct output_struct < struct input_struct ivar >
+{
+ oi = ((struct input_struct) ivar).ii;
+ oc = ((struct input_struct) ivar).ic;
+};
+
+struct output_struct out;
+struct input_struct in;
+
+BEGIN
+{
+ in.ii = 100;
+ in.ic = 'z';
+
+ printf("Translating only a part of the input struct\n");
+ out.oi = xlate < struct output_struct > (in).oi;
+
+ printf("out.oi: %d\t out.oc: %d\n", out.oi, out.oc);
+}
+
+BEGIN
+/(100 != out.oi) || (0 != out.oc)/
+{
+ exit(1);
+}
+
+BEGIN
+/(100 == out.oi) && (0 == out.oc)/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialOutputTransDefn.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialOutputTransDefn.d
new file mode 100644
index 00000000..9be52a9f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.PartialOutputTransDefn.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * A translator declaration may omit expressions for one or more members
+ * of the output type
+ *
+ * SECTION: Translators/Translator Declarations;
+ * Translators/Translate Operator
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii;
+ char ic;
+};
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+
+translator struct output_struct < struct input_struct *ivar >
+{
+ oi = ((struct input_struct *) ivar)->ii;
+};
+
+BEGIN
+{
+ printf("Translating only a part of the input struct");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ProcModelTrans.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ProcModelTrans.d
new file mode 100644
index 00000000..ff313eca
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.ProcModelTrans.d
@@ -0,0 +1,53 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Use the translators in /usr/lib/dtrace/procfs.d
+ *
+ * SECTION: Translators/ Translator Declarations
+ * SECTION: Translators/ Translate Operator
+ * SECTION: Translators/Process Model Translators
+ *
+ */
+
+#pragma D option quiet
+
+proc_t *T;
+
+BEGIN
+{
+ mypr_addr = xlate < psinfo_t > (T).pr_addr;
+ printf("pr_addr: %d", mypr_addr);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.RepeatDeclaration.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.RepeatDeclaration.d
new file mode 100644
index 00000000..a928c3e2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.RepeatDeclaration.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Reassign the members of the output struct using another translator
+ * input struct.
+ *
+ * SECTION: Translators/Translator Declarations
+ */
+
+#pragma D option quiet
+
+struct input_struct1 {
+ int ii1;
+ char ic1;
+} *ivar1;
+
+struct input_struct2 {
+ long ii2;
+ long ic2;
+} *ivar2;
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+
+translator struct output_struct < struct input_struct1 *ivar1 >
+{
+ oi = ((struct input_struct1 *) ivar1)->ii1;
+ oc = ((struct input_struct1 *) ivar1)->ic1;
+};
+
+translator struct output_struct < struct input_struct2 *ivar2 >
+{
+ oi = ((struct input_struct2 *) ivar2)->ii2;
+ oc = ((struct input_struct2 *) ivar2)->ic2;
+};
+
+BEGIN
+{
+ printf("Reassignment of a struct's members with different input");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.SimultaneousTranslators.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.SimultaneousTranslators.d
new file mode 100644
index 00000000..63cd72ca
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.SimultaneousTranslators.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Assign the different members of the output of the translator using
+ * different translator declarations.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct1 {
+ int ii1;
+ char ic1;
+} *ivar1;
+
+struct input_struct2 {
+ int ii2;
+ char ic2;
+} *ivar2;
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+
+translator struct output_struct < struct input_struct1 *ivar1 >
+{
+ oi = ((struct input_struct1 *) ivar1)->ii1;
+};
+
+translator struct output_struct < struct input_struct2 *ivar2 >
+{
+ oc = ((struct input_struct2 *) ivar2)->ic2;
+};
+
+BEGIN
+{
+ printf("Translate members of output with different input structs");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.StructureAssignment.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.StructureAssignment.d
new file mode 100644
index 00000000..277d95fe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.StructureAssignment.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * If the entire output is copied by means of a structure assignment, any
+ * members for which no translation expressions are defined will be filled
+ * with zeroes.
+ *
+ * SECTION: Translators/ Translate Operator
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii;
+ char ic;
+};
+
+struct output_struct {
+ int oi;
+ char oc;
+};
+
+
+translator struct output_struct < struct input_struct ivar >
+{
+ oi = ((struct input_struct) ivar).ii;
+};
+
+struct output_struct out;
+struct input_struct in;
+
+BEGIN
+{
+ in.ii = 100;
+ in.ic = 'z';
+
+ printf("Translating via struct assignment\n");
+ out = xlate < struct output_struct > (in);
+
+ printf("out.oi: %d\t out.oc: %d\n", out.oi, out.oc);
+}
+
+BEGIN
+/(100 != out.oi) || (0 != out.oc)/
+{
+ exit(1);
+}
+
+BEGIN
+/(100 == out.oi) && (0 == out.oc)/
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransNonPointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransNonPointer.d
new file mode 100644
index 00000000..3ec81434
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransNonPointer.d
@@ -0,0 +1,84 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Translate the input expression to output struct type
+ *
+ * SECTION: Translators/ Translator Declarations
+ * SECTION: Translators/ Translate Operator
+ *
+ */
+
+#pragma D option quiet
+
+struct myinput_struct {
+ int i;
+ char c;
+};
+
+struct myoutput_struct {
+ int myi;
+ char myc;
+};
+
+translator struct myoutput_struct < struct myinput_struct ivar >
+{
+ myi = ((struct myinput_struct ) ivar).i;
+ myc = ((struct myinput_struct ) ivar).c;
+
+};
+
+struct myinput_struct f;
+BEGIN
+{
+ f.i = 10;
+ f.c = 'c';
+
+ realmyi = xlate < struct myoutput_struct > (f).myi;
+ realmyc = xlate < struct myoutput_struct > (f).myc;
+}
+
+BEGIN
+/(10 != f.i) || ('c' != f.c)/
+{
+ exit(1);
+}
+
+BEGIN
+/(10 == f.i) && ('c' == f.c)/
+{
+ printf("realmyi: %d\n", realmyi);
+ printf("realmyc: %c\n", realmyc);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransOutputPointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransOutputPointer.d
new file mode 100644
index 00000000..9069bf5d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransOutputPointer.d
@@ -0,0 +1,80 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Translate an input expression to a pointer to a struct
+ *
+ * SECTION: Translators/ Translator Declarations
+ * SECTION: Translators/ Translate Operator
+ *
+ */
+
+#pragma D option quiet
+
+struct myinput_struct {
+ int i;
+ char c;
+};
+
+struct myoutput_struct {
+ int myi;
+ char myc;
+};
+
+translator struct myoutput_struct < struct myinput_struct ivar >
+{
+ myi = ((struct myinput_struct ) ivar).i;
+ myc = ((struct myinput_struct ) ivar).c;
+
+};
+
+struct myinput_struct f;
+
+BEGIN
+{
+ f.i = 1203;
+ f.c = 'v';
+
+ realmyi = xlate < struct myoutput_struct *> (f)->myi;
+ realmyc = xlate < struct myoutput_struct *> (f)->myc;
+}
+
+BEGIN
+/(1203 != realmyi) || ('v' != realmyc)/
+{
+ printf("Failure");
+ exit(1);
+}
+
+BEGIN
+/(1203 == realmyi) && ('v' == realmyc)/
+{
+ printf("Success");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransPointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransPointer.d
new file mode 100644
index 00000000..34d31d44
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TransPointer.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the normal declaration of translators.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct myinput_struct {
+ int i;
+ char c;
+};
+
+struct myoutput_struct {
+ int myi;
+ char myc;
+};
+
+translator struct myoutput_struct < struct myinput_struct *ivar >
+{
+ myi = ((struct myinput_struct *) ivar)->i;
+ myc = ((struct myinput_struct *) ivar)->c;
+
+};
+
+struct myinput_struct *f;
+
+BEGIN
+{
+ printf("Good translator defn");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TranslateSelf.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TranslateSelf.d
new file mode 100644
index 00000000..9059093f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.TranslateSelf.d
@@ -0,0 +1,76 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the translation of a struct to itself.
+ *
+ * SECTION: Translators/ Translator Declarations.
+ * SECTION: Translators/ Translate operator.
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < struct output_struct uvar >
+{
+ myi = ((struct output_struct ) uvar).myi;
+ myc = ((struct output_struct ) uvar).myc;
+};
+
+struct output_struct out;
+struct output_struct outer;
+
+BEGIN
+{
+ out.myi = 1234;
+ out.myc = 'a';
+
+ printf("Test translation of a struct to itself\n");
+ outer = xlate < struct output_struct > (out);
+
+ printf("outer.myi: %d\t outer.myc: %c\n", outer.myi, outer.myc);
+}
+
+BEGIN
+/(1234 != outer.myi) || ('a' != outer.myc)/
+{
+ exit(1);
+}
+
+BEGIN
+/(1234 == outer.myi) && ('a' == outer.myc)/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionInputTrans.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionInputTrans.d
new file mode 100644
index 00000000..fb2dcf09
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionInputTrans.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test the declaration of translators with a union to be the input type.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+union input_union {
+ int i;
+ char c;
+} *ivar;
+
+struct output_struct {
+ int myi;
+ char myc;
+};
+
+translator struct output_struct < union input_union *ivar >
+{
+ myi = ((union input_union *) ivar)->i;
+ myc = ((union input_union *) ivar)->c;
+
+};
+
+BEGIN
+{
+ printf("Translator definition good\n");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionOutputTrans.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionOutputTrans.d
new file mode 100644
index 00000000..3b2c588d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators/tst.UnionOutputTrans.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * The output type in a translator definition can be a union.
+ *
+ * SECTION: Translators/Translator Declarations
+ *
+ *
+ */
+
+#pragma D option quiet
+
+struct input_struct {
+ int ii;
+ char ic;
+} *ivar;
+
+union output_union {
+ int oi;
+ char oc;
+};
+
+translator union output_union < struct input_struct *ivar >
+{
+ oi = ((struct input_struct *) ivar)->ii;
+ oc = ((struct input_struct *) ivar)->ic;
+
+};
+
+BEGIN
+{
+ printf("Test translator definition with union output");
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_DECL_IDRED.DupTypeDef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_DECL_IDRED.DupTypeDef.d
new file mode 100644
index 00000000..47a9fdfe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_DECL_IDRED.DupTypeDef.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+/*
+ * ASSERTION: Cannot redeclare identifier using typedef.
+ *
+ * SECTION: Type and Constant Definitions/Typedef
+ *
+ * NOTES:
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+typedef int new_int;
+
+BEGIN
+{
+ exit(0);
+}
+
+typedef char new_int;
+
+END
+{
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.BadExistingTypedef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.BadExistingTypedef.d
new file mode 100644
index 00000000..38521a05
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.BadExistingTypedef.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+/*
+ * ASSERTION:
+ * The typedef keyword throws an D_SYNTAX error when a bad existing type is
+ * used.
+ *
+ * SECTION: Type and Constant Definitions/Typedef
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+typedef pint new_int;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.TypedefInClause.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.TypedefInClause.d
new file mode 100644
index 00000000..0cb8cf73
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/err.D_SYNTAX.TypedefInClause.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+/*
+ * ASSERTION:
+ * The typedef keyword can be used outside of the probe clauses only.
+ *
+ * SECTION: Type and Constant Definitions/Typedef
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ typedef int new_int;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.ChainTypedef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.ChainTypedef.d
new file mode 100644
index 00000000..00810a52
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.ChainTypedef.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION: An identifier used to alias a primitive data type can be further
+ * used to typedef other aliases. typedef is transitive.
+ *
+ * SECTION: Type and Constant Definitions/Typedef
+ *
+ * NOTES:
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+typedef int new_int;
+typedef new_int latest_int;
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.TypedefDataAssign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.TypedefDataAssign.d
new file mode 100644
index 00000000..4565be55
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/typedef/tst.TypedefDataAssign.d
@@ -0,0 +1,118 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Test the typedef keyword with the different D data types. Declare different
+ * data types and test some of them with values.
+ *
+ * SECTION: Type and Constant Definitions/Typedef
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+typedef char new_char;
+typedef short new_short;
+typedef int new_int;
+typedef long new_long;
+typedef long long new_long_long;
+typedef int8_t new_int8;
+typedef int16_t new_int16;
+typedef int32_t new_int32;
+typedef int64_t new_int64;
+typedef intptr_t new_intptr;
+typedef uint8_t new_uint8;
+typedef uint16_t new_uint16;
+typedef uint32_t new_uint32;
+typedef uint64_t new_uint64;
+typedef uintptr_t new_uintptr;
+typedef float new_float;
+typedef double new_double;
+typedef long double new_long_double;
+
+typedef int * pointer;
+
+typedef struct {
+ char ch;
+ int in;
+ long lg;
+} new_struct;
+
+typedef union {
+ char ch;
+ int in;
+ long lg;
+} new_union;
+
+typedef enum {
+ RED,
+ GREEN,
+ BLUE
+} new_enum;
+
+new_char c;
+new_short s;
+new_int i;
+new_long l;
+new_long_long ll;
+new_int8 i8;
+new_int16 i16;
+new_int32 i32;
+new_int64 i64;
+new_intptr iptr;
+new_uint8 ui8;
+new_uint16 ui16;
+new_uint32 ui32;
+new_uint64 ui64;
+new_uintptr uiptr;
+new_float f;
+new_double d;
+new_long_double ld;
+new_struct ns;
+new_union nu;
+new_enum ne;
+
+pointer p;
+
+BEGIN
+{
+ ns.ch = 'c';
+ ns.in = 4;
+ ns.lg = 4;
+
+ nu.ch = 'd';
+ nu.in = 5;
+ nu.lg = 5;
+
+ i = 10;
+
+ printf("Struct: %c, %d, %d\n", ns.ch, ns.in, ns.lg);
+ printf("Union: %c, %d, %d\n", nu.ch, nu.in, nu.lg);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CAST_INVAL.badcast.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CAST_INVAL.badcast.d
new file mode 100644
index 00000000..13d58eac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CAST_INVAL.badcast.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Test an illegal cast - make sure dtrace catches it.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+
+BEGIN
+{
+ (char)trace(`kmem_flags);
+ exit();
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CG_DYN.ResultDynType.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CG_DYN.ResultDynType.d
new file mode 100644
index 00000000..74f2d701
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CG_DYN.ResultDynType.d
@@ -0,0 +1,47 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * An expression cannot evaluate to result of dynamic type.
+ *
+ * SECTION: Errtag/D_CG_DYN
+ */
+
+#pragma D option quiet
+
+translator lwpsinfo_t < int i >
+{
+ pr_flag = i;
+};
+
+BEGIN
+{
+ xlate < lwpsinfo_t * > (0);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CHR_OFLOW.charconst.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CHR_OFLOW.charconst.d
new file mode 100644
index 00000000..b158c3ca
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_CHR_OFLOW.charconst.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * verify the use of multi-char constants in single quotes
+ *
+ * SECTION: Types, Operators, and Expressions/Constants
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ char_bad = 'abc\fefghi';
+
+ printf("decimal value = %d", char_bad);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_BADCLASS.bad.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_BADCLASS.bad.d
new file mode 100644
index 00000000..5064a591
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_BADCLASS.bad.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid class names should be handled as an error.
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ *
+ */
+
+register x;
+
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_CHARATTR.badtype3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_CHARATTR.badtype3.d
new file mode 100644
index 00000000..e1407bc4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_CHARATTR.badtype3.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid type name
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ *
+ */
+
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ i = (char long)0;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype4.d
new file mode 100644
index 00000000..e925a860
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype4.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid type name
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ *
+ */
+
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ i = (char int)0;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype5.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype5.d
new file mode 100644
index 00000000..b7a3b050
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_COMBO.badtype5.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid type name
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ *
+ */
+
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ i = (double double)0;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENCONST.badeval.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENCONST.badeval.d
new file mode 100644
index 00000000..5e1c19db
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENCONST.badeval.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Attempt a bogus enum declaration by assigning a non-constant expression
+ * to an enumerator.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ */
+
+enum e {
+ TAG = "i am not an integer constant!"
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enoflow.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enoflow.d
new file mode 100644
index 00000000..25e14a69
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enoflow.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Define an enumerations with a overflow value.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ */
+
+enum e {
+ toobig = 2147483648
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enuflow.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enuflow.d
new file mode 100644
index 00000000..3709cb2f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_ENOFLOW.enuflow.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Define an enumerations with a overflow value using negative value.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ */
+
+
+enum e {
+ toosmall = -2147483649
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_SCOPE.scopeop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_SCOPE.scopeop.d
new file mode 100644
index 00000000..ddac451f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_SCOPE.scopeop.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Using the scope operator in a declaration will result in a
+ * D_DECL_SCOPE error.
+ *
+ * SECTION: Variables/External Variables
+ *
+ */
+
+#pragma D option quiet
+
+int `xyz;
+
+BEGIN
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_USELESS.baddec.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_USELESS.baddec.d
new file mode 100644
index 00000000..7e3606e0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_DECL_USELESS.baddec.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Bad external declarations will result in a D_DECL_USELESS
+ * error.
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ *
+ */
+
+extern int;
+
+BEGIN
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ACT.badcond.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ACT.badcond.d
new file mode 100644
index 00000000..b139f9e7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ACT.badcond.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Tracing functions may not be second and third expressions
+ * of a conditional expr.
+ *
+ * SECTION: Types, Operators, and Expressions/Conditional Expressions
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ i = 1;
+ x = i == 0 ? trace(0): trace(1);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ARITH.badoperand.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ARITH.badoperand.d
new file mode 100644
index 00000000..9fefb170
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_ARITH.badoperand.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Arithmetic operations with a +/- must be followed by an arithmetic
+ * type.
+ *
+ * SECTION: Types, Operators, and Expressions/Arithmetic Operators
+ *
+ */
+
+
+
+BEGIN
+{
+ p = 123 + -trace(0);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INCOMPAT.badassign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INCOMPAT.badassign.d
new file mode 100644
index 00000000..04815a9d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INCOMPAT.badassign.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Assignment operators do not supported on all types
+ *
+ * SECTION: Types, Operators, and Expressions/Assignment Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ a = 3;
+ a += "foobar";
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badbitop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badbitop.d
new file mode 100644
index 00000000..a210ea15
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badbitop.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Bitwise operators not supported on all types
+ *
+ * SECTION: Types, Operators, and Expressions/Bitwise Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+/"char" & "foo"/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badshift.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badshift.d
new file mode 100644
index 00000000..978df1d4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_INT.badshift.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Shift operators not supported on all types
+ *
+ * SECTION: Types, Operators, and Expressions/Bitwise Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ x = "char" << 2;
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badcond.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badcond.d
new file mode 100644
index 00000000..2972ac23
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badcond.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Conditional expressions not supported on all types
+ *
+ * SECTION: Types, Operators, and Expressions/Conditional Expressions
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ a = "boo";
+ c = "boo" ? "should": "fail";
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badincop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badincop.d
new file mode 100644
index 00000000..dfd5a315
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badincop.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Increment operators not supported on all types
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ a = "boo";
+ c = a++;
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badlogop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badlogop.d
new file mode 100644
index 00000000..4f084c77
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_OP_SCALAR.badlogop.d
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Logical operators not supported on all types
+ *
+ * SECTION: Types, Operators, and Expressions/Logical Operators
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+/"char" && "foo"/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_PROTO_LEN.badcond1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_PROTO_LEN.badcond1.d
new file mode 100644
index 00000000..8e327509
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_PROTO_LEN.badcond1.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Conditional expressions do not accept tracing functions in
+ * the second or third expression
+ *
+ * SECTION: Types, Operators, and Expressions/Conditional Expressions
+ *
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ a = "boo";
+ c = a == "boo" ? printf("error\n") : trace();
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badenum.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badenum.d
new file mode 100644
index 00000000..3b537759
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badenum.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test a bogus enum declaration using an invalid identifer.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ */
+
+
+enum foo`bar
+{
+
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badid.d
new file mode 100644
index 00000000..a28182cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badid.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Identifiers cannot begin with a digit
+ *
+ * SECTION: Types, Operators, and Expressions/Identifier Names and Keywords
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+int 0abc;
+
+BEGIN
+{
+ 0abc = 5;
+ printf("0abc is %d", 0abc);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badstruct.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badstruct.d
new file mode 100644
index 00000000..6c57d215
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_SYNTAX.badstruct.d
@@ -0,0 +1,38 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Attempt a bogus struct declaration using an invalid identifer.
+ *
+ * SECTION: Structs and Unions/Structs
+ */
+
+struct foo`bar {
+
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype1.d
new file mode 100644
index 00000000..4f6d1e32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype1.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid type name
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ *
+ */
+
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ i = (long short)0;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype2.d
new file mode 100644
index 00000000..f40e95f1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.badtype2.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Invalid type name
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ *
+ */
+
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ i = (short long)0;
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupenum.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupenum.d
new file mode 100644
index 00000000..2282f2d8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupenum.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Attempt a bogus enum declaration that contains duplicated enumerator names.
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ */
+
+enum foo {
+ x = 3,
+ x = 4
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupstruct.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupstruct.d
new file mode 100644
index 00000000..4102cd90
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_UNKNOWN.dupstruct.d
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Attempt a bogus struct declaration that contains duplicated member names.
+ *
+ * SECTION: Structs and Unions/Structs
+ */
+
+struct foo {
+ int x;
+ char x;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_XLATE_REDECL.ResultDynType.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_XLATE_REDECL.ResultDynType.d
new file mode 100644
index 00000000..f4e7dfd1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/err.D_XLATE_REDECL.ResultDynType.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * An expression cannot evaluate to result of dynamic type.
+ *
+ * SECTION: Errtag/D_CG_DYN
+ */
+
+#pragma D option quiet
+
+translator lwpsinfo_t < kthread_t *T >
+{
+ pr_flag = T->t_flag;
+ pr_lwpid = T->t_tid;
+};
+
+BEGIN
+{
+ xlate < lwpsinfo_t * > (curthread);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.assignops.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.assignops.d
new file mode 100644
index 00000000..6bc27b09
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.assignops.d
@@ -0,0 +1,82 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify assignment operators
+ *
+ * SECTION: Types, Operators, and Expressions/Assignment Operators
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ int_1 = 0x100;
+ int_2 = 0xf0f0;
+ int_3 = 0x0f0f;
+
+ intn = 0x1;
+
+ intn += int_1;
+ printf("%x\n", intn);
+ intn -= int_1;
+ printf("%x\n", intn);
+ intn *= int_1;
+ printf("%x\n", intn);
+ intn /= int_1;
+ printf("%x\n", intn);
+ intn %= int_1;
+ printf("%x\n", intn);
+ printf("\n");
+
+ intb = 0x0000;
+
+ intb |= (int_2 | intb);
+ printf("%x\n", intb);
+ intb &= (int_2 | int_3);
+ printf("%x\n", intb);
+ intb ^= (int_2 | int_3);
+ printf("%x\n", intb);
+ intb |= ~(intb);
+ printf("%x\n", intb);
+ printf("\n");
+
+ intb = int_2;
+
+ printf("%x\n", intb);
+ intb <<= 3;
+ printf("%x\n", intb);
+ intb >>= 3;
+ printf("%x\n", intb);
+
+ exit(0);
+
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.badshiftops.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.badshiftops.d
new file mode 100644
index 00000000..ac3c014e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.badshiftops.d
@@ -0,0 +1,49 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Negative values and values greater than the LH operand are
+ * accepted.
+ *
+ * SECTION: Types, Operators, and Expressions/Bitwise Operators
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ int_1 = 0xffff;
+
+ nint = int_1 << -6;
+ printf("%x %x\n", int_1, nint);
+ nint = int_1 << 100;
+ printf("%x %x\n", int_1, nint);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d
new file mode 100644
index 00000000..8e762d5b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test declaration processing of all the fundamental kinds of type
+ * declarations. Check their sizes.
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ */
+
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("\nsizeof (char) = %u\n", sizeof (char));
+ printf("sizeof (signed char) = %u\n", sizeof (signed char));
+ printf("sizeof (unsigned char) = %u\n", sizeof (unsigned char));
+ printf("sizeof (short) = %u\n", sizeof (short));
+ printf("sizeof (signed short) = %u\n", sizeof (signed short));
+ printf("sizeof (unsigned short) = %u\n", sizeof (unsigned short));
+ printf("sizeof (int) = %u\n", sizeof (int));
+ printf("sizeof (signed int) = %u\n", sizeof (signed int));
+ printf("sizeof (unsigned int) = %u\n", sizeof (unsigned int));
+ printf("sizeof (long long) = %u\n", sizeof (long long));
+ printf("sizeof (signed long long) = %u\n", sizeof (signed long long));
+ printf("sizeof (unsigned long long) = %u\n",
+ sizeof (unsigned long long));
+ printf("sizeof (float) = %u\n", sizeof (float));
+ printf("sizeof (double) = %u\n", sizeof (double));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d.out
new file mode 100644
index 00000000..fd05217f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.basics.d.out
@@ -0,0 +1,16 @@
+
+sizeof (char) = 1
+sizeof (signed char) = 1
+sizeof (unsigned char) = 1
+sizeof (short) = 2
+sizeof (signed short) = 2
+sizeof (unsigned short) = 2
+sizeof (int) = 4
+sizeof (signed int) = 4
+sizeof (unsigned int) = 4
+sizeof (long long) = 8
+sizeof (signed long long) = 8
+sizeof (unsigned long long) = 8
+sizeof (float) = 4
+sizeof (double) = 8
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.bitops.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.bitops.d
new file mode 100644
index 00000000..fc643bab
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.bitops.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify relational operators with pointers
+ *
+ * SECTION: Types, Operators, and Expressions/Bitwise Operators
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ int_1 = 0xffff;
+ int_2 = 0;
+ int_3 = 0x0f0f;
+
+
+ printf("%x %x %x\n", int_1 & int_2, int_1 & int_3, int_2 & int_3);
+ printf("%x %x %x\n", int_1 | int_2, int_1 | int_3, int_2 | int_3);
+ printf("%x %x %x\n", int_1 ^ int_2, int_1 ^ int_3, int_2 ^ int_3);
+
+ printf("%x\n", int_1 & int_2 & int_3);
+ printf("%x\n", int_1 & int_2 ^ int_3);
+ printf("%x\n", int_1 & int_2 | int_3);
+ printf("%x\n", int_1 | int_2 & int_3);
+ printf("%x\n", int_1 | int_2 ^ int_3);
+ printf("%x\n", int_1 | int_2 | int_3);
+ printf("%x\n", int_1 ^ int_2 & int_3);
+ printf("%x\n", int_1 ^ int_2 ^ int_3);
+ printf("%x\n", int_1 ^ int_2 | int_3);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.charconstants.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.charconstants.d
new file mode 100644
index 00000000..84aa61bf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.charconstants.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * verify the use of char constants
+ *
+ * SECTION: Types, Operators, and Expressions/Constants
+ *
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ char_1 = 'a';
+ char_2 = '\"';
+ char_3 = '\"\ba';
+ char_4 = '\?';
+ char_5 = '\'';
+ char_6 = '\\';
+ char_7 = '\0103';
+ char_8 = '\x4E';
+ char_9 = '\c'; /* Note - this is not an escape sequence */
+ char_10 = 'ab\"d';
+ char_11 = 'a\bcdefgh';
+
+ printf("decimal value = %d; character value = %c\n", char_1, char_1);
+ printf("decimal value = %d; character value = %c\n", char_2, char_2);
+ printf("decimal value = %d; character value = %c\n", char_3, char_3);
+ printf("decimal value = %d; character value = %c\n", char_4, char_4);
+ printf("decimal value = %d; character value = %c\n", char_5, char_5);
+ printf("decimal value = %d; character value = %c\n", char_6, char_6);
+ printf("decimal value = %d; character value = %c\n", char_7, char_7);
+ printf("decimal value = %d; character value = %c\n", char_8, char_8);
+ printf("decimal value = %d; character value = %c\n", char_9, char_9);
+ printf("decimal value = %d; character value = %c\n", char_10, char_10);
+ printf("decimal value = %d\n", char_11);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.complex.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.complex.d
new file mode 100644
index 00000000..a912670a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.complex.d
@@ -0,0 +1,74 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Test a complex structure and verify that tracemem can be used to
+ * look at it.
+ *
+ * SECTION: Structs and Unions/Structs;
+ * Actions and Subroutines/tracemem()
+ */
+
+
+
+#pragma D option quiet
+
+struct s {
+ int i;
+ char c;
+ double d;
+ float f;
+ long l;
+ long long ll;
+ union sigval u;
+ enum uio_rw e;
+ struct vnode s;
+ struct s1 {
+ int i;
+ char c;
+ double d;
+ float f;
+ long l;
+ long long ll;
+ union sigval u;
+ enum uio_rw e;
+ struct vnode s;
+ } sx;
+ int a[2];
+ int *p;
+ int *ap[4];
+ int (*fp)();
+ int (*afp[2])();
+};
+
+BEGIN
+{
+ tracemem(curthread, sizeof (struct s));
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.condexpr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.condexpr.d
new file mode 100644
index 00000000..fe23a73b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.condexpr.d
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * positive check conditional expressions
+ *
+ * SECTION: Types, Operators, and Expressions/Conditional Expressions
+ *
+ * NOTES: these tests are from the User's Guide
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ i = 0;
+ x = i == 0 ? "zero" : "non-zero";
+
+ c = 'd';
+ hexval = (c >= '0' && c <= '9') ? c - '0':
+ (c >= 'a' && c <= 'z') ? c + 10 - 'a' : c + 10 - 'A';
+}
+
+tick-1
+/x == "zero" && hexval == 13/
+{
+ exit(0);
+}
+
+tick-1
+/x != "zero" || hexval != 13/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.constants.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.constants.d
new file mode 100644
index 00000000..101bb8b8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.constants.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * verify that integer constants can be written in decimal
+ * octal or hexadecimal
+ *
+ * SECTION: Types, Operators, and Expressions/Constants
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ decimal = 12345;
+ octal = 012345;
+ hexadecimal_1 = 0x12345;
+ hexadecimal_2 = 0X12345;
+
+ printf("%d %d %d %d", decimal, octal, hexadecimal_1, hexadecimal_2);
+ printf("%d %o %x %x", decimal, octal, hexadecimal_1, hexadecimal_2);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.conv.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.conv.d
new file mode 100644
index 00000000..90204245
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.conv.d
@@ -0,0 +1,109 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * positive type conversion checks
+ *
+ * SECTION: Types, Operators, and Expressions/Type Conversions
+ *
+ * NOTES: not all type conversions are checked. A lot of this section
+ * is tested within other tests.
+ */
+
+#pragma D option quiet
+
+unsigned int i;
+char c;
+short s;
+long l;
+long long ll;
+
+BEGIN
+{
+/* char -> int */
+ c = 'A';
+ i = c;
+ printf("c is %c i is %d\n", c, i);
+
+/* int -> char */
+
+ i = 1601;
+ c = i;
+ printf("i is %d c is %c\n", i, c);
+
+/* char -> short */
+ c = 'A';
+ s = c;
+ printf("c is %c s is %d\n", c, s);
+
+/* short -> char */
+
+ s = 1601;
+ c = s;
+ printf("s is %d c is %c\n", s, c);
+
+/* int -> short */
+
+ i = 1601;
+ s = i;
+ printf("i is %d s is %d\n", i, s);
+
+/* short -> int */
+
+ s = 1601;
+ i = s;
+ printf("s is %d i is %d\n", s, i);
+
+/* int -> long long */
+
+ i = 4294967295;
+ ll = i;
+ printf("i is %d ll is %x\n", i, ll);
+
+/* long long -> int */
+
+ ll = 8589934591;
+ i = ll;
+ printf("ll is %d i is %x\n", ll, i);
+
+/* char -> long long */
+
+ c = 'A';
+ ll = c;
+ printf("c is %c ll is %x\n", c, ll);
+
+/* long long -> char */
+
+ ll = 8589934401;
+ c = ll;
+ printf("ll is %x c is %c\n", ll, c);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.enum.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.enum.d
new file mode 100644
index 00000000..49a97bff
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.enum.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Positive enumeration test
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ */
+
+#pragma D option quiet
+
+enum my_enum {
+ zero,
+ one = 1,
+ two,
+ three,
+ four = 4,
+ minimum = -2147483648,
+ maximum = 2147483647
+};
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intincop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intincop.d
new file mode 100644
index 00000000..77eb7025
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intincop.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify increment operator using integers
+ *
+ * SECTION: Type and Constant Definitions/Enumerations
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ int_orig = 100;
+ int_pos = 100+1;
+ int_neg = 100-1;
+
+ int_pos_before = ++int_orig;
+ int_orig = 100;
+ int_neg_before = --int_orig;
+ int_orig = 100;
+ int_pos_after = int_orig++;
+ int_orig = 100;
+ int_neg_after = int_orig--;
+ int_orig = 100;
+
+}
+
+tick-1
+/int_pos_before == int_pos && int_neg_before == int_neg &&
+ int_pos_after == int_orig && int_pos_after == int_orig/
+{
+ exit(0);
+}
+
+
+tick-1
+/int_pos_before != int_pos || int_neg_before != int_neg ||
+ int_pos_after != int_orig || int_pos_after != int_orig/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intops.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intops.d
new file mode 100644
index 00000000..a3744804
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.intops.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify relational operators with integers
+ *
+ * SECTION: Types, Operators, and Expressions/Relational Operators;
+ * Types, Operators, and Expressions/Precedence
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ int_1 = 0x100;
+ int_2 = 0x101;
+ int_3 = 0x99;
+}
+
+tick-1
+/int_1 >= int_2 || int_2 <= int_1 || int_1 == int_2/
+{
+ printf("Shouldn't end up here (1)\n");
+ printf("int_1 = %x int_2 = %x int_3 = %x\n",
+ (int) int_1, (int) int_2, (int) int_3);
+ exit(1);
+}
+
+tick-1
+/int_3 > int_1 || int_1 < int_3 || int_3 == int_1/
+{
+ printf("Shouldn't end up here (2)\n");
+ printf("int_1 = %x int_2 = %x int_3 = %x\n",
+ (int) int_1, (int) int_2, (int) int_3);
+ exit(1);
+}
+
+tick-1
+/int_2 > int_3 && int_1 < int_2 ^^ int_3 == int_2 && !(int_1 != int_2)/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.inttypes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.inttypes.d
new file mode 100644
index 00000000..80bfa1f2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.inttypes.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * Verify integer type aliases
+ *
+ * SECTION: Types, Operators, and Expressions/Data Types and Sizes
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+BEGIN
+{
+ printf("sizeof (int8_t) = %u\n", sizeof (int8_t));
+ printf("sizeof (int16_t) = %u\n", sizeof (int16_t));
+ printf("sizeof (int32_t) = %u\n", sizeof (int32_t));
+ printf("sizeof (int64_t) = %u\n", sizeof (int64_t));
+ printf("sizeof (intptr_t) = %u\n", sizeof (intptr_t));
+ printf("sizeof (uint8_t) = %u\n", sizeof (uint8_t));
+ printf("sizeof (uint16_t) = %u\n", sizeof (uint16_t));
+ printf("sizeof (uint32_t) = %u\n", sizeof (uint32_t));
+ printf("sizeof (uint64_t) = %u\n", sizeof (uint64_t));
+ printf("sizeof (uintptr_t) = %u\n", sizeof (uintptr_t));
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrincop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrincop.d
new file mode 100644
index 00000000..0fdd561a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrincop.d
@@ -0,0 +1,72 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify increment/decrement operator using pointers
+ *
+ * SECTION: Types, Operators, and Expressions/Increment and Decrement Operators
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ ptr_orig = &`kmem_flags;
+ ptr_pos = &`kmem_flags+1;
+ ptr_neg = &`kmem_flags-1;
+
+ ptr_pos_before = ++ptr_orig;
+ ptr_orig = &`kmem_flags;
+ ptr_neg_before = --ptr_orig;
+
+ ptr_orig = &`kmem_flags;
+ ptr_pos_after = ptr_orig++;
+ ptr_orig = &`kmem_flags;
+ ptr_neg_after = ptr_orig--;
+ ptr_orig = &`kmem_flags;
+
+}
+
+tick-1
+/ptr_pos_before == ptr_pos && ptr_neg_before == ptr_neg &&
+ ptr_pos_after == ptr_orig && ptr_pos_after == ptr_orig/
+{
+ exit(0);
+}
+
+
+tick-1
+/ptr_pos_before != ptr_pos || ptr_neg_before != ptr_neg ||
+ ptr_pos_after != ptr_orig || ptr_pos_after != ptr_orig/
+{
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrops.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrops.d
new file mode 100644
index 00000000..d4144b09
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.ptrops.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify relational operators with pointers
+ *
+ * SECTION: Types, Operators, and Expressions/Relational Operators;
+ * Types, Operators, and Expressions/Logical Operators;
+ * Types, Operators, and Expressions/Precedence
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ ptr_1 = &`kmem_flags;
+ ptr_2 = (&`kmem_flags) + 1;
+ ptr_3 = (&`kmem_flags) - 1 ;
+}
+
+tick-1
+/ptr_1 >= ptr_2 || ptr_2 <= ptr_1 || ptr_1 == ptr_2/
+{
+ printf("Shouldn't end up here (1)\n");
+ printf("ptr_1 = %x ptr_2 = %x ptr_3 = %x\n",
+ (int) ptr_1, (int) ptr_2, (int) ptr_3);
+ exit(1);
+}
+
+tick-1
+/ptr_3 > ptr_1 || ptr_1 < ptr_3 || ptr_3 == ptr_1/
+{
+ printf("Shouldn't end up here (2)\n");
+ printf("ptr_1 = %x ptr_2 = %x ptr_3 = %x\n",
+ (int) ptr_1, (int) ptr_2, (int) ptr_3);
+ exit(1);
+}
+
+tick-1
+/ptr_3 > ptr_2 || ptr_1 < ptr_2 ^^ ptr_3 == ptr_2 && !(ptr_1 != ptr_2)/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relenum.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relenum.d
new file mode 100644
index 00000000..8fa6d585
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relenum.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify relational operators with enumerations
+ *
+ * SECTION: Types, Operators, and Expressions/Relational Operators
+ *
+ */
+
+#pragma D option quiet
+
+enum numbers_1 {
+ zero,
+ one,
+ two
+};
+
+enum numbers_2 {
+ null,
+ first,
+ second
+};
+
+tick-1
+/zero >= one || second <= first || zero == second/
+{
+ printf("Shouldn't end up here (1)\n");
+ printf("zero = %d; one = %d; two = %d", zero, one, two);
+ printf("null = %d; first = %d; second = %d", null, first, second);
+ exit(1);
+}
+
+tick-1
+/second < one || two > second || null == first/
+{
+ printf("Shouldn't end up here (2)\n");
+ printf("zero = %d; one = %d; two = %d", zero, one, two);
+ printf("null = %d; first = %d; second = %d", null, first, second);
+ exit(1);
+}
+
+tick-1
+/first < two && second > one && one != two && zero != first/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relstring.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relstring.d
new file mode 100644
index 00000000..9e9ef29d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.relstring.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify relational operators with strings
+ *
+ * SECTION: Types, Operators, and Expressions/Relational Operators
+ *
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ string_1 = "abcde";
+ string_2 = "aabcde";
+ string_3 = "abcdef";
+}
+
+tick-1
+/string_1 <= string_2 || string_2 >= string_1 || string_1 == string_2/
+{
+ printf("Shouldn't end up here (1)\n");
+ printf("string_1 = %s string_2 = %s string_3 = %s\n",
+ string_1, string_2, string_3);
+ exit(1);
+}
+
+tick-1
+/string_3 < string_1 || string_1 > string_3 || string_3 == string_1/
+{
+ printf("Shouldn't end up here (2)\n");
+ printf("string_1 = %s string_2 = %s string_3 = %s n",
+ string_1, string_2, string_3);
+ exit(1);
+}
+
+tick-1
+/string_3 > string_1 && string_1 > string_2 &&
+ string_1 != string_2 && string_2 != string_3/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.shiftops.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.shiftops.d
new file mode 100644
index 00000000..a2602385
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.shiftops.d
@@ -0,0 +1,62 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify shift operators
+ *
+ * SECTION: Types, Operators, and Expressions/Bitwise Operators;
+ * Types, Operators, and Expressions/Precedence
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ int_1 = 0xffff;
+
+ nint = (((((((((((int_1 << 2 >> 2) << 3 >> 3) << 4 >> 4) << 5 >> 5)
+ << 6 >> 6) << 7 >> 7) << 8 >>8) << 9 >> 9) << 10 >> 10)
+ << 11 >> 11) << 12 >> 12);
+
+}
+
+tick-1
+/nint != int_1/
+{
+ printf("Unexpected error nint = %x, expected %x\n", nint, int_1);
+ exit(1);
+}
+
+tick-1
+/nint == int_1/
+{
+ exit(0);
+
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.stringconstants.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.stringconstants.d
new file mode 100644
index 00000000..9fa08056
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.stringconstants.d
@@ -0,0 +1,51 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * verify the use of char type
+ *
+ * SECTION: Types, Operators, and Expressions/Constants
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+string string_1;
+
+BEGIN
+{
+ string_1 = "abcd\n\n\nefg";
+ string_2 = "abc\"\t\044\?\x4D";
+ string_3 = "\?\\\'\"\0";
+
+ printf("string_1 = %s\n", string_1);
+ printf("string_2 = %s\n", string_2);
+ printf("string_3 = %s\n", string_3);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.struct.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.struct.d
new file mode 100644
index 00000000..86610f63
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.struct.d
@@ -0,0 +1,84 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declare a dynamic type and then use it to copyin the first 3 environment
+ * variable pointers from the current process.
+ *
+ * SECTION: Structs and Unions/Structs;
+ * Actions and Subroutines/copyin();
+ * Actions and Subroutines/copyinstr();
+ * Variables/External Variables
+ *
+ * NOTES:
+ * This test program declares a dynamic type and then uses it to copyin the
+ * first three environment variable pointers from the current process. We
+ * then use the dynamic type to access the result of our copyin(). The
+ * special "D" module type scope is also tested.
+ */
+
+#pragma D option quiet
+
+struct env_vars_32 {
+ uint32_t e1;
+ uint32_t e2;
+ uint32_t e3;
+};
+
+struct env_vars_64 {
+ uint64_t e1;
+ uint64_t e2;
+ uint64_t e3;
+};
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_ILP32/
+{
+ e32 = (struct D`env_vars_32 *)
+ copyin(curpsinfo->pr_envp, sizeof (struct D`env_vars_32));
+
+ printf("e1 = \"%s\"\n", stringof(copyinstr(e32->e1)));
+ printf("e2 = \"%s\"\n", stringof(copyinstr(e32->e2)));
+ printf("e3 = \"%s\"\n", stringof(copyinstr(e32->e3)));
+
+ exit(0);
+}
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_LP64/
+{
+ e64 = (struct D`env_vars_64 *)
+ copyin(curpsinfo->pr_envp, sizeof (struct D`env_vars_64));
+
+ printf("e1 = \"%s\"\n", stringof(copyinstr(e64->e1)));
+ printf("e2 = \"%s\"\n", stringof(copyinstr(e64->e2)));
+ printf("e3 = \"%s\"\n", stringof(copyinstr(e64->e3)));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.typedef.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.typedef.d
new file mode 100644
index 00000000..aabfc9ba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.typedef.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declares a dynamic type and then uses it to copyin the first three
+ * environment variable pointers from the current process.
+ *
+ * SECTION: Structs and Unions/Structs;
+ * Actions and Subroutines/copyin();
+ * Actions and Subroutines/copyinstr();
+ * Variables/External Variables
+ *
+ * NOTES:
+ * This test program declares a dynamic type and then uses it to copyin the
+ * first three environment variable pointers from the current process. We
+ * then use the dynamic type to access the result of our copyin(). The
+ * special "D" module type scope is also tested. This is similar to our
+ * struct declaration test but here we use a typedef.
+ */
+
+#pragma D option quiet
+
+typedef struct env_vars_32 {
+ uint32_t e1;
+ uint32_t e2;
+ uint32_t e3;
+} env_vars_32_t;
+
+typedef struct env_vars_64 {
+ uint64_t e1;
+ uint64_t e2;
+ uint64_t e3;
+} env_vars_64_t;
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_ILP32/
+{
+ e32 = (D`env_vars_32_t *)
+ copyin(curpsinfo->pr_envp, sizeof (D`env_vars_32_t));
+
+ printf("e1 = \"%s\"\n", stringof(copyinstr(e32->e1)));
+ printf("e2 = \"%s\"\n", stringof(copyinstr(e32->e2)));
+ printf("e3 = \"%s\"\n", stringof(copyinstr(e32->e3)));
+
+ exit(0);
+}
+
+BEGIN
+/curpsinfo->pr_dmodel == PR_MODEL_LP64/
+{
+ e64 = (D`env_vars_64_t *)
+ copyin(curpsinfo->pr_envp, sizeof (D`env_vars_64_t));
+
+ printf("e1 = \"%s\"\n", stringof(copyinstr(e64->e1)));
+ printf("e2 = \"%s\"\n", stringof(copyinstr(e64->e2)));
+ printf("e3 = \"%s\"\n", stringof(copyinstr(e64->e3)));
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.unaryop.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.unaryop.d
new file mode 100644
index 00000000..b9938e4f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/types/tst.unaryop.d
@@ -0,0 +1,50 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify unary operator
+ *
+ * SECTION: Types, Operators, and Expressions/Bitwise Operators
+ */
+
+#pragma D option quiet
+
+
+BEGIN
+{
+ int_1 = 0xffff;
+ int_2 = 0;
+ int_3 = 0x0f0f;
+
+ printf("%x %x %x\n", int_1, int_2, int_3);
+ printf("%x %x %x\n", ~int_1, ~int_2, ~int_3);
+ printf("%x %x %x\n", ~~int_1, ~~int_2, ~~int_3);
+ printf("%x %x %x\n", ~~~int_1, ~~~int_2, ~~~int_3);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_ADDROF_VAR.UnionPointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_ADDROF_VAR.UnionPointer.d
new file mode 100644
index 00000000..0a292cde
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_ADDROF_VAR.UnionPointer.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Trying to access the members of a user defined union by means of
+ * a pointer to it should throw a D_ADDROF_VAR compiler error.
+ *
+ * SECTION: Structs and Unions/Pointers to Structs
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ int position;
+ int content;
+
+};
+
+union record var;
+union record *ptr;
+
+BEGIN
+{
+
+ var.position = 1;
+ var.content = 'a';
+
+ ptr = &var;
+
+ printf("ptr->position: %d\tptr->content: %c\n",
+ ptr->position, ptr->content);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon.d
new file mode 100644
index 00000000..4adb36e9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Combining multiple union definitions in a single line should throw a
+ * compiler error.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ int position;
+ char content;
+}
+
+
+union pirate {
+ int position;
+ char content;
+};
+
+union superStruct super;
+union record rec;
+union pirate pir;
+
+BEGIN
+{
+ rec.content = 'a';
+ rec.position = 1;
+
+ pir.content = 'b';
+ pir.position = 2;
+
+ printf(
+ "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d",
+ rec.content, rec.position, pir.content, pir.position);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon1.d
new file mode 100644
index 00000000..5506a976
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon1.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Combining multiple union definitions in a single line should throw a
+ * compiler error.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ int position;
+ char content;
+};
+
+
+union pirate {
+ int position;
+ char content;
+}
+
+union record rec;
+union pirate pir;
+
+BEGIN
+{
+ rec.content = 'a';
+ rec.position = 1;
+
+ pir.content = 'b';
+ pir.position = 2;
+
+ printf(
+ "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d",
+ rec.content, rec.position, pir.content, pir.position);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.circular.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.circular.d
new file mode 100644
index 00000000..ae6e647f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.circular.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * A circular definition of unions (two unions defining each other as
+ * members) should throw an error at compile time.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ union pirate p;
+ int position;
+ char content;
+};
+
+
+union pirate {
+ union record r;
+ int position;
+ char content;
+};
+
+union record rec;
+union pirate pir;
+
+BEGIN
+{
+ rec.position = 0;
+ rec.content = 'a';
+ printf(
+ "rec.position: %d\nrec.content: %c\n", rec.position, rec.content);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.order.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.order.d
new file mode 100644
index 00000000..9e2ec69f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.order.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When two unions are defined such that one of them contains the other, the
+ * inner union has to be defined first.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+
+#pragma D option quiet
+
+
+union record {
+ union pirate p;
+ int position;
+ char content;
+};
+
+union pirate {
+ int position;
+ char content;
+};
+
+union record rec;
+union pirate pir;
+
+BEGIN
+{
+ rec.content = 'y';
+ rec.position = 2;
+
+ pir.content = 'z';
+ pir.position = 26;
+
+ printf(
+ "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d",
+ rec.content, rec.position, pir.content, pir.position);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.recursive.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.recursive.d
new file mode 100644
index 00000000..2a86b9cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.recursive.d
@@ -0,0 +1,59 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Recursive naming of unions should produce compiler error.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ union record rec;
+ int position;
+ char content;
+};
+
+union record r1;
+union record r2;
+
+BEGIN
+{
+ r1.position = 1;
+ r1.content = 'a';
+
+ r2.position = 2;
+ r2.content = 'b';
+
+ printf("r1.position: %d\nr1.content: %c\n", r1.position, r1.content);
+ printf("r2.position: %d\nr2.content: %c\n", r2.position, r2.content);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.simple.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.simple.d
new file mode 100644
index 00000000..781d7266
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.simple.d
@@ -0,0 +1,58 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declaring an inner union without defining it else where should throw
+ * a compiler error.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+#pragma D option quiet
+
+
+union record {
+ union pirate p;
+ int position;
+ char content;
+};
+
+
+union record rec;
+
+BEGIN
+{
+ rec.position = 0;
+ rec.content = 'a';
+ printf("rec.position: %d\nrec.content: %c\n",
+ rec.position, rec.content);
+
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_PROTO_ARG.DupUnionAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_PROTO_ARG.DupUnionAssoc.d
new file mode 100644
index 00000000..f9187412
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_PROTO_ARG.DupUnionAssoc.d
@@ -0,0 +1,80 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Declaring an associative array with a union to be its key type and trying to
+ * index with another union having the same composition throws an error.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ int position;
+ char content;
+};
+
+union pirate {
+ int position;
+ char content;
+};
+
+union record r1;
+union record r2;
+union pirate p1;
+union pirate p2;
+
+BEGIN
+{
+ r1.position = 1;
+ r1.content = 'a';
+
+ r2.position = 2;
+ r2.content = 'b';
+
+ p1.position = 1;
+ p1.content = 'a';
+
+ p2.position = 2;
+ p2.content = 'b';
+
+ assoc_array[r1] = 1000;
+ assoc_array[r2] = 2000;
+ assoc_array[p1] = 3333;
+ assoc_array[p2] = 4444;
+
+ printf("assoc_array[r1]: %d\n", assoc_array[r1]);
+ printf("assoc_array[r2]: %d\n", assoc_array[r2]);
+ printf("assoc_array[p1]: %d\n", assoc_array[p1]);
+ printf("assoc_array[p2]: %d\n", assoc_array[p2]);
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionAssoc.d
new file mode 100644
index 00000000..882b6ae0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionAssoc.d
@@ -0,0 +1,71 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * When a union is used as a key for an associative array, the key is formed
+ * by using the values of the members of the union variable and not the
+ * address of the union variable.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ int position;
+ char content;
+};
+
+union record r1;
+union record r2;
+
+BEGIN
+{
+ r1.position = 1;
+ r1.content = 'a';
+
+ r2.position = 1;
+ r2.content = 'a';
+
+ assoc_array[r1] = 1000;
+ assoc_array[r2] = 2000;
+
+ printf("assoc_array[r1]: %d\n", assoc_array[r1]);
+ printf("assoc_array[r2]: %d\n", assoc_array[r2]);
+
+ exit(0);
+}
+
+END
+/assoc_array[r1] != assoc_array[r2]/
+{
+ printf("Error");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionDataTypes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionDataTypes.d
new file mode 100644
index 00000000..d5d292d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionDataTypes.d
@@ -0,0 +1,132 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Declaration of the different data types within a union and
+ * their definitions in a later clause should work fine.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ * NOTES: The floats, doubles and strings have not been implemented yet.
+ * When they do, appropriate lines in the code below should be uncommented.
+ * Similarly, the lines with the kmem_flags pointer assignment should be
+ * uncommented when the issues pertaining to it are clarified.
+ *
+ */
+
+#pragma D option quiet
+
+union record {
+ char new_char;
+ short new_short;
+ int new_int;
+ long new_long;
+ long long new_long_long;
+ int8_t new_int8;
+ int16_t new_int16;
+ int32_t new_int32;
+ int64_t new_int64;
+ intptr_t new_intptr;
+ uint8_t new_uint8;
+ uint16_t new_uint16;
+ uint32_t new_uint32;
+ uint64_t new_uint64;
+ uintptr_t new_uintptr;
+
+ /*float new_float;
+ double new_double;
+ long double new_long_double;
+
+ string new_string;
+ */
+
+ struct {
+ char ch;
+ int in;
+ long lg;
+ } new_struct;
+
+ union {
+ char ch;
+ int in;
+ long lg;
+ } new_union;
+
+enum {
+ RED,
+ GREEN,
+ BLUE
+} new_enum;
+
+
+ int *pointer;
+} var;
+
+/*
+ var.pointer = &`kmem_flags;
+*/
+BEGIN
+{
+ var.new_char = 'c';
+ var.new_short = 10;
+ var.new_int = 100;
+ var.new_long = 1234567890;
+ var.new_long_long = 1234512345;
+ var.new_int8 = 'p';
+ var.new_int16 = 20;
+ var.new_int32 = 200;
+ var.new_int64 = 2000000;
+ var.new_intptr = 0x12345;
+ var.new_uint8 = 'q';
+ var.new_uint16 = 30;
+ var.new_uint32 = 300;
+ var.new_uint64 = 3000000;
+ var.new_uintptr = 0x67890;
+
+ /* var.new_float = 1.23456;
+ var.new_double = 2.34567890;
+ var.new_long_double = 3.567890123;
+
+ var.new_string = "hello";
+ */
+
+ /*
+ var.pointer = &`kmem_flags;
+ */
+
+ var.new_struct.ch = 'c';
+ var.new_struct.in = 4;
+ var.new_struct.lg = 4;
+
+ var.new_union.ch = 'd';
+ var.new_union.in = 5;
+ var.new_union.lg = 5;
+
+
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionInside.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionInside.d
new file mode 100644
index 00000000..9569002b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionInside.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * Verify the nested behavior of unions.
+ *
+ * SECTION: Structs and Unions/Unions
+ *
+ */
+#pragma D option quiet
+
+union InnerMost {
+ int position;
+ char content;
+};
+
+union InnerMore {
+ union InnerMost IMost;
+ int dummy_More;
+};
+
+union Inner {
+ union InnerMore IMore;
+ int dummy_More;
+};
+
+union Outer {
+ union Inner I;
+ int dummy_More;
+};
+
+union OuterMore {
+ union Outer O;
+ int dummy_More;
+};
+
+union OuterMost {
+ union OuterMore OMore;
+ int dummy_More;
+} OMost;
+
+
+BEGIN
+{
+
+ OMost.OMore.O.I.IMore.IMost.position = 5;
+ OMost.OMore.O.I.IMore.IMost.content = 'e';
+
+ printf("OMost.OMore.O.I.IMore.IMost.content: %c\n",
+ OMost.OMore.O.I.IMore.IMost.content);
+
+ exit(0);
+}
+
+END
+/'e' != OMost.OMore.O.I.IMore.IMost.content/
+{
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/argmap.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/argmap.d
new file mode 100644
index 00000000..0a1c3609
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/argmap.d
@@ -0,0 +1,31 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+provider test_prov {
+ probe place(int i, int j) : (int j, int i, int i, int j);
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/args.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/args.d
new file mode 100644
index 00000000..a11984c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/args.d
@@ -0,0 +1,31 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+provider test_prov {
+ probe place(int i, int j);
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/forker.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/forker.d
new file mode 100644
index 00000000..f63b965d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/forker.d
@@ -0,0 +1,31 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+provider forker {
+ probe fire();
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.andpid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.andpid.ksh
new file mode 100644
index 00000000..2096422b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.andpid.ksh
@@ -0,0 +1,46 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -c date -s /dev/stdin <<EOF
+plockstat\$target::mutex_lock_impl:,
+pid\$target::mutex_lock_impl:
+{}
+EOF
+
+if [ $? -ne 0 ]; then
+ print -u2 "dtrace failed"
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.c
new file mode 100644
index 00000000..5697ef51
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.c
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/sdt.h>
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ DTRACE_PROBE2(test_prov, place, 10, 4);
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.d
new file mode 100644
index 00000000..fd9f9f47
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.d
@@ -0,0 +1,65 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Verify that argN and args[N] variables are properly remapped.
+ */
+
+BEGIN
+{
+ /* Timeout after 5 seconds */
+ timeout = timestamp + 5000000000;
+}
+
+test_prov$1:::place
+/arg0 != 4 || arg1 != 10 || arg2 != 10 || arg3 != 4/
+{
+ printf("args are %d, %d, %d, %d; should be 4, 10, 10, 4",
+ arg0, arg1, arg2, arg3);
+ exit(1);
+}
+
+test_prov$1:::place
+/args[0] != 4 || args[1] != 10 || args[2] != 10 || args[3] != 4/
+{
+ printf("args are %d, %d, %d, %d; should be 4, 10, 10, 4",
+ args[0], args[1], args[2], args[3]);
+ exit(1);
+}
+
+test_prov$1:::place
+{
+ exit(0);
+}
+
+profile:::tick-1
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.c
new file mode 100644
index 00000000..5697ef51
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.c
@@ -0,0 +1,39 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/sdt.h>
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ DTRACE_PROBE2(test_prov, place, 10, 4);
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.d
new file mode 100644
index 00000000..bb74e80f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.d
@@ -0,0 +1,60 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * SECTION:
+ *
+ * NOTES:
+ *
+ */
+BEGIN
+{
+ /* Timeout after 5 seconds */
+ timeout = timestamp + 5000000000;
+}
+
+test_prov$1:::place
+/arg0 == 10 && arg1 == 4/
+{
+ exit(0);
+}
+
+test_prov$1:::place
+{
+ printf("args are %d, %d; should be 10, 4", arg0, arg1);
+ exit(1);
+}
+
+profile:::tick-1
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh
new file mode 100644
index 00000000..291fe83f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh
@@ -0,0 +1,84 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+}
+EOF
+
+cc -xarch=generic64 -c -o test64.o test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c 64-bit"
+ exit 1
+fi
+cc -xarch=generic -c -o test32.o test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c 32-bit"
+ exit 1
+fi
+
+$dtrace -G -s prov.d test32.o test64.o
+if [ $? -eq 0 ]; then
+ print -u2 "DOF generation failed to generate a warning"
+ exit 1
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh
new file mode 100644
index 00000000..68dbb034
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh
@@ -0,0 +1,107 @@
+#!/usr/bin/ksh
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# This test verifies that a program that corrupts its own environment
+# without inducing a crash does not crash solely due to drti.o's use of
+# getenv(3C).
+#
+
+PATH=/usr/bin:/usr/sbin:$PATH
+
+if (( $# != 1 )); then
+ print -u2 'expected one argument: <dtrace-path>'
+ exit 2
+fi
+
+#
+# jdtrace does not implement the -h option that is required to generate
+# C header files.
+#
+if [[ "$1" == */jdtrace ]]; then
+ exit 0
+fi
+
+dtrace="$1"
+startdir="$PWD"
+dir=$(mktemp -td drtiXXXXXX)
+if (( $? != 0 )); then
+ print -u2 'Could not create safe temporary directory'
+ exit 2
+fi
+
+cd "$dir"
+
+cat > Makefile <<EOF
+all: main
+
+main: main.o prov.o
+ \$(CC) -o main main.o prov.o
+
+main.o: main.c prov.h
+ \$(CC) -c main.c
+
+prov.h: prov.d
+ $dtrace -h -s prov.d
+
+prov.o: prov.d main.o
+ $dtrace -G -32 -s prov.d main.o
+EOF
+
+cat > prov.d <<EOF
+provider tester {
+ probe entry();
+};
+EOF
+
+cat > main.c <<EOF
+#include <stdlib.h>
+#include <sys/sdt.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv, char **envp)
+{
+ envp[0] = (char*)0xff;
+ TESTER_ENTRY();
+ return 0;
+}
+EOF
+
+make > /dev/null
+status=$?
+if (( $status != 0 )) ; then
+ print -u2 "failed to build"
+else
+ ./main
+ status=$?
+fi
+
+cd "$startdir"
+rm -rf "$dir"
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh
new file mode 100755
index 00000000..0a666662
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh
@@ -0,0 +1,159 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test verifies that USDT providers are removed when its associated
+# load object is closed via dlclose(3dl).
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > Makefile <<EOF
+all: main livelib.so deadlib.so
+
+main: main.o prov.o
+ cc -o main main.o
+
+main.o: main.c
+ cc -c main.c
+
+
+livelib.so: livelib.o prov.o
+ cc -z defs -G -o livelib.so livelib.o prov.o -lc
+
+livelib.o: livelib.c prov.h
+ cc -c livelib.c
+
+prov.o: livelib.o prov.d
+ $dtrace -G -s prov.d livelib.o
+
+prov.h: prov.d
+ $dtrace -h -s prov.d
+
+
+deadlib.so: deadlib.o
+ cc -z defs -G -o deadlib.so deadlib.o -lc
+
+deadlib.o: deadlib.c
+ cc -c deadlib.c
+
+clean:
+ rm -f main.o livelib.o prov.o prov.h deadlib.o
+
+clobber: clean
+ rm -f main livelib.so deadlib.so
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+cat > livelib.c <<EOF
+#include "prov.h"
+
+void
+go(void)
+{
+ TEST_PROV_GO();
+}
+EOF
+
+cat > deadlib.c <<EOF
+void
+go(void)
+{
+}
+EOF
+
+
+cat > main.c <<EOF
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ void *live;
+
+ if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
+ printf("dlopen of livelib.so failed: %s\n", dlerror());
+ return (1);
+ }
+
+ (void) dlclose(live);
+
+ pause();
+
+ return (0);
+}
+EOF
+
+/usr/ccs/bin/make > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "failed to build"
+ exit 1
+fi
+
+script() {
+ $dtrace -w -x bufsize=1k -c ./main -qs /dev/stdin <<EOF
+ syscall::pause:entry
+ /pid == \$target/
+ {
+ system("$dtrace -l -P test_prov*");
+ system("kill %d", \$target);
+ exit(0);
+ }
+
+ tick-1s
+ /i++ == 5/
+ {
+ printf("failed\n");
+ exit(1);
+ }
+EOF
+}
+
+script 2>&1
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh.out
new file mode 100644
index 00000000..2f5bb15f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh.out
@@ -0,0 +1,3 @@
+dtrace: failed to match test_prov*:::: No probe matches description
+ ID PROVIDER MODULE FUNCTION NAME
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh
new file mode 100755
index 00000000..c83d8bfa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh
@@ -0,0 +1,160 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > Makefile <<EOF
+all: main livelib.so deadlib.so
+
+main: main.o prov.o
+ cc -o main main.o
+
+main.o: main.c
+ cc -c main.c
+
+
+livelib.so: livelib.o prov.o
+ cc -z defs -G -o livelib.so livelib.o prov.o -lc
+
+livelib.o: livelib.c prov.h
+ cc -c livelib.c
+
+prov.o: livelib.o prov.d
+ $dtrace -G -s prov.d livelib.o
+
+prov.h: prov.d
+ $dtrace -h -s prov.d
+
+
+deadlib.so: deadlib.o
+ cc -z defs -G -o deadlib.so deadlib.o -lc
+
+deadlib.o: deadlib.c
+ cc -c deadlib.c
+
+clean:
+ rm -f main.o livelib.o prov.o prov.h deadlib.o
+
+clobber: clean
+ rm -f main livelib.so deadlib.so
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+cat > livelib.c <<EOF
+#include "prov.h"
+
+void
+go(void)
+{
+ TEST_PROV_GO();
+}
+EOF
+
+cat > deadlib.c <<EOF
+void
+go(void)
+{
+}
+EOF
+
+
+cat > main.c <<EOF
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ void *live, *dead;
+ void *go;
+
+ if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
+ printf("dlopen of livelib.so failed: %s\n", dlerror());
+ return (1);
+ }
+
+ (void) dlclose(live);
+
+ if ((dead = dlopen("./deadlib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
+ printf("dlopen of deadlib.so failed: %s\n", dlerror());
+ return (1);
+ }
+
+ if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
+ printf("dlopen of livelib.so failed: %s\n", dlerror());
+ return (1);
+ }
+
+ if ((go = dlsym(live, "go")) == NULL) {
+ printf("failed to lookup 'go' in livelib.so\n");
+ return (1);
+ }
+
+ ((void (*)(void))go)();
+
+ return (0);
+}
+EOF
+
+/usr/ccs/bin/make > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "failed to build"
+ exit 1
+fi
+
+script() {
+ $dtrace -w -c ./main -Zqs /dev/stdin <<EOF
+ test_prov*:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh.out
new file mode 100644
index 00000000..2164eabc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh.out
@@ -0,0 +1,2 @@
+livelib.so:go:go
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh
new file mode 100755
index 00000000..72f24ce5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh
@@ -0,0 +1,170 @@
+#!/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test verifies that performing a dlclose(3dl) on a library doesn't
+# cause existing pid provider probes to become invalid.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > Makefile <<EOF
+all: main livelib.so deadlib.so
+
+main: main.o prov.o
+ cc -o main main.o
+
+main.o: main.c
+ cc -c main.c
+
+
+livelib.so: livelib.o prov.o
+ cc -z defs -G -o livelib.so livelib.o prov.o -lc
+
+livelib.o: livelib.c prov.h
+ cc -c livelib.c
+
+prov.o: livelib.o prov.d
+ $dtrace -G -s prov.d livelib.o
+
+prov.h: prov.d
+ $dtrace -h -s prov.d
+
+
+deadlib.so: deadlib.o
+ cc -z defs -G -o deadlib.so deadlib.o -lc
+
+deadlib.o: deadlib.c
+ cc -c deadlib.c
+
+clean:
+ rm -f main.o livelib.o prov.o prov.h deadlib.o
+
+clobber: clean
+ rm -f main livelib.so deadlib.so
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+cat > livelib.c <<EOF
+#include "prov.h"
+
+void
+go(void)
+{
+ TEST_PROV_GO();
+}
+EOF
+
+cat > deadlib.c <<EOF
+void
+go(void)
+{
+}
+EOF
+
+
+cat > main.c <<EOF
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+
+static void
+foo(void)
+{
+ (void) close(-1);
+}
+
+int
+main(int argc, char **argv)
+{
+ void *live;
+
+ if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
+ printf("dlopen of livelib.so failed: %s\n", dlerror());
+ return (1);
+ }
+
+ (void) dlclose(live);
+
+ foo();
+
+ return (0);
+}
+EOF
+
+/usr/ccs/bin/make > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "failed to build"
+ exit 1
+fi
+
+script() {
+ $dtrace -c ./main -s /dev/stdin <<EOF
+ pid\$target:a.out:foo:entry
+ {
+ gotit = 1;
+ exit(0);
+ }
+
+ tick-1s
+ /i++ == 5/
+ {
+ printf("test timed out");
+ exit(1);
+ }
+
+ END
+ /!gotit/
+ {
+ printf("program ended without hitting probe");
+ exit(1);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh
new file mode 100644
index 00000000..687e435e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh
@@ -0,0 +1,106 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# Make sure temporary symbols generated due to DTrace probes in static
+# functions are removed in the final link step.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+static void
+foo(void)
+{
+ TEST_PROV_GO();
+}
+
+int
+main(int argc, char **argv)
+{
+ foo();
+
+ return (0);
+}
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+nm test.o | grep \$dtrace > /dev/null
+if [ $? -ne 0 ]; then
+ print -u2 "no temporary symbols in the object file"
+ exit 1
+fi
+
+nm test | grep \$dtrace > /dev/null
+if [ $? -eq 0 ]; then
+ print -u2 "failed to eliminate temporary symbols"
+ exit 1
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh
new file mode 100644
index 00000000..ba62be75
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh
@@ -0,0 +1,96 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+}
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh.out
new file mode 100644
index 00000000..b856cc59
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh.out
@@ -0,0 +1,2 @@
+test:main:go
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh
new file mode 100644
index 00000000..34016484
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh
@@ -0,0 +1,113 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test is primarily intended to verify a fix for SPARC, but there's no
+# harm in running it on other platforms. Here, we verify that is-enabled
+# probes don't interfere with return values from previously invoked functions.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <stdio.h>
+#include "prov.h"
+
+int
+foo(void)
+{
+ return (24);
+}
+
+int
+main(int argc, char **argv)
+{
+ int a = foo();
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+ (void) printf("%d %d %d\n", a, a, a);
+
+ return (0);
+}
+EOF
+
+cc -c -xO2 test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ ./test
+
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out
new file mode 100644
index 00000000..563d68fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out
@@ -0,0 +1,3 @@
+24 24 24
+24 24 24
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh
new file mode 100644
index 00000000..9d2646cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh
@@ -0,0 +1,118 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+#include <sys/sdt.h>
+
+int
+main(int argc, char **argv)
+{
+ DTRACE_PROBE(test_prov, entry);
+ DTRACE_PROBE(test_prov, __entry);
+ DTRACE_PROBE(test_prov, foo__entry);
+ DTRACE_PROBE(test_prov, carpentry);
+ DTRACE_PROBE(test_prov, miniatureturn);
+ DTRACE_PROBE(test_prov, foo__return);
+ DTRACE_PROBE(test_prov, __return);
+ /*
+ * Unfortunately, a "return" probe is not currently possible due to
+ * the conflict with a reserved word.
+ */
+ DTRACE_PROBE(test_prov, done);
+}
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe entry();
+ probe __entry();
+ probe foo__entry();
+ probe carpentry();
+ probe miniatureturn();
+ probe foo__return();
+ probe __return();
+ probe done();
+};
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -wqZFs /dev/stdin <<EOF
+ BEGIN
+ {
+ system("$DIR/test");
+ printf("\n");
+ }
+
+ test_prov*:::done
+ /progenyof(\$pid)/
+ {
+ exit(0);
+ }
+
+ test_prov*:::
+ /progenyof(\$pid)/
+ {
+ printf("\n");
+ }
+EOF
+}
+
+script | cut -c5-
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh.out
new file mode 100644
index 00000000..3bf28907
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh.out
@@ -0,0 +1,10 @@
+FUNCTION
+| :BEGIN
+ -> main
+ -> main
+ -> main
+ | main:carpentry
+ | main:miniatureturn
+ <- main
+ <- main
+ | main:done
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh
new file mode 100755
index 00000000..9c12e6de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh
@@ -0,0 +1,105 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ TEST_PROV_GO();
+ if (fork() == 0) {
+ TEST_PROV_GO();
+ return (0);
+ }
+
+ (void) wait(NULL);
+ TEST_PROV_GO();
+
+ return (0);
+}
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script() {
+ $dtrace -c ./test -Zqs /dev/stdin <<EOF
+ test_prov*:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh.out
new file mode 100644
index 00000000..c656c337
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh.out
@@ -0,0 +1,4 @@
+test:main:go
+test:main:go
+test:main:go
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.c
new file mode 100644
index 00000000..ade7f83b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.c
@@ -0,0 +1,47 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+
+#include "forker.h"
+
+int
+main(int argc, char **argv)
+{
+ int i;
+
+ for (i = 0; i < 10000; i++) {
+ FORKER_FIRE();
+ if (fork() == 0)
+ exit(0);
+
+ (void) wait(NULL);
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh
new file mode 100755
index 00000000..d35fc4db
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh
@@ -0,0 +1,55 @@
+#!/usr/bin/ksh
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+#
+# Test that we don't deadlock between forking and enabling/disabling USDT
+# probes. This test has succeeded if it completes at all.
+#
+
+./tst.forker.exe &
+id=$!
+
+while kill -0 $id >/dev/null 2>&1; do
+ $dtrace -p $id -s /dev/stdin <<-EOF
+ forker*:::fire
+ /i++ == 4/
+ {
+ exit(0);
+ }
+ EOF
+done
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh
new file mode 100644
index 00000000..68a8d016
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh
@@ -0,0 +1,96 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+}
+EOF
+
+cc -xarch=generic -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -xarch=generic -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh
new file mode 100644
index 00000000..39de8e0d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh
@@ -0,0 +1,100 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+}
+EOF
+
+cc -xarch=generic64 -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -xarch=generic64 -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+if [ `isainfo -b` -ne '64']; then
+ script
+ status=$?
+else
+ status=0
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.header.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.header.ksh
new file mode 100644
index 00000000..08a1912b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.header.ksh
@@ -0,0 +1,85 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe zero();
+ probe one(uintptr_t);
+ probe u_nder(char *);
+ probe d__ash(int **);
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ TEST_PROV_ZERO();
+ TEST_PROV_ONE(1);
+ TEST_PROV_U_NDER("hi there");
+ TEST_PROV_D_ASH(argv);
+}
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.include.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.include.ksh
new file mode 100644
index 00000000..5683f47d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.include.ksh
@@ -0,0 +1,61 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+# Make sure <unistd.h> defines _DTRACE_VERSION
+
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+#include <unistd.h>
+
+int
+main(int argc, char **argv)
+{
+#ifdef _DTRACE_VERSION
+ return (0);
+#else
+ return (1);
+#endif
+}
+EOF
+
+cc -xarch=generic -o test test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+
+./test
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh
new file mode 100644
index 00000000..ec07e057
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh
@@ -0,0 +1,82 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+#include <sys/sdt.h>
+
+int
+main(int argc, char **argv)
+{
+ DTRACE_PROBE(test_prov, zero);
+ DTRACE_PROBE1(test_prov, one, 1);
+ DTRACE_PROBE2(test_prov, two, 2, 3);
+ DTRACE_PROBE3(test_prov, three, 4, 5, 7);
+ DTRACE_PROBE4(test_prov, four, 7, 8, 9, 10);
+ DTRACE_PROBE5(test_prov, five, 11, 12, 13, 14, 15);
+}
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe zero();
+ probe one(uintptr_t);
+ probe two(uintptr_t, uintptr_t);
+ probe three(uintptr_t, uintptr_t, uintptr_t);
+ probe four(uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+ probe five(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+};
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh
new file mode 100644
index 00000000..01b2126c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh
@@ -0,0 +1,84 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+ppriv -s A=basic $$
+
+cat > test.c <<EOF
+#include <sys/sdt.h>
+
+int
+main(int argc, char **argv)
+{
+ DTRACE_PROBE(test_prov, zero);
+ DTRACE_PROBE1(test_prov, one, 1);
+ DTRACE_PROBE2(test_prov, two, 2, 3);
+ DTRACE_PROBE3(test_prov, three, 4, 5, 7);
+ DTRACE_PROBE4(test_prov, four, 7, 8, 9, 10);
+ DTRACE_PROBE5(test_prov, five, 11, 12, 13, 14, 15);
+}
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe zero();
+ probe one(uintptr_t);
+ probe two(uintptr_t, uintptr_t);
+ probe three(uintptr_t, uintptr_t, uintptr_t);
+ probe four(uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+ probe five(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+};
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh
new file mode 100755
index 00000000..0c8b072c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh
@@ -0,0 +1,99 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ TEST_PROV_GO();
+ TEST_PROV_GO();
+ TEST_PROV_GO();
+ TEST_PROV_GO();
+
+ return (0);
+}
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script() {
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh.out
new file mode 100644
index 00000000..5e826192
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh.out
@@ -0,0 +1,5 @@
+test:main:go
+test:main:go
+test:main:go
+test:main:go
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh
new file mode 100644
index 00000000..a911bcdf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh
@@ -0,0 +1,90 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+# Fake up a scenario where _DTRACE_VERSION is not defined by having our own
+# <unistd.h>. This tests that dtrace -h will produce a header file which can
+# be used on a system where DTrace is not present.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+touch unistd.h
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ TEST_PROV_GO();
+
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+
+ return (0);
+}
+EOF
+
+cc -I. -xarch=generic -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+cc -xarch=generic -o test test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+./test
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh
new file mode 100644
index 00000000..989d6d32
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh
@@ -0,0 +1,82 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED())
+ return (2);
+
+ return (0);
+}
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh
new file mode 100644
index 00000000..7fad4015
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.reeval.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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+#include <sys/sdt.h>
+
+int
+main(int argc, char **argv)
+{
+ DTRACE_PROBE(test_prov, zero);
+}
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe zero();
+};
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -wZs /dev/stdin <<EOF
+ BEGIN
+ {
+ system("$DIR/test");
+ }
+
+ test_prov*:::
+ {
+ seen = 1;
+ }
+
+ proc:::exit
+ /progenyof(\$pid) && execname == "test"/
+ {
+ exit(seen ? 0 : 2);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh
new file mode 100644
index 00000000..1ebcdb95
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+#include <unistd.h>
+#include <sys/sdt.h>
+
+static void
+foo(void)
+{
+ DTRACE_PROBE(test_prov, probe1);
+ DTRACE_PROBE(test_prov, probe2);
+}
+
+int
+main(int argc, char **argv)
+{
+ DTRACE_PROBE(test_prov, probe1);
+ DTRACE_PROBE(test_prov, probe2);
+ foo();
+}
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe probe1();
+ probe probe2();
+};
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh.out
new file mode 100644
index 00000000..a559d97a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh.out
@@ -0,0 +1,5 @@
+test:main:probe1
+test:main:probe2
+test:foo:probe1
+test:foo:probe2
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh
new file mode 100644
index 00000000..7cf9004c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh
@@ -0,0 +1,108 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+# Rebuilding an object file containing DOF changes slightly when the object
+# files containing the probes have already been modified. This tests that
+# case by generating the DOF object, removing it, and building it again.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+#include <unistd.h>
+#include <sys/sdt.h>
+
+static void
+foo(void)
+{
+ DTRACE_PROBE(test_prov, probe1);
+ DTRACE_PROBE(test_prov, probe2);
+}
+
+int
+main(int argc, char **argv)
+{
+ DTRACE_PROBE(test_prov, probe1);
+ DTRACE_PROBE(test_prov, probe2);
+ foo();
+}
+EOF
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe probe1();
+ probe probe2();
+};
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create initial DOF"
+ exit 1
+fi
+rm -f prov.o
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create final DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ $dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh.out
new file mode 100644
index 00000000..a559d97a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh.out
@@ -0,0 +1,5 @@
+test:main:probe1
+test:main:probe2
+test:foo:probe1
+test:foo:probe2
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh
new file mode 100755
index 00000000..d5d9fdc4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh
@@ -0,0 +1,96 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ TEST_PROV_GO();
+
+ return (0);
+}
+EOF
+
+cc -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script() {
+ $dtrace -c 'ppriv -e -s A=basic ./test' -Zqs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh.out
new file mode 100644
index 00000000..b856cc59
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh.out
@@ -0,0 +1,2 @@
+test:main:go
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.c
new file mode 100644
index 00000000..edd3dd15
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.c
@@ -0,0 +1,61 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+void grow1(int);
+
+void
+grow(int frame)
+{
+ /*
+ * Create a ridiculously large stack - enough to push us over
+ * the default setting of 'dtrace_ustackdepth_max' (2048).
+ */
+ if (frame >= 2048)
+ for (;;)
+ getpid();
+
+ grow1(++frame);
+}
+
+void
+grow1(int frame)
+{
+ grow(++frame);
+}
+
+int
+main(int argc, char *argv[])
+{
+ grow(1);
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.d
new file mode 100644
index 00000000..66fda5ba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.bigstack.d
@@ -0,0 +1,45 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+syscall::getpid:entry
+/pid == $1/
+{
+ @[ustackdepth] = count();
+}
+
+ERROR
+/arg4 == DTRACEFLT_BADSTACK/
+{
+ exit(0);
+}
+
+profile:::tick-1s
+/++n == 10/
+{
+ exit(1)
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.depth.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.depth.ksh
new file mode 100644
index 00000000..26cff421
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.depth.ksh
@@ -0,0 +1,110 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+file=out.$$
+dtrace=$1
+
+rm -f $file
+
+$dtrace -o $file -c date -s /dev/stdin <<EOF
+
+ #pragma D option quiet
+ #pragma D option bufsize=1M
+ #pragma D option bufpolicy=fill
+
+ pid\$target:::entry,
+ pid\$target:::return,
+ pid\$target:a.out::,
+ syscall:::return,
+ profile:::profile-997
+ /pid == \$target/
+ {
+ printf("START %s:%s:%s:%s\n",
+ probeprov, probemod, probefunc, probename);
+ trace(ustackdepth);
+ ustack(100);
+ trace("END\n");
+ }
+
+ tick-1sec
+ /n++ == 10/
+ {
+ trace("test timed out...");
+ exit(1);
+ }
+EOF
+
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+perl /dev/stdin $file <<EOF
+ while (<>) {
+ chomp;
+
+ last if /^\$/;
+
+ die "expected START at \$.\n" unless /^START/;
+
+ \$_ = <>;
+ chomp;
+ die "expected depth (\$_) at \$.\n" unless /^(\d+)\$/;
+ \$depth = \$1;
+
+ for (\$i = 0; \$i < \$depth; \$i++) {
+ \$_ = <>;
+ chomp;
+ die "unexpected END at \$.\n" if /^END/;
+ }
+
+ \$_ = <>;
+ chomp;
+ die "expected END at \$.\n" unless /^END\$/;
+ }
+EOF
+
+status=$?
+
+count=`wc -l $file | cut -f1 -do`
+if [ "$count" -lt 1000 ]; then
+ echo $tst: output was too short
+ status=1
+fi
+
+
+if [ "$status" -eq 0 ]; then
+ rm -f $file
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.c
new file mode 100644
index 00000000..bdeb16d9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.c
@@ -0,0 +1,61 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <unistd.h>
+
+volatile long long count = 0;
+
+int
+baz(int a)
+{
+ (void) getpid();
+ while (count != -1) {
+ count++;
+ a++;
+ }
+
+ return (a + 1);
+}
+
+int
+bar(int a)
+{
+ return (baz(a + 1) - 1);
+}
+
+int
+foo(int a, int b)
+{
+ return (bar(a) - b);
+}
+
+int
+main(int argc, char **argv)
+{
+ return (foo(argc, (int)argv) == 0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.ksh
new file mode 100644
index 00000000..1a7e0e12
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/ustack/tst.spin.ksh
@@ -0,0 +1,139 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+file=out.$$
+dtrace=$1
+
+rm -f $file
+
+dir=`dirname $tst`
+
+$dtrace -o $file -c $dir/tst.spin.exe -s /dev/stdin <<EOF
+
+ #pragma D option quiet
+ #pragma D option destructive
+ #pragma D option evaltime=main
+
+ /*
+ * Toss out the first 100 samples to wait for the program to enter
+ * its steady state.
+ */
+
+ profile-1999
+ /pid == \$target && n++ > 100/
+ {
+ @total = count();
+ @stacks[ustack(4)] = count();
+ }
+
+ tick-1s
+ {
+ secs++;
+ }
+
+ tick-1s
+ /secs > 5/
+ {
+ done = 1;
+ }
+
+ tick-1s
+ /secs > 10/
+ {
+ trace("test timed out");
+ exit(1);
+ }
+
+ profile-1999
+ /pid == \$target && done/
+ {
+ raise(SIGINT);
+ exit(0);
+ }
+
+ END
+ {
+ printa("TOTAL %@u\n", @total);
+ printa("START%kEND\n", @stacks);
+ }
+EOF
+
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+perl /dev/stdin $file <<EOF
+ \$_ = <>;
+ chomp;
+ die "output problem\n" unless /^TOTAL (\d+)/;
+ \$count = \$1;
+ die "too few samples (\$count)\n" unless \$count >= 1000;
+
+ while (<>) {
+ chomp;
+
+ last if /^$/;
+
+ die "expected START at \$.\n" unless /^START/;
+
+
+ \$_ = <>;
+ chomp;
+ die "expected END at \$.\n" unless /\`baz\+/;
+
+ \$_ = <>;
+ chomp;
+ die "expected END at \$.\n" unless /\`bar\+/;
+
+ \$_ = <>;
+ chomp;
+ die "expected END at \$.\n" unless /\`foo\+/;
+
+ \$_ = <>;
+ chomp;
+ die "expected END at \$.\n" unless /\`main\+/;
+
+ \$_ = <>;
+ chomp;
+ die "expected END at \$.\n" unless /^END\$/;
+ }
+
+EOF
+
+status=$?
+if [ "$status" -eq 0 ]; then
+ rm -f $file
+fi
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.gid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.gid.d
new file mode 100644
index 00000000..23fcf389
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.gid.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+/curpsinfo->pr_gid == gid/
+{
+ exit(0);
+}
+
+BEGIN
+{
+ printf("%d != %d\n", curpsinfo->pr_gid, gid);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.nullassign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.nullassign.d
new file mode 100644
index 00000000..accc763f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.nullassign.d
@@ -0,0 +1,94 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+{
+ die = "Die";
+ tap = ", SystemTap, ";
+ the = "The";
+}
+
+BEGIN
+{
+ phrase = strjoin(die, tap);
+ phrase = strjoin(phrase, die);
+ expected = "Die, SystemTap, Die";
+}
+
+BEGIN
+/phrase != expected/
+{
+ printf("global: expected '%s', found '%s'\n", expected, phrase);
+ exit(1);
+}
+
+BEGIN
+{
+ this->phrase = strjoin(the, tap);
+}
+
+BEGIN
+{
+ this->phrase = strjoin(this->phrase, the);
+ expected = "The, SystemTap, The";
+}
+
+BEGIN
+/this->phrase != expected/
+{
+ printf("clause-local: expected '%s', found '%s'\n",
+ expected, this->phrase);
+ exit(2);
+}
+
+BEGIN
+{
+ phrase = NULL;
+ this->phrase = NULL;
+}
+
+BEGIN
+/phrase != NULL/
+{
+ printf("expected global to be NULL\n");
+ exit(3);
+}
+
+BEGIN
+/this->phrase != NULL/
+{
+ printf("expected clause-local to be NULL\n");
+ exit(4);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ppid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ppid.d
new file mode 100644
index 00000000..5f0da5fd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ppid.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+/curpsinfo->pr_ppid == ppid/
+{
+ exit(0);
+}
+
+BEGIN
+{
+ printf("%d != %d\n", curpsinfo->pr_ppid, ppid);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh
new file mode 100644
index 00000000..8427ea0c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh
@@ -0,0 +1,65 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This test is a bit naughty; it's assuming that ld.so.1 has an implementation
+# of calloc(3C), and that it's implemented in terms of the ld.so.1
+# implementation of malloc(3C). If you're reading this comment because
+# those assumptions have become false, please accept my apologies...
+#
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -qs /dev/stdin -c "/usr/bin/echo" <<EOF
+pid\$target:ld.so.1:calloc:entry
+{
+ self->calloc = 1;
+}
+
+pid\$target:ld.so.1:malloc:entry
+/self->calloc/
+{
+ @[umod(ucaller), ufunc(ucaller)] = count();
+}
+
+pid\$target:ld.so.1:calloc:return
+/self->calloc/
+{
+ self->calloc = 0;
+}
+
+END
+{
+ printa("%A %A\n", @);
+}
+EOF
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh.out
new file mode 100644
index 00000000..86c72a4e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.ucaller.ksh.out
@@ -0,0 +1,3 @@
+
+ld.so.1 ld.so.1`calloc
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.uid.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.uid.d
new file mode 100644
index 00000000..bf1c9dc5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.uid.d
@@ -0,0 +1,41 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+BEGIN
+/curpsinfo->pr_uid == uid/
+{
+ exit(0);
+}
+
+BEGIN
+{
+ printf("%d != %d\n", curpsinfo->pr_uid, uid);
+ exit(1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.walltimestamp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.walltimestamp.d
new file mode 100644
index 00000000..e17bb946
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/vars/tst.walltimestamp.d
@@ -0,0 +1,55 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+uint64_t now;
+
+BEGIN
+{
+ now = 18252813184; /* Jan 1, 2004 00:00:00 */
+}
+
+BEGIN
+/walltimestamp < timestamp/
+{
+ printf("%d < %d", walltimestamp, timestamp);
+ exit(1);
+}
+
+BEGIN
+/walltimestamp < now/
+{
+ printf("%d (%Y) is before %Y", walltimestamp, walltimestamp, now);
+ exit(2);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/tst.1.0.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/tst.1.0.d
new file mode 100644
index 00000000..0ab2af78
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/version/tst.1.0.d
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option version=1.0
+
+/*
+ * The following identifiers were added as D built-ins as of version 1.1.
+ * Using these identifiers as user-specified variables should be illegal in
+ * that and any later versions, but legal in earlier versions.
+ */
+int strstr;
+int strchr;
+int strrchr;
+int strtok;
+int substr;
+int index;
+int freopen;
+
+BEGIN
+{
+ exit(0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile
new file mode 100644
index 00000000..05e9a039
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile
@@ -0,0 +1,51 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+ASFLAGS += -P -D_ASM $(CPPFLAGS)
+CLOBBER_FILES += helper_helper.o annotated_helper.o
+
+# For the helper test we require an executable data section.
+ustack/tst.helper.exe := MAPFILE.NED=
+
+ustack/tst.helper.exe: ustack/tst.helper.o ustack/helper_helper.o
+ $(LINK.c) -o ustack/tst.helper.exe \
+ ustack/tst.helper.o ustack/helper_helper.o $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+ustack/helper_helper.o: ustack/helper_helper.d
+ $(COMPILE.d) -o ustack/helper_helper.o -s ustack/helper_helper.d
+
+ustack/tst.annotated.exe: ustack/tst.annotated.o ustack/annotated_helper.o
+ $(LINK.c) -o ustack/tst.annotated.exe \
+ ustack/tst.annotated.o ustack/annotated_helper.o $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+ustack/annotated_helper.o: ustack/annotated_helper.d
+ $(COMPILE.d) -o ustack/annotated_helper.o -s ustack/annotated_helper.d
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/tst.uregsarray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/tst.uregsarray.d
new file mode 100644
index 00000000..5543c0a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/arrays/tst.uregsarray.d
@@ -0,0 +1,63 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive test to make sure that we can invoke x86
+ * ureg[] aliases.
+ *
+ * SECTION: User Process Tracing/uregs Array
+ *
+ * NOTES: This test does no verification - the value of the output
+ * is not deterministic.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("R_GS = 0x%x\n", uregs[R_GS]);
+ printf("R_ES = 0x%x\n", uregs[R_ES]);
+ printf("R_DS = 0x%x\n", uregs[R_DS]);
+ printf("R_EDI = 0x%x\n", uregs[R_EDI]);
+ printf("R_ESI = 0x%x\n", uregs[R_ESI]);
+ printf("R_EBP = 0x%x\n", uregs[R_EBP]);
+ printf("R_EBX = 0x%x\n", uregs[R_EBX]);
+ printf("R_EDX = 0x%x\n", uregs[R_EDX]);
+ printf("R_ECX = 0x%x\n", uregs[R_ECX]);
+ printf("R_EAX = 0x%x\n", uregs[R_EAX]);
+ printf("R_TRAPNO = 0x%x\n", uregs[R_TRAPNO]);
+ printf("R_ERR = 0x%x\n", uregs[R_ERR]);
+ printf("R_EIP = 0x%x\n", uregs[R_EIP]);
+ printf("R_CS = 0x%x\n", uregs[R_CS]);
+ printf("R_EFL = 0x%x\n", uregs[R_EFL]);
+ printf("R_UESP = 0x%x\n", uregs[R_UESP]);
+ printf("R_SS = 0x%x\n", uregs[R_SS]);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyin.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyin.d
new file mode 100644
index 00000000..f14c8afc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyin.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * ASSERTION:
+ * On IA/32, there is a single 32-bit address space that is partitioned
+ * between user-level and kernel-level. copyin()/copyinstr() and
+ * copyout()/copyoutstr() must check that addresses specified as
+ * user-level addresses are actually at user-level. This test attempts
+ * to perform an illegal copyin() from a kernel address. It asserts that
+ * the fault type is DTRACEFLT_BADADDR and that the bad address is set to
+ * the kernel address from which the copyin() was attempted.
+ *
+ * SECTION: Actions and Subroutines/copyin();
+ * Actions and Subroutines/copyin();
+ * User Process Tracing/copyin() and copyinstr()
+ */
+
+BEGIN
+{
+ dtrace_zero = copyin((uintptr_t)&`dtrace_zero, sizeof (int));
+ exit(1);
+}
+
+ERROR
+{
+ exit(arg4 == DTRACEFLT_BADADDR &&
+ arg5 == (uint64_t)&`dtrace_zero ? 0 : 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyinstr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyinstr.d
new file mode 100644
index 00000000..ac049936
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyinstr.d
@@ -0,0 +1,52 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * On IA/32, there is a single 32-bit address space that is partitioned
+ * between user-level and kernel-level. copyin()/copyinstr() and
+ * copyout()/copyoutstr() must check that addresses specified as
+ * user-level addresses are actually at user-level. This test attempts
+ * to perform an illegal copyinstr() from a kernel address. It asserts
+ * that the fault type is DTRACEFLT_BADADDR and that the bad address is
+ * set to the kernel address from which the copyinstr() was attempted.
+ *
+ * SECTION: Actions and Subroutines/copyinstr();
+ * User Process Tracing/copyin() and copyinstr()
+ */
+
+BEGIN
+{
+ os = copyinstr((uintptr_t)&`utsname);
+ exit(1);
+}
+
+ERROR
+{
+ exit(arg4 == DTRACEFLT_BADADDR && arg5 == (uint64_t)&`utsname ? 0 : 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyout.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyout.d
new file mode 100644
index 00000000..8909cd3a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyout.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * On IA/32, there is a single 32-bit address space that is partitioned
+ * between user-level and kernel-level. copyin()/copyinstr() and
+ * copyout()/copyoutstr() must check that addresses specified as
+ * user-level addresses are actually at user-level. This test attempts
+ * to perform an illegal copyout() to a kernel address. It asserts that
+ * the fault type is DTRACEFLT_BADADDR and that the bad address is set to
+ * the kernel address to which the copyout() was attempted.
+ *
+ * SECTION: Actions and Subroutines/copyout()
+ *
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ this->a = (uint32_t *)alloca(4);
+ *this->a = -1;
+ copyout(this->a, (uintptr_t)&`clock, 4);
+ exit(1);
+}
+
+ERROR
+{
+ exit(arg4 == DTRACEFLT_BADADDR && arg5 == (uint64_t)&`clock ? 0 : 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyoutstr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyoutstr.d
new file mode 100644
index 00000000..d7166cd2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/funcs/tst.badcopyoutstr.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * On IA/32, there is a single 32-bit address space that is partitioned
+ * between user-level and kernel-level. copyin()/copyinstr() and
+ * copyout()/copyoutstr() must check that addresses specified as
+ * user-level addresses are actually at user-level. This test attempts
+ * to perform an illegal copyoutstr() to a kernel address. It asserts
+ * that the fault type is DTRACEFLT_BADADDR and that the bad address is
+ * set to the kernel address to which the copyoutstr() was attempted.
+ *
+ * SECTION: Actions and Subroutines/copyoutstr()
+ *
+ */
+
+#pragma D option destructive
+
+BEGIN
+{
+ this->str = alloca(10);
+ bcopy("kablammo!", this->str, 10);
+ copyoutstr(this->str, (uintptr_t)&`clock, 10);
+ exit(1);
+}
+
+ERROR
+{
+ exit(arg4 == DTRACEFLT_BADADDR && arg5 == (uint64_t)&`clock ? 0 : 1);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d
new file mode 100644
index 00000000..50753b8a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure that DTrace doesn't explode on an invalid instruction.
+ */
+
+pid$1:a.out:badfunc:entry
+{
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s
new file mode 100644
index 00000000..27f7f991
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s
@@ -0,0 +1,41 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .long 0
+
+ ENTRY(badfunc)
+ .byte 0xff
+ .byte 0xff
+ SET_SIZE(badfunc)
+
+ ENTRY(main)
+1: jmp 1b
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.d
new file mode 100644
index 00000000..cfcf0a71
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * SECTION:
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option destructive
+
+pid$1:a.out:waiting:entry
+{
+ this->a = (char *)alloca(1);
+ *this->a = 1;
+ copyout(this->a, arg0, 1);
+}
+
+pid$1:a.out:main:,
+pid$1:a.out:other:
+{
+}
+
+pid$1:a.out:bad:entry
+{
+ exit(1);
+}
+
+syscall::rexit:entry
+/pid == $1/
+{
+ exit(0);
+}
+
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.s
new file mode 100644
index 00000000..82a58920
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.branch.s
@@ -0,0 +1,73 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .long 0
+
+ ENTRY(waiting)
+ pushl %ebp
+ movl %esp, %ebp
+ movl 8(%ebp), %eax
+ movl (%eax), %eax
+ popl %ebp
+ ret
+ SET_SIZE(waiting)
+
+ ENTRY(main)
+ pushl %ebp
+ movl %esp, %ebp
+ subl $0x4, %esp
+ movl $0x0, -4(%ebp)
+
+1:
+ leal -4(%ebp), %eax
+ pushl %eax
+ call waiting
+ addl $0x4, %esp
+
+ testl %eax, %eax
+ jz 1b
+
+ addl $0x4, %esp
+
+ xorl %eax, %eax
+ testl %eax, %eax
+ jz other
+
+ ALTENTRY(bad)
+ movl 0x0, %eax
+ SET_SIZE(bad)
+ SET_SIZE(main)
+
+ ENTRY(other)
+ xorl %eax, %eax
+ popl %ebp
+ ret
+ SET_SIZE(other)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.d
new file mode 100644
index 00000000..c484c3f0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * SECTION:
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option destructive
+
+pid$1:a.out:waiting:entry
+{
+ this->a = (char *)alloca(1);
+ *this->a = 1;
+ copyout(this->a, arg0, 1);
+}
+
+pid$1:a.out:main:,
+pid$1:a.out:inner:
+{
+}
+
+syscall::rexit:entry
+/pid == $1/
+{
+ exit(0);
+}
+
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.s
new file mode 100644
index 00000000..134a5aff
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.embedded.s
@@ -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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .long 0
+
+ ENTRY(waiting)
+ pushl %ebp
+ movl %esp, %ebp
+ movl 8(%ebp), %eax
+ movl (%eax), %eax
+ popl %ebp
+ ret
+ SET_SIZE(waiting)
+
+ ENTRY(main)
+ pushl %ebp
+ movl %esp, %ebp
+ subl $0x4, %esp
+ movl $0x0, -4(%ebp)
+1:
+ leal -4(%ebp), %eax
+ pushl %eax
+ call waiting
+ addl $0x4, %esp
+
+ testl %eax, %eax
+ jz 1b
+
+ addl $0x4, %esp
+
+ ALTENTRY(inner)
+ nop
+ nop
+ nop
+ SET_SIZE(inner)
+
+ xorl %eax, %eax
+ popl %ebp
+ ret
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.d
new file mode 100644
index 00000000..358466fe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.d
@@ -0,0 +1,76 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Validated the emulation of various flavors of the return
+ * instruction.
+ */
+
+#pragma D option destructive
+
+pid$1:a.out:waiting:entry
+{
+ this->a = (char *)alloca(1);
+ *this->a = 1;
+ copyout(this->a, arg0, 1);
+}
+
+pid$1:a.out:ret*:
+{
+ printf("%%sp = %x", uregs[R_SP]);
+}
+
+pid$1:a.out:ret*:return
+{
+}
+
+pid$1:a.out:done:entry
+{
+ exit(0);
+}
+
+pid$1:a.out:main:return
+{
+ printf("%%eax = %x", uregs[R_EAX]);
+}
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.s
new file mode 100644
index 00000000..bccdb1a3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.ret.s
@@ -0,0 +1,114 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .long 0
+
+ ENTRY(ret1)
+ ret
+ SET_SIZE(ret1)
+
+ ENTRY(ret2)
+ repz
+ ret
+ SET_SIZE(ret2)
+
+ ENTRY(ret3)
+ ret $0
+ SET_SIZE(ret3)
+
+ ENTRY(ret4)
+ repz
+ ret $0
+ SET_SIZE(ret4)
+
+ ENTRY(ret5)
+ pushl (%esp)
+ ret $4
+ SET_SIZE(ret5)
+
+ ENTRY(ret6)
+ pushl (%esp)
+ repz
+ ret $4
+ SET_SIZE(ret6)
+
+ ENTRY(waiting)
+ pushl %ebp
+ movl %esp, %ebp
+ movl 8(%ebp), %eax
+ movl (%eax), %eax
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ SET_SIZE(waiting)
+
+ ENTRY(main)
+ pushl %ebp
+ movl %esp, %ebp
+ subl $0x4, %esp
+ movl $0x0, -4(%ebp)
+
+1:
+ leal -4(%ebp), %eax
+ pushl %eax
+ call waiting
+ addl $0x4, %esp
+
+ testl %eax, %eax
+ jz 1b
+
+ movl %esp, %esi
+
+ call ret1
+ call ret2
+ call ret3
+ call ret4
+ call ret5
+ call ret6
+
+ cmpl %esp, %esi
+ jne 1f
+
+ ALTENTRY(done)
+ nop
+ SET_SIZE(done)
+
+ movl $0, %eax
+ movl %ebp, %esp
+ popl %ebp
+ ret
+
+1:
+ movl $1, %eax
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.ksh
new file mode 100755
index 00000000..5477f5c9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.ksh
@@ -0,0 +1,50 @@
+#!/bin/ksh -p
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+# Make sure we can match against 2-byte rets
+
+./tst.retlist.exe&
+PID=$!
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+match=`$dtrace -l -n pid$PID:a.out:simple: -n pid$PID:a.out:complex: | wc -l`
+
+kill $PID
+
+if [ "$match" -ne 12 ]; then
+ echo wrong number of matched probes: $match
+ exit 1
+fi
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.s
new file mode 100644
index 00000000..e85e9f5c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/pid/tst.retlist.s
@@ -0,0 +1,51 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .long 0
+
+ ENTRY(simple)
+ repz
+ ret
+ SET_SIZE(simple)
+
+ ENTRY(complex)
+ pushl %ebp
+ movl %esp, %ebp
+ movl 8(%ebp), %eax
+ movl (%eax), %eax
+ popl %ebp
+ repz
+ ret
+ SET_SIZE(complex)
+
+ ENTRY(main)
+1: jmp 1b
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/annotated_helper.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/annotated_helper.d
new file mode 100644
index 00000000..3b977097
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/annotated_helper.d
@@ -0,0 +1,32 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+dtrace:helper:ustack:
+{
+ "@it's annotated"
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/helper_helper.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/helper_helper.d
new file mode 100644
index 00000000..8abc47d0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/helper_helper.d
@@ -0,0 +1,32 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+dtrace:helper:ustack:
+{
+ "<it's working>"
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.c
new file mode 100644
index 00000000..8cdf8aba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.c
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+int
+baz(void)
+{
+ return (8);
+}
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ baz();
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d
new file mode 100644
index 00000000..dd795bec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d
@@ -0,0 +1,35 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+pid$1:a.out:baz:entry
+{
+ ustack(1, 1024);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d.out
new file mode 100644
index 00000000..806d6a2b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.annotated.d.out
@@ -0,0 +1,4 @@
+
+ tst.annotated.exe`baz
+ [ it's annotated ]
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.d
new file mode 100644
index 00000000..78218bd7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+syscall::getpid:entry
+/pid == $1/
+{
+ @[ustackdepth] = count();
+}
+
+ERROR
+/arg4 == DTRACEFLT_BADSTACK/
+{
+ exit(0);
+}
+
+profile:::tick-1s
+/++n == 10/
+{
+ exit(1)
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.s
new file mode 100644
index 00000000..3bf7c0bf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.circstack.s
@@ -0,0 +1,43 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .long 0
+
+ ENTRY(main)
+ pushl %ebp
+ movl %esp, %ebp
+ movl %esp, (%ebp)
+loop:
+ call getpid
+ jmp loop
+ leave
+ ret
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.c
new file mode 100644
index 00000000..69ab6a85
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.c
@@ -0,0 +1,82 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <strings.h>
+
+int
+baz(void)
+{
+ return (8);
+}
+
+static int
+foo(void)
+{
+ /*
+ * In order to assure that our helper is properly employed to identify
+ * the frame, we're going to trampoline through data.
+ */
+ uint8_t instr[] = {
+ 0x55, /* pushl %ebp */
+ 0x8b, 0xec, /* movl %esp, %ebp */
+ 0xe8, 0x0, 0x0, 0x0, 0x0, /* call baz */
+ 0x8b, 0xe5, /* movl %ebp, %esp */
+ 0x5d, /* popl %ebp */
+ 0xc3 /* ret */
+ };
+ uint8_t *fp = malloc(sizeof (instr));
+
+ /*
+ * Do our little relocation dance.
+ */
+ *((int *)&instr[4]) = (uintptr_t)baz - (uintptr_t)&fp[8];
+
+ /*
+ * Copy the code to the heap (it's a pain to build in ON with an
+ * executable stack).
+ */
+ bcopy(instr, fp, sizeof (instr));
+
+ (*(int (*)(void))fp)();
+
+ free(fp);
+
+ return (0);
+}
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ foo();
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d
new file mode 100644
index 00000000..ce2b9b30
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * SECTION:
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+pid$1:a.out:baz:entry
+{
+ ustack(2, 1024);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d.out
new file mode 100644
index 00000000..29646288
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i386/ustack/tst.helper.d.out
@@ -0,0 +1,4 @@
+
+ tst.helper.exe`baz
+ <it's working>
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile
new file mode 100644
index 00000000..68378bbe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile
@@ -0,0 +1,29 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.basic.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.basic.ksh
new file mode 100644
index 00000000..3a5ce6f0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.basic.ksh
@@ -0,0 +1,77 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# ASSERTION: Make sure that we can map in and read the Xen trace buffers.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+#
+# Do not fail the test in a domU
+#
+if [ ! -c /dev/xen/privcmd ]; then
+ exit 0
+fi
+
+dtrace=$1
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ xdt:sched::on-cpu
+ /arg0 == 0/
+ {
+ self->on++;
+ }
+
+ xdt:sched::off-cpu
+ /arg0 == 0 && self->on/
+ {
+ self->off++;
+ }
+
+ xdt:sched::off-cpu
+ /self->on > 50 && self->off > 50/
+ {
+ exit(0);
+ }
+
+ profile:::tick-1sec
+ /n++ > 10/
+ {
+ exit(1);
+ }
+EOF
+}
+
+script
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.hvmenable.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.hvmenable.ksh
new file mode 100644
index 00000000..3719c202
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.hvmenable.ksh
@@ -0,0 +1,64 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# ASSERTION: HVM probes should enable successfully.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+#
+# Do not fail the test in a domU
+#
+if [ ! -c /dev/xen/privcmd ]; then
+ exit 0
+fi
+
+dtrace=$1
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ dtrace:::BEGIN
+ {
+ exit(0);
+ }
+
+ xdt:hvm::vmentry,
+ xdt:hvm::vmexit
+ {}
+EOF
+}
+
+script
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.memenable.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.memenable.ksh
new file mode 100644
index 00000000..25d39cbf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.memenable.ksh
@@ -0,0 +1,65 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# ASSERTION: Mem probes should enable successfully.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+#
+# Do not fail the test in a domU
+#
+if [ ! -c /dev/xen/privcmd ]; then
+ exit 0
+fi
+
+dtrace=$1
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ dtrace:::BEGIN
+ {
+ exit(0);
+ }
+
+ xdt:mem::page-grant-map,
+ xdt:mem::page-grant-unmap,
+ xdt:mem::page-grant-transfer
+ {}
+EOF
+}
+
+script
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh
new file mode 100644
index 00000000..5b14fc98
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh
@@ -0,0 +1,121 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# ASSERTION: Sched probe arguments should be valid.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+#
+# do not fail test in a domU
+#
+if [ ! -c /dev/xen/privcmd ]; then
+ exit 0
+fi
+
+dtrace=$1
+outf=/tmp/sched.args.$$
+
+script()
+{
+ $dtrace -c '/usr/bin/sleep 10' -o $outf -qs /dev/stdin <<EOF
+ xdt:sched::off-cpu,
+ xdt:sched::on-cpu,
+ xdt:sched::block,
+ xdt:sched::sleep,
+ xdt:sched::wake,
+ xdt:sched::yield
+ {
+ /* print domid vcpu pcpu probename */
+ printf("%d %d %d %s\n", arg0, arg1, \`xdt_curpcpu, probename);
+ }
+EOF
+}
+
+validate()
+{
+ /usr/bin/nawk '
+ BEGIN {
+ while (("/usr/sbin/xm vcpu-list" | getline)) {
+ if ($1 != "Name") {
+ domid = $2
+ vcpu = $3
+
+ vcpumap[domid, vcpu] = 1
+
+ split($7, affinity, ",")
+ for (i in affinity) {
+ if (split(affinity[i], p, "-") > 1) {
+ for (pcpu = p[1]; pcpu <= p[2];\
+ pcpu++) {
+ cpumap[domid, vcpu,
+ pcpu] = 1
+ }
+ } else {
+ cpumap[domid, vcpu,
+ affinity[i]] = 1
+ }
+ }
+ }
+ }
+ }
+
+ /^$/ { next }
+
+ /wake/ {
+ if (vcpumap[$1, $2]) {
+ next
+ } else {
+ print "error: " $0
+ exit 1
+ }
+ }
+
+ {
+ if (cpumap[$1, $2, "any"] || cpumap[$1, $2, $3]) {
+ next
+ } else {
+ print "error: " $0
+ exit 1
+ }
+ }
+ ' $outf
+}
+
+script
+status=$?
+
+if [ $status == 0 ]; then
+ validate
+ status=$?
+fi
+
+rm $outf
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedenable.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedenable.ksh
new file mode 100644
index 00000000..54c3352e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedenable.ksh
@@ -0,0 +1,74 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# ASSERTION: Sched probes should enable successfully.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+#
+# do not fail test in a domU
+#
+if [ ! -c /dev/xen/privcmd ]; then
+ exit 0
+fi
+
+dtrace=$1
+
+script()
+{
+ $dtrace -qs /dev/stdin <<EOF
+ dtrace:::BEGIN
+ {
+ exit(0);
+ }
+
+ xdt:sched::off-cpu,
+ xdt:sched::on-cpu,
+ xdt:sched::idle-off-cpu,
+ xdt:sched::idle-on-cpu,
+ xdt:sched::block,
+ xdt:sched::sleep,
+ xdt:sched::wake,
+ xdt:sched::yield,
+ xdt:sched::shutdown-poweroff,
+ xdt:sched::shutdown-reboot,
+ xdt:sched::shutdown-suspend,
+ xdt:sched::shutdown-crash
+ {}
+EOF
+}
+
+script
+status=$?
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile
new file mode 100644
index 00000000..28e814dc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile
@@ -0,0 +1,51 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+ASFLAGS += -P -D_ASM
+
+pid/tst.br.o := ASFLAGS += -xarch=v8plus
+
+all: ustack/tst.helper.exe ustack/tst.annotated.exe
+
+ustack/tst.helper.exe: ustack/tst.helper.o ustack/helper_helper.o
+ $(LINK.c) -o ustack/tst.helper.exe \
+ ustack/tst.helper.o ustack/helper_helper.o $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+ustack/helper_helper.o: ustack/helper_helper.d
+ $(COMPILE.d) -o ustack/helper_helper.o -s ustack/helper_helper.d
+
+ustack/tst.annotated.exe: ustack/tst.annotated.o ustack/annotated_helper.o
+ $(LINK.c) -o ustack/tst.annotated.exe \
+ ustack/tst.annotated.o ustack/annotated_helper.o $(LDLIBS)
+ $(POST_PROCESS) ; $(STRIP_STABS)
+
+ustack/annotated_helper.o: ustack/annotated_helper.d
+ $(COMPILE.d) -o ustack/annotated_helper.o -s ustack/annotated_helper.d
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/tst.uregsarray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/tst.uregsarray.d
new file mode 100644
index 00000000..3ef38983
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/arrays/tst.uregsarray.d
@@ -0,0 +1,85 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+
+/*
+ * ASSERTION:
+ * Positive test to make sure that we can invoke sparc
+ * ureg[] aliases.
+ *
+ * SECTION: User Process Tracing/uregs Array
+ *
+ * NOTES: This test does no verification - the value of the output
+ * is not deterministic.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ printf("R_G0 = 0x%x\n", uregs[R_G0]);
+ printf("R_G1 = 0x%x\n", uregs[R_G1]);
+ printf("R_G2 = 0x%x\n", uregs[R_G2]);
+ printf("R_G3 = 0x%x\n", uregs[R_G3]);
+ printf("R_G4 = 0x%x\n", uregs[R_G4]);
+ printf("R_G5 = 0x%x\n", uregs[R_G5]);
+ printf("R_G6 = 0x%x\n", uregs[R_G6]);
+ printf("R_G7 = 0x%x\n", uregs[R_G7]);
+ printf("R_O0 = 0x%x\n", uregs[R_O0]);
+ printf("R_O1 = 0x%x\n", uregs[R_O1]);
+ printf("R_O2 = 0x%x\n", uregs[R_O2]);
+ printf("R_O3 = 0x%x\n", uregs[R_O3]);
+ printf("R_O4 = 0x%x\n", uregs[R_O4]);
+ printf("R_O5 = 0x%x\n", uregs[R_O5]);
+ printf("R_O6 = 0x%x\n", uregs[R_O6]);
+ printf("R_O7 = 0x%x\n", uregs[R_O7]);
+ printf("R_L0 = 0x%x\n", uregs[R_L0]);
+ printf("R_L1 = 0x%x\n", uregs[R_L1]);
+ printf("R_L2 = 0x%x\n", uregs[R_L2]);
+ printf("R_L3 = 0x%x\n", uregs[R_L3]);
+ printf("R_L4 = 0x%x\n", uregs[R_L4]);
+ printf("R_L5 = 0x%x\n", uregs[R_L5]);
+ printf("R_L6 = 0x%x\n", uregs[R_L6]);
+ printf("R_L7 = 0x%x\n", uregs[R_L7]);
+ printf("R_I0 = 0x%x\n", uregs[R_I0]);
+ printf("R_I1 = 0x%x\n", uregs[R_I1]);
+ printf("R_I2 = 0x%x\n", uregs[R_I2]);
+ printf("R_I3 = 0x%x\n", uregs[R_I3]);
+ printf("R_I4 = 0x%x\n", uregs[R_I4]);
+ printf("R_I5 = 0x%x\n", uregs[R_I5]);
+ printf("R_I6 = 0x%x\n", uregs[R_I6]);
+ printf("R_I7 = 0x%x\n", uregs[R_I7]);
+ printf("R_CCR = 0x%x\n", uregs[R_CCR]);
+ printf("R_PC = 0x%x\n", uregs[R_PC]);
+ printf("R_NPC = 0x%x\n", uregs[R_NPC]);
+ printf("R_Y = 0x%x\n", uregs[R_Y]);
+ printf("R_ASI = 0x%x\n", uregs[R_ASI]);
+ printf("R_FPRS = 0x%x\n", uregs[R_FPRS]);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.d
new file mode 100644
index 00000000..3e466274
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.d
@@ -0,0 +1,40 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: On SPARC, you can't trace misaligned offsets
+ *
+ * SECTION: User Process Tracing/pid Provider
+ *
+ * NOTES:
+ *
+ */
+
+pid$1:a.out:main:7
+{
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.exe b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.exe
new file mode 100755
index 00000000..595db1de
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/err.D_PROC_ALIGN.misaligned.exe
@@ -0,0 +1,29 @@
+#!/bin/ksh
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+sleep 1000000
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d
new file mode 100644
index 00000000..cf1dc02e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d
@@ -0,0 +1,70 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Trace all instructions in the function 'test' to verify that
+ * the branches are emulated correctly.
+ */
+
+#pragma D option destructive
+#pragma D option quiet
+
+pid$1:a.out:waiting:entry
+{
+ this->a = (char *)alloca(1);
+ *this->a = 1;
+ copyout(this->a, arg0, 1);
+}
+
+pid$1:a.out:test:
+{
+ printf("%s:%s\n", probefunc, probename);
+}
+
+syscall::rexit:entry
+/pid == $1/
+{
+ exit(0);
+}
+
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d.out
new file mode 100644
index 00000000..8559271e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.d.out
@@ -0,0 +1,23 @@
+test:entry
+test:0
+test:4
+test:8
+test:c
+test:10
+test:14
+test:18
+test:1c
+test:20
+test:24
+test:28
+test:2c
+test:30
+test:34
+test:38
+test:3c
+test:40
+test:44
+test:48
+test:4c
+test:return
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.s
new file mode 100644
index 00000000..dfa7d270
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.br.s
@@ -0,0 +1,81 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .word 0
+
+ ENTRY(waiting)
+ retl
+ ldub [%o0], %o0
+ SET_SIZE(waiting)
+
+ ENTRY(test)
+ mov 1, %g1
+
+ brz %g1, 1f
+ nop
+ brlez %g1, 1f
+ nop
+ brlz %g0, 1f
+ nop
+ brlz %g1, 1f
+ nop
+ brnz %g0, 1f
+ sub %g0, 2, %g1
+ brgz %g1, 1f
+ nop
+ brgz %g0, 1f
+ nop
+ brgez %g1, 1f
+ nop
+
+ mov %g1, %o0
+
+1:
+ retl
+ nop
+ SET_SIZE(test)
+
+ ENTRY(main)
+ save %sp, -SA(MINFRAME + 4), %sp
+ stb %g0, [%fp - 4]
+1:
+ call waiting
+ sub %fp, 4, %o0
+ tst %o0
+ bz 1b
+ nop
+
+ call test
+ nop
+
+ ret
+ restore %g0, %g0, %o0
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.d
new file mode 100644
index 00000000..cfcf0a71
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.d
@@ -0,0 +1,78 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * SECTION:
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option destructive
+
+pid$1:a.out:waiting:entry
+{
+ this->a = (char *)alloca(1);
+ *this->a = 1;
+ copyout(this->a, arg0, 1);
+}
+
+pid$1:a.out:main:,
+pid$1:a.out:other:
+{
+}
+
+pid$1:a.out:bad:entry
+{
+ exit(1);
+}
+
+syscall::rexit:entry
+/pid == $1/
+{
+ exit(0);
+}
+
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.s
new file mode 100644
index 00000000..3e6531f3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.branch.s
@@ -0,0 +1,63 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .word 0
+
+ ENTRY(waiting)
+ retl
+ ldub [%o0], %o0
+ SET_SIZE(waiting)
+
+ ENTRY(main)
+ save %sp, -SA(MINFRAME + 4), %sp
+ stb %g0, [%fp - 4]
+1:
+ call waiting
+ sub %fp, 4, %o0
+ tst %o0
+ bz 1b
+ nop
+
+ restore
+
+ tst %g0
+ be other
+ nop
+
+ ALTENTRY(bad)
+ illtrap
+ SET_SIZE(bad)
+ SET_SIZE(main)
+
+ ENTRY(other)
+ retl
+ clr %o0
+ SET_SIZE(other)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.d
new file mode 100644
index 00000000..c484c3f0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.d
@@ -0,0 +1,73 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * SECTION:
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option destructive
+
+pid$1:a.out:waiting:entry
+{
+ this->a = (char *)alloca(1);
+ *this->a = 1;
+ copyout(this->a, arg0, 1);
+}
+
+pid$1:a.out:main:,
+pid$1:a.out:inner:
+{
+}
+
+syscall::rexit:entry
+/pid == $1/
+{
+ exit(0);
+}
+
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.s
new file mode 100644
index 00000000..612f0b92
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/pid/tst.embedded.s
@@ -0,0 +1,59 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .word 0
+
+ ENTRY(waiting)
+ retl
+ ldub [%o0], %o0
+ SET_SIZE(waiting)
+
+ ENTRY(main)
+ save %sp, -SA(MINFRAME + 4), %sp
+ stb %g0, [%fp - 4]
+1:
+ call waiting
+ sub %fp, 4, %o0
+ tst %o0
+ bz 1b
+ nop
+
+ restore
+
+ ALTENTRY(inner)
+ nop
+ nop
+ nop
+ SET_SIZE(inner)
+
+ retl
+ clr %o0
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/tst.tailcall.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/tst.tailcall.ksh
new file mode 100644
index 00000000..cfd7a631
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/usdt/tst.tailcall.ksh
@@ -0,0 +1,132 @@
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# ASSERTION: Make sure USDT probes work as tail-calls on SPARC.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.s <<EOF
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .word 0
+
+ ENTRY(test)
+ save %sp, -SA(MINFRAME + 4), %sp
+ mov 9, %i0
+ mov 19, %i1
+ mov 2006, %i2
+ call __dtrace_test___fire
+ restore
+ SET_SIZE(test)
+
+ ENTRY(main)
+ save %sp, -SA(MINFRAME + 4), %sp
+
+1:
+ call test
+ nop
+
+ ba 1b
+ nop
+
+ ret
+ restore %g0, %g0, %o0
+ SET_SIZE(main)
+EOF
+
+cat > prov.d <<EOF
+provider test {
+ probe fire(int, int, int);
+};
+EOF
+
+/usr/ccs/bin/as -xregsym=no -P -D_ASM -o test.o test.s
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.s"
+ exit 1
+fi
+
+$dtrace -G -32 -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+
+cc -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+$dtrace -c ./test -s /dev/stdin <<EOF
+test\$target:::fire
+/arg0 == 9 && arg1 == 19 && arg2 == 2006/
+{
+ printf("%d/%d/%d", arg0, arg1, arg2);
+ exit(0);
+}
+
+test\$target:::fire
+{
+ printf("%d/%d/%d", arg0, arg1, arg2);
+ exit(1);
+}
+
+BEGIN
+{
+ /*
+ * Let's just do this for 5 seconds.
+ */
+ timeout = timestamp + 5000000000;
+}
+
+profile:::tick-4
+/timestamp > timeout/
+{
+ trace("test timed out");
+ exit(1);
+}
+EOF
+
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/annotated_helper.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/annotated_helper.d
new file mode 100644
index 00000000..3577f86f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/annotated_helper.d
@@ -0,0 +1,32 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ident "%Z%%M% %I% %E% SMI"
+
+dtrace:helper:ustack:
+{
+ "@it's annotated"
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/helper_helper.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/helper_helper.d
new file mode 100644
index 00000000..8abc47d0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/helper_helper.d
@@ -0,0 +1,32 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+dtrace:helper:ustack:
+{
+ "<it's working>"
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.c
new file mode 100644
index 00000000..8cdf8aba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.c
@@ -0,0 +1,43 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+int
+baz(void)
+{
+ return (8);
+}
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ baz();
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d
new file mode 100644
index 00000000..dd795bec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d
@@ -0,0 +1,35 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option quiet
+
+pid$1:a.out:baz:entry
+{
+ ustack(1, 1024);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d.out
new file mode 100644
index 00000000..806d6a2b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.annotated.d.out
@@ -0,0 +1,4 @@
+
+ tst.annotated.exe`baz
+ [ it's annotated ]
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.d
new file mode 100644
index 00000000..78218bd7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.d
@@ -0,0 +1,46 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+syscall::getpid:entry
+/pid == $1/
+{
+ @[ustackdepth] = count();
+}
+
+ERROR
+/arg4 == DTRACEFLT_BADSTACK/
+{
+ exit(0);
+}
+
+profile:::tick-1s
+/++n == 10/
+{
+ exit(1)
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.s
new file mode 100644
index 00000000..a5076c96
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.circstack.s
@@ -0,0 +1,44 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ DGDEF(__fsr_init_value)
+ .word 0
+
+ ENTRY(main)
+ save %sp, -SA(MINFRAME), %sp
+ mov %sp, %fp
+loop:
+ call getpid
+ nop
+ ba loop
+ nop
+ ret
+ restore
+ SET_SIZE(main)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.c
new file mode 100644
index 00000000..fa4802ac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.c
@@ -0,0 +1,81 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <strings.h>
+
+int
+baz(void)
+{
+ return (8);
+}
+
+static int
+foo(void)
+{
+ /*
+ * In order to assure that our helper is properly employed to identify
+ * the frame, we're going to trampoline through data.
+ */
+ uint32_t instr[] = {
+ 0x9de3bfa0, /* save %sp, -0x60, %sp */
+ 0x40000000, /* call baz */
+ 0x01000000, /* nop */
+ 0x81c7e008, /* ret */
+ 0x81e80000 /* restore */
+ };
+ uint32_t *fp = malloc(sizeof (instr));
+
+ /*
+ * Do our little relocation dance.
+ */
+ instr[1] |= ((uintptr_t)baz - (uintptr_t)&fp[1]) >> 2;
+
+ /*
+ * Copy the code to the heap (it's a pain to build in ON with an
+ * executable stack).
+ */
+ bcopy(instr, fp, sizeof (instr));
+
+ (*(int (*)(void))fp)();
+
+ free(fp);
+
+ return (0);
+}
+
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ foo();
+ }
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d
new file mode 100644
index 00000000..ce2b9b30
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d
@@ -0,0 +1,44 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ *
+ * SECTION:
+ *
+ * NOTES:
+ *
+ */
+
+#pragma D option quiet
+
+pid$1:a.out:baz:entry
+{
+ ustack(2, 1024);
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d.out
new file mode 100644
index 00000000..29646288
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.helper.d.out
@@ -0,0 +1,4 @@
+
+ tst.helper.exe`baz
+ <it's working>
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.trapstat.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.trapstat.ksh
new file mode 100644
index 00000000..84af8006
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/sparc/ustack/tst.trapstat.ksh
@@ -0,0 +1,87 @@
+#/bin/ksh -p
+#
+# 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 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+#
+# This script verifies that user-land stacks can be walked safely
+# when the trapstat(1M) utility is running. An arbitrary program, w(1),
+# is started once a second to ensure stacks can be walked at all stages
+# of the process lifecycle.
+#
+
+script()
+{
+ $dtrace -o $dtraceout -s /dev/stdin <<EOF
+ fbt:::
+ {
+ @[ustackdepth] = count();
+ }
+EOF
+}
+
+run_commands()
+{
+ cnt=0
+
+ while [ $cnt -lt 10 ]; do
+ w > /dev/null
+ sleep 1
+ cnt=$(($cnt+1))
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+dtraceout=/tmp/dtrace.out.$$
+script 2>/dev/null &
+timeout=15
+
+#
+# Sleep while the above script fires into life. To guard against dtrace dying
+# and us sleeping forever we allow 15 secs for this to happen. This should be
+# enough for even the slowest systems.
+#
+while [ ! -f $dtraceout ]; do
+ sleep 1
+ timeout=$(($timeout-1))
+ if [ $timeout -eq 0 ]; then
+ echo "dtrace failed to start. Exiting."
+ exit 1
+ fi
+done
+
+run_commands &
+trapstat -t 1 10
+status=$?
+
+rm $dtraceout
+
+exit $status
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c
new file mode 100644
index 00000000..4518f596
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c
@@ -0,0 +1,1370 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/sysmacros.h>
+#include <sys/param.h>
+#include <sys/mman.h>
+#else /* VBOX */
+#endif /* VBOX */
+#include <ctf_impl.h>
+
+/*
+ * This static string is used as the template for initially populating a
+ * dynamic container's string table. We always store \0 in the first byte,
+ * and we use the generic string "PARENT" to mark this container's parent
+ * if one is associated with the container using ctf_import().
+ */
+static const char _CTF_STRTAB_TEMPLATE[] = "\0PARENT";
+
+/*
+ * To create an empty CTF container, we just declare a zeroed header and call
+ * ctf_bufopen() on it. If ctf_bufopen succeeds, we mark the new container r/w
+ * and initialize the dynamic members. We set dtstrlen to 1 to reserve the
+ * first byte of the string table for a \0 byte, and we start assigning type
+ * IDs at 1 because type ID 0 is used as a sentinel.
+ */
+ctf_file_t *
+ctf_create(int *errp)
+{
+ static const ctf_header_t hdr = { { CTF_MAGIC, CTF_VERSION, 0 } };
+
+ const ulong_t hashlen = 128;
+ ctf_dtdef_t **hash = ctf_alloc(hashlen * sizeof (ctf_dtdef_t *));
+ ctf_sect_t cts;
+ ctf_file_t *fp;
+
+ if (hash == NULL)
+ return (ctf_set_open_errno(errp, EAGAIN));
+
+ cts.cts_name = _CTF_SECTION;
+ cts.cts_type = SHT_PROGBITS;
+ cts.cts_flags = 0;
+ cts.cts_data = &hdr;
+ cts.cts_size = sizeof (hdr);
+ cts.cts_entsize = 1;
+ cts.cts_offset = 0;
+
+ if ((fp = ctf_bufopen(&cts, NULL, NULL, errp)) == NULL) {
+ ctf_free(hash, hashlen * sizeof (ctf_dtdef_t *));
+ return (NULL);
+ }
+
+ fp->ctf_flags |= LCTF_RDWR;
+ fp->ctf_dthashlen = hashlen;
+ bzero(hash, hashlen * sizeof (ctf_dtdef_t *));
+ fp->ctf_dthash = hash;
+ fp->ctf_dtstrlen = sizeof (_CTF_STRTAB_TEMPLATE);
+ fp->ctf_dtnextid = 1;
+ fp->ctf_dtoldid = 0;
+
+ return (fp);
+}
+
+static uchar_t *
+ctf_copy_smembers(ctf_dtdef_t *dtd, uint_t soff, uchar_t *t)
+{
+ ctf_dmdef_t *dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ ctf_member_t ctm;
+
+ for (; dmd != NULL; dmd = ctf_list_next(dmd)) {
+ if (dmd->dmd_name) {
+ ctm.ctm_name = soff;
+ soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1;
+ } else
+ ctm.ctm_name = 0;
+
+ ctm.ctm_type = (ushort_t)dmd->dmd_type;
+ ctm.ctm_offset = (ushort_t)dmd->dmd_offset;
+
+ bcopy(&ctm, t, sizeof (ctm));
+ t += sizeof (ctm);
+ }
+
+ return (t);
+}
+
+static uchar_t *
+ctf_copy_lmembers(ctf_dtdef_t *dtd, uint_t soff, uchar_t *t)
+{
+ ctf_dmdef_t *dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ ctf_lmember_t ctlm;
+
+ for (; dmd != NULL; dmd = ctf_list_next(dmd)) {
+ if (dmd->dmd_name) {
+ ctlm.ctlm_name = soff;
+ soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1;
+ } else
+ ctlm.ctlm_name = 0;
+
+ ctlm.ctlm_type = (ushort_t)dmd->dmd_type;
+ ctlm.ctlm_pad = 0;
+ ctlm.ctlm_offsethi = CTF_OFFSET_TO_LMEMHI(dmd->dmd_offset);
+ ctlm.ctlm_offsetlo = CTF_OFFSET_TO_LMEMLO(dmd->dmd_offset);
+
+ bcopy(&ctlm, t, sizeof (ctlm));
+ t += sizeof (ctlm);
+ }
+
+ return (t);
+}
+
+static uchar_t *
+ctf_copy_emembers(ctf_dtdef_t *dtd, uint_t soff, uchar_t *t)
+{
+ ctf_dmdef_t *dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ ctf_enum_t cte;
+
+ for (; dmd != NULL; dmd = ctf_list_next(dmd)) {
+ cte.cte_name = soff;
+ cte.cte_value = dmd->dmd_value;
+ soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1;
+ bcopy(&cte, t, sizeof (cte));
+ t += sizeof (cte);
+ }
+
+ return (t);
+}
+
+static uchar_t *
+ctf_copy_membnames(ctf_dtdef_t *dtd, uchar_t *s)
+{
+ ctf_dmdef_t *dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ size_t len;
+
+ for (; dmd != NULL; dmd = ctf_list_next(dmd)) {
+ if (dmd->dmd_name == NULL)
+ continue; /* skip anonymous members */
+ len = strlen(dmd->dmd_name) + 1;
+ bcopy(dmd->dmd_name, s, len);
+ s += len;
+ }
+
+ return (s);
+}
+
+/*
+ * If the specified CTF container is writable and has been modified, reload
+ * this container with the updated type definitions. In order to make this
+ * code and the rest of libctf as simple as possible, we perform updates by
+ * taking the dynamic type definitions and creating an in-memory CTF file
+ * containing the definitions, and then call ctf_bufopen() on it. This not
+ * only leverages ctf_bufopen(), but also avoids having to bifurcate the rest
+ * of the library code with different lookup paths for static and dynamic
+ * type definitions. We are therefore optimizing greatly for lookup over
+ * update, which we assume will be an uncommon operation. We perform one
+ * extra trick here for the benefit of callers and to keep our code simple:
+ * ctf_bufopen() will return a new ctf_file_t, but we want to keep the fp
+ * constant for the caller, so after ctf_bufopen() returns, we use bcopy to
+ * swap the interior of the old and new ctf_file_t's, and then free the old.
+ */
+int
+ctf_update(ctf_file_t *fp)
+{
+ ctf_file_t ofp, *nfp;
+ ctf_header_t hdr;
+ ctf_dtdef_t *dtd;
+ ctf_sect_t cts;
+
+ uchar_t *s, *s0, *t;
+ size_t size;
+ void *buf;
+ int err;
+
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno(fp, ECTF_RDONLY));
+
+ if (!(fp->ctf_flags & LCTF_DIRTY))
+ return (0); /* no update required */
+
+ /*
+ * Fill in an initial CTF header. We will leave the label, object,
+ * and function sections empty and only output a header, type section,
+ * and string table. The type section begins at a 4-byte aligned
+ * boundary past the CTF header itself (at relative offset zero).
+ */
+ bzero(&hdr, sizeof (hdr));
+ hdr.cth_magic = CTF_MAGIC;
+ hdr.cth_version = CTF_VERSION;
+
+ if (fp->ctf_flags & LCTF_CHILD)
+ hdr.cth_parname = 1; /* i.e. _CTF_STRTAB_TEMPLATE[1] */
+
+ /*
+ * Iterate through the dynamic type definition list and compute the
+ * size of the CTF type section we will need to generate.
+ */
+ for (size = 0, dtd = ctf_list_next(&fp->ctf_dtdefs);
+ dtd != NULL; dtd = ctf_list_next(dtd)) {
+
+ uint_t kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
+ uint_t vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
+
+ if (dtd->dtd_data.ctt_size != CTF_LSIZE_SENT)
+ size += sizeof (ctf_stype_t);
+ else
+ size += sizeof (ctf_type_t);
+
+ switch (kind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ size += sizeof (uint_t);
+ break;
+ case CTF_K_ARRAY:
+ size += sizeof (ctf_array_t);
+ break;
+ case CTF_K_FUNCTION:
+ size += sizeof (ushort_t) * (vlen + (vlen & 1));
+ break;
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ if (dtd->dtd_data.ctt_size < CTF_LSTRUCT_THRESH)
+ size += sizeof (ctf_member_t) * vlen;
+ else
+ size += sizeof (ctf_lmember_t) * vlen;
+ break;
+ case CTF_K_ENUM:
+ size += sizeof (ctf_enum_t) * vlen;
+ break;
+ }
+ }
+
+ /*
+ * Fill in the string table offset and size, compute the size of the
+ * entire CTF buffer we need, and then allocate a new buffer and
+ * bcopy the finished header to the start of the buffer.
+ */
+ hdr.cth_stroff = hdr.cth_typeoff + VBDTCAST(uint_t)size;
+ hdr.cth_strlen = VBDTCAST(uint_t)fp->ctf_dtstrlen;
+ size = sizeof (ctf_header_t) + hdr.cth_stroff + hdr.cth_strlen;
+
+ if ((buf = ctf_data_alloc(size)) == MAP_FAILED)
+ return (ctf_set_errno(fp, EAGAIN));
+
+ bcopy(&hdr, buf, sizeof (ctf_header_t));
+ t = (uchar_t *)buf + sizeof (ctf_header_t);
+ s = s0 = (uchar_t *)buf + sizeof (ctf_header_t) + hdr.cth_stroff;
+
+ bcopy(_CTF_STRTAB_TEMPLATE, s, sizeof (_CTF_STRTAB_TEMPLATE));
+ s += sizeof (_CTF_STRTAB_TEMPLATE);
+
+ /*
+ * We now take a final lap through the dynamic type definition list and
+ * copy the appropriate type records and strings to the output buffer.
+ */
+ for (dtd = ctf_list_next(&fp->ctf_dtdefs);
+ dtd != NULL; dtd = ctf_list_next(dtd)) {
+
+ uint_t kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
+ uint_t vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
+
+ ctf_array_t cta;
+ uint_t encoding;
+ size_t len;
+
+ if (dtd->dtd_name != NULL) {
+ dtd->dtd_data.ctt_name = (uint_t)(s - s0);
+ len = strlen(dtd->dtd_name) + 1;
+ bcopy(dtd->dtd_name, s, len);
+ s += len;
+ } else
+ dtd->dtd_data.ctt_name = 0;
+
+ if (dtd->dtd_data.ctt_size != CTF_LSIZE_SENT)
+ len = sizeof (ctf_stype_t);
+ else
+ len = sizeof (ctf_type_t);
+
+ bcopy(&dtd->dtd_data, t, len);
+ t += len;
+
+ switch (kind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ if (kind == CTF_K_INTEGER) {
+ encoding = CTF_INT_DATA(
+ dtd->dtd_u.dtu_enc.cte_format,
+ dtd->dtd_u.dtu_enc.cte_offset,
+ dtd->dtd_u.dtu_enc.cte_bits);
+ } else {
+ encoding = CTF_FP_DATA(
+ dtd->dtd_u.dtu_enc.cte_format,
+ dtd->dtd_u.dtu_enc.cte_offset,
+ dtd->dtd_u.dtu_enc.cte_bits);
+ }
+ bcopy(&encoding, t, sizeof (encoding));
+ t += sizeof (encoding);
+ break;
+
+ case CTF_K_ARRAY:
+ cta.cta_contents = (ushort_t)
+ dtd->dtd_u.dtu_arr.ctr_contents;
+ cta.cta_index = (ushort_t)
+ dtd->dtd_u.dtu_arr.ctr_index;
+ cta.cta_nelems = dtd->dtd_u.dtu_arr.ctr_nelems;
+ bcopy(&cta, t, sizeof (cta));
+ t += sizeof (cta);
+ break;
+
+ case CTF_K_FUNCTION: {
+ ushort_t *argv = (ushort_t *)(uintptr_t)t;
+ uint_t argc;
+
+ for (argc = 0; argc < vlen; argc++)
+ *argv++ = (ushort_t)dtd->dtd_u.dtu_argv[argc];
+
+ if (vlen & 1)
+ *argv++ = 0; /* pad to 4-byte boundary */
+
+ t = (uchar_t *)argv;
+ break;
+ }
+
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ if (dtd->dtd_data.ctt_size < CTF_LSTRUCT_THRESH)
+ t = ctf_copy_smembers(dtd, (uint_t)(s - s0), t);
+ else
+ t = ctf_copy_lmembers(dtd, (uint_t)(s - s0), t);
+ s = ctf_copy_membnames(dtd, s);
+ break;
+
+ case CTF_K_ENUM:
+ t = ctf_copy_emembers(dtd, (uint_t)(s - s0), t);
+ s = ctf_copy_membnames(dtd, s);
+ break;
+ }
+ }
+
+ /*
+ * Finally, we are ready to ctf_bufopen() the new container. If this
+ * is successful, we then switch nfp and fp and free the old container.
+ */
+ ctf_data_protect(buf, size);
+ cts.cts_name = _CTF_SECTION;
+ cts.cts_type = SHT_PROGBITS;
+ cts.cts_flags = 0;
+ cts.cts_data = buf;
+ cts.cts_size = size;
+ cts.cts_entsize = 1;
+ cts.cts_offset = 0;
+
+ if ((nfp = ctf_bufopen(&cts, NULL, NULL, &err)) == NULL) {
+ ctf_data_free(buf, size);
+ return (ctf_set_errno(fp, err));
+ }
+
+ (void) ctf_setmodel(nfp, ctf_getmodel(fp));
+ (void) ctf_import(nfp, fp->ctf_parent);
+
+ nfp->ctf_refcnt = fp->ctf_refcnt;
+ nfp->ctf_flags |= fp->ctf_flags & ~LCTF_DIRTY;
+ nfp->ctf_data.cts_data = NULL; /* force ctf_data_free() on close */
+ nfp->ctf_dthash = fp->ctf_dthash;
+ nfp->ctf_dthashlen = fp->ctf_dthashlen;
+ nfp->ctf_dtdefs = fp->ctf_dtdefs;
+ nfp->ctf_dtstrlen = fp->ctf_dtstrlen;
+ nfp->ctf_dtnextid = fp->ctf_dtnextid;
+ nfp->ctf_dtoldid = fp->ctf_dtnextid - 1;
+ nfp->ctf_specific = fp->ctf_specific;
+
+ fp->ctf_dthash = NULL;
+ fp->ctf_dthashlen = 0;
+ bzero(&fp->ctf_dtdefs, sizeof (ctf_list_t));
+
+ bcopy(fp, &ofp, sizeof (ctf_file_t));
+ bcopy(nfp, fp, sizeof (ctf_file_t));
+ bcopy(&ofp, nfp, sizeof (ctf_file_t));
+
+ /*
+ * Initialize the ctf_lookup_by_name top-level dictionary. We keep an
+ * array of type name prefixes and the corresponding ctf_hash to use.
+ * NOTE: This code must be kept in sync with the code in ctf_bufopen().
+ */
+ fp->ctf_lookups[0].ctl_hash = &fp->ctf_structs;
+ fp->ctf_lookups[1].ctl_hash = &fp->ctf_unions;
+ fp->ctf_lookups[2].ctl_hash = &fp->ctf_enums;
+ fp->ctf_lookups[3].ctl_hash = &fp->ctf_names;
+
+ nfp->ctf_refcnt = 1; /* force nfp to be freed */
+ ctf_close(nfp);
+
+ return (0);
+}
+
+void
+ctf_dtd_insert(ctf_file_t *fp, ctf_dtdef_t *dtd)
+{
+ ulong_t h = dtd->dtd_type & (fp->ctf_dthashlen - 1);
+
+ dtd->dtd_hash = fp->ctf_dthash[h];
+ fp->ctf_dthash[h] = dtd;
+ ctf_list_append(&fp->ctf_dtdefs, dtd);
+}
+
+void
+ctf_dtd_delete(ctf_file_t *fp, ctf_dtdef_t *dtd)
+{
+ ulong_t h = dtd->dtd_type & (fp->ctf_dthashlen - 1);
+ ctf_dtdef_t *p, **q = &fp->ctf_dthash[h];
+ ctf_dmdef_t *dmd, *nmd;
+ size_t len;
+
+ for (p = *q; p != NULL; p = p->dtd_hash) {
+ if (p != dtd)
+ q = &p->dtd_hash;
+ else
+ break;
+ }
+
+ if (p != NULL)
+ *q = p->dtd_hash;
+
+ switch (CTF_INFO_KIND(dtd->dtd_data.ctt_info)) {
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ case CTF_K_ENUM:
+ for (dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = nmd) {
+ if (dmd->dmd_name != NULL) {
+ len = strlen(dmd->dmd_name) + 1;
+ ctf_free(dmd->dmd_name, len);
+ fp->ctf_dtstrlen -= len;
+ }
+ nmd = ctf_list_next(dmd);
+ ctf_free(dmd, sizeof (ctf_dmdef_t));
+ }
+ break;
+ case CTF_K_FUNCTION:
+ ctf_free(dtd->dtd_u.dtu_argv, sizeof (ctf_id_t) *
+ CTF_INFO_VLEN(dtd->dtd_data.ctt_info));
+ break;
+ }
+
+ if (dtd->dtd_name) {
+ len = strlen(dtd->dtd_name) + 1;
+ ctf_free(dtd->dtd_name, len);
+ fp->ctf_dtstrlen -= len;
+ }
+
+ ctf_list_delete(&fp->ctf_dtdefs, dtd);
+ ctf_free(dtd, sizeof (ctf_dtdef_t));
+}
+
+ctf_dtdef_t *
+ctf_dtd_lookup(ctf_file_t *fp, ctf_id_t type)
+{
+ ulong_t h = type & (fp->ctf_dthashlen - 1);
+ ctf_dtdef_t *dtd;
+
+ if (fp->ctf_dthash == NULL)
+ return (NULL);
+
+ for (dtd = fp->ctf_dthash[h]; dtd != NULL; dtd = dtd->dtd_hash) {
+ if (dtd->dtd_type == type)
+ break;
+ }
+
+ return (dtd);
+}
+
+/*
+ * Discard all of the dynamic type definitions that have been added to the
+ * container since the last call to ctf_update(). We locate such types by
+ * scanning the list and deleting elements that have type IDs greater than
+ * ctf_dtoldid, which is set by ctf_update(), above.
+ */
+int
+ctf_discard(ctf_file_t *fp)
+{
+ ctf_dtdef_t *dtd, *ntd VBDTMSC(NULL);
+
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno(fp, ECTF_RDONLY));
+
+ if (!(fp->ctf_flags & LCTF_DIRTY))
+ return (0); /* no update required */
+
+ for (dtd = ctf_list_next(&fp->ctf_dtdefs); dtd != NULL; dtd = ntd) {
+ if (dtd->dtd_type <= (intptr_t /*vbox*/)fp->ctf_dtoldid)
+ continue; /* skip types that have been committed */
+
+ ntd = ctf_list_next(dtd);
+ ctf_dtd_delete(fp, dtd);
+ }
+
+ fp->ctf_dtnextid = fp->ctf_dtoldid + 1;
+ fp->ctf_flags &= ~LCTF_DIRTY;
+
+ return (0);
+}
+
+static ctf_id_t
+ctf_add_generic(ctf_file_t *fp, uint_t flag, const char *name, ctf_dtdef_t **rp)
+{
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+ char *s = NULL;
+
+ if (flag != CTF_ADD_NONROOT && flag != CTF_ADD_ROOT)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno(fp, ECTF_RDONLY));
+
+ if (CTF_INDEX_TO_TYPE(fp->ctf_dtnextid, 1) > CTF_MAX_TYPE)
+ return (ctf_set_errno(fp, ECTF_FULL));
+
+ if ((dtd = ctf_alloc(sizeof (ctf_dtdef_t))) == NULL)
+ return (ctf_set_errno(fp, EAGAIN));
+
+ if (name != NULL && (s = ctf_strdup(name)) == NULL) {
+ ctf_free(dtd, sizeof (ctf_dtdef_t));
+ return (ctf_set_errno(fp, EAGAIN));
+ }
+
+ type = fp->ctf_dtnextid++;
+ type = CTF_INDEX_TO_TYPE(type, (fp->ctf_flags & LCTF_CHILD));
+
+ bzero(dtd, sizeof (ctf_dtdef_t));
+ dtd->dtd_name = s;
+ dtd->dtd_type = type;
+
+ if (s != NULL)
+ fp->ctf_dtstrlen += strlen(s) + 1;
+
+ ctf_dtd_insert(fp, dtd);
+ fp->ctf_flags |= LCTF_DIRTY;
+
+ *rp = dtd;
+ return (type);
+}
+
+/*
+ * When encoding integer sizes, we want to convert a byte count in the range
+ * 1-8 to the closest power of 2 (e.g. 3->4, 5->8, etc). The clp2() function
+ * is a clever implementation from "Hacker's Delight" by Henry Warren, Jr.
+ */
+static size_t
+clp2(size_t x)
+{
+ x--;
+
+ x |= (x >> 1);
+ x |= (x >> 2);
+ x |= (x >> 4);
+ x |= (x >> 8);
+ x |= (x >> 16);
+
+ return (x + 1);
+}
+
+static ctf_id_t
+ctf_add_encoded(ctf_file_t *fp, uint_t flag,
+ const char *name, const ctf_encoding_t *ep, uint_t kind)
+{
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ if (ep == NULL)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, 0);
+ dtd->dtd_data.ctt_size = VBDTCAST(ushort_t)clp2(P2ROUNDUP(ep->cte_bits, NBBY) / NBBY);
+ dtd->dtd_u.dtu_enc = *ep;
+
+ return (type);
+}
+
+static ctf_id_t
+ctf_add_reftype(ctf_file_t *fp, uint_t flag, ctf_id_t ref, uint_t kind)
+{
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ if (ref == CTF_ERR || ref < 0 || ref > CTF_MAX_TYPE)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, 0);
+ dtd->dtd_data.ctt_type = (ushort_t)ref;
+
+ return (type);
+}
+
+ctf_id_t
+ctf_add_integer(ctf_file_t *fp, uint_t flag,
+ const char *name, const ctf_encoding_t *ep)
+{
+ return (ctf_add_encoded(fp, flag, name, ep, CTF_K_INTEGER));
+}
+
+ctf_id_t
+ctf_add_float(ctf_file_t *fp, uint_t flag,
+ const char *name, const ctf_encoding_t *ep)
+{
+ return (ctf_add_encoded(fp, flag, name, ep, CTF_K_FLOAT));
+}
+
+ctf_id_t
+ctf_add_pointer(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
+{
+ return (ctf_add_reftype(fp, flag, ref, CTF_K_POINTER));
+}
+
+ctf_id_t
+ctf_add_array(ctf_file_t *fp, uint_t flag, const ctf_arinfo_t *arp)
+{
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ if (arp == NULL)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_ARRAY, flag, 0);
+ dtd->dtd_data.ctt_size = 0;
+ dtd->dtd_u.dtu_arr = *arp;
+
+ return (type);
+}
+
+int
+ctf_set_array(ctf_file_t *fp, ctf_id_t type, const ctf_arinfo_t *arp)
+{
+ ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, type);
+
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno(fp, ECTF_RDONLY));
+
+ if (dtd == NULL || CTF_INFO_KIND(dtd->dtd_data.ctt_info) != CTF_K_ARRAY)
+ return (ctf_set_errno(fp, ECTF_BADID));
+
+ fp->ctf_flags |= LCTF_DIRTY;
+ dtd->dtd_u.dtu_arr = *arp;
+
+ return (0);
+}
+
+ctf_id_t
+ctf_add_function(ctf_file_t *fp, uint_t flag,
+ const ctf_funcinfo_t *ctc, const ctf_id_t *argv)
+{
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+ uint_t vlen;
+ ctf_id_t *vdat = NULL;
+
+ if (ctc == NULL || (ctc->ctc_flags & ~CTF_FUNC_VARARG) != 0 ||
+ (ctc->ctc_argc != 0 && argv == NULL))
+ return (ctf_set_errno(fp, EINVAL));
+
+ vlen = ctc->ctc_argc;
+ if (ctc->ctc_flags & CTF_FUNC_VARARG)
+ vlen++; /* add trailing zero to indicate varargs (see below) */
+
+ if (vlen > CTF_MAX_VLEN)
+ return (ctf_set_errno(fp, EOVERFLOW));
+
+ if (vlen != 0 && (vdat = ctf_alloc(sizeof (ctf_id_t) * vlen)) == NULL)
+ return (ctf_set_errno(fp, EAGAIN));
+
+ if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR) {
+ ctf_free(vdat, sizeof (ctf_id_t) * vlen);
+ return (CTF_ERR); /* errno is set for us */
+ }
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_FUNCTION, flag, vlen);
+ dtd->dtd_data.ctt_type = (ushort_t)ctc->ctc_return;
+
+ bcopy(argv, vdat, sizeof (ctf_id_t) * ctc->ctc_argc);
+ if (ctc->ctc_flags & CTF_FUNC_VARARG)
+ vdat[vlen - 1] = 0; /* add trailing zero to indicate varargs */
+ dtd->dtd_u.dtu_argv = vdat;
+
+ return (type);
+}
+
+ctf_id_t
+ctf_add_struct(ctf_file_t *fp, uint_t flag, const char *name)
+{
+ ctf_hash_t *hp = &fp->ctf_structs;
+ ctf_helem_t *hep = NULL;
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ if (name != NULL)
+ hep = ctf_hash_lookup(hp, fp, name, strlen(name));
+
+ if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD)
+ dtd = ctf_dtd_lookup(fp, type = hep->h_type);
+ else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_STRUCT, flag, 0);
+ dtd->dtd_data.ctt_size = 0;
+
+ return (type);
+}
+
+ctf_id_t
+ctf_add_union(ctf_file_t *fp, uint_t flag, const char *name)
+{
+ ctf_hash_t *hp = &fp->ctf_unions;
+ ctf_helem_t *hep = NULL;
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ if (name != NULL)
+ hep = ctf_hash_lookup(hp, fp, name, strlen(name));
+
+ if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD)
+ dtd = ctf_dtd_lookup(fp, type = hep->h_type);
+ else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_UNION, flag, 0);
+ dtd->dtd_data.ctt_size = 0;
+
+ return (type);
+}
+
+ctf_id_t
+ctf_add_enum(ctf_file_t *fp, uint_t flag, const char *name)
+{
+ ctf_hash_t *hp = &fp->ctf_enums;
+ ctf_helem_t *hep = NULL;
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ if (name != NULL)
+ hep = ctf_hash_lookup(hp, fp, name, strlen(name));
+
+ if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD)
+ dtd = ctf_dtd_lookup(fp, type = hep->h_type);
+ else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_ENUM, flag, 0);
+ dtd->dtd_data.ctt_size = VBDTCAST(ushort_t)fp->ctf_dmodel->ctd_int;
+
+ return (type);
+}
+
+ctf_id_t
+ctf_add_forward(ctf_file_t *fp, uint_t flag, const char *name, uint_t kind)
+{
+ ctf_hash_t *hp;
+ ctf_helem_t *hep;
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ switch (kind) {
+ case CTF_K_STRUCT:
+ hp = &fp->ctf_structs;
+ break;
+ case CTF_K_UNION:
+ hp = &fp->ctf_unions;
+ break;
+ case CTF_K_ENUM:
+ hp = &fp->ctf_enums;
+ break;
+ default:
+ return (ctf_set_errno(fp, ECTF_NOTSUE));
+ }
+
+ /*
+ * If the type is already defined or exists as a forward tag, just
+ * return the ctf_id_t of the existing definition.
+ */
+ if (name != NULL && (hep = ctf_hash_lookup(hp,
+ fp, name, strlen(name))) != NULL)
+ return (hep->h_type);
+
+ if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_FORWARD, flag, 0);
+ dtd->dtd_data.ctt_type = kind;
+
+ return (type);
+}
+
+ctf_id_t
+ctf_add_typedef(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref)
+{
+ ctf_dtdef_t *dtd;
+ ctf_id_t type;
+
+ if (ref == CTF_ERR || ref < 0 || ref > CTF_MAX_TYPE)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_TYPEDEF, flag, 0);
+ dtd->dtd_data.ctt_type = (ushort_t)ref;
+
+ return (type);
+}
+
+ctf_id_t
+ctf_add_volatile(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
+{
+ return (ctf_add_reftype(fp, flag, ref, CTF_K_VOLATILE));
+}
+
+ctf_id_t
+ctf_add_const(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
+{
+ return (ctf_add_reftype(fp, flag, ref, CTF_K_CONST));
+}
+
+ctf_id_t
+ctf_add_restrict(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
+{
+ return (ctf_add_reftype(fp, flag, ref, CTF_K_RESTRICT));
+}
+
+int
+ctf_add_enumerator(ctf_file_t *fp, ctf_id_t enid, const char *name, int value)
+{
+ ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, enid);
+ ctf_dmdef_t *dmd;
+
+ uint_t kind, vlen, root;
+ char *s;
+
+ if (name == NULL)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno(fp, ECTF_RDONLY));
+
+ if (dtd == NULL)
+ return (ctf_set_errno(fp, ECTF_BADID));
+
+ kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
+ root = CTF_INFO_ISROOT(dtd->dtd_data.ctt_info);
+ vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
+
+ if (kind != CTF_K_ENUM)
+ return (ctf_set_errno(fp, ECTF_NOTENUM));
+
+ if (vlen == CTF_MAX_VLEN)
+ return (ctf_set_errno(fp, ECTF_DTFULL));
+
+ for (dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next(dmd)) {
+ if (strcmp(dmd->dmd_name, name) == 0)
+ return (ctf_set_errno(fp, ECTF_DUPMEMBER));
+ }
+
+ if ((dmd = ctf_alloc(sizeof (ctf_dmdef_t))) == NULL)
+ return (ctf_set_errno(fp, EAGAIN));
+
+ if ((s = ctf_strdup(name)) == NULL) {
+ ctf_free(dmd, sizeof (ctf_dmdef_t));
+ return (ctf_set_errno(fp, EAGAIN));
+ }
+
+ dmd->dmd_name = s;
+ dmd->dmd_type = CTF_ERR;
+ dmd->dmd_offset = 0;
+ dmd->dmd_value = value;
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, root, vlen + 1);
+ ctf_list_append(&dtd->dtd_u.dtu_members, dmd);
+
+ fp->ctf_dtstrlen += strlen(s) + 1;
+ fp->ctf_flags |= LCTF_DIRTY;
+
+ return (0);
+}
+
+int
+ctf_add_member(ctf_file_t *fp, ctf_id_t souid, const char *name, ctf_id_t type)
+{
+ ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, souid);
+ ctf_dmdef_t *dmd;
+
+ ssize_t msize, malign, ssize;
+ uint_t kind, vlen, root;
+ char *s = NULL;
+
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno(fp, ECTF_RDONLY));
+
+ if (dtd == NULL)
+ return (ctf_set_errno(fp, ECTF_BADID));
+
+ kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
+ root = CTF_INFO_ISROOT(dtd->dtd_data.ctt_info);
+ vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
+
+ if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
+ return (ctf_set_errno(fp, ECTF_NOTSOU));
+
+ if (vlen == CTF_MAX_VLEN)
+ return (ctf_set_errno(fp, ECTF_DTFULL));
+
+ if (name != NULL) {
+ for (dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next(dmd)) {
+ if (dmd->dmd_name != NULL &&
+ strcmp(dmd->dmd_name, name) == 0)
+ return (ctf_set_errno(fp, ECTF_DUPMEMBER));
+ }
+ }
+
+ if ((msize = ctf_type_size(fp, type)) == CTF_ERR ||
+ (malign = ctf_type_align(fp, type)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((dmd = ctf_alloc(sizeof (ctf_dmdef_t))) == NULL)
+ return (ctf_set_errno(fp, EAGAIN));
+
+ if (name != NULL && (s = ctf_strdup(name)) == NULL) {
+ ctf_free(dmd, sizeof (ctf_dmdef_t));
+ return (ctf_set_errno(fp, EAGAIN));
+ }
+
+ dmd->dmd_name = s;
+ dmd->dmd_type = type;
+ dmd->dmd_value = -1;
+
+ if (kind == CTF_K_STRUCT && vlen != 0) {
+ ctf_dmdef_t *lmd = ctf_list_prev(&dtd->dtd_u.dtu_members);
+ ctf_id_t ltype = ctf_type_resolve(fp, lmd->dmd_type);
+ size_t off = lmd->dmd_offset;
+
+ ctf_encoding_t linfo;
+ ssize_t lsize;
+
+ if (ctf_type_encoding(fp, ltype, &linfo) != CTF_ERR)
+ off += linfo.cte_bits;
+ else if ((lsize = ctf_type_size(fp, ltype)) != CTF_ERR)
+ off += lsize * NBBY;
+
+ /*
+ * Round up the offset of the end of the last member to the
+ * next byte boundary, convert 'off' to bytes, and then round
+ * it up again to the next multiple of the alignment required
+ * by the new member. Finally, convert back to bits and store
+ * the result in dmd_offset. Technically we could do more
+ * efficient packing if the new member is a bit-field, but
+ * we're the "compiler" and ANSI says we can do as we choose.
+ */
+ off = roundup(off, NBBY) / NBBY;
+ off = roundup(off, MAX(malign, 1));
+ dmd->dmd_offset = off * NBBY;
+ ssize = off + msize;
+ } else {
+ dmd->dmd_offset = 0;
+ ssize = ctf_get_ctt_size(fp, &dtd->dtd_data, NULL, NULL);
+ ssize = MAX(ssize, msize);
+ }
+
+ if (ssize > CTF_MAX_SIZE) {
+ dtd->dtd_data.ctt_size = CTF_LSIZE_SENT;
+ dtd->dtd_data.ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(ssize);
+ dtd->dtd_data.ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(ssize);
+ } else
+ dtd->dtd_data.ctt_size = (ushort_t)ssize;
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, root, vlen + 1);
+ ctf_list_append(&dtd->dtd_u.dtu_members, dmd);
+
+ if (s != NULL)
+ fp->ctf_dtstrlen += strlen(s) + 1;
+
+ fp->ctf_flags |= LCTF_DIRTY;
+ return (0);
+}
+
+static int
+enumcmp(const char *name, int value, void *arg)
+{
+ ctf_bundle_t *ctb = arg;
+ int bvalue;
+
+ return (ctf_enum_value(ctb->ctb_file, ctb->ctb_type,
+ name, &bvalue) == CTF_ERR || value != bvalue);
+}
+
+static int
+enumadd(const char *name, int value, void *arg)
+{
+ ctf_bundle_t *ctb = arg;
+
+ return (ctf_add_enumerator(ctb->ctb_file, ctb->ctb_type,
+ name, value) == CTF_ERR);
+}
+
+/*ARGSUSED*/
+static int
+membcmp(const char *name, ctf_id_t type, ulong_t offset, void *arg)
+{
+ ctf_bundle_t *ctb = arg;
+ ctf_membinfo_t ctm;
+ RT_NOREF1(type);
+
+ return (ctf_member_info(ctb->ctb_file, ctb->ctb_type,
+ name, &ctm) == CTF_ERR || ctm.ctm_offset != offset);
+}
+
+static int
+membadd(const char *name, ctf_id_t type, ulong_t offset, void *arg)
+{
+ ctf_bundle_t *ctb = arg;
+ ctf_dmdef_t *dmd;
+ char *s = NULL;
+
+ if ((dmd = ctf_alloc(sizeof (ctf_dmdef_t))) == NULL)
+ return (ctf_set_errno(ctb->ctb_file, EAGAIN));
+
+ if (name != NULL && (s = ctf_strdup(name)) == NULL) {
+ ctf_free(dmd, sizeof (ctf_dmdef_t));
+ return (ctf_set_errno(ctb->ctb_file, EAGAIN));
+ }
+
+ /*
+ * For now, dmd_type is copied as the src_fp's type; it is reset to an
+ * equivalent dst_fp type by a final loop in ctf_add_type(), below.
+ */
+ dmd->dmd_name = s;
+ dmd->dmd_type = type;
+ dmd->dmd_offset = offset;
+ dmd->dmd_value = -1;
+
+ ctf_list_append(&ctb->ctb_dtd->dtd_u.dtu_members, dmd);
+
+ if (s != NULL)
+ ctb->ctb_file->ctf_dtstrlen += strlen(s) + 1;
+
+ ctb->ctb_file->ctf_flags |= LCTF_DIRTY;
+ return (0);
+}
+
+/*
+ * The ctf_add_type routine is used to copy a type from a source CTF container
+ * to a dynamic destination container. This routine operates recursively by
+ * following the source type's links and embedded member types. If the
+ * destination container already contains a named type which has the same
+ * attributes, then we succeed and return this type but no changes occur.
+ */
+ctf_id_t
+ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
+{
+ ctf_id_t dst_type = CTF_ERR;
+ uint_t dst_kind = CTF_K_UNKNOWN;
+
+ const ctf_type_t *tp;
+ const char *name;
+ uint_t kind, flag, vlen;
+
+ ctf_bundle_t src, dst;
+ ctf_encoding_t src_en, dst_en;
+ ctf_arinfo_t src_ar, dst_ar;
+
+ ctf_dtdef_t *dtd;
+ ctf_funcinfo_t ctc;
+ ssize_t size;
+
+ ctf_hash_t *hp;
+ ctf_helem_t *hep;
+
+ if (!(dst_fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno(dst_fp, ECTF_RDONLY));
+
+ if ((tp = ctf_lookup_by_id(&src_fp, src_type)) == NULL)
+ return (ctf_set_errno(dst_fp, ctf_errno(src_fp)));
+
+ name = ctf_strptr(src_fp, tp->ctt_name);
+ kind = LCTF_INFO_KIND(src_fp, tp->ctt_info);
+ flag = LCTF_INFO_ROOT(src_fp, tp->ctt_info);
+ vlen = LCTF_INFO_VLEN(src_fp, tp->ctt_info);
+
+ switch (kind) {
+ case CTF_K_STRUCT:
+ hp = &dst_fp->ctf_structs;
+ break;
+ case CTF_K_UNION:
+ hp = &dst_fp->ctf_unions;
+ break;
+ case CTF_K_ENUM:
+ hp = &dst_fp->ctf_enums;
+ break;
+ default:
+ hp = &dst_fp->ctf_names;
+ break;
+ }
+
+ /*
+ * If the source type has a name and is a root type (visible at the
+ * top-level scope), lookup the name in the destination container and
+ * verify that it is of the same kind before we do anything else.
+ */
+ if ((flag & CTF_ADD_ROOT) && name[0] != '\0' &&
+ (hep = ctf_hash_lookup(hp, dst_fp, name, strlen(name))) != NULL) {
+ dst_type = (ctf_id_t)hep->h_type;
+ dst_kind = ctf_type_kind(dst_fp, dst_type);
+ }
+
+ /*
+ * If an identically named dst_type exists, fail with ECTF_CONFLICT
+ * unless dst_type is a forward declaration and src_type is a struct,
+ * union, or enum (i.e. the definition of the previous forward decl).
+ */
+ if (dst_type != CTF_ERR && dst_kind != kind && (
+ dst_kind != CTF_K_FORWARD || (kind != CTF_K_ENUM &&
+ kind != CTF_K_STRUCT && kind != CTF_K_UNION)))
+ return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
+
+ /*
+ * If the non-empty name was not found in the appropriate hash, search
+ * the list of pending dynamic definitions that are not yet committed.
+ * If a matching name and kind are found, assume this is the type that
+ * we are looking for. This is necessary to permit ctf_add_type() to
+ * operate recursively on entities such as a struct that contains a
+ * pointer member that refers to the same struct type.
+ */
+ if (dst_type == CTF_ERR && name[0] != '\0') {
+ for (dtd = ctf_list_prev(&dst_fp->ctf_dtdefs); dtd != NULL &&
+ dtd->dtd_type > (intptr_t /*vbox*/)dst_fp->ctf_dtoldid;
+ dtd = ctf_list_prev(dtd)) {
+ if ((uint_t)CTF_INFO_KIND(dtd->dtd_data.ctt_info) == kind &&
+ dtd->dtd_name != NULL &&
+ strcmp(dtd->dtd_name, name) == 0)
+ return (dtd->dtd_type);
+ }
+ }
+
+ src.ctb_file = src_fp;
+ src.ctb_type = src_type;
+ src.ctb_dtd = NULL;
+
+ dst.ctb_file = dst_fp;
+ dst.ctb_type = dst_type;
+ dst.ctb_dtd = NULL;
+
+ /*
+ * Now perform kind-specific processing. If dst_type is CTF_ERR, then
+ * we add a new type with the same properties as src_type to dst_fp.
+ * If dst_type is not CTF_ERR, then we verify that dst_type has the
+ * same attributes as src_type. We recurse for embedded references.
+ */
+ switch (kind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ if (ctf_type_encoding(src_fp, src_type, &src_en) != 0)
+ return (ctf_set_errno(dst_fp, ctf_errno(src_fp)));
+
+ if (dst_type != CTF_ERR) {
+ if (ctf_type_encoding(dst_fp, dst_type, &dst_en) != 0)
+ return (CTF_ERR); /* errno is set for us */
+
+ if (bcmp(&src_en, &dst_en, sizeof (ctf_encoding_t)))
+ return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
+
+ } else if (kind == CTF_K_INTEGER) {
+ dst_type = ctf_add_integer(dst_fp, flag, name, &src_en);
+ } else
+ dst_type = ctf_add_float(dst_fp, flag, name, &src_en);
+ break;
+
+ case CTF_K_POINTER:
+ case CTF_K_VOLATILE:
+ case CTF_K_CONST:
+ case CTF_K_RESTRICT:
+ src_type = ctf_type_reference(src_fp, src_type);
+ src_type = ctf_add_type(dst_fp, src_fp, src_type);
+
+ if (src_type == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dst_type = ctf_add_reftype(dst_fp, flag, src_type, kind);
+ break;
+
+ case CTF_K_ARRAY:
+ if (ctf_array_info(src_fp, src_type, &src_ar) == CTF_ERR)
+ return (ctf_set_errno(dst_fp, ctf_errno(src_fp)));
+
+ src_ar.ctr_contents =
+ ctf_add_type(dst_fp, src_fp, src_ar.ctr_contents);
+ src_ar.ctr_index =
+ ctf_add_type(dst_fp, src_fp, src_ar.ctr_index);
+ src_ar.ctr_nelems = src_ar.ctr_nelems;
+
+ if (src_ar.ctr_contents == CTF_ERR ||
+ src_ar.ctr_index == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ if (dst_type != CTF_ERR) {
+ if (ctf_array_info(dst_fp, dst_type, &dst_ar) != 0)
+ return (CTF_ERR); /* errno is set for us */
+
+ if (bcmp(&src_ar, &dst_ar, sizeof (ctf_arinfo_t)))
+ return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
+ } else
+ dst_type = ctf_add_array(dst_fp, flag, &src_ar);
+ break;
+
+ case CTF_K_FUNCTION:
+ ctc.ctc_return = ctf_add_type(dst_fp, src_fp, tp->ctt_type);
+ ctc.ctc_argc = 0;
+ ctc.ctc_flags = 0;
+
+ if (ctc.ctc_return == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dst_type = ctf_add_function(dst_fp, flag, &ctc, NULL);
+ break;
+
+ case CTF_K_STRUCT:
+ case CTF_K_UNION: {
+ ctf_dmdef_t *dmd;
+ int errs = 0;
+
+ /*
+ * Technically to match a struct or union we need to check both
+ * ways (src members vs. dst, dst members vs. src) but we make
+ * this more optimal by only checking src vs. dst and comparing
+ * the total size of the structure (which we must do anyway)
+ * which covers the possibility of dst members not in src.
+ * This optimization can be defeated for unions, but is so
+ * pathological as to render it irrelevant for our purposes.
+ */
+ if (dst_type != CTF_ERR && dst_kind != CTF_K_FORWARD) {
+ if (ctf_type_size(src_fp, src_type) !=
+ ctf_type_size(dst_fp, dst_type))
+ return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
+
+ if (ctf_member_iter(src_fp, src_type, membcmp, &dst))
+ return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
+
+ break;
+ }
+
+ /*
+ * Unlike the other cases, copying structs and unions is done
+ * manually so as to avoid repeated lookups in ctf_add_member
+ * and to ensure the exact same member offsets as in src_type.
+ */
+ dst_type = ctf_add_generic(dst_fp, flag, name, &dtd);
+ if (dst_type == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ dst.ctb_type = dst_type;
+ dst.ctb_dtd = dtd;
+
+ if (ctf_member_iter(src_fp, src_type, membadd, &dst) != 0)
+ errs++; /* increment errs and fail at bottom of case */
+
+ if ((size = ctf_type_size(src_fp, src_type)) > CTF_MAX_SIZE) {
+ dtd->dtd_data.ctt_size = CTF_LSIZE_SENT;
+ dtd->dtd_data.ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size);
+ dtd->dtd_data.ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size);
+ } else
+ dtd->dtd_data.ctt_size = (ushort_t)size;
+
+ dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, vlen);
+
+ /*
+ * Make a final pass through the members changing each dmd_type
+ * (a src_fp type) to an equivalent type in dst_fp. We pass
+ * through all members, leaving any that fail set to CTF_ERR.
+ */
+ for (dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next(dmd)) {
+ if ((dmd->dmd_type = ctf_add_type(dst_fp, src_fp,
+ dmd->dmd_type)) == CTF_ERR)
+ errs++;
+ }
+
+ if (errs)
+ return (CTF_ERR); /* errno is set for us */
+ break;
+ }
+
+ case CTF_K_ENUM:
+ if (dst_type != CTF_ERR && dst_kind != CTF_K_FORWARD) {
+ if (ctf_enum_iter(src_fp, src_type, enumcmp, &dst) ||
+ ctf_enum_iter(dst_fp, dst_type, enumcmp, &src))
+ return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
+ } else {
+ dst_type = ctf_add_enum(dst_fp, flag, name);
+ if ((dst.ctb_type = dst_type) == CTF_ERR ||
+ ctf_enum_iter(src_fp, src_type, enumadd, &dst))
+ return (CTF_ERR); /* errno is set for us */
+ }
+ break;
+
+ case CTF_K_FORWARD:
+ if (dst_type == CTF_ERR) {
+ dst_type = ctf_add_forward(dst_fp,
+ flag, name, CTF_K_STRUCT); /* assume STRUCT */
+ }
+ break;
+
+ case CTF_K_TYPEDEF:
+ src_type = ctf_type_reference(src_fp, src_type);
+ src_type = ctf_add_type(dst_fp, src_fp, src_type);
+
+ if (src_type == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ /*
+ * If dst_type is not CTF_ERR at this point, we should check if
+ * ctf_type_reference(dst_fp, dst_type) != src_type and if so
+ * fail with ECTF_CONFLICT. However, this causes problems with
+ * <sys/types.h> typedefs that vary based on things like if
+ * _ILP32x then pid_t is int otherwise long. We therefore omit
+ * this check and assume that if the identically named typedef
+ * already exists in dst_fp, it is correct or equivalent.
+ */
+ if (dst_type == CTF_ERR) {
+ dst_type = ctf_add_typedef(dst_fp, flag,
+ name, src_type);
+ }
+ break;
+
+ default:
+ return (ctf_set_errno(dst_fp, ECTF_CORRUPT));
+ }
+
+ return (dst_type);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c
new file mode 100644
index 00000000..f544d8f6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c
@@ -0,0 +1,190 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+/*
+ * CTF Declaration Stack
+ *
+ * In order to implement ctf_type_name(), we must convert a type graph back
+ * into a C type declaration. Unfortunately, a type graph represents a storage
+ * class ordering of the type whereas a type declaration must obey the C rules
+ * for operator precedence, and the two orderings are frequently in conflict.
+ * For example, consider these CTF type graphs and their C declarations:
+ *
+ * CTF_K_POINTER -> CTF_K_FUNCTION -> CTF_K_INTEGER : int (*)()
+ * CTF_K_POINTER -> CTF_K_ARRAY -> CTF_K_INTEGER : int (*)[]
+ *
+ * In each case, parentheses are used to raise operator * to higher lexical
+ * precedence, so the string form of the C declaration cannot be constructed by
+ * walking the type graph links and forming the string from left to right.
+ *
+ * The functions in this file build a set of stacks from the type graph nodes
+ * corresponding to the C operator precedence levels in the appropriate order.
+ * The code in ctf_type_name() can then iterate over the levels and nodes in
+ * lexical precedence order and construct the final C declaration string.
+ */
+
+#include <ctf_impl.h>
+
+void
+ctf_decl_init(ctf_decl_t *cd, char *buf, size_t len)
+{
+ int i;
+
+ bzero(cd, sizeof (ctf_decl_t));
+
+ for (i = CTF_PREC_BASE; i < CTF_PREC_MAX; i++)
+ cd->cd_order[i] = CTF_PREC_BASE - 1;
+
+ cd->cd_qualp = CTF_PREC_BASE;
+ cd->cd_ordp = CTF_PREC_BASE;
+
+ cd->cd_buf = buf;
+ cd->cd_ptr = buf;
+ cd->cd_end = buf + len;
+}
+
+void
+ctf_decl_fini(ctf_decl_t *cd)
+{
+ ctf_decl_node_t *cdp, *ndp;
+ int i;
+
+ for (i = CTF_PREC_BASE; i < CTF_PREC_MAX; i++) {
+ for (cdp = ctf_list_next(&cd->cd_nodes[i]);
+ cdp != NULL; cdp = ndp) {
+ ndp = ctf_list_next(cdp);
+ ctf_free(cdp, sizeof (ctf_decl_node_t));
+ }
+ }
+}
+
+void
+ctf_decl_push(ctf_decl_t *cd, ctf_file_t *fp, ctf_id_t type)
+{
+ ctf_decl_node_t *cdp;
+ ctf_decl_prec_t prec;
+ uint_t kind, n = 1;
+ int is_qual = 0;
+
+ const ctf_type_t *tp;
+ ctf_arinfo_t ar;
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL) {
+ cd->cd_err = fp->ctf_errno;
+ return;
+ }
+
+ switch (kind = LCTF_INFO_KIND(fp, tp->ctt_info)) {
+ case CTF_K_ARRAY:
+ (void) ctf_array_info(fp, type, &ar);
+ ctf_decl_push(cd, fp, ar.ctr_contents);
+ n = ar.ctr_nelems;
+ prec = CTF_PREC_ARRAY;
+ break;
+
+ case CTF_K_TYPEDEF:
+ if (ctf_strptr(fp, tp->ctt_name)[0] == '\0') {
+ ctf_decl_push(cd, fp, tp->ctt_type);
+ return;
+ }
+ prec = CTF_PREC_BASE;
+ break;
+
+ case CTF_K_FUNCTION:
+ ctf_decl_push(cd, fp, tp->ctt_type);
+ prec = CTF_PREC_FUNCTION;
+ break;
+
+ case CTF_K_POINTER:
+ ctf_decl_push(cd, fp, tp->ctt_type);
+ prec = CTF_PREC_POINTER;
+ break;
+
+ case CTF_K_VOLATILE:
+ case CTF_K_CONST:
+ case CTF_K_RESTRICT:
+ ctf_decl_push(cd, fp, tp->ctt_type);
+ prec = cd->cd_qualp;
+ is_qual++;
+ break;
+
+ default:
+ prec = CTF_PREC_BASE;
+ }
+
+ if ((cdp = ctf_alloc(sizeof (ctf_decl_node_t))) == NULL) {
+ cd->cd_err = EAGAIN;
+ return;
+ }
+
+ cdp->cd_type = type;
+ cdp->cd_kind = kind;
+ cdp->cd_n = n;
+
+ if (ctf_list_next(&cd->cd_nodes[prec]) == NULL)
+ cd->cd_order[prec] = cd->cd_ordp++;
+
+ /*
+ * Reset cd_qualp to the highest precedence level that we've seen so
+ * far that can be qualified (CTF_PREC_BASE or CTF_PREC_POINTER).
+ */
+ if (prec > cd->cd_qualp && prec < CTF_PREC_ARRAY)
+ cd->cd_qualp = prec;
+
+ /*
+ * C array declarators are ordered inside out so prepend them. Also by
+ * convention qualifiers of base types precede the type specifier (e.g.
+ * const int vs. int const) even though the two forms are equivalent.
+ */
+ if (kind == CTF_K_ARRAY || (is_qual && prec == CTF_PREC_BASE))
+ ctf_list_prepend(&cd->cd_nodes[prec], cdp);
+ else
+ ctf_list_append(&cd->cd_nodes[prec], cdp);
+}
+
+/*PRINTFLIKE2*/
+void
+ctf_decl_sprintf(ctf_decl_t *cd, const char *format, ...)
+{
+ size_t len = (size_t)(cd->cd_end - cd->cd_ptr);
+ va_list ap;
+ size_t n;
+
+ va_start(ap, format);
+#ifndef VBOX
+ n = vsnprintf(cd->cd_ptr, len, format, ap);
+#else
+ n = RTStrPrintfV(cd->cd_ptr, len, format, ap);
+#endif
+ va_end(ap);
+
+ cd->cd_ptr += MIN(n, len);
+ cd->cd_len += n;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c
new file mode 100644
index 00000000..414cb075
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c
@@ -0,0 +1,99 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <ctf_impl.h>
+
+static const char *const _ctf_errlist[] = {
+ "File is not in CTF or ELF format", /* ECTF_FMT */
+ "File uses more recent ELF version than libctf", /* ECTF_ELFVERS */
+ "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */
+ "File is a different endian-ness than libctf", /* ECTF_ENDIAN */
+ "Symbol table uses invalid entry size", /* ECTF_SYMTAB */
+ "Symbol table data buffer is not valid", /* ECTF_SYMBAD */
+ "String table data buffer is not valid", /* ECTF_STRBAD */
+ "File data structure corruption detected", /* ECTF_CORRUPT */
+ "File does not contain CTF data", /* ECTF_NOCTFDATA */
+ "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */
+ "Symbol table information is not available", /* ECTF_NOSYMTAB */
+ "Type information is in parent and unavailable", /* ECTF_NOPARENT */
+ "Cannot import types with different data model", /* ECTF_DMODEL */
+ "Failed to mmap a needed data section", /* ECTF_MMAP */
+ "Decompression package SUNWzlib not installed", /* ECTF_ZMISSING */
+ "Failed to initialize decompression library", /* ECTF_ZINIT */
+ "Failed to allocate decompression buffer", /* ECTF_ZALLOC */
+ "Failed to decompress CTF data", /* ECTF_DECOMPRESS */
+ "External string table is not available", /* ECTF_STRTAB */
+ "String name offset is corrupt", /* ECTF_BADNAME */
+ "Invalid type identifier", /* ECTF_BADID */
+ "Type is not a struct or union", /* ECTF_NOTSOU */
+ "Type is not an enum", /* ECTF_NOTENUM */
+ "Type is not a struct, union, or enum", /* ECTF_NOTSUE */
+ "Type is not an integer or float", /* ECTF_NOTINTFP */
+ "Type is not an array", /* ECTF_NOTARRAY */
+ "Type does not reference another type", /* ECTF_NOTREF */
+ "Input buffer is too small for type name", /* ECTF_NAMELEN */
+ "No type information available for that name", /* ECTF_NOTYPE */
+ "Syntax error in type name", /* ECTF_SYNTAX */
+ "Symbol table entry is not a function", /* ECTF_NOTFUNC */
+ "No function information available for symbol", /* ECTF_NOFUNCDAT */
+ "Symbol table entry is not a data object", /* ECTF_NOTDATA */
+ "No type information available for symbol", /* ECTF_NOTYPEDAT */
+ "No label information available for that name", /* ECTF_NOLABEL */
+ "File does not contain any labels", /* ECTF_NOLABELDATA */
+ "Feature not supported", /* ECTF_NOTSUP */
+ "Invalid enum element name", /* ECTF_NOENUMNAM */
+ "Invalid member name", /* ECTF_NOMEMBNAM */
+ "CTF container is read-only", /* ECTF_RDONLY */
+ "Limit on number of dynamic type members reached", /* ECTF_DTFULL */
+ "Limit on number of dynamic types reached", /* ECTF_FULL */
+ "Duplicate member name definition", /* ECTF_DUPMEMBER */
+ "Conflicting type is already defined", /* ECTF_CONFLICT */
+};
+
+static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]);
+
+const char *
+ctf_errmsg(int error)
+{
+ const char *str;
+
+ if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr)
+ str = _ctf_errlist[error - ECTF_BASE];
+ else
+ str = ctf_strerror(error);
+
+ return (str ? str : "Unknown error");
+}
+
+int
+ctf_errno(ctf_file_t *fp)
+{
+ return (fp->ctf_errno);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c
new file mode 100644
index 00000000..e2f390c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c
@@ -0,0 +1,180 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <ctf_impl.h>
+
+static const ushort_t _CTF_EMPTY[1] = { 0 };
+
+int
+ctf_hash_create(ctf_hash_t *hp, ulong_t nelems)
+{
+ if (nelems > USHRT_MAX)
+ return (EOVERFLOW);
+
+ /*
+ * If the hash table is going to be empty, don't bother allocating any
+ * memory and make the only bucket point to a zero so lookups fail.
+ */
+ if (nelems == 0) {
+ bzero(hp, sizeof (ctf_hash_t));
+ hp->h_buckets = (ushort_t *)_CTF_EMPTY;
+ hp->h_nbuckets = 1;
+ return (0);
+ }
+
+ hp->h_nbuckets = 211; /* use a prime number of hash buckets */
+ hp->h_nelems = nelems + 1; /* we use index zero as a sentinel */
+ hp->h_free = 1; /* first free element is index 1 */
+
+ hp->h_buckets = ctf_alloc(sizeof (ushort_t) * hp->h_nbuckets);
+ hp->h_chains = ctf_alloc(sizeof (ctf_helem_t) * hp->h_nelems);
+
+ if (hp->h_buckets == NULL || hp->h_chains == NULL) {
+ ctf_hash_destroy(hp);
+ return (EAGAIN);
+ }
+
+ bzero(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets);
+ bzero(hp->h_chains, sizeof (ctf_helem_t) * hp->h_nelems);
+
+ return (0);
+}
+
+uint_t
+ctf_hash_size(const ctf_hash_t *hp)
+{
+ return (hp->h_nelems ? hp->h_nelems - 1 : 0);
+}
+
+static ulong_t
+ctf_hash_compute(const char *key, size_t len)
+{
+ ulong_t g, h = 0;
+ const char *p, *q = key + len;
+ size_t n = 0;
+
+ for (p = key; p < q; p++, n++) {
+ h = (h << 4) + *p;
+
+ if ((g = (h & 0xf0000000)) != 0) {
+ h ^= (g >> 24);
+ h ^= g;
+ }
+ }
+
+ return (h);
+}
+
+int
+ctf_hash_insert(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name)
+{
+ ctf_strs_t *ctsp = &fp->ctf_str[CTF_NAME_STID(name)];
+ const char *str = ctsp->cts_strs + CTF_NAME_OFFSET(name);
+ ctf_helem_t *hep = &hp->h_chains[hp->h_free];
+ ulong_t h;
+
+ if (type == 0)
+ return (EINVAL);
+
+ if (hp->h_free >= hp->h_nelems)
+ return (EOVERFLOW);
+
+ if (ctsp->cts_strs == NULL)
+ return (ECTF_STRTAB);
+
+ if (ctsp->cts_len <= CTF_NAME_OFFSET(name))
+ return (ECTF_BADNAME);
+
+ if (str[0] == '\0')
+ return (0); /* just ignore empty strings on behalf of caller */
+
+ hep->h_name = name;
+ hep->h_type = type;
+ h = ctf_hash_compute(str, strlen(str)) % hp->h_nbuckets;
+ hep->h_next = hp->h_buckets[h];
+ hp->h_buckets[h] = hp->h_free++;
+
+ return (0);
+}
+
+/*
+ * Wrapper for ctf_hash_lookup/ctf_hash_insert: if the key is already in the
+ * hash, override the previous definition with this new official definition.
+ * If the key is not present, then call ctf_hash_insert() and hash it in.
+ */
+int
+ctf_hash_define(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name)
+{
+ const char *str = ctf_strptr(fp, name);
+ ctf_helem_t *hep = ctf_hash_lookup(hp, fp, str, strlen(str));
+
+ if (hep == NULL)
+ return (ctf_hash_insert(hp, fp, type, name));
+
+ hep->h_type = type;
+ return (0);
+}
+
+ctf_helem_t *
+ctf_hash_lookup(ctf_hash_t *hp, ctf_file_t *fp, const char *key, size_t len)
+{
+ ctf_helem_t *hep;
+ ctf_strs_t *ctsp;
+ const char *str;
+ ushort_t i;
+
+ ulong_t h = ctf_hash_compute(key, len) % hp->h_nbuckets;
+
+ for (i = hp->h_buckets[h]; i != 0; i = hep->h_next) {
+ hep = &hp->h_chains[i];
+ ctsp = &fp->ctf_str[CTF_NAME_STID(hep->h_name)];
+ str = ctsp->cts_strs + CTF_NAME_OFFSET(hep->h_name);
+
+ if (strncmp(key, str, len) == 0 && str[len] == '\0')
+ return (hep);
+ }
+
+ return (NULL);
+}
+
+void
+ctf_hash_destroy(ctf_hash_t *hp)
+{
+ if (hp->h_buckets != NULL && hp->h_nbuckets != 1) {
+ ctf_free(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets);
+ hp->h_buckets = NULL;
+ }
+
+ if (hp->h_chains != NULL) {
+ ctf_free(hp->h_chains, sizeof (ctf_helem_t) * hp->h_nelems);
+ hp->h_chains = NULL;
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h
new file mode 100644
index 00000000..b8dcc6db
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h
@@ -0,0 +1,353 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _CTF_IMPL_H
+#define _CTF_IMPL_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <sys/sysmacros.h>
+#else /* VBOX */
+# include <iprt/formats/elf32.h>
+# include <iprt/formats/elf64.h>
+# include <errno.h>
+# include "VBoxDTraceLibCWrappers.h"
+#endif /* VBOX */
+#include <sys/ctf_api.h>
+
+#ifdef _KERNEL
+
+#ifndef VBOX
+#include <sys/systm.h>
+#include <sys/cmn_err.h>
+#include <sys/varargs.h>
+#endif
+
+#define isspace(c) \
+ ((c) == ' ' || (c) == '\t' || (c) == '\n' || \
+ (c) == '\r' || (c) == '\f' || (c) == '\v')
+
+#define MAP_FAILED ((void *)-1)
+
+#else /* _KERNEL */
+
+#ifndef VBOX
+#include <strings.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <limits.h>
+#include <ctype.h>
+#endif
+
+#endif /* _KERNEL */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ctf_helem {
+ uint_t h_name; /* reference to name in string table */
+ ushort_t h_type; /* corresponding type ID number */
+ ushort_t h_next; /* index of next element in hash chain */
+} ctf_helem_t;
+
+typedef struct ctf_hash {
+ ushort_t *h_buckets; /* hash bucket array (chain indices) */
+ ctf_helem_t *h_chains; /* hash chains buffer */
+ ushort_t h_nbuckets; /* number of elements in bucket array */
+ ushort_t h_nelems; /* number of elements in hash table */
+ uint_t h_free; /* index of next free hash element */
+} ctf_hash_t;
+
+typedef struct ctf_strs {
+ const char *cts_strs; /* base address of string table */
+ size_t cts_len; /* size of string table in bytes */
+} ctf_strs_t;
+
+typedef struct ctf_dmodel {
+ const char *ctd_name; /* data model name */
+ int ctd_code; /* data model code */
+ size_t ctd_pointer; /* size of void * in bytes */
+ size_t ctd_char; /* size of char in bytes */
+ size_t ctd_short; /* size of short in bytes */
+ size_t ctd_int; /* size of int in bytes */
+ size_t ctd_long; /* size of long in bytes */
+} ctf_dmodel_t;
+
+typedef struct ctf_lookup {
+ const char *ctl_prefix; /* string prefix for this lookup */
+ size_t ctl_len; /* length of prefix string in bytes */
+ ctf_hash_t *ctl_hash; /* pointer to hash table for lookup */
+} ctf_lookup_t;
+
+typedef struct ctf_fileops {
+ ushort_t (*ctfo_get_kind)(ushort_t);
+ ushort_t (*ctfo_get_root)(ushort_t);
+ ushort_t (*ctfo_get_vlen)(ushort_t);
+} ctf_fileops_t;
+
+typedef struct ctf_list {
+ struct ctf_list *l_prev; /* previous pointer or tail pointer */
+ struct ctf_list *l_next; /* next pointer or head pointer */
+} ctf_list_t;
+
+typedef enum {
+ CTF_PREC_BASE,
+ CTF_PREC_POINTER,
+ CTF_PREC_ARRAY,
+ CTF_PREC_FUNCTION,
+ CTF_PREC_MAX
+} ctf_decl_prec_t;
+
+typedef struct ctf_decl_node {
+ ctf_list_t cd_list; /* linked list pointers */
+ ctf_id_t cd_type; /* type identifier */
+ uint_t cd_kind; /* type kind */
+ uint_t cd_n; /* type dimension if array */
+} ctf_decl_node_t;
+
+typedef struct ctf_decl {
+ ctf_list_t cd_nodes[CTF_PREC_MAX]; /* declaration node stacks */
+ int cd_order[CTF_PREC_MAX]; /* storage order of decls */
+ ctf_decl_prec_t cd_qualp; /* qualifier precision */
+ ctf_decl_prec_t cd_ordp; /* ordered precision */
+ char *cd_buf; /* buffer for output */
+ char *cd_ptr; /* buffer location */
+ char *cd_end; /* buffer limit */
+ size_t cd_len; /* buffer space required */
+ int cd_err; /* saved error value */
+} ctf_decl_t;
+
+typedef struct ctf_dmdef {
+ ctf_list_t dmd_list; /* list forward/back pointers */
+ char *dmd_name; /* name of this member */
+ ctf_id_t dmd_type; /* type of this member (for sou) */
+ ulong_t dmd_offset; /* offset of this member in bits (for sou) */
+ int dmd_value; /* value of this member (for enum) */
+} ctf_dmdef_t;
+
+typedef struct ctf_dtdef {
+ ctf_list_t dtd_list; /* list forward/back pointers */
+ struct ctf_dtdef *dtd_hash; /* hash chain pointer for ctf_dthash */
+ char *dtd_name; /* name associated with definition (if any) */
+ ctf_id_t dtd_type; /* type identifier for this definition */
+ ctf_type_t dtd_data; /* type node (see <sys/ctf.h>) */
+ union {
+ ctf_list_t dtu_members; /* struct, union, or enum */
+ ctf_arinfo_t dtu_arr; /* array */
+ ctf_encoding_t dtu_enc; /* integer or float */
+ ctf_id_t *dtu_argv; /* function */
+ } dtd_u;
+} ctf_dtdef_t;
+
+typedef struct ctf_bundle {
+ ctf_file_t *ctb_file; /* CTF container handle */
+ ctf_id_t ctb_type; /* CTF type identifier */
+ ctf_dtdef_t *ctb_dtd; /* CTF dynamic type definition (if any) */
+} ctf_bundle_t;
+
+/*
+ * The ctf_file is the structure used to represent a CTF container to library
+ * clients, who see it only as an opaque pointer. Modifications can therefore
+ * be made freely to this structure without regard to client versioning. The
+ * ctf_file_t typedef appears in <sys/ctf_api.h> and declares a forward tag.
+ *
+ * NOTE: ctf_update() requires that everything inside of ctf_file either be an
+ * immediate value, a pointer to dynamically allocated data *outside* of the
+ * ctf_file itself, or a pointer to statically allocated data. If you add a
+ * pointer to ctf_file that points to something within the ctf_file itself,
+ * you must make corresponding changes to ctf_update().
+ */
+struct ctf_file {
+ const ctf_fileops_t *ctf_fileops; /* version-specific file operations */
+ ctf_sect_t ctf_data; /* CTF data from object file */
+ ctf_sect_t ctf_symtab; /* symbol table from object file */
+ ctf_sect_t ctf_strtab; /* string table from object file */
+ ctf_hash_t ctf_structs; /* hash table of struct types */
+ ctf_hash_t ctf_unions; /* hash table of union types */
+ ctf_hash_t ctf_enums; /* hash table of enum types */
+ ctf_hash_t ctf_names; /* hash table of remaining type names */
+ ctf_lookup_t ctf_lookups[5]; /* pointers to hashes for name lookup */
+ ctf_strs_t ctf_str[2]; /* array of string table base and bounds */
+ const uchar_t *ctf_base; /* base of CTF header + uncompressed buffer */
+ const uchar_t *ctf_buf; /* uncompressed CTF data buffer */
+ size_t ctf_size; /* size of CTF header + uncompressed data */
+ uint_t *ctf_sxlate; /* translation table for symtab entries */
+ ulong_t ctf_nsyms; /* number of entries in symtab xlate table */
+ uint_t *ctf_txlate; /* translation table for type IDs */
+ ushort_t *ctf_ptrtab; /* translation table for pointer-to lookups */
+ ulong_t ctf_typemax; /* maximum valid type ID number */
+ const ctf_dmodel_t *ctf_dmodel; /* data model pointer (see above) */
+ struct ctf_file *ctf_parent; /* parent CTF container (if any) */
+ const char *ctf_parlabel; /* label in parent container (if any) */
+ const char *ctf_parname; /* basename of parent (if any) */
+ uint_t ctf_refcnt; /* reference count (for parent links) */
+ uint_t ctf_flags; /* libctf flags (see below) */
+ int ctf_errno; /* error code for most recent error */
+ int ctf_version; /* CTF data version */
+ ctf_dtdef_t **ctf_dthash; /* hash of dynamic type definitions */
+ ulong_t ctf_dthashlen; /* size of dynamic type hash bucket array */
+ ctf_list_t ctf_dtdefs; /* list of dynamic type definitions */
+ size_t ctf_dtstrlen; /* total length of dynamic type strings */
+ ulong_t ctf_dtnextid; /* next dynamic type id to assign */
+ ulong_t ctf_dtoldid; /* oldest id that has been committed */
+ void *ctf_specific; /* data for ctf_get/setspecific */
+};
+
+#define LCTF_INDEX_TO_TYPEPTR(fp, i) \
+ ((ctf_type_t *)((uintptr_t)(fp)->ctf_buf + (fp)->ctf_txlate[(i)]))
+
+#define LCTF_INFO_KIND(fp, info) ((fp)->ctf_fileops->ctfo_get_kind(info))
+#define LCTF_INFO_ROOT(fp, info) ((fp)->ctf_fileops->ctfo_get_root(info))
+#define LCTF_INFO_VLEN(fp, info) ((fp)->ctf_fileops->ctfo_get_vlen(info))
+
+#define LCTF_MMAP 0x0001 /* libctf should munmap buffers on close */
+#define LCTF_CHILD 0x0002 /* CTF container is a child */
+#define LCTF_RDWR 0x0004 /* CTF container is writable */
+#define LCTF_DIRTY 0x0008 /* CTF container has been modified */
+
+#define ECTF_BASE 1000 /* base value for libctf errnos */
+
+enum {
+ ECTF_FMT = ECTF_BASE, /* file is not in CTF or ELF format */
+ ECTF_ELFVERS, /* ELF version is more recent than libctf */
+ ECTF_CTFVERS, /* CTF version is more recent than libctf */
+ ECTF_ENDIAN, /* data is different endian-ness than lib */
+ ECTF_SYMTAB, /* symbol table uses invalid entry size */
+ ECTF_SYMBAD, /* symbol table data buffer invalid */
+ ECTF_STRBAD, /* string table data buffer invalid */
+ ECTF_CORRUPT, /* file data corruption detected */
+ ECTF_NOCTFDATA, /* ELF file does not contain CTF data */
+ ECTF_NOCTFBUF, /* buffer does not contain CTF data */
+ ECTF_NOSYMTAB, /* symbol table data is not available */
+ ECTF_NOPARENT, /* parent CTF container is not available */
+ ECTF_DMODEL, /* data model mismatch */
+ ECTF_MMAP, /* failed to mmap a data section */
+ ECTF_ZMISSING, /* decompression library not installed */
+ ECTF_ZINIT, /* failed to initialize decompression library */
+ ECTF_ZALLOC, /* failed to allocate decompression buffer */
+ ECTF_DECOMPRESS, /* failed to decompress CTF data */
+ ECTF_STRTAB, /* string table for this string is missing */
+ ECTF_BADNAME, /* string offset is corrupt w.r.t. strtab */
+ ECTF_BADID, /* invalid type ID number */
+ ECTF_NOTSOU, /* type is not a struct or union */
+ ECTF_NOTENUM, /* type is not an enum */
+ ECTF_NOTSUE, /* type is not a struct, union, or enum */
+ ECTF_NOTINTFP, /* type is not an integer or float */
+ ECTF_NOTARRAY, /* type is not an array */
+ ECTF_NOTREF, /* type does not reference another type */
+ ECTF_NAMELEN, /* buffer is too small to hold type name */
+ ECTF_NOTYPE, /* no type found corresponding to name */
+ ECTF_SYNTAX, /* syntax error in type name */
+ ECTF_NOTFUNC, /* symtab entry does not refer to a function */
+ ECTF_NOFUNCDAT, /* no func info available for function */
+ ECTF_NOTDATA, /* symtab entry does not refer to a data obj */
+ ECTF_NOTYPEDAT, /* no type info available for object */
+ ECTF_NOLABEL, /* no label found corresponding to name */
+ ECTF_NOLABELDATA, /* file does not contain any labels */
+ ECTF_NOTSUP, /* feature not supported */
+ ECTF_NOENUMNAM, /* enum element name not found */
+ ECTF_NOMEMBNAM, /* member name not found */
+ ECTF_RDONLY, /* CTF container is read-only */
+ ECTF_DTFULL, /* CTF type is full (no more members allowed) */
+ ECTF_FULL, /* CTF container is full */
+ ECTF_DUPMEMBER, /* duplicate member name definition */
+ ECTF_CONFLICT /* conflicting type definition present */
+};
+
+extern ssize_t ctf_get_ctt_size(const ctf_file_t *, const ctf_type_t *,
+ ssize_t *, ssize_t *);
+
+extern const ctf_type_t *ctf_lookup_by_id(ctf_file_t **, ctf_id_t);
+
+extern int ctf_hash_create(ctf_hash_t *, ulong_t);
+extern int ctf_hash_insert(ctf_hash_t *, ctf_file_t *, ushort_t, uint_t);
+extern int ctf_hash_define(ctf_hash_t *, ctf_file_t *, ushort_t, uint_t);
+extern ctf_helem_t *ctf_hash_lookup(ctf_hash_t *, ctf_file_t *,
+ const char *, size_t);
+extern uint_t ctf_hash_size(const ctf_hash_t *);
+extern void ctf_hash_destroy(ctf_hash_t *);
+
+#define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev))
+#define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next))
+
+extern void ctf_list_append(ctf_list_t *, void *);
+extern void ctf_list_prepend(ctf_list_t *, void *);
+extern void ctf_list_delete(ctf_list_t *, void *);
+
+extern void ctf_dtd_insert(ctf_file_t *, ctf_dtdef_t *);
+extern void ctf_dtd_delete(ctf_file_t *, ctf_dtdef_t *);
+extern ctf_dtdef_t *ctf_dtd_lookup(ctf_file_t *, ctf_id_t);
+
+extern void ctf_decl_init(ctf_decl_t *, char *, size_t);
+extern void ctf_decl_fini(ctf_decl_t *);
+extern void ctf_decl_push(ctf_decl_t *, ctf_file_t *, ctf_id_t);
+extern void ctf_decl_sprintf(ctf_decl_t *, const char *, ...);
+
+extern const char *ctf_strraw(ctf_file_t *, uint_t);
+extern const char *ctf_strptr(ctf_file_t *, uint_t);
+
+extern ctf_file_t *ctf_set_open_errno(int *, int);
+extern long ctf_set_errno(ctf_file_t *, int);
+
+extern const void *ctf_sect_mmap(ctf_sect_t *, int);
+extern void ctf_sect_munmap(const ctf_sect_t *);
+
+extern void *ctf_data_alloc(size_t);
+extern void ctf_data_free(void *, size_t);
+extern void ctf_data_protect(void *, size_t);
+
+extern void *ctf_alloc(size_t);
+extern void ctf_free(void *, size_t);
+
+extern char *ctf_strdup(const char *);
+extern const char *ctf_strerror(int);
+extern void ctf_dprintf(const char *, ...);
+
+extern void *ctf_zopen(int *);
+
+extern const char _CTF_SECTION[]; /* name of CTF ELF section */
+extern const char _CTF_NULLSTR[]; /* empty string */
+
+extern int _libctf_version; /* library client version */
+extern int _libctf_debug; /* debugging messages enabled */
+
+#ifdef VBOX
+# ifndef MAP_FAILED /* returned by ctf_data_alloc on failure. */
+# define MAP_FAILED ((void *)~(uintptr_t)0)
+# endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CTF_IMPL_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c
new file mode 100644
index 00000000..798353dc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c
@@ -0,0 +1,158 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2002-2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <ctf_impl.h>
+
+static int
+extract_label_info(ctf_file_t *fp, const ctf_lblent_t **ctl, uint_t *num_labels)
+{
+ const ctf_header_t *h;
+
+ /*
+ * Labels are only supported in V2 or later
+ */
+ if (fp->ctf_version < CTF_VERSION_2) {
+ *ctl = NULL; /* Shup up, GCC! */
+ *num_labels = 0;
+ return (ctf_set_errno(fp, ECTF_NOTSUP));
+ }
+
+ h = (const ctf_header_t *)fp->ctf_data.cts_data;
+
+ /* LINTED - pointer alignment */
+ *ctl = (const ctf_lblent_t *)(fp->ctf_buf + h->cth_lbloff);
+ *num_labels = (h->cth_objtoff - h->cth_lbloff) / sizeof (ctf_lblent_t);
+
+ return (0);
+}
+
+/*
+ * Returns the topmost label, or NULL if any errors are encountered
+ */
+const char *
+ctf_label_topmost(ctf_file_t *fp)
+{
+ const ctf_lblent_t *ctlp;
+ const char *s;
+ uint_t num_labels;
+
+ if (extract_label_info(fp, &ctlp, &num_labels) == CTF_ERR)
+ return (NULL); /* errno is set */
+
+ if (num_labels == 0) {
+ (void) ctf_set_errno(fp, ECTF_NOLABELDATA);
+ return (NULL);
+ }
+
+ if ((s = ctf_strraw(fp, (ctlp + num_labels - 1)->ctl_label)) == NULL)
+ (void) ctf_set_errno(fp, ECTF_CORRUPT);
+
+ return (s);
+}
+
+/*
+ * Iterate over all labels. We pass the label string and the lblinfo_t struct
+ * to the specified callback function.
+ */
+int
+ctf_label_iter(ctf_file_t *fp, ctf_label_f *func, void *arg)
+{
+ const ctf_lblent_t *ctlp;
+ uint_t i, num_labels;
+ ctf_lblinfo_t linfo;
+ const char *lname;
+ int rc;
+
+ if (extract_label_info(fp, &ctlp, &num_labels) == CTF_ERR)
+ return (CTF_ERR); /* errno is set */
+
+ if (num_labels == 0)
+ return (ctf_set_errno(fp, ECTF_NOLABELDATA));
+
+ for (i = 0; i < num_labels; i++, ctlp++) {
+ if ((lname = ctf_strraw(fp, ctlp->ctl_label)) == NULL) {
+ ctf_dprintf("failed to decode label %u with "
+ "typeidx %u\n", ctlp->ctl_label, ctlp->ctl_typeidx);
+ return (ctf_set_errno(fp, ECTF_CORRUPT));
+ }
+
+ linfo.ctb_typeidx = ctlp->ctl_typeidx;
+ if ((rc = func(lname, &linfo, arg)) != 0)
+ return (rc);
+ }
+
+ return (0);
+}
+
+typedef struct linfo_cb_arg {
+ const char *lca_name; /* Label we want to retrieve info for */
+ ctf_lblinfo_t *lca_info; /* Where to store the info about the label */
+} linfo_cb_arg_t;
+
+static int
+label_info_cb(const char *lname, const ctf_lblinfo_t *linfo, void *arg)
+{
+ /*
+ * If lname matches the label we are looking for, copy the
+ * lblinfo_t struct for the caller.
+ */
+ if (strcmp(lname, ((linfo_cb_arg_t *)arg)->lca_name) == 0) {
+ /*
+ * Allow caller not to allocate storage to test if label exists
+ */
+ if (((linfo_cb_arg_t *)arg)->lca_info != NULL)
+ bcopy(linfo, ((linfo_cb_arg_t *)arg)->lca_info,
+ sizeof (ctf_lblinfo_t));
+ return (1); /* Indicate we found a match */
+ }
+
+ return (0);
+}
+
+/*
+ * Retrieve information about the label with name "lname"
+ */
+int
+ctf_label_info(ctf_file_t *fp, const char *lname, ctf_lblinfo_t *linfo)
+{
+ linfo_cb_arg_t cb_arg;
+ int rc;
+
+ cb_arg.lca_name = lname;
+ cb_arg.lca_info = linfo;
+
+ if ((rc = ctf_label_iter(fp, label_info_cb, &cb_arg)) == CTF_ERR)
+ return (rc);
+
+ if (rc != 1)
+ return (ctf_set_errno(fp, ECTF_NOLABEL));
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c
new file mode 100644
index 00000000..c49d6162
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c
@@ -0,0 +1,322 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/sysmacros.h>
+#else /* VBOX */
+# include <ctype.h>
+#endif /* VBOX */
+#include <ctf_impl.h>
+
+/*
+ * Compare the given input string and length against a table of known C storage
+ * qualifier keywords. We just ignore these in ctf_lookup_by_name, below. To
+ * do this quickly, we use a pre-computed Perfect Hash Function similar to the
+ * technique originally described in the classic paper:
+ *
+ * R.J. Cichelli, "Minimal Perfect Hash Functions Made Simple",
+ * Communications of the ACM, Volume 23, Issue 1, January 1980, pp. 17-19.
+ *
+ * For an input string S of length N, we use hash H = S[N - 1] + N - 105, which
+ * for the current set of qualifiers yields a unique H in the range [0 .. 20].
+ * The hash can be modified when the keyword set changes as necessary. We also
+ * store the length of each keyword and check it prior to the final strcmp().
+ */
+static int
+isqualifier(const char *s, size_t len)
+{
+ static const struct qual {
+ const char *q_name;
+ size_t q_len;
+ } qhash[] = {
+ { "static", 6 }, { "", 0 }, { "", 0 }, { "", 0 },
+ { "volatile", 8 }, { "", 0 }, { "", 0 }, { "", 0 }, { "", 0 },
+ { "", 0 }, { "auto", 4 }, { "extern", 6 }, { "", 0 }, { "", 0 },
+ { "", 0 }, { "", 0 }, { "const", 5 }, { "register", 8 },
+ { "", 0 }, { "restrict", 8 }, { "_Restrict", 9 }
+ };
+
+ int h = s[len - 1] + (int)len - 105;
+ const struct qual *qp = &qhash[h];
+
+ return (h >= 0 && h < sizeof (qhash) / sizeof (qhash[0]) &&
+ len == qp->q_len && strncmp(qp->q_name, s, qp->q_len) == 0);
+}
+
+/*
+ * Attempt to convert the given C type name into the corresponding CTF type ID.
+ * It is not possible to do complete and proper conversion of type names
+ * without implementing a more full-fledged parser, which is necessary to
+ * handle things like types that are function pointers to functions that
+ * have arguments that are function pointers, and fun stuff like that.
+ * Instead, this function implements a very simple conversion algorithm that
+ * finds the things that we actually care about: structs, unions, enums,
+ * integers, floats, typedefs, and pointers to any of these named types.
+ */
+ctf_id_t
+ctf_lookup_by_name(ctf_file_t *fp, const char *name)
+{
+ static const char delimiters[] = " \t\n\r\v\f*";
+
+ const ctf_lookup_t *lp;
+ const ctf_helem_t *hp;
+ const char *p, *q, *end;
+ ctf_id_t type = 0;
+ ctf_id_t ntype, ptype;
+
+ if (name == NULL)
+ return (ctf_set_errno(fp, EINVAL));
+
+ for (p = name, end = name + strlen(name); *p != '\0'; p = q) {
+ while (isspace(*p))
+ p++; /* skip leading ws */
+
+ if (p == end)
+ break;
+
+ if ((q = strpbrk(p + 1, delimiters)) == NULL)
+ q = end; /* compare until end */
+
+ if (*p == '*') {
+ /*
+ * Find a pointer to type by looking in fp->ctf_ptrtab.
+ * If we can't find a pointer to the given type, see if
+ * we can compute a pointer to the type resulting from
+ * resolving the type down to its base type and use
+ * that instead. This helps with cases where the CTF
+ * data includes "struct foo *" but not "foo_t *" and
+ * the user tries to access "foo_t *" in the debugger.
+ */
+ ntype = fp->ctf_ptrtab[CTF_TYPE_TO_INDEX(type)];
+ if (ntype == 0) {
+ ntype = ctf_type_resolve(fp, type);
+ if (ntype == CTF_ERR || (ntype = fp->ctf_ptrtab[
+ CTF_TYPE_TO_INDEX(ntype)]) == 0) {
+ (void) ctf_set_errno(fp, ECTF_NOTYPE);
+ goto err;
+ }
+ }
+
+ type = CTF_INDEX_TO_TYPE(ntype,
+ (fp->ctf_flags & LCTF_CHILD));
+
+ q = p + 1;
+ continue;
+ }
+
+ if (isqualifier(p, (size_t)(q - p)))
+ continue; /* skip qualifier keyword */
+
+ for (lp = fp->ctf_lookups; lp->ctl_prefix != NULL; lp++) {
+ if (lp->ctl_prefix[0] == '\0' ||
+#ifdef VBOX
+ ( strncmp(p, lp->ctl_prefix, (size_t)(q - p)) == 0
+ && lp->ctl_len <= (size_t)(q - p)) /* don't push 'p' to far and crash */ ) {
+#else
+ strncmp(p, lp->ctl_prefix, (size_t)(q - p)) == 0) {
+#endif
+ for (p += lp->ctl_len; isspace(*p); p++)
+ continue; /* skip prefix and next ws */
+
+ if ((q = strchr(p, '*')) == NULL)
+ q = end; /* compare until end */
+
+ while (isspace(q[-1]))
+ q--; /* exclude trailing ws */
+
+ if ((hp = ctf_hash_lookup(lp->ctl_hash, fp, p,
+ (size_t)(q - p))) == NULL) {
+ (void) ctf_set_errno(fp, ECTF_NOTYPE);
+ goto err;
+ }
+
+ type = hp->h_type;
+ break;
+ }
+ }
+
+ if (lp->ctl_prefix == NULL) {
+ (void) ctf_set_errno(fp, ECTF_NOTYPE);
+ goto err;
+ }
+ }
+
+ if (*p != '\0' || type == 0)
+ return (ctf_set_errno(fp, ECTF_SYNTAX));
+
+ return (type);
+
+err:
+ if (fp->ctf_parent != NULL &&
+ (ptype = ctf_lookup_by_name(fp->ctf_parent, name)) != CTF_ERR)
+ return (ptype);
+
+ return (CTF_ERR);
+}
+
+/*
+ * Given a symbol table index, return the type of the data object described
+ * by the corresponding entry in the symbol table.
+ */
+ctf_id_t
+ctf_lookup_by_symbol(ctf_file_t *fp, ulong_t symidx)
+{
+ const ctf_sect_t *sp = &fp->ctf_symtab;
+ ctf_id_t type;
+
+ if (sp->cts_data == NULL)
+ return (ctf_set_errno(fp, ECTF_NOSYMTAB));
+
+ if (symidx >= fp->ctf_nsyms)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if (sp->cts_entsize == sizeof (Elf32_Sym)) {
+ const Elf32_Sym *symp = (Elf32_Sym *)sp->cts_data + symidx;
+ if (ELF32_ST_TYPE(symp->st_info) != STT_OBJECT)
+ return (ctf_set_errno(fp, ECTF_NOTDATA));
+ } else {
+ const Elf64_Sym *symp = (Elf64_Sym *)sp->cts_data + symidx;
+ if (ELF64_ST_TYPE(symp->st_info) != STT_OBJECT)
+ return (ctf_set_errno(fp, ECTF_NOTDATA));
+ }
+
+ if (fp->ctf_sxlate[symidx] == ~0u /*VBOX: -1u*/)
+ return (ctf_set_errno(fp, ECTF_NOTYPEDAT));
+
+ type = *(ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]);
+ if (type == 0)
+ return (ctf_set_errno(fp, ECTF_NOTYPEDAT));
+
+ return (type);
+}
+
+/*
+ * Return the pointer to the internal CTF type data corresponding to the
+ * given type ID. If the ID is invalid, the function returns NULL.
+ * This function is not exported outside of the library.
+ */
+const ctf_type_t *
+ctf_lookup_by_id(ctf_file_t **fpp, ctf_id_t type)
+{
+ ctf_file_t *fp = *fpp; /* caller passes in starting CTF container */
+
+ if ((fp->ctf_flags & LCTF_CHILD) && CTF_TYPE_ISPARENT(type) &&
+ (fp = fp->ctf_parent) == NULL) {
+ (void) ctf_set_errno(*fpp, ECTF_NOPARENT);
+ return (NULL);
+ }
+
+ type = CTF_TYPE_TO_INDEX(type);
+ if (type > 0 && type <= (intptr_t/*vbox*/)fp->ctf_typemax) {
+ *fpp = fp; /* function returns ending CTF container */
+ return (LCTF_INDEX_TO_TYPEPTR(fp, type));
+ }
+
+ (void) ctf_set_errno(fp, ECTF_BADID);
+ return (NULL);
+}
+
+/*
+ * Given a symbol table index, return the info for the function described
+ * by the corresponding entry in the symbol table.
+ */
+int
+ctf_func_info(ctf_file_t *fp, ulong_t symidx, ctf_funcinfo_t *fip)
+{
+ const ctf_sect_t *sp = &fp->ctf_symtab;
+ const ushort_t *dp;
+ ushort_t info, kind, n;
+
+ if (sp->cts_data == NULL)
+ return (ctf_set_errno(fp, ECTF_NOSYMTAB));
+
+ if (symidx >= fp->ctf_nsyms)
+ return (ctf_set_errno(fp, EINVAL));
+
+ if (sp->cts_entsize == sizeof (Elf32_Sym)) {
+ const Elf32_Sym *symp = (Elf32_Sym *)sp->cts_data + symidx;
+ if (ELF32_ST_TYPE(symp->st_info) != STT_FUNC)
+ return (ctf_set_errno(fp, ECTF_NOTFUNC));
+ } else {
+ const Elf64_Sym *symp = (Elf64_Sym *)sp->cts_data + symidx;
+ if (ELF64_ST_TYPE(symp->st_info) != STT_FUNC)
+ return (ctf_set_errno(fp, ECTF_NOTFUNC));
+ }
+
+ if (fp->ctf_sxlate[symidx] == ~0u /*VBOX: -1u*/)
+ return (ctf_set_errno(fp, ECTF_NOFUNCDAT));
+
+ dp = (ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]);
+
+ info = *dp++;
+ kind = LCTF_INFO_KIND(fp, info);
+ n = LCTF_INFO_VLEN(fp, info);
+
+ if (kind == CTF_K_UNKNOWN && n == 0)
+ return (ctf_set_errno(fp, ECTF_NOFUNCDAT));
+
+ if (kind != CTF_K_FUNCTION)
+ return (ctf_set_errno(fp, ECTF_CORRUPT));
+
+ fip->ctc_return = *dp++;
+ fip->ctc_argc = n;
+ fip->ctc_flags = 0;
+
+ if (n != 0 && dp[n - 1] == 0) {
+ fip->ctc_flags |= CTF_FUNC_VARARG;
+ fip->ctc_argc--;
+ }
+
+ return (0);
+}
+
+/*
+ * Given a symbol table index, return the arguments for the function described
+ * by the corresponding entry in the symbol table.
+ */
+int
+ctf_func_args(ctf_file_t *fp, ulong_t symidx, uint_t argc, ctf_id_t *argv)
+{
+ const ushort_t *dp;
+ ctf_funcinfo_t f;
+
+ if (ctf_func_info(fp, symidx, &f) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ /*
+ * The argument data is two ushort_t's past the translation table
+ * offset: one for the function info, and one for the return type.
+ */
+ dp = (ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]) + 2;
+
+ for (argc = MIN(argc, f.ctc_argc); argc != 0; argc--)
+ *argv++ = *dp++;
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c
new file mode 100644
index 00000000..f86a0cfd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c
@@ -0,0 +1,972 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#ifndef VBOX
+#include <ctf_impl.h>
+#include <sys/mman.h>
+#include <sys/zmod.h>
+#else /* VBOX */
+# define CTF_OLD_VERSIONS
+# include <ctf_impl.h>
+# include <zlib.h>
+# define z_compress compress
+# define z_uncompress uncompress
+# define z_strerror zError
+#endif /* VBOX */
+
+static const ctf_dmodel_t _libctf_models[] = {
+ { "ILP32", CTF_MODEL_ILP32, 4, 1, 2, 4, 4 },
+ { "LP64", CTF_MODEL_LP64, 8, 1, 2, 4, 8 },
+ { NULL, 0, 0, 0, 0, 0, 0 }
+};
+
+const char _CTF_SECTION[] = ".SUNW_ctf";
+const char _CTF_NULLSTR[] = "";
+
+int _libctf_version = CTF_VERSION; /* library client version */
+int _libctf_debug = 0; /* debugging messages enabled */
+
+static ushort_t
+get_kind_v1(ushort_t info)
+{
+ return (CTF_INFO_KIND_V1(info));
+}
+
+static ushort_t
+get_kind_v2(ushort_t info)
+{
+ return (CTF_INFO_KIND(info));
+}
+
+static ushort_t
+get_root_v1(ushort_t info)
+{
+ return (CTF_INFO_ISROOT_V1(info));
+}
+
+static ushort_t
+get_root_v2(ushort_t info)
+{
+ return (CTF_INFO_ISROOT(info));
+}
+
+static ushort_t
+get_vlen_v1(ushort_t info)
+{
+ return (CTF_INFO_VLEN_V1(info));
+}
+
+static ushort_t
+get_vlen_v2(ushort_t info)
+{
+ return (CTF_INFO_VLEN(info));
+}
+
+static const ctf_fileops_t ctf_fileops[] = {
+ { NULL, NULL },
+ { get_kind_v1, get_root_v1, get_vlen_v1 },
+ { get_kind_v2, get_root_v2, get_vlen_v2 },
+};
+
+/*
+ * Convert a 32-bit ELF symbol into GElf (Elf64) and return a pointer to it.
+ */
+static Elf64_Sym *
+sym_to_gelf(const Elf32_Sym *src, Elf64_Sym *dst)
+{
+ dst->st_name = src->st_name;
+ dst->st_value = src->st_value;
+ dst->st_size = src->st_size;
+ dst->st_info = src->st_info;
+ dst->st_other = src->st_other;
+ dst->st_shndx = src->st_shndx;
+
+ return (dst);
+}
+
+/*
+ * Initialize the symtab translation table by filling each entry with the
+ * offset of the CTF type or function data corresponding to each STT_FUNC or
+ * STT_OBJECT entry in the symbol table.
+ */
+static int
+init_symtab(ctf_file_t *fp, const ctf_header_t *hp,
+ const ctf_sect_t *sp, const ctf_sect_t *strp)
+{
+ const uchar_t *symp = sp->cts_data;
+ uint_t *xp = fp->ctf_sxlate;
+ uint_t *xend = xp + fp->ctf_nsyms;
+
+ uint_t objtoff = hp->cth_objtoff;
+ uint_t funcoff = hp->cth_funcoff;
+
+ ushort_t info, vlen;
+ Elf64_Sym sym, *gsp;
+ const char *name;
+
+ /*
+ * The CTF data object and function type sections are ordered to match
+ * the relative order of the respective symbol types in the symtab.
+ * If no type information is available for a symbol table entry, a
+ * pad is inserted in the CTF section. As a further optimization,
+ * anonymous or undefined symbols are omitted from the CTF data.
+ */
+ for (; xp < xend; xp++, symp += sp->cts_entsize) {
+ if (sp->cts_entsize == sizeof (Elf32_Sym))
+ gsp = sym_to_gelf((Elf32_Sym *)(uintptr_t)symp, &sym);
+ else
+ gsp = (Elf64_Sym *)(uintptr_t)symp;
+
+ if (gsp->st_name < strp->cts_size)
+ name = (const char *)strp->cts_data + gsp->st_name;
+ else
+ name = _CTF_NULLSTR;
+
+ if (gsp->st_name == 0 || gsp->st_shndx == SHN_UNDEF ||
+ strcmp(name, "_START_") == 0 ||
+ strcmp(name, "_END_") == 0) {
+ *xp = ~0u /*VBOX: -1u*/;
+ continue;
+ }
+
+ switch (ELF64_ST_TYPE(gsp->st_info)) {
+ case STT_OBJECT:
+ if (objtoff >= hp->cth_funcoff ||
+ (gsp->st_shndx == SHN_ABS && gsp->st_value == 0)) {
+ *xp = ~0u /*VBOX: -1u*/;
+ break;
+ }
+
+ *xp = objtoff;
+ objtoff += sizeof (ushort_t);
+ break;
+
+ case STT_FUNC:
+ if (funcoff >= hp->cth_typeoff) {
+ *xp = ~0u /*VBOX: -1u*/;
+ break;
+ }
+
+ *xp = funcoff;
+
+ info = *(ushort_t *)((uintptr_t)fp->ctf_buf + funcoff);
+ vlen = LCTF_INFO_VLEN(fp, info);
+
+ /*
+ * If we encounter a zero pad at the end, just skip it.
+ * Otherwise skip over the function and its return type
+ * (+2) and the argument list (vlen).
+ */
+ if (LCTF_INFO_KIND(fp, info) == CTF_K_UNKNOWN &&
+ vlen == 0)
+ funcoff += sizeof (ushort_t); /* skip pad */
+ else
+ funcoff += sizeof (ushort_t) * (vlen + 2);
+ break;
+
+ default:
+ *xp = ~0u /*VBOX: -1u*/;
+ break;
+ }
+ }
+
+ ctf_dprintf("loaded %lu symtab entries\n", fp->ctf_nsyms);
+ return (0);
+}
+
+/*
+ * Initialize the type ID translation table with the byte offset of each type,
+ * and initialize the hash tables of each named type.
+ */
+static int
+init_types(ctf_file_t *fp, const ctf_header_t *cth)
+{
+ /* LINTED - pointer alignment */
+ const ctf_type_t *tbuf = (ctf_type_t *)(fp->ctf_buf + cth->cth_typeoff);
+ /* LINTED - pointer alignment */
+ const ctf_type_t *tend = (ctf_type_t *)(fp->ctf_buf + cth->cth_stroff);
+
+ ulong_t pop[CTF_K_MAX + 1] = { 0 };
+ const ctf_type_t *tp;
+ ctf_hash_t *hp;
+ ushort_t id, dst;
+ uint_t *xp;
+
+ /*
+ * We initially determine whether the container is a child or a parent
+ * based on the value of cth_parname. To support containers that pre-
+ * date cth_parname, we also scan the types themselves for references
+ * to values in the range reserved for child types in our first pass.
+ */
+ int child = cth->cth_parname != 0;
+ int nlstructs = 0, nlunions = 0;
+ int err;
+
+ /*
+ * We make two passes through the entire type section. In this first
+ * pass, we count the number of each type and the total number of types.
+ */
+ for (tp = tbuf; tp < tend; fp->ctf_typemax++) {
+ ushort_t kind = LCTF_INFO_KIND(fp, tp->ctt_info);
+ ulong_t vlen = LCTF_INFO_VLEN(fp, tp->ctt_info);
+ ssize_t size, increment;
+
+ size_t vbytes;
+ uint_t n;
+
+ (void) ctf_get_ctt_size(fp, tp, &size, &increment);
+
+ switch (kind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ vbytes = sizeof (uint_t);
+ break;
+ case CTF_K_ARRAY:
+ vbytes = sizeof (ctf_array_t);
+ break;
+ case CTF_K_FUNCTION:
+ vbytes = sizeof (ushort_t) * (vlen + (vlen & 1));
+ break;
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ if (fp->ctf_version == CTF_VERSION_1 ||
+ size < CTF_LSTRUCT_THRESH) {
+ ctf_member_t *mp = (ctf_member_t *)
+ ((uintptr_t)tp + increment);
+
+ vbytes = sizeof (ctf_member_t) * vlen;
+ for (n = vlen; n != 0; n--, mp++)
+ child |= CTF_TYPE_ISCHILD(mp->ctm_type);
+ } else {
+ ctf_lmember_t *lmp = (ctf_lmember_t *)
+ ((uintptr_t)tp + increment);
+
+ vbytes = sizeof (ctf_lmember_t) * vlen;
+ for (n = vlen; n != 0; n--, lmp++)
+ child |=
+ CTF_TYPE_ISCHILD(lmp->ctlm_type);
+ }
+ break;
+ case CTF_K_ENUM:
+ vbytes = sizeof (ctf_enum_t) * vlen;
+ break;
+ case CTF_K_FORWARD:
+ /*
+ * For forward declarations, ctt_type is the CTF_K_*
+ * kind for the tag, so bump that population count too.
+ * If ctt_type is unknown, treat the tag as a struct.
+ */
+ if (tp->ctt_type == CTF_K_UNKNOWN ||
+ tp->ctt_type >= CTF_K_MAX)
+ pop[CTF_K_STRUCT]++;
+ else
+ pop[tp->ctt_type]++;
+ RT_FALL_THRU();
+ case CTF_K_UNKNOWN:
+ vbytes = 0;
+ break;
+ case CTF_K_POINTER:
+ case CTF_K_TYPEDEF:
+ case CTF_K_VOLATILE:
+ case CTF_K_CONST:
+ case CTF_K_RESTRICT:
+ child |= CTF_TYPE_ISCHILD(tp->ctt_type);
+ vbytes = 0;
+ break;
+ default:
+ ctf_dprintf("detected invalid CTF kind -- %u\n", kind);
+ return (ECTF_CORRUPT);
+ }
+ tp = (ctf_type_t *)((uintptr_t)tp + increment + vbytes);
+ pop[kind]++;
+ }
+
+ /*
+ * If we detected a reference to a child type ID, then we know this
+ * container is a child and may have a parent's types imported later.
+ */
+ if (child) {
+ ctf_dprintf("CTF container %p is a child\n", (void *)fp);
+ fp->ctf_flags |= LCTF_CHILD;
+ } else
+ ctf_dprintf("CTF container %p is a parent\n", (void *)fp);
+
+ /*
+ * Now that we've counted up the number of each type, we can allocate
+ * the hash tables, type translation table, and pointer table.
+ */
+ if ((err = ctf_hash_create(&fp->ctf_structs, pop[CTF_K_STRUCT])) != 0)
+ return (err);
+
+ if ((err = ctf_hash_create(&fp->ctf_unions, pop[CTF_K_UNION])) != 0)
+ return (err);
+
+ if ((err = ctf_hash_create(&fp->ctf_enums, pop[CTF_K_ENUM])) != 0)
+ return (err);
+
+ if ((err = ctf_hash_create(&fp->ctf_names,
+ pop[CTF_K_INTEGER] + pop[CTF_K_FLOAT] + pop[CTF_K_FUNCTION] +
+ pop[CTF_K_TYPEDEF] + pop[CTF_K_POINTER] + pop[CTF_K_VOLATILE] +
+ pop[CTF_K_CONST] + pop[CTF_K_RESTRICT])) != 0)
+ return (err);
+
+ fp->ctf_txlate = ctf_alloc(sizeof (uint_t) * (fp->ctf_typemax + 1));
+ fp->ctf_ptrtab = ctf_alloc(sizeof (ushort_t) * (fp->ctf_typemax + 1));
+
+ if (fp->ctf_txlate == NULL || fp->ctf_ptrtab == NULL)
+ return (EAGAIN); /* memory allocation failed */
+
+ xp = fp->ctf_txlate;
+ *xp++ = 0; /* type id 0 is used as a sentinel value */
+
+ bzero(fp->ctf_txlate, sizeof (uint_t) * (fp->ctf_typemax + 1));
+ bzero(fp->ctf_ptrtab, sizeof (ushort_t) * (fp->ctf_typemax + 1));
+
+ /*
+ * In the second pass through the types, we fill in each entry of the
+ * type and pointer tables and add names to the appropriate hashes.
+ */
+ for (id = 1, tp = tbuf; tp < tend; xp++, id++) {
+ ushort_t kind = LCTF_INFO_KIND(fp, tp->ctt_info);
+ ulong_t vlen = LCTF_INFO_VLEN(fp, tp->ctt_info);
+ ssize_t size, increment;
+
+ const char *name;
+ size_t vbytes;
+ ctf_helem_t *hep;
+ ctf_encoding_t cte;
+
+ (void) ctf_get_ctt_size(fp, tp, &size, &increment);
+ name = ctf_strptr(fp, tp->ctt_name);
+
+ switch (kind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ /*
+ * Only insert a new integer base type definition if
+ * this type name has not been defined yet. We re-use
+ * the names with different encodings for bit-fields.
+ */
+ if ((hep = ctf_hash_lookup(&fp->ctf_names, fp,
+ name, strlen(name))) == NULL) {
+ err = ctf_hash_insert(&fp->ctf_names, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+ } else if (ctf_type_encoding(fp, hep->h_type,
+ &cte) == 0 && cte.cte_bits == 0) {
+ /*
+ * Work-around SOS8 stabs bug: replace existing
+ * intrinsic w/ same name if it was zero bits.
+ */
+ hep->h_type = CTF_INDEX_TO_TYPE(id, child);
+ }
+ vbytes = sizeof (uint_t);
+ break;
+
+ case CTF_K_ARRAY:
+ vbytes = sizeof (ctf_array_t);
+ break;
+
+ case CTF_K_FUNCTION:
+ err = ctf_hash_insert(&fp->ctf_names, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+ vbytes = sizeof (ushort_t) * (vlen + (vlen & 1));
+ break;
+
+ case CTF_K_STRUCT:
+ err = ctf_hash_define(&fp->ctf_structs, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+
+ if (fp->ctf_version == CTF_VERSION_1 ||
+ size < CTF_LSTRUCT_THRESH)
+ vbytes = sizeof (ctf_member_t) * vlen;
+ else {
+ vbytes = sizeof (ctf_lmember_t) * vlen;
+ nlstructs++;
+ }
+ break;
+
+ case CTF_K_UNION:
+ err = ctf_hash_define(&fp->ctf_unions, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+
+ if (fp->ctf_version == CTF_VERSION_1 ||
+ size < CTF_LSTRUCT_THRESH)
+ vbytes = sizeof (ctf_member_t) * vlen;
+ else {
+ vbytes = sizeof (ctf_lmember_t) * vlen;
+ nlunions++;
+ }
+ break;
+
+ case CTF_K_ENUM:
+ err = ctf_hash_define(&fp->ctf_enums, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+
+ vbytes = sizeof (ctf_enum_t) * vlen;
+ break;
+
+ case CTF_K_TYPEDEF:
+ err = ctf_hash_insert(&fp->ctf_names, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+ vbytes = 0;
+ break;
+
+ case CTF_K_FORWARD:
+ /*
+ * Only insert forward tags into the given hash if the
+ * type or tag name is not already present.
+ */
+ switch (tp->ctt_type) {
+ case CTF_K_STRUCT:
+ hp = &fp->ctf_structs;
+ break;
+ case CTF_K_UNION:
+ hp = &fp->ctf_unions;
+ break;
+ case CTF_K_ENUM:
+ hp = &fp->ctf_enums;
+ break;
+ default:
+ hp = &fp->ctf_structs;
+ }
+
+ if (ctf_hash_lookup(hp, fp,
+ name, strlen(name)) == NULL) {
+ err = ctf_hash_insert(hp, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+ }
+ vbytes = 0;
+ break;
+
+ case CTF_K_POINTER:
+ /*
+ * If the type referenced by the pointer is in this CTF
+ * container, then store the index of the pointer type
+ * in fp->ctf_ptrtab[ index of referenced type ].
+ */
+ if (CTF_TYPE_ISCHILD(tp->ctt_type) == child &&
+ CTF_TYPE_TO_INDEX(tp->ctt_type) <= (intptr_t/*vbox*/)fp->ctf_typemax)
+ fp->ctf_ptrtab[
+ CTF_TYPE_TO_INDEX(tp->ctt_type)] = id;
+ RT_FALL_THRU();
+
+ case CTF_K_VOLATILE:
+ case CTF_K_CONST:
+ case CTF_K_RESTRICT:
+ err = ctf_hash_insert(&fp->ctf_names, fp,
+ CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
+ if (err != 0 && err != ECTF_STRTAB)
+ return (err);
+ RT_FALL_THRU();
+
+ default:
+ vbytes = 0;
+ break;
+ }
+
+ *xp = (uint_t)((uintptr_t)tp - (uintptr_t)fp->ctf_buf);
+ tp = (ctf_type_t *)((uintptr_t)tp + increment + vbytes);
+ }
+
+ ctf_dprintf("%lu total types processed\n", fp->ctf_typemax);
+ ctf_dprintf("%u enum names hashed\n", ctf_hash_size(&fp->ctf_enums));
+ ctf_dprintf("%u struct names hashed (%d long)\n",
+ ctf_hash_size(&fp->ctf_structs), nlstructs);
+ ctf_dprintf("%u union names hashed (%d long)\n",
+ ctf_hash_size(&fp->ctf_unions), nlunions);
+ ctf_dprintf("%u base type names hashed\n",
+ ctf_hash_size(&fp->ctf_names));
+
+ /*
+ * Make an additional pass through the pointer table to find pointers
+ * that point to anonymous typedef nodes. If we find one, modify the
+ * pointer table so that the pointer is also known to point to the
+ * node that is referenced by the anonymous typedef node.
+ */
+ for (id = 1; id <= fp->ctf_typemax; id++) {
+ if ((dst = fp->ctf_ptrtab[id]) != 0) {
+ tp = LCTF_INDEX_TO_TYPEPTR(fp, id);
+
+ if (LCTF_INFO_KIND(fp, tp->ctt_info) == CTF_K_TYPEDEF &&
+ strcmp(ctf_strptr(fp, tp->ctt_name), "") == 0 &&
+ CTF_TYPE_ISCHILD(tp->ctt_type) == child &&
+ CTF_TYPE_TO_INDEX(tp->ctt_type) <= (intptr_t /*vbox*/)fp->ctf_typemax)
+ fp->ctf_ptrtab[
+ CTF_TYPE_TO_INDEX(tp->ctt_type)] = dst;
+ }
+ }
+
+ return (0);
+}
+
+/*
+ * Decode the specified CTF buffer and optional symbol table and create a new
+ * CTF container representing the symbolic debugging information. This code
+ * can be used directly by the debugger, or it can be used as the engine for
+ * ctf_fdopen() or ctf_open(), below.
+ */
+ctf_file_t *
+ctf_bufopen(const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
+ const ctf_sect_t *strsect, int *errp)
+{
+ const ctf_preamble_t *pp;
+ ctf_header_t hp;
+ ctf_file_t *fp;
+ void *buf, *base;
+ size_t size, hdrsz;
+ int err;
+
+ if (ctfsect == NULL || ((symsect == NULL) != (strsect == NULL)))
+ return (ctf_set_open_errno(errp, EINVAL));
+
+ if (symsect != NULL && symsect->cts_entsize != sizeof (Elf32_Sym) &&
+ symsect->cts_entsize != sizeof (Elf64_Sym))
+ return (ctf_set_open_errno(errp, ECTF_SYMTAB));
+
+ if (symsect != NULL && symsect->cts_data == NULL)
+ return (ctf_set_open_errno(errp, ECTF_SYMBAD));
+
+ if (strsect != NULL && strsect->cts_data == NULL)
+ return (ctf_set_open_errno(errp, ECTF_STRBAD));
+
+ if (ctfsect->cts_size < sizeof (ctf_preamble_t))
+ return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));
+
+ pp = (const ctf_preamble_t *)ctfsect->cts_data;
+
+ ctf_dprintf("ctf_bufopen: magic=0x%x version=%u\n",
+ pp->ctp_magic, pp->ctp_version);
+
+ /*
+ * Validate each part of the CTF header (either V1 or V2).
+ * First, we validate the preamble (common to all versions). At that
+ * point, we know specific header version, and can validate the
+ * version-specific parts including section offsets and alignments.
+ */
+ if (pp->ctp_magic != CTF_MAGIC)
+ return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));
+
+ if (pp->ctp_version == CTF_VERSION_2) {
+ if (ctfsect->cts_size < sizeof (ctf_header_t))
+ return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));
+
+ bcopy(ctfsect->cts_data, &hp, sizeof (hp));
+ hdrsz = sizeof (ctf_header_t);
+
+ } else if (pp->ctp_version == CTF_VERSION_1) {
+ const ctf_header_v1_t *h1p =
+ (const ctf_header_v1_t *)ctfsect->cts_data;
+
+ if (ctfsect->cts_size < sizeof (ctf_header_v1_t))
+ return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));
+
+ bzero(&hp, sizeof (hp));
+ hp.cth_preamble = h1p->cth_preamble;
+ hp.cth_objtoff = h1p->cth_objtoff;
+ hp.cth_funcoff = h1p->cth_funcoff;
+ hp.cth_typeoff = h1p->cth_typeoff;
+ hp.cth_stroff = h1p->cth_stroff;
+ hp.cth_strlen = h1p->cth_strlen;
+
+ hdrsz = sizeof (ctf_header_v1_t);
+ } else
+ return (ctf_set_open_errno(errp, ECTF_CTFVERS));
+
+ size = hp.cth_stroff + hp.cth_strlen;
+
+ ctf_dprintf("ctf_bufopen: uncompressed size=%lu\n", (ulong_t)size);
+
+ if (hp.cth_lbloff > size || hp.cth_objtoff > size ||
+ hp.cth_funcoff > size || hp.cth_typeoff > size ||
+ hp.cth_stroff > size)
+ return (ctf_set_open_errno(errp, ECTF_CORRUPT));
+
+ if (hp.cth_lbloff > hp.cth_objtoff ||
+ hp.cth_objtoff > hp.cth_funcoff ||
+ hp.cth_funcoff > hp.cth_typeoff ||
+ hp.cth_typeoff > hp.cth_stroff)
+ return (ctf_set_open_errno(errp, ECTF_CORRUPT));
+
+ if ((hp.cth_lbloff & 3) || (hp.cth_objtoff & 1) ||
+ (hp.cth_funcoff & 1) || (hp.cth_typeoff & 3))
+ return (ctf_set_open_errno(errp, ECTF_CORRUPT));
+
+ /*
+ * Once everything is determined to be valid, attempt to decompress
+ * the CTF data buffer if it is compressed. Otherwise we just put
+ * the data section's buffer pointer into ctf_buf, below.
+ */
+ if (hp.cth_flags & CTF_F_COMPRESS) {
+#ifndef VBOX
+ size_t srclen, dstlen;
+#else
+ uLong srclen;
+ uLong dstlen;
+#endif
+ const void *src;
+ int rc = Z_OK;
+
+#ifndef VBOX
+ if (ctf_zopen(errp) == NULL)
+ return (NULL); /* errp is set for us */
+#endif
+
+ if ((base = ctf_data_alloc(size + hdrsz)) == MAP_FAILED)
+ return (ctf_set_open_errno(errp, ECTF_ZALLOC));
+
+ bcopy(ctfsect->cts_data, base, hdrsz);
+ ((ctf_preamble_t *)base)->ctp_flags &= ~CTF_F_COMPRESS;
+ buf = (uchar_t *)base + hdrsz;
+
+ src = (uchar_t *)ctfsect->cts_data + hdrsz;
+ srclen = VBDTCAST(uLong)(ctfsect->cts_size - hdrsz);
+ dstlen = VBDTCAST(uLong)size;
+
+ if ((rc = z_uncompress(buf, &dstlen, src, srclen)) != Z_OK) {
+ ctf_dprintf("zlib inflate err: %s\n", z_strerror(rc));
+ ctf_data_free(base, size + hdrsz);
+ return (ctf_set_open_errno(errp, ECTF_DECOMPRESS));
+ }
+
+ if (dstlen != size) {
+ ctf_dprintf("zlib inflate short -- got %lu of %lu "
+ "bytes\n", (ulong_t)dstlen, (ulong_t)size);
+ ctf_data_free(base, size + hdrsz);
+ return (ctf_set_open_errno(errp, ECTF_CORRUPT));
+ }
+
+ ctf_data_protect(base, size + hdrsz);
+
+ } else {
+ base = (void *)ctfsect->cts_data;
+ buf = (uchar_t *)base + hdrsz;
+ }
+
+ /*
+ * Once we have uncompressed and validated the CTF data buffer, we can
+ * proceed with allocating a ctf_file_t and initializing it.
+ */
+ if ((fp = ctf_alloc(sizeof (ctf_file_t))) == NULL)
+ return (ctf_set_open_errno(errp, EAGAIN));
+
+ bzero(fp, sizeof (ctf_file_t));
+ fp->ctf_version = hp.cth_version;
+ fp->ctf_fileops = &ctf_fileops[hp.cth_version];
+ bcopy(ctfsect, &fp->ctf_data, sizeof (ctf_sect_t));
+
+ if (symsect != NULL) {
+ bcopy(symsect, &fp->ctf_symtab, sizeof (ctf_sect_t));
+ bcopy(strsect, &fp->ctf_strtab, sizeof (ctf_sect_t));
+ }
+
+ if (fp->ctf_data.cts_name != NULL)
+ fp->ctf_data.cts_name = ctf_strdup(fp->ctf_data.cts_name);
+ if (fp->ctf_symtab.cts_name != NULL)
+ fp->ctf_symtab.cts_name = ctf_strdup(fp->ctf_symtab.cts_name);
+ if (fp->ctf_strtab.cts_name != NULL)
+ fp->ctf_strtab.cts_name = ctf_strdup(fp->ctf_strtab.cts_name);
+
+ if (fp->ctf_data.cts_name == NULL)
+ fp->ctf_data.cts_name = _CTF_NULLSTR;
+ if (fp->ctf_symtab.cts_name == NULL)
+ fp->ctf_symtab.cts_name = _CTF_NULLSTR;
+ if (fp->ctf_strtab.cts_name == NULL)
+ fp->ctf_strtab.cts_name = _CTF_NULLSTR;
+
+ fp->ctf_str[CTF_STRTAB_0].cts_strs = (const char *)buf + hp.cth_stroff;
+ fp->ctf_str[CTF_STRTAB_0].cts_len = hp.cth_strlen;
+
+ if (strsect != NULL) {
+ fp->ctf_str[CTF_STRTAB_1].cts_strs = strsect->cts_data;
+ fp->ctf_str[CTF_STRTAB_1].cts_len = strsect->cts_size;
+ }
+
+ fp->ctf_base = base;
+ fp->ctf_buf = buf;
+ fp->ctf_size = size + hdrsz;
+
+ /*
+ * If we have a parent container name and label, store the relocated
+ * string pointers in the CTF container for easy access later.
+ */
+ if (hp.cth_parlabel != 0)
+ fp->ctf_parlabel = ctf_strptr(fp, hp.cth_parlabel);
+ if (hp.cth_parname != 0)
+ fp->ctf_parname = ctf_strptr(fp, hp.cth_parname);
+
+ ctf_dprintf("ctf_bufopen: parent name %s (label %s)\n",
+ fp->ctf_parname ? fp->ctf_parname : "<NULL>",
+ fp->ctf_parlabel ? fp->ctf_parlabel : "<NULL>");
+
+ /*
+ * If we have a symbol table section, allocate and initialize
+ * the symtab translation table, pointed to by ctf_sxlate.
+ */
+ if (symsect != NULL) {
+ fp->ctf_nsyms = symsect->cts_size / symsect->cts_entsize;
+ fp->ctf_sxlate = ctf_alloc(fp->ctf_nsyms * sizeof (uint_t));
+
+ if (fp->ctf_sxlate == NULL) {
+ (void) ctf_set_open_errno(errp, EAGAIN);
+ goto bad;
+ }
+
+ if ((err = init_symtab(fp, &hp, symsect, strsect)) != 0) {
+ (void) ctf_set_open_errno(errp, err);
+ goto bad;
+ }
+ }
+
+ if ((err = init_types(fp, &hp)) != 0) {
+ (void) ctf_set_open_errno(errp, err);
+ goto bad;
+ }
+
+ /*
+ * Initialize the ctf_lookup_by_name top-level dictionary. We keep an
+ * array of type name prefixes and the corresponding ctf_hash to use.
+ * NOTE: This code must be kept in sync with the code in ctf_update().
+ */
+ fp->ctf_lookups[0].ctl_prefix = "struct";
+ fp->ctf_lookups[0].ctl_len = strlen(fp->ctf_lookups[0].ctl_prefix);
+ fp->ctf_lookups[0].ctl_hash = &fp->ctf_structs;
+ fp->ctf_lookups[1].ctl_prefix = "union";
+ fp->ctf_lookups[1].ctl_len = strlen(fp->ctf_lookups[1].ctl_prefix);
+ fp->ctf_lookups[1].ctl_hash = &fp->ctf_unions;
+ fp->ctf_lookups[2].ctl_prefix = "enum";
+ fp->ctf_lookups[2].ctl_len = strlen(fp->ctf_lookups[2].ctl_prefix);
+ fp->ctf_lookups[2].ctl_hash = &fp->ctf_enums;
+ fp->ctf_lookups[3].ctl_prefix = _CTF_NULLSTR;
+ fp->ctf_lookups[3].ctl_len = strlen(fp->ctf_lookups[3].ctl_prefix);
+ fp->ctf_lookups[3].ctl_hash = &fp->ctf_names;
+ fp->ctf_lookups[4].ctl_prefix = NULL;
+ fp->ctf_lookups[4].ctl_len = 0;
+ fp->ctf_lookups[4].ctl_hash = NULL;
+
+ if (symsect != NULL) {
+ if (symsect->cts_entsize == sizeof (Elf64_Sym))
+ (void) ctf_setmodel(fp, CTF_MODEL_LP64);
+ else
+ (void) ctf_setmodel(fp, CTF_MODEL_ILP32);
+ } else
+ (void) ctf_setmodel(fp, CTF_MODEL_NATIVE);
+
+ fp->ctf_refcnt = 1;
+ return (fp);
+
+bad:
+ ctf_close(fp);
+ return (NULL);
+}
+
+/*
+ * Close the specified CTF container and free associated data structures. Note
+ * that ctf_close() is a reference counted operation: if the specified file is
+ * the parent of other active containers, its reference count will be greater
+ * than one and it will be freed later when no active children exist.
+ */
+void
+ctf_close(ctf_file_t *fp)
+{
+ ctf_dtdef_t *dtd, *ntd;
+
+ if (fp == NULL)
+ return; /* allow ctf_close(NULL) to simplify caller code */
+
+ ctf_dprintf("ctf_close(%p) refcnt=%u\n", (void *)fp, fp->ctf_refcnt);
+
+ if (fp->ctf_refcnt > 1) {
+ fp->ctf_refcnt--;
+ return;
+ }
+
+ if (fp->ctf_parent != NULL)
+ ctf_close(fp->ctf_parent);
+
+ for (dtd = ctf_list_next(&fp->ctf_dtdefs); dtd != NULL; dtd = ntd) {
+ ntd = ctf_list_next(dtd);
+ ctf_dtd_delete(fp, dtd);
+ }
+
+ ctf_free(fp->ctf_dthash, fp->ctf_dthashlen * sizeof (ctf_dtdef_t *));
+
+ if (fp->ctf_flags & LCTF_MMAP) {
+ if (fp->ctf_data.cts_data != NULL)
+ ctf_sect_munmap(&fp->ctf_data);
+ if (fp->ctf_symtab.cts_data != NULL)
+ ctf_sect_munmap(&fp->ctf_symtab);
+ if (fp->ctf_strtab.cts_data != NULL)
+ ctf_sect_munmap(&fp->ctf_strtab);
+ }
+
+ if (fp->ctf_data.cts_name != _CTF_NULLSTR &&
+ fp->ctf_data.cts_name != NULL) {
+ ctf_free((char *)fp->ctf_data.cts_name,
+ strlen(fp->ctf_data.cts_name) + 1);
+ }
+
+ if (fp->ctf_symtab.cts_name != _CTF_NULLSTR &&
+ fp->ctf_symtab.cts_name != NULL) {
+ ctf_free((char *)fp->ctf_symtab.cts_name,
+ strlen(fp->ctf_symtab.cts_name) + 1);
+ }
+
+ if (fp->ctf_strtab.cts_name != _CTF_NULLSTR &&
+ fp->ctf_strtab.cts_name != NULL) {
+ ctf_free((char *)fp->ctf_strtab.cts_name,
+ strlen(fp->ctf_strtab.cts_name) + 1);
+ }
+
+ if (fp->ctf_base != fp->ctf_data.cts_data && fp->ctf_base != NULL)
+ ctf_data_free((void *)fp->ctf_base, fp->ctf_size);
+
+ if (fp->ctf_sxlate != NULL)
+ ctf_free(fp->ctf_sxlate, sizeof (uint_t) * fp->ctf_nsyms);
+
+ if (fp->ctf_txlate != NULL) {
+ ctf_free(fp->ctf_txlate,
+ sizeof (uint_t) * (fp->ctf_typemax + 1));
+ }
+
+ if (fp->ctf_ptrtab != NULL) {
+ ctf_free(fp->ctf_ptrtab,
+ sizeof (ushort_t) * (fp->ctf_typemax + 1));
+ }
+
+ ctf_hash_destroy(&fp->ctf_structs);
+ ctf_hash_destroy(&fp->ctf_unions);
+ ctf_hash_destroy(&fp->ctf_enums);
+ ctf_hash_destroy(&fp->ctf_names);
+
+ ctf_free(fp, sizeof (ctf_file_t));
+}
+
+/*
+ * Return the CTF handle for the parent CTF container, if one exists.
+ * Otherwise return NULL to indicate this container has no imported parent.
+ */
+ctf_file_t *
+ctf_parent_file(ctf_file_t *fp)
+{
+ return (fp->ctf_parent);
+}
+
+/*
+ * Return the name of the parent CTF container, if one exists. Otherwise
+ * return NULL to indicate this container is a root container.
+ */
+const char *
+ctf_parent_name(ctf_file_t *fp)
+{
+ return (fp->ctf_parname);
+}
+
+/*
+ * Import the types from the specified parent container by storing a pointer
+ * to it in ctf_parent and incrementing its reference count. Only one parent
+ * is allowed: if a parent already exists, it is replaced by the new parent.
+ */
+int
+ctf_import(ctf_file_t *fp, ctf_file_t *pfp)
+{
+ if (fp == NULL || fp == pfp || (pfp != NULL && pfp->ctf_refcnt == 0))
+ return (ctf_set_errno(fp, EINVAL));
+
+ if (pfp != NULL && pfp->ctf_dmodel != fp->ctf_dmodel)
+ return (ctf_set_errno(fp, ECTF_DMODEL));
+
+ if (fp->ctf_parent != NULL)
+ ctf_close(fp->ctf_parent);
+
+ if (pfp != NULL) {
+ fp->ctf_flags |= LCTF_CHILD;
+ pfp->ctf_refcnt++;
+ }
+
+ fp->ctf_parent = pfp;
+ return (0);
+}
+
+/*
+ * Set the data model constant for the CTF container.
+ */
+int
+ctf_setmodel(ctf_file_t *fp, int model)
+{
+ const ctf_dmodel_t *dp;
+
+ for (dp = _libctf_models; dp->ctd_name != NULL; dp++) {
+ if (dp->ctd_code == model) {
+ fp->ctf_dmodel = dp;
+ return (0);
+ }
+ }
+
+ return (ctf_set_errno(fp, EINVAL));
+}
+
+/*
+ * Return the data model constant for the CTF container.
+ */
+int
+ctf_getmodel(ctf_file_t *fp)
+{
+ return (fp->ctf_dmodel->ctd_code);
+}
+
+void
+ctf_setspecific(ctf_file_t *fp, void *data)
+{
+ fp->ctf_specific = data;
+}
+
+void *
+ctf_getspecific(ctf_file_t *fp)
+{
+ return (fp->ctf_specific);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c
new file mode 100644
index 00000000..7375c067
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c
@@ -0,0 +1,847 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <ctf_impl.h>
+
+ssize_t
+ctf_get_ctt_size(const ctf_file_t *fp, const ctf_type_t *tp, ssize_t *sizep,
+ ssize_t *incrementp)
+{
+ ssize_t size, increment;
+
+ if (fp->ctf_version > CTF_VERSION_1 &&
+ tp->ctt_size == CTF_LSIZE_SENT) {
+ size = CTF_TYPE_LSIZE(tp);
+ increment = sizeof (ctf_type_t);
+ } else {
+ size = tp->ctt_size;
+ increment = sizeof (ctf_stype_t);
+ }
+
+ if (sizep)
+ *sizep = size;
+ if (incrementp)
+ *incrementp = increment;
+
+ return (size);
+}
+
+/*
+ * Iterate over the members of a STRUCT or UNION. We pass the name, member
+ * type, and offset of each member to the specified callback function.
+ */
+int
+ctf_member_iter(ctf_file_t *fp, ctf_id_t type, ctf_member_f *func, void *arg)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+ ssize_t size, increment;
+ uint_t kind, n;
+ int rc;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ (void) ctf_get_ctt_size(fp, tp, &size, &increment);
+ kind = LCTF_INFO_KIND(fp, tp->ctt_info);
+
+ if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
+ return (ctf_set_errno(ofp, ECTF_NOTSOU));
+
+ if (fp->ctf_version == CTF_VERSION_1 || size < CTF_LSTRUCT_THRESH) {
+ const ctf_member_t *mp = (const ctf_member_t *)
+ ((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, mp++) {
+ const char *name = ctf_strptr(fp, mp->ctm_name);
+ if ((rc = func(name, mp->ctm_type, mp->ctm_offset,
+ arg)) != 0)
+ return (rc);
+ }
+
+ } else {
+ const ctf_lmember_t *lmp = (const ctf_lmember_t *)
+ ((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, lmp++) {
+ const char *name = ctf_strptr(fp, lmp->ctlm_name);
+ if ((rc = func(name, lmp->ctlm_type,
+ (ulong_t)CTF_LMEM_OFFSET(lmp), arg)) != 0)
+ return (rc);
+ }
+ }
+
+ return (0);
+}
+
+/*
+ * Iterate over the members of an ENUM. We pass the string name and associated
+ * integer value of each enum element to the specified callback function.
+ */
+int
+ctf_enum_iter(ctf_file_t *fp, ctf_id_t type, ctf_enum_f *func, void *arg)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+ const ctf_enum_t *ep;
+ ssize_t increment;
+ uint_t n;
+ int rc;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ENUM)
+ return (ctf_set_errno(ofp, ECTF_NOTENUM));
+
+ (void) ctf_get_ctt_size(fp, tp, NULL, &increment);
+
+ ep = (const ctf_enum_t *)((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, ep++) {
+ const char *name = ctf_strptr(fp, ep->cte_name);
+ if ((rc = func(name, ep->cte_value, arg)) != 0)
+ return (rc);
+ }
+
+ return (0);
+}
+
+/*
+ * Iterate over every root (user-visible) type in the given CTF container.
+ * We pass the type ID of each type to the specified callback function.
+ */
+int
+ctf_type_iter(ctf_file_t *fp, ctf_type_f *func, void *arg)
+{
+ ctf_id_t id, max = fp->ctf_typemax;
+ int rc, child = (fp->ctf_flags & LCTF_CHILD);
+
+ for (id = 1; id <= max; id++) {
+ const ctf_type_t *tp = LCTF_INDEX_TO_TYPEPTR(fp, id);
+ if (CTF_INFO_ISROOT(tp->ctt_info) &&
+ (rc = func(CTF_INDEX_TO_TYPE(id, child), arg)) != 0)
+ return (rc);
+ }
+
+ return (0);
+}
+
+/*
+ * Follow a given type through the graph for TYPEDEF, VOLATILE, CONST, and
+ * RESTRICT nodes until we reach a "base" type node. This is useful when
+ * we want to follow a type ID to a node that has members or a size. To guard
+ * against infinite loops, we implement simplified cycle detection and check
+ * each link against itself, the previous node, and the topmost node.
+ */
+ctf_id_t
+ctf_type_resolve(ctf_file_t *fp, ctf_id_t type)
+{
+ ctf_id_t prev = type, otype = type;
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+
+ while ((tp = ctf_lookup_by_id(&fp, type)) != NULL) {
+ switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
+ case CTF_K_TYPEDEF:
+ case CTF_K_VOLATILE:
+ case CTF_K_CONST:
+ case CTF_K_RESTRICT:
+ if (tp->ctt_type == type || tp->ctt_type == otype ||
+ tp->ctt_type == prev) {
+ ctf_dprintf("type %ld cycle detected\n", otype);
+ return (ctf_set_errno(ofp, ECTF_CORRUPT));
+ }
+ prev = type;
+ type = tp->ctt_type;
+ break;
+ default:
+ return (type);
+ }
+ }
+
+ return (CTF_ERR); /* errno is set for us */
+}
+
+/*
+ * Lookup the given type ID and print a string name for it into buf. Return
+ * the actual number of bytes (not including \0) needed to format the name.
+ */
+ssize_t
+ctf_type_lname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
+{
+ ctf_decl_t cd;
+ ctf_decl_node_t *cdp;
+ ctf_decl_prec_t prec, lp, rp;
+ int ptr, arr;
+ uint_t k;
+
+ if (fp == NULL && type == CTF_ERR)
+ return (-1); /* simplify caller code by permitting CTF_ERR */
+
+ ctf_decl_init(&cd, buf, len);
+ ctf_decl_push(&cd, fp, type);
+
+ if (cd.cd_err != 0) {
+ ctf_decl_fini(&cd);
+ return (ctf_set_errno(fp, cd.cd_err));
+ }
+
+ /*
+ * If the type graph's order conflicts with lexical precedence order
+ * for pointers or arrays, then we need to surround the declarations at
+ * the corresponding lexical precedence with parentheses. This can
+ * result in either a parenthesized pointer (*) as in int (*)() or
+ * int (*)[], or in a parenthesized pointer and array as in int (*[])().
+ */
+ ptr = cd.cd_order[CTF_PREC_POINTER] > CTF_PREC_POINTER;
+ arr = cd.cd_order[CTF_PREC_ARRAY] > CTF_PREC_ARRAY;
+
+ rp = arr ? CTF_PREC_ARRAY : ptr ? CTF_PREC_POINTER : -1;
+ lp = ptr ? CTF_PREC_POINTER : arr ? CTF_PREC_ARRAY : -1;
+
+ k = CTF_K_POINTER; /* avoid leading whitespace (see below) */
+
+ for (prec = CTF_PREC_BASE; prec < CTF_PREC_MAX; prec++) {
+ for (cdp = ctf_list_next(&cd.cd_nodes[prec]);
+ cdp != NULL; cdp = ctf_list_next(cdp)) {
+
+ ctf_file_t *rfp = fp;
+ const ctf_type_t *tp =
+ ctf_lookup_by_id(&rfp, cdp->cd_type);
+ const char *name = ctf_strptr(rfp, tp->ctt_name);
+
+ if (k != CTF_K_POINTER && k != CTF_K_ARRAY)
+ ctf_decl_sprintf(&cd, " ");
+
+ if (lp == prec) {
+ ctf_decl_sprintf(&cd, "(");
+ lp = -1;
+ }
+
+ switch (cdp->cd_kind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ case CTF_K_TYPEDEF:
+ ctf_decl_sprintf(&cd, "%s", name);
+ break;
+ case CTF_K_POINTER:
+ ctf_decl_sprintf(&cd, "*");
+ break;
+ case CTF_K_ARRAY:
+ ctf_decl_sprintf(&cd, "[%u]", cdp->cd_n);
+ break;
+ case CTF_K_FUNCTION:
+ ctf_decl_sprintf(&cd, "()");
+ break;
+ case CTF_K_STRUCT:
+ case CTF_K_FORWARD:
+ ctf_decl_sprintf(&cd, "struct %s", name);
+ break;
+ case CTF_K_UNION:
+ ctf_decl_sprintf(&cd, "union %s", name);
+ break;
+ case CTF_K_ENUM:
+ ctf_decl_sprintf(&cd, "enum %s", name);
+ break;
+ case CTF_K_VOLATILE:
+ ctf_decl_sprintf(&cd, "volatile");
+ break;
+ case CTF_K_CONST:
+ ctf_decl_sprintf(&cd, "const");
+ break;
+ case CTF_K_RESTRICT:
+ ctf_decl_sprintf(&cd, "restrict");
+ break;
+ }
+
+ k = cdp->cd_kind;
+ }
+
+ if (rp == prec)
+ ctf_decl_sprintf(&cd, ")");
+ }
+
+ if (cd.cd_len >= len)
+ (void) ctf_set_errno(fp, ECTF_NAMELEN);
+
+ ctf_decl_fini(&cd);
+ return (cd.cd_len);
+}
+
+/*
+ * Lookup the given type ID and print a string name for it into buf. If buf
+ * is too small, return NULL: the ECTF_NAMELEN error is set on 'fp' for us.
+ */
+char *
+ctf_type_name(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
+{
+ ssize_t rv = ctf_type_lname(fp, type, buf, len);
+ return (rv >= 0 && VBDTCAST(size_t)rv < len ? buf : NULL);
+}
+
+/*
+ * Resolve the type down to a base type node, and then return the size
+ * of the type storage in bytes.
+ */
+ssize_t
+ctf_type_size(ctf_file_t *fp, ctf_id_t type)
+{
+ const ctf_type_t *tp;
+ ssize_t size;
+ ctf_arinfo_t ar;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (-1); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (-1); /* errno is set for us */
+
+ switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
+ case CTF_K_POINTER:
+ return (fp->ctf_dmodel->ctd_pointer);
+
+ case CTF_K_FUNCTION:
+ return (0); /* function size is only known by symtab */
+
+ case CTF_K_ENUM:
+ return (fp->ctf_dmodel->ctd_int);
+
+ case CTF_K_ARRAY:
+ /*
+ * Array size is not directly returned by stabs data. Instead,
+ * it defines the element type and requires the user to perform
+ * the multiplication. If ctf_get_ctt_size() returns zero, the
+ * current version of ctfconvert does not compute member sizes
+ * and we compute the size here on its behalf.
+ */
+ if ((size = ctf_get_ctt_size(fp, tp, NULL, NULL)) > 0)
+ return (size);
+
+ if (ctf_array_info(fp, type, &ar) == CTF_ERR ||
+ (size = ctf_type_size(fp, ar.ctr_contents)) == CTF_ERR)
+ return (-1); /* errno is set for us */
+
+ return (size * ar.ctr_nelems);
+
+ default:
+ return (ctf_get_ctt_size(fp, tp, NULL, NULL));
+ }
+}
+
+/*
+ * Resolve the type down to a base type node, and then return the alignment
+ * needed for the type storage in bytes.
+ */
+ssize_t
+ctf_type_align(ctf_file_t *fp, ctf_id_t type)
+{
+ const ctf_type_t *tp;
+ ctf_arinfo_t r;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (-1); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (-1); /* errno is set for us */
+
+ switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
+ case CTF_K_POINTER:
+ case CTF_K_FUNCTION:
+ return (fp->ctf_dmodel->ctd_pointer);
+
+ case CTF_K_ARRAY:
+ if (ctf_array_info(fp, type, &r) == CTF_ERR)
+ return (-1); /* errno is set for us */
+ return (ctf_type_align(fp, r.ctr_contents));
+
+ case CTF_K_STRUCT:
+ case CTF_K_UNION: {
+ uint_t n = LCTF_INFO_VLEN(fp, tp->ctt_info);
+ ssize_t size, increment;
+ size_t align = 0;
+ const void *vmp;
+
+ (void) ctf_get_ctt_size(fp, tp, &size, &increment);
+ vmp = (uchar_t *)tp + increment;
+
+ if (LCTF_INFO_KIND(fp, tp->ctt_info) == CTF_K_STRUCT)
+ n = MIN(n, 1); /* only use first member for structs */
+
+ if (fp->ctf_version == CTF_VERSION_1 ||
+ size < CTF_LSTRUCT_THRESH) {
+ const ctf_member_t *mp = vmp;
+ for (; n != 0; n--, mp++) {
+ ssize_t am = ctf_type_align(fp, mp->ctm_type);
+ align = MAX(VBDTCAST(ssize_t)align, am);
+ }
+ } else {
+ const ctf_lmember_t *lmp = vmp;
+ for (; n != 0; n--, lmp++) {
+ ssize_t am = ctf_type_align(fp, lmp->ctlm_type);
+ align = MAX(VBDTCAST(ssize_t)align, am);
+ }
+ }
+
+ return (align);
+ }
+
+ case CTF_K_ENUM:
+ return (fp->ctf_dmodel->ctd_int);
+
+ default:
+ return (ctf_get_ctt_size(fp, tp, NULL, NULL));
+ }
+}
+
+/*
+ * Return the kind (CTF_K_* constant) for the specified type ID.
+ */
+int
+ctf_type_kind(ctf_file_t *fp, ctf_id_t type)
+{
+ const ctf_type_t *tp;
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ return (LCTF_INFO_KIND(fp, tp->ctt_info));
+}
+
+/*
+ * If the type is one that directly references another type (such as POINTER),
+ * then return the ID of the type to which it refers.
+ */
+ctf_id_t
+ctf_type_reference(ctf_file_t *fp, ctf_id_t type)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
+ case CTF_K_POINTER:
+ case CTF_K_TYPEDEF:
+ case CTF_K_VOLATILE:
+ case CTF_K_CONST:
+ case CTF_K_RESTRICT:
+ return (tp->ctt_type);
+ default:
+ return (ctf_set_errno(ofp, ECTF_NOTREF));
+ }
+}
+
+/*
+ * Find a pointer to type by looking in fp->ctf_ptrtab. If we can't find a
+ * pointer to the given type, see if we can compute a pointer to the type
+ * resulting from resolving the type down to its base type and use that
+ * instead. This helps with cases where the CTF data includes "struct foo *"
+ * but not "foo_t *" and the user accesses "foo_t *" in the debugger.
+ */
+ctf_id_t
+ctf_type_pointer(ctf_file_t *fp, ctf_id_t type)
+{
+ ctf_file_t *ofp = fp;
+ ctf_id_t ntype;
+
+ if (ctf_lookup_by_id(&fp, type) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((ntype = fp->ctf_ptrtab[CTF_TYPE_TO_INDEX(type)]) != 0)
+ return (CTF_INDEX_TO_TYPE(ntype, (fp->ctf_flags & LCTF_CHILD)));
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (ctf_set_errno(ofp, ECTF_NOTYPE));
+
+ if (ctf_lookup_by_id(&fp, type) == NULL)
+ return (ctf_set_errno(ofp, ECTF_NOTYPE));
+
+ if ((ntype = fp->ctf_ptrtab[CTF_TYPE_TO_INDEX(type)]) != 0)
+ return (CTF_INDEX_TO_TYPE(ntype, (fp->ctf_flags & LCTF_CHILD)));
+
+ return (ctf_set_errno(ofp, ECTF_NOTYPE));
+}
+
+/*
+ * Return the encoding for the specified INTEGER or FLOAT.
+ */
+int
+ctf_type_encoding(ctf_file_t *fp, ctf_id_t type, ctf_encoding_t *ep)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+ ssize_t increment;
+ uint_t data;
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ (void) ctf_get_ctt_size(fp, tp, NULL, &increment);
+
+ switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
+ case CTF_K_INTEGER:
+ data = *(const uint_t *)((uintptr_t)tp + increment);
+ ep->cte_format = CTF_INT_ENCODING(data);
+ ep->cte_offset = CTF_INT_OFFSET(data);
+ ep->cte_bits = CTF_INT_BITS(data);
+ break;
+ case CTF_K_FLOAT:
+ data = *(const uint_t *)((uintptr_t)tp + increment);
+ ep->cte_format = CTF_FP_ENCODING(data);
+ ep->cte_offset = CTF_FP_OFFSET(data);
+ ep->cte_bits = CTF_FP_BITS(data);
+ break;
+ default:
+ return (ctf_set_errno(ofp, ECTF_NOTINTFP));
+ }
+
+ return (0);
+}
+
+int
+ctf_type_cmp(ctf_file_t *lfp, ctf_id_t ltype, ctf_file_t *rfp, ctf_id_t rtype)
+{
+ int rval;
+
+ if (ltype < rtype)
+ rval = -1;
+ else if (ltype > rtype)
+ rval = 1;
+ else
+ rval = 0;
+
+ if (lfp == rfp)
+ return (rval);
+
+ if (CTF_TYPE_ISPARENT(ltype) && lfp->ctf_parent != NULL)
+ lfp = lfp->ctf_parent;
+
+ if (CTF_TYPE_ISPARENT(rtype) && rfp->ctf_parent != NULL)
+ rfp = rfp->ctf_parent;
+
+ if (lfp < rfp)
+ return (-1);
+
+ if (lfp > rfp)
+ return (1);
+
+ return (rval);
+}
+
+/*
+ * Return a boolean value indicating if two types are compatible integers or
+ * floating-pointer values. This function returns true if the two types are
+ * the same, or if they have the same ASCII name and encoding properties.
+ * This function could be extended to test for compatibility for other kinds.
+ */
+int
+ctf_type_compat(ctf_file_t *lfp, ctf_id_t ltype,
+ ctf_file_t *rfp, ctf_id_t rtype)
+{
+ const ctf_type_t *ltp, *rtp;
+ ctf_encoding_t le, re;
+ ctf_arinfo_t la, ra;
+ uint_t lkind, rkind;
+
+ if (ctf_type_cmp(lfp, ltype, rfp, rtype) == 0)
+ return (1);
+
+ ltype = ctf_type_resolve(lfp, ltype);
+ lkind = ctf_type_kind(lfp, ltype);
+
+ rtype = ctf_type_resolve(rfp, rtype);
+ rkind = ctf_type_kind(rfp, rtype);
+
+ if (lkind != rkind ||
+ (ltp = ctf_lookup_by_id(&lfp, ltype)) == NULL ||
+ (rtp = ctf_lookup_by_id(&rfp, rtype)) == NULL ||
+ strcmp(ctf_strptr(lfp, ltp->ctt_name),
+ ctf_strptr(rfp, rtp->ctt_name)) != 0)
+ return (0);
+
+ switch (lkind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ return (ctf_type_encoding(lfp, ltype, &le) == 0 &&
+ ctf_type_encoding(rfp, rtype, &re) == 0 &&
+ bcmp(&le, &re, sizeof (ctf_encoding_t)) == 0);
+ case CTF_K_POINTER:
+ return (ctf_type_compat(lfp, ctf_type_reference(lfp, ltype),
+ rfp, ctf_type_reference(rfp, rtype)));
+ case CTF_K_ARRAY:
+ return (ctf_array_info(lfp, ltype, &la) == 0 &&
+ ctf_array_info(rfp, rtype, &ra) == 0 &&
+ la.ctr_nelems == ra.ctr_nelems && ctf_type_compat(
+ lfp, la.ctr_contents, rfp, ra.ctr_contents) &&
+ ctf_type_compat(lfp, la.ctr_index, rfp, ra.ctr_index));
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ return (ctf_type_size(lfp, ltype) == ctf_type_size(rfp, rtype));
+ case CTF_K_ENUM:
+ case CTF_K_FORWARD:
+ return (1); /* no other checks required for these type kinds */
+ default:
+ return (0); /* should not get here since we did a resolve */
+ }
+}
+
+/*
+ * Return the type and offset for a given member of a STRUCT or UNION.
+ */
+int
+ctf_member_info(ctf_file_t *fp, ctf_id_t type, const char *name,
+ ctf_membinfo_t *mip)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+ ssize_t size, increment;
+ uint_t kind, n;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ (void) ctf_get_ctt_size(fp, tp, &size, &increment);
+ kind = LCTF_INFO_KIND(fp, tp->ctt_info);
+
+ if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
+ return (ctf_set_errno(ofp, ECTF_NOTSOU));
+
+ if (fp->ctf_version == CTF_VERSION_1 || size < CTF_LSTRUCT_THRESH) {
+ const ctf_member_t *mp = (const ctf_member_t *)
+ ((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, mp++) {
+ if (strcmp(ctf_strptr(fp, mp->ctm_name), name) == 0) {
+ mip->ctm_type = mp->ctm_type;
+ mip->ctm_offset = mp->ctm_offset;
+ return (0);
+ }
+ }
+ } else {
+ const ctf_lmember_t *lmp = (const ctf_lmember_t *)
+ ((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, lmp++) {
+ if (strcmp(ctf_strptr(fp, lmp->ctlm_name), name) == 0) {
+ mip->ctm_type = lmp->ctlm_type;
+ mip->ctm_offset = (ulong_t)CTF_LMEM_OFFSET(lmp);
+ return (0);
+ }
+ }
+ }
+
+ return (ctf_set_errno(ofp, ECTF_NOMEMBNAM));
+}
+
+/*
+ * Return the array type, index, and size information for the specified ARRAY.
+ */
+int
+ctf_array_info(ctf_file_t *fp, ctf_id_t type, ctf_arinfo_t *arp)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+ const ctf_array_t *ap;
+ ssize_t increment;
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ARRAY)
+ return (ctf_set_errno(ofp, ECTF_NOTARRAY));
+
+ (void) ctf_get_ctt_size(fp, tp, NULL, &increment);
+
+ ap = (const ctf_array_t *)((uintptr_t)tp + increment);
+ arp->ctr_contents = ap->cta_contents;
+ arp->ctr_index = ap->cta_index;
+ arp->ctr_nelems = ap->cta_nelems;
+
+ return (0);
+}
+
+/*
+ * Convert the specified value to the corresponding enum member name, if a
+ * matching name can be found. Otherwise NULL is returned.
+ */
+const char *
+ctf_enum_name(ctf_file_t *fp, ctf_id_t type, int value)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+ const ctf_enum_t *ep;
+ ssize_t increment;
+ uint_t n;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (NULL); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (NULL); /* errno is set for us */
+
+ if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ENUM) {
+ (void) ctf_set_errno(ofp, ECTF_NOTENUM);
+ return (NULL);
+ }
+
+ (void) ctf_get_ctt_size(fp, tp, NULL, &increment);
+
+ ep = (const ctf_enum_t *)((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, ep++) {
+ if (ep->cte_value == value)
+ return (ctf_strptr(fp, ep->cte_name));
+ }
+
+ (void) ctf_set_errno(ofp, ECTF_NOENUMNAM);
+ return (NULL);
+}
+
+/*
+ * Convert the specified enum tag name to the corresponding value, if a
+ * matching name can be found. Otherwise CTF_ERR is returned.
+ */
+int
+ctf_enum_value(ctf_file_t *fp, ctf_id_t type, const char *name, int *valp)
+{
+ ctf_file_t *ofp = fp;
+ const ctf_type_t *tp;
+ const ctf_enum_t *ep;
+ ssize_t size, increment;
+ uint_t n;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ENUM) {
+ (void) ctf_set_errno(ofp, ECTF_NOTENUM);
+ return (CTF_ERR);
+ }
+
+ (void) ctf_get_ctt_size(fp, tp, &size, &increment);
+
+ ep = (const ctf_enum_t *)((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, ep++) {
+ if (strcmp(ctf_strptr(fp, ep->cte_name), name) == 0) {
+ if (valp != NULL)
+ *valp = ep->cte_value;
+ return (0);
+ }
+ }
+
+ (void) ctf_set_errno(ofp, ECTF_NOENUMNAM);
+ return (CTF_ERR);
+}
+
+/*
+ * Recursively visit the members of any type. This function is used as the
+ * engine for ctf_type_visit, below. We resolve the input type, recursively
+ * invoke ourself for each type member if the type is a struct or union, and
+ * then invoke the callback function on the current type. If any callback
+ * returns non-zero, we abort and percolate the error code back up to the top.
+ */
+static int
+ctf_type_rvisit(ctf_file_t *fp, ctf_id_t type, ctf_visit_f *func, void *arg,
+ const char *name, ulong_t offset, int depth)
+{
+ ctf_id_t otype = type;
+ const ctf_type_t *tp;
+ ssize_t size, increment;
+ uint_t kind, n;
+ int rc;
+
+ if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
+ return (CTF_ERR); /* errno is set for us */
+
+ if ((rc = func(name, otype, offset, depth, arg)) != 0)
+ return (rc);
+
+ kind = LCTF_INFO_KIND(fp, tp->ctt_info);
+
+ if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
+ return (0);
+
+ (void) ctf_get_ctt_size(fp, tp, &size, &increment);
+
+ if (fp->ctf_version == CTF_VERSION_1 || size < CTF_LSTRUCT_THRESH) {
+ const ctf_member_t *mp = (const ctf_member_t *)
+ ((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, mp++) {
+ if ((rc = ctf_type_rvisit(fp, mp->ctm_type,
+ func, arg, ctf_strptr(fp, mp->ctm_name),
+ offset + mp->ctm_offset, depth + 1)) != 0)
+ return (rc);
+ }
+
+ } else {
+ const ctf_lmember_t *lmp = (const ctf_lmember_t *)
+ ((uintptr_t)tp + increment);
+
+ for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, lmp++) {
+ if ((rc = ctf_type_rvisit(fp, lmp->ctlm_type,
+ func, arg, ctf_strptr(fp, lmp->ctlm_name),
+ offset + (ulong_t)CTF_LMEM_OFFSET(lmp),
+ depth + 1)) != 0)
+ return (rc);
+ }
+ }
+
+ return (0);
+}
+
+/*
+ * Recursively visit the members of any type. We pass the name, member
+ * type, and offset of each member to the specified callback function.
+ */
+int
+ctf_type_visit(ctf_file_t *fp, ctf_id_t type, ctf_visit_f *func, void *arg)
+{
+ return (ctf_type_rvisit(fp, type, func, arg, "", 0, 0));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c
new file mode 100644
index 00000000..c13c1d64
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c
@@ -0,0 +1,154 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <ctf_impl.h>
+
+/*
+ * Simple doubly-linked list append routine. This implementation assumes that
+ * each list element contains an embedded ctf_list_t as the first member.
+ * An additional ctf_list_t is used to store the head (l_next) and tail
+ * (l_prev) pointers. The current head and tail list elements have their
+ * previous and next pointers set to NULL, respectively.
+ */
+void
+ctf_list_append(ctf_list_t *lp, void *new)
+{
+ ctf_list_t *p = lp->l_prev; /* p = tail list element */
+ ctf_list_t *q = new; /* q = new list element */
+
+ lp->l_prev = q;
+ q->l_prev = p;
+ q->l_next = NULL;
+
+ if (p != NULL)
+ p->l_next = q;
+ else
+ lp->l_next = q;
+}
+
+/*
+ * Prepend the specified existing element to the given ctf_list_t. The
+ * existing pointer should be pointing at a struct with embedded ctf_list_t.
+ */
+void
+ctf_list_prepend(ctf_list_t *lp, void *new)
+{
+ ctf_list_t *p = new; /* p = new list element */
+ ctf_list_t *q = lp->l_next; /* q = head list element */
+
+ lp->l_next = p;
+ p->l_prev = NULL;
+ p->l_next = q;
+
+ if (q != NULL)
+ q->l_prev = p;
+ else
+ lp->l_prev = p;
+}
+
+/*
+ * Delete the specified existing element from the given ctf_list_t. The
+ * existing pointer should be pointing at a struct with embedded ctf_list_t.
+ */
+void
+ctf_list_delete(ctf_list_t *lp, void *existing)
+{
+ ctf_list_t *p = existing;
+
+ if (p->l_prev != NULL)
+ p->l_prev->l_next = p->l_next;
+ else
+ lp->l_next = p->l_next;
+
+ if (p->l_next != NULL)
+ p->l_next->l_prev = p->l_prev;
+ else
+ lp->l_prev = p->l_prev;
+}
+
+/*
+ * Convert an encoded CTF string name into a pointer to a C string by looking
+ * up the appropriate string table buffer and then adding the offset.
+ */
+const char *
+ctf_strraw(ctf_file_t *fp, uint_t name)
+{
+ ctf_strs_t *ctsp = &fp->ctf_str[CTF_NAME_STID(name)];
+
+ if (ctsp->cts_strs != NULL && CTF_NAME_OFFSET(name) < ctsp->cts_len)
+ return (ctsp->cts_strs + CTF_NAME_OFFSET(name));
+
+ /* string table not loaded or corrupt offset */
+ return (NULL);
+}
+
+const char *
+ctf_strptr(ctf_file_t *fp, uint_t name)
+{
+ const char *s = ctf_strraw(fp, name);
+ return (s != NULL ? s : "(?)");
+}
+
+/*
+ * Same strdup(3C), but use ctf_alloc() to do the memory allocation.
+ */
+char *
+ctf_strdup(const char *s1)
+{
+ char *s2 = ctf_alloc(strlen(s1) + 1);
+
+ if (s2 != NULL)
+ (void) strcpy(s2, s1);
+
+ return (s2);
+}
+
+/*
+ * Store the specified error code into errp if it is non-NULL, and then
+ * return NULL for the benefit of the caller.
+ */
+ctf_file_t *
+ctf_set_open_errno(int *errp, int error)
+{
+ if (errp != NULL)
+ *errp = error;
+ return (NULL);
+}
+
+/*
+ * Store the specified error code into the CTF container, and then return
+ * CTF_ERR for the benefit of the caller.
+ */
+long
+ctf_set_errno(ctf_file_t *fp, int err)
+{
+ fp->ctf_errno = err;
+ return (CTF_ERR);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/dtrace_data.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/dtrace_data.c
new file mode 100644
index 00000000..7e1d3d9b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/common/dtrace/dtrace_data.c
@@ -0,0 +1,113 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+
+/*
+ * In order to let the DTrace fasttrap provider trace processes before libc
+ * is initialized, we place this structure in the thread pointer register.
+ * This is communicated to the kernel (in the elfexec() function) by
+ * placing the address of this structure in the PT_SUNWDTRACE program
+ * header with the -zdtrace_data=<object> option to ld(1).
+ *
+ * Besides DTrace use, the initialization sequence carried out for the
+ * PT_SUNWDTRACE data is an essential step required for the correct
+ * initialization of any process. Therefore, PT_SUNWDTRACE data must
+ * exist in any interpretor available on Solaris.
+ *
+ * ld.so.1 is the standard interpretor on all Solaris platforms. However,
+ * for ABI compliance, 32-bit executables are able to identify libc.so.1
+ * as their interpretor. Therefore, this data file is used to build all
+ * instances of ld.so.1, and the 32-bit versions of libc.so.1. Note,
+ * although libc.so.1 can act as an interpretor for 32-bit applications,
+ * libc.so.1 only provides a bootstrap mechanism to load and jump to
+ * ld.so.1.
+ *
+ * The fields of the program header are set as follows:
+ * p_type: PT_SUNWDTRACE
+ * p_vaddr: address of dtrace_data
+ * p_memsz: size of dtrace_data
+ * p_flags: flags of segment dtrace_data is assigned to
+ * p_paddr: <reserved>
+ * p_filesz: <reserved>
+ * p_offset: <reserved>
+ * p_align: <reserved>
+ *
+ * See the comment in fasttrap.h for information on how to safely change
+ * this data structure and the other places that need to be kept in sync.
+ */
+
+#if defined(__sparc)
+
+#pragma align 64(dtrace_data)
+uint32_t dtrace_data[32] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x9de04000, /* save %g1, %g0, %sp */
+ 0x81e80000, /* restore %g0, %g0, %g0 */
+ 0x91d0203a, /* ta 0x3a */
+ 0x81ca0000, /* return %o0 */
+ 0, 0, /* self pointer (must be zero) */
+ 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+#elif defined(__amd64)
+
+#pragma align 64(dtrace_data)
+uint8_t dtrace_data[64] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, /* self pointer (must be zero) */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+#elif defined(__i386)
+
+#pragma align 64(dtrace_data)
+uint8_t dtrace_data[64] = {
+ 0, 0, 0, 0, /* self pointer (must be zero) */
+ 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+#else
+
+#error "unknown ISA"
+
+#endif
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile
new file mode 100644
index 00000000..5a8b3f9e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile
@@ -0,0 +1,55 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.lib
+
+HDRS = libctf.h
+HDRDIR = common
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
+lint := TARGET = lint
+
+.KEEP_STATE:
+
+all clean clobber install lint: $(SUBDIRS)
+
+install_h: $(ROOTHDRS)
+
+check: $(CHECKHDRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.com b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.com
new file mode 100644
index 00000000..267d67aa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.com
@@ -0,0 +1,72 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+LIBRARY = libctf.a
+VERS = .1
+
+COMMON_OBJS = \
+ ctf_create.o \
+ ctf_decl.o \
+ ctf_error.o \
+ ctf_hash.o \
+ ctf_labels.o \
+ ctf_lookup.o \
+ ctf_open.o \
+ ctf_types.o \
+ ctf_util.o
+
+LIB_OBJS = \
+ ctf_lib.o \
+ ctf_subr.o
+
+OBJECTS = $(COMMON_OBJS) $(LIB_OBJS)
+
+include ../../Makefile.lib
+include ../../Makefile.rootfs
+
+SRCS = $(COMMON_OBJS:%.o=../../../common/ctf/%.c) $(LIB_OBJS:%.o=../common/%.c)
+LIBS = $(DYNLIB) $(LINTLIB)
+
+SRCDIR = ../common
+
+CPPFLAGS += -I../common -I../../../common/ctf -DCTF_OLD_VERSIONS
+CFLAGS += $(CCVERBOSE)
+LDLIBS += -lc
+
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+lint: lintcheck
+
+include ../../Makefile.targ
+
+objs/%.o pics/%.o: ../../../common/ctf/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/amd64/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/amd64/Makefile
new file mode 100644
index 00000000..c9bd26cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/amd64/Makefile
@@ -0,0 +1,31 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c
new file mode 100644
index 00000000..3109da13
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c
@@ -0,0 +1,596 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <ctf_impl.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <gelf.h>
+#else
+# include <libctf.h>
+# include <ctf_impl.h>
+# include <iprt/param.h>
+# include <sys/stat.h>
+# include <stdio.h>
+# include <fcntl.h>
+# ifdef _MSC_VER
+# include <io.h>
+# else
+# include <unistd.h>
+# endif
+# define stat64 stat
+# define fstat64 fstat
+# define open64 open
+# define off64_t int64_t
+#endif
+
+#ifndef VBOX /* staticly linked in */
+#ifdef _LP64
+static const char *_libctf_zlib = "/usr/lib/64/libz.so";
+#else
+static const char *_libctf_zlib = "/usr/lib/libz.so";
+#endif
+
+static struct {
+ int (*z_uncompress)(uchar_t *, ulong_t *, const uchar_t *, ulong_t);
+ const char *(*z_error)(int);
+ void *z_dlp;
+} zlib;
+#endif /* !VBOX */
+
+static size_t _PAGESIZE;
+static size_t _PAGEMASK;
+
+#ifndef VBOX
+#pragma init(_libctf_init)
+void
+_libctf_init(void)
+#else
+void libctf_init(void)
+#endif
+{
+#ifndef VBOX
+ const char *p = getenv("LIBCTF_DECOMPRESSOR");
+
+ if (p != NULL)
+ _libctf_zlib = p; /* use alternate decompression library */
+#endif
+
+ _libctf_debug = getenv("LIBCTF_DEBUG") != NULL;
+
+#ifndef VBOX
+ _PAGESIZE = getpagesize();
+#else
+ _PAGESIZE = PAGE_SIZE;
+#endif
+ _PAGEMASK = ~(_PAGESIZE - 1);
+}
+
+#ifdef VBOX
+/*
+ * Fake MMAP for read only access.
+ */
+# define munmap(a_pvMem, a_cbMem) \
+ RTMemPageFree(a_pvMem, a_cbMem)
+
+# define mmap64(a_pvAddr, a_cb, a_fProt, a_fFlags, a_fd, a_offFile) \
+ VBoxCtfMap64Fake(a_pvAddr, a_cb, a_fProt, a_fFlags, a_fd, a_offFile)
+
+# undef PROT_READ
+# define PROT_READ 0xfeed
+# undef MAP_PRIVATE
+# define MAP_PRIVATE 0xbeef
+
+static void *VBoxCtfMap64Fake(void *pvAddr, size_t cb, int fProt, int fFlags, int fd, int64_t offFile)
+{
+ off_t const offSaved = lseek(fd, 0, SEEK_CUR);
+ void *pvRet = NULL;
+ int err;
+ RT_NOREF2(fProt, fFlags);
+
+ Assert(pvAddr == NULL); NOREF(pvAddr);
+ Assert(fProt == PROT_READ);
+ Assert(fFlags == MAP_PRIVATE);
+ if ((off_t)offFile != offFile) {
+ errno = EIO;
+ return MAP_FAILED;
+ }
+
+ if (lseek(offFile, offFile, SEEK_SET) >= 0) {
+
+ pvRet = RTMemPageAllocZ(cb);
+ if (!pvRet) {
+#ifdef _MSC_VER
+ ssize_t cbRead = read(fd, pvRet, (unsigned int)cb);
+#else
+ ssize_t cbRead = read(fd, pvRet, cb);
+#endif
+ if (cbRead < 0) {
+ RTMemPageFree(pvRet, cb);
+ pvRet = MAP_FAILED;
+ }
+ } else {
+ errno = ENOMEM;
+ pvRet = MAP_FAILED;
+ }
+
+ /* restore original position */
+ err = errno;
+ lseek(offSaved, 0, SEEK_SET);
+ errno = err;
+ }
+
+ return pvRet;
+}
+
+/*
+ * pread64
+ */
+#define pread64(a_fd, a_pvBuf, a_cbToRead, a_offFile) \
+ VBoxCtfPRead64(a_fd, a_pvBuf, a_cbToRead, a_offFile)
+
+static ssize_t VBoxCtfPRead64(int fd, void *pvBuf, size_t cbToRead, int64_t offFile)
+{
+ if ((off_t)offFile != offFile) {
+ errno = EIO;
+ return -1;
+ }
+
+ if (lseek(fd, offFile, SEEK_SET) < 0)
+ return -1;
+#ifndef _MSC_VER
+ return read(fd, pvBuf, cbToRead);
+#else
+ return read(fd, pvBuf, (unsigned int)cbToRead);
+#endif
+}
+
+
+
+#endif /* VBOX */
+
+#ifndef VBOX
+
+/*
+ * Attempt to dlopen the decompression library and locate the symbols of
+ * interest that we will need to call. This information in cached so
+ * that multiple calls to ctf_bufopen() do not need to reopen the library.
+ */
+void *
+ctf_zopen(int *errp)
+{
+ ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib);
+
+ if (zlib.z_dlp != NULL)
+ return (zlib.z_dlp); /* library is already loaded */
+
+ if (access(_libctf_zlib, R_OK) == -1)
+ return (ctf_set_open_errno(errp, ECTF_ZMISSING));
+
+ if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL)
+ return (ctf_set_open_errno(errp, ECTF_ZINIT));
+
+ zlib.z_uncompress = (int (*)()) dlsym(zlib.z_dlp, "uncompress");
+ zlib.z_error = (const char *(*)()) dlsym(zlib.z_dlp, "zError");
+
+ if (zlib.z_uncompress == NULL || zlib.z_error == NULL) {
+ (void) dlclose(zlib.z_dlp);
+ bzero(&zlib, sizeof (zlib));
+ return (ctf_set_open_errno(errp, ECTF_ZINIT));
+ }
+
+ return (zlib.z_dlp);
+}
+
+/*
+ * The ctf_bufopen() routine calls these subroutines, defined by <sys/zmod.h>,
+ * which we then patch through to the functions in the decompression library.
+ */
+int
+z_uncompress(void *dst, size_t *dstlen, const void *src, size_t srclen)
+{
+ return (zlib.z_uncompress(dst, (ulong_t *)dstlen, src, srclen));
+}
+
+const char *
+z_strerror(int err)
+{
+ return (zlib.z_error(err));
+}
+
+#endif /* VBOX */
+
+/*
+ * Convert a 32-bit ELF file header into GElf.
+ */
+static void
+ehdr_to_gelf(const Elf32_Ehdr *src, GElf_Ehdr *dst)
+{
+ bcopy(src->e_ident, dst->e_ident, EI_NIDENT);
+ dst->e_type = src->e_type;
+ dst->e_machine = src->e_machine;
+ dst->e_version = src->e_version;
+ dst->e_entry = (Elf64_Addr)src->e_entry;
+ dst->e_phoff = (Elf64_Off)src->e_phoff;
+ dst->e_shoff = (Elf64_Off)src->e_shoff;
+ dst->e_flags = src->e_flags;
+ dst->e_ehsize = src->e_ehsize;
+ dst->e_phentsize = src->e_phentsize;
+ dst->e_phnum = src->e_phnum;
+ dst->e_shentsize = src->e_shentsize;
+ dst->e_shnum = src->e_shnum;
+ dst->e_shstrndx = src->e_shstrndx;
+}
+
+/*
+ * Convert a 32-bit ELF section header into GElf.
+ */
+static void
+shdr_to_gelf(const Elf32_Shdr *src, GElf_Shdr *dst)
+{
+ dst->sh_name = src->sh_name;
+ dst->sh_type = src->sh_type;
+ dst->sh_flags = src->sh_flags;
+ dst->sh_addr = src->sh_addr;
+ dst->sh_offset = src->sh_offset;
+ dst->sh_size = src->sh_size;
+ dst->sh_link = src->sh_link;
+ dst->sh_info = src->sh_info;
+ dst->sh_addralign = src->sh_addralign;
+ dst->sh_entsize = src->sh_entsize;
+}
+
+/*
+ * In order to mmap a section from the ELF file, we must round down sh_offset
+ * to the previous page boundary, and mmap the surrounding page. We store
+ * the pointer to the start of the actual section data back into sp->cts_data.
+ */
+const void *
+ctf_sect_mmap(ctf_sect_t *sp, int fd)
+{
+ size_t pageoff = sp->cts_offset & ~_PAGEMASK;
+
+ caddr_t base = mmap64(NULL, sp->cts_size + pageoff, PROT_READ,
+ MAP_PRIVATE, fd, sp->cts_offset & _PAGEMASK);
+
+ if (base != MAP_FAILED)
+ sp->cts_data = base + pageoff;
+
+ return (base);
+}
+
+/*
+ * Since sp->cts_data has the adjusted offset, we have to again round down
+ * to get the actual mmap address and round up to get the size.
+ */
+void
+ctf_sect_munmap(const ctf_sect_t *sp)
+{
+ uintptr_t addr = (uintptr_t)sp->cts_data;
+ uintptr_t pageoff = addr & ~_PAGEMASK;
+
+ (void) munmap((void *)(addr - pageoff), sp->cts_size + pageoff);
+}
+
+/*
+ * Open the specified file descriptor and return a pointer to a CTF container.
+ * The file can be either an ELF file or raw CTF file. The caller is
+ * responsible for closing the file descriptor when it is no longer needed.
+ */
+ctf_file_t *
+ctf_fdopen(int fd, int *errp)
+{
+ ctf_sect_t ctfsect, symsect, strsect;
+ ctf_file_t *fp = NULL;
+
+ struct stat64 st;
+ ssize_t nbytes;
+
+ union {
+ ctf_preamble_t ctf;
+ Elf32_Ehdr e32;
+ GElf_Ehdr e64;
+ } hdr;
+
+ bzero(&ctfsect, sizeof (ctf_sect_t));
+ bzero(&symsect, sizeof (ctf_sect_t));
+ bzero(&strsect, sizeof (ctf_sect_t));
+ bzero(&hdr, sizeof (hdr));
+
+ if (fstat64(fd, &st) == -1)
+ return (ctf_set_open_errno(errp, errno));
+
+ if ((nbytes = pread64(fd, &hdr.ctf, sizeof (hdr), 0)) <= 0)
+ return (ctf_set_open_errno(errp, nbytes < 0? errno : ECTF_FMT));
+
+ /*
+ * If we have read enough bytes to form a CTF header and the magic
+ * string matches, attempt to interpret the file as raw CTF.
+ */
+ if (nbytes >= sizeof (ctf_preamble_t) &&
+ hdr.ctf.ctp_magic == CTF_MAGIC) {
+ if (hdr.ctf.ctp_version > CTF_VERSION)
+ return (ctf_set_open_errno(errp, ECTF_CTFVERS));
+
+ ctfsect.cts_data = mmap64(NULL, st.st_size, PROT_READ,
+ MAP_PRIVATE, fd, 0);
+
+ if (ctfsect.cts_data == MAP_FAILED)
+ return (ctf_set_open_errno(errp, errno));
+
+ ctfsect.cts_name = _CTF_SECTION;
+ ctfsect.cts_type = SHT_PROGBITS;
+ ctfsect.cts_flags = SHF_ALLOC;
+ ctfsect.cts_size = (size_t)st.st_size;
+ ctfsect.cts_entsize = 1;
+ ctfsect.cts_offset = 0;
+
+ if ((fp = ctf_bufopen(&ctfsect, NULL, NULL, errp)) == NULL)
+ ctf_sect_munmap(&ctfsect);
+
+ return (fp);
+ }
+
+ /*
+ * If we have read enough bytes to form an ELF header and the magic
+ * string matches, attempt to interpret the file as an ELF file. We
+ * do our own largefile ELF processing, and convert everything to
+ * GElf structures so that clients can operate on any data model.
+ */
+ if (nbytes >= sizeof (Elf32_Ehdr) &&
+ bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
+#ifdef _BIG_ENDIAN
+ uchar_t order = ELFDATA2MSB;
+#else
+ uchar_t order = ELFDATA2LSB;
+#endif
+ GElf_Half i, n;
+ GElf_Shdr *sp;
+
+ void *strs_map;
+ size_t strs_mapsz;
+ const char *strs;
+
+ if (hdr.e32.e_ident[EI_DATA] != order)
+ return (ctf_set_open_errno(errp, ECTF_ENDIAN));
+ if (hdr.e32.e_version != EV_CURRENT)
+ return (ctf_set_open_errno(errp, ECTF_ELFVERS));
+
+ if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS64) {
+ if (nbytes < sizeof (GElf_Ehdr))
+ return (ctf_set_open_errno(errp, ECTF_FMT));
+ } else {
+ Elf32_Ehdr e32 = hdr.e32;
+ ehdr_to_gelf(&e32, &hdr.e64);
+ }
+
+ if (hdr.e64.e_shstrndx >= hdr.e64.e_shnum)
+ return (ctf_set_open_errno(errp, ECTF_CORRUPT));
+
+ n = hdr.e64.e_shnum;
+ nbytes = sizeof (GElf_Shdr) * n;
+
+ if ((sp = malloc(nbytes)) == NULL)
+ return (ctf_set_open_errno(errp, errno));
+
+ /*
+ * Read in and convert to GElf the array of Shdr structures
+ * from e_shoff so we can locate sections of interest.
+ */
+ if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS32) {
+ Elf32_Shdr *sp32;
+
+ nbytes = sizeof (Elf32_Shdr) * n;
+
+ if ((sp32 = malloc(nbytes)) == NULL || pread64(fd,
+ sp32, nbytes, hdr.e64.e_shoff) != nbytes) {
+ free(sp);
+ return (ctf_set_open_errno(errp, errno));
+ }
+
+ for (i = 0; i < n; i++)
+ shdr_to_gelf(&sp32[i], &sp[i]);
+
+ free(sp32);
+
+ } else if (pread64(fd, sp, nbytes, hdr.e64.e_shoff) != nbytes) {
+ free(sp);
+ return (ctf_set_open_errno(errp, errno));
+ }
+
+ /*
+ * Now mmap the section header strings section so that we can
+ * perform string comparison on the section names.
+ */
+ strs_mapsz = sp[hdr.e64.e_shstrndx].sh_size +
+ (sp[hdr.e64.e_shstrndx].sh_offset & ~_PAGEMASK);
+
+ strs_map = mmap64(NULL, strs_mapsz, PROT_READ, MAP_PRIVATE,
+ fd, sp[hdr.e64.e_shstrndx].sh_offset & _PAGEMASK);
+
+ strs = (const char *)strs_map +
+ (sp[hdr.e64.e_shstrndx].sh_offset & ~_PAGEMASK);
+
+ if (strs_map == MAP_FAILED) {
+ free(sp);
+ return (ctf_set_open_errno(errp, ECTF_MMAP));
+ }
+
+ /*
+ * Iterate over the section header array looking for the CTF
+ * section and symbol table. The strtab is linked to symtab.
+ */
+ for (i = 0; i < n; i++) {
+ const GElf_Shdr *shp = &sp[i];
+ const GElf_Shdr *lhp = &sp[shp->sh_link];
+
+ if (shp->sh_link >= hdr.e64.e_shnum)
+ continue; /* corrupt sh_link field */
+
+ if (shp->sh_name >= sp[hdr.e64.e_shstrndx].sh_size ||
+ lhp->sh_name >= sp[hdr.e64.e_shstrndx].sh_size)
+ continue; /* corrupt sh_name field */
+
+ if (shp->sh_type == SHT_PROGBITS &&
+ strcmp(strs + shp->sh_name, _CTF_SECTION) == 0) {
+ ctfsect.cts_name = strs + shp->sh_name;
+ ctfsect.cts_type = shp->sh_type;
+ ctfsect.cts_flags = shp->sh_flags;
+ ctfsect.cts_size = shp->sh_size;
+ ctfsect.cts_entsize = shp->sh_entsize;
+ ctfsect.cts_offset = (off64_t)shp->sh_offset;
+
+ } else if (shp->sh_type == SHT_SYMTAB) {
+ symsect.cts_name = strs + shp->sh_name;
+ symsect.cts_type = shp->sh_type;
+ symsect.cts_flags = shp->sh_flags;
+ symsect.cts_size = shp->sh_size;
+ symsect.cts_entsize = shp->sh_entsize;
+ symsect.cts_offset = (off64_t)shp->sh_offset;
+
+ strsect.cts_name = strs + lhp->sh_name;
+ strsect.cts_type = lhp->sh_type;
+ strsect.cts_flags = lhp->sh_flags;
+ strsect.cts_size = lhp->sh_size;
+ strsect.cts_entsize = lhp->sh_entsize;
+ strsect.cts_offset = (off64_t)lhp->sh_offset;
+ }
+ }
+
+ free(sp); /* free section header array */
+
+ if (ctfsect.cts_type == SHT_NULL) {
+ (void) munmap(strs_map, strs_mapsz);
+ return (ctf_set_open_errno(errp, ECTF_NOCTFDATA));
+ }
+
+ /*
+ * Now mmap the CTF data, symtab, and strtab sections and
+ * call ctf_bufopen() to do the rest of the work.
+ */
+ if (ctf_sect_mmap(&ctfsect, fd) == MAP_FAILED) {
+ (void) munmap(strs_map, strs_mapsz);
+ return (ctf_set_open_errno(errp, ECTF_MMAP));
+ }
+
+ if (symsect.cts_type != SHT_NULL &&
+ strsect.cts_type != SHT_NULL) {
+ if (ctf_sect_mmap(&symsect, fd) == MAP_FAILED ||
+ ctf_sect_mmap(&strsect, fd) == MAP_FAILED) {
+ (void) ctf_set_open_errno(errp, ECTF_MMAP);
+ goto bad; /* unmap all and abort */
+ }
+ fp = ctf_bufopen(&ctfsect, &symsect, &strsect, errp);
+ } else
+ fp = ctf_bufopen(&ctfsect, NULL, NULL, errp);
+bad:
+ if (fp == NULL) {
+ ctf_sect_munmap(&ctfsect);
+ ctf_sect_munmap(&symsect);
+ ctf_sect_munmap(&strsect);
+ } else
+ fp->ctf_flags |= LCTF_MMAP;
+
+ (void) munmap(strs_map, strs_mapsz);
+ return (fp);
+ }
+
+ return (ctf_set_open_errno(errp, ECTF_FMT));
+}
+
+/*
+ * Open the specified file and return a pointer to a CTF container. The file
+ * can be either an ELF file or raw CTF file. This is just a convenient
+ * wrapper around ctf_fdopen() for callers.
+ */
+ctf_file_t *
+ctf_open(const char *filename, int *errp)
+{
+ ctf_file_t *fp;
+ int fd;
+
+ if ((fd = open64(filename, O_RDONLY)) == -1) {
+ if (errp != NULL)
+ *errp = errno;
+ return (NULL);
+ }
+
+ fp = ctf_fdopen(fd, errp);
+ (void) close(fd);
+ return (fp);
+}
+
+/*
+ * Write the uncompressed CTF data stream to the specified file descriptor.
+ * This is useful for saving the results of dynamic CTF containers.
+ */
+int
+ctf_write(ctf_file_t *fp, int fd)
+{
+ const uchar_t *buf = fp->ctf_base;
+ ssize_t resid = fp->ctf_size;
+ ssize_t len;
+
+ while (resid != 0) {
+ if ((len = write(fd, buf, resid)) <= 0)
+ return (ctf_set_errno(fp, errno));
+ resid -= len;
+ buf += len;
+ }
+
+ return (0);
+}
+
+/*
+ * Set the CTF library client version to the specified version. If version is
+ * zero, we just return the default library version number.
+ */
+int
+ctf_version(int version)
+{
+ if (version < 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ if (version > 0) {
+ if (version > CTF_VERSION) {
+ errno = ENOTSUP;
+ return (-1);
+ }
+ ctf_dprintf("ctf_version: client using version %d\n", version);
+ _libctf_version = version;
+ }
+
+ return (_libctf_version);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c
new file mode 100644
index 00000000..7de8069b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c
@@ -0,0 +1,119 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <ctf_impl.h>
+#include <libctf.h>
+#ifndef VBOX
+#include <sys/mman.h>
+#include <stdarg.h>
+#else
+# include <iprt/asm.h>
+# include <iprt/log.h>
+#endif
+
+void *
+ctf_data_alloc(size_t size)
+{
+#ifndef VBOX
+ return (mmap(NULL, size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0));
+#else
+ void *pv = RTMemPageAlloc(size);
+ return pv == NULL ? MAP_FAILED : pv;
+#endif
+}
+
+void
+ctf_data_free(void *buf, size_t size)
+{
+#ifndef VBOX
+ (void) munmap(buf, size);
+#else
+ RTMemProtect(buf, size, RTMEM_PROT_WRITE | RTMEM_PROT_READ);
+ RTMemPageFree(buf, size);
+#endif
+}
+
+void
+ctf_data_protect(void *buf, size_t size)
+{
+#ifndef VBOX
+ (void) mprotect(buf, size, PROT_READ);
+#else
+ int rc = RTMemProtect(buf, size, RTMEM_PROT_READ);
+ AssertRC(rc);
+#endif
+}
+
+void *
+ctf_alloc(size_t size)
+{
+#ifndef VBOX
+ return (malloc(size));
+#else
+ return RTMemAlloc(size);
+#endif
+}
+
+/*ARGSUSED*/
+void
+ctf_free(void *buf, size_t size)
+{
+#ifndef VBOX
+ free(buf);
+#else
+ RT_NOREF1(size);
+ RTMemFree(buf);
+#endif
+}
+
+const char *
+ctf_strerror(int err)
+{
+ return (strerror(err));
+}
+
+/*PRINTFLIKE1*/
+void
+ctf_dprintf(const char *format, ...)
+{
+ if (_libctf_debug) {
+ va_list alist;
+
+ va_start(alist, format);
+#ifndef VBOX
+ (void) fputs("libctf DEBUG: ", stderr);
+ (void) vfprintf(stderr, format, alist);
+#else
+ RTLogPrintf("libctf DEBUG: %N", format, alist);
+#endif
+ va_end(alist);
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h
new file mode 100644
index 00000000..ac7b9a43
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h
@@ -0,0 +1,66 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2001-2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * This header file defines the interfaces available from the CTF debugger
+ * library, libctf. This library provides functions that a debugger can
+ * use to operate on data in the Compact ANSI-C Type Format (CTF). This
+ * is NOT a public interface, although it may eventually become one in
+ * the fullness of time after we gain more experience with the interfaces.
+ *
+ * In the meantime, be aware that any program linked with libctf in this
+ * release of Solaris is almost guaranteed to break in the next release.
+ *
+ * In short, do not user this header file or libctf for any purpose.
+ */
+
+#ifndef _LIBCTF_H
+#define _LIBCTF_H
+
+#ifndef VBOX
+# pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <sys/ctf_api.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This flag can be used to enable debug messages.
+ */
+extern int _libctf_debug;
+
+#ifdef VBOX
+extern void libctf_init(void);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBCTF_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/llib-lctf b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/llib-lctf
new file mode 100644
index 00000000..53310dec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/llib-lctf
@@ -0,0 +1,32 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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) 2001 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include <libctf.h>
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/mapfile-vers b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/mapfile-vers
new file mode 100644
index 00000000..c218edc3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/mapfile-vers
@@ -0,0 +1,114 @@
+#
+# 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) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+# There really should be only one SUNWprivate version.
+# Don't add any more. Add new private symbols to SUNWprivate_1.2
+
+SYMBOL_VERSION SUNWprivate_1.2 {
+ global:
+ ctf_add_array;
+ ctf_add_const;
+ ctf_add_enum;
+ ctf_add_enumerator;
+ ctf_add_float;
+ ctf_add_forward;
+ ctf_add_function;
+ ctf_add_integer;
+ ctf_add_member;
+ ctf_add_pointer;
+ ctf_add_restrict;
+ ctf_add_struct;
+ ctf_add_type;
+ ctf_add_typedef;
+ ctf_add_union;
+ ctf_add_volatile;
+ ctf_create;
+ ctf_discard;
+ ctf_enum_value;
+ ctf_label_info;
+ ctf_label_iter;
+ ctf_label_topmost;
+ ctf_member_info;
+ ctf_parent_file;
+ ctf_parent_name;
+ ctf_set_array;
+ ctf_type_align;
+ ctf_type_cmp;
+ ctf_type_compat;
+ ctf_type_pointer;
+ ctf_update;
+ ctf_write;
+} SUNWprivate_1.1;
+
+SYMBOL_VERSION SUNWprivate_1.1 {
+ global:
+ ctf_array_info;
+ ctf_bufopen;
+ ctf_close;
+ ctf_enum_iter;
+ ctf_enum_name;
+ ctf_errmsg;
+ ctf_errno;
+ ctf_fdopen;
+ ctf_func_args;
+ ctf_func_info;
+ ctf_getmodel;
+ ctf_getspecific;
+ ctf_import;
+ ctf_lookup_by_name;
+ ctf_lookup_by_symbol;
+ ctf_member_iter;
+ ctf_open;
+ ctf_setmodel;
+ ctf_setspecific;
+ ctf_type_encoding;
+ ctf_type_iter;
+ ctf_type_kind;
+ ctf_type_lname;
+ ctf_type_name;
+ ctf_type_reference;
+ ctf_type_resolve;
+ ctf_type_size;
+ ctf_type_visit;
+ ctf_version;
+ _libctf_debug;
+ local:
+ *;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/i386/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/i386/Makefile
new file mode 100644
index 00000000..a3332242
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/i386/Makefile
@@ -0,0 +1,30 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparc/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparc/Makefile
new file mode 100644
index 00000000..a3332242
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparc/Makefile
@@ -0,0 +1,30 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparcv9/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparcv9/Makefile
new file mode 100644
index 00000000..c9bd26cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/sparcv9/Makefile
@@ -0,0 +1,31 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile
new file mode 100644
index 00000000..c24a0800
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile
@@ -0,0 +1,63 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.lib
+
+HDRS = dtrace.h
+HDRDIR = common
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
+lint := TARGET = lint
+yydebug := TARGET = yydebug
+
+.KEEP_STATE:
+
+all clean clobber lint yydebug: $(SUBDIRS)
+
+install: install_h $(SUBDIRS)
+
+install_h: $(ROOTHDRS)
+
+check: $(CHECKHDRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
+
+#
+# Cross-reference customization: build the cross-reference only over the
+# source directories, and ignore Makefiles and machine-generated source.
+#
+XRDIRS = common i386 sparc sparcv9
+XRDEL = dt_lex.c dt_grammar.c Makefile*
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.com b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.com
new file mode 100644
index 00000000..c4f967fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.com
@@ -0,0 +1,233 @@
+#
+# 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+#
+
+LIBRARY = libdtrace.a
+VERS = .1
+
+LIBSRCS = \
+ dt_aggregate.c \
+ dt_as.c \
+ dt_buf.c \
+ dt_cc.c \
+ dt_cg.c \
+ dt_consume.c \
+ dt_decl.c \
+ dt_dis.c \
+ dt_dof.c \
+ dt_error.c \
+ dt_errtags.c \
+ dt_handle.c \
+ dt_ident.c \
+ dt_inttab.c \
+ dt_link.c \
+ dt_list.c \
+ dt_open.c \
+ dt_options.c \
+ dt_program.c \
+ dt_map.c \
+ dt_module.c \
+ dt_names.c \
+ dt_parser.c \
+ dt_pcb.c \
+ dt_pid.c \
+ dt_pragma.c \
+ dt_printf.c \
+ dt_proc.c \
+ dt_provider.c \
+ dt_regset.c \
+ dt_string.c \
+ dt_strtab.c \
+ dt_subr.c \
+ dt_work.c \
+ dt_xlator.c
+
+LIBISASRCS = \
+ dt_isadep.c
+
+OBJECTS = dt_lex.o dt_grammar.o $(MACHOBJS) $(LIBSRCS:%.c=%.o) $(LIBISASRCS:%.c=%.o)
+
+DRTISRC = drti.c
+DRTIOBJ = $(DRTISRC:%.c=%.o)
+
+DLIBSRCS += \
+ errno.d \
+ fc.d \
+ io.d \
+ ip.d \
+ iscsit.d \
+ net.d \
+ nfs.d \
+ procfs.d \
+ regs.d \
+ sched.d \
+ signal.d \
+ scsi.d \
+ srp.d \
+ sysevent.d \
+ tcp.d \
+ udp.d \
+ unistd.d
+
+include ../../Makefile.lib
+
+SRCS = $(LIBSRCS:%.c=../common/%.c) $(LIBISASRCS:%.c=../$(MACH)/%.c)
+LIBS = $(DYNLIB) $(LINTLIB)
+
+SRCDIR = ../common
+
+CLEANFILES += dt_lex.c dt_grammar.c dt_grammar.h y.output
+CLEANFILES += ../common/procfs.sed ../common/procfs.d
+CLEANFILES += ../common/io.sed ../common/io.d
+CLEANFILES += ../common/ip.sed ../common/ip.d
+CLEANFILES += ../common/net.sed ../common/net.d
+CLEANFILES += ../common/errno.d ../common/signal.d
+CLEANFILES += ../common/dt_errtags.c ../common/dt_names.c
+CLEANFILES += ../common/sysevent.sed ../common/sysevent.d
+CLEANFILES += ../common/tcp.sed ../common/tcp.d
+CLEANFILES += ../common/udp.sed ../common/udp.d
+
+CLOBBERFILES += drti.o
+
+CPPFLAGS += -I../common -I.
+CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
+CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS)
+YYCFLAGS =
+LDLIBS += -lgen -lproc -lrtld_db -lnsl -lsocket -lctf -lelf -lc
+DRTILDLIBS = $(LDLIBS.lib) -lc
+
+yydebug := YYCFLAGS += -DYYDEBUG
+
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+
+LFLAGS = -t -v
+YFLAGS = -d -v
+
+ROOTDLIBDIR = $(ROOT)/usr/lib/dtrace
+ROOTDLIBDIR64 = $(ROOT)/usr/lib/dtrace/64
+
+ROOTDLIBS = $(DLIBSRCS:%=$(ROOTDLIBDIR)/%)
+ROOTDOBJS = $(ROOTDLIBDIR)/$(DRTIOBJ)
+ROOTDOBJS64 = $(ROOTDLIBDIR64)/$(DRTIOBJ)
+
+.KEEP_STATE:
+
+all: $(LIBS) $(DRTIOBJ)
+
+lint: lintdrti lintcheck
+
+lintdrti: ../common/$(DRTISRC)
+ $(LINT.c) ../common/$(DRTISRC) $(DRTILDLIBS)
+
+dt_lex.c: $(SRCDIR)/dt_lex.l dt_grammar.h
+ $(LEX) $(LFLAGS) $(SRCDIR)/dt_lex.l > $@
+
+dt_grammar.c dt_grammar.h: $(SRCDIR)/dt_grammar.y
+ $(YACC) $(YFLAGS) $(SRCDIR)/dt_grammar.y
+ @mv y.tab.h dt_grammar.h
+ @mv y.tab.c dt_grammar.c
+
+pics/dt_lex.o pics/dt_grammar.o := CFLAGS += $(YYCFLAGS)
+pics/dt_lex.o pics/dt_grammar.o := CFLAGS64 += $(YYCFLAGS)
+
+pics/dt_lex.o pics/dt_grammar.o := CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
+pics/dt_lex.o pics/dt_grammar.o := CCVERBOSE =
+
+../common/dt_errtags.c: ../common/mkerrtags.sh ../common/dt_errtags.h
+ sh ../common/mkerrtags.sh < ../common/dt_errtags.h > $@
+
+../common/dt_names.c: ../common/mknames.sh $(SRC)/uts/common/sys/dtrace.h
+ sh ../common/mknames.sh < $(SRC)/uts/common/sys/dtrace.h > $@
+
+../common/errno.d: ../common/mkerrno.sh $(SRC)/uts/common/sys/errno.h
+ sh ../common/mkerrno.sh < $(SRC)/uts/common/sys/errno.h > $@
+
+../common/signal.d: ../common/mksignal.sh $(SRC)/uts/common/sys/iso/signal_iso.h
+ sh ../common/mksignal.sh < $(SRC)/uts/common/sys/iso/signal_iso.h > $@
+
+../common/%.sed: ../common/%.sed.in
+ $(COMPILE.cpp) -D_KERNEL $< | tr -d ' ' | tr '"' '@' | \
+ sed 's/\&/\\\&/g' | grep '^s/' > $@
+
+../common/procfs.d: ../common/procfs.sed ../common/procfs.d.in
+ sed -f ../common/procfs.sed < ../common/procfs.d.in > $@
+
+../common/io.d: ../common/io.sed ../common/io.d.in
+ sed -f ../common/io.sed < ../common/io.d.in > $@
+
+../common/ip.d: ../common/ip.sed ../common/ip.d.in
+ sed -f ../common/ip.sed < ../common/ip.d.in > $@
+
+../common/net.d: ../common/net.sed ../common/net.d.in
+ sed -f ../common/net.sed < ../common/net.d.in > $@
+
+../common/sysevent.d: ../common/sysevent.sed ../common/sysevent.d.in
+ sed -f ../common/sysevent.sed < ../common/sysevent.d.in > $@
+
+../common/tcp.d: ..//common/tcp.sed ../common/tcp.d.in
+ sed -f ../common/tcp.sed < ../common/tcp.d.in > $@
+
+../common/udp.d: ../common/udp.sed ../common/udp.d.in
+ sed -f ../common/udp.sed < ../common/udp.d.in > $@
+
+pics/%.o: ../$(MACH)/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+pics/%.o: ../$(MACH)/%.s
+ $(COMPILE.s) -o $@ $<
+ $(POST_PROCESS_O)
+
+%.o: ../common/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+$(ROOTDLIBDIR):
+ $(INS.dir)
+
+$(ROOTDLIBDIR64): $(ROOTDLIBDIR)
+ $(INS.dir)
+
+$(ROOTDLIBDIR)/%.d: ../common/%.d
+ $(INS.file)
+
+$(ROOTDLIBDIR)/%.d: ../$(MACH)/%.d
+ $(INS.file)
+
+$(ROOTDLIBDIR)/%.d: %.d
+ $(INS.file)
+
+$(ROOTDLIBDIR)/%.o: %.o
+ $(INS.file)
+
+$(ROOTDLIBDIR64)/%.o: %.o
+ $(INS.file)
+
+$(ROOTDLIBS): $(ROOTDLIBDIR)
+
+$(ROOTDOBJS): $(ROOTDLIBDIR)
+
+$(ROOTDOBJS64): $(ROOTDLIBDIR64)
+
+include ../../Makefile.targ
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile
new file mode 100644
index 00000000..e9cdd5bd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile
@@ -0,0 +1,46 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+ASFLAGS += $(AS_PICFLAGS) -P -D_ASM
+
+MACHOBJS = dis_tables.o
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+SRCS += $(SRC)/common/dis/i386/dis_tables.c
+CPPFLAGS += -I$(SRC)/common/dis/i386
+CPPFLAGS += -D_ELF64
+
+LINTFLAGS64 += -erroff=E_BAD_PTR_CAST_ALIGN
+
+pics/%.o: $(SRC)/common/dis/i386/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+install yydebug: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) \
+ $(ROOTDLIBS) $(ROOTDOBJS64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/amd64/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/drti.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/drti.c
new file mode 100644
index 00000000..3b5f0cbb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/drti.c
@@ -0,0 +1,190 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <link.h>
+#include <sys/dtrace.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * In Solaris 10 GA, the only mechanism for communicating helper information
+ * is through the DTrace helper pseudo-device node in /devices; there is
+ * no /dev link. Because of this, USDT providers and helper actions don't
+ * work inside of non-global zones. This issue was addressed by adding
+ * the /dev and having this initialization code use that /dev link. If the
+ * /dev link doesn't exist it falls back to looking for the /devices node
+ * as this code may be embedded in a binary which runs on Solaris 10 GA.
+ *
+ * Users may set the following environment variable to affect the way
+ * helper initialization takes place:
+ *
+ * DTRACE_DOF_INIT_DEBUG enable debugging output
+ * DTRACE_DOF_INIT_DISABLE disable helper loading
+ * DTRACE_DOF_INIT_DEVNAME set the path to the helper node
+ */
+
+static const char *devname = "/dev/dtrace/helper";
+static const char *olddevname = "/devices/pseudo/dtrace@0:helper";
+
+static const char *modname; /* Name of this load object */
+static int gen; /* DOF helper generation */
+extern dof_hdr_t __SUNW_dof; /* DOF defined in the .SUNW_dof section */
+static boolean_t dof_init_debug = B_FALSE; /* From DTRACE_DOF_INIT_DEBUG */
+
+static void
+dprintf(int debug, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (debug && !dof_init_debug)
+ return;
+
+ va_start(ap, fmt);
+
+ if (modname == NULL)
+ (void) fprintf(stderr, "dtrace DOF: ");
+ else
+ (void) fprintf(stderr, "dtrace DOF %s: ", modname);
+
+ (void) vfprintf(stderr, fmt, ap);
+
+ if (fmt[strlen(fmt) - 1] != '\n')
+ (void) fprintf(stderr, ": %s\n", strerror(errno));
+
+ va_end(ap);
+}
+
+#pragma init(dtrace_dof_init)
+static void
+dtrace_dof_init(void)
+{
+ dof_hdr_t *dof = &__SUNW_dof;
+#ifdef _LP64
+ Elf64_Ehdr *elf;
+#else
+ Elf32_Ehdr *elf;
+#endif
+ dof_helper_t dh;
+ Link_map *lmp;
+ Lmid_t lmid;
+ int fd;
+ const char *p;
+
+ if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL)
+ return;
+
+ if (getenv("DTRACE_DOF_INIT_DEBUG") != NULL)
+ dof_init_debug = B_TRUE;
+
+ if (dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lmp) == -1 || lmp == NULL) {
+ dprintf(1, "couldn't discover module name or address\n");
+ return;
+ }
+
+ if (dlinfo(RTLD_SELF, RTLD_DI_LMID, &lmid) == -1) {
+ dprintf(1, "couldn't discover link map ID\n");
+ return;
+ }
+
+ if ((modname = strrchr(lmp->l_name, '/')) == NULL)
+ modname = lmp->l_name;
+ else
+ modname++;
+
+ if (dof->dofh_ident[DOF_ID_MAG0] != DOF_MAG_MAG0 ||
+ dof->dofh_ident[DOF_ID_MAG1] != DOF_MAG_MAG1 ||
+ dof->dofh_ident[DOF_ID_MAG2] != DOF_MAG_MAG2 ||
+ dof->dofh_ident[DOF_ID_MAG3] != DOF_MAG_MAG3) {
+ dprintf(0, ".SUNW_dof section corrupt\n");
+ return;
+ }
+
+ elf = (void *)lmp->l_addr;
+
+ dh.dofhp_dof = (uintptr_t)dof;
+ dh.dofhp_addr = elf->e_type == ET_DYN ? lmp->l_addr : 0;
+
+ if (lmid == 0) {
+ (void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod),
+ "%s", modname);
+ } else {
+ (void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod),
+ "LM%lu`%s", lmid, modname);
+ }
+
+ if ((p = getenv("DTRACE_DOF_INIT_DEVNAME")) != NULL)
+ devname = p;
+
+ if ((fd = open64(devname, O_RDWR)) < 0) {
+ dprintf(1, "failed to open helper device %s", devname);
+
+ /*
+ * If the device path wasn't explicitly set, try again with
+ * the old device path.
+ */
+ if (p != NULL)
+ return;
+
+ devname = olddevname;
+
+ if ((fd = open64(devname, O_RDWR)) < 0) {
+ dprintf(1, "failed to open helper device %s", devname);
+ return;
+ }
+ }
+
+ if ((gen = ioctl(fd, DTRACEHIOC_ADDDOF, &dh)) == -1)
+ dprintf(1, "DTrace ioctl failed for DOF at %p", dof);
+ else
+ dprintf(1, "DTrace ioctl succeeded for DOF at %p\n", dof);
+
+ (void) close(fd);
+}
+
+#pragma fini(dtrace_dof_fini)
+static void
+dtrace_dof_fini(void)
+{
+ int fd;
+
+ if ((fd = open64(devname, O_RDWR)) < 0) {
+ dprintf(1, "failed to open helper device %s", devname);
+ return;
+ }
+
+ if ((gen = ioctl(fd, DTRACEHIOC_REMOVE, gen)) == -1)
+ dprintf(1, "DTrace ioctl failed to remove DOF (%d)\n", gen);
+ else
+ dprintf(1, "DTrace ioctl removed DOF (%d)\n", gen);
+
+ (void) close(fd);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_aggregate.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_aggregate.c
new file mode 100644
index 00000000..831b1081
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_aggregate.c
@@ -0,0 +1,1917 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdlib.h>
+#include <strings.h>
+#include <errno.h>
+#include <unistd.h>
+#include <dt_impl.h>
+#include <assert.h>
+#include <alloca.h>
+#include <limits.h>
+#else /* VBOX */
+# include "dt_impl.h"
+# ifdef _MSC_VER
+# pragma warning(disable:4018) /* signed/unsigned comparsion mismatch warning */
+# endif
+# include <iprt/mp.h>
+#endif /* VBOX */
+
+#define DTRACE_AHASHSIZE 32779 /* big 'ol prime */
+
+/*
+ * Because qsort(3C) does not allow an argument to be passed to a comparison
+ * function, the variables that affect comparison must regrettably be global;
+ * they are protected by a global static lock, dt_qsort_lock.
+ */
+#ifndef VBOX
+static pthread_mutex_t dt_qsort_lock = PTHREAD_MUTEX_INITIALIZER;
+#else
+RTCRITSECT dt_qsort_lock;
+#endif
+
+static int dt_revsort;
+static int dt_keysort;
+static int dt_keypos;
+
+#define DT_LESSTHAN (dt_revsort == 0 ? -1 : 1)
+#define DT_GREATERTHAN (dt_revsort == 0 ? 1 : -1)
+
+static void
+dt_aggregate_count(int64_t *existing, int64_t *new, size_t size)
+{
+ VBDTTYPE(size_t,int) i;
+
+ for (i = 0; i < size / sizeof (int64_t); i++)
+ existing[i] = existing[i] + new[i];
+}
+
+static int
+dt_aggregate_countcmp(int64_t *lhs, int64_t *rhs)
+{
+ int64_t lvar = *lhs;
+ int64_t rvar = *rhs;
+
+ if (lvar < rvar)
+ return (DT_LESSTHAN);
+
+ if (lvar > rvar)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+dt_aggregate_min(int64_t *existing, int64_t *new, size_t size)
+{
+ RT_NOREF1(size);
+ if (*new < *existing)
+ *existing = *new;
+}
+
+/*ARGSUSED*/
+static void
+dt_aggregate_max(int64_t *existing, int64_t *new, size_t size)
+{
+ RT_NOREF1(size);
+ if (*new > *existing)
+ *existing = *new;
+}
+
+static int
+dt_aggregate_averagecmp(int64_t *lhs, int64_t *rhs)
+{
+ int64_t lavg = lhs[0] ? (lhs[1] / lhs[0]) : 0;
+ int64_t ravg = rhs[0] ? (rhs[1] / rhs[0]) : 0;
+
+ if (lavg < ravg)
+ return (DT_LESSTHAN);
+
+ if (lavg > ravg)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
+static int
+dt_aggregate_stddevcmp(int64_t *lhs, int64_t *rhs)
+{
+ uint64_t lsd = dt_stddev((uint64_t *)lhs, 1);
+ uint64_t rsd = dt_stddev((uint64_t *)rhs, 1);
+
+ if (lsd < rsd)
+ return (DT_LESSTHAN);
+
+ if (lsd > rsd)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+dt_aggregate_lquantize(int64_t *existing, int64_t *new, size_t size)
+{
+ int64_t arg = *existing++;
+ uint16_t levels = DTRACE_LQUANTIZE_LEVELS(arg);
+ int i;
+ RT_NOREF1(size);
+
+ for (i = 0; i <= levels + 1; i++)
+ existing[i] = existing[i] + new[i + 1];
+}
+
+static long double
+dt_aggregate_lquantizedsum(int64_t *lquanta)
+{
+ int64_t arg = *lquanta++;
+ int32_t base = DTRACE_LQUANTIZE_BASE(arg);
+ uint16_t step = DTRACE_LQUANTIZE_STEP(arg);
+ uint16_t levels = DTRACE_LQUANTIZE_LEVELS(arg), i;
+ long double total = (long double)lquanta[0] * (long double)(base - 1);
+
+ for (i = 0; i < levels; base += step, i++)
+ total += (long double)lquanta[i + 1] * (long double)base;
+
+ return (total + (long double)lquanta[levels + 1] *
+ (long double)(base + 1));
+}
+
+static int64_t
+dt_aggregate_lquantizedzero(int64_t *lquanta)
+{
+ int64_t arg = *lquanta++;
+ int32_t base = DTRACE_LQUANTIZE_BASE(arg);
+ uint16_t step = DTRACE_LQUANTIZE_STEP(arg);
+ uint16_t levels = DTRACE_LQUANTIZE_LEVELS(arg), i;
+
+ if (base - 1 == 0)
+ return (lquanta[0]);
+
+ for (i = 0; i < levels; base += step, i++) {
+ if (base != 0)
+ continue;
+
+ return (lquanta[i + 1]);
+ }
+
+ if (base + 1 == 0)
+ return (lquanta[levels + 1]);
+
+ return (0);
+}
+
+static int
+dt_aggregate_lquantizedcmp(int64_t *lhs, int64_t *rhs)
+{
+ long double lsum = dt_aggregate_lquantizedsum(lhs);
+ long double rsum = dt_aggregate_lquantizedsum(rhs);
+ int64_t lzero, rzero;
+
+ if (lsum < rsum)
+ return (DT_LESSTHAN);
+
+ if (lsum > rsum)
+ return (DT_GREATERTHAN);
+
+ /*
+ * If they're both equal, then we will compare based on the weights at
+ * zero. If the weights at zero are equal (or if zero is not within
+ * the range of the linear quantization), then this will be judged a
+ * tie and will be resolved based on the key comparison.
+ */
+ lzero = dt_aggregate_lquantizedzero(lhs);
+ rzero = dt_aggregate_lquantizedzero(rhs);
+
+ if (lzero < rzero)
+ return (DT_LESSTHAN);
+
+ if (lzero > rzero)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
+static int
+dt_aggregate_quantizedcmp(int64_t *lhs, int64_t *rhs)
+{
+ int nbuckets = DTRACE_QUANTIZE_NBUCKETS, i;
+ long double ltotal = 0, rtotal = 0;
+ int64_t lzero VBDTMSC(0), rzero VBDTMSC(0);
+
+ for (i = 0; i < nbuckets; i++) {
+ int64_t bucketval = DTRACE_QUANTIZE_BUCKETVAL(i);
+
+ if (bucketval == 0) {
+ lzero = lhs[i];
+ rzero = rhs[i];
+ }
+
+ ltotal += (long double)bucketval * (long double)lhs[i];
+ rtotal += (long double)bucketval * (long double)rhs[i];
+ }
+
+ if (ltotal < rtotal)
+ return (DT_LESSTHAN);
+
+ if (ltotal > rtotal)
+ return (DT_GREATERTHAN);
+
+ /*
+ * If they're both equal, then we will compare based on the weights at
+ * zero. If the weights at zero are equal, then this will be judged a
+ * tie and will be resolved based on the key comparison.
+ */
+ if (lzero < rzero)
+ return (DT_LESSTHAN);
+
+ if (lzero > rzero)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
+static void
+dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data)
+{
+#ifndef VBOX
+ uint64_t pid = data[0];
+ uint64_t *pc = &data[1];
+ struct ps_prochandle *P;
+ GElf_Sym sym;
+
+ if (dtp->dt_vector != NULL)
+ return;
+
+ if ((P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0)) == NULL)
+ return;
+
+ dt_proc_lock(dtp, P);
+
+ if (Plookup_by_addr(P, *pc, NULL, 0, &sym) == 0)
+ *pc = sym.st_value;
+
+ dt_proc_unlock(dtp, P);
+ dt_proc_release(dtp, P);
+#else
+ RT_NOREF2(dtp, data);
+#endif
+}
+
+static void
+dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data)
+{
+#ifndef VBOX
+ uint64_t pid = data[0];
+ uint64_t *pc = &data[1];
+ struct ps_prochandle *P;
+ const prmap_t *map;
+
+ if (dtp->dt_vector != NULL)
+ return;
+
+ if ((P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0)) == NULL)
+ return;
+
+ dt_proc_lock(dtp, P);
+
+ if ((map = Paddr_to_map(P, *pc)) != NULL)
+ *pc = map->pr_vaddr;
+
+ dt_proc_unlock(dtp, P);
+ dt_proc_release(dtp, P);
+#else
+ RT_NOREF2(dtp, data);
+#endif
+}
+
+static void
+dt_aggregate_sym(dtrace_hdl_t *dtp, uint64_t *data)
+{
+ GElf_Sym sym;
+ uint64_t *pc = data;
+
+ if (dtrace_lookup_by_addr(dtp, *pc, &sym, NULL) == 0)
+ *pc = sym.st_value;
+}
+
+static void
+dt_aggregate_mod(dtrace_hdl_t *dtp, uint64_t *data)
+{
+ uint64_t *pc = data;
+ dt_module_t *dmp;
+
+ if (dtp->dt_vector != NULL) {
+ /*
+ * We don't have a way of just getting the module for a
+ * vectored open, and it doesn't seem to be worth defining
+ * one. This means that use of mod() won't get true
+ * aggregation in the postmortem case (some modules may
+ * appear more than once in aggregation output). It seems
+ * unlikely that anyone will ever notice or care...
+ */
+ return;
+ }
+
+ for (dmp = dt_list_next(&dtp->dt_modlist); dmp != NULL;
+ dmp = dt_list_next(dmp)) {
+ if (*pc - dmp->dm_text_va < dmp->dm_text_size) {
+ *pc = dmp->dm_text_va;
+ return;
+ }
+ }
+}
+
+static dtrace_aggvarid_t
+dt_aggregate_aggvarid(dt_ahashent_t *ent)
+{
+ dtrace_aggdesc_t *agg = ent->dtahe_data.dtada_desc;
+ caddr_t data = ent->dtahe_data.dtada_data;
+ dtrace_recdesc_t *rec = agg->dtagd_rec;
+
+ /*
+ * First, we'll check the variable ID in the aggdesc. If it's valid,
+ * we'll return it. If not, we'll use the compiler-generated ID
+ * present as the first record.
+ */
+ if (agg->dtagd_varid != DTRACE_AGGVARIDNONE)
+ return (agg->dtagd_varid);
+
+ agg->dtagd_varid = *((dtrace_aggvarid_t *)(uintptr_t)(data +
+ rec->dtrd_offset));
+
+ return (agg->dtagd_varid);
+}
+
+
+static int
+dt_aggregate_snap_cpu(dtrace_hdl_t *dtp, processorid_t cpu)
+{
+ dtrace_epid_t id;
+ uint64_t hashval;
+ size_t offs, roffs, size, ndx;
+ int i, j, rval;
+ caddr_t addr, data;
+ dtrace_recdesc_t *rec;
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ dtrace_aggdesc_t *agg;
+ dt_ahash_t *hash = &agp->dtat_hash;
+ dt_ahashent_t *h;
+ dtrace_bufdesc_t b = agp->dtat_buf, *buf = &b;
+ dtrace_aggdata_t *aggdata;
+ int flags = agp->dtat_flags;
+
+ buf->dtbd_cpu = cpu;
+
+ if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, buf) == -1) {
+ if (errno == ENOENT) {
+ /*
+ * If that failed with ENOENT, it may be because the
+ * CPU was unconfigured. This is okay; we'll just
+ * do nothing but return success.
+ */
+ return (0);
+ }
+
+ return (dt_set_errno(dtp, errno));
+ }
+
+ if (buf->dtbd_drops != 0) {
+ if (dt_handle_cpudrop(dtp, cpu,
+ DTRACEDROP_AGGREGATION, buf->dtbd_drops) == -1)
+ return (-1);
+ }
+
+ if (buf->dtbd_size == 0)
+ return (0);
+
+ if (hash->dtah_hash == NULL) {
+ size_t size;
+
+ hash->dtah_size = DTRACE_AHASHSIZE;
+ size = hash->dtah_size * sizeof (dt_ahashent_t *);
+
+ if ((hash->dtah_hash = malloc(size)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ bzero(hash->dtah_hash, size);
+ }
+
+ for (offs = 0; offs < buf->dtbd_size; ) {
+ /*
+ * We're guaranteed to have an ID.
+ */
+ id = *((dtrace_epid_t *)((uintptr_t)buf->dtbd_data +
+ (uintptr_t)offs));
+
+ if (id == DTRACE_AGGIDNONE) {
+ /*
+ * This is filler to assure proper alignment of the
+ * next record; we simply ignore it.
+ */
+ offs += sizeof (id);
+ continue;
+ }
+
+ if ((rval = dt_aggid_lookup(dtp, id, &agg)) != 0)
+ return (rval);
+
+ addr = buf->dtbd_data + offs;
+ size = agg->dtagd_size;
+ hashval = 0;
+
+ for (j = 0; j < agg->dtagd_nrecs - 1; j++) {
+ rec = &agg->dtagd_rec[j];
+ roffs = rec->dtrd_offset;
+
+ switch (rec->dtrd_action) {
+ case DTRACEACT_USYM:
+ dt_aggregate_usym(dtp,
+ /* LINTED - alignment */
+ (uint64_t *)&addr[roffs]);
+ break;
+
+ case DTRACEACT_UMOD:
+ dt_aggregate_umod(dtp,
+ /* LINTED - alignment */
+ (uint64_t *)&addr[roffs]);
+ break;
+
+ case DTRACEACT_SYM:
+ /* LINTED - alignment */
+ dt_aggregate_sym(dtp, (uint64_t *)&addr[roffs]);
+ break;
+
+ case DTRACEACT_MOD:
+ /* LINTED - alignment */
+ dt_aggregate_mod(dtp, (uint64_t *)&addr[roffs]);
+ break;
+
+ default:
+ break;
+ }
+
+ for (i = 0; i < rec->dtrd_size; i++)
+ hashval += addr[roffs + i];
+ }
+
+ ndx = hashval % hash->dtah_size;
+
+ for (h = hash->dtah_hash[ndx]; h != NULL; h = h->dtahe_next) {
+ if (h->dtahe_hashval != hashval)
+ continue;
+
+ if (h->dtahe_size != size)
+ continue;
+
+ aggdata = &h->dtahe_data;
+ data = aggdata->dtada_data;
+
+ for (j = 0; j < agg->dtagd_nrecs - 1; j++) {
+ rec = &agg->dtagd_rec[j];
+ roffs = rec->dtrd_offset;
+
+ for (i = 0; i < rec->dtrd_size; i++)
+ if (addr[roffs + i] != data[roffs + i])
+ goto hashnext;
+ }
+
+ /*
+ * We found it. Now we need to apply the aggregating
+ * action on the data here.
+ */
+ rec = &agg->dtagd_rec[agg->dtagd_nrecs - 1];
+ roffs = rec->dtrd_offset;
+ /* LINTED - alignment */
+ h->dtahe_aggregate((int64_t *)&data[roffs],
+ /* LINTED - alignment */
+ (int64_t *)&addr[roffs], rec->dtrd_size);
+
+ /*
+ * If we're keeping per CPU data, apply the aggregating
+ * action there as well.
+ */
+ if (aggdata->dtada_percpu != NULL) {
+ data = aggdata->dtada_percpu[cpu];
+
+ /* LINTED - alignment */
+ h->dtahe_aggregate((int64_t *)data,
+ /* LINTED - alignment */
+ (int64_t *)&addr[roffs], rec->dtrd_size);
+ }
+
+ goto bufnext;
+hashnext:
+ continue;
+ }
+
+ /*
+ * If we're here, we couldn't find an entry for this record.
+ */
+ if ((h = malloc(sizeof (dt_ahashent_t))) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ bzero(h, sizeof (dt_ahashent_t));
+ aggdata = &h->dtahe_data;
+
+ if ((aggdata->dtada_data = malloc(size)) == NULL) {
+ free(h);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ bcopy(addr, aggdata->dtada_data, size);
+ aggdata->dtada_size = size;
+ aggdata->dtada_desc = agg;
+ aggdata->dtada_handle = dtp;
+ (void) dt_epid_lookup(dtp, agg->dtagd_epid,
+ &aggdata->dtada_edesc, &aggdata->dtada_pdesc);
+ aggdata->dtada_normal = 1;
+
+ h->dtahe_hashval = hashval;
+ h->dtahe_size = size;
+ (void) dt_aggregate_aggvarid(h);
+
+ rec = &agg->dtagd_rec[agg->dtagd_nrecs - 1];
+
+ if (flags & DTRACE_A_PERCPU) {
+ int max_cpus = agp->dtat_maxcpu;
+ caddr_t *percpu = malloc(max_cpus * sizeof (caddr_t));
+
+ if (percpu == NULL) {
+ free(aggdata->dtada_data);
+ free(h);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ for (j = 0; j < max_cpus; j++) {
+ percpu[j] = malloc(rec->dtrd_size);
+
+ if (percpu[j] == NULL) {
+ while (--j >= 0)
+ free(percpu[j]);
+
+ free(aggdata->dtada_data);
+ free(h);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ if ((unsigned)j == cpu) {
+ bcopy(&addr[rec->dtrd_offset],
+ percpu[j], rec->dtrd_size);
+ } else {
+ bzero(percpu[j], rec->dtrd_size);
+ }
+ }
+
+ aggdata->dtada_percpu = percpu;
+ }
+
+ switch (rec->dtrd_action) {
+ case DTRACEAGG_MIN:
+ h->dtahe_aggregate = dt_aggregate_min;
+ break;
+
+ case DTRACEAGG_MAX:
+ h->dtahe_aggregate = dt_aggregate_max;
+ break;
+
+ case DTRACEAGG_LQUANTIZE:
+ h->dtahe_aggregate = dt_aggregate_lquantize;
+ break;
+
+ case DTRACEAGG_COUNT:
+ case DTRACEAGG_SUM:
+ case DTRACEAGG_AVG:
+ case DTRACEAGG_STDDEV:
+ case DTRACEAGG_QUANTIZE:
+ h->dtahe_aggregate = dt_aggregate_count;
+ break;
+
+ default:
+ return (dt_set_errno(dtp, EDT_BADAGG));
+ }
+
+ if (hash->dtah_hash[ndx] != NULL)
+ hash->dtah_hash[ndx]->dtahe_prev = h;
+
+ h->dtahe_next = hash->dtah_hash[ndx];
+ hash->dtah_hash[ndx] = h;
+
+ if (hash->dtah_all != NULL)
+ hash->dtah_all->dtahe_prevall = h;
+
+ h->dtahe_nextall = hash->dtah_all;
+ hash->dtah_all = h;
+bufnext:
+ offs += agg->dtagd_size;
+ }
+
+ return (0);
+}
+
+int
+dtrace_aggregate_snap(dtrace_hdl_t *dtp)
+{
+ int i, rval;
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ hrtime_t now = gethrtime();
+ dtrace_optval_t interval = dtp->dt_options[DTRACEOPT_AGGRATE];
+
+ if (dtp->dt_lastagg != 0) {
+ if (now - dtp->dt_lastagg < interval)
+ return (0);
+
+ dtp->dt_lastagg += interval;
+ } else {
+ dtp->dt_lastagg = now;
+ }
+
+ if (!dtp->dt_active)
+ return (dt_set_errno(dtp, EINVAL));
+
+ if (agp->dtat_buf.dtbd_size == 0)
+ return (0);
+
+ for (i = 0; i < agp->dtat_ncpus; i++) {
+ if ((rval = dt_aggregate_snap_cpu(dtp, agp->dtat_cpus[i])))
+ return (rval);
+ }
+
+ return (0);
+}
+
+static int
+dt_aggregate_hashcmp(const void *lhs, const void *rhs)
+{
+ dt_ahashent_t *lh = *((dt_ahashent_t **)lhs);
+ dt_ahashent_t *rh = *((dt_ahashent_t **)rhs);
+ dtrace_aggdesc_t *lagg = lh->dtahe_data.dtada_desc;
+ dtrace_aggdesc_t *ragg = rh->dtahe_data.dtada_desc;
+
+ if (lagg->dtagd_nrecs < ragg->dtagd_nrecs)
+ return (DT_LESSTHAN);
+
+ if (lagg->dtagd_nrecs > ragg->dtagd_nrecs)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
+static int
+dt_aggregate_varcmp(const void *lhs, const void *rhs)
+{
+ dt_ahashent_t *lh = *((dt_ahashent_t **)lhs);
+ dt_ahashent_t *rh = *((dt_ahashent_t **)rhs);
+ dtrace_aggvarid_t lid, rid;
+
+ lid = dt_aggregate_aggvarid(lh);
+ rid = dt_aggregate_aggvarid(rh);
+
+ if (lid < rid)
+ return (DT_LESSTHAN);
+
+ if (lid > rid)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
+static int
+dt_aggregate_keycmp(const void *lhs, const void *rhs)
+{
+ dt_ahashent_t *lh = *((dt_ahashent_t **)lhs);
+ dt_ahashent_t *rh = *((dt_ahashent_t **)rhs);
+ dtrace_aggdesc_t *lagg = lh->dtahe_data.dtada_desc;
+ dtrace_aggdesc_t *ragg = rh->dtahe_data.dtada_desc;
+ dtrace_recdesc_t *lrec, *rrec;
+ char *ldata, *rdata;
+ int rval, i, j, keypos, nrecs;
+
+ if ((rval = dt_aggregate_hashcmp(lhs, rhs)) != 0)
+ return (rval);
+
+ nrecs = lagg->dtagd_nrecs - 1;
+ assert(nrecs == ragg->dtagd_nrecs - 1);
+
+ keypos = dt_keypos + 1 >= nrecs ? 0 : dt_keypos;
+
+ for (i = 1; i < nrecs; i++) {
+ uint64_t lval, rval;
+ int ndx = i + keypos;
+
+ if (ndx >= nrecs)
+ ndx = ndx - nrecs + 1;
+
+ lrec = &lagg->dtagd_rec[ndx];
+ rrec = &ragg->dtagd_rec[ndx];
+
+ ldata = lh->dtahe_data.dtada_data + lrec->dtrd_offset;
+ rdata = rh->dtahe_data.dtada_data + rrec->dtrd_offset;
+
+ if (lrec->dtrd_size < rrec->dtrd_size)
+ return (DT_LESSTHAN);
+
+ if (lrec->dtrd_size > rrec->dtrd_size)
+ return (DT_GREATERTHAN);
+
+ switch (lrec->dtrd_size) {
+ case sizeof (uint64_t):
+ /* LINTED - alignment */
+ lval = *((uint64_t *)ldata);
+ /* LINTED - alignment */
+ rval = *((uint64_t *)rdata);
+ break;
+
+ case sizeof (uint32_t):
+ /* LINTED - alignment */
+ lval = *((uint32_t *)ldata);
+ /* LINTED - alignment */
+ rval = *((uint32_t *)rdata);
+ break;
+
+ case sizeof (uint16_t):
+ /* LINTED - alignment */
+ lval = *((uint16_t *)ldata);
+ /* LINTED - alignment */
+ rval = *((uint16_t *)rdata);
+ break;
+
+ case sizeof (uint8_t):
+ lval = *((uint8_t *)ldata);
+ rval = *((uint8_t *)rdata);
+ break;
+
+ default:
+ switch (lrec->dtrd_action) {
+ case DTRACEACT_UMOD:
+ case DTRACEACT_UADDR:
+ case DTRACEACT_USYM:
+ for (j = 0; j < 2; j++) {
+ /* LINTED - alignment */
+ lval = ((uint64_t *)ldata)[j];
+ /* LINTED - alignment */
+ rval = ((uint64_t *)rdata)[j];
+
+ if (lval < rval)
+ return (DT_LESSTHAN);
+
+ if (lval > rval)
+ return (DT_GREATERTHAN);
+ }
+
+ break;
+
+ default:
+ for (j = 0; j < lrec->dtrd_size; j++) {
+ lval = ((uint8_t *)ldata)[j];
+ rval = ((uint8_t *)rdata)[j];
+
+ if (lval < rval)
+ return (DT_LESSTHAN);
+
+ if (lval > rval)
+ return (DT_GREATERTHAN);
+ }
+ }
+
+ continue;
+ }
+
+ if (lval < rval)
+ return (DT_LESSTHAN);
+
+ if (lval > rval)
+ return (DT_GREATERTHAN);
+ }
+
+ return (0);
+}
+
+static int
+dt_aggregate_valcmp(const void *lhs, const void *rhs)
+{
+ dt_ahashent_t *lh = *((dt_ahashent_t **)lhs);
+ dt_ahashent_t *rh = *((dt_ahashent_t **)rhs);
+ dtrace_aggdesc_t *lagg = lh->dtahe_data.dtada_desc;
+ dtrace_aggdesc_t *ragg = rh->dtahe_data.dtada_desc;
+ caddr_t ldata = lh->dtahe_data.dtada_data;
+ caddr_t rdata = rh->dtahe_data.dtada_data;
+ dtrace_recdesc_t *lrec VBDTMSC(NULL), *rrec VBDTMSC(NULL);
+ int64_t *laddr, *raddr;
+ int rval, i;
+
+ if ((rval = dt_aggregate_hashcmp(lhs, rhs)) != 0)
+ return (rval);
+
+ if (lagg->dtagd_nrecs > ragg->dtagd_nrecs)
+ return (DT_GREATERTHAN);
+
+ if (lagg->dtagd_nrecs < ragg->dtagd_nrecs)
+ return (DT_LESSTHAN);
+
+ for (i = 0; i < lagg->dtagd_nrecs; i++) {
+ lrec = &lagg->dtagd_rec[i];
+ rrec = &ragg->dtagd_rec[i];
+
+ if (lrec->dtrd_offset < rrec->dtrd_offset)
+ return (DT_LESSTHAN);
+
+ if (lrec->dtrd_offset > rrec->dtrd_offset)
+ return (DT_GREATERTHAN);
+
+ if (lrec->dtrd_action < rrec->dtrd_action)
+ return (DT_LESSTHAN);
+
+ if (lrec->dtrd_action > rrec->dtrd_action)
+ return (DT_GREATERTHAN);
+ }
+
+ laddr = (int64_t *)(uintptr_t)(ldata + lrec->dtrd_offset);
+ raddr = (int64_t *)(uintptr_t)(rdata + rrec->dtrd_offset);
+
+ switch (lrec->dtrd_action) {
+ case DTRACEAGG_AVG:
+ rval = dt_aggregate_averagecmp(laddr, raddr);
+ break;
+
+ case DTRACEAGG_STDDEV:
+ rval = dt_aggregate_stddevcmp(laddr, raddr);
+ break;
+
+ case DTRACEAGG_QUANTIZE:
+ rval = dt_aggregate_quantizedcmp(laddr, raddr);
+ break;
+
+ case DTRACEAGG_LQUANTIZE:
+ rval = dt_aggregate_lquantizedcmp(laddr, raddr);
+ break;
+
+ case DTRACEAGG_COUNT:
+ case DTRACEAGG_SUM:
+ case DTRACEAGG_MIN:
+ case DTRACEAGG_MAX:
+ rval = dt_aggregate_countcmp(laddr, raddr);
+ break;
+
+ default:
+ assert(0);
+ }
+
+ return (rval);
+}
+
+static int
+dt_aggregate_valkeycmp(const void *lhs, const void *rhs)
+{
+ int rval;
+
+ if ((rval = dt_aggregate_valcmp(lhs, rhs)) != 0)
+ return (rval);
+
+ /*
+ * If we're here, the values for the two aggregation elements are
+ * equal. We already know that the key layout is the same for the two
+ * elements; we must now compare the keys themselves as a tie-breaker.
+ */
+ return (dt_aggregate_keycmp(lhs, rhs));
+}
+
+static int
+dt_aggregate_keyvarcmp(const void *lhs, const void *rhs)
+{
+ int rval;
+
+ if ((rval = dt_aggregate_keycmp(lhs, rhs)) != 0)
+ return (rval);
+
+ return (dt_aggregate_varcmp(lhs, rhs));
+}
+
+static int
+dt_aggregate_varkeycmp(const void *lhs, const void *rhs)
+{
+ int rval;
+
+ if ((rval = dt_aggregate_varcmp(lhs, rhs)) != 0)
+ return (rval);
+
+ return (dt_aggregate_keycmp(lhs, rhs));
+}
+
+static int
+dt_aggregate_valvarcmp(const void *lhs, const void *rhs)
+{
+ int rval;
+
+ if ((rval = dt_aggregate_valkeycmp(lhs, rhs)) != 0)
+ return (rval);
+
+ return (dt_aggregate_varcmp(lhs, rhs));
+}
+
+static int
+dt_aggregate_varvalcmp(const void *lhs, const void *rhs)
+{
+ int rval;
+
+ if ((rval = dt_aggregate_varcmp(lhs, rhs)) != 0)
+ return (rval);
+
+ return (dt_aggregate_valkeycmp(lhs, rhs));
+}
+
+static int
+dt_aggregate_keyvarrevcmp(const void *lhs, const void *rhs)
+{
+ return (dt_aggregate_keyvarcmp(rhs, lhs));
+}
+
+static int
+dt_aggregate_varkeyrevcmp(const void *lhs, const void *rhs)
+{
+ return (dt_aggregate_varkeycmp(rhs, lhs));
+}
+
+static int
+dt_aggregate_valvarrevcmp(const void *lhs, const void *rhs)
+{
+ return (dt_aggregate_valvarcmp(rhs, lhs));
+}
+
+static int
+dt_aggregate_varvalrevcmp(const void *lhs, const void *rhs)
+{
+ return (dt_aggregate_varvalcmp(rhs, lhs));
+}
+
+static int
+dt_aggregate_bundlecmp(const void *lhs, const void *rhs)
+{
+ dt_ahashent_t **lh = *((dt_ahashent_t ***)lhs);
+ dt_ahashent_t **rh = *((dt_ahashent_t ***)rhs);
+ int i, rval;
+
+ if (dt_keysort) {
+ /*
+ * If we're sorting on keys, we need to scan until we find the
+ * last entry -- that's the representative key. (The order of
+ * the bundle is values followed by key to accommodate the
+ * default behavior of sorting by value.) If the keys are
+ * equal, we'll fall into the value comparison loop, below.
+ */
+ for (i = 0; lh[i + 1] != NULL; i++)
+ continue;
+
+ assert(i != 0);
+ assert(rh[i + 1] == NULL);
+
+ if ((rval = dt_aggregate_keycmp(&lh[i], &rh[i])) != 0)
+ return (rval);
+ }
+
+ for (i = 0; ; i++) {
+ if (lh[i + 1] == NULL) {
+ /*
+ * All of the values are equal; if we're sorting on
+ * keys, then we're only here because the keys were
+ * found to be equal and these records are therefore
+ * equal. If we're not sorting on keys, we'll use the
+ * key comparison from the representative key as the
+ * tie-breaker.
+ */
+ if (dt_keysort)
+ return (0);
+
+ assert(i != 0);
+ assert(rh[i + 1] == NULL);
+ return (dt_aggregate_keycmp(&lh[i], &rh[i]));
+ } else {
+ if ((rval = dt_aggregate_valcmp(&lh[i], &rh[i])) != 0)
+ return (rval);
+ }
+ }
+}
+
+int
+dt_aggregate_go(dtrace_hdl_t *dtp)
+{
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ dtrace_optval_t size, cpu;
+ dtrace_bufdesc_t *buf = &agp->dtat_buf;
+ int rval, i;
+
+ assert(agp->dtat_maxcpu == 0);
+ assert(agp->dtat_ncpu == 0);
+ assert(agp->dtat_cpus == NULL);
+
+#ifndef VBOX
+ agp->dtat_maxcpu = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
+ agp->dtat_ncpu = dt_sysconf(dtp, _SC_NPROCESSORS_MAX);
+#else
+ agp->dtat_maxcpu = RTMpGetMaxCpuId() + 1;
+ agp->dtat_ncpu = RTMpGetCount();
+#endif
+ agp->dtat_cpus = malloc(agp->dtat_ncpu * sizeof (processorid_t));
+
+ if (agp->dtat_cpus == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ /*
+ * Use the aggregation buffer size as reloaded from the kernel.
+ */
+ size = dtp->dt_options[DTRACEOPT_AGGSIZE];
+
+ rval = dtrace_getopt(dtp, "aggsize", &size);
+ assert(rval == 0);
+
+ if (size == 0 || size == DTRACEOPT_UNSET)
+ return (0);
+
+ buf = &agp->dtat_buf;
+ buf->dtbd_size = size;
+
+ if ((buf->dtbd_data = malloc(buf->dtbd_size)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ /*
+ * Now query for the CPUs enabled.
+ */
+ rval = dtrace_getopt(dtp, "cpu", &cpu);
+ assert(rval == 0 && cpu != DTRACEOPT_UNSET);
+
+ if (cpu != DTRACE_CPUALL) {
+ assert(cpu < agp->dtat_ncpu);
+ agp->dtat_cpus[agp->dtat_ncpus++] = (processorid_t)cpu;
+
+ return (0);
+ }
+
+ agp->dtat_ncpus = 0;
+ for (i = 0; i < agp->dtat_maxcpu; i++) {
+ if (dt_status(dtp, i) == -1)
+ continue;
+
+ agp->dtat_cpus[agp->dtat_ncpus++] = i;
+ }
+
+ return (0);
+}
+
+static int
+dt_aggwalk_rval(dtrace_hdl_t *dtp, dt_ahashent_t *h, int rval)
+{
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ dtrace_aggdata_t *data;
+ dtrace_aggdesc_t *aggdesc;
+ dtrace_recdesc_t *rec;
+ int i;
+
+ switch (rval) {
+ case DTRACE_AGGWALK_NEXT:
+ break;
+
+ case DTRACE_AGGWALK_CLEAR: {
+ uint32_t size, offs = 0;
+
+ aggdesc = h->dtahe_data.dtada_desc;
+ rec = &aggdesc->dtagd_rec[aggdesc->dtagd_nrecs - 1];
+ size = rec->dtrd_size;
+ data = &h->dtahe_data;
+
+ if (rec->dtrd_action == DTRACEAGG_LQUANTIZE) {
+ offs = sizeof (uint64_t);
+ size -= sizeof (uint64_t);
+ }
+
+ bzero(&data->dtada_data[rec->dtrd_offset] + offs, size);
+
+ if (data->dtada_percpu == NULL)
+ break;
+
+ for (i = 0; i < dtp->dt_aggregate.dtat_maxcpu; i++)
+ bzero(data->dtada_percpu[i] + offs, size);
+ break;
+ }
+
+ case DTRACE_AGGWALK_ERROR:
+ /*
+ * We assume that errno is already set in this case.
+ */
+ return (dt_set_errno(dtp, errno));
+
+ case DTRACE_AGGWALK_ABORT:
+ return (dt_set_errno(dtp, EDT_DIRABORT));
+
+ case DTRACE_AGGWALK_DENORMALIZE:
+ h->dtahe_data.dtada_normal = 1;
+ return (0);
+
+ case DTRACE_AGGWALK_NORMALIZE:
+ if (h->dtahe_data.dtada_normal == 0) {
+ h->dtahe_data.dtada_normal = 1;
+ return (dt_set_errno(dtp, EDT_BADRVAL));
+ }
+
+ return (0);
+
+ case DTRACE_AGGWALK_REMOVE: {
+ dtrace_aggdata_t *aggdata = &h->dtahe_data;
+ int i, max_cpus = agp->dtat_maxcpu;
+
+ /*
+ * First, remove this hash entry from its hash chain.
+ */
+ if (h->dtahe_prev != NULL) {
+ h->dtahe_prev->dtahe_next = h->dtahe_next;
+ } else {
+ dt_ahash_t *hash = &agp->dtat_hash;
+ size_t ndx = h->dtahe_hashval % hash->dtah_size;
+
+ assert(hash->dtah_hash[ndx] == h);
+ hash->dtah_hash[ndx] = h->dtahe_next;
+ }
+
+ if (h->dtahe_next != NULL)
+ h->dtahe_next->dtahe_prev = h->dtahe_prev;
+
+ /*
+ * Now remove it from the list of all hash entries.
+ */
+ if (h->dtahe_prevall != NULL) {
+ h->dtahe_prevall->dtahe_nextall = h->dtahe_nextall;
+ } else {
+ dt_ahash_t *hash = &agp->dtat_hash;
+
+ assert(hash->dtah_all == h);
+ hash->dtah_all = h->dtahe_nextall;
+ }
+
+ if (h->dtahe_nextall != NULL)
+ h->dtahe_nextall->dtahe_prevall = h->dtahe_prevall;
+
+ /*
+ * We're unlinked. We can safely destroy the data.
+ */
+ if (aggdata->dtada_percpu != NULL) {
+ for (i = 0; i < max_cpus; i++)
+ free(aggdata->dtada_percpu[i]);
+ free(aggdata->dtada_percpu);
+ }
+
+ free(aggdata->dtada_data);
+ free(h);
+
+ return (0);
+ }
+
+ default:
+ return (dt_set_errno(dtp, EDT_BADRVAL));
+ }
+
+ return (0);
+}
+
+void
+dt_aggregate_qsort(dtrace_hdl_t *dtp, void *base, size_t nel, size_t width,
+ int (*compar)(const void *, const void *))
+{
+ int rev = dt_revsort, key = dt_keysort, keypos = dt_keypos;
+ dtrace_optval_t keyposopt = dtp->dt_options[DTRACEOPT_AGGSORTKEYPOS];
+
+ dt_revsort = (dtp->dt_options[DTRACEOPT_AGGSORTREV] != DTRACEOPT_UNSET);
+ dt_keysort = (dtp->dt_options[DTRACEOPT_AGGSORTKEY] != DTRACEOPT_UNSET);
+
+ if (keyposopt != DTRACEOPT_UNSET && keyposopt <= INT_MAX) {
+ dt_keypos = (int)keyposopt;
+ } else {
+ dt_keypos = 0;
+ }
+
+ if (compar == NULL) {
+ if (!dt_keysort) {
+ compar = dt_aggregate_varvalcmp;
+ } else {
+ compar = dt_aggregate_varkeycmp;
+ }
+ }
+
+ qsort(base, nel, width, compar);
+
+ dt_revsort = rev;
+ dt_keysort = key;
+ dt_keypos = keypos;
+}
+
+int
+dtrace_aggregate_walk(dtrace_hdl_t *dtp, dtrace_aggregate_f *func, void *arg)
+{
+ dt_ahashent_t *h, *next;
+ dt_ahash_t *hash = &dtp->dt_aggregate.dtat_hash;
+
+ for (h = hash->dtah_all; h != NULL; h = next) {
+ /*
+ * dt_aggwalk_rval() can potentially remove the current hash
+ * entry; we need to load the next hash entry before calling
+ * into it.
+ */
+ next = h->dtahe_nextall;
+
+ if (dt_aggwalk_rval(dtp, h, func(&h->dtahe_data, arg)) == -1)
+ return (-1);
+ }
+
+ return (0);
+}
+
+static int
+dt_aggregate_walk_sorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg,
+ int (*sfunc)(const void *, const void *))
+{
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ dt_ahashent_t *h, **sorted;
+ dt_ahash_t *hash = &agp->dtat_hash;
+ size_t i, nentries = 0;
+
+ for (h = hash->dtah_all; h != NULL; h = h->dtahe_nextall)
+ nentries++;
+
+ sorted = dt_alloc(dtp, nentries * sizeof (dt_ahashent_t *));
+
+ if (sorted == NULL)
+ return (-1);
+
+ for (h = hash->dtah_all, i = 0; h != NULL; h = h->dtahe_nextall)
+ sorted[i++] = h;
+
+#ifndef VBOX
+ (void) pthread_mutex_lock(&dt_qsort_lock);
+#else
+ RTCritSectEnter(&dt_qsort_lock);
+#endif
+
+ if (sfunc == NULL) {
+ dt_aggregate_qsort(dtp, sorted, nentries,
+ sizeof (dt_ahashent_t *), NULL);
+ } else {
+ /*
+ * If we've been explicitly passed a sorting function,
+ * we'll use that -- ignoring the values of the "aggsortrev",
+ * "aggsortkey" and "aggsortkeypos" options.
+ */
+ qsort(sorted, nentries, sizeof (dt_ahashent_t *), sfunc);
+ }
+
+#ifndef VBOX
+ (void) pthread_mutex_unlock(&dt_qsort_lock);
+#else
+ RTCritSectLeave(&dt_qsort_lock);
+#endif
+
+ for (i = 0; i < nentries; i++) {
+ h = sorted[i];
+
+ if (dt_aggwalk_rval(dtp, h, func(&h->dtahe_data, arg)) == -1) {
+ dt_free(dtp, sorted);
+ return (-1);
+ }
+ }
+
+ dt_free(dtp, sorted);
+ return (0);
+}
+
+int
+dtrace_aggregate_walk_sorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func, arg, NULL));
+}
+
+int
+dtrace_aggregate_walk_keysorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_varkeycmp));
+}
+
+int
+dtrace_aggregate_walk_valsorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_varvalcmp));
+}
+
+int
+dtrace_aggregate_walk_keyvarsorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_keyvarcmp));
+}
+
+int
+dtrace_aggregate_walk_valvarsorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_valvarcmp));
+}
+
+int
+dtrace_aggregate_walk_keyrevsorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_varkeyrevcmp));
+}
+
+int
+dtrace_aggregate_walk_valrevsorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_varvalrevcmp));
+}
+
+int
+dtrace_aggregate_walk_keyvarrevsorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_keyvarrevcmp));
+}
+
+int
+dtrace_aggregate_walk_valvarrevsorted(dtrace_hdl_t *dtp,
+ dtrace_aggregate_f *func, void *arg)
+{
+ return (dt_aggregate_walk_sorted(dtp, func,
+ arg, dt_aggregate_valvarrevcmp));
+}
+
+int
+dtrace_aggregate_walk_joined(dtrace_hdl_t *dtp, dtrace_aggvarid_t *aggvars,
+ int naggvars, dtrace_aggregate_walk_joined_f *func, void *arg)
+{
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ dt_ahashent_t *h, **sorted = NULL, ***bundle VBDTMSC(NULL), **nbundle;
+ const dtrace_aggdata_t **data;
+ dt_ahashent_t *zaggdata = NULL;
+ dt_ahash_t *hash = &agp->dtat_hash;
+ size_t nentries = 0, nbundles = 0, start, zsize = 0, bundlesize;
+ dtrace_aggvarid_t max = 0, aggvar;
+ int rval = -1, *map, *remap = NULL;
+ int i, j;
+ dtrace_optval_t sortpos = dtp->dt_options[DTRACEOPT_AGGSORTPOS];
+
+ /*
+ * If the sorting position is greater than the number of aggregation
+ * variable IDs, we silently set it to 0.
+ */
+ if (sortpos == DTRACEOPT_UNSET || sortpos >= naggvars)
+ sortpos = 0;
+
+ /*
+ * First we need to translate the specified aggregation variable IDs
+ * into a linear map that will allow us to translate an aggregation
+ * variable ID into its position in the specified aggvars.
+ */
+ for (i = 0; i < naggvars; i++) {
+ if (aggvars[i] == DTRACE_AGGVARIDNONE || aggvars[i] < 0)
+ return (dt_set_errno(dtp, EDT_BADAGGVAR));
+
+ if (aggvars[i] > max)
+ max = aggvars[i];
+ }
+
+ if ((map = dt_zalloc(dtp, (max + 1) * sizeof (int))) == NULL)
+ return (-1);
+
+ zaggdata = dt_zalloc(dtp, naggvars * sizeof (dt_ahashent_t));
+
+ if (zaggdata == NULL)
+ goto out;
+
+ for (i = 0; i < naggvars; i++) {
+ int ndx = i + sortpos;
+
+ if (ndx >= naggvars)
+ ndx -= naggvars;
+
+ aggvar = aggvars[ndx];
+ assert(aggvar <= max);
+
+ if (map[aggvar]) {
+ /*
+ * We have an aggregation variable that is present
+ * more than once in the array of aggregation
+ * variables. While it's unclear why one might want
+ * to do this, it's legal. To support this construct,
+ * we will allocate a remap that will indicate the
+ * position from which this aggregation variable
+ * should be pulled. (That is, where the remap will
+ * map from one position to another.)
+ */
+ if (remap == NULL) {
+ remap = dt_zalloc(dtp, naggvars * sizeof (int));
+
+ if (remap == NULL)
+ goto out;
+ }
+
+ /*
+ * Given that the variable is already present, assert
+ * that following through the mapping and adjusting
+ * for the sort position yields the same aggregation
+ * variable ID.
+ */
+ assert(aggvars[(map[aggvar] - 1 + sortpos) %
+ naggvars] == aggvars[ndx]);
+
+ remap[i] = map[aggvar];
+ continue;
+ }
+
+ map[aggvar] = i + 1;
+ }
+
+ /*
+ * We need to take two passes over the data to size our allocation, so
+ * we'll use the first pass to also fill in the zero-filled data to be
+ * used to properly format a zero-valued aggregation.
+ */
+ for (h = hash->dtah_all; h != NULL; h = h->dtahe_nextall) {
+ dtrace_aggvarid_t id;
+ int ndx;
+
+ if ((id = dt_aggregate_aggvarid(h)) > max || !(ndx = map[id]))
+ continue;
+
+ if (zaggdata[ndx - 1].dtahe_size == 0) {
+ zaggdata[ndx - 1].dtahe_size = h->dtahe_size;
+ zaggdata[ndx - 1].dtahe_data = h->dtahe_data;
+ }
+
+ nentries++;
+ }
+
+ if (nentries == 0) {
+ /*
+ * We couldn't find any entries; there is nothing else to do.
+ */
+ rval = 0;
+ goto out;
+ }
+
+ /*
+ * Before we sort the data, we're going to look for any holes in our
+ * zero-filled data. This will occur if an aggregation variable that
+ * we are being asked to print has not yet been assigned the result of
+ * any aggregating action for _any_ tuple. The issue becomes that we
+ * would like a zero value to be printed for all columns for this
+ * aggregation, but without any record description, we don't know the
+ * aggregating action that corresponds to the aggregation variable. To
+ * try to find a match, we're simply going to lookup aggregation IDs
+ * (which are guaranteed to be contiguous and to start from 1), looking
+ * for the specified aggregation variable ID. If we find a match,
+ * we'll use that. If we iterate over all aggregation IDs and don't
+ * find a match, then we must be an anonymous enabling. (Anonymous
+ * enablings can't currently derive either aggregation variable IDs or
+ * aggregation variable names given only an aggregation ID.) In this
+ * obscure case (anonymous enabling, multiple aggregation printa() with
+ * some aggregations not represented for any tuple), our defined
+ * behavior is that the zero will be printed in the format of the first
+ * aggregation variable that contains any non-zero value.
+ */
+ for (i = 0; i < naggvars; i++) {
+ if (zaggdata[i].dtahe_size == 0) {
+ dtrace_aggvarid_t aggvar;
+
+ aggvar = aggvars[(i - sortpos + naggvars) % naggvars];
+ assert(zaggdata[i].dtahe_data.dtada_data == NULL);
+
+ for (j = DTRACE_AGGIDNONE + 1; ; j++) {
+ dtrace_aggdesc_t *agg;
+ dtrace_aggdata_t *aggdata;
+
+ if (dt_aggid_lookup(dtp, j, &agg) != 0)
+ break;
+
+ if (agg->dtagd_varid != aggvar)
+ continue;
+
+ /*
+ * We have our description -- now we need to
+ * cons up the zaggdata entry for it.
+ */
+ aggdata = &zaggdata[i].dtahe_data;
+ aggdata->dtada_size = agg->dtagd_size;
+ aggdata->dtada_desc = agg;
+ aggdata->dtada_handle = dtp;
+ (void) dt_epid_lookup(dtp, agg->dtagd_epid,
+ &aggdata->dtada_edesc,
+ &aggdata->dtada_pdesc);
+ aggdata->dtada_normal = 1;
+ zaggdata[i].dtahe_hashval = 0;
+ zaggdata[i].dtahe_size = agg->dtagd_size;
+ break;
+ }
+
+ if (zaggdata[i].dtahe_size == 0) {
+ caddr_t data;
+
+ /*
+ * We couldn't find this aggregation, meaning
+ * that we have never seen it before for any
+ * tuple _and_ this is an anonymous enabling.
+ * That is, we're in the obscure case outlined
+ * above. In this case, our defined behavior
+ * is to format the data in the format of the
+ * first non-zero aggregation -- of which, of
+ * course, we know there to be at least one
+ * (or nentries would have been zero).
+ */
+ for (j = 0; j < naggvars; j++) {
+ if (zaggdata[j].dtahe_size != 0)
+ break;
+ }
+
+ assert(j < naggvars);
+ zaggdata[i] = zaggdata[j];
+
+ data = zaggdata[i].dtahe_data.dtada_data;
+ assert(data != NULL);
+ }
+ }
+ }
+
+ /*
+ * Now we need to allocate our zero-filled data for use for
+ * aggregations that don't have a value corresponding to a given key.
+ */
+ for (i = 0; i < naggvars; i++) {
+ dtrace_aggdata_t *aggdata = &zaggdata[i].dtahe_data;
+ dtrace_aggdesc_t *aggdesc = aggdata->dtada_desc;
+ dtrace_recdesc_t *rec;
+ uint64_t larg;
+ caddr_t zdata;
+
+ zsize = zaggdata[i].dtahe_size;
+ assert(zsize != 0);
+
+ if ((zdata = dt_zalloc(dtp, zsize)) == NULL) {
+ /*
+ * If we failed to allocated some zero-filled data, we
+ * need to zero out the remaining dtada_data pointers
+ * to prevent the wrong data from being freed below.
+ */
+ for (j = i; j < naggvars; j++)
+ zaggdata[j].dtahe_data.dtada_data = NULL;
+ goto out;
+ }
+
+ aggvar = aggvars[(i - sortpos + naggvars) % naggvars];
+
+ /*
+ * First, the easy bit. To maintain compatibility with
+ * consumers that pull the compiler-generated ID out of the
+ * data, we put that ID at the top of the zero-filled data.
+ */
+ rec = &aggdesc->dtagd_rec[0];
+ /* LINTED - alignment */
+ *((dtrace_aggvarid_t *)(zdata + rec->dtrd_offset)) = aggvar;
+
+ rec = &aggdesc->dtagd_rec[aggdesc->dtagd_nrecs - 1];
+
+ /*
+ * Now for the more complicated part. If (and only if) this
+ * is an lquantize() aggregating action, zero-filled data is
+ * not equivalent to an empty record: we must also get the
+ * parameters for the lquantize().
+ */
+ if (rec->dtrd_action == DTRACEAGG_LQUANTIZE) {
+ if (aggdata->dtada_data != NULL) {
+ /*
+ * The easier case here is if we actually have
+ * some prototype data -- in which case we
+ * manually dig it out of the aggregation
+ * record.
+ */
+ /* LINTED - alignment */
+ larg = *((uint64_t *)(aggdata->dtada_data +
+ rec->dtrd_offset));
+ } else {
+ /*
+ * We don't have any prototype data. As a
+ * result, we know that we _do_ have the
+ * compiler-generated information. (If this
+ * were an anonymous enabling, all of our
+ * zero-filled data would have prototype data
+ * -- either directly or indirectly.) So as
+ * gross as it is, we'll grovel around in the
+ * compiler-generated information to find the
+ * lquantize() parameters.
+ */
+ dtrace_stmtdesc_t *sdp;
+ dt_ident_t *aid;
+ dt_idsig_t *isp;
+
+ sdp = (dtrace_stmtdesc_t *)(uintptr_t)
+ aggdesc->dtagd_rec[0].dtrd_uarg;
+ aid = sdp->dtsd_aggdata;
+ isp = (dt_idsig_t *)aid->di_data;
+ assert(isp->dis_auxinfo != 0);
+ larg = isp->dis_auxinfo;
+ }
+
+ /* LINTED - alignment */
+ *((uint64_t *)(zdata + rec->dtrd_offset)) = larg;
+ }
+
+ aggdata->dtada_data = zdata;
+ }
+
+ /*
+ * Now that we've dealt with setting up our zero-filled data, we can
+ * allocate our sorted array, and take another pass over the data to
+ * fill it.
+ */
+ sorted = dt_alloc(dtp, nentries * sizeof (dt_ahashent_t *));
+
+ if (sorted == NULL)
+ goto out;
+
+ for (h = hash->dtah_all, i = 0; h != NULL; h = h->dtahe_nextall) {
+ dtrace_aggvarid_t id;
+
+ if ((id = dt_aggregate_aggvarid(h)) > max || !map[id])
+ continue;
+
+ sorted[i++] = h;
+ }
+
+ assert((size_t/*vbox*/)i == nentries);
+
+ /*
+ * We've loaded our array; now we need to sort by value to allow us
+ * to create bundles of like value. We're going to acquire the
+ * dt_qsort_lock here, and hold it across all of our subsequent
+ * comparison and sorting.
+ */
+#ifndef VBOX
+ (void) pthread_mutex_lock(&dt_qsort_lock);
+#else
+ RTCritSectEnter(&dt_qsort_lock);
+#endif
+
+ qsort(sorted, nentries, sizeof (dt_ahashent_t *),
+ dt_aggregate_keyvarcmp);
+
+ /*
+ * Now we need to go through and create bundles. Because the number
+ * of bundles is bounded by the size of the sorted array, we're going
+ * to reuse the underlying storage. And note that "bundle" is an
+ * array of pointers to arrays of pointers to dt_ahashent_t -- making
+ * its type (regrettably) "dt_ahashent_t ***". (Regrettable because
+ * '*' -- like '_' and 'X' -- should never appear in triplicate in
+ * an ideal world.)
+ */
+ bundle = (dt_ahashent_t ***)sorted;
+
+ for (i = 1, start = 0; (size_t/*vbox*/)i <= nentries; i++) {
+ if ((size_t/*vbox*/)i < nentries &&
+ dt_aggregate_keycmp(&sorted[i], &sorted[i - 1]) == 0)
+ continue;
+
+ /*
+ * We have a bundle boundary. Everything from start to
+ * (i - 1) belongs in one bundle.
+ */
+ assert((size_t/*vbox*/)i - start <= (size_t/*vbox*/)naggvars);
+ bundlesize = (naggvars + 2) * sizeof (dt_ahashent_t *);
+
+ if ((nbundle = dt_zalloc(dtp, bundlesize)) == NULL) {
+#ifndef VBOX
+ (void) pthread_mutex_unlock(&dt_qsort_lock);
+#else
+ RTCritSectLeave(&dt_qsort_lock);
+#endif
+ goto out;
+ }
+
+ for (j = VBDTCAST(int)start; j < i; j++) {
+ dtrace_aggvarid_t id = dt_aggregate_aggvarid(sorted[j]);
+
+ assert(id <= max);
+ assert(map[id] != 0);
+ assert(map[id] - 1 < naggvars);
+ assert(nbundle[map[id] - 1] == NULL);
+ nbundle[map[id] - 1] = sorted[j];
+
+ if (nbundle[naggvars] == NULL)
+ nbundle[naggvars] = sorted[j];
+ }
+
+ for (j = 0; j < naggvars; j++) {
+ if (nbundle[j] != NULL)
+ continue;
+
+ /*
+ * Before we assume that this aggregation variable
+ * isn't present (and fall back to using the
+ * zero-filled data allocated earlier), check the
+ * remap. If we have a remapping, we'll drop it in
+ * here. Note that we might be remapping an
+ * aggregation variable that isn't present for this
+ * key; in this case, the aggregation data that we
+ * copy will point to the zeroed data.
+ */
+ if (remap != NULL && remap[j]) {
+ assert(remap[j] - 1 < j);
+ assert(nbundle[remap[j] - 1] != NULL);
+ nbundle[j] = nbundle[remap[j] - 1];
+ } else {
+ nbundle[j] = &zaggdata[j];
+ }
+ }
+
+ bundle[nbundles++] = nbundle;
+ start = i;
+ }
+
+ /*
+ * Now we need to re-sort based on the first value.
+ */
+ dt_aggregate_qsort(dtp, bundle, nbundles, sizeof (dt_ahashent_t **),
+ dt_aggregate_bundlecmp);
+
+#ifndef VBOX
+ (void) pthread_mutex_unlock(&dt_qsort_lock);
+#else
+ RTCritSectLeave(&dt_qsort_lock);
+#endif
+
+ /*
+ * We're done! Now we just need to go back over the sorted bundles,
+ * calling the function.
+ */
+ data = alloca((naggvars + 1) * sizeof (dtrace_aggdata_t *));
+
+ for (i = 0; (size_t/*vbox*/)i < nbundles; i++) {
+ for (j = 0; j < naggvars; j++)
+ data[j + 1] = NULL;
+
+ for (j = 0; j < naggvars; j++) {
+ int ndx = j - sortpos;
+
+ if (ndx < 0)
+ ndx += naggvars;
+
+ assert(bundle[i][ndx] != NULL);
+ data[j + 1] = &bundle[i][ndx]->dtahe_data;
+ }
+
+ for (j = 0; j < naggvars; j++)
+ assert(data[j + 1] != NULL);
+
+ /*
+ * The representative key is the last element in the bundle.
+ * Assert that we have one, and then set it to be the first
+ * element of data.
+ */
+ assert(bundle[i][j] != NULL);
+ data[0] = &bundle[i][j]->dtahe_data;
+
+ if ((rval = func(data, naggvars + 1, arg)) == -1)
+ goto out;
+ }
+
+ rval = 0;
+out:
+ for (i = 0; (size_t/*vbox*/)i < nbundles; i++)
+ dt_free(dtp, bundle[i]);
+
+ if (zaggdata != NULL) {
+ for (i = 0; i < naggvars; i++)
+ dt_free(dtp, zaggdata[i].dtahe_data.dtada_data);
+ }
+
+ dt_free(dtp, zaggdata);
+ dt_free(dtp, sorted);
+ dt_free(dtp, remap);
+ dt_free(dtp, map);
+
+ return (rval);
+}
+
+int
+dtrace_aggregate_print(dtrace_hdl_t *dtp, FILE *fp,
+ dtrace_aggregate_walk_f *func)
+{
+ dt_print_aggdata_t pd;
+
+ pd.dtpa_dtp = dtp;
+ pd.dtpa_fp = fp;
+ pd.dtpa_allunprint = 1;
+
+ if (func == NULL)
+ func = dtrace_aggregate_walk_sorted;
+
+ if ((*func)(dtp, dt_print_agg, &pd) == -1)
+ return (dt_set_errno(dtp, dtp->dt_errno));
+
+ return (0);
+}
+
+void
+dtrace_aggregate_clear(dtrace_hdl_t *dtp)
+{
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ dt_ahash_t *hash = &agp->dtat_hash;
+ dt_ahashent_t *h;
+ dtrace_aggdata_t *data;
+ dtrace_aggdesc_t *aggdesc;
+ dtrace_recdesc_t *rec;
+ int i, max_cpus = agp->dtat_maxcpu;
+
+ for (h = hash->dtah_all; h != NULL; h = h->dtahe_nextall) {
+ aggdesc = h->dtahe_data.dtada_desc;
+ rec = &aggdesc->dtagd_rec[aggdesc->dtagd_nrecs - 1];
+ data = &h->dtahe_data;
+
+ bzero(&data->dtada_data[rec->dtrd_offset], rec->dtrd_size);
+
+ if (data->dtada_percpu == NULL)
+ continue;
+
+ for (i = 0; i < max_cpus; i++)
+ bzero(data->dtada_percpu[i], rec->dtrd_size);
+ }
+}
+
+void
+dt_aggregate_destroy(dtrace_hdl_t *dtp)
+{
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+ dt_ahash_t *hash = &agp->dtat_hash;
+ dt_ahashent_t *h, *next;
+ dtrace_aggdata_t *aggdata;
+ int i, max_cpus = agp->dtat_maxcpu;
+
+ if (hash->dtah_hash == NULL) {
+ assert(hash->dtah_all == NULL);
+ } else {
+ free(hash->dtah_hash);
+
+ for (h = hash->dtah_all; h != NULL; h = next) {
+ next = h->dtahe_nextall;
+
+ aggdata = &h->dtahe_data;
+
+ if (aggdata->dtada_percpu != NULL) {
+ for (i = 0; i < max_cpus; i++)
+ free(aggdata->dtada_percpu[i]);
+ free(aggdata->dtada_percpu);
+ }
+
+ free(aggdata->dtada_data);
+ free(h);
+ }
+
+ hash->dtah_hash = NULL;
+ hash->dtah_all = NULL;
+ hash->dtah_size = 0;
+ }
+
+ free(agp->dtat_buf.dtbd_data);
+ free(agp->dtat_cpus);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.c
new file mode 100644
index 00000000..728457cd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.c
@@ -0,0 +1,507 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <assert.h>
+#else /* VBOX */
+# include <iprt/asm.h>
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_parser.h>
+#include <dt_as.h>
+
+void
+dt_irlist_create(dt_irlist_t *dlp)
+{
+ bzero(dlp, sizeof (dt_irlist_t));
+ dlp->dl_label = 1;
+}
+
+void
+dt_irlist_destroy(dt_irlist_t *dlp)
+{
+ dt_irnode_t *dip, *nip;
+
+ for (dip = dlp->dl_list; dip != NULL; dip = nip) {
+ nip = dip->di_next;
+ free(dip);
+ }
+}
+
+void
+dt_irlist_append(dt_irlist_t *dlp, dt_irnode_t *dip)
+{
+ if (dlp->dl_last != NULL)
+ dlp->dl_last->di_next = dip;
+ else
+ dlp->dl_list = dip;
+
+ dlp->dl_last = dip;
+
+ if (dip->di_label == DT_LBL_NONE || dip->di_instr != DIF_INSTR_NOP)
+ dlp->dl_len++; /* don't count forward refs in instr count */
+}
+
+uint_t
+dt_irlist_label(dt_irlist_t *dlp)
+{
+ return (dlp->dl_label++);
+}
+
+/*ARGSUSED*/
+static int
+dt_countvar(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
+{
+ size_t *np = data;
+ RT_NOREF1(dhp);
+
+ if (idp->di_flags & (DT_IDFLG_DIFR | DT_IDFLG_DIFW))
+ (*np)++; /* include variable in vartab */
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_copyvar(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
+{
+ dt_pcb_t *pcb = data;
+ dtrace_difv_t *dvp;
+ ssize_t stroff;
+ dt_node_t dn;
+ RT_NOREF1(dhp);
+
+ if (!(idp->di_flags & (DT_IDFLG_DIFR | DT_IDFLG_DIFW)))
+ return (0); /* omit variable from vartab */
+
+ dvp = &pcb->pcb_difo->dtdo_vartab[pcb->pcb_asvidx++];
+ stroff = dt_strtab_insert(pcb->pcb_strtab, idp->di_name);
+
+ if (stroff == -1L)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+ if (stroff > DIF_STROFF_MAX)
+ longjmp(pcb->pcb_jmpbuf, EDT_STR2BIG);
+
+ dvp->dtdv_name = (uint_t)stroff;
+ dvp->dtdv_id = idp->di_id;
+ dvp->dtdv_flags = 0;
+
+ dvp->dtdv_kind = (idp->di_kind == DT_IDENT_ARRAY) ?
+ DIFV_KIND_ARRAY : DIFV_KIND_SCALAR;
+
+ if (idp->di_flags & DT_IDFLG_LOCAL)
+ dvp->dtdv_scope = DIFV_SCOPE_LOCAL;
+ else if (idp->di_flags & DT_IDFLG_TLS)
+ dvp->dtdv_scope = DIFV_SCOPE_THREAD;
+ else
+ dvp->dtdv_scope = DIFV_SCOPE_GLOBAL;
+
+ if (idp->di_flags & DT_IDFLG_DIFR)
+ dvp->dtdv_flags |= DIFV_F_REF;
+ if (idp->di_flags & DT_IDFLG_DIFW)
+ dvp->dtdv_flags |= DIFV_F_MOD;
+
+ bzero(&dn, sizeof (dn));
+ dt_node_type_assign(&dn, idp->di_ctfp, idp->di_type);
+ dt_node_diftype(pcb->pcb_hdl, &dn, &dvp->dtdv_type);
+
+ idp->di_flags &= ~(DT_IDFLG_DIFR | DT_IDFLG_DIFW);
+ return (0);
+}
+
+static ssize_t
+dt_copystr(const char *s, size_t n, size_t off, dt_pcb_t *pcb)
+{
+ bcopy(s, pcb->pcb_difo->dtdo_strtab + off, n);
+ return (n);
+}
+
+/*
+ * Rewrite the xlate/xlarg instruction at dtdo_buf[i] so that the instruction's
+ * xltab index reflects the offset 'xi' of the assigned dtdo_xlmtab[] location.
+ * We track the cumulative references to translators and members in the pcb's
+ * pcb_asxrefs[] array, a two-dimensional array of bitmaps indexed by the
+ * global translator id and then by the corresponding translator member id.
+ */
+static void
+dt_as_xlate(dt_pcb_t *pcb, dtrace_difo_t *dp,
+ uint_t i, uint_t xi, dt_node_t *dnp)
+{
+ dtrace_hdl_t *dtp = pcb->pcb_hdl;
+ dt_xlator_t *dxp = dnp->dn_membexpr->dn_xlator;
+
+ assert(i < dp->dtdo_len);
+ assert(xi < dp->dtdo_xlmlen);
+
+ assert(dnp->dn_kind == DT_NODE_MEMBER);
+ assert(dnp->dn_membexpr->dn_kind == DT_NODE_XLATOR);
+
+ assert(dxp->dx_id < dtp->dt_xlatorid);
+ assert(dnp->dn_membid < dxp->dx_nmembers);
+
+ if (pcb->pcb_asxrefs == NULL) {
+ pcb->pcb_asxreflen = dtp->dt_xlatorid;
+ pcb->pcb_asxrefs =
+ dt_zalloc(dtp, sizeof (ulong_t *) * pcb->pcb_asxreflen);
+ if (pcb->pcb_asxrefs == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ if (pcb->pcb_asxrefs[dxp->dx_id] == NULL) {
+ pcb->pcb_asxrefs[dxp->dx_id] =
+ dt_zalloc(dtp, BT_SIZEOFMAP(dxp->dx_nmembers));
+ if (pcb->pcb_asxrefs[dxp->dx_id] == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ dp->dtdo_buf[i] = DIF_INSTR_XLATE(
+ DIF_INSTR_OP(dp->dtdo_buf[i]), xi, DIF_INSTR_RD(dp->dtdo_buf[i]));
+
+ BT_SET(pcb->pcb_asxrefs[dxp->dx_id], dnp->dn_membid);
+ dp->dtdo_xlmtab[xi] = dnp;
+}
+
+static void
+dt_as_undef(const dt_ident_t *idp, uint_t offset)
+{
+ const char *kind, *mark = (idp->di_flags & DT_IDFLG_USER) ? "``" : "`";
+ const dtrace_syminfo_t *dts = idp->di_data;
+
+ if (idp->di_flags & DT_IDFLG_USER)
+ kind = "user";
+ else if (idp->di_flags & DT_IDFLG_PRIM)
+ kind = "primary kernel";
+ else
+ kind = "loadable kernel";
+
+ yylineno = idp->di_lineno;
+
+ xyerror(D_ASRELO, "relocation remains against %s symbol %s%s%s (offset "
+ "0x%x)\n", kind, dts->dts_object, mark, dts->dts_name, offset);
+}
+
+dtrace_difo_t *
+dt_as(dt_pcb_t *pcb)
+{
+ dtrace_hdl_t *dtp = pcb->pcb_hdl;
+ dt_irlist_t *dlp = &pcb->pcb_ir;
+ uint_t *labels = NULL;
+ dt_irnode_t *dip;
+ dtrace_difo_t *dp;
+ dt_ident_t *idp;
+
+ size_t n = 0;
+ uint_t i;
+
+ uint_t kmask VBDTMSC(0), kbits VBDTMSC(0), umask VBDTMSC(0), ubits VBDTMSC(0);
+ uint_t krel = 0, urel = 0, xlrefs = 0;
+
+ /*
+ * Select bitmasks based upon the desired symbol linking policy. We
+ * test (di_extern->di_flags & xmask) == xbits to determine if the
+ * symbol should have a relocation entry generated in the loop below.
+ *
+ * DT_LINK_KERNEL = kernel symbols static, user symbols dynamic
+ * DT_LINK_PRIMARY = primary kernel symbols static, others dynamic
+ * DT_LINK_DYNAMIC = all symbols dynamic
+ * DT_LINK_STATIC = all symbols static
+ *
+ * By 'static' we mean that we use the symbol's value at compile-time
+ * in the final DIF. By 'dynamic' we mean that we create a relocation
+ * table entry for the symbol's value so it can be relocated later.
+ */
+ switch (dtp->dt_linkmode) {
+ case DT_LINK_KERNEL:
+ kmask = 0;
+ kbits = ~0u;
+ umask = DT_IDFLG_USER;
+ ubits = DT_IDFLG_USER;
+ break;
+ case DT_LINK_PRIMARY:
+ kmask = DT_IDFLG_USER | DT_IDFLG_PRIM;
+ kbits = 0;
+ umask = DT_IDFLG_USER;
+ ubits = DT_IDFLG_USER;
+ break;
+ case DT_LINK_DYNAMIC:
+ kmask = DT_IDFLG_USER;
+ kbits = 0;
+ umask = DT_IDFLG_USER;
+ ubits = DT_IDFLG_USER;
+ break;
+ case DT_LINK_STATIC:
+ kmask = umask = 0;
+ kbits = ubits = ~0u;
+ break;
+ default:
+ xyerror(D_UNKNOWN, "internal error -- invalid link mode %u\n",
+ dtp->dt_linkmode);
+ }
+
+ assert(pcb->pcb_difo == NULL);
+ pcb->pcb_difo = dt_zalloc(dtp, sizeof (dtrace_difo_t));
+
+ if ((dp = pcb->pcb_difo) == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dp->dtdo_buf = dt_alloc(dtp, sizeof (dif_instr_t) * dlp->dl_len);
+
+ if (dp->dtdo_buf == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if ((labels = dt_alloc(dtp, sizeof (uint_t) * dlp->dl_label)) == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * Make an initial pass through the instruction list, filling in the
+ * instruction buffer with valid instructions and skipping labeled nops.
+ * While doing this, we also fill in our labels[] translation table
+ * and we count up the number of relocation table entries we will need.
+ */
+ for (i = 0, dip = dlp->dl_list; dip != NULL; dip = dip->di_next) {
+ if (dip->di_label != DT_LBL_NONE)
+ labels[dip->di_label] = i;
+
+ if (dip->di_label == DT_LBL_NONE ||
+ dip->di_instr != DIF_INSTR_NOP)
+ dp->dtdo_buf[i++] = dip->di_instr;
+
+ if (dip->di_extern == NULL)
+ continue; /* no external references needed */
+
+ switch (DIF_INSTR_OP(dip->di_instr)) {
+ case DIF_OP_SETX:
+ idp = dip->di_extern;
+ if ((idp->di_flags & kmask) == kbits)
+ krel++;
+ else if ((idp->di_flags & umask) == ubits)
+ urel++;
+ break;
+ case DIF_OP_XLATE:
+ case DIF_OP_XLARG:
+ xlrefs++;
+ break;
+ default:
+ xyerror(D_UNKNOWN, "unexpected assembler relocation "
+ "for opcode 0x%x\n", DIF_INSTR_OP(dip->di_instr));
+ }
+ }
+
+ assert(i == dlp->dl_len);
+ dp->dtdo_len = dlp->dl_len;
+
+ /*
+ * Make a second pass through the instructions, relocating each branch
+ * label to the index of the final instruction in the buffer and noting
+ * any other instruction-specific DIFO flags such as dtdo_destructive.
+ */
+ for (i = 0; i < dp->dtdo_len; i++) {
+ dif_instr_t instr = dp->dtdo_buf[i];
+ uint_t op = DIF_INSTR_OP(instr);
+
+ if (op == DIF_OP_CALL) {
+ if (DIF_INSTR_SUBR(instr) == DIF_SUBR_COPYOUT ||
+ DIF_INSTR_SUBR(instr) == DIF_SUBR_COPYOUTSTR)
+ dp->dtdo_destructive = 1;
+ continue;
+ }
+
+ if (op >= DIF_OP_BA && op <= DIF_OP_BLEU) {
+ assert(DIF_INSTR_LABEL(instr) < dlp->dl_label);
+ dp->dtdo_buf[i] = DIF_INSTR_BRANCH(op,
+ labels[DIF_INSTR_LABEL(instr)]);
+ }
+ }
+
+ dt_free(dtp, labels);
+ pcb->pcb_asvidx = 0;
+
+ /*
+ * Allocate memory for the appropriate number of variable records and
+ * then fill in each variable record. As we populate the variable
+ * table we insert the corresponding variable names into the strtab.
+ */
+ (void) dt_idhash_iter(dtp->dt_tls, dt_countvar, &n);
+ (void) dt_idhash_iter(dtp->dt_globals, dt_countvar, &n);
+ (void) dt_idhash_iter(pcb->pcb_locals, dt_countvar, &n);
+
+ if (n != 0) {
+ dp->dtdo_vartab = dt_alloc(dtp, n * sizeof (dtrace_difv_t));
+ dp->dtdo_varlen = (uint32_t)n;
+
+ if (dp->dtdo_vartab == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) dt_idhash_iter(dtp->dt_tls, dt_copyvar, pcb);
+ (void) dt_idhash_iter(dtp->dt_globals, dt_copyvar, pcb);
+ (void) dt_idhash_iter(pcb->pcb_locals, dt_copyvar, pcb);
+ }
+
+ /*
+ * Allocate memory for the appropriate number of relocation table
+ * entries based upon our kernel and user counts from the first pass.
+ */
+ if (krel != 0) {
+ dp->dtdo_kreltab = dt_alloc(dtp,
+ krel * sizeof (dof_relodesc_t));
+ dp->dtdo_krelen = krel;
+
+ if (dp->dtdo_kreltab == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ if (urel != 0) {
+ dp->dtdo_ureltab = dt_alloc(dtp,
+ urel * sizeof (dof_relodesc_t));
+ dp->dtdo_urelen = urel;
+
+ if (dp->dtdo_ureltab == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ if (xlrefs != 0) {
+ dp->dtdo_xlmtab = dt_zalloc(dtp, sizeof (dt_node_t *) * xlrefs);
+ dp->dtdo_xlmlen = xlrefs;
+
+ if (dp->dtdo_xlmtab == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ /*
+ * If any relocations are needed, make another pass through the
+ * instruction list and fill in the relocation table entries.
+ */
+ if (krel + urel + xlrefs != 0) {
+ uint_t knodef = pcb->pcb_cflags & DTRACE_C_KNODEF;
+ uint_t unodef = pcb->pcb_cflags & DTRACE_C_UNODEF;
+
+ dof_relodesc_t *krp = dp->dtdo_kreltab;
+ dof_relodesc_t *urp = dp->dtdo_ureltab;
+ dt_node_t **xlp = dp->dtdo_xlmtab;
+
+ i = 0; /* dtdo_buf[] index */
+
+ for (dip = dlp->dl_list; dip != NULL; dip = dip->di_next) {
+ dof_relodesc_t *rp;
+ ssize_t soff;
+ uint_t nodef;
+
+ if (dip->di_label != DT_LBL_NONE &&
+ dip->di_instr == DIF_INSTR_NOP)
+ continue; /* skip label declarations */
+
+ i++; /* advance dtdo_buf[] index */
+
+ if (DIF_INSTR_OP(dip->di_instr) == DIF_OP_XLATE ||
+ DIF_INSTR_OP(dip->di_instr) == DIF_OP_XLARG) {
+ assert(dp->dtdo_buf[i - 1] == dip->di_instr);
+ dt_as_xlate(pcb, dp, i - 1, (uint_t)
+ (xlp++ - dp->dtdo_xlmtab), dip->di_extern);
+ continue;
+ }
+
+ if ((idp = dip->di_extern) == NULL)
+ continue; /* no relocation entry needed */
+
+ if ((idp->di_flags & kmask) == kbits) {
+ nodef = knodef;
+ rp = krp++;
+ } else if ((idp->di_flags & umask) == ubits) {
+ nodef = unodef;
+ rp = urp++;
+ } else
+ continue;
+
+ if (!nodef)
+ dt_as_undef(idp, i);
+
+ assert(DIF_INSTR_OP(dip->di_instr) == DIF_OP_SETX);
+ soff = dt_strtab_insert(pcb->pcb_strtab, idp->di_name);
+
+ if (soff == -1L)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+ if (soff > DIF_STROFF_MAX)
+ longjmp(pcb->pcb_jmpbuf, EDT_STR2BIG);
+
+ rp->dofr_name = (dof_stridx_t)soff;
+ rp->dofr_type = DOF_RELO_SETX;
+ rp->dofr_offset = DIF_INSTR_INTEGER(dip->di_instr) *
+ sizeof (uint64_t);
+ rp->dofr_data = 0;
+ }
+
+ assert(krp == dp->dtdo_kreltab + dp->dtdo_krelen);
+ assert(urp == dp->dtdo_ureltab + dp->dtdo_urelen);
+ assert(xlp == dp->dtdo_xlmtab + dp->dtdo_xlmlen);
+ assert(i == dp->dtdo_len);
+ }
+
+ /*
+ * Allocate memory for the compiled string table and then copy the
+ * chunks from the string table into the final string buffer.
+ */
+ if ((n = dt_strtab_size(pcb->pcb_strtab)) != 0) {
+ if ((dp->dtdo_strtab = dt_alloc(dtp, n)) == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) dt_strtab_write(pcb->pcb_strtab,
+ (dt_strtab_write_f *)dt_copystr, pcb);
+ dp->dtdo_strlen = (uint32_t)n;
+ }
+
+ /*
+ * Allocate memory for the compiled integer table and then copy the
+ * integer constants from the table into the final integer buffer.
+ */
+ if ((n = dt_inttab_size(pcb->pcb_inttab)) != 0) {
+ if ((dp->dtdo_inttab = dt_alloc(dtp,
+ n * sizeof (uint64_t))) == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dt_inttab_write(pcb->pcb_inttab, dp->dtdo_inttab);
+ dp->dtdo_intlen = (uint32_t)n;
+ }
+
+ /*
+ * Fill in the DIFO return type from the type associated with the
+ * node saved in pcb_dret, and then clear pcb_difo and pcb_dret
+ * now that the assembler has completed successfully.
+ */
+ dt_node_diftype(dtp, pcb->pcb_dret, &dp->dtdo_rtype);
+ pcb->pcb_difo = NULL;
+ pcb->pcb_dret = NULL;
+
+ if (pcb->pcb_cflags & DTRACE_C_DIFV)
+ dt_dis(dp, stderr);
+
+ return (dp);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.h
new file mode 100644
index 00000000..cb246402
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_as.h
@@ -0,0 +1,66 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_AS_H
+#define _DT_AS_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#endif
+#include <sys/dtrace.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dt_irnode {
+ uint_t di_label; /* label number or DT_LBL_NONE */
+ dif_instr_t di_instr; /* instruction opcode */
+ void *di_extern; /* opcode-specific external reference */
+ struct dt_irnode *di_next; /* next instruction */
+} dt_irnode_t;
+
+#define DT_LBL_NONE 0 /* no label on this instruction */
+
+typedef struct dt_irlist {
+ dt_irnode_t *dl_list; /* pointer to first node in list */
+ dt_irnode_t *dl_last; /* pointer to last node in list */
+ uint_t dl_len; /* number of valid instructions */
+ uint_t dl_label; /* next label number to assign */
+} dt_irlist_t;
+
+extern void dt_irlist_create(dt_irlist_t *);
+extern void dt_irlist_destroy(dt_irlist_t *);
+extern void dt_irlist_append(dt_irlist_t *, dt_irnode_t *);
+extern uint_t dt_irlist_label(dt_irlist_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_AS_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.c
new file mode 100644
index 00000000..e7b22bde
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.c
@@ -0,0 +1,181 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+/*
+ * DTrace Memory Buffer Routines
+ *
+ * The routines in this file are used to create an automatically resizing
+ * memory buffer that can be written to like a file. Memory buffers are
+ * used to construct DOF to ioctl() to dtrace(7D), and provide semantics that
+ * simplify caller code. Specifically, any allocation errors result in an
+ * error code being set inside the buffer which is maintained persistently and
+ * propagates to another buffer if the buffer in error is concatenated. These
+ * semantics permit callers to execute a large series of writes without needing
+ * to check for errors and then perform a single check before using the buffer.
+ */
+
+#ifndef VBOX
+#include <sys/sysmacros.h>
+#include <strings.h>
+#endif
+
+#include <dt_impl.h>
+#include <dt_buf.h>
+
+void
+dt_buf_create(dtrace_hdl_t *dtp, dt_buf_t *bp, const char *name, size_t len)
+{
+ if (len == 0)
+ len = _dtrace_bufsize;
+
+ bp->dbu_buf = bp->dbu_ptr = dt_zalloc(dtp, len);
+ bp->dbu_len = len;
+
+ if (bp->dbu_buf == NULL)
+ bp->dbu_err = dtrace_errno(dtp);
+ else
+ bp->dbu_err = 0;
+
+ bp->dbu_resizes = 0;
+ bp->dbu_name = name;
+}
+
+void
+dt_buf_destroy(dtrace_hdl_t *dtp, dt_buf_t *bp)
+{
+ dt_dprintf("dt_buf_destroy(%s): size=%lu resizes=%u\n",
+ bp->dbu_name, (ulong_t)bp->dbu_len, bp->dbu_resizes);
+
+ dt_free(dtp, bp->dbu_buf);
+}
+
+void
+dt_buf_reset(dtrace_hdl_t *dtp, dt_buf_t *bp)
+{
+ if ((bp->dbu_ptr = bp->dbu_buf) != NULL)
+ bp->dbu_err = 0;
+ else
+ dt_buf_create(dtp, bp, bp->dbu_name, bp->dbu_len);
+}
+
+void
+dt_buf_write(dtrace_hdl_t *dtp, dt_buf_t *bp,
+ const void *buf, size_t len, size_t align)
+{
+ size_t off = (size_t)(bp->dbu_ptr - bp->dbu_buf);
+ size_t adj = roundup(off, align) - off;
+
+ if (bp->dbu_err != 0) {
+ (void) dt_set_errno(dtp, bp->dbu_err);
+ return; /* write silently fails */
+ }
+
+ if (bp->dbu_ptr + adj + len > bp->dbu_buf + bp->dbu_len) {
+ size_t new_len = bp->dbu_len * 2;
+ uchar_t *new_buf;
+ uint_t r = 1;
+
+ while (bp->dbu_ptr + adj + len > bp->dbu_buf + new_len) {
+ new_len *= 2;
+ r++;
+ }
+
+ if ((new_buf = dt_zalloc(dtp, new_len)) == NULL) {
+ bp->dbu_err = dtrace_errno(dtp);
+ return;
+ }
+
+ bcopy(bp->dbu_buf, new_buf, off);
+ dt_free(dtp, bp->dbu_buf);
+
+ bp->dbu_buf = new_buf;
+ bp->dbu_ptr = new_buf + off;
+ bp->dbu_len = new_len;
+ bp->dbu_resizes += r;
+ }
+
+ bp->dbu_ptr += adj;
+ bcopy(buf, bp->dbu_ptr, len);
+ bp->dbu_ptr += len;
+}
+
+void
+dt_buf_concat(dtrace_hdl_t *dtp, dt_buf_t *dst,
+ const dt_buf_t *src, size_t align)
+{
+ if (dst->dbu_err == 0 && src->dbu_err != 0) {
+ (void) dt_set_errno(dtp, src->dbu_err);
+ dst->dbu_err = src->dbu_err;
+ } else {
+ dt_buf_write(dtp, dst, src->dbu_buf,
+ (size_t)(src->dbu_ptr - src->dbu_buf), align);
+ }
+}
+
+size_t
+dt_buf_offset(const dt_buf_t *bp, size_t align)
+{
+ size_t off = (size_t)(bp->dbu_ptr - bp->dbu_buf);
+ return (roundup(off, align));
+}
+
+size_t
+dt_buf_len(const dt_buf_t *bp)
+{
+ return (bp->dbu_ptr - bp->dbu_buf);
+}
+
+int
+dt_buf_error(const dt_buf_t *bp)
+{
+ return (bp->dbu_err);
+}
+
+void *
+dt_buf_ptr(const dt_buf_t *bp)
+{
+ return (bp->dbu_buf);
+}
+
+void *
+dt_buf_claim(dtrace_hdl_t *dtp, dt_buf_t *bp)
+{
+ void *buf = bp->dbu_buf;
+
+ if (bp->dbu_err != 0) {
+ dt_free(dtp, buf);
+ buf = NULL;
+ }
+
+ bp->dbu_buf = bp->dbu_ptr = NULL;
+ bp->dbu_len = 0;
+
+ return (buf);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.h
new file mode 100644
index 00000000..a8b465f8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_buf.h
@@ -0,0 +1,71 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_BUF_H
+#define _DT_BUF_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dtrace.h>
+
+typedef struct dt_buf {
+ const char *dbu_name; /* string name for debugging */
+ uchar_t *dbu_buf; /* buffer base address */
+ uchar_t *dbu_ptr; /* current buffer location */
+ size_t dbu_len; /* buffer size in bytes */
+ int dbu_err; /* errno value if error */
+ int dbu_resizes; /* number of resizes */
+} dt_buf_t;
+
+extern void dt_buf_create(dtrace_hdl_t *, dt_buf_t *, const char *, size_t);
+extern void dt_buf_destroy(dtrace_hdl_t *, dt_buf_t *);
+extern void dt_buf_reset(dtrace_hdl_t *, dt_buf_t *);
+
+extern void dt_buf_write(dtrace_hdl_t *, dt_buf_t *,
+ const void *, size_t, size_t);
+
+extern void dt_buf_concat(dtrace_hdl_t *, dt_buf_t *,
+ const dt_buf_t *, size_t);
+
+extern size_t dt_buf_offset(const dt_buf_t *, size_t);
+extern size_t dt_buf_len(const dt_buf_t *);
+
+extern int dt_buf_error(const dt_buf_t *);
+extern void *dt_buf_ptr(const dt_buf_t *);
+
+extern void *dt_buf_claim(dtrace_hdl_t *, dt_buf_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_BUF_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cc.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cc.c
new file mode 100644
index 00000000..5315d88d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cc.c
@@ -0,0 +1,2321 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * DTrace D Language Compiler
+ *
+ * The code in this source file implements the main engine for the D language
+ * compiler. The driver routine for the compiler is dt_compile(), below. The
+ * compiler operates on either stdio FILEs or in-memory strings as its input
+ * and can produce either dtrace_prog_t structures from a D program or a single
+ * dtrace_difo_t structure from a D expression. Multiple entry points are
+ * provided as wrappers around dt_compile() for the various input/output pairs.
+ * The compiler itself is implemented across the following source files:
+ *
+ * dt_lex.l - lex scanner
+ * dt_grammar.y - yacc grammar
+ * dt_parser.c - parse tree creation and semantic checking
+ * dt_decl.c - declaration stack processing
+ * dt_xlator.c - D translator lookup and creation
+ * dt_ident.c - identifier and symbol table routines
+ * dt_pragma.c - #pragma processing and D pragmas
+ * dt_printf.c - D printf() and printa() argument checking and processing
+ * dt_cc.c - compiler driver and dtrace_prog_t construction
+ * dt_cg.c - DIF code generator
+ * dt_as.c - DIF assembler
+ * dt_dof.c - dtrace_prog_t -> DOF conversion
+ *
+ * Several other source files provide collections of utility routines used by
+ * these major files. The compiler itself is implemented in multiple passes:
+ *
+ * (1) The input program is scanned and parsed by dt_lex.l and dt_grammar.y
+ * and parse tree nodes are constructed using the routines in dt_parser.c.
+ * This node construction pass is described further in dt_parser.c.
+ *
+ * (2) The parse tree is "cooked" by assigning each clause a context (see the
+ * routine dt_setcontext(), below) based on its probe description and then
+ * recursively descending the tree performing semantic checking. The cook
+ * routines are also implemented in dt_parser.c and described there.
+ *
+ * (3) For actions that are DIF expression statements, the DIF code generator
+ * and assembler are invoked to create a finished DIFO for the statement.
+ *
+ * (4) The dtrace_prog_t data structures for the program clauses and actions
+ * are built, containing pointers to any DIFOs created in step (3).
+ *
+ * (5) The caller invokes a routine in dt_dof.c to convert the finished program
+ * into DOF format for use in anonymous tracing or enabling in the kernel.
+ *
+ * In the implementation, steps 2-4 are intertwined in that they are performed
+ * in order for each clause as part of a loop that executes over the clauses.
+ *
+ * The D compiler currently implements nearly no optimization. The compiler
+ * implements integer constant folding as part of pass (1), and a set of very
+ * simple peephole optimizations as part of pass (3). As with any C compiler,
+ * a large number of optimizations are possible on both the intermediate data
+ * structures and the generated DIF code. These possibilities should be
+ * investigated in the context of whether they will have any substantive effect
+ * on the overall DTrace probe effect before they are undertaken.
+ */
+
+#ifndef VBOX
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <assert.h>
+#include <strings.h>
+#include <signal.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ucontext.h>
+#include <limits.h>
+#include <ctype.h>
+#include <dirent.h>
+#else /* VBOX */
+# include <ctype.h>
+# include <iprt/dir.h>
+# ifdef _MSC_VER
+# include <io.h>
+# else
+# include <unistd.h>
+# endif
+# if defined(RT_OS_WINDOWS) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+# ifdef _MSC_VER
+# define ftruncate64 _chsize
+# else
+# define ftruncate64 ftruncate
+# endif
+# define lseek64 lseek
+# endif
+#endif /* VBOX */
+#include <dt_module.h>
+#include <dt_program.h>
+#include <dt_provider.h>
+#include <dt_printf.h>
+#include <dt_pid.h>
+#include <dt_grammar.h>
+#include <dt_ident.h>
+#include <dt_string.h>
+#include <dt_impl.h>
+
+static const dtrace_diftype_t dt_void_rtype = {
+ DIF_TYPE_CTF, CTF_K_INTEGER, 0, 0, 0
+};
+
+static const dtrace_diftype_t dt_int_rtype = {
+ DIF_TYPE_CTF, CTF_K_INTEGER, 0, 0, sizeof (uint64_t)
+};
+
+static void *dt_compile(dtrace_hdl_t *, int, dtrace_probespec_t, void *,
+ uint_t, int, char *const[], FILE *, const char *);
+
+
+/*ARGSUSED*/
+static int
+dt_idreset(dt_idhash_t *dhp, dt_ident_t *idp, void *ignored)
+{
+ RT_NOREF2(dhp, ignored);
+ idp->di_flags &= ~(DT_IDFLG_REF | DT_IDFLG_MOD |
+ DT_IDFLG_DIFR | DT_IDFLG_DIFW);
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_idpragma(dt_idhash_t *dhp, dt_ident_t *idp, void *ignored)
+{
+ RT_NOREF2(dhp, ignored);
+ yylineno = idp->di_lineno;
+ xyerror(D_PRAGMA_UNUSED, "unused #pragma %s\n", (char *)idp->di_iarg);
+#ifndef _MSC_VER /* unreachable */
+ return (0);
+#endif
+}
+
+static dtrace_stmtdesc_t *
+dt_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp,
+ dtrace_attribute_t descattr, dtrace_attribute_t stmtattr)
+{
+ dtrace_stmtdesc_t *sdp = dtrace_stmt_create(dtp, edp);
+
+ if (sdp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ assert(yypcb->pcb_stmt == NULL);
+ yypcb->pcb_stmt = sdp;
+
+ sdp->dtsd_descattr = descattr;
+ sdp->dtsd_stmtattr = stmtattr;
+
+ return (sdp);
+}
+
+static dtrace_actdesc_t *
+dt_stmt_action(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *new;
+
+ if ((new = dtrace_stmt_action(dtp, sdp)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ return (new);
+}
+
+/*
+ * Utility function to determine if a given action description is destructive.
+ * The dtdo_destructive bit is set for us by the DIF assembler (see dt_as.c).
+ */
+static int
+dt_action_destructive(const dtrace_actdesc_t *ap)
+{
+ return (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind) || (ap->dtad_kind ==
+ DTRACEACT_DIFEXPR && ap->dtad_difo->dtdo_destructive));
+}
+
+static void
+dt_stmt_append(dtrace_stmtdesc_t *sdp, const dt_node_t *dnp)
+{
+ dtrace_ecbdesc_t *edp = sdp->dtsd_ecbdesc;
+ dtrace_actdesc_t *ap, *tap;
+ int commit = 0;
+ int speculate = 0;
+ int datarec = 0;
+
+ /*
+ * Make sure that the new statement jibes with the rest of the ECB.
+ */
+ for (ap = edp->dted_action; ap != NULL; ap = ap->dtad_next) {
+ if (ap->dtad_kind == DTRACEACT_COMMIT) {
+ if (commit) {
+ dnerror(dnp, D_COMM_COMM, "commit( ) may "
+ "not follow commit( )\n");
+ }
+
+ if (datarec) {
+ dnerror(dnp, D_COMM_DREC, "commit( ) may "
+ "not follow data-recording action(s)\n");
+ }
+
+ for (tap = ap; tap != NULL; tap = tap->dtad_next) {
+ if (!DTRACEACT_ISAGG(tap->dtad_kind))
+ continue;
+
+ dnerror(dnp, D_AGG_COMM, "aggregating actions "
+ "may not follow commit( )\n");
+ }
+
+ commit = 1;
+ continue;
+ }
+
+ if (ap->dtad_kind == DTRACEACT_SPECULATE) {
+ if (speculate) {
+ dnerror(dnp, D_SPEC_SPEC, "speculate( ) may "
+ "not follow speculate( )\n");
+ }
+
+ if (commit) {
+ dnerror(dnp, D_SPEC_COMM, "speculate( ) may "
+ "not follow commit( )\n");
+ }
+
+ if (datarec) {
+ dnerror(dnp, D_SPEC_DREC, "speculate( ) may "
+ "not follow data-recording action(s)\n");
+ }
+
+ speculate = 1;
+ continue;
+ }
+
+ if (DTRACEACT_ISAGG(ap->dtad_kind)) {
+ if (speculate) {
+ dnerror(dnp, D_AGG_SPEC, "aggregating actions "
+ "may not follow speculate( )\n");
+ }
+
+ datarec = 1;
+ continue;
+ }
+
+ if (speculate) {
+ if (dt_action_destructive(ap)) {
+ dnerror(dnp, D_ACT_SPEC, "destructive actions "
+ "may not follow speculate( )\n");
+ }
+
+ if (ap->dtad_kind == DTRACEACT_EXIT) {
+ dnerror(dnp, D_EXIT_SPEC, "exit( ) may not "
+ "follow speculate( )\n");
+ }
+ }
+
+ /*
+ * Exclude all non data-recording actions.
+ */
+ if (dt_action_destructive(ap) ||
+ ap->dtad_kind == DTRACEACT_DISCARD)
+ continue;
+
+ if (ap->dtad_kind == DTRACEACT_DIFEXPR &&
+ ap->dtad_difo->dtdo_rtype.dtdt_kind == DIF_TYPE_CTF &&
+ ap->dtad_difo->dtdo_rtype.dtdt_size == 0)
+ continue;
+
+ if (commit) {
+ dnerror(dnp, D_DREC_COMM, "data-recording actions "
+ "may not follow commit( )\n");
+ }
+
+ if (!speculate)
+ datarec = 1;
+ }
+
+ if (dtrace_stmt_add(yypcb->pcb_hdl, yypcb->pcb_prog, sdp) != 0)
+ longjmp(yypcb->pcb_jmpbuf, dtrace_errno(yypcb->pcb_hdl));
+
+ if (yypcb->pcb_stmt == sdp)
+ yypcb->pcb_stmt = NULL;
+}
+
+/*
+ * For the first element of an aggregation tuple or for printa(), we create a
+ * simple DIF program that simply returns the immediate value that is the ID
+ * of the aggregation itself. This could be optimized in the future by
+ * creating a new in-kernel dtad_kind that just returns an integer.
+ */
+static void
+dt_action_difconst(dtrace_actdesc_t *ap, uint_t id, dtrace_actkind_t kind)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dtrace_difo_t *dp = dt_zalloc(dtp, sizeof (dtrace_difo_t));
+
+ if (dp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dp->dtdo_buf = dt_alloc(dtp, sizeof (dif_instr_t) * 2);
+ dp->dtdo_inttab = dt_alloc(dtp, sizeof (uint64_t));
+
+ if (dp->dtdo_buf == NULL || dp->dtdo_inttab == NULL) {
+ dt_difo_free(dtp, dp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ dp->dtdo_buf[0] = DIF_INSTR_SETX(0, 1); /* setx DIF_INTEGER[0], %r1 */
+ dp->dtdo_buf[1] = DIF_INSTR_RET(1); /* ret %r1 */
+ dp->dtdo_len = 2;
+ dp->dtdo_inttab[0] = id;
+ dp->dtdo_intlen = 1;
+ dp->dtdo_rtype = dt_int_rtype;
+
+ ap->dtad_difo = dp;
+ ap->dtad_kind = kind;
+}
+
+static void
+dt_action_clear(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dt_ident_t *aid;
+ dtrace_actdesc_t *ap;
+ dt_node_t *anp;
+
+ char n[DT_TYPE_NAMELEN];
+ int argc = 0;
+
+ for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
+ argc++; /* count up arguments for error messages below */
+
+ if (argc != 1) {
+ dnerror(dnp, D_CLEAR_PROTO,
+ "%s( ) prototype mismatch: %d args passed, 1 expected\n",
+ dnp->dn_ident->di_name, argc);
+ }
+
+ anp = dnp->dn_args;
+ assert(anp != NULL);
+
+ if (anp->dn_kind != DT_NODE_AGG) {
+ dnerror(dnp, D_CLEAR_AGGARG,
+ "%s( ) argument #1 is incompatible with prototype:\n"
+ "\tprototype: aggregation\n\t argument: %s\n",
+ dnp->dn_ident->di_name,
+ dt_node_type_name(anp, n, sizeof (n)));
+ }
+
+ aid = anp->dn_ident;
+
+ if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
+ dnerror(dnp, D_CLEAR_AGGBAD,
+ "undefined aggregation: @%s\n", aid->di_name);
+ }
+
+ ap = dt_stmt_action(dtp, sdp);
+ dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
+ ap->dtad_arg = DT_ACT_CLEAR;
+}
+
+static void
+dt_action_normalize(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dt_ident_t *aid;
+ dtrace_actdesc_t *ap;
+ dt_node_t *anp, *normal;
+ int denormal = (strcmp(dnp->dn_ident->di_name, "denormalize") == 0);
+
+ char n[DT_TYPE_NAMELEN];
+ int argc = 0;
+
+ for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
+ argc++; /* count up arguments for error messages below */
+
+ if ((denormal && argc != 1) || (!denormal && argc != 2)) {
+ dnerror(dnp, D_NORMALIZE_PROTO,
+ "%s( ) prototype mismatch: %d args passed, %d expected\n",
+ dnp->dn_ident->di_name, argc, denormal ? 1 : 2);
+ }
+
+ anp = dnp->dn_args;
+ assert(anp != NULL);
+
+ if (anp->dn_kind != DT_NODE_AGG) {
+ dnerror(dnp, D_NORMALIZE_AGGARG,
+ "%s( ) argument #1 is incompatible with prototype:\n"
+ "\tprototype: aggregation\n\t argument: %s\n",
+ dnp->dn_ident->di_name,
+ dt_node_type_name(anp, n, sizeof (n)));
+ }
+
+ if ((normal = anp->dn_list) != NULL && !dt_node_is_scalar(normal)) {
+ dnerror(dnp, D_NORMALIZE_SCALAR,
+ "%s( ) argument #2 must be of scalar type\n",
+ dnp->dn_ident->di_name);
+ }
+
+ aid = anp->dn_ident;
+
+ if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
+ dnerror(dnp, D_NORMALIZE_AGGBAD,
+ "undefined aggregation: @%s\n", aid->di_name);
+ }
+
+ ap = dt_stmt_action(dtp, sdp);
+ dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
+
+ if (denormal) {
+ ap->dtad_arg = DT_ACT_DENORMALIZE;
+ return;
+ }
+
+ ap->dtad_arg = DT_ACT_NORMALIZE;
+
+ assert(normal != NULL);
+ ap = dt_stmt_action(dtp, sdp);
+ dt_cg(yypcb, normal);
+
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_LIBACT;
+ ap->dtad_arg = DT_ACT_NORMALIZE;
+}
+
+static void
+dt_action_trunc(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dt_ident_t *aid;
+ dtrace_actdesc_t *ap;
+ dt_node_t *anp, *trunc;
+
+ char n[DT_TYPE_NAMELEN];
+ int argc = 0;
+
+ for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
+ argc++; /* count up arguments for error messages below */
+
+ if (argc > 2 || argc < 1) {
+ dnerror(dnp, D_TRUNC_PROTO,
+ "%s( ) prototype mismatch: %d args passed, %s expected\n",
+ dnp->dn_ident->di_name, argc,
+ argc < 1 ? "at least 1" : "no more than 2");
+ }
+
+ anp = dnp->dn_args;
+ assert(anp != NULL);
+ trunc = anp->dn_list;
+
+ if (anp->dn_kind != DT_NODE_AGG) {
+ dnerror(dnp, D_TRUNC_AGGARG,
+ "%s( ) argument #1 is incompatible with prototype:\n"
+ "\tprototype: aggregation\n\t argument: %s\n",
+ dnp->dn_ident->di_name,
+ dt_node_type_name(anp, n, sizeof (n)));
+ }
+
+ if (argc == 2) {
+ assert(trunc != NULL);
+ if (!dt_node_is_scalar(trunc)) {
+ dnerror(dnp, D_TRUNC_SCALAR,
+ "%s( ) argument #2 must be of scalar type\n",
+ dnp->dn_ident->di_name);
+ }
+ }
+
+ aid = anp->dn_ident;
+
+ if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
+ dnerror(dnp, D_TRUNC_AGGBAD,
+ "undefined aggregation: @%s\n", aid->di_name);
+ }
+
+ ap = dt_stmt_action(dtp, sdp);
+ dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
+ ap->dtad_arg = DT_ACT_TRUNC;
+
+ ap = dt_stmt_action(dtp, sdp);
+
+ if (argc == 1) {
+ dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
+ } else {
+ assert(trunc != NULL);
+ dt_cg(yypcb, trunc);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_LIBACT;
+ }
+
+ ap->dtad_arg = DT_ACT_TRUNC;
+}
+
+static void
+dt_action_printa(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dt_ident_t *aid, *fid;
+ dtrace_actdesc_t *ap;
+ const char *format;
+ dt_node_t *anp, *proto = NULL;
+
+ char n[DT_TYPE_NAMELEN];
+ int argc = 0, argr = 0;
+
+ for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
+ argc++; /* count up arguments for error messages below */
+
+ switch (dnp->dn_args->dn_kind) {
+ case DT_NODE_STRING:
+ format = dnp->dn_args->dn_string;
+ anp = dnp->dn_args->dn_list;
+ argr = 2;
+ break;
+ case DT_NODE_AGG:
+ format = NULL;
+ anp = dnp->dn_args;
+ argr = 1;
+ break;
+ default:
+ format = NULL;
+ anp = dnp->dn_args;
+ argr = 1;
+ }
+
+ if (argc < argr) {
+ dnerror(dnp, D_PRINTA_PROTO,
+ "%s( ) prototype mismatch: %d args passed, %d expected\n",
+ dnp->dn_ident->di_name, argc, argr);
+ }
+
+ assert(anp != NULL);
+
+ while (anp != NULL) {
+ if (anp->dn_kind != DT_NODE_AGG) {
+ dnerror(dnp, D_PRINTA_AGGARG,
+ "%s( ) argument #%d is incompatible with "
+ "prototype:\n\tprototype: aggregation\n"
+ "\t argument: %s\n", dnp->dn_ident->di_name, argr,
+ dt_node_type_name(anp, n, sizeof (n)));
+ }
+
+ aid = anp->dn_ident;
+ fid = aid->di_iarg;
+
+ if (aid->di_gen == dtp->dt_gen &&
+ !(aid->di_flags & DT_IDFLG_MOD)) {
+ dnerror(dnp, D_PRINTA_AGGBAD,
+ "undefined aggregation: @%s\n", aid->di_name);
+ }
+
+ /*
+ * If we have multiple aggregations, we must be sure that
+ * their key signatures match.
+ */
+ if (proto != NULL) {
+ dt_printa_validate(proto, anp);
+ } else {
+ proto = anp;
+ }
+
+ if (format != NULL) {
+ yylineno = dnp->dn_line;
+
+ sdp->dtsd_fmtdata =
+ dt_printf_create(yypcb->pcb_hdl, format);
+ dt_printf_validate(sdp->dtsd_fmtdata,
+ DT_PRINTF_AGGREGATION, dnp->dn_ident, 1,
+ fid->di_id, ((dt_idsig_t *)aid->di_data)->dis_args);
+ format = NULL;
+ }
+
+ ap = dt_stmt_action(dtp, sdp);
+ dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_PRINTA);
+
+ anp = anp->dn_list;
+ argr++;
+ }
+}
+
+static void
+dt_action_printflike(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp,
+ dtrace_actkind_t kind)
+{
+ dt_node_t *anp, *arg1;
+ dtrace_actdesc_t *ap = NULL;
+ char n[DT_TYPE_NAMELEN], *str;
+
+ assert(DTRACEACT_ISPRINTFLIKE(kind));
+
+ if (dnp->dn_args->dn_kind != DT_NODE_STRING) {
+ dnerror(dnp, D_PRINTF_ARG_FMT,
+ "%s( ) argument #1 is incompatible with prototype:\n"
+ "\tprototype: string constant\n\t argument: %s\n",
+ dnp->dn_ident->di_name,
+ dt_node_type_name(dnp->dn_args, n, sizeof (n)));
+ }
+
+ arg1 = dnp->dn_args->dn_list;
+ yylineno = dnp->dn_line;
+ str = dnp->dn_args->dn_string;
+
+
+ /*
+ * If this is an freopen(), we use an empty string to denote that
+ * stdout should be restored. For other printf()-like actions, an
+ * empty format string is illegal: an empty format string would
+ * result in malformed DOF, and the compiler thus flags an empty
+ * format string as a compile-time error. To avoid propagating the
+ * freopen() special case throughout the system, we simply transpose
+ * an empty string into a sentinel string (DT_FREOPEN_RESTORE) that
+ * denotes that stdout should be restored.
+ */
+ if (kind == DTRACEACT_FREOPEN) {
+ if (strcmp(str, DT_FREOPEN_RESTORE) == 0) {
+ /*
+ * Our sentinel is always an invalid argument to
+ * freopen(), but if it's been manually specified, we
+ * must fail now instead of when the freopen() is
+ * actually evaluated.
+ */
+ dnerror(dnp, D_FREOPEN_INVALID,
+ "%s( ) argument #1 cannot be \"%s\"\n",
+ dnp->dn_ident->di_name, DT_FREOPEN_RESTORE);
+ }
+
+ if (str[0] == '\0')
+ str = DT_FREOPEN_RESTORE;
+ }
+
+ sdp->dtsd_fmtdata = dt_printf_create(dtp, str);
+
+ dt_printf_validate(sdp->dtsd_fmtdata, DT_PRINTF_EXACTLEN,
+ dnp->dn_ident, 1, DTRACEACT_AGGREGATION, arg1);
+
+ if (arg1 == NULL) {
+ dif_instr_t *dbuf;
+ dtrace_difo_t *dp;
+
+ if ((dbuf = dt_alloc(dtp, sizeof (dif_instr_t))) == NULL ||
+ (dp = dt_zalloc(dtp, sizeof (dtrace_difo_t))) == NULL) {
+ dt_free(dtp, dbuf);
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ dbuf[0] = DIF_INSTR_RET(DIF_REG_R0); /* ret %r0 */
+
+ dp->dtdo_buf = dbuf;
+ dp->dtdo_len = 1;
+ dp->dtdo_rtype = dt_int_rtype;
+
+ ap = dt_stmt_action(dtp, sdp);
+ ap->dtad_difo = dp;
+ ap->dtad_kind = kind;
+ return;
+ }
+
+ for (anp = arg1; anp != NULL; anp = anp->dn_list) {
+ ap = dt_stmt_action(dtp, sdp);
+ dt_cg(yypcb, anp);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = kind;
+ }
+}
+
+static void
+dt_action_trace(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ if (dt_node_is_void(dnp->dn_args)) {
+ dnerror(dnp->dn_args, D_TRACE_VOID,
+ "trace( ) may not be applied to a void expression\n");
+ }
+
+ if (dt_node_is_dynamic(dnp->dn_args)) {
+ dnerror(dnp->dn_args, D_TRACE_DYN,
+ "trace( ) may not be applied to a dynamic expression\n");
+ }
+
+ dt_cg(yypcb, dnp->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_DIFEXPR;
+}
+
+static void
+dt_action_tracemem(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_node_t *addr = dnp->dn_args;
+ dt_node_t *size = dnp->dn_args->dn_list;
+
+ char n[DT_TYPE_NAMELEN];
+
+ if (dt_node_is_integer(addr) == 0 && dt_node_is_pointer(addr) == 0) {
+ dnerror(addr, D_TRACEMEM_ADDR,
+ "tracemem( ) argument #1 is incompatible with "
+ "prototype:\n\tprototype: pointer or integer\n"
+ "\t argument: %s\n",
+ dt_node_type_name(addr, n, sizeof (n)));
+ }
+
+ if (dt_node_is_posconst(size) == 0) {
+ dnerror(size, D_TRACEMEM_SIZE, "tracemem( ) argument #2 must "
+ "be a non-zero positive integral constant expression\n");
+ }
+
+ dt_cg(yypcb, addr);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_DIFEXPR;
+
+ ap->dtad_difo->dtdo_rtype.dtdt_flags |= DIF_TF_BYREF;
+ ap->dtad_difo->dtdo_rtype.dtdt_size = size->dn_value;
+}
+
+static void
+dt_action_stack_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap, dt_node_t *arg0)
+{
+ ap->dtad_kind = DTRACEACT_STACK;
+
+ if (dtp->dt_options[DTRACEOPT_STACKFRAMES] != DTRACEOPT_UNSET) {
+ ap->dtad_arg = dtp->dt_options[DTRACEOPT_STACKFRAMES];
+ } else {
+ ap->dtad_arg = 0;
+ }
+
+ if (arg0 != NULL) {
+ if (arg0->dn_list != NULL) {
+ dnerror(arg0, D_STACK_PROTO, "stack( ) prototype "
+ "mismatch: too many arguments\n");
+ }
+
+ if (dt_node_is_posconst(arg0) == 0) {
+ dnerror(arg0, D_STACK_SIZE, "stack( ) size must be a "
+ "non-zero positive integral constant expression\n");
+ }
+
+ ap->dtad_arg = arg0->dn_value;
+ }
+}
+
+static void
+dt_action_stack(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ dt_action_stack_args(dtp, ap, dnp->dn_args);
+}
+
+static void
+dt_action_ustack_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap, dt_node_t *dnp)
+{
+ uint32_t nframes = 0;
+ uint32_t strsize = 0; /* default string table size */
+ dt_node_t *arg0 = dnp->dn_args;
+ dt_node_t *arg1 = arg0 != NULL ? arg0->dn_list : NULL;
+
+ assert(dnp->dn_ident->di_id == DT_ACT_JSTACK ||
+ dnp->dn_ident->di_id == DT_ACT_USTACK);
+
+ if (dnp->dn_ident->di_id == DT_ACT_JSTACK) {
+ if (dtp->dt_options[DTRACEOPT_JSTACKFRAMES] != DTRACEOPT_UNSET)
+ nframes = dtp->dt_options[DTRACEOPT_JSTACKFRAMES];
+
+ if (dtp->dt_options[DTRACEOPT_JSTACKSTRSIZE] != DTRACEOPT_UNSET)
+ strsize = dtp->dt_options[DTRACEOPT_JSTACKSTRSIZE];
+
+ ap->dtad_kind = DTRACEACT_JSTACK;
+ } else {
+ assert(dnp->dn_ident->di_id == DT_ACT_USTACK);
+
+ if (dtp->dt_options[DTRACEOPT_USTACKFRAMES] != DTRACEOPT_UNSET)
+ nframes = dtp->dt_options[DTRACEOPT_USTACKFRAMES];
+
+ ap->dtad_kind = DTRACEACT_USTACK;
+ }
+
+ if (arg0 != NULL) {
+ if (!dt_node_is_posconst(arg0)) {
+ dnerror(arg0, D_USTACK_FRAMES, "ustack( ) argument #1 "
+ "must be a non-zero positive integer constant\n");
+ }
+ nframes = (uint32_t)arg0->dn_value;
+ }
+
+ if (arg1 != NULL) {
+ if (arg1->dn_kind != DT_NODE_INT ||
+ ((arg1->dn_flags & DT_NF_SIGNED) &&
+ (int64_t)arg1->dn_value < 0)) {
+ dnerror(arg1, D_USTACK_STRSIZE, "ustack( ) argument #2 "
+ "must be a positive integer constant\n");
+ }
+
+ if (arg1->dn_list != NULL) {
+ dnerror(arg1, D_USTACK_PROTO, "ustack( ) prototype "
+ "mismatch: too many arguments\n");
+ }
+
+ strsize = (uint32_t)arg1->dn_value;
+ }
+
+ ap->dtad_arg = DTRACE_USTACK_ARG(nframes, strsize);
+}
+
+static void
+dt_action_ustack(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ dt_action_ustack_args(dtp, ap, dnp);
+}
+
+static void
+dt_action_setopt(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap;
+ dt_node_t *arg0, *arg1;
+
+ /*
+ * The prototype guarantees that we are called with either one or
+ * two arguments, and that any arguments that are present are strings.
+ */
+ arg0 = dnp->dn_args;
+ arg1 = arg0->dn_list;
+
+ ap = dt_stmt_action(dtp, sdp);
+ dt_cg(yypcb, arg0);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_LIBACT;
+ ap->dtad_arg = DT_ACT_SETOPT;
+
+ ap = dt_stmt_action(dtp, sdp);
+
+ if (arg1 == NULL) {
+ dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
+ } else {
+ dt_cg(yypcb, arg1);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_LIBACT;
+ }
+
+ ap->dtad_arg = DT_ACT_SETOPT;
+}
+
+/*ARGSUSED*/
+static void
+dt_action_symmod_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap,
+ dt_node_t *dnp, dtrace_actkind_t kind)
+{
+ RT_NOREF1(dtp);
+ assert(kind == DTRACEACT_SYM || kind == DTRACEACT_MOD ||
+ kind == DTRACEACT_USYM || kind == DTRACEACT_UMOD ||
+ kind == DTRACEACT_UADDR);
+
+ dt_cg(yypcb, dnp);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = kind;
+ ap->dtad_difo->dtdo_rtype.dtdt_size = sizeof (uint64_t);
+}
+
+static void
+dt_action_symmod(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp,
+ dtrace_actkind_t kind)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ dt_action_symmod_args(dtp, ap, dnp->dn_args, kind);
+}
+
+/*ARGSUSED*/
+static void
+dt_action_ftruncate(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ RT_NOREF1(dnp);
+
+ /*
+ * Library actions need a DIFO that serves as an argument. As
+ * ftruncate() doesn't take an argument, we generate the constant 0
+ * in a DIFO; this constant will be ignored when the ftruncate() is
+ * processed.
+ */
+ dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
+ ap->dtad_arg = DT_ACT_FTRUNCATE;
+}
+
+/*ARGSUSED*/
+static void
+dt_action_stop(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ RT_NOREF1(dnp);
+
+ ap->dtad_kind = DTRACEACT_STOP;
+ ap->dtad_arg = 0;
+}
+
+/*ARGSUSED*/
+static void
+dt_action_breakpoint(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ RT_NOREF1(dnp);
+
+ ap->dtad_kind = DTRACEACT_BREAKPOINT;
+ ap->dtad_arg = 0;
+}
+
+/*ARGSUSED*/
+static void
+dt_action_panic(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ RT_NOREF1(dnp);
+
+ ap->dtad_kind = DTRACEACT_PANIC;
+ ap->dtad_arg = 0;
+}
+
+static void
+dt_action_chill(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_cg(yypcb, dnp->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_CHILL;
+}
+
+static void
+dt_action_raise(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_cg(yypcb, dnp->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_RAISE;
+}
+
+static void
+dt_action_exit(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_cg(yypcb, dnp->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_EXIT;
+ ap->dtad_difo->dtdo_rtype.dtdt_size = sizeof (int);
+}
+
+static void
+dt_action_speculate(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_cg(yypcb, dnp->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_SPECULATE;
+}
+
+static void
+dt_action_commit(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_cg(yypcb, dnp->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_COMMIT;
+}
+
+static void
+dt_action_discard(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_cg(yypcb, dnp->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_DISCARD;
+}
+
+static void
+dt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ switch (dnp->dn_expr->dn_ident->di_id) {
+ case DT_ACT_BREAKPOINT:
+ dt_action_breakpoint(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_CHILL:
+ dt_action_chill(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_CLEAR:
+ dt_action_clear(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_COMMIT:
+ dt_action_commit(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_DENORMALIZE:
+ dt_action_normalize(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_DISCARD:
+ dt_action_discard(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_EXIT:
+ dt_action_exit(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_FREOPEN:
+ dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_FREOPEN);
+ break;
+ case DT_ACT_FTRUNCATE:
+ dt_action_ftruncate(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_MOD:
+ dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_MOD);
+ break;
+ case DT_ACT_NORMALIZE:
+ dt_action_normalize(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_PANIC:
+ dt_action_panic(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_PRINTA:
+ dt_action_printa(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_PRINTF:
+ dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_PRINTF);
+ break;
+ case DT_ACT_RAISE:
+ dt_action_raise(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_SETOPT:
+ dt_action_setopt(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_SPECULATE:
+ dt_action_speculate(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_STACK:
+ dt_action_stack(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_STOP:
+ dt_action_stop(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_SYM:
+ dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_SYM);
+ break;
+ case DT_ACT_SYSTEM:
+ dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_SYSTEM);
+ break;
+ case DT_ACT_TRACE:
+ dt_action_trace(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_TRACEMEM:
+ dt_action_tracemem(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_TRUNC:
+ dt_action_trunc(dtp, dnp->dn_expr, sdp);
+ break;
+ case DT_ACT_UADDR:
+ dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_UADDR);
+ break;
+ case DT_ACT_UMOD:
+ dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_UMOD);
+ break;
+ case DT_ACT_USYM:
+ dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_USYM);
+ break;
+ case DT_ACT_USTACK:
+ case DT_ACT_JSTACK:
+ dt_action_ustack(dtp, dnp->dn_expr, sdp);
+ break;
+ default:
+ dnerror(dnp->dn_expr, D_UNKNOWN, "tracing function %s( ) is "
+ "not yet supported\n", dnp->dn_expr->dn_ident->di_name);
+ }
+}
+
+static void
+dt_compile_exp(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+
+ dt_cg(yypcb, dnp->dn_expr);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_difo->dtdo_rtype = dt_void_rtype;
+ ap->dtad_kind = DTRACEACT_DIFEXPR;
+}
+
+static void
+dt_compile_agg(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
+{
+ dt_ident_t *aid, *fid;
+ dt_node_t *anp, *incr = NULL;
+ dtrace_actdesc_t *ap;
+ uint_t n = 1, argmax VBDTMSC(0);
+ uint64_t arg = 0;
+
+ /*
+ * If the aggregation has no aggregating function applied to it, then
+ * this statement has no effect. Flag this as a programming error.
+ */
+ if (dnp->dn_aggfun == NULL) {
+ dnerror(dnp, D_AGG_NULL, "expression has null effect: @%s\n",
+ dnp->dn_ident->di_name);
+ }
+
+ aid = dnp->dn_ident;
+ fid = dnp->dn_aggfun->dn_ident;
+
+ if (dnp->dn_aggfun->dn_args != NULL &&
+ dt_node_is_scalar(dnp->dn_aggfun->dn_args) == 0) {
+ dnerror(dnp->dn_aggfun, D_AGG_SCALAR, "%s( ) argument #1 must "
+ "be of scalar type\n", fid->di_name);
+ }
+
+ /*
+ * The ID of the aggregation itself is implicitly recorded as the first
+ * member of each aggregation tuple so we can distinguish them later.
+ */
+ ap = dt_stmt_action(dtp, sdp);
+ dt_action_difconst(ap, aid->di_id, DTRACEACT_DIFEXPR);
+
+ for (anp = dnp->dn_aggtup; anp != NULL; anp = anp->dn_list) {
+ ap = dt_stmt_action(dtp, sdp);
+ n++;
+
+ if (anp->dn_kind == DT_NODE_FUNC) {
+ if (anp->dn_ident->di_id == DT_ACT_STACK) {
+ dt_action_stack_args(dtp, ap, anp->dn_args);
+ continue;
+ }
+
+ if (anp->dn_ident->di_id == DT_ACT_USTACK ||
+ anp->dn_ident->di_id == DT_ACT_JSTACK) {
+ dt_action_ustack_args(dtp, ap, anp);
+ continue;
+ }
+
+ switch (anp->dn_ident->di_id) {
+ case DT_ACT_UADDR:
+ dt_action_symmod_args(dtp, ap,
+ anp->dn_args, DTRACEACT_UADDR);
+ continue;
+
+ case DT_ACT_USYM:
+ dt_action_symmod_args(dtp, ap,
+ anp->dn_args, DTRACEACT_USYM);
+ continue;
+
+ case DT_ACT_UMOD:
+ dt_action_symmod_args(dtp, ap,
+ anp->dn_args, DTRACEACT_UMOD);
+ continue;
+
+ case DT_ACT_SYM:
+ dt_action_symmod_args(dtp, ap,
+ anp->dn_args, DTRACEACT_SYM);
+ continue;
+
+ case DT_ACT_MOD:
+ dt_action_symmod_args(dtp, ap,
+ anp->dn_args, DTRACEACT_MOD);
+ continue;
+
+ default:
+ break;
+ }
+ }
+
+ dt_cg(yypcb, anp);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_kind = DTRACEACT_DIFEXPR;
+ }
+
+ if (fid->di_id == DTRACEAGG_LQUANTIZE) {
+ /*
+ * For linear quantization, we have between two and four
+ * arguments in addition to the expression:
+ *
+ * arg1 => Base value
+ * arg2 => Limit value
+ * arg3 => Quantization level step size (defaults to 1)
+ * arg4 => Quantization increment value (defaults to 1)
+ */
+ dt_node_t *arg1 = dnp->dn_aggfun->dn_args->dn_list;
+ dt_node_t *arg2 = arg1->dn_list;
+ dt_node_t *arg3 = arg2->dn_list;
+ dt_idsig_t *isp;
+ uint64_t nlevels, step = 1, oarg;
+ int64_t baseval, limitval;
+
+ if (arg1->dn_kind != DT_NODE_INT) {
+ dnerror(arg1, D_LQUANT_BASETYPE, "lquantize( ) "
+ "argument #1 must be an integer constant\n");
+ }
+
+ baseval = (int64_t)arg1->dn_value;
+
+ if (baseval < INT32_MIN || baseval > INT32_MAX) {
+ dnerror(arg1, D_LQUANT_BASEVAL, "lquantize( ) "
+ "argument #1 must be a 32-bit quantity\n");
+ }
+
+ if (arg2->dn_kind != DT_NODE_INT) {
+ dnerror(arg2, D_LQUANT_LIMTYPE, "lquantize( ) "
+ "argument #2 must be an integer constant\n");
+ }
+
+ limitval = (int64_t)arg2->dn_value;
+
+ if (limitval < INT32_MIN || limitval > INT32_MAX) {
+ dnerror(arg2, D_LQUANT_LIMVAL, "lquantize( ) "
+ "argument #2 must be a 32-bit quantity\n");
+ }
+
+ if (limitval < baseval) {
+ dnerror(dnp, D_LQUANT_MISMATCH,
+ "lquantize( ) base (argument #1) must be less "
+ "than limit (argument #2)\n");
+ }
+
+ if (arg3 != NULL) {
+ if (!dt_node_is_posconst(arg3)) {
+ dnerror(arg3, D_LQUANT_STEPTYPE, "lquantize( ) "
+ "argument #3 must be a non-zero positive "
+ "integer constant\n");
+ }
+
+ if ((step = arg3->dn_value) > UINT16_MAX) {
+ dnerror(arg3, D_LQUANT_STEPVAL, "lquantize( ) "
+ "argument #3 must be a 16-bit quantity\n");
+ }
+ }
+
+ nlevels = (limitval - baseval) / step;
+
+ if (nlevels == 0) {
+ dnerror(dnp, D_LQUANT_STEPLARGE,
+ "lquantize( ) step (argument #3) too large: must "
+ "have at least one quantization level\n");
+ }
+
+ if (nlevels > UINT16_MAX) {
+ dnerror(dnp, D_LQUANT_STEPSMALL, "lquantize( ) step "
+ "(argument #3) too small: number of quantization "
+ "levels must be a 16-bit quantity\n");
+ }
+
+ arg = (step << DTRACE_LQUANTIZE_STEPSHIFT) |
+ (nlevels << DTRACE_LQUANTIZE_LEVELSHIFT) |
+ ((baseval << DTRACE_LQUANTIZE_BASESHIFT) &
+ DTRACE_LQUANTIZE_BASEMASK);
+
+ assert(arg != 0);
+
+ isp = (dt_idsig_t *)aid->di_data;
+
+ if (isp->dis_auxinfo == 0) {
+ /*
+ * This is the first time we've seen an lquantize()
+ * for this aggregation; we'll store our argument
+ * as the auxiliary signature information.
+ */
+ isp->dis_auxinfo = arg;
+ } else if ((oarg = isp->dis_auxinfo) != arg) {
+ /*
+ * If we have seen this lquantize() before and the
+ * argument doesn't match the original argument, pick
+ * the original argument apart to concisely report the
+ * mismatch.
+ */
+ int obaseval = DTRACE_LQUANTIZE_BASE(oarg);
+ VBDTTYPE(unsigned,int) onlevels = DTRACE_LQUANTIZE_LEVELS(oarg);
+ VBDTTYPE(unsigned,int) ostep = DTRACE_LQUANTIZE_STEP(oarg);
+
+ if (obaseval != baseval) {
+ dnerror(dnp, D_LQUANT_MATCHBASE, "lquantize( ) "
+ "base (argument #1) doesn't match previous "
+ "declaration: expected %d, found %d\n",
+ obaseval, (int)baseval);
+ }
+
+ if (onlevels * ostep != nlevels * step) {
+ dnerror(dnp, D_LQUANT_MATCHLIM, "lquantize( ) "
+ "limit (argument #2) doesn't match previous"
+ " declaration: expected %d, found %d\n",
+ obaseval + onlevels * ostep,
+ (int)baseval + (int)nlevels * (int)step);
+ }
+
+ if (ostep != step) {
+ dnerror(dnp, D_LQUANT_MATCHSTEP, "lquantize( ) "
+ "step (argument #3) doesn't match previous "
+ "declaration: expected %d, found %d\n",
+ ostep, (int)step);
+ }
+
+ /*
+ * We shouldn't be able to get here -- one of the
+ * parameters must be mismatched if the arguments
+ * didn't match.
+ */
+ assert(0);
+ }
+
+ incr = arg3 != NULL ? arg3->dn_list : NULL;
+ argmax = 5;
+ }
+
+ if (fid->di_id == DTRACEAGG_QUANTIZE) {
+ incr = dnp->dn_aggfun->dn_args->dn_list;
+ argmax = 2;
+ }
+
+ if (incr != NULL) {
+ if (!dt_node_is_scalar(incr)) {
+ dnerror(dnp, D_PROTO_ARG, "%s( ) increment value "
+ "(argument #%d) must be of scalar type\n",
+ fid->di_name, argmax);
+ }
+
+ if ((anp = incr->dn_list) != NULL) {
+ int argc = argmax;
+
+ for (; anp != NULL; anp = anp->dn_list)
+ argc++;
+
+ dnerror(incr, D_PROTO_LEN, "%s( ) prototype "
+ "mismatch: %d args passed, at most %d expected",
+ fid->di_name, argc, argmax);
+ }
+
+ ap = dt_stmt_action(dtp, sdp);
+ n++;
+
+ dt_cg(yypcb, incr);
+ ap->dtad_difo = dt_as(yypcb);
+ ap->dtad_difo->dtdo_rtype = dt_void_rtype;
+ ap->dtad_kind = DTRACEACT_DIFEXPR;
+ }
+
+ assert(sdp->dtsd_aggdata == NULL);
+ sdp->dtsd_aggdata = aid;
+
+ ap = dt_stmt_action(dtp, sdp);
+ assert(fid->di_kind == DT_IDENT_AGGFUNC);
+ assert(DTRACEACT_ISAGG(fid->di_id));
+ ap->dtad_kind = fid->di_id;
+ ap->dtad_ntuple = n;
+ ap->dtad_arg = arg;
+
+ if (dnp->dn_aggfun->dn_args != NULL) {
+ dt_cg(yypcb, dnp->dn_aggfun->dn_args);
+ ap->dtad_difo = dt_as(yypcb);
+ }
+}
+
+static void
+dt_compile_one_clause(dtrace_hdl_t *dtp, dt_node_t *cnp, dt_node_t *pnp)
+{
+ dtrace_ecbdesc_t *edp;
+ dtrace_stmtdesc_t *sdp;
+ dt_node_t *dnp;
+
+ yylineno = pnp->dn_line;
+ dt_setcontext(dtp, pnp->dn_desc);
+ (void) dt_node_cook(cnp, DT_IDFLG_REF);
+
+ if (DT_TREEDUMP_PASS(dtp, 2))
+ dt_node_printr(cnp, stderr, 0);
+
+ if ((edp = dt_ecbdesc_create(dtp, pnp->dn_desc)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ assert(yypcb->pcb_ecbdesc == NULL);
+ yypcb->pcb_ecbdesc = edp;
+
+ if (cnp->dn_pred != NULL) {
+ dt_cg(yypcb, cnp->dn_pred);
+ edp->dted_pred.dtpdd_difo = dt_as(yypcb);
+ }
+
+ if (cnp->dn_acts == NULL) {
+ dt_stmt_append(dt_stmt_create(dtp, edp,
+ cnp->dn_ctxattr, _dtrace_defattr), cnp);
+ }
+
+ for (dnp = cnp->dn_acts; dnp != NULL; dnp = dnp->dn_list) {
+ assert(yypcb->pcb_stmt == NULL);
+ sdp = dt_stmt_create(dtp, edp, cnp->dn_ctxattr, cnp->dn_attr);
+
+ switch (dnp->dn_kind) {
+ case DT_NODE_DEXPR:
+ if (dnp->dn_expr->dn_kind == DT_NODE_AGG)
+ dt_compile_agg(dtp, dnp->dn_expr, sdp);
+ else
+ dt_compile_exp(dtp, dnp, sdp);
+ break;
+ case DT_NODE_DFUNC:
+ dt_compile_fun(dtp, dnp, sdp);
+ break;
+ case DT_NODE_AGG:
+ dt_compile_agg(dtp, dnp, sdp);
+ break;
+ default:
+ dnerror(dnp, D_UNKNOWN, "internal error -- node kind "
+ "%u is not a valid statement\n", dnp->dn_kind);
+ }
+
+ assert(yypcb->pcb_stmt == sdp);
+ dt_stmt_append(sdp, dnp);
+ }
+
+ assert(yypcb->pcb_ecbdesc == edp);
+ dt_ecbdesc_release(dtp, edp);
+ dt_endcontext(dtp);
+ yypcb->pcb_ecbdesc = NULL;
+}
+
+static void
+dt_compile_clause(dtrace_hdl_t *dtp, dt_node_t *cnp)
+{
+ dt_node_t *pnp;
+
+ for (pnp = cnp->dn_pdescs; pnp != NULL; pnp = pnp->dn_list)
+ dt_compile_one_clause(dtp, cnp, pnp);
+}
+
+static void
+dt_compile_xlator(dt_node_t *dnp)
+{
+ dt_xlator_t *dxp = dnp->dn_xlator;
+ dt_node_t *mnp;
+
+ for (mnp = dnp->dn_members; mnp != NULL; mnp = mnp->dn_list) {
+ assert(dxp->dx_membdif[mnp->dn_membid] == NULL);
+ dt_cg(yypcb, mnp);
+ dxp->dx_membdif[mnp->dn_membid] = dt_as(yypcb);
+ }
+}
+
+void
+dt_setcontext(dtrace_hdl_t *dtp, dtrace_probedesc_t *pdp)
+{
+ const dtrace_pattr_t *pap;
+ dt_probe_t *prp;
+#ifndef VBOX
+ dt_provider_t *pvp;
+#endif
+ dt_ident_t *idp;
+ char attrstr[8];
+ int err;
+
+#ifndef VBOX
+ /*
+ * Both kernel and pid based providers are allowed to have names
+ * ending with what could be interpreted as a number. We assume it's
+ * a pid and that we may need to dynamically create probes for
+ * that process if:
+ *
+ * (1) The provider doesn't exist, or,
+ * (2) The provider exists and has DTRACE_PRIV_PROC privilege.
+ *
+ * On an error, dt_pid_create_probes() will set the error message
+ * and tag -- we just have to longjmp() out of here.
+ */
+ if (isdigit(pdp->dtpd_provider[strlen(pdp->dtpd_provider) - 1]) &&
+ ((pvp = dt_provider_lookup(dtp, pdp->dtpd_provider)) == NULL ||
+ pvp->pv_desc.dtvd_priv.dtpp_flags & DTRACE_PRIV_PROC) &&
+ dt_pid_create_probes(pdp, dtp, yypcb) != 0) {
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+ }
+#endif
+
+ /*
+ * Call dt_probe_info() to get the probe arguments and attributes. If
+ * a representative probe is found, set 'pap' to the probe provider's
+ * attributes. Otherwise set 'pap' to default Unstable attributes.
+ */
+ if ((prp = dt_probe_info(dtp, pdp, &yypcb->pcb_pinfo)) == NULL) {
+ pap = &_dtrace_prvdesc;
+ err = dtrace_errno(dtp);
+ bzero(&yypcb->pcb_pinfo, sizeof (dtrace_probeinfo_t));
+ yypcb->pcb_pinfo.dtp_attr = pap->dtpa_provider;
+ yypcb->pcb_pinfo.dtp_arga = pap->dtpa_args;
+ } else {
+ pap = &prp->pr_pvp->pv_desc.dtvd_attr;
+ err = 0;
+ }
+
+ if (err == EDT_NOPROBE && !(yypcb->pcb_cflags & DTRACE_C_ZDEFS)) {
+ xyerror(D_PDESC_ZERO, "probe description %s:%s:%s:%s does not "
+ "match any probes\n", pdp->dtpd_provider, pdp->dtpd_mod,
+ pdp->dtpd_func, pdp->dtpd_name);
+ }
+
+ if (err != EDT_NOPROBE && err != EDT_UNSTABLE && err != 0)
+ xyerror(D_PDESC_INVAL, "%s\n", dtrace_errmsg(dtp, err));
+
+ dt_dprintf("set context to %s:%s:%s:%s [%u] prp=%p attr=%s argc=%d\n",
+ pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name,
+ pdp->dtpd_id, (void *)prp, dt_attr_str(yypcb->pcb_pinfo.dtp_attr,
+ attrstr, sizeof (attrstr)), yypcb->pcb_pinfo.dtp_argc);
+
+ /*
+ * Reset the stability attributes of D global variables that vary
+ * based on the attributes of the provider and context itself.
+ */
+ if ((idp = dt_idhash_lookup(dtp->dt_globals, "probeprov")) != NULL)
+ idp->di_attr = pap->dtpa_provider;
+ if ((idp = dt_idhash_lookup(dtp->dt_globals, "probemod")) != NULL)
+ idp->di_attr = pap->dtpa_mod;
+ if ((idp = dt_idhash_lookup(dtp->dt_globals, "probefunc")) != NULL)
+ idp->di_attr = pap->dtpa_func;
+ if ((idp = dt_idhash_lookup(dtp->dt_globals, "probename")) != NULL)
+ idp->di_attr = pap->dtpa_name;
+ if ((idp = dt_idhash_lookup(dtp->dt_globals, "args")) != NULL)
+ idp->di_attr = pap->dtpa_args;
+
+ yypcb->pcb_pdesc = pdp;
+ yypcb->pcb_probe = prp;
+}
+
+/*
+ * Reset context-dependent variables and state at the end of cooking a D probe
+ * definition clause. This ensures that external declarations between clauses
+ * do not reference any stale context-dependent data from the previous clause.
+ */
+void
+dt_endcontext(dtrace_hdl_t *dtp)
+{
+ static const char *const cvars[] = {
+ "probeprov", "probemod", "probefunc", "probename", "args", NULL
+ };
+
+ dt_ident_t *idp;
+ int i;
+
+ for (i = 0; cvars[i] != NULL; i++) {
+ if ((idp = dt_idhash_lookup(dtp->dt_globals, cvars[i])) != NULL)
+ idp->di_attr = _dtrace_defattr;
+ }
+
+ yypcb->pcb_pdesc = NULL;
+ yypcb->pcb_probe = NULL;
+}
+
+static int
+dt_reduceid(dt_idhash_t *dhp, dt_ident_t *idp, dtrace_hdl_t *dtp)
+{
+ if (idp->di_vers != 0 && idp->di_vers > dtp->dt_vmax)
+ dt_idhash_delete(dhp, idp);
+
+ return (0);
+}
+
+/*
+ * When dtrace_setopt() is called for "version", it calls dt_reduce() to remove
+ * any identifiers or translators that have been previously defined as bound to
+ * a version greater than the specified version. Therefore, in our current
+ * version implementation, establishing a binding is a one-way transformation.
+ * In addition, no versioning is currently provided for types as our .d library
+ * files do not define any types and we reserve prefixes DTRACE_ and dtrace_
+ * for our exclusive use. If required, type versioning will require more work.
+ */
+int
+dt_reduce(dtrace_hdl_t *dtp, dt_version_t v)
+{
+ char s[DT_VERSION_STRMAX];
+ dt_xlator_t *dxp, *nxp;
+
+ if (v > dtp->dt_vmax)
+ return (dt_set_errno(dtp, EDT_VERSREDUCED));
+ else if (v == dtp->dt_vmax)
+ return (0); /* no reduction necessary */
+
+ dt_dprintf("reducing api version to %s\n",
+ dt_version_num2str(v, s, sizeof (s)));
+
+ dtp->dt_vmax = v;
+
+ for (dxp = dt_list_next(&dtp->dt_xlators); dxp != NULL; dxp = nxp) {
+ nxp = dt_list_next(dxp);
+ if ((dxp->dx_souid.di_vers != 0 && dxp->dx_souid.di_vers > v) ||
+ (dxp->dx_ptrid.di_vers != 0 && dxp->dx_ptrid.di_vers > v))
+ dt_list_delete(&dtp->dt_xlators, dxp);
+ }
+
+ (void) dt_idhash_iter(dtp->dt_macros, (dt_idhash_f *)dt_reduceid, dtp);
+ (void) dt_idhash_iter(dtp->dt_aggs, (dt_idhash_f *)dt_reduceid, dtp);
+ (void) dt_idhash_iter(dtp->dt_globals, (dt_idhash_f *)dt_reduceid, dtp);
+ (void) dt_idhash_iter(dtp->dt_tls, (dt_idhash_f *)dt_reduceid, dtp);
+
+ return (0);
+}
+
+/*
+ * Fork and exec the cpp(1) preprocessor to run over the specified input file,
+ * and return a FILE handle for the cpp output. We use the /dev/fd filesystem
+ * here to simplify the code by leveraging file descriptor inheritance.
+ */
+static FILE *
+dt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
+{
+#ifndef VBOX
+ int argc = dtp->dt_cpp_argc;
+ char **argv = malloc(sizeof (char *) * (argc + 5));
+ FILE *ofp = tmpfile();
+
+ char ipath[20], opath[20]; /* big enough for /dev/fd/ + INT_MAX + \0 */
+ char verdef[32]; /* big enough for -D__SUNW_D_VERSION=0x%08x + \0 */
+
+ struct sigaction act, oact;
+ sigset_t mask, omask;
+
+ int wstat, estat;
+ pid_t pid;
+ off64_t off;
+ int c;
+
+ if (argv == NULL || ofp == NULL) {
+ (void) dt_set_errno(dtp, errno);
+ goto err;
+ }
+
+ /*
+ * If the input is a seekable file, see if it is an interpreter file.
+ * If we see #!, seek past the first line because cpp will choke on it.
+ * We start cpp just prior to the \n at the end of this line so that
+ * it still sees the newline, ensuring that #line values are correct.
+ */
+ if (isatty(fileno(ifp)) == 0 && (off = ftello64(ifp)) != -1) {
+ if ((c = fgetc(ifp)) == '#' && (c = fgetc(ifp)) == '!') {
+ for (off += 2; c != '\n'; off++) {
+ if ((c = fgetc(ifp)) == EOF)
+ break;
+ }
+ if (c == '\n')
+ off--; /* start cpp just prior to \n */
+ }
+ (void) fflush(ifp);
+ (void) fseeko64(ifp, off, SEEK_SET);
+ }
+
+ (void) snprintf(ipath, sizeof (ipath), "/dev/fd/%d", fileno(ifp));
+ (void) snprintf(opath, sizeof (opath), "/dev/fd/%d", fileno(ofp));
+
+ bcopy(dtp->dt_cpp_argv, argv, sizeof (char *) * argc);
+
+ (void) snprintf(verdef, sizeof (verdef),
+ "-D__SUNW_D_VERSION=0x%08x", dtp->dt_vmax);
+ argv[argc++] = verdef;
+
+ switch (dtp->dt_stdcmode) {
+ case DT_STDC_XA:
+ case DT_STDC_XT:
+ argv[argc++] = "-D__STDC__=0";
+ break;
+ case DT_STDC_XC:
+ argv[argc++] = "-D__STDC__=1";
+ break;
+ }
+
+ argv[argc++] = ipath;
+ argv[argc++] = opath;
+ argv[argc] = NULL;
+
+ /*
+ * libdtrace must be able to be embedded in other programs that may
+ * include application-specific signal handlers. Therefore, if we
+ * need to fork to run cpp(1), we must avoid generating a SIGCHLD
+ * that could confuse the containing application. To do this,
+ * we block SIGCHLD and reset its disposition to SIG_DFL.
+ * We restore our signal state once we are done.
+ */
+ (void) sigemptyset(&mask);
+ (void) sigaddset(&mask, SIGCHLD);
+ (void) sigprocmask(SIG_BLOCK, &mask, &omask);
+
+ bzero(&act, sizeof (act));
+ act.sa_handler = SIG_DFL;
+ (void) sigaction(SIGCHLD, &act, &oact);
+
+ if ((pid = fork1()) == -1) {
+ (void) sigaction(SIGCHLD, &oact, NULL);
+ (void) sigprocmask(SIG_SETMASK, &omask, NULL);
+ (void) dt_set_errno(dtp, EDT_CPPFORK);
+ goto err;
+ }
+
+ if (pid == 0) {
+ (void) execvp(dtp->dt_cpp_path, argv);
+ _exit(errno == ENOENT ? 127 : 126);
+ }
+
+ do {
+ dt_dprintf("waiting for %s (PID %d)\n", dtp->dt_cpp_path,
+ (int)pid);
+ } while (waitpid(pid, &wstat, 0) == -1 && errno == EINTR);
+
+ (void) sigaction(SIGCHLD, &oact, NULL);
+ (void) sigprocmask(SIG_SETMASK, &omask, NULL);
+
+ dt_dprintf("%s returned exit status 0x%x\n", dtp->dt_cpp_path, wstat);
+ estat = WIFEXITED(wstat) ? WEXITSTATUS(wstat) : -1;
+
+ if (estat != 0) {
+ switch (estat) {
+ case 126:
+ (void) dt_set_errno(dtp, EDT_CPPEXEC);
+ break;
+ case 127:
+ (void) dt_set_errno(dtp, EDT_CPPENT);
+ break;
+ default:
+ (void) dt_set_errno(dtp, EDT_CPPERR);
+ }
+ goto err;
+ }
+
+ free(argv);
+ (void) fflush(ofp);
+ (void) fseek(ofp, 0, SEEK_SET);
+ return (ofp);
+
+err:
+ free(argv);
+ (void) fclose(ofp);
+ return (NULL);
+
+#else /* VBOX */
+ RT_NOREF1(ifp);
+ (void) dt_set_errno(dtp, EDT_CPPERR);
+ return (NULL);
+#endif /* VBOX */
+}
+
+static void
+dt_lib_depend_error(dtrace_hdl_t *dtp, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ dt_set_errmsg(dtp, NULL, NULL, NULL, 0, format, ap);
+ va_end(ap);
+}
+
+int
+dt_lib_depend_add(dtrace_hdl_t *dtp, dt_list_t *dlp, const char *arg)
+{
+ dt_lib_depend_t *dld;
+ const char *end;
+
+ assert(arg != NULL);
+
+ if ((end = strrchr(arg, '/')) == NULL)
+ return (dt_set_errno(dtp, EINVAL));
+
+ if ((dld = dt_zalloc(dtp, sizeof (dt_lib_depend_t))) == NULL)
+ return (-1);
+
+ if ((dld->dtld_libpath = dt_alloc(dtp, MAXPATHLEN)) == NULL) {
+ dt_free(dtp, dld);
+ return (-1);
+ }
+
+ (void) strlcpy(dld->dtld_libpath, arg, end - arg + 2);
+ if ((dld->dtld_library = strdup(arg)) == NULL) {
+ dt_free(dtp, dld->dtld_libpath);
+ dt_free(dtp, dld);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ dt_list_append(dlp, dld);
+ return (0);
+}
+
+dt_lib_depend_t *
+dt_lib_depend_lookup(dt_list_t *dld, const char *arg)
+{
+ dt_lib_depend_t *dldn;
+
+ for (dldn = dt_list_next(dld); dldn != NULL;
+ dldn = dt_list_next(dldn)) {
+ if (strcmp(dldn->dtld_library, arg) == 0)
+ return (dldn);
+ }
+
+ return (NULL);
+}
+
+/*
+ * Go through all the library files, and, if any library dependencies exist for
+ * that file, add it to that node's list of dependents. The result of this
+ * will be a graph which can then be topologically sorted to produce a
+ * compilation order.
+ */
+static int
+dt_lib_build_graph(dtrace_hdl_t *dtp)
+{
+ dt_lib_depend_t *dld, *dpld;
+
+ for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
+ dld = dt_list_next(dld)) {
+ char *library = dld->dtld_library;
+
+ for (dpld = dt_list_next(&dld->dtld_dependencies); dpld != NULL;
+ dpld = dt_list_next(dpld)) {
+ dt_lib_depend_t *dlda;
+
+ if ((dlda = dt_lib_depend_lookup(&dtp->dt_lib_dep,
+ dpld->dtld_library)) == NULL) {
+ dt_lib_depend_error(dtp,
+ "Invalid library dependency in %s: %s\n",
+ dld->dtld_library, dpld->dtld_library);
+
+ return (dt_set_errno(dtp, EDT_COMPILER));
+ }
+
+ if ((dt_lib_depend_add(dtp, &dlda->dtld_dependents,
+ library)) != 0) {
+ return (-1); /* preserve dt_errno */
+ }
+ }
+ }
+ return (0);
+}
+
+static int
+dt_topo_sort(dtrace_hdl_t *dtp, dt_lib_depend_t *dld, int *count)
+{
+ dt_lib_depend_t *dpld, *dlda, *new;
+
+ dld->dtld_start = ++(*count);
+
+ for (dpld = dt_list_next(&dld->dtld_dependents); dpld != NULL;
+ dpld = dt_list_next(dpld)) {
+ dlda = dt_lib_depend_lookup(&dtp->dt_lib_dep,
+ dpld->dtld_library);
+ assert(dlda != NULL);
+
+ if (dlda->dtld_start == 0 &&
+ dt_topo_sort(dtp, dlda, count) == -1)
+ return (-1);
+ }
+
+ if ((new = dt_zalloc(dtp, sizeof (dt_lib_depend_t))) == NULL)
+ return (-1);
+
+ if ((new->dtld_library = strdup(dld->dtld_library)) == NULL) {
+ dt_free(dtp, new);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ new->dtld_start = dld->dtld_start;
+ new->dtld_finish = dld->dtld_finish = ++(*count);
+ dt_list_prepend(&dtp->dt_lib_dep_sorted, new);
+
+ dt_dprintf("library %s sorted (%d/%d)\n", new->dtld_library,
+ new->dtld_start, new->dtld_finish);
+
+ return (0);
+}
+
+static int
+dt_lib_depend_sort(dtrace_hdl_t *dtp)
+{
+ dt_lib_depend_t *dld, *dpld, *dlda;
+ int count = 0;
+
+ if (dt_lib_build_graph(dtp) == -1)
+ return (-1); /* preserve dt_errno */
+
+ /*
+ * Perform a topological sort of the graph that hangs off
+ * dtp->dt_lib_dep. The result of this process will be a
+ * dependency ordered list located at dtp->dt_lib_dep_sorted.
+ */
+ for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
+ dld = dt_list_next(dld)) {
+ if (dld->dtld_start == 0 &&
+ dt_topo_sort(dtp, dld, &count) == -1)
+ return (-1); /* preserve dt_errno */;
+ }
+
+ /*
+ * Check the graph for cycles. If an ancestor's finishing time is
+ * less than any of its dependent's finishing times then a back edge
+ * exists in the graph and this is a cycle.
+ */
+ for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
+ dld = dt_list_next(dld)) {
+ for (dpld = dt_list_next(&dld->dtld_dependents); dpld != NULL;
+ dpld = dt_list_next(dpld)) {
+ dlda = dt_lib_depend_lookup(&dtp->dt_lib_dep_sorted,
+ dpld->dtld_library);
+ assert(dlda != NULL);
+
+ if (dlda->dtld_finish > dld->dtld_finish) {
+ dt_lib_depend_error(dtp,
+ "Cyclic dependency detected: %s => %s\n",
+ dld->dtld_library, dpld->dtld_library);
+
+ return (dt_set_errno(dtp, EDT_COMPILER));
+ }
+ }
+ }
+
+ return (0);
+}
+
+static void
+dt_lib_depend_free(dtrace_hdl_t *dtp)
+{
+ dt_lib_depend_t *dld, *dlda;
+
+ while ((dld = dt_list_next(&dtp->dt_lib_dep)) != NULL) {
+ while ((dlda = dt_list_next(&dld->dtld_dependencies)) != NULL) {
+ dt_list_delete(&dld->dtld_dependencies, dlda);
+ dt_free(dtp, dlda->dtld_library);
+ dt_free(dtp, dlda->dtld_libpath);
+ dt_free(dtp, dlda);
+ }
+ while ((dlda = dt_list_next(&dld->dtld_dependents)) != NULL) {
+ dt_list_delete(&dld->dtld_dependents, dlda);
+ dt_free(dtp, dlda->dtld_library);
+ dt_free(dtp, dlda->dtld_libpath);
+ dt_free(dtp, dlda);
+ }
+ dt_list_delete(&dtp->dt_lib_dep, dld);
+ dt_free(dtp, dld->dtld_library);
+ dt_free(dtp, dld->dtld_libpath);
+ dt_free(dtp, dld);
+ }
+
+ while ((dld = dt_list_next(&dtp->dt_lib_dep_sorted)) != NULL) {
+ dt_list_delete(&dtp->dt_lib_dep_sorted, dld);
+ dt_free(dtp, dld->dtld_library);
+ dt_free(dtp, dld);
+ }
+}
+
+
+/*
+ * Open all of the .d library files found in the specified directory and
+ * compile each one in topological order to cache its inlines and translators,
+ * etc. We silently ignore any missing directories and other files found
+ * therein. We only fail (and thereby fail dt_load_libs()) if we fail to
+ * compile a library and the error is something other than #pragma D depends_on.
+ * Dependency errors are silently ignored to permit a library directory to
+ * contain libraries which may not be accessible depending on our privileges.
+ */
+static int
+dt_load_libs_dir(dtrace_hdl_t *dtp, const char *path)
+{
+#ifndef VBOX
+ struct dirent *dp;
+ const char *p;
+ DIR *dirp;
+#else
+ RTDIR hDir;
+ RTDIRENTRY DirEntry;
+ const char *p;
+ int rc;
+#endif
+
+ char fname[PATH_MAX];
+ dtrace_prog_t *pgp;
+ FILE *fp;
+ void *rv;
+ dt_lib_depend_t *dld;
+
+#ifndef VBOX
+ if ((dirp = opendir(path)) == NULL) {
+ dt_dprintf("skipping lib dir %s: %s\n", path, strerror(errno));
+ return (0);
+ }
+#else
+ rc = RTDirOpen(&hDir, path);
+ if (RT_FAILURE(rc)) {
+ char szTmp[160];
+ RTErrQueryMsgShort(rc, szTmp, sizeof(szTmp), false /*fFaileIfUnknown*/);
+ dt_dprintf("skipping lib dir %s: %s\n", path, szTmp);
+ return (0);
+ }
+#endif
+
+ /* First, parse each file for library dependencies. */
+#ifndef VBOX
+ while ((dp = readdir(dirp)) != NULL) {
+#else
+ while (RT_SUCCESS(RTDirRead(hDir, &DirEntry, 0))) {
+ struct FakeDirEntry {
+ const char *d_name;
+ } FakeDirEntry, *dp = &FakeDirEntry;
+ FakeDirEntry.d_name = DirEntry.szName;
+#endif
+ if ((p = strrchr(dp->d_name, '.')) == NULL || strcmp(p, ".d"))
+ continue; /* skip any filename not ending in .d */
+
+ (void) snprintf(fname, sizeof (fname),
+ "%s/%s", path, dp->d_name);
+
+ if ((fp = fopen(fname, "r")) == NULL) {
+ dt_dprintf("skipping library %s: %s\n",
+ fname, strerror(errno));
+ continue;
+ }
+
+ dtp->dt_filetag = fname;
+ if (dt_lib_depend_add(dtp, &dtp->dt_lib_dep, fname) != 0)
+ goto err;
+
+ rv = dt_compile(dtp, DT_CTX_DPROG,
+ DTRACE_PROBESPEC_NAME, NULL,
+ DTRACE_C_EMPTY | DTRACE_C_CTL, 0, NULL, fp, NULL);
+
+ if (rv != NULL && dtp->dt_errno &&
+ (dtp->dt_errno != EDT_COMPILER ||
+ dtp->dt_errtag != dt_errtag(D_PRAGMA_DEPEND)))
+ goto err;
+
+ if (dtp->dt_errno)
+ dt_dprintf("error parsing library %s: %s\n",
+ fname, dtrace_errmsg(dtp, dtrace_errno(dtp)));
+
+ (void) fclose(fp);
+ dtp->dt_filetag = NULL;
+ }
+
+#ifndef VBOX
+ (void) closedir(dirp);
+#else
+ RTDirClose(hDir);
+#endif
+ /*
+ * Finish building the graph containing the library dependencies
+ * and perform a topological sort to generate an ordered list
+ * for compilation.
+ */
+ if (dt_lib_depend_sort(dtp) == -1)
+ goto err;
+
+ for (dld = dt_list_next(&dtp->dt_lib_dep_sorted); dld != NULL;
+ dld = dt_list_next(dld)) {
+
+ if ((fp = fopen(dld->dtld_library, "r")) == NULL) {
+ dt_dprintf("skipping library %s: %s\n",
+ dld->dtld_library, strerror(errno));
+ continue;
+ }
+
+ dtp->dt_filetag = dld->dtld_library;
+ pgp = dtrace_program_fcompile(dtp, fp, DTRACE_C_EMPTY, 0, NULL);
+ (void) fclose(fp);
+ dtp->dt_filetag = NULL;
+
+ if (pgp == NULL && (dtp->dt_errno != EDT_COMPILER ||
+ dtp->dt_errtag != dt_errtag(D_PRAGMA_DEPEND)))
+ goto err;
+
+ if (pgp == NULL) {
+ dt_dprintf("skipping library %s: %s\n",
+ dld->dtld_library,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ } else {
+ dld->dtld_loaded = B_TRUE;
+ dt_program_destroy(dtp, pgp);
+ }
+ }
+
+ dt_lib_depend_free(dtp);
+ return (0);
+
+err:
+ dt_lib_depend_free(dtp);
+ return (-1); /* preserve dt_errno */
+}
+
+/*
+ * Load the contents of any appropriate DTrace .d library files. These files
+ * contain inlines and translators that will be cached by the compiler. We
+ * defer this activity until the first compile to permit libdtrace clients to
+ * add their own library directories and so that we can properly report errors.
+ */
+static int
+dt_load_libs(dtrace_hdl_t *dtp)
+{
+ dt_dirpath_t *dirp;
+
+ if (dtp->dt_cflags & DTRACE_C_NOLIBS)
+ return (0); /* libraries already processed */
+
+ dtp->dt_cflags |= DTRACE_C_NOLIBS;
+
+ for (dirp = dt_list_next(&dtp->dt_lib_path);
+ dirp != NULL; dirp = dt_list_next(dirp)) {
+ if (dt_load_libs_dir(dtp, dirp->dir_path) != 0) {
+ dtp->dt_cflags &= ~DTRACE_C_NOLIBS;
+ return (-1); /* errno is set for us */
+ }
+ }
+
+ return (0);
+}
+
+static void *
+dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg,
+ uint_t cflags, int argc, char *const argv[], FILE *fp, const char *s)
+{
+ dt_node_t *dnp;
+ dt_decl_t *ddp;
+ dt_pcb_t pcb;
+ void *rv;
+ int err;
+
+ if ((fp == NULL && s == NULL) || (cflags & ~DTRACE_C_MASK) != 0) {
+ (void) dt_set_errno(dtp, EINVAL);
+ return (NULL);
+ }
+
+ if (dt_list_next(&dtp->dt_lib_path) != NULL && dt_load_libs(dtp) != 0)
+ return (NULL); /* errno is set for us */
+
+ if (dtp->dt_globals->dh_nelems != 0)
+ (void) dt_idhash_iter(dtp->dt_globals, dt_idreset, NULL);
+
+ if (dtp->dt_tls->dh_nelems != 0)
+ (void) dt_idhash_iter(dtp->dt_tls, dt_idreset, NULL);
+
+ if (fp && (cflags & DTRACE_C_CPP) && (fp = dt_preproc(dtp, fp)) == NULL)
+ return (NULL); /* errno is set for us */
+
+ dt_pcb_push(dtp, &pcb);
+
+ pcb.pcb_fileptr = fp;
+ pcb.pcb_string = s;
+ pcb.pcb_strptr = s;
+ pcb.pcb_strlen = s ? strlen(s) : 0;
+ pcb.pcb_sargc = argc;
+ pcb.pcb_sargv = argv;
+ pcb.pcb_sflagv = argc ? calloc(argc, sizeof (ushort_t)) : NULL;
+ pcb.pcb_pspec = pspec;
+ pcb.pcb_cflags = dtp->dt_cflags | cflags;
+ pcb.pcb_amin = dtp->dt_amin;
+ pcb.pcb_yystate = -1;
+ pcb.pcb_context = context;
+ pcb.pcb_token = context;
+
+#ifdef USING_FLEX /* In case flex starts work too early. Moved from dt_pcb_push. */
+ yyinit(&pcb);
+#endif
+ if (context != DT_CTX_DPROG)
+ yybegin(YYS_EXPR);
+ else if (cflags & DTRACE_C_CTL)
+ yybegin(YYS_CONTROL);
+ else
+ yybegin(YYS_CLAUSE);
+
+ rv = NULL;
+ if ((err = setjmp(yypcb->pcb_jmpbuf)) != 0)
+ goto out;
+
+ if (yypcb->pcb_sargc != 0 && yypcb->pcb_sflagv == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ yypcb->pcb_idents = dt_idhash_create("ambiguous", NULL, 0, 0);
+ yypcb->pcb_locals = dt_idhash_create("clause local", NULL,
+ DIF_VAR_OTHER_UBASE, DIF_VAR_OTHER_MAX);
+
+ if (yypcb->pcb_idents == NULL || yypcb->pcb_locals == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * Invoke the parser to evaluate the D source code. If any errors
+ * occur during parsing, an error function will be called and we
+ * will longjmp back to pcb_jmpbuf to abort. If parsing succeeds,
+ * we optionally display the parse tree if debugging is enabled.
+ */
+ if (yyparse() != 0 || yypcb->pcb_root == NULL)
+ xyerror(D_EMPTY, "empty D program translation unit\n");
+
+ yybegin(YYS_DONE);
+
+ if (cflags & DTRACE_C_CTL)
+ goto out;
+
+ if (context != DT_CTX_DTYPE && DT_TREEDUMP_PASS(dtp, 1))
+ dt_node_printr(yypcb->pcb_root, stderr, 0);
+
+ if (yypcb->pcb_pragmas != NULL)
+ (void) dt_idhash_iter(yypcb->pcb_pragmas, dt_idpragma, NULL);
+
+ if (argc > 1 && !(yypcb->pcb_cflags & DTRACE_C_ARGREF) &&
+ !(yypcb->pcb_sflagv[argc - 1] & DT_IDFLG_REF)) {
+ xyerror(D_MACRO_UNUSED, "extraneous argument '%s' ($%d is "
+ "not referenced)\n", yypcb->pcb_sargv[argc - 1], argc - 1);
+ }
+
+ /*
+ * If we have successfully created a parse tree for a D program, loop
+ * over the clauses and actions and instantiate the corresponding
+ * libdtrace program. If we are parsing a D expression, then we
+ * simply run the code generator and assembler on the resulting tree.
+ */
+ switch (context) {
+ case DT_CTX_DPROG:
+ assert(yypcb->pcb_root->dn_kind == DT_NODE_PROG);
+
+ if ((dnp = yypcb->pcb_root->dn_list) == NULL &&
+ !(yypcb->pcb_cflags & DTRACE_C_EMPTY))
+ xyerror(D_EMPTY, "empty D program translation unit\n");
+
+ if ((yypcb->pcb_prog = dt_program_create(dtp)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, dtrace_errno(dtp));
+
+ for (; dnp != NULL; dnp = dnp->dn_list) {
+ switch (dnp->dn_kind) {
+ case DT_NODE_CLAUSE:
+ dt_compile_clause(dtp, dnp);
+ break;
+ case DT_NODE_XLATOR:
+ if (dtp->dt_xlatemode == DT_XL_DYNAMIC)
+ dt_compile_xlator(dnp);
+ break;
+ case DT_NODE_PROVIDER:
+ (void) dt_node_cook(dnp, DT_IDFLG_REF);
+ break;
+ }
+ }
+
+ yypcb->pcb_prog->dp_xrefs = yypcb->pcb_asxrefs;
+ yypcb->pcb_prog->dp_xrefslen = yypcb->pcb_asxreflen;
+ yypcb->pcb_asxrefs = NULL;
+ yypcb->pcb_asxreflen = 0;
+
+ rv = yypcb->pcb_prog;
+ break;
+
+ case DT_CTX_DEXPR:
+ (void) dt_node_cook(yypcb->pcb_root, DT_IDFLG_REF);
+ dt_cg(yypcb, yypcb->pcb_root);
+ rv = dt_as(yypcb);
+ break;
+
+ case DT_CTX_DTYPE:
+ ddp = (dt_decl_t *)yypcb->pcb_root; /* root is really a decl */
+ err = dt_decl_type(ddp, arg);
+ dt_decl_free(ddp);
+
+ if (err != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+
+ rv = NULL;
+ break;
+ }
+
+out:
+ if (context != DT_CTX_DTYPE && DT_TREEDUMP_PASS(dtp, 3))
+ dt_node_printr(yypcb->pcb_root, stderr, 0);
+
+ if (dtp->dt_cdefs_fd != -1 && (ftruncate64(dtp->dt_cdefs_fd, 0) == -1 ||
+ lseek64(dtp->dt_cdefs_fd, 0, SEEK_SET) == -1 ||
+ ctf_write(dtp->dt_cdefs->dm_ctfp, dtp->dt_cdefs_fd) == CTF_ERR))
+ dt_dprintf("failed to update CTF cache: %s\n", strerror(errno));
+
+ if (dtp->dt_ddefs_fd != -1 && (ftruncate64(dtp->dt_ddefs_fd, 0) == -1 ||
+ lseek64(dtp->dt_ddefs_fd, 0, SEEK_SET) == -1 ||
+ ctf_write(dtp->dt_ddefs->dm_ctfp, dtp->dt_ddefs_fd) == CTF_ERR))
+ dt_dprintf("failed to update CTF cache: %s\n", strerror(errno));
+
+ if (yypcb->pcb_fileptr && (cflags & DTRACE_C_CPP))
+ (void) fclose(yypcb->pcb_fileptr); /* close dt_preproc() file */
+
+ dt_pcb_pop(dtp, err);
+ (void) dt_set_errno(dtp, err);
+ return (err ? NULL : rv);
+}
+
+dtrace_prog_t *
+dtrace_program_strcompile(dtrace_hdl_t *dtp, const char *s,
+ dtrace_probespec_t spec, uint_t cflags, int argc, char *const argv[])
+{
+ return (dt_compile(dtp, DT_CTX_DPROG,
+ spec, NULL, cflags, argc, argv, NULL, s));
+}
+
+dtrace_prog_t *
+dtrace_program_fcompile(dtrace_hdl_t *dtp, FILE *fp,
+ uint_t cflags, int argc, char *const argv[])
+{
+ return (dt_compile(dtp, DT_CTX_DPROG,
+ DTRACE_PROBESPEC_NAME, NULL, cflags, argc, argv, fp, NULL));
+}
+
+int
+dtrace_type_strcompile(dtrace_hdl_t *dtp, const char *s, dtrace_typeinfo_t *dtt)
+{
+ (void) dt_compile(dtp, DT_CTX_DTYPE,
+ DTRACE_PROBESPEC_NONE, dtt, 0, 0, NULL, NULL, s);
+ return (dtp->dt_errno ? -1 : 0);
+}
+
+int
+dtrace_type_fcompile(dtrace_hdl_t *dtp, FILE *fp, dtrace_typeinfo_t *dtt)
+{
+ (void) dt_compile(dtp, DT_CTX_DTYPE,
+ DTRACE_PROBESPEC_NONE, dtt, 0, 0, NULL, fp, NULL);
+ return (dtp->dt_errno ? -1 : 0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cg.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cg.c
new file mode 100644
index 00000000..0ce6feae
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cg.c
@@ -0,0 +1,1973 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/sysmacros.h>
+#include <sys/isa_defs.h>
+
+#include <strings.h>
+#include <stdlib.h>
+#include <setjmp.h>
+#include <assert.h>
+#include <errno.h>
+#else /* VBOX */
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_grammar.h>
+#include <dt_parser.h>
+#include <dt_provider.h>
+
+static void dt_cg_node(dt_node_t *, dt_irlist_t *, dt_regset_t *);
+
+static dt_irnode_t *
+dt_cg_node_alloc(uint_t label, dif_instr_t instr)
+{
+ dt_irnode_t *dip = malloc(sizeof (dt_irnode_t));
+
+ if (dip == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dip->di_label = label;
+ dip->di_instr = instr;
+ dip->di_extern = NULL;
+ dip->di_next = NULL;
+
+ return (dip);
+}
+
+/*
+ * Code generator wrapper function for ctf_member_info. If we are given a
+ * reference to a forward declaration tag, search the entire type space for
+ * the actual definition and then call ctf_member_info on the result.
+ */
+static ctf_file_t *
+dt_cg_membinfo(ctf_file_t *fp, ctf_id_t type, const char *s, ctf_membinfo_t *mp)
+{
+ while (ctf_type_kind(fp, type) == CTF_K_FORWARD) {
+ char n[DT_TYPE_NAMELEN];
+ dtrace_typeinfo_t dtt;
+
+ if (ctf_type_name(fp, type, n, sizeof (n)) == NULL ||
+ dt_type_lookup(n, &dtt) == -1 || (
+ dtt.dtt_ctfp == fp && dtt.dtt_type == type))
+ break; /* unable to improve our position */
+
+ fp = dtt.dtt_ctfp;
+ type = ctf_type_resolve(fp, dtt.dtt_type);
+ }
+
+ if (ctf_member_info(fp, type, s, mp) == CTF_ERR)
+ return (NULL); /* ctf_errno is set for us */
+
+ return (fp);
+}
+
+static void
+dt_cg_xsetx(dt_irlist_t *dlp, dt_ident_t *idp, uint_t lbl, int reg, uint64_t x)
+{
+ int flag = idp != NULL ? DT_INT_PRIVATE : DT_INT_SHARED;
+ int intoff = dt_inttab_insert(yypcb->pcb_inttab, x, flag);
+ dif_instr_t instr = DIF_INSTR_SETX((uint_t)intoff, reg);
+
+ if (intoff == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (intoff > DIF_INTOFF_MAX)
+ longjmp(yypcb->pcb_jmpbuf, EDT_INT2BIG);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl, instr));
+
+ if (idp != NULL)
+ dlp->dl_last->di_extern = idp;
+}
+
+static void
+dt_cg_setx(dt_irlist_t *dlp, int reg, uint64_t x)
+{
+ dt_cg_xsetx(dlp, NULL, DT_LBL_NONE, reg, x);
+}
+
+/*
+ * When loading bit-fields, we want to convert a byte count in the range
+ * 1-8 to the closest power of 2 (e.g. 3->4, 5->8, etc). The clp2() function
+ * is a clever implementation from "Hacker's Delight" by Henry Warren, Jr.
+ */
+static size_t
+clp2(size_t x)
+{
+ x--;
+
+ x |= (x >> 1);
+ x |= (x >> 2);
+ x |= (x >> 4);
+ x |= (x >> 8);
+ x |= (x >> 16);
+
+ return (x + 1);
+}
+
+/*
+ * Lookup the correct load opcode to use for the specified node and CTF type.
+ * We determine the size and convert it to a 3-bit index. Our lookup table
+ * is constructed to use a 5-bit index, consisting of the 3-bit size 0-7, a
+ * bit for the sign, and a bit for userland address. For example, a 4-byte
+ * signed load from userland would be at the following table index:
+ * user=1 sign=1 size=4 => binary index 11011 = decimal index 27
+ */
+static uint_t
+dt_cg_load(dt_node_t *dnp, ctf_file_t *ctfp, ctf_id_t type)
+{
+ static const uint_t ops[] = {
+ DIF_OP_LDUB, DIF_OP_LDUH, 0, DIF_OP_LDUW,
+ 0, 0, 0, DIF_OP_LDX,
+ DIF_OP_LDSB, DIF_OP_LDSH, 0, DIF_OP_LDSW,
+ 0, 0, 0, DIF_OP_LDX,
+ DIF_OP_ULDUB, DIF_OP_ULDUH, 0, DIF_OP_ULDUW,
+ 0, 0, 0, DIF_OP_ULDX,
+ DIF_OP_ULDSB, DIF_OP_ULDSH, 0, DIF_OP_ULDSW,
+ 0, 0, 0, DIF_OP_ULDX,
+ };
+
+ ctf_encoding_t e;
+ ssize_t size;
+
+ /*
+ * If we're loading a bit-field, the size of our load is found by
+ * rounding cte_bits up to a byte boundary and then finding the
+ * nearest power of two to this value (see clp2(), above).
+ */
+ if ((dnp->dn_flags & DT_NF_BITFIELD) &&
+ ctf_type_encoding(ctfp, type, &e) != CTF_ERR)
+ size = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY);
+ else
+ size = ctf_type_size(ctfp, type);
+
+ if (size < 1 || size > 8 || (size & (size - 1)) != 0) {
+ xyerror(D_UNKNOWN, "internal error -- cg cannot load "
+ "size %ld when passed by value\n", (long)size);
+ }
+
+ size--; /* convert size to 3-bit index */
+
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ size |= 0x08;
+ if (dnp->dn_flags & DT_NF_USERLAND)
+ size |= 0x10;
+
+ return (ops[size]);
+}
+
+static void
+dt_cg_ptrsize(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp,
+ uint_t op, int dreg)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ ctf_arinfo_t r;
+ dif_instr_t instr;
+ ctf_id_t type;
+ uint_t kind;
+ ssize_t size;
+ int sreg;
+
+ if ((sreg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ type = ctf_type_resolve(ctfp, dnp->dn_type);
+ kind = ctf_type_kind(ctfp, type);
+ assert(kind == CTF_K_POINTER || kind == CTF_K_ARRAY);
+
+ if (kind == CTF_K_ARRAY) {
+ if (ctf_array_info(ctfp, type, &r) != 0) {
+ yypcb->pcb_hdl->dt_ctferr = ctf_errno(ctfp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
+ }
+ type = r.ctr_contents;
+ } else
+ type = ctf_type_reference(ctfp, type);
+
+ if ((size = ctf_type_size(ctfp, type)) == 1)
+ return; /* multiply or divide by one can be omitted */
+
+ dt_cg_setx(dlp, sreg, size);
+ instr = DIF_INSTR_FMT(op, dreg, sreg, dreg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, sreg);
+}
+
+/*
+ * If the result of a "." or "->" operation is a bit-field, we use this routine
+ * to generate an epilogue to the load instruction that extracts the value. In
+ * the diagrams below the "ld??" is the load instruction that is generated to
+ * load the containing word that is generating prior to calling this function.
+ *
+ * Epilogue for unsigned fields: Epilogue for signed fields:
+ *
+ * ldu? [r1], r1 lds? [r1], r1
+ * setx USHIFT, r2 setx 64 - SSHIFT, r2
+ * srl r1, r2, r1 sll r1, r2, r1
+ * setx (1 << bits) - 1, r2 setx 64 - bits, r2
+ * and r1, r2, r1 sra r1, r2, r1
+ *
+ * The *SHIFT constants above changes value depending on the endian-ness of our
+ * target architecture. Refer to the comments below for more details.
+ */
+static void
+dt_cg_field_get(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp,
+ ctf_file_t *fp, const ctf_membinfo_t *mp)
+{
+ ctf_encoding_t e;
+ dif_instr_t instr;
+ uint64_t shift;
+ int r1, r2;
+
+ if (ctf_type_encoding(fp, mp->ctm_type, &e) != 0 || e.cte_bits > 64) {
+ xyerror(D_UNKNOWN, "cg: bad field: off %lu type <%ld> "
+ "bits %u\n", mp->ctm_offset, mp->ctm_type, e.cte_bits);
+ }
+
+ assert(dnp->dn_op == DT_TOK_PTR || dnp->dn_op == DT_TOK_DOT);
+ r1 = dnp->dn_left->dn_reg;
+
+ if ((r2 = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ /*
+ * On little-endian architectures, ctm_offset counts from the right so
+ * ctm_offset % NBBY itself is the amount we want to shift right to
+ * move the value bits to the little end of the register to mask them.
+ * On big-endian architectures, ctm_offset counts from the left so we
+ * must subtract (ctm_offset % NBBY + cte_bits) from the size in bits
+ * we used for the load. The size of our load in turn is found by
+ * rounding cte_bits up to a byte boundary and then finding the
+ * nearest power of two to this value (see clp2(), above). These
+ * properties are used to compute shift as USHIFT or SSHIFT, below.
+ */
+ if (dnp->dn_flags & DT_NF_SIGNED) {
+#ifdef _BIG_ENDIAN
+ shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY -
+ mp->ctm_offset % NBBY;
+#else
+ shift = mp->ctm_offset % NBBY + e.cte_bits;
+#endif
+ dt_cg_setx(dlp, r2, 64 - shift);
+ instr = DIF_INSTR_FMT(DIF_OP_SLL, r1, r2, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_setx(dlp, r2, 64 - e.cte_bits);
+ instr = DIF_INSTR_FMT(DIF_OP_SRA, r1, r2, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ } else {
+#ifdef _BIG_ENDIAN
+ shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY -
+ (mp->ctm_offset % NBBY + e.cte_bits);
+#else
+ shift = mp->ctm_offset % NBBY;
+#endif
+ dt_cg_setx(dlp, r2, shift);
+ instr = DIF_INSTR_FMT(DIF_OP_SRL, r1, r2, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_setx(dlp, r2, (1ULL << e.cte_bits) - 1);
+ instr = DIF_INSTR_FMT(DIF_OP_AND, r1, r2, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ }
+
+ dt_regset_free(drp, r2);
+}
+
+/*
+ * If the destination of a store operation is a bit-field, we use this routine
+ * to generate a prologue to the store instruction that loads the surrounding
+ * bits, clears the destination field, and ORs in the new value of the field.
+ * In the diagram below the "st?" is the store instruction that is generated to
+ * store the containing word that is generating after calling this function.
+ *
+ * ld [dst->dn_reg], r1
+ * setx ~(((1 << cte_bits) - 1) << (ctm_offset % NBBY)), r2
+ * and r1, r2, r1
+ *
+ * setx (1 << cte_bits) - 1, r2
+ * and src->dn_reg, r2, r2
+ * setx ctm_offset % NBBY, r3
+ * sll r2, r3, r2
+ *
+ * or r1, r2, r1
+ * st? r1, [dst->dn_reg]
+ *
+ * This routine allocates a new register to hold the value to be stored and
+ * returns it. The caller is responsible for freeing this register later.
+ */
+static int
+dt_cg_field_set(dt_node_t *src, dt_irlist_t *dlp,
+ dt_regset_t *drp, dt_node_t *dst)
+{
+ uint64_t cmask, fmask, shift;
+ dif_instr_t instr;
+ int r1, r2, r3;
+
+ ctf_membinfo_t m;
+ ctf_encoding_t e;
+ ctf_file_t *fp, *ofp;
+ ctf_id_t type;
+
+ assert(dst->dn_op == DT_TOK_PTR || dst->dn_op == DT_TOK_DOT);
+ assert(dst->dn_right->dn_kind == DT_NODE_IDENT);
+
+ fp = dst->dn_left->dn_ctfp;
+ type = ctf_type_resolve(fp, dst->dn_left->dn_type);
+
+ if (dst->dn_op == DT_TOK_PTR) {
+ type = ctf_type_reference(fp, type);
+ type = ctf_type_resolve(fp, type);
+ }
+
+ if ((fp = dt_cg_membinfo(ofp = fp, type,
+ dst->dn_right->dn_string, &m)) == NULL) {
+ yypcb->pcb_hdl->dt_ctferr = ctf_errno(ofp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
+ }
+
+ if (ctf_type_encoding(fp, m.ctm_type, &e) != 0 || e.cte_bits > 64) {
+ xyerror(D_UNKNOWN, "cg: bad field: off %lu type <%ld> "
+ "bits %u\n", m.ctm_offset, m.ctm_type, e.cte_bits);
+ }
+
+ if ((r1 = dt_regset_alloc(drp)) == -1 ||
+ (r2 = dt_regset_alloc(drp)) == -1 ||
+ (r3 = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ /*
+ * Compute shifts and masks. We need to compute "shift" as the amount
+ * we need to shift left to position our field in the containing word.
+ * Refer to the comments in dt_cg_field_get(), above, for more info.
+ * We then compute fmask as the mask that truncates the value in the
+ * input register to width cte_bits, and cmask as the mask used to
+ * pass through the containing bits and zero the field bits.
+ */
+#ifdef _BIG_ENDIAN
+ shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY -
+ (m.ctm_offset % NBBY + e.cte_bits);
+#else
+ shift = m.ctm_offset % NBBY;
+#endif
+ fmask = (1ULL << e.cte_bits) - 1;
+ cmask = ~(fmask << shift);
+
+ instr = DIF_INSTR_LOAD(
+ dt_cg_load(dst, fp, m.ctm_type), dst->dn_reg, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_setx(dlp, r2, cmask);
+ instr = DIF_INSTR_FMT(DIF_OP_AND, r1, r2, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_setx(dlp, r2, fmask);
+ instr = DIF_INSTR_FMT(DIF_OP_AND, src->dn_reg, r2, r2);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_setx(dlp, r3, shift);
+ instr = DIF_INSTR_FMT(DIF_OP_SLL, r2, r3, r2);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_FMT(DIF_OP_OR, r1, r2, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_regset_free(drp, r3);
+ dt_regset_free(drp, r2);
+
+ return (r1);
+}
+
+static void
+dt_cg_store(dt_node_t *src, dt_irlist_t *dlp, dt_regset_t *drp, dt_node_t *dst)
+{
+ ctf_encoding_t e;
+ dif_instr_t instr VBDTMSC(0);
+ size_t size;
+ int reg;
+
+ /*
+ * If we're loading a bit-field, the size of our store is found by
+ * rounding dst's cte_bits up to a byte boundary and then finding the
+ * nearest power of two to this value (see clp2(), above).
+ */
+ if ((dst->dn_flags & DT_NF_BITFIELD) &&
+ ctf_type_encoding(dst->dn_ctfp, dst->dn_type, &e) != CTF_ERR)
+ size = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY);
+ else
+ size = dt_node_type_size(src);
+
+ if (src->dn_flags & DT_NF_REF) {
+ if ((reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ dt_cg_setx(dlp, reg, size);
+ instr = DIF_INSTR_COPYS(src->dn_reg, reg, dst->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, reg);
+ } else {
+ if (dst->dn_flags & DT_NF_BITFIELD)
+ reg = dt_cg_field_set(src, dlp, drp, dst);
+ else
+ reg = src->dn_reg;
+
+ switch (size) {
+ case 1:
+ instr = DIF_INSTR_STORE(DIF_OP_STB, reg, dst->dn_reg);
+ break;
+ case 2:
+ instr = DIF_INSTR_STORE(DIF_OP_STH, reg, dst->dn_reg);
+ break;
+ case 4:
+ instr = DIF_INSTR_STORE(DIF_OP_STW, reg, dst->dn_reg);
+ break;
+ case 8:
+ instr = DIF_INSTR_STORE(DIF_OP_STX, reg, dst->dn_reg);
+ break;
+ default:
+ xyerror(D_UNKNOWN, "internal error -- cg cannot store "
+ "size %lu when passed by value\n", (ulong_t)size);
+ }
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ if (dst->dn_flags & DT_NF_BITFIELD)
+ dt_regset_free(drp, reg);
+ }
+}
+
+/*
+ * Generate code for a typecast or for argument promotion from the type of the
+ * actual to the type of the formal. We need to generate code for casts when
+ * a scalar type is being narrowed or changing signed-ness. We first shift the
+ * desired bits high (losing excess bits if narrowing) and then shift them down
+ * using logical shift (unsigned result) or arithmetic shift (signed result).
+ */
+static void
+dt_cg_typecast(const dt_node_t *src, const dt_node_t *dst,
+ dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ size_t srcsize = dt_node_type_size(src);
+ size_t dstsize = dt_node_type_size(dst);
+
+ dif_instr_t instr;
+#ifndef VBOX
+ int reg, n;
+#else
+ int reg;
+ uint64_t n;
+#endif
+
+ if (dt_node_is_scalar(dst) && (dstsize < srcsize ||
+ (src->dn_flags & DT_NF_SIGNED) ^ (dst->dn_flags & DT_NF_SIGNED))) {
+ if ((reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ if (dstsize < srcsize)
+ n = sizeof (uint64_t) * NBBY - dstsize * NBBY;
+ else
+ n = sizeof (uint64_t) * NBBY - srcsize * NBBY;
+
+ dt_cg_setx(dlp, reg, n);
+
+ instr = DIF_INSTR_FMT(DIF_OP_SLL,
+ src->dn_reg, reg, dst->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_FMT((dst->dn_flags & DT_NF_SIGNED) ?
+ DIF_OP_SRA : DIF_OP_SRL, dst->dn_reg, reg, dst->dn_reg);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, reg);
+ }
+}
+
+/*
+ * Generate code to push the specified argument list on to the tuple stack.
+ * We use this routine for handling subroutine calls and associative arrays.
+ * We must first generate code for all subexpressions before loading the stack
+ * because any subexpression could itself require the use of the tuple stack.
+ * This holds a number of registers equal to the number of arguments, but this
+ * is not a huge problem because the number of arguments can't exceed the
+ * number of tuple register stack elements anyway. At most one extra register
+ * is required (either by dt_cg_typecast() or for dtdt_size, below). This
+ * implies that a DIF implementation should offer a number of general purpose
+ * registers at least one greater than the number of tuple registers.
+ */
+static void
+dt_cg_arglist(dt_ident_t *idp, dt_node_t *args,
+ dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ const dt_idsig_t *isp = idp->di_data;
+ dt_node_t *dnp;
+ VBDTTYPE(uint_t,int) i = 0;
+
+ for (dnp = args; dnp != NULL; dnp = dnp->dn_list)
+ dt_cg_node(dnp, dlp, drp);
+
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, DIF_INSTR_FLUSHTS));
+
+ for (dnp = args; dnp != NULL; dnp = dnp->dn_list, i++) {
+ dtrace_diftype_t t;
+ dif_instr_t instr;
+ uint_t op;
+ int reg;
+
+ dt_node_diftype(yypcb->pcb_hdl, dnp, &t);
+
+ isp->dis_args[i].dn_reg = dnp->dn_reg; /* re-use register */
+ dt_cg_typecast(dnp, &isp->dis_args[i], dlp, drp);
+ isp->dis_args[i].dn_reg = -1;
+
+ if (t.dtdt_flags & DIF_TF_BYREF)
+ op = DIF_OP_PUSHTR;
+ else
+ op = DIF_OP_PUSHTV;
+
+ if (t.dtdt_size != 0) {
+ if ((reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ dt_cg_setx(dlp, reg, t.dtdt_size);
+ } else
+ reg = DIF_REG_R0;
+
+ instr = DIF_INSTR_PUSHTS(op, t.dtdt_kind, reg, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, dnp->dn_reg);
+
+ if (reg != DIF_REG_R0)
+ dt_regset_free(drp, reg);
+ }
+
+ if (i > yypcb->pcb_hdl->dt_conf.dtc_diftupregs)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOTUPREG);
+}
+
+static void
+dt_cg_arithmetic_op(dt_node_t *dnp, dt_irlist_t *dlp,
+ dt_regset_t *drp, uint_t op)
+{
+ int is_ptr_op = (dnp->dn_op == DT_TOK_ADD || dnp->dn_op == DT_TOK_SUB ||
+ dnp->dn_op == DT_TOK_ADD_EQ || dnp->dn_op == DT_TOK_SUB_EQ);
+
+ int lp_is_ptr = dt_node_is_pointer(dnp->dn_left);
+ int rp_is_ptr = dt_node_is_pointer(dnp->dn_right);
+
+ dif_instr_t instr;
+
+ if (lp_is_ptr && rp_is_ptr) {
+ assert(dnp->dn_op == DT_TOK_SUB);
+ is_ptr_op = 0;
+ }
+
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ if (is_ptr_op && rp_is_ptr)
+ dt_cg_ptrsize(dnp, dlp, drp, DIF_OP_MUL, dnp->dn_left->dn_reg);
+
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ if (is_ptr_op && lp_is_ptr)
+ dt_cg_ptrsize(dnp, dlp, drp, DIF_OP_MUL, dnp->dn_right->dn_reg);
+
+ instr = DIF_INSTR_FMT(op, dnp->dn_left->dn_reg,
+ dnp->dn_right->dn_reg, dnp->dn_left->dn_reg);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, dnp->dn_right->dn_reg);
+ dnp->dn_reg = dnp->dn_left->dn_reg;
+
+ if (lp_is_ptr && rp_is_ptr)
+ dt_cg_ptrsize(dnp->dn_right,
+ dlp, drp, DIF_OP_UDIV, dnp->dn_reg);
+}
+
+static uint_t
+dt_cg_stvar(const dt_ident_t *idp)
+{
+ static const uint_t aops[] = { DIF_OP_STGAA, DIF_OP_STTAA, DIF_OP_NOP };
+ static const uint_t sops[] = { DIF_OP_STGS, DIF_OP_STTS, DIF_OP_STLS };
+
+ uint_t i = (((idp->di_flags & DT_IDFLG_LOCAL) != 0) << 1) |
+ ((idp->di_flags & DT_IDFLG_TLS) != 0);
+
+ return (idp->di_kind == DT_IDENT_ARRAY ? aops[i] : sops[i]);
+}
+
+static void
+dt_cg_prearith_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp, uint_t op)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ dif_instr_t instr;
+ ctf_id_t type;
+ ssize_t size = 1;
+ int reg;
+
+ if (dt_node_is_pointer(dnp)) {
+ type = ctf_type_resolve(ctfp, dnp->dn_type);
+ assert(ctf_type_kind(ctfp, type) == CTF_K_POINTER);
+ size = ctf_type_size(ctfp, ctf_type_reference(ctfp, type));
+ }
+
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+
+ if ((reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ dt_cg_setx(dlp, reg, size);
+
+ instr = DIF_INSTR_FMT(op, dnp->dn_reg, reg, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, reg);
+
+ /*
+ * If we are modifying a variable, generate an stv instruction from
+ * the variable specified by the identifier. If we are storing to a
+ * memory address, generate code again for the left-hand side using
+ * DT_NF_REF to get the address, and then generate a store to it.
+ * In both paths, we store the value in dnp->dn_reg (the new value).
+ */
+ if (dnp->dn_child->dn_kind == DT_NODE_VAR) {
+ dt_ident_t *idp = dt_ident_resolve(dnp->dn_child->dn_ident);
+
+ idp->di_flags |= DT_IDFLG_DIFW;
+ instr = DIF_INSTR_STV(dt_cg_stvar(idp),
+ idp->di_id, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ } else {
+ uint_t rbit = dnp->dn_child->dn_flags & DT_NF_REF;
+
+ assert(dnp->dn_child->dn_flags & DT_NF_WRITABLE);
+ assert(dnp->dn_child->dn_flags & DT_NF_LVALUE);
+
+ dnp->dn_child->dn_flags |= DT_NF_REF; /* force pass-by-ref */
+ dt_cg_node(dnp->dn_child, dlp, drp);
+
+ dt_cg_store(dnp, dlp, drp, dnp->dn_child);
+ dt_regset_free(drp, dnp->dn_child->dn_reg);
+
+ dnp->dn_left->dn_flags &= ~DT_NF_REF;
+ dnp->dn_left->dn_flags |= rbit;
+ }
+}
+
+static void
+dt_cg_postarith_op(dt_node_t *dnp, dt_irlist_t *dlp,
+ dt_regset_t *drp, uint_t op)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ dif_instr_t instr;
+ ctf_id_t type;
+ ssize_t size = 1;
+ int nreg;
+
+ if (dt_node_is_pointer(dnp)) {
+ type = ctf_type_resolve(ctfp, dnp->dn_type);
+ assert(ctf_type_kind(ctfp, type) == CTF_K_POINTER);
+ size = ctf_type_size(ctfp, ctf_type_reference(ctfp, type));
+ }
+
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+
+ if ((nreg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ dt_cg_setx(dlp, nreg, size);
+ instr = DIF_INSTR_FMT(op, dnp->dn_reg, nreg, nreg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ /*
+ * If we are modifying a variable, generate an stv instruction from
+ * the variable specified by the identifier. If we are storing to a
+ * memory address, generate code again for the left-hand side using
+ * DT_NF_REF to get the address, and then generate a store to it.
+ * In both paths, we store the value from 'nreg' (the new value).
+ */
+ if (dnp->dn_child->dn_kind == DT_NODE_VAR) {
+ dt_ident_t *idp = dt_ident_resolve(dnp->dn_child->dn_ident);
+
+ idp->di_flags |= DT_IDFLG_DIFW;
+ instr = DIF_INSTR_STV(dt_cg_stvar(idp), idp->di_id, nreg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ } else {
+ uint_t rbit = dnp->dn_child->dn_flags & DT_NF_REF;
+ int oreg = dnp->dn_reg;
+
+ assert(dnp->dn_child->dn_flags & DT_NF_WRITABLE);
+ assert(dnp->dn_child->dn_flags & DT_NF_LVALUE);
+
+ dnp->dn_child->dn_flags |= DT_NF_REF; /* force pass-by-ref */
+ dt_cg_node(dnp->dn_child, dlp, drp);
+
+ dnp->dn_reg = nreg;
+ dt_cg_store(dnp, dlp, drp, dnp->dn_child);
+ dnp->dn_reg = oreg;
+
+ dt_regset_free(drp, dnp->dn_child->dn_reg);
+ dnp->dn_left->dn_flags &= ~DT_NF_REF;
+ dnp->dn_left->dn_flags |= rbit;
+ }
+
+ dt_regset_free(drp, nreg);
+}
+
+/*
+ * Determine if we should perform signed or unsigned comparison for an OP2.
+ * If both operands are of arithmetic type, perform the usual arithmetic
+ * conversions to determine the common real type for comparison [ISOC 6.5.8.3].
+ */
+static int
+dt_cg_compare_signed(dt_node_t *dnp)
+{
+ dt_node_t dn;
+
+ if (dt_node_is_string(dnp->dn_left) ||
+ dt_node_is_string(dnp->dn_right))
+ return (1); /* strings always compare signed */
+ else if (!dt_node_is_arith(dnp->dn_left) ||
+ !dt_node_is_arith(dnp->dn_right))
+ return (0); /* non-arithmetic types always compare unsigned */
+
+ bzero(&dn, sizeof (dn));
+ dt_node_promote(dnp->dn_left, dnp->dn_right, &dn);
+ return (dn.dn_flags & DT_NF_SIGNED);
+}
+
+static void
+dt_cg_compare_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp, uint_t op)
+{
+ uint_t lbl_true = dt_irlist_label(dlp);
+ uint_t lbl_post = dt_irlist_label(dlp);
+
+ dif_instr_t instr;
+ uint_t opc;
+
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ dt_cg_node(dnp->dn_right, dlp, drp);
+
+ if (dt_node_is_string(dnp->dn_left) || dt_node_is_string(dnp->dn_right))
+ opc = DIF_OP_SCMP;
+ else
+ opc = DIF_OP_CMP;
+
+ instr = DIF_INSTR_CMP(opc, dnp->dn_left->dn_reg, dnp->dn_right->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, dnp->dn_right->dn_reg);
+ dnp->dn_reg = dnp->dn_left->dn_reg;
+
+ instr = DIF_INSTR_BRANCH(op, lbl_true);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_MOV(DIF_REG_R0, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BA, lbl_post);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_xsetx(dlp, NULL, lbl_true, dnp->dn_reg, 1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_post, DIF_INSTR_NOP));
+}
+
+/*
+ * Code generation for the ternary op requires some trickery with the assembler
+ * in order to conserve registers. We generate code for dn_expr and dn_left
+ * and free their registers so they do not have be consumed across codegen for
+ * dn_right. We insert a dummy MOV at the end of dn_left into the destination
+ * register, which is not yet known because we haven't done dn_right yet, and
+ * save the pointer to this instruction node. We then generate code for
+ * dn_right and use its register as our output. Finally, we reach back and
+ * patch the instruction for dn_left to move its output into this register.
+ */
+static void
+dt_cg_ternary_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ uint_t lbl_false = dt_irlist_label(dlp);
+ uint_t lbl_post = dt_irlist_label(dlp);
+
+ dif_instr_t instr;
+ dt_irnode_t *dip;
+
+ dt_cg_node(dnp->dn_expr, dlp, drp);
+ instr = DIF_INSTR_TST(dnp->dn_expr->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, dnp->dn_expr->dn_reg);
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BE, lbl_false);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ instr = DIF_INSTR_MOV(dnp->dn_left->dn_reg, DIF_REG_R0);
+ dip = dt_cg_node_alloc(DT_LBL_NONE, instr); /* save dip for below */
+ dt_irlist_append(dlp, dip);
+ dt_regset_free(drp, dnp->dn_left->dn_reg);
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BA, lbl_post);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_false, DIF_INSTR_NOP));
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ dnp->dn_reg = dnp->dn_right->dn_reg;
+
+ /*
+ * Now that dn_reg is assigned, reach back and patch the correct MOV
+ * instruction into the tail of dn_left. We know dn_reg was unused
+ * at that point because otherwise dn_right couldn't have allocated it.
+ */
+ dip->di_instr = DIF_INSTR_MOV(dnp->dn_left->dn_reg, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_post, DIF_INSTR_NOP));
+}
+
+static void
+dt_cg_logical_and(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ uint_t lbl_false = dt_irlist_label(dlp);
+ uint_t lbl_post = dt_irlist_label(dlp);
+
+ dif_instr_t instr;
+
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ instr = DIF_INSTR_TST(dnp->dn_left->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, dnp->dn_left->dn_reg);
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BE, lbl_false);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ instr = DIF_INSTR_TST(dnp->dn_right->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dnp->dn_reg = dnp->dn_right->dn_reg;
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BE, lbl_false);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_setx(dlp, dnp->dn_reg, 1);
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BA, lbl_post);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_MOV(DIF_REG_R0, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_false, instr));
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_post, DIF_INSTR_NOP));
+}
+
+static void
+dt_cg_logical_xor(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ uint_t lbl_next = dt_irlist_label(dlp);
+ uint_t lbl_tail = dt_irlist_label(dlp);
+
+ dif_instr_t instr;
+
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ instr = DIF_INSTR_TST(dnp->dn_left->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BE, lbl_next);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_cg_setx(dlp, dnp->dn_left->dn_reg, 1);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_next, DIF_INSTR_NOP));
+ dt_cg_node(dnp->dn_right, dlp, drp);
+
+ instr = DIF_INSTR_TST(dnp->dn_right->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BE, lbl_tail);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_cg_setx(dlp, dnp->dn_right->dn_reg, 1);
+
+ instr = DIF_INSTR_FMT(DIF_OP_XOR, dnp->dn_left->dn_reg,
+ dnp->dn_right->dn_reg, dnp->dn_left->dn_reg);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_tail, instr));
+
+ dt_regset_free(drp, dnp->dn_right->dn_reg);
+ dnp->dn_reg = dnp->dn_left->dn_reg;
+}
+
+static void
+dt_cg_logical_or(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ uint_t lbl_true = dt_irlist_label(dlp);
+ uint_t lbl_false = dt_irlist_label(dlp);
+ uint_t lbl_post = dt_irlist_label(dlp);
+
+ dif_instr_t instr;
+
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ instr = DIF_INSTR_TST(dnp->dn_left->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, dnp->dn_left->dn_reg);
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BNE, lbl_true);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ instr = DIF_INSTR_TST(dnp->dn_right->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dnp->dn_reg = dnp->dn_right->dn_reg;
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BE, lbl_false);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_xsetx(dlp, NULL, lbl_true, dnp->dn_reg, 1);
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BA, lbl_post);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_MOV(DIF_REG_R0, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_false, instr));
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_post, DIF_INSTR_NOP));
+}
+
+static void
+dt_cg_logical_neg(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ uint_t lbl_zero = dt_irlist_label(dlp);
+ uint_t lbl_post = dt_irlist_label(dlp);
+
+ dif_instr_t instr;
+
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+
+ instr = DIF_INSTR_TST(dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BE, lbl_zero);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_MOV(DIF_REG_R0, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BA, lbl_post);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_xsetx(dlp, NULL, lbl_zero, dnp->dn_reg, 1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(lbl_post, DIF_INSTR_NOP));
+}
+
+static void
+dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ dif_instr_t instr;
+ dt_ident_t *idp;
+
+ /*
+ * If we are performing a structure assignment of a translated type,
+ * we must instantiate all members and create a snapshot of the object
+ * in scratch space. We allocs a chunk of memory, generate code for
+ * each member, and then set dnp->dn_reg to the scratch object address.
+ */
+ if ((idp = dt_node_resolve(dnp->dn_right, DT_IDENT_XLSOU)) != NULL) {
+ ctf_membinfo_t ctm;
+ dt_xlator_t *dxp = idp->di_data;
+ dt_node_t *mnp, dn, mn;
+ int r1, r2;
+
+ /*
+ * Create two fake dt_node_t's representing operator "." and a
+ * right-hand identifier child node. These will be repeatedly
+ * modified according to each instantiated member so that we
+ * can pass them to dt_cg_store() and effect a member store.
+ */
+ bzero(&dn, sizeof (dt_node_t));
+ dn.dn_kind = DT_NODE_OP2;
+ dn.dn_op = DT_TOK_DOT;
+ dn.dn_left = dnp;
+ dn.dn_right = &mn;
+
+ bzero(&mn, sizeof (dt_node_t));
+ mn.dn_kind = DT_NODE_IDENT;
+ mn.dn_op = DT_TOK_IDENT;
+
+ /*
+ * Allocate a register for our scratch data pointer. First we
+ * set it to the size of our data structure, and then replace
+ * it with the result of an allocs of the specified size.
+ */
+ if ((r1 = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ dt_cg_setx(dlp, r1,
+ ctf_type_size(dxp->dx_dst_ctfp, dxp->dx_dst_base));
+
+ instr = DIF_INSTR_ALLOCS(r1, r1);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ /*
+ * When dt_cg_asgn_op() is called, we have already generated
+ * code for dnp->dn_right, which is the translator input. We
+ * now associate this register with the translator's input
+ * identifier so it can be referenced during our member loop.
+ */
+ dxp->dx_ident->di_flags |= DT_IDFLG_CGREG;
+ dxp->dx_ident->di_id = dnp->dn_right->dn_reg;
+
+ for (mnp = dxp->dx_members; mnp != NULL; mnp = mnp->dn_list) {
+ /*
+ * Generate code for the translator member expression,
+ * and then cast the result to the member type.
+ */
+ dt_cg_node(mnp->dn_membexpr, dlp, drp);
+ mnp->dn_reg = mnp->dn_membexpr->dn_reg;
+ dt_cg_typecast(mnp->dn_membexpr, mnp, dlp, drp);
+
+ /*
+ * Ask CTF for the offset of the member so we can store
+ * to the appropriate offset. This call has already
+ * been done once by the parser, so it should succeed.
+ */
+ if (ctf_member_info(dxp->dx_dst_ctfp, dxp->dx_dst_base,
+ mnp->dn_membname, &ctm) == CTF_ERR) {
+ yypcb->pcb_hdl->dt_ctferr =
+ ctf_errno(dxp->dx_dst_ctfp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
+ }
+
+ /*
+ * If the destination member is at offset 0, store the
+ * result directly to r1 (the scratch buffer address).
+ * Otherwise allocate another temporary for the offset
+ * and add r1 to it before storing the result.
+ */
+ if (ctm.ctm_offset != 0) {
+ if ((r2 = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ /*
+ * Add the member offset rounded down to the
+ * nearest byte. If the offset was not aligned
+ * on a byte boundary, this member is a bit-
+ * field and dt_cg_store() will handle masking.
+ */
+ dt_cg_setx(dlp, r2, ctm.ctm_offset / NBBY);
+ instr = DIF_INSTR_FMT(DIF_OP_ADD, r1, r2, r2);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_node_type_propagate(mnp, &dn);
+ dn.dn_right->dn_string = mnp->dn_membname;
+ dn.dn_reg = r2;
+
+ dt_cg_store(mnp, dlp, drp, &dn);
+ dt_regset_free(drp, r2);
+
+ } else {
+ dt_node_type_propagate(mnp, &dn);
+ dn.dn_right->dn_string = mnp->dn_membname;
+ dn.dn_reg = r1;
+
+ dt_cg_store(mnp, dlp, drp, &dn);
+ }
+
+ dt_regset_free(drp, mnp->dn_reg);
+ }
+
+ dxp->dx_ident->di_flags &= ~DT_IDFLG_CGREG;
+ dxp->dx_ident->di_id = 0;
+
+ if (dnp->dn_right->dn_reg != -1)
+ dt_regset_free(drp, dnp->dn_right->dn_reg);
+
+ assert(dnp->dn_reg == dnp->dn_right->dn_reg);
+ dnp->dn_reg = r1;
+ }
+
+ /*
+ * If we are storing to a variable, generate an stv instruction from
+ * the variable specified by the identifier. If we are storing to a
+ * memory address, generate code again for the left-hand side using
+ * DT_NF_REF to get the address, and then generate a store to it.
+ * In both paths, we assume dnp->dn_reg already has the new value.
+ */
+ if (dnp->dn_left->dn_kind == DT_NODE_VAR) {
+ idp = dt_ident_resolve(dnp->dn_left->dn_ident);
+
+ if (idp->di_kind == DT_IDENT_ARRAY)
+ dt_cg_arglist(idp, dnp->dn_left->dn_args, dlp, drp);
+
+ idp->di_flags |= DT_IDFLG_DIFW;
+ instr = DIF_INSTR_STV(dt_cg_stvar(idp),
+ idp->di_id, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ } else {
+ uint_t rbit = dnp->dn_left->dn_flags & DT_NF_REF;
+
+ assert(dnp->dn_left->dn_flags & DT_NF_WRITABLE);
+ assert(dnp->dn_left->dn_flags & DT_NF_LVALUE);
+
+ dnp->dn_left->dn_flags |= DT_NF_REF; /* force pass-by-ref */
+
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ dt_cg_store(dnp, dlp, drp, dnp->dn_left);
+ dt_regset_free(drp, dnp->dn_left->dn_reg);
+
+ dnp->dn_left->dn_flags &= ~DT_NF_REF;
+ dnp->dn_left->dn_flags |= rbit;
+ }
+}
+
+static void
+dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ dif_instr_t instr;
+ uint_t op;
+
+ assert(dnp->dn_kind == DT_NODE_VAR);
+ assert(!(dnp->dn_ident->di_flags & DT_IDFLG_LOCAL));
+ assert(dnp->dn_args != NULL);
+
+ dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);
+
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ if (dnp->dn_ident->di_flags & DT_IDFLG_TLS)
+ op = DIF_OP_LDTAA;
+ else
+ op = DIF_OP_LDGAA;
+
+ dnp->dn_ident->di_flags |= DT_IDFLG_DIFR;
+ instr = DIF_INSTR_LDV(op, dnp->dn_ident->di_id, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ /*
+ * If the associative array is a pass-by-reference type, then we are
+ * loading its value as a pointer to either load or store through it.
+ * The array element in question may not have been faulted in yet, in
+ * which case DIF_OP_LD*AA will return zero. We append an epilogue
+ * of instructions similar to the following:
+ *
+ * ld?aa id, %r1 ! base ld?aa instruction above
+ * tst %r1 ! start of epilogue
+ * +--- bne label
+ * | setx size, %r1
+ * | allocs %r1, %r1
+ * | st?aa id, %r1
+ * | ld?aa id, %r1
+ * v
+ * label: < rest of code >
+ *
+ * The idea is that we allocs a zero-filled chunk of scratch space and
+ * do a DIF_OP_ST*AA to fault in and initialize the array element, and
+ * then reload it to get the faulted-in address of the new variable
+ * storage. This isn't cheap, but pass-by-ref associative array values
+ * are (thus far) uncommon and the allocs cost only occurs once. If
+ * this path becomes important to DTrace users, we can improve things
+ * by adding a new DIF opcode to fault in associative array elements.
+ */
+ if (dnp->dn_flags & DT_NF_REF) {
+ uint_t stvop = op == DIF_OP_LDTAA ? DIF_OP_STTAA : DIF_OP_STGAA;
+ uint_t label = dt_irlist_label(dlp);
+
+ instr = DIF_INSTR_TST(dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_BRANCH(DIF_OP_BNE, label);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_cg_setx(dlp, dnp->dn_reg, dt_node_type_size(dnp));
+ instr = DIF_INSTR_ALLOCS(dnp->dn_reg, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dnp->dn_ident->di_flags |= DT_IDFLG_DIFW;
+ instr = DIF_INSTR_STV(stvop, dnp->dn_ident->di_id, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_LDV(op, dnp->dn_ident->di_id, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(label, DIF_INSTR_NOP));
+ }
+}
+
+static void
+dt_cg_array_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ dt_probe_t *prp = yypcb->pcb_probe;
+ uintmax_t saved = dnp->dn_args->dn_value;
+ dt_ident_t *idp = dnp->dn_ident;
+
+ dif_instr_t instr;
+ uint_t op;
+ size_t size;
+#ifndef VBOX
+ int reg, n;
+#else
+ int reg;
+ uint64_t n;
+#endif
+
+ assert(dnp->dn_kind == DT_NODE_VAR);
+ assert(!(idp->di_flags & DT_IDFLG_LOCAL));
+
+ assert(dnp->dn_args->dn_kind == DT_NODE_INT);
+ assert(dnp->dn_args->dn_list == NULL);
+
+ /*
+ * If this is a reference in the args[] array, temporarily modify the
+ * array index according to the static argument mapping (if any),
+ * unless the argument reference is provided by a dynamic translator.
+ * If we're using a dynamic translator for args[], then just set dn_reg
+ * to an invalid reg and return: DIF_OP_XLARG will fetch the arg later.
+ */
+ if (idp->di_id == DIF_VAR_ARGS) {
+ if ((idp->di_kind == DT_IDENT_XLPTR ||
+ idp->di_kind == DT_IDENT_XLSOU) &&
+ dt_xlator_dynamic(idp->di_data)) {
+ dnp->dn_reg = -1;
+ return;
+ }
+ dnp->dn_args->dn_value = prp->pr_mapping[saved];
+ }
+
+ dt_cg_node(dnp->dn_args, dlp, drp);
+ dnp->dn_args->dn_value = saved;
+
+ dnp->dn_reg = dnp->dn_args->dn_reg;
+
+ if (idp->di_flags & DT_IDFLG_TLS)
+ op = DIF_OP_LDTA;
+ else
+ op = DIF_OP_LDGA;
+
+ idp->di_flags |= DT_IDFLG_DIFR;
+
+ instr = DIF_INSTR_LDA(op, idp->di_id,
+ dnp->dn_args->dn_reg, dnp->dn_reg);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ /*
+ * If this is a reference to the args[] array, we need to take the
+ * additional step of explicitly eliminating any bits larger than the
+ * type size: the DIF interpreter in the kernel will always give us
+ * the raw (64-bit) argument value, and any bits larger than the type
+ * size may be junk. As a practical matter, this arises only on 64-bit
+ * architectures and only when the argument index is larger than the
+ * number of arguments passed directly to DTrace: if a 8-, 16- or
+ * 32-bit argument must be retrieved from the stack, it is possible
+ * (and it some cases, likely) that the upper bits will be garbage.
+ */
+ if (idp->di_id != DIF_VAR_ARGS || !dt_node_is_scalar(dnp))
+ return;
+
+ if ((size = dt_node_type_size(dnp)) == sizeof (uint64_t))
+ return;
+
+ if ((reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ assert(size < sizeof (uint64_t));
+ n = sizeof (uint64_t) * NBBY - size * NBBY;
+
+ dt_cg_setx(dlp, reg, n);
+
+ instr = DIF_INSTR_FMT(DIF_OP_SLL, dnp->dn_reg, reg, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_FMT((dnp->dn_flags & DT_NF_SIGNED) ?
+ DIF_OP_SRA : DIF_OP_SRL, dnp->dn_reg, reg, dnp->dn_reg);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, reg);
+}
+
+/*
+ * Generate code for an inlined variable reference. Inlines can be used to
+ * define either scalar or associative array substitutions. For scalars, we
+ * simply generate code for the parse tree saved in the identifier's din_root,
+ * and then cast the resulting expression to the inline's declaration type.
+ * For arrays, we take the input parameter subtrees from dnp->dn_args and
+ * temporarily store them in the din_root of each din_argv[i] identifier,
+ * which are themselves inlines and were set up for us by the parser. The
+ * result is that any reference to the inlined parameter inside the top-level
+ * din_root will turn into a recursive call to dt_cg_inline() for a scalar
+ * inline whose din_root will refer to the subtree pointed to by the argument.
+ */
+static void
+dt_cg_inline(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ dt_ident_t *idp = dnp->dn_ident;
+ dt_idnode_t *inp = idp->di_iarg;
+
+ dt_idnode_t *pinp;
+ dt_node_t *pnp;
+ int i;
+
+ assert(idp->di_flags & DT_IDFLG_INLINE);
+ assert(idp->di_ops == &dt_idops_inline);
+
+ if (idp->di_kind == DT_IDENT_ARRAY) {
+ for (i = 0, pnp = dnp->dn_args;
+ pnp != NULL; pnp = pnp->dn_list, i++) {
+ if (inp->din_argv[i] != NULL) {
+ pinp = inp->din_argv[i]->di_iarg;
+ pinp->din_root = pnp;
+ }
+ }
+ }
+
+ dt_cg_node(inp->din_root, dlp, drp);
+ dnp->dn_reg = inp->din_root->dn_reg;
+ dt_cg_typecast(inp->din_root, dnp, dlp, drp);
+
+ if (idp->di_kind == DT_IDENT_ARRAY) {
+ for (i = 0; i < inp->din_argc; i++) {
+ pinp = inp->din_argv[i]->di_iarg;
+ pinp->din_root = NULL;
+ }
+ }
+}
+
+static void
+dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ ctf_file_t *octfp;
+ ctf_membinfo_t m;
+ ctf_id_t type;
+
+ dif_instr_t instr;
+ dt_ident_t *idp;
+ ssize_t stroff;
+ uint_t op;
+ int reg;
+
+ switch (dnp->dn_op) {
+ case DT_TOK_COMMA:
+ dt_cg_node(dnp->dn_left, dlp, drp);
+ dt_regset_free(drp, dnp->dn_left->dn_reg);
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ dnp->dn_reg = dnp->dn_right->dn_reg;
+ break;
+
+ case DT_TOK_ASGN:
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ dnp->dn_reg = dnp->dn_right->dn_reg;
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_ADD_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_ADD);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_SUB_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_SUB);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_MUL_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_MUL);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_DIV_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp,
+ (dnp->dn_flags & DT_NF_SIGNED) ? DIF_OP_SDIV : DIF_OP_UDIV);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_MOD_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp,
+ (dnp->dn_flags & DT_NF_SIGNED) ? DIF_OP_SREM : DIF_OP_UREM);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_AND_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_AND);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_XOR_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_XOR);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_OR_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_OR);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_LSH_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_SLL);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_RSH_EQ:
+ dt_cg_arithmetic_op(dnp, dlp, drp,
+ (dnp->dn_flags & DT_NF_SIGNED) ? DIF_OP_SRA : DIF_OP_SRL);
+ dt_cg_asgn_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_QUESTION:
+ dt_cg_ternary_op(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_LOR:
+ dt_cg_logical_or(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_LXOR:
+ dt_cg_logical_xor(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_LAND:
+ dt_cg_logical_and(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_BOR:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_OR);
+ break;
+
+ case DT_TOK_XOR:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_XOR);
+ break;
+
+ case DT_TOK_BAND:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_AND);
+ break;
+
+ case DT_TOK_EQU:
+ dt_cg_compare_op(dnp, dlp, drp, DIF_OP_BE);
+ break;
+
+ case DT_TOK_NEQ:
+ dt_cg_compare_op(dnp, dlp, drp, DIF_OP_BNE);
+ break;
+
+ case DT_TOK_LT:
+ dt_cg_compare_op(dnp, dlp, drp,
+ dt_cg_compare_signed(dnp) ? DIF_OP_BL : DIF_OP_BLU);
+ break;
+
+ case DT_TOK_LE:
+ dt_cg_compare_op(dnp, dlp, drp,
+ dt_cg_compare_signed(dnp) ? DIF_OP_BLE : DIF_OP_BLEU);
+ break;
+
+ case DT_TOK_GT:
+ dt_cg_compare_op(dnp, dlp, drp,
+ dt_cg_compare_signed(dnp) ? DIF_OP_BG : DIF_OP_BGU);
+ break;
+
+ case DT_TOK_GE:
+ dt_cg_compare_op(dnp, dlp, drp,
+ dt_cg_compare_signed(dnp) ? DIF_OP_BGE : DIF_OP_BGEU);
+ break;
+
+ case DT_TOK_LSH:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_SLL);
+ break;
+
+ case DT_TOK_RSH:
+ dt_cg_arithmetic_op(dnp, dlp, drp,
+ (dnp->dn_flags & DT_NF_SIGNED) ? DIF_OP_SRA : DIF_OP_SRL);
+ break;
+
+ case DT_TOK_ADD:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_ADD);
+ break;
+
+ case DT_TOK_SUB:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_SUB);
+ break;
+
+ case DT_TOK_MUL:
+ dt_cg_arithmetic_op(dnp, dlp, drp, DIF_OP_MUL);
+ break;
+
+ case DT_TOK_DIV:
+ dt_cg_arithmetic_op(dnp, dlp, drp,
+ (dnp->dn_flags & DT_NF_SIGNED) ? DIF_OP_SDIV : DIF_OP_UDIV);
+ break;
+
+ case DT_TOK_MOD:
+ dt_cg_arithmetic_op(dnp, dlp, drp,
+ (dnp->dn_flags & DT_NF_SIGNED) ? DIF_OP_SREM : DIF_OP_UREM);
+ break;
+
+ case DT_TOK_LNEG:
+ dt_cg_logical_neg(dnp, dlp, drp);
+ break;
+
+ case DT_TOK_BNEG:
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+ instr = DIF_INSTR_NOT(dnp->dn_reg, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ break;
+
+ case DT_TOK_PREINC:
+ dt_cg_prearith_op(dnp, dlp, drp, DIF_OP_ADD);
+ break;
+
+ case DT_TOK_POSTINC:
+ dt_cg_postarith_op(dnp, dlp, drp, DIF_OP_ADD);
+ break;
+
+ case DT_TOK_PREDEC:
+ dt_cg_prearith_op(dnp, dlp, drp, DIF_OP_SUB);
+ break;
+
+ case DT_TOK_POSTDEC:
+ dt_cg_postarith_op(dnp, dlp, drp, DIF_OP_SUB);
+ break;
+
+ case DT_TOK_IPOS:
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+ break;
+
+ case DT_TOK_INEG:
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+
+ instr = DIF_INSTR_FMT(DIF_OP_SUB, DIF_REG_R0,
+ dnp->dn_reg, dnp->dn_reg);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ break;
+
+ case DT_TOK_DEREF:
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+
+ if (!(dnp->dn_flags & DT_NF_REF)) {
+ uint_t ubit = dnp->dn_flags & DT_NF_USERLAND;
+
+ /*
+ * Save and restore DT_NF_USERLAND across dt_cg_load():
+ * we need the sign bit from dnp and the user bit from
+ * dnp->dn_child in order to get the proper opcode.
+ */
+ dnp->dn_flags |=
+ (dnp->dn_child->dn_flags & DT_NF_USERLAND);
+
+ instr = DIF_INSTR_LOAD(dt_cg_load(dnp, ctfp,
+ dnp->dn_type), dnp->dn_reg, dnp->dn_reg);
+
+ dnp->dn_flags &= ~DT_NF_USERLAND;
+ dnp->dn_flags |= ubit;
+
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ }
+ break;
+
+ case DT_TOK_ADDROF: {
+ uint_t rbit = dnp->dn_child->dn_flags & DT_NF_REF;
+
+ dnp->dn_child->dn_flags |= DT_NF_REF; /* force pass-by-ref */
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+
+ dnp->dn_child->dn_flags &= ~DT_NF_REF;
+ dnp->dn_child->dn_flags |= rbit;
+ break;
+ }
+
+ case DT_TOK_SIZEOF: {
+ size_t size = dt_node_sizeof(dnp->dn_child);
+
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ assert(size != 0);
+ dt_cg_setx(dlp, dnp->dn_reg, size);
+ break;
+ }
+
+ case DT_TOK_STRINGOF:
+ dt_cg_node(dnp->dn_child, dlp, drp);
+ dnp->dn_reg = dnp->dn_child->dn_reg;
+ break;
+
+ case DT_TOK_XLATE:
+ /*
+ * An xlate operator appears in either an XLATOR, indicating a
+ * reference to a dynamic translator, or an OP2, indicating
+ * use of the xlate operator in the user's program. For the
+ * dynamic case, generate an xlate opcode with a reference to
+ * the corresponding member, pre-computed for us in dn_members.
+ */
+ if (dnp->dn_kind == DT_NODE_XLATOR) {
+ dt_xlator_t *dxp = dnp->dn_xlator;
+
+ assert(dxp->dx_ident->di_flags & DT_IDFLG_CGREG);
+ assert(dxp->dx_ident->di_id != 0);
+
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ if (dxp->dx_arg == -1) {
+ instr = DIF_INSTR_MOV(
+ dxp->dx_ident->di_id, dnp->dn_reg);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ op = DIF_OP_XLATE;
+ } else
+ op = DIF_OP_XLARG;
+
+ instr = DIF_INSTR_XLATE(op, 0, dnp->dn_reg);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ dlp->dl_last->di_extern = dnp->dn_xmember;
+ break;
+ }
+
+ assert(dnp->dn_kind == DT_NODE_OP2);
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ dnp->dn_reg = dnp->dn_right->dn_reg;
+ break;
+
+ case DT_TOK_LPAR:
+ dt_cg_node(dnp->dn_right, dlp, drp);
+ dnp->dn_reg = dnp->dn_right->dn_reg;
+ dt_cg_typecast(dnp->dn_right, dnp, dlp, drp);
+ break;
+
+ case DT_TOK_PTR:
+ case DT_TOK_DOT:
+ assert(dnp->dn_right->dn_kind == DT_NODE_IDENT);
+ dt_cg_node(dnp->dn_left, dlp, drp);
+
+ /*
+ * If the left-hand side of PTR or DOT is a dynamic variable,
+ * we expect it to be the output of a D translator. In this
+ * case, we look up the parse tree corresponding to the member
+ * that is being accessed and run the code generator over it.
+ * We then cast the result as if by the assignment operator.
+ */
+ if ((idp = dt_node_resolve(
+ dnp->dn_left, DT_IDENT_XLSOU)) != NULL ||
+ (idp = dt_node_resolve(
+ dnp->dn_left, DT_IDENT_XLPTR)) != NULL) {
+
+ dt_xlator_t *dxp;
+ dt_node_t *mnp;
+
+ dxp = idp->di_data;
+ mnp = dt_xlator_member(dxp, dnp->dn_right->dn_string);
+ assert(mnp != NULL);
+
+ dxp->dx_ident->di_flags |= DT_IDFLG_CGREG;
+ dxp->dx_ident->di_id = dnp->dn_left->dn_reg;
+
+ dt_cg_node(mnp->dn_membexpr, dlp, drp);
+ dnp->dn_reg = mnp->dn_membexpr->dn_reg;
+ dt_cg_typecast(mnp->dn_membexpr, dnp, dlp, drp);
+
+ dxp->dx_ident->di_flags &= ~DT_IDFLG_CGREG;
+ dxp->dx_ident->di_id = 0;
+
+ if (dnp->dn_left->dn_reg != -1)
+ dt_regset_free(drp, dnp->dn_left->dn_reg);
+ break;
+ }
+
+ ctfp = dnp->dn_left->dn_ctfp;
+ type = ctf_type_resolve(ctfp, dnp->dn_left->dn_type);
+
+ if (dnp->dn_op == DT_TOK_PTR) {
+ type = ctf_type_reference(ctfp, type);
+ type = ctf_type_resolve(ctfp, type);
+ }
+
+ if ((ctfp = dt_cg_membinfo(octfp = ctfp, type,
+ dnp->dn_right->dn_string, &m)) == NULL) {
+ yypcb->pcb_hdl->dt_ctferr = ctf_errno(octfp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
+ }
+
+ if (m.ctm_offset != 0) {
+ if ((reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ /*
+ * If the offset is not aligned on a byte boundary, it
+ * is a bit-field member and we will extract the value
+ * bits below after we generate the appropriate load.
+ */
+ dt_cg_setx(dlp, reg, m.ctm_offset / NBBY);
+
+ instr = DIF_INSTR_FMT(DIF_OP_ADD,
+ dnp->dn_left->dn_reg, reg, dnp->dn_left->dn_reg);
+
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, reg);
+ }
+
+ if (!(dnp->dn_flags & DT_NF_REF)) {
+ uint_t ubit = dnp->dn_flags & DT_NF_USERLAND;
+
+ /*
+ * Save and restore DT_NF_USERLAND across dt_cg_load():
+ * we need the sign bit from dnp and the user bit from
+ * dnp->dn_left in order to get the proper opcode.
+ */
+ dnp->dn_flags |=
+ (dnp->dn_left->dn_flags & DT_NF_USERLAND);
+
+ instr = DIF_INSTR_LOAD(dt_cg_load(dnp,
+ ctfp, m.ctm_type), dnp->dn_left->dn_reg,
+ dnp->dn_left->dn_reg);
+
+ dnp->dn_flags &= ~DT_NF_USERLAND;
+ dnp->dn_flags |= ubit;
+
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ if (dnp->dn_flags & DT_NF_BITFIELD)
+ dt_cg_field_get(dnp, dlp, drp, ctfp, &m);
+ }
+
+ dnp->dn_reg = dnp->dn_left->dn_reg;
+ break;
+
+ case DT_TOK_STRING:
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ assert(dnp->dn_kind == DT_NODE_STRING);
+ stroff = dt_strtab_insert(yypcb->pcb_strtab, dnp->dn_string);
+
+ if (stroff == -1L)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ if (stroff > DIF_STROFF_MAX)
+ longjmp(yypcb->pcb_jmpbuf, EDT_STR2BIG);
+
+ instr = DIF_INSTR_SETS((ulong_t)stroff, dnp->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ break;
+
+ case DT_TOK_IDENT:
+ /*
+ * If the specified identifier is a variable on which we have
+ * set the code generator register flag, then this variable
+ * has already had code generated for it and saved in di_id.
+ * Allocate a new register and copy the existing value to it.
+ */
+ if (dnp->dn_kind == DT_NODE_VAR &&
+ (dnp->dn_ident->di_flags & DT_IDFLG_CGREG)) {
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ instr = DIF_INSTR_MOV(dnp->dn_ident->di_id,
+ dnp->dn_reg);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ break;
+ }
+
+ /*
+ * Identifiers can represent function calls, variable refs, or
+ * symbols. First we check for inlined variables, and handle
+ * them by generating code for the inline parse tree.
+ */
+ if (dnp->dn_kind == DT_NODE_VAR &&
+ (dnp->dn_ident->di_flags & DT_IDFLG_INLINE)) {
+ dt_cg_inline(dnp, dlp, drp);
+ break;
+ }
+
+ switch (dnp->dn_kind) {
+ case DT_NODE_FUNC:
+ if ((idp = dnp->dn_ident)->di_kind != DT_IDENT_FUNC) {
+ dnerror(dnp, D_CG_EXPR, "%s %s( ) may not be "
+ "called from a D expression (D program "
+ "context required)\n",
+ dt_idkind_name(idp->di_kind), idp->di_name);
+ }
+
+ dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);
+
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ instr = DIF_INSTR_CALL(
+ dnp->dn_ident->di_id, dnp->dn_reg);
+
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ break;
+
+ case DT_NODE_VAR:
+ if (dnp->dn_ident->di_kind == DT_IDENT_XLSOU ||
+ dnp->dn_ident->di_kind == DT_IDENT_XLPTR) {
+ /*
+ * This can only happen if we have translated
+ * args[]. See dt_idcook_args() for details.
+ */
+ assert(dnp->dn_ident->di_id == DIF_VAR_ARGS);
+ dt_cg_array_op(dnp, dlp, drp);
+ break;
+ }
+
+ if (dnp->dn_ident->di_kind == DT_IDENT_ARRAY) {
+ if (dnp->dn_ident->di_id > DIF_VAR_ARRAY_MAX)
+ dt_cg_assoc_op(dnp, dlp, drp);
+ else
+ dt_cg_array_op(dnp, dlp, drp);
+ break;
+ }
+
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ if (dnp->dn_ident->di_flags & DT_IDFLG_LOCAL)
+ op = DIF_OP_LDLS;
+ else if (dnp->dn_ident->di_flags & DT_IDFLG_TLS)
+ op = DIF_OP_LDTS;
+ else
+ op = DIF_OP_LDGS;
+
+ dnp->dn_ident->di_flags |= DT_IDFLG_DIFR;
+
+ instr = DIF_INSTR_LDV(op,
+ dnp->dn_ident->di_id, dnp->dn_reg);
+
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ break;
+
+ case DT_NODE_SYM: {
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dtrace_syminfo_t *sip = dnp->dn_ident->di_data;
+ GElf_Sym sym;
+
+ if (dtrace_lookup_by_name(dtp,
+ sip->dts_object, sip->dts_name, &sym, NULL) == -1) {
+ xyerror(D_UNKNOWN, "cg failed for symbol %s`%s:"
+ " %s\n", sip->dts_object, sip->dts_name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ dt_cg_xsetx(dlp, dnp->dn_ident,
+ DT_LBL_NONE, dnp->dn_reg, sym.st_value);
+
+ if (!(dnp->dn_flags & DT_NF_REF)) {
+ instr = DIF_INSTR_LOAD(dt_cg_load(dnp, ctfp,
+ dnp->dn_type), dnp->dn_reg, dnp->dn_reg);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ }
+ break;
+ }
+
+ default:
+ xyerror(D_UNKNOWN, "internal error -- node type %u is "
+ "not valid for an identifier\n", dnp->dn_kind);
+ }
+ break;
+
+ case DT_TOK_INT:
+ if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+
+ dt_cg_setx(dlp, dnp->dn_reg, dnp->dn_value);
+ break;
+
+ default:
+ xyerror(D_UNKNOWN, "internal error -- token type %u is not a "
+ "valid D compilation token\n", dnp->dn_op);
+ }
+}
+
+void
+dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
+{
+ dif_instr_t instr;
+ dt_xlator_t *dxp VBDTMSC(NULL);
+
+ if (pcb->pcb_regs == NULL && (pcb->pcb_regs =
+ dt_regset_create(pcb->pcb_hdl->dt_conf.dtc_difintregs)) == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dt_regset_reset(pcb->pcb_regs);
+ (void) dt_regset_alloc(pcb->pcb_regs); /* allocate %r0 */
+
+ if (pcb->pcb_inttab != NULL)
+ dt_inttab_destroy(pcb->pcb_inttab);
+
+ if ((pcb->pcb_inttab = dt_inttab_create(yypcb->pcb_hdl)) == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (pcb->pcb_strtab != NULL)
+ dt_strtab_destroy(pcb->pcb_strtab);
+
+ if ((pcb->pcb_strtab = dt_strtab_create(BUFSIZ)) == NULL)
+ longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dt_irlist_destroy(&pcb->pcb_ir);
+ dt_irlist_create(&pcb->pcb_ir);
+
+ assert(pcb->pcb_dret == NULL);
+ pcb->pcb_dret = dnp;
+
+ if (dt_node_is_dynamic(dnp)) {
+ dnerror(dnp, D_CG_DYN, "expression cannot evaluate to result "
+ "of dynamic type\n");
+ }
+
+ /*
+ * If we're generating code for a translator body, assign the input
+ * parameter to the first available register (i.e. caller passes %r1).
+ */
+ if (dnp->dn_kind == DT_NODE_MEMBER) {
+ dxp = dnp->dn_membxlator;
+ dnp = dnp->dn_membexpr;
+
+ dxp->dx_ident->di_flags |= DT_IDFLG_CGREG;
+ dxp->dx_ident->di_id = dt_regset_alloc(pcb->pcb_regs);
+ }
+
+ dt_cg_node(dnp, &pcb->pcb_ir, pcb->pcb_regs);
+ instr = DIF_INSTR_RET(dnp->dn_reg);
+ dt_regset_free(pcb->pcb_regs, dnp->dn_reg);
+ dt_irlist_append(&pcb->pcb_ir, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ if (dnp->dn_kind == DT_NODE_MEMBER) {
+ dt_regset_free(pcb->pcb_regs, dxp->dx_ident->di_id);
+ dxp->dx_ident->di_id = 0;
+ dxp->dx_ident->di_flags &= ~DT_IDFLG_CGREG;
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_consume.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_consume.c
new file mode 100644
index 00000000..d12e4743
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_consume.c
@@ -0,0 +1,2342 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#include <stdlib.h>
+#include <strings.h>
+#include <errno.h>
+#include <unistd.h>
+#include <limits.h>
+#include <assert.h>
+#include <ctype.h>
+#include <alloca.h>
+#else /* VBOX */
+# include <ctype.h>
+# include <iprt/mp.h>
+# ifdef _MSC_VER
+# pragma warning(disable:4146) /* -uint64_t warnings */
+# include <io.h>
+# define ftruncate _chsize
+# define fseeko fseek
+# else
+# include <unistd.h>
+# endif
+#endif /* VBOX */
+#include <dt_impl.h>
+
+#define DT_MASK_LO 0x00000000FFFFFFFFULL
+
+/*
+ * We declare this here because (1) we need it and (2) we want to avoid a
+ * dependency on libm in libdtrace.
+ */
+static long double
+dt_fabsl(long double x)
+{
+ if (x < 0)
+ return (-x);
+
+ return (x);
+}
+
+/*
+ * 128-bit arithmetic functions needed to support the stddev() aggregating
+ * action.
+ */
+static int
+dt_gt_128(uint64_t *a, uint64_t *b)
+{
+ return (a[1] > b[1] || (a[1] == b[1] && a[0] > b[0]));
+}
+
+static int
+dt_ge_128(uint64_t *a, uint64_t *b)
+{
+ return (a[1] > b[1] || (a[1] == b[1] && a[0] >= b[0]));
+}
+
+static int
+dt_le_128(uint64_t *a, uint64_t *b)
+{
+ return (a[1] < b[1] || (a[1] == b[1] && a[0] <= b[0]));
+}
+
+/*
+ * Shift the 128-bit value in a by b. If b is positive, shift left.
+ * If b is negative, shift right.
+ */
+static void
+dt_shift_128(uint64_t *a, int b)
+{
+ uint64_t mask;
+
+ if (b == 0)
+ return;
+
+ if (b < 0) {
+ b = -b;
+ if (b >= 64) {
+ a[0] = a[1] >> (b - 64);
+ a[1] = 0;
+ } else {
+ a[0] >>= b;
+ mask = 1LL << (64 - b);
+ mask -= 1;
+ a[0] |= ((a[1] & mask) << (64 - b));
+ a[1] >>= b;
+ }
+ } else {
+ if (b >= 64) {
+ a[1] = a[0] << (b - 64);
+ a[0] = 0;
+ } else {
+ a[1] <<= b;
+ mask = a[0] >> (64 - b);
+ a[1] |= mask;
+ a[0] <<= b;
+ }
+ }
+}
+
+static int
+dt_nbits_128(uint64_t *a)
+{
+ int nbits = 0;
+ uint64_t tmp[2];
+ uint64_t zero[2] = { 0, 0 };
+
+ tmp[0] = a[0];
+ tmp[1] = a[1];
+
+ dt_shift_128(tmp, -1);
+ while (dt_gt_128(tmp, zero)) {
+ dt_shift_128(tmp, -1);
+ nbits++;
+ }
+
+ return (nbits);
+}
+
+static void
+dt_subtract_128(uint64_t *minuend, uint64_t *subtrahend, uint64_t *difference)
+{
+ uint64_t result[2];
+
+ result[0] = minuend[0] - subtrahend[0];
+ result[1] = minuend[1] - subtrahend[1] -
+ (minuend[0] < subtrahend[0] ? 1 : 0);
+
+ difference[0] = result[0];
+ difference[1] = result[1];
+}
+
+static void
+dt_add_128(uint64_t *addend1, uint64_t *addend2, uint64_t *sum)
+{
+ uint64_t result[2];
+
+ result[0] = addend1[0] + addend2[0];
+ result[1] = addend1[1] + addend2[1] +
+ (result[0] < addend1[0] || result[0] < addend2[0] ? 1 : 0);
+
+ sum[0] = result[0];
+ sum[1] = result[1];
+}
+
+/*
+ * The basic idea is to break the 2 64-bit values into 4 32-bit values,
+ * use native multiplication on those, and then re-combine into the
+ * resulting 128-bit value.
+ *
+ * (hi1 << 32 + lo1) * (hi2 << 32 + lo2) =
+ * hi1 * hi2 << 64 +
+ * hi1 * lo2 << 32 +
+ * hi2 * lo1 << 32 +
+ * lo1 * lo2
+ */
+static void
+dt_multiply_128(uint64_t factor1, uint64_t factor2, uint64_t *product)
+{
+ uint64_t hi1, hi2, lo1, lo2;
+ uint64_t tmp[2];
+
+ hi1 = factor1 >> 32;
+ hi2 = factor2 >> 32;
+
+ lo1 = factor1 & DT_MASK_LO;
+ lo2 = factor2 & DT_MASK_LO;
+
+ product[0] = lo1 * lo2;
+ product[1] = hi1 * hi2;
+
+ tmp[0] = hi1 * lo2;
+ tmp[1] = 0;
+ dt_shift_128(tmp, 32);
+ dt_add_128(product, tmp, product);
+
+ tmp[0] = hi2 * lo1;
+ tmp[1] = 0;
+ dt_shift_128(tmp, 32);
+ dt_add_128(product, tmp, product);
+}
+
+/*
+ * This is long-hand division.
+ *
+ * We initialize subtrahend by shifting divisor left as far as possible. We
+ * loop, comparing subtrahend to dividend: if subtrahend is smaller, we
+ * subtract and set the appropriate bit in the result. We then shift
+ * subtrahend right by one bit for the next comparison.
+ */
+static void
+dt_divide_128(uint64_t *dividend, uint64_t divisor, uint64_t *quotient)
+{
+ uint64_t result[2] = { 0, 0 };
+ uint64_t remainder[2];
+ uint64_t subtrahend[2];
+ uint64_t divisor_128[2];
+ uint64_t mask[2] = { 1, 0 };
+ int log = 0;
+
+ assert(divisor != 0);
+
+ divisor_128[0] = divisor;
+ divisor_128[1] = 0;
+
+ remainder[0] = dividend[0];
+ remainder[1] = dividend[1];
+
+ subtrahend[0] = divisor;
+ subtrahend[1] = 0;
+
+ while (divisor > 0) {
+ log++;
+ divisor >>= 1;
+ }
+
+ dt_shift_128(subtrahend, 128 - log);
+ dt_shift_128(mask, 128 - log);
+
+ while (dt_ge_128(remainder, divisor_128)) {
+ if (dt_ge_128(remainder, subtrahend)) {
+ dt_subtract_128(remainder, subtrahend, remainder);
+ result[0] |= mask[0];
+ result[1] |= mask[1];
+ }
+
+ dt_shift_128(subtrahend, -1);
+ dt_shift_128(mask, -1);
+ }
+
+ quotient[0] = result[0];
+ quotient[1] = result[1];
+}
+
+/*
+ * This is the long-hand method of calculating a square root.
+ * The algorithm is as follows:
+ *
+ * 1. Group the digits by 2 from the right.
+ * 2. Over the leftmost group, find the largest single-digit number
+ * whose square is less than that group.
+ * 3. Subtract the result of the previous step (2 or 4, depending) and
+ * bring down the next two-digit group.
+ * 4. For the result R we have so far, find the largest single-digit number
+ * x such that 2 * R * 10 * x + x^2 is less than the result from step 3.
+ * (Note that this is doubling R and performing a decimal left-shift by 1
+ * and searching for the appropriate decimal to fill the one's place.)
+ * The value x is the next digit in the square root.
+ * Repeat steps 3 and 4 until the desired precision is reached. (We're
+ * dealing with integers, so the above is sufficient.)
+ *
+ * In decimal, the square root of 582,734 would be calculated as so:
+ *
+ * __7__6__3
+ * | 58 27 34
+ * -49 (7^2 == 49 => 7 is the first digit in the square root)
+ * --
+ * 9 27 (Subtract and bring down the next group.)
+ * 146 8 76 (2 * 7 * 10 * 6 + 6^2 == 876 => 6 is the next digit in
+ * ----- the square root)
+ * 51 34 (Subtract and bring down the next group.)
+ * 1523 45 69 (2 * 76 * 10 * 3 + 3^2 == 4569 => 3 is the next digit in
+ * ----- the square root)
+ * 5 65 (remainder)
+ *
+ * The above algorithm applies similarly in binary, but note that the
+ * only possible non-zero value for x in step 4 is 1, so step 4 becomes a
+ * simple decision: is 2 * R * 2 * 1 + 1^2 (aka R << 2 + 1) less than the
+ * preceding difference?
+ *
+ * In binary, the square root of 11011011 would be calculated as so:
+ *
+ * __1__1__1__0
+ * | 11 01 10 11
+ * 01 (0 << 2 + 1 == 1 < 11 => this bit is 1)
+ * --
+ * 10 01 10 11
+ * 101 1 01 (1 << 2 + 1 == 101 < 1001 => next bit is 1)
+ * -----
+ * 1 00 10 11
+ * 1101 11 01 (11 << 2 + 1 == 1101 < 10010 => next bit is 1)
+ * -------
+ * 1 01 11
+ * 11101 1 11 01 (111 << 2 + 1 == 11101 > 10111 => last bit is 0)
+ *
+ */
+static uint64_t
+dt_sqrt_128(uint64_t *square)
+{
+ uint64_t result[2] = { 0, 0 };
+ uint64_t diff[2] = { 0, 0 };
+ uint64_t one[2] = { 1, 0 };
+ uint64_t next_pair[2];
+ uint64_t next_try[2];
+ uint64_t bit_pairs, pair_shift;
+ VBDTTYPE(uint64_t,int) i;
+
+ bit_pairs = dt_nbits_128(square) / 2;
+ pair_shift = bit_pairs * 2;
+
+ for (i = 0; i <= bit_pairs; i++) {
+ /*
+ * Bring down the next pair of bits.
+ */
+ next_pair[0] = square[0];
+ next_pair[1] = square[1];
+ dt_shift_128(next_pair, -pair_shift);
+ next_pair[0] &= 0x3;
+ next_pair[1] = 0;
+
+ dt_shift_128(diff, 2);
+ dt_add_128(diff, next_pair, diff);
+
+ /*
+ * next_try = R << 2 + 1
+ */
+ next_try[0] = result[0];
+ next_try[1] = result[1];
+ dt_shift_128(next_try, 2);
+ dt_add_128(next_try, one, next_try);
+
+ if (dt_le_128(next_try, diff)) {
+ dt_subtract_128(diff, next_try, diff);
+ dt_shift_128(result, 1);
+ dt_add_128(result, one, result);
+ } else {
+ dt_shift_128(result, 1);
+ }
+
+ pair_shift -= 2;
+ }
+
+ assert(result[1] == 0);
+
+ return (result[0]);
+}
+
+uint64_t
+dt_stddev(uint64_t *data, uint64_t normal)
+{
+ uint64_t avg_of_squares[2];
+ uint64_t square_of_avg[2];
+ int64_t norm_avg;
+ uint64_t diff[2];
+
+ /*
+ * The standard approximation for standard deviation is
+ * sqrt(average(x**2) - average(x)**2), i.e. the square root
+ * of the average of the squares minus the square of the average.
+ */
+ dt_divide_128(data + 2, normal, avg_of_squares);
+ dt_divide_128(avg_of_squares, data[0], avg_of_squares);
+
+ norm_avg = (int64_t)data[1] / (int64_t)normal / (int64_t)data[0];
+
+ if (norm_avg < 0)
+ norm_avg = -norm_avg;
+
+ dt_multiply_128((uint64_t)norm_avg, (uint64_t)norm_avg, square_of_avg);
+
+ dt_subtract_128(avg_of_squares, square_of_avg, diff);
+
+ return (dt_sqrt_128(diff));
+}
+
+static int
+dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
+ dtrace_bufdesc_t *buf, size_t offs)
+{
+ dtrace_probedesc_t *pd = data->dtpda_pdesc, *npd;
+ dtrace_eprobedesc_t *epd = data->dtpda_edesc, *nepd;
+ char *p = pd->dtpd_provider, *n = pd->dtpd_name, *sub;
+ dtrace_flowkind_t flow = DTRACEFLOW_NONE;
+ const char *str = NULL;
+ static const char *e_str[2] = { " -> ", " => " };
+ static const char *r_str[2] = { " <- ", " <= " };
+ static const char *ent = "entry", *ret = "return";
+ static VBDTTYPE(size_t,int) entlen = 0, retlen = 0;
+ dtrace_epid_t next, id = epd->dtepd_epid;
+ int rval;
+
+ if (entlen == 0) {
+ assert(retlen == 0);
+ entlen = strlen(ent);
+ retlen = strlen(ret);
+ }
+
+ /*
+ * If the name of the probe is "entry" or ends with "-entry", we
+ * treat it as an entry; if it is "return" or ends with "-return",
+ * we treat it as a return. (This allows application-provided probes
+ * like "method-entry" or "function-entry" to participate in flow
+ * indentation -- without accidentally misinterpreting popular probe
+ * names like "carpentry", "gentry" or "Coventry".)
+ */
+ if ((sub = strstr(n, ent)) != NULL && sub[entlen] == '\0' &&
+ (sub == n || sub[-1] == '-')) {
+ flow = DTRACEFLOW_ENTRY;
+ str = e_str[strcmp(p, "syscall") == 0];
+ } else if ((sub = strstr(n, ret)) != NULL && sub[retlen] == '\0' &&
+ (sub == n || sub[-1] == '-')) {
+ flow = DTRACEFLOW_RETURN;
+ str = r_str[strcmp(p, "syscall") == 0];
+ }
+
+ /*
+ * If we're going to indent this, we need to check the ID of our last
+ * call. If we're looking at the same probe ID but a different EPID,
+ * we _don't_ want to indent. (Yes, there are some minor holes in
+ * this scheme -- it's a heuristic.)
+ */
+ if (flow == DTRACEFLOW_ENTRY) {
+ if ((last != DTRACE_EPIDNONE && id != last &&
+ pd->dtpd_id == dtp->dt_pdesc[last]->dtpd_id))
+ flow = DTRACEFLOW_NONE;
+ }
+
+ /*
+ * If we're going to unindent this, it's more difficult to see if
+ * we don't actually want to unindent it -- we need to look at the
+ * _next_ EPID.
+ */
+ if (flow == DTRACEFLOW_RETURN) {
+ offs += epd->dtepd_size;
+
+ do {
+ if (offs >= buf->dtbd_size) {
+ /*
+ * We're at the end -- maybe. If the oldest
+ * record is non-zero, we need to wrap.
+ */
+ if (buf->dtbd_oldest != 0) {
+ offs = 0;
+ } else {
+ goto out;
+ }
+ }
+
+ next = *(uint32_t *)((uintptr_t)buf->dtbd_data + offs);
+
+ if (next == DTRACE_EPIDNONE)
+ offs += sizeof (id);
+ } while (next == DTRACE_EPIDNONE);
+
+ if ((rval = dt_epid_lookup(dtp, next, &nepd, &npd)) != 0)
+ return (rval);
+
+ if (next != id && npd->dtpd_id == pd->dtpd_id)
+ flow = DTRACEFLOW_NONE;
+ }
+
+out:
+ if (flow == DTRACEFLOW_ENTRY || flow == DTRACEFLOW_RETURN) {
+ data->dtpda_prefix = str;
+ } else {
+ data->dtpda_prefix = "| ";
+ }
+
+ if (flow == DTRACEFLOW_RETURN && data->dtpda_indent > 0)
+ data->dtpda_indent -= 2;
+
+ data->dtpda_flow = flow;
+
+ return (0);
+}
+
+static int
+dt_nullprobe(void)
+{
+ return (DTRACE_CONSUME_THIS);
+}
+
+static int
+dt_nullrec(void)
+{
+ return (DTRACE_CONSUME_NEXT);
+}
+
+int
+dt_print_quantline(dtrace_hdl_t *dtp, FILE *fp, int64_t val,
+ uint64_t normal, long double total, char positives, char negatives)
+{
+ long double f;
+ uint_t depth, len = 40;
+
+ const char *ats = "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
+ const char *spaces = " ";
+
+ assert(strlen(ats) == len && strlen(spaces) == len);
+ assert(!(total == 0 && (positives || negatives)));
+ assert(!(val < 0 && !negatives));
+ assert(!(val > 0 && !positives));
+ assert(!(val != 0 && total == 0));
+
+ if (!negatives) {
+ if (positives) {
+ f = (dt_fabsl((long double)val) * len) / total;
+ depth = (uint_t)(f + 0.5);
+ } else {
+ depth = 0;
+ }
+
+ return (dt_printf(dtp, fp, "|%s%s %-9lld\n", ats + len - depth,
+ spaces + depth, (long long)val / normal));
+ }
+
+ if (!positives) {
+ f = (dt_fabsl((long double)val) * len) / total;
+ depth = (uint_t)(f + 0.5);
+
+ return (dt_printf(dtp, fp, "%s%s| %-9lld\n", spaces + depth,
+ ats + len - depth, (long long)val / normal));
+ }
+
+ /*
+ * If we're here, we have both positive and negative bucket values.
+ * To express this graphically, we're going to generate both positive
+ * and negative bars separated by a centerline. These bars are half
+ * the size of normal quantize()/lquantize() bars, so we divide the
+ * length in half before calculating the bar length.
+ */
+ len /= 2;
+ ats = &ats[len];
+ spaces = &spaces[len];
+
+ f = (dt_fabsl((long double)val) * len) / total;
+ depth = (uint_t)(f + 0.5);
+
+ if (val <= 0) {
+ return (dt_printf(dtp, fp, "%s%s|%*s %-9lld\n", spaces + depth,
+ ats + len - depth, len, "", (long long)val / normal));
+ } else {
+ return (dt_printf(dtp, fp, "%20s|%s%s %-9lld\n", "",
+ ats + len - depth, spaces + depth,
+ (long long)val / normal));
+ }
+}
+
+int
+dt_print_quantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr,
+ size_t size, uint64_t normal)
+{
+ const int64_t *data = addr;
+ int i, first_bin = 0, last_bin = DTRACE_QUANTIZE_NBUCKETS - 1;
+ long double total = 0;
+ char positives = 0, negatives = 0;
+
+ if (size != DTRACE_QUANTIZE_NBUCKETS * sizeof (uint64_t))
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ while (first_bin < DTRACE_QUANTIZE_NBUCKETS - 1 && data[first_bin] == 0)
+ first_bin++;
+
+ if (first_bin == DTRACE_QUANTIZE_NBUCKETS - 1) {
+ /*
+ * There isn't any data. This is possible if (and only if)
+ * negative increment values have been used. In this case,
+ * we'll print the buckets around 0.
+ */
+ first_bin = DTRACE_QUANTIZE_ZEROBUCKET - 1;
+ last_bin = DTRACE_QUANTIZE_ZEROBUCKET + 1;
+ } else {
+ if (first_bin > 0)
+ first_bin--;
+
+ while (last_bin > 0 && data[last_bin] == 0)
+ last_bin--;
+
+ if (last_bin < DTRACE_QUANTIZE_NBUCKETS - 1)
+ last_bin++;
+ }
+
+ for (i = first_bin; i <= last_bin; i++) {
+ positives |= (data[i] > 0);
+ negatives |= (data[i] < 0);
+ total += dt_fabsl((long double)data[i]);
+ }
+
+ if (dt_printf(dtp, fp, "\n%16s %41s %-9s\n", "value",
+ "------------- Distribution -------------", "count") < 0)
+ return (-1);
+
+ for (i = first_bin; i <= last_bin; i++) {
+ if (dt_printf(dtp, fp, "%16lld ",
+ (long long)DTRACE_QUANTIZE_BUCKETVAL(i)) < 0)
+ return (-1);
+
+ if (dt_print_quantline(dtp, fp, data[i], normal, total,
+ positives, negatives) < 0)
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
+dt_print_lquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr,
+ size_t size, uint64_t normal)
+{
+ const int64_t *data = addr;
+ int i, first_bin, last_bin, base;
+ uint64_t arg;
+ long double total = 0;
+ uint16_t step, levels;
+ char positives = 0, negatives = 0;
+
+ if (size < sizeof (uint64_t))
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ arg = *data++;
+ size -= sizeof (uint64_t);
+
+ base = DTRACE_LQUANTIZE_BASE(arg);
+ step = DTRACE_LQUANTIZE_STEP(arg);
+ levels = DTRACE_LQUANTIZE_LEVELS(arg);
+
+ first_bin = 0;
+ last_bin = levels + 1;
+
+ if (size != sizeof (uint64_t) * (levels + 2))
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ while (first_bin <= levels + 1 && data[first_bin] == 0)
+ first_bin++;
+
+ if (first_bin > levels + 1) {
+ first_bin = 0;
+ last_bin = 2;
+ } else {
+ if (first_bin > 0)
+ first_bin--;
+
+ while (last_bin > 0 && data[last_bin] == 0)
+ last_bin--;
+
+ if (last_bin < levels + 1)
+ last_bin++;
+ }
+
+ for (i = first_bin; i <= last_bin; i++) {
+ positives |= (data[i] > 0);
+ negatives |= (data[i] < 0);
+ total += dt_fabsl((long double)data[i]);
+ }
+
+ if (dt_printf(dtp, fp, "\n%16s %41s %-9s\n", "value",
+ "------------- Distribution -------------", "count") < 0)
+ return (-1);
+
+ for (i = first_bin; i <= last_bin; i++) {
+ char c[32];
+ int err;
+
+ if (i == 0) {
+ (void) snprintf(c, sizeof (c), "< %d",
+ base / (uint32_t)normal);
+ err = dt_printf(dtp, fp, "%16s ", c);
+ } else if (i == levels + 1) {
+ (void) snprintf(c, sizeof (c), ">= %d",
+ base + (levels * step));
+ err = dt_printf(dtp, fp, "%16s ", c);
+ } else {
+ err = dt_printf(dtp, fp, "%16d ",
+ base + (i - 1) * step);
+ }
+
+ if (err < 0 || dt_print_quantline(dtp, fp, data[i], normal,
+ total, positives, negatives) < 0)
+ return (-1);
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_print_average(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr,
+ size_t size, uint64_t normal)
+{
+ /* LINTED - alignment */
+ int64_t *data = (int64_t *)addr;
+ RT_NOREF1(size);
+
+ return (dt_printf(dtp, fp, " %16lld", data[0] ?
+ (long long)(data[1] / (int64_t)normal / data[0]) : 0));
+}
+
+/*ARGSUSED*/
+static int
+dt_print_stddev(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr,
+ size_t size, uint64_t normal)
+{
+ /* LINTED - alignment */
+ uint64_t *data = (uint64_t *)addr;
+ RT_NOREF1(size);
+
+ return (dt_printf(dtp, fp, " %16llu", data[0] ?
+ (unsigned long long) dt_stddev(data, normal) : 0));
+}
+
+/*ARGSUSED*/
+int
+dt_print_bytes(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr,
+ size_t nbytes, int width, int quiet)
+{
+ /*
+ * If the byte stream is a series of printable characters, followed by
+ * a terminating byte, we print it out as a string. Otherwise, we
+ * assume that it's something else and just print the bytes.
+ */
+#ifdef VBOX
+ size_t i, j;
+ int margin = 5;
+#else
+ int i, j, margin = 5;
+#endif
+ char *c = (char *)addr;
+
+ if (nbytes == 0)
+ return (0);
+
+ if (dtp->dt_options[DTRACEOPT_RAWBYTES] != DTRACEOPT_UNSET)
+ goto raw;
+
+ for (i = 0; i < nbytes; i++) {
+ /*
+ * We define a "printable character" to be one for which
+ * isprint(3C) returns non-zero, isspace(3C) returns non-zero,
+ * or a character which is either backspace or the bell.
+ * Backspace and the bell are regrettably special because
+ * they fail the first two tests -- and yet they are entirely
+ * printable. These are the only two control characters that
+ * have meaning for the terminal and for which isprint(3C) and
+ * isspace(3C) return 0.
+ */
+ if (isprint(c[i]) || isspace(c[i]) ||
+ c[i] == '\b' || c[i] == '\a')
+ continue;
+
+ if (c[i] == '\0' && i > 0) {
+ /*
+ * This looks like it might be a string. Before we
+ * assume that it is indeed a string, check the
+ * remainder of the byte range; if it contains
+ * additional non-nul characters, we'll assume that
+ * it's a binary stream that just happens to look like
+ * a string, and we'll print out the individual bytes.
+ */
+ for (j = i + 1; j < nbytes; j++) {
+ if (c[j] != '\0')
+ break;
+ }
+
+ if (j != nbytes)
+ break;
+
+ if (quiet)
+ return (dt_printf(dtp, fp, "%s", c));
+ else
+ return (dt_printf(dtp, fp, " %-*s", width, c));
+ }
+
+ break;
+ }
+
+ if (i == nbytes) {
+ /*
+ * The byte range is all printable characters, but there is
+ * no trailing nul byte. We'll assume that it's a string and
+ * print it as such.
+ */
+ char *s = alloca(nbytes + 1);
+ bcopy(c, s, nbytes);
+ s[nbytes] = '\0';
+ return (dt_printf(dtp, fp, " %-*s", width, s));
+ }
+
+raw:
+ if (dt_printf(dtp, fp, "\n%*s ", margin, "") < 0)
+ return (-1);
+
+ for (i = 0; i < 16; i++)
+ if (dt_printf(dtp, fp, " %c", "0123456789abcdef"[i]) < 0)
+ return (-1);
+
+ if (dt_printf(dtp, fp, " 0123456789abcdef\n") < 0)
+ return (-1);
+
+
+ for (i = 0; i < nbytes; i += 16) {
+ if (dt_printf(dtp, fp, "%*s%5x:", margin, "", i) < 0)
+ return (-1);
+
+ for (j = i; j < i + 16 && j < nbytes; j++) {
+ if (dt_printf(dtp, fp, " %02x", (uchar_t)c[j]) < 0)
+ return (-1);
+ }
+
+ while (j++ % 16) {
+ if (dt_printf(dtp, fp, " ") < 0)
+ return (-1);
+ }
+
+ if (dt_printf(dtp, fp, " ") < 0)
+ return (-1);
+
+ for (j = i; j < i + 16 && j < nbytes; j++) {
+ if (dt_printf(dtp, fp, "%c",
+ c[j] < ' ' || c[j] > '~' ? '.' : c[j]) < 0)
+ return (-1);
+ }
+
+ if (dt_printf(dtp, fp, "\n") < 0)
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
+dt_print_stack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ caddr_t addr, int depth, int size)
+{
+ dtrace_syminfo_t dts;
+ GElf_Sym sym;
+ int i, indent;
+ char c[PATH_MAX * 2];
+ uint64_t pc;
+
+ if (dt_printf(dtp, fp, "\n") < 0)
+ return (-1);
+
+ if (format == NULL)
+ format = "%s";
+
+ if (dtp->dt_options[DTRACEOPT_STACKINDENT] != DTRACEOPT_UNSET)
+ indent = (int)dtp->dt_options[DTRACEOPT_STACKINDENT];
+ else
+ indent = _dtrace_stkindent;
+
+ for (i = 0; i < depth; i++) {
+ switch (size) {
+ case sizeof (uint32_t):
+ /* LINTED - alignment */
+ pc = *((uint32_t *)addr);
+ break;
+
+ case sizeof (uint64_t):
+ /* LINTED - alignment */
+ pc = *((uint64_t *)addr);
+ break;
+
+ default:
+ return (dt_set_errno(dtp, EDT_BADSTACKPC));
+ }
+
+ if (pc == 0 /*VBOX: NULL is a ptr */)
+ break;
+
+ addr += size;
+
+ if (dt_printf(dtp, fp, "%*s", indent, "") < 0)
+ return (-1);
+
+ if (dtrace_lookup_by_addr(dtp, pc, &sym, &dts) == 0) {
+ if (pc > sym.st_value) {
+ (void) snprintf(c, sizeof (c), "%s`%s+0x%llx",
+ dts.dts_object, dts.dts_name,
+ pc - sym.st_value);
+ } else {
+ (void) snprintf(c, sizeof (c), "%s`%s",
+ dts.dts_object, dts.dts_name);
+ }
+ } else {
+ /*
+ * We'll repeat the lookup, but this time we'll specify
+ * a NULL GElf_Sym -- indicating that we're only
+ * interested in the containing module.
+ */
+ if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0) {
+ (void) snprintf(c, sizeof (c), "%s`0x%llx",
+ dts.dts_object, pc);
+ } else {
+ (void) snprintf(c, sizeof (c), "0x%llx", pc);
+ }
+ }
+
+ if (dt_printf(dtp, fp, format, c) < 0)
+ return (-1);
+
+ if (dt_printf(dtp, fp, "\n") < 0)
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
+dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ caddr_t addr, uint64_t arg)
+{
+ /* LINTED - alignment */
+ uint64_t *pc = (uint64_t *)addr;
+ uint32_t depth = DTRACE_USTACK_NFRAMES(arg);
+ uint32_t strsize = DTRACE_USTACK_STRSIZE(arg);
+ const char *strbase = addr + (depth + 1) * sizeof (uint64_t);
+ const char *str = strsize ? strbase : NULL;
+ int err = 0;
+
+#ifndef VBOX
+ char name[PATH_MAX], objname[PATH_MAX], c[PATH_MAX * 2];
+ struct ps_prochandle *P;
+ GElf_Sym sym;
+#else
+ char c[PATH_MAX * 2];
+#endif
+ int i, indent;
+ pid_t pid;
+
+ if (depth == 0)
+ return (0);
+
+ pid = (pid_t)*pc++;
+
+ if (dt_printf(dtp, fp, "\n") < 0)
+ return (-1);
+
+ if (format == NULL)
+ format = "%s";
+
+ if (dtp->dt_options[DTRACEOPT_STACKINDENT] != DTRACEOPT_UNSET)
+ indent = (int)dtp->dt_options[DTRACEOPT_STACKINDENT];
+ else
+ indent = _dtrace_stkindent;
+
+ /*
+ * Ultimately, we need to add an entry point in the library vector for
+ * determining <symbol, offset> from <pid, address>. For now, if
+ * this is a vector open, we just print the raw address or string.
+ */
+#ifndef VBOX
+ if (dtp->dt_vector == NULL)
+ P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0);
+ else
+ P = NULL;
+
+ if (P != NULL)
+ dt_proc_lock(dtp, P); /* lock handle while we perform lookups */
+#endif
+
+ for (i = 0; VBDTCAST(uint_t)i < depth && pc[i] != 0/*NULL*/; i++) {
+#ifndef VBOX
+ const prmap_t *map;
+#endif
+
+ if ((err = dt_printf(dtp, fp, "%*s", indent, "")) < 0)
+ break;
+
+#ifndef VBOX
+ if (P != NULL && Plookup_by_addr(P, pc[i],
+ name, sizeof (name), &sym) == 0) {
+ (void) Pobjname(P, pc[i], objname, sizeof (objname));
+
+ if (pc[i] > sym.st_value) {
+ (void) snprintf(c, sizeof (c),
+ "%s`%s+0x%llx", dt_basename(objname), name,
+ (u_longlong_t)(pc[i] - sym.st_value));
+ } else {
+ (void) snprintf(c, sizeof (c),
+ "%s`%s", dt_basename(objname), name);
+ }
+ } else if (str != NULL && str[0] != '\0' && str[0] != '@' &&
+ (P != NULL && ((map = Paddr_to_map(P, pc[i])) == NULL ||
+ (map->pr_mflags & MA_WRITE)))) {
+ /*
+ * If the current string pointer in the string table
+ * does not point to an empty string _and_ the program
+ * counter falls in a writable region, we'll use the
+ * string from the string table instead of the raw
+ * address. This last condition is necessary because
+ * some (broken) ustack helpers will return a string
+ * even for a program counter that they can't
+ * identify. If we have a string for a program
+ * counter that falls in a segment that isn't
+ * writable, we assume that we have fallen into this
+ * case and we refuse to use the string.
+ */
+ (void) snprintf(c, sizeof (c), "%s", str);
+ } else {
+ if (P != NULL && Pobjname(P, pc[i], objname,
+ sizeof (objname)) != NULL) {
+ (void) snprintf(c, sizeof (c), "%s`0x%llx",
+ dt_basename(objname), (u_longlong_t)pc[i]);
+ } else {
+#else
+ { {
+#endif
+ (void) snprintf(c, sizeof (c), "0x%llx",
+ (u_longlong_t)pc[i]);
+ }
+ }
+
+ if ((err = dt_printf(dtp, fp, format, c)) < 0)
+ break;
+
+ if ((err = dt_printf(dtp, fp, "\n")) < 0)
+ break;
+
+ if (str != NULL && str[0] == '@') {
+ /*
+ * If the first character of the string is an "at" sign,
+ * then the string is inferred to be an annotation --
+ * and it is printed out beneath the frame and offset
+ * with brackets.
+ */
+ if ((err = dt_printf(dtp, fp, "%*s", indent, "")) < 0)
+ break;
+
+ (void) snprintf(c, sizeof (c), " [ %s ]", &str[1]);
+
+ if ((err = dt_printf(dtp, fp, format, c)) < 0)
+ break;
+
+ if ((err = dt_printf(dtp, fp, "\n")) < 0)
+ break;
+ }
+
+ if (str != NULL) {
+ str += strlen(str) + 1;
+ if ((uintptr_t/*vbox*/)(str - strbase) >= strsize)
+ str = NULL;
+ }
+ }
+
+#ifndef VBOX
+ if (P != NULL) {
+ dt_proc_unlock(dtp, P);
+ dt_proc_release(dtp, P);
+ }
+#endif
+
+ return (err);
+}
+
+static int
+dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act)
+{
+ /* LINTED - alignment */
+ uint64_t pid = ((uint64_t *)addr)[0];
+ /* LINTED - alignment */
+ uint64_t pc = ((uint64_t *)addr)[1];
+ const char *format = " %-50s";
+ char *s;
+ int n, len = 256;
+
+#ifndef VBOX
+ if (act == DTRACEACT_USYM && dtp->dt_vector == NULL) {
+ struct ps_prochandle *P;
+
+ if ((P = dt_proc_grab(dtp, pid,
+ PGRAB_RDONLY | PGRAB_FORCE, 0)) != NULL) {
+ GElf_Sym sym;
+
+ dt_proc_lock(dtp, P);
+
+ if (Plookup_by_addr(P, pc, NULL, 0, &sym) == 0)
+ pc = sym.st_value;
+
+ dt_proc_unlock(dtp, P);
+ dt_proc_release(dtp, P);
+ }
+ }
+#else
+ RT_NOREF1(act);
+#endif
+
+ do {
+ n = len;
+ s = alloca(n);
+ } while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) > n);
+
+ return (dt_printf(dtp, fp, format, s));
+}
+
+int
+dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
+{
+ /* LINTED - alignment */
+ uint64_t pid = ((uint64_t *)addr)[0];
+ /* LINTED - alignment */
+ uint64_t pc = ((uint64_t *)addr)[1];
+ int err = 0;
+
+#ifndef VBOX
+ char objname[PATH_MAX], c[PATH_MAX * 2];
+ struct ps_prochandle *P;
+#else
+ char c[64];
+#endif
+
+ if (format == NULL)
+ format = " %-50s";
+
+#ifndef VBOX
+ /*
+ * See the comment in dt_print_ustack() for the rationale for
+ * printing raw addresses in the vectored case.
+ */
+ if (dtp->dt_vector == NULL)
+ P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0);
+ else
+ P = NULL;
+
+ if (P != NULL)
+ dt_proc_lock(dtp, P); /* lock handle while we perform lookups */
+
+ if (P != NULL && Pobjname(P, pc, objname, sizeof (objname)) != NULL) {
+ (void) snprintf(c, sizeof (c), "%s", dt_basename(objname));
+ } else {
+ (void) snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc);
+ }
+
+ err = dt_printf(dtp, fp, format, c);
+
+ if (P != NULL) {
+ dt_proc_unlock(dtp, P);
+ dt_proc_release(dtp, P);
+ }
+#else /* VBOX */
+ RT_NOREF_PV(pid);
+ snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc);
+ err = dt_printf(dtp, fp, format, c);
+#endif /* VBOX */
+
+ return (err);
+}
+
+static int
+dt_print_sym(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
+{
+ /* LINTED - alignment */
+ uint64_t pc = *((uint64_t *)addr);
+ dtrace_syminfo_t dts;
+ GElf_Sym sym;
+ char c[PATH_MAX * 2];
+
+ if (format == NULL)
+ format = " %-50s";
+
+ if (dtrace_lookup_by_addr(dtp, pc, &sym, &dts) == 0) {
+ (void) snprintf(c, sizeof (c), "%s`%s",
+ dts.dts_object, dts.dts_name);
+ } else {
+ /*
+ * We'll repeat the lookup, but this time we'll specify a
+ * NULL GElf_Sym -- indicating that we're only interested in
+ * the containing module.
+ */
+ if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0) {
+ (void) snprintf(c, sizeof (c), "%s`0x%llx",
+ dts.dts_object, (u_longlong_t)pc);
+ } else {
+ (void) snprintf(c, sizeof (c), "0x%llx",
+ (u_longlong_t)pc);
+ }
+ }
+
+ if (dt_printf(dtp, fp, format, c) < 0)
+ return (-1);
+
+ return (0);
+}
+
+int
+dt_print_mod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
+{
+ /* LINTED - alignment */
+ uint64_t pc = *((uint64_t *)addr);
+ dtrace_syminfo_t dts;
+ char c[PATH_MAX * 2];
+
+ if (format == NULL)
+ format = " %-50s";
+
+ if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0) {
+ (void) snprintf(c, sizeof (c), "%s", dts.dts_object);
+ } else {
+ (void) snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc);
+ }
+
+ if (dt_printf(dtp, fp, format, c) < 0)
+ return (-1);
+
+ return (0);
+}
+
+typedef struct dt_normal {
+ dtrace_aggvarid_t dtnd_id;
+ uint64_t dtnd_normal;
+} dt_normal_t;
+
+static int
+dt_normalize_agg(const dtrace_aggdata_t *aggdata, void *arg)
+{
+ dt_normal_t *normal = arg;
+ dtrace_aggdesc_t *agg = aggdata->dtada_desc;
+ dtrace_aggvarid_t id = normal->dtnd_id;
+
+ if (agg->dtagd_nrecs == 0)
+ return (DTRACE_AGGWALK_NEXT);
+
+ if (agg->dtagd_varid != id)
+ return (DTRACE_AGGWALK_NEXT);
+
+ ((dtrace_aggdata_t *)aggdata)->dtada_normal = normal->dtnd_normal;
+ return (DTRACE_AGGWALK_NORMALIZE);
+}
+
+static int
+dt_normalize(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec)
+{
+ dt_normal_t normal;
+ caddr_t addr;
+
+ /*
+ * We (should) have two records: the aggregation ID followed by the
+ * normalization value.
+ */
+ addr = base + rec->dtrd_offset;
+
+ if (rec->dtrd_size != sizeof (dtrace_aggvarid_t))
+ return (dt_set_errno(dtp, EDT_BADNORMAL));
+
+ /* LINTED - alignment */
+ normal.dtnd_id = *((dtrace_aggvarid_t *)addr);
+ rec++;
+
+ if (rec->dtrd_action != DTRACEACT_LIBACT)
+ return (dt_set_errno(dtp, EDT_BADNORMAL));
+
+ if (rec->dtrd_arg != DT_ACT_NORMALIZE)
+ return (dt_set_errno(dtp, EDT_BADNORMAL));
+
+ addr = base + rec->dtrd_offset;
+
+ switch (rec->dtrd_size) {
+ case sizeof (uint64_t):
+ /* LINTED - alignment */
+ normal.dtnd_normal = *((uint64_t *)addr);
+ break;
+ case sizeof (uint32_t):
+ /* LINTED - alignment */
+ normal.dtnd_normal = *((uint32_t *)addr);
+ break;
+ case sizeof (uint16_t):
+ /* LINTED - alignment */
+ normal.dtnd_normal = *((uint16_t *)addr);
+ break;
+ case sizeof (uint8_t):
+ normal.dtnd_normal = *((uint8_t *)addr);
+ break;
+ default:
+ return (dt_set_errno(dtp, EDT_BADNORMAL));
+ }
+
+ (void) dtrace_aggregate_walk(dtp, dt_normalize_agg, &normal);
+
+ return (0);
+}
+
+static int
+dt_denormalize_agg(const dtrace_aggdata_t *aggdata, void *arg)
+{
+ dtrace_aggdesc_t *agg = aggdata->dtada_desc;
+ dtrace_aggvarid_t id = *((dtrace_aggvarid_t *)arg);
+
+ if (agg->dtagd_nrecs == 0)
+ return (DTRACE_AGGWALK_NEXT);
+
+ if (agg->dtagd_varid != id)
+ return (DTRACE_AGGWALK_NEXT);
+
+ return (DTRACE_AGGWALK_DENORMALIZE);
+}
+
+static int
+dt_clear_agg(const dtrace_aggdata_t *aggdata, void *arg)
+{
+ dtrace_aggdesc_t *agg = aggdata->dtada_desc;
+ dtrace_aggvarid_t id = *((dtrace_aggvarid_t *)arg);
+
+ if (agg->dtagd_nrecs == 0)
+ return (DTRACE_AGGWALK_NEXT);
+
+ if (agg->dtagd_varid != id)
+ return (DTRACE_AGGWALK_NEXT);
+
+ return (DTRACE_AGGWALK_CLEAR);
+}
+
+typedef struct dt_trunc {
+ dtrace_aggvarid_t dttd_id;
+ uint64_t dttd_remaining;
+} dt_trunc_t;
+
+static int
+dt_trunc_agg(const dtrace_aggdata_t *aggdata, void *arg)
+{
+ dt_trunc_t *trunc = arg;
+ dtrace_aggdesc_t *agg = aggdata->dtada_desc;
+ dtrace_aggvarid_t id = trunc->dttd_id;
+
+ if (agg->dtagd_nrecs == 0)
+ return (DTRACE_AGGWALK_NEXT);
+
+ if (agg->dtagd_varid != id)
+ return (DTRACE_AGGWALK_NEXT);
+
+ if (trunc->dttd_remaining == 0)
+ return (DTRACE_AGGWALK_REMOVE);
+
+ trunc->dttd_remaining--;
+ return (DTRACE_AGGWALK_NEXT);
+}
+
+static int
+dt_trunc(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec)
+{
+ dt_trunc_t trunc;
+ caddr_t addr;
+ int64_t remaining;
+ int (*func)(dtrace_hdl_t *, dtrace_aggregate_f *, void *);
+
+ /*
+ * We (should) have two records: the aggregation ID followed by the
+ * number of aggregation entries after which the aggregation is to be
+ * truncated.
+ */
+ addr = base + rec->dtrd_offset;
+
+ if (rec->dtrd_size != sizeof (dtrace_aggvarid_t))
+ return (dt_set_errno(dtp, EDT_BADTRUNC));
+
+ /* LINTED - alignment */
+ trunc.dttd_id = *((dtrace_aggvarid_t *)addr);
+ rec++;
+
+ if (rec->dtrd_action != DTRACEACT_LIBACT)
+ return (dt_set_errno(dtp, EDT_BADTRUNC));
+
+ if (rec->dtrd_arg != DT_ACT_TRUNC)
+ return (dt_set_errno(dtp, EDT_BADTRUNC));
+
+ addr = base + rec->dtrd_offset;
+
+ switch (rec->dtrd_size) {
+ case sizeof (uint64_t):
+ /* LINTED - alignment */
+ remaining = *((int64_t *)addr);
+ break;
+ case sizeof (uint32_t):
+ /* LINTED - alignment */
+ remaining = *((int32_t *)addr);
+ break;
+ case sizeof (uint16_t):
+ /* LINTED - alignment */
+ remaining = *((int16_t *)addr);
+ break;
+ case sizeof (uint8_t):
+ remaining = *((int8_t *)addr);
+ break;
+ default:
+ return (dt_set_errno(dtp, EDT_BADNORMAL));
+ }
+
+ if (remaining < 0) {
+ func = dtrace_aggregate_walk_valsorted;
+ remaining = -remaining;
+ } else {
+ func = dtrace_aggregate_walk_valrevsorted;
+ }
+
+ assert(remaining >= 0);
+ trunc.dttd_remaining = remaining;
+
+ (void) func(dtp, dt_trunc_agg, &trunc);
+
+ return (0);
+}
+
+static int
+dt_print_datum(dtrace_hdl_t *dtp, FILE *fp, dtrace_recdesc_t *rec,
+ caddr_t addr, size_t size, uint64_t normal)
+{
+ int err;
+ dtrace_actkind_t act = rec->dtrd_action;
+
+ switch (act) {
+ case DTRACEACT_STACK:
+ return (dt_print_stack(dtp, fp, NULL, addr,
+ rec->dtrd_arg, rec->dtrd_size / rec->dtrd_arg));
+
+ case DTRACEACT_USTACK:
+ case DTRACEACT_JSTACK:
+ return (dt_print_ustack(dtp, fp, NULL, addr, rec->dtrd_arg));
+
+ case DTRACEACT_USYM:
+ case DTRACEACT_UADDR:
+ return (dt_print_usym(dtp, fp, addr, act));
+
+ case DTRACEACT_UMOD:
+ return (dt_print_umod(dtp, fp, NULL, addr));
+
+ case DTRACEACT_SYM:
+ return (dt_print_sym(dtp, fp, NULL, addr));
+
+ case DTRACEACT_MOD:
+ return (dt_print_mod(dtp, fp, NULL, addr));
+
+ case DTRACEAGG_QUANTIZE:
+ return (dt_print_quantize(dtp, fp, addr, size, normal));
+
+ case DTRACEAGG_LQUANTIZE:
+ return (dt_print_lquantize(dtp, fp, addr, size, normal));
+
+ case DTRACEAGG_AVG:
+ return (dt_print_average(dtp, fp, addr, size, normal));
+
+ case DTRACEAGG_STDDEV:
+ return (dt_print_stddev(dtp, fp, addr, size, normal));
+
+ default:
+ break;
+ }
+
+ switch (size) {
+ case sizeof (uint64_t):
+ err = dt_printf(dtp, fp, " %16lld",
+ /* LINTED - alignment */
+ (long long)*((uint64_t *)addr) / normal);
+ break;
+ case sizeof (uint32_t):
+ /* LINTED - alignment */
+ err = dt_printf(dtp, fp, " %8d", *((uint32_t *)addr) /
+ (uint32_t)normal);
+ break;
+ case sizeof (uint16_t):
+ /* LINTED - alignment */
+ err = dt_printf(dtp, fp, " %5d", *((uint16_t *)addr) /
+ (uint32_t)normal);
+ break;
+ case sizeof (uint8_t):
+ err = dt_printf(dtp, fp, " %3d", *((uint8_t *)addr) /
+ (uint32_t)normal);
+ break;
+ default:
+ err = dt_print_bytes(dtp, fp, addr, size, 50, 0);
+ break;
+ }
+
+ return (err);
+}
+
+int
+dt_print_aggs(const dtrace_aggdata_t **aggsdata, int naggvars, void *arg)
+{
+ int i, aggact = 0;
+ dt_print_aggdata_t *pd = arg;
+ const dtrace_aggdata_t *aggdata = aggsdata[0];
+ dtrace_aggdesc_t *agg = aggdata->dtada_desc;
+ FILE *fp = pd->dtpa_fp;
+ dtrace_hdl_t *dtp = pd->dtpa_dtp;
+ dtrace_recdesc_t *rec;
+ dtrace_actkind_t act;
+ caddr_t addr;
+ size_t size;
+
+ /*
+ * Iterate over each record description in the key, printing the traced
+ * data, skipping the first datum (the tuple member created by the
+ * compiler).
+ */
+ for (i = 1; i < agg->dtagd_nrecs; i++) {
+ rec = &agg->dtagd_rec[i];
+ act = rec->dtrd_action;
+ addr = aggdata->dtada_data + rec->dtrd_offset;
+ size = rec->dtrd_size;
+
+ if (DTRACEACT_ISAGG(act)) {
+ aggact = i;
+ break;
+ }
+
+ if (dt_print_datum(dtp, fp, rec, addr, size, 1) < 0)
+ return (-1);
+
+ if (dt_buffered_flush(dtp, NULL, rec, aggdata,
+ DTRACE_BUFDATA_AGGKEY) < 0)
+ return (-1);
+ }
+
+ assert(aggact != 0);
+
+ for (i = (naggvars == 1 ? 0 : 1); i < naggvars; i++) {
+ uint64_t normal;
+
+ aggdata = aggsdata[i];
+ agg = aggdata->dtada_desc;
+ rec = &agg->dtagd_rec[aggact];
+ act = rec->dtrd_action;
+ addr = aggdata->dtada_data + rec->dtrd_offset;
+ size = rec->dtrd_size;
+
+ assert(DTRACEACT_ISAGG(act));
+ normal = aggdata->dtada_normal;
+
+ if (dt_print_datum(dtp, fp, rec, addr, size, normal) < 0)
+ return (-1);
+
+ if (dt_buffered_flush(dtp, NULL, rec, aggdata,
+ DTRACE_BUFDATA_AGGVAL) < 0)
+ return (-1);
+
+ if (!pd->dtpa_allunprint)
+ agg->dtagd_flags |= DTRACE_AGD_PRINTED;
+ }
+
+ if (dt_printf(dtp, fp, "\n") < 0)
+ return (-1);
+
+ if (dt_buffered_flush(dtp, NULL, NULL, aggdata,
+ DTRACE_BUFDATA_AGGFORMAT | DTRACE_BUFDATA_AGGLAST) < 0)
+ return (-1);
+
+ return (0);
+}
+
+int
+dt_print_agg(const dtrace_aggdata_t *aggdata, void *arg)
+{
+ dt_print_aggdata_t *pd = arg;
+ dtrace_aggdesc_t *agg = aggdata->dtada_desc;
+ dtrace_aggvarid_t aggvarid = pd->dtpa_id;
+
+ if (pd->dtpa_allunprint) {
+ if (agg->dtagd_flags & DTRACE_AGD_PRINTED)
+ return (0);
+ } else {
+ /*
+ * If we're not printing all unprinted aggregations, then the
+ * aggregation variable ID denotes a specific aggregation
+ * variable that we should print -- skip any other aggregations
+ * that we encounter.
+ */
+ if (agg->dtagd_nrecs == 0)
+ return (0);
+
+ if (aggvarid != agg->dtagd_varid)
+ return (0);
+ }
+
+ return (dt_print_aggs(&aggdata, 1, arg));
+}
+
+int
+dt_setopt(dtrace_hdl_t *dtp, const dtrace_probedata_t *data,
+ const char *option, const char *value)
+{
+#ifndef VBOX
+ int len, rval;
+#else
+ size_t len;
+ int rval;
+#endif
+ char *msg;
+ const char *errstr;
+ dtrace_setoptdata_t optdata;
+
+ bzero(&optdata, sizeof (optdata));
+ (void) dtrace_getopt(dtp, option, &optdata.dtsda_oldval);
+
+ if (dtrace_setopt(dtp, option, value) == 0) {
+ (void) dtrace_getopt(dtp, option, &optdata.dtsda_newval);
+ optdata.dtsda_probe = data;
+ optdata.dtsda_option = option;
+ optdata.dtsda_handle = dtp;
+
+ if ((rval = dt_handle_setopt(dtp, &optdata)) != 0)
+ return (rval);
+
+ return (0);
+ }
+
+ errstr = dtrace_errmsg(dtp, dtrace_errno(dtp));
+ len = strlen(option) + strlen(value) + strlen(errstr) + 80;
+ msg = alloca(len);
+
+ (void) snprintf(msg, len, "couldn't set option \"%s\" to \"%s\": %s\n",
+ option, value, errstr);
+
+ if ((rval = dt_handle_liberr(dtp, data, msg)) == 0)
+ return (0);
+
+ return (rval);
+}
+
+static int
+dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, dtrace_bufdesc_t *buf,
+ dtrace_consume_probe_f *efunc, dtrace_consume_rec_f *rfunc, void *arg)
+{
+ dtrace_epid_t id;
+ size_t offs, start = buf->dtbd_oldest, end = buf->dtbd_size;
+ int flow = (dtp->dt_options[DTRACEOPT_FLOWINDENT] != DTRACEOPT_UNSET);
+ int quiet = (dtp->dt_options[DTRACEOPT_QUIET] != DTRACEOPT_UNSET);
+ int rval, i, n;
+ dtrace_epid_t last = DTRACE_EPIDNONE;
+ dtrace_probedata_t data;
+ uint64_t drops;
+ caddr_t addr;
+
+ bzero(&data, sizeof (data));
+ data.dtpda_handle = dtp;
+ data.dtpda_cpu = cpu;
+
+again:
+ for (offs = start; offs < end; ) {
+ dtrace_eprobedesc_t *epd;
+
+ /*
+ * We're guaranteed to have an ID.
+ */
+ id = *(uint32_t *)((uintptr_t)buf->dtbd_data + offs);
+
+ if (id == DTRACE_EPIDNONE) {
+ /*
+ * This is filler to assure proper alignment of the
+ * next record; we simply ignore it.
+ */
+ offs += sizeof (id);
+ continue;
+ }
+
+ if ((rval = dt_epid_lookup(dtp, id, &data.dtpda_edesc,
+ &data.dtpda_pdesc)) != 0)
+ return (rval);
+
+ epd = data.dtpda_edesc;
+ data.dtpda_data = buf->dtbd_data + offs;
+
+ if (data.dtpda_edesc->dtepd_uarg != DT_ECB_DEFAULT) {
+ rval = dt_handle(dtp, &data);
+
+ if (rval == DTRACE_CONSUME_NEXT)
+ goto nextepid;
+
+ if (rval == DTRACE_CONSUME_ERROR)
+ return (-1);
+ }
+
+ if (flow)
+ (void) dt_flowindent(dtp, &data, last, buf, offs);
+
+ rval = (*efunc)(&data, arg);
+
+ if (flow) {
+ if (data.dtpda_flow == DTRACEFLOW_ENTRY)
+ data.dtpda_indent += 2;
+ }
+
+ if (rval == DTRACE_CONSUME_NEXT)
+ goto nextepid;
+
+ if (rval == DTRACE_CONSUME_ABORT)
+ return (dt_set_errno(dtp, EDT_DIRABORT));
+
+ if (rval != DTRACE_CONSUME_THIS)
+ return (dt_set_errno(dtp, EDT_BADRVAL));
+
+ for (i = 0; i < epd->dtepd_nrecs; i++) {
+ dtrace_recdesc_t *rec = &epd->dtepd_rec[i];
+ dtrace_actkind_t act = rec->dtrd_action;
+
+ data.dtpda_data = buf->dtbd_data + offs +
+ rec->dtrd_offset;
+ addr = data.dtpda_data;
+
+ if (act == DTRACEACT_LIBACT) {
+ uint64_t arg = rec->dtrd_arg;
+ dtrace_aggvarid_t id;
+
+ switch (arg) {
+ case DT_ACT_CLEAR:
+ /* LINTED - alignment */
+ id = *((dtrace_aggvarid_t *)addr);
+ (void) dtrace_aggregate_walk(dtp,
+ dt_clear_agg, &id);
+ continue;
+
+ case DT_ACT_DENORMALIZE:
+ /* LINTED - alignment */
+ id = *((dtrace_aggvarid_t *)addr);
+ (void) dtrace_aggregate_walk(dtp,
+ dt_denormalize_agg, &id);
+ continue;
+
+ case DT_ACT_FTRUNCATE:
+ {
+ int res;
+ if (fp == NULL)
+ continue;
+
+ (void) fflush(fp);
+ res = ftruncate(fileno(fp), 0);
+ NOREF(res);
+ (void) fseeko(fp, 0, SEEK_SET);
+ continue;
+ }
+ case DT_ACT_NORMALIZE:
+ if (i == epd->dtepd_nrecs - 1)
+ return (dt_set_errno(dtp,
+ EDT_BADNORMAL));
+
+ if (dt_normalize(dtp,
+ buf->dtbd_data + offs, rec) != 0)
+ return (-1);
+
+ i++;
+ continue;
+
+ case DT_ACT_SETOPT: {
+ uint64_t *opts = dtp->dt_options;
+ dtrace_recdesc_t *valrec;
+ uint32_t valsize;
+ caddr_t val;
+ int rv;
+
+ if (i == epd->dtepd_nrecs - 1) {
+ return (dt_set_errno(dtp,
+ EDT_BADSETOPT));
+ }
+
+ valrec = &epd->dtepd_rec[++i];
+ valsize = valrec->dtrd_size;
+
+ if (valrec->dtrd_action != act ||
+ valrec->dtrd_arg != arg) {
+ return (dt_set_errno(dtp,
+ EDT_BADSETOPT));
+ }
+
+ if (valsize > sizeof (uint64_t)) {
+ val = buf->dtbd_data + offs +
+ valrec->dtrd_offset;
+ } else {
+ val = "1";
+ }
+
+ rv = dt_setopt(dtp, &data, addr, val);
+
+ if (rv != 0)
+ return (-1);
+
+ flow = (opts[DTRACEOPT_FLOWINDENT] !=
+ DTRACEOPT_UNSET);
+ quiet = (opts[DTRACEOPT_QUIET] !=
+ DTRACEOPT_UNSET);
+
+ continue;
+ }
+
+ case DT_ACT_TRUNC:
+ if (i == epd->dtepd_nrecs - 1)
+ return (dt_set_errno(dtp,
+ EDT_BADTRUNC));
+
+ if (dt_trunc(dtp,
+ buf->dtbd_data + offs, rec) != 0)
+ return (-1);
+
+ i++;
+ continue;
+
+ default:
+ continue;
+ }
+ }
+
+ rval = (*rfunc)(&data, rec, arg);
+
+ if (rval == DTRACE_CONSUME_NEXT)
+ continue;
+
+ if (rval == DTRACE_CONSUME_ABORT)
+ return (dt_set_errno(dtp, EDT_DIRABORT));
+
+ if (rval != DTRACE_CONSUME_THIS)
+ return (dt_set_errno(dtp, EDT_BADRVAL));
+
+ if (act == DTRACEACT_STACK) {
+ int depth = rec->dtrd_arg;
+
+ if (dt_print_stack(dtp, fp, NULL, addr, depth,
+ rec->dtrd_size / depth) < 0)
+ return (-1);
+ goto nextrec;
+ }
+
+ if (act == DTRACEACT_USTACK ||
+ act == DTRACEACT_JSTACK) {
+ if (dt_print_ustack(dtp, fp, NULL,
+ addr, rec->dtrd_arg) < 0)
+ return (-1);
+ goto nextrec;
+ }
+
+ if (act == DTRACEACT_SYM) {
+ if (dt_print_sym(dtp, fp, NULL, addr) < 0)
+ return (-1);
+ goto nextrec;
+ }
+
+ if (act == DTRACEACT_MOD) {
+ if (dt_print_mod(dtp, fp, NULL, addr) < 0)
+ return (-1);
+ goto nextrec;
+ }
+
+ if (act == DTRACEACT_USYM || act == DTRACEACT_UADDR) {
+ if (dt_print_usym(dtp, fp, addr, act) < 0)
+ return (-1);
+ goto nextrec;
+ }
+
+ if (act == DTRACEACT_UMOD) {
+ if (dt_print_umod(dtp, fp, NULL, addr) < 0)
+ return (-1);
+ goto nextrec;
+ }
+
+ if (DTRACEACT_ISPRINTFLIKE(act)) {
+ void *fmtdata;
+ int (*func)(dtrace_hdl_t *, FILE *, void *,
+ const dtrace_probedata_t *,
+ const dtrace_recdesc_t *, uint_t,
+ const void *buf, size_t) VBDTMSC(NULL);
+
+ if ((fmtdata = dt_format_lookup(dtp,
+ rec->dtrd_format)) == NULL)
+ goto nofmt;
+
+ switch (act) {
+ case DTRACEACT_PRINTF:
+ func = dtrace_fprintf;
+ break;
+ case DTRACEACT_PRINTA:
+ func = dtrace_fprinta;
+ break;
+ case DTRACEACT_SYSTEM:
+ func = dtrace_system;
+ break;
+ case DTRACEACT_FREOPEN:
+ func = dtrace_freopen;
+ break;
+ }
+
+ n = (*func)(dtp, fp, fmtdata, &data,
+ rec, epd->dtepd_nrecs - i,
+ (uchar_t *)buf->dtbd_data + offs,
+ buf->dtbd_size - offs);
+
+ if (n < 0)
+ return (-1); /* errno is set for us */
+
+ if (n > 0)
+ i += n - 1;
+ goto nextrec;
+ }
+
+nofmt:
+ if (act == DTRACEACT_PRINTA) {
+ dt_print_aggdata_t pd;
+ dtrace_aggvarid_t *aggvars;
+ int j, naggvars = 0;
+ size_t size = ((epd->dtepd_nrecs - i) *
+ sizeof (dtrace_aggvarid_t));
+
+ if ((aggvars = dt_alloc(dtp, size)) == NULL)
+ return (-1);
+
+ /*
+ * This might be a printa() with multiple
+ * aggregation variables. We need to scan
+ * forward through the records until we find
+ * a record from a different statement.
+ */
+ for (j = i; j < epd->dtepd_nrecs; j++) {
+ dtrace_recdesc_t *nrec;
+ caddr_t naddr;
+
+ nrec = &epd->dtepd_rec[j];
+
+ if (nrec->dtrd_uarg != rec->dtrd_uarg)
+ break;
+
+ if (nrec->dtrd_action != act) {
+ return (dt_set_errno(dtp,
+ EDT_BADAGG));
+ }
+
+ naddr = buf->dtbd_data + offs +
+ nrec->dtrd_offset;
+
+ aggvars[naggvars++] =
+ /* LINTED - alignment */
+ *((dtrace_aggvarid_t *)naddr);
+ }
+
+ i = j - 1;
+ bzero(&pd, sizeof (pd));
+ pd.dtpa_dtp = dtp;
+ pd.dtpa_fp = fp;
+
+ assert(naggvars >= 1);
+
+ if (naggvars == 1) {
+ pd.dtpa_id = aggvars[0];
+ dt_free(dtp, aggvars);
+
+ if (dt_printf(dtp, fp, "\n") < 0 ||
+ dtrace_aggregate_walk_sorted(dtp,
+ dt_print_agg, &pd) < 0)
+ return (-1);
+ goto nextrec;
+ }
+
+ if (dt_printf(dtp, fp, "\n") < 0 ||
+ dtrace_aggregate_walk_joined(dtp, aggvars,
+ naggvars, dt_print_aggs, &pd) < 0) {
+ dt_free(dtp, aggvars);
+ return (-1);
+ }
+
+ dt_free(dtp, aggvars);
+ goto nextrec;
+ }
+
+ switch (rec->dtrd_size) {
+ case sizeof (uint64_t):
+ n = dt_printf(dtp, fp,
+ quiet ? "%lld" : " %16lld",
+ /* LINTED - alignment */
+ *((unsigned long long *)addr));
+ break;
+ case sizeof (uint32_t):
+ n = dt_printf(dtp, fp, quiet ? "%d" : " %8d",
+ /* LINTED - alignment */
+ *((uint32_t *)addr));
+ break;
+ case sizeof (uint16_t):
+ n = dt_printf(dtp, fp, quiet ? "%d" : " %5d",
+ /* LINTED - alignment */
+ *((uint16_t *)addr));
+ break;
+ case sizeof (uint8_t):
+ n = dt_printf(dtp, fp, quiet ? "%d" : " %3d",
+ *((uint8_t *)addr));
+ break;
+ default:
+ n = dt_print_bytes(dtp, fp, addr,
+ rec->dtrd_size, 33, quiet);
+ break;
+ }
+
+ if (n < 0)
+ return (-1); /* errno is set for us */
+
+nextrec:
+ if (dt_buffered_flush(dtp, &data, rec, NULL, 0) < 0)
+ return (-1); /* errno is set for us */
+ }
+
+ /*
+ * Call the record callback with a NULL record to indicate
+ * that we're done processing this EPID.
+ */
+ rval = (*rfunc)(&data, NULL, arg);
+nextepid:
+ offs += epd->dtepd_size;
+ last = id;
+ }
+
+ if (buf->dtbd_oldest != 0 && start == buf->dtbd_oldest) {
+ end = buf->dtbd_oldest;
+ start = 0;
+ goto again;
+ }
+
+ if ((drops = buf->dtbd_drops) == 0)
+ return (0);
+
+ /*
+ * Explicitly zero the drops to prevent us from processing them again.
+ */
+ buf->dtbd_drops = 0;
+
+ return (dt_handle_cpudrop(dtp, cpu, DTRACEDROP_PRINCIPAL, drops));
+}
+
+typedef struct dt_begin {
+ dtrace_consume_probe_f *dtbgn_probefunc;
+ dtrace_consume_rec_f *dtbgn_recfunc;
+ void *dtbgn_arg;
+ dtrace_handle_err_f *dtbgn_errhdlr;
+ void *dtbgn_errarg;
+ int dtbgn_beginonly;
+} dt_begin_t;
+
+static int
+dt_consume_begin_probe(const dtrace_probedata_t *data, void *arg)
+{
+ dt_begin_t *begin = (dt_begin_t *)arg;
+ dtrace_probedesc_t *pd = data->dtpda_pdesc;
+
+ int r1 = (strcmp(pd->dtpd_provider, "dtrace") == 0);
+ int r2 = (strcmp(pd->dtpd_name, "BEGIN") == 0);
+
+ if (begin->dtbgn_beginonly) {
+ if (!(r1 && r2))
+ return (DTRACE_CONSUME_NEXT);
+ } else {
+ if (r1 && r2)
+ return (DTRACE_CONSUME_NEXT);
+ }
+
+ /*
+ * We have a record that we're interested in. Now call the underlying
+ * probe function...
+ */
+ return (begin->dtbgn_probefunc(data, begin->dtbgn_arg));
+}
+
+static int
+dt_consume_begin_record(const dtrace_probedata_t *data,
+ const dtrace_recdesc_t *rec, void *arg)
+{
+ dt_begin_t *begin = (dt_begin_t *)arg;
+
+ return (begin->dtbgn_recfunc(data, rec, begin->dtbgn_arg));
+}
+
+static int
+dt_consume_begin_error(const dtrace_errdata_t *data, void *arg)
+{
+ dt_begin_t *begin = (dt_begin_t *)arg;
+ dtrace_probedesc_t *pd = data->dteda_pdesc;
+
+ int r1 = (strcmp(pd->dtpd_provider, "dtrace") == 0);
+ int r2 = (strcmp(pd->dtpd_name, "BEGIN") == 0);
+
+ if (begin->dtbgn_beginonly) {
+ if (!(r1 && r2))
+ return (DTRACE_HANDLE_OK);
+ } else {
+ if (r1 && r2)
+ return (DTRACE_HANDLE_OK);
+ }
+
+ return (begin->dtbgn_errhdlr(data, begin->dtbgn_errarg));
+}
+
+static int
+dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
+ dtrace_consume_probe_f *pf, dtrace_consume_rec_f *rf, void *arg)
+{
+ /*
+ * There's this idea that the BEGIN probe should be processed before
+ * everything else, and that the END probe should be processed after
+ * anything else. In the common case, this is pretty easy to deal
+ * with. However, a situation may arise where the BEGIN enabling and
+ * END enabling are on the same CPU, and some enabling in the middle
+ * occurred on a different CPU. To deal with this (blech!) we need to
+ * consume the BEGIN buffer up until the end of the BEGIN probe, and
+ * then set it aside. We will then process every other CPU, and then
+ * we'll return to the BEGIN CPU and process the rest of the data
+ * (which will inevitably include the END probe, if any). Making this
+ * even more complicated (!) is the library's ERROR enabling. Because
+ * this enabling is processed before we even get into the consume call
+ * back, any ERROR firing would result in the library's ERROR enabling
+ * being processed twice -- once in our first pass (for BEGIN probes),
+ * and again in our second pass (for everything but BEGIN probes). To
+ * deal with this, we interpose on the ERROR handler to assure that we
+ * only process ERROR enablings induced by BEGIN enablings in the
+ * first pass, and that we only process ERROR enablings _not_ induced
+ * by BEGIN enablings in the second pass.
+ */
+ dt_begin_t begin;
+ processorid_t cpu = dtp->dt_beganon;
+ dtrace_bufdesc_t nbuf;
+ int rval, i;
+ static int max_ncpus;
+ dtrace_optval_t size;
+
+ dtp->dt_beganon = (processorid_t)-1;
+
+ if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
+ /*
+ * We really don't expect this to fail, but it is at least
+ * technically possible for this to fail with ENOENT. In this
+ * case, we just drive on...
+ */
+ if (errno == ENOENT)
+ return (0);
+
+ return (dt_set_errno(dtp, errno));
+ }
+
+ if (!dtp->dt_stopped || buf->dtbd_cpu != dtp->dt_endedon) {
+ /*
+ * This is the simple case. We're either not stopped, or if
+ * we are, we actually processed any END probes on another
+ * CPU. We can simply consume this buffer and return.
+ */
+ return (dt_consume_cpu(dtp, fp, cpu, buf, pf, rf, arg));
+ }
+
+ begin.dtbgn_probefunc = pf;
+ begin.dtbgn_recfunc = rf;
+ begin.dtbgn_arg = arg;
+ begin.dtbgn_beginonly = 1;
+
+ /*
+ * We need to interpose on the ERROR handler to be sure that we
+ * only process ERRORs induced by BEGIN.
+ */
+ begin.dtbgn_errhdlr = dtp->dt_errhdlr;
+ begin.dtbgn_errarg = dtp->dt_errarg;
+ dtp->dt_errhdlr = dt_consume_begin_error;
+ dtp->dt_errarg = &begin;
+
+ rval = dt_consume_cpu(dtp, fp, cpu, buf, dt_consume_begin_probe,
+ dt_consume_begin_record, &begin);
+
+ dtp->dt_errhdlr = begin.dtbgn_errhdlr;
+ dtp->dt_errarg = begin.dtbgn_errarg;
+
+ if (rval != 0)
+ return (rval);
+
+ /*
+ * Now allocate a new buffer. We'll use this to deal with every other
+ * CPU.
+ */
+ bzero(&nbuf, sizeof (dtrace_bufdesc_t));
+ (void) dtrace_getopt(dtp, "bufsize", &size);
+ if ((nbuf.dtbd_data = malloc(size)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ if (max_ncpus == 0)
+#ifndef VBOX
+ max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
+#else
+ max_ncpus = RTMpGetMaxCpuId() + 1;
+#endif
+
+ for (i = 0; i < max_ncpus; i++) {
+ nbuf.dtbd_cpu = i;
+
+ if ((unsigned)i == cpu)
+ continue;
+
+ if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &nbuf) == -1) {
+ /*
+ * If we failed with ENOENT, it may be because the
+ * CPU was unconfigured -- this is okay. Any other
+ * error, however, is unexpected.
+ */
+ if (errno == ENOENT)
+ continue;
+
+ free(nbuf.dtbd_data);
+
+ return (dt_set_errno(dtp, errno));
+ }
+
+ if ((rval = dt_consume_cpu(dtp, fp,
+ i, &nbuf, pf, rf, arg)) != 0) {
+ free(nbuf.dtbd_data);
+ return (rval);
+ }
+ }
+
+ free(nbuf.dtbd_data);
+
+ /*
+ * Okay -- we're done with the other buffers. Now we want to
+ * reconsume the first buffer -- but this time we're looking for
+ * everything _but_ BEGIN. And of course, in order to only consume
+ * those ERRORs _not_ associated with BEGIN, we need to reinstall our
+ * ERROR interposition function...
+ */
+ begin.dtbgn_beginonly = 0;
+
+ assert(begin.dtbgn_errhdlr == dtp->dt_errhdlr);
+ assert(begin.dtbgn_errarg == dtp->dt_errarg);
+ dtp->dt_errhdlr = dt_consume_begin_error;
+ dtp->dt_errarg = &begin;
+
+ rval = dt_consume_cpu(dtp, fp, cpu, buf, dt_consume_begin_probe,
+ dt_consume_begin_record, &begin);
+
+ dtp->dt_errhdlr = begin.dtbgn_errhdlr;
+ dtp->dt_errarg = begin.dtbgn_errarg;
+
+ return (rval);
+}
+
+int
+dtrace_consume(dtrace_hdl_t *dtp, FILE *fp,
+ dtrace_consume_probe_f *pf, dtrace_consume_rec_f *rf, void *arg)
+{
+ dtrace_bufdesc_t *buf = &dtp->dt_buf;
+ dtrace_optval_t size;
+ static int max_ncpus;
+ int i, rval;
+ dtrace_optval_t interval = dtp->dt_options[DTRACEOPT_SWITCHRATE];
+ hrtime_t now = gethrtime();
+
+ if (dtp->dt_lastswitch != 0) {
+ if (now - dtp->dt_lastswitch < VBDTCAST(hrtime_t)interval)
+ return (0);
+
+ dtp->dt_lastswitch += interval;
+ } else {
+ dtp->dt_lastswitch = now;
+ }
+
+ if (!dtp->dt_active)
+ return (dt_set_errno(dtp, EINVAL));
+
+ if (max_ncpus == 0)
+#ifndef VBOX
+ max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
+#else
+ max_ncpus = RTMpGetMaxCpuId() + 1;
+#endif
+
+ if (pf == NULL)
+ pf = (dtrace_consume_probe_f *)(uintptr_t)dt_nullprobe;
+
+ if (rf == NULL)
+ rf = (dtrace_consume_rec_f *)(uintptr_t)dt_nullrec;
+
+ if (buf->dtbd_data == NULL) {
+ (void) dtrace_getopt(dtp, "bufsize", &size);
+ if ((buf->dtbd_data = malloc(size)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ buf->dtbd_size = size;
+ }
+
+ /*
+ * If we have just begun, we want to first process the CPU that
+ * executed the BEGIN probe (if any).
+ */
+ if (dtp->dt_active && dtp->dt_beganon != -1) {
+ buf->dtbd_cpu = dtp->dt_beganon;
+ if ((rval = dt_consume_begin(dtp, fp, buf, pf, rf, arg)) != 0)
+ return (rval);
+ }
+
+ for (i = 0; i < max_ncpus; i++) {
+ buf->dtbd_cpu = i;
+
+ /*
+ * If we have stopped, we want to process the CPU on which the
+ * END probe was processed only _after_ we have processed
+ * everything else.
+ */
+ if (dtp->dt_stopped && ((unsigned)i == dtp->dt_endedon))
+ continue;
+
+ if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
+ /*
+ * If we failed with ENOENT, it may be because the
+ * CPU was unconfigured -- this is okay. Any other
+ * error, however, is unexpected.
+ */
+ if (errno == ENOENT)
+ continue;
+
+ return (dt_set_errno(dtp, errno));
+ }
+
+ if ((rval = dt_consume_cpu(dtp, fp, i, buf, pf, rf, arg)) != 0)
+ return (rval);
+ }
+
+ if (!dtp->dt_stopped)
+ return (0);
+
+ buf->dtbd_cpu = dtp->dt_endedon;
+
+ if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
+ /*
+ * This _really_ shouldn't fail, but it is strictly speaking
+ * possible for this to return ENOENT if the CPU that called
+ * the END enabling somehow managed to become unconfigured.
+ * It's unclear how the user can possibly expect anything
+ * rational to happen in this case -- the state has been thrown
+ * out along with the unconfigured CPU -- so we'll just drive
+ * on...
+ */
+ if (errno == ENOENT)
+ return (0);
+
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (dt_consume_cpu(dtp, fp, dtp->dt_endedon, buf, pf, rf, arg));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.c
new file mode 100644
index 00000000..5d79ab8c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.c
@@ -0,0 +1,1130 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <strings.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <alloca.h>
+#include <assert.h>
+#endif
+
+#include <dt_decl.h>
+#include <dt_parser.h>
+#include <dt_module.h>
+#include <dt_impl.h>
+
+static dt_decl_t *
+dt_decl_check(dt_decl_t *ddp)
+{
+ if (ddp->dd_kind == CTF_K_UNKNOWN)
+ return (ddp); /* nothing to check if the type is not yet set */
+
+ if (ddp->dd_name != NULL && strcmp(ddp->dd_name, "char") == 0 &&
+ (ddp->dd_attr & (DT_DA_SHORT | DT_DA_LONG | DT_DA_LONGLONG))) {
+ xyerror(D_DECL_CHARATTR, "invalid type declaration: short and "
+ "long may not be used with char type\n");
+ }
+
+ if (ddp->dd_name != NULL && strcmp(ddp->dd_name, "void") == 0 &&
+ (ddp->dd_attr & (DT_DA_SHORT | DT_DA_LONG | DT_DA_LONGLONG |
+ (DT_DA_SIGNED | DT_DA_UNSIGNED)))) {
+ xyerror(D_DECL_VOIDATTR, "invalid type declaration: attributes "
+ "may not be used with void type\n");
+ }
+
+ if (ddp->dd_kind != CTF_K_INTEGER &&
+ (ddp->dd_attr & (DT_DA_SIGNED | DT_DA_UNSIGNED))) {
+ xyerror(D_DECL_SIGNINT, "invalid type declaration: signed and "
+ "unsigned may only be used with integer type\n");
+ }
+
+ if (ddp->dd_kind != CTF_K_INTEGER && ddp->dd_kind != CTF_K_FLOAT &&
+ (ddp->dd_attr & (DT_DA_LONG | DT_DA_LONGLONG))) {
+ xyerror(D_DECL_LONGINT, "invalid type declaration: long and "
+ "long long may only be used with integer or "
+ "floating-point type\n");
+ }
+
+ return (ddp);
+}
+
+dt_decl_t *
+dt_decl_alloc(ushort_t kind, char *name)
+{
+ dt_decl_t *ddp = malloc(sizeof (dt_decl_t));
+
+ if (ddp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ ddp->dd_kind = kind;
+ ddp->dd_attr = 0;
+ ddp->dd_ctfp = NULL;
+ ddp->dd_type = CTF_ERR;
+ ddp->dd_name = name;
+ ddp->dd_node = NULL;
+ ddp->dd_next = NULL;
+
+ return (ddp);
+}
+
+void
+dt_decl_free(dt_decl_t *ddp)
+{
+ dt_decl_t *ndp;
+
+ for (; ddp != NULL; ddp = ndp) {
+ ndp = ddp->dd_next;
+ free(ddp->dd_name);
+ dt_node_list_free(&ddp->dd_node);
+ free(ddp);
+ }
+}
+
+void
+dt_decl_reset(void)
+{
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+ dt_decl_t *ddp = dsp->ds_decl;
+
+ while (ddp->dd_next != NULL) {
+ dsp->ds_decl = ddp->dd_next;
+ ddp->dd_next = NULL;
+ dt_decl_free(ddp);
+ ddp = dsp->ds_decl;
+ }
+}
+
+dt_decl_t *
+dt_decl_push(dt_decl_t *ddp)
+{
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+ dt_decl_t *top = dsp->ds_decl;
+
+ if (top != NULL &&
+ top->dd_kind == CTF_K_UNKNOWN && top->dd_name == NULL) {
+ top->dd_kind = CTF_K_INTEGER;
+ (void) dt_decl_check(top);
+ }
+
+ assert(ddp->dd_next == NULL);
+ ddp->dd_next = top;
+ dsp->ds_decl = ddp;
+
+ return (ddp);
+}
+
+dt_decl_t *
+dt_decl_pop(void)
+{
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+ dt_decl_t *ddp = dt_decl_top();
+
+ dsp->ds_decl = NULL;
+ free(dsp->ds_ident);
+ dsp->ds_ident = NULL;
+ dsp->ds_ctfp = NULL;
+ dsp->ds_type = CTF_ERR;
+ dsp->ds_class = DT_DC_DEFAULT;
+ dsp->ds_enumval = -1;
+
+ return (ddp);
+}
+
+dt_decl_t *
+dt_decl_pop_param(char **idp)
+{
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+
+ if (dsp->ds_class != DT_DC_DEFAULT && dsp->ds_class != DT_DC_REGISTER) {
+ xyerror(D_DECL_PARMCLASS, "inappropriate storage class "
+ "for function or associative array parameter\n");
+ }
+
+ if (idp != NULL && dt_decl_top() != NULL) {
+ *idp = dsp->ds_ident;
+ dsp->ds_ident = NULL;
+ }
+
+ return (dt_decl_pop());
+}
+
+dt_decl_t *
+dt_decl_top(void)
+{
+ dt_decl_t *ddp = yypcb->pcb_dstack.ds_decl;
+
+ if (ddp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NODECL);
+
+ if (ddp->dd_kind == CTF_K_UNKNOWN && ddp->dd_name == NULL) {
+ ddp->dd_kind = CTF_K_INTEGER;
+ (void) dt_decl_check(ddp);
+ }
+
+ return (ddp);
+}
+
+dt_decl_t *
+dt_decl_ident(char *name)
+{
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+ dt_decl_t *ddp = dsp->ds_decl;
+
+ if (dsp->ds_ident != NULL) {
+ free(name);
+ xyerror(D_DECL_IDENT, "old-style declaration or "
+ "incorrect type specified\n");
+ }
+
+ dsp->ds_ident = name;
+
+ if (ddp == NULL)
+ ddp = dt_decl_push(dt_decl_alloc(CTF_K_UNKNOWN, NULL));
+
+ return (ddp);
+}
+
+void
+dt_decl_class(dt_dclass_t class)
+{
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+
+ if (dsp->ds_class != DT_DC_DEFAULT) {
+ xyerror(D_DECL_CLASS, "only one storage class allowed "
+ "in a declaration\n");
+ }
+
+ dsp->ds_class = class;
+}
+
+/*
+ * Set the kind and name of the current declaration. If none is allocated,
+ * make a new decl and push it on to the top of our stack. If the name or kind
+ * is already set for the current decl, then we need to fail this declaration.
+ * This can occur because too many types were given (e.g. "int int"), etc.
+ */
+dt_decl_t *
+dt_decl_spec(ushort_t kind, char *name)
+{
+ dt_decl_t *ddp = yypcb->pcb_dstack.ds_decl;
+
+ if (ddp == NULL)
+ return (dt_decl_push(dt_decl_alloc(kind, name)));
+
+ /*
+ * If we already have a type name specified and we see another type
+ * name, this is an error if the declaration is a typedef. If the
+ * declaration is not a typedef, then the user may be trying to declare
+ * a variable whose name has been returned by lex as a TNAME token:
+ * call dt_decl_ident() as if the grammar's IDENT rule was matched.
+ */
+ if (ddp->dd_name != NULL && kind == CTF_K_TYPEDEF) {
+ if (yypcb->pcb_dstack.ds_class != DT_DC_TYPEDEF)
+ return (dt_decl_ident(name));
+ xyerror(D_DECL_IDRED, "identifier redeclared: %s\n", name);
+ }
+
+ if (ddp->dd_name != NULL || ddp->dd_kind != CTF_K_UNKNOWN)
+ xyerror(D_DECL_COMBO, "invalid type combination\n");
+
+ ddp->dd_kind = kind;
+ ddp->dd_name = name;
+
+ if (name != NULL && strchr(name, '`') != NULL) {
+ xyerror(D_DECL_SCOPE, "D scoping operator may not be used "
+ "in a type name\n");
+ }
+
+ return (dt_decl_check(ddp));
+}
+
+dt_decl_t *
+dt_decl_attr(ushort_t attr)
+{
+ dt_decl_t *ddp = yypcb->pcb_dstack.ds_decl;
+
+ if (ddp == NULL) {
+ ddp = dt_decl_push(dt_decl_alloc(CTF_K_UNKNOWN, NULL));
+ ddp->dd_attr = attr;
+ return (ddp);
+ }
+
+ if (attr == DT_DA_LONG && (ddp->dd_attr & DT_DA_LONG)) {
+ ddp->dd_attr &= ~DT_DA_LONG;
+ attr = DT_DA_LONGLONG;
+ }
+
+ ddp->dd_attr |= attr;
+ return (dt_decl_check(ddp));
+}
+
+/*
+ * Examine the list of formal parameters 'flist' and determine if the formal
+ * name fnp->dn_string is defined in this list (B_TRUE) or not (B_FALSE).
+ * If 'fnp' is in 'flist', do not search beyond 'fnp' itself in 'flist'.
+ */
+static int
+dt_decl_protoform(dt_node_t *fnp, dt_node_t *flist)
+{
+ dt_node_t *dnp;
+
+ for (dnp = flist; dnp != fnp && dnp != NULL; dnp = dnp->dn_list) {
+ if (dnp->dn_string != NULL &&
+ strcmp(dnp->dn_string, fnp->dn_string) == 0)
+ return (B_TRUE);
+ }
+
+ return (B_FALSE);
+}
+
+/*
+ * Common code for parsing array, function, and probe definition prototypes.
+ * The prototype node list is specified as 'plist'. The formal prototype
+ * against which to compare the prototype is specified as 'flist'. If plist
+ * and flist are the same, we require that named parameters are unique. If
+ * plist and flist are different, we require that named parameters in plist
+ * match a name that is present in flist.
+ */
+int
+dt_decl_prototype(dt_node_t *plist,
+ dt_node_t *flist, const char *kind, uint_t flags)
+{
+ char n[DT_TYPE_NAMELEN];
+ int is_void, v = 0, i = 1;
+ int form = plist != flist;
+ dt_node_t *dnp;
+
+ for (dnp = plist; dnp != NULL; dnp = dnp->dn_list, i++) {
+
+ if (dnp->dn_type == CTF_ERR && !(flags & DT_DP_VARARGS)) {
+ dnerror(dnp, D_DECL_PROTO_VARARGS, "%s prototype may "
+ "not use a variable-length argument list\n", kind);
+ }
+
+ if (dt_node_is_dynamic(dnp) && !(flags & DT_DP_DYNAMIC)) {
+ dnerror(dnp, D_DECL_PROTO_TYPE, "%s prototype may not "
+ "use parameter of type %s: %s, parameter #%d\n",
+ kind, dt_node_type_name(dnp, n, sizeof (n)),
+ dnp->dn_string ? dnp->dn_string : "(anonymous)", i);
+ }
+
+ is_void = dt_node_is_void(dnp);
+ v += is_void;
+
+ if (is_void && !(flags & DT_DP_VOID)) {
+ dnerror(dnp, D_DECL_PROTO_TYPE, "%s prototype may not "
+ "use parameter of type %s: %s, parameter #%d\n",
+ kind, dt_node_type_name(dnp, n, sizeof (n)),
+ dnp->dn_string ? dnp->dn_string : "(anonymous)", i);
+ }
+
+ if (is_void && dnp->dn_string != NULL) {
+ dnerror(dnp, D_DECL_PROTO_NAME, "void parameter may "
+ "not have a name: %s\n", dnp->dn_string);
+ }
+
+ if (dnp->dn_string != NULL &&
+ dt_decl_protoform(dnp, flist) != form) {
+ dnerror(dnp, D_DECL_PROTO_FORM, "parameter is "
+ "%s declared in %s prototype: %s, parameter #%d\n",
+ form ? "not" : "already", kind, dnp->dn_string, i);
+ }
+
+ if (dnp->dn_string == NULL &&
+ !is_void && !(flags & DT_DP_ANON)) {
+ dnerror(dnp, D_DECL_PROTO_NAME, "parameter declaration "
+ "requires a name: parameter #%d\n", i);
+ }
+ }
+
+ if (v != 0 && plist->dn_list != NULL)
+ xyerror(D_DECL_PROTO_VOID, "void must be sole parameter\n");
+
+ return (v ? 0 : i - 1); /* return zero if sole parameter is 'void' */
+}
+
+dt_decl_t *
+dt_decl_array(dt_node_t *dnp)
+{
+ dt_decl_t *ddp = dt_decl_push(dt_decl_alloc(CTF_K_ARRAY, NULL));
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+ dt_decl_t *ndp = ddp;
+
+ /*
+ * After pushing the array on to the decl stack, scan ahead for multi-
+ * dimensional array declarations and push the current decl to the
+ * bottom to match the resulting CTF type tree and data layout. Refer
+ * to the comments in dt_decl_type() and ISO C 6.5.2.1 for more info.
+ */
+ while (ndp->dd_next != NULL && ndp->dd_next->dd_kind == CTF_K_ARRAY)
+ ndp = ndp->dd_next; /* skip to bottom-most array declaration */
+
+ if (ndp != ddp) {
+ if (dnp != NULL && dnp->dn_kind == DT_NODE_TYPE) {
+ xyerror(D_DECL_DYNOBJ,
+ "cannot declare array of associative arrays\n");
+ }
+ dsp->ds_decl = ddp->dd_next;
+ ddp->dd_next = ndp->dd_next;
+ ndp->dd_next = ddp;
+ }
+
+ if (ddp->dd_next->dd_name != NULL &&
+ strcmp(ddp->dd_next->dd_name, "void") == 0)
+ xyerror(D_DECL_VOIDOBJ, "cannot declare array of void\n");
+
+ if (dnp != NULL && dnp->dn_kind != DT_NODE_TYPE) {
+ dnp = ddp->dd_node = dt_node_cook(dnp, DT_IDFLG_REF);
+
+ if (dt_node_is_posconst(dnp) == 0) {
+ xyerror(D_DECL_ARRSUB, "positive integral constant "
+ "expression or tuple signature expected as "
+ "array declaration subscript\n");
+ }
+
+ if (dnp->dn_value > UINT_MAX)
+ xyerror(D_DECL_ARRBIG, "array dimension too big\n");
+
+ } else if (dnp != NULL) {
+ ddp->dd_node = dnp;
+ (void) dt_decl_prototype(dnp, dnp, "array", DT_DP_ANON);
+ }
+
+ return (ddp);
+}
+
+/*
+ * When a function is declared, we need to fudge the decl stack a bit if the
+ * declaration uses the function pointer (*)() syntax. In this case, the
+ * dt_decl_func() call occurs *after* the dt_decl_ptr() call, even though the
+ * resulting type is "pointer to function". To make the pointer land on top,
+ * we check to see if 'pdp' is non-NULL and a pointer. If it is, we search
+ * backward for a decl tagged with DT_DA_PAREN, and if one is found, the func
+ * decl is inserted behind this node in the decl list instead of at the top.
+ * In all cases, the func decl's dd_next pointer is set to the decl chain
+ * for the function's return type and the function parameter list is discarded.
+ */
+dt_decl_t *
+dt_decl_func(dt_decl_t *pdp, dt_node_t *dnp)
+{
+ dt_decl_t *ddp = dt_decl_alloc(CTF_K_FUNCTION, NULL);
+
+ ddp->dd_node = dnp;
+
+ (void) dt_decl_prototype(dnp, dnp, "function",
+ DT_DP_VARARGS | DT_DP_VOID | DT_DP_ANON);
+
+ if (pdp == NULL || pdp->dd_kind != CTF_K_POINTER)
+ return (dt_decl_push(ddp));
+
+ while (pdp->dd_next != NULL && !(pdp->dd_next->dd_attr & DT_DA_PAREN))
+ pdp = pdp->dd_next;
+
+ if (pdp->dd_next == NULL)
+ return (dt_decl_push(ddp));
+
+ ddp->dd_next = pdp->dd_next;
+ pdp->dd_next = ddp;
+
+ return (pdp);
+}
+
+dt_decl_t *
+dt_decl_ptr(void)
+{
+ return (dt_decl_push(dt_decl_alloc(CTF_K_POINTER, NULL)));
+}
+
+dt_decl_t *
+dt_decl_sou(uint_t kind, char *name)
+{
+ dt_decl_t *ddp = dt_decl_spec(kind, name);
+ char n[DT_TYPE_NAMELEN];
+ ctf_file_t *ctfp;
+ ctf_id_t type;
+ uint_t flag;
+
+ if (yypcb->pcb_idepth != 0)
+ ctfp = yypcb->pcb_hdl->dt_cdefs->dm_ctfp;
+ else
+ ctfp = yypcb->pcb_hdl->dt_ddefs->dm_ctfp;
+
+ if (yypcb->pcb_dstack.ds_next != NULL)
+ flag = CTF_ADD_NONROOT;
+ else
+ flag = CTF_ADD_ROOT;
+
+ (void) snprintf(n, sizeof (n), "%s %s",
+ kind == CTF_K_STRUCT ? "struct" : "union",
+ name == NULL ? "(anon)" : name);
+
+ if (name != NULL && (type = ctf_lookup_by_name(ctfp, n)) != CTF_ERR &&
+ ctf_type_kind(ctfp, type) != CTF_K_FORWARD)
+ xyerror(D_DECL_TYPERED, "type redeclared: %s\n", n);
+
+ if (kind == CTF_K_STRUCT)
+ type = ctf_add_struct(ctfp, flag, name);
+ else
+ type = ctf_add_union(ctfp, flag, name);
+
+ if (type == CTF_ERR || ctf_update(ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to define %s: %s\n",
+ n, ctf_errmsg(ctf_errno(ctfp)));
+ }
+
+ ddp->dd_ctfp = ctfp;
+ ddp->dd_type = type;
+
+ dt_scope_push(ctfp, type);
+ return (ddp);
+}
+
+void
+dt_decl_member(dt_node_t *dnp)
+{
+ dt_scope_t *dsp = yypcb->pcb_dstack.ds_next;
+ dt_decl_t *ddp = yypcb->pcb_dstack.ds_decl;
+ char *ident = yypcb->pcb_dstack.ds_ident;
+
+ const char *idname = ident ? ident : "(anon)";
+ char n[DT_TYPE_NAMELEN];
+
+ dtrace_typeinfo_t dtt;
+ ctf_encoding_t cte VBDTMSC({0});
+ ctf_id_t base;
+ uint_t kind;
+ ssize_t size;
+
+ if (dsp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOSCOPE);
+
+ if (ddp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NODECL);
+
+ if (dnp == NULL && ident == NULL)
+ xyerror(D_DECL_MNAME, "member declaration requires a name\n");
+
+ if (ddp->dd_kind == CTF_K_UNKNOWN && ddp->dd_name == NULL) {
+ ddp->dd_kind = CTF_K_INTEGER;
+ (void) dt_decl_check(ddp);
+ }
+
+ if (dt_decl_type(ddp, &dtt) != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+
+ if (ident != NULL && strchr(ident, '`') != NULL) {
+ xyerror(D_DECL_SCOPE, "D scoping operator may not be used "
+ "in a member name (%s)\n", ident);
+ }
+
+ if (dtt.dtt_ctfp == DT_DYN_CTFP(yypcb->pcb_hdl) &&
+ dtt.dtt_type == DT_DYN_TYPE(yypcb->pcb_hdl)) {
+ xyerror(D_DECL_DYNOBJ,
+ "cannot have dynamic member: %s\n", ident);
+ }
+
+ base = ctf_type_resolve(dtt.dtt_ctfp, dtt.dtt_type);
+ kind = ctf_type_kind(dtt.dtt_ctfp, base);
+ size = ctf_type_size(dtt.dtt_ctfp, base);
+
+ if (kind == CTF_K_FORWARD || ((kind == CTF_K_STRUCT ||
+ kind == CTF_K_UNION) && size == 0)) {
+ xyerror(D_DECL_INCOMPLETE, "incomplete struct/union/enum %s: "
+ "%s\n", dt_type_name(dtt.dtt_ctfp, dtt.dtt_type,
+ n, sizeof (n)), ident);
+ }
+
+ if (size == 0)
+ xyerror(D_DECL_VOIDOBJ, "cannot have void member: %s\n", ident);
+
+ /*
+ * If a bit-field qualifier was part of the member declaration, create
+ * a new integer type of the same name and attributes as the base type
+ * and size equal to the specified number of bits. We reset 'dtt' to
+ * refer to this new bit-field type and continue on to add the member.
+ */
+ if (dnp != NULL) {
+ dnp = dt_node_cook(dnp, DT_IDFLG_REF);
+
+ /*
+ * A bit-field member with no declarator is permitted to have
+ * size zero and indicates that no more fields are to be packed
+ * into the current storage unit. We ignore these directives
+ * as the underlying ctf code currently does so for all fields.
+ */
+ if (ident == NULL && dnp->dn_kind == DT_NODE_INT &&
+ dnp->dn_value == 0) {
+ dt_node_free(dnp);
+ goto done;
+ }
+
+ if (dt_node_is_posconst(dnp) == 0) {
+ xyerror(D_DECL_BFCONST, "positive integral constant "
+ "expression expected as bit-field size\n");
+ }
+
+ if (ctf_type_kind(dtt.dtt_ctfp, base) != CTF_K_INTEGER ||
+ ctf_type_encoding(dtt.dtt_ctfp, base, &cte) == CTF_ERR ||
+ IS_VOID(cte)) {
+ xyerror(D_DECL_BFTYPE, "invalid type for "
+ "bit-field: %s\n", idname);
+ }
+
+ if (dnp->dn_value > cte.cte_bits) {
+ xyerror(D_DECL_BFSIZE, "bit-field too big "
+ "for type: %s\n", idname);
+ }
+
+ cte.cte_offset = 0;
+ cte.cte_bits = (uint_t)dnp->dn_value;
+
+ dtt.dtt_type = ctf_add_integer(dsp->ds_ctfp,
+ CTF_ADD_NONROOT, ctf_type_name(dtt.dtt_ctfp,
+ dtt.dtt_type, n, sizeof (n)), &cte);
+
+ if (dtt.dtt_type == CTF_ERR ||
+ ctf_update(dsp->ds_ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to create type for "
+ "member '%s': %s\n", idname,
+ ctf_errmsg(ctf_errno(dsp->ds_ctfp)));
+ }
+
+ dtt.dtt_ctfp = dsp->ds_ctfp;
+ dt_node_free(dnp);
+ }
+
+ /*
+ * If the member type is not defined in the same CTF container as the
+ * one associated with the current scope (i.e. the container for the
+ * struct or union itself) or its parent, copy the member type into
+ * this container and reset dtt to refer to the copied type.
+ */
+ if (dtt.dtt_ctfp != dsp->ds_ctfp &&
+ dtt.dtt_ctfp != ctf_parent_file(dsp->ds_ctfp)) {
+
+ dtt.dtt_type = ctf_add_type(dsp->ds_ctfp,
+ dtt.dtt_ctfp, dtt.dtt_type);
+ dtt.dtt_ctfp = dsp->ds_ctfp;
+
+ if (dtt.dtt_type == CTF_ERR ||
+ ctf_update(dtt.dtt_ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to copy type of '%s': %s\n",
+ idname, ctf_errmsg(ctf_errno(dtt.dtt_ctfp)));
+ }
+ }
+
+ if (ctf_add_member(dsp->ds_ctfp, dsp->ds_type,
+ ident, dtt.dtt_type) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to define member '%s': %s\n",
+ idname, ctf_errmsg(ctf_errno(dsp->ds_ctfp)));
+ }
+
+done:
+ free(ident);
+ yypcb->pcb_dstack.ds_ident = NULL;
+ dt_decl_reset();
+}
+
+/*ARGSUSED*/
+static int
+dt_decl_hasmembers(const char *name, int value, void *private)
+{
+ RT_NOREF3(name, value, private);
+ return (1); /* abort search and return true if a member exists */
+}
+
+dt_decl_t *
+dt_decl_enum(char *name)
+{
+ dt_decl_t *ddp = dt_decl_spec(CTF_K_ENUM, name);
+ char n[DT_TYPE_NAMELEN];
+ ctf_file_t *ctfp;
+ ctf_id_t type;
+ uint_t flag;
+
+ if (yypcb->pcb_idepth != 0)
+ ctfp = yypcb->pcb_hdl->dt_cdefs->dm_ctfp;
+ else
+ ctfp = yypcb->pcb_hdl->dt_ddefs->dm_ctfp;
+
+ if (yypcb->pcb_dstack.ds_next != NULL)
+ flag = CTF_ADD_NONROOT;
+ else
+ flag = CTF_ADD_ROOT;
+
+ (void) snprintf(n, sizeof (n), "enum %s", name ? name : "(anon)");
+
+ if (name != NULL && (type = ctf_lookup_by_name(ctfp, n)) != CTF_ERR) {
+ if (ctf_enum_iter(ctfp, type, dt_decl_hasmembers, NULL))
+ xyerror(D_DECL_TYPERED, "type redeclared: %s\n", n);
+ } else if ((type = ctf_add_enum(ctfp, flag, name)) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to define %s: %s\n",
+ n, ctf_errmsg(ctf_errno(ctfp)));
+ }
+
+ ddp->dd_ctfp = ctfp;
+ ddp->dd_type = type;
+
+ dt_scope_push(ctfp, type);
+ return (ddp);
+}
+
+void
+dt_decl_enumerator(char *s, dt_node_t *dnp)
+{
+ dt_scope_t *dsp = yypcb->pcb_dstack.ds_next;
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+
+ dt_idnode_t *inp;
+ dt_ident_t *idp;
+ char *name;
+ int value;
+
+#ifndef VBOX
+ name = strdupa(s);
+#else
+ MY_STRDUPA(name, s);
+#endif
+ free(s);
+
+ if (dsp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOSCOPE);
+
+ assert(dsp->ds_decl->dd_kind == CTF_K_ENUM);
+ value = dsp->ds_enumval + 1; /* default is previous value plus one */
+
+ if (strchr(name, '`') != NULL) {
+ xyerror(D_DECL_SCOPE, "D scoping operator may not be used in "
+ "an enumerator name (%s)\n", name);
+ }
+
+ /*
+ * If the enumerator is being assigned a value, cook and check the node
+ * and then free it after we get the value. We also permit references
+ * to identifiers which are previously defined enumerators in the type.
+ */
+ if (dnp != NULL) {
+ if (dnp->dn_kind != DT_NODE_IDENT || ctf_enum_value(
+ dsp->ds_ctfp, dsp->ds_type, dnp->dn_string, &value) != 0) {
+ dnp = dt_node_cook(dnp, DT_IDFLG_REF);
+
+ if (dnp->dn_kind != DT_NODE_INT) {
+ xyerror(D_DECL_ENCONST, "enumerator '%s' must "
+ "be assigned to an integral constant "
+ "expression\n", name);
+ }
+
+ if ((intmax_t)dnp->dn_value > INT_MAX ||
+ (intmax_t)dnp->dn_value < INT_MIN) {
+ xyerror(D_DECL_ENOFLOW, "enumerator '%s' value "
+ "overflows INT_MAX (%d)\n", name, INT_MAX);
+ }
+
+ value = (int)dnp->dn_value;
+ }
+ dt_node_free(dnp);
+ }
+
+ if (ctf_add_enumerator(dsp->ds_ctfp, dsp->ds_type,
+ name, value) == CTF_ERR || ctf_update(dsp->ds_ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to define enumerator '%s': %s\n",
+ name, ctf_errmsg(ctf_errno(dsp->ds_ctfp)));
+ }
+
+ dsp->ds_enumval = value; /* save most recent value */
+
+ /*
+ * If the enumerator name matches an identifier in the global scope,
+ * flag this as an error. We only do this for "D" enumerators to
+ * prevent "C" header file enumerators from conflicting with the ever-
+ * growing list of D built-in global variables and inlines. If a "C"
+ * enumerator conflicts with a global identifier, we add the enumerator
+ * but do not insert a corresponding inline (i.e. the D variable wins).
+ */
+ if (dt_idstack_lookup(&yypcb->pcb_globals, name) != NULL) {
+ if (dsp->ds_ctfp == dtp->dt_ddefs->dm_ctfp) {
+ xyerror(D_DECL_IDRED,
+ "identifier redeclared: %s\n", name);
+ } else
+ return;
+ }
+
+ dt_dprintf("add global enumerator %s = %d\n", name, value);
+
+ idp = dt_idhash_insert(dtp->dt_globals, name, DT_IDENT_ENUM,
+ DT_IDFLG_INLINE | DT_IDFLG_REF, 0, _dtrace_defattr, 0,
+ &dt_idops_inline, NULL, dtp->dt_gen);
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ yyintprefix = 0;
+ yyintsuffix[0] = '\0';
+ yyintdecimal = 0;
+
+ dnp = dt_node_int(value);
+ dt_node_type_assign(dnp, dsp->ds_ctfp, dsp->ds_type);
+
+ if ((inp = malloc(sizeof (dt_idnode_t))) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * Remove the INT node from the node allocation list and store it in
+ * din_list and din_root so it persists with and is freed by the ident.
+ */
+ assert(yypcb->pcb_list == dnp);
+ yypcb->pcb_list = dnp->dn_link;
+ dnp->dn_link = NULL;
+
+ bzero(inp, sizeof (dt_idnode_t));
+ inp->din_list = dnp;
+ inp->din_root = dnp;
+
+ idp->di_iarg = inp;
+ idp->di_ctfp = dsp->ds_ctfp;
+ idp->di_type = dsp->ds_type;
+}
+
+/*
+ * Look up the type corresponding to the specified decl stack. The scoping of
+ * the underlying type names is handled by dt_type_lookup(). We build up the
+ * name from the specified string and prefixes and then lookup the type. If
+ * we fail, an errmsg is saved and the caller must abort with EDT_COMPILER.
+ */
+int
+dt_decl_type(dt_decl_t *ddp, dtrace_typeinfo_t *tip)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+
+ dt_module_t *dmp;
+ ctf_arinfo_t r;
+ ctf_id_t type;
+
+ char n[DT_TYPE_NAMELEN];
+ uint_t flag;
+ char *name;
+ int rv;
+
+ /*
+ * Based on our current #include depth and decl stack depth, determine
+ * which dynamic CTF module and scope to use when adding any new types.
+ */
+ dmp = yypcb->pcb_idepth ? dtp->dt_cdefs : dtp->dt_ddefs;
+ flag = yypcb->pcb_dstack.ds_next ? CTF_ADD_NONROOT : CTF_ADD_ROOT;
+
+ /*
+ * If we have already cached a CTF type for this decl, then we just
+ * return the type information for the cached type.
+ */
+ if (ddp->dd_ctfp != NULL &&
+ (dmp = dt_module_lookup_by_ctf(dtp, ddp->dd_ctfp)) != NULL) {
+ tip->dtt_object = dmp->dm_name;
+ tip->dtt_ctfp = ddp->dd_ctfp;
+ tip->dtt_type = ddp->dd_type;
+ return (0);
+ }
+
+ /*
+ * Currently CTF treats all function pointers identically. We cache a
+ * representative ID of kind CTF_K_FUNCTION and just return that type.
+ * If we want to support full function declarations, dd_next refers to
+ * the declaration of the function return type, and the parameter list
+ * should be parsed and hung off a new pointer inside of this decl.
+ */
+ if (ddp->dd_kind == CTF_K_FUNCTION) {
+ tip->dtt_object = dtp->dt_ddefs->dm_name;
+ tip->dtt_ctfp = DT_FUNC_CTFP(dtp);
+ tip->dtt_type = DT_FUNC_TYPE(dtp);
+ return (0);
+ }
+
+ /*
+ * If the decl is a pointer, resolve the rest of the stack by calling
+ * dt_decl_type() recursively and then compute a pointer to the result.
+ * Similar to the code above, we return a cached id for function ptrs.
+ */
+ if (ddp->dd_kind == CTF_K_POINTER) {
+ if (ddp->dd_next->dd_kind == CTF_K_FUNCTION) {
+ tip->dtt_object = dtp->dt_ddefs->dm_name;
+ tip->dtt_ctfp = DT_FPTR_CTFP(dtp);
+ tip->dtt_type = DT_FPTR_TYPE(dtp);
+ return (0);
+ }
+
+ if ((rv = dt_decl_type(ddp->dd_next, tip)) == 0 &&
+ (rv = dt_type_pointer(tip)) != 0) {
+ xywarn(D_UNKNOWN, "cannot find type: %s*: %s\n",
+ dt_type_name(tip->dtt_ctfp, tip->dtt_type,
+ n, sizeof (n)), ctf_errmsg(dtp->dt_ctferr));
+ }
+
+ return (rv);
+ }
+
+ /*
+ * If the decl is an array, we must find the base type and then call
+ * dt_decl_type() recursively and then build an array of the result.
+ * The C and D multi-dimensional array syntax requires that consecutive
+ * array declarations be processed from right-to-left (i.e. top-down
+ * from the perspective of the declaration stack). For example, an
+ * array declaration such as int x[3][5] is stored on the stack as:
+ *
+ * (bottom) NULL <- ( INT "int" ) <- ( ARR [3] ) <- ( ARR [5] ) (top)
+ *
+ * but means that x is declared to be an array of 3 objects each of
+ * which is an array of 5 integers, or in CTF representation:
+ *
+ * type T1:( content=int, nelems=5 ) type T2:( content=T1, nelems=3 )
+ *
+ * For more details, refer to K&R[5.7] and ISO C 6.5.2.1. Rather than
+ * overcomplicate the implementation of dt_decl_type(), we push array
+ * declarations down into the stack in dt_decl_array(), above, so that
+ * by the time dt_decl_type() is called, the decl stack looks like:
+ *
+ * (bottom) NULL <- ( INT "int" ) <- ( ARR [5] ) <- ( ARR [3] ) (top)
+ *
+ * which permits a straightforward recursive descent of the decl stack
+ * to build the corresponding CTF type tree in the appropriate order.
+ */
+ if (ddp->dd_kind == CTF_K_ARRAY) {
+ /*
+ * If the array decl has a parameter list associated with it,
+ * this is an associative array declaration: return <DYN>.
+ */
+ if (ddp->dd_node != NULL &&
+ ddp->dd_node->dn_kind == DT_NODE_TYPE) {
+ tip->dtt_object = dtp->dt_ddefs->dm_name;
+ tip->dtt_ctfp = DT_DYN_CTFP(dtp);
+ tip->dtt_type = DT_DYN_TYPE(dtp);
+ return (0);
+ }
+
+ if ((rv = dt_decl_type(ddp->dd_next, tip)) != 0)
+ return (rv);
+
+ /*
+ * If the array base type is not defined in the target
+ * container or its parent, copy the type to the target
+ * container and reset dtt_ctfp and dtt_type to the copy.
+ */
+ if (tip->dtt_ctfp != dmp->dm_ctfp &&
+ tip->dtt_ctfp != ctf_parent_file(dmp->dm_ctfp)) {
+
+ tip->dtt_type = ctf_add_type(dmp->dm_ctfp,
+ tip->dtt_ctfp, tip->dtt_type);
+ tip->dtt_ctfp = dmp->dm_ctfp;
+
+ if (tip->dtt_type == CTF_ERR ||
+ ctf_update(tip->dtt_ctfp) == CTF_ERR) {
+ xywarn(D_UNKNOWN, "failed to copy type: %s\n",
+ ctf_errmsg(ctf_errno(tip->dtt_ctfp)));
+ return (-1);
+ }
+ }
+
+ /*
+ * The array index type is irrelevant in C and D: just set it
+ * to "long" for all array types that we create on-the-fly.
+ */
+ r.ctr_contents = tip->dtt_type;
+ r.ctr_index = ctf_lookup_by_name(tip->dtt_ctfp, "long");
+ r.ctr_nelems = ddp->dd_node ?
+ (uint_t)ddp->dd_node->dn_value : 0;
+
+ tip->dtt_object = dmp->dm_name;
+ tip->dtt_ctfp = dmp->dm_ctfp;
+ tip->dtt_type = ctf_add_array(dmp->dm_ctfp, CTF_ADD_ROOT, &r);
+
+ if (tip->dtt_type == CTF_ERR ||
+ ctf_update(tip->dtt_ctfp) == CTF_ERR) {
+ xywarn(D_UNKNOWN, "failed to create array type: %s\n",
+ ctf_errmsg(ctf_errno(tip->dtt_ctfp)));
+ return (-1);
+ }
+
+ return (0);
+ }
+
+ /*
+ * Allocate space for the type name and enough space for the maximum
+ * additional text ("unsigned long long \0" requires 20 more bytes).
+ */
+ name = alloca(ddp->dd_name ? strlen(ddp->dd_name) + 20 : 20);
+ name[0] = '\0';
+
+ switch (ddp->dd_kind) {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ if (ddp->dd_attr & DT_DA_SIGNED)
+ (void) strcat(name, "signed ");
+ if (ddp->dd_attr & DT_DA_UNSIGNED)
+ (void) strcat(name, "unsigned ");
+ if (ddp->dd_attr & DT_DA_SHORT)
+ (void) strcat(name, "short ");
+ if (ddp->dd_attr & DT_DA_LONG)
+ (void) strcat(name, "long ");
+ if (ddp->dd_attr & DT_DA_LONGLONG)
+ (void) strcat(name, "long long ");
+ if (ddp->dd_attr == 0 && ddp->dd_name == NULL)
+ (void) strcat(name, "int");
+ break;
+ case CTF_K_STRUCT:
+ (void) strcpy(name, "struct ");
+ break;
+ case CTF_K_UNION:
+ (void) strcpy(name, "union ");
+ break;
+ case CTF_K_ENUM:
+ (void) strcpy(name, "enum ");
+ break;
+ case CTF_K_TYPEDEF:
+ break;
+ default:
+ xywarn(D_UNKNOWN, "internal error -- "
+ "bad decl kind %u\n", ddp->dd_kind);
+ return (-1);
+ }
+
+ /*
+ * Add dd_name unless a short, long, or long long is explicitly
+ * suffixed by int. We use the C/CTF canonical names for integers.
+ */
+ if (ddp->dd_name != NULL && (ddp->dd_kind != CTF_K_INTEGER ||
+ (ddp->dd_attr & (DT_DA_SHORT | DT_DA_LONG | DT_DA_LONGLONG)) == 0))
+ (void) strcat(name, ddp->dd_name);
+
+ /*
+ * Lookup the type. If we find it, we're done. Otherwise create a
+ * forward tag for the type if it is a struct, union, or enum. If
+ * we can't find it and we can't create a tag, return failure.
+ */
+ if ((rv = dt_type_lookup(name, tip)) == 0)
+ return (rv);
+
+ switch (ddp->dd_kind) {
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ case CTF_K_ENUM:
+ type = ctf_add_forward(dmp->dm_ctfp, flag,
+ ddp->dd_name, ddp->dd_kind);
+ break;
+ default:
+ xywarn(D_UNKNOWN, "failed to resolve type %s: %s\n", name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ return (rv);
+ }
+
+ if (type == CTF_ERR || ctf_update(dmp->dm_ctfp) == CTF_ERR) {
+ xywarn(D_UNKNOWN, "failed to add forward tag for %s: %s\n",
+ name, ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ return (-1);
+ }
+
+ ddp->dd_ctfp = dmp->dm_ctfp;
+ ddp->dd_type = type;
+
+ tip->dtt_object = dmp->dm_name;
+ tip->dtt_ctfp = dmp->dm_ctfp;
+ tip->dtt_type = type;
+
+ return (0);
+}
+
+void
+dt_scope_create(dt_scope_t *dsp)
+{
+ dsp->ds_decl = NULL;
+ dsp->ds_next = NULL;
+ dsp->ds_ident = NULL;
+ dsp->ds_ctfp = NULL;
+ dsp->ds_type = CTF_ERR;
+ dsp->ds_class = DT_DC_DEFAULT;
+ dsp->ds_enumval = -1;
+}
+
+void
+dt_scope_destroy(dt_scope_t *dsp)
+{
+ dt_scope_t *nsp;
+
+ for (; dsp != NULL; dsp = nsp) {
+ dt_decl_free(dsp->ds_decl);
+ free(dsp->ds_ident);
+ nsp = dsp->ds_next;
+ if (dsp != &yypcb->pcb_dstack)
+ free(dsp);
+ }
+}
+
+void
+dt_scope_push(ctf_file_t *ctfp, ctf_id_t type)
+{
+ dt_scope_t *rsp = &yypcb->pcb_dstack;
+ dt_scope_t *dsp = malloc(sizeof (dt_scope_t));
+
+ if (dsp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dsp->ds_decl = rsp->ds_decl;
+ dsp->ds_next = rsp->ds_next;
+ dsp->ds_ident = rsp->ds_ident;
+ dsp->ds_ctfp = ctfp;
+ dsp->ds_type = type;
+ dsp->ds_class = rsp->ds_class;
+ dsp->ds_enumval = rsp->ds_enumval;
+
+ dt_scope_create(rsp);
+ rsp->ds_next = dsp;
+}
+
+dt_decl_t *
+dt_scope_pop(void)
+{
+ dt_scope_t *rsp = &yypcb->pcb_dstack;
+ dt_scope_t *dsp = rsp->ds_next;
+
+ if (dsp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOSCOPE);
+
+ if (dsp->ds_ctfp != NULL && ctf_update(dsp->ds_ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to update type definitions: %s\n",
+ ctf_errmsg(ctf_errno(dsp->ds_ctfp)));
+ }
+
+ dt_decl_free(rsp->ds_decl);
+ free(rsp->ds_ident);
+
+ rsp->ds_decl = dsp->ds_decl;
+ rsp->ds_next = dsp->ds_next;
+ rsp->ds_ident = dsp->ds_ident;
+ rsp->ds_ctfp = dsp->ds_ctfp;
+ rsp->ds_type = dsp->ds_type;
+ rsp->ds_class = dsp->ds_class;
+ rsp->ds_enumval = dsp->ds_enumval;
+
+ free(dsp);
+ return (rsp->ds_decl);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.h
new file mode 100644
index 00000000..af383399
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.h
@@ -0,0 +1,128 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_DECL_H
+#define _DT_DECL_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#endif
+#include <libctf.h>
+#include <dtrace.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct dt_node; /* forward declaration of dt_node_t */
+
+typedef struct dt_decl {
+ ushort_t dd_kind; /* declaration kind (CTF_K_* kind) */
+ ushort_t dd_attr; /* attributes (DT_DA_* flags) */
+ ctf_file_t *dd_ctfp; /* CTF container for decl's type */
+ ctf_id_t dd_type; /* CTF identifier for decl's type */
+ char *dd_name; /* string name of this decl (or NULL) */
+ struct dt_node *dd_node; /* node for array size or parm list */
+ struct dt_decl *dd_next; /* next declaration in list */
+} dt_decl_t;
+
+#define DT_DA_SIGNED 0x0001 /* signed integer value */
+#define DT_DA_UNSIGNED 0x0002 /* unsigned integer value */
+#define DT_DA_SHORT 0x0004 /* short integer value */
+#define DT_DA_LONG 0x0008 /* long integer or double */
+#define DT_DA_LONGLONG 0x0010 /* long long integer value */
+#define DT_DA_CONST 0x0020 /* qualify type as const */
+#define DT_DA_RESTRICT 0x0040 /* qualify type as restrict */
+#define DT_DA_VOLATILE 0x0080 /* qualify type as volatile */
+#define DT_DA_PAREN 0x0100 /* parenthesis tag */
+
+typedef enum dt_dclass {
+ DT_DC_DEFAULT, /* no storage class specified */
+ DT_DC_AUTO, /* automatic storage */
+ DT_DC_REGISTER, /* register storage */
+ DT_DC_STATIC, /* static storage */
+ DT_DC_EXTERN, /* extern storage */
+ DT_DC_TYPEDEF, /* type definition */
+ DT_DC_SELF, /* thread-local storage */
+ DT_DC_THIS /* clause-local storage */
+} dt_dclass_t;
+
+typedef struct dt_scope {
+ dt_decl_t *ds_decl; /* pointer to top of decl stack */
+ struct dt_scope *ds_next; /* pointer to next scope */
+ char *ds_ident; /* identifier for this scope (if any) */
+ ctf_file_t *ds_ctfp; /* CTF container for this scope */
+ ctf_id_t ds_type; /* CTF id of enclosing type */
+ dt_dclass_t ds_class; /* declaration class for this scope */
+ int ds_enumval; /* most recent enumerator value */
+} dt_scope_t;
+
+extern dt_decl_t *dt_decl_alloc(ushort_t, char *);
+extern void dt_decl_free(dt_decl_t *);
+extern void dt_decl_reset(void);
+extern dt_decl_t *dt_decl_push(dt_decl_t *);
+extern dt_decl_t *dt_decl_pop(void);
+extern dt_decl_t *dt_decl_pop_param(char **);
+extern dt_decl_t *dt_decl_top(void);
+
+extern dt_decl_t *dt_decl_ident(char *);
+extern void dt_decl_class(dt_dclass_t);
+
+#define DT_DP_VARARGS 0x1 /* permit varargs in prototype */
+#define DT_DP_DYNAMIC 0x2 /* permit dynamic type in prototype */
+#define DT_DP_VOID 0x4 /* permit void type in prototype */
+#define DT_DP_ANON 0x8 /* permit anonymous parameters */
+
+extern int dt_decl_prototype(struct dt_node *, struct dt_node *,
+ const char *, uint_t);
+
+extern dt_decl_t *dt_decl_spec(ushort_t, char *);
+extern dt_decl_t *dt_decl_attr(ushort_t);
+extern dt_decl_t *dt_decl_array(struct dt_node *);
+extern dt_decl_t *dt_decl_func(dt_decl_t *, struct dt_node *);
+extern dt_decl_t *dt_decl_ptr(void);
+
+extern dt_decl_t *dt_decl_sou(uint_t, char *);
+extern void dt_decl_member(struct dt_node *);
+
+extern dt_decl_t *dt_decl_enum(char *);
+extern void dt_decl_enumerator(char *, struct dt_node *);
+
+extern int dt_decl_type(dt_decl_t *, dtrace_typeinfo_t *);
+
+extern void dt_scope_create(dt_scope_t *);
+extern void dt_scope_destroy(dt_scope_t *);
+extern void dt_scope_push(ctf_file_t *, ctf_id_t);
+extern dt_decl_t *dt_scope_pop(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_DECL_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dis.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dis.c
new file mode 100644
index 00000000..44523931
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dis.c
@@ -0,0 +1,524 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <strings.h>
+#include <stdio.h>
+#endif
+
+#include <dt_impl.h>
+#include <dt_ident.h>
+
+/*ARGSUSED*/
+static void
+dt_dis_log(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s %%r%u, %%r%u, %%r%u", name,
+ DIF_INSTR_R1(in), DIF_INSTR_R2(in), DIF_INSTR_RD(in));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_branch(const dtrace_difo_t *dp, const char *name,
+ dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s %u", name, DIF_INSTR_LABEL(in));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_load(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s [%%r%u], %%r%u", name,
+ DIF_INSTR_R1(in), DIF_INSTR_RD(in));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_store(const dtrace_difo_t *dp, const char *name,
+ dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s %%r%u, [%%r%u]", name,
+ DIF_INSTR_R1(in), DIF_INSTR_RD(in));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_str(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ RT_NOREF2(dp, in);
+ (void) fprintf(fp, "%s", name);
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_r1rd(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s %%r%u, %%r%u", name,
+ DIF_INSTR_R1(in), DIF_INSTR_RD(in));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_cmp(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s %%r%u, %%r%u", name,
+ DIF_INSTR_R1(in), DIF_INSTR_R2(in));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_tst(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s %%r%u", name, DIF_INSTR_R1(in));
+}
+
+static const char *
+dt_dis_varname(const dtrace_difo_t *dp, uint_t id, uint_t scope)
+{
+ const dtrace_difv_t *dvp = dp->dtdo_vartab;
+ uint_t i;
+
+ for (i = 0; i < dp->dtdo_varlen; i++, dvp++) {
+ if (dvp->dtdv_id == id && dvp->dtdv_scope == scope) {
+ if (dvp->dtdv_name < dp->dtdo_strlen)
+ return (dp->dtdo_strtab + dvp->dtdv_name);
+ break;
+ }
+ }
+
+ return (NULL);
+}
+
+static uint_t
+dt_dis_scope(const char *name)
+{
+ switch (name[2]) {
+ case 'l': return (DIFV_SCOPE_LOCAL);
+ case 't': return (DIFV_SCOPE_THREAD);
+ case 'g': return (DIFV_SCOPE_GLOBAL);
+ default: return (~0u /*VBOX: was -1u*/);
+ }
+}
+
+static void
+dt_dis_lda(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ uint_t var = DIF_INSTR_R1(in);
+ const char *vname;
+
+ (void) fprintf(fp, "%-4s DT_VAR(%u), %%r%u, %%r%u", name,
+ var, DIF_INSTR_R2(in), DIF_INSTR_RD(in));
+
+ if ((vname = dt_dis_varname(dp, var, dt_dis_scope(name))) != NULL)
+ (void) fprintf(fp, "\t\t! DT_VAR(%u) = \"%s\"", var, vname);
+}
+
+static void
+dt_dis_ldv(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ uint_t var = DIF_INSTR_VAR(in);
+ const char *vname;
+
+ (void) fprintf(fp, "%-4s DT_VAR(%u), %%r%u",
+ name, var, DIF_INSTR_RD(in));
+
+ if ((vname = dt_dis_varname(dp, var, dt_dis_scope(name))) != NULL)
+ (void) fprintf(fp, "\t\t! DT_VAR(%u) = \"%s\"", var, vname);
+}
+
+static void
+dt_dis_stv(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ uint_t var = DIF_INSTR_VAR(in);
+ const char *vname;
+
+ (void) fprintf(fp, "%-4s %%r%u, DT_VAR(%u)",
+ name, DIF_INSTR_RS(in), var);
+
+ if ((vname = dt_dis_varname(dp, var, dt_dis_scope(name))) != NULL)
+ (void) fprintf(fp, "\t\t! DT_VAR(%u) = \"%s\"", var, vname);
+}
+
+static void
+dt_dis_setx(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ uint_t intptr = DIF_INSTR_INTEGER(in);
+
+ (void) fprintf(fp, "%-4s DT_INTEGER[%u], %%r%u", name,
+ intptr, DIF_INSTR_RD(in));
+
+ if (intptr < dp->dtdo_intlen) {
+ (void) fprintf(fp, "\t\t! 0x%llx",
+ (u_longlong_t)dp->dtdo_inttab[intptr]);
+ }
+}
+
+static void
+dt_dis_sets(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ uint_t strptr = DIF_INSTR_STRING(in);
+
+ (void) fprintf(fp, "%-4s DT_STRING[%u], %%r%u", name,
+ strptr, DIF_INSTR_RD(in));
+
+ if (strptr < dp->dtdo_strlen)
+ (void) fprintf(fp, "\t\t! \"%s\"", dp->dtdo_strtab + strptr);
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_ret(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ RT_NOREF1(dp);
+ (void) fprintf(fp, "%-4s %%r%u", name, DIF_INSTR_RD(in));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_call(const dtrace_difo_t *dp, const char *name, dif_instr_t in, FILE *fp)
+{
+ uint_t subr = DIF_INSTR_SUBR(in);
+ RT_NOREF1(dp);
+
+ (void) fprintf(fp, "%-4s DIF_SUBR(%u), %%r%u\t\t! %s",
+ name, subr, DIF_INSTR_RD(in), dtrace_subrstr(NULL, subr));
+}
+
+/*ARGSUSED*/
+static void
+dt_dis_pushts(const dtrace_difo_t *dp,
+ const char *name, dif_instr_t in, FILE *fp)
+{
+ static const char *const tnames[] = { "D type", "string" };
+ uint_t type = DIF_INSTR_TYPE(in);
+ RT_NOREF1(dp);
+
+ (void) fprintf(fp, "%-4s DT_TYPE(%u), %%r%u, %%r%u",
+ name, type, DIF_INSTR_R2(in), DIF_INSTR_RS(in));
+
+ if (type < sizeof (tnames) / sizeof (tnames[0]))
+ (void) fprintf(fp, "\t! DT_TYPE(%u) = %s", type, tnames[type]);
+}
+
+static void
+dt_dis_xlate(const dtrace_difo_t *dp,
+ const char *name, dif_instr_t in, FILE *fp)
+{
+ uint_t xlr = DIF_INSTR_XLREF(in);
+
+ (void) fprintf(fp, "%-4s DT_XLREF[%u], %%r%u",
+ name, xlr, DIF_INSTR_RD(in));
+
+ if (xlr < dp->dtdo_xlmlen) {
+ (void) fprintf(fp, "\t\t! DT_XLREF[%u] = %u.%s", xlr,
+ (uint_t)dp->dtdo_xlmtab[xlr]->dn_membexpr->dn_xlator->dx_id,
+ dp->dtdo_xlmtab[xlr]->dn_membname);
+ }
+}
+
+static char *
+dt_dis_typestr(const dtrace_diftype_t *t, char *buf, size_t len)
+{
+ char kind[16], ckind[16];
+
+ switch (t->dtdt_kind) {
+ case DIF_TYPE_CTF:
+ (void) strcpy(kind, "D type");
+ break;
+ case DIF_TYPE_STRING:
+ (void) strcpy(kind, "string");
+ break;
+ default:
+ (void) snprintf(kind, sizeof (kind), "0x%x", t->dtdt_kind);
+ }
+
+ switch (t->dtdt_ckind) {
+ case CTF_K_UNKNOWN:
+ (void) strcpy(ckind, "unknown");
+ break;
+ case CTF_K_INTEGER:
+ (void) strcpy(ckind, "integer");
+ break;
+ case CTF_K_FLOAT:
+ (void) strcpy(ckind, "float");
+ break;
+ case CTF_K_POINTER:
+ (void) strcpy(ckind, "pointer");
+ break;
+ case CTF_K_ARRAY:
+ (void) strcpy(ckind, "array");
+ break;
+ case CTF_K_FUNCTION:
+ (void) strcpy(ckind, "function");
+ break;
+ case CTF_K_STRUCT:
+ (void) strcpy(ckind, "struct");
+ break;
+ case CTF_K_UNION:
+ (void) strcpy(ckind, "union");
+ break;
+ case CTF_K_ENUM:
+ (void) strcpy(ckind, "enum");
+ break;
+ case CTF_K_FORWARD:
+ (void) strcpy(ckind, "forward");
+ break;
+ case CTF_K_TYPEDEF:
+ (void) strcpy(ckind, "typedef");
+ break;
+ case CTF_K_VOLATILE:
+ (void) strcpy(ckind, "volatile");
+ break;
+ case CTF_K_CONST:
+ (void) strcpy(ckind, "const");
+ break;
+ case CTF_K_RESTRICT:
+ (void) strcpy(ckind, "restrict");
+ break;
+ default:
+ (void) snprintf(ckind, sizeof (ckind), "0x%x", t->dtdt_ckind);
+ }
+
+ if (t->dtdt_flags & DIF_TF_BYREF) {
+ (void) snprintf(buf, len, "%s (%s) by ref (size %lu)",
+ kind, ckind, (ulong_t)t->dtdt_size);
+ } else {
+ (void) snprintf(buf, len, "%s (%s) (size %lu)",
+ kind, ckind, (ulong_t)t->dtdt_size);
+ }
+
+ return (buf);
+}
+
+static void
+dt_dis_rtab(const char *rtag, const dtrace_difo_t *dp, FILE *fp,
+ const dof_relodesc_t *rp, uint32_t len)
+{
+ (void) fprintf(fp, "\n%-4s %-8s %-8s %s\n",
+ rtag, "OFFSET", "DATA", "NAME");
+
+ for (; len != 0; len--, rp++) {
+ (void) fprintf(fp, "%-4u %-8llu %-8llu %s\n",
+ rp->dofr_type, (u_longlong_t)rp->dofr_offset,
+ (u_longlong_t)rp->dofr_data,
+ &dp->dtdo_strtab[rp->dofr_name]);
+ }
+}
+
+void
+dt_dis(const dtrace_difo_t *dp, FILE *fp)
+{
+ static const struct opent {
+ const char *op_name;
+ void (*op_func)(const dtrace_difo_t *, const char *,
+ dif_instr_t, FILE *);
+ } optab[] = {
+ { "(illegal opcode)", dt_dis_str },
+ { "or", dt_dis_log }, /* DIF_OP_OR */
+ { "xor", dt_dis_log }, /* DIF_OP_XOR */
+ { "and", dt_dis_log }, /* DIF_OP_AND */
+ { "sll", dt_dis_log }, /* DIF_OP_SLL */
+ { "srl", dt_dis_log }, /* DIF_OP_SRL */
+ { "sub", dt_dis_log }, /* DIF_OP_SUB */
+ { "add", dt_dis_log }, /* DIF_OP_ADD */
+ { "mul", dt_dis_log }, /* DIF_OP_MUL */
+ { "sdiv", dt_dis_log }, /* DIF_OP_SDIV */
+ { "udiv", dt_dis_log }, /* DIF_OP_UDIV */
+ { "srem", dt_dis_log }, /* DIF_OP_SREM */
+ { "urem", dt_dis_log }, /* DIF_OP_UREM */
+ { "not", dt_dis_r1rd }, /* DIF_OP_NOT */
+ { "mov", dt_dis_r1rd }, /* DIF_OP_MOV */
+ { "cmp", dt_dis_cmp }, /* DIF_OP_CMP */
+ { "tst", dt_dis_tst }, /* DIF_OP_TST */
+ { "ba", dt_dis_branch }, /* DIF_OP_BA */
+ { "be", dt_dis_branch }, /* DIF_OP_BE */
+ { "bne", dt_dis_branch }, /* DIF_OP_BNE */
+ { "bg", dt_dis_branch }, /* DIF_OP_BG */
+ { "bgu", dt_dis_branch }, /* DIF_OP_BGU */
+ { "bge", dt_dis_branch }, /* DIF_OP_BGE */
+ { "bgeu", dt_dis_branch }, /* DIF_OP_BGEU */
+ { "bl", dt_dis_branch }, /* DIF_OP_BL */
+ { "blu", dt_dis_branch }, /* DIF_OP_BLU */
+ { "ble", dt_dis_branch }, /* DIF_OP_BLE */
+ { "bleu", dt_dis_branch }, /* DIF_OP_BLEU */
+ { "ldsb", dt_dis_load }, /* DIF_OP_LDSB */
+ { "ldsh", dt_dis_load }, /* DIF_OP_LDSH */
+ { "ldsw", dt_dis_load }, /* DIF_OP_LDSW */
+ { "ldub", dt_dis_load }, /* DIF_OP_LDUB */
+ { "lduh", dt_dis_load }, /* DIF_OP_LDUH */
+ { "lduw", dt_dis_load }, /* DIF_OP_LDUW */
+ { "ldx", dt_dis_load }, /* DIF_OP_LDX */
+ { "ret", dt_dis_ret }, /* DIF_OP_RET */
+ { "nop", dt_dis_str }, /* DIF_OP_NOP */
+ { "setx", dt_dis_setx }, /* DIF_OP_SETX */
+ { "sets", dt_dis_sets }, /* DIF_OP_SETS */
+ { "scmp", dt_dis_cmp }, /* DIF_OP_SCMP */
+ { "ldga", dt_dis_lda }, /* DIF_OP_LDGA */
+ { "ldgs", dt_dis_ldv }, /* DIF_OP_LDGS */
+ { "stgs", dt_dis_stv }, /* DIF_OP_STGS */
+ { "ldta", dt_dis_lda }, /* DIF_OP_LDTA */
+ { "ldts", dt_dis_ldv }, /* DIF_OP_LDTS */
+ { "stts", dt_dis_stv }, /* DIF_OP_STTS */
+ { "sra", dt_dis_log }, /* DIF_OP_SRA */
+ { "call", dt_dis_call }, /* DIF_OP_CALL */
+ { "pushtr", dt_dis_pushts }, /* DIF_OP_PUSHTR */
+ { "pushtv", dt_dis_pushts }, /* DIF_OP_PUSHTV */
+ { "popts", dt_dis_str }, /* DIF_OP_POPTS */
+ { "flushts", dt_dis_str }, /* DIF_OP_FLUSHTS */
+ { "ldgaa", dt_dis_ldv }, /* DIF_OP_LDGAA */
+ { "ldtaa", dt_dis_ldv }, /* DIF_OP_LDTAA */
+ { "stgaa", dt_dis_stv }, /* DIF_OP_STGAA */
+ { "sttaa", dt_dis_stv }, /* DIF_OP_STTAA */
+ { "ldls", dt_dis_ldv }, /* DIF_OP_LDLS */
+ { "stls", dt_dis_stv }, /* DIF_OP_STLS */
+ { "allocs", dt_dis_r1rd }, /* DIF_OP_ALLOCS */
+ { "copys", dt_dis_log }, /* DIF_OP_COPYS */
+ { "stb", dt_dis_store }, /* DIF_OP_STB */
+ { "sth", dt_dis_store }, /* DIF_OP_STH */
+ { "stw", dt_dis_store }, /* DIF_OP_STW */
+ { "stx", dt_dis_store }, /* DIF_OP_STX */
+ { "uldsb", dt_dis_load }, /* DIF_OP_ULDSB */
+ { "uldsh", dt_dis_load }, /* DIF_OP_ULDSH */
+ { "uldsw", dt_dis_load }, /* DIF_OP_ULDSW */
+ { "uldub", dt_dis_load }, /* DIF_OP_ULDUB */
+ { "ulduh", dt_dis_load }, /* DIF_OP_ULDUH */
+ { "ulduw", dt_dis_load }, /* DIF_OP_ULDUW */
+ { "uldx", dt_dis_load }, /* DIF_OP_ULDX */
+ { "rldsb", dt_dis_load }, /* DIF_OP_RLDSB */
+ { "rldsh", dt_dis_load }, /* DIF_OP_RLDSH */
+ { "rldsw", dt_dis_load }, /* DIF_OP_RLDSW */
+ { "rldub", dt_dis_load }, /* DIF_OP_RLDUB */
+ { "rlduh", dt_dis_load }, /* DIF_OP_RLDUH */
+ { "rlduw", dt_dis_load }, /* DIF_OP_RLDUW */
+ { "rldx", dt_dis_load }, /* DIF_OP_RLDX */
+ { "xlate", dt_dis_xlate }, /* DIF_OP_XLATE */
+ { "xlarg", dt_dis_xlate }, /* DIF_OP_XLARG */
+ };
+
+ const struct opent *op;
+ ulong_t i = 0;
+ char type[DT_TYPE_NAMELEN];
+
+ (void) fprintf(fp, "\nDIFO 0x%p returns %s\n", (void *)dp,
+ dt_dis_typestr(&dp->dtdo_rtype, type, sizeof (type)));
+
+ (void) fprintf(fp, "%-3s %-8s %s\n",
+ "OFF", "OPCODE", "INSTRUCTION");
+
+ for (i = 0; i < dp->dtdo_len; i++) {
+ dif_instr_t instr = dp->dtdo_buf[i];
+ dif_instr_t opcode = DIF_INSTR_OP(instr);
+
+ if (opcode >= sizeof (optab) / sizeof (optab[0]))
+ opcode = 0; /* force invalid opcode message */
+
+ op = &optab[opcode];
+ (void) fprintf(fp, "%02lu: %08x ", i, instr);
+ op->op_func(dp, op->op_name, instr, fp);
+ (void) fprintf(fp, "\n");
+ }
+
+ if (dp->dtdo_varlen != 0) {
+ (void) fprintf(fp, "\n%-16s %-4s %-3s %-3s %-4s %s\n",
+ "NAME", "ID", "KND", "SCP", "FLAG", "TYPE");
+ }
+
+ for (i = 0; i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+ char kind[4], scope[4], flags[16] = { 0 };
+
+ switch (v->dtdv_kind) {
+ case DIFV_KIND_ARRAY:
+ (void) strcpy(kind, "arr");
+ break;
+ case DIFV_KIND_SCALAR:
+ (void) strcpy(kind, "scl");
+ break;
+ default:
+ (void) snprintf(kind, sizeof (kind),
+ "%u", v->dtdv_kind);
+ }
+
+ switch (v->dtdv_scope) {
+ case DIFV_SCOPE_GLOBAL:
+ (void) strcpy(scope, "glb");
+ break;
+ case DIFV_SCOPE_THREAD:
+ (void) strcpy(scope, "tls");
+ break;
+ case DIFV_SCOPE_LOCAL:
+ (void) strcpy(scope, "loc");
+ break;
+ default:
+ (void) snprintf(scope, sizeof (scope),
+ "%u", v->dtdv_scope);
+ }
+
+ if (v->dtdv_flags & ~(DIFV_F_REF | DIFV_F_MOD)) {
+ (void) snprintf(flags, sizeof (flags), "/0x%x",
+ v->dtdv_flags & ~(DIFV_F_REF | DIFV_F_MOD));
+ }
+
+ if (v->dtdv_flags & DIFV_F_REF)
+ (void) strcat(flags, "/r");
+ if (v->dtdv_flags & DIFV_F_MOD)
+ (void) strcat(flags, "/w");
+
+ (void) fprintf(fp, "%-16s %-4x %-3s %-3s %-4s %s\n",
+ &dp->dtdo_strtab[v->dtdv_name],
+ v->dtdv_id, kind, scope, flags + 1,
+ dt_dis_typestr(&v->dtdv_type, type, sizeof (type)));
+ }
+
+ if (dp->dtdo_xlmlen != 0) {
+ (void) fprintf(fp, "\n%-4s %-3s %-12s %s\n",
+ "XLID", "ARG", "MEMBER", "TYPE");
+ }
+
+ for (i = 0; i < dp->dtdo_xlmlen; i++) {
+ dt_node_t *dnp = dp->dtdo_xlmtab[i];
+ dt_xlator_t *dxp = dnp->dn_membexpr->dn_xlator;
+ (void) fprintf(fp, "%-4u %-3d %-12s %s\n",
+ (uint_t)dxp->dx_id, dxp->dx_arg, dnp->dn_membname,
+ dt_node_type_name(dnp, type, sizeof (type)));
+ }
+
+ if (dp->dtdo_krelen != 0)
+ dt_dis_rtab("KREL", dp, fp, dp->dtdo_kreltab, dp->dtdo_krelen);
+
+ if (dp->dtdo_urelen != 0)
+ dt_dis_rtab("UREL", dp, fp, dp->dtdo_ureltab, dp->dtdo_urelen);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.c
new file mode 100644
index 00000000..bca55087
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.c
@@ -0,0 +1,969 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <sys/types.h>
+#include <sys/sysmacros.h>
+
+#include <strings.h>
+#include <alloca.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#else /* VBOX */
+# include <iprt/asm.h>
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_strtab.h>
+#include <dt_program.h>
+#include <dt_provider.h>
+#include <dt_xlator.h>
+#include <dt_dof.h>
+
+void
+dt_dof_init(dtrace_hdl_t *dtp)
+{
+ dt_dof_t *ddo = &dtp->dt_dof;
+
+ ddo->ddo_hdl = dtp;
+ ddo->ddo_nsecs = 0;
+ ddo->ddo_strsec = DOF_SECIDX_NONE;
+ ddo->ddo_xlimport = NULL;
+ ddo->ddo_xlexport = NULL;
+
+ dt_buf_create(dtp, &ddo->ddo_secs, "section headers", 0);
+ dt_buf_create(dtp, &ddo->ddo_strs, "string table", 0);
+ dt_buf_create(dtp, &ddo->ddo_ldata, "loadable data", 0);
+ dt_buf_create(dtp, &ddo->ddo_udata, "unloadable data", 0);
+
+ dt_buf_create(dtp, &ddo->ddo_probes, "probe data", 0);
+ dt_buf_create(dtp, &ddo->ddo_args, "probe args", 0);
+ dt_buf_create(dtp, &ddo->ddo_offs, "probe offs", 0);
+ dt_buf_create(dtp, &ddo->ddo_enoffs, "probe is-enabled offs", 0);
+ dt_buf_create(dtp, &ddo->ddo_rels, "probe rels", 0);
+
+ dt_buf_create(dtp, &ddo->ddo_xlms, "xlate members", 0);
+}
+
+void
+dt_dof_fini(dtrace_hdl_t *dtp)
+{
+ dt_dof_t *ddo = &dtp->dt_dof;
+
+ dt_free(dtp, ddo->ddo_xlimport);
+ dt_free(dtp, ddo->ddo_xlexport);
+
+ dt_buf_destroy(dtp, &ddo->ddo_secs);
+ dt_buf_destroy(dtp, &ddo->ddo_strs);
+ dt_buf_destroy(dtp, &ddo->ddo_ldata);
+ dt_buf_destroy(dtp, &ddo->ddo_udata);
+
+ dt_buf_destroy(dtp, &ddo->ddo_probes);
+ dt_buf_destroy(dtp, &ddo->ddo_args);
+ dt_buf_destroy(dtp, &ddo->ddo_offs);
+ dt_buf_destroy(dtp, &ddo->ddo_enoffs);
+ dt_buf_destroy(dtp, &ddo->ddo_rels);
+
+ dt_buf_destroy(dtp, &ddo->ddo_xlms);
+}
+
+static int
+dt_dof_reset(dtrace_hdl_t *dtp, dtrace_prog_t *pgp)
+{
+ dt_dof_t *ddo = &dtp->dt_dof;
+ uint_t i, nx = dtp->dt_xlatorid;
+
+ assert(ddo->ddo_hdl == dtp);
+ ddo->ddo_pgp = pgp;
+
+ ddo->ddo_nsecs = 0;
+ ddo->ddo_strsec = DOF_SECIDX_NONE;
+
+ dt_free(dtp, ddo->ddo_xlimport);
+ dt_free(dtp, ddo->ddo_xlexport);
+
+ ddo->ddo_xlimport = dt_alloc(dtp, sizeof (dof_secidx_t) * nx);
+ ddo->ddo_xlexport = dt_alloc(dtp, sizeof (dof_secidx_t) * nx);
+
+ if (nx != 0 && (ddo->ddo_xlimport == NULL || ddo->ddo_xlexport == NULL))
+ return (-1); /* errno is set for us */
+
+ for (i = 0; i < nx; i++) {
+ ddo->ddo_xlimport[i] = DOF_SECIDX_NONE;
+ ddo->ddo_xlexport[i] = DOF_SECIDX_NONE;
+ }
+
+ dt_buf_reset(dtp, &ddo->ddo_secs);
+ dt_buf_reset(dtp, &ddo->ddo_strs);
+ dt_buf_reset(dtp, &ddo->ddo_ldata);
+ dt_buf_reset(dtp, &ddo->ddo_udata);
+
+ dt_buf_reset(dtp, &ddo->ddo_probes);
+ dt_buf_reset(dtp, &ddo->ddo_args);
+ dt_buf_reset(dtp, &ddo->ddo_offs);
+ dt_buf_reset(dtp, &ddo->ddo_enoffs);
+ dt_buf_reset(dtp, &ddo->ddo_rels);
+
+ dt_buf_reset(dtp, &ddo->ddo_xlms);
+ return (0);
+}
+
+/*
+ * Add a loadable DOF section to the file using the specified data buffer and
+ * the specified DOF section attributes. DOF_SECF_LOAD must be set in flags.
+ * If 'data' is NULL, the caller is responsible for manipulating the ldata buf.
+ */
+static dof_secidx_t
+dof_add_lsect(dt_dof_t *ddo, const void *data, uint32_t type,
+ uint32_t align, uint32_t flags, uint32_t entsize, uint64_t size)
+{
+ dtrace_hdl_t *dtp = ddo->ddo_hdl;
+ dof_sec_t s;
+
+ s.dofs_type = type;
+ s.dofs_align = align;
+ s.dofs_flags = flags | DOF_SECF_LOAD;
+ s.dofs_entsize = entsize;
+ s.dofs_offset = dt_buf_offset(&ddo->ddo_ldata, align);
+ s.dofs_size = size;
+
+ dt_buf_write(dtp, &ddo->ddo_secs, &s, sizeof (s), sizeof (uint64_t));
+
+ if (data != NULL)
+ dt_buf_write(dtp, &ddo->ddo_ldata, data, size, align);
+
+ return (ddo->ddo_nsecs++);
+}
+
+/*
+ * Add an unloadable DOF section to the file using the specified data buffer
+ * and DOF section attributes. DOF_SECF_LOAD must *not* be set in flags.
+ * If 'data' is NULL, the caller is responsible for manipulating the udata buf.
+ */
+static dof_secidx_t
+dof_add_usect(dt_dof_t *ddo, const void *data, uint32_t type,
+ uint32_t align, uint32_t flags, uint32_t entsize, uint64_t size)
+{
+ dtrace_hdl_t *dtp = ddo->ddo_hdl;
+ dof_sec_t s;
+
+ s.dofs_type = type;
+ s.dofs_align = align;
+ s.dofs_flags = flags & ~DOF_SECF_LOAD;
+ s.dofs_entsize = entsize;
+ s.dofs_offset = dt_buf_offset(&ddo->ddo_udata, align);
+ s.dofs_size = size;
+
+ dt_buf_write(dtp, &ddo->ddo_secs, &s, sizeof (s), sizeof (uint64_t));
+
+ if (data != NULL)
+ dt_buf_write(dtp, &ddo->ddo_udata, data, size, align);
+
+ return (ddo->ddo_nsecs++);
+}
+
+/*
+ * Add a string to the global string table associated with the DOF. The offset
+ * of the string is returned as an index into the string table.
+ */
+static dof_stridx_t
+dof_add_string(dt_dof_t *ddo, const char *s)
+{
+ dt_buf_t *bp = &ddo->ddo_strs;
+ dof_stridx_t i = VBDTCAST(dof_stridx_t)dt_buf_len(bp);
+
+ if (i != 0 && (s == NULL || *s == '\0'))
+ return (0); /* string table has \0 at offset 0 */
+
+ dt_buf_write(ddo->ddo_hdl, bp, s, strlen(s) + 1, sizeof (char));
+ return (i);
+}
+
+static dof_attr_t
+dof_attr(const dtrace_attribute_t *ap)
+{
+ return (DOF_ATTR(ap->dtat_name, ap->dtat_data, ap->dtat_class));
+}
+
+static dof_secidx_t
+dof_add_difo(dt_dof_t *ddo, const dtrace_difo_t *dp)
+{
+ dof_secidx_t dsecs[5]; /* enough for all possible DIFO sections */
+ uint_t nsecs = 0;
+
+ dof_difohdr_t *dofd;
+ dof_relohdr_t dofr;
+ dof_secidx_t relsec;
+
+ dof_secidx_t strsec = DOF_SECIDX_NONE;
+ dof_secidx_t intsec = DOF_SECIDX_NONE;
+ dof_secidx_t hdrsec = DOF_SECIDX_NONE;
+
+ if (dp->dtdo_buf != NULL) {
+ dsecs[nsecs++] = dof_add_lsect(ddo, dp->dtdo_buf,
+ DOF_SECT_DIF, sizeof (dif_instr_t), 0,
+ sizeof (dif_instr_t), sizeof (dif_instr_t) * dp->dtdo_len);
+ }
+
+ if (dp->dtdo_inttab != NULL) {
+ dsecs[nsecs++] = intsec = dof_add_lsect(ddo, dp->dtdo_inttab,
+ DOF_SECT_INTTAB, sizeof (uint64_t), 0,
+ sizeof (uint64_t), sizeof (uint64_t) * dp->dtdo_intlen);
+ }
+
+ if (dp->dtdo_strtab != NULL) {
+ dsecs[nsecs++] = strsec = dof_add_lsect(ddo, dp->dtdo_strtab,
+ DOF_SECT_STRTAB, sizeof (char), 0, 0, dp->dtdo_strlen);
+ }
+
+ if (dp->dtdo_vartab != NULL) {
+ dsecs[nsecs++] = dof_add_lsect(ddo, dp->dtdo_vartab,
+ DOF_SECT_VARTAB, sizeof (uint_t), 0, sizeof (dtrace_difv_t),
+ sizeof (dtrace_difv_t) * dp->dtdo_varlen);
+ }
+
+ if (dp->dtdo_xlmtab != NULL) {
+ dof_xlref_t *xlt, *xlp;
+ dt_node_t **pnp;
+
+ xlt = alloca(sizeof (dof_xlref_t) * dp->dtdo_xlmlen);
+ pnp = dp->dtdo_xlmtab;
+
+ /*
+ * dtdo_xlmtab contains pointers to the translator members.
+ * The translator itself is in sect ddo_xlimport[dxp->dx_id].
+ * The XLMEMBERS entries are in order by their dn_membid, so
+ * the member section offset is the population count of bits
+ * in ddo_pgp->dp_xlrefs[] up to and not including dn_membid.
+ */
+ for (xlp = xlt; xlp < xlt + dp->dtdo_xlmlen; xlp++) {
+ dt_node_t *dnp = *pnp++;
+ dt_xlator_t *dxp = dnp->dn_membexpr->dn_xlator;
+
+ xlp->dofxr_xlator = ddo->ddo_xlimport[dxp->dx_id];
+ xlp->dofxr_member = dt_popcb(
+ ddo->ddo_pgp->dp_xrefs[dxp->dx_id], dnp->dn_membid);
+ xlp->dofxr_argn = (uint32_t)dxp->dx_arg;
+ }
+
+ dsecs[nsecs++] = dof_add_lsect(ddo, xlt, DOF_SECT_XLTAB,
+ sizeof (dof_secidx_t), 0, sizeof (dof_xlref_t),
+ sizeof (dof_xlref_t) * dp->dtdo_xlmlen);
+ }
+
+ /*
+ * Copy the return type and the array of section indices that form the
+ * DIFO into a single dof_difohdr_t and then add DOF_SECT_DIFOHDR.
+ */
+ assert(nsecs <= sizeof (dsecs) / sizeof (dsecs[0]));
+ dofd = alloca(sizeof (dtrace_diftype_t) + sizeof (dsecs));
+ bcopy(&dp->dtdo_rtype, &dofd->dofd_rtype, sizeof (dtrace_diftype_t));
+ bcopy(dsecs, &dofd->dofd_links, sizeof (dof_secidx_t) * nsecs);
+
+ hdrsec = dof_add_lsect(ddo, dofd, DOF_SECT_DIFOHDR,
+ sizeof (dof_secidx_t), 0, 0,
+ sizeof (dtrace_diftype_t) + sizeof (dof_secidx_t) * nsecs);
+
+ /*
+ * Add any other sections related to dtrace_difo_t. These are not
+ * referenced in dof_difohdr_t because they are not used by emulation.
+ */
+ if (dp->dtdo_kreltab != NULL) {
+ relsec = dof_add_lsect(ddo, dp->dtdo_kreltab, DOF_SECT_RELTAB,
+ sizeof (uint64_t), 0, sizeof (dof_relodesc_t),
+ sizeof (dof_relodesc_t) * dp->dtdo_krelen);
+
+ /*
+ * This code assumes the target of all relocations is the
+ * integer table 'intsec' (DOF_SECT_INTTAB). If other sections
+ * need relocation in the future this will need to change.
+ */
+ dofr.dofr_strtab = strsec;
+ dofr.dofr_relsec = relsec;
+ dofr.dofr_tgtsec = intsec;
+
+ (void) dof_add_lsect(ddo, &dofr, DOF_SECT_KRELHDR,
+ sizeof (dof_secidx_t), 0, 0, sizeof (dof_relohdr_t));
+ }
+
+ if (dp->dtdo_ureltab != NULL) {
+ relsec = dof_add_lsect(ddo, dp->dtdo_ureltab, DOF_SECT_RELTAB,
+ sizeof (uint64_t), 0, sizeof (dof_relodesc_t),
+ sizeof (dof_relodesc_t) * dp->dtdo_urelen);
+
+ /*
+ * This code assumes the target of all relocations is the
+ * integer table 'intsec' (DOF_SECT_INTTAB). If other sections
+ * need relocation in the future this will need to change.
+ */
+ dofr.dofr_strtab = strsec;
+ dofr.dofr_relsec = relsec;
+ dofr.dofr_tgtsec = intsec;
+
+ (void) dof_add_lsect(ddo, &dofr, DOF_SECT_URELHDR,
+ sizeof (dof_secidx_t), 0, 0, sizeof (dof_relohdr_t));
+ }
+
+ return (hdrsec);
+}
+
+static void
+dof_add_translator(dt_dof_t *ddo, const dt_xlator_t *dxp, uint_t type)
+{
+ dtrace_hdl_t *dtp = ddo->ddo_hdl;
+ dof_xlmember_t dofxm;
+ dof_xlator_t dofxl;
+ dof_secidx_t *xst;
+
+ char buf[DT_TYPE_NAMELEN];
+ dt_node_t *dnp;
+ uint_t i = 0;
+
+ assert(type == DOF_SECT_XLIMPORT || type == DOF_SECT_XLEXPORT);
+ xst = type == DOF_SECT_XLIMPORT ? ddo->ddo_xlimport : ddo->ddo_xlexport;
+
+ if (xst[dxp->dx_id] != DOF_SECIDX_NONE)
+ return; /* translator has already been emitted */
+
+ dt_buf_reset(dtp, &ddo->ddo_xlms);
+
+ /*
+ * Generate an array of dof_xlmember_t's into ddo_xlms. If we are
+ * importing the translator, add only those members referenced by the
+ * program and set the dofxm_difo reference of each member to NONE. If
+ * we're exporting the translator, add all members and a DIFO for each.
+ */
+ for (dnp = dxp->dx_members; dnp != NULL; dnp = dnp->dn_list, i++) {
+ if (type == DOF_SECT_XLIMPORT) {
+ if (!BT_TEST(ddo->ddo_pgp->dp_xrefs[dxp->dx_id], i))
+ continue; /* member is not referenced */
+ dofxm.dofxm_difo = DOF_SECIDX_NONE;
+ } else {
+ dofxm.dofxm_difo = dof_add_difo(ddo,
+ dxp->dx_membdif[dnp->dn_membid]);
+ }
+
+ dofxm.dofxm_name = dof_add_string(ddo, dnp->dn_membname);
+ dt_node_diftype(dtp, dnp, &dofxm.dofxm_type);
+
+ dt_buf_write(dtp, &ddo->ddo_xlms,
+ &dofxm, sizeof (dofxm), sizeof (uint32_t));
+ }
+
+ dofxl.dofxl_members = dof_add_lsect(ddo, NULL, DOF_SECT_XLMEMBERS,
+ sizeof (uint32_t), 0, sizeof (dofxm), dt_buf_len(&ddo->ddo_xlms));
+
+ dt_buf_concat(dtp, &ddo->ddo_ldata, &ddo->ddo_xlms, sizeof (uint32_t));
+
+ dofxl.dofxl_strtab = ddo->ddo_strsec;
+ dofxl.dofxl_argv = dof_add_string(ddo, ctf_type_name(
+ dxp->dx_src_ctfp, dxp->dx_src_type, buf, sizeof (buf)));
+ dofxl.dofxl_argc = 1;
+ dofxl.dofxl_type = dof_add_string(ddo, ctf_type_name(
+ dxp->dx_dst_ctfp, dxp->dx_dst_type, buf, sizeof (buf)));
+ dofxl.dofxl_attr = dof_attr(&dxp->dx_souid.di_attr);
+
+ xst[dxp->dx_id] = dof_add_lsect(ddo, &dofxl, type,
+ sizeof (uint32_t), 0, 0, sizeof (dofxl));
+}
+
+/*ARGSUSED*/
+static int
+dof_add_probe(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
+{
+ dt_dof_t *ddo = data;
+ dtrace_hdl_t *dtp = ddo->ddo_hdl;
+ dt_probe_t *prp = idp->di_data;
+
+ dof_probe_t dofpr;
+ dof_relodesc_t dofr;
+ dt_probe_instance_t *pip;
+ dt_node_t *dnp;
+
+ char buf[DT_TYPE_NAMELEN];
+ uint_t i;
+ RT_NOREF1(dhp);
+
+ dofpr.dofpr_addr = 0;
+ dofpr.dofpr_name = dof_add_string(ddo, prp->pr_name);
+ dofpr.dofpr_nargv = VBDTCAST(dof_stridx_t)dt_buf_len(&ddo->ddo_strs);
+
+ for (dnp = prp->pr_nargs; dnp != NULL; dnp = dnp->dn_list) {
+ (void) dof_add_string(ddo, ctf_type_name(dnp->dn_ctfp,
+ dnp->dn_type, buf, sizeof (buf)));
+ }
+
+ dofpr.dofpr_xargv = VBDTCAST(dof_stridx_t)dt_buf_len(&ddo->ddo_strs);
+
+ for (dnp = prp->pr_xargs; dnp != NULL; dnp = dnp->dn_list) {
+ (void) dof_add_string(ddo, ctf_type_name(dnp->dn_ctfp,
+ dnp->dn_type, buf, sizeof (buf)));
+ }
+
+ dofpr.dofpr_argidx = VBDTCAST(uint32_t)dt_buf_len(&ddo->ddo_args) / sizeof (uint8_t);
+
+ for (i = 0; i < prp->pr_xargc; i++) {
+ dt_buf_write(dtp, &ddo->ddo_args, &prp->pr_mapping[i],
+ sizeof (uint8_t), sizeof (uint8_t));
+ }
+
+ dofpr.dofpr_nargc = prp->pr_nargc;
+ dofpr.dofpr_xargc = prp->pr_xargc;
+ dofpr.dofpr_pad1 = 0;
+ dofpr.dofpr_pad2 = 0;
+
+ for (pip = prp->pr_inst; pip != NULL; pip = pip->pi_next) {
+ dt_dprintf("adding probe for %s:%s\n", pip->pi_fname,
+ prp->pr_name);
+
+ dofpr.dofpr_func = dof_add_string(ddo, pip->pi_fname);
+
+ /*
+ * There should be one probe offset or is-enabled probe offset
+ * or else this probe instance won't have been created. The
+ * kernel will reject DOF which has a probe with no offsets.
+ */
+ assert(pip->pi_noffs + pip->pi_nenoffs > 0);
+
+ dofpr.dofpr_offidx =
+ VBDTCAST(uint32_t)(dt_buf_len(&ddo->ddo_offs) / sizeof (uint32_t));
+ dofpr.dofpr_noffs = pip->pi_noffs;
+ dt_buf_write(dtp, &ddo->ddo_offs, pip->pi_offs,
+ pip->pi_noffs * sizeof (uint32_t), sizeof (uint32_t));
+
+ dofpr.dofpr_enoffidx =
+ VBDTCAST(uint32_t)(dt_buf_len(&ddo->ddo_enoffs) / sizeof (uint32_t));
+ dofpr.dofpr_nenoffs = pip->pi_nenoffs;
+ dt_buf_write(dtp, &ddo->ddo_enoffs, pip->pi_enoffs,
+ pip->pi_nenoffs * sizeof (uint32_t), sizeof (uint32_t));
+
+ /*
+ * If pi_rname isn't set, the relocation will be against the
+ * function name. If it is, the relocation will be against
+ * pi_rname. This will be used if the function is scoped
+ * locally so an alternate symbol is added for the purpose
+ * of this relocation.
+ */
+ if (pip->pi_rname[0] == '\0')
+ dofr.dofr_name = dofpr.dofpr_func;
+ else
+ dofr.dofr_name = dof_add_string(ddo, pip->pi_rname);
+ dofr.dofr_type = DOF_RELO_SETX;
+ dofr.dofr_offset = dt_buf_len(&ddo->ddo_probes);
+ dofr.dofr_data = 0;
+
+ dt_buf_write(dtp, &ddo->ddo_rels, &dofr,
+ sizeof (dofr), sizeof (uint64_t));
+
+ dt_buf_write(dtp, &ddo->ddo_probes, &dofpr,
+ sizeof (dofpr), sizeof (uint64_t));
+ }
+
+ return (0);
+}
+
+static void
+dof_add_provider(dt_dof_t *ddo, const dt_provider_t *pvp)
+{
+ dtrace_hdl_t *dtp = ddo->ddo_hdl;
+ dof_provider_t dofpv;
+ dof_relohdr_t dofr;
+ dof_secidx_t *dofs;
+ ulong_t xr, nxr;
+ size_t sz;
+ id_t i;
+
+ if (pvp->pv_flags & DT_PROVIDER_IMPL)
+ return; /* ignore providers that are exported by dtrace(7D) */
+
+ nxr = dt_popcb(pvp->pv_xrefs, pvp->pv_xrmax);
+ dofs = alloca(sizeof (dof_secidx_t) * (nxr + 1));
+ xr = 1; /* reserve dofs[0] for the provider itself */
+
+ /*
+ * For each translator referenced by the provider (pv_xrefs), emit an
+ * exported translator section for it if one hasn't been created yet.
+ */
+ for (i = 0; i < pvp->pv_xrmax; i++) {
+ if (BT_TEST(pvp->pv_xrefs, i) &&
+ dtp->dt_xlatemode == DT_XL_DYNAMIC) {
+ dof_add_translator(ddo,
+ dt_xlator_lookup_id(dtp, i), DOF_SECT_XLEXPORT);
+ dofs[xr++] = ddo->ddo_xlexport[i];
+ }
+ }
+
+ dt_buf_reset(dtp, &ddo->ddo_probes);
+ dt_buf_reset(dtp, &ddo->ddo_args);
+ dt_buf_reset(dtp, &ddo->ddo_offs);
+ dt_buf_reset(dtp, &ddo->ddo_enoffs);
+ dt_buf_reset(dtp, &ddo->ddo_rels);
+
+ (void) dt_idhash_iter(pvp->pv_probes, dof_add_probe, ddo);
+
+ dofpv.dofpv_probes = dof_add_lsect(ddo, NULL, DOF_SECT_PROBES,
+ sizeof (uint64_t), 0, sizeof (dof_probe_t),
+ dt_buf_len(&ddo->ddo_probes));
+
+ dt_buf_concat(dtp, &ddo->ddo_ldata,
+ &ddo->ddo_probes, sizeof (uint64_t));
+
+ dofpv.dofpv_prargs = dof_add_lsect(ddo, NULL, DOF_SECT_PRARGS,
+ sizeof (uint8_t), 0, sizeof (uint8_t), dt_buf_len(&ddo->ddo_args));
+
+ dt_buf_concat(dtp, &ddo->ddo_ldata, &ddo->ddo_args, sizeof (uint8_t));
+
+ dofpv.dofpv_proffs = dof_add_lsect(ddo, NULL, DOF_SECT_PROFFS,
+ sizeof (uint_t), 0, sizeof (uint_t), dt_buf_len(&ddo->ddo_offs));
+
+ dt_buf_concat(dtp, &ddo->ddo_ldata, &ddo->ddo_offs, sizeof (uint_t));
+
+ if ((sz = dt_buf_len(&ddo->ddo_enoffs)) != 0) {
+ dofpv.dofpv_prenoffs = dof_add_lsect(ddo, NULL,
+ DOF_SECT_PRENOFFS, sizeof (uint_t), 0, sizeof (uint_t), sz);
+ } else {
+ dofpv.dofpv_prenoffs = DOF_SECT_NONE;
+ }
+
+ dt_buf_concat(dtp, &ddo->ddo_ldata, &ddo->ddo_enoffs, sizeof (uint_t));
+
+ dofpv.dofpv_strtab = ddo->ddo_strsec;
+ dofpv.dofpv_name = dof_add_string(ddo, pvp->pv_desc.dtvd_name);
+
+ dofpv.dofpv_provattr = dof_attr(&pvp->pv_desc.dtvd_attr.dtpa_provider);
+ dofpv.dofpv_modattr = dof_attr(&pvp->pv_desc.dtvd_attr.dtpa_mod);
+ dofpv.dofpv_funcattr = dof_attr(&pvp->pv_desc.dtvd_attr.dtpa_func);
+ dofpv.dofpv_nameattr = dof_attr(&pvp->pv_desc.dtvd_attr.dtpa_name);
+ dofpv.dofpv_argsattr = dof_attr(&pvp->pv_desc.dtvd_attr.dtpa_args);
+
+ dofs[0] = dof_add_lsect(ddo, &dofpv, DOF_SECT_PROVIDER,
+ sizeof (dof_secidx_t), 0, 0, sizeof (dof_provider_t));
+
+ dofr.dofr_strtab = dofpv.dofpv_strtab;
+ dofr.dofr_tgtsec = dofpv.dofpv_probes;
+ dofr.dofr_relsec = dof_add_lsect(ddo, NULL, DOF_SECT_RELTAB,
+ sizeof (uint64_t), 0, sizeof (dof_relodesc_t),
+ dt_buf_len(&ddo->ddo_rels));
+
+ dt_buf_concat(dtp, &ddo->ddo_ldata, &ddo->ddo_rels, sizeof (uint64_t));
+
+ (void) dof_add_lsect(ddo, &dofr, DOF_SECT_URELHDR,
+ sizeof (dof_secidx_t), 0, 0, sizeof (dof_relohdr_t));
+
+ if (nxr != 0 && dtp->dt_xlatemode == DT_XL_DYNAMIC) {
+ (void) dof_add_lsect(ddo, dofs, DOF_SECT_PREXPORT,
+ sizeof (dof_secidx_t), 0, sizeof (dof_secidx_t),
+ sizeof (dof_secidx_t) * (nxr + 1));
+ }
+}
+
+static int
+dof_hdr(dtrace_hdl_t *dtp, uint8_t dofversion, dof_hdr_t *hp)
+{
+ /*
+ * If our config values cannot fit in a uint8_t, we can't generate a
+ * DOF header since the values won't fit. This can only happen if the
+ * user forcibly compiles a program with an artificial configuration.
+ */
+ if (dtp->dt_conf.dtc_difversion > UINT8_MAX ||
+ dtp->dt_conf.dtc_difintregs > UINT8_MAX ||
+ dtp->dt_conf.dtc_diftupregs > UINT8_MAX)
+ return (dt_set_errno(dtp, EOVERFLOW));
+
+ bzero(hp, sizeof (dof_hdr_t));
+
+ hp->dofh_ident[DOF_ID_MAG0] = DOF_MAG_MAG0;
+ hp->dofh_ident[DOF_ID_MAG1] = DOF_MAG_MAG1;
+ hp->dofh_ident[DOF_ID_MAG2] = DOF_MAG_MAG2;
+ hp->dofh_ident[DOF_ID_MAG3] = DOF_MAG_MAG3;
+
+ if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64)
+ hp->dofh_ident[DOF_ID_MODEL] = DOF_MODEL_LP64;
+ else
+ hp->dofh_ident[DOF_ID_MODEL] = DOF_MODEL_ILP32;
+
+ hp->dofh_ident[DOF_ID_ENCODING] = DOF_ENCODE_NATIVE;
+ hp->dofh_ident[DOF_ID_VERSION] = dofversion;
+ hp->dofh_ident[DOF_ID_DIFVERS] = dtp->dt_conf.dtc_difversion;
+ hp->dofh_ident[DOF_ID_DIFIREG] = dtp->dt_conf.dtc_difintregs;
+ hp->dofh_ident[DOF_ID_DIFTREG] = dtp->dt_conf.dtc_diftupregs;
+
+ hp->dofh_hdrsize = sizeof (dof_hdr_t);
+ hp->dofh_secsize = sizeof (dof_sec_t);
+ hp->dofh_secoff = sizeof (dof_hdr_t);
+
+ return (0);
+}
+
+void *
+dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags)
+{
+ dt_dof_t *ddo = &dtp->dt_dof;
+
+ const dtrace_ecbdesc_t *edp, *last;
+ const dtrace_probedesc_t *pdp;
+ const dtrace_actdesc_t *ap;
+ const dt_stmt_t *stp;
+
+ uint_t maxacts = 0;
+ uint_t maxfmt = 0;
+
+ dt_provider_t *pvp;
+ dt_xlator_t *dxp;
+ dof_actdesc_t *dofa;
+ dof_sec_t *sp;
+ size_t ssize, lsize;
+ dof_hdr_t h;
+
+ dt_buf_t dof;
+ char *fmt;
+ uint_t i;
+
+ if (flags & ~DTRACE_D_MASK) {
+ (void) dt_set_errno(dtp, EINVAL);
+ return (NULL);
+ }
+
+ flags |= dtp->dt_dflags;
+
+ if (dof_hdr(dtp, pgp->dp_dofversion, &h) != 0)
+ return (NULL);
+
+ if (dt_dof_reset(dtp, pgp) != 0)
+ return (NULL);
+
+ /*
+ * Iterate through the statement list computing the maximum number of
+ * actions and the maximum format string for allocating local buffers.
+ */
+ for (last = NULL, stp = dt_list_next(&pgp->dp_stmts);
+ stp != NULL; stp = dt_list_next(stp), last = edp) {
+
+ dtrace_stmtdesc_t *sdp = stp->ds_desc;
+ dtrace_actdesc_t *ap = sdp->dtsd_action;
+
+ if (sdp->dtsd_fmtdata != NULL) {
+ i = VBDTCAST(uint_t)dtrace_printf_format(dtp,
+ sdp->dtsd_fmtdata, NULL, 0);
+ maxfmt = MAX(maxfmt, i);
+ }
+
+ if ((edp = sdp->dtsd_ecbdesc) == last)
+ continue; /* same ecb as previous statement */
+
+ for (i = 0, ap = edp->dted_action; ap; ap = ap->dtad_next)
+ i++;
+
+ maxacts = MAX(maxacts, i);
+ }
+
+ dofa = alloca(sizeof (dof_actdesc_t) * maxacts);
+ fmt = alloca(maxfmt + 1);
+
+ ddo->ddo_strsec = dof_add_lsect(ddo, NULL, DOF_SECT_STRTAB, 1, 0, 0, 0);
+ (void) dof_add_string(ddo, "");
+
+ /*
+ * If there are references to dynamic translators in the program, add
+ * an imported translator table entry for each referenced translator.
+ */
+ if (pgp->dp_xrefslen != 0) {
+ for (dxp = dt_list_next(&dtp->dt_xlators);
+ dxp != NULL; dxp = dt_list_next(dxp)) {
+ if (dxp->dx_id < pgp->dp_xrefslen &&
+ pgp->dp_xrefs[dxp->dx_id] != NULL)
+ dof_add_translator(ddo, dxp, DOF_SECT_XLIMPORT);
+ }
+ }
+
+ /*
+ * Now iterate through the statement list, creating the DOF section
+ * headers and data for each one and adding them to our buffers.
+ */
+ for (last = NULL, stp = dt_list_next(&pgp->dp_stmts);
+ stp != NULL; stp = dt_list_next(stp), last = edp) {
+
+ dof_secidx_t probesec = DOF_SECIDX_NONE;
+ dof_secidx_t prdsec = DOF_SECIDX_NONE;
+ dof_secidx_t actsec = DOF_SECIDX_NONE;
+
+ const dt_stmt_t *next = stp;
+ dtrace_stmtdesc_t *sdp = stp->ds_desc;
+ dof_stridx_t strndx = 0;
+ dof_probedesc_t dofp;
+ dof_ecbdesc_t dofe;
+ uint_t i;
+
+ if ((edp = stp->ds_desc->dtsd_ecbdesc) == last)
+ continue; /* same ecb as previous statement */
+
+ pdp = &edp->dted_probe;
+
+ /*
+ * Add a DOF_SECT_PROBEDESC for the ECB's probe description,
+ * and copy the probe description strings into the string table.
+ */
+ dofp.dofp_strtab = ddo->ddo_strsec;
+ dofp.dofp_provider = dof_add_string(ddo, pdp->dtpd_provider);
+ dofp.dofp_mod = dof_add_string(ddo, pdp->dtpd_mod);
+ dofp.dofp_func = dof_add_string(ddo, pdp->dtpd_func);
+ dofp.dofp_name = dof_add_string(ddo, pdp->dtpd_name);
+ dofp.dofp_id = pdp->dtpd_id;
+
+ probesec = dof_add_lsect(ddo, &dofp, DOF_SECT_PROBEDESC,
+ sizeof (dof_secidx_t), 0,
+ sizeof (dof_probedesc_t), sizeof (dof_probedesc_t));
+
+ /*
+ * If there is a predicate DIFO associated with the ecbdesc,
+ * write out the DIFO sections and save the DIFO section index.
+ */
+ if (edp->dted_pred.dtpdd_difo != NULL)
+ prdsec = dof_add_difo(ddo, edp->dted_pred.dtpdd_difo);
+
+ /*
+ * Now iterate through the action list generating DIFOs as
+ * referenced therein and adding action descriptions to 'dofa'.
+ */
+ for (i = 0, ap = edp->dted_action;
+ ap != NULL; ap = ap->dtad_next, i++) {
+
+ if (ap->dtad_difo != NULL) {
+ dofa[i].dofa_difo =
+ dof_add_difo(ddo, ap->dtad_difo);
+ } else
+ dofa[i].dofa_difo = DOF_SECIDX_NONE;
+
+ /*
+ * If the first action in a statement has format data,
+ * add the format string to the global string table.
+ */
+ if (sdp != NULL && ap == sdp->dtsd_action) {
+ if (sdp->dtsd_fmtdata != NULL) {
+ (void) dtrace_printf_format(dtp,
+ sdp->dtsd_fmtdata, fmt, maxfmt + 1);
+ strndx = dof_add_string(ddo, fmt);
+ } else
+ strndx = 0; /* use dtad_arg instead */
+
+ if ((next = dt_list_next(next)) != NULL)
+ sdp = next->ds_desc;
+ else
+ sdp = NULL;
+ }
+
+ if (strndx != 0) {
+ dofa[i].dofa_arg = strndx;
+ dofa[i].dofa_strtab = ddo->ddo_strsec;
+ } else {
+ dofa[i].dofa_arg = ap->dtad_arg;
+ dofa[i].dofa_strtab = DOF_SECIDX_NONE;
+ }
+
+ dofa[i].dofa_kind = ap->dtad_kind;
+ dofa[i].dofa_ntuple = ap->dtad_ntuple;
+ dofa[i].dofa_uarg = ap->dtad_uarg;
+ }
+
+ if (i > 0) {
+ actsec = dof_add_lsect(ddo, dofa, DOF_SECT_ACTDESC,
+ sizeof (uint64_t), 0, sizeof (dof_actdesc_t),
+ sizeof (dof_actdesc_t) * i);
+ }
+
+ /*
+ * Now finally, add the DOF_SECT_ECBDESC referencing all the
+ * previously created sub-sections.
+ */
+ dofe.dofe_probes = probesec;
+ dofe.dofe_pred = prdsec;
+ dofe.dofe_actions = actsec;
+ dofe.dofe_pad = 0;
+ dofe.dofe_uarg = edp->dted_uarg;
+
+ (void) dof_add_lsect(ddo, &dofe, DOF_SECT_ECBDESC,
+ sizeof (uint64_t), 0, 0, sizeof (dof_ecbdesc_t));
+ }
+
+ /*
+ * If any providers are user-defined, output DOF sections corresponding
+ * to the providers and the probes and arguments that they define.
+ */
+ if (flags & DTRACE_D_PROBES) {
+ for (pvp = dt_list_next(&dtp->dt_provlist);
+ pvp != NULL; pvp = dt_list_next(pvp))
+ dof_add_provider(ddo, pvp);
+ }
+
+ /*
+ * If we're not stripping unloadable sections, generate compiler
+ * comments and any other unloadable miscellany.
+ */
+ if (!(flags & DTRACE_D_STRIP)) {
+ (void) dof_add_usect(ddo, _dtrace_version, DOF_SECT_COMMENTS,
+ sizeof (char), 0, 0, strlen(_dtrace_version) + 1);
+#ifndef VBOX
+ (void) dof_add_usect(ddo, &dtp->dt_uts, DOF_SECT_UTSNAME,
+ sizeof (char), 0, 0, sizeof (struct utsname));
+#endif
+ }
+
+ /*
+ * Compute and fill in the appropriate values for the dof_hdr_t's
+ * dofh_secnum, dofh_loadsz, and dofh_filez values.
+ */
+ h.dofh_secnum = ddo->ddo_nsecs;
+ ssize = sizeof (h) + dt_buf_len(&ddo->ddo_secs);
+
+ h.dofh_loadsz = ssize +
+ dt_buf_len(&ddo->ddo_ldata) +
+ dt_buf_len(&ddo->ddo_strs);
+
+ if (dt_buf_len(&ddo->ddo_udata) != 0) {
+ lsize = roundup(h.dofh_loadsz, sizeof (uint64_t));
+ h.dofh_filesz = lsize + dt_buf_len(&ddo->ddo_udata);
+ } else {
+ lsize = h.dofh_loadsz;
+ h.dofh_filesz = lsize;
+ }
+
+ /*
+ * Set the global DOF_SECT_STRTAB's offset to be after the header,
+ * section headers, and other loadable data. Since we're going to
+ * iterate over the buffer data directly, we must check for errors.
+ */
+ if ((i = dt_buf_error(&ddo->ddo_secs)) != 0) {
+ (void) dt_set_errno(dtp, i);
+ return (NULL);
+ }
+
+ sp = dt_buf_ptr(&ddo->ddo_secs);
+ assert(sp[ddo->ddo_strsec].dofs_type == DOF_SECT_STRTAB);
+ assert(ssize == sizeof (h) + sizeof (dof_sec_t) * ddo->ddo_nsecs);
+
+ sp[ddo->ddo_strsec].dofs_offset = ssize + dt_buf_len(&ddo->ddo_ldata);
+ sp[ddo->ddo_strsec].dofs_size = dt_buf_len(&ddo->ddo_strs);
+
+ /*
+ * Now relocate all the other section headers by adding the appropriate
+ * delta to their respective dofs_offset values.
+ */
+ for (i = 0; i < ddo->ddo_nsecs; i++, sp++) {
+ if (i == ddo->ddo_strsec)
+ continue; /* already relocated above */
+
+ if (sp->dofs_flags & DOF_SECF_LOAD)
+ sp->dofs_offset += ssize;
+ else
+ sp->dofs_offset += lsize;
+ }
+
+ /*
+ * Finally, assemble the complete in-memory DOF buffer by writing the
+ * header and then concatenating all our buffers. dt_buf_concat() will
+ * propagate any errors and cause dt_buf_claim() to return NULL.
+ */
+ dt_buf_create(dtp, &dof, "dof", h.dofh_filesz);
+
+ dt_buf_write(dtp, &dof, &h, sizeof (h), sizeof (uint64_t));
+ dt_buf_concat(dtp, &dof, &ddo->ddo_secs, sizeof (uint64_t));
+ dt_buf_concat(dtp, &dof, &ddo->ddo_ldata, sizeof (uint64_t));
+ dt_buf_concat(dtp, &dof, &ddo->ddo_strs, sizeof (char));
+ dt_buf_concat(dtp, &dof, &ddo->ddo_udata, sizeof (uint64_t));
+
+ return (dt_buf_claim(dtp, &dof));
+}
+
+void
+dtrace_dof_destroy(dtrace_hdl_t *dtp, void *dof)
+{
+ dt_free(dtp, dof);
+}
+
+void *
+dtrace_getopt_dof(dtrace_hdl_t *dtp)
+{
+ dof_hdr_t *dof;
+ dof_sec_t *sec;
+ dof_optdesc_t *dofo;
+ int i, nopts = 0, len = sizeof (dof_hdr_t) +
+ roundup(sizeof (dof_sec_t), sizeof (uint64_t));
+
+ for (i = 0; i < DTRACEOPT_MAX; i++) {
+ if (dtp->dt_options[i] != DTRACEOPT_UNSET)
+ nopts++;
+ }
+
+ len += sizeof (dof_optdesc_t) * nopts;
+
+ if ((dof = dt_zalloc(dtp, len)) == NULL ||
+ dof_hdr(dtp, DOF_VERSION, dof) != 0) {
+ dt_free(dtp, dof);
+ return (NULL);
+ }
+
+ dof->dofh_secnum = 1; /* only DOF_SECT_OPTDESC */
+ dof->dofh_loadsz = len;
+ dof->dofh_filesz = len;
+
+ /*
+ * Fill in the option section header...
+ */
+ sec = (dof_sec_t *)((uintptr_t)dof + sizeof (dof_hdr_t));
+ sec->dofs_type = DOF_SECT_OPTDESC;
+ sec->dofs_align = sizeof (uint64_t);
+ sec->dofs_flags = DOF_SECF_LOAD;
+ sec->dofs_entsize = sizeof (dof_optdesc_t);
+
+ dofo = (dof_optdesc_t *)((uintptr_t)sec +
+ roundup(sizeof (dof_sec_t), sizeof (uint64_t)));
+
+ sec->dofs_offset = (uintptr_t)dofo - (uintptr_t)dof;
+ sec->dofs_size = sizeof (dof_optdesc_t) * nopts;
+
+ for (i = 0; i < DTRACEOPT_MAX; i++) {
+ if (dtp->dt_options[i] == DTRACEOPT_UNSET)
+ continue;
+
+ dofo->dofo_option = i;
+ dofo->dofo_strtab = DOF_SECIDX_NONE;
+ dofo->dofo_value = dtp->dt_options[i];
+ dofo++;
+ }
+
+ return (dof);
+}
+
+void *
+dtrace_geterr_dof(dtrace_hdl_t *dtp)
+{
+ if (dtp->dt_errprog != NULL)
+ return (dtrace_dof_create(dtp, dtp->dt_errprog, 0));
+
+ (void) dt_set_errno(dtp, EDT_BADERROR);
+ return (NULL);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.h
new file mode 100644
index 00000000..a896497d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.h
@@ -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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_DOF_H
+#define _DT_DOF_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <dtrace.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dt_buf.h>
+
+typedef struct dt_dof {
+ dtrace_hdl_t *ddo_hdl; /* libdtrace handle */
+ dtrace_prog_t *ddo_pgp; /* current program */
+ uint_t ddo_nsecs; /* number of sections */
+ dof_secidx_t ddo_strsec; /* global strings section index */
+ dof_secidx_t *ddo_xlimport; /* imported xlator section indices */
+ dof_secidx_t *ddo_xlexport; /* exported xlator section indices */
+ dt_buf_t ddo_secs; /* section headers */
+ dt_buf_t ddo_strs; /* global strings */
+ dt_buf_t ddo_ldata; /* loadable section data */
+ dt_buf_t ddo_udata; /* unloadable section data */
+ dt_buf_t ddo_probes; /* probe section data */
+ dt_buf_t ddo_args; /* probe arguments section data */
+ dt_buf_t ddo_offs; /* probe offsets section data */
+ dt_buf_t ddo_enoffs; /* is-enabled offsets section data */
+ dt_buf_t ddo_rels; /* probe relocation section data */
+ dt_buf_t ddo_xlms; /* xlate members section data */
+} dt_dof_t;
+
+extern void dt_dof_init(dtrace_hdl_t *);
+extern void dt_dof_fini(dtrace_hdl_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_DOF_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_error.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_error.c
new file mode 100644
index 00000000..ffcf4fcc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_error.c
@@ -0,0 +1,219 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#include <strings.h>
+#endif
+#include <dt_impl.h>
+
+static const struct {
+ int err;
+ const char *msg;
+} _dt_errlist[] = {
+ { EDT_VERSION, "Client requested version newer than library" },
+ { EDT_VERSINVAL, "Version is not properly formatted or is too large" },
+ { EDT_VERSUNDEF, "Requested version is not supported by compiler" },
+ { EDT_VERSREDUCED, "Requested version conflicts with earlier setting" },
+ { EDT_CTF, "Unexpected libctf error" },
+ { EDT_COMPILER, "Error in D program compilation" },
+ { EDT_NOREG, "Insufficient registers to generate code" },
+ { EDT_NOTUPREG, "Insufficient tuple registers to generate code" },
+ { EDT_NOMEM, "Memory allocation failure" },
+ { EDT_INT2BIG, "Integer constant table limit exceeded" },
+ { EDT_STR2BIG, "String constant table limit exceeded" },
+ { EDT_NOMOD, "Unknown module name" },
+ { EDT_NOPROV, "Unknown provider name" },
+ { EDT_NOPROBE, "No probe matches description" },
+ { EDT_NOSYM, "Unknown symbol name" },
+ { EDT_NOSYMADDR, "No symbol corresponds to address" },
+ { EDT_NOTYPE, "Unknown type name" },
+ { EDT_NOVAR, "Unknown variable name" },
+ { EDT_NOAGG, "Unknown aggregation name" },
+ { EDT_BADSCOPE, "Improper use of scoping operator in type name" },
+ { EDT_BADSPEC, "Overspecified probe description" },
+ { EDT_BADSPCV, "Undefined macro variable in probe description" },
+ { EDT_BADID, "Unknown probe identifier" },
+ { EDT_NOTLOADED, "Module is no longer loaded" },
+ { EDT_NOCTF, "Module does not contain any CTF data" },
+ { EDT_DATAMODEL, "Module and program data models do not match" },
+ { EDT_DIFVERS, "Library uses newer DIF version than kernel" },
+ { EDT_BADAGG, "Unknown aggregating action" },
+ { EDT_FIO, "Error occurred while reading from input stream" },
+ { EDT_DIFINVAL, "DIF program content is invalid" },
+ { EDT_DIFSIZE, "DIF program exceeds maximum program size" },
+ { EDT_DIFFAULT, "DIF program contains invalid pointer" },
+ { EDT_BADPROBE, "Invalid probe specification" },
+ { EDT_BADPGLOB, "Probe description has too many globbing characters" },
+ { EDT_NOSCOPE, "Declaration scope stack underflow" },
+ { EDT_NODECL, "Declaration stack underflow" },
+ { EDT_DMISMATCH, "Data record list does not match statement" },
+ { EDT_DOFFSET, "Data record offset exceeds buffer boundary" },
+ { EDT_DALIGN, "Data record has inappropriate alignment" },
+ { EDT_BADOPTNAME, "Invalid option name" },
+ { EDT_BADOPTVAL, "Invalid value for specified option" },
+ { EDT_BADOPTCTX, "Option cannot be used from within a D program" },
+ { EDT_CPPFORK, "Failed to fork preprocessor" },
+ { EDT_CPPEXEC, "Failed to exec preprocessor" },
+ { EDT_CPPENT, "Preprocessor not found" },
+ { EDT_CPPERR, "Preprocessor failed to process input program" },
+ { EDT_SYMOFLOW, "Symbol table identifier space exhausted" },
+ { EDT_ACTIVE, "Operation illegal when tracing is active" },
+ { EDT_DESTRUCTIVE, "Destructive actions not allowed" },
+ { EDT_NOANON, "No anonymous tracing state" },
+ { EDT_ISANON, "Can't claim anonymous state and enable probes" },
+ { EDT_ENDTOOBIG, "END enablings exceed size of principal buffer" },
+ { EDT_NOCONV, "Failed to load type for printf conversion" },
+ { EDT_BADCONV, "Incomplete printf conversion" },
+ { EDT_BADERROR, "Invalid library ERROR action" },
+ { EDT_ERRABORT, "Abort due to error" },
+ { EDT_DROPABORT, "Abort due to drop" },
+ { EDT_DIRABORT, "Abort explicitly directed" },
+ { EDT_BADRVAL, "Invalid return value from callback" },
+ { EDT_BADNORMAL, "Invalid normalization" },
+ { EDT_BUFTOOSMALL, "Enabling exceeds size of buffer" },
+ { EDT_BADTRUNC, "Invalid truncation" },
+ { EDT_BUSY, "DTrace cannot be used when kernel debugger is active" },
+ { EDT_ACCESS, "DTrace requires additional privileges" },
+ { EDT_NOENT, "DTrace device not available on system" },
+ { EDT_BRICKED, "Abort due to systemic unresponsiveness" },
+ { EDT_HARDWIRE, "Failed to load language definitions" },
+ { EDT_ELFVERSION, "libelf is out-of-date with respect to libdtrace" },
+ { EDT_NOBUFFERED, "Attempt to buffer output without handler" },
+ { EDT_UNSTABLE, "Description matched an unstable set of probes" },
+ { EDT_BADSETOPT, "Invalid setopt() library action" },
+ { EDT_BADSTACKPC, "Invalid stack program counter size" },
+ { EDT_BADAGGVAR, "Invalid aggregation variable identifier" },
+ { EDT_OVERSION, "Client requested deprecated version of library" },
+ { EDT_ENABLING_ERR, "Failed to enable probe" }
+};
+
+static const int _dt_nerr = sizeof (_dt_errlist) / sizeof (_dt_errlist[0]);
+
+const char *
+dtrace_errmsg(dtrace_hdl_t *dtp, int error)
+{
+ const char *str;
+ int i;
+
+ if (error == EDT_COMPILER && dtp != NULL && dtp->dt_errmsg[0] != '\0')
+ str = dtp->dt_errmsg;
+ else if (error == EDT_CTF && dtp != NULL && dtp->dt_ctferr != 0)
+ str = ctf_errmsg(dtp->dt_ctferr);
+ else if (error >= EDT_BASE && (error - EDT_BASE) < _dt_nerr) {
+ for (i = 0; i < _dt_nerr; i++) {
+ if (_dt_errlist[i].err == error)
+ return (_dt_errlist[i].msg);
+ }
+ str = NULL;
+ } else
+ str = strerror(error);
+
+ return (str ? str : "Unknown error");
+}
+
+int
+dtrace_errno(dtrace_hdl_t *dtp)
+{
+ return (dtp->dt_errno);
+}
+
+int
+dt_set_errno(dtrace_hdl_t *dtp, int err)
+{
+ dtp->dt_errno = err;
+ return (-1);
+}
+
+void
+dt_set_errmsg(dtrace_hdl_t *dtp, const char *errtag, const char *region,
+ const char *filename, int lineno, const char *format, va_list ap)
+{
+ size_t len, n;
+ char *p, *s;
+
+ s = dtp->dt_errmsg;
+ n = sizeof (dtp->dt_errmsg);
+
+ if (errtag != NULL && (yypcb->pcb_cflags & DTRACE_C_ETAGS))
+ (void) snprintf(s, n, "[%s] ", errtag);
+ else
+ s[0] = '\0';
+
+ len = strlen(dtp->dt_errmsg);
+ s = dtp->dt_errmsg + len;
+ n = sizeof (dtp->dt_errmsg) - len;
+
+ if (filename == NULL)
+ filename = dtp->dt_filetag;
+
+ if (filename != NULL)
+ (void) snprintf(s, n, "\"%s\", line %d: ", filename, lineno);
+ else if (lineno != 0)
+ (void) snprintf(s, n, "line %d: ", lineno);
+ else if (region != NULL)
+ (void) snprintf(s, n, "in %s: ", region);
+
+ len = strlen(dtp->dt_errmsg);
+ s = dtp->dt_errmsg + len;
+ n = sizeof (dtp->dt_errmsg) - len;
+ (void) vsnprintf(s, n, format, ap);
+
+ if ((p = strrchr(dtp->dt_errmsg, '\n')) != NULL)
+ *p = '\0'; /* remove trailing \n from message buffer */
+
+ dtp->dt_errtag = errtag;
+}
+
+/*ARGSUSED*/
+const char *
+dtrace_faultstr(dtrace_hdl_t *dtp, int fault)
+{
+ int i;
+
+ static const struct {
+ int code;
+ const char *str;
+ } faults[] = {
+ { DTRACEFLT_BADADDR, "invalid address" },
+ { DTRACEFLT_BADALIGN, "invalid alignment" },
+ { DTRACEFLT_ILLOP, "illegal operation" },
+ { DTRACEFLT_DIVZERO, "divide-by-zero" },
+ { DTRACEFLT_NOSCRATCH, "out of scratch space" },
+ { DTRACEFLT_KPRIV, "invalid kernel access" },
+ { DTRACEFLT_UPRIV, "invalid user access" },
+ { DTRACEFLT_TUPOFLOW, "tuple stack overflow" },
+ { DTRACEFLT_BADSTACK, "bad stack" },
+ { DTRACEFLT_LIBRARY, "library-level fault" },
+ { 0, NULL }
+ };
+ RT_NOREF1(dtp);
+
+ for (i = 0; faults[i].str != NULL; i++) {
+ if (faults[i].code == fault)
+ return (faults[i].str);
+ }
+
+ return ("unknown fault");
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_errtags.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_errtags.h
new file mode 100644
index 00000000..c81142d3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_errtags.h
@@ -0,0 +1,249 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_ERRTAGS_H
+#define _DT_ERRTAGS_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This enum definition is used to define a set of error tags associated with
+ * the D compiler's various error conditions. The shell script mkerrtags.sh is
+ * used to parse this file and create a corresponding dt_errtags.c source file.
+ * If you do something other than add a new error tag here, you may need to
+ * update the mkerrtags shell script as it is based upon simple regexps.
+ */
+typedef enum {
+ D_UNKNOWN, /* unknown D compiler error */
+ D_SYNTAX, /* syntax error in input stream */
+ D_EMPTY, /* empty translation unit */
+ D_TYPE_ERR, /* type definition missing */
+ D_TYPE_MEMBER, /* type member not found */
+ D_ASRELO, /* relocation remains against symbol */
+ D_CG_EXPR, /* tracing function called from expr */
+ D_CG_DYN, /* expression returns dynamic result */
+ D_ATTR_MIN, /* attributes less than amin setting */
+ D_ID_OFLOW, /* identifier space overflow */
+ D_PDESC_ZERO, /* probedesc matches zero probes */
+ D_PDESC_INVAL, /* probedesc is not valid */
+ D_PRED_SCALAR, /* predicate must be of scalar type */
+ D_FUNC_IDENT, /* function designator is not ident */
+ D_FUNC_UNDEF, /* function ident is not defined */
+ D_FUNC_IDKIND, /* function ident is of wrong idkind */
+ D_OFFSETOF_TYPE, /* offsetof arg is not sou type */
+ D_OFFSETOF_BITFIELD, /* offsetof applied to field member */
+ D_SIZEOF_TYPE, /* invalid sizeof type */
+ D_SIZEOF_BITFIELD, /* sizeof applied to field member */
+ D_STRINGOF_TYPE, /* invalid stringof type */
+ D_OP_IDENT, /* operand must be an identifier */
+ D_OP_INT, /* operand must be integral type */
+ D_OP_SCALAR, /* operand must be scalar type */
+ D_OP_ARITH, /* operand must be arithmetic type */
+ D_OP_WRITE, /* operand must be writable variable */
+ D_OP_LVAL, /* operand must be lvalue */
+ D_OP_INCOMPAT, /* operand types are not compatible */
+ D_OP_VFPTR, /* operand cannot be void or func ptr */
+ D_OP_ARRFUN, /* operand cannot be array or func */
+ D_OP_PTR, /* operand must be a pointer */
+ D_OP_SOU, /* operand must be struct or union */
+ D_OP_INCOMPLETE, /* operand is an incomplete type */
+ D_OP_DYN, /* operand cannot be of dynamic type */
+ D_OP_ACT, /* operand cannot be action */
+ D_AGG_REDEF, /* aggregation cannot be redefined */
+ D_AGG_FUNC, /* aggregating function required */
+ D_AGG_MDIM, /* aggregation used as multi-dim arr */
+ D_ARR_BADREF, /* access non-array using tuple */
+ D_ARR_LOCAL, /* cannot define local assc array */
+ D_DIV_ZERO, /* division by zero detected */
+ D_DEREF_NONPTR, /* dereference non-pointer type */
+ D_DEREF_VOID, /* dereference void pointer */
+ D_DEREF_FUNC, /* dereference function pointer */
+ D_ADDROF_LVAL, /* unary & applied to non-lvalue */
+ D_ADDROF_VAR, /* unary & applied to variable */
+ D_ADDROF_BITFIELD, /* unary & applied to field member */
+ D_XLATE_REDECL, /* translator redeclared */
+ D_XLATE_NOCONV, /* no conversion for member defined */
+ D_XLATE_NONE, /* no translator for type combo */
+ D_XLATE_SOU, /* dst must be struct or union type */
+ D_XLATE_INCOMPAT, /* translator member type incompat */
+ D_XLATE_MEMB, /* translator member is not valid */
+ D_CAST_INVAL, /* invalid cast expression */
+ D_PRAGERR, /* #pragma error message */
+ D_PRAGCTL_INVAL, /* invalid control directive */
+ D_PRAGMA_INVAL, /* invalid compiler pragma */
+ D_PRAGMA_UNUSED, /* unused compiler pragma */
+ D_PRAGMA_MALFORM, /* malformed #pragma argument list */
+ D_PRAGMA_OPTSET, /* failed to set #pragma option */
+ D_PRAGMA_SCOPE, /* #pragma identifier scope error */
+ D_PRAGMA_DEPEND, /* #pragma dependency not satisfied */
+ D_MACRO_UNDEF, /* macro parameter is not defined */
+ D_MACRO_OFLOW, /* macro parameter integer overflow */
+ D_MACRO_UNUSED, /* macro parameter is never used */
+ D_INT_OFLOW, /* integer constant overflow */
+ D_INT_DIGIT, /* integer digit is not valid */
+ D_STR_NL, /* newline in string literal */
+ D_CHR_NL, /* newline in character constant */
+ D_CHR_NULL, /* empty character constant */
+ D_CHR_OFLOW, /* character constant is too long */
+ D_IDENT_BADREF, /* identifier expected type mismatch */
+ D_IDENT_UNDEF, /* identifier is not known/defined */
+ D_IDENT_AMBIG, /* identifier is ambiguous (var/enum) */
+ D_SYM_BADREF, /* kernel/user symbol ref mismatch */
+ D_SYM_NOTYPES, /* no CTF data available for sym ref */
+ D_SYM_MODEL, /* module/program data model mismatch */
+ D_VAR_UNDEF, /* reference to undefined variable */
+ D_VAR_UNSUP, /* unsupported variable specification */
+ D_PROTO_LEN, /* prototype length mismatch */
+ D_PROTO_ARG, /* prototype argument mismatch */
+ D_ARGS_MULTI, /* description matches unstable set */
+ D_ARGS_XLATOR, /* no args[] translator defined */
+ D_ARGS_NONE, /* no args[] available */
+ D_ARGS_TYPE, /* invalid args[] type */
+ D_ARGS_IDX, /* invalid args[] index */
+ D_REGS_IDX, /* invalid regs[] index */
+ D_KEY_TYPE, /* invalid agg or array key type */
+ D_PRINTF_DYN_PROTO, /* dynamic size argument missing */
+ D_PRINTF_DYN_TYPE, /* dynamic size type mismatch */
+ D_PRINTF_AGG_CONV, /* improper use of %@ conversion */
+ D_PRINTF_ARG_PROTO, /* conversion missing value argument */
+ D_PRINTF_ARG_TYPE, /* conversion arg has wrong type */
+ D_PRINTF_ARG_EXTRA, /* extra arguments specified */
+ D_PRINTF_ARG_FMT, /* format string is not a constant */
+ D_PRINTF_FMT_EMPTY, /* format string is empty */
+ D_DECL_CHARATTR, /* bad attributes for char decl */
+ D_DECL_VOIDATTR, /* bad attributes for void decl */
+ D_DECL_SIGNINT, /* sign/unsign with non-integer decl */
+ D_DECL_LONGINT, /* long with non-arithmetic decl */
+ D_DECL_IDENT, /* old-style declaration or bad type */
+ D_DECL_CLASS, /* more than one storage class given */
+ D_DECL_BADCLASS, /* decl class not supported in D */
+ D_DECL_PARMCLASS, /* invalid class for parameter type */
+ D_DECL_COMBO, /* bad decl specifier combination */
+ D_DECL_ARRSUB, /* const int required for array size */
+ D_DECL_ARRNULL, /* array decl requires dim or tuple */
+ D_DECL_ARRBIG, /* array size too big */
+ D_DECL_IDRED, /* decl identifier redeclared */
+ D_DECL_TYPERED, /* decl type redeclared */
+ D_DECL_MNAME, /* member name missing */
+ D_DECL_SCOPE, /* scoping operator used in decl */
+ D_DECL_BFCONST, /* bit-field requires const size expr */
+ D_DECL_BFSIZE, /* bit-field size too big for type */
+ D_DECL_BFTYPE, /* bit-field type is not valid */
+ D_DECL_ENCONST, /* enum tag requires const size expr */
+ D_DECL_ENOFLOW, /* enumerator value overflows INT_MAX */
+ D_DECL_USELESS, /* useless external declaration */
+ D_DECL_LOCASSC, /* attempt to decl local assc array */
+ D_DECL_VOIDOBJ, /* attempt to decl void object */
+ D_DECL_DYNOBJ, /* attempt to decl dynamic object */
+ D_DECL_INCOMPLETE, /* declaration uses incomplete type */
+ D_DECL_PROTO_VARARGS, /* varargs not allowed in prototype */
+ D_DECL_PROTO_TYPE, /* type not allowed in prototype */
+ D_DECL_PROTO_VOID, /* void must be sole parameter */
+ D_DECL_PROTO_NAME, /* void parameter may not have a name */
+ D_DECL_PROTO_FORM, /* parameter name has no formal */
+ D_COMM_COMM, /* commit() after commit() */
+ D_COMM_DREC, /* commit() after data action */
+ D_SPEC_SPEC, /* speculate() after speculate() */
+ D_SPEC_COMM, /* speculate() after commit() */
+ D_SPEC_DREC, /* speculate() after data action */
+ D_AGG_COMM, /* aggregating act after commit() */
+ D_AGG_SPEC, /* aggregating act after speculate() */
+ D_AGG_NULL, /* aggregation stmt has null effect */
+ D_AGG_SCALAR, /* aggregating function needs scalar */
+ D_ACT_SPEC, /* destructive action after speculate */
+ D_EXIT_SPEC, /* exit() action after speculate */
+ D_DREC_COMM, /* data action after commit() */
+ D_PRINTA_PROTO, /* printa() prototype mismatch */
+ D_PRINTA_AGGARG, /* aggregation arg type mismatch */
+ D_PRINTA_AGGBAD, /* printa() aggregation not defined */
+ D_PRINTA_AGGKEY, /* printa() aggregation key mismatch */
+ D_PRINTA_AGGPROTO, /* printa() aggregation mismatch */
+ D_TRACE_VOID, /* trace() argument has void type */
+ D_TRACE_DYN, /* trace() argument has dynamic type */
+ D_TRACEMEM_ADDR, /* tracemem() address bad type */
+ D_TRACEMEM_SIZE, /* tracemem() size bad type */
+ D_STACK_PROTO, /* stack() prototype mismatch */
+ D_STACK_SIZE, /* stack() size argument bad type */
+ D_USTACK_FRAMES, /* ustack() frames arg bad type */
+ D_USTACK_STRSIZE, /* ustack() strsize arg bad type */
+ D_USTACK_PROTO, /* ustack() prototype mismatch */
+ D_LQUANT_BASETYPE, /* lquantize() bad base type */
+ D_LQUANT_BASEVAL, /* lquantize() bad base value */
+ D_LQUANT_LIMTYPE, /* lquantize() bad limit type */
+ D_LQUANT_LIMVAL, /* lquantize() bad limit value */
+ D_LQUANT_MISMATCH, /* lquantize() limit < base */
+ D_LQUANT_STEPTYPE, /* lquantize() bad step type */
+ D_LQUANT_STEPVAL, /* lquantize() bad step value */
+ D_LQUANT_STEPLARGE, /* lquantize() step too large */
+ D_LQUANT_STEPSMALL, /* lquantize() step too small */
+ D_QUANT_PROTO, /* quantize() prototype mismatch */
+ D_PROC_OFF, /* byte offset exceeds function size */
+ D_PROC_ALIGN, /* byte offset has invalid alignment */
+ D_PROC_NAME, /* invalid process probe name */
+ D_PROC_GRAB, /* failed to grab process */
+ D_PROC_DYN, /* process is not dynamically linked */
+ D_PROC_LIB, /* invalid process library name */
+ D_PROC_FUNC, /* no such function in process */
+ D_PROC_CREATEFAIL, /* pid probe creation failed */
+ D_PROC_NODEV, /* fasttrap device is not installed */
+ D_PROC_BADPID, /* user probe pid invalid */
+ D_PROC_BADPROV, /* user probe provider invalid */
+ D_PROC_USDT, /* problem initializing usdt */
+ D_CLEAR_PROTO, /* clear() prototype mismatch */
+ D_CLEAR_AGGARG, /* aggregation arg type mismatch */
+ D_CLEAR_AGGBAD, /* clear() aggregation not defined */
+ D_NORMALIZE_PROTO, /* normalize() prototype mismatch */
+ D_NORMALIZE_SCALAR, /* normalize() value must be scalar */
+ D_NORMALIZE_AGGARG, /* aggregation arg type mismatch */
+ D_NORMALIZE_AGGBAD, /* normalize() aggregation not def. */
+ D_TRUNC_PROTO, /* trunc() prototype mismatch */
+ D_TRUNC_SCALAR, /* trunc() value must be scalar */
+ D_TRUNC_AGGARG, /* aggregation arg type mismatch */
+ D_TRUNC_AGGBAD, /* trunc() aggregation not def. */
+ D_PROV_BADNAME, /* invalid provider name */
+ D_PROV_INCOMPAT, /* provider/probe interface mismatch */
+ D_PROV_PRDUP, /* duplicate probe declaration */
+ D_PROV_PRARGLEN, /* probe argument list too long */
+ D_PROV_PRXLATOR, /* probe argument translator missing */
+ D_FREOPEN_INVALID, /* frename() filename is invalid */
+ D_LQUANT_MATCHBASE, /* lquantize() mismatch on base */
+ D_LQUANT_MATCHLIM, /* lquantize() mismatch on limit */
+ D_LQUANT_MATCHSTEP /* lquantize() mismatch on step */
+} dt_errtag_t;
+
+extern const char *dt_errtag(dt_errtag_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_ERRTAGS_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_grammar.y b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_grammar.y
new file mode 100644
index 00000000..e83bb53e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_grammar.y
@@ -0,0 +1,846 @@
+%{
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#else
+# ifdef _MSC_VER
+# pragma warning(disable:4255 4702)
+# endif
+#endif
+
+#include <dt_impl.h>
+
+#define OP1(op, c) dt_node_op1(op, c)
+#define OP2(op, l, r) dt_node_op2(op, l, r)
+#define OP3(x, y, z) dt_node_op3(x, y, z)
+#define LINK(l, r) dt_node_link(l, r)
+#define DUP(s) strdup(s)
+
+#ifdef VBOX
+# define YYMALLOC RTMemAlloc
+# define YYFREE RTMemFree
+#endif
+
+
+%}
+
+%union {
+ dt_node_t *l_node;
+ dt_decl_t *l_decl;
+ char *l_str;
+ uintmax_t l_int;
+ int l_tok;
+}
+
+%token DT_TOK_COMMA DT_TOK_ELLIPSIS
+%token DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ
+%token DT_TOK_DIV_EQ DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ
+%token DT_TOK_LSH_EQ DT_TOK_RSH_EQ DT_TOK_QUESTION DT_TOK_COLON
+%token DT_TOK_LOR DT_TOK_LXOR DT_TOK_LAND
+%token DT_TOK_BOR DT_TOK_XOR DT_TOK_BAND DT_TOK_EQU DT_TOK_NEQ
+%token DT_TOK_LT DT_TOK_LE DT_TOK_GT DT_TOK_GE DT_TOK_LSH DT_TOK_RSH
+%token DT_TOK_ADD DT_TOK_SUB DT_TOK_MUL DT_TOK_DIV DT_TOK_MOD
+%token DT_TOK_LNEG DT_TOK_BNEG DT_TOK_ADDADD DT_TOK_SUBSUB
+%token DT_TOK_PREINC DT_TOK_POSTINC DT_TOK_PREDEC DT_TOK_POSTDEC
+%token DT_TOK_IPOS DT_TOK_INEG DT_TOK_DEREF DT_TOK_ADDROF
+%token DT_TOK_OFFSETOF DT_TOK_SIZEOF DT_TOK_STRINGOF DT_TOK_XLATE
+%token DT_TOK_LPAR DT_TOK_RPAR DT_TOK_LBRAC DT_TOK_RBRAC DT_TOK_PTR DT_TOK_DOT
+
+%token <l_str> DT_TOK_STRING
+%token <l_str> DT_TOK_IDENT
+%token <l_str> DT_TOK_PSPEC
+%token <l_str> DT_TOK_AGG
+%token <l_str> DT_TOK_TNAME
+%token <l_int> DT_TOK_INT
+
+%token DT_KEY_AUTO
+%token DT_KEY_BREAK
+%token DT_KEY_CASE
+%token DT_KEY_CHAR
+%token DT_KEY_CONST
+%token DT_KEY_CONTINUE
+%token DT_KEY_COUNTER
+%token DT_KEY_DEFAULT
+%token DT_KEY_DO
+%token DT_KEY_DOUBLE
+%token DT_KEY_ELSE
+%token DT_KEY_ENUM
+%token DT_KEY_EXTERN
+%token DT_KEY_FLOAT
+%token DT_KEY_FOR
+%token DT_KEY_GOTO
+%token DT_KEY_IF
+%token DT_KEY_IMPORT
+%token DT_KEY_INLINE
+%token DT_KEY_INT
+%token DT_KEY_LONG
+%token DT_KEY_PROBE
+%token DT_KEY_PROVIDER
+%token DT_KEY_REGISTER
+%token DT_KEY_RESTRICT
+%token DT_KEY_RETURN
+%token DT_KEY_SELF
+%token DT_KEY_SHORT
+%token DT_KEY_SIGNED
+%token DT_KEY_STATIC
+%token DT_KEY_STRING
+%token DT_KEY_STRUCT
+%token DT_KEY_SWITCH
+%token DT_KEY_THIS
+%token DT_KEY_TYPEDEF
+%token DT_KEY_UNION
+%token DT_KEY_UNSIGNED
+%token DT_KEY_VOID
+%token DT_KEY_VOLATILE
+%token DT_KEY_WHILE
+%token DT_KEY_XLATOR
+
+%token DT_TOK_EPRED
+%token DT_CTX_DEXPR
+%token DT_CTX_DPROG
+%token DT_CTX_DTYPE
+%token DT_TOK_EOF 0
+
+%left DT_TOK_COMMA
+%right DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ DT_TOK_DIV_EQ
+ DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ DT_TOK_LSH_EQ
+ DT_TOK_RSH_EQ
+%left DT_TOK_QUESTION DT_TOK_COLON
+%left DT_TOK_LOR
+%left DT_TOK_LXOR
+%left DT_TOK_LAND
+%left DT_TOK_BOR
+%left DT_TOK_XOR
+%left DT_TOK_BAND
+%left DT_TOK_EQU DT_TOK_NEQ
+%left DT_TOK_LT DT_TOK_LE DT_TOK_GT DT_TOK_GE
+%left DT_TOK_LSH DT_TOK_RSH
+%left DT_TOK_ADD DT_TOK_SUB
+%left DT_TOK_MUL DT_TOK_DIV DT_TOK_MOD
+%right DT_TOK_LNEG DT_TOK_BNEG DT_TOK_ADDADD DT_TOK_SUBSUB
+ DT_TOK_IPOS DT_TOK_INEG
+%right DT_TOK_DEREF DT_TOK_ADDROF DT_TOK_SIZEOF DT_TOK_STRINGOF DT_TOK_XLATE
+%left DT_TOK_LPAR DT_TOK_RPAR DT_TOK_LBRAC DT_TOK_RBRAC DT_TOK_PTR DT_TOK_DOT
+
+%type <l_node> d_expression
+%type <l_node> d_program
+%type <l_node> d_type
+
+%type <l_node> translation_unit
+%type <l_node> external_declaration
+%type <l_node> inline_definition
+%type <l_node> translator_definition
+%type <l_node> translator_member_list
+%type <l_node> translator_member
+%type <l_node> provider_definition
+%type <l_node> provider_probe_list
+%type <l_node> provider_probe
+%type <l_node> probe_definition
+%type <l_node> probe_specifiers
+%type <l_node> probe_specifier_list
+%type <l_node> probe_specifier
+%type <l_node> statement_list
+%type <l_node> statement
+%type <l_node> declaration
+%type <l_node> init_declarator_list
+%type <l_node> init_declarator
+
+%type <l_decl> type_specifier
+%type <l_decl> type_qualifier
+%type <l_decl> struct_or_union_specifier
+%type <l_decl> specifier_qualifier_list
+%type <l_decl> enum_specifier
+%type <l_decl> declarator
+%type <l_decl> direct_declarator
+%type <l_decl> pointer
+%type <l_decl> type_qualifier_list
+%type <l_decl> type_name
+%type <l_decl> abstract_declarator
+%type <l_decl> direct_abstract_declarator
+
+%type <l_node> parameter_type_list
+%type <l_node> parameter_list
+%type <l_node> parameter_declaration
+
+%type <l_node> array
+%type <l_node> array_parameters
+%type <l_node> function
+%type <l_node> function_parameters
+
+%type <l_node> expression
+%type <l_node> assignment_expression
+%type <l_node> conditional_expression
+%type <l_node> constant_expression
+%type <l_node> logical_or_expression
+%type <l_node> logical_xor_expression
+%type <l_node> logical_and_expression
+%type <l_node> inclusive_or_expression
+%type <l_node> exclusive_or_expression
+%type <l_node> and_expression
+%type <l_node> equality_expression
+%type <l_node> relational_expression
+%type <l_node> shift_expression
+%type <l_node> additive_expression
+%type <l_node> multiplicative_expression
+%type <l_node> cast_expression
+%type <l_node> unary_expression
+%type <l_node> postfix_expression
+%type <l_node> primary_expression
+%type <l_node> argument_expression_list
+
+%type <l_tok> assignment_operator
+%type <l_tok> unary_operator
+%type <l_tok> struct_or_union
+
+%%
+
+dtrace_program: d_expression DT_TOK_EOF { return (dt_node_root($1)); }
+ | d_program DT_TOK_EOF { return (dt_node_root($1)); }
+ | d_type DT_TOK_EOF { return (dt_node_root($1)); }
+ ;
+
+d_expression: DT_CTX_DEXPR { $$ = NULL; }
+ | DT_CTX_DEXPR expression { $$ = $2; }
+ ;
+
+d_program: DT_CTX_DPROG { $$ = dt_node_program(NULL); }
+ | DT_CTX_DPROG translation_unit { $$ = dt_node_program($2); }
+ ;
+
+d_type: DT_CTX_DTYPE { $$ = NULL; }
+ | DT_CTX_DTYPE type_name { $$ = (dt_node_t *)$2; }
+ ;
+
+translation_unit:
+ external_declaration
+ | translation_unit external_declaration { $$ = LINK($1, $2); }
+ ;
+
+external_declaration:
+ inline_definition
+ | translator_definition
+ | provider_definition
+ | probe_definition
+ | declaration
+ ;
+
+inline_definition:
+ DT_KEY_INLINE declaration_specifiers declarator
+ { dt_scope_push(NULL, CTF_ERR); } DT_TOK_ASGN
+ assignment_expression ';' {
+ /*
+ * We push a new declaration scope before shifting the
+ * assignment_expression in order to preserve ds_class
+ * and ds_ident for use in dt_node_inline(). Once the
+ * entire inline_definition rule is matched, pop the
+ * scope and construct the inline using the saved decl.
+ */
+ dt_scope_pop();
+ $$ = dt_node_inline($6);
+ }
+ ;
+
+translator_definition:
+ DT_KEY_XLATOR type_name DT_TOK_LT type_name
+ DT_TOK_IDENT DT_TOK_GT '{' translator_member_list '}' ';' {
+ $$ = dt_node_xlator($2, $4, $5, $8);
+ }
+ | DT_KEY_XLATOR type_name DT_TOK_LT type_name
+ DT_TOK_IDENT DT_TOK_GT '{' '}' ';' {
+ $$ = dt_node_xlator($2, $4, $5, NULL);
+ }
+ ;
+
+translator_member_list:
+ translator_member
+ | translator_member_list translator_member { $$ = LINK($1,$2); }
+ ;
+
+translator_member:
+ DT_TOK_IDENT DT_TOK_ASGN assignment_expression ';' {
+ $$ = dt_node_member(NULL, $1, $3);
+ }
+ ;
+
+provider_definition:
+ DT_KEY_PROVIDER DT_TOK_IDENT '{' provider_probe_list '}' ';' {
+ $$ = dt_node_provider($2, $4);
+ }
+ | DT_KEY_PROVIDER DT_TOK_IDENT '{' '}' ';' {
+ $$ = dt_node_provider($2, NULL);
+ }
+ ;
+
+provider_probe_list:
+ provider_probe
+ | provider_probe_list provider_probe { $$ = LINK($1, $2); }
+ ;
+
+provider_probe:
+ DT_KEY_PROBE DT_TOK_IDENT function DT_TOK_COLON function ';' {
+ $$ = dt_node_probe($2, 2, $3, $5);
+ }
+ | DT_KEY_PROBE DT_TOK_IDENT function ';' {
+ $$ = dt_node_probe($2, 1, $3, NULL);
+ }
+ ;
+
+
+probe_definition:
+ probe_specifiers {
+ /*
+ * If the input stream is a file, do not permit a probe
+ * specification without / <pred> / or { <act> } after
+ * it. This can only occur if the next token is EOF or
+ * an ambiguous predicate was slurped up as a comment.
+ * We cannot perform this check if input() is a string
+ * because dtrace(1M) [-fmnP] also use the compiler and
+ * things like dtrace -n BEGIN have to be accepted.
+ */
+ if (yypcb->pcb_fileptr != NULL) {
+ dnerror($1, D_SYNTAX, "expected predicate and/"
+ "or actions following probe description\n");
+ }
+ $$ = dt_node_clause($1, NULL, NULL);
+ }
+ | probe_specifiers '{' statement_list '}' {
+ $$ = dt_node_clause($1, NULL, $3);
+ }
+ | probe_specifiers DT_TOK_DIV expression DT_TOK_EPRED {
+ dnerror($3, D_SYNTAX, "expected actions { } following "
+ "probe description and predicate\n");
+ }
+ | probe_specifiers DT_TOK_DIV expression DT_TOK_EPRED
+ '{' statement_list '}' {
+ $$ = dt_node_clause($1, $3, $6);
+ }
+ ;
+
+probe_specifiers:
+ probe_specifier_list { yybegin(YYS_EXPR); $$ = $1; }
+ ;
+
+probe_specifier_list:
+ probe_specifier
+ | probe_specifier_list DT_TOK_COMMA probe_specifier {
+ $$ = LINK($1, $3);
+ }
+ ;
+
+probe_specifier:
+ DT_TOK_PSPEC { $$ = dt_node_pdesc_by_name($1); }
+ | DT_TOK_INT { $$ = dt_node_pdesc_by_id($1); }
+ ;
+
+statement_list: statement { $$ = $1; }
+ | statement_list ';' statement { $$ = LINK($1, $3); }
+ ;
+
+statement: /* empty */ { $$ = NULL; }
+ | expression { $$ = dt_node_statement($1); }
+ ;
+
+argument_expression_list:
+ assignment_expression
+ | argument_expression_list DT_TOK_COMMA assignment_expression {
+ $$ = LINK($1, $3);
+ }
+ ;
+
+primary_expression:
+ DT_TOK_IDENT { $$ = dt_node_ident($1); }
+ | DT_TOK_AGG { $$ = dt_node_ident($1); }
+ | DT_TOK_INT { $$ = dt_node_int($1); }
+ | DT_TOK_STRING { $$ = dt_node_string($1); }
+ | DT_KEY_SELF { $$ = dt_node_ident(DUP("self")); }
+ | DT_KEY_THIS { $$ = dt_node_ident(DUP("this")); }
+ | DT_TOK_LPAR expression DT_TOK_RPAR { $$ = $2; }
+ ;
+
+postfix_expression:
+ primary_expression
+ | postfix_expression
+ DT_TOK_LBRAC argument_expression_list DT_TOK_RBRAC {
+ $$ = OP2(DT_TOK_LBRAC, $1, $3);
+ }
+ | postfix_expression DT_TOK_LPAR DT_TOK_RPAR {
+ $$ = dt_node_func($1, NULL);
+ }
+ | postfix_expression
+ DT_TOK_LPAR argument_expression_list DT_TOK_RPAR {
+ $$ = dt_node_func($1, $3);
+ }
+ | postfix_expression DT_TOK_DOT DT_TOK_IDENT {
+ $$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));
+ }
+ | postfix_expression DT_TOK_DOT DT_TOK_TNAME {
+ $$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));
+ }
+ | postfix_expression DT_TOK_PTR DT_TOK_IDENT {
+ $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));
+ }
+ | postfix_expression DT_TOK_PTR DT_TOK_TNAME {
+ $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));
+ }
+ | postfix_expression DT_TOK_ADDADD {
+ $$ = OP1(DT_TOK_POSTINC, $1);
+ }
+ | postfix_expression DT_TOK_SUBSUB {
+ $$ = OP1(DT_TOK_POSTDEC, $1);
+ }
+ | DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA
+ DT_TOK_IDENT DT_TOK_RPAR {
+ $$ = dt_node_offsetof($3, $5);
+ }
+ | DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA
+ DT_TOK_TNAME DT_TOK_RPAR {
+ $$ = dt_node_offsetof($3, $5);
+ }
+ | DT_TOK_XLATE DT_TOK_LT type_name DT_TOK_GT
+ DT_TOK_LPAR expression DT_TOK_RPAR {
+ $$ = OP2(DT_TOK_XLATE, dt_node_type($3), $6);
+ }
+ ;
+
+unary_expression:
+ postfix_expression
+ | DT_TOK_ADDADD unary_expression { $$ = OP1(DT_TOK_PREINC, $2); }
+ | DT_TOK_SUBSUB unary_expression { $$ = OP1(DT_TOK_PREDEC, $2); }
+ | unary_operator cast_expression { $$ = OP1($1, $2); }
+ | DT_TOK_SIZEOF unary_expression { $$ = OP1(DT_TOK_SIZEOF, $2); }
+ | DT_TOK_SIZEOF DT_TOK_LPAR type_name DT_TOK_RPAR {
+ $$ = OP1(DT_TOK_SIZEOF, dt_node_type($3));
+ }
+ | DT_TOK_STRINGOF unary_expression {
+ $$ = OP1(DT_TOK_STRINGOF, $2);
+ }
+ ;
+
+unary_operator: DT_TOK_BAND { $$ = DT_TOK_ADDROF; }
+ | DT_TOK_MUL { $$ = DT_TOK_DEREF; }
+ | DT_TOK_ADD { $$ = DT_TOK_IPOS; }
+ | DT_TOK_SUB { $$ = DT_TOK_INEG; }
+ | DT_TOK_BNEG { $$ = DT_TOK_BNEG; }
+ | DT_TOK_LNEG { $$ = DT_TOK_LNEG; }
+ ;
+
+cast_expression:
+ unary_expression
+ | DT_TOK_LPAR type_name DT_TOK_RPAR cast_expression {
+ $$ = OP2(DT_TOK_LPAR, dt_node_type($2), $4);
+ }
+ ;
+
+multiplicative_expression:
+ cast_expression
+ | multiplicative_expression DT_TOK_MUL cast_expression {
+ $$ = OP2(DT_TOK_MUL, $1, $3);
+ }
+ | multiplicative_expression DT_TOK_DIV cast_expression {
+ $$ = OP2(DT_TOK_DIV, $1, $3);
+ }
+ | multiplicative_expression DT_TOK_MOD cast_expression {
+ $$ = OP2(DT_TOK_MOD, $1, $3);
+ }
+ ;
+
+additive_expression:
+ multiplicative_expression
+ | additive_expression DT_TOK_ADD multiplicative_expression {
+ $$ = OP2(DT_TOK_ADD, $1, $3);
+ }
+ | additive_expression DT_TOK_SUB multiplicative_expression {
+ $$ = OP2(DT_TOK_SUB, $1, $3);
+ }
+ ;
+
+shift_expression:
+ additive_expression
+ | shift_expression DT_TOK_LSH additive_expression {
+ $$ = OP2(DT_TOK_LSH, $1, $3);
+ }
+ | shift_expression DT_TOK_RSH additive_expression {
+ $$ = OP2(DT_TOK_RSH, $1, $3);
+ }
+ ;
+
+relational_expression:
+ shift_expression
+ | relational_expression DT_TOK_LT shift_expression {
+ $$ = OP2(DT_TOK_LT, $1, $3);
+ }
+ | relational_expression DT_TOK_GT shift_expression {
+ $$ = OP2(DT_TOK_GT, $1, $3);
+ }
+ | relational_expression DT_TOK_LE shift_expression {
+ $$ = OP2(DT_TOK_LE, $1, $3);
+ }
+ | relational_expression DT_TOK_GE shift_expression {
+ $$ = OP2(DT_TOK_GE, $1, $3);
+ }
+ ;
+
+equality_expression:
+ relational_expression
+ | equality_expression DT_TOK_EQU relational_expression {
+ $$ = OP2(DT_TOK_EQU, $1, $3);
+ }
+ | equality_expression DT_TOK_NEQ relational_expression {
+ $$ = OP2(DT_TOK_NEQ, $1, $3);
+ }
+ ;
+
+and_expression:
+ equality_expression
+ | and_expression DT_TOK_BAND equality_expression {
+ $$ = OP2(DT_TOK_BAND, $1, $3);
+ }
+ ;
+
+exclusive_or_expression:
+ and_expression
+ | exclusive_or_expression DT_TOK_XOR and_expression {
+ $$ = OP2(DT_TOK_XOR, $1, $3);
+ }
+ ;
+
+inclusive_or_expression:
+ exclusive_or_expression
+ | inclusive_or_expression DT_TOK_BOR exclusive_or_expression {
+ $$ = OP2(DT_TOK_BOR, $1, $3);
+ }
+ ;
+
+logical_and_expression:
+ inclusive_or_expression
+ | logical_and_expression DT_TOK_LAND inclusive_or_expression {
+ $$ = OP2(DT_TOK_LAND, $1, $3);
+ }
+ ;
+
+logical_xor_expression:
+ logical_and_expression
+ | logical_xor_expression DT_TOK_LXOR logical_and_expression {
+ $$ = OP2(DT_TOK_LXOR, $1, $3);
+ }
+ ;
+
+logical_or_expression:
+ logical_xor_expression
+ | logical_or_expression DT_TOK_LOR logical_xor_expression {
+ $$ = OP2(DT_TOK_LOR, $1, $3);
+ }
+ ;
+
+constant_expression: conditional_expression
+ ;
+
+conditional_expression:
+ logical_or_expression
+ | logical_or_expression DT_TOK_QUESTION expression DT_TOK_COLON
+ conditional_expression { $$ = OP3($1, $3, $5); }
+ ;
+
+assignment_expression:
+ conditional_expression
+ | unary_expression assignment_operator assignment_expression {
+ $$ = OP2($2, $1, $3);
+ }
+ ;
+
+assignment_operator:
+ DT_TOK_ASGN { $$ = DT_TOK_ASGN; }
+ | DT_TOK_MUL_EQ { $$ = DT_TOK_MUL_EQ; }
+ | DT_TOK_DIV_EQ { $$ = DT_TOK_DIV_EQ; }
+ | DT_TOK_MOD_EQ { $$ = DT_TOK_MOD_EQ; }
+ | DT_TOK_ADD_EQ { $$ = DT_TOK_ADD_EQ; }
+ | DT_TOK_SUB_EQ { $$ = DT_TOK_SUB_EQ; }
+ | DT_TOK_LSH_EQ { $$ = DT_TOK_LSH_EQ; }
+ | DT_TOK_RSH_EQ { $$ = DT_TOK_RSH_EQ; }
+ | DT_TOK_AND_EQ { $$ = DT_TOK_AND_EQ; }
+ | DT_TOK_XOR_EQ { $$ = DT_TOK_XOR_EQ; }
+ | DT_TOK_OR_EQ { $$ = DT_TOK_OR_EQ; }
+ ;
+
+expression: assignment_expression
+ | expression DT_TOK_COMMA assignment_expression {
+ $$ = OP2(DT_TOK_COMMA, $1, $3);
+ }
+ ;
+
+declaration: declaration_specifiers ';' {
+ $$ = dt_node_decl();
+ dt_decl_free(dt_decl_pop());
+ yybegin(YYS_CLAUSE);
+ }
+ | declaration_specifiers init_declarator_list ';' {
+ $$ = $2;
+ dt_decl_free(dt_decl_pop());
+ yybegin(YYS_CLAUSE);
+ }
+ ;
+
+declaration_specifiers:
+ d_storage_class_specifier
+ | d_storage_class_specifier declaration_specifiers
+ | type_specifier
+ | type_specifier declaration_specifiers
+ | type_qualifier
+ | type_qualifier declaration_specifiers
+ ;
+
+parameter_declaration_specifiers:
+ storage_class_specifier
+ | storage_class_specifier declaration_specifiers
+ | type_specifier
+ | type_specifier declaration_specifiers
+ | type_qualifier
+ | type_qualifier declaration_specifiers
+ ;
+
+storage_class_specifier:
+ DT_KEY_AUTO { dt_decl_class(DT_DC_AUTO); }
+ | DT_KEY_REGISTER { dt_decl_class(DT_DC_REGISTER); }
+ | DT_KEY_STATIC { dt_decl_class(DT_DC_STATIC); }
+ | DT_KEY_EXTERN { dt_decl_class(DT_DC_EXTERN); }
+ | DT_KEY_TYPEDEF { dt_decl_class(DT_DC_TYPEDEF); }
+ ;
+
+d_storage_class_specifier:
+ storage_class_specifier
+ | DT_KEY_SELF { dt_decl_class(DT_DC_SELF); }
+ | DT_KEY_THIS { dt_decl_class(DT_DC_THIS); }
+ ;
+
+type_specifier: DT_KEY_VOID { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("void")); }
+ | DT_KEY_CHAR { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("char")); }
+ | DT_KEY_SHORT { $$ = dt_decl_attr(DT_DA_SHORT); }
+ | DT_KEY_INT { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("int")); }
+ | DT_KEY_LONG { $$ = dt_decl_attr(DT_DA_LONG); }
+ | DT_KEY_FLOAT { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("float")); }
+ | DT_KEY_DOUBLE { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("double")); }
+ | DT_KEY_SIGNED { $$ = dt_decl_attr(DT_DA_SIGNED); }
+ | DT_KEY_UNSIGNED { $$ = dt_decl_attr(DT_DA_UNSIGNED); }
+ | DT_KEY_STRING {
+ $$ = dt_decl_spec(CTF_K_TYPEDEF, DUP("string"));
+ }
+ | DT_TOK_TNAME { $$ = dt_decl_spec(CTF_K_TYPEDEF, $1); }
+ | struct_or_union_specifier
+ | enum_specifier
+ ;
+
+type_qualifier: DT_KEY_CONST { $$ = dt_decl_attr(DT_DA_CONST); }
+ | DT_KEY_RESTRICT { $$ = dt_decl_attr(DT_DA_RESTRICT); }
+ | DT_KEY_VOLATILE { $$ = dt_decl_attr(DT_DA_VOLATILE); }
+ ;
+
+struct_or_union_specifier:
+ struct_or_union_definition struct_declaration_list '}' {
+ $$ = dt_scope_pop();
+ }
+ | struct_or_union DT_TOK_IDENT { $$ = dt_decl_spec($1, $2); }
+ | struct_or_union DT_TOK_TNAME { $$ = dt_decl_spec($1, $2); }
+ ;
+
+struct_or_union_definition:
+ struct_or_union '{' { dt_decl_sou($1, NULL); }
+ | struct_or_union DT_TOK_IDENT '{' { dt_decl_sou($1, $2); }
+ | struct_or_union DT_TOK_TNAME '{' { dt_decl_sou($1, $2); }
+ ;
+
+struct_or_union:
+ DT_KEY_STRUCT { $$ = CTF_K_STRUCT; }
+ | DT_KEY_UNION { $$ = CTF_K_UNION; }
+ ;
+
+struct_declaration_list:
+ struct_declaration
+ | struct_declaration_list struct_declaration
+ ;
+
+init_declarator_list:
+ init_declarator
+ | init_declarator_list DT_TOK_COMMA init_declarator {
+ $$ = LINK($1, $3);
+ }
+ ;
+
+init_declarator:
+ declarator {
+ $$ = dt_node_decl();
+ dt_decl_reset();
+ }
+ ;
+
+struct_declaration:
+ specifier_qualifier_list struct_declarator_list ';' {
+ dt_decl_free(dt_decl_pop());
+ }
+ ;
+
+specifier_qualifier_list:
+ type_specifier
+ | type_specifier specifier_qualifier_list { $$ = $2; }
+ | type_qualifier
+ | type_qualifier specifier_qualifier_list { $$ = $2; }
+ ;
+
+struct_declarator_list:
+ struct_declarator
+ | struct_declarator_list DT_TOK_COMMA struct_declarator
+ ;
+
+struct_declarator:
+ declarator { dt_decl_member(NULL); }
+ | DT_TOK_COLON constant_expression { dt_decl_member($2); }
+ | declarator DT_TOK_COLON constant_expression {
+ dt_decl_member($3);
+ }
+ ;
+
+enum_specifier:
+ enum_definition enumerator_list '}' { $$ = dt_scope_pop(); }
+ | DT_KEY_ENUM DT_TOK_IDENT { $$ = dt_decl_spec(CTF_K_ENUM, $2); }
+ | DT_KEY_ENUM DT_TOK_TNAME { $$ = dt_decl_spec(CTF_K_ENUM, $2); }
+ ;
+
+enum_definition:
+ DT_KEY_ENUM '{' { dt_decl_enum(NULL); }
+ | DT_KEY_ENUM DT_TOK_IDENT '{' { dt_decl_enum($2); }
+ | DT_KEY_ENUM DT_TOK_TNAME '{' { dt_decl_enum($2); }
+ ;
+
+enumerator_list:
+ enumerator
+ | enumerator_list DT_TOK_COMMA enumerator
+ ;
+
+enumerator: DT_TOK_IDENT { dt_decl_enumerator($1, NULL); }
+ | DT_TOK_IDENT DT_TOK_ASGN expression {
+ dt_decl_enumerator($1, $3);
+ }
+ ;
+
+declarator: direct_declarator
+ | pointer direct_declarator
+ ;
+
+direct_declarator:
+ DT_TOK_IDENT { $$ = dt_decl_ident($1); }
+ | lparen declarator DT_TOK_RPAR { $$ = $2; }
+ | direct_declarator array { dt_decl_array($2); }
+ | direct_declarator function { dt_decl_func($1, $2); }
+ ;
+
+lparen: DT_TOK_LPAR { dt_decl_top()->dd_attr |= DT_DA_PAREN; }
+ ;
+
+pointer: DT_TOK_MUL { $$ = dt_decl_ptr(); }
+ | DT_TOK_MUL type_qualifier_list { $$ = dt_decl_ptr(); }
+ | DT_TOK_MUL pointer { $$ = dt_decl_ptr(); }
+ | DT_TOK_MUL type_qualifier_list pointer { $$ = dt_decl_ptr(); }
+ ;
+
+type_qualifier_list:
+ type_qualifier
+ | type_qualifier_list type_qualifier { $$ = $2; }
+ ;
+
+parameter_type_list:
+ parameter_list
+ | DT_TOK_ELLIPSIS { $$ = dt_node_vatype(); }
+ | parameter_list DT_TOK_COMMA DT_TOK_ELLIPSIS {
+ $$ = LINK($1, dt_node_vatype());
+ }
+ ;
+
+parameter_list: parameter_declaration
+ | parameter_list DT_TOK_COMMA parameter_declaration {
+ $$ = LINK($1, $3);
+ }
+ ;
+
+parameter_declaration:
+ parameter_declaration_specifiers {
+ $$ = dt_node_type(NULL);
+ }
+ | parameter_declaration_specifiers declarator {
+ $$ = dt_node_type(NULL);
+ }
+ | parameter_declaration_specifiers abstract_declarator {
+ $$ = dt_node_type(NULL);
+ }
+ ;
+
+type_name: specifier_qualifier_list {
+ $$ = dt_decl_pop();
+ }
+ | specifier_qualifier_list abstract_declarator {
+ $$ = dt_decl_pop();
+ }
+ ;
+
+abstract_declarator:
+ pointer
+ | direct_abstract_declarator
+ | pointer direct_abstract_declarator
+ ;
+
+direct_abstract_declarator:
+ lparen abstract_declarator DT_TOK_RPAR { $$ = $2; }
+ | direct_abstract_declarator array { dt_decl_array($2); }
+ | array { dt_decl_array($1); $$ = NULL; }
+ | direct_abstract_declarator function { dt_decl_func($1, $2); }
+ | function { dt_decl_func(NULL, $1); }
+ ;
+
+array: DT_TOK_LBRAC { dt_scope_push(NULL, CTF_ERR); }
+ array_parameters DT_TOK_RBRAC {
+ dt_scope_pop();
+ $$ = $3;
+ }
+ ;
+
+array_parameters:
+ /* empty */ { $$ = NULL; }
+ | constant_expression { $$ = $1; }
+ | parameter_type_list { $$ = $1; }
+ ;
+
+function: DT_TOK_LPAR { dt_scope_push(NULL, CTF_ERR); }
+ function_parameters DT_TOK_RPAR {
+ dt_scope_pop();
+ $$ = $3;
+ }
+ ;
+
+function_parameters:
+ /* empty */ { $$ = NULL; }
+ | parameter_type_list { $$ = $1; }
+ ;
+
+%%
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_handle.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_handle.c
new file mode 100644
index 00000000..b02e5cc8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_handle.c
@@ -0,0 +1,483 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <errno.h>
+#include <unistd.h>
+#include <assert.h>
+#include <alloca.h>
+#endif
+
+#include <dt_impl.h>
+#include <dt_program.h>
+
+static const char _dt_errprog[] =
+"dtrace:::ERROR"
+"{"
+" trace(arg1);"
+" trace(arg2);"
+" trace(arg3);"
+" trace(arg4);"
+" trace(arg5);"
+"}";
+
+int
+dtrace_handle_err(dtrace_hdl_t *dtp, dtrace_handle_err_f *hdlr, void *arg)
+{
+ dtrace_prog_t *pgp = NULL;
+ dt_stmt_t *stp;
+ dtrace_ecbdesc_t *edp;
+
+ /*
+ * We don't currently support multiple error handlers.
+ */
+ if (dtp->dt_errhdlr != NULL)
+ return (dt_set_errno(dtp, EALREADY));
+
+ /*
+ * If the DTRACEOPT_GRABANON is enabled, the anonymous enabling will
+ * already have a dtrace:::ERROR probe enabled; save 'hdlr' and 'arg'
+ * but do not bother compiling and enabling _dt_errprog.
+ */
+ if (dtp->dt_options[DTRACEOPT_GRABANON] != DTRACEOPT_UNSET)
+ goto out;
+
+ if ((pgp = dtrace_program_strcompile(dtp, _dt_errprog,
+ DTRACE_PROBESPEC_NAME, DTRACE_C_ZDEFS, 0, NULL)) == NULL)
+ return (dt_set_errno(dtp, dtrace_errno(dtp)));
+
+ stp = dt_list_next(&pgp->dp_stmts);
+ assert(stp != NULL);
+
+ edp = stp->ds_desc->dtsd_ecbdesc;
+ assert(edp != NULL);
+ edp->dted_uarg = DT_ECB_ERROR;
+
+out:
+ dtp->dt_errhdlr = hdlr;
+ dtp->dt_errarg = arg;
+ dtp->dt_errprog = pgp;
+
+ return (0);
+}
+
+int
+dtrace_handle_drop(dtrace_hdl_t *dtp, dtrace_handle_drop_f *hdlr, void *arg)
+{
+ if (dtp->dt_drophdlr != NULL)
+ return (dt_set_errno(dtp, EALREADY));
+
+ dtp->dt_drophdlr = hdlr;
+ dtp->dt_droparg = arg;
+
+ return (0);
+}
+
+int
+dtrace_handle_proc(dtrace_hdl_t *dtp, dtrace_handle_proc_f *hdlr, void *arg)
+{
+ if (dtp->dt_prochdlr != NULL)
+ return (dt_set_errno(dtp, EALREADY));
+
+ dtp->dt_prochdlr = hdlr;
+ dtp->dt_procarg = arg;
+
+ return (0);
+}
+
+int
+dtrace_handle_buffered(dtrace_hdl_t *dtp, dtrace_handle_buffered_f *hdlr,
+ void *arg)
+{
+ if (dtp->dt_bufhdlr != NULL)
+ return (dt_set_errno(dtp, EALREADY));
+
+ if (hdlr == NULL)
+ return (dt_set_errno(dtp, EINVAL));
+
+ dtp->dt_bufhdlr = hdlr;
+ dtp->dt_bufarg = arg;
+
+ return (0);
+}
+
+int
+dtrace_handle_setopt(dtrace_hdl_t *dtp, dtrace_handle_setopt_f *hdlr,
+ void *arg)
+{
+ if (hdlr == NULL)
+ return (dt_set_errno(dtp, EINVAL));
+
+ dtp->dt_setopthdlr = hdlr;
+ dtp->dt_setoptarg = arg;
+
+ return (0);
+}
+
+#define DT_REC(type, ndx) *((type *)((uintptr_t)data->dtpda_data + \
+ epd->dtepd_rec[(ndx)].dtrd_offset))
+
+static int
+dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data)
+{
+ dtrace_eprobedesc_t *epd = data->dtpda_edesc, *errepd;
+ dtrace_probedesc_t *pd = data->dtpda_pdesc, *errpd;
+ dtrace_errdata_t err;
+ dtrace_epid_t epid;
+
+ char where[30];
+ char details[30];
+ char offinfo[30];
+ const int slop = 80;
+ const char *faultstr;
+ char *str;
+ VBDTTYPE(size_t,int) len;
+
+ assert(epd->dtepd_uarg == DT_ECB_ERROR);
+
+ if (epd->dtepd_nrecs != 5 || strcmp(pd->dtpd_provider, "dtrace") != 0 ||
+ strcmp(pd->dtpd_name, "ERROR") != 0)
+ return (dt_set_errno(dtp, EDT_BADERROR));
+
+ /*
+ * This is an error. We have the following items here: EPID,
+ * faulting action, DIF offset, fault code and faulting address.
+ */
+ epid = (uint32_t)DT_REC(uint64_t, 0);
+
+ if (dt_epid_lookup(dtp, epid, &errepd, &errpd) != 0)
+ return (dt_set_errno(dtp, EDT_BADERROR));
+
+ err.dteda_edesc = errepd;
+ err.dteda_pdesc = errpd;
+ err.dteda_cpu = data->dtpda_cpu;
+ err.dteda_action = (int)DT_REC(uint64_t, 1);
+ err.dteda_offset = (int)DT_REC(uint64_t, 2);
+ err.dteda_fault = (int)DT_REC(uint64_t, 3);
+ err.dteda_addr = DT_REC(uint64_t, 4);
+
+ faultstr = dtrace_faultstr(dtp, err.dteda_fault);
+ len = sizeof (where) + sizeof (offinfo) + strlen(faultstr) +
+ strlen(errpd->dtpd_provider) + strlen(errpd->dtpd_mod) +
+ strlen(errpd->dtpd_name) + strlen(errpd->dtpd_func) +
+ slop;
+
+ str = (char *)alloca(len);
+
+ if (err.dteda_action == 0) {
+ (void) sprintf(where, "predicate");
+ } else {
+ (void) sprintf(where, "action #%d", err.dteda_action);
+ }
+
+ if (err.dteda_offset != -1) {
+ (void) sprintf(offinfo, " at DIF offset %d", err.dteda_offset);
+ } else {
+ offinfo[0] = 0;
+ }
+
+ switch (err.dteda_fault) {
+ case DTRACEFLT_BADADDR:
+ case DTRACEFLT_BADALIGN:
+ case DTRACEFLT_BADSTACK:
+ (void) sprintf(details, " (0x%llx)",
+ (u_longlong_t)err.dteda_addr);
+ break;
+
+ default:
+ details[0] = 0;
+ }
+
+ (void) snprintf(str, len, "error on enabled probe ID %u "
+ "(ID %u: %s:%s:%s:%s): %s%s in %s%s\n",
+ epid, errpd->dtpd_id, errpd->dtpd_provider,
+ errpd->dtpd_mod, errpd->dtpd_func,
+ errpd->dtpd_name, dtrace_faultstr(dtp, err.dteda_fault),
+ details, where, offinfo);
+
+ err.dteda_msg = str;
+
+ if (dtp->dt_errhdlr == NULL)
+ return (dt_set_errno(dtp, EDT_ERRABORT));
+
+ if ((*dtp->dt_errhdlr)(&err, dtp->dt_errarg) == DTRACE_HANDLE_ABORT)
+ return (dt_set_errno(dtp, EDT_ERRABORT));
+
+ return (0);
+}
+
+int
+dt_handle_liberr(dtrace_hdl_t *dtp, const dtrace_probedata_t *data,
+ const char *faultstr)
+{
+ dtrace_probedesc_t *errpd = data->dtpda_pdesc;
+ dtrace_errdata_t err;
+ const int slop = 80;
+ char *str;
+ VBDTTYPE(size_t,int) len;
+
+ err.dteda_edesc = data->dtpda_edesc;
+ err.dteda_pdesc = errpd;
+ err.dteda_cpu = data->dtpda_cpu;
+ err.dteda_action = -1;
+ err.dteda_offset = -1;
+ err.dteda_fault = DTRACEFLT_LIBRARY;
+ err.dteda_addr = 0 /*NULL*/;
+
+ len = strlen(faultstr) +
+ strlen(errpd->dtpd_provider) + strlen(errpd->dtpd_mod) +
+ strlen(errpd->dtpd_name) + strlen(errpd->dtpd_func) +
+ slop;
+
+ str = alloca(len);
+
+ (void) snprintf(str, len, "error on enabled probe ID %u "
+ "(ID %u: %s:%s:%s:%s): %s\n",
+ data->dtpda_edesc->dtepd_epid,
+ errpd->dtpd_id, errpd->dtpd_provider,
+ errpd->dtpd_mod, errpd->dtpd_func,
+ errpd->dtpd_name, faultstr);
+
+ err.dteda_msg = str;
+
+ if (dtp->dt_errhdlr == NULL)
+ return (dt_set_errno(dtp, EDT_ERRABORT));
+
+ if ((*dtp->dt_errhdlr)(&err, dtp->dt_errarg) == DTRACE_HANDLE_ABORT)
+ return (dt_set_errno(dtp, EDT_ERRABORT));
+
+ return (0);
+}
+
+#define DROPTAG(x) x, #x
+
+static const struct {
+ dtrace_dropkind_t dtdrg_kind;
+ char *dtdrg_tag;
+} _dt_droptags[] = {
+ { DROPTAG(DTRACEDROP_PRINCIPAL) },
+ { DROPTAG(DTRACEDROP_AGGREGATION) },
+ { DROPTAG(DTRACEDROP_DYNAMIC) },
+ { DROPTAG(DTRACEDROP_DYNRINSE) },
+ { DROPTAG(DTRACEDROP_DYNDIRTY) },
+ { DROPTAG(DTRACEDROP_SPEC) },
+ { DROPTAG(DTRACEDROP_SPECBUSY) },
+ { DROPTAG(DTRACEDROP_SPECUNAVAIL) },
+ { DROPTAG(DTRACEDROP_DBLERROR) },
+ { DROPTAG(DTRACEDROP_STKSTROVERFLOW) },
+ { 0, NULL }
+};
+
+static const char *
+dt_droptag(dtrace_dropkind_t kind)
+{
+ int i;
+
+ for (i = 0; _dt_droptags[i].dtdrg_tag != NULL; i++) {
+ if (_dt_droptags[i].dtdrg_kind == kind)
+ return (_dt_droptags[i].dtdrg_tag);
+ }
+
+ return ("DTRACEDROP_UNKNOWN");
+}
+
+int
+dt_handle_cpudrop(dtrace_hdl_t *dtp, processorid_t cpu,
+ dtrace_dropkind_t what, uint64_t howmany)
+{
+ dtrace_dropdata_t drop;
+ char str[80], *s;
+ VBDTTYPE(size_t,int) size;
+
+ assert(what == DTRACEDROP_PRINCIPAL || what == DTRACEDROP_AGGREGATION);
+
+ bzero(&drop, sizeof (drop));
+ drop.dtdda_handle = dtp;
+ drop.dtdda_cpu = cpu;
+ drop.dtdda_kind = what;
+ drop.dtdda_drops = howmany;
+ drop.dtdda_msg = str;
+
+ if (dtp->dt_droptags) {
+ (void) snprintf(str, sizeof (str), "[%s] ", dt_droptag(what));
+ s = &str[strlen(str)];
+ size = sizeof (str) - (s - str);
+ } else {
+ s = str;
+ size = sizeof (str);
+ }
+
+ (void) snprintf(s, size, "%llu %sdrop%s on CPU %d\n",
+ howmany, what == DTRACEDROP_PRINCIPAL ? "" : "aggregation ",
+ howmany > 1 ? "s" : "", cpu);
+
+ if (dtp->dt_drophdlr == NULL)
+ return (dt_set_errno(dtp, EDT_DROPABORT));
+
+ if ((*dtp->dt_drophdlr)(&drop, dtp->dt_droparg) == DTRACE_HANDLE_ABORT)
+ return (dt_set_errno(dtp, EDT_DROPABORT));
+
+ return (0);
+}
+
+static const struct {
+ dtrace_dropkind_t dtdrt_kind;
+ uintptr_t dtdrt_offset;
+ const char *dtdrt_str;
+ const char *dtdrt_msg;
+} _dt_droptab[] = {
+ { DTRACEDROP_DYNAMIC,
+ offsetof(dtrace_status_t, dtst_dyndrops),
+ "dynamic variable drop" },
+
+ { DTRACEDROP_DYNRINSE,
+ offsetof(dtrace_status_t, dtst_dyndrops_rinsing),
+ "dynamic variable drop", " with non-empty rinsing list" },
+
+ { DTRACEDROP_DYNDIRTY,
+ offsetof(dtrace_status_t, dtst_dyndrops_dirty),
+ "dynamic variable drop", " with non-empty dirty list" },
+
+ { DTRACEDROP_SPEC,
+ offsetof(dtrace_status_t, dtst_specdrops),
+ "speculative drop" },
+
+ { DTRACEDROP_SPECBUSY,
+ offsetof(dtrace_status_t, dtst_specdrops_busy),
+ "failed speculation", " (available buffer(s) still busy)" },
+
+ { DTRACEDROP_SPECUNAVAIL,
+ offsetof(dtrace_status_t, dtst_specdrops_unavail),
+ "failed speculation", " (no speculative buffer available)" },
+
+ { DTRACEDROP_STKSTROVERFLOW,
+ offsetof(dtrace_status_t, dtst_stkstroverflows),
+ "jstack()/ustack() string table overflow" },
+
+ { DTRACEDROP_DBLERROR,
+ offsetof(dtrace_status_t, dtst_dblerrors),
+ "error", " in ERROR probe enabling" },
+
+ { 0, 0, NULL }
+};
+
+int
+dt_handle_status(dtrace_hdl_t *dtp, dtrace_status_t *old, dtrace_status_t *new)
+{
+ dtrace_dropdata_t drop;
+ char str[80], *s;
+ uintptr_t base = (uintptr_t)new, obase = (uintptr_t)old;
+ int i, size;
+
+ bzero(&drop, sizeof (drop));
+ drop.dtdda_handle = dtp;
+ drop.dtdda_cpu = DTRACE_CPUALL;
+ drop.dtdda_msg = str;
+
+ /*
+ * First, check to see if we've been killed -- in which case we abort.
+ */
+ if (new->dtst_killed && !old->dtst_killed)
+ return (dt_set_errno(dtp, EDT_BRICKED));
+
+ for (i = 0; _dt_droptab[i].dtdrt_str != NULL; i++) {
+ uintptr_t naddr = base + _dt_droptab[i].dtdrt_offset;
+ uintptr_t oaddr = obase + _dt_droptab[i].dtdrt_offset;
+
+ uint64_t nval = *((uint64_t *)naddr);
+ uint64_t oval = *((uint64_t *)oaddr);
+
+ if (nval == oval)
+ continue;
+
+ if (dtp->dt_droptags) {
+ (void) snprintf(str, sizeof (str), "[%s] ",
+ dt_droptag(_dt_droptab[i].dtdrt_kind));
+ s = &str[strlen(str)];
+ size = VBDTCAST(int)sizeof (str) - (s - str);
+ } else {
+ s = str;
+ size = sizeof (str);
+ }
+
+ (void) snprintf(s, size, "%llu %s%s%s\n", nval - oval,
+ _dt_droptab[i].dtdrt_str, (nval - oval > 1) ? "s" : "",
+ _dt_droptab[i].dtdrt_msg != NULL ?
+ _dt_droptab[i].dtdrt_msg : "");
+
+ drop.dtdda_kind = _dt_droptab[i].dtdrt_kind;
+ drop.dtdda_total = nval;
+ drop.dtdda_drops = nval - oval;
+
+ if (dtp->dt_drophdlr == NULL)
+ return (dt_set_errno(dtp, EDT_DROPABORT));
+
+ if ((*dtp->dt_drophdlr)(&drop,
+ dtp->dt_droparg) == DTRACE_HANDLE_ABORT)
+ return (dt_set_errno(dtp, EDT_DROPABORT));
+ }
+
+ return (0);
+}
+
+int
+dt_handle_setopt(dtrace_hdl_t *dtp, dtrace_setoptdata_t *data)
+{
+ void *arg = dtp->dt_setoptarg;
+
+ if (dtp->dt_setopthdlr == NULL)
+ return (0);
+
+ if ((*dtp->dt_setopthdlr)(data, arg) == DTRACE_HANDLE_ABORT)
+ return (dt_set_errno(dtp, EDT_DIRABORT));
+
+ return (0);
+}
+
+int
+dt_handle(dtrace_hdl_t *dtp, dtrace_probedata_t *data)
+{
+ dtrace_eprobedesc_t *epd = data->dtpda_edesc;
+ int rval;
+
+ switch (epd->dtepd_uarg) {
+ case DT_ECB_ERROR:
+ rval = dt_handle_err(dtp, data);
+ break;
+
+ default:
+ return (DTRACE_CONSUME_THIS);
+ }
+
+ if (rval == 0)
+ return (DTRACE_CONSUME_NEXT);
+
+ return (DTRACE_CONSUME_ERROR);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.c
new file mode 100644
index 00000000..37a80be8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.c
@@ -0,0 +1,1049 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <sys/sysmacros.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <alloca.h>
+#include <assert.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/procfs_isa.h>
+#include <limits.h>
+#else /* VBOX */
+# include <ctype.h>
+#endif /* VBOX */
+
+#include <dt_ident.h>
+#include <dt_parser.h>
+#include <dt_provider.h>
+#include <dt_strtab.h>
+#include <dt_impl.h>
+
+/*
+ * Common code for cooking an identifier that uses a typed signature list (we
+ * use this for associative arrays and functions). If the argument list is
+ * of the same length and types, then return the return type. Otherwise
+ * print an appropriate compiler error message and abort the compile.
+ */
+static void
+dt_idcook_sign(dt_node_t *dnp, dt_ident_t *idp,
+ int argc, dt_node_t *args, const char *prefix, const char *suffix)
+{
+ dt_idsig_t *isp = idp->di_data;
+ int i, compat, mismatch, arglimit, iskey;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ iskey = idp->di_kind == DT_IDENT_ARRAY || idp->di_kind == DT_IDENT_AGG;
+
+ if (isp->dis_varargs >= 0) {
+ mismatch = argc < isp->dis_varargs;
+ arglimit = isp->dis_varargs;
+ } else if (isp->dis_optargs >= 0) {
+ mismatch = (argc < isp->dis_optargs || argc > isp->dis_argc);
+ arglimit = argc;
+ } else {
+ mismatch = argc != isp->dis_argc;
+ arglimit = isp->dis_argc;
+ }
+
+ if (mismatch) {
+ xyerror(D_PROTO_LEN, "%s%s%s prototype mismatch: %d %s%s"
+ "passed, %s%d expected\n", prefix, idp->di_name, suffix,
+ argc, iskey ? "key" : "arg", argc == 1 ? " " : "s ",
+ isp->dis_optargs >= 0 ? "at least " : "",
+ isp->dis_optargs >= 0 ? isp->dis_optargs : arglimit);
+ }
+
+ for (i = 0; i < arglimit; i++, args = args->dn_list) {
+ if (isp->dis_args[i].dn_ctfp != NULL)
+ compat = dt_node_is_argcompat(&isp->dis_args[i], args);
+ else
+ compat = 1; /* "@" matches any type */
+
+ if (!compat) {
+ xyerror(D_PROTO_ARG,
+ "%s%s%s %s #%d is incompatible with "
+ "prototype:\n\tprototype: %s\n\t%9s: %s\n",
+ prefix, idp->di_name, suffix,
+ iskey ? "key" : "argument", i + 1,
+ dt_node_type_name(&isp->dis_args[i], n1,
+ sizeof (n1)),
+ iskey ? "key" : "argument",
+ dt_node_type_name(args, n2, sizeof (n2)));
+ }
+ }
+
+ dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
+}
+
+/*
+ * Cook an associative array identifier. If this is the first time we are
+ * cooking this array, create its signature based on the argument list.
+ * Otherwise validate the argument list against the existing signature.
+ */
+static void
+dt_idcook_assc(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
+{
+ if (idp->di_data == NULL) {
+ dt_idsig_t *isp = idp->di_data = malloc(sizeof (dt_idsig_t));
+ char n[DT_TYPE_NAMELEN];
+ int i;
+
+ if (isp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ isp->dis_varargs = -1;
+ isp->dis_optargs = -1;
+ isp->dis_argc = argc;
+ isp->dis_args = NULL;
+ isp->dis_auxinfo = 0;
+
+ if (argc != 0 && (isp->dis_args = calloc(argc,
+ sizeof (dt_node_t))) == NULL) {
+ idp->di_data = NULL;
+ free(isp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ /*
+ * If this identifier has not been explicitly declared earlier,
+ * set the identifier's base type to be our special type <DYN>.
+ * If this ident is an aggregation, it will remain as is. If
+ * this ident is an associative array, it will be reassigned
+ * based on the result type of the first assignment statement.
+ */
+ if (!(idp->di_flags & DT_IDFLG_DECL)) {
+ idp->di_ctfp = DT_DYN_CTFP(yypcb->pcb_hdl);
+ idp->di_type = DT_DYN_TYPE(yypcb->pcb_hdl);
+ }
+
+ for (i = 0; i < argc; i++, args = args->dn_list) {
+ if (dt_node_is_dynamic(args) || dt_node_is_void(args)) {
+ xyerror(D_KEY_TYPE, "%s expression may not be "
+ "used as %s index: key #%d\n",
+ dt_node_type_name(args, n, sizeof (n)),
+ dt_idkind_name(idp->di_kind), i + 1);
+ }
+
+ dt_node_type_propagate(args, &isp->dis_args[i]);
+ isp->dis_args[i].dn_list = &isp->dis_args[i + 1];
+ }
+
+ if (argc != 0)
+ isp->dis_args[argc - 1].dn_list = NULL;
+
+ dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
+
+ } else {
+ dt_idcook_sign(dnp, idp, argc, args,
+ idp->di_kind == DT_IDENT_AGG ? "@" : "", "[ ]");
+ }
+}
+
+/*
+ * Cook a function call. If this is the first time we are cooking this
+ * identifier, create its type signature based on predefined prototype stored
+ * in di_iarg. We then validate the argument list against this signature.
+ */
+static void
+dt_idcook_func(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
+{
+ if (idp->di_data == NULL) {
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dtrace_typeinfo_t dtt;
+ dt_idsig_t *isp;
+ char *s, *p1, *p2;
+ int i = 0;
+
+ assert(idp->di_iarg != NULL);
+#ifndef VBOX
+ s = strdupa(idp->di_iarg);
+#else
+ MY_STRDUPA(s, idp->di_iarg);
+#endif
+
+ if ((p2 = strrchr(s, ')')) != NULL)
+ *p2 = '\0'; /* mark end of parameter list string */
+
+ if ((p1 = strchr(s, '(')) != NULL)
+ *p1++ = '\0'; /* mark end of return type string */
+
+ if (p1 == NULL || p2 == NULL) {
+ xyerror(D_UNKNOWN, "internal error: malformed entry "
+ "for built-in function %s\n", idp->di_name);
+ }
+
+ for (p2 = p1; *p2 != '\0'; p2++) {
+ if (!isspace(*p2)) {
+ i++;
+ break;
+ }
+ }
+
+ for (p2 = strchr(p2, ','); p2++ != NULL; i++)
+ p2 = strchr(p2, ',');
+
+ /*
+ * We first allocate a new ident signature structure with the
+ * appropriate number of argument entries, and then look up
+ * the return type and store its CTF data in di_ctfp/type.
+ */
+ if ((isp = idp->di_data = malloc(sizeof (dt_idsig_t))) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ isp->dis_varargs = -1;
+ isp->dis_optargs = -1;
+ isp->dis_argc = i;
+ isp->dis_args = NULL;
+ isp->dis_auxinfo = 0;
+
+ if (i != 0 && (isp->dis_args = calloc(i,
+ sizeof (dt_node_t))) == NULL) {
+ idp->di_data = NULL;
+ free(isp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ if (dt_type_lookup(s, &dtt) == -1) {
+ xyerror(D_UNKNOWN, "failed to resolve type of %s (%s):"
+ " %s\n", idp->di_name, s,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ if (idp->di_kind == DT_IDENT_AGGFUNC) {
+ idp->di_ctfp = DT_DYN_CTFP(dtp);
+ idp->di_type = DT_DYN_TYPE(dtp);
+ } else {
+ idp->di_ctfp = dtt.dtt_ctfp;
+ idp->di_type = dtt.dtt_type;
+ }
+
+ /*
+ * For each comma-delimited parameter in the prototype string,
+ * we look up the corresponding type and store its CTF data in
+ * the corresponding location in dis_args[]. We also recognize
+ * the special type string "@" to indicate that the specified
+ * parameter may be a D expression of *any* type (represented
+ * as a dis_args[] element with ctfp = NULL, type == CTF_ERR).
+ * If a varargs "..." is present, we record the argument index
+ * in dis_varargs for the benefit of dt_idcook_sign(), above.
+ * If the type of an argument is enclosed in square brackets
+ * (e.g. "[int]"), the argument is considered optional: the
+ * argument may be absent, but if it is present, it must be of
+ * the specified type. Note that varargs may not optional,
+ * optional arguments may not follow varargs, and non-optional
+ * arguments may not follow optional arguments.
+ */
+ for (i = 0; i < isp->dis_argc; i++, p1 = p2) {
+ while (isspace(*p1))
+ p1++; /* skip leading whitespace */
+
+ if ((p2 = strchr(p1, ',')) == NULL)
+ p2 = p1 + strlen(p1);
+ else
+ *p2++ = '\0';
+
+ if (strcmp(p1, "@") == 0 || strcmp(p1, "...") == 0) {
+ isp->dis_args[i].dn_ctfp = NULL;
+ isp->dis_args[i].dn_type = CTF_ERR;
+ if (*p1 == '.')
+ isp->dis_varargs = i;
+ continue;
+ }
+
+ if (*p1 == '[' && p1[strlen(p1) - 1] == ']') {
+ if (isp->dis_varargs != -1) {
+ xyerror(D_UNKNOWN, "optional arg#%d "
+ "may not follow variable arg#%d\n",
+ i + 1, isp->dis_varargs + 1);
+ }
+
+ if (isp->dis_optargs == -1)
+ isp->dis_optargs = i;
+
+ p1[strlen(p1) - 1] = '\0';
+ p1++;
+ } else if (isp->dis_optargs != -1) {
+ xyerror(D_UNKNOWN, "required arg#%d may not "
+ "follow optional arg#%d\n", i + 1,
+ isp->dis_optargs + 1);
+ }
+
+ if (dt_type_lookup(p1, &dtt) == -1) {
+ xyerror(D_UNKNOWN, "failed to resolve type of "
+ "%s arg#%d (%s): %s\n", idp->di_name, i + 1,
+ p1, dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ dt_node_type_assign(&isp->dis_args[i],
+ dtt.dtt_ctfp, dtt.dtt_type);
+ }
+ }
+
+ dt_idcook_sign(dnp, idp, argc, args, "", "( )");
+}
+
+/*
+ * Cook a reference to the dynamically typed args[] array. We verify that the
+ * reference is using a single integer constant, and then construct a new ident
+ * representing the appropriate type or translation specifically for this node.
+ */
+static void
+dt_idcook_args(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_probe_t *prp = yypcb->pcb_probe;
+
+ dt_node_t tag, *nnp, *xnp;
+ dt_xlator_t *dxp;
+ dt_ident_t *xidp;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ if (argc != 1) {
+ xyerror(D_PROTO_LEN, "%s[ ] prototype mismatch: %d arg%s"
+ "passed, 1 expected\n", idp->di_name, argc,
+ argc == 1 ? " " : "s ");
+ }
+
+ if (ap->dn_kind != DT_NODE_INT) {
+ xyerror(D_PROTO_ARG, "%s[ ] argument #1 is incompatible with "
+ "prototype:\n\tprototype: %s\n\t argument: %s\n",
+ idp->di_name, "integer constant",
+ dt_type_name(ap->dn_ctfp, ap->dn_type, n1, sizeof (n1)));
+ }
+
+ if (yypcb->pcb_pdesc == NULL) {
+ xyerror(D_ARGS_NONE, "%s[ ] may not be referenced outside "
+ "of a probe clause\n", idp->di_name);
+ }
+
+ if (prp == NULL) {
+ xyerror(D_ARGS_MULTI,
+ "%s[ ] may not be referenced because probe description %s "
+ "matches an unstable set of probes\n", idp->di_name,
+ dtrace_desc2str(yypcb->pcb_pdesc, n1, sizeof (n1)));
+ }
+
+ if (ap->dn_value >= VBDTCAST(uintmax_t)prp->pr_argc) {
+ xyerror(D_ARGS_IDX, "index %lld is out of range for %s %s[ ]\n",
+ (longlong_t)ap->dn_value, dtrace_desc2str(yypcb->pcb_pdesc,
+ n1, sizeof (n1)), idp->di_name);
+ }
+
+ /*
+ * Look up the native and translated argument types for the probe.
+ * If no translation is needed, these will be the same underlying node.
+ * If translation is needed, look up the appropriate translator. Once
+ * we have the appropriate node, create a new dt_ident_t for this node,
+ * assign it the appropriate attributes, and set the type of 'dnp'.
+ */
+ xnp = prp->pr_xargv[ap->dn_value];
+ nnp = prp->pr_nargv[prp->pr_mapping[ap->dn_value]];
+
+ if (xnp->dn_type == CTF_ERR) {
+ xyerror(D_ARGS_TYPE, "failed to resolve translated type for "
+ "%s[%lld]\n", idp->di_name, (longlong_t)ap->dn_value);
+ }
+
+ if (nnp->dn_type == CTF_ERR) {
+ xyerror(D_ARGS_TYPE, "failed to resolve native type for "
+ "%s[%lld]\n", idp->di_name, (longlong_t)ap->dn_value);
+ }
+
+ if (dtp->dt_xlatemode == DT_XL_STATIC && (
+ nnp == xnp || dt_node_is_argcompat(nnp, xnp))) {
+ dnp->dn_ident = dt_ident_create(idp->di_name, idp->di_kind,
+ idp->di_flags | DT_IDFLG_ORPHAN, idp->di_id, idp->di_attr,
+ idp->di_vers, idp->di_ops, idp->di_iarg, idp->di_gen);
+
+ if (dnp->dn_ident == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dt_node_type_assign(dnp,
+ prp->pr_argv[ap->dn_value].dtt_ctfp,
+ prp->pr_argv[ap->dn_value].dtt_type);
+
+ } else if ((dxp = dt_xlator_lookup(dtp,
+ nnp, xnp, DT_XLATE_FUZZY)) != NULL || (
+ dxp = dt_xlator_lookup(dtp, dt_probe_tag(prp, ap->dn_value, &tag),
+ xnp, DT_XLATE_EXACT | DT_XLATE_EXTERN)) != NULL) {
+
+ xidp = dt_xlator_ident(dxp, xnp->dn_ctfp, xnp->dn_type);
+
+ dnp->dn_ident = dt_ident_create(idp->di_name, xidp->di_kind,
+ xidp->di_flags | DT_IDFLG_ORPHAN, idp->di_id, idp->di_attr,
+ idp->di_vers, idp->di_ops, idp->di_iarg, idp->di_gen);
+
+ if (dnp->dn_ident == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (dt_xlator_dynamic(dxp))
+ dxp->dx_arg = (int)ap->dn_value;
+
+ /*
+ * Propagate relevant members from the translator's internal
+ * dt_ident_t. This code must be kept in sync with the state
+ * that is initialized for idents in dt_xlator_create().
+ */
+ dnp->dn_ident->di_data = xidp->di_data;
+ dnp->dn_ident->di_ctfp = xidp->di_ctfp;
+ dnp->dn_ident->di_type = xidp->di_type;
+
+ dt_node_type_assign(dnp, DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+
+ } else {
+ xyerror(D_ARGS_XLATOR, "translator for %s[%lld] from %s to %s "
+ "is not defined\n", idp->di_name, (longlong_t)ap->dn_value,
+ dt_node_type_name(nnp, n1, sizeof (n1)),
+ dt_node_type_name(xnp, n2, sizeof (n2)));
+ }
+
+ assert(dnp->dn_ident->di_flags & DT_IDFLG_ORPHAN);
+ assert(dnp->dn_ident->di_id == idp->di_id);
+}
+
+static void
+dt_idcook_regs(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)
+{
+ dtrace_typeinfo_t dtt;
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ char n[DT_TYPE_NAMELEN];
+
+ if (argc != 1) {
+ xyerror(D_PROTO_LEN, "%s[ ] prototype mismatch: %d arg%s"
+ "passed, 1 expected\n", idp->di_name,
+ argc, argc == 1 ? " " : "s ");
+ }
+
+ if (ap->dn_kind != DT_NODE_INT) {
+ xyerror(D_PROTO_ARG, "%s[ ] argument #1 is incompatible with "
+ "prototype:\n\tprototype: %s\n\t argument: %s\n",
+ idp->di_name, "integer constant",
+ dt_type_name(ap->dn_ctfp, ap->dn_type, n, sizeof (n)));
+ }
+
+ if ((ap->dn_flags & DT_NF_SIGNED) && (int64_t)ap->dn_value < 0) {
+ xyerror(D_REGS_IDX, "index %lld is out of range for array %s\n",
+ (longlong_t)ap->dn_value, idp->di_name);
+ }
+
+ if (dt_type_lookup("uint64_t", &dtt) == -1) {
+ xyerror(D_UNKNOWN, "failed to resolve type of %s: %s\n",
+ idp->di_name, dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ idp->di_ctfp = dtt.dtt_ctfp;
+ idp->di_type = dtt.dtt_type;
+
+ dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
+}
+
+/*ARGSUSED*/
+static void
+dt_idcook_type(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
+{
+ RT_NOREF2(argc, args);
+ if (idp->di_type == CTF_ERR) {
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dtrace_typeinfo_t dtt;
+
+ if (dt_type_lookup(idp->di_iarg, &dtt) == -1) {
+ xyerror(D_UNKNOWN,
+ "failed to resolve type %s for identifier %s: %s\n",
+ (const char *)idp->di_iarg, idp->di_name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ idp->di_ctfp = dtt.dtt_ctfp;
+ idp->di_type = dtt.dtt_type;
+ }
+
+ dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
+}
+
+/*ARGSUSED*/
+static void
+dt_idcook_thaw(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
+{
+ RT_NOREF2(argc, args);
+ if (idp->di_ctfp != NULL && idp->di_type != CTF_ERR)
+ dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
+}
+
+static void
+dt_idcook_inline(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
+{
+ if (idp->di_kind == DT_IDENT_ARRAY)
+ dt_idcook_assc(dnp, idp, argc, args);
+ else
+ dt_idcook_thaw(dnp, idp, argc, args);
+}
+
+static void
+dt_iddtor_sign(dt_ident_t *idp)
+{
+ if (idp->di_data != NULL)
+ free(((dt_idsig_t *)idp->di_data)->dis_args);
+ free(idp->di_data);
+}
+
+static void
+dt_iddtor_free(dt_ident_t *idp)
+{
+ free(idp->di_data);
+}
+
+static void
+dt_iddtor_inline(dt_ident_t *idp)
+{
+ dt_idnode_t *inp = idp->di_iarg;
+
+ if (inp != NULL) {
+ dt_node_link_free(&inp->din_list);
+
+ if (inp->din_hash != NULL)
+ dt_idhash_destroy(inp->din_hash);
+
+ free(inp->din_argv);
+ free(inp);
+ }
+
+ if (idp->di_kind == DT_IDENT_ARRAY)
+ dt_iddtor_sign(idp);
+ else
+ dt_iddtor_free(idp);
+}
+
+/*ARGSUSED*/
+static void
+dt_iddtor_none(dt_ident_t *idp)
+{
+ RT_NOREF1(idp);
+ /* do nothing */
+}
+
+static void
+dt_iddtor_probe(dt_ident_t *idp)
+{
+ if (idp->di_data != NULL)
+ dt_probe_destroy(idp->di_data);
+}
+
+static size_t
+dt_idsize_type(dt_ident_t *idp)
+{
+ return (ctf_type_size(idp->di_ctfp, idp->di_type));
+}
+
+/*ARGSUSED*/
+static size_t
+dt_idsize_none(dt_ident_t *idp)
+{
+ RT_NOREF1(idp);
+ return (0);
+}
+
+const dt_idops_t dt_idops_assc = {
+ dt_idcook_assc,
+ dt_iddtor_sign,
+ dt_idsize_none,
+};
+
+const dt_idops_t dt_idops_func = {
+ dt_idcook_func,
+ dt_iddtor_sign,
+ dt_idsize_none,
+};
+
+const dt_idops_t dt_idops_args = {
+ dt_idcook_args,
+ dt_iddtor_none,
+ dt_idsize_none,
+};
+
+const dt_idops_t dt_idops_regs = {
+ dt_idcook_regs,
+ dt_iddtor_free,
+ dt_idsize_none,
+};
+
+const dt_idops_t dt_idops_type = {
+ dt_idcook_type,
+ dt_iddtor_free,
+ dt_idsize_type,
+};
+
+const dt_idops_t dt_idops_thaw = {
+ dt_idcook_thaw,
+ dt_iddtor_free,
+ dt_idsize_type,
+};
+
+const dt_idops_t dt_idops_inline = {
+ dt_idcook_inline,
+ dt_iddtor_inline,
+ dt_idsize_type,
+};
+
+const dt_idops_t dt_idops_probe = {
+ dt_idcook_thaw,
+ dt_iddtor_probe,
+ dt_idsize_none,
+};
+
+static void
+dt_idhash_populate(dt_idhash_t *dhp)
+{
+ const dt_ident_t *idp = dhp->dh_tmpl;
+
+ dhp->dh_tmpl = NULL; /* clear dh_tmpl first to avoid recursion */
+ dt_dprintf("populating %s idhash from %p\n", dhp->dh_name, (void *)idp);
+
+ for (; idp->di_name != NULL; idp++) {
+ if (dt_idhash_insert(dhp, idp->di_name,
+ idp->di_kind, idp->di_flags, idp->di_id, idp->di_attr,
+ idp->di_vers, idp->di_ops ? idp->di_ops : &dt_idops_thaw,
+ idp->di_iarg, 0) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+}
+
+dt_idhash_t *
+dt_idhash_create(const char *name, const dt_ident_t *tmpl,
+ uint_t min, uint_t max)
+{
+ dt_idhash_t *dhp;
+ size_t size;
+
+ assert(min <= max);
+
+ size = sizeof (dt_idhash_t) +
+ sizeof (dt_ident_t *) * (_dtrace_strbuckets - 1);
+
+ if ((dhp = malloc(size)) == NULL)
+ return (NULL);
+
+ bzero(dhp, size);
+ dhp->dh_name = name;
+ dhp->dh_tmpl = tmpl;
+ dhp->dh_nextid = min;
+ dhp->dh_minid = min;
+ dhp->dh_maxid = max;
+ dhp->dh_hashsz = _dtrace_strbuckets;
+
+ return (dhp);
+}
+
+/*
+ * Destroy an entire identifier hash. This must be done using two passes with
+ * an inlined version of dt_ident_destroy() to avoid referencing freed memory.
+ * In the first pass di_dtor() is called for all identifiers; then the second
+ * pass frees the actual dt_ident_t's. These must be done separately because
+ * a di_dtor() may operate on data structures which contain references to other
+ * identifiers inside of this hash itself (e.g. a global inline definition
+ * which contains a parse tree that refers to another global variable).
+ */
+void
+dt_idhash_destroy(dt_idhash_t *dhp)
+{
+ dt_ident_t *idp, *next;
+ ulong_t i;
+
+ for (i = 0; i < dhp->dh_hashsz; i++) {
+ for (idp = dhp->dh_hash[i]; idp != NULL; idp = next) {
+ next = idp->di_next;
+ idp->di_ops->di_dtor(idp);
+ }
+ }
+
+ for (i = 0; i < dhp->dh_hashsz; i++) {
+ for (idp = dhp->dh_hash[i]; idp != NULL; idp = next) {
+ next = idp->di_next;
+ free(idp->di_name);
+ free(idp);
+ }
+ }
+
+ free(dhp);
+}
+
+void
+dt_idhash_update(dt_idhash_t *dhp)
+{
+ uint_t nextid = dhp->dh_minid;
+ dt_ident_t *idp;
+ ulong_t i;
+
+ for (i = 0; i < dhp->dh_hashsz; i++) {
+ for (idp = dhp->dh_hash[i]; idp != NULL; idp = idp->di_next) {
+ /*
+ * Right now we're hard coding which types need to be
+ * reset, but ideally this would be done dynamically.
+ */
+ if (idp->di_kind == DT_IDENT_ARRAY ||
+ idp->di_kind == DT_IDENT_SCALAR ||
+ idp->di_kind == DT_IDENT_AGG)
+ nextid = MAX(nextid, idp->di_id + 1);
+ }
+ }
+
+ dhp->dh_nextid = nextid;
+}
+
+dt_ident_t *
+dt_idhash_lookup(dt_idhash_t *dhp, const char *name)
+{
+ size_t len;
+ ulong_t h = dt_strtab_hash(name, &len) % dhp->dh_hashsz;
+ dt_ident_t *idp;
+
+ if (dhp->dh_tmpl != NULL)
+ dt_idhash_populate(dhp); /* fill hash w/ initial population */
+
+ for (idp = dhp->dh_hash[h]; idp != NULL; idp = idp->di_next) {
+ if (strcmp(idp->di_name, name) == 0)
+ return (idp);
+ }
+
+ return (NULL);
+}
+
+int
+dt_idhash_nextid(dt_idhash_t *dhp, uint_t *p)
+{
+ if (dhp->dh_nextid >= dhp->dh_maxid)
+ return (-1); /* no more id's are free to allocate */
+
+ *p = dhp->dh_nextid++;
+ return (0);
+}
+
+ulong_t
+dt_idhash_size(const dt_idhash_t *dhp)
+{
+ return (dhp->dh_nelems);
+}
+
+const char *
+dt_idhash_name(const dt_idhash_t *dhp)
+{
+ return (dhp->dh_name);
+}
+
+dt_ident_t *
+dt_idhash_insert(dt_idhash_t *dhp, const char *name, ushort_t kind,
+ ushort_t flags, uint_t id, dtrace_attribute_t attr, uint_t vers,
+ const dt_idops_t *ops, void *iarg, ulong_t gen)
+{
+ dt_ident_t *idp;
+ ulong_t h;
+
+ if (dhp->dh_tmpl != NULL)
+ dt_idhash_populate(dhp); /* fill hash w/ initial population */
+
+ idp = dt_ident_create(name, kind, flags, id,
+ attr, vers, ops, iarg, gen);
+
+ if (idp == NULL)
+ return (NULL);
+
+ h = dt_strtab_hash(name, NULL) % dhp->dh_hashsz;
+ idp->di_next = dhp->dh_hash[h];
+
+ dhp->dh_hash[h] = idp;
+ dhp->dh_nelems++;
+
+ if (dhp->dh_defer != NULL)
+ dhp->dh_defer(dhp, idp);
+
+ return (idp);
+}
+
+void
+dt_idhash_xinsert(dt_idhash_t *dhp, dt_ident_t *idp)
+{
+ ulong_t h;
+
+ if (dhp->dh_tmpl != NULL)
+ dt_idhash_populate(dhp); /* fill hash w/ initial population */
+
+ h = dt_strtab_hash(idp->di_name, NULL) % dhp->dh_hashsz;
+ idp->di_next = dhp->dh_hash[h];
+ idp->di_flags &= ~DT_IDFLG_ORPHAN;
+
+ dhp->dh_hash[h] = idp;
+ dhp->dh_nelems++;
+
+ if (dhp->dh_defer != NULL)
+ dhp->dh_defer(dhp, idp);
+}
+
+void
+dt_idhash_delete(dt_idhash_t *dhp, dt_ident_t *key)
+{
+ size_t len;
+ ulong_t h = dt_strtab_hash(key->di_name, &len) % dhp->dh_hashsz;
+ dt_ident_t **pp = &dhp->dh_hash[h];
+ dt_ident_t *idp;
+
+ for (idp = dhp->dh_hash[h]; idp != NULL; idp = idp->di_next) {
+ if (idp == key)
+ break;
+ else
+ pp = &idp->di_next;
+ }
+
+ assert(idp == key);
+ *pp = idp->di_next;
+
+ assert(dhp->dh_nelems != 0);
+ dhp->dh_nelems--;
+
+ if (!(idp->di_flags & DT_IDFLG_ORPHAN))
+ dt_ident_destroy(idp);
+}
+
+static int
+dt_idhash_comp(const void *lp, const void *rp)
+{
+ const dt_ident_t *lhs = *((const dt_ident_t **)lp);
+ const dt_ident_t *rhs = *((const dt_ident_t **)rp);
+
+ if (lhs->di_id != rhs->di_id)
+ return ((int)(lhs->di_id - rhs->di_id));
+ else
+ return (strcmp(lhs->di_name, rhs->di_name));
+}
+
+int
+dt_idhash_iter(dt_idhash_t *dhp, dt_idhash_f *func, void *data)
+{
+ dt_ident_t **ids;
+ dt_ident_t *idp;
+ ulong_t i, j, n;
+ int rv;
+
+ if (dhp->dh_tmpl != NULL)
+ dt_idhash_populate(dhp); /* fill hash w/ initial population */
+
+ n = dhp->dh_nelems;
+ ids = alloca(sizeof (dt_ident_t *) * n);
+
+ for (i = 0, j = 0; i < dhp->dh_hashsz; i++) {
+ for (idp = dhp->dh_hash[i]; idp != NULL; idp = idp->di_next)
+ ids[j++] = idp;
+ }
+
+ qsort(ids, dhp->dh_nelems, sizeof (dt_ident_t *), dt_idhash_comp);
+
+ for (i = 0; i < n; i++) {
+ if ((rv = func(dhp, ids[i], data)) != 0)
+ return (rv);
+ }
+
+ return (0);
+}
+
+dt_ident_t *
+dt_idstack_lookup(dt_idstack_t *sp, const char *name)
+{
+ dt_idhash_t *dhp;
+ dt_ident_t *idp;
+
+ for (dhp = dt_list_prev(&sp->dids_list);
+ dhp != NULL; dhp = dt_list_prev(dhp)) {
+ if ((idp = dt_idhash_lookup(dhp, name)) != NULL)
+ return (idp);
+ }
+
+ return (NULL);
+}
+
+void
+dt_idstack_push(dt_idstack_t *sp, dt_idhash_t *dhp)
+{
+ dt_list_append(&sp->dids_list, dhp);
+}
+
+void
+dt_idstack_pop(dt_idstack_t *sp, dt_idhash_t *dhp)
+{
+ assert(dt_list_prev(&sp->dids_list) == dhp);
+ dt_list_delete(&sp->dids_list, dhp);
+}
+
+dt_ident_t *
+dt_ident_create(const char *name, ushort_t kind, ushort_t flags, uint_t id,
+ dtrace_attribute_t attr, uint_t vers,
+ const dt_idops_t *ops, void *iarg, ulong_t gen)
+{
+ dt_ident_t *idp;
+ char *s = NULL;
+
+ if ((name != NULL && (s = strdup(name)) == NULL) ||
+ (idp = malloc(sizeof (dt_ident_t))) == NULL) {
+ free(s);
+ return (NULL);
+ }
+
+ idp->di_name = s;
+ idp->di_kind = kind;
+ idp->di_flags = flags;
+ idp->di_id = id;
+ idp->di_attr = attr;
+ idp->di_vers = vers;
+ idp->di_ops = ops;
+ idp->di_iarg = iarg;
+ idp->di_data = NULL;
+ idp->di_ctfp = NULL;
+ idp->di_type = CTF_ERR;
+ idp->di_next = NULL;
+ idp->di_gen = gen;
+ idp->di_lineno = yylineno;
+
+ return (idp);
+}
+
+/*
+ * Destroy an individual identifier. This code must be kept in sync with the
+ * dt_idhash_destroy() function below, which separates out the call to di_dtor.
+ */
+void
+dt_ident_destroy(dt_ident_t *idp)
+{
+ idp->di_ops->di_dtor(idp);
+ free(idp->di_name);
+ free(idp);
+}
+
+void
+dt_ident_morph(dt_ident_t *idp, ushort_t kind,
+ const dt_idops_t *ops, void *iarg)
+{
+ idp->di_ops->di_dtor(idp);
+ idp->di_kind = kind;
+ idp->di_ops = ops;
+ idp->di_iarg = iarg;
+ idp->di_data = NULL;
+}
+
+dtrace_attribute_t
+dt_ident_cook(dt_node_t *dnp, dt_ident_t *idp, dt_node_t **pargp)
+{
+ dtrace_attribute_t attr;
+ dt_node_t *args, *argp;
+ int argc = 0;
+
+ attr = dt_node_list_cook(pargp, DT_IDFLG_REF);
+ args = pargp ? *pargp : NULL;
+
+ for (argp = args; argp != NULL; argp = argp->dn_list)
+ argc++;
+
+ idp->di_ops->di_cook(dnp, idp, argc, args);
+
+ if (idp->di_flags & DT_IDFLG_USER)
+ dnp->dn_flags |= DT_NF_USERLAND;
+
+ return (dt_attr_min(attr, idp->di_attr));
+}
+
+void
+dt_ident_type_assign(dt_ident_t *idp, ctf_file_t *fp, ctf_id_t type)
+{
+ idp->di_ctfp = fp;
+ idp->di_type = type;
+}
+
+dt_ident_t *
+dt_ident_resolve(dt_ident_t *idp)
+{
+ while (idp->di_flags & DT_IDFLG_INLINE) {
+ const dt_node_t *dnp = ((dt_idnode_t *)idp->di_iarg)->din_root;
+
+ if (dnp == NULL)
+ break; /* can't resolve any further yet */
+
+ switch (dnp->dn_kind) {
+ case DT_NODE_VAR:
+ case DT_NODE_SYM:
+ case DT_NODE_FUNC:
+ case DT_NODE_AGG:
+ case DT_NODE_INLINE:
+ case DT_NODE_PROBE:
+ idp = dnp->dn_ident;
+ continue;
+ }
+
+ if (dt_node_is_dynamic(dnp))
+ idp = dnp->dn_ident;
+ else
+ break;
+ }
+
+ return (idp);
+}
+
+size_t
+dt_ident_size(dt_ident_t *idp)
+{
+ idp = dt_ident_resolve(idp);
+ return (idp->di_ops->di_size(idp));
+}
+
+int
+dt_ident_unref(const dt_ident_t *idp)
+{
+ return (idp->di_gen == yypcb->pcb_hdl->dt_gen &&
+ (idp->di_flags & (DT_IDFLG_REF|DT_IDFLG_MOD|DT_IDFLG_DECL)) == 0);
+}
+
+const char *
+dt_idkind_name(uint_t kind)
+{
+ switch (kind) {
+ case DT_IDENT_ARRAY: return ("associative array");
+ case DT_IDENT_SCALAR: return ("scalar");
+ case DT_IDENT_PTR: return ("pointer");
+ case DT_IDENT_FUNC: return ("function");
+ case DT_IDENT_AGG: return ("aggregation");
+ case DT_IDENT_AGGFUNC: return ("aggregating function");
+ case DT_IDENT_ACTFUNC: return ("tracing function");
+ case DT_IDENT_XLSOU: return ("translated data");
+ case DT_IDENT_XLPTR: return ("pointer to translated data");
+ case DT_IDENT_SYMBOL: return ("external symbol reference");
+ case DT_IDENT_ENUM: return ("enumerator");
+ case DT_IDENT_PRAGAT: return ("#pragma attributes");
+ case DT_IDENT_PRAGBN: return ("#pragma binding");
+ case DT_IDENT_PROBE: return ("probe definition");
+ default: return ("<?>");
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.h
new file mode 100644
index 00000000..367ed5e7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.h
@@ -0,0 +1,185 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_IDENT_H
+#define _DT_IDENT_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <libctf.h>
+#include <dtrace.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dt_list.h>
+
+struct dt_node;
+struct dt_ident;
+struct dt_idhash;
+struct dt_irlist;
+struct dt_regset;
+
+typedef struct dt_idsig {
+ int dis_varargs; /* argument index of start of varargs (or -1) */
+ int dis_optargs; /* argument index of start of optargs (or -1) */
+ int dis_argc; /* number of types in this signature */
+ struct dt_node *dis_args; /* array of nodes representing formal types */
+ uint64_t dis_auxinfo; /* auxiliary signature information, if any */
+} dt_idsig_t;
+
+typedef struct dt_idnode {
+ struct dt_node *din_list; /* allocation list for parse tree nodes */
+ struct dt_node *din_root; /* root of this identifier's parse tree */
+ struct dt_idhash *din_hash; /* identifiers private to this subtree */
+ struct dt_ident **din_argv; /* identifiers in din_hash for arguments */
+ int din_argc; /* length of din_argv[] array */
+} dt_idnode_t;
+
+typedef struct dt_idops {
+ void (*di_cook)(struct dt_node *, struct dt_ident *,
+ int, struct dt_node *);
+ void (*di_dtor)(struct dt_ident *);
+ size_t (*di_size)(struct dt_ident *);
+} dt_idops_t;
+
+typedef struct dt_ident {
+ char *di_name; /* identifier name */
+ ushort_t di_kind; /* identifier kind (see below) */
+ ushort_t di_flags; /* identifier flags (see below) */
+ uint_t di_id; /* variable or subr id (see <sys/dtrace.h>) */
+ dtrace_attribute_t di_attr; /* identifier stability attributes */
+ uint_t di_vers; /* identifier version number (dt_version_t) */
+ const dt_idops_t *di_ops; /* identifier's class-specific ops vector */
+ void *di_iarg; /* initial argument pointer for ops vector */
+ void *di_data; /* private data pointer for ops vector */
+ ctf_file_t *di_ctfp; /* CTF container for the variable data type */
+ ctf_id_t di_type; /* CTF identifier for the variable data type */
+ struct dt_ident *di_next; /* pointer to next ident in hash chain */
+ ulong_t di_gen; /* generation number (pass that created me) */
+ int di_lineno; /* line number that defined this identifier */
+} dt_ident_t;
+
+#define DT_IDENT_ARRAY 0 /* identifier is an array variable */
+#define DT_IDENT_SCALAR 1 /* identifier is a scalar variable */
+#define DT_IDENT_PTR 2 /* identifier is a magic pointer */
+#define DT_IDENT_FUNC 3 /* identifier is a built-in function */
+#define DT_IDENT_AGG 4 /* identifier is an aggregation */
+#define DT_IDENT_AGGFUNC 5 /* identifier is an aggregating function */
+#define DT_IDENT_ACTFUNC 6 /* identifier is an action function */
+#define DT_IDENT_XLSOU 7 /* identifier is a translated struct or union */
+#define DT_IDENT_XLPTR 8 /* identifier is a translated pointer */
+#define DT_IDENT_SYMBOL 9 /* identifier is an external symbol */
+#define DT_IDENT_ENUM 10 /* identifier is an enumerator */
+#define DT_IDENT_PRAGAT 11 /* identifier is #pragma attributes */
+#define DT_IDENT_PRAGBN 12 /* identifier is #pragma binding */
+#define DT_IDENT_PROBE 13 /* identifier is a probe definition */
+
+#define DT_IDFLG_TLS 0x0001 /* variable is thread-local storage */
+#define DT_IDFLG_LOCAL 0x0002 /* variable is local storage */
+#define DT_IDFLG_WRITE 0x0004 /* variable is writable (can be modified) */
+#define DT_IDFLG_INLINE 0x0008 /* variable is an inline definition */
+#define DT_IDFLG_REF 0x0010 /* variable is referenced by this program */
+#define DT_IDFLG_MOD 0x0020 /* variable is modified by this program */
+#define DT_IDFLG_DIFR 0x0040 /* variable is referenced by current DIFO */
+#define DT_IDFLG_DIFW 0x0080 /* variable is modified by current DIFO */
+#define DT_IDFLG_CGREG 0x0100 /* variable is inlined by code generator */
+#define DT_IDFLG_USER 0x0200 /* variable is associated with userland */
+#define DT_IDFLG_PRIM 0x0400 /* variable is associated with primary object */
+#define DT_IDFLG_DECL 0x0800 /* variable is associated with explicit decl */
+#define DT_IDFLG_ORPHAN 0x1000 /* variable is in a dt_node and not dt_idhash */
+
+typedef struct dt_idhash {
+ dt_list_t dh_list; /* list prev/next pointers for dt_idstack */
+ const char *dh_name; /* name of this hash table */
+ void (*dh_defer)(struct dt_idhash *, dt_ident_t *); /* defer callback */
+ const dt_ident_t *dh_tmpl; /* template for initial ident population */
+ uint_t dh_nextid; /* next id to be returned by idhash_nextid() */
+ uint_t dh_minid; /* min id to be returned by idhash_nextid() */
+ uint_t dh_maxid; /* max id to be returned by idhash_nextid() */
+ ulong_t dh_nelems; /* number of identifiers in hash table */
+ ulong_t dh_hashsz; /* number of entries in dh_buckets array */
+ dt_ident_t *dh_hash[1]; /* array of hash table bucket pointers */
+} dt_idhash_t;
+
+typedef struct dt_idstack {
+ dt_list_t dids_list; /* list meta-data for dt_idhash_t stack */
+} dt_idstack_t;
+
+extern const dt_idops_t dt_idops_assc; /* associative array or aggregation */
+extern const dt_idops_t dt_idops_func; /* function call built-in */
+extern const dt_idops_t dt_idops_args; /* args[] built-in */
+extern const dt_idops_t dt_idops_regs; /* regs[]/uregs[] built-in */
+extern const dt_idops_t dt_idops_type; /* predefined type name string */
+extern const dt_idops_t dt_idops_thaw; /* prefrozen type identifier */
+extern const dt_idops_t dt_idops_inline; /* inline variable */
+extern const dt_idops_t dt_idops_probe; /* probe definition */
+
+extern dt_idhash_t *dt_idhash_create(const char *, const dt_ident_t *,
+ uint_t, uint_t);
+extern void dt_idhash_destroy(dt_idhash_t *);
+extern void dt_idhash_update(dt_idhash_t *);
+extern dt_ident_t *dt_idhash_lookup(dt_idhash_t *, const char *);
+extern int dt_idhash_nextid(dt_idhash_t *, uint_t *);
+extern ulong_t dt_idhash_size(const dt_idhash_t *);
+extern const char *dt_idhash_name(const dt_idhash_t *);
+
+extern dt_ident_t *dt_idhash_insert(dt_idhash_t *, const char *, ushort_t,
+ ushort_t, uint_t, dtrace_attribute_t, uint_t,
+ const dt_idops_t *, void *, ulong_t);
+
+extern void dt_idhash_xinsert(dt_idhash_t *, dt_ident_t *);
+extern void dt_idhash_delete(dt_idhash_t *, dt_ident_t *);
+
+typedef int dt_idhash_f(dt_idhash_t *, dt_ident_t *, void *);
+extern int dt_idhash_iter(dt_idhash_t *, dt_idhash_f *, void *);
+
+extern dt_ident_t *dt_idstack_lookup(dt_idstack_t *, const char *);
+extern void dt_idstack_push(dt_idstack_t *, dt_idhash_t *);
+extern void dt_idstack_pop(dt_idstack_t *, dt_idhash_t *);
+
+extern dt_ident_t *dt_ident_create(const char *, ushort_t, ushort_t, uint_t,
+ dtrace_attribute_t, uint_t, const dt_idops_t *, void *, ulong_t);
+extern void dt_ident_destroy(dt_ident_t *);
+extern void dt_ident_morph(dt_ident_t *, ushort_t, const dt_idops_t *, void *);
+extern dtrace_attribute_t dt_ident_cook(struct dt_node *,
+ dt_ident_t *, struct dt_node **);
+
+extern void dt_ident_type_assign(dt_ident_t *, ctf_file_t *, ctf_id_t);
+extern dt_ident_t *dt_ident_resolve(dt_ident_t *);
+extern size_t dt_ident_size(dt_ident_t *);
+extern int dt_ident_unref(const dt_ident_t *);
+
+extern const char *dt_idkind_name(uint_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_IDENT_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_impl.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_impl.h
new file mode 100644
index 00000000..0e40f722
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_impl.h
@@ -0,0 +1,669 @@
+/*
+ * 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 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_IMPL_H
+#define _DT_IMPL_H
+
+#ifndef VBOX
+#include <sys/param.h>
+#include <sys/objfs.h>
+#include <setjmp.h>
+#include <libctf.h>
+#include <dtrace.h>
+#include <gelf.h>
+#include <synch.h>
+#else /* VBOX */
+# include <setjmp.h>
+# include <libctf.h>
+# include <dtrace.h>
+# include <errno.h>
+# include "VBoxDTraceLibCWrappers.h"
+#endif /* VBOX*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dt_parser.h>
+#include <dt_regset.h>
+#include <dt_inttab.h>
+#include <dt_strtab.h>
+#include <dt_ident.h>
+#include <dt_list.h>
+#include <dt_decl.h>
+#include <dt_as.h>
+#include <dt_proc.h>
+#include <dt_dof.h>
+#include <dt_pcb.h>
+
+struct dt_module; /* see below */
+struct dt_pfdict; /* see <dt_printf.h> */
+struct dt_arg; /* see below */
+struct dt_provider; /* see <dt_provider.h> */
+struct dt_xlator; /* see <dt_xlator.h> */
+
+typedef struct dt_intrinsic {
+ const char *din_name; /* string name of the intrinsic type */
+ ctf_encoding_t din_data; /* integer or floating-point CTF encoding */
+ uint_t din_kind; /* CTF type kind to instantiate */
+} dt_intrinsic_t;
+
+typedef struct dt_typedef {
+ const char *dty_src; /* string name of typedef source type */
+ const char *dty_dst; /* string name of typedef destination type */
+} dt_typedef_t;
+
+typedef struct dt_intdesc {
+ const char *did_name; /* string name of the integer type */
+ ctf_file_t *did_ctfp; /* CTF container for this type reference */
+ ctf_id_t did_type; /* CTF type reference for this type */
+ uintmax_t did_limit; /* maximum positive value held by type */
+} dt_intdesc_t;
+
+typedef struct dt_modops {
+ uint_t (*do_syminit)(struct dt_module *);
+ void (*do_symsort)(struct dt_module *);
+ GElf_Sym *(*do_symname)(struct dt_module *,
+ const char *, GElf_Sym *, uint_t *);
+ GElf_Sym *(*do_symaddr)(struct dt_module *,
+ GElf_Addr, GElf_Sym *, uint_t *);
+} dt_modops_t;
+
+typedef struct dt_arg {
+ int da_ndx; /* index of this argument */
+ int da_mapping; /* mapping of argument indices to arguments */
+ ctf_id_t da_type; /* type of argument */
+ ctf_file_t *da_ctfp; /* CTF container for type */
+ dt_ident_t *da_xlator; /* translator, if any */
+ struct dt_arg *da_next; /* next argument */
+} dt_arg_t;
+
+typedef struct dt_sym {
+ uint_t ds_symid; /* id of corresponding symbol */
+ uint_t ds_next; /* index of next element in hash chain */
+} dt_sym_t;
+
+typedef struct dt_module {
+ dt_list_t dm_list; /* list forward/back pointers */
+ char dm_name[DTRACE_MODNAMELEN]; /* string name of module */
+ char dm_file[MAXPATHLEN]; /* file path of module (if any) */
+ struct dt_module *dm_next; /* pointer to next module in hash chain */
+ const dt_modops_t *dm_ops; /* pointer to data model's ops vector */
+#ifndef VBOX
+ Elf *dm_elf; /* libelf handle for module object */
+ objfs_info_t dm_info; /* object filesystem private info */
+#endif
+ ctf_sect_t dm_symtab; /* symbol table for module */
+ ctf_sect_t dm_strtab; /* string table for module */
+ ctf_sect_t dm_ctdata; /* CTF data for module */
+ ctf_file_t *dm_ctfp; /* CTF container handle */
+ uint_t *dm_symbuckets; /* symbol table hash buckets (chain indices) */
+ dt_sym_t *dm_symchains; /* symbol table hash chains buffer */
+ void *dm_asmap; /* symbol pointers sorted by value */
+ uint_t dm_symfree; /* index of next free hash element */
+ uint_t dm_nsymbuckets; /* number of elements in bucket array */
+ uint_t dm_nsymelems; /* number of elements in hash table */
+ uint_t dm_asrsv; /* actual reserved size of dm_asmap */
+ uint_t dm_aslen; /* number of entries in dm_asmap */
+ uint_t dm_flags; /* module flags (see below) */
+ int dm_modid; /* modinfo(1M) module identifier */
+ GElf_Addr dm_text_va; /* virtual address of text section */
+ GElf_Xword dm_text_size; /* size in bytes of text section */
+ GElf_Addr dm_data_va; /* virtual address of data section */
+ GElf_Xword dm_data_size; /* size in bytes of data section */
+ GElf_Addr dm_bss_va; /* virtual address of BSS */
+ GElf_Xword dm_bss_size; /* size in bytes of BSS */
+ dt_idhash_t *dm_extern; /* external symbol definitions */
+} dt_module_t;
+
+#define DT_DM_LOADED 0x1 /* module symbol and type data is loaded */
+#define DT_DM_KERNEL 0x2 /* module is associated with a kernel object */
+#define DT_DM_PRIMARY 0x4 /* module is a krtld primary kernel object */
+
+typedef struct dt_provmod {
+ char *dp_name; /* name of provider module */
+ struct dt_provmod *dp_next; /* next module */
+} dt_provmod_t;
+
+typedef struct dt_ahashent {
+ struct dt_ahashent *dtahe_prev; /* prev on hash chain */
+ struct dt_ahashent *dtahe_next; /* next on hash chain */
+ struct dt_ahashent *dtahe_prevall; /* prev on list of all */
+ struct dt_ahashent *dtahe_nextall; /* next on list of all */
+ uint64_t dtahe_hashval; /* hash value */
+ size_t dtahe_size; /* size of data */
+ dtrace_aggdata_t dtahe_data; /* data */
+ void (*dtahe_aggregate)(int64_t *, int64_t *, size_t); /* function */
+} dt_ahashent_t;
+
+typedef struct dt_ahash {
+ dt_ahashent_t **dtah_hash; /* hash table */
+ dt_ahashent_t *dtah_all; /* list of all elements */
+ size_t dtah_size; /* size of hash table */
+} dt_ahash_t;
+
+typedef struct dt_aggregate {
+ dtrace_bufdesc_t dtat_buf; /* buf aggregation snapshot */
+ int dtat_flags; /* aggregate flags */
+ processorid_t dtat_ncpus; /* number of CPUs in aggregate */
+ processorid_t *dtat_cpus; /* CPUs in aggregate */
+ processorid_t dtat_ncpu; /* size of dtat_cpus array */
+ processorid_t dtat_maxcpu; /* maximum number of CPUs */
+ dt_ahash_t dtat_hash; /* aggregate hash table */
+} dt_aggregate_t;
+
+typedef struct dt_print_aggdata {
+ dtrace_hdl_t *dtpa_dtp; /* pointer to libdtrace handle */
+ dtrace_aggvarid_t dtpa_id; /* aggregation variable of interest */
+ FILE *dtpa_fp; /* file pointer */
+ int dtpa_allunprint; /* print only unprinted aggregations */
+} dt_print_aggdata_t;
+
+typedef struct dt_dirpath {
+ dt_list_t dir_list; /* linked-list forward/back pointers */
+ char *dir_path; /* directory pathname */
+} dt_dirpath_t;
+
+typedef struct dt_lib_depend {
+ dt_list_t dtld_deplist; /* linked-list forward/back pointers */
+ char *dtld_library; /* library name */
+ char *dtld_libpath; /* library pathname */
+ uint_t dtld_finish; /* completion time in tsort for lib */
+ uint_t dtld_start; /* starting time in tsort for lib */
+ uint_t dtld_loaded; /* boolean: is this library loaded */
+ dt_list_t dtld_dependencies; /* linked-list of lib dependencies */
+ dt_list_t dtld_dependents; /* linked-list of lib dependents */
+} dt_lib_depend_t;
+
+typedef uint32_t dt_version_t; /* encoded version (see below) */
+
+struct dtrace_hdl {
+ const dtrace_vector_t *dt_vector; /* library vector, if vectored open */
+ void *dt_varg; /* vector argument, if vectored open */
+ dtrace_conf_t dt_conf; /* DTrace driver configuration profile */
+ char dt_errmsg[BUFSIZ]; /* buffer for formatted syntax error msgs */
+ const char *dt_errtag; /* tag used with last call to dt_set_errmsg() */
+ dt_pcb_t *dt_pcb; /* pointer to current parsing control block */
+ ulong_t dt_gen; /* compiler generation number */
+ dt_list_t dt_programs; /* linked list of dtrace_prog_t's */
+ dt_list_t dt_xlators; /* linked list of dt_xlator_t's */
+ struct dt_xlator **dt_xlatormap; /* dt_xlator_t's indexed by dx_id */
+ id_t dt_xlatorid; /* next dt_xlator_t id to assign */
+ dt_ident_t *dt_externs; /* linked list of external symbol identifiers */
+ dt_idhash_t *dt_macros; /* hash table of macro variable identifiers */
+ dt_idhash_t *dt_aggs; /* hash table of aggregation identifiers */
+ dt_idhash_t *dt_globals; /* hash table of global identifiers */
+ dt_idhash_t *dt_tls; /* hash table of thread-local identifiers */
+ dt_list_t dt_modlist; /* linked list of dt_module_t's */
+ dt_module_t **dt_mods; /* hash table of dt_module_t's */
+ uint_t dt_modbuckets; /* number of module hash buckets */
+ uint_t dt_nmods; /* number of modules in hash and list */
+ dt_provmod_t *dt_provmod; /* linked list of provider modules */
+ dt_module_t *dt_exec; /* pointer to executable module */
+ dt_module_t *dt_rtld; /* pointer to run-time linker module */
+ dt_module_t *dt_cdefs; /* pointer to C dynamic type module */
+ dt_module_t *dt_ddefs; /* pointer to D dynamic type module */
+ dt_list_t dt_provlist; /* linked list of dt_provider_t's */
+ struct dt_provider **dt_provs; /* hash table of dt_provider_t's */
+ uint_t dt_provbuckets; /* number of provider hash buckets */
+ uint_t dt_nprovs; /* number of providers in hash and list */
+ dt_proc_hash_t *dt_procs; /* hash table of grabbed process handles */
+ dt_intdesc_t dt_ints[6]; /* cached integer type descriptions */
+ ctf_id_t dt_type_func; /* cached CTF identifier for function type */
+ ctf_id_t dt_type_fptr; /* cached CTF identifier for function pointer */
+ ctf_id_t dt_type_str; /* cached CTF identifier for string type */
+ ctf_id_t dt_type_dyn; /* cached CTF identifier for <DYN> type */
+ ctf_id_t dt_type_stack; /* cached CTF identifier for stack type */
+ ctf_id_t dt_type_symaddr; /* cached CTF identifier for _symaddr type */
+ ctf_id_t dt_type_usymaddr; /* cached CTF ident. for _usymaddr type */
+ size_t dt_maxprobe; /* max enabled probe ID */
+ dtrace_eprobedesc_t **dt_edesc; /* enabled probe descriptions */
+ dtrace_probedesc_t **dt_pdesc; /* probe descriptions for enabled prbs */
+ size_t dt_maxagg; /* max aggregation ID */
+ dtrace_aggdesc_t **dt_aggdesc; /* aggregation descriptions */
+ int dt_maxformat; /* max format ID */
+ void **dt_formats; /* pointer to format array */
+ dt_aggregate_t dt_aggregate; /* aggregate */
+ dtrace_bufdesc_t dt_buf; /* staging buffer */
+ struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */
+ dt_version_t dt_vmax; /* optional ceiling on program API binding */
+ dtrace_attribute_t dt_amin; /* optional floor on program attributes */
+ char *dt_cpp_path; /* pathname of cpp(1) to invoke if needed */
+ char **dt_cpp_argv; /* argument vector for exec'ing cpp(1) */
+ int dt_cpp_argc; /* count of initialized cpp(1) arguments */
+ int dt_cpp_args; /* size of dt_cpp_argv[] array */
+ char *dt_ld_path; /* pathname of ld(1) to invoke if needed */
+ dt_list_t dt_lib_path; /* linked-list forming library search path */
+ uint_t dt_lazyload; /* boolean: set via -xlazyload */
+ uint_t dt_droptags; /* boolean: set via -xdroptags */
+ uint_t dt_active; /* boolean: set once tracing is active */
+ uint_t dt_stopped; /* boolean: set once tracing is stopped */
+ processorid_t dt_beganon; /* CPU that executed BEGIN probe (if any) */
+ processorid_t dt_endedon; /* CPU that executed END probe (if any) */
+ uint_t dt_oflags; /* dtrace open-time options (see dtrace.h) */
+ uint_t dt_cflags; /* dtrace compile-time options (see dtrace.h) */
+ uint_t dt_dflags; /* dtrace link-time options (see dtrace.h) */
+ uint_t dt_prcmode; /* dtrace process create mode (see dt_proc.h) */
+ uint_t dt_linkmode; /* dtrace symbol linking mode (see below) */
+ uint_t dt_linktype; /* dtrace link output file type (see below) */
+ uint_t dt_xlatemode; /* dtrace translator linking mode (see below) */
+ uint_t dt_stdcmode; /* dtrace stdc compatibility mode (see below) */
+ uint_t dt_treedump; /* dtrace tree debug bitmap (see below) */
+ uint64_t dt_options[DTRACEOPT_MAX]; /* dtrace run-time options */
+ int dt_version; /* library version requested by client */
+ int dt_ctferr; /* error resulting from last CTF failure */
+ int dt_errno; /* error resulting from last failed operation */
+ int dt_fd; /* file descriptor for dtrace pseudo-device */
+ int dt_ftfd; /* file descriptor for fasttrap pseudo-device */
+ int dt_fterr; /* saved errno from failed open of dt_ftfd */
+ int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */
+ int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */
+ int dt_stdout_fd; /* file descriptor for saved stdout */
+ dtrace_handle_err_f *dt_errhdlr; /* error handler, if any */
+ void *dt_errarg; /* error handler argument */
+ dtrace_prog_t *dt_errprog; /* error handler program, if any */
+ dtrace_handle_drop_f *dt_drophdlr; /* drop handler, if any */
+ void *dt_droparg; /* drop handler argument */
+ dtrace_handle_proc_f *dt_prochdlr; /* proc handler, if any */
+ void *dt_procarg; /* proc handler argument */
+ dtrace_handle_setopt_f *dt_setopthdlr; /* setopt handler, if any */
+ void *dt_setoptarg; /* setopt handler argument */
+ dtrace_status_t dt_status[2]; /* status cache */
+ int dt_statusgen; /* current status generation */
+ hrtime_t dt_laststatus; /* last status */
+ hrtime_t dt_lastswitch; /* last switch of buffer data */
+ hrtime_t dt_lastagg; /* last snapshot of aggregation data */
+ char *dt_sprintf_buf; /* buffer for dtrace_sprintf() */
+ int dt_sprintf_buflen; /* length of dtrace_sprintf() buffer */
+ const char *dt_filetag; /* default filetag for dt_set_errmsg() */
+ char *dt_buffered_buf; /* buffer for buffered output */
+ size_t dt_buffered_offs; /* current offset into buffered buffer */
+ size_t dt_buffered_size; /* size of buffered buffer */
+ dtrace_handle_buffered_f *dt_bufhdlr; /* buffered handler, if any */
+ void *dt_bufarg; /* buffered handler argument */
+ dt_dof_t dt_dof; /* DOF generation buffers (see dt_dof.c) */
+#ifndef VBOX
+ struct utsname dt_uts; /* uname(2) information for system */
+#endif
+ dt_list_t dt_lib_dep; /* scratch linked-list of lib dependencies */
+ dt_list_t dt_lib_dep_sorted; /* dependency sorted library list */
+};
+
+/*
+ * Values for the user arg of the ECB.
+ */
+#define DT_ECB_DEFAULT 0
+#define DT_ECB_ERROR 1
+
+/*
+ * Values for the dt_linkmode property, which is used by the assembler when
+ * processing external symbol references. User can set using -xlink=<mode>.
+ */
+#define DT_LINK_KERNEL 0 /* kernel syms static, user syms dynamic */
+#define DT_LINK_PRIMARY 1 /* primary kernel syms static, others dynamic */
+#define DT_LINK_DYNAMIC 2 /* all symbols dynamic */
+#define DT_LINK_STATIC 3 /* all symbols static */
+
+/*
+ * Values for the dt_linktype property, which is used by dtrace_program_link()
+ * to determine the type of output file that is desired by the client.
+ */
+#define DT_LTYP_ELF 0 /* produce ELF containing DOF */
+#define DT_LTYP_DOF 1 /* produce stand-alone DOF */
+
+/*
+ * Values for the dt_xlatemode property, which is used to determine whether
+ * references to dynamic translators are permitted. Set using -xlate=<mode>.
+ */
+#define DT_XL_STATIC 0 /* require xlators to be statically defined */
+#define DT_XL_DYNAMIC 1 /* produce references to dynamic translators */
+
+/*
+ * Values for the dt_stdcmode property, which is used by the compiler when
+ * running cpp to determine the presence and setting of the __STDC__ macro.
+ */
+#define DT_STDC_XA 0 /* ISO C + K&R C compat w/o ISO: __STDC__=0 */
+#define DT_STDC_XC 1 /* Strict ISO C: __STDC__=1 */
+#define DT_STDC_XS 2 /* K&R C: __STDC__ not defined */
+#define DT_STDC_XT 3 /* ISO C + K&R C compat with ISO: __STDC__=0 */
+
+/*
+ * Macro to test whether a given pass bit is set in the dt_treedump bit-vector.
+ * If the bit for pass 'p' is set, the D compiler displays the parse tree for
+ * the program by printing it to stderr at the end of compiler pass 'p'.
+ */
+#define DT_TREEDUMP_PASS(dtp, p) ((dtp)->dt_treedump & (1 << ((p) - 1)))
+
+/*
+ * Macros for accessing the cached CTF container and type ID for the common
+ * types "int", "string", and <DYN>, which we need to use frequently in the D
+ * compiler. The DT_INT_* macro relies upon "int" being at index 0 in the
+ * _dtrace_ints_* tables in dt_open.c; the others are also set up there.
+ */
+#define DT_INT_CTFP(dtp) ((dtp)->dt_ints[0].did_ctfp)
+#define DT_INT_TYPE(dtp) ((dtp)->dt_ints[0].did_type)
+
+#define DT_FUNC_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
+#define DT_FUNC_TYPE(dtp) ((dtp)->dt_type_func)
+
+#define DT_FPTR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
+#define DT_FPTR_TYPE(dtp) ((dtp)->dt_type_fptr)
+
+#define DT_STR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
+#define DT_STR_TYPE(dtp) ((dtp)->dt_type_str)
+
+#define DT_DYN_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
+#define DT_DYN_TYPE(dtp) ((dtp)->dt_type_dyn)
+
+#define DT_STACK_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
+#define DT_STACK_TYPE(dtp) ((dtp)->dt_type_stack)
+
+#define DT_SYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
+#define DT_SYMADDR_TYPE(dtp) ((dtp)->dt_type_symaddr)
+
+#define DT_USYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
+#define DT_USYMADDR_TYPE(dtp) ((dtp)->dt_type_usymaddr)
+
+/*
+ * Actions and subroutines are both DT_NODE_FUNC nodes; to avoid confusing
+ * an action for a subroutine (or vice versa), we assure that the DT_ACT_*
+ * constants and the DIF_SUBR_* constants occupy non-overlapping ranges by
+ * starting the DT_ACT_* constants at DIF_SUBR_MAX + 1.
+ */
+#define DT_ACT_BASE DIF_SUBR_MAX + 1
+#define DT_ACT(n) (DT_ACT_BASE + (n))
+
+#define DT_ACT_PRINTF DT_ACT(0) /* printf() action */
+#define DT_ACT_TRACE DT_ACT(1) /* trace() action */
+#define DT_ACT_TRACEMEM DT_ACT(2) /* tracemem() action */
+#define DT_ACT_STACK DT_ACT(3) /* stack() action */
+#define DT_ACT_STOP DT_ACT(4) /* stop() action */
+#define DT_ACT_BREAKPOINT DT_ACT(5) /* breakpoint() action */
+#define DT_ACT_PANIC DT_ACT(6) /* panic() action */
+#define DT_ACT_SPECULATE DT_ACT(7) /* speculate() action */
+#define DT_ACT_COMMIT DT_ACT(8) /* commit() action */
+#define DT_ACT_DISCARD DT_ACT(9) /* discard() action */
+#define DT_ACT_CHILL DT_ACT(10) /* chill() action */
+#define DT_ACT_EXIT DT_ACT(11) /* exit() action */
+#define DT_ACT_USTACK DT_ACT(12) /* ustack() action */
+#define DT_ACT_PRINTA DT_ACT(13) /* printa() action */
+#define DT_ACT_RAISE DT_ACT(14) /* raise() action */
+#define DT_ACT_CLEAR DT_ACT(15) /* clear() action */
+#define DT_ACT_NORMALIZE DT_ACT(16) /* normalize() action */
+#define DT_ACT_DENORMALIZE DT_ACT(17) /* denormalize() action */
+#define DT_ACT_TRUNC DT_ACT(18) /* trunc() action */
+#define DT_ACT_SYSTEM DT_ACT(19) /* system() action */
+#define DT_ACT_JSTACK DT_ACT(20) /* jstack() action */
+#define DT_ACT_FTRUNCATE DT_ACT(21) /* ftruncate() action */
+#define DT_ACT_FREOPEN DT_ACT(22) /* freopen() action */
+#define DT_ACT_SYM DT_ACT(23) /* sym()/func() actions */
+#define DT_ACT_MOD DT_ACT(24) /* mod() action */
+#define DT_ACT_USYM DT_ACT(25) /* usym()/ufunc() actions */
+#define DT_ACT_UMOD DT_ACT(26) /* umod() action */
+#define DT_ACT_UADDR DT_ACT(27) /* uaddr() action */
+#define DT_ACT_SETOPT DT_ACT(28) /* setopt() action */
+
+/*
+ * Sentinel to tell freopen() to restore the saved stdout. This must not
+ * be ever valid for opening for write access via freopen(3C), which of
+ * course, "." never is.
+ */
+#define DT_FREOPEN_RESTORE "."
+
+#define EDT_BASE 1000 /* base value for libdtrace errnos */
+
+enum {
+ EDT_VERSION = EDT_BASE, /* client is requesting unsupported version */
+ EDT_VERSINVAL, /* version string is invalid or overflows */
+ EDT_VERSUNDEF, /* requested API version is not defined */
+ EDT_VERSREDUCED, /* requested API version has been reduced */
+ EDT_CTF, /* libctf called failed (dt_ctferr has more) */
+ EDT_COMPILER, /* error in D program compilation */
+ EDT_NOREG, /* register allocation failure */
+ EDT_NOTUPREG, /* tuple register allocation failure */
+ EDT_NOMEM, /* memory allocation failure */
+ EDT_INT2BIG, /* integer limit exceeded */
+ EDT_STR2BIG, /* string limit exceeded */
+ EDT_NOMOD, /* unknown module name */
+ EDT_NOPROV, /* unknown provider name */
+ EDT_NOPROBE, /* unknown probe name */
+ EDT_NOSYM, /* unknown symbol name */
+ EDT_NOSYMADDR, /* no symbol corresponds to address */
+ EDT_NOTYPE, /* unknown type name */
+ EDT_NOVAR, /* unknown variable name */
+ EDT_NOAGG, /* unknown aggregation name */
+ EDT_BADSCOPE, /* improper use of type name scoping operator */
+ EDT_BADSPEC, /* overspecified probe description */
+ EDT_BADSPCV, /* bad macro variable in probe description */
+ EDT_BADID, /* invalid probe identifier */
+ EDT_NOTLOADED, /* module is not currently loaded */
+ EDT_NOCTF, /* module does not contain any CTF data */
+ EDT_DATAMODEL, /* module and program data models don't match */
+ EDT_DIFVERS, /* library has newer DIF version than driver */
+ EDT_BADAGG, /* unrecognized aggregating action */
+ EDT_FIO, /* file i/o error */
+ EDT_DIFINVAL, /* invalid DIF program */
+ EDT_DIFSIZE, /* invalid DIF size */
+ EDT_DIFFAULT, /* failed to copyin DIF program */
+ EDT_BADPROBE, /* bad probe description */
+ EDT_BADPGLOB, /* bad probe description globbing pattern */
+ EDT_NOSCOPE, /* declaration scope stack underflow */
+ EDT_NODECL, /* declaration stack underflow */
+ EDT_DMISMATCH, /* record list does not match statement */
+ EDT_DOFFSET, /* record data offset error */
+ EDT_DALIGN, /* record data alignment error */
+ EDT_BADOPTNAME, /* invalid dtrace_setopt option name */
+ EDT_BADOPTVAL, /* invalid dtrace_setopt option value */
+ EDT_BADOPTCTX, /* invalid dtrace_setopt option context */
+ EDT_CPPFORK, /* failed to fork preprocessor */
+ EDT_CPPEXEC, /* failed to exec preprocessor */
+ EDT_CPPENT, /* preprocessor not found */
+ EDT_CPPERR, /* unknown preprocessor error */
+ EDT_SYMOFLOW, /* external symbol table overflow */
+ EDT_ACTIVE, /* operation illegal when tracing is active */
+ EDT_DESTRUCTIVE, /* destructive actions not allowed */
+ EDT_NOANON, /* no anonymous tracing state */
+ EDT_ISANON, /* can't claim anon state and enable probes */
+ EDT_ENDTOOBIG, /* END enablings exceed size of prncpl buffer */
+ EDT_NOCONV, /* failed to load type for printf conversion */
+ EDT_BADCONV, /* incomplete printf conversion */
+ EDT_BADERROR, /* invalid library ERROR action */
+ EDT_ERRABORT, /* abort due to error */
+ EDT_DROPABORT, /* abort due to drop */
+ EDT_DIRABORT, /* abort explicitly directed */
+ EDT_BADRVAL, /* invalid return value from callback */
+ EDT_BADNORMAL, /* invalid normalization */
+ EDT_BUFTOOSMALL, /* enabling exceeds size of buffer */
+ EDT_BADTRUNC, /* invalid truncation */
+ EDT_BUSY, /* device busy (active kernel debugger) */
+ EDT_ACCESS, /* insufficient privileges to use DTrace */
+ EDT_NOENT, /* dtrace device not available */
+ EDT_BRICKED, /* abort due to systemic unresponsiveness */
+ EDT_HARDWIRE, /* failed to load hard-wired definitions */
+ EDT_ELFVERSION, /* libelf is out-of-date w.r.t libdtrace */
+ EDT_NOBUFFERED, /* attempt to buffer output without handler */
+ EDT_UNSTABLE, /* description matched unstable set of probes */
+ EDT_BADSETOPT, /* invalid setopt library action */
+ EDT_BADSTACKPC, /* invalid stack program counter size */
+ EDT_BADAGGVAR, /* invalid aggregation variable identifier */
+ EDT_OVERSION, /* client is requesting deprecated version */
+ EDT_ENABLING_ERR /* failed to enable probe */
+};
+
+/*
+ * Interfaces for parsing and comparing DTrace attribute tuples, which describe
+ * stability and architectural binding information. The dtrace_attribute_t
+ * structure and associated constant definitions are found in <sys/dtrace.h>.
+ */
+extern dtrace_attribute_t dt_attr_min(dtrace_attribute_t, dtrace_attribute_t);
+extern dtrace_attribute_t dt_attr_max(dtrace_attribute_t, dtrace_attribute_t);
+extern char *dt_attr_str(dtrace_attribute_t, char *, size_t);
+extern int dt_attr_cmp(dtrace_attribute_t, dtrace_attribute_t);
+
+/*
+ * Interfaces for parsing and handling DTrace version strings. Version binding
+ * is a feature of the D compiler that is handled completely independently of
+ * the DTrace kernel infrastructure, so the definitions are here in libdtrace.
+ * Version strings are compiled into an encoded uint32_t which can be compared
+ * using C comparison operators. Version definitions are found in dt_open.c.
+ */
+#define DT_VERSION_STRMAX 16 /* enough for "255.4095.4095\0" */
+#define DT_VERSION_MAJMAX 0xFF /* maximum major version number */
+#define DT_VERSION_MINMAX 0xFFF /* maximum minor version number */
+#define DT_VERSION_MICMAX 0xFFF /* maximum micro version number */
+
+#define DT_VERSION_NUMBER(M, m, u) \
+ ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF))
+
+#define DT_VERSION_MAJOR(v) (((v) & 0xFF000000) >> 24)
+#define DT_VERSION_MINOR(v) (((v) & 0x00FFF000) >> 12)
+#define DT_VERSION_MICRO(v) ((v) & 0x00000FFF)
+
+extern char *dt_version_num2str(dt_version_t, char *, size_t);
+extern int dt_version_str2num(const char *, dt_version_t *);
+extern int dt_version_defined(dt_version_t);
+
+/*
+ * Miscellaneous internal libdtrace interfaces. The definitions below are for
+ * libdtrace routines that do not yet merit their own separate header file.
+ */
+extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *);
+extern char *dt_cpp_pop_arg(dtrace_hdl_t *);
+
+extern int dt_set_errno(dtrace_hdl_t *, int);
+extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *,
+ const char *, int, const char *, va_list);
+
+extern int dt_ioctl(dtrace_hdl_t *, int, void *);
+extern int dt_status(dtrace_hdl_t *, processorid_t);
+extern long dt_sysconf(dtrace_hdl_t *, int);
+extern ssize_t dt_write(dtrace_hdl_t *, int, const void *, size_t);
+extern int dt_printf(dtrace_hdl_t *, FILE *, const char *, ...);
+
+extern void *dt_zalloc(dtrace_hdl_t *, size_t);
+extern void *dt_alloc(dtrace_hdl_t *, size_t);
+extern void dt_free(dtrace_hdl_t *, void *);
+extern void dt_difo_free(dtrace_hdl_t *, dtrace_difo_t *);
+
+extern int dt_gmatch(const char *, const char *);
+extern char *dt_basename(char *);
+
+extern ulong_t dt_popc(ulong_t);
+extern ulong_t dt_popcb(const ulong_t *, ulong_t);
+
+extern int dt_buffered_enable(dtrace_hdl_t *);
+extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *,
+ const dtrace_recdesc_t *, const dtrace_aggdata_t *, uint32_t flags);
+extern void dt_buffered_disable(dtrace_hdl_t *);
+extern void dt_buffered_destroy(dtrace_hdl_t *);
+
+extern uint64_t dt_stddev(uint64_t *, uint64_t);
+
+extern int dt_options_load(dtrace_hdl_t *);
+
+extern void dt_dprintf(const char *, ...);
+
+extern void dt_setcontext(dtrace_hdl_t *, dtrace_probedesc_t *);
+extern void dt_endcontext(dtrace_hdl_t *);
+
+extern void dt_pragma(dt_node_t *);
+extern int dt_reduce(dtrace_hdl_t *, dt_version_t);
+extern void dt_cg(dt_pcb_t *, dt_node_t *);
+extern dtrace_difo_t *dt_as(dt_pcb_t *);
+extern void dt_dis(const dtrace_difo_t *, FILE *);
+
+extern int dt_aggregate_go(dtrace_hdl_t *);
+extern int dt_aggregate_init(dtrace_hdl_t *);
+extern void dt_aggregate_destroy(dtrace_hdl_t *);
+
+extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t,
+ dtrace_eprobedesc_t **, dtrace_probedesc_t **);
+extern void dt_epid_destroy(dtrace_hdl_t *);
+extern int dt_aggid_lookup(dtrace_hdl_t *, dtrace_aggid_t, dtrace_aggdesc_t **);
+extern void dt_aggid_destroy(dtrace_hdl_t *);
+
+extern void *dt_format_lookup(dtrace_hdl_t *, int);
+extern void dt_format_destroy(dtrace_hdl_t *);
+
+extern int dt_print_quantize(dtrace_hdl_t *, FILE *,
+ const void *, size_t, uint64_t);
+extern int dt_print_lquantize(dtrace_hdl_t *, FILE *,
+ const void *, size_t, uint64_t);
+extern int dt_print_agg(const dtrace_aggdata_t *, void *);
+
+extern int dt_handle(dtrace_hdl_t *, dtrace_probedata_t *);
+extern int dt_handle_liberr(dtrace_hdl_t *,
+ const dtrace_probedata_t *, const char *);
+extern int dt_handle_cpudrop(dtrace_hdl_t *, processorid_t,
+ dtrace_dropkind_t, uint64_t);
+extern int dt_handle_status(dtrace_hdl_t *,
+ dtrace_status_t *, dtrace_status_t *);
+extern int dt_handle_setopt(dtrace_hdl_t *, dtrace_setoptdata_t *);
+
+extern int dt_lib_depend_add(dtrace_hdl_t *, dt_list_t *, const char *);
+extern dt_lib_depend_t *dt_lib_depend_lookup(dt_list_t *, const char *);
+
+extern dt_pcb_t *yypcb; /* pointer to current parser control block */
+extern char yyintprefix; /* int token prefix for macros (+/-) */
+extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */
+extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */
+extern char yytext[]; /* lex input buffer */
+extern int yylineno; /* lex line number */
+extern int yydebug; /* lex debugging */
+extern dt_node_t *yypragma; /* lex token list for control lines */
+#ifdef VBOX
+extern int yylex(void);
+#endif
+
+extern const dtrace_attribute_t _dtrace_maxattr; /* maximum attributes */
+extern const dtrace_attribute_t _dtrace_defattr; /* default attributes */
+extern const dtrace_attribute_t _dtrace_symattr; /* symbol ref attributes */
+extern const dtrace_attribute_t _dtrace_typattr; /* type ref attributes */
+extern const dtrace_attribute_t _dtrace_prvattr; /* provider attributes */
+extern const dtrace_pattr_t _dtrace_prvdesc; /* provider attribute bundle */
+
+extern const dt_version_t _dtrace_versions[]; /* array of valid versions */
+extern const char *const _dtrace_version; /* current version string */
+
+extern int _dtrace_strbuckets; /* number of hash buckets for strings */
+extern int _dtrace_intbuckets; /* number of hash buckets for ints */
+extern uint_t _dtrace_stkindent; /* default indent for stack/ustack */
+extern uint_t _dtrace_pidbuckets; /* number of hash buckets for pids */
+extern uint_t _dtrace_pidlrulim; /* number of proc handles to cache */
+extern int _dtrace_debug; /* debugging messages enabled */
+extern size_t _dtrace_bufsize; /* default dt_buf_create() size */
+extern int _dtrace_argmax; /* default maximum probe arguments */
+
+extern const char *_dtrace_libdir; /* default library directory */
+extern const char *_dtrace_moddir; /* default kernel module directory */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_IMPL_H */
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.c
new file mode 100644
index 00000000..9055f439
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.c
@@ -0,0 +1,117 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <assert.h>
+#endif
+
+#include <dt_inttab.h>
+#include <dt_impl.h>
+
+dt_inttab_t *
+dt_inttab_create(dtrace_hdl_t *dtp)
+{
+ uint_t len = _dtrace_intbuckets;
+ dt_inttab_t *ip;
+
+ assert((len & (len - 1)) == 0);
+
+ if ((ip = dt_zalloc(dtp, sizeof (dt_inttab_t))) == NULL ||
+ (ip->int_hash = dt_zalloc(dtp, sizeof (void *) * len)) == NULL) {
+ dt_free(dtp, ip);
+ return (NULL);
+ }
+
+ ip->int_hdl = dtp;
+ ip->int_hashlen = len;
+
+ return (ip);
+}
+
+void
+dt_inttab_destroy(dt_inttab_t *ip)
+{
+ dt_inthash_t *hp, *np;
+
+ for (hp = ip->int_head; hp != NULL; hp = np) {
+ np = hp->inh_next;
+ dt_free(ip->int_hdl, hp);
+ }
+
+ dt_free(ip->int_hdl, ip->int_hash);
+ dt_free(ip->int_hdl, ip);
+}
+
+int
+dt_inttab_insert(dt_inttab_t *ip, uint64_t value, uint_t flags)
+{
+ uint_t h = value & (ip->int_hashlen - 1);
+ dt_inthash_t *hp;
+
+ if (flags & DT_INT_SHARED) {
+ for (hp = ip->int_hash[h]; hp != NULL; hp = hp->inh_hash) {
+ if (hp->inh_value == value && hp->inh_flags == flags)
+ return (hp->inh_index);
+ }
+ }
+
+ if ((hp = dt_alloc(ip->int_hdl, sizeof (dt_inthash_t))) == NULL)
+ return (-1);
+
+ hp->inh_hash = ip->int_hash[h];
+ hp->inh_next = NULL;
+ hp->inh_value = value;
+ hp->inh_index = ip->int_index++;
+ hp->inh_flags = flags;
+
+ ip->int_hash[h] = hp;
+ ip->int_nelems++;
+
+ if (ip->int_head == NULL)
+ ip->int_head = hp;
+ else
+ ip->int_tail->inh_next = hp;
+
+ ip->int_tail = hp;
+ return (hp->inh_index);
+}
+
+uint_t
+dt_inttab_size(const dt_inttab_t *ip)
+{
+ return (ip->int_nelems);
+}
+
+void
+dt_inttab_write(const dt_inttab_t *ip, uint64_t *dst)
+{
+ const dt_inthash_t *hp;
+
+ for (hp = ip->int_head; hp != NULL; hp = hp->inh_next)
+ *dst++ = hp->inh_value;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.h
new file mode 100644
index 00000000..08daa4bb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.h
@@ -0,0 +1,71 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_INTTAB_H
+#define _DT_INTTAB_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <dtrace.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dt_inthash {
+ struct dt_inthash *inh_hash; /* next dt_inthash in hash chain */
+ struct dt_inthash *inh_next; /* next dt_inthash in output table */
+ uint64_t inh_value; /* value associated with this element */
+ uint_t inh_index; /* index associated with this element */
+ uint_t inh_flags; /* flags (see below) */
+} dt_inthash_t;
+
+typedef struct dt_inttab {
+ dtrace_hdl_t *int_hdl; /* pointer back to library handle */
+ dt_inthash_t **int_hash; /* array of hash buckets */
+ uint_t int_hashlen; /* size of hash bucket array */
+ uint_t int_nelems; /* number of elements hashed */
+ dt_inthash_t *int_head; /* head of table in index order */
+ dt_inthash_t *int_tail; /* tail of table in index order */
+ uint_t int_index; /* next index to hand out */
+} dt_inttab_t;
+
+#define DT_INT_PRIVATE 0 /* only a single ref for this entry */
+#define DT_INT_SHARED 1 /* multiple refs can share entry */
+
+extern dt_inttab_t *dt_inttab_create(dtrace_hdl_t *);
+extern void dt_inttab_destroy(dt_inttab_t *);
+extern int dt_inttab_insert(dt_inttab_t *, uint64_t, uint_t);
+extern uint_t dt_inttab_size(const dt_inttab_t *);
+extern void dt_inttab_write(const dt_inttab_t *, uint64_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_INTTAB_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_lex.l b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_lex.l
new file mode 100644
index 00000000..39228108
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_lex.l
@@ -0,0 +1,931 @@
+%{
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#else /* VBOX */
+# ifdef RT_OS_WINDOWS /* No unistd.h on windows, avoid redef warnings of the [U]INTxx_MAX defines caused by no inttypes.h/stdint.h. */
+# define YY_NO_UNISTD_H
+# undef INT8_MIN
+# undef INT16_MIN
+# undef INT32_MIN
+# undef INT64_MIN
+# undef INT8_MAX
+# undef INT16_MAX
+# undef INT32_MAX
+# undef INT64_MAX
+# undef UINT8_MAX
+# undef UINT16_MAX
+# undef UINT32_MAX
+# undef UINT64_MAX
+# endif
+# ifdef _MSC_VER
+# pragma warning(disable:4668 4131 4255)
+# endif
+# ifdef __GNUC__
+# if ((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x40002
+# pragma GCC diagnostic ignored "-Wunused-function"
+# endif
+# endif
+# include <iprt/ctype.h>
+# include <iprt/err.h>
+# define isdigit(a_ch) RT_C_IS_DIGIT(a_ch)
+# ifdef _MSC_VER
+# include <io.h> /* win_flex: isatty */
+# endif
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_grammar.h>
+#include <dt_parser.h>
+#include <dt_string.h>
+
+#ifndef USING_FLEX
+/*
+ * We need to undefine lex's input and unput macros so that references to these
+ * call the functions provided at the end of this source file.
+ */
+#undef input
+#undef unput
+#else /* USING_FLEX */
+# define YY_INPUT(buf, result, max_size) \
+ do { \
+ if (yypcb->pcb_fileptr != NULL) { \
+ result = (int)fread(buf, 1, max_size, yypcb->pcb_fileptr); \
+ if (!result && ferror(yypcb->pcb_fileptr)) \
+ longjmp(yypcb->pcb_jmpbuf, EDT_FIO); \
+ /*YY_FATAL_ERROR("input in flex scanner failed");*/ \
+ } else { \
+ size_t off = yypcb->pcb_strptr - yypcb->pcb_string; \
+ if (off < yypcb->pcb_strlen) { \
+ off = yypcb->pcb_strlen - off; \
+ result = max_size; \
+ if ((size_t)result > off) \
+ result = (int)off; \
+ memcpy(buf, yypcb->pcb_strptr, result); \
+ yypcb->pcb_strptr += result; \
+ /*fprintf(stderr, "yy_input -> %d '%.*s'\n", result, result, buf);*/ \
+ } else { \
+ buf[0] = '\0'; \
+ result = 0; \
+ /*fprintf(stderr, "yy_input -> %d\n", result);*/ \
+ } \
+ } \
+ } while (0)
+#endif /* USING_FLEX */
+
+static int id_or_type(const char *);
+#ifndef USING_FLEX
+static int input(void);
+static void unput(int);
+#endif
+
+/*
+ * We first define a set of labeled states for use in the D lexer and then a
+ * set of regular expressions to simplify things below. The lexer states are:
+ *
+ * S0 - D program clause and expression lexing
+ * S1 - D comments (i.e. skip everything until end of comment)
+ * S2 - D program outer scope (probe specifiers and declarations)
+ * S3 - D control line parsing (i.e. after ^# is seen but before \n)
+ * S4 - D control line scan (locate control directives only and invoke S3)
+ */
+%}
+
+%e 1500 /* maximum nodes */
+%p 3700 /* maximum positions */
+%n 600 /* maximum states */
+
+%s S0 S1 S2 S3 S4
+
+RGX_AGG "@"[a-zA-Z_][0-9a-zA-Z_]*
+RGX_PSPEC [-$:a-zA-Z_.?*\\\[\]!][-$:0-9a-zA-Z_.`?*\\\[\]!]*
+RGX_IDENT [a-zA-Z_`][0-9a-zA-Z_`]*
+RGX_INT ([0-9]+|0[xX][0-9A-Fa-f]+)[uU]?[lL]?[lL]?
+RGX_FP ([0-9]+("."?)[0-9]*|"."[0-9]+)((e|E)("+"|-)?[0-9]+)?[fFlL]?
+RGX_WS [\f\n\r\t\v ]
+RGX_STR ([^"\\\n]|\\[^"\n]|\\\")*
+RGX_CHR ([^'\\\n]|\\[^'\n]|\\')*
+RGX_INTERP ^[\f\t\v ]*#!.*
+RGX_CTL ^[\f\t\v ]*#
+
+%%
+
+%{
+
+/*
+ * We insert a special prologue into yylex() itself: if the pcb contains a
+ * context token, we return that prior to running the normal lexer. This
+ * allows libdtrace to force yacc into one of our three parsing contexts: D
+ * expression (DT_CTX_DEXPR), D program (DT_CTX_DPROG) or D type (DT_CTX_DTYPE).
+ * Once the token is returned, we clear it so this only happens once.
+ */
+if (yypcb->pcb_token != 0) {
+ int tok = yypcb->pcb_token;
+ yypcb->pcb_token = 0;
+ return (tok);
+}
+
+%}
+
+<S0>auto return (DT_KEY_AUTO);
+<S0>break return (DT_KEY_BREAK);
+<S0>case return (DT_KEY_CASE);
+<S0>char return (DT_KEY_CHAR);
+<S0>const return (DT_KEY_CONST);
+<S0>continue return (DT_KEY_CONTINUE);
+<S0>counter return (DT_KEY_COUNTER);
+<S0>default return (DT_KEY_DEFAULT);
+<S0>do return (DT_KEY_DO);
+<S0>double return (DT_KEY_DOUBLE);
+<S0>else return (DT_KEY_ELSE);
+<S0>enum return (DT_KEY_ENUM);
+<S0>extern return (DT_KEY_EXTERN);
+<S0>float return (DT_KEY_FLOAT);
+<S0>for return (DT_KEY_FOR);
+<S0>goto return (DT_KEY_GOTO);
+<S0>if return (DT_KEY_IF);
+<S0>import return (DT_KEY_IMPORT);
+<S0>inline return (DT_KEY_INLINE);
+<S0>int return (DT_KEY_INT);
+<S0>long return (DT_KEY_LONG);
+<S0>offsetof return (DT_TOK_OFFSETOF);
+<S0>probe return (DT_KEY_PROBE);
+<S0>provider return (DT_KEY_PROVIDER);
+<S0>register return (DT_KEY_REGISTER);
+<S0>restrict return (DT_KEY_RESTRICT);
+<S0>return return (DT_KEY_RETURN);
+<S0>self return (DT_KEY_SELF);
+<S0>short return (DT_KEY_SHORT);
+<S0>signed return (DT_KEY_SIGNED);
+<S0>sizeof return (DT_TOK_SIZEOF);
+<S0>static return (DT_KEY_STATIC);
+<S0>string return (DT_KEY_STRING);
+<S0>stringof return (DT_TOK_STRINGOF);
+<S0>struct return (DT_KEY_STRUCT);
+<S0>switch return (DT_KEY_SWITCH);
+<S0>this return (DT_KEY_THIS);
+<S0>translator return (DT_KEY_XLATOR);
+<S0>typedef return (DT_KEY_TYPEDEF);
+<S0>union return (DT_KEY_UNION);
+<S0>unsigned return (DT_KEY_UNSIGNED);
+<S0>void return (DT_KEY_VOID);
+<S0>volatile return (DT_KEY_VOLATILE);
+<S0>while return (DT_KEY_WHILE);
+<S0>xlate return (DT_TOK_XLATE);
+
+<S2>auto { yybegin(YYS_EXPR); return (DT_KEY_AUTO); }
+<S2>char { yybegin(YYS_EXPR); return (DT_KEY_CHAR); }
+<S2>const { yybegin(YYS_EXPR); return (DT_KEY_CONST); }
+<S2>counter { yybegin(YYS_DEFINE); return (DT_KEY_COUNTER); }
+<S2>double { yybegin(YYS_EXPR); return (DT_KEY_DOUBLE); }
+<S2>enum { yybegin(YYS_EXPR); return (DT_KEY_ENUM); }
+<S2>extern { yybegin(YYS_EXPR); return (DT_KEY_EXTERN); }
+<S2>float { yybegin(YYS_EXPR); return (DT_KEY_FLOAT); }
+<S2>import { yybegin(YYS_EXPR); return (DT_KEY_IMPORT); }
+<S2>inline { yybegin(YYS_DEFINE); return (DT_KEY_INLINE); }
+<S2>int { yybegin(YYS_EXPR); return (DT_KEY_INT); }
+<S2>long { yybegin(YYS_EXPR); return (DT_KEY_LONG); }
+<S2>provider { yybegin(YYS_DEFINE); return (DT_KEY_PROVIDER); }
+<S2>register { yybegin(YYS_EXPR); return (DT_KEY_REGISTER); }
+<S2>restrict { yybegin(YYS_EXPR); return (DT_KEY_RESTRICT); }
+<S2>self { yybegin(YYS_EXPR); return (DT_KEY_SELF); }
+<S2>short { yybegin(YYS_EXPR); return (DT_KEY_SHORT); }
+<S2>signed { yybegin(YYS_EXPR); return (DT_KEY_SIGNED); }
+<S2>static { yybegin(YYS_EXPR); return (DT_KEY_STATIC); }
+<S2>string { yybegin(YYS_EXPR); return (DT_KEY_STRING); }
+<S2>struct { yybegin(YYS_EXPR); return (DT_KEY_STRUCT); }
+<S2>this { yybegin(YYS_EXPR); return (DT_KEY_THIS); }
+<S2>translator { yybegin(YYS_DEFINE); return (DT_KEY_XLATOR); }
+<S2>typedef { yybegin(YYS_EXPR); return (DT_KEY_TYPEDEF); }
+<S2>union { yybegin(YYS_EXPR); return (DT_KEY_UNION); }
+<S2>unsigned { yybegin(YYS_EXPR); return (DT_KEY_UNSIGNED); }
+<S2>void { yybegin(YYS_EXPR); return (DT_KEY_VOID); }
+<S2>volatile { yybegin(YYS_EXPR); return (DT_KEY_VOLATILE); }
+
+<S0>"$$"[0-9]+ {
+ int i = atoi(yytext + 2);
+ char *v = "";
+
+ /*
+ * A macro argument reference substitutes the text of
+ * an argument in place of the current token. When we
+ * see $$<d> we fetch the saved string from pcb_sargv
+ * (or use the default argument if the option has been
+ * set and the argument hasn't been specified) and
+ * return a token corresponding to this string.
+ */
+ if (i < 0 || (i >= yypcb->pcb_sargc &&
+ !(yypcb->pcb_cflags & DTRACE_C_DEFARG))) {
+ xyerror(D_MACRO_UNDEF, "macro argument %s is "
+ "not defined\n", yytext);
+ }
+
+ if (i < yypcb->pcb_sargc) {
+ v = yypcb->pcb_sargv[i]; /* get val from pcb */
+ yypcb->pcb_sflagv[i] |= DT_IDFLG_REF;
+ }
+
+ if ((yylval.l_str = strdup(v)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) stresc2chr(yylval.l_str);
+ return (DT_TOK_STRING);
+ }
+
+<S0>"$"[0-9]+ {
+ int i = atoi(yytext + 1);
+ char *p, *v = "0";
+
+ /*
+ * A macro argument reference substitutes the text of
+ * one identifier or integer pattern for another. When
+ * we see $<d> we fetch the saved string from pcb_sargv
+ * (or use the default argument if the option has been
+ * set and the argument hasn't been specified) and
+ * return a token corresponding to this string.
+ */
+ if (i < 0 || (i >= yypcb->pcb_sargc &&
+ !(yypcb->pcb_cflags & DTRACE_C_DEFARG))) {
+ xyerror(D_MACRO_UNDEF, "macro argument %s is "
+ "not defined\n", yytext);
+ }
+
+ if (i < yypcb->pcb_sargc) {
+ v = yypcb->pcb_sargv[i]; /* get val from pcb */
+ yypcb->pcb_sflagv[i] |= DT_IDFLG_REF;
+ }
+
+ /*
+ * If the macro text is not a valid integer or ident,
+ * then we treat it as a string. The string may be
+ * optionally enclosed in quotes, which we strip.
+ */
+ if (strbadidnum(v)) {
+ size_t len = strlen(v);
+
+ if (len != 1 && *v == '"' && v[len - 1] == '"')
+ yylval.l_str = strndup(v + 1, len - 2);
+ else
+ yylval.l_str = strndup(v, len);
+
+ if (yylval.l_str == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) stresc2chr(yylval.l_str);
+ return (DT_TOK_STRING);
+ }
+
+ /*
+ * If the macro text is not a string an begins with a
+ * digit or a +/- sign, process it as an integer token.
+ */
+ if (isdigit(v[0]) || v[0] == '-' || v[0] == '+') {
+#ifdef VBOX
+ int rc;
+ uint64_t uTmp = 0;
+#endif
+ if (isdigit(v[0]))
+ yyintprefix = 0;
+ else
+ yyintprefix = *v++;
+
+#ifndef VBOX
+ errno = 0;
+ yylval.l_int = strtoull(v, &p, 0);
+ (void) strncpy(yyintsuffix, p,
+ sizeof (yyintsuffix));
+ yyintdecimal = *v != '0';
+ if (errno == ERANGE)
+#else
+ rc = RTStrToUInt64Ex(v, &p, 0, &uTmp);
+ yylval.l_int = uTmp;
+ RTStrCopy(yyintsuffix, sizeof(yyintsuffix), p);
+ yyintdecimal = *v != '0';
+ if (rc == VWRN_NUMBER_TOO_BIG || rc == VWRN_NEGATIVE_UNSIGNED)
+#endif
+ xyerror(D_MACRO_OFLOW, "macro argument"
+ " %s constant %s results in integer"
+ " overflow\n", yytext, v);
+
+ return (DT_TOK_INT);
+ }
+
+ return (id_or_type(v));
+ }
+
+<S0>"$$"{RGX_IDENT} {
+ dt_ident_t *idp = dt_idhash_lookup(
+ yypcb->pcb_hdl->dt_macros, yytext + 2);
+
+ char s[16]; /* enough for UINT_MAX + \0 */
+
+ if (idp == NULL) {
+ xyerror(D_MACRO_UNDEF, "macro variable %s "
+ "is not defined\n", yytext);
+ }
+
+ /*
+ * For the moment, all current macro variables are of
+ * type id_t (refer to dtrace_update() for details).
+ */
+ (void) snprintf(s, sizeof (s), "%u", idp->di_id);
+ if ((yylval.l_str = strdup(s)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ return (DT_TOK_STRING);
+ }
+
+<S0>"$"{RGX_IDENT} {
+ dt_ident_t *idp = dt_idhash_lookup(
+ yypcb->pcb_hdl->dt_macros, yytext + 1);
+
+ if (idp == NULL) {
+ xyerror(D_MACRO_UNDEF, "macro variable %s "
+ "is not defined\n", yytext);
+ }
+
+ /*
+ * For the moment, all current macro variables are of
+ * type id_t (refer to dtrace_update() for details).
+ */
+ yylval.l_int = (intmax_t)(int)idp->di_id;
+ yyintprefix = 0;
+ yyintsuffix[0] = '\0';
+ yyintdecimal = 1;
+
+ return (DT_TOK_INT);
+ }
+
+<S0>{RGX_IDENT} {
+ return (id_or_type(yytext));
+ }
+
+<S0>{RGX_AGG} {
+ if ((yylval.l_str = strdup(yytext)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ return (DT_TOK_AGG);
+ }
+
+<S0>"@" {
+ if ((yylval.l_str = strdup("@_")) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ return (DT_TOK_AGG);
+ }
+
+<S0>{RGX_INT} |
+<S2>{RGX_INT} |
+<S3>{RGX_INT} {
+ char *p;
+
+#ifndef VBOX
+ errno = 0;
+ yylval.l_int = strtoull(yytext, &p, 0);
+ yyintprefix = 0;
+ (void) strncpy(yyintsuffix, p, sizeof (yyintsuffix));
+ yyintdecimal = yytext[0] != '0';
+ if (errno == ERANGE)
+#else
+ uint64_t uTmp = 0;
+ int rc = RTStrToUInt64Ex(yytext, &p, 0, &uTmp);
+ yylval.l_int = uTmp;
+ yyintprefix = 0;
+ RTStrCopy(yyintsuffix, sizeof(yyintsuffix), p);
+ yyintdecimal = yytext[0] != '0';
+ if (rc == VWRN_NUMBER_TOO_BIG || rc == VWRN_NEGATIVE_UNSIGNED)
+#endif
+ xyerror(D_INT_OFLOW, "constant %s results in "
+ "integer overflow\n", yytext);
+
+ if (*p != '\0' && strchr("uUlL", *p) == NULL) {
+ xyerror(D_INT_DIGIT, "constant %s contains "
+ "invalid digit %c\n", yytext, *p);
+ }
+
+ if ((YYSTATE) != S3)
+ return (DT_TOK_INT);
+
+ yypragma = dt_node_link(yypragma,
+ dt_node_int(yylval.l_int));
+ }
+
+<S0>{RGX_FP} yyerror("floating-point constants are not permitted\n");
+
+ /* VBOX changed:
+<S0>\"{RGX_STR}$ |
+<S3>\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal");
+ input: */
+<S0,S3>\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal");
+
+<S0>\"{RGX_STR}\" |
+<S3>\"{RGX_STR}\" {
+ /*
+ * Quoted string -- convert C escape sequences and
+ * return the string as a token.
+ */
+ yylval.l_str = strndup(yytext + 1, yyleng - 2);
+
+ if (yylval.l_str == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ (void) stresc2chr(yylval.l_str);
+ if ((YYSTATE) != S3)
+ return (DT_TOK_STRING);
+
+ yypragma = dt_node_link(yypragma,
+ dt_node_string(yylval.l_str));
+ }
+
+<S0>'{RGX_CHR}$ xyerror(D_CHR_NL, "newline encountered in character constant");
+
+<S0>'{RGX_CHR}' {
+ char *s, *p, *q;
+ size_t nbytes;
+
+ /*
+ * Character constant -- convert C escape sequences and
+ * return the character as an integer immediate value.
+ */
+ if (yyleng == 2)
+ xyerror(D_CHR_NULL, "empty character constant");
+
+ s = yytext + 1;
+ yytext[yyleng - 1] = '\0';
+ nbytes = stresc2chr(s);
+ yylval.l_int = 0;
+ yyintprefix = 0;
+ yyintsuffix[0] = '\0';
+ yyintdecimal = 1;
+
+ if (nbytes > sizeof (yylval.l_int)) {
+ xyerror(D_CHR_OFLOW, "character constant is "
+ "too long");
+ }
+#ifdef _LITTLE_ENDIAN
+ p = ((char *)&yylval.l_int) + nbytes - 1;
+ for (q = s; nbytes != 0; nbytes--)
+ *p-- = *q++;
+#else
+ bcopy(s, ((char *)&yylval.l_int) +
+ sizeof (yylval.l_int) - nbytes, nbytes);
+#endif
+ return (DT_TOK_INT);
+ }
+
+<S0>"/*" |
+<S2>"/*" {
+ yypcb->pcb_cstate = (YYSTATE);
+ BEGIN(S1);
+ }
+
+<S0>{RGX_INTERP} |
+<S2>{RGX_INTERP} ; /* discard any #! lines */
+
+<S0>{RGX_CTL} |
+<S2>{RGX_CTL} |
+<S4>{RGX_CTL} {
+ assert(yypragma == NULL);
+ yypcb->pcb_cstate = (YYSTATE);
+ BEGIN(S3);
+ }
+
+<S4>. ; /* discard */
+<S4>"\n" ; /* discard */
+
+<S0>"/" {
+ int c, tok;
+
+ /*
+ * The use of "/" as the predicate delimiter and as the
+ * integer division symbol requires special lookahead
+ * to avoid a shift/reduce conflict in the D grammar.
+ * We look ahead to the next non-whitespace character.
+ * If we encounter EOF, ";", "{", or "/", then this "/"
+ * closes the predicate and we return DT_TOK_EPRED.
+ * If we encounter anything else, it's DT_TOK_DIV.
+ */
+ while ((c = input()) != 0) {
+ if (strchr("\f\n\r\t\v ", c) == NULL)
+ break;
+ }
+
+ if (c == 0 || c == ';' || c == '{' || c == '/') {
+ if (yypcb->pcb_parens != 0) {
+ yyerror("closing ) expected in "
+ "predicate before /\n");
+ }
+ if (yypcb->pcb_brackets != 0) {
+ yyerror("closing ] expected in "
+ "predicate before /\n");
+ }
+ tok = DT_TOK_EPRED;
+ } else
+ tok = DT_TOK_DIV;
+
+ if (c != EOF) unput(c);
+ return (tok);
+ }
+
+<S0>"(" {
+ yypcb->pcb_parens++;
+ return (DT_TOK_LPAR);
+ }
+
+<S0>")" {
+ if (--yypcb->pcb_parens < 0)
+ yyerror("extra ) in input stream\n");
+ return (DT_TOK_RPAR);
+ }
+
+<S0>"[" {
+ yypcb->pcb_brackets++;
+ return (DT_TOK_LBRAC);
+ }
+
+<S0>"]" {
+ if (--yypcb->pcb_brackets < 0)
+ yyerror("extra ] in input stream\n");
+ return (DT_TOK_RBRAC);
+ }
+
+<S0>"{" |
+<S2>"{" {
+ yypcb->pcb_braces++;
+ return ('{');
+ }
+
+<S0>"}" {
+ if (--yypcb->pcb_braces < 0)
+ yyerror("extra } in input stream\n");
+ return ('}');
+ }
+
+<S0>"|" return (DT_TOK_BOR);
+<S0>"^" return (DT_TOK_XOR);
+<S0>"&" return (DT_TOK_BAND);
+<S0>"&&" return (DT_TOK_LAND);
+<S0>"^^" return (DT_TOK_LXOR);
+<S0>"||" return (DT_TOK_LOR);
+<S0>"==" return (DT_TOK_EQU);
+<S0>"!=" return (DT_TOK_NEQ);
+<S0>"<" return (DT_TOK_LT);
+<S0>"<=" return (DT_TOK_LE);
+<S0>">" return (DT_TOK_GT);
+<S0>">=" return (DT_TOK_GE);
+<S0>"<<" return (DT_TOK_LSH);
+<S0>">>" return (DT_TOK_RSH);
+<S0>"+" return (DT_TOK_ADD);
+<S0>"-" return (DT_TOK_SUB);
+<S0>"*" return (DT_TOK_MUL);
+<S0>"%" return (DT_TOK_MOD);
+<S0>"~" return (DT_TOK_BNEG);
+<S0>"!" return (DT_TOK_LNEG);
+<S0>"?" return (DT_TOK_QUESTION);
+<S0>":" return (DT_TOK_COLON);
+<S0>"." return (DT_TOK_DOT);
+<S0>"->" return (DT_TOK_PTR);
+<S0>"=" return (DT_TOK_ASGN);
+<S0>"+=" return (DT_TOK_ADD_EQ);
+<S0>"-=" return (DT_TOK_SUB_EQ);
+<S0>"*=" return (DT_TOK_MUL_EQ);
+<S0>"/=" return (DT_TOK_DIV_EQ);
+<S0>"%=" return (DT_TOK_MOD_EQ);
+<S0>"&=" return (DT_TOK_AND_EQ);
+<S0>"^=" return (DT_TOK_XOR_EQ);
+<S0>"|=" return (DT_TOK_OR_EQ);
+<S0>"<<=" return (DT_TOK_LSH_EQ);
+<S0>">>=" return (DT_TOK_RSH_EQ);
+<S0>"++" return (DT_TOK_ADDADD);
+<S0>"--" return (DT_TOK_SUBSUB);
+<S0>"..." return (DT_TOK_ELLIPSIS);
+<S0>"," return (DT_TOK_COMMA);
+<S0>";" return (';');
+<S0>{RGX_WS} ; /* discard */
+<S0>"\\"\n ; /* discard */
+<S0>. yyerror("syntax error near \"%c\"\n", yytext[0]);
+
+<S1>"/*" yyerror("/* encountered inside a comment\n");
+<S1>"*/" BEGIN(yypcb->pcb_cstate);
+ /* VBOX - START */
+<S1><<EOF>> yyerror("end-of-file encountered before matching */\n");
+ /* VBOX - END */
+<S1>.|\n ; /* discard */
+
+<S2>{RGX_PSPEC} {
+ /*
+ * S2 has an ambiguity because RGX_PSPEC includes '*'
+ * as a glob character and '*' also can be DT_TOK_STAR.
+ * Since lex always matches the longest token, this
+ * rule can be matched by an input string like "int*",
+ * which could begin a global variable declaration such
+ * as "int*x;" or could begin a RGX_PSPEC with globbing
+ * such as "int* { trace(timestamp); }". If C_PSPEC is
+ * not set, we must resolve the ambiguity in favor of
+ * the type and perform lexer pushback if the fragment
+ * before '*' or entire fragment matches a type name.
+ * If C_PSPEC is set, we always return a PSPEC token.
+ * If C_PSPEC is off, the user can avoid ambiguity by
+ * including a ':' delimiter in the specifier, which
+ * they should be doing anyway to specify the provider.
+ */
+ if (!(yypcb->pcb_cflags & DTRACE_C_PSPEC) &&
+ strchr(yytext, ':') == NULL) {
+
+ char *p = strchr(yytext, '*');
+ char *q = yytext + yyleng - 1;
+
+ if (p != NULL && p > yytext)
+ *p = '\0'; /* prune yytext */
+
+ if (dt_type_lookup(yytext, NULL) == 0) {
+ yylval.l_str = strdup(yytext);
+
+ if (yylval.l_str == NULL) {
+ longjmp(yypcb->pcb_jmpbuf,
+ EDT_NOMEM);
+ }
+
+ if (p != NULL && p > yytext) {
+ for (*p = '*'; q >= p; q--)
+ unput(*q);
+ }
+
+ yybegin(YYS_EXPR);
+ return (DT_TOK_TNAME);
+ }
+
+ if (p != NULL && p > yytext)
+ *p = '*'; /* restore yytext */
+ }
+
+ if ((yylval.l_str = strdup(yytext)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ return (DT_TOK_PSPEC);
+ }
+
+<S2>"/" return (DT_TOK_DIV);
+<S2>"," return (DT_TOK_COMMA);
+
+<S2>{RGX_WS} ; /* discard */
+<S2>. yyerror("syntax error near \"%c\"\n", yytext[0]);
+
+<S3>\n {
+ dt_pragma(yypragma);
+ yypragma = NULL;
+ BEGIN(yypcb->pcb_cstate);
+ }
+
+<S3>[\f\t\v ]+ ; /* discard */
+
+<S3>[^\f\n\t\v "]+ {
+ dt_node_t *dnp;
+
+ if ((yylval.l_str = strdup(yytext)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * We want to call dt_node_ident() here, but we can't
+ * because it will expand inlined identifiers, which we
+ * don't want to do from #pragma context in order to
+ * support pragmas that apply to the ident itself. We
+ * call dt_node_string() and then reset dn_op instead.
+ */
+ dnp = dt_node_string(yylval.l_str);
+ dnp->dn_kind = DT_NODE_IDENT;
+ dnp->dn_op = DT_TOK_IDENT;
+ yypragma = dt_node_link(yypragma, dnp);
+ }
+
+ /* VBOX - BEGIN */
+<S3><<EOF>> yyerror("end-of-file encountered before end of control line\n");
+ /* VBOX - END */
+<S3>. yyerror("syntax error near \"%c\"\n", yytext[0]);
+
+%%
+
+/*
+ * yybegin provides a wrapper for use from C code around the lex BEGIN() macro.
+ * We use two main states for lexing because probe descriptions use a syntax
+ * that is incompatible with the normal D tokens (e.g. names can contain "-").
+ * yybegin also handles the job of switching between two lists of dt_nodes
+ * as we allocate persistent definitions, like inlines, and transient nodes
+ * that will be freed once we are done parsing the current program file.
+ */
+void
+yybegin(yystate_t state)
+{
+#if YYDEBUG /* VBOX: ifdef YYDEBUG => if YYDEBUG */
+ yydebug = _dtrace_debug;
+#endif
+ if (yypcb->pcb_yystate == state)
+ return; /* nothing to do if we're in the state already */
+
+ if (yypcb->pcb_yystate == YYS_DEFINE) {
+ yypcb->pcb_list = yypcb->pcb_hold;
+ yypcb->pcb_hold = NULL;
+ }
+
+ switch (state) {
+ case YYS_CLAUSE:
+ BEGIN(S2);
+ break;
+ case YYS_DEFINE:
+ assert(yypcb->pcb_hold == NULL);
+ yypcb->pcb_hold = yypcb->pcb_list;
+ yypcb->pcb_list = NULL;
+ RT_FALL_THRU();
+ case YYS_EXPR:
+ BEGIN(S0);
+ break;
+ case YYS_DONE:
+ break;
+ case YYS_CONTROL:
+ BEGIN(S4);
+ break;
+ default:
+ xyerror(D_UNKNOWN, "internal error -- bad yystate %d\n", state);
+ }
+
+ yypcb->pcb_yystate = state;
+}
+
+void
+yyinit(dt_pcb_t *pcb)
+{
+ yypcb = pcb;
+ yylineno = 1;
+ yypragma = NULL;
+#ifndef USING_FLEX
+ yysptr = yysbuf;
+#else
+ yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
+#endif
+}
+
+/*
+ * Given a lexeme 's' (typically yytext), set yylval and return an appropriate
+ * token to the parser indicating either an identifier or a typedef name.
+ * User-defined global variables always take precedence over types, but we do
+ * use some heuristics because D programs can look at an ever-changing set of
+ * kernel types and also can implicitly instantiate variables by assignment,
+ * unlike in C. The code here is ordered carefully as lookups are not cheap.
+ */
+static int
+id_or_type(const char *s)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_decl_t *ddp = yypcb->pcb_dstack.ds_decl;
+ int c0, c1, ttok = DT_TOK_TNAME;
+ dt_ident_t *idp;
+
+ if ((s = yylval.l_str = strdup(s)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * If the lexeme is a global variable or likely identifier or *not* a
+ * type_name, then it is an identifier token.
+ */
+ if (dt_idstack_lookup(&yypcb->pcb_globals, s) != NULL ||
+ dt_idhash_lookup(yypcb->pcb_idents, s) != NULL ||
+ dt_type_lookup(s, NULL) != 0)
+ return (DT_TOK_IDENT);
+
+ /*
+ * If we're in the midst of parsing a declaration and a type_specifier
+ * has already been shifted, then return DT_TOK_IDENT instead of TNAME.
+ * This semantic is necessary to permit valid ISO C code such as:
+ *
+ * typedef int foo;
+ * struct s { foo foo; };
+ *
+ * without causing shift/reduce conflicts in the direct_declarator part
+ * of the grammar. The result is that we must check for conflicting
+ * redeclarations of the same identifier as part of dt_node_decl().
+ */
+ if (ddp != NULL && ddp->dd_name != NULL)
+ return (DT_TOK_IDENT);
+
+ /*
+ * If the lexeme is a type name and we are not in a program clause,
+ * then always interpret it as a type and return DT_TOK_TNAME.
+ */
+ if ((YYSTATE) != S0)
+ return (DT_TOK_TNAME);
+
+ /*
+ * If the lexeme matches a type name but is in a program clause, then
+ * it could be a type or it could be an undefined variable. Peek at
+ * the next token to decide. If we see ++, --, [, or =, we know there
+ * might be an assignment that is trying to create a global variable,
+ * so we optimistically return DT_TOK_IDENT. There is no harm in being
+ * wrong: a type_name followed by ++, --, [, or = is a syntax error.
+ */
+ while ((c0 = input()) != 0) {
+ if (strchr("\f\n\r\t\v ", c0) == NULL)
+ break;
+ }
+
+ switch (c0) {
+ case '+':
+ case '-':
+ if ((c1 = input()) == c0)
+ ttok = DT_TOK_IDENT;
+ if (c1 != EOF) unput(c1);
+ break;
+
+ case '=':
+ if ((c1 = input()) != c0)
+ ttok = DT_TOK_IDENT;
+ if (c1 != EOF) unput(c1);
+ break;
+ case '[':
+ ttok = DT_TOK_IDENT;
+ break;
+ }
+
+ if (ttok == DT_TOK_IDENT) {
+ idp = dt_idhash_insert(yypcb->pcb_idents, s, DT_IDENT_SCALAR, 0,
+ 0, _dtrace_defattr, 0, &dt_idops_thaw, NULL, dtp->dt_gen);
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ if (c0 != EOF) unput(c0);
+ return (ttok);
+}
+
+#ifndef USING_FLEX
+
+static int
+input(void)
+{
+ int c;
+
+ if (yysptr > yysbuf)
+ c = *--yysptr;
+ else if (yypcb->pcb_fileptr != NULL)
+ c = fgetc(yypcb->pcb_fileptr);
+ else if (yypcb->pcb_strptr < yypcb->pcb_string + yypcb->pcb_strlen)
+ c = *(unsigned char *)(yypcb->pcb_strptr++);
+ else
+ c = EOF;
+
+ if (c == '\n')
+ yylineno++;
+
+ if (c != EOF)
+ return (c);
+
+ if ((YYSTATE) == S1)
+ yyerror("end-of-file encountered before matching */\n");
+
+ if ((YYSTATE) == S3)
+ yyerror("end-of-file encountered before end of control line\n");
+
+ if (yypcb->pcb_fileptr != NULL && ferror(yypcb->pcb_fileptr))
+ longjmp(yypcb->pcb_jmpbuf, EDT_FIO);
+
+ return (0); /* EOF */
+}
+
+static void
+unput(int c)
+{
+ if (c == '\n')
+ yylineno--;
+
+ *yysptr++ = c;
+ yytchar = c;
+}
+
+#endif /* USING_FLEX */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_link.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_link.c
new file mode 100644
index 00000000..e910ac3f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_link.c
@@ -0,0 +1,1634 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#define ELF_TARGET_ALL
+#include <elf.h>
+
+#include <sys/types.h>
+#include <sys/sysmacros.h>
+
+#include <unistd.h>
+#include <strings.h>
+#include <alloca.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <wait.h>
+#include <assert.h>
+#include <sys/ipc.h>
+
+#include <dt_impl.h>
+#include <dt_provider.h>
+#include <dt_program.h>
+#include <dt_string.h>
+
+#define ESHDR_NULL 0
+#define ESHDR_SHSTRTAB 1
+#define ESHDR_DOF 2
+#define ESHDR_STRTAB 3
+#define ESHDR_SYMTAB 4
+#define ESHDR_REL 5
+#define ESHDR_NUM 6
+
+#define PWRITE_SCN(index, data) \
+ (lseek64(fd, (off64_t)elf_file.shdr[(index)].sh_offset, SEEK_SET) != \
+ (off64_t)elf_file.shdr[(index)].sh_offset || \
+ dt_write(dtp, fd, (data), elf_file.shdr[(index)].sh_size) != \
+ elf_file.shdr[(index)].sh_size)
+
+static const char DTRACE_SHSTRTAB32[] = "\0"
+".shstrtab\0" /* 1 */
+".SUNW_dof\0" /* 11 */
+".strtab\0" /* 21 */
+".symtab\0" /* 29 */
+#ifdef __sparc
+".rela.SUNW_dof"; /* 37 */
+#else
+".rel.SUNW_dof"; /* 37 */
+#endif
+
+static const char DTRACE_SHSTRTAB64[] = "\0"
+".shstrtab\0" /* 1 */
+".SUNW_dof\0" /* 11 */
+".strtab\0" /* 21 */
+".symtab\0" /* 29 */
+".rela.SUNW_dof"; /* 37 */
+
+static const char DOFSTR[] = "__SUNW_dof";
+static const char DOFLAZYSTR[] = "___SUNW_dof";
+
+typedef struct dt_link_pair {
+ struct dt_link_pair *dlp_next; /* next pair in linked list */
+ void *dlp_str; /* buffer for string table */
+ void *dlp_sym; /* buffer for symbol table */
+} dt_link_pair_t;
+
+typedef struct dof_elf32 {
+ uint32_t de_nrel; /* relocation count */
+#ifdef __sparc
+ Elf32_Rela *de_rel; /* array of relocations for sparc */
+#else
+ Elf32_Rel *de_rel; /* array of relocations for x86 */
+#endif
+ uint32_t de_nsym; /* symbol count */
+ Elf32_Sym *de_sym; /* array of symbols */
+ uint32_t de_strlen; /* size of of string table */
+ char *de_strtab; /* string table */
+ uint32_t de_global; /* index of the first global symbol */
+} dof_elf32_t;
+
+static int
+prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep)
+{
+ dof_sec_t *dofs, *s;
+ dof_relohdr_t *dofrh;
+ dof_relodesc_t *dofr;
+ char *strtab;
+ int i, j, nrel;
+ size_t strtabsz = 1;
+ uint32_t count = 0;
+ size_t base;
+ Elf32_Sym *sym;
+#ifdef __sparc
+ Elf32_Rela *rel;
+#else
+ Elf32_Rel *rel;
+#endif
+
+ /*LINTED*/
+ dofs = (dof_sec_t *)((char *)dof + dof->dofh_secoff);
+
+ /*
+ * First compute the size of the string table and the number of
+ * relocations present in the DOF.
+ */
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ if (dofs[i].dofs_type != DOF_SECT_URELHDR)
+ continue;
+
+ /*LINTED*/
+ dofrh = (dof_relohdr_t *)((char *)dof + dofs[i].dofs_offset);
+
+ s = &dofs[dofrh->dofr_strtab];
+ strtab = (char *)dof + s->dofs_offset;
+ assert(strtab[0] == '\0');
+ strtabsz += s->dofs_size - 1;
+
+ s = &dofs[dofrh->dofr_relsec];
+ /*LINTED*/
+ dofr = (dof_relodesc_t *)((char *)dof + s->dofs_offset);
+ count += s->dofs_size / s->dofs_entsize;
+ }
+
+ dep->de_strlen = strtabsz;
+ dep->de_nrel = count;
+ dep->de_nsym = count + 1; /* the first symbol is always null */
+
+ if (dtp->dt_lazyload) {
+ dep->de_strlen += sizeof (DOFLAZYSTR);
+ dep->de_nsym++;
+ } else {
+ dep->de_strlen += sizeof (DOFSTR);
+ dep->de_nsym++;
+ }
+
+ if ((dep->de_rel = calloc(dep->de_nrel,
+ sizeof (dep->de_rel[0]))) == NULL) {
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ if ((dep->de_sym = calloc(dep->de_nsym, sizeof (Elf32_Sym))) == NULL) {
+ free(dep->de_rel);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ if ((dep->de_strtab = calloc(dep->de_strlen, 1)) == NULL) {
+ free(dep->de_rel);
+ free(dep->de_sym);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ count = 0;
+ strtabsz = 1;
+ dep->de_strtab[0] = '\0';
+ rel = dep->de_rel;
+ sym = dep->de_sym;
+ dep->de_global = 1;
+
+ /*
+ * The first symbol table entry must be zeroed and is always ignored.
+ */
+ bzero(sym, sizeof (Elf32_Sym));
+ sym++;
+
+ /*
+ * Take a second pass through the DOF sections filling in the
+ * memory we allocated.
+ */
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ if (dofs[i].dofs_type != DOF_SECT_URELHDR)
+ continue;
+
+ /*LINTED*/
+ dofrh = (dof_relohdr_t *)((char *)dof + dofs[i].dofs_offset);
+
+ s = &dofs[dofrh->dofr_strtab];
+ strtab = (char *)dof + s->dofs_offset;
+ bcopy(strtab + 1, dep->de_strtab + strtabsz, s->dofs_size);
+ base = strtabsz;
+ strtabsz += s->dofs_size - 1;
+
+ s = &dofs[dofrh->dofr_relsec];
+ /*LINTED*/
+ dofr = (dof_relodesc_t *)((char *)dof + s->dofs_offset);
+ nrel = s->dofs_size / s->dofs_entsize;
+
+ s = &dofs[dofrh->dofr_tgtsec];
+
+ for (j = 0; j < nrel; j++) {
+#if defined(__i386) || defined(__amd64)
+ rel->r_offset = s->dofs_offset +
+ dofr[j].dofr_offset;
+ rel->r_info = ELF32_R_INFO(count + dep->de_global,
+ R_386_32);
+#elif defined(__sparc)
+ /*
+ * Add 4 bytes to hit the low half of this 64-bit
+ * big-endian address.
+ */
+ rel->r_offset = s->dofs_offset +
+ dofr[j].dofr_offset + 4;
+ rel->r_info = ELF32_R_INFO(count + dep->de_global,
+ R_SPARC_32);
+#else
+#error unknown ISA
+#endif
+
+ sym->st_name = base + dofr[j].dofr_name - 1;
+ sym->st_value = 0;
+ sym->st_size = 0;
+ sym->st_info = ELF32_ST_INFO(STB_GLOBAL, STT_FUNC);
+ sym->st_other = 0;
+ sym->st_shndx = SHN_UNDEF;
+
+ rel++;
+ sym++;
+ count++;
+ }
+ }
+
+ /*
+ * Add a symbol for the DOF itself. We use a different symbol for
+ * lazily and actively loaded DOF to make them easy to distinguish.
+ */
+ sym->st_name = strtabsz;
+ sym->st_value = 0;
+ sym->st_size = dof->dofh_filesz;
+ sym->st_info = ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT);
+ sym->st_other = 0;
+ sym->st_shndx = ESHDR_DOF;
+ sym++;
+
+ if (dtp->dt_lazyload) {
+ bcopy(DOFLAZYSTR, dep->de_strtab + strtabsz,
+ sizeof (DOFLAZYSTR));
+ strtabsz += sizeof (DOFLAZYSTR);
+ } else {
+ bcopy(DOFSTR, dep->de_strtab + strtabsz, sizeof (DOFSTR));
+ strtabsz += sizeof (DOFSTR);
+ }
+
+ assert(count == dep->de_nrel);
+ assert(strtabsz == dep->de_strlen);
+
+ return (0);
+}
+
+
+typedef struct dof_elf64 {
+ uint32_t de_nrel;
+ Elf64_Rela *de_rel;
+ uint32_t de_nsym;
+ Elf64_Sym *de_sym;
+
+ uint32_t de_strlen;
+ char *de_strtab;
+
+ uint32_t de_global;
+} dof_elf64_t;
+
+static int
+prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
+{
+ dof_sec_t *dofs, *s;
+ dof_relohdr_t *dofrh;
+ dof_relodesc_t *dofr;
+ char *strtab;
+ int i, j, nrel;
+ size_t strtabsz = 1;
+ uint32_t count = 0;
+ size_t base;
+ Elf64_Sym *sym;
+ Elf64_Rela *rel;
+
+ /*LINTED*/
+ dofs = (dof_sec_t *)((char *)dof + dof->dofh_secoff);
+
+ /*
+ * First compute the size of the string table and the number of
+ * relocations present in the DOF.
+ */
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ if (dofs[i].dofs_type != DOF_SECT_URELHDR)
+ continue;
+
+ /*LINTED*/
+ dofrh = (dof_relohdr_t *)((char *)dof + dofs[i].dofs_offset);
+
+ s = &dofs[dofrh->dofr_strtab];
+ strtab = (char *)dof + s->dofs_offset;
+ assert(strtab[0] == '\0');
+ strtabsz += s->dofs_size - 1;
+
+ s = &dofs[dofrh->dofr_relsec];
+ /*LINTED*/
+ dofr = (dof_relodesc_t *)((char *)dof + s->dofs_offset);
+ count += s->dofs_size / s->dofs_entsize;
+ }
+
+ dep->de_strlen = strtabsz;
+ dep->de_nrel = count;
+ dep->de_nsym = count + 1; /* the first symbol is always null */
+
+ if (dtp->dt_lazyload) {
+ dep->de_strlen += sizeof (DOFLAZYSTR);
+ dep->de_nsym++;
+ } else {
+ dep->de_strlen += sizeof (DOFSTR);
+ dep->de_nsym++;
+ }
+
+ if ((dep->de_rel = calloc(dep->de_nrel,
+ sizeof (dep->de_rel[0]))) == NULL) {
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ if ((dep->de_sym = calloc(dep->de_nsym, sizeof (Elf64_Sym))) == NULL) {
+ free(dep->de_rel);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ if ((dep->de_strtab = calloc(dep->de_strlen, 1)) == NULL) {
+ free(dep->de_rel);
+ free(dep->de_sym);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ count = 0;
+ strtabsz = 1;
+ dep->de_strtab[0] = '\0';
+ rel = dep->de_rel;
+ sym = dep->de_sym;
+ dep->de_global = 1;
+
+ /*
+ * The first symbol table entry must be zeroed and is always ignored.
+ */
+ bzero(sym, sizeof (Elf64_Sym));
+ sym++;
+
+ /*
+ * Take a second pass through the DOF sections filling in the
+ * memory we allocated.
+ */
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ if (dofs[i].dofs_type != DOF_SECT_URELHDR)
+ continue;
+
+ /*LINTED*/
+ dofrh = (dof_relohdr_t *)((char *)dof + dofs[i].dofs_offset);
+
+ s = &dofs[dofrh->dofr_strtab];
+ strtab = (char *)dof + s->dofs_offset;
+ bcopy(strtab + 1, dep->de_strtab + strtabsz, s->dofs_size);
+ base = strtabsz;
+ strtabsz += s->dofs_size - 1;
+
+ s = &dofs[dofrh->dofr_relsec];
+ /*LINTED*/
+ dofr = (dof_relodesc_t *)((char *)dof + s->dofs_offset);
+ nrel = s->dofs_size / s->dofs_entsize;
+
+ s = &dofs[dofrh->dofr_tgtsec];
+
+ for (j = 0; j < nrel; j++) {
+#if defined(__i386) || defined(__amd64)
+ rel->r_offset = s->dofs_offset +
+ dofr[j].dofr_offset;
+ rel->r_info = ELF64_R_INFO(count + dep->de_global,
+ R_AMD64_64);
+#elif defined(__sparc)
+ rel->r_offset = s->dofs_offset +
+ dofr[j].dofr_offset;
+ rel->r_info = ELF64_R_INFO(count + dep->de_global,
+ R_SPARC_64);
+#else
+#error unknown ISA
+#endif
+
+ sym->st_name = base + dofr[j].dofr_name - 1;
+ sym->st_value = 0;
+ sym->st_size = 0;
+ sym->st_info = GELF_ST_INFO(STB_GLOBAL, STT_FUNC);
+ sym->st_other = 0;
+ sym->st_shndx = SHN_UNDEF;
+
+ rel++;
+ sym++;
+ count++;
+ }
+ }
+
+ /*
+ * Add a symbol for the DOF itself. We use a different symbol for
+ * lazily and actively loaded DOF to make them easy to distinguish.
+ */
+ sym->st_name = strtabsz;
+ sym->st_value = 0;
+ sym->st_size = dof->dofh_filesz;
+ sym->st_info = GELF_ST_INFO(STB_GLOBAL, STT_OBJECT);
+ sym->st_other = 0;
+ sym->st_shndx = ESHDR_DOF;
+ sym++;
+
+ if (dtp->dt_lazyload) {
+ bcopy(DOFLAZYSTR, dep->de_strtab + strtabsz,
+ sizeof (DOFLAZYSTR));
+ strtabsz += sizeof (DOFLAZYSTR);
+ } else {
+ bcopy(DOFSTR, dep->de_strtab + strtabsz, sizeof (DOFSTR));
+ strtabsz += sizeof (DOFSTR);
+ }
+
+ assert(count == dep->de_nrel);
+ assert(strtabsz == dep->de_strlen);
+
+ return (0);
+}
+
+/*
+ * Write out an ELF32 file prologue consisting of a header, section headers,
+ * and a section header string table. The DOF data will follow this prologue
+ * and complete the contents of the given ELF file.
+ */
+static int
+dump_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
+{
+ struct {
+ Elf32_Ehdr ehdr;
+ Elf32_Shdr shdr[ESHDR_NUM];
+ } elf_file;
+
+ Elf32_Shdr *shp;
+ Elf32_Off off;
+ dof_elf32_t de;
+ int ret = 0;
+ uint_t nshdr;
+
+ if (prepare_elf32(dtp, dof, &de) != 0)
+ return (-1); /* errno is set for us */
+
+ /*
+ * If there are no relocations, we only need enough sections for
+ * the shstrtab and the DOF.
+ */
+ nshdr = de.de_nrel == 0 ? ESHDR_SYMTAB + 1 : ESHDR_NUM;
+
+ bzero(&elf_file, sizeof (elf_file));
+
+ elf_file.ehdr.e_ident[EI_MAG0] = ELFMAG0;
+ elf_file.ehdr.e_ident[EI_MAG1] = ELFMAG1;
+ elf_file.ehdr.e_ident[EI_MAG2] = ELFMAG2;
+ elf_file.ehdr.e_ident[EI_MAG3] = ELFMAG3;
+ elf_file.ehdr.e_ident[EI_VERSION] = EV_CURRENT;
+ elf_file.ehdr.e_ident[EI_CLASS] = ELFCLASS32;
+#if defined(_BIG_ENDIAN)
+ elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2MSB;
+#elif defined(_LITTLE_ENDIAN)
+ elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2LSB;
+#endif
+ elf_file.ehdr.e_type = ET_REL;
+#if defined(__sparc)
+ elf_file.ehdr.e_machine = EM_SPARC;
+#elif defined(__i386) || defined(__amd64)
+ elf_file.ehdr.e_machine = EM_386;
+#endif
+ elf_file.ehdr.e_version = EV_CURRENT;
+ elf_file.ehdr.e_shoff = sizeof (Elf32_Ehdr);
+ elf_file.ehdr.e_ehsize = sizeof (Elf32_Ehdr);
+ elf_file.ehdr.e_phentsize = sizeof (Elf32_Phdr);
+ elf_file.ehdr.e_shentsize = sizeof (Elf32_Shdr);
+ elf_file.ehdr.e_shnum = nshdr;
+ elf_file.ehdr.e_shstrndx = ESHDR_SHSTRTAB;
+ off = sizeof (elf_file) + nshdr * sizeof (Elf32_Shdr);
+
+ shp = &elf_file.shdr[ESHDR_SHSTRTAB];
+ shp->sh_name = 1; /* DTRACE_SHSTRTAB32[1] = ".shstrtab" */
+ shp->sh_type = SHT_STRTAB;
+ shp->sh_offset = off;
+ shp->sh_size = sizeof (DTRACE_SHSTRTAB32);
+ shp->sh_addralign = sizeof (char);
+ off = P2ROUNDUP(shp->sh_offset + shp->sh_size, 8);
+
+ shp = &elf_file.shdr[ESHDR_DOF];
+ shp->sh_name = 11; /* DTRACE_SHSTRTAB32[11] = ".SUNW_dof" */
+ shp->sh_flags = SHF_ALLOC;
+ shp->sh_type = SHT_SUNW_dof;
+ shp->sh_offset = off;
+ shp->sh_size = dof->dofh_filesz;
+ shp->sh_addralign = 8;
+ off = shp->sh_offset + shp->sh_size;
+
+ shp = &elf_file.shdr[ESHDR_STRTAB];
+ shp->sh_name = 21; /* DTRACE_SHSTRTAB32[21] = ".strtab" */
+ shp->sh_flags = SHF_ALLOC;
+ shp->sh_type = SHT_STRTAB;
+ shp->sh_offset = off;
+ shp->sh_size = de.de_strlen;
+ shp->sh_addralign = sizeof (char);
+ off = P2ROUNDUP(shp->sh_offset + shp->sh_size, 4);
+
+ shp = &elf_file.shdr[ESHDR_SYMTAB];
+ shp->sh_name = 29; /* DTRACE_SHSTRTAB32[29] = ".symtab" */
+ shp->sh_flags = SHF_ALLOC;
+ shp->sh_type = SHT_SYMTAB;
+ shp->sh_entsize = sizeof (Elf32_Sym);
+ shp->sh_link = ESHDR_STRTAB;
+ shp->sh_offset = off;
+ shp->sh_info = de.de_global;
+ shp->sh_size = de.de_nsym * sizeof (Elf32_Sym);
+ shp->sh_addralign = 4;
+ off = P2ROUNDUP(shp->sh_offset + shp->sh_size, 4);
+
+ if (de.de_nrel == 0) {
+ if (dt_write(dtp, fd, &elf_file,
+ sizeof (elf_file)) != sizeof (elf_file) ||
+ PWRITE_SCN(ESHDR_SHSTRTAB, DTRACE_SHSTRTAB32) ||
+ PWRITE_SCN(ESHDR_STRTAB, de.de_strtab) ||
+ PWRITE_SCN(ESHDR_SYMTAB, de.de_sym) ||
+ PWRITE_SCN(ESHDR_DOF, dof)) {
+ ret = dt_set_errno(dtp, errno);
+ }
+ } else {
+ shp = &elf_file.shdr[ESHDR_REL];
+ shp->sh_name = 37; /* DTRACE_SHSTRTAB32[37] = ".rel.SUNW_dof" */
+ shp->sh_flags = SHF_ALLOC;
+#ifdef __sparc
+ shp->sh_type = SHT_RELA;
+#else
+ shp->sh_type = SHT_REL;
+#endif
+ shp->sh_entsize = sizeof (de.de_rel[0]);
+ shp->sh_link = ESHDR_SYMTAB;
+ shp->sh_info = ESHDR_DOF;
+ shp->sh_offset = off;
+ shp->sh_size = de.de_nrel * sizeof (de.de_rel[0]);
+ shp->sh_addralign = 4;
+
+ if (dt_write(dtp, fd, &elf_file,
+ sizeof (elf_file)) != sizeof (elf_file) ||
+ PWRITE_SCN(ESHDR_SHSTRTAB, DTRACE_SHSTRTAB32) ||
+ PWRITE_SCN(ESHDR_STRTAB, de.de_strtab) ||
+ PWRITE_SCN(ESHDR_SYMTAB, de.de_sym) ||
+ PWRITE_SCN(ESHDR_REL, de.de_rel) ||
+ PWRITE_SCN(ESHDR_DOF, dof)) {
+ ret = dt_set_errno(dtp, errno);
+ }
+ }
+
+ free(de.de_strtab);
+ free(de.de_sym);
+ free(de.de_rel);
+
+ return (ret);
+}
+
+/*
+ * Write out an ELF64 file prologue consisting of a header, section headers,
+ * and a section header string table. The DOF data will follow this prologue
+ * and complete the contents of the given ELF file.
+ */
+static int
+dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
+{
+ struct {
+ Elf64_Ehdr ehdr;
+ Elf64_Shdr shdr[ESHDR_NUM];
+ } elf_file;
+
+ Elf64_Shdr *shp;
+ Elf64_Off off;
+ dof_elf64_t de;
+ int ret = 0;
+ uint_t nshdr;
+
+ if (prepare_elf64(dtp, dof, &de) != 0)
+ return (-1); /* errno is set for us */
+
+ /*
+ * If there are no relocations, we only need enough sections for
+ * the shstrtab and the DOF.
+ */
+ nshdr = de.de_nrel == 0 ? ESHDR_SYMTAB + 1 : ESHDR_NUM;
+
+ bzero(&elf_file, sizeof (elf_file));
+
+ elf_file.ehdr.e_ident[EI_MAG0] = ELFMAG0;
+ elf_file.ehdr.e_ident[EI_MAG1] = ELFMAG1;
+ elf_file.ehdr.e_ident[EI_MAG2] = ELFMAG2;
+ elf_file.ehdr.e_ident[EI_MAG3] = ELFMAG3;
+ elf_file.ehdr.e_ident[EI_VERSION] = EV_CURRENT;
+ elf_file.ehdr.e_ident[EI_CLASS] = ELFCLASS64;
+#if defined(_BIG_ENDIAN)
+ elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2MSB;
+#elif defined(_LITTLE_ENDIAN)
+ elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2LSB;
+#endif
+ elf_file.ehdr.e_type = ET_REL;
+#if defined(__sparc)
+ elf_file.ehdr.e_machine = EM_SPARCV9;
+#elif defined(__i386) || defined(__amd64)
+ elf_file.ehdr.e_machine = EM_AMD64;
+#endif
+ elf_file.ehdr.e_version = EV_CURRENT;
+ elf_file.ehdr.e_shoff = sizeof (Elf64_Ehdr);
+ elf_file.ehdr.e_ehsize = sizeof (Elf64_Ehdr);
+ elf_file.ehdr.e_phentsize = sizeof (Elf64_Phdr);
+ elf_file.ehdr.e_shentsize = sizeof (Elf64_Shdr);
+ elf_file.ehdr.e_shnum = nshdr;
+ elf_file.ehdr.e_shstrndx = ESHDR_SHSTRTAB;
+ off = sizeof (elf_file) + nshdr * sizeof (Elf64_Shdr);
+
+ shp = &elf_file.shdr[ESHDR_SHSTRTAB];
+ shp->sh_name = 1; /* DTRACE_SHSTRTAB64[1] = ".shstrtab" */
+ shp->sh_type = SHT_STRTAB;
+ shp->sh_offset = off;
+ shp->sh_size = sizeof (DTRACE_SHSTRTAB64);
+ shp->sh_addralign = sizeof (char);
+ off = P2ROUNDUP(shp->sh_offset + shp->sh_size, 8);
+
+ shp = &elf_file.shdr[ESHDR_DOF];
+ shp->sh_name = 11; /* DTRACE_SHSTRTAB64[11] = ".SUNW_dof" */
+ shp->sh_flags = SHF_ALLOC;
+ shp->sh_type = SHT_SUNW_dof;
+ shp->sh_offset = off;
+ shp->sh_size = dof->dofh_filesz;
+ shp->sh_addralign = 8;
+ off = shp->sh_offset + shp->sh_size;
+
+ shp = &elf_file.shdr[ESHDR_STRTAB];
+ shp->sh_name = 21; /* DTRACE_SHSTRTAB64[21] = ".strtab" */
+ shp->sh_flags = SHF_ALLOC;
+ shp->sh_type = SHT_STRTAB;
+ shp->sh_offset = off;
+ shp->sh_size = de.de_strlen;
+ shp->sh_addralign = sizeof (char);
+ off = P2ROUNDUP(shp->sh_offset + shp->sh_size, 8);
+
+ shp = &elf_file.shdr[ESHDR_SYMTAB];
+ shp->sh_name = 29; /* DTRACE_SHSTRTAB64[29] = ".symtab" */
+ shp->sh_flags = SHF_ALLOC;
+ shp->sh_type = SHT_SYMTAB;
+ shp->sh_entsize = sizeof (Elf64_Sym);
+ shp->sh_link = ESHDR_STRTAB;
+ shp->sh_offset = off;
+ shp->sh_info = de.de_global;
+ shp->sh_size = de.de_nsym * sizeof (Elf64_Sym);
+ shp->sh_addralign = 8;
+ off = P2ROUNDUP(shp->sh_offset + shp->sh_size, 8);
+
+ if (de.de_nrel == 0) {
+ if (dt_write(dtp, fd, &elf_file,
+ sizeof (elf_file)) != sizeof (elf_file) ||
+ PWRITE_SCN(ESHDR_SHSTRTAB, DTRACE_SHSTRTAB64) ||
+ PWRITE_SCN(ESHDR_STRTAB, de.de_strtab) ||
+ PWRITE_SCN(ESHDR_SYMTAB, de.de_sym) ||
+ PWRITE_SCN(ESHDR_DOF, dof)) {
+ ret = dt_set_errno(dtp, errno);
+ }
+ } else {
+ shp = &elf_file.shdr[ESHDR_REL];
+ shp->sh_name = 37; /* DTRACE_SHSTRTAB64[37] = ".rel.SUNW_dof" */
+ shp->sh_flags = SHF_ALLOC;
+ shp->sh_type = SHT_RELA;
+ shp->sh_entsize = sizeof (de.de_rel[0]);
+ shp->sh_link = ESHDR_SYMTAB;
+ shp->sh_info = ESHDR_DOF;
+ shp->sh_offset = off;
+ shp->sh_size = de.de_nrel * sizeof (de.de_rel[0]);
+ shp->sh_addralign = 8;
+
+ if (dt_write(dtp, fd, &elf_file,
+ sizeof (elf_file)) != sizeof (elf_file) ||
+ PWRITE_SCN(ESHDR_SHSTRTAB, DTRACE_SHSTRTAB64) ||
+ PWRITE_SCN(ESHDR_STRTAB, de.de_strtab) ||
+ PWRITE_SCN(ESHDR_SYMTAB, de.de_sym) ||
+ PWRITE_SCN(ESHDR_REL, de.de_rel) ||
+ PWRITE_SCN(ESHDR_DOF, dof)) {
+ ret = dt_set_errno(dtp, errno);
+ }
+ }
+
+ free(de.de_strtab);
+ free(de.de_sym);
+ free(de.de_rel);
+
+ return (ret);
+}
+
+static int
+dt_symtab_lookup(Elf_Data *data_sym, int nsym, uintptr_t addr, uint_t shn,
+ GElf_Sym *sym)
+{
+ int i, ret = -1;
+ GElf_Sym s;
+
+ for (i = 0; i < nsym && gelf_getsym(data_sym, i, sym) != NULL; i++) {
+ if (GELF_ST_TYPE(sym->st_info) == STT_FUNC &&
+ shn == sym->st_shndx &&
+ sym->st_value <= addr &&
+ addr < sym->st_value + sym->st_size) {
+ if (GELF_ST_BIND(sym->st_info) == STB_GLOBAL)
+ return (0);
+
+ ret = 0;
+ s = *sym;
+ }
+ }
+
+ if (ret == 0)
+ *sym = s;
+ return (ret);
+}
+
+#if defined(__sparc)
+
+#define DT_OP_RET 0x81c7e008
+#define DT_OP_NOP 0x01000000
+#define DT_OP_CALL 0x40000000
+#define DT_OP_CLR_O0 0x90102000
+
+#define DT_IS_MOV_O7(inst) (((inst) & 0xffffe000) == 0x9e100000)
+#define DT_IS_RESTORE(inst) (((inst) & 0xc1f80000) == 0x81e80000)
+#define DT_IS_RETL(inst) (((inst) & 0xfff83fff) == 0x81c02008)
+
+#define DT_RS2(inst) ((inst) & 0x1f)
+#define DT_MAKE_RETL(reg) (0x81c02008 | ((reg) << 14))
+
+/*ARGSUSED*/
+static int
+dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
+ uint32_t *off)
+{
+ uint32_t *ip;
+
+ if ((rela->r_offset & (sizeof (uint32_t) - 1)) != 0)
+ return (-1);
+
+ /*LINTED*/
+ ip = (uint32_t *)(p + rela->r_offset);
+
+ /*
+ * We only know about some specific relocation types.
+ */
+ if (GELF_R_TYPE(rela->r_info) != R_SPARC_WDISP30 &&
+ GELF_R_TYPE(rela->r_info) != R_SPARC_WPLT30)
+ return (-1);
+
+ /*
+ * We may have already processed this object file in an earlier linker
+ * invocation. Check to see if the present instruction sequence matches
+ * the one we would install below.
+ */
+ if (isenabled) {
+ if (ip[0] == DT_OP_NOP) {
+ (*off) += sizeof (ip[0]);
+ return (0);
+ }
+ } else {
+ if (DT_IS_RESTORE(ip[1])) {
+ if (ip[0] == DT_OP_RET) {
+ (*off) += sizeof (ip[0]);
+ return (0);
+ }
+ } else if (DT_IS_MOV_O7(ip[1])) {
+ if (DT_IS_RETL(ip[0]))
+ return (0);
+ } else {
+ if (ip[0] == DT_OP_NOP) {
+ (*off) += sizeof (ip[0]);
+ return (0);
+ }
+ }
+ }
+
+ /*
+ * We only expect call instructions with a displacement of 0.
+ */
+ if (ip[0] != DT_OP_CALL) {
+ dt_dprintf("found %x instead of a call instruction at %llx\n",
+ ip[0], (u_longlong_t)rela->r_offset);
+ return (-1);
+ }
+
+ if (isenabled) {
+ /*
+ * It would necessarily indicate incorrect usage if an is-
+ * enabled probe were tail-called so flag that as an error.
+ * It's also potentially (very) tricky to handle gracefully,
+ * but could be done if this were a desired use scenario.
+ */
+ if (DT_IS_RESTORE(ip[1]) || DT_IS_MOV_O7(ip[1])) {
+ dt_dprintf("tail call to is-enabled probe at %llx\n",
+ (u_longlong_t)rela->r_offset);
+ return (-1);
+ }
+
+
+ /*
+ * On SPARC, we take advantage of the fact that the first
+ * argument shares the same register as for the return value.
+ * The macro handles the work of zeroing that register so we
+ * don't need to do anything special here. We instrument the
+ * instruction in the delay slot as we'll need to modify the
+ * return register after that instruction has been emulated.
+ */
+ ip[0] = DT_OP_NOP;
+ (*off) += sizeof (ip[0]);
+ } else {
+ /*
+ * If the call is followed by a restore, it's a tail call so
+ * change the call to a ret. If the call if followed by a mov
+ * of a register into %o7, it's a tail call in leaf context
+ * so change the call to a retl-like instruction that returns
+ * to that register value + 8 (rather than the typical %o7 +
+ * 8); the delay slot instruction is left, but should have no
+ * effect. Otherwise we change the call to be a nop. We
+ * identify the subsequent instruction as the probe point in
+ * all but the leaf tail-call case to ensure that arguments to
+ * the probe are complete and consistent. An astute, though
+ * largely hypothetical, observer would note that there is the
+ * possibility of a false-positive probe firing if the function
+ * contained a branch to the instruction in the delay slot of
+ * the call. Fixing this would require significant in-kernel
+ * modifications, and isn't worth doing until we see it in the
+ * wild.
+ */
+ if (DT_IS_RESTORE(ip[1])) {
+ ip[0] = DT_OP_RET;
+ (*off) += sizeof (ip[0]);
+ } else if (DT_IS_MOV_O7(ip[1])) {
+ ip[0] = DT_MAKE_RETL(DT_RS2(ip[1]));
+ } else {
+ ip[0] = DT_OP_NOP;
+ (*off) += sizeof (ip[0]);
+ }
+ }
+
+ return (0);
+}
+
+#elif defined(__i386) || defined(__amd64)
+
+#define DT_OP_NOP 0x90
+#define DT_OP_RET 0xc3
+#define DT_OP_CALL 0xe8
+#define DT_OP_JMP32 0xe9
+#define DT_OP_REX_RAX 0x48
+#define DT_OP_XOR_EAX_0 0x33
+#define DT_OP_XOR_EAX_1 0xc0
+
+static int
+dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
+ uint32_t *off)
+{
+ uint8_t *ip = (uint8_t *)(p + rela->r_offset - 1);
+ uint8_t ret;
+
+ /*
+ * On x86, the first byte of the instruction is the call opcode and
+ * the next four bytes are the 32-bit address; the relocation is for
+ * the address operand. We back up the offset to the first byte of
+ * the instruction. For is-enabled probes, we later advance the offset
+ * so that it hits the first nop in the instruction sequence.
+ */
+ (*off) -= 1;
+
+ /*
+ * We only know about some specific relocation types. Luckily
+ * these types have the same values on both 32-bit and 64-bit
+ * x86 architectures.
+ */
+ if (GELF_R_TYPE(rela->r_info) != R_386_PC32 &&
+ GELF_R_TYPE(rela->r_info) != R_386_PLT32)
+ return (-1);
+
+ /*
+ * We may have already processed this object file in an earlier linker
+ * invocation. Check to see if the present instruction sequence matches
+ * the one we would install. For is-enabled probes, we advance the
+ * offset to the first nop instruction in the sequence to match the
+ * text modification code below.
+ */
+ if (!isenabled) {
+ if ((ip[0] == DT_OP_NOP || ip[0] == DT_OP_RET) &&
+ ip[1] == DT_OP_NOP && ip[2] == DT_OP_NOP &&
+ ip[3] == DT_OP_NOP && ip[4] == DT_OP_NOP)
+ return (0);
+ } else if (dtp->dt_oflags & DTRACE_O_LP64) {
+ if (ip[0] == DT_OP_REX_RAX &&
+ ip[1] == DT_OP_XOR_EAX_0 && ip[2] == DT_OP_XOR_EAX_1 &&
+ (ip[3] == DT_OP_NOP || ip[3] == DT_OP_RET) &&
+ ip[4] == DT_OP_NOP) {
+ (*off) += 3;
+ return (0);
+ }
+ } else {
+ if (ip[0] == DT_OP_XOR_EAX_0 && ip[1] == DT_OP_XOR_EAX_1 &&
+ (ip[2] == DT_OP_NOP || ip[2] == DT_OP_RET) &&
+ ip[3] == DT_OP_NOP && ip[4] == DT_OP_NOP) {
+ (*off) += 2;
+ return (0);
+ }
+ }
+
+ /*
+ * We expect either a call instrution with a 32-bit displacement or a
+ * jmp instruction with a 32-bit displacement acting as a tail-call.
+ */
+ if (ip[0] != DT_OP_CALL && ip[0] != DT_OP_JMP32) {
+ dt_dprintf("found %x instead of a call or jmp instruction at "
+ "%llx\n", ip[0], (u_longlong_t)rela->r_offset);
+ return (-1);
+ }
+
+ ret = (ip[0] == DT_OP_JMP32) ? DT_OP_RET : DT_OP_NOP;
+
+ /*
+ * Establish the instruction sequence -- all nops for probes, and an
+ * instruction to clear the return value register (%eax/%rax) followed
+ * by nops for is-enabled probes. For is-enabled probes, we advance
+ * the offset to the first nop. This isn't stricly necessary but makes
+ * for more readable disassembly when the probe is enabled.
+ */
+ if (!isenabled) {
+ ip[0] = ret;
+ ip[1] = DT_OP_NOP;
+ ip[2] = DT_OP_NOP;
+ ip[3] = DT_OP_NOP;
+ ip[4] = DT_OP_NOP;
+ } else if (dtp->dt_oflags & DTRACE_O_LP64) {
+ ip[0] = DT_OP_REX_RAX;
+ ip[1] = DT_OP_XOR_EAX_0;
+ ip[2] = DT_OP_XOR_EAX_1;
+ ip[3] = ret;
+ ip[4] = DT_OP_NOP;
+ (*off) += 3;
+ } else {
+ ip[0] = DT_OP_XOR_EAX_0;
+ ip[1] = DT_OP_XOR_EAX_1;
+ ip[2] = ret;
+ ip[3] = DT_OP_NOP;
+ ip[4] = DT_OP_NOP;
+ (*off) += 2;
+ }
+
+ return (0);
+}
+
+#else
+#error unknown ISA
+#endif
+
+/*PRINTFLIKE5*/
+static int
+dt_link_error(dtrace_hdl_t *dtp, Elf *elf, int fd, dt_link_pair_t *bufs,
+ const char *format, ...)
+{
+ va_list ap;
+ dt_link_pair_t *pair;
+
+ va_start(ap, format);
+ dt_set_errmsg(dtp, NULL, NULL, NULL, 0, format, ap);
+ va_end(ap);
+
+ if (elf != NULL)
+ (void) elf_end(elf);
+
+ if (fd >= 0)
+ (void) close(fd);
+
+ while ((pair = bufs) != NULL) {
+ bufs = pair->dlp_next;
+ dt_free(dtp, pair->dlp_str);
+ dt_free(dtp, pair->dlp_sym);
+ dt_free(dtp, pair);
+ }
+
+ return (dt_set_errno(dtp, EDT_COMPILER));
+}
+
+static int
+process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
+{
+ static const char dt_prefix[] = "__dtrace";
+ static const char dt_enabled[] = "enabled";
+ static const char dt_symprefix[] = "$dtrace";
+ static const char dt_symfmt[] = "%s%d.%s";
+ int fd, i, ndx, eprobe, mod = 0;
+ Elf *elf = NULL;
+ GElf_Ehdr ehdr;
+ Elf_Scn *scn_rel, *scn_sym, *scn_str, *scn_tgt;
+ Elf_Data *data_rel, *data_sym, *data_str, *data_tgt;
+ GElf_Shdr shdr_rel, shdr_sym, shdr_str, shdr_tgt;
+ GElf_Sym rsym, fsym, dsym;
+ GElf_Rela rela;
+ char *s, *p, *r;
+ char pname[DTRACE_PROVNAMELEN];
+ dt_provider_t *pvp;
+ dt_probe_t *prp;
+ uint32_t off, eclass, emachine1, emachine2;
+ size_t symsize, nsym, isym, istr, len;
+ key_t objkey;
+ dt_link_pair_t *pair, *bufs = NULL;
+ dt_strtab_t *strtab;
+
+ if ((fd = open64(obj, O_RDWR)) == -1) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "failed to open %s: %s", obj, strerror(errno)));
+ }
+
+ if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "failed to process %s: %s", obj, elf_errmsg(elf_errno())));
+ }
+
+ switch (elf_kind(elf)) {
+ case ELF_K_ELF:
+ break;
+ case ELF_K_AR:
+ return (dt_link_error(dtp, elf, fd, bufs, "archives are not "
+ "permitted; use the contents of the archive instead: %s",
+ obj));
+ default:
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "invalid file type: %s", obj));
+ }
+
+ if (gelf_getehdr(elf, &ehdr) == NULL) {
+ return (dt_link_error(dtp, elf, fd, bufs, "corrupt file: %s",
+ obj));
+ }
+
+ if (dtp->dt_oflags & DTRACE_O_LP64) {
+ eclass = ELFCLASS64;
+#if defined(__sparc)
+ emachine1 = emachine2 = EM_SPARCV9;
+#elif defined(__i386) || defined(__amd64)
+ emachine1 = emachine2 = EM_AMD64;
+#endif
+ symsize = sizeof (Elf64_Sym);
+ } else {
+ eclass = ELFCLASS32;
+#if defined(__sparc)
+ emachine1 = EM_SPARC;
+ emachine2 = EM_SPARC32PLUS;
+#elif defined(__i386) || defined(__amd64)
+ emachine1 = emachine2 = EM_386;
+#endif
+ symsize = sizeof (Elf32_Sym);
+ }
+
+ if (ehdr.e_ident[EI_CLASS] != eclass) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "incorrect ELF class for object file: %s", obj));
+ }
+
+ if (ehdr.e_machine != emachine1 && ehdr.e_machine != emachine2) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "incorrect ELF machine type for object file: %s", obj));
+ }
+
+ /*
+ * We use this token as a relatively unique handle for this file on the
+ * system in order to disambiguate potential conflicts between files of
+ * the same name which contain identially named local symbols.
+ */
+ if ((objkey = ftok(obj, 0)) == (key_t)-1) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "failed to generate unique key for object file: %s", obj));
+ }
+
+ scn_rel = NULL;
+ while ((scn_rel = elf_nextscn(elf, scn_rel)) != NULL) {
+ if (gelf_getshdr(scn_rel, &shdr_rel) == NULL)
+ goto err;
+
+ /*
+ * Skip any non-relocation sections.
+ */
+ if (shdr_rel.sh_type != SHT_RELA && shdr_rel.sh_type != SHT_REL)
+ continue;
+
+ if ((data_rel = elf_getdata(scn_rel, NULL)) == NULL)
+ goto err;
+
+ /*
+ * Grab the section, section header and section data for the
+ * symbol table that this relocation section references.
+ */
+ if ((scn_sym = elf_getscn(elf, shdr_rel.sh_link)) == NULL ||
+ gelf_getshdr(scn_sym, &shdr_sym) == NULL ||
+ (data_sym = elf_getdata(scn_sym, NULL)) == NULL)
+ goto err;
+
+ /*
+ * Ditto for that symbol table's string table.
+ */
+ if ((scn_str = elf_getscn(elf, shdr_sym.sh_link)) == NULL ||
+ gelf_getshdr(scn_str, &shdr_str) == NULL ||
+ (data_str = elf_getdata(scn_str, NULL)) == NULL)
+ goto err;
+
+ /*
+ * Grab the section, section header and section data for the
+ * target section for the relocations. For the relocations
+ * we're looking for -- this will typically be the text of the
+ * object file.
+ */
+ if ((scn_tgt = elf_getscn(elf, shdr_rel.sh_info)) == NULL ||
+ gelf_getshdr(scn_tgt, &shdr_tgt) == NULL ||
+ (data_tgt = elf_getdata(scn_tgt, NULL)) == NULL)
+ goto err;
+
+ /*
+ * We're looking for relocations to symbols matching this form:
+ *
+ * __dtrace[enabled]_<prov>___<probe>
+ *
+ * For the generated object, we need to record the location
+ * identified by the relocation, and create a new relocation
+ * in the generated object that will be resolved at link time
+ * to the location of the function in which the probe is
+ * embedded. In the target object, we change the matched symbol
+ * so that it will be ignored at link time, and we modify the
+ * target (text) section to replace the call instruction with
+ * one or more nops.
+ *
+ * If the function containing the probe is locally scoped
+ * (static), we create an alias used by the relocation in the
+ * generated object. The alias, a new symbol, will be global
+ * (so that the relocation from the generated object can be
+ * resolved), and hidden (so that it is converted to a local
+ * symbol at link time). Such aliases have this form:
+ *
+ * $dtrace<key>.<function>
+ *
+ * We take a first pass through all the relocations to
+ * populate our string table and count the number of extra
+ * symbols we'll require.
+ */
+ strtab = dt_strtab_create(1);
+ nsym = 0;
+ isym = data_sym->d_size / symsize;
+ istr = data_str->d_size;
+
+ for (i = 0; i < shdr_rel.sh_size / shdr_rel.sh_entsize; i++) {
+
+ if (shdr_rel.sh_type == SHT_RELA) {
+ if (gelf_getrela(data_rel, i, &rela) == NULL)
+ continue;
+ } else {
+ GElf_Rel rel;
+ if (gelf_getrel(data_rel, i, &rel) == NULL)
+ continue;
+ rela.r_offset = rel.r_offset;
+ rela.r_info = rel.r_info;
+ rela.r_addend = 0;
+ }
+
+ if (gelf_getsym(data_sym, GELF_R_SYM(rela.r_info),
+ &rsym) == NULL) {
+ dt_strtab_destroy(strtab);
+ goto err;
+ }
+
+ s = (char *)data_str->d_buf + rsym.st_name;
+
+ if (strncmp(s, dt_prefix, sizeof (dt_prefix) - 1) != 0)
+ continue;
+
+ if (dt_symtab_lookup(data_sym, isym, rela.r_offset,
+ shdr_rel.sh_info, &fsym) != 0) {
+ dt_strtab_destroy(strtab);
+ goto err;
+ }
+
+ if (GELF_ST_BIND(fsym.st_info) != STB_LOCAL)
+ continue;
+
+ if (fsym.st_name > data_str->d_size) {
+ dt_strtab_destroy(strtab);
+ goto err;
+ }
+
+ s = (char *)data_str->d_buf + fsym.st_name;
+
+ /*
+ * If this symbol isn't of type function, we've really
+ * driven off the rails or the object file is corrupt.
+ */
+ if (GELF_ST_TYPE(fsym.st_info) != STT_FUNC) {
+ dt_strtab_destroy(strtab);
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "expected %s to be of type function", s));
+ }
+
+ len = snprintf(NULL, 0, dt_symfmt, dt_symprefix,
+ objkey, s) + 1;
+ if ((p = dt_alloc(dtp, len)) == NULL) {
+ dt_strtab_destroy(strtab);
+ goto err;
+ }
+ (void) snprintf(p, len, dt_symfmt, dt_symprefix,
+ objkey, s);
+
+ if (dt_strtab_index(strtab, p) == -1) {
+ nsym++;
+ (void) dt_strtab_insert(strtab, p);
+ }
+
+ dt_free(dtp, p);
+ }
+
+ /*
+ * If needed, allocate the additional space for the symbol
+ * table and string table copying the old data into the new
+ * buffers, and marking the buffers as dirty. We inject those
+ * newly allocated buffers into the libelf data structures, but
+ * are still responsible for freeing them once we're done with
+ * the elf handle.
+ */
+ if (nsym > 0) {
+ /*
+ * The first byte of the string table is reserved for
+ * the \0 entry.
+ */
+ len = dt_strtab_size(strtab) - 1;
+
+ assert(len > 0);
+ assert(dt_strtab_index(strtab, "") == 0);
+
+ dt_strtab_destroy(strtab);
+
+ if ((pair = dt_alloc(dtp, sizeof (*pair))) == NULL)
+ goto err;
+
+ if ((pair->dlp_str = dt_alloc(dtp, data_str->d_size +
+ len)) == NULL) {
+ dt_free(dtp, pair);
+ goto err;
+ }
+
+ if ((pair->dlp_sym = dt_alloc(dtp, data_sym->d_size +
+ nsym * symsize)) == NULL) {
+ dt_free(dtp, pair->dlp_str);
+ dt_free(dtp, pair);
+ goto err;
+ }
+
+ pair->dlp_next = bufs;
+ bufs = pair;
+
+ bcopy(data_str->d_buf, pair->dlp_str, data_str->d_size);
+ data_str->d_buf = pair->dlp_str;
+ data_str->d_size += len;
+ (void) elf_flagdata(data_str, ELF_C_SET, ELF_F_DIRTY);
+
+ shdr_str.sh_size += len;
+ (void) gelf_update_shdr(scn_str, &shdr_str);
+
+ bcopy(data_sym->d_buf, pair->dlp_sym, data_sym->d_size);
+ data_sym->d_buf = pair->dlp_sym;
+ data_sym->d_size += nsym * symsize;
+ (void) elf_flagdata(data_sym, ELF_C_SET, ELF_F_DIRTY);
+
+ shdr_sym.sh_size += nsym * symsize;
+ (void) gelf_update_shdr(scn_sym, &shdr_sym);
+
+ nsym += isym;
+ } else {
+ dt_strtab_destroy(strtab);
+ }
+
+ /*
+ * Now that the tables have been allocated, perform the
+ * modifications described above.
+ */
+ for (i = 0; i < shdr_rel.sh_size / shdr_rel.sh_entsize; i++) {
+
+ if (shdr_rel.sh_type == SHT_RELA) {
+ if (gelf_getrela(data_rel, i, &rela) == NULL)
+ continue;
+ } else {
+ GElf_Rel rel;
+ if (gelf_getrel(data_rel, i, &rel) == NULL)
+ continue;
+ rela.r_offset = rel.r_offset;
+ rela.r_info = rel.r_info;
+ rela.r_addend = 0;
+ }
+
+ ndx = GELF_R_SYM(rela.r_info);
+
+ if (gelf_getsym(data_sym, ndx, &rsym) == NULL ||
+ rsym.st_name > data_str->d_size)
+ goto err;
+
+ s = (char *)data_str->d_buf + rsym.st_name;
+
+ if (strncmp(s, dt_prefix, sizeof (dt_prefix) - 1) != 0)
+ continue;
+
+ s += sizeof (dt_prefix) - 1;
+
+ /*
+ * Check to see if this is an 'is-enabled' check as
+ * opposed to a normal probe.
+ */
+ if (strncmp(s, dt_enabled,
+ sizeof (dt_enabled) - 1) == 0) {
+ s += sizeof (dt_enabled) - 1;
+ eprobe = 1;
+ *eprobesp = 1;
+ dt_dprintf("is-enabled probe\n");
+ } else {
+ eprobe = 0;
+ dt_dprintf("normal probe\n");
+ }
+
+ if (*s++ != '_')
+ goto err;
+
+ if ((p = strstr(s, "___")) == NULL ||
+ p - s >= sizeof (pname))
+ goto err;
+
+ bcopy(s, pname, p - s);
+ pname[p - s] = '\0';
+
+ p = strhyphenate(p + 3); /* strlen("___") */
+
+ if (dt_symtab_lookup(data_sym, isym, rela.r_offset,
+ shdr_rel.sh_info, &fsym) != 0)
+ goto err;
+
+ if (fsym.st_name > data_str->d_size)
+ goto err;
+
+ assert(GELF_ST_TYPE(fsym.st_info) == STT_FUNC);
+
+ /*
+ * If a NULL relocation name is passed to
+ * dt_probe_define(), the function name is used for the
+ * relocation. The relocation needs to use a mangled
+ * name if the symbol is locally scoped; the function
+ * name may need to change if we've found the global
+ * alias for the locally scoped symbol (we prefer
+ * global symbols to locals in dt_symtab_lookup()).
+ */
+ s = (char *)data_str->d_buf + fsym.st_name;
+ r = NULL;
+
+ if (GELF_ST_BIND(fsym.st_info) == STB_LOCAL) {
+ dsym = fsym;
+ dsym.st_name = istr;
+ dsym.st_info = GELF_ST_INFO(STB_GLOBAL,
+ STT_FUNC);
+ dsym.st_other =
+ ELF64_ST_VISIBILITY(STV_ELIMINATE);
+ (void) gelf_update_sym(data_sym, isym, &dsym);
+
+ r = (char *)data_str->d_buf + istr;
+ istr += 1 + sprintf(r, dt_symfmt,
+ dt_symprefix, objkey, s);
+ isym++;
+ assert(isym <= nsym);
+
+ } else if (strncmp(s, dt_symprefix,
+ strlen(dt_symprefix)) == 0) {
+ r = s;
+ if ((s = strchr(s, '.')) == NULL)
+ goto err;
+ s++;
+ }
+
+ if ((pvp = dt_provider_lookup(dtp, pname)) == NULL) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "no such provider %s", pname));
+ }
+
+ if ((prp = dt_probe_lookup(pvp, p)) == NULL) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "no such probe %s", p));
+ }
+
+ assert(fsym.st_value <= rela.r_offset);
+
+ off = rela.r_offset - fsym.st_value;
+ if (dt_modtext(dtp, data_tgt->d_buf, eprobe,
+ &rela, &off) != 0) {
+ goto err;
+ }
+
+ if (dt_probe_define(pvp, prp, s, r, off, eprobe) != 0) {
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "failed to allocate space for probe"));
+ }
+
+ mod = 1;
+ (void) elf_flagdata(data_tgt, ELF_C_SET, ELF_F_DIRTY);
+
+ /*
+ * This symbol may already have been marked to
+ * be ignored by another relocation referencing
+ * the same symbol or if this object file has
+ * already been processed by an earlier link
+ * invocation.
+ */
+ if (rsym.st_shndx != SHN_SUNW_IGNORE) {
+ rsym.st_shndx = SHN_SUNW_IGNORE;
+ (void) gelf_update_sym(data_sym, ndx, &rsym);
+ }
+ }
+ }
+
+ if (mod && elf_update(elf, ELF_C_WRITE) == -1)
+ goto err;
+
+ (void) elf_end(elf);
+ (void) close(fd);
+
+ while ((pair = bufs) != NULL) {
+ bufs = pair->dlp_next;
+ dt_free(dtp, pair->dlp_str);
+ dt_free(dtp, pair->dlp_sym);
+ dt_free(dtp, pair);
+ }
+
+ return (0);
+
+err:
+ return (dt_link_error(dtp, elf, fd, bufs,
+ "an error was encountered while processing %s", obj));
+}
+
+int
+dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
+ const char *file, int objc, char *const objv[])
+{
+ char drti[PATH_MAX];
+ dof_hdr_t *dof;
+ int fd, status, i, cur;
+ char *cmd, tmp;
+ size_t len;
+ int eprobes = 0, ret = 0;
+
+ /*
+ * A NULL program indicates a special use in which we just link
+ * together a bunch of object files specified in objv and then
+ * unlink(2) those object files.
+ */
+ if (pgp == NULL) {
+ const char *fmt = "%s -o %s -r";
+
+ len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file) + 1;
+
+ for (i = 0; i < objc; i++)
+ len += strlen(objv[i]) + 1;
+
+ cmd = alloca(len);
+
+ cur = snprintf(cmd, len, fmt, dtp->dt_ld_path, file);
+
+ for (i = 0; i < objc; i++)
+ cur += snprintf(cmd + cur, len - cur, " %s", objv[i]);
+
+ if ((status = system(cmd)) == -1) {
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "failed to run %s: %s", dtp->dt_ld_path,
+ strerror(errno)));
+ }
+
+ if (WIFSIGNALED(status)) {
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "failed to link %s: %s failed due to signal %d",
+ file, dtp->dt_ld_path, WTERMSIG(status)));
+ }
+
+ if (WEXITSTATUS(status) != 0) {
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "failed to link %s: %s exited with status %d\n",
+ file, dtp->dt_ld_path, WEXITSTATUS(status)));
+ }
+
+ for (i = 0; i < objc; i++) {
+ if (strcmp(objv[i], file) != 0)
+ (void) unlink(objv[i]);
+ }
+
+ return (0);
+ }
+
+ for (i = 0; i < objc; i++) {
+ if (process_obj(dtp, objv[i], &eprobes) != 0)
+ return (-1); /* errno is set for us */
+ }
+
+ /*
+ * If there are is-enabled probes then we need to force use of DOF
+ * version 2.
+ */
+ if (eprobes && pgp->dp_dofversion < DOF_VERSION_2)
+ pgp->dp_dofversion = DOF_VERSION_2;
+
+ if ((dof = dtrace_dof_create(dtp, pgp, dflags)) == NULL)
+ return (-1); /* errno is set for us */
+
+ /*
+ * Create a temporary file and then unlink it if we're going to
+ * combine it with drti.o later. We can still refer to it in child
+ * processes as /dev/fd/<fd>.
+ */
+ if ((fd = open64(file, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) {
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "failed to open %s: %s", file, strerror(errno)));
+ }
+
+ /*
+ * If -xlinktype=DOF has been selected, just write out the DOF.
+ * Otherwise proceed to the default of generating and linking ELF.
+ */
+ switch (dtp->dt_linktype) {
+ case DT_LTYP_DOF:
+ if (dt_write(dtp, fd, dof, dof->dofh_filesz) < dof->dofh_filesz)
+ ret = errno;
+
+ if (close(fd) != 0 && ret == 0)
+ ret = errno;
+
+ if (ret != 0) {
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "failed to write %s: %s", file, strerror(ret)));
+ }
+
+ return (0);
+
+ case DT_LTYP_ELF:
+ break; /* fall through to the rest of dtrace_program_link() */
+
+ default:
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "invalid link type %u\n", dtp->dt_linktype));
+ }
+
+
+ if (!dtp->dt_lazyload)
+ (void) unlink(file);
+
+ if (dtp->dt_oflags & DTRACE_O_LP64)
+ status = dump_elf64(dtp, dof, fd);
+ else
+ status = dump_elf32(dtp, dof, fd);
+
+ if (status != 0 || lseek(fd, 0, SEEK_SET) != 0) {
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "failed to write %s: %s", file, strerror(errno)));
+ }
+
+ if (!dtp->dt_lazyload) {
+ const char *fmt = "%s -o %s -r -Blocal -Breduce /dev/fd/%d %s";
+
+ if (dtp->dt_oflags & DTRACE_O_LP64) {
+ (void) snprintf(drti, sizeof (drti),
+ "%s/64/drti.o", _dtrace_libdir);
+ } else {
+ (void) snprintf(drti, sizeof (drti),
+ "%s/drti.o", _dtrace_libdir);
+ }
+
+ len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, fd,
+ drti) + 1;
+
+ cmd = alloca(len);
+
+ (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, fd, drti);
+
+ if ((status = system(cmd)) == -1) {
+ ret = dt_link_error(dtp, NULL, -1, NULL,
+ "failed to run %s: %s", dtp->dt_ld_path,
+ strerror(errno));
+ goto done;
+ }
+
+ (void) close(fd); /* release temporary file */
+
+ if (WIFSIGNALED(status)) {
+ ret = dt_link_error(dtp, NULL, -1, NULL,
+ "failed to link %s: %s failed due to signal %d",
+ file, dtp->dt_ld_path, WTERMSIG(status));
+ goto done;
+ }
+
+ if (WEXITSTATUS(status) != 0) {
+ ret = dt_link_error(dtp, NULL, -1, NULL,
+ "failed to link %s: %s exited with status %d\n",
+ file, dtp->dt_ld_path, WEXITSTATUS(status));
+ goto done;
+ }
+ } else {
+ (void) close(fd);
+ }
+
+done:
+ dtrace_dof_destroy(dtp, dof);
+ return (ret);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.c
new file mode 100644
index 00000000..598433ed
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.c
@@ -0,0 +1,117 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+/*
+ * Simple doubly-linked list implementation. This implementation assumes that
+ * each list element contains an embedded dt_list_t (previous and next
+ * pointers), which is typically the first member of the element struct.
+ * An additional dt_list_t is used to store the head (dl_next) and tail
+ * (dl_prev) pointers. The current head and tail list elements have their
+ * previous and next pointers set to NULL, respectively.
+ */
+
+#ifndef VBOX
+#include <unistd.h>
+#include <assert.h>
+#else
+# include "VBoxDTraceLibCWrappers.h"
+#endif
+#include <dt_list.h>
+
+void
+dt_list_append(dt_list_t *dlp, void *new)
+{
+ dt_list_t *p = dlp->dl_prev; /* p = tail list element */
+ dt_list_t *q = new; /* q = new list element */
+
+ dlp->dl_prev = q;
+ q->dl_prev = p;
+ q->dl_next = NULL;
+
+ if (p != NULL) {
+ assert(p->dl_next == NULL);
+ p->dl_next = q;
+ } else {
+ assert(dlp->dl_next == NULL);
+ dlp->dl_next = q;
+ }
+}
+
+void
+dt_list_prepend(dt_list_t *dlp, void *new)
+{
+ dt_list_t *p = new; /* p = new list element */
+ dt_list_t *q = dlp->dl_next; /* q = head list element */
+
+ dlp->dl_next = p;
+ p->dl_prev = NULL;
+ p->dl_next = q;
+
+ if (q != NULL) {
+ assert(q->dl_prev == NULL);
+ q->dl_prev = p;
+ } else {
+ assert(dlp->dl_prev == NULL);
+ dlp->dl_prev = p;
+ }
+}
+
+void
+dt_list_insert(dt_list_t *dlp, void *after_me, void *new)
+{
+ dt_list_t *p = after_me;
+ dt_list_t *q = new;
+
+ if (p == NULL || p->dl_next == NULL) {
+ dt_list_append(dlp, new);
+ return;
+ }
+
+ q->dl_next = p->dl_next;
+ q->dl_prev = p;
+ p->dl_next = q;
+ q->dl_next->dl_prev = q;
+}
+
+void
+dt_list_delete(dt_list_t *dlp, void *existing)
+{
+ dt_list_t *p = existing;
+
+ if (p->dl_prev != NULL)
+ p->dl_prev->dl_next = p->dl_next;
+ else
+ dlp->dl_next = p->dl_next;
+
+ if (p->dl_next != NULL)
+ p->dl_next->dl_prev = p->dl_prev;
+ else
+ dlp->dl_prev = p->dl_prev;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.h
new file mode 100644
index 00000000..d13987dc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_list.h
@@ -0,0 +1,57 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_LIST_H
+#define _DT_LIST_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#else
+# include "VBoxDTraceTypes.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dt_list {
+ struct dt_list *dl_prev;
+ struct dt_list *dl_next;
+} dt_list_t;
+
+#define dt_list_prev(elem) ((void *)(((dt_list_t *)(elem))->dl_prev))
+#define dt_list_next(elem) ((void *)(((dt_list_t *)(elem))->dl_next))
+
+extern void dt_list_append(dt_list_t *, void *);
+extern void dt_list_prepend(dt_list_t *, void *);
+extern void dt_list_insert(dt_list_t *, void *, void *);
+extern void dt_list_delete(dt_list_t *, void *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_LIST_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_map.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_map.c
new file mode 100644
index 00000000..89921dfb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_map.c
@@ -0,0 +1,428 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdlib.h>
+#include <strings.h>
+#include <errno.h>
+#include <unistd.h>
+#include <assert.h>
+#endif
+
+#include <dt_impl.h>
+#include <dt_printf.h>
+
+static int
+dt_epid_add(dtrace_hdl_t *dtp, dtrace_epid_t id)
+{
+ dtrace_id_t max;
+ int rval, i, maxformat;
+ dtrace_eprobedesc_t *enabled, *nenabled;
+ dtrace_probedesc_t *probe;
+
+ while (id >= (max = VBDTCAST(dtrace_id_t)dtp->dt_maxprobe) || dtp->dt_pdesc == NULL) {
+ dtrace_id_t new_max = max ? (max << 1) : 1;
+ size_t nsize = new_max * sizeof (void *);
+ dtrace_probedesc_t **new_pdesc;
+ dtrace_eprobedesc_t **new_edesc;
+
+ if ((new_pdesc = malloc(nsize)) == NULL ||
+ (new_edesc = malloc(nsize)) == NULL) {
+ free(new_pdesc);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ bzero(new_pdesc, nsize);
+ bzero(new_edesc, nsize);
+
+ if (dtp->dt_pdesc != NULL) {
+ size_t osize = max * sizeof (void *);
+
+ bcopy(dtp->dt_pdesc, new_pdesc, osize);
+ free(dtp->dt_pdesc);
+
+ bcopy(dtp->dt_edesc, new_edesc, osize);
+ free(dtp->dt_edesc);
+ }
+
+ dtp->dt_pdesc = new_pdesc;
+ dtp->dt_edesc = new_edesc;
+ dtp->dt_maxprobe = new_max;
+ }
+
+ if (dtp->dt_pdesc[id] != NULL)
+ return (0);
+
+ if ((enabled = malloc(sizeof (dtrace_eprobedesc_t))) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ bzero(enabled, sizeof (dtrace_eprobedesc_t));
+ enabled->dtepd_epid = id;
+ enabled->dtepd_nrecs = 1;
+
+ if (dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled) == -1) {
+ rval = dt_set_errno(dtp, errno);
+ free(enabled);
+ return (rval);
+ }
+
+ if (DTRACE_SIZEOF_EPROBEDESC(enabled) != sizeof (*enabled)) {
+ /*
+ * There must be more than one action. Allocate the
+ * appropriate amount of space and try again.
+ */
+ if ((nenabled =
+ malloc(DTRACE_SIZEOF_EPROBEDESC(enabled))) != NULL)
+ bcopy(enabled, nenabled, sizeof (*enabled));
+
+ free(enabled);
+
+ if ((enabled = nenabled) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ rval = dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled);
+
+ if (rval == -1) {
+ rval = dt_set_errno(dtp, errno);
+ free(enabled);
+ return (rval);
+ }
+ }
+
+ if ((probe = malloc(sizeof (dtrace_probedesc_t))) == NULL) {
+ free(enabled);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ probe->dtpd_id = enabled->dtepd_probeid;
+
+ if (dt_ioctl(dtp, DTRACEIOC_PROBES, probe) == -1) {
+ rval = dt_set_errno(dtp, errno);
+ goto err;
+ }
+
+ for (i = 0; i < enabled->dtepd_nrecs; i++) {
+ dtrace_fmtdesc_t fmt;
+ dtrace_recdesc_t *rec = &enabled->dtepd_rec[i];
+
+ if (!DTRACEACT_ISPRINTFLIKE(rec->dtrd_action))
+ continue;
+
+ if (rec->dtrd_format == 0)
+ continue;
+
+ if (rec->dtrd_format <= dtp->dt_maxformat &&
+ dtp->dt_formats[rec->dtrd_format - 1] != NULL)
+ continue;
+
+ bzero(&fmt, sizeof (fmt));
+ fmt.dtfd_format = rec->dtrd_format;
+ fmt.dtfd_string = NULL;
+ fmt.dtfd_length = 0;
+
+ if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) {
+ rval = dt_set_errno(dtp, errno);
+ goto err;
+ }
+
+ if ((fmt.dtfd_string = malloc(fmt.dtfd_length)) == NULL) {
+ rval = dt_set_errno(dtp, EDT_NOMEM);
+ goto err;
+ }
+
+ if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) {
+ rval = dt_set_errno(dtp, errno);
+ free(fmt.dtfd_string);
+ goto err;
+ }
+
+ while (rec->dtrd_format > (maxformat = dtp->dt_maxformat)) {
+ int new_max = maxformat ? (maxformat << 1) : 1;
+ size_t nsize = new_max * sizeof (void *);
+ size_t osize = maxformat * sizeof (void *);
+ void **new_formats = malloc(nsize);
+
+ if (new_formats == NULL) {
+ rval = dt_set_errno(dtp, EDT_NOMEM);
+ free(fmt.dtfd_string);
+ goto err;
+ }
+
+ bzero(new_formats, nsize);
+ bcopy(dtp->dt_formats, new_formats, osize);
+ free(dtp->dt_formats);
+
+ dtp->dt_formats = new_formats;
+ dtp->dt_maxformat = new_max;
+ }
+
+ dtp->dt_formats[rec->dtrd_format - 1] =
+ rec->dtrd_action == DTRACEACT_PRINTA ?
+ dtrace_printa_create(dtp, fmt.dtfd_string) :
+ dtrace_printf_create(dtp, fmt.dtfd_string);
+
+ free(fmt.dtfd_string);
+
+ if (dtp->dt_formats[rec->dtrd_format - 1] == NULL) {
+ rval = -1; /* dt_errno is set for us */
+ goto err;
+ }
+ }
+
+ dtp->dt_pdesc[id] = probe;
+ dtp->dt_edesc[id] = enabled;
+
+ return (0);
+
+err:
+ /*
+ * If we failed, free our allocated probes. Note that if we failed
+ * while allocating formats, we aren't going to free formats that
+ * we have already allocated. This is okay; these formats are
+ * hanging off of dt_formats and will therefore not be leaked.
+ */
+ free(enabled);
+ free(probe);
+ return (rval);
+}
+
+int
+dt_epid_lookup(dtrace_hdl_t *dtp, dtrace_epid_t epid,
+ dtrace_eprobedesc_t **epdp, dtrace_probedesc_t **pdp)
+{
+ int rval;
+
+ if (epid >= dtp->dt_maxprobe || dtp->dt_pdesc[epid] == NULL) {
+ if ((rval = dt_epid_add(dtp, epid)) != 0)
+ return (rval);
+ }
+
+ assert(epid < dtp->dt_maxprobe);
+ assert(dtp->dt_edesc[epid] != NULL);
+ assert(dtp->dt_pdesc[epid] != NULL);
+ *epdp = dtp->dt_edesc[epid];
+ *pdp = dtp->dt_pdesc[epid];
+
+ return (0);
+}
+
+void
+dt_epid_destroy(dtrace_hdl_t *dtp)
+{
+ size_t i;
+
+ assert((dtp->dt_pdesc != NULL && dtp->dt_edesc != NULL &&
+ dtp->dt_maxprobe > 0) || (dtp->dt_pdesc == NULL &&
+ dtp->dt_edesc == NULL && dtp->dt_maxprobe == 0));
+
+ if (dtp->dt_pdesc == NULL)
+ return;
+
+ for (i = 0; i < dtp->dt_maxprobe; i++) {
+ if (dtp->dt_edesc[i] == NULL) {
+ assert(dtp->dt_pdesc[i] == NULL);
+ continue;
+ }
+
+ assert(dtp->dt_pdesc[i] != NULL);
+ free(dtp->dt_edesc[i]);
+ free(dtp->dt_pdesc[i]);
+ }
+
+ free(dtp->dt_pdesc);
+ dtp->dt_pdesc = NULL;
+
+ free(dtp->dt_edesc);
+ dtp->dt_edesc = NULL;
+ dtp->dt_maxprobe = 0;
+}
+
+void *
+dt_format_lookup(dtrace_hdl_t *dtp, int format)
+{
+ if (format == 0 || format > dtp->dt_maxformat)
+ return (NULL);
+
+ if (dtp->dt_formats == NULL)
+ return (NULL);
+
+ return (dtp->dt_formats[format - 1]);
+}
+
+void
+dt_format_destroy(dtrace_hdl_t *dtp)
+{
+ int i;
+
+ for (i = 0; i < dtp->dt_maxformat; i++) {
+ if (dtp->dt_formats[i] != NULL)
+ dt_printf_destroy(dtp->dt_formats[i]);
+ }
+
+ free(dtp->dt_formats);
+ dtp->dt_formats = NULL;
+}
+
+static int
+dt_aggid_add(dtrace_hdl_t *dtp, dtrace_aggid_t id)
+{
+ dtrace_id_t max;
+ dtrace_epid_t epid;
+ int rval;
+
+ while (id >= (max = VBDTCAST(dtrace_id_t)dtp->dt_maxagg) || dtp->dt_aggdesc == NULL) {
+ dtrace_id_t new_max = max ? (max << 1) : 1;
+ size_t nsize = new_max * sizeof (void *);
+ dtrace_aggdesc_t **new_aggdesc;
+
+ if ((new_aggdesc = malloc(nsize)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ bzero(new_aggdesc, nsize);
+
+ if (dtp->dt_aggdesc != NULL) {
+ bcopy(dtp->dt_aggdesc, new_aggdesc,
+ max * sizeof (void *));
+ free(dtp->dt_aggdesc);
+ }
+
+ dtp->dt_aggdesc = new_aggdesc;
+ dtp->dt_maxagg = new_max;
+ }
+
+ if (dtp->dt_aggdesc[id] == NULL) {
+ dtrace_aggdesc_t *agg, *nagg;
+
+ if ((agg = malloc(sizeof (dtrace_aggdesc_t))) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ bzero(agg, sizeof (dtrace_aggdesc_t));
+ agg->dtagd_id = id;
+ agg->dtagd_nrecs = 1;
+
+ if (dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg) == -1) {
+ rval = dt_set_errno(dtp, errno);
+ free(agg);
+ return (rval);
+ }
+
+ if (DTRACE_SIZEOF_AGGDESC(agg) != sizeof (*agg)) {
+ /*
+ * There must be more than one action. Allocate the
+ * appropriate amount of space and try again.
+ */
+ if ((nagg = malloc(DTRACE_SIZEOF_AGGDESC(agg))) != NULL)
+ bcopy(agg, nagg, sizeof (*agg));
+
+ free(agg);
+
+ if ((agg = nagg) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ rval = dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg);
+
+ if (rval == -1) {
+ rval = dt_set_errno(dtp, errno);
+ free(agg);
+ return (rval);
+ }
+ }
+
+ /*
+ * If we have a uarg, it's a pointer to the compiler-generated
+ * statement; we'll use this value to get the name and
+ * compiler-generated variable ID for the aggregation. If
+ * we're grabbing an anonymous enabling, this pointer value
+ * is obviously meaningless -- and in this case, we can't
+ * provide the compiler-generated aggregation information.
+ */
+ if (dtp->dt_options[DTRACEOPT_GRABANON] == DTRACEOPT_UNSET &&
+ agg->dtagd_rec[0].dtrd_uarg != 0 /*NULL*/) {
+ dtrace_stmtdesc_t *sdp;
+ dt_ident_t *aid;
+
+ sdp = (dtrace_stmtdesc_t *)(uintptr_t)
+ agg->dtagd_rec[0].dtrd_uarg;
+ aid = sdp->dtsd_aggdata;
+ agg->dtagd_name = aid->di_name;
+ agg->dtagd_varid = aid->di_id;
+ } else {
+ agg->dtagd_varid = DTRACE_AGGVARIDNONE;
+ }
+
+ if ((epid = agg->dtagd_epid) >= dtp->dt_maxprobe ||
+ dtp->dt_pdesc[epid] == NULL) {
+ if ((rval = dt_epid_add(dtp, epid)) != 0) {
+ free(agg);
+ return (rval);
+ }
+ }
+
+ dtp->dt_aggdesc[id] = agg;
+ }
+
+ return (0);
+}
+
+int
+dt_aggid_lookup(dtrace_hdl_t *dtp, dtrace_aggid_t aggid,
+ dtrace_aggdesc_t **adp)
+{
+ int rval;
+
+ if (aggid >= dtp->dt_maxagg || dtp->dt_aggdesc[aggid] == NULL) {
+ if ((rval = dt_aggid_add(dtp, aggid)) != 0)
+ return (rval);
+ }
+
+ assert(aggid < dtp->dt_maxagg);
+ assert(dtp->dt_aggdesc[aggid] != NULL);
+ *adp = dtp->dt_aggdesc[aggid];
+
+ return (0);
+}
+
+void
+dt_aggid_destroy(dtrace_hdl_t *dtp)
+{
+ size_t i;
+
+ assert((dtp->dt_aggdesc != NULL && dtp->dt_maxagg != 0) ||
+ (dtp->dt_aggdesc == NULL && dtp->dt_maxagg == 0));
+
+ if (dtp->dt_aggdesc == NULL)
+ return;
+
+ for (i = 0; i < dtp->dt_maxagg; i++) {
+ if (dtp->dt_aggdesc[i] != NULL)
+ free(dtp->dt_aggdesc[i]);
+ }
+
+ free(dtp->dt_aggdesc);
+ dtp->dt_aggdesc = NULL;
+ dtp->dt_maxagg = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.c
new file mode 100644
index 00000000..8cafc7a8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.c
@@ -0,0 +1,1348 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <sys/types.h>
+#include <sys/modctl.h>
+#include <sys/kobj.h>
+#include <sys/kobj_impl.h>
+#include <sys/sysmacros.h>
+#include <sys/elf.h>
+#include <sys/task.h>
+
+#include <unistd.h>
+#include <project.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <libelf.h>
+#include <limits.h>
+#include <assert.h>
+#include <errno.h>
+#include <dirent.h>
+#else /* VBOX */
+# include <iprt/formats/elf32.h>
+# ifdef _MSC_VER
+# include <process.h>
+# define getuid() 0
+# define getgid() 0
+# define geteuid() 0
+# define getegid() 0
+# define getpid() _getpid()
+# define getppid() 0
+
+# define getpgid(a) 0
+# define getsid(a) 0
+# else
+# include <unistd.h>
+# endif
+# define getprojid() 0
+# define gettaskid() 0
+
+#endif /* VBOX */
+
+#include <dt_strtab.h>
+#include <dt_module.h>
+#include <dt_impl.h>
+
+
+static const char *dt_module_strtab; /* active strtab for qsort callbacks */
+
+static void
+dt_module_symhash_insert(dt_module_t *dmp, const char *name, uint_t id)
+{
+ dt_sym_t *dsp = &dmp->dm_symchains[dmp->dm_symfree];
+ uint_t h;
+
+ assert(dmp->dm_symfree < dmp->dm_nsymelems + 1);
+
+ dsp->ds_symid = id;
+ h = dt_strtab_hash(name, NULL) % dmp->dm_nsymbuckets;
+ dsp->ds_next = dmp->dm_symbuckets[h];
+ dmp->dm_symbuckets[h] = dmp->dm_symfree++;
+}
+
+static uint_t
+dt_module_syminit32(dt_module_t *dmp)
+{
+#if STT_NUM != (STT_TLS + 1)
+#error "STT_NUM has grown. update dt_module_syminit32()"
+#endif
+
+ const Elf32_Sym *sym = dmp->dm_symtab.cts_data;
+ const char *base = dmp->dm_strtab.cts_data;
+ size_t ss_size = dmp->dm_strtab.cts_size;
+ uint_t i, n = dmp->dm_nsymelems;
+ uint_t asrsv = 0;
+
+ for (i = 0; i < n; i++, sym++) {
+ const char *name = base + sym->st_name;
+ uchar_t type = ELF32_ST_TYPE(sym->st_info);
+
+ if (type >= STT_NUM || type == STT_SECTION)
+ continue; /* skip sections and unknown types */
+
+ if (sym->st_name == 0 || sym->st_name >= ss_size)
+ continue; /* skip null or invalid names */
+
+ if (sym->st_value != 0 &&
+ (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size))
+ asrsv++; /* reserve space in the address map */
+
+ dt_module_symhash_insert(dmp, name, i);
+ }
+
+ return (asrsv);
+}
+
+static uint_t
+dt_module_syminit64(dt_module_t *dmp)
+{
+#if STT_NUM != (STT_TLS + 1)
+#error "STT_NUM has grown. update dt_module_syminit64()"
+#endif
+
+ const Elf64_Sym *sym = dmp->dm_symtab.cts_data;
+ const char *base = dmp->dm_strtab.cts_data;
+ size_t ss_size = dmp->dm_strtab.cts_size;
+ uint_t i, n = dmp->dm_nsymelems;
+ uint_t asrsv = 0;
+
+ for (i = 0; i < n; i++, sym++) {
+ const char *name = base + sym->st_name;
+ uchar_t type = ELF64_ST_TYPE(sym->st_info);
+
+ if (type >= STT_NUM || type == STT_SECTION)
+ continue; /* skip sections and unknown types */
+
+ if (sym->st_name == 0 || sym->st_name >= ss_size)
+ continue; /* skip null or invalid names */
+
+ if (sym->st_value != 0 &&
+ (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size))
+ asrsv++; /* reserve space in the address map */
+
+ dt_module_symhash_insert(dmp, name, i);
+ }
+
+ return (asrsv);
+}
+
+/*
+ * Sort comparison function for 32-bit symbol address-to-name lookups. We sort
+ * symbols by value. If values are equal, we prefer the symbol that is
+ * non-zero sized, typed, not weak, or lexically first, in that order.
+ */
+static int
+dt_module_symcomp32(const void *lp, const void *rp)
+{
+ Elf32_Sym *lhs = *((Elf32_Sym **)lp);
+ Elf32_Sym *rhs = *((Elf32_Sym **)rp);
+
+ if (lhs->st_value != rhs->st_value)
+ return (lhs->st_value > rhs->st_value ? 1 : -1);
+
+ if ((lhs->st_size == 0) != (rhs->st_size == 0))
+ return (lhs->st_size == 0 ? 1 : -1);
+
+ if ((ELF32_ST_TYPE(lhs->st_info) == STT_NOTYPE) !=
+ (ELF32_ST_TYPE(rhs->st_info) == STT_NOTYPE))
+ return (ELF32_ST_TYPE(lhs->st_info) == STT_NOTYPE ? 1 : -1);
+
+ if ((ELF32_ST_BIND(lhs->st_info) == STB_WEAK) !=
+ (ELF32_ST_BIND(rhs->st_info) == STB_WEAK))
+ return (ELF32_ST_BIND(lhs->st_info) == STB_WEAK ? 1 : -1);
+
+ return (strcmp(dt_module_strtab + lhs->st_name,
+ dt_module_strtab + rhs->st_name));
+}
+
+/*
+ * Sort comparison function for 64-bit symbol address-to-name lookups. We sort
+ * symbols by value. If values are equal, we prefer the symbol that is
+ * non-zero sized, typed, not weak, or lexically first, in that order.
+ */
+static int
+dt_module_symcomp64(const void *lp, const void *rp)
+{
+ Elf64_Sym *lhs = *((Elf64_Sym **)lp);
+ Elf64_Sym *rhs = *((Elf64_Sym **)rp);
+
+ if (lhs->st_value != rhs->st_value)
+ return (lhs->st_value > rhs->st_value ? 1 : -1);
+
+ if ((lhs->st_size == 0) != (rhs->st_size == 0))
+ return (lhs->st_size == 0 ? 1 : -1);
+
+ if ((ELF64_ST_TYPE(lhs->st_info) == STT_NOTYPE) !=
+ (ELF64_ST_TYPE(rhs->st_info) == STT_NOTYPE))
+ return (ELF64_ST_TYPE(lhs->st_info) == STT_NOTYPE ? 1 : -1);
+
+ if ((ELF64_ST_BIND(lhs->st_info) == STB_WEAK) !=
+ (ELF64_ST_BIND(rhs->st_info) == STB_WEAK))
+ return (ELF64_ST_BIND(lhs->st_info) == STB_WEAK ? 1 : -1);
+
+ return (strcmp(dt_module_strtab + lhs->st_name,
+ dt_module_strtab + rhs->st_name));
+}
+
+static void
+dt_module_symsort32(dt_module_t *dmp)
+{
+ Elf32_Sym *symtab = (Elf32_Sym *)dmp->dm_symtab.cts_data;
+ Elf32_Sym **sympp = (Elf32_Sym **)dmp->dm_asmap;
+ const dt_sym_t *dsp = dmp->dm_symchains + 1;
+ uint_t i, n = dmp->dm_symfree;
+
+ for (i = 1; i < n; i++, dsp++) {
+ Elf32_Sym *sym = symtab + dsp->ds_symid;
+ if (sym->st_value != 0 &&
+ (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size))
+ *sympp++ = sym;
+ }
+
+ dmp->dm_aslen = (uint_t)(sympp - (Elf32_Sym **)dmp->dm_asmap);
+ assert(dmp->dm_aslen <= dmp->dm_asrsv);
+
+ dt_module_strtab = dmp->dm_strtab.cts_data;
+ qsort(dmp->dm_asmap, dmp->dm_aslen,
+ sizeof (Elf32_Sym *), dt_module_symcomp32);
+ dt_module_strtab = NULL;
+}
+
+static void
+dt_module_symsort64(dt_module_t *dmp)
+{
+ Elf64_Sym *symtab = (Elf64_Sym *)dmp->dm_symtab.cts_data;
+ Elf64_Sym **sympp = (Elf64_Sym **)dmp->dm_asmap;
+ const dt_sym_t *dsp = dmp->dm_symchains + 1;
+ uint_t i, n = dmp->dm_symfree;
+
+ for (i = 1; i < n; i++, dsp++) {
+ Elf64_Sym *sym = symtab + dsp->ds_symid;
+ if (sym->st_value != 0 &&
+ (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size))
+ *sympp++ = sym;
+ }
+
+ dmp->dm_aslen = (uint_t)(sympp - (Elf64_Sym **)dmp->dm_asmap);
+ assert(dmp->dm_aslen <= dmp->dm_asrsv);
+
+ dt_module_strtab = dmp->dm_strtab.cts_data;
+ qsort(dmp->dm_asmap, dmp->dm_aslen,
+ sizeof (Elf64_Sym *), dt_module_symcomp64);
+ dt_module_strtab = NULL;
+}
+
+static GElf_Sym *
+dt_module_symgelf32(const Elf32_Sym *src, GElf_Sym *dst)
+{
+ if (dst != NULL) {
+ dst->st_name = src->st_name;
+ dst->st_info = src->st_info;
+ dst->st_other = src->st_other;
+ dst->st_shndx = src->st_shndx;
+ dst->st_value = src->st_value;
+ dst->st_size = src->st_size;
+ }
+
+ return (dst);
+}
+
+static GElf_Sym *
+dt_module_symgelf64(const Elf64_Sym *src, GElf_Sym *dst)
+{
+ if (dst != NULL)
+ bcopy(src, dst, sizeof (GElf_Sym));
+
+ return (dst);
+}
+
+static GElf_Sym *
+dt_module_symname32(dt_module_t *dmp, const char *name,
+ GElf_Sym *symp, uint_t *idp)
+{
+ const Elf32_Sym *symtab = dmp->dm_symtab.cts_data;
+ const char *strtab = dmp->dm_strtab.cts_data;
+
+ const Elf32_Sym *sym;
+ const dt_sym_t *dsp;
+ uint_t i, h;
+
+ if (dmp->dm_nsymelems == 0)
+ return (NULL);
+
+ h = dt_strtab_hash(name, NULL) % dmp->dm_nsymbuckets;
+
+ for (i = dmp->dm_symbuckets[h]; i != 0; i = dsp->ds_next) {
+ dsp = &dmp->dm_symchains[i];
+ sym = symtab + dsp->ds_symid;
+
+ if (strcmp(name, strtab + sym->st_name) == 0) {
+ if (idp != NULL)
+ *idp = dsp->ds_symid;
+ return (dt_module_symgelf32(sym, symp));
+ }
+ }
+
+ return (NULL);
+}
+
+static GElf_Sym *
+dt_module_symname64(dt_module_t *dmp, const char *name,
+ GElf_Sym *symp, uint_t *idp)
+{
+ const Elf64_Sym *symtab = dmp->dm_symtab.cts_data;
+ const char *strtab = dmp->dm_strtab.cts_data;
+
+ const Elf64_Sym *sym;
+ const dt_sym_t *dsp;
+ uint_t i, h;
+
+ if (dmp->dm_nsymelems == 0)
+ return (NULL);
+
+ h = dt_strtab_hash(name, NULL) % dmp->dm_nsymbuckets;
+
+ for (i = dmp->dm_symbuckets[h]; i != 0; i = dsp->ds_next) {
+ dsp = &dmp->dm_symchains[i];
+ sym = symtab + dsp->ds_symid;
+
+ if (strcmp(name, strtab + sym->st_name) == 0) {
+ if (idp != NULL)
+ *idp = dsp->ds_symid;
+ return (dt_module_symgelf64(sym, symp));
+ }
+ }
+
+ return (NULL);
+}
+
+static GElf_Sym *
+dt_module_symaddr32(dt_module_t *dmp, GElf_Addr addr,
+ GElf_Sym *symp, uint_t *idp)
+{
+ const Elf32_Sym **asmap = (const Elf32_Sym **)dmp->dm_asmap;
+ const Elf32_Sym *symtab = dmp->dm_symtab.cts_data;
+ const Elf32_Sym *sym;
+
+ uint_t i, mid, lo = 0, hi = dmp->dm_aslen - 1;
+ Elf32_Addr v;
+
+ if (dmp->dm_aslen == 0)
+ return (NULL);
+
+ while (hi - lo > 1) {
+ mid = (lo + hi) / 2;
+ if (addr >= asmap[mid]->st_value)
+ lo = mid;
+ else
+ hi = mid;
+ }
+
+ i = addr < asmap[hi]->st_value ? lo : hi;
+ sym = asmap[i];
+ v = sym->st_value;
+
+ /*
+ * If the previous entry has the same value, improve our choice. The
+ * order of equal-valued symbols is determined by the comparison func.
+ */
+ while (i-- != 0 && asmap[i]->st_value == v)
+ sym = asmap[i];
+
+ if (addr - sym->st_value < MAX(sym->st_size, 1)) {
+ if (idp != NULL)
+ *idp = (uint_t)(sym - symtab);
+ return (dt_module_symgelf32(sym, symp));
+ }
+
+ return (NULL);
+}
+
+static GElf_Sym *
+dt_module_symaddr64(dt_module_t *dmp, GElf_Addr addr,
+ GElf_Sym *symp, uint_t *idp)
+{
+ const Elf64_Sym **asmap = (const Elf64_Sym **)dmp->dm_asmap;
+ const Elf64_Sym *symtab = dmp->dm_symtab.cts_data;
+ const Elf64_Sym *sym;
+
+ uint_t i, mid, lo = 0, hi = dmp->dm_aslen - 1;
+ Elf64_Addr v;
+
+ if (dmp->dm_aslen == 0)
+ return (NULL);
+
+ while (hi - lo > 1) {
+ mid = (lo + hi) / 2;
+ if (addr >= asmap[mid]->st_value)
+ lo = mid;
+ else
+ hi = mid;
+ }
+
+ i = addr < asmap[hi]->st_value ? lo : hi;
+ sym = asmap[i];
+ v = sym->st_value;
+
+ /*
+ * If the previous entry has the same value, improve our choice. The
+ * order of equal-valued symbols is determined by the comparison func.
+ */
+ while (i-- != 0 && asmap[i]->st_value == v)
+ sym = asmap[i];
+
+ if (addr - sym->st_value < MAX(sym->st_size, 1)) {
+ if (idp != NULL)
+ *idp = (uint_t)(sym - symtab);
+ return (dt_module_symgelf64(sym, symp));
+ }
+
+ return (NULL);
+}
+
+static const dt_modops_t dt_modops_32 = {
+ dt_module_syminit32,
+ dt_module_symsort32,
+ dt_module_symname32,
+ dt_module_symaddr32
+};
+
+static const dt_modops_t dt_modops_64 = {
+ dt_module_syminit64,
+ dt_module_symsort64,
+ dt_module_symname64,
+ dt_module_symaddr64
+};
+
+dt_module_t *
+dt_module_create(dtrace_hdl_t *dtp, const char *name)
+{
+ uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_modbuckets;
+ dt_module_t *dmp;
+
+ for (dmp = dtp->dt_mods[h]; dmp != NULL; dmp = dmp->dm_next) {
+ if (strcmp(dmp->dm_name, name) == 0)
+ return (dmp);
+ }
+
+ if ((dmp = malloc(sizeof (dt_module_t))) == NULL)
+ return (NULL); /* caller must handle allocation failure */
+
+ bzero(dmp, sizeof (dt_module_t));
+ (void) strlcpy(dmp->dm_name, name, sizeof (dmp->dm_name));
+ dt_list_append(&dtp->dt_modlist, dmp);
+ dmp->dm_next = dtp->dt_mods[h];
+ dtp->dt_mods[h] = dmp;
+ dtp->dt_nmods++;
+
+ if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64)
+ dmp->dm_ops = &dt_modops_64;
+ else
+ dmp->dm_ops = &dt_modops_32;
+
+ return (dmp);
+}
+
+dt_module_t *
+dt_module_lookup_by_name(dtrace_hdl_t *dtp, const char *name)
+{
+ uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_modbuckets;
+ dt_module_t *dmp;
+
+ for (dmp = dtp->dt_mods[h]; dmp != NULL; dmp = dmp->dm_next) {
+ if (strcmp(dmp->dm_name, name) == 0)
+ return (dmp);
+ }
+
+ return (NULL);
+}
+
+/*ARGSUSED*/
+dt_module_t *
+dt_module_lookup_by_ctf(dtrace_hdl_t *dtp, ctf_file_t *ctfp)
+{
+ RT_NOREF1(dtp);
+ return (ctfp ? ctf_getspecific(ctfp) : NULL);
+}
+
+static int
+dt_module_load_sect(dtrace_hdl_t *dtp, dt_module_t *dmp, ctf_sect_t *ctsp)
+{
+#ifndef VBOX /** @todo consider this later */
+ const char *s;
+ size_t shstrs;
+ GElf_Shdr sh;
+ Elf_Data *dp;
+ Elf_Scn *sp;
+
+ if (elf_getshdrstrndx(dmp->dm_elf, &shstrs) == -1)
+ return (dt_set_errno(dtp, EDT_NOTLOADED));
+
+ for (sp = NULL; (sp = elf_nextscn(dmp->dm_elf, sp)) != NULL; ) {
+ if (gelf_getshdr(sp, &sh) == NULL || sh.sh_type == SHT_NULL ||
+ (s = elf_strptr(dmp->dm_elf, shstrs, sh.sh_name)) == NULL)
+ continue; /* skip any malformed sections */
+
+ if (sh.sh_type == ctsp->cts_type &&
+ sh.sh_entsize == ctsp->cts_entsize &&
+ strcmp(s, ctsp->cts_name) == 0)
+ break; /* section matches specification */
+ }
+
+ /*
+ * If the section isn't found, return success but leave cts_data set
+ * to NULL and cts_size set to zero for our caller.
+ */
+ if (sp == NULL || (dp = elf_getdata(sp, NULL)) == NULL)
+ return (0);
+
+ ctsp->cts_data = dp->d_buf;
+ ctsp->cts_size = dp->d_size;
+
+ dt_dprintf("loaded %s [%s] (%lu bytes)\n",
+ dmp->dm_name, ctsp->cts_name, (ulong_t)ctsp->cts_size);
+
+#else /* VBOX */
+ RT_NOREF3(dtp, dmp, ctsp);
+#endif /* VBOX */
+ return (0);
+}
+
+int
+dt_module_load(dtrace_hdl_t *dtp, dt_module_t *dmp)
+{
+ if (dmp->dm_flags & DT_DM_LOADED)
+ return (0); /* module is already loaded */
+
+ dmp->dm_ctdata.cts_name = ".SUNW_ctf";
+ dmp->dm_ctdata.cts_type = SHT_PROGBITS;
+ dmp->dm_ctdata.cts_flags = 0;
+ dmp->dm_ctdata.cts_data = NULL;
+ dmp->dm_ctdata.cts_size = 0;
+ dmp->dm_ctdata.cts_entsize = 0;
+ dmp->dm_ctdata.cts_offset = 0;
+
+ dmp->dm_symtab.cts_name = ".symtab";
+ dmp->dm_symtab.cts_type = SHT_SYMTAB;
+ dmp->dm_symtab.cts_flags = 0;
+ dmp->dm_symtab.cts_data = NULL;
+ dmp->dm_symtab.cts_size = 0;
+ dmp->dm_symtab.cts_entsize = dmp->dm_ops == &dt_modops_64 ?
+ sizeof (Elf64_Sym) : sizeof (Elf32_Sym);
+ dmp->dm_symtab.cts_offset = 0;
+
+ dmp->dm_strtab.cts_name = ".strtab";
+ dmp->dm_strtab.cts_type = SHT_STRTAB;
+ dmp->dm_strtab.cts_flags = 0;
+ dmp->dm_strtab.cts_data = NULL;
+ dmp->dm_strtab.cts_size = 0;
+ dmp->dm_strtab.cts_entsize = 0;
+ dmp->dm_strtab.cts_offset = 0;
+
+ /*
+ * Attempt to load the module's CTF section, symbol table section, and
+ * string table section. Note that modules may not contain CTF data:
+ * this will result in a successful load_sect but data of size zero.
+ * We will then fail if dt_module_getctf() is called, as shown below.
+ */
+ if (dt_module_load_sect(dtp, dmp, &dmp->dm_ctdata) == -1 ||
+ dt_module_load_sect(dtp, dmp, &dmp->dm_symtab) == -1 ||
+ dt_module_load_sect(dtp, dmp, &dmp->dm_strtab) == -1) {
+ dt_module_unload(dtp, dmp);
+ return (-1); /* dt_errno is set for us */
+ }
+
+ /*
+ * Allocate the hash chains and hash buckets for symbol name lookup.
+ * This is relatively simple since the symbol table is of fixed size
+ * and is known in advance. We allocate one extra element since we
+ * use element indices instead of pointers and zero is our sentinel.
+ */
+ dmp->dm_nsymelems =
+ VBDTCAST(uint_t)(dmp->dm_symtab.cts_size / dmp->dm_symtab.cts_entsize);
+
+ dmp->dm_nsymbuckets = _dtrace_strbuckets;
+ dmp->dm_symfree = 1; /* first free element is index 1 */
+
+ dmp->dm_symbuckets = malloc(sizeof (uint_t) * dmp->dm_nsymbuckets);
+ dmp->dm_symchains = malloc(sizeof (dt_sym_t) * dmp->dm_nsymelems + 1);
+
+ if (dmp->dm_symbuckets == NULL || dmp->dm_symchains == NULL) {
+ dt_module_unload(dtp, dmp);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ bzero(dmp->dm_symbuckets, sizeof (uint_t) * dmp->dm_nsymbuckets);
+ bzero(dmp->dm_symchains, sizeof (dt_sym_t) * dmp->dm_nsymelems + 1);
+
+ /*
+ * Iterate over the symbol table data buffer and insert each symbol
+ * name into the name hash if the name and type are valid. Then
+ * allocate the address map, fill it in, and sort it.
+ */
+ dmp->dm_asrsv = dmp->dm_ops->do_syminit(dmp);
+
+ dt_dprintf("hashed %s [%s] (%u symbols)\n",
+ dmp->dm_name, dmp->dm_symtab.cts_name, dmp->dm_symfree - 1);
+
+ if ((dmp->dm_asmap = malloc(sizeof (void *) * dmp->dm_asrsv)) == NULL) {
+ dt_module_unload(dtp, dmp);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ dmp->dm_ops->do_symsort(dmp);
+
+ dt_dprintf("sorted %s [%s] (%u symbols)\n",
+ dmp->dm_name, dmp->dm_symtab.cts_name, dmp->dm_aslen);
+
+ dmp->dm_flags |= DT_DM_LOADED;
+ return (0);
+}
+
+ctf_file_t *
+dt_module_getctf(dtrace_hdl_t *dtp, dt_module_t *dmp)
+{
+ const char *parent;
+ dt_module_t *pmp;
+ ctf_file_t *pfp;
+ int model;
+
+ if (dmp->dm_ctfp != NULL || dt_module_load(dtp, dmp) != 0)
+ return (dmp->dm_ctfp);
+
+ if (dmp->dm_ops == &dt_modops_64)
+ model = CTF_MODEL_LP64;
+ else
+ model = CTF_MODEL_ILP32;
+
+ /*
+ * If the data model of the module does not match our program data
+ * model, then do not permit CTF from this module to be opened and
+ * returned to the compiler. If we support mixed data models in the
+ * future for combined kernel/user tracing, this can be removed.
+ */
+ if (dtp->dt_conf.dtc_ctfmodel != (uint_t)model) {
+ (void) dt_set_errno(dtp, EDT_DATAMODEL);
+ return (NULL);
+ }
+
+ if (dmp->dm_ctdata.cts_size == 0) {
+ (void) dt_set_errno(dtp, EDT_NOCTF);
+ return (NULL);
+ }
+
+ dmp->dm_ctfp = ctf_bufopen(&dmp->dm_ctdata,
+ &dmp->dm_symtab, &dmp->dm_strtab, &dtp->dt_ctferr);
+
+ if (dmp->dm_ctfp == NULL) {
+ (void) dt_set_errno(dtp, EDT_CTF);
+ return (NULL);
+ }
+
+ (void) ctf_setmodel(dmp->dm_ctfp, model);
+ ctf_setspecific(dmp->dm_ctfp, dmp);
+
+ if ((parent = ctf_parent_name(dmp->dm_ctfp)) != NULL) {
+ if ((pmp = dt_module_create(dtp, parent)) == NULL ||
+ (pfp = dt_module_getctf(dtp, pmp)) == NULL) {
+ if (pmp == NULL)
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ goto err;
+ }
+
+ if (ctf_import(dmp->dm_ctfp, pfp) == CTF_ERR) {
+ dtp->dt_ctferr = ctf_errno(dmp->dm_ctfp);
+ (void) dt_set_errno(dtp, EDT_CTF);
+ goto err;
+ }
+ }
+
+ dt_dprintf("loaded CTF container for %s (%p)\n",
+ dmp->dm_name, (void *)dmp->dm_ctfp);
+
+ return (dmp->dm_ctfp);
+
+err:
+ ctf_close(dmp->dm_ctfp);
+ dmp->dm_ctfp = NULL;
+ return (NULL);
+}
+
+/*ARGSUSED*/
+void
+dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp)
+{
+ RT_NOREF1(dtp);
+ ctf_close(dmp->dm_ctfp);
+ dmp->dm_ctfp = NULL;
+
+ bzero(&dmp->dm_ctdata, sizeof (ctf_sect_t));
+ bzero(&dmp->dm_symtab, sizeof (ctf_sect_t));
+ bzero(&dmp->dm_strtab, sizeof (ctf_sect_t));
+
+ if (dmp->dm_symbuckets != NULL) {
+ free(dmp->dm_symbuckets);
+ dmp->dm_symbuckets = NULL;
+ }
+
+ if (dmp->dm_symchains != NULL) {
+ free(dmp->dm_symchains);
+ dmp->dm_symchains = NULL;
+ }
+
+ if (dmp->dm_asmap != NULL) {
+ free(dmp->dm_asmap);
+ dmp->dm_asmap = NULL;
+ }
+
+ dmp->dm_symfree = 0;
+ dmp->dm_nsymbuckets = 0;
+ dmp->dm_nsymelems = 0;
+ dmp->dm_asrsv = 0;
+ dmp->dm_aslen = 0;
+
+ dmp->dm_text_va = 0/*NULL*/;
+ dmp->dm_text_size = 0;
+ dmp->dm_data_va = 0/*NULL*/;
+ dmp->dm_data_size = 0;
+ dmp->dm_bss_va = 0/*NULL*/;
+ dmp->dm_bss_size = 0;
+
+ if (dmp->dm_extern != NULL) {
+ dt_idhash_destroy(dmp->dm_extern);
+ dmp->dm_extern = NULL;
+ }
+
+#ifndef VBOX
+ (void) elf_end(dmp->dm_elf);
+ dmp->dm_elf = NULL;
+#endif
+
+ dmp->dm_flags &= ~DT_DM_LOADED;
+}
+
+void
+dt_module_destroy(dtrace_hdl_t *dtp, dt_module_t *dmp)
+{
+ uint_t h = dt_strtab_hash(dmp->dm_name, NULL) % dtp->dt_modbuckets;
+ dt_module_t **dmpp = &dtp->dt_mods[h];
+
+ dt_list_delete(&dtp->dt_modlist, dmp);
+ assert(dtp->dt_nmods != 0);
+ dtp->dt_nmods--;
+
+ /*
+ * Now remove this module from its hash chain. We expect to always
+ * find the module on its hash chain, so in this loop we assert that
+ * we don't run off the end of the list.
+ */
+ while (*dmpp != dmp) {
+ dmpp = &((*dmpp)->dm_next);
+ assert(*dmpp != NULL);
+ }
+
+ *dmpp = dmp->dm_next;
+
+ dt_module_unload(dtp, dmp);
+ free(dmp);
+}
+
+/*
+ * Insert a new external symbol reference into the specified module. The new
+ * symbol will be marked as undefined and is assigned a symbol index beyond
+ * any existing cached symbols from this module. We use the ident's di_data
+ * field to store a pointer to a copy of the dtrace_syminfo_t for this symbol.
+ */
+dt_ident_t *
+dt_module_extern(dtrace_hdl_t *dtp, dt_module_t *dmp,
+ const char *name, const dtrace_typeinfo_t *tip)
+{
+ dtrace_syminfo_t *sip;
+ dt_ident_t *idp;
+ uint_t id;
+
+ if (dmp->dm_extern == NULL && (dmp->dm_extern = dt_idhash_create(
+ "extern", NULL, dmp->dm_nsymelems, UINT_MAX)) == NULL) {
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ return (NULL);
+ }
+
+ if (dt_idhash_nextid(dmp->dm_extern, &id) == -1) {
+ (void) dt_set_errno(dtp, EDT_SYMOFLOW);
+ return (NULL);
+ }
+
+ if ((sip = malloc(sizeof (dtrace_syminfo_t))) == NULL) {
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ return (NULL);
+ }
+
+ idp = dt_idhash_insert(dmp->dm_extern, name, DT_IDENT_SYMBOL, 0, id,
+ _dtrace_symattr, 0, &dt_idops_thaw, NULL, dtp->dt_gen);
+
+ if (idp == NULL) {
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ free(sip);
+ return (NULL);
+ }
+
+ sip->dts_object = dmp->dm_name;
+ sip->dts_name = idp->di_name;
+ sip->dts_id = idp->di_id;
+
+ idp->di_data = sip;
+ idp->di_ctfp = tip->dtt_ctfp;
+ idp->di_type = tip->dtt_type;
+
+ return (idp);
+}
+
+const char *
+dt_module_modelname(dt_module_t *dmp)
+{
+ if (dmp->dm_ops == &dt_modops_64)
+ return ("64-bit");
+ else
+ return ("32-bit");
+}
+
+#ifndef VBOX
+/*
+ * Update our module cache by adding an entry for the specified module 'name'.
+ * We create the dt_module_t and populate it using /system/object/<name>/.
+ */
+static void
+dt_module_update(dtrace_hdl_t *dtp, const char *name)
+{
+ char fname[MAXPATHLEN];
+ struct stat64 st;
+ int fd, err, bits;
+
+ dt_module_t *dmp;
+ const char *s;
+ size_t shstrs;
+ GElf_Shdr sh;
+ Elf_Data *dp;
+ Elf_Scn *sp;
+
+ (void) snprintf(fname, sizeof (fname),
+ "%s/%s/object", OBJFS_ROOT, name);
+
+ if ((fd = open(fname, O_RDONLY)) == -1 || fstat64(fd, &st) == -1 ||
+ (dmp = dt_module_create(dtp, name)) == NULL) {
+ dt_dprintf("failed to open %s: %s\n", fname, strerror(errno));
+ (void) close(fd);
+ return;
+ }
+
+ /*
+ * Since the module can unload out from under us (and /system/object
+ * will return ENOENT), tell libelf to cook the entire file now and
+ * then close the underlying file descriptor immediately. If this
+ * succeeds, we know that we can continue safely using dmp->dm_elf.
+ */
+ dmp->dm_elf = elf_begin(fd, ELF_C_READ, NULL);
+ err = elf_cntl(dmp->dm_elf, ELF_C_FDREAD);
+ (void) close(fd);
+
+ if (dmp->dm_elf == NULL || err == -1 ||
+ elf_getshdrstrndx(dmp->dm_elf, &shstrs) == -1) {
+ dt_dprintf("failed to load %s: %s\n",
+ fname, elf_errmsg(elf_errno()));
+ dt_module_destroy(dtp, dmp);
+ return;
+ }
+
+ switch (gelf_getclass(dmp->dm_elf)) {
+ case ELFCLASS32:
+ dmp->dm_ops = &dt_modops_32;
+ bits = 32;
+ break;
+ case ELFCLASS64:
+ dmp->dm_ops = &dt_modops_64;
+ bits = 64;
+ break;
+ default:
+ dt_dprintf("failed to load %s: unknown ELF class\n", fname);
+ dt_module_destroy(dtp, dmp);
+ return;
+ }
+
+ /*
+ * Iterate over the section headers locating various sections of
+ * interest and use their attributes to flesh out the dt_module_t.
+ */
+ for (sp = NULL; (sp = elf_nextscn(dmp->dm_elf, sp)) != NULL; ) {
+ if (gelf_getshdr(sp, &sh) == NULL || sh.sh_type == SHT_NULL ||
+ (s = elf_strptr(dmp->dm_elf, shstrs, sh.sh_name)) == NULL)
+ continue; /* skip any malformed sections */
+
+ if (strcmp(s, ".text") == 0) {
+ dmp->dm_text_size = sh.sh_size;
+ dmp->dm_text_va = sh.sh_addr;
+ } else if (strcmp(s, ".data") == 0) {
+ dmp->dm_data_size = sh.sh_size;
+ dmp->dm_data_va = sh.sh_addr;
+ } else if (strcmp(s, ".bss") == 0) {
+ dmp->dm_bss_size = sh.sh_size;
+ dmp->dm_bss_va = sh.sh_addr;
+ } else if (strcmp(s, ".info") == 0 &&
+ (dp = elf_getdata(sp, NULL)) != NULL) {
+ bcopy(dp->d_buf, &dmp->dm_info,
+ MIN(sh.sh_size, sizeof (dmp->dm_info)));
+ } else if (strcmp(s, ".filename") == 0 &&
+ (dp = elf_getdata(sp, NULL)) != NULL) {
+ (void) strlcpy(dmp->dm_file,
+ dp->d_buf, sizeof (dmp->dm_file));
+ }
+ }
+
+ dmp->dm_flags |= DT_DM_KERNEL;
+ dmp->dm_modid = (int)OBJFS_MODID(st.st_ino);
+
+ if (dmp->dm_info.objfs_info_primary)
+ dmp->dm_flags |= DT_DM_PRIMARY;
+
+ dt_dprintf("opened %d-bit module %s (%s) [%d]\n",
+ bits, dmp->dm_name, dmp->dm_file, dmp->dm_modid);
+}
+#endif /* !VBOX */
+
+/*
+ * Unload all the loaded modules and then refresh the module cache with the
+ * latest list of loaded modules and their address ranges.
+ */
+void
+dtrace_update(dtrace_hdl_t *dtp)
+{
+#ifndef VBOX
+ dt_module_t *dmp;
+ DIR *dirp;
+
+ for (dmp = dt_list_next(&dtp->dt_modlist);
+ dmp != NULL; dmp = dt_list_next(dmp))
+ dt_module_unload(dtp, dmp);
+
+ /*
+ * Open /system/object and attempt to create a libdtrace module for
+ * each kernel module that is loaded on the current system.
+ */
+ if (!(dtp->dt_oflags & DTRACE_O_NOSYS) &&
+ (dirp = opendir(OBJFS_ROOT)) != NULL) {
+ struct dirent *dp;
+
+ while ((dp = readdir(dirp)) != NULL) {
+ if (dp->d_name[0] != '.')
+ dt_module_update(dtp, dp->d_name);
+ }
+
+ (void) closedir(dirp);
+ }
+#endif /* !VBOX */
+
+ /*
+ * Look up all the macro identifiers and set di_id to the latest value.
+ * This code collaborates with dt_lex.l on the use of di_id. We will
+ * need to implement something fancier if we need to support non-ints.
+ */
+ dt_idhash_lookup(dtp->dt_macros, "egid")->di_id = getegid();
+ dt_idhash_lookup(dtp->dt_macros, "euid")->di_id = geteuid();
+ dt_idhash_lookup(dtp->dt_macros, "gid")->di_id = getgid();
+ dt_idhash_lookup(dtp->dt_macros, "pid")->di_id = getpid();
+ dt_idhash_lookup(dtp->dt_macros, "pgid")->di_id = getpgid(0);
+ dt_idhash_lookup(dtp->dt_macros, "ppid")->di_id = getppid();
+ dt_idhash_lookup(dtp->dt_macros, "projid")->di_id = getprojid();
+ dt_idhash_lookup(dtp->dt_macros, "sid")->di_id = getsid(0);
+ dt_idhash_lookup(dtp->dt_macros, "taskid")->di_id = gettaskid();
+ dt_idhash_lookup(dtp->dt_macros, "uid")->di_id = getuid();
+
+ /*
+ * Cache the pointers to the modules representing the base executable
+ * and the run-time linker in the dtrace client handle. Note that on
+ * x86 krtld is folded into unix, so if we don't find it, use unix
+ * instead.
+ */
+ dtp->dt_exec = dt_module_lookup_by_name(dtp, "genunix");
+ dtp->dt_rtld = dt_module_lookup_by_name(dtp, "krtld");
+ if (dtp->dt_rtld == NULL)
+ dtp->dt_rtld = dt_module_lookup_by_name(dtp, "unix");
+
+ /*
+ * If this is the first time we are initializing the module list,
+ * remove the module for genunix from the module list and then move it
+ * to the front of the module list. We do this so that type and symbol
+ * queries encounter genunix and thereby optimize for the common case
+ * in dtrace_lookup_by_name() and dtrace_lookup_by_type(), below.
+ */
+ if (dtp->dt_exec != NULL &&
+ dtp->dt_cdefs == NULL && dtp->dt_ddefs == NULL) {
+ dt_list_delete(&dtp->dt_modlist, dtp->dt_exec);
+ dt_list_prepend(&dtp->dt_modlist, dtp->dt_exec);
+ }
+}
+
+static dt_module_t *
+dt_module_from_object(dtrace_hdl_t *dtp, const char *object)
+{
+ int err = EDT_NOMOD;
+ dt_module_t *dmp;
+
+ switch ((intptr_t)object) {
+ case DTRACE_OBJ_INT_EXEC:
+ dmp = dtp->dt_exec;
+ break;
+ case DTRACE_OBJ_INT_RTLD:
+ dmp = dtp->dt_rtld;
+ break;
+ case DTRACE_OBJ_INT_CDEFS:
+ dmp = dtp->dt_cdefs;
+ break;
+ case DTRACE_OBJ_INT_DDEFS:
+ dmp = dtp->dt_ddefs;
+ break;
+ default:
+ dmp = dt_module_create(dtp, object);
+ err = EDT_NOMEM;
+ }
+
+ if (dmp == NULL)
+ (void) dt_set_errno(dtp, err);
+
+ return (dmp);
+}
+
+/*
+ * Exported interface to look up a symbol by name. We return the GElf_Sym and
+ * complete symbol information for the matching symbol.
+ */
+int
+dtrace_lookup_by_name(dtrace_hdl_t *dtp, const char *object, const char *name,
+ GElf_Sym *symp, dtrace_syminfo_t *sip)
+{
+ dt_module_t *dmp;
+ dt_ident_t *idp;
+ uint_t n, id;
+ GElf_Sym sym;
+
+ uint_t mask = 0; /* mask of dt_module flags to match */
+ uint_t bits = 0; /* flag bits that must be present */
+
+ if (object != DTRACE_OBJ_EVERY &&
+ object != DTRACE_OBJ_KMODS &&
+ object != DTRACE_OBJ_UMODS) {
+ if ((dmp = dt_module_from_object(dtp, object)) == NULL)
+ return (-1); /* dt_errno is set for us */
+
+ if (dt_module_load(dtp, dmp) == -1)
+ return (-1); /* dt_errno is set for us */
+ n = 1;
+
+ } else {
+ if (object == DTRACE_OBJ_KMODS)
+ mask = bits = DT_DM_KERNEL;
+ else if (object == DTRACE_OBJ_UMODS)
+ mask = DT_DM_KERNEL;
+
+ dmp = dt_list_next(&dtp->dt_modlist);
+ n = dtp->dt_nmods;
+ }
+
+ if (symp == NULL)
+ symp = &sym;
+
+ for (; n > 0; n--, dmp = dt_list_next(dmp)) {
+ if ((dmp->dm_flags & mask) != bits)
+ continue; /* failed to match required attributes */
+
+ if (dt_module_load(dtp, dmp) == -1)
+ continue; /* failed to load symbol table */
+
+ if (dmp->dm_ops->do_symname(dmp, name, symp, &id) != NULL) {
+ if (sip != NULL) {
+ sip->dts_object = dmp->dm_name;
+ sip->dts_name = (const char *)
+ dmp->dm_strtab.cts_data + symp->st_name;
+ sip->dts_id = id;
+ }
+ return (0);
+ }
+
+ if (dmp->dm_extern != NULL &&
+ (idp = dt_idhash_lookup(dmp->dm_extern, name)) != NULL) {
+ if (symp != &sym) {
+ symp->st_name = (uintptr_t)idp->di_name;
+ symp->st_info =
+ GELF_ST_INFO(STB_GLOBAL, STT_NOTYPE);
+ symp->st_other = 0;
+ symp->st_shndx = SHN_UNDEF;
+ symp->st_value = 0;
+ symp->st_size =
+ ctf_type_size(idp->di_ctfp, idp->di_type);
+ }
+
+ if (sip != NULL) {
+ sip->dts_object = dmp->dm_name;
+ sip->dts_name = idp->di_name;
+ sip->dts_id = idp->di_id;
+ }
+
+ return (0);
+ }
+ }
+
+ return (dt_set_errno(dtp, EDT_NOSYM));
+}
+
+/*
+ * Exported interface to look up a symbol by address. We return the GElf_Sym
+ * and complete symbol information for the matching symbol.
+ */
+int
+dtrace_lookup_by_addr(dtrace_hdl_t *dtp, GElf_Addr addr,
+ GElf_Sym *symp, dtrace_syminfo_t *sip)
+{
+ dt_module_t *dmp;
+ uint_t id VBDTMSC(0);
+ const dtrace_vector_t *v = dtp->dt_vector;
+
+ if (v != NULL)
+ return (v->dtv_lookup_by_addr(dtp->dt_varg, addr, symp, sip));
+
+ for (dmp = dt_list_next(&dtp->dt_modlist); dmp != NULL;
+ dmp = dt_list_next(dmp)) {
+ if (addr - dmp->dm_text_va < dmp->dm_text_size ||
+ addr - dmp->dm_data_va < dmp->dm_data_size ||
+ addr - dmp->dm_bss_va < dmp->dm_bss_size)
+ break;
+ }
+
+ if (dmp == NULL)
+ return (dt_set_errno(dtp, EDT_NOSYMADDR));
+
+ if (dt_module_load(dtp, dmp) == -1)
+ return (-1); /* dt_errno is set for us */
+
+ if (symp != NULL) {
+ if (dmp->dm_ops->do_symaddr(dmp, addr, symp, &id) == NULL)
+ return (dt_set_errno(dtp, EDT_NOSYMADDR));
+ }
+
+ if (sip != NULL) {
+ sip->dts_object = dmp->dm_name;
+
+ if (symp != NULL) {
+ sip->dts_name = (const char *)
+ dmp->dm_strtab.cts_data + symp->st_name;
+ sip->dts_id = id;
+ } else {
+ sip->dts_name = NULL;
+ sip->dts_id = 0;
+ }
+ }
+
+ return (0);
+}
+
+int
+dtrace_lookup_by_type(dtrace_hdl_t *dtp, const char *object, const char *name,
+ dtrace_typeinfo_t *tip)
+{
+ dtrace_typeinfo_t ti;
+ dt_module_t *dmp;
+ int found = 0;
+ ctf_id_t id;
+ uint_t n;
+ int justone;
+
+ uint_t mask = 0; /* mask of dt_module flags to match */
+ uint_t bits = 0; /* flag bits that must be present */
+
+ if (object != DTRACE_OBJ_EVERY &&
+ object != DTRACE_OBJ_KMODS &&
+ object != DTRACE_OBJ_UMODS) {
+ if ((dmp = dt_module_from_object(dtp, object)) == NULL)
+ return (-1); /* dt_errno is set for us */
+
+ if (dt_module_load(dtp, dmp) == -1)
+ return (-1); /* dt_errno is set for us */
+ n = 1;
+ justone = 1;
+
+ } else {
+ if (object == DTRACE_OBJ_KMODS)
+ mask = bits = DT_DM_KERNEL;
+ else if (object == DTRACE_OBJ_UMODS)
+ mask = DT_DM_KERNEL;
+
+ dmp = dt_list_next(&dtp->dt_modlist);
+ n = dtp->dt_nmods;
+ justone = 0;
+ }
+
+ if (tip == NULL)
+ tip = &ti;
+
+ for (; n > 0; n--, dmp = dt_list_next(dmp)) {
+ if ((dmp->dm_flags & mask) != bits)
+ continue; /* failed to match required attributes */
+
+ /*
+ * If we can't load the CTF container, continue on to the next
+ * module. If our search was scoped to only one module then
+ * return immediately leaving dt_errno unmodified.
+ */
+ if (dt_module_getctf(dtp, dmp) == NULL) {
+ if (justone)
+ return (-1);
+ continue;
+ }
+
+ /*
+ * Look up the type in the module's CTF container. If our
+ * match is a forward declaration tag, save this choice in
+ * 'tip' and keep going in the hope that we will locate the
+ * underlying structure definition. Otherwise just return.
+ */
+ if ((id = ctf_lookup_by_name(dmp->dm_ctfp, name)) != CTF_ERR) {
+ tip->dtt_object = dmp->dm_name;
+ tip->dtt_ctfp = dmp->dm_ctfp;
+ tip->dtt_type = id;
+
+ if (ctf_type_kind(dmp->dm_ctfp, ctf_type_resolve(
+ dmp->dm_ctfp, id)) != CTF_K_FORWARD)
+ return (0);
+
+ found++;
+ }
+ }
+
+ if (found == 0)
+ return (dt_set_errno(dtp, EDT_NOTYPE));
+
+ return (0);
+}
+
+int
+dtrace_symbol_type(dtrace_hdl_t *dtp, const GElf_Sym *symp,
+ const dtrace_syminfo_t *sip, dtrace_typeinfo_t *tip)
+{
+ dt_module_t *dmp;
+
+ tip->dtt_object = NULL;
+ tip->dtt_ctfp = NULL;
+ tip->dtt_type = CTF_ERR;
+
+ if ((dmp = dt_module_lookup_by_name(dtp, sip->dts_object)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMOD));
+
+ if (symp->st_shndx == SHN_UNDEF && dmp->dm_extern != NULL) {
+ dt_ident_t *idp =
+ dt_idhash_lookup(dmp->dm_extern, sip->dts_name);
+
+ if (idp == NULL)
+ return (dt_set_errno(dtp, EDT_NOSYM));
+
+ tip->dtt_ctfp = idp->di_ctfp;
+ tip->dtt_type = idp->di_type;
+
+ } else if (GELF_ST_TYPE(symp->st_info) != STT_FUNC) {
+ if (dt_module_getctf(dtp, dmp) == NULL)
+ return (-1); /* errno is set for us */
+
+ tip->dtt_ctfp = dmp->dm_ctfp;
+ tip->dtt_type = ctf_lookup_by_symbol(dmp->dm_ctfp, sip->dts_id);
+
+ if (tip->dtt_type == CTF_ERR) {
+ dtp->dt_ctferr = ctf_errno(tip->dtt_ctfp);
+ return (dt_set_errno(dtp, EDT_CTF));
+ }
+
+ } else {
+ tip->dtt_ctfp = DT_FPTR_CTFP(dtp);
+ tip->dtt_type = DT_FPTR_TYPE(dtp);
+ }
+
+ tip->dtt_object = dmp->dm_name;
+ return (0);
+}
+
+static dtrace_objinfo_t *
+dt_module_info(const dt_module_t *dmp, dtrace_objinfo_t *dto)
+{
+ dto->dto_name = dmp->dm_name;
+ dto->dto_file = dmp->dm_file;
+ dto->dto_id = dmp->dm_modid;
+ dto->dto_flags = 0;
+
+ if (dmp->dm_flags & DT_DM_KERNEL)
+ dto->dto_flags |= DTRACE_OBJ_F_KERNEL;
+ if (dmp->dm_flags & DT_DM_PRIMARY)
+ dto->dto_flags |= DTRACE_OBJ_F_PRIMARY;
+
+ dto->dto_text_va = dmp->dm_text_va;
+ dto->dto_text_size = dmp->dm_text_size;
+ dto->dto_data_va = dmp->dm_data_va;
+ dto->dto_data_size = dmp->dm_data_size;
+ dto->dto_bss_va = dmp->dm_bss_va;
+ dto->dto_bss_size = dmp->dm_bss_size;
+
+ return (dto);
+}
+
+int
+dtrace_object_iter(dtrace_hdl_t *dtp, dtrace_obj_f *func, void *data)
+{
+ const dt_module_t *dmp = dt_list_next(&dtp->dt_modlist);
+ dtrace_objinfo_t dto;
+ int rv;
+
+ for (; dmp != NULL; dmp = dt_list_next(dmp)) {
+ if ((rv = (*func)(dtp, dt_module_info(dmp, &dto), data)) != 0)
+ return (rv);
+ }
+
+ return (0);
+}
+
+int
+dtrace_object_info(dtrace_hdl_t *dtp, const char *object, dtrace_objinfo_t *dto)
+{
+ dt_module_t *dmp;
+
+ if (object == DTRACE_OBJ_EVERY || object == DTRACE_OBJ_KMODS ||
+ object == DTRACE_OBJ_UMODS || dto == NULL)
+ return (dt_set_errno(dtp, EINVAL));
+
+ if ((dmp = dt_module_from_object(dtp, object)) == NULL)
+ return (-1); /* dt_errno is set for us */
+
+ if (dt_module_load(dtp, dmp) == -1)
+ return (-1); /* dt_errno is set for us */
+
+ (void) dt_module_info(dmp, dto);
+ return (0);
+}
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.h
new file mode 100644
index 00000000..bf6ceded
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.h
@@ -0,0 +1,58 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_MODULE_H
+#define _DT_MODULE_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <dt_impl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern dt_module_t *dt_module_create(dtrace_hdl_t *, const char *);
+extern int dt_module_load(dtrace_hdl_t *, dt_module_t *);
+extern void dt_module_unload(dtrace_hdl_t *, dt_module_t *);
+extern void dt_module_destroy(dtrace_hdl_t *, dt_module_t *);
+
+extern dt_module_t *dt_module_lookup_by_name(dtrace_hdl_t *, const char *);
+extern dt_module_t *dt_module_lookup_by_ctf(dtrace_hdl_t *, ctf_file_t *);
+
+extern ctf_file_t *dt_module_getctf(dtrace_hdl_t *, dt_module_t *);
+extern dt_ident_t *dt_module_extern(dtrace_hdl_t *, dt_module_t *,
+ const char *, const dtrace_typeinfo_t *);
+
+extern const char *dt_module_modelname(dt_module_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_MODULE_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c
new file mode 100644
index 00000000..88db7a9b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c
@@ -0,0 +1,1500 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <sys/types.h>
+#include <sys/modctl.h>
+#include <sys/systeminfo.h>
+
+#include <libelf.h>
+#include <strings.h>
+#include <alloca.h>
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <assert.h>
+
+#ifndef _MSC_VER
+# define _POSIX_PTHREAD_SEMANTICS
+# include <dirent.h>
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+
+#else /* VBOX */
+# ifndef _MSC_VER
+# include <sys/resource.h>
+# include <unistd.h>
+# else
+# include <io.h>
+# endif
+# include <VBox/sup.h>
+# include <VBox/err.h>
+# include <iprt/path.h>
+# include <iprt/stream.h>
+# include <iprt/buildconfig.h>
+# include "../../../../../Main/include/ExtPackUtil.h"
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_program.h>
+#include <dt_module.h>
+#include <dt_printf.h>
+#include <dt_string.h>
+#include <dt_provider.h>
+
+/*
+ * Stability and versioning definitions. These #defines are used in the tables
+ * of identifiers below to fill in the attribute and version fields associated
+ * with each identifier. The DT_ATTR_* macros are a convenience to permit more
+ * concise declarations of common attributes such as Stable/Stable/Common. The
+ * DT_VERS_* macros declare the encoded integer values of all versions used so
+ * far. DT_VERS_LATEST must correspond to the latest version value among all
+ * versions exported by the D compiler. DT_VERS_STRING must be an ASCII string
+ * that contains DT_VERS_LATEST within it along with any suffixes (e.g. Beta).
+ * You must update DT_VERS_LATEST and DT_VERS_STRING when adding a new version,
+ * and then add the new version to the _dtrace_versions[] array declared below.
+ * Refer to the Solaris Dynamic Tracing Guide Stability and Versioning chapters
+ * respectively for an explanation of these DTrace features and their values.
+ *
+ * NOTE: Although the DTrace versioning scheme supports the labeling and
+ * introduction of incompatible changes (e.g. dropping an interface in a
+ * major release), the libdtrace code does not currently support this.
+ * All versions are assumed to strictly inherit from one another. If
+ * we ever need to provide divergent interfaces, this will need work.
+ */
+#define DT_ATTR_STABCMN { DTRACE_STABILITY_STABLE, \
+ DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON }
+
+#define DT_ATTR_EVOLCMN { DTRACE_STABILITY_EVOLVING, \
+ DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON \
+}
+
+/*
+ * The version number should be increased for every customer visible release
+ * of Solaris. The major number should be incremented when a fundamental
+ * change has been made that would affect all consumers, and would reflect
+ * sweeping changes to DTrace or the D language. The minor number should be
+ * incremented when a change is introduced that could break scripts that had
+ * previously worked; for example, adding a new built-in variable could break
+ * a script which was already using that identifier. The micro number should
+ * be changed when introducing functionality changes or major bug fixes that
+ * do not affect backward compatibility -- this is merely to make capabilities
+ * easily determined from the version number. Minor bugs do not require any
+ * modification to the version number.
+ */
+#define DT_VERS_1_0 DT_VERSION_NUMBER(1, 0, 0)
+#define DT_VERS_1_1 DT_VERSION_NUMBER(1, 1, 0)
+#define DT_VERS_1_2 DT_VERSION_NUMBER(1, 2, 0)
+#define DT_VERS_1_2_1 DT_VERSION_NUMBER(1, 2, 1)
+#define DT_VERS_1_2_2 DT_VERSION_NUMBER(1, 2, 2)
+#define DT_VERS_1_3 DT_VERSION_NUMBER(1, 3, 0)
+#define DT_VERS_1_4 DT_VERSION_NUMBER(1, 4, 0)
+#define DT_VERS_1_4_1 DT_VERSION_NUMBER(1, 4, 1)
+#define DT_VERS_1_5 DT_VERSION_NUMBER(1, 5, 0)
+#define DT_VERS_1_6 DT_VERSION_NUMBER(1, 6, 0)
+#define DT_VERS_1_6_1 DT_VERSION_NUMBER(1, 6, 1)
+#define DT_VERS_1_6_2 DT_VERSION_NUMBER(1, 6, 2)
+#define DT_VERS_1_6_3 DT_VERSION_NUMBER(1, 6, 3)
+#define DT_VERS_LATEST DT_VERS_1_6_3
+#define DT_VERS_STRING "Sun D 1.6.3"
+
+const dt_version_t _dtrace_versions[] = {
+ DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */
+ DT_VERS_1_1, /* D API 1.1.0 Solaris Express 6/05 */
+ DT_VERS_1_2, /* D API 1.2.0 Solaris 10 Update 1 */
+ DT_VERS_1_2_1, /* D API 1.2.1 Solaris Express 4/06 */
+ DT_VERS_1_2_2, /* D API 1.2.2 Solaris Express 6/06 */
+ DT_VERS_1_3, /* D API 1.3 Solaris Express 10/06 */
+ DT_VERS_1_4, /* D API 1.4 Solaris Express 2/07 */
+ DT_VERS_1_4_1, /* D API 1.4.1 Solaris Express 4/07 */
+ DT_VERS_1_5, /* D API 1.5 Solaris Express 7/07 */
+ DT_VERS_1_6, /* D API 1.6 */
+ DT_VERS_1_6_1, /* D API 1.6.1 */
+ DT_VERS_1_6_2, /* D API 1.6.2 */
+ DT_VERS_1_6_3, /* D API 1.6.3 */
+ 0
+};
+
+/*
+ * Table of global identifiers. This is used to populate the global identifier
+ * hash when a new dtrace client open occurs. For more info see dt_ident.h.
+ * The global identifiers that represent functions use the dt_idops_func ops
+ * and specify the private data pointer as a prototype string which is parsed
+ * when the identifier is first encountered. These prototypes look like ANSI
+ * C function prototypes except that the special symbol "@" can be used as a
+ * wildcard to represent a single parameter of any type (i.e. any dt_node_t).
+ * The standard "..." notation can also be used to represent varargs. An empty
+ * parameter list is taken to mean void (that is, no arguments are permitted).
+ * A parameter enclosed in square brackets (e.g. "[int]") denotes an optional
+ * argument.
+ */
+static const dt_ident_t _dtrace_globals[] = {
+{ "alloca", DT_IDENT_FUNC, 0, DIF_SUBR_ALLOCA, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void *(size_t)" },
+{ "arg0", DT_IDENT_SCALAR, 0, DIF_VAR_ARG0, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg1", DT_IDENT_SCALAR, 0, DIF_VAR_ARG1, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg2", DT_IDENT_SCALAR, 0, DIF_VAR_ARG2, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg3", DT_IDENT_SCALAR, 0, DIF_VAR_ARG3, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg4", DT_IDENT_SCALAR, 0, DIF_VAR_ARG4, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg5", DT_IDENT_SCALAR, 0, DIF_VAR_ARG5, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg6", DT_IDENT_SCALAR, 0, DIF_VAR_ARG6, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg7", DT_IDENT_SCALAR, 0, DIF_VAR_ARG7, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg8", DT_IDENT_SCALAR, 0, DIF_VAR_ARG8, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "arg9", DT_IDENT_SCALAR, 0, DIF_VAR_ARG9, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "args", DT_IDENT_ARRAY, 0, DIF_VAR_ARGS, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_args, NULL },
+{ "avg", DT_IDENT_AGGFUNC, 0, DTRACEAGG_AVG, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@)" },
+{ "basename", DT_IDENT_FUNC, 0, DIF_SUBR_BASENAME, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "string(const char *)" },
+{ "bcopy", DT_IDENT_FUNC, 0, DIF_SUBR_BCOPY, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(void *, void *, size_t)" },
+{ "breakpoint", DT_IDENT_ACTFUNC, 0, DT_ACT_BREAKPOINT,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void()" },
+{ "caller", DT_IDENT_SCALAR, 0, DIF_VAR_CALLER, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uintptr_t" },
+{ "chill", DT_IDENT_ACTFUNC, 0, DT_ACT_CHILL, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(int)" },
+{ "cleanpath", DT_IDENT_FUNC, 0, DIF_SUBR_CLEANPATH, DT_ATTR_STABCMN,
+ DT_VERS_1_0, &dt_idops_func, "string(const char *)" },
+{ "clear", DT_IDENT_ACTFUNC, 0, DT_ACT_CLEAR, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(...)" },
+{ "commit", DT_IDENT_ACTFUNC, 0, DT_ACT_COMMIT, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(int)" },
+{ "copyin", DT_IDENT_FUNC, 0, DIF_SUBR_COPYIN, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void *(uintptr_t, size_t)" },
+{ "copyinstr", DT_IDENT_FUNC, 0, DIF_SUBR_COPYINSTR,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "string(uintptr_t, [size_t])" },
+{ "copyinto", DT_IDENT_FUNC, 0, DIF_SUBR_COPYINTO, DT_ATTR_STABCMN,
+ DT_VERS_1_0, &dt_idops_func, "void(uintptr_t, size_t, void *)" },
+{ "copyout", DT_IDENT_FUNC, 0, DIF_SUBR_COPYOUT, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(void *, uintptr_t, size_t)" },
+{ "copyoutstr", DT_IDENT_FUNC, 0, DIF_SUBR_COPYOUTSTR,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(char *, uintptr_t, size_t)" },
+{ "count", DT_IDENT_AGGFUNC, 0, DTRACEAGG_COUNT, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void()" },
+{ "curthread", DT_IDENT_SCALAR, 0, DIF_VAR_CURTHREAD,
+ { DTRACE_STABILITY_STABLE, DTRACE_STABILITY_PRIVATE,
+ DTRACE_CLASS_COMMON }, DT_VERS_1_0,
+ &dt_idops_type, "genunix`kthread_t *" },
+{ "ddi_pathname", DT_IDENT_FUNC, 0, DIF_SUBR_DDI_PATHNAME,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "string(void *, int64_t)" },
+{ "denormalize", DT_IDENT_ACTFUNC, 0, DT_ACT_DENORMALIZE, DT_ATTR_STABCMN,
+ DT_VERS_1_0, &dt_idops_func, "void(...)" },
+{ "dirname", DT_IDENT_FUNC, 0, DIF_SUBR_DIRNAME, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "string(const char *)" },
+{ "discard", DT_IDENT_ACTFUNC, 0, DT_ACT_DISCARD, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(int)" },
+{ "epid", DT_IDENT_SCALAR, 0, DIF_VAR_EPID, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uint_t" },
+{ "errno", DT_IDENT_SCALAR, 0, DIF_VAR_ERRNO, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int" },
+{ "execname", DT_IDENT_SCALAR, 0, DIF_VAR_EXECNAME,
+ DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" },
+{ "exit", DT_IDENT_ACTFUNC, 0, DT_ACT_EXIT, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(int)" },
+{ "freopen", DT_IDENT_ACTFUNC, 0, DT_ACT_FREOPEN, DT_ATTR_STABCMN,
+ DT_VERS_1_1, &dt_idops_func, "void(@, ...)" },
+{ "ftruncate", DT_IDENT_ACTFUNC, 0, DT_ACT_FTRUNCATE, DT_ATTR_STABCMN,
+ DT_VERS_1_0, &dt_idops_func, "void()" },
+{ "func", DT_IDENT_ACTFUNC, 0, DT_ACT_SYM, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" },
+{ "getmajor", DT_IDENT_FUNC, 0, DIF_SUBR_GETMAJOR,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "genunix`major_t(genunix`dev_t)" },
+{ "getminor", DT_IDENT_FUNC, 0, DIF_SUBR_GETMINOR,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "genunix`minor_t(genunix`dev_t)" },
+{ "htonl", DT_IDENT_FUNC, 0, DIF_SUBR_HTONL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint32_t(uint32_t)" },
+{ "htonll", DT_IDENT_FUNC, 0, DIF_SUBR_HTONLL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint64_t(uint64_t)" },
+{ "htons", DT_IDENT_FUNC, 0, DIF_SUBR_HTONS, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint16_t(uint16_t)" },
+{ "gid", DT_IDENT_SCALAR, 0, DIF_VAR_GID, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "gid_t" },
+{ "id", DT_IDENT_SCALAR, 0, DIF_VAR_ID, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uint_t" },
+{ "index", DT_IDENT_FUNC, 0, DIF_SUBR_INDEX, DT_ATTR_STABCMN, DT_VERS_1_1,
+ &dt_idops_func, "int(const char *, const char *, [int])" },
+{ "inet_ntoa", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA, DT_ATTR_STABCMN,
+ DT_VERS_1_5, &dt_idops_func, "string(ipaddr_t *)" },
+{ "inet_ntoa6", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA6, DT_ATTR_STABCMN,
+ DT_VERS_1_5, &dt_idops_func, "string(in6_addr_t *)" },
+{ "inet_ntop", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOP, DT_ATTR_STABCMN,
+ DT_VERS_1_5, &dt_idops_func, "string(int, void *)" },
+{ "ipl", DT_IDENT_SCALAR, 0, DIF_VAR_IPL, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uint_t" },
+{ "jstack", DT_IDENT_ACTFUNC, 0, DT_ACT_JSTACK, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "stack(...)" },
+{ "lltostr", DT_IDENT_FUNC, 0, DIF_SUBR_LLTOSTR, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "string(int64_t)" },
+{ "lquantize", DT_IDENT_AGGFUNC, 0, DTRACEAGG_LQUANTIZE,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@, int32_t, int32_t, ...)" },
+{ "max", DT_IDENT_AGGFUNC, 0, DTRACEAGG_MAX, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@)" },
+{ "min", DT_IDENT_AGGFUNC, 0, DTRACEAGG_MIN, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@)" },
+{ "mod", DT_IDENT_ACTFUNC, 0, DT_ACT_MOD, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" },
+{ "msgdsize", DT_IDENT_FUNC, 0, DIF_SUBR_MSGDSIZE,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "size_t(mblk_t *)" },
+{ "msgsize", DT_IDENT_FUNC, 0, DIF_SUBR_MSGSIZE,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "size_t(mblk_t *)" },
+{ "mutex_owned", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNED,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "int(genunix`kmutex_t *)" },
+{ "mutex_owner", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNER,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "genunix`kthread_t *(genunix`kmutex_t *)" },
+{ "mutex_type_adaptive", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_ADAPTIVE,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "int(genunix`kmutex_t *)" },
+{ "mutex_type_spin", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_SPIN,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "int(genunix`kmutex_t *)" },
+{ "ntohl", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint32_t(uint32_t)" },
+{ "ntohll", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHLL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint64_t(uint64_t)" },
+{ "ntohs", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHS, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint16_t(uint16_t)" },
+{ "normalize", DT_IDENT_ACTFUNC, 0, DT_ACT_NORMALIZE, DT_ATTR_STABCMN,
+ DT_VERS_1_0, &dt_idops_func, "void(...)" },
+{ "panic", DT_IDENT_ACTFUNC, 0, DT_ACT_PANIC, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void()" },
+{ "pid", DT_IDENT_SCALAR, 0, DIF_VAR_PID, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "pid_t" },
+{ "ppid", DT_IDENT_SCALAR, 0, DIF_VAR_PPID, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "pid_t" },
+{ "printa", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTA, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@, ...)" },
+{ "printf", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTF, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@, ...)" },
+{ "probefunc", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEFUNC,
+ DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" },
+{ "probemod", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEMOD,
+ DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" },
+{ "probename", DT_IDENT_SCALAR, 0, DIF_VAR_PROBENAME,
+ DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" },
+{ "probeprov", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEPROV,
+ DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" },
+{ "progenyof", DT_IDENT_FUNC, 0, DIF_SUBR_PROGENYOF,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "int(pid_t)" },
+{ "quantize", DT_IDENT_AGGFUNC, 0, DTRACEAGG_QUANTIZE,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@, ...)" },
+{ "raise", DT_IDENT_ACTFUNC, 0, DT_ACT_RAISE, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(int)" },
+{ "rand", DT_IDENT_FUNC, 0, DIF_SUBR_RAND, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "int()" },
+{ "rindex", DT_IDENT_FUNC, 0, DIF_SUBR_RINDEX, DT_ATTR_STABCMN, DT_VERS_1_1,
+ &dt_idops_func, "int(const char *, const char *, [int])" },
+{ "rw_iswriter", DT_IDENT_FUNC, 0, DIF_SUBR_RW_ISWRITER,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "int(genunix`krwlock_t *)" },
+{ "rw_read_held", DT_IDENT_FUNC, 0, DIF_SUBR_RW_READ_HELD,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "int(genunix`krwlock_t *)" },
+{ "rw_write_held", DT_IDENT_FUNC, 0, DIF_SUBR_RW_WRITE_HELD,
+ DT_ATTR_EVOLCMN, DT_VERS_1_0,
+ &dt_idops_func, "int(genunix`krwlock_t *)" },
+{ "self", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "void" },
+{ "setopt", DT_IDENT_ACTFUNC, 0, DT_ACT_SETOPT, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "void(const char *, [const char *])" },
+{ "speculate", DT_IDENT_ACTFUNC, 0, DT_ACT_SPECULATE,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(int)" },
+{ "speculation", DT_IDENT_FUNC, 0, DIF_SUBR_SPECULATION,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "int()" },
+{ "stack", DT_IDENT_ACTFUNC, 0, DT_ACT_STACK, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "stack(...)" },
+{ "stackdepth", DT_IDENT_SCALAR, 0, DIF_VAR_STACKDEPTH,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uint32_t" },
+{ "stddev", DT_IDENT_AGGFUNC, 0, DTRACEAGG_STDDEV, DT_ATTR_STABCMN,
+ DT_VERS_1_6, &dt_idops_func, "void(@)" },
+{ "stop", DT_IDENT_ACTFUNC, 0, DT_ACT_STOP, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void()" },
+{ "strchr", DT_IDENT_FUNC, 0, DIF_SUBR_STRCHR, DT_ATTR_STABCMN, DT_VERS_1_1,
+ &dt_idops_func, "string(const char *, char)" },
+{ "strlen", DT_IDENT_FUNC, 0, DIF_SUBR_STRLEN, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "size_t(const char *)" },
+{ "strjoin", DT_IDENT_FUNC, 0, DIF_SUBR_STRJOIN, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "string(const char *, const char *)" },
+{ "strrchr", DT_IDENT_FUNC, 0, DIF_SUBR_STRRCHR, DT_ATTR_STABCMN, DT_VERS_1_1,
+ &dt_idops_func, "string(const char *, char)" },
+{ "strstr", DT_IDENT_FUNC, 0, DIF_SUBR_STRSTR, DT_ATTR_STABCMN, DT_VERS_1_1,
+ &dt_idops_func, "string(const char *, const char *)" },
+{ "strtok", DT_IDENT_FUNC, 0, DIF_SUBR_STRTOK, DT_ATTR_STABCMN, DT_VERS_1_1,
+ &dt_idops_func, "string(const char *, const char *)" },
+{ "substr", DT_IDENT_FUNC, 0, DIF_SUBR_SUBSTR, DT_ATTR_STABCMN, DT_VERS_1_1,
+ &dt_idops_func, "string(const char *, int, [int])" },
+{ "sum", DT_IDENT_AGGFUNC, 0, DTRACEAGG_SUM, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@)" },
+{ "sym", DT_IDENT_ACTFUNC, 0, DT_ACT_SYM, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" },
+{ "system", DT_IDENT_ACTFUNC, 0, DT_ACT_SYSTEM, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@, ...)" },
+{ "this", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "void" },
+{ "tid", DT_IDENT_SCALAR, 0, DIF_VAR_TID, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "id_t" },
+{ "timestamp", DT_IDENT_SCALAR, 0, DIF_VAR_TIMESTAMP,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uint64_t" },
+{ "trace", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACE, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@)" },
+{ "tracemem", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACEMEM,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "void(@, size_t)" },
+{ "trunc", DT_IDENT_ACTFUNC, 0, DT_ACT_TRUNC, DT_ATTR_STABCMN,
+ DT_VERS_1_0, &dt_idops_func, "void(...)" },
+{ "uaddr", DT_IDENT_ACTFUNC, 0, DT_ACT_UADDR, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" },
+{ "ucaller", DT_IDENT_SCALAR, 0, DIF_VAR_UCALLER, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_type, "uint64_t" },
+{ "ufunc", DT_IDENT_ACTFUNC, 0, DT_ACT_USYM, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" },
+{ "uid", DT_IDENT_SCALAR, 0, DIF_VAR_UID, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uid_t" },
+{ "umod", DT_IDENT_ACTFUNC, 0, DT_ACT_UMOD, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" },
+{ "uregs", DT_IDENT_ARRAY, 0, DIF_VAR_UREGS, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_regs, NULL },
+{ "ustack", DT_IDENT_ACTFUNC, 0, DT_ACT_USTACK, DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_func, "stack(...)" },
+{ "ustackdepth", DT_IDENT_SCALAR, 0, DIF_VAR_USTACKDEPTH,
+ DT_ATTR_STABCMN, DT_VERS_1_2,
+ &dt_idops_type, "uint32_t" },
+{ "usym", DT_IDENT_ACTFUNC, 0, DT_ACT_USYM, DT_ATTR_STABCMN,
+ DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" },
+{ "vtimestamp", DT_IDENT_SCALAR, 0, DIF_VAR_VTIMESTAMP,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "uint64_t" },
+{ "walltimestamp", DT_IDENT_SCALAR, 0, DIF_VAR_WALLTIMESTAMP,
+ DT_ATTR_STABCMN, DT_VERS_1_0,
+ &dt_idops_type, "int64_t" },
+{ "zonename", DT_IDENT_SCALAR, 0, DIF_VAR_ZONENAME,
+ DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" },
+{ NULL, 0, 0, 0, { 0, 0, 0 }, 0, NULL, NULL }
+};
+
+/*
+ * Tables of ILP32 intrinsic integer and floating-point type templates to use
+ * to populate the dynamic "C" CTF type container.
+ */
+static const dt_intrinsic_t _dtrace_intrinsics_32[] = {
+{ "void", { CTF_INT_SIGNED, 0, 0 }, CTF_K_INTEGER },
+{ "signed", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "unsigned", { 0, 0, 32 }, CTF_K_INTEGER },
+{ "char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER },
+{ "short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER },
+{ "int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "long", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER },
+{ "signed char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER },
+{ "signed short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER },
+{ "signed int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "signed long", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "signed long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER },
+{ "unsigned char", { CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER },
+{ "unsigned short", { 0, 0, 16 }, CTF_K_INTEGER },
+{ "unsigned int", { 0, 0, 32 }, CTF_K_INTEGER },
+{ "unsigned long", { 0, 0, 32 }, CTF_K_INTEGER },
+{ "unsigned long long", { 0, 0, 64 }, CTF_K_INTEGER },
+{ "_Bool", { CTF_INT_BOOL, 0, 8 }, CTF_K_INTEGER },
+{ "float", { CTF_FP_SINGLE, 0, 32 }, CTF_K_FLOAT },
+{ "double", { CTF_FP_DOUBLE, 0, 64 }, CTF_K_FLOAT },
+{ "long double", { CTF_FP_LDOUBLE, 0, 128 }, CTF_K_FLOAT },
+{ "float imaginary", { CTF_FP_IMAGRY, 0, 32 }, CTF_K_FLOAT },
+{ "double imaginary", { CTF_FP_DIMAGRY, 0, 64 }, CTF_K_FLOAT },
+{ "long double imaginary", { CTF_FP_LDIMAGRY, 0, 128 }, CTF_K_FLOAT },
+{ "float complex", { CTF_FP_CPLX, 0, 64 }, CTF_K_FLOAT },
+{ "double complex", { CTF_FP_DCPLX, 0, 128 }, CTF_K_FLOAT },
+{ "long double complex", { CTF_FP_LDCPLX, 0, 256 }, CTF_K_FLOAT },
+{ NULL, { 0, 0, 0 }, 0 }
+};
+
+/*
+ * Tables of LP64 intrinsic integer and floating-point type templates to use
+ * to populate the dynamic "C" CTF type container.
+ */
+static const dt_intrinsic_t _dtrace_intrinsics_64[] = {
+{ "void", { CTF_INT_SIGNED, 0, 0 }, CTF_K_INTEGER },
+{ "signed", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "unsigned", { 0, 0, 32 }, CTF_K_INTEGER },
+{ "char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER },
+{ "short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER },
+{ "int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER },
+{ "long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER },
+{ "signed char", { CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER },
+{ "signed short", { CTF_INT_SIGNED, 0, 16 }, CTF_K_INTEGER },
+{ "signed int", { CTF_INT_SIGNED, 0, 32 }, CTF_K_INTEGER },
+{ "signed long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER },
+{ "signed long long", { CTF_INT_SIGNED, 0, 64 }, CTF_K_INTEGER },
+{ "unsigned char", { CTF_INT_CHAR, 0, 8 }, CTF_K_INTEGER },
+{ "unsigned short", { 0, 0, 16 }, CTF_K_INTEGER },
+{ "unsigned int", { 0, 0, 32 }, CTF_K_INTEGER },
+{ "unsigned long", { 0, 0, 64 }, CTF_K_INTEGER },
+{ "unsigned long long", { 0, 0, 64 }, CTF_K_INTEGER },
+{ "_Bool", { CTF_INT_BOOL, 0, 8 }, CTF_K_INTEGER },
+{ "float", { CTF_FP_SINGLE, 0, 32 }, CTF_K_FLOAT },
+{ "double", { CTF_FP_DOUBLE, 0, 64 }, CTF_K_FLOAT },
+{ "long double", { CTF_FP_LDOUBLE, 0, 128 }, CTF_K_FLOAT },
+{ "float imaginary", { CTF_FP_IMAGRY, 0, 32 }, CTF_K_FLOAT },
+{ "double imaginary", { CTF_FP_DIMAGRY, 0, 64 }, CTF_K_FLOAT },
+{ "long double imaginary", { CTF_FP_LDIMAGRY, 0, 128 }, CTF_K_FLOAT },
+{ "float complex", { CTF_FP_CPLX, 0, 64 }, CTF_K_FLOAT },
+{ "double complex", { CTF_FP_DCPLX, 0, 128 }, CTF_K_FLOAT },
+{ "long double complex", { CTF_FP_LDCPLX, 0, 256 }, CTF_K_FLOAT },
+{ NULL, { 0, 0, 0 }, 0 }
+};
+
+/*
+ * Tables of ILP32 typedefs to use to populate the dynamic "D" CTF container.
+ * These aliases ensure that D definitions can use typical <sys/types.h> names.
+ */
+static const dt_typedef_t _dtrace_typedefs_32[] = {
+{ "char", "int8_t" },
+{ "short", "int16_t" },
+{ "int", "int32_t" },
+{ "long long", "int64_t" },
+{ "int", "intptr_t" },
+{ "int", "ssize_t" },
+{ "unsigned char", "uint8_t" },
+{ "unsigned short", "uint16_t" },
+{ "unsigned", "uint32_t" },
+{ "unsigned long long", "uint64_t" },
+{ "unsigned char", "uchar_t" },
+{ "unsigned short", "ushort_t" },
+{ "unsigned", "uint_t" },
+{ "unsigned long", "ulong_t" },
+{ "unsigned long long", "u_longlong_t" },
+{ "int", "ptrdiff_t" },
+{ "unsigned", "uintptr_t" },
+{ "unsigned", "size_t" },
+{ "long", "id_t" },
+{ "long", "pid_t" },
+{ NULL, NULL }
+};
+
+/*
+ * Tables of LP64 typedefs to use to populate the dynamic "D" CTF container.
+ * These aliases ensure that D definitions can use typical <sys/types.h> names.
+ */
+static const dt_typedef_t _dtrace_typedefs_64[] = {
+{ "char", "int8_t" },
+{ "short", "int16_t" },
+{ "int", "int32_t" },
+{ "long", "int64_t" },
+{ "long", "intptr_t" },
+{ "long", "ssize_t" },
+{ "unsigned char", "uint8_t" },
+{ "unsigned short", "uint16_t" },
+{ "unsigned", "uint32_t" },
+{ "unsigned long", "uint64_t" },
+{ "unsigned char", "uchar_t" },
+{ "unsigned short", "ushort_t" },
+{ "unsigned", "uint_t" },
+{ "unsigned long", "ulong_t" },
+{ "unsigned long long", "u_longlong_t" },
+{ "long", "ptrdiff_t" },
+{ "unsigned long", "uintptr_t" },
+{ "unsigned long", "size_t" },
+{ "int", "id_t" },
+{ "int", "pid_t" },
+{ NULL, NULL }
+};
+
+/*
+ * Tables of ILP32 integer type templates used to populate the dtp->dt_ints[]
+ * cache when a new dtrace client open occurs. Values are set by dtrace_open().
+ */
+static const dt_intdesc_t _dtrace_ints_32[] = {
+{ "int", NULL, CTF_ERR, 0x7fffffffULL },
+{ "unsigned int", NULL, CTF_ERR, 0xffffffffULL },
+{ "long", NULL, CTF_ERR, 0x7fffffffULL },
+{ "unsigned long", NULL, CTF_ERR, 0xffffffffULL },
+{ "long long", NULL, CTF_ERR, 0x7fffffffffffffffULL },
+{ "unsigned long long", NULL, CTF_ERR, 0xffffffffffffffffULL }
+};
+
+/*
+ * Tables of LP64 integer type templates used to populate the dtp->dt_ints[]
+ * cache when a new dtrace client open occurs. Values are set by dtrace_open().
+ */
+static const dt_intdesc_t _dtrace_ints_64[] = {
+{ "int", NULL, CTF_ERR, 0x7fffffffULL },
+{ "unsigned int", NULL, CTF_ERR, 0xffffffffULL },
+{ "long", NULL, CTF_ERR, 0x7fffffffffffffffULL },
+{ "unsigned long", NULL, CTF_ERR, 0xffffffffffffffffULL },
+{ "long long", NULL, CTF_ERR, 0x7fffffffffffffffULL },
+{ "unsigned long long", NULL, CTF_ERR, 0xffffffffffffffffULL }
+};
+
+/*
+ * Table of macro variable templates used to populate the macro identifier hash
+ * when a new dtrace client open occurs. Values are set by dtrace_update().
+ */
+static const dt_ident_t _dtrace_macros[] = {
+{ "egid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "euid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "gid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "pid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "pgid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "ppid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "projid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "sid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "taskid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "target", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ "uid", DT_IDENT_SCALAR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0 },
+{ NULL, 0, 0, 0, { 0, 0, 0 }, 0 }
+};
+
+/*
+ * Hard-wired definition string to be compiled and cached every time a new
+ * DTrace library handle is initialized. This string should only be used to
+ * contain definitions that should be present regardless of DTRACE_O_NOLIBS.
+ */
+static const char _dtrace_hardwire[] = "\
+inline long NULL = 0; \n\
+#pragma D binding \"1.0\" NULL\n\
+";
+
+/*
+ * Default DTrace configuration to use when opening libdtrace DTRACE_O_NODEV.
+ * If DTRACE_O_NODEV is not set, we load the configuration from the kernel.
+ * The use of CTF_MODEL_NATIVE is more subtle than it might appear: we are
+ * relying on the fact that when running dtrace(1M), isaexec will invoke the
+ * binary with the same bitness as the kernel, which is what we want by default
+ * when generating our DIF. The user can override the choice using oflags.
+ */
+static const dtrace_conf_t _dtrace_conf = {
+ DIF_VERSION, /* dtc_difversion */
+ DIF_DIR_NREGS, /* dtc_difintregs */
+ DIF_DTR_NREGS, /* dtc_diftupregs */
+ CTF_MODEL_NATIVE /* dtc_ctfmodel */
+};
+
+const dtrace_attribute_t _dtrace_maxattr = {
+ DTRACE_STABILITY_MAX,
+ DTRACE_STABILITY_MAX,
+ DTRACE_CLASS_MAX
+};
+
+const dtrace_attribute_t _dtrace_defattr = {
+ DTRACE_STABILITY_STABLE,
+ DTRACE_STABILITY_STABLE,
+ DTRACE_CLASS_COMMON
+};
+
+const dtrace_attribute_t _dtrace_symattr = {
+ DTRACE_STABILITY_PRIVATE,
+ DTRACE_STABILITY_PRIVATE,
+ DTRACE_CLASS_UNKNOWN
+};
+
+const dtrace_attribute_t _dtrace_typattr = {
+ DTRACE_STABILITY_PRIVATE,
+ DTRACE_STABILITY_PRIVATE,
+ DTRACE_CLASS_UNKNOWN
+};
+
+const dtrace_attribute_t _dtrace_prvattr = {
+ DTRACE_STABILITY_PRIVATE,
+ DTRACE_STABILITY_PRIVATE,
+ DTRACE_CLASS_UNKNOWN
+};
+
+const dtrace_pattr_t _dtrace_prvdesc = {
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON },
+};
+
+const char *_dtrace_defcpp = "/usr/ccs/lib/cpp"; /* default cpp(1) to invoke */
+const char *_dtrace_defld = "/usr/ccs/bin/ld"; /* default ld(1) to invoke */
+
+const char *_dtrace_libdir = "/usr/lib/dtrace"; /* default library directory */
+const char *_dtrace_provdir = "/dev/dtrace/provider"; /* provider directory */
+
+int _dtrace_strbuckets = 211; /* default number of hash buckets (prime) */
+int _dtrace_intbuckets = 256; /* default number of integer buckets (Pof2) */
+uint_t _dtrace_strsize = 256; /* default size of string intrinsic type */
+uint_t _dtrace_stkindent = 14; /* default whitespace indent for stack/ustack */
+uint_t _dtrace_pidbuckets = 64; /* default number of pid hash buckets */
+uint_t _dtrace_pidlrulim = 8; /* default number of pid handles to cache */
+size_t _dtrace_bufsize = 512; /* default dt_buf_create() size */
+int _dtrace_argmax = 32; /* default maximum number of probe arguments */
+
+int _dtrace_debug = 0; /* debug messages enabled (off) */
+const char *const _dtrace_version = DT_VERS_STRING; /* API version string */
+#ifndef VBOX
+int _dtrace_rdvers = RD_VERSION; /* rtld_db feature version */
+#endif
+
+typedef struct dt_fdlist {
+ int *df_fds; /* array of provider driver file descriptors */
+ uint_t df_ents; /* number of valid elements in df_fds[] */
+ uint_t df_size; /* size of df_fds[] */
+} dt_fdlist_t;
+
+
+#ifdef VBOX
+# include <iprt/critsect.h>
+# include <libctf.h>
+extern RTCRITSECT dt_qsort_lock; /* dt_aggregate.c */
+
+void dtrace_init(void)
+#else /* !VBOX */
+#pragma init(_dtrace_init)
+void
+_dtrace_init(void)
+#endif /* !VBOX */
+{
+ _dtrace_debug = getenv("DTRACE_DEBUG") != NULL;
+
+#ifndef VBOX
+ for (; _dtrace_rdvers > 0; _dtrace_rdvers--) {
+ if (rd_init(_dtrace_rdvers) == RD_OK)
+ break;
+ }
+#else
+
+ libctf_init();
+ RTCritSectInit(&dt_qsort_lock);
+#endif
+}
+
+static dtrace_hdl_t *
+set_open_errno(dtrace_hdl_t *dtp, int *errp, int err)
+{
+ if (dtp != NULL)
+ dtrace_close(dtp);
+ if (errp != NULL)
+ *errp = err;
+ return (NULL);
+}
+
+#ifndef VBOX
+static void
+dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp)
+{
+ dt_provmod_t *prov;
+ char path[PATH_MAX];
+ struct dirent *dp, *ep;
+ DIR *dirp;
+ int fd;
+
+ if ((dirp = opendir(_dtrace_provdir)) == NULL)
+ return; /* failed to open directory; just skip it */
+
+ ep = alloca(sizeof (struct dirent) + PATH_MAX + 1);
+ bzero(ep, sizeof (struct dirent) + PATH_MAX + 1);
+
+ while (readdir_r(dirp, ep, &dp) == 0 && dp != NULL) {
+ if (dp->d_name[0] == '.')
+ continue; /* skip "." and ".." */
+
+ if (dfp->df_ents == dfp->df_size) {
+ uint_t size = dfp->df_size ? dfp->df_size * 2 : 16;
+ int *fds = realloc(dfp->df_fds, size * sizeof (int));
+
+ if (fds == NULL)
+ break; /* skip the rest of this directory */
+
+ dfp->df_fds = fds;
+ dfp->df_size = size;
+ }
+
+ (void) snprintf(path, sizeof (path), "%s/%s",
+ _dtrace_provdir, dp->d_name);
+
+ if ((fd = open(path, O_RDONLY)) == -1)
+ continue; /* failed to open driver; just skip it */
+
+ if (((prov = malloc(sizeof (dt_provmod_t))) == NULL) ||
+ (prov->dp_name = malloc(strlen(dp->d_name) + 1)) == NULL) {
+ free(prov);
+ (void) close(fd);
+ break;
+ }
+
+ (void) strcpy(prov->dp_name, dp->d_name);
+ prov->dp_next = *provmod;
+ *provmod = prov;
+
+ dt_dprintf("opened provider %s\n", dp->d_name);
+ dfp->df_fds[dfp->df_ents++] = fd;
+ }
+
+ (void) closedir(dirp);
+}
+#endif /* !VBOX */
+
+static void
+dt_provmod_destroy(dt_provmod_t **provmod)
+{
+ dt_provmod_t *next, *current;
+
+ for (current = *provmod; current != NULL; current = next) {
+ next = current->dp_next;
+ free(current->dp_name);
+ free(current);
+ }
+
+ *provmod = NULL;
+}
+
+#ifndef VBOX
+static const char *
+dt_get_sysinfo(int cmd, char *buf, size_t len)
+{
+ ssize_t rv = sysinfo(cmd, buf, len);
+ char *p = buf;
+
+ if (rv < 0 || rv > len)
+ (void) snprintf(buf, len, "%s", "Unknown");
+
+ while ((p = strchr(p, '.')) != NULL)
+ *p++ = '_';
+ return (buf);
+}
+#endif /* !VBOX */
+
+static dtrace_hdl_t *
+dt_vopen(int version, int flags, int *errp,
+ const dtrace_vector_t *vector, void *arg)
+{
+ dtrace_hdl_t *dtp = NULL;
+ int dtfd = -1, ftfd = -1, fterr = 0;
+ dtrace_prog_t *pgp;
+ dt_module_t *dmp;
+ dt_provmod_t *provmod = NULL;
+ int i, err;
+#ifndef _MSC_VER
+ struct rlimit rl;
+#endif
+
+ const dt_intrinsic_t *dinp;
+ const dt_typedef_t *dtyp;
+ const dt_ident_t *idp;
+
+ dtrace_typeinfo_t dtt;
+ ctf_funcinfo_t ctc;
+ ctf_arinfo_t ctr;
+
+#ifndef VBOX
+ dt_fdlist_t df = { NULL, 0, 0 };
+#endif
+
+ char isadef[32], utsdef[32];
+#ifndef VBOX
+ char s1[64], s2[64];
+#endif
+
+#ifdef VBOX
+ char szModPath[RTPATH_MAX];
+ void *pvImageBase;
+ int rc;
+#endif
+
+ if (version <= 0)
+ return (set_open_errno(dtp, errp, EINVAL));
+
+ if (version > DTRACE_VERSION)
+ return (set_open_errno(dtp, errp, EDT_VERSION));
+
+ if (version < DTRACE_VERSION) {
+ /*
+ * Currently, increasing the library version number is used to
+ * denote a binary incompatible change. That is, a consumer
+ * of the library cannot run on a version of the library with
+ * a higher DTRACE_VERSION number than the consumer compiled
+ * against. Once the library API has been committed to,
+ * backwards binary compatibility will be required; at that
+ * time, this check should change to return EDT_OVERSION only
+ * if the specified version number is less than the version
+ * number at the time of interface commitment.
+ */
+ return (set_open_errno(dtp, errp, EDT_OVERSION));
+ }
+
+ if (flags & ~DTRACE_O_MASK)
+ return (set_open_errno(dtp, errp, EINVAL));
+
+ if ((flags & DTRACE_O_LP64) && (flags & DTRACE_O_ILP32))
+ return (set_open_errno(dtp, errp, EINVAL));
+
+ if (vector == NULL && arg != NULL)
+ return (set_open_errno(dtp, errp, EINVAL));
+
+#ifndef VBOX
+ if (elf_version(EV_CURRENT) == EV_NONE)
+ return (set_open_errno(dtp, errp, EDT_ELFVERSION));
+#endif
+
+ if (vector != NULL || (flags & DTRACE_O_NODEV))
+ goto alloc; /* do not attempt to open dtrace device */
+
+#ifndef _MSC_VER
+ /*
+ * Before we get going, crank our limit on file descriptors up to the
+ * hard limit. This is to allow for the fact that libproc keeps file
+ * descriptors to objects open for the lifetime of the proc handle;
+ * without raising our hard limit, we would have an acceptably small
+ * bound on the number of processes that we could concurrently
+ * instrument with the pid provider.
+ */
+ if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
+ rl.rlim_cur = rl.rlim_max;
+ (void) setrlimit(RLIMIT_NOFILE, &rl);
+ }
+#endif
+
+#ifndef VBOX
+ /*
+ * Get the device path of each of the providers. We hold them open
+ * in the df.df_fds list until we open the DTrace driver itself,
+ * allowing us to see all of the probes provided on this system. Once
+ * we have the DTrace driver open, we can safely close all the providers
+ * now that they have registered with the framework.
+ */
+ dt_provmod_open(&provmod, &df);
+
+ dtfd = open("/dev/dtrace/dtrace", O_RDWR);
+ err = errno; /* save errno from opening dtfd */
+
+ ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR);
+ fterr = ftfd == -1 ? errno : 0; /* save errno from open ftfd */
+
+ while (df.df_ents-- != 0)
+ (void) close(df.df_fds[df.df_ents]);
+
+ free(df.df_fds);
+
+ /*
+ * If we failed to open the dtrace device, fail dtrace_open().
+ * We convert some kernel errnos to custom libdtrace errnos to
+ * improve the resulting message from the usual strerror().
+ */
+ if (dtfd == -1) {
+ dt_provmod_destroy(&provmod);
+ switch (err) {
+ case ENOENT:
+ err = EDT_NOENT;
+ break;
+ case EBUSY:
+ err = EDT_BUSY;
+ break;
+ case EACCES:
+ err = EDT_ACCESS;
+ break;
+ }
+ return (set_open_errno(dtp, errp, err));
+ }
+
+ (void) fcntl(dtfd, F_SETFD, FD_CLOEXEC);
+ (void) fcntl(ftfd, F_SETFD, FD_CLOEXEC);
+
+#else /* VBOX */
+
+ rc = SUPR3Init(NULL);
+ if (RT_FAILURE(rc)) {
+ switch (rc) {
+ case VERR_VM_DRIVER_LOAD_ERROR:
+ case VERR_VM_DRIVER_OPEN_ERROR:
+ err = EDT_BUSY;
+ break;
+ case VERR_VM_DRIVER_NOT_INSTALLED:
+ err = EDT_NOENT;
+ break;
+ case VERR_VERSION_MISMATCH:
+ case VERR_VM_DRIVER_VERSION_MISMATCH:
+ err = EDT_VERSION;
+ break;
+ case VERR_VM_DRIVER_NOT_ACCESSIBLE:
+ default:
+ err = EDT_ACCESS;
+ break;
+ }
+ RTStrmPrintf(g_pStdErr, "SUPR3Init: -> %Rrc\n", rc);
+ return (set_open_errno(dtp, errp, err));
+ }
+
+ rc = RTPathAppPrivateArch(szModPath, sizeof(szModPath));
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szModPath, sizeof(szModPath),
+ VBOX_EXTPACK_INSTALL_DIR RTPATH_SLASH_STR VBOX_EXTPACK_VBOXDTRACE_MANGLED_NAME);
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szModPath, sizeof(szModPath), RTBldCfgTargetDotArch());
+ if (RT_SUCCESS(rc))
+ rc = RTPathAppend(szModPath, sizeof(szModPath), "VBoxDTraceR0.r0");
+ if (RT_SUCCESS(rc)) {
+ PRTERRINFO pErrInfo = RTErrInfoAlloc(1024);
+ rc = SUPR3LoadModule(szModPath, "VBoxDTraceR0.r0", &pvImageBase, pErrInfo);
+ if (RT_FAILURE(rc)) {
+ RTStrmPrintf(g_pStdErr, "SUPR3LoadModule: %s -> %Rrc; %s\n", szModPath, rc, pErrInfo->pszMsg);
+ RTErrInfoFree(pErrInfo);
+ return (set_open_errno(dtp, errp, EDT_NOTLOADED));
+ }
+ RTErrInfoFree(pErrInfo);
+ }
+ if (RT_FAILURE(rc)) {
+ RTStrmPrintf(g_pStdErr, "SUPR3LoadModule: path buffer too small (%Rrc)\n", rc);
+ return (set_open_errno(dtp, errp, EDT_BUFTOOSMALL));
+ }
+
+ rc = SUPR3TracerOpen(RT_MAKE_U32_FROM_U8('V', 'B', 'D', 'T'), 0);
+ if (RT_FAILURE(rc)) {
+ RTStrmPrintf(g_pStdErr, "SUPR3TracerOpen: %Rrc\n", rc);
+ return (set_open_errno(dtp, errp, EDT_ACCESS));
+ }
+#endif /* VBOX */
+
+alloc:
+ if ((dtp = malloc(sizeof (dtrace_hdl_t))) == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+
+ bzero(dtp, sizeof (dtrace_hdl_t));
+ dtp->dt_oflags = flags;
+ dtp->dt_prcmode = DT_PROC_STOP_PREINIT;
+ dtp->dt_linkmode = DT_LINK_KERNEL;
+ dtp->dt_linktype = DT_LTYP_ELF;
+ dtp->dt_xlatemode = DT_XL_STATIC;
+ dtp->dt_stdcmode = DT_STDC_XA;
+ dtp->dt_version = version;
+ dtp->dt_fd = dtfd;
+ dtp->dt_ftfd = ftfd;
+ dtp->dt_fterr = fterr;
+ dtp->dt_cdefs_fd = -1;
+ dtp->dt_ddefs_fd = -1;
+ dtp->dt_stdout_fd = -1;
+ dtp->dt_modbuckets = _dtrace_strbuckets;
+ dtp->dt_mods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *));
+ dtp->dt_provbuckets = _dtrace_strbuckets;
+ dtp->dt_provs = calloc(dtp->dt_provbuckets, sizeof (dt_provider_t *));
+ dt_proc_hash_create(dtp);
+ dtp->dt_vmax = DT_VERS_LATEST;
+ dtp->dt_cpp_path = strdup(_dtrace_defcpp);
+ dtp->dt_cpp_argv = malloc(sizeof (char *));
+ dtp->dt_cpp_argc = 1;
+ dtp->dt_cpp_args = 1;
+ dtp->dt_ld_path = strdup(_dtrace_defld);
+ dtp->dt_provmod = provmod;
+ dtp->dt_vector = vector;
+ dtp->dt_varg = arg;
+ dt_dof_init(dtp);
+#ifndef VBOX
+ (void) uname(&dtp->dt_uts);
+#endif
+
+ if (dtp->dt_mods == NULL || dtp->dt_provs == NULL ||
+ dtp->dt_procs == NULL || dtp->dt_ld_path == NULL ||
+ dtp->dt_cpp_path == NULL || dtp->dt_cpp_argv == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+
+ for (i = 0; i < DTRACEOPT_MAX; i++)
+ dtp->dt_options[i] = (uint64_t)DTRACEOPT_UNSET;
+
+ dtp->dt_cpp_argv[0] = (char *)strbasename(dtp->dt_cpp_path);
+
+ (void) snprintf(isadef, sizeof (isadef), "-D__SUNW_D_%u",
+ (uint_t)(sizeof (void *) * NBBY));
+
+#ifndef VBOX
+ (void) snprintf(utsdef, sizeof (utsdef), "-D__%s_%s",
+ dt_get_sysinfo(SI_SYSNAME, s1, sizeof (s1)),
+ dt_get_sysinfo(SI_RELEASE, s2, sizeof (s2)));
+#endif
+
+ if (dt_cpp_add_arg(dtp, "-D__sun") == NULL ||
+ dt_cpp_add_arg(dtp, "-D__unix") == NULL ||
+ dt_cpp_add_arg(dtp, "-D__SVR4") == NULL ||
+ dt_cpp_add_arg(dtp, "-D__SUNW_D=1") == NULL ||
+ dt_cpp_add_arg(dtp, isadef) == NULL ||
+ dt_cpp_add_arg(dtp, utsdef) == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+
+ if (flags & DTRACE_O_NODEV)
+ bcopy(&_dtrace_conf, &dtp->dt_conf, sizeof (_dtrace_conf));
+ else if (dt_ioctl(dtp, DTRACEIOC_CONF, &dtp->dt_conf) != 0)
+ return (set_open_errno(dtp, errp, errno));
+
+ if (flags & DTRACE_O_LP64)
+ dtp->dt_conf.dtc_ctfmodel = CTF_MODEL_LP64;
+ else if (flags & DTRACE_O_ILP32)
+ dtp->dt_conf.dtc_ctfmodel = CTF_MODEL_ILP32;
+
+#ifdef __sparc
+ /*
+ * On SPARC systems, __sparc is always defined for <sys/isa_defs.h>
+ * and __sparcv9 is defined if we are doing a 64-bit compile.
+ */
+ if (dt_cpp_add_arg(dtp, "-D__sparc") == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+
+ if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64 &&
+ dt_cpp_add_arg(dtp, "-D__sparcv9") == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+#endif
+
+#ifdef __x86
+ /*
+ * On x86 systems, __i386 is defined for <sys/isa_defs.h> for 32-bit
+ * compiles and __amd64 is defined for 64-bit compiles. Unlike SPARC,
+ * they are defined exclusive of one another (see PSARC 2004/619).
+ */
+ if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64) {
+ if (dt_cpp_add_arg(dtp, "-D__amd64") == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+ } else {
+ if (dt_cpp_add_arg(dtp, "-D__i386") == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+ }
+#endif
+
+ if (dtp->dt_conf.dtc_difversion < DIF_VERSION)
+ return (set_open_errno(dtp, errp, EDT_DIFVERS));
+
+ if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_ILP32)
+ bcopy(_dtrace_ints_32, dtp->dt_ints, sizeof (_dtrace_ints_32));
+ else
+ bcopy(_dtrace_ints_64, dtp->dt_ints, sizeof (_dtrace_ints_64));
+
+ dtp->dt_macros = dt_idhash_create("macro", NULL, 0, UINT_MAX);
+ dtp->dt_aggs = dt_idhash_create("aggregation", NULL,
+ DTRACE_AGGVARIDNONE + 1, UINT_MAX);
+
+ dtp->dt_globals = dt_idhash_create("global", _dtrace_globals,
+ DIF_VAR_OTHER_UBASE, DIF_VAR_OTHER_MAX);
+
+ dtp->dt_tls = dt_idhash_create("thread local", NULL,
+ DIF_VAR_OTHER_UBASE, DIF_VAR_OTHER_MAX);
+
+ if (dtp->dt_macros == NULL || dtp->dt_aggs == NULL ||
+ dtp->dt_globals == NULL || dtp->dt_tls == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+
+ /*
+ * Populate the dt_macros identifier hash table by hand: we can't use
+ * the dt_idhash_populate() mechanism because we're not yet compiling
+ * and dtrace_update() needs to immediately reference these idents.
+ */
+ for (idp = _dtrace_macros; idp->di_name != NULL; idp++) {
+ if (dt_idhash_insert(dtp->dt_macros, idp->di_name,
+ idp->di_kind, idp->di_flags, idp->di_id, idp->di_attr,
+ idp->di_vers, idp->di_ops ? idp->di_ops : &dt_idops_thaw,
+ idp->di_iarg, 0) == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+ }
+
+ /*
+ * Update the module list using /system/object and load the values for
+ * the macro variable definitions according to the current process.
+ */
+ dtrace_update(dtp);
+
+ /*
+ * Select the intrinsics and typedefs we want based on the data model.
+ * The intrinsics are under "C". The typedefs are added under "D".
+ */
+ if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_ILP32) {
+ dinp = _dtrace_intrinsics_32;
+ dtyp = _dtrace_typedefs_32;
+ } else {
+ dinp = _dtrace_intrinsics_64;
+ dtyp = _dtrace_typedefs_64;
+ }
+
+ /*
+ * Create a dynamic CTF container under the "C" scope for intrinsic
+ * types and types defined in ANSI-C header files that are included.
+ */
+ if ((dmp = dtp->dt_cdefs = dt_module_create(dtp, "C")) == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+
+ if ((dmp->dm_ctfp = ctf_create(&dtp->dt_ctferr)) == NULL)
+ return (set_open_errno(dtp, errp, EDT_CTF));
+
+ dt_dprintf("created CTF container for %s (%p)\n",
+ dmp->dm_name, (void *)dmp->dm_ctfp);
+
+ (void) ctf_setmodel(dmp->dm_ctfp, dtp->dt_conf.dtc_ctfmodel);
+ ctf_setspecific(dmp->dm_ctfp, dmp);
+
+ dmp->dm_flags = DT_DM_LOADED; /* fake up loaded bit */
+ dmp->dm_modid = -1; /* no module ID */
+
+ /*
+ * Fill the dynamic "C" CTF container with all of the intrinsic
+ * integer and floating-point types appropriate for this data model.
+ */
+ for (; dinp->din_name != NULL; dinp++) {
+ if (dinp->din_kind == CTF_K_INTEGER) {
+ err = ctf_add_integer(dmp->dm_ctfp, CTF_ADD_ROOT,
+ dinp->din_name, &dinp->din_data);
+ } else {
+ err = ctf_add_float(dmp->dm_ctfp, CTF_ADD_ROOT,
+ dinp->din_name, &dinp->din_data);
+ }
+
+ if (err == CTF_ERR) {
+ dt_dprintf("failed to add %s to C container: %s\n",
+ dinp->din_name, ctf_errmsg(
+ ctf_errno(dmp->dm_ctfp)));
+ return (set_open_errno(dtp, errp, EDT_CTF));
+ }
+ }
+
+ if (ctf_update(dmp->dm_ctfp) != 0) {
+ dt_dprintf("failed to update C container: %s\n",
+ ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ return (set_open_errno(dtp, errp, EDT_CTF));
+ }
+
+ /*
+ * Add intrinsic pointer types that are needed to initialize printf
+ * format dictionary types (see table in dt_printf.c).
+ */
+ (void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT,
+ ctf_lookup_by_name(dmp->dm_ctfp, "void"));
+
+ (void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT,
+ ctf_lookup_by_name(dmp->dm_ctfp, "char"));
+
+ (void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT,
+ ctf_lookup_by_name(dmp->dm_ctfp, "int"));
+
+ if (ctf_update(dmp->dm_ctfp) != 0) {
+ dt_dprintf("failed to update C container: %s\n",
+ ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ return (set_open_errno(dtp, errp, EDT_CTF));
+ }
+
+ /*
+ * Create a dynamic CTF container under the "D" scope for types that
+ * are defined by the D program itself or on-the-fly by the D compiler.
+ * The "D" CTF container is a child of the "C" CTF container.
+ */
+ if ((dmp = dtp->dt_ddefs = dt_module_create(dtp, "D")) == NULL)
+ return (set_open_errno(dtp, errp, EDT_NOMEM));
+
+ if ((dmp->dm_ctfp = ctf_create(&dtp->dt_ctferr)) == NULL)
+ return (set_open_errno(dtp, errp, EDT_CTF));
+
+ dt_dprintf("created CTF container for %s (%p)\n",
+ dmp->dm_name, (void *)dmp->dm_ctfp);
+
+ (void) ctf_setmodel(dmp->dm_ctfp, dtp->dt_conf.dtc_ctfmodel);
+ ctf_setspecific(dmp->dm_ctfp, dmp);
+
+ dmp->dm_flags = DT_DM_LOADED; /* fake up loaded bit */
+ dmp->dm_modid = -1; /* no module ID */
+
+ if (ctf_import(dmp->dm_ctfp, dtp->dt_cdefs->dm_ctfp) == CTF_ERR) {
+ dt_dprintf("failed to import D parent container: %s\n",
+ ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ return (set_open_errno(dtp, errp, EDT_CTF));
+ }
+
+ /*
+ * Fill the dynamic "D" CTF container with all of the built-in typedefs
+ * that we need to use for our D variable and function definitions.
+ * This ensures that basic inttypes.h names are always available to us.
+ */
+ for (; dtyp->dty_src != NULL; dtyp++) {
+ if (ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT,
+ dtyp->dty_dst, ctf_lookup_by_name(dmp->dm_ctfp,
+ dtyp->dty_src)) == CTF_ERR) {
+ dt_dprintf("failed to add typedef %s %s to D "
+ "container: %s", dtyp->dty_src, dtyp->dty_dst,
+ ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ return (set_open_errno(dtp, errp, EDT_CTF));
+ }
+ }
+
+ /*
+ * Insert a CTF ID corresponding to a pointer to a type of kind
+ * CTF_K_FUNCTION we can use in the compiler for function pointers.
+ * CTF treats all function pointers as "int (*)()" so we only need one.
+ */
+ ctc.ctc_return = ctf_lookup_by_name(dmp->dm_ctfp, "int");
+ ctc.ctc_argc = 0;
+ ctc.ctc_flags = 0;
+
+ dtp->dt_type_func = ctf_add_function(dmp->dm_ctfp,
+ CTF_ADD_ROOT, &ctc, NULL);
+
+ dtp->dt_type_fptr = ctf_add_pointer(dmp->dm_ctfp,
+ CTF_ADD_ROOT, dtp->dt_type_func);
+
+ /*
+ * We also insert CTF definitions for the special D intrinsic types
+ * string and <DYN> into the D container. The string type is added
+ * as a typedef of char[n]. The <DYN> type is an alias for void.
+ * We compare types to these special CTF ids throughout the compiler.
+ */
+ ctr.ctr_contents = ctf_lookup_by_name(dmp->dm_ctfp, "char");
+ ctr.ctr_index = ctf_lookup_by_name(dmp->dm_ctfp, "long");
+ ctr.ctr_nelems = _dtrace_strsize;
+
+ dtp->dt_type_str = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT,
+ "string", ctf_add_array(dmp->dm_ctfp, CTF_ADD_ROOT, &ctr));
+
+ dtp->dt_type_dyn = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT,
+ "<DYN>", ctf_lookup_by_name(dmp->dm_ctfp, "void"));
+
+ dtp->dt_type_stack = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT,
+ "stack", ctf_lookup_by_name(dmp->dm_ctfp, "void"));
+
+ dtp->dt_type_symaddr = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT,
+ "_symaddr", ctf_lookup_by_name(dmp->dm_ctfp, "void"));
+
+ dtp->dt_type_usymaddr = ctf_add_typedef(dmp->dm_ctfp, CTF_ADD_ROOT,
+ "_usymaddr", ctf_lookup_by_name(dmp->dm_ctfp, "void"));
+
+ if (dtp->dt_type_func == CTF_ERR || dtp->dt_type_fptr == CTF_ERR ||
+ dtp->dt_type_str == CTF_ERR || dtp->dt_type_dyn == CTF_ERR ||
+ dtp->dt_type_stack == CTF_ERR || dtp->dt_type_symaddr == CTF_ERR ||
+ dtp->dt_type_usymaddr == CTF_ERR) {
+ dt_dprintf("failed to add intrinsic to D container: %s\n",
+ ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ return (set_open_errno(dtp, errp, EDT_CTF));
+ }
+
+ if (ctf_update(dmp->dm_ctfp) != 0) {
+ dt_dprintf("failed update D container: %s\n",
+ ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ return (set_open_errno(dtp, errp, EDT_CTF));
+ }
+
+ /*
+ * Initialize the integer description table used to convert integer
+ * constants to the appropriate types. Refer to the comments above
+ * dt_node_int() for a complete description of how this table is used.
+ */
+ for (i = 0; i < sizeof (dtp->dt_ints) / sizeof (dtp->dt_ints[0]); i++) {
+ if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_EVERY,
+ dtp->dt_ints[i].did_name, &dtt) != 0) {
+ dt_dprintf("failed to lookup integer type %s: %s\n",
+ dtp->dt_ints[i].did_name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ return (set_open_errno(dtp, errp, dtp->dt_errno));
+ }
+ dtp->dt_ints[i].did_ctfp = dtt.dtt_ctfp;
+ dtp->dt_ints[i].did_type = dtt.dtt_type;
+ }
+
+ /*
+ * Now that we've created the "C" and "D" containers, move them to the
+ * start of the module list so that these types and symbols are found
+ * first (for stability) when iterating through the module list.
+ */
+ dt_list_delete(&dtp->dt_modlist, dtp->dt_ddefs);
+ dt_list_prepend(&dtp->dt_modlist, dtp->dt_ddefs);
+
+ dt_list_delete(&dtp->dt_modlist, dtp->dt_cdefs);
+ dt_list_prepend(&dtp->dt_modlist, dtp->dt_cdefs);
+
+ if (dt_pfdict_create(dtp) == -1)
+ return (set_open_errno(dtp, errp, dtp->dt_errno));
+
+ /*
+ * If we are opening libdtrace DTRACE_O_NODEV enable C_ZDEFS by default
+ * because without /dev/dtrace open, we will not be able to load the
+ * names and attributes of any providers or probes from the kernel.
+ */
+ if (flags & DTRACE_O_NODEV)
+ dtp->dt_cflags |= DTRACE_C_ZDEFS;
+
+ /*
+ * Load hard-wired inlines into the definition cache by calling the
+ * compiler on the raw definition string defined above.
+ */
+ if ((pgp = dtrace_program_strcompile(dtp, _dtrace_hardwire,
+ DTRACE_PROBESPEC_NONE, DTRACE_C_EMPTY, 0, NULL)) == NULL) {
+ dt_dprintf("failed to load hard-wired definitions: %s\n",
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ return (set_open_errno(dtp, errp, EDT_HARDWIRE));
+ }
+
+ dt_program_destroy(dtp, pgp);
+
+#ifndef VBOX
+ /*
+ * Set up the default DTrace library path. Once set, the next call to
+ * dt_compile() will compile all the libraries. We intentionally defer
+ * library processing to improve overhead for clients that don't ever
+ * compile, and to provide better error reporting (because the full
+ * reporting of compiler errors requires dtrace_open() to succeed).
+ */
+ if (dtrace_setopt(dtp, "libdir", _dtrace_libdir) != 0)
+ return (set_open_errno(dtp, errp, dtp->dt_errno));
+#endif
+
+ return (dtp);
+}
+
+dtrace_hdl_t *
+dtrace_open(int version, int flags, int *errp)
+{
+ return (dt_vopen(version, flags, errp, NULL, NULL));
+}
+
+dtrace_hdl_t *
+dtrace_vopen(int version, int flags, int *errp,
+ const dtrace_vector_t *vector, void *arg)
+{
+ return (dt_vopen(version, flags, errp, vector, arg));
+}
+
+void
+dtrace_close(dtrace_hdl_t *dtp)
+{
+ dt_ident_t *idp, *ndp;
+ dt_module_t *dmp;
+ dt_provider_t *pvp;
+ dtrace_prog_t *pgp;
+ dt_xlator_t *dxp;
+ dt_dirpath_t *dirp;
+ int i;
+
+ if (dtp->dt_procs != NULL)
+ dt_proc_hash_destroy(dtp);
+
+ while ((pgp = dt_list_next(&dtp->dt_programs)) != NULL)
+ dt_program_destroy(dtp, pgp);
+
+ while ((dxp = dt_list_next(&dtp->dt_xlators)) != NULL)
+ dt_xlator_destroy(dtp, dxp);
+
+ dt_free(dtp, dtp->dt_xlatormap);
+
+ for (idp = dtp->dt_externs; idp != NULL; idp = ndp) {
+ ndp = idp->di_next;
+ dt_ident_destroy(idp);
+ }
+
+ if (dtp->dt_macros != NULL)
+ dt_idhash_destroy(dtp->dt_macros);
+ if (dtp->dt_aggs != NULL)
+ dt_idhash_destroy(dtp->dt_aggs);
+ if (dtp->dt_globals != NULL)
+ dt_idhash_destroy(dtp->dt_globals);
+ if (dtp->dt_tls != NULL)
+ dt_idhash_destroy(dtp->dt_tls);
+
+ while ((dmp = dt_list_next(&dtp->dt_modlist)) != NULL)
+ dt_module_destroy(dtp, dmp);
+
+ while ((pvp = dt_list_next(&dtp->dt_provlist)) != NULL)
+ dt_provider_destroy(dtp, pvp);
+
+ if (dtp->dt_fd != -1)
+ (void) close(dtp->dt_fd);
+ if (dtp->dt_ftfd != -1)
+ (void) close(dtp->dt_ftfd);
+ if (dtp->dt_cdefs_fd != -1)
+ (void) close(dtp->dt_cdefs_fd);
+ if (dtp->dt_ddefs_fd != -1)
+ (void) close(dtp->dt_ddefs_fd);
+ if (dtp->dt_stdout_fd != -1)
+ (void) close(dtp->dt_stdout_fd);
+
+ dt_epid_destroy(dtp);
+ dt_aggid_destroy(dtp);
+ dt_format_destroy(dtp);
+ dt_buffered_destroy(dtp);
+ dt_aggregate_destroy(dtp);
+ free(dtp->dt_buf.dtbd_data);
+ dt_pfdict_destroy(dtp);
+ dt_provmod_destroy(&dtp->dt_provmod);
+ dt_dof_fini(dtp);
+
+ for (i = 1; i < dtp->dt_cpp_argc; i++)
+ free(dtp->dt_cpp_argv[i]);
+
+ while ((dirp = dt_list_next(&dtp->dt_lib_path)) != NULL) {
+ dt_list_delete(&dtp->dt_lib_path, dirp);
+ free(dirp->dir_path);
+ free(dirp);
+ }
+
+ free(dtp->dt_cpp_argv);
+ free(dtp->dt_cpp_path);
+ free(dtp->dt_ld_path);
+
+ free(dtp->dt_mods);
+ free(dtp->dt_provs);
+ free(dtp);
+}
+
+int
+dtrace_provider_modules(dtrace_hdl_t *dtp, const char **mods, int nmods)
+{
+ dt_provmod_t *prov;
+ int i = 0;
+
+ for (prov = dtp->dt_provmod; prov != NULL; prov = prov->dp_next, i++) {
+ if (i < nmods)
+ mods[i] = prov->dp_name;
+ }
+
+ return (i);
+}
+
+int
+dtrace_ctlfd(dtrace_hdl_t *dtp)
+{
+ return (dtp->dt_fd);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_options.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_options.c
new file mode 100644
index 00000000..b843cb82
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_options.c
@@ -0,0 +1,1118 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/resource.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+
+#include <strings.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include <alloca.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#else /* VBOX */
+# ifndef _MSC_VER
+# include <sys/resource.h>
+# include <unistd.h>
+# include <signal.h>
+# if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+# define open64 open
+# endif
+# else
+# include <io.h>
+# define STDERR_FILENO 2
+# define open64 open
+# endif
+# include <fcntl.h>
+# include <stdlib.h>
+# include <iprt/err.h>
+
+# if RT_GNUC_PREREQ(10, 0)
+# pragma GCC diagnostic ignored "-Walloca-larger-than="
+# endif
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_string.h>
+
+static int
+dt_opt_agg(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dt_aggregate_t *agp = &dtp->dt_aggregate;
+
+ if (arg != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ agp->dtat_flags |= option;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_amin(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ char str[DTRACE_ATTR2STR_MAX];
+ dtrace_attribute_t attr;
+ RT_NOREF1(option);
+
+ if (arg == NULL || dtrace_str2attr(arg, &attr) == -1)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dt_dprintf("set compiler attribute minimum to %s\n",
+ dtrace_attr2str(attr, str, sizeof (str)));
+
+ if (dtp->dt_pcb != NULL) {
+ dtp->dt_pcb->pcb_cflags |= DTRACE_C_EATTR;
+ dtp->dt_pcb->pcb_amin = attr;
+ } else {
+ dtp->dt_cflags |= DTRACE_C_EATTR;
+ dtp->dt_amin = attr;
+ }
+
+ return (0);
+}
+
+static void
+dt_coredump(void)
+{
+ const char msg[] = "libdtrace DEBUG: [ forcing coredump ]\n";
+
+#ifndef _MSC_VER
+ struct sigaction act;
+ struct rlimit lim;
+#endif
+
+ int res = write(STDERR_FILENO, msg, sizeof (msg) - 1);
+ NOREF(res);
+
+#ifndef _MSC_VER
+ act.sa_handler = SIG_DFL;
+ act.sa_flags = 0;
+
+ (void) sigemptyset(&act.sa_mask);
+ (void) sigaction(SIGABRT, &act, NULL);
+
+ lim.rlim_cur = RLIM_INFINITY;
+ lim.rlim_max = RLIM_INFINITY;
+
+ (void) setrlimit(RLIMIT_CORE, &lim);
+#endif /* !_MSC_VER */
+ abort();
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_core(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ static int enabled = 0;
+ RT_NOREF1(option);
+
+ if (arg != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (enabled++ || atexit(dt_coredump) == 0)
+ return (0);
+
+ return (dt_set_errno(dtp, errno));
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_cpp_hdrs(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF1(option);
+
+ if (arg != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dtp->dt_pcb != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTCTX));
+
+ if (dt_cpp_add_arg(dtp, "-H") == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_cpp_path(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ char *cpp;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dtp->dt_pcb != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTCTX));
+
+ if ((cpp = strdup(arg)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ dtp->dt_cpp_argv[0] = (char *)strbasename(cpp);
+ free(dtp->dt_cpp_path);
+ dtp->dt_cpp_path = cpp;
+
+ return (0);
+}
+
+static int
+dt_opt_cpp_opts(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ char *buf;
+ size_t len;
+ const char *opt = (const char *)option;
+
+ if (opt == NULL || arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dtp->dt_pcb != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTCTX));
+
+ len = strlen(opt) + strlen(arg) + 1;
+ buf = alloca(len);
+
+ (void) strcpy(buf, opt);
+ (void) strcat(buf, arg);
+
+ if (dt_cpp_add_arg(dtp, buf) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_ctypes(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ int fd;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if ((fd = open64(arg, O_CREAT | O_WRONLY, 0666)) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ (void) close(dtp->dt_cdefs_fd);
+ dtp->dt_cdefs_fd = fd;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_droptags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF2(option, arg);
+
+ dtp->dt_droptags = 1;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_dtypes(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ int fd;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if ((fd = open64(arg, O_CREAT | O_WRONLY, 0666)) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ (void) close(dtp->dt_ddefs_fd);
+ dtp->dt_ddefs_fd = fd;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_debug(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF1(option);
+
+ if (arg != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ _dtrace_debug = 1;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_iregs(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ int n;
+ RT_NOREF2(arg, option);
+
+ if (arg == NULL || (n = atoi(arg)) <= 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_conf.dtc_difintregs = n;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_lazyload(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF2(arg, option);
+ dtp->dt_lazyload = 1;
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_ld_path(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ char *ld;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dtp->dt_pcb != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTCTX));
+
+ if ((ld = strdup(arg)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ free(dtp->dt_ld_path);
+ dtp->dt_ld_path = ld;
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_libdir(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dt_dirpath_t *dp;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if ((dp = malloc(sizeof (dt_dirpath_t))) == NULL ||
+ (dp->dir_path = strdup(arg)) == NULL) {
+ free(dp);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ dt_list_append(&dtp->dt_lib_path, dp);
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_linkmode(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (strcmp(arg, "kernel") == 0)
+ dtp->dt_linkmode = DT_LINK_KERNEL;
+ else if (strcmp(arg, "primary") == 0)
+ dtp->dt_linkmode = DT_LINK_PRIMARY;
+ else if (strcmp(arg, "dynamic") == 0)
+ dtp->dt_linkmode = DT_LINK_DYNAMIC;
+ else if (strcmp(arg, "static") == 0)
+ dtp->dt_linkmode = DT_LINK_STATIC;
+ else
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_linktype(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (strcasecmp(arg, "elf") == 0)
+ dtp->dt_linktype = DT_LTYP_ELF;
+ else if (strcasecmp(arg, "dof") == 0)
+ dtp->dt_linktype = DT_LTYP_DOF;
+ else
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_evaltime(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (strcmp(arg, "exec") == 0)
+ dtp->dt_prcmode = DT_PROC_STOP_CREATE;
+ else if (strcmp(arg, "preinit") == 0)
+ dtp->dt_prcmode = DT_PROC_STOP_PREINIT;
+ else if (strcmp(arg, "postinit") == 0)
+ dtp->dt_prcmode = DT_PROC_STOP_POSTINIT;
+ else if (strcmp(arg, "main") == 0)
+ dtp->dt_prcmode = DT_PROC_STOP_MAIN;
+ else
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_pgmax(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ int n;
+ RT_NOREF1(option);
+
+ if (arg == NULL || (n = atoi(arg)) < 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_procs->dph_lrulim = n;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_stdc(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dtp->dt_pcb != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTCTX));
+
+ if (strcmp(arg, "a") == 0)
+ dtp->dt_stdcmode = DT_STDC_XA;
+ else if (strcmp(arg, "c") == 0)
+ dtp->dt_stdcmode = DT_STDC_XC;
+ else if (strcmp(arg, "s") == 0)
+ dtp->dt_stdcmode = DT_STDC_XS;
+ else if (strcmp(arg, "t") == 0)
+ dtp->dt_stdcmode = DT_STDC_XT;
+ else
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_syslibdir(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dt_dirpath_t *dp = dt_list_next(&dtp->dt_lib_path);
+ char *path;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if ((path = strdup(arg)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ free(dp->dir_path);
+ dp->dir_path = path;
+
+ return (0);
+}
+
+
+/*ARGSUSED*/
+static int
+dt_opt_tree(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ int m;
+ RT_NOREF1(option);
+
+ if (arg == NULL || (m = atoi(arg)) <= 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_treedump = m;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_tregs(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ int n;
+ RT_NOREF1(option);
+
+ if (arg == NULL || (n = atoi(arg)) <= 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_conf.dtc_diftupregs = n;
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_xlate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (strcmp(arg, "dynamic") == 0)
+ dtp->dt_xlatemode = DT_XL_DYNAMIC;
+ else if (strcmp(arg, "static") == 0)
+ dtp->dt_xlatemode = DT_XL_STATIC;
+ else
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_cflags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ if (arg != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dtp->dt_pcb != NULL)
+ dtp->dt_pcb->pcb_cflags |= option;
+ else
+ dtp->dt_cflags |= option;
+
+ return (0);
+}
+
+static int
+dt_opt_dflags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ if (arg != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_dflags |= option;
+ return (0);
+}
+
+static int
+dt_opt_invcflags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ if (arg != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dtp->dt_pcb != NULL)
+ dtp->dt_pcb->pcb_cflags &= ~option;
+ else
+ dtp->dt_cflags &= ~option;
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_version(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dt_version_t v;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (dt_version_str2num(arg, &v) == -1)
+ return (dt_set_errno(dtp, EDT_VERSINVAL));
+
+ if (!dt_version_defined(v))
+ return (dt_set_errno(dtp, EDT_VERSUNDEF));
+
+ return (dt_reduce(dtp, v));
+}
+
+static int
+dt_opt_runtime(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+#ifndef VBOX
+ char *end;
+#endif
+ dtrace_optval_t val = 0;
+ int i;
+
+ const struct {
+ char *positive;
+ char *negative;
+ } couples[] = {
+ { "yes", "no" },
+ { "enable", "disable" },
+ { "enabled", "disabled" },
+ { "true", "false" },
+ { "on", "off" },
+ { "set", "unset" },
+ { NULL }
+ };
+
+ if (arg != NULL) {
+ if (arg[0] == '\0') {
+ val = DTRACEOPT_UNSET;
+ goto out;
+ }
+
+ for (i = 0; couples[i].positive != NULL; i++) {
+ if (strcasecmp(couples[i].positive, arg) == 0) {
+ val = 1;
+ goto out;
+ }
+
+ if (strcasecmp(couples[i].negative, arg) == 0) {
+ val = DTRACEOPT_UNSET;
+ goto out;
+ }
+ }
+
+#ifndef VBOX
+ errno = 0;
+ val = strtoull(arg, &end, 0);
+
+ if (*end != '\0' || errno != 0 || val < 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+#else
+ i = RTStrToInt64Full(arg, 0, &val);
+ if (i != VINF_SUCCESS)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+#endif
+ }
+
+out:
+ dtp->dt_options[option] = val;
+ return (0);
+}
+
+static int
+dt_optval_parse(const char *arg, dtrace_optval_t *rval)
+{
+ dtrace_optval_t mul = 1;
+ size_t len;
+ char *end;
+#ifdef VBOX
+ int rc;
+#endif
+
+ len = strlen(arg);
+#ifndef VBOX
+ errno = 0;
+#endif
+
+ switch (arg[len - 1]) {
+ case 't':
+ case 'T':
+ mul *= 1024;
+ RT_FALL_THRU();
+ case 'g':
+ case 'G':
+ mul *= 1024;
+ RT_FALL_THRU();
+ case 'm':
+ case 'M':
+ mul *= 1024;
+ RT_FALL_THRU();
+ case 'k':
+ case 'K':
+ mul *= 1024;
+ RT_FALL_THRU();
+ default:
+ break;
+ }
+
+#ifndef VBOX
+ errno = 0;
+ *rval = strtoull(arg, &end, 0) * mul;
+
+ if ((mul > 1 && end != &arg[len - 1]) || (mul == 1 && *end != '\0') ||
+ *rval < 0 || errno != 0)
+ return (-1);
+#else
+ *rval = -1;
+ if (mul == 1) {
+ rc = RTStrToInt64Full(arg, 0, rval);
+ if (rc != VINF_SUCCESS || *rval < 0)
+ return (-1);
+ } else {
+ rc = RTStrToInt64Ex(arg, &end, 0, rval);
+ if ( rc != VWRN_TRAILING_CHARS
+ || end != &arg[len - 1]
+ || *rval < 0)
+ return (-1);
+ *rval *= mul;
+ if (*rval < 0)
+ return (-1);
+ }
+#endif
+
+ return (0);
+}
+
+static int
+dt_opt_size(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dtrace_optval_t val = 0;
+
+ if (arg != NULL && dt_optval_parse(arg, &val) != 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_options[option] = val;
+ return (0);
+}
+
+static int
+dt_opt_rate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ char *end;
+ int i;
+ dtrace_optval_t mul = 1, val = 0;
+
+ const struct {
+ char *name;
+ hrtime_t mul;
+ } suffix[] = {
+ { "ns", NANOSEC / NANOSEC },
+ { "nsec", NANOSEC / NANOSEC },
+ { "us", NANOSEC / MICROSEC },
+ { "usec", NANOSEC / MICROSEC },
+ { "ms", NANOSEC / MILLISEC },
+ { "msec", NANOSEC / MILLISEC },
+ { "s", NANOSEC / SEC },
+ { "sec", NANOSEC / SEC },
+ { "m", NANOSEC * (hrtime_t)60 },
+ { "min", NANOSEC * (hrtime_t)60 },
+ { "h", NANOSEC * (hrtime_t)60 * (hrtime_t)60 },
+ { "hour", NANOSEC * (hrtime_t)60 * (hrtime_t)60 },
+ { "d", NANOSEC * (hrtime_t)(24 * 60 * 60) },
+ { "day", NANOSEC * (hrtime_t)(24 * 60 * 60) },
+ { "hz", 0 },
+ { NULL }
+ };
+
+ if (arg != NULL) {
+#ifndef VBOX
+ errno = 0;
+ val = strtoull(arg, &end, 0);
+#else
+ int rc = RTStrToInt64Ex(arg, &end, 0, &val);
+ if (rc != VWRN_TRAILING_CHARS)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+#endif
+
+ for (i = 0; suffix[i].name != NULL; i++) {
+ if (strcasecmp(suffix[i].name, end) == 0) {
+ mul = suffix[i].mul;
+ break;
+ }
+ }
+
+ if ((suffix[i].name == NULL && *end != '\0') || val < 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (mul == 0) {
+ /*
+ * The rate has been specified in frequency-per-second.
+ */
+ if (val != 0)
+ val = NANOSEC / val;
+ } else {
+ val *= mul;
+ }
+ }
+
+ dtp->dt_options[option] = val;
+ return (0);
+}
+
+/*
+ * When setting the strsize option, set the option in the dt_options array
+ * using dt_opt_size() as usual, and then update the definition of the CTF
+ * type for the D intrinsic "string" to be an array of the corresponding size.
+ * If any errors occur, reset dt_options[option] to its previous value.
+ */
+static int
+dt_opt_strsize(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dtrace_optval_t val = dtp->dt_options[option];
+ ctf_file_t *fp = DT_STR_CTFP(dtp);
+ ctf_id_t type = ctf_type_resolve(fp, DT_STR_TYPE(dtp));
+ ctf_arinfo_t r;
+
+ if (dt_opt_size(dtp, arg, option) != 0)
+ return (-1); /* dt_errno is set for us */
+
+ if (dtp->dt_options[option] > UINT_MAX) {
+ dtp->dt_options[option] = val;
+ return (dt_set_errno(dtp, EOVERFLOW));
+ }
+
+ if (ctf_array_info(fp, type, &r) == CTF_ERR) {
+ dtp->dt_options[option] = val;
+ dtp->dt_ctferr = ctf_errno(fp);
+ return (dt_set_errno(dtp, EDT_CTF));
+ }
+
+ r.ctr_nelems = (uint_t)dtp->dt_options[option];
+
+ if (ctf_set_array(fp, type, &r) == CTF_ERR ||
+ ctf_update(fp) == CTF_ERR) {
+ dtp->dt_options[option] = val;
+ dtp->dt_ctferr = ctf_errno(fp);
+ return (dt_set_errno(dtp, EDT_CTF));
+ }
+
+ return (0);
+}
+
+static const struct {
+ const char *dtbp_name;
+ int dtbp_policy;
+} _dtrace_bufpolicies[] = {
+ { "ring", DTRACEOPT_BUFPOLICY_RING },
+ { "fill", DTRACEOPT_BUFPOLICY_FILL },
+ { "switch", DTRACEOPT_BUFPOLICY_SWITCH },
+ { NULL, 0 }
+};
+
+/*ARGSUSED*/
+static int
+dt_opt_bufpolicy(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dtrace_optval_t policy = DTRACEOPT_UNSET;
+ int i;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ for (i = 0; _dtrace_bufpolicies[i].dtbp_name != NULL; i++) {
+ if (strcmp(_dtrace_bufpolicies[i].dtbp_name, arg) == 0) {
+ policy = _dtrace_bufpolicies[i].dtbp_policy;
+ break;
+ }
+ }
+
+ if (policy == DTRACEOPT_UNSET)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_options[DTRACEOPT_BUFPOLICY] = policy;
+
+ return (0);
+}
+
+static const struct {
+ const char *dtbr_name;
+ int dtbr_policy;
+} _dtrace_bufresize[] = {
+ { "auto", DTRACEOPT_BUFRESIZE_AUTO },
+ { "manual", DTRACEOPT_BUFRESIZE_MANUAL },
+ { NULL, 0 }
+};
+
+/*ARGSUSED*/
+static int
+dt_opt_bufresize(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dtrace_optval_t policy = DTRACEOPT_UNSET;
+ int i;
+ RT_NOREF1(option);
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ for (i = 0; _dtrace_bufresize[i].dtbr_name != NULL; i++) {
+ if (strcmp(_dtrace_bufresize[i].dtbr_name, arg) == 0) {
+ policy = _dtrace_bufresize[i].dtbr_policy;
+ break;
+ }
+ }
+
+ if (policy == DTRACEOPT_UNSET)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ dtp->dt_options[DTRACEOPT_BUFRESIZE] = policy;
+
+ return (0);
+}
+
+int
+dt_options_load(dtrace_hdl_t *dtp)
+{
+ dof_hdr_t hdr, *dof;
+ dof_sec_t *sec VBDTMSC(NULL);
+ size_t offs;
+ VBDTTYPE(uint32_t,int) i;
+
+ /*
+ * To load the option values, we need to ask the kernel to provide its
+ * DOF, which we'll sift through to look for OPTDESC sections.
+ */
+ bzero(&hdr, sizeof (dof_hdr_t));
+ hdr.dofh_loadsz = sizeof (dof_hdr_t);
+
+ if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &hdr) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ if (hdr.dofh_loadsz < sizeof (dof_hdr_t))
+ return (dt_set_errno(dtp, EINVAL));
+
+ dof = alloca(hdr.dofh_loadsz);
+ bzero(dof, sizeof (dof_hdr_t));
+ dof->dofh_loadsz = hdr.dofh_loadsz;
+
+ for (i = 0; i < DTRACEOPT_MAX; i++)
+ dtp->dt_options[i] = (uint64_t)DTRACEOPT_UNSET;
+
+ if (dt_ioctl(dtp, DTRACEIOC_DOFGET, dof) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ sec = (dof_sec_t *)(uintptr_t)((uintptr_t)dof +
+ dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (sec->dofs_type != DOF_SECT_OPTDESC)
+ continue;
+
+ break;
+ }
+
+ for (offs = 0; offs < sec->dofs_size; offs += sec->dofs_entsize) {
+ dof_optdesc_t *opt = (dof_optdesc_t *)(uintptr_t)
+ ((uintptr_t)dof + sec->dofs_offset + offs);
+
+ if (opt->dofo_strtab != DOF_SECIDX_NONE)
+ continue;
+
+ if (opt->dofo_option >= DTRACEOPT_MAX)
+ continue;
+
+ dtp->dt_options[opt->dofo_option] = opt->dofo_value;
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_opt_preallocate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ dtrace_optval_t size;
+ void *p;
+ RT_NOREF1(option);
+
+ if (arg == NULL || dt_optval_parse(arg, &size) != 0)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (size > SIZE_MAX)
+ size = SIZE_MAX;
+
+ if ((p = dt_zalloc(dtp, size)) == NULL) {
+ do {
+ size /= 2;
+ } while ((p = dt_zalloc(dtp, size)) == NULL);
+ }
+
+ dt_free(dtp, p);
+
+ return (0);
+}
+
+typedef struct dt_option {
+ const char *o_name;
+ int (*o_func)(dtrace_hdl_t *, const char *, uintptr_t);
+ uintptr_t o_option;
+} dt_option_t;
+
+/*
+ * Compile-time options.
+ */
+static const dt_option_t _dtrace_ctoptions[] = {
+ { "aggpercpu", dt_opt_agg, DTRACE_A_PERCPU },
+ { "amin", dt_opt_amin },
+ { "argref", dt_opt_cflags, DTRACE_C_ARGREF },
+ { "core", dt_opt_core },
+ { "cpp", dt_opt_cflags, DTRACE_C_CPP },
+ { "cpphdrs", dt_opt_cpp_hdrs },
+ { "cpppath", dt_opt_cpp_path },
+ { "ctypes", dt_opt_ctypes },
+ { "defaultargs", dt_opt_cflags, DTRACE_C_DEFARG },
+ { "dtypes", dt_opt_dtypes },
+ { "debug", dt_opt_debug },
+ { "define", dt_opt_cpp_opts, (uintptr_t)"-D" },
+ { "droptags", dt_opt_droptags },
+ { "empty", dt_opt_cflags, DTRACE_C_EMPTY },
+ { "errtags", dt_opt_cflags, DTRACE_C_ETAGS },
+ { "evaltime", dt_opt_evaltime },
+ { "incdir", dt_opt_cpp_opts, (uintptr_t)"-I" },
+ { "iregs", dt_opt_iregs },
+ { "kdefs", dt_opt_invcflags, DTRACE_C_KNODEF },
+ { "knodefs", dt_opt_cflags, DTRACE_C_KNODEF },
+ { "late", dt_opt_xlate },
+ { "lazyload", dt_opt_lazyload },
+ { "ldpath", dt_opt_ld_path },
+ { "libdir", dt_opt_libdir },
+ { "linkmode", dt_opt_linkmode },
+ { "linktype", dt_opt_linktype },
+ { "nolibs", dt_opt_cflags, DTRACE_C_NOLIBS },
+ { "pgmax", dt_opt_pgmax },
+ { "preallocate", dt_opt_preallocate },
+ { "pspec", dt_opt_cflags, DTRACE_C_PSPEC },
+ { "stdc", dt_opt_stdc },
+ { "strip", dt_opt_dflags, DTRACE_D_STRIP },
+ { "syslibdir", dt_opt_syslibdir },
+ { "tree", dt_opt_tree },
+ { "tregs", dt_opt_tregs },
+ { "udefs", dt_opt_invcflags, DTRACE_C_UNODEF },
+ { "undef", dt_opt_cpp_opts, (uintptr_t)"-U" },
+ { "unodefs", dt_opt_cflags, DTRACE_C_UNODEF },
+ { "verbose", dt_opt_cflags, DTRACE_C_DIFV },
+ { "version", dt_opt_version },
+ { "zdefs", dt_opt_cflags, DTRACE_C_ZDEFS },
+ { NULL }
+};
+
+/*
+ * Run-time options.
+ */
+static const dt_option_t _dtrace_rtoptions[] = {
+ { "aggsize", dt_opt_size, DTRACEOPT_AGGSIZE },
+ { "bufsize", dt_opt_size, DTRACEOPT_BUFSIZE },
+ { "bufpolicy", dt_opt_bufpolicy, DTRACEOPT_BUFPOLICY },
+ { "bufresize", dt_opt_bufresize, DTRACEOPT_BUFRESIZE },
+ { "cleanrate", dt_opt_rate, DTRACEOPT_CLEANRATE },
+ { "cpu", dt_opt_runtime, DTRACEOPT_CPU },
+ { "destructive", dt_opt_runtime, DTRACEOPT_DESTRUCTIVE },
+ { "dynvarsize", dt_opt_size, DTRACEOPT_DYNVARSIZE },
+ { "grabanon", dt_opt_runtime, DTRACEOPT_GRABANON },
+ { "jstackframes", dt_opt_runtime, DTRACEOPT_JSTACKFRAMES },
+ { "jstackstrsize", dt_opt_size, DTRACEOPT_JSTACKSTRSIZE },
+ { "nspec", dt_opt_runtime, DTRACEOPT_NSPEC },
+ { "specsize", dt_opt_size, DTRACEOPT_SPECSIZE },
+ { "stackframes", dt_opt_runtime, DTRACEOPT_STACKFRAMES },
+ { "statusrate", dt_opt_rate, DTRACEOPT_STATUSRATE },
+ { "strsize", dt_opt_strsize, DTRACEOPT_STRSIZE },
+ { "ustackframes", dt_opt_runtime, DTRACEOPT_USTACKFRAMES },
+ { NULL }
+};
+
+/*
+ * Dynamic run-time options.
+ */
+static const dt_option_t _dtrace_drtoptions[] = {
+ { "aggrate", dt_opt_rate, DTRACEOPT_AGGRATE },
+ { "aggsortkey", dt_opt_runtime, DTRACEOPT_AGGSORTKEY },
+ { "aggsortkeypos", dt_opt_runtime, DTRACEOPT_AGGSORTKEYPOS },
+ { "aggsortpos", dt_opt_runtime, DTRACEOPT_AGGSORTPOS },
+ { "aggsortrev", dt_opt_runtime, DTRACEOPT_AGGSORTREV },
+ { "flowindent", dt_opt_runtime, DTRACEOPT_FLOWINDENT },
+ { "quiet", dt_opt_runtime, DTRACEOPT_QUIET },
+ { "rawbytes", dt_opt_runtime, DTRACEOPT_RAWBYTES },
+ { "stackindent", dt_opt_runtime, DTRACEOPT_STACKINDENT },
+ { "switchrate", dt_opt_rate, DTRACEOPT_SWITCHRATE },
+ { NULL }
+};
+
+int
+dtrace_getopt(dtrace_hdl_t *dtp, const char *opt, dtrace_optval_t *val)
+{
+ const dt_option_t *op;
+
+ if (opt == NULL)
+ return (dt_set_errno(dtp, EINVAL));
+
+ /*
+ * We only need to search the run-time options -- it's not legal
+ * to get the values of compile-time options.
+ */
+ for (op = _dtrace_rtoptions; op->o_name != NULL; op++) {
+ if (strcmp(op->o_name, opt) == 0) {
+ *val = dtp->dt_options[op->o_option];
+ return (0);
+ }
+ }
+
+ for (op = _dtrace_drtoptions; op->o_name != NULL; op++) {
+ if (strcmp(op->o_name, opt) == 0) {
+ *val = dtp->dt_options[op->o_option];
+ return (0);
+ }
+ }
+
+ return (dt_set_errno(dtp, EDT_BADOPTNAME));
+}
+
+int
+dtrace_setopt(dtrace_hdl_t *dtp, const char *opt, const char *val)
+{
+ const dt_option_t *op;
+
+ if (opt == NULL)
+ return (dt_set_errno(dtp, EINVAL));
+
+ for (op = _dtrace_ctoptions; op->o_name != NULL; op++) {
+ if (strcmp(op->o_name, opt) == 0)
+ return (op->o_func(dtp, val, op->o_option));
+ }
+
+ for (op = _dtrace_drtoptions; op->o_name != NULL; op++) {
+ if (strcmp(op->o_name, opt) == 0)
+ return (op->o_func(dtp, val, op->o_option));
+ }
+
+ for (op = _dtrace_rtoptions; op->o_name != NULL; op++) {
+ if (strcmp(op->o_name, opt) == 0) {
+ /*
+ * Only dynamic run-time options may be set while
+ * tracing is active.
+ */
+ if (dtp->dt_active)
+ return (dt_set_errno(dtp, EDT_ACTIVE));
+
+ return (op->o_func(dtp, val, op->o_option));
+ }
+ }
+
+ return (dt_set_errno(dtp, EDT_BADOPTNAME));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.c
new file mode 100644
index 00000000..7261b794
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.c
@@ -0,0 +1,4907 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * DTrace D Language Parser
+ *
+ * The D Parser is a lex/yacc parser consisting of the lexer dt_lex.l, the
+ * parsing grammar dt_grammar.y, and this file, dt_parser.c, which handles
+ * the construction of the parse tree nodes and their syntactic validation.
+ * The parse tree is constructed of dt_node_t structures (see <dt_parser.h>)
+ * that are built in two passes: (1) the "create" pass, where the parse tree
+ * nodes are allocated by calls from the grammar to dt_node_*() subroutines,
+ * and (2) the "cook" pass, where nodes are coalesced, assigned D types, and
+ * validated according to the syntactic rules of the language.
+ *
+ * All node allocations are performed using dt_node_alloc(). All node frees
+ * during the parsing phase are performed by dt_node_free(), which frees node-
+ * internal state but does not actually free the nodes. All final node frees
+ * are done as part of the end of dt_compile() or as part of destroying
+ * persistent identifiers or translators which have embedded nodes.
+ *
+ * The dt_node_* routines that implement pass (1) may allocate new nodes. The
+ * dt_cook_* routines that implement pass (2) may *not* allocate new nodes.
+ * They may free existing nodes using dt_node_free(), but they may not actually
+ * deallocate any dt_node_t's. Currently dt_cook_op2() is an exception to this
+ * rule: see the comments therein for how this issue is resolved.
+ *
+ * The dt_cook_* routines are responsible for (at minimum) setting the final
+ * node type (dn_ctfp/dn_type) and attributes (dn_attr). If dn_ctfp/dn_type
+ * are set manually (i.e. not by one of the type assignment functions), then
+ * the DT_NF_COOKED flag must be set manually on the node.
+ *
+ * The cooking pass can be applied to the same parse tree more than once (used
+ * in the case of a comma-separated list of probe descriptions). As such, the
+ * cook routines must not perform any parse tree transformations which would
+ * be invalid if the tree were subsequently cooked using a different context.
+ *
+ * The dn_ctfp and dn_type fields form the type of the node. This tuple can
+ * take on the following set of values, which form our type invariants:
+ *
+ * 1. dn_ctfp = NULL, dn_type = CTF_ERR
+ *
+ * In this state, the node has unknown type and is not yet cooked. The
+ * DT_NF_COOKED flag is not yet set on the node.
+ *
+ * 2. dn_ctfp = DT_DYN_CTFP(dtp), dn_type = DT_DYN_TYPE(dtp)
+ *
+ * In this state, the node is a dynamic D type. This means that generic
+ * operations are not valid on this node and only code that knows how to
+ * examine the inner details of the node can operate on it. A <DYN> node
+ * must have dn_ident set to point to an identifier describing the object
+ * and its type. The DT_NF_REF flag is set for all nodes of type <DYN>.
+ * At present, the D compiler uses the <DYN> type for:
+ *
+ * - associative arrays that do not yet have a value type defined
+ * - translated data (i.e. the result of the xlate operator)
+ * - aggregations
+ *
+ * 3. dn_ctfp = DT_STR_CTFP(dtp), dn_type = DT_STR_TYPE(dtp)
+ *
+ * In this state, the node is of type D string. The string type is really
+ * a char[0] typedef, but requires special handling throughout the compiler.
+ *
+ * 4. dn_ctfp != NULL, dn_type = any other type ID
+ *
+ * In this state, the node is of some known D/CTF type. The normal libctf
+ * APIs can be used to learn more about the type name or structure. When
+ * the type is assigned, the DT_NF_SIGNED, DT_NF_REF, and DT_NF_BITFIELD
+ * flags cache the corresponding attributes of the underlying CTF type.
+ */
+
+#ifndef VBOX
+#include <sys/param.h>
+#include <limits.h>
+#include <setjmp.h>
+#include <strings.h>
+#include <assert.h>
+#include <alloca.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ctype.h>
+#else /* VBOX */
+# include <ctype.h>
+# ifdef _MSC_VER
+# pragma warning(disable:4146) /* -unsigned */
+# pragma warning(disable:4267) /* size_t to int */
+# endif
+#endif /* VBOX */
+
+#include <dt_impl.h>
+#include <dt_grammar.h>
+#include <dt_module.h>
+#include <dt_provider.h>
+#include <dt_string.h>
+#include <dt_as.h>
+
+dt_pcb_t *yypcb; /* current control block for parser */
+dt_node_t *yypragma; /* lex token list for control lines */
+char yyintprefix; /* int token macro prefix (+/-) */
+char yyintsuffix[4]; /* int token suffix string [uU][lL] */
+int yyintdecimal; /* int token format flag (1=decimal, 0=octal/hex) */
+
+static const char *
+opstr(int op)
+{
+ switch (op) {
+ case DT_TOK_COMMA: return (",");
+ case DT_TOK_ELLIPSIS: return ("...");
+ case DT_TOK_ASGN: return ("=");
+ case DT_TOK_ADD_EQ: return ("+=");
+ case DT_TOK_SUB_EQ: return ("-=");
+ case DT_TOK_MUL_EQ: return ("*=");
+ case DT_TOK_DIV_EQ: return ("/=");
+ case DT_TOK_MOD_EQ: return ("%=");
+ case DT_TOK_AND_EQ: return ("&=");
+ case DT_TOK_XOR_EQ: return ("^=");
+ case DT_TOK_OR_EQ: return ("|=");
+ case DT_TOK_LSH_EQ: return ("<<=");
+ case DT_TOK_RSH_EQ: return (">>=");
+ case DT_TOK_QUESTION: return ("?");
+ case DT_TOK_COLON: return (":");
+ case DT_TOK_LOR: return ("||");
+ case DT_TOK_LXOR: return ("^^");
+ case DT_TOK_LAND: return ("&&");
+ case DT_TOK_BOR: return ("|");
+ case DT_TOK_XOR: return ("^");
+ case DT_TOK_BAND: return ("&");
+ case DT_TOK_EQU: return ("==");
+ case DT_TOK_NEQ: return ("!=");
+ case DT_TOK_LT: return ("<");
+ case DT_TOK_LE: return ("<=");
+ case DT_TOK_GT: return (">");
+ case DT_TOK_GE: return (">=");
+ case DT_TOK_LSH: return ("<<");
+ case DT_TOK_RSH: return (">>");
+ case DT_TOK_ADD: return ("+");
+ case DT_TOK_SUB: return ("-");
+ case DT_TOK_MUL: return ("*");
+ case DT_TOK_DIV: return ("/");
+ case DT_TOK_MOD: return ("%");
+ case DT_TOK_LNEG: return ("!");
+ case DT_TOK_BNEG: return ("~");
+ case DT_TOK_ADDADD: return ("++");
+ case DT_TOK_PREINC: return ("++");
+ case DT_TOK_POSTINC: return ("++");
+ case DT_TOK_SUBSUB: return ("--");
+ case DT_TOK_PREDEC: return ("--");
+ case DT_TOK_POSTDEC: return ("--");
+ case DT_TOK_IPOS: return ("+");
+ case DT_TOK_INEG: return ("-");
+ case DT_TOK_DEREF: return ("*");
+ case DT_TOK_ADDROF: return ("&");
+ case DT_TOK_OFFSETOF: return ("offsetof");
+ case DT_TOK_SIZEOF: return ("sizeof");
+ case DT_TOK_STRINGOF: return ("stringof");
+ case DT_TOK_XLATE: return ("xlate");
+ case DT_TOK_LPAR: return ("(");
+ case DT_TOK_RPAR: return (")");
+ case DT_TOK_LBRAC: return ("[");
+ case DT_TOK_RBRAC: return ("]");
+ case DT_TOK_PTR: return ("->");
+ case DT_TOK_DOT: return (".");
+ case DT_TOK_STRING: return ("<string>");
+ case DT_TOK_IDENT: return ("<ident>");
+ case DT_TOK_TNAME: return ("<type>");
+ case DT_TOK_INT: return ("<int>");
+ default: return ("<?>");
+ }
+}
+
+int
+dt_type_lookup(const char *s, dtrace_typeinfo_t *tip)
+{
+ static const char delimiters[] = " \t\n\r\v\f*`";
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ const char *p, *q, *end, *obj;
+
+ for (p = s, end = s + strlen(s); *p != '\0'; p = q) {
+ while (isspace(*p))
+ p++; /* skip leading whitespace prior to token */
+
+ if (p == end || (q = strpbrk(p + 1, delimiters)) == NULL)
+ break; /* empty string or single token remaining */
+
+ if (*q == '`') {
+ char *object = alloca((size_t)(q - p) + 1);
+ char *type = alloca((size_t)(end - s) + 1);
+
+ /*
+ * Copy from the start of the token (p) to the location
+ * backquote (q) to extract the nul-terminated object.
+ */
+ bcopy(p, object, (size_t)(q - p));
+ object[(size_t)(q - p)] = '\0';
+
+ /*
+ * Copy the original string up to the start of this
+ * token (p) into type, and then concatenate everything
+ * after q. This is the type name without the object.
+ */
+ bcopy(s, type, (size_t)(p - s));
+ bcopy(q + 1, type + (size_t)(p - s), strlen(q + 1) + 1);
+
+ if (strchr(q + 1, '`') != NULL)
+ return (dt_set_errno(dtp, EDT_BADSCOPE));
+
+ return (dtrace_lookup_by_type(dtp, object, type, tip));
+ }
+ }
+
+ if (yypcb->pcb_idepth != 0)
+ obj = DTRACE_OBJ_CDEFS;
+ else
+ obj = DTRACE_OBJ_EVERY;
+
+ return (dtrace_lookup_by_type(dtp, obj, s, tip));
+}
+
+/*
+ * When we parse type expressions or parse an expression with unary "&", we
+ * need to find a type that is a pointer to a previously known type.
+ * Unfortunately CTF is limited to a per-container view, so ctf_type_pointer()
+ * alone does not suffice for our needs. We provide a more intelligent wrapper
+ * for the compiler that attempts to compute a pointer to either the given type
+ * or its base (that is, we try both "foo_t *" and "struct foo *"), and also
+ * to potentially construct the required type on-the-fly.
+ */
+int
+dt_type_pointer(dtrace_typeinfo_t *tip)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ ctf_file_t *ctfp = tip->dtt_ctfp;
+ ctf_id_t type = tip->dtt_type;
+ ctf_id_t base = ctf_type_resolve(ctfp, type);
+
+ dt_module_t *dmp;
+ ctf_id_t ptr;
+
+ if ((ptr = ctf_type_pointer(ctfp, type)) != CTF_ERR ||
+ (ptr = ctf_type_pointer(ctfp, base)) != CTF_ERR) {
+ tip->dtt_type = ptr;
+ return (0);
+ }
+
+ if (yypcb->pcb_idepth != 0)
+ dmp = dtp->dt_cdefs;
+ else
+ dmp = dtp->dt_ddefs;
+
+ if (ctfp != dmp->dm_ctfp && ctfp != ctf_parent_file(dmp->dm_ctfp) &&
+ (type = ctf_add_type(dmp->dm_ctfp, ctfp, type)) == CTF_ERR) {
+ dtp->dt_ctferr = ctf_errno(dmp->dm_ctfp);
+ return (dt_set_errno(dtp, EDT_CTF));
+ }
+
+ ptr = ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, type);
+
+ if (ptr == CTF_ERR || ctf_update(dmp->dm_ctfp) == CTF_ERR) {
+ dtp->dt_ctferr = ctf_errno(dmp->dm_ctfp);
+ return (dt_set_errno(dtp, EDT_CTF));
+ }
+
+ tip->dtt_object = dmp->dm_name;
+ tip->dtt_ctfp = dmp->dm_ctfp;
+ tip->dtt_type = ptr;
+
+ return (0);
+}
+
+const char *
+dt_type_name(ctf_file_t *ctfp, ctf_id_t type, char *buf, size_t len)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+
+ if (ctfp == DT_FPTR_CTFP(dtp) && type == DT_FPTR_TYPE(dtp))
+ (void) snprintf(buf, len, "function pointer");
+ else if (ctfp == DT_FUNC_CTFP(dtp) && type == DT_FUNC_TYPE(dtp))
+ (void) snprintf(buf, len, "function");
+ else if (ctfp == DT_DYN_CTFP(dtp) && type == DT_DYN_TYPE(dtp))
+ (void) snprintf(buf, len, "dynamic variable");
+ else if (ctfp == NULL)
+ (void) snprintf(buf, len, "<none>");
+ else if (ctf_type_name(ctfp, type, buf, len) == NULL)
+ (void) snprintf(buf, len, "unknown");
+
+ return (buf);
+}
+
+/*
+ * Perform the "usual arithmetic conversions" to determine which of the two
+ * input operand types should be promoted and used as a result type. The
+ * rules for this are described in ISOC[6.3.1.8] and K&R[A6.5].
+ */
+static void
+dt_type_promote(dt_node_t *lp, dt_node_t *rp, ctf_file_t **ofp, ctf_id_t *otype)
+{
+ ctf_file_t *lfp = lp->dn_ctfp;
+ ctf_id_t ltype = lp->dn_type;
+
+ ctf_file_t *rfp = rp->dn_ctfp;
+ ctf_id_t rtype = rp->dn_type;
+
+ ctf_id_t lbase = ctf_type_resolve(lfp, ltype);
+ uint_t lkind = ctf_type_kind(lfp, lbase);
+
+ ctf_id_t rbase = ctf_type_resolve(rfp, rtype);
+ uint_t rkind = ctf_type_kind(rfp, rbase);
+
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ ctf_encoding_t le, re;
+ uint_t lrank, rrank;
+
+ assert(lkind == CTF_K_INTEGER || lkind == CTF_K_ENUM);
+ assert(rkind == CTF_K_INTEGER || rkind == CTF_K_ENUM);
+
+ if (lkind == CTF_K_ENUM) {
+ lfp = DT_INT_CTFP(dtp);
+ ltype = lbase = DT_INT_TYPE(dtp);
+ }
+
+ if (rkind == CTF_K_ENUM) {
+ rfp = DT_INT_CTFP(dtp);
+ rtype = rbase = DT_INT_TYPE(dtp);
+ }
+
+ if (ctf_type_encoding(lfp, lbase, &le) == CTF_ERR) {
+ yypcb->pcb_hdl->dt_ctferr = ctf_errno(lfp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
+ }
+
+ if (ctf_type_encoding(rfp, rbase, &re) == CTF_ERR) {
+ yypcb->pcb_hdl->dt_ctferr = ctf_errno(rfp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
+ }
+
+ /*
+ * Compute an integer rank based on the size and unsigned status.
+ * If rank is identical, pick the "larger" of the equivalent types
+ * which we define as having a larger base ctf_id_t. If rank is
+ * different, pick the type with the greater rank.
+ */
+ lrank = le.cte_bits + ((le.cte_format & CTF_INT_SIGNED) == 0);
+ rrank = re.cte_bits + ((re.cte_format & CTF_INT_SIGNED) == 0);
+
+ if (lrank == rrank) {
+ if (lbase - rbase < 0)
+ goto return_rtype;
+ else
+ goto return_ltype;
+ } else if (lrank > rrank) {
+ goto return_ltype;
+ } else
+ goto return_rtype;
+
+return_ltype:
+ *ofp = lfp;
+ *otype = ltype;
+ return;
+
+return_rtype:
+ *ofp = rfp;
+ *otype = rtype;
+}
+
+void
+dt_node_promote(dt_node_t *lp, dt_node_t *rp, dt_node_t *dnp)
+{
+ dt_type_promote(lp, rp, &dnp->dn_ctfp, &dnp->dn_type);
+ dt_node_type_assign(dnp, dnp->dn_ctfp, dnp->dn_type);
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+}
+
+const char *
+dt_node_name(const dt_node_t *dnp, char *buf, size_t len)
+{
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ const char *prefix = "", *suffix = "";
+ const dtrace_syminfo_t *dts;
+ char *s;
+
+ switch (dnp->dn_kind) {
+ case DT_NODE_INT:
+ (void) snprintf(buf, len, "integer constant 0x%llx",
+ (u_longlong_t)dnp->dn_value);
+ break;
+ case DT_NODE_STRING:
+ s = strchr2esc(dnp->dn_string, strlen(dnp->dn_string));
+ (void) snprintf(buf, len, "string constant \"%s\"",
+ s != NULL ? s : dnp->dn_string);
+ free(s);
+ break;
+ case DT_NODE_IDENT:
+ (void) snprintf(buf, len, "identifier %s", dnp->dn_string);
+ break;
+ case DT_NODE_VAR:
+ case DT_NODE_FUNC:
+ case DT_NODE_AGG:
+ case DT_NODE_INLINE:
+ switch (dnp->dn_ident->di_kind) {
+ case DT_IDENT_FUNC:
+ case DT_IDENT_AGGFUNC:
+ case DT_IDENT_ACTFUNC:
+ suffix = "( )";
+ break;
+ case DT_IDENT_AGG:
+ prefix = "@";
+ break;
+ }
+ (void) snprintf(buf, len, "%s %s%s%s",
+ dt_idkind_name(dnp->dn_ident->di_kind),
+ prefix, dnp->dn_ident->di_name, suffix);
+ break;
+ case DT_NODE_SYM:
+ dts = dnp->dn_ident->di_data;
+ (void) snprintf(buf, len, "symbol %s`%s",
+ dts->dts_object, dts->dts_name);
+ break;
+ case DT_NODE_TYPE:
+ (void) snprintf(buf, len, "type %s",
+ dt_node_type_name(dnp, n1, sizeof (n1)));
+ break;
+ case DT_NODE_OP1:
+ case DT_NODE_OP2:
+ case DT_NODE_OP3:
+ (void) snprintf(buf, len, "operator %s", opstr(dnp->dn_op));
+ break;
+ case DT_NODE_DEXPR:
+ case DT_NODE_DFUNC:
+ if (dnp->dn_expr)
+ return (dt_node_name(dnp->dn_expr, buf, len));
+ (void) snprintf(buf, len, "%s", "statement");
+ break;
+ case DT_NODE_PDESC:
+ if (dnp->dn_desc->dtpd_id == 0) {
+ (void) snprintf(buf, len,
+ "probe description %s:%s:%s:%s",
+ dnp->dn_desc->dtpd_provider, dnp->dn_desc->dtpd_mod,
+ dnp->dn_desc->dtpd_func, dnp->dn_desc->dtpd_name);
+ } else {
+ (void) snprintf(buf, len, "probe description %u",
+ dnp->dn_desc->dtpd_id);
+ }
+ break;
+ case DT_NODE_CLAUSE:
+ (void) snprintf(buf, len, "%s", "clause");
+ break;
+ case DT_NODE_MEMBER:
+ (void) snprintf(buf, len, "member %s", dnp->dn_membname);
+ break;
+ case DT_NODE_XLATOR:
+ (void) snprintf(buf, len, "translator <%s> (%s)",
+ dt_type_name(dnp->dn_xlator->dx_dst_ctfp,
+ dnp->dn_xlator->dx_dst_type, n1, sizeof (n1)),
+ dt_type_name(dnp->dn_xlator->dx_src_ctfp,
+ dnp->dn_xlator->dx_src_type, n2, sizeof (n2)));
+ break;
+ case DT_NODE_PROG:
+ (void) snprintf(buf, len, "%s", "program");
+ break;
+ default:
+ (void) snprintf(buf, len, "node <%u>", dnp->dn_kind);
+ break;
+ }
+
+ return (buf);
+}
+
+/*
+ * dt_node_xalloc() can be used to create new parse nodes from any libdtrace
+ * caller. The caller is responsible for assigning dn_link appropriately.
+ */
+dt_node_t *
+dt_node_xalloc(dtrace_hdl_t *dtp, int kind)
+{
+ dt_node_t *dnp = dt_alloc(dtp, sizeof (dt_node_t));
+
+ if (dnp == NULL)
+ return (NULL);
+
+ dnp->dn_ctfp = NULL;
+ dnp->dn_type = CTF_ERR;
+ dnp->dn_kind = (uchar_t)kind;
+ dnp->dn_flags = 0;
+ dnp->dn_op = 0;
+ dnp->dn_line = -1;
+ dnp->dn_reg = -1;
+ dnp->dn_attr = _dtrace_defattr;
+ dnp->dn_list = NULL;
+ dnp->dn_link = NULL;
+ bzero(&dnp->dn_u, sizeof (dnp->dn_u));
+
+ return (dnp);
+}
+
+/*
+ * dt_node_alloc() is used to create new parse nodes from the parser. It
+ * assigns the node location based on the current lexer line number and places
+ * the new node on the default allocation list. If allocation fails, we
+ * automatically longjmp the caller back to the enclosing compilation call.
+ */
+static dt_node_t *
+dt_node_alloc(int kind)
+{
+ dt_node_t *dnp = dt_node_xalloc(yypcb->pcb_hdl, kind);
+
+ if (dnp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dnp->dn_line = yylineno;
+ dnp->dn_link = yypcb->pcb_list;
+ yypcb->pcb_list = dnp;
+
+ return (dnp);
+}
+
+void
+dt_node_free(dt_node_t *dnp)
+{
+ uchar_t kind = dnp->dn_kind;
+
+ dnp->dn_kind = DT_NODE_FREE;
+
+ switch (kind) {
+ case DT_NODE_STRING:
+ case DT_NODE_IDENT:
+ case DT_NODE_TYPE:
+ free(dnp->dn_string);
+ dnp->dn_string = NULL;
+ break;
+
+ case DT_NODE_VAR:
+ case DT_NODE_FUNC:
+ case DT_NODE_PROBE:
+ if (dnp->dn_ident != NULL) {
+ if (dnp->dn_ident->di_flags & DT_IDFLG_ORPHAN)
+ dt_ident_destroy(dnp->dn_ident);
+ dnp->dn_ident = NULL;
+ }
+ dt_node_list_free(&dnp->dn_args);
+ break;
+
+ case DT_NODE_OP1:
+ if (dnp->dn_child != NULL) {
+ dt_node_free(dnp->dn_child);
+ dnp->dn_child = NULL;
+ }
+ break;
+
+ case DT_NODE_OP3:
+ if (dnp->dn_expr != NULL) {
+ dt_node_free(dnp->dn_expr);
+ dnp->dn_expr = NULL;
+ }
+ RT_FALL_THRU();
+ case DT_NODE_OP2:
+ if (dnp->dn_left != NULL) {
+ dt_node_free(dnp->dn_left);
+ dnp->dn_left = NULL;
+ }
+ if (dnp->dn_right != NULL) {
+ dt_node_free(dnp->dn_right);
+ dnp->dn_right = NULL;
+ }
+ break;
+
+ case DT_NODE_DEXPR:
+ case DT_NODE_DFUNC:
+ if (dnp->dn_expr != NULL) {
+ dt_node_free(dnp->dn_expr);
+ dnp->dn_expr = NULL;
+ }
+ break;
+
+ case DT_NODE_AGG:
+ if (dnp->dn_aggfun != NULL) {
+ dt_node_free(dnp->dn_aggfun);
+ dnp->dn_aggfun = NULL;
+ }
+ dt_node_list_free(&dnp->dn_aggtup);
+ break;
+
+ case DT_NODE_PDESC:
+ free(dnp->dn_spec);
+ dnp->dn_spec = NULL;
+ free(dnp->dn_desc);
+ dnp->dn_desc = NULL;
+ break;
+
+ case DT_NODE_CLAUSE:
+ if (dnp->dn_pred != NULL)
+ dt_node_free(dnp->dn_pred);
+ if (dnp->dn_locals != NULL)
+ dt_idhash_destroy(dnp->dn_locals);
+ dt_node_list_free(&dnp->dn_pdescs);
+ dt_node_list_free(&dnp->dn_acts);
+ break;
+
+ case DT_NODE_MEMBER:
+ free(dnp->dn_membname);
+ dnp->dn_membname = NULL;
+ if (dnp->dn_membexpr != NULL) {
+ dt_node_free(dnp->dn_membexpr);
+ dnp->dn_membexpr = NULL;
+ }
+ break;
+
+ case DT_NODE_PROVIDER:
+ dt_node_list_free(&dnp->dn_probes);
+ free(dnp->dn_provname);
+ dnp->dn_provname = NULL;
+ break;
+
+ case DT_NODE_PROG:
+ dt_node_list_free(&dnp->dn_list);
+ break;
+ }
+}
+
+void
+dt_node_attr_assign(dt_node_t *dnp, dtrace_attribute_t attr)
+{
+ if ((yypcb->pcb_cflags & DTRACE_C_EATTR) &&
+ (dt_attr_cmp(attr, yypcb->pcb_amin) < 0)) {
+ char a[DTRACE_ATTR2STR_MAX];
+ char s[BUFSIZ];
+
+ dnerror(dnp, D_ATTR_MIN, "attributes for %s (%s) are less than "
+ "predefined minimum\n", dt_node_name(dnp, s, sizeof (s)),
+ dtrace_attr2str(attr, a, sizeof (a)));
+ }
+
+ dnp->dn_attr = attr;
+}
+
+void
+dt_node_type_assign(dt_node_t *dnp, ctf_file_t *fp, ctf_id_t type)
+{
+ ctf_id_t base = ctf_type_resolve(fp, type);
+ uint_t kind = ctf_type_kind(fp, base);
+ ctf_encoding_t e;
+
+ dnp->dn_flags &=
+ ~(DT_NF_SIGNED | DT_NF_REF | DT_NF_BITFIELD | DT_NF_USERLAND);
+
+ if (kind == CTF_K_INTEGER && ctf_type_encoding(fp, base, &e) == 0) {
+ size_t size = e.cte_bits / NBBY;
+
+ if (size > 8 || (e.cte_bits % NBBY) != 0 || (size & (size - 1)))
+ dnp->dn_flags |= DT_NF_BITFIELD;
+
+ if (e.cte_format & CTF_INT_SIGNED)
+ dnp->dn_flags |= DT_NF_SIGNED;
+ }
+
+ if (kind == CTF_K_FLOAT && ctf_type_encoding(fp, base, &e) == 0) {
+ if (e.cte_bits / NBBY > sizeof (uint64_t))
+ dnp->dn_flags |= DT_NF_REF;
+ }
+
+ if (kind == CTF_K_STRUCT || kind == CTF_K_UNION ||
+ kind == CTF_K_FORWARD ||
+ kind == CTF_K_ARRAY || kind == CTF_K_FUNCTION)
+ dnp->dn_flags |= DT_NF_REF;
+ else if (yypcb != NULL && fp == DT_DYN_CTFP(yypcb->pcb_hdl) &&
+ type == DT_DYN_TYPE(yypcb->pcb_hdl))
+ dnp->dn_flags |= DT_NF_REF;
+
+ dnp->dn_flags |= DT_NF_COOKED;
+ dnp->dn_ctfp = fp;
+ dnp->dn_type = type;
+}
+
+void
+dt_node_type_propagate(const dt_node_t *src, dt_node_t *dst)
+{
+ assert(src->dn_flags & DT_NF_COOKED);
+ dst->dn_flags = src->dn_flags & ~DT_NF_LVALUE;
+ dst->dn_ctfp = src->dn_ctfp;
+ dst->dn_type = src->dn_type;
+}
+
+const char *
+dt_node_type_name(const dt_node_t *dnp, char *buf, size_t len)
+{
+ if (dt_node_is_dynamic(dnp) && dnp->dn_ident != NULL) {
+ (void) snprintf(buf, len, "%s",
+ dt_idkind_name(dt_ident_resolve(dnp->dn_ident)->di_kind));
+ return (buf);
+ }
+
+ if (dnp->dn_flags & DT_NF_USERLAND) {
+ size_t n = snprintf(buf, len, "userland ");
+ len = len > n ? len - n : 0;
+ (void) dt_type_name(dnp->dn_ctfp, dnp->dn_type, buf + n, len);
+ return (buf);
+ }
+
+ return (dt_type_name(dnp->dn_ctfp, dnp->dn_type, buf, len));
+}
+
+size_t
+dt_node_type_size(const dt_node_t *dnp)
+{
+ if (dnp->dn_kind == DT_NODE_STRING)
+ return (strlen(dnp->dn_string) + 1);
+
+ if (dt_node_is_dynamic(dnp) && dnp->dn_ident != NULL)
+ return (dt_ident_size(dnp->dn_ident));
+
+ return (ctf_type_size(dnp->dn_ctfp, dnp->dn_type));
+}
+
+/*
+ * Determine if the specified parse tree node references an identifier of the
+ * specified kind, and if so return a pointer to it; otherwise return NULL.
+ * This function resolves the identifier itself, following through any inlines.
+ */
+dt_ident_t *
+dt_node_resolve(const dt_node_t *dnp, uint_t idkind)
+{
+ dt_ident_t *idp;
+
+ switch (dnp->dn_kind) {
+ case DT_NODE_VAR:
+ case DT_NODE_SYM:
+ case DT_NODE_FUNC:
+ case DT_NODE_AGG:
+ case DT_NODE_INLINE:
+ case DT_NODE_PROBE:
+ idp = dt_ident_resolve(dnp->dn_ident);
+ return (idp->di_kind == idkind ? idp : NULL);
+ }
+
+ if (dt_node_is_dynamic(dnp)) {
+ idp = dt_ident_resolve(dnp->dn_ident);
+ return (idp->di_kind == idkind ? idp : NULL);
+ }
+
+ return (NULL);
+}
+
+size_t
+dt_node_sizeof(const dt_node_t *dnp)
+{
+ dtrace_syminfo_t *sip;
+ GElf_Sym sym;
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+
+ /*
+ * The size of the node as used for the sizeof() operator depends on
+ * the kind of the node. If the node is a SYM, the size is obtained
+ * from the symbol table; if it is not a SYM, the size is determined
+ * from the node's type. This is slightly different from C's sizeof()
+ * operator in that (for example) when applied to a function, sizeof()
+ * will evaluate to the length of the function rather than the size of
+ * the function type.
+ */
+ if (dnp->dn_kind != DT_NODE_SYM)
+ return (dt_node_type_size(dnp));
+
+ sip = dnp->dn_ident->di_data;
+
+ if (dtrace_lookup_by_name(dtp, sip->dts_object,
+ sip->dts_name, &sym, NULL) == -1)
+ return (0);
+
+ return (sym.st_size);
+}
+
+int
+dt_node_is_integer(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ ctf_encoding_t e;
+ ctf_id_t type;
+ uint_t kind;
+
+ assert(dnp->dn_flags & DT_NF_COOKED);
+
+ type = ctf_type_resolve(fp, dnp->dn_type);
+ kind = ctf_type_kind(fp, type);
+
+ if (kind == CTF_K_INTEGER &&
+ ctf_type_encoding(fp, type, &e) == 0 && IS_VOID(e))
+ return (0); /* void integer */
+
+ return (kind == CTF_K_INTEGER || kind == CTF_K_ENUM);
+}
+
+int
+dt_node_is_float(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ ctf_encoding_t e;
+ ctf_id_t type;
+ uint_t kind;
+
+ assert(dnp->dn_flags & DT_NF_COOKED);
+
+ type = ctf_type_resolve(fp, dnp->dn_type);
+ kind = ctf_type_kind(fp, type);
+
+ return (kind == CTF_K_FLOAT &&
+ ctf_type_encoding(dnp->dn_ctfp, type, &e) == 0 && (
+ e.cte_format == CTF_FP_SINGLE || e.cte_format == CTF_FP_DOUBLE ||
+ e.cte_format == CTF_FP_LDOUBLE));
+}
+
+int
+dt_node_is_scalar(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ ctf_encoding_t e;
+ ctf_id_t type;
+ uint_t kind;
+
+ assert(dnp->dn_flags & DT_NF_COOKED);
+
+ type = ctf_type_resolve(fp, dnp->dn_type);
+ kind = ctf_type_kind(fp, type);
+
+ if (kind == CTF_K_INTEGER &&
+ ctf_type_encoding(fp, type, &e) == 0 && IS_VOID(e))
+ return (0); /* void cannot be used as a scalar */
+
+ return (kind == CTF_K_INTEGER || kind == CTF_K_ENUM ||
+ kind == CTF_K_POINTER);
+}
+
+int
+dt_node_is_arith(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ ctf_encoding_t e;
+ ctf_id_t type;
+ uint_t kind;
+
+ assert(dnp->dn_flags & DT_NF_COOKED);
+
+ type = ctf_type_resolve(fp, dnp->dn_type);
+ kind = ctf_type_kind(fp, type);
+
+ if (kind == CTF_K_INTEGER)
+ return (ctf_type_encoding(fp, type, &e) == 0 && !IS_VOID(e));
+ else
+ return (kind == CTF_K_ENUM);
+}
+
+int
+dt_node_is_vfptr(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ ctf_encoding_t e;
+ ctf_id_t type;
+ uint_t kind;
+
+ assert(dnp->dn_flags & DT_NF_COOKED);
+
+ type = ctf_type_resolve(fp, dnp->dn_type);
+ if (ctf_type_kind(fp, type) != CTF_K_POINTER)
+ return (0); /* type is not a pointer */
+
+ type = ctf_type_resolve(fp, ctf_type_reference(fp, type));
+ kind = ctf_type_kind(fp, type);
+
+ return (kind == CTF_K_FUNCTION || (kind == CTF_K_INTEGER &&
+ ctf_type_encoding(fp, type, &e) == 0 && IS_VOID(e)));
+}
+
+int
+dt_node_is_dynamic(const dt_node_t *dnp)
+{
+ if (dnp->dn_kind == DT_NODE_VAR &&
+ (dnp->dn_ident->di_flags & DT_IDFLG_INLINE)) {
+ const dt_idnode_t *inp = dnp->dn_ident->di_iarg;
+ return (inp->din_root ? dt_node_is_dynamic(inp->din_root) : 0);
+ }
+
+ return (dnp->dn_ctfp == DT_DYN_CTFP(yypcb->pcb_hdl) &&
+ dnp->dn_type == DT_DYN_TYPE(yypcb->pcb_hdl));
+}
+
+int
+dt_node_is_string(const dt_node_t *dnp)
+{
+ return (dnp->dn_ctfp == DT_STR_CTFP(yypcb->pcb_hdl) &&
+ dnp->dn_type == DT_STR_TYPE(yypcb->pcb_hdl));
+}
+
+int
+dt_node_is_stack(const dt_node_t *dnp)
+{
+ return (dnp->dn_ctfp == DT_STACK_CTFP(yypcb->pcb_hdl) &&
+ dnp->dn_type == DT_STACK_TYPE(yypcb->pcb_hdl));
+}
+
+int
+dt_node_is_symaddr(const dt_node_t *dnp)
+{
+ return (dnp->dn_ctfp == DT_SYMADDR_CTFP(yypcb->pcb_hdl) &&
+ dnp->dn_type == DT_SYMADDR_TYPE(yypcb->pcb_hdl));
+}
+
+int
+dt_node_is_usymaddr(const dt_node_t *dnp)
+{
+ return (dnp->dn_ctfp == DT_USYMADDR_CTFP(yypcb->pcb_hdl) &&
+ dnp->dn_type == DT_USYMADDR_TYPE(yypcb->pcb_hdl));
+}
+
+int
+dt_node_is_strcompat(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ ctf_encoding_t e;
+ ctf_arinfo_t r;
+ ctf_id_t base;
+ uint_t kind;
+
+ assert(dnp->dn_flags & DT_NF_COOKED);
+
+ base = ctf_type_resolve(fp, dnp->dn_type);
+ kind = ctf_type_kind(fp, base);
+
+ if (kind == CTF_K_POINTER &&
+ (base = ctf_type_reference(fp, base)) != CTF_ERR &&
+ (base = ctf_type_resolve(fp, base)) != CTF_ERR &&
+ ctf_type_encoding(fp, base, &e) == 0 && IS_CHAR(e))
+ return (1); /* promote char pointer to string */
+
+ if (kind == CTF_K_ARRAY && ctf_array_info(fp, base, &r) == 0 &&
+ (base = ctf_type_resolve(fp, r.ctr_contents)) != CTF_ERR &&
+ ctf_type_encoding(fp, base, &e) == 0 && IS_CHAR(e))
+ return (1); /* promote char array to string */
+
+ return (0);
+}
+
+int
+dt_node_is_pointer(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ uint_t kind;
+
+ assert(dnp->dn_flags & DT_NF_COOKED);
+
+ if (dt_node_is_string(dnp))
+ return (0); /* string are pass-by-ref but act like structs */
+
+ kind = ctf_type_kind(fp, ctf_type_resolve(fp, dnp->dn_type));
+ return (kind == CTF_K_POINTER || kind == CTF_K_ARRAY);
+}
+
+int
+dt_node_is_void(const dt_node_t *dnp)
+{
+ ctf_file_t *fp = dnp->dn_ctfp;
+ ctf_encoding_t e;
+ ctf_id_t type;
+
+ if (dt_node_is_dynamic(dnp))
+ return (0); /* <DYN> is an alias for void but not the same */
+
+ if (dt_node_is_stack(dnp))
+ return (0);
+
+ if (dt_node_is_symaddr(dnp) || dt_node_is_usymaddr(dnp))
+ return (0);
+
+ type = ctf_type_resolve(fp, dnp->dn_type);
+
+ return (ctf_type_kind(fp, type) == CTF_K_INTEGER &&
+ ctf_type_encoding(fp, type, &e) == 0 && IS_VOID(e));
+}
+
+int
+dt_node_is_ptrcompat(const dt_node_t *lp, const dt_node_t *rp,
+ ctf_file_t **fpp, ctf_id_t *tp)
+{
+ ctf_file_t *lfp = lp->dn_ctfp;
+ ctf_file_t *rfp = rp->dn_ctfp;
+
+ ctf_id_t lbase = CTF_ERR, rbase = CTF_ERR;
+ ctf_id_t lref = CTF_ERR, rref = CTF_ERR;
+
+ int lp_is_void, rp_is_void, lp_is_int, rp_is_int, compat;
+ uint_t lkind VBDTMSC(0), rkind VBDTMSC(0);
+ ctf_encoding_t e;
+ ctf_arinfo_t r;
+
+ assert(lp->dn_flags & DT_NF_COOKED);
+ assert(rp->dn_flags & DT_NF_COOKED);
+
+ if (dt_node_is_dynamic(lp) || dt_node_is_dynamic(rp))
+ return (0); /* fail if either node is a dynamic variable */
+
+ lp_is_int = dt_node_is_integer(lp);
+ rp_is_int = dt_node_is_integer(rp);
+
+ if (lp_is_int && rp_is_int)
+ return (0); /* fail if both nodes are integers */
+
+ if (lp_is_int && (lp->dn_kind != DT_NODE_INT || lp->dn_value != 0))
+ return (0); /* fail if lp is an integer that isn't 0 constant */
+
+ if (rp_is_int && (rp->dn_kind != DT_NODE_INT || rp->dn_value != 0))
+ return (0); /* fail if rp is an integer that isn't 0 constant */
+
+ if ((lp_is_int == 0 && rp_is_int == 0) && (
+ (lp->dn_flags & DT_NF_USERLAND) ^ (rp->dn_flags & DT_NF_USERLAND)))
+ return (0); /* fail if only one pointer is a userland address */
+
+ /*
+ * Resolve the left-hand and right-hand types to their base type, and
+ * then resolve the referenced type as well (assuming the base type
+ * is CTF_K_POINTER or CTF_K_ARRAY). Otherwise [lr]ref = CTF_ERR.
+ */
+ if (!lp_is_int) {
+ lbase = ctf_type_resolve(lfp, lp->dn_type);
+ lkind = ctf_type_kind(lfp, lbase);
+
+ if (lkind == CTF_K_POINTER) {
+ lref = ctf_type_resolve(lfp,
+ ctf_type_reference(lfp, lbase));
+ } else if (lkind == CTF_K_ARRAY &&
+ ctf_array_info(lfp, lbase, &r) == 0) {
+ lref = ctf_type_resolve(lfp, r.ctr_contents);
+ }
+ }
+
+ if (!rp_is_int) {
+ rbase = ctf_type_resolve(rfp, rp->dn_type);
+ rkind = ctf_type_kind(rfp, rbase);
+
+ if (rkind == CTF_K_POINTER) {
+ rref = ctf_type_resolve(rfp,
+ ctf_type_reference(rfp, rbase));
+ } else if (rkind == CTF_K_ARRAY &&
+ ctf_array_info(rfp, rbase, &r) == 0) {
+ rref = ctf_type_resolve(rfp, r.ctr_contents);
+ }
+ }
+
+ /*
+ * We know that one or the other type may still be a zero-valued
+ * integer constant. To simplify the code below, set the integer
+ * type variables equal to the non-integer types and proceed.
+ */
+ if (lp_is_int) {
+ lbase = rbase;
+ lkind = rkind;
+ lref = rref;
+ lfp = rfp;
+ } else if (rp_is_int) {
+ rbase = lbase;
+ rkind = lkind;
+ rref = lref;
+ rfp = lfp;
+ }
+
+ lp_is_void = ctf_type_encoding(lfp, lref, &e) == 0 && IS_VOID(e);
+ rp_is_void = ctf_type_encoding(rfp, rref, &e) == 0 && IS_VOID(e);
+
+ /*
+ * The types are compatible if both are pointers to the same type, or
+ * if either pointer is a void pointer. If they are compatible, set
+ * tp to point to the more specific pointer type and return it.
+ */
+ compat = (lkind == CTF_K_POINTER || lkind == CTF_K_ARRAY) &&
+ (rkind == CTF_K_POINTER || rkind == CTF_K_ARRAY) &&
+ (lp_is_void || rp_is_void || ctf_type_compat(lfp, lref, rfp, rref));
+
+ if (compat) {
+ if (fpp != NULL)
+ *fpp = rp_is_void ? lfp : rfp;
+ if (tp != NULL)
+ *tp = rp_is_void ? lbase : rbase;
+ }
+
+ return (compat);
+}
+
+/*
+ * The rules for checking argument types against parameter types are described
+ * in the ANSI-C spec (see K&R[A7.3.2] and K&R[A7.17]). We use the same rule
+ * set to determine whether associative array arguments match the prototype.
+ */
+int
+dt_node_is_argcompat(const dt_node_t *lp, const dt_node_t *rp)
+{
+ ctf_file_t *lfp = lp->dn_ctfp;
+ ctf_file_t *rfp = rp->dn_ctfp;
+
+ assert(lp->dn_flags & DT_NF_COOKED);
+ assert(rp->dn_flags & DT_NF_COOKED);
+
+ if (dt_node_is_integer(lp) && dt_node_is_integer(rp))
+ return (1); /* integer types are compatible */
+
+ if (dt_node_is_strcompat(lp) && dt_node_is_strcompat(rp))
+ return (1); /* string types are compatible */
+
+ if (dt_node_is_stack(lp) && dt_node_is_stack(rp))
+ return (1); /* stack types are compatible */
+
+ if (dt_node_is_symaddr(lp) && dt_node_is_symaddr(rp))
+ return (1); /* symaddr types are compatible */
+
+ if (dt_node_is_usymaddr(lp) && dt_node_is_usymaddr(rp))
+ return (1); /* usymaddr types are compatible */
+
+ switch (ctf_type_kind(lfp, ctf_type_resolve(lfp, lp->dn_type))) {
+ case CTF_K_FUNCTION:
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ return (ctf_type_compat(lfp, lp->dn_type, rfp, rp->dn_type));
+ default:
+ return (dt_node_is_ptrcompat(lp, rp, NULL, NULL));
+ }
+}
+
+/*
+ * We provide dt_node_is_posconst() as a convenience routine for callers who
+ * wish to verify that an argument is a positive non-zero integer constant.
+ */
+int
+dt_node_is_posconst(const dt_node_t *dnp)
+{
+ return (dnp->dn_kind == DT_NODE_INT && dnp->dn_value != 0 && (
+ (dnp->dn_flags & DT_NF_SIGNED) == 0 || (int64_t)dnp->dn_value > 0));
+}
+
+int
+dt_node_is_actfunc(const dt_node_t *dnp)
+{
+ return (dnp->dn_kind == DT_NODE_FUNC &&
+ dnp->dn_ident->di_kind == DT_IDENT_ACTFUNC);
+}
+
+/*
+ * The original rules for integer constant typing are described in K&R[A2.5.1].
+ * However, since we support long long, we instead use the rules from ISO C99
+ * clause 6.4.4.1 since that is where long longs are formally described. The
+ * rules require us to know whether the constant was specified in decimal or
+ * in octal or hex, which we do by looking at our lexer's 'yyintdecimal' flag.
+ * The type of an integer constant is the first of the corresponding list in
+ * which its value can be represented:
+ *
+ * unsuffixed decimal: int, long, long long
+ * unsuffixed oct/hex: int, unsigned int, long, unsigned long,
+ * long long, unsigned long long
+ * suffix [uU]: unsigned int, unsigned long, unsigned long long
+ * suffix [lL] decimal: long, long long
+ * suffix [lL] oct/hex: long, unsigned long, long long, unsigned long long
+ * suffix [uU][Ll]: unsigned long, unsigned long long
+ * suffix ll/LL decimal: long long
+ * suffix ll/LL oct/hex: long long, unsigned long long
+ * suffix [uU][ll/LL]: unsigned long long
+ *
+ * Given that our lexer has already validated the suffixes by regexp matching,
+ * there is an obvious way to concisely encode these rules: construct an array
+ * of the types in the order int, unsigned int, long, unsigned long, long long,
+ * unsigned long long. Compute an integer array starting index based on the
+ * suffix (e.g. none = 0, u = 1, ull = 5), and compute an increment based on
+ * the specifier (dec/oct/hex) and suffix (u). Then iterate from the starting
+ * index to the end, advancing using the increment, and searching until we
+ * find a limit that matches or we run out of choices (overflow). To make it
+ * even faster, we precompute the table of type information in dtrace_open().
+ */
+dt_node_t *
+dt_node_int(uintmax_t value)
+{
+ dt_node_t *dnp = dt_node_alloc(DT_NODE_INT);
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+
+ int n = (yyintdecimal | (yyintsuffix[0] == 'u')) + 1;
+ int i = 0;
+
+ const char *p;
+ char c;
+
+ dnp->dn_op = DT_TOK_INT;
+ dnp->dn_value = value;
+
+ for (p = yyintsuffix; (c = *p) != '\0'; p++) {
+ if (c == 'U' || c == 'u')
+ i += 1;
+ else if (c == 'L' || c == 'l')
+ i += 2;
+ }
+
+ for (; i < sizeof (dtp->dt_ints) / sizeof (dtp->dt_ints[0]); i += n) {
+ if (value <= dtp->dt_ints[i].did_limit) {
+ dt_node_type_assign(dnp,
+ dtp->dt_ints[i].did_ctfp,
+ dtp->dt_ints[i].did_type);
+
+ /*
+ * If a prefix character is present in macro text, add
+ * in the corresponding operator node (see dt_lex.l).
+ */
+ switch (yyintprefix) {
+ case '+':
+ return (dt_node_op1(DT_TOK_IPOS, dnp));
+ case '-':
+ return (dt_node_op1(DT_TOK_INEG, dnp));
+ default:
+ return (dnp);
+ }
+ }
+ }
+
+ xyerror(D_INT_OFLOW, "integer constant 0x%llx cannot be represented "
+ "in any built-in integral type\n", (u_longlong_t)value);
+ /*NOTREACHED*/
+#ifndef _MSC_VER
+ return (NULL); /* keep gcc happy */
+#endif
+}
+
+dt_node_t *
+dt_node_string(char *string)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *dnp;
+
+ if (string == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dnp = dt_node_alloc(DT_NODE_STRING);
+ dnp->dn_op = DT_TOK_STRING;
+ dnp->dn_string = string;
+ dt_node_type_assign(dnp, DT_STR_CTFP(dtp), DT_STR_TYPE(dtp));
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_ident(char *name)
+{
+ dt_ident_t *idp;
+ dt_node_t *dnp;
+
+ if (name == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * If the identifier is an inlined integer constant, then create an INT
+ * node that is a clone of the inline parse tree node and return that
+ * immediately, allowing this inline to be used in parsing contexts
+ * that require constant expressions (e.g. scalar array sizes).
+ */
+ if ((idp = dt_idstack_lookup(&yypcb->pcb_globals, name)) != NULL &&
+ (idp->di_flags & DT_IDFLG_INLINE)) {
+ dt_idnode_t *inp = idp->di_iarg;
+
+ if (inp->din_root != NULL &&
+ inp->din_root->dn_kind == DT_NODE_INT) {
+ free(name);
+
+ dnp = dt_node_alloc(DT_NODE_INT);
+ dnp->dn_op = DT_TOK_INT;
+ dnp->dn_value = inp->din_root->dn_value;
+ dt_node_type_propagate(inp->din_root, dnp);
+
+ return (dnp);
+ }
+ }
+
+ dnp = dt_node_alloc(DT_NODE_IDENT);
+ dnp->dn_op = name[0] == '@' ? DT_TOK_AGG : DT_TOK_IDENT;
+ dnp->dn_string = name;
+
+ return (dnp);
+}
+
+/*
+ * Create an empty node of type corresponding to the given declaration.
+ * Explicit references to user types (C or D) are assigned the default
+ * stability; references to other types are _dtrace_typattr (Private).
+ */
+dt_node_t *
+dt_node_type(dt_decl_t *ddp)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dtrace_typeinfo_t dtt;
+ dt_node_t *dnp;
+ char *name = NULL;
+ int err;
+
+ /*
+ * If 'ddp' is NULL, we get a decl by popping the decl stack. This
+ * form of dt_node_type() is used by parameter rules in dt_grammar.y.
+ */
+ if (ddp == NULL)
+ ddp = dt_decl_pop_param(&name);
+
+ err = dt_decl_type(ddp, &dtt);
+ dt_decl_free(ddp);
+
+ if (err != 0) {
+ free(name);
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+ }
+
+ dnp = dt_node_alloc(DT_NODE_TYPE);
+ dnp->dn_op = DT_TOK_IDENT;
+ dnp->dn_string = name;
+ dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
+
+ if (dtt.dtt_ctfp == dtp->dt_cdefs->dm_ctfp ||
+ dtt.dtt_ctfp == dtp->dt_ddefs->dm_ctfp)
+ dt_node_attr_assign(dnp, _dtrace_defattr);
+ else
+ dt_node_attr_assign(dnp, _dtrace_typattr);
+
+ return (dnp);
+}
+
+/*
+ * Create a type node corresponding to a varargs (...) parameter by just
+ * assigning it type CTF_ERR. The decl processing code will handle this.
+ */
+dt_node_t *
+dt_node_vatype(void)
+{
+ dt_node_t *dnp = dt_node_alloc(DT_NODE_TYPE);
+
+ dnp->dn_op = DT_TOK_IDENT;
+ dnp->dn_ctfp = yypcb->pcb_hdl->dt_cdefs->dm_ctfp;
+ dnp->dn_type = CTF_ERR;
+ dnp->dn_attr = _dtrace_defattr;
+
+ return (dnp);
+}
+
+/*
+ * Instantiate a decl using the contents of the current declaration stack. As
+ * we do not currently permit decls to be initialized, this function currently
+ * returns NULL and no parse node is created. When this function is called,
+ * the topmost scope's ds_ident pointer will be set to NULL (indicating no
+ * init_declarator rule was matched) or will point to the identifier to use.
+ */
+dt_node_t *
+dt_node_decl(void)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+ dt_dclass_t class = dsp->ds_class;
+ dt_decl_t *ddp = dt_decl_top();
+
+ dt_module_t *dmp;
+ dtrace_typeinfo_t dtt;
+ ctf_id_t type;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ if (dt_decl_type(ddp, &dtt) != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+
+ /*
+ * If we have no declaration identifier, then this is either a spurious
+ * declaration of an intrinsic type (e.g. "extern int;") or declaration
+ * or redeclaration of a struct, union, or enum type or tag.
+ */
+ if (dsp->ds_ident == NULL) {
+ if (ddp->dd_kind != CTF_K_STRUCT &&
+ ddp->dd_kind != CTF_K_UNION && ddp->dd_kind != CTF_K_ENUM)
+ xyerror(D_DECL_USELESS, "useless declaration\n");
+
+ dt_dprintf("type %s added as id %ld\n", dt_type_name(
+ ddp->dd_ctfp, ddp->dd_type, n1, sizeof (n1)), ddp->dd_type);
+
+ return (NULL);
+ }
+
+ if (strchr(dsp->ds_ident, '`') != NULL) {
+ xyerror(D_DECL_SCOPE, "D scoping operator may not be used in "
+ "a declaration name (%s)\n", dsp->ds_ident);
+ }
+
+ /*
+ * If we are nested inside of a C include file, add the declaration to
+ * the C definition module; otherwise use the D definition module.
+ */
+ if (yypcb->pcb_idepth != 0)
+ dmp = dtp->dt_cdefs;
+ else
+ dmp = dtp->dt_ddefs;
+
+ /*
+ * If we see a global or static declaration of a function prototype,
+ * treat this as equivalent to a D extern declaration.
+ */
+ if (ctf_type_kind(dtt.dtt_ctfp, dtt.dtt_type) == CTF_K_FUNCTION &&
+ (class == DT_DC_DEFAULT || class == DT_DC_STATIC))
+ class = DT_DC_EXTERN;
+
+ switch (class) {
+ case DT_DC_AUTO:
+ case DT_DC_REGISTER:
+ case DT_DC_STATIC:
+ xyerror(D_DECL_BADCLASS, "specified storage class not "
+ "appropriate in D\n");
+ /*NOTREACHED*/
+
+ case DT_DC_EXTERN: {
+ dtrace_typeinfo_t ott;
+ dtrace_syminfo_t dts;
+ GElf_Sym sym;
+
+ int exists = dtrace_lookup_by_name(dtp,
+ dmp->dm_name, dsp->ds_ident, &sym, &dts) == 0;
+
+ if (exists && (dtrace_symbol_type(dtp, &sym, &dts, &ott) != 0 ||
+ ctf_type_cmp(dtt.dtt_ctfp, dtt.dtt_type,
+ ott.dtt_ctfp, ott.dtt_type) != 0)) {
+ xyerror(D_DECL_IDRED, "identifier redeclared: %s`%s\n"
+ "\t current: %s\n\tprevious: %s\n",
+ dmp->dm_name, dsp->ds_ident,
+ dt_type_name(dtt.dtt_ctfp, dtt.dtt_type,
+ n1, sizeof (n1)),
+ dt_type_name(ott.dtt_ctfp, ott.dtt_type,
+ n2, sizeof (n2)));
+ } else if (!exists && dt_module_extern(dtp, dmp,
+ dsp->ds_ident, &dtt) == NULL) {
+ xyerror(D_UNKNOWN,
+ "failed to extern %s: %s\n", dsp->ds_ident,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ } else {
+ dt_dprintf("extern %s`%s type=<%s>\n",
+ dmp->dm_name, dsp->ds_ident,
+ dt_type_name(dtt.dtt_ctfp, dtt.dtt_type,
+ n1, sizeof (n1)));
+ }
+ break;
+ }
+
+ case DT_DC_TYPEDEF:
+ if (dt_idstack_lookup(&yypcb->pcb_globals, dsp->ds_ident)) {
+ xyerror(D_DECL_IDRED, "global variable identifier "
+ "redeclared: %s\n", dsp->ds_ident);
+ }
+
+ if (ctf_lookup_by_name(dmp->dm_ctfp,
+ dsp->ds_ident) != CTF_ERR) {
+ xyerror(D_DECL_IDRED,
+ "typedef redeclared: %s\n", dsp->ds_ident);
+ }
+
+ /*
+ * If the source type for the typedef is not defined in the
+ * target container or its parent, copy the type to the target
+ * container and reset dtt_ctfp and dtt_type to the copy.
+ */
+ if (dtt.dtt_ctfp != dmp->dm_ctfp &&
+ dtt.dtt_ctfp != ctf_parent_file(dmp->dm_ctfp)) {
+
+ dtt.dtt_type = ctf_add_type(dmp->dm_ctfp,
+ dtt.dtt_ctfp, dtt.dtt_type);
+ dtt.dtt_ctfp = dmp->dm_ctfp;
+
+ if (dtt.dtt_type == CTF_ERR ||
+ ctf_update(dtt.dtt_ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to copy typedef %s "
+ "source type: %s\n", dsp->ds_ident,
+ ctf_errmsg(ctf_errno(dtt.dtt_ctfp)));
+ }
+ }
+
+ type = ctf_add_typedef(dmp->dm_ctfp,
+ CTF_ADD_ROOT, dsp->ds_ident, dtt.dtt_type);
+
+ if (type == CTF_ERR || ctf_update(dmp->dm_ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to typedef %s: %s\n",
+ dsp->ds_ident, ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
+ }
+
+ dt_dprintf("typedef %s added as id %ld\n", dsp->ds_ident, type);
+ break;
+
+ default: {
+ ctf_encoding_t cte;
+ dt_idhash_t *dhp;
+ dt_ident_t *idp;
+ dt_node_t idn;
+ int assc, idkind;
+ uint_t id, kind;
+ ushort_t idflags;
+
+ switch (class) {
+ case DT_DC_THIS:
+ dhp = yypcb->pcb_locals;
+ idflags = DT_IDFLG_LOCAL;
+ idp = dt_idhash_lookup(dhp, dsp->ds_ident);
+ break;
+ case DT_DC_SELF:
+ dhp = dtp->dt_tls;
+ idflags = DT_IDFLG_TLS;
+ idp = dt_idhash_lookup(dhp, dsp->ds_ident);
+ break;
+ default:
+ dhp = dtp->dt_globals;
+ idflags = 0;
+ idp = dt_idstack_lookup(
+ &yypcb->pcb_globals, dsp->ds_ident);
+ break;
+ }
+
+ if (ddp->dd_kind == CTF_K_ARRAY && ddp->dd_node == NULL) {
+ xyerror(D_DECL_ARRNULL,
+ "array declaration requires array dimension or "
+ "tuple signature: %s\n", dsp->ds_ident);
+ }
+
+ if (idp != NULL && idp->di_gen == 0) {
+ xyerror(D_DECL_IDRED, "built-in identifier "
+ "redeclared: %s\n", idp->di_name);
+ }
+
+ if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_CDEFS,
+ dsp->ds_ident, NULL) == 0 ||
+ dtrace_lookup_by_type(dtp, DTRACE_OBJ_DDEFS,
+ dsp->ds_ident, NULL) == 0) {
+ xyerror(D_DECL_IDRED, "typedef identifier "
+ "redeclared: %s\n", dsp->ds_ident);
+ }
+
+ /*
+ * Cache some attributes of the decl to make the rest of this
+ * code simpler: if the decl is an array which is subscripted
+ * by a type rather than an integer, then it's an associative
+ * array (assc). We then expect to match either DT_IDENT_ARRAY
+ * for associative arrays or DT_IDENT_SCALAR for anything else.
+ */
+ assc = ddp->dd_kind == CTF_K_ARRAY &&
+ ddp->dd_node->dn_kind == DT_NODE_TYPE;
+
+ idkind = assc ? DT_IDENT_ARRAY : DT_IDENT_SCALAR;
+
+ /*
+ * Create a fake dt_node_t on the stack so we can determine the
+ * type of any matching identifier by assigning to this node.
+ * If the pre-existing ident has its di_type set, propagate
+ * the type by hand so as not to trigger a prototype check for
+ * arrays (yet); otherwise we use dt_ident_cook() on the ident
+ * to ensure it is fully initialized before looking at it.
+ */
+ bzero(&idn, sizeof (dt_node_t));
+
+ if (idp != NULL && idp->di_type != CTF_ERR)
+ dt_node_type_assign(&idn, idp->di_ctfp, idp->di_type);
+ else if (idp != NULL)
+ (void) dt_ident_cook(&idn, idp, NULL);
+
+ if (assc) {
+ if (class == DT_DC_THIS) {
+ xyerror(D_DECL_LOCASSC, "associative arrays "
+ "may not be declared as local variables:"
+ " %s\n", dsp->ds_ident);
+ }
+
+ if (dt_decl_type(ddp->dd_next, &dtt) != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+ }
+
+ if (idp != NULL && (idp->di_kind != idkind ||
+ ctf_type_cmp(dtt.dtt_ctfp, dtt.dtt_type,
+ idn.dn_ctfp, idn.dn_type) != 0)) {
+ xyerror(D_DECL_IDRED, "identifier redeclared: %s\n"
+ "\t current: %s %s\n\tprevious: %s %s\n",
+ dsp->ds_ident, dt_idkind_name(idkind),
+ dt_type_name(dtt.dtt_ctfp,
+ dtt.dtt_type, n1, sizeof (n1)),
+ dt_idkind_name(idp->di_kind),
+ dt_node_type_name(&idn, n2, sizeof (n2)));
+
+ } else if (idp != NULL && assc) {
+ const dt_idsig_t *isp = idp->di_data;
+ dt_node_t *dnp = ddp->dd_node;
+ int argc = 0;
+
+ for (; dnp != NULL; dnp = dnp->dn_list, argc++) {
+ const dt_node_t *pnp = &isp->dis_args[argc];
+
+ if (argc >= isp->dis_argc)
+ continue; /* tuple length mismatch */
+
+ if (ctf_type_cmp(dnp->dn_ctfp, dnp->dn_type,
+ pnp->dn_ctfp, pnp->dn_type) == 0)
+ continue;
+
+ xyerror(D_DECL_IDRED,
+ "identifier redeclared: %s\n"
+ "\t current: %s, key #%d of type %s\n"
+ "\tprevious: %s, key #%d of type %s\n",
+ dsp->ds_ident,
+ dt_idkind_name(idkind), argc + 1,
+ dt_node_type_name(dnp, n1, sizeof (n1)),
+ dt_idkind_name(idp->di_kind), argc + 1,
+ dt_node_type_name(pnp, n2, sizeof (n2)));
+ }
+
+ if (isp->dis_argc != argc) {
+ xyerror(D_DECL_IDRED,
+ "identifier redeclared: %s\n"
+ "\t current: %s of %s, tuple length %d\n"
+ "\tprevious: %s of %s, tuple length %d\n",
+ dsp->ds_ident, dt_idkind_name(idkind),
+ dt_type_name(dtt.dtt_ctfp, dtt.dtt_type,
+ n1, sizeof (n1)), argc,
+ dt_idkind_name(idp->di_kind),
+ dt_node_type_name(&idn, n2, sizeof (n2)),
+ isp->dis_argc);
+ }
+
+ } else if (idp == NULL) {
+ type = ctf_type_resolve(dtt.dtt_ctfp, dtt.dtt_type);
+ kind = ctf_type_kind(dtt.dtt_ctfp, type);
+
+ switch (kind) {
+ case CTF_K_INTEGER:
+ if (ctf_type_encoding(dtt.dtt_ctfp, type,
+ &cte) == 0 && IS_VOID(cte)) {
+ xyerror(D_DECL_VOIDOBJ, "cannot have "
+ "void object: %s\n", dsp->ds_ident);
+ }
+ break;
+ case CTF_K_STRUCT:
+ case CTF_K_UNION:
+ if (ctf_type_size(dtt.dtt_ctfp, type) != 0)
+ break; /* proceed to declaring */
+ RT_FALL_THRU();
+ case CTF_K_FORWARD:
+ xyerror(D_DECL_INCOMPLETE,
+ "incomplete struct/union/enum %s: %s\n",
+ dt_type_name(dtt.dtt_ctfp, dtt.dtt_type,
+ n1, sizeof (n1)), dsp->ds_ident);
+ /*NOTREACHED*/
+ }
+
+ if (dt_idhash_nextid(dhp, &id) == -1) {
+ xyerror(D_ID_OFLOW, "cannot create %s: limit "
+ "on number of %s variables exceeded\n",
+ dsp->ds_ident, dt_idhash_name(dhp));
+ }
+
+ dt_dprintf("declare %s %s variable %s, id=%u\n",
+ dt_idhash_name(dhp), dt_idkind_name(idkind),
+ dsp->ds_ident, id);
+
+ idp = dt_idhash_insert(dhp, dsp->ds_ident, idkind,
+ idflags | DT_IDFLG_WRITE | DT_IDFLG_DECL, id,
+ _dtrace_defattr, 0, assc ? &dt_idops_assc :
+ &dt_idops_thaw, NULL, dtp->dt_gen);
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dt_ident_type_assign(idp, dtt.dtt_ctfp, dtt.dtt_type);
+
+ /*
+ * If we are declaring an associative array, use our
+ * fake parse node to cook the new assoc identifier.
+ * This will force the ident code to instantiate the
+ * array type signature corresponding to the list of
+ * types pointed to by ddp->dd_node. We also reset
+ * the identifier's attributes based upon the result.
+ */
+ if (assc) {
+ idp->di_attr =
+ dt_ident_cook(&idn, idp, &ddp->dd_node);
+ }
+ }
+ }
+
+ } /* end of switch */
+
+ free(dsp->ds_ident);
+ dsp->ds_ident = NULL;
+
+ return (NULL);
+}
+
+dt_node_t *
+dt_node_func(dt_node_t *dnp, dt_node_t *args)
+{
+ dt_ident_t *idp;
+
+ if (dnp->dn_kind != DT_NODE_IDENT) {
+ xyerror(D_FUNC_IDENT,
+ "function designator is not of function type\n");
+ }
+
+ idp = dt_idstack_lookup(&yypcb->pcb_globals, dnp->dn_string);
+
+ if (idp == NULL) {
+ xyerror(D_FUNC_UNDEF,
+ "undefined function name: %s\n", dnp->dn_string);
+ }
+
+ if (idp->di_kind != DT_IDENT_FUNC &&
+ idp->di_kind != DT_IDENT_AGGFUNC &&
+ idp->di_kind != DT_IDENT_ACTFUNC) {
+ xyerror(D_FUNC_IDKIND, "%s '%s' may not be referenced as a "
+ "function\n", dt_idkind_name(idp->di_kind), idp->di_name);
+ }
+
+ free(dnp->dn_string);
+ dnp->dn_string = NULL;
+
+ dnp->dn_kind = DT_NODE_FUNC;
+ dnp->dn_flags &= ~DT_NF_COOKED;
+ dnp->dn_ident = idp;
+ dnp->dn_args = args;
+ dnp->dn_list = NULL;
+
+ return (dnp);
+}
+
+/*
+ * The offsetof() function is special because it takes a type name as an
+ * argument. It does not actually construct its own node; after looking up the
+ * structure or union offset, we just return an integer node with the offset.
+ */
+dt_node_t *
+dt_node_offsetof(dt_decl_t *ddp, char *s)
+{
+ dtrace_typeinfo_t dtt;
+ dt_node_t dn;
+ char *name;
+ int err;
+
+ ctf_membinfo_t ctm;
+ ctf_id_t type;
+ uint_t kind;
+
+#ifndef VBOX
+ name = strdupa(s);
+#else
+ MY_STRDUPA(name, s);
+#endif
+ free(s);
+
+ err = dt_decl_type(ddp, &dtt);
+ dt_decl_free(ddp);
+
+ if (err != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+
+ type = ctf_type_resolve(dtt.dtt_ctfp, dtt.dtt_type);
+ kind = ctf_type_kind(dtt.dtt_ctfp, type);
+
+ if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) {
+ xyerror(D_OFFSETOF_TYPE,
+ "offsetof operand must be a struct or union type\n");
+ }
+
+ if (ctf_member_info(dtt.dtt_ctfp, type, name, &ctm) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "failed to determine offset of %s: %s\n",
+ name, ctf_errmsg(ctf_errno(dtt.dtt_ctfp)));
+ }
+
+ bzero(&dn, sizeof (dn));
+ dt_node_type_assign(&dn, dtt.dtt_ctfp, ctm.ctm_type);
+
+ if (dn.dn_flags & DT_NF_BITFIELD) {
+ xyerror(D_OFFSETOF_BITFIELD,
+ "cannot take offset of a bit-field: %s\n", name);
+ }
+
+ return (dt_node_int(ctm.ctm_offset / NBBY));
+}
+
+dt_node_t *
+dt_node_op1(int op, dt_node_t *cp)
+{
+ dt_node_t *dnp;
+
+ if (cp->dn_kind == DT_NODE_INT) {
+ switch (op) {
+ case DT_TOK_INEG:
+ /*
+ * If we're negating an unsigned integer, zero out any
+ * extra top bits to truncate the value to the size of
+ * the effective type determined by dt_node_int().
+ */
+ cp->dn_value = -cp->dn_value;
+ if (!(cp->dn_flags & DT_NF_SIGNED)) {
+ cp->dn_value &= ~0ULL >>
+ (64 - dt_node_type_size(cp) * NBBY);
+ }
+ RT_FALL_THRU();
+ case DT_TOK_IPOS:
+ return (cp);
+ case DT_TOK_BNEG:
+ cp->dn_value = ~cp->dn_value;
+ return (cp);
+ case DT_TOK_LNEG:
+ cp->dn_value = !cp->dn_value;
+ return (cp);
+ }
+ }
+
+ /*
+ * If sizeof is applied to a type_name or string constant, we can
+ * transform 'cp' into an integer constant in the node construction
+ * pass so that it can then be used for arithmetic in this pass.
+ */
+ if (op == DT_TOK_SIZEOF &&
+ (cp->dn_kind == DT_NODE_STRING || cp->dn_kind == DT_NODE_TYPE)) {
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ size_t size = dt_node_type_size(cp);
+
+ if (size == 0) {
+ xyerror(D_SIZEOF_TYPE, "cannot apply sizeof to an "
+ "operand of unknown size\n");
+ }
+
+ dt_node_type_assign(cp, dtp->dt_ddefs->dm_ctfp,
+ ctf_lookup_by_name(dtp->dt_ddefs->dm_ctfp, "size_t"));
+
+ cp->dn_kind = DT_NODE_INT;
+ cp->dn_op = DT_TOK_INT;
+ cp->dn_value = size;
+
+ return (cp);
+ }
+
+ dnp = dt_node_alloc(DT_NODE_OP1);
+ assert(op <= USHRT_MAX);
+ dnp->dn_op = (ushort_t)op;
+ dnp->dn_child = cp;
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_op2(int op, dt_node_t *lp, dt_node_t *rp)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *dnp;
+
+ /*
+ * First we check for operations that are illegal -- namely those that
+ * might result in integer division by zero, and abort if one is found.
+ */
+ if (rp->dn_kind == DT_NODE_INT && rp->dn_value == 0 &&
+ (op == DT_TOK_MOD || op == DT_TOK_DIV ||
+ op == DT_TOK_MOD_EQ || op == DT_TOK_DIV_EQ))
+ xyerror(D_DIV_ZERO, "expression contains division by zero\n");
+
+ /*
+ * If both children are immediate values, we can just perform inline
+ * calculation and return a new immediate node with the result.
+ */
+ if (lp->dn_kind == DT_NODE_INT && rp->dn_kind == DT_NODE_INT) {
+ uintmax_t l = lp->dn_value;
+ uintmax_t r = rp->dn_value;
+
+ dnp = dt_node_int(0); /* allocate new integer node for result */
+
+ switch (op) {
+ case DT_TOK_LOR:
+ dnp->dn_value = l || r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_LXOR:
+ dnp->dn_value = (l != 0) ^ (r != 0);
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_LAND:
+ dnp->dn_value = l && r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_BOR:
+ dnp->dn_value = l | r;
+ dt_node_promote(lp, rp, dnp);
+ break;
+ case DT_TOK_XOR:
+ dnp->dn_value = l ^ r;
+ dt_node_promote(lp, rp, dnp);
+ break;
+ case DT_TOK_BAND:
+ dnp->dn_value = l & r;
+ dt_node_promote(lp, rp, dnp);
+ break;
+ case DT_TOK_EQU:
+ dnp->dn_value = l == r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_NEQ:
+ dnp->dn_value = l != r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_LT:
+ dt_node_promote(lp, rp, dnp);
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ dnp->dn_value = (intmax_t)l < (intmax_t)r;
+ else
+ dnp->dn_value = l < r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_LE:
+ dt_node_promote(lp, rp, dnp);
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ dnp->dn_value = (intmax_t)l <= (intmax_t)r;
+ else
+ dnp->dn_value = l <= r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_GT:
+ dt_node_promote(lp, rp, dnp);
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ dnp->dn_value = (intmax_t)l > (intmax_t)r;
+ else
+ dnp->dn_value = l > r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_GE:
+ dt_node_promote(lp, rp, dnp);
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ dnp->dn_value = (intmax_t)l >= (intmax_t)r;
+ else
+ dnp->dn_value = l >= r;
+ dt_node_type_assign(dnp,
+ DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+ case DT_TOK_LSH:
+ dnp->dn_value = l << r;
+ dt_node_type_propagate(lp, dnp);
+ dt_node_attr_assign(rp,
+ dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+ case DT_TOK_RSH:
+ dnp->dn_value = l >> r;
+ dt_node_type_propagate(lp, dnp);
+ dt_node_attr_assign(rp,
+ dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+ case DT_TOK_ADD:
+ dnp->dn_value = l + r;
+ dt_node_promote(lp, rp, dnp);
+ break;
+ case DT_TOK_SUB:
+ dnp->dn_value = l - r;
+ dt_node_promote(lp, rp, dnp);
+ break;
+ case DT_TOK_MUL:
+ dnp->dn_value = l * r;
+ dt_node_promote(lp, rp, dnp);
+ break;
+ case DT_TOK_DIV:
+ dt_node_promote(lp, rp, dnp);
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ dnp->dn_value = (intmax_t)l / (intmax_t)r;
+ else
+ dnp->dn_value = l / r;
+ break;
+ case DT_TOK_MOD:
+ dt_node_promote(lp, rp, dnp);
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ dnp->dn_value = (intmax_t)l % (intmax_t)r;
+ else
+ dnp->dn_value = l % r;
+ break;
+ default:
+ dt_node_free(dnp);
+ dnp = NULL;
+ }
+
+ if (dnp != NULL) {
+ dt_node_free(lp);
+ dt_node_free(rp);
+ return (dnp);
+ }
+ }
+
+ /*
+ * If an integer constant is being cast to another integer type, we can
+ * perform the cast as part of integer constant folding in this pass.
+ * We must take action when the integer is being cast to a smaller type
+ * or if it is changing signed-ness. If so, we first shift rp's bits
+ * bits high (losing excess bits if narrowing) and then shift them down
+ * with either a logical shift (unsigned) or arithmetic shift (signed).
+ */
+ if (op == DT_TOK_LPAR && rp->dn_kind == DT_NODE_INT &&
+ dt_node_is_integer(lp)) {
+ size_t srcsize = dt_node_type_size(rp);
+ size_t dstsize = dt_node_type_size(lp);
+
+ if ((dstsize < srcsize) || ((lp->dn_flags & DT_NF_SIGNED) ^
+ (rp->dn_flags & DT_NF_SIGNED))) {
+ int n = dstsize < srcsize ?
+ (sizeof (uint64_t) * NBBY - dstsize * NBBY) :
+ (sizeof (uint64_t) * NBBY - srcsize * NBBY);
+
+ rp->dn_value <<= n;
+ if (lp->dn_flags & DT_NF_SIGNED)
+ rp->dn_value = (intmax_t)rp->dn_value >> n;
+ else
+ rp->dn_value = rp->dn_value >> n;
+ }
+
+ dt_node_type_propagate(lp, rp);
+ dt_node_attr_assign(rp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ dt_node_free(lp);
+
+ return (rp);
+ }
+
+ /*
+ * If no immediate optimizations are available, create an new OP2 node
+ * and glue the left and right children into place and return.
+ */
+ dnp = dt_node_alloc(DT_NODE_OP2);
+ assert(op <= USHRT_MAX);
+ dnp->dn_op = (ushort_t)op;
+ dnp->dn_left = lp;
+ dnp->dn_right = rp;
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_op3(dt_node_t *expr, dt_node_t *lp, dt_node_t *rp)
+{
+ dt_node_t *dnp;
+
+ if (expr->dn_kind == DT_NODE_INT)
+ return (expr->dn_value != 0 ? lp : rp);
+
+ dnp = dt_node_alloc(DT_NODE_OP3);
+ dnp->dn_op = DT_TOK_QUESTION;
+ dnp->dn_expr = expr;
+ dnp->dn_left = lp;
+ dnp->dn_right = rp;
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_statement(dt_node_t *expr)
+{
+ dt_node_t *dnp;
+
+ if (expr->dn_kind == DT_NODE_AGG)
+ return (expr);
+
+ if (expr->dn_kind == DT_NODE_FUNC &&
+ expr->dn_ident->di_kind == DT_IDENT_ACTFUNC)
+ dnp = dt_node_alloc(DT_NODE_DFUNC);
+ else
+ dnp = dt_node_alloc(DT_NODE_DEXPR);
+
+ dnp->dn_expr = expr;
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_pdesc_by_name(char *spec)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *dnp;
+
+ if (spec == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dnp = dt_node_alloc(DT_NODE_PDESC);
+ dnp->dn_spec = spec;
+ dnp->dn_desc = malloc(sizeof (dtrace_probedesc_t));
+
+ if (dnp->dn_desc == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (dtrace_xstr2desc(dtp, yypcb->pcb_pspec, dnp->dn_spec,
+ yypcb->pcb_sargc, yypcb->pcb_sargv, dnp->dn_desc) != 0) {
+ xyerror(D_PDESC_INVAL, "invalid probe description \"%s\": %s\n",
+ dnp->dn_spec, dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ free(dnp->dn_spec);
+ dnp->dn_spec = NULL;
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_pdesc_by_id(uintmax_t id)
+{
+ static const char *const names[] = {
+ "providers", "modules", "functions"
+ };
+
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *dnp = dt_node_alloc(DT_NODE_PDESC);
+
+ if ((dnp->dn_desc = malloc(sizeof (dtrace_probedesc_t))) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (id > UINT_MAX) {
+ xyerror(D_PDESC_INVAL, "identifier %llu exceeds maximum "
+ "probe id\n", (u_longlong_t)id);
+ }
+
+ if (yypcb->pcb_pspec != DTRACE_PROBESPEC_NAME) {
+ xyerror(D_PDESC_INVAL, "probe identifier %llu not permitted "
+ "when specifying %s\n", (u_longlong_t)id,
+ names[yypcb->pcb_pspec]);
+ }
+
+ if (dtrace_id2desc(dtp, (dtrace_id_t)id, dnp->dn_desc) != 0) {
+ xyerror(D_PDESC_INVAL, "invalid probe identifier %llu: %s\n",
+ (u_longlong_t)id, dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_clause(dt_node_t *pdescs, dt_node_t *pred, dt_node_t *acts)
+{
+ dt_node_t *dnp = dt_node_alloc(DT_NODE_CLAUSE);
+
+ dnp->dn_pdescs = pdescs;
+ dnp->dn_pred = pred;
+ dnp->dn_acts = acts;
+
+ yybegin(YYS_CLAUSE);
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_inline(dt_node_t *expr)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_scope_t *dsp = &yypcb->pcb_dstack;
+ dt_decl_t *ddp = dt_decl_top();
+
+ char n[DT_TYPE_NAMELEN];
+ dtrace_typeinfo_t dtt;
+
+ dt_ident_t *idp, *rdp;
+ dt_idnode_t *inp;
+ dt_node_t *dnp;
+
+ if (dt_decl_type(ddp, &dtt) != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+
+ if (dsp->ds_class != DT_DC_DEFAULT) {
+ xyerror(D_DECL_BADCLASS, "specified storage class not "
+ "appropriate for inline declaration\n");
+ }
+
+ if (dsp->ds_ident == NULL)
+ xyerror(D_DECL_USELESS, "inline declaration requires a name\n");
+
+ if ((idp = dt_idstack_lookup(
+ &yypcb->pcb_globals, dsp->ds_ident)) != NULL) {
+ xyerror(D_DECL_IDRED, "identifier redefined: %s\n\t current: "
+ "inline definition\n\tprevious: %s %s\n",
+ idp->di_name, dt_idkind_name(idp->di_kind),
+ (idp->di_flags & DT_IDFLG_INLINE) ? "inline" : "");
+ }
+
+ /*
+ * If we are declaring an inlined array, verify that we have a tuple
+ * signature, and then recompute 'dtt' as the array's value type.
+ */
+ if (ddp->dd_kind == CTF_K_ARRAY) {
+ if (ddp->dd_node == NULL) {
+ xyerror(D_DECL_ARRNULL, "inline declaration requires "
+ "array tuple signature: %s\n", dsp->ds_ident);
+ }
+
+ if (ddp->dd_node->dn_kind != DT_NODE_TYPE) {
+ xyerror(D_DECL_ARRNULL, "inline declaration cannot be "
+ "of scalar array type: %s\n", dsp->ds_ident);
+ }
+
+ if (dt_decl_type(ddp->dd_next, &dtt) != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+ }
+
+ /*
+ * If the inline identifier is not defined, then create it with the
+ * orphan flag set. We do not insert the identifier into dt_globals
+ * until we have successfully cooked the right-hand expression, below.
+ */
+ dnp = dt_node_alloc(DT_NODE_INLINE);
+ dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
+ dt_node_attr_assign(dnp, _dtrace_defattr);
+
+ if (dt_node_is_void(dnp)) {
+ xyerror(D_DECL_VOIDOBJ,
+ "cannot declare void inline: %s\n", dsp->ds_ident);
+ }
+
+ if (ctf_type_kind(dnp->dn_ctfp, ctf_type_resolve(
+ dnp->dn_ctfp, dnp->dn_type)) == CTF_K_FORWARD) {
+ xyerror(D_DECL_INCOMPLETE,
+ "incomplete struct/union/enum %s: %s\n",
+ dt_node_type_name(dnp, n, sizeof (n)), dsp->ds_ident);
+ }
+
+ if ((inp = malloc(sizeof (dt_idnode_t))) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ bzero(inp, sizeof (dt_idnode_t));
+
+ idp = dnp->dn_ident = dt_ident_create(dsp->ds_ident,
+ ddp->dd_kind == CTF_K_ARRAY ? DT_IDENT_ARRAY : DT_IDENT_SCALAR,
+ DT_IDFLG_INLINE | DT_IDFLG_REF | DT_IDFLG_DECL | DT_IDFLG_ORPHAN, 0,
+ _dtrace_defattr, 0, &dt_idops_inline, inp, dtp->dt_gen);
+
+ if (idp == NULL) {
+ free(inp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ /*
+ * If we're inlining an associative array, create a private identifier
+ * hash containing the named parameters and store it in inp->din_hash.
+ * We then push this hash on to the top of the pcb_globals stack.
+ */
+ if (ddp->dd_kind == CTF_K_ARRAY) {
+ dt_idnode_t *pinp;
+ dt_ident_t *pidp;
+ dt_node_t *pnp;
+ uint_t i = 0;
+
+ for (pnp = ddp->dd_node; pnp != NULL; pnp = pnp->dn_list)
+ i++; /* count up parameters for din_argv[] */
+
+ inp->din_hash = dt_idhash_create("inline args", NULL, 0, 0);
+ inp->din_argv = calloc(i, sizeof (dt_ident_t *));
+
+ if (inp->din_hash == NULL || inp->din_argv == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * Create an identifier for each parameter as a scalar inline,
+ * and store it in din_hash and in position in din_argv[]. The
+ * parameter identifiers also use dt_idops_inline, but we leave
+ * the dt_idnode_t argument 'pinp' zeroed. This will be filled
+ * in by the code generation pass with references to the args.
+ */
+ for (i = 0, pnp = ddp->dd_node;
+ pnp != NULL; pnp = pnp->dn_list, i++) {
+
+ if (pnp->dn_string == NULL)
+ continue; /* ignore anonymous parameters */
+
+ if ((pinp = malloc(sizeof (dt_idnode_t))) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ pidp = dt_idhash_insert(inp->din_hash, pnp->dn_string,
+ DT_IDENT_SCALAR, DT_IDFLG_DECL | DT_IDFLG_INLINE, 0,
+ _dtrace_defattr, 0, &dt_idops_inline,
+ pinp, dtp->dt_gen);
+
+ if (pidp == NULL) {
+ free(pinp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ }
+
+ inp->din_argv[i] = pidp;
+ bzero(pinp, sizeof (dt_idnode_t));
+ dt_ident_type_assign(pidp, pnp->dn_ctfp, pnp->dn_type);
+ }
+
+ dt_idstack_push(&yypcb->pcb_globals, inp->din_hash);
+ }
+
+ /*
+ * Unlike most constructors, we need to explicitly cook the right-hand
+ * side of the inline definition immediately to prevent recursion. If
+ * the right-hand side uses the inline itself, the cook will fail.
+ */
+ expr = dt_node_cook(expr, DT_IDFLG_REF);
+
+ if (ddp->dd_kind == CTF_K_ARRAY)
+ dt_idstack_pop(&yypcb->pcb_globals, inp->din_hash);
+
+ /*
+ * Set the type, attributes, and flags for the inline. If the right-
+ * hand expression has an identifier, propagate its flags. Then cook
+ * the identifier to fully initialize it: if we're declaring an inline
+ * associative array this will construct a type signature from 'ddp'.
+ */
+ if (dt_node_is_dynamic(expr))
+ rdp = dt_ident_resolve(expr->dn_ident);
+ else if (expr->dn_kind == DT_NODE_VAR || expr->dn_kind == DT_NODE_SYM)
+ rdp = expr->dn_ident;
+ else
+ rdp = NULL;
+
+ if (rdp != NULL) {
+ idp->di_flags |= (rdp->di_flags &
+ (DT_IDFLG_WRITE | DT_IDFLG_USER | DT_IDFLG_PRIM));
+ }
+
+ idp->di_attr = dt_attr_min(_dtrace_defattr, expr->dn_attr);
+ dt_ident_type_assign(idp, dtt.dtt_ctfp, dtt.dtt_type);
+ (void) dt_ident_cook(dnp, idp, &ddp->dd_node);
+
+ /*
+ * Store the parse tree nodes for 'expr' inside of idp->di_data ('inp')
+ * so that they will be preserved with this identifier. Then pop the
+ * inline declaration from the declaration stack and restore the lexer.
+ */
+ inp->din_list = yypcb->pcb_list;
+ inp->din_root = expr;
+
+ dt_decl_free(dt_decl_pop());
+ yybegin(YYS_CLAUSE);
+
+ /*
+ * Finally, insert the inline identifier into dt_globals to make it
+ * visible, and then cook 'dnp' to check its type against 'expr'.
+ */
+ dt_idhash_xinsert(dtp->dt_globals, idp);
+ return (dt_node_cook(dnp, DT_IDFLG_REF));
+}
+
+dt_node_t *
+dt_node_member(dt_decl_t *ddp, char *name, dt_node_t *expr)
+{
+ dtrace_typeinfo_t dtt VBDTMSC({NULL});
+ dt_node_t *dnp;
+ int err;
+
+ if (ddp != NULL) {
+ err = dt_decl_type(ddp, &dtt);
+ dt_decl_free(ddp);
+
+ if (err != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+ }
+
+ dnp = dt_node_alloc(DT_NODE_MEMBER);
+ dnp->dn_membname = name;
+ dnp->dn_membexpr = expr;
+
+ if (ddp != NULL)
+ dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_xlator(dt_decl_t *ddp, dt_decl_t *sdp, char *name, dt_node_t *members)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dtrace_typeinfo_t src, dst;
+ dt_node_t sn, dn;
+ dt_xlator_t *dxp;
+ dt_node_t *dnp;
+ int edst, esrc;
+ uint_t kind;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ edst = dt_decl_type(ddp, &dst);
+ dt_decl_free(ddp);
+
+ esrc = dt_decl_type(sdp, &src);
+ dt_decl_free(sdp);
+
+ if (edst != 0 || esrc != 0) {
+ free(name);
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+ }
+
+ bzero(&sn, sizeof (sn));
+ dt_node_type_assign(&sn, src.dtt_ctfp, src.dtt_type);
+
+ bzero(&dn, sizeof (dn));
+ dt_node_type_assign(&dn, dst.dtt_ctfp, dst.dtt_type);
+
+ if (dt_xlator_lookup(dtp, &sn, &dn, DT_XLATE_EXACT) != NULL) {
+ xyerror(D_XLATE_REDECL,
+ "translator from %s to %s has already been declared\n",
+ dt_node_type_name(&sn, n1, sizeof (n1)),
+ dt_node_type_name(&dn, n2, sizeof (n2)));
+ }
+
+ kind = ctf_type_kind(dst.dtt_ctfp,
+ ctf_type_resolve(dst.dtt_ctfp, dst.dtt_type));
+
+ if (kind == CTF_K_FORWARD) {
+ xyerror(D_XLATE_SOU, "incomplete struct/union/enum %s\n",
+ dt_type_name(dst.dtt_ctfp, dst.dtt_type, n1, sizeof (n1)));
+ }
+
+ if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) {
+ xyerror(D_XLATE_SOU,
+ "translator output type must be a struct or union\n");
+ }
+
+ dxp = dt_xlator_create(dtp, &src, &dst, name, members, yypcb->pcb_list);
+ yybegin(YYS_CLAUSE);
+ free(name);
+
+ if (dxp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ dnp = dt_node_alloc(DT_NODE_XLATOR);
+ dnp->dn_xlator = dxp;
+ dnp->dn_members = members;
+
+ return (dt_node_cook(dnp, DT_IDFLG_REF));
+}
+
+dt_node_t *
+dt_node_probe(char *s, int protoc, dt_node_t *nargs, dt_node_t *xargs)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ int nargc, xargc;
+ dt_node_t *dnp;
+
+ size_t len = strlen(s) + 3; /* +3 for :: and \0 */
+ char *name = alloca(len);
+
+ (void) snprintf(name, len, "::%s", s);
+ (void) strhyphenate(name);
+ free(s);
+
+ if (strchr(name, '`') != NULL) {
+ xyerror(D_PROV_BADNAME, "probe name may not "
+ "contain scoping operator: %s\n", name);
+ }
+
+ if (strlen(name) - 2 >= DTRACE_NAMELEN) {
+ xyerror(D_PROV_BADNAME, "probe name may not exceed %d "
+ "characters: %s\n", DTRACE_NAMELEN - 1, name);
+ }
+
+ dnp = dt_node_alloc(DT_NODE_PROBE);
+
+ dnp->dn_ident = dt_ident_create(name, DT_IDENT_PROBE,
+ DT_IDFLG_ORPHAN, DTRACE_IDNONE, _dtrace_defattr, 0,
+ &dt_idops_probe, NULL, dtp->dt_gen);
+
+ nargc = dt_decl_prototype(nargs, nargs,
+ "probe input", DT_DP_VOID | DT_DP_ANON);
+
+ xargc = dt_decl_prototype(xargs, nargs,
+ "probe output", DT_DP_VOID);
+
+ if (nargc > UINT8_MAX) {
+ xyerror(D_PROV_PRARGLEN, "probe %s input prototype exceeds %u "
+ "parameters: %d params used\n", name, UINT8_MAX, nargc);
+ }
+
+ if (xargc > UINT8_MAX) {
+ xyerror(D_PROV_PRARGLEN, "probe %s output prototype exceeds %u "
+ "parameters: %d params used\n", name, UINT8_MAX, xargc);
+ }
+
+ if (dnp->dn_ident == NULL || dt_probe_create(dtp,
+ dnp->dn_ident, protoc, nargs, nargc, xargs, xargc) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_provider(char *name, dt_node_t *probes)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *dnp = dt_node_alloc(DT_NODE_PROVIDER);
+ dt_node_t *lnp;
+ size_t len;
+
+ dnp->dn_provname = name;
+ dnp->dn_probes = probes;
+
+ if (strchr(name, '`') != NULL) {
+ dnerror(dnp, D_PROV_BADNAME, "provider name may not "
+ "contain scoping operator: %s\n", name);
+ }
+
+ if ((len = strlen(name)) >= DTRACE_PROVNAMELEN) {
+ dnerror(dnp, D_PROV_BADNAME, "provider name may not exceed %d "
+ "characters: %s\n", DTRACE_PROVNAMELEN - 1, name);
+ }
+
+ if (isdigit(name[len - 1])) {
+ dnerror(dnp, D_PROV_BADNAME, "provider name may not "
+ "end with a digit: %s\n", name);
+ }
+
+ /*
+ * Check to see if the provider is already defined or visible through
+ * dtrace(7D). If so, set dn_provred to treat it as a re-declaration.
+ * If not, create a new provider and set its interface-only flag. This
+ * flag may be cleared later by calls made to dt_probe_declare().
+ */
+ if ((dnp->dn_provider = dt_provider_lookup(dtp, name)) != NULL)
+ dnp->dn_provred = B_TRUE;
+ else if ((dnp->dn_provider = dt_provider_create(dtp, name)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ else
+ dnp->dn_provider->pv_flags |= DT_PROVIDER_INTF;
+
+ /*
+ * Store all parse nodes created since we consumed the DT_KEY_PROVIDER
+ * token with the provider and then restore our lexing state to CLAUSE.
+ * Note that if dnp->dn_provred is true, we may end up storing dups of
+ * a provider's interface and implementation: we eat this space because
+ * the implementation will likely need to redeclare probe members, and
+ * therefore may result in those member nodes becoming persistent.
+ */
+ for (lnp = yypcb->pcb_list; lnp->dn_link != NULL; lnp = lnp->dn_link)
+ continue; /* skip to end of allocation list */
+
+ lnp->dn_link = dnp->dn_provider->pv_nodes;
+ dnp->dn_provider->pv_nodes = yypcb->pcb_list;
+
+ yybegin(YYS_CLAUSE);
+ return (dnp);
+}
+
+dt_node_t *
+dt_node_program(dt_node_t *lnp)
+{
+ dt_node_t *dnp = dt_node_alloc(DT_NODE_PROG);
+ dnp->dn_list = lnp;
+ return (dnp);
+}
+
+/*
+ * This function provides the underlying implementation of cooking an
+ * identifier given its node, a hash of dynamic identifiers, an identifier
+ * kind, and a boolean flag indicating whether we are allowed to instantiate
+ * a new identifier if the string is not found. This function is either
+ * called from dt_cook_ident(), below, or directly by the various cooking
+ * routines that are allowed to instantiate identifiers (e.g. op2 TOK_ASGN).
+ */
+static void
+dt_xcook_ident(dt_node_t *dnp, dt_idhash_t *dhp, uint_t idkind, int create)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ const char *sname = dt_idhash_name(dhp);
+ int uref = 0;
+
+ dtrace_attribute_t attr = _dtrace_defattr;
+ dt_ident_t *idp;
+ dtrace_syminfo_t dts;
+ GElf_Sym sym;
+
+ const char *scope, *mark;
+ uchar_t dnkind;
+ char *name;
+
+ /*
+ * Look for scoping marks in the identifier. If one is found, set our
+ * scope to either DTRACE_OBJ_KMODS or UMODS or to the first part of
+ * the string that specifies the scope using an explicit module name.
+ * If two marks in a row are found, set 'uref' (user symbol reference).
+ * Otherwise we set scope to DTRACE_OBJ_EXEC, indicating that normal
+ * scope is desired and we should search the specified idhash.
+ */
+ if ((name = strrchr(dnp->dn_string, '`')) != NULL) {
+ if (name > dnp->dn_string && name[-1] == '`') {
+ uref++;
+ name[-1] = '\0';
+ }
+
+ if (name == dnp->dn_string + uref)
+ scope = uref ? DTRACE_OBJ_UMODS : DTRACE_OBJ_KMODS;
+ else
+ scope = dnp->dn_string;
+
+ *name++ = '\0'; /* leave name pointing after scoping mark */
+ dnkind = DT_NODE_VAR;
+
+ } else if (idkind == DT_IDENT_AGG) {
+ scope = DTRACE_OBJ_EXEC;
+ name = dnp->dn_string + 1;
+ dnkind = DT_NODE_AGG;
+ } else {
+ scope = DTRACE_OBJ_EXEC;
+ name = dnp->dn_string;
+ dnkind = DT_NODE_VAR;
+ }
+
+ /*
+ * If create is set to false, and we fail our idhash lookup, preset
+ * the errno code to EDT_NOVAR for our final error message below.
+ * If we end up calling dtrace_lookup_by_name(), it will reset the
+ * errno appropriately and that error will be reported instead.
+ */
+ (void) dt_set_errno(dtp, EDT_NOVAR);
+ mark = uref ? "``" : "`";
+
+ if (scope == DTRACE_OBJ_EXEC && (
+ (dhp != dtp->dt_globals &&
+ (idp = dt_idhash_lookup(dhp, name)) != NULL) ||
+ (dhp == dtp->dt_globals &&
+ (idp = dt_idstack_lookup(&yypcb->pcb_globals, name)) != NULL))) {
+ /*
+ * Check that we are referencing the ident in the manner that
+ * matches its type if this is a global lookup. In the TLS or
+ * local case, we don't know how the ident will be used until
+ * the time operator -> is seen; more parsing is needed.
+ */
+ if (idp->di_kind != idkind && dhp == dtp->dt_globals) {
+ xyerror(D_IDENT_BADREF, "%s '%s' may not be referenced "
+ "as %s\n", dt_idkind_name(idp->di_kind),
+ idp->di_name, dt_idkind_name(idkind));
+ }
+
+ /*
+ * Arrays and aggregations are not cooked individually. They
+ * have dynamic types and must be referenced using operator [].
+ * This is handled explicitly by the code for DT_TOK_LBRAC.
+ */
+ if (idp->di_kind != DT_IDENT_ARRAY &&
+ idp->di_kind != DT_IDENT_AGG)
+ attr = dt_ident_cook(dnp, idp, NULL);
+ else {
+ dt_node_type_assign(dnp,
+ DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+ attr = idp->di_attr;
+ }
+
+ free(dnp->dn_string);
+ dnp->dn_string = NULL;
+ dnp->dn_kind = dnkind;
+ dnp->dn_ident = idp;
+ dnp->dn_flags |= DT_NF_LVALUE;
+
+ if (idp->di_flags & DT_IDFLG_WRITE)
+ dnp->dn_flags |= DT_NF_WRITABLE;
+
+ dt_node_attr_assign(dnp, attr);
+
+ } else if (dhp == dtp->dt_globals && scope != DTRACE_OBJ_EXEC &&
+ dtrace_lookup_by_name(dtp, scope, name, &sym, &dts) == 0) {
+
+ dt_module_t *mp = dt_module_lookup_by_name(dtp, dts.dts_object);
+ int umod = (mp->dm_flags & DT_DM_KERNEL) == 0;
+ static const char *const kunames[] = { "kernel", "user" };
+
+ dtrace_typeinfo_t dtt;
+ dtrace_syminfo_t *sip;
+
+ if (uref ^ umod) {
+ xyerror(D_SYM_BADREF, "%s module '%s' symbol '%s' may "
+ "not be referenced as a %s symbol\n", kunames[umod],
+ dts.dts_object, dts.dts_name, kunames[uref]);
+ }
+
+ if (dtrace_symbol_type(dtp, &sym, &dts, &dtt) != 0) {
+ /*
+ * For now, we special-case EDT_DATAMODEL to clarify
+ * that mixed data models are not currently supported.
+ */
+ if (dtp->dt_errno == EDT_DATAMODEL) {
+ xyerror(D_SYM_MODEL, "cannot use %s symbol "
+ "%s%s%s in a %s D program\n",
+ dt_module_modelname(mp),
+ dts.dts_object, mark, dts.dts_name,
+ dt_module_modelname(dtp->dt_ddefs));
+ }
+
+ xyerror(D_SYM_NOTYPES,
+ "no symbolic type information is available for "
+ "%s%s%s: %s\n", dts.dts_object, mark, dts.dts_name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+
+ idp = dt_ident_create(name, DT_IDENT_SYMBOL, 0, 0,
+ _dtrace_symattr, 0, &dt_idops_thaw, NULL, dtp->dt_gen);
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (mp->dm_flags & DT_DM_PRIMARY)
+ idp->di_flags |= DT_IDFLG_PRIM;
+
+ idp->di_next = dtp->dt_externs;
+ dtp->dt_externs = idp;
+
+ if ((sip = malloc(sizeof (dtrace_syminfo_t))) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ bcopy(&dts, sip, sizeof (dtrace_syminfo_t));
+ idp->di_data = sip;
+ idp->di_ctfp = dtt.dtt_ctfp;
+ idp->di_type = dtt.dtt_type;
+
+ free(dnp->dn_string);
+ dnp->dn_string = NULL;
+ dnp->dn_kind = DT_NODE_SYM;
+ dnp->dn_ident = idp;
+ dnp->dn_flags |= DT_NF_LVALUE;
+
+ dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
+ dt_node_attr_assign(dnp, _dtrace_symattr);
+
+ if (uref) {
+ idp->di_flags |= DT_IDFLG_USER;
+ dnp->dn_flags |= DT_NF_USERLAND;
+ }
+ } else if (scope == DTRACE_OBJ_EXEC && create == B_TRUE) {
+ uint_t flags = DT_IDFLG_WRITE;
+ uint_t id;
+
+ if (dt_idhash_nextid(dhp, &id) == -1) {
+ xyerror(D_ID_OFLOW, "cannot create %s: limit on number "
+ "of %s variables exceeded\n", name, sname);
+ }
+
+ if (dhp == yypcb->pcb_locals)
+ flags |= DT_IDFLG_LOCAL;
+ else if (dhp == dtp->dt_tls)
+ flags |= DT_IDFLG_TLS;
+
+ dt_dprintf("create %s %s variable %s, id=%u\n",
+ sname, dt_idkind_name(idkind), name, id);
+
+ if (idkind == DT_IDENT_ARRAY || idkind == DT_IDENT_AGG) {
+ idp = dt_idhash_insert(dhp, name,
+ idkind, flags, id, _dtrace_defattr, 0,
+ &dt_idops_assc, NULL, dtp->dt_gen);
+ } else {
+ idp = dt_idhash_insert(dhp, name,
+ idkind, flags, id, _dtrace_defattr, 0,
+ &dt_idops_thaw, NULL, dtp->dt_gen);
+ }
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ /*
+ * Arrays and aggregations are not cooked individually. They
+ * have dynamic types and must be referenced using operator [].
+ * This is handled explicitly by the code for DT_TOK_LBRAC.
+ */
+ if (idp->di_kind != DT_IDENT_ARRAY &&
+ idp->di_kind != DT_IDENT_AGG)
+ attr = dt_ident_cook(dnp, idp, NULL);
+ else {
+ dt_node_type_assign(dnp,
+ DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+ attr = idp->di_attr;
+ }
+
+ free(dnp->dn_string);
+ dnp->dn_string = NULL;
+ dnp->dn_kind = dnkind;
+ dnp->dn_ident = idp;
+ dnp->dn_flags |= DT_NF_LVALUE | DT_NF_WRITABLE;
+
+ dt_node_attr_assign(dnp, attr);
+
+ } else if (scope != DTRACE_OBJ_EXEC) {
+ xyerror(D_IDENT_UNDEF, "failed to resolve %s%s%s: %s\n",
+ dnp->dn_string, mark, name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ } else {
+ xyerror(D_IDENT_UNDEF, "failed to resolve %s: %s\n",
+ dnp->dn_string, dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+}
+
+static dt_node_t *
+dt_cook_ident(dt_node_t *dnp, uint_t idflags)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+
+ if (dnp->dn_op == DT_TOK_AGG)
+ dt_xcook_ident(dnp, dtp->dt_aggs, DT_IDENT_AGG, B_FALSE);
+ else
+ dt_xcook_ident(dnp, dtp->dt_globals, DT_IDENT_SCALAR, B_FALSE);
+
+ return (dt_node_cook(dnp, idflags));
+}
+
+/*
+ * Since operators [ and -> can instantiate new variables before we know
+ * whether the reference is for a read or a write, we need to check read
+ * references to determine if the identifier is currently dt_ident_unref().
+ * If so, we report that this first access was to an undefined variable.
+ */
+static dt_node_t *
+dt_cook_var(dt_node_t *dnp, uint_t idflags)
+{
+ dt_ident_t *idp = dnp->dn_ident;
+
+ if ((idflags & DT_IDFLG_REF) && dt_ident_unref(idp)) {
+ dnerror(dnp, D_VAR_UNDEF,
+ "%s%s has not yet been declared or assigned\n",
+ (idp->di_flags & DT_IDFLG_LOCAL) ? "this->" :
+ (idp->di_flags & DT_IDFLG_TLS) ? "self->" : "",
+ idp->di_name);
+ }
+
+ dt_node_attr_assign(dnp, dt_ident_cook(dnp, idp, &dnp->dn_args));
+ return (dnp);
+}
+
+/*ARGSUSED*/
+static dt_node_t *
+dt_cook_func(dt_node_t *dnp, uint_t idflags)
+{
+ RT_NOREF1(idflags);
+
+ dt_node_attr_assign(dnp,
+ dt_ident_cook(dnp, dnp->dn_ident, &dnp->dn_args));
+
+ return (dnp);
+}
+
+static dt_node_t *
+dt_cook_op1(dt_node_t *dnp, uint_t idflags)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *cp = dnp->dn_child;
+
+ char n[DT_TYPE_NAMELEN];
+ dtrace_typeinfo_t dtt;
+ dt_ident_t *idp;
+
+ ctf_encoding_t e;
+ ctf_arinfo_t r;
+ ctf_id_t type, base;
+ uint_t kind;
+
+ if (dnp->dn_op == DT_TOK_PREINC || dnp->dn_op == DT_TOK_POSTINC ||
+ dnp->dn_op == DT_TOK_PREDEC || dnp->dn_op == DT_TOK_POSTDEC)
+ idflags = DT_IDFLG_REF | DT_IDFLG_MOD;
+ else
+ idflags = DT_IDFLG_REF;
+
+ /*
+ * We allow the unary ++ and -- operators to instantiate new scalar
+ * variables if applied to an identifier; otherwise just cook as usual.
+ */
+ if (cp->dn_kind == DT_NODE_IDENT && (idflags & DT_IDFLG_MOD))
+ dt_xcook_ident(cp, dtp->dt_globals, DT_IDENT_SCALAR, B_TRUE);
+
+ cp = dnp->dn_child = dt_node_cook(cp, 0); /* don't set idflags yet */
+
+ if (cp->dn_kind == DT_NODE_VAR && dt_ident_unref(cp->dn_ident)) {
+ if (dt_type_lookup("int64_t", &dtt) != 0)
+ xyerror(D_TYPE_ERR, "failed to lookup int64_t\n");
+
+ dt_ident_type_assign(cp->dn_ident, dtt.dtt_ctfp, dtt.dtt_type);
+ dt_node_type_assign(cp, dtt.dtt_ctfp, dtt.dtt_type);
+ }
+
+ if (cp->dn_kind == DT_NODE_VAR)
+ cp->dn_ident->di_flags |= idflags;
+
+ switch (dnp->dn_op) {
+ case DT_TOK_DEREF:
+ /*
+ * If the deref operator is applied to a translated pointer,
+ * we can just set our output type to the base translation.
+ */
+ if ((idp = dt_node_resolve(cp, DT_IDENT_XLPTR)) != NULL) {
+ dt_xlator_t *dxp = idp->di_data;
+
+ dnp->dn_ident = &dxp->dx_souid;
+ dt_node_type_assign(dnp,
+ DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+ break;
+ }
+
+ type = ctf_type_resolve(cp->dn_ctfp, cp->dn_type);
+ kind = ctf_type_kind(cp->dn_ctfp, type);
+
+ if (kind == CTF_K_ARRAY) {
+ if (ctf_array_info(cp->dn_ctfp, type, &r) != 0) {
+ dtp->dt_ctferr = ctf_errno(cp->dn_ctfp);
+ longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
+ } else
+ type = r.ctr_contents;
+ } else if (kind == CTF_K_POINTER) {
+ type = ctf_type_reference(cp->dn_ctfp, type);
+ } else {
+ xyerror(D_DEREF_NONPTR,
+ "cannot dereference non-pointer type\n");
+ }
+
+ dt_node_type_assign(dnp, cp->dn_ctfp, type);
+ base = ctf_type_resolve(cp->dn_ctfp, type);
+ kind = ctf_type_kind(cp->dn_ctfp, base);
+
+ if (kind == CTF_K_INTEGER && ctf_type_encoding(cp->dn_ctfp,
+ base, &e) == 0 && IS_VOID(e)) {
+ xyerror(D_DEREF_VOID,
+ "cannot dereference pointer to void\n");
+ }
+
+ if (kind == CTF_K_FUNCTION) {
+ xyerror(D_DEREF_FUNC,
+ "cannot dereference pointer to function\n");
+ }
+
+ if (kind != CTF_K_ARRAY || dt_node_is_string(dnp))
+ dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.4.3] */
+
+ /*
+ * If we propagated the l-value bit and the child operand was
+ * a writable D variable or a binary operation of the form
+ * a + b where a is writable, then propagate the writable bit.
+ * This is necessary to permit assignments to scalar arrays,
+ * which are converted to expressions of the form *(a + i).
+ */
+ if ((cp->dn_flags & DT_NF_WRITABLE) ||
+ (cp->dn_kind == DT_NODE_OP2 && cp->dn_op == DT_TOK_ADD &&
+ (cp->dn_left->dn_flags & DT_NF_WRITABLE)))
+ dnp->dn_flags |= DT_NF_WRITABLE;
+
+ if ((cp->dn_flags & DT_NF_USERLAND) &&
+ (kind == CTF_K_POINTER || (dnp->dn_flags & DT_NF_REF)))
+ dnp->dn_flags |= DT_NF_USERLAND;
+ break;
+
+ case DT_TOK_IPOS:
+ case DT_TOK_INEG:
+ if (!dt_node_is_arith(cp)) {
+ xyerror(D_OP_ARITH, "operator %s requires an operand "
+ "of arithmetic type\n", opstr(dnp->dn_op));
+ }
+ dt_node_type_propagate(cp, dnp); /* see K&R[A7.4.4-6] */
+ break;
+
+ case DT_TOK_BNEG:
+ if (!dt_node_is_integer(cp)) {
+ xyerror(D_OP_INT, "operator %s requires an operand of "
+ "integral type\n", opstr(dnp->dn_op));
+ }
+ dt_node_type_propagate(cp, dnp); /* see K&R[A7.4.4-6] */
+ break;
+
+ case DT_TOK_LNEG:
+ if (!dt_node_is_scalar(cp)) {
+ xyerror(D_OP_SCALAR, "operator %s requires an operand "
+ "of scalar type\n", opstr(dnp->dn_op));
+ }
+ dt_node_type_assign(dnp, DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ break;
+
+ case DT_TOK_ADDROF:
+ if (cp->dn_kind == DT_NODE_VAR || cp->dn_kind == DT_NODE_AGG) {
+ xyerror(D_ADDROF_VAR,
+ "cannot take address of dynamic variable\n");
+ }
+
+ if (dt_node_is_dynamic(cp)) {
+ xyerror(D_ADDROF_VAR,
+ "cannot take address of dynamic object\n");
+ }
+
+ if (!(cp->dn_flags & DT_NF_LVALUE)) {
+ xyerror(D_ADDROF_LVAL, /* see K&R[A7.4.2] */
+ "unacceptable operand for unary & operator\n");
+ }
+
+ if (cp->dn_flags & DT_NF_BITFIELD) {
+ xyerror(D_ADDROF_BITFIELD,
+ "cannot take address of bit-field\n");
+ }
+
+ dtt.dtt_object = NULL;
+ dtt.dtt_ctfp = cp->dn_ctfp;
+ dtt.dtt_type = cp->dn_type;
+
+ if (dt_type_pointer(&dtt) == -1) {
+ xyerror(D_TYPE_ERR, "cannot find type for \"&\": %s*\n",
+ dt_node_type_name(cp, n, sizeof (n)));
+ }
+
+ dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
+
+ if (cp->dn_flags & DT_NF_USERLAND)
+ dnp->dn_flags |= DT_NF_USERLAND;
+ break;
+
+ case DT_TOK_SIZEOF:
+ if (cp->dn_flags & DT_NF_BITFIELD) {
+ xyerror(D_SIZEOF_BITFIELD,
+ "cannot apply sizeof to a bit-field\n");
+ }
+
+ if (dt_node_sizeof(cp) == 0) {
+ xyerror(D_SIZEOF_TYPE, "cannot apply sizeof to an "
+ "operand of unknown size\n");
+ }
+
+ dt_node_type_assign(dnp, dtp->dt_ddefs->dm_ctfp,
+ ctf_lookup_by_name(dtp->dt_ddefs->dm_ctfp, "size_t"));
+ break;
+
+ case DT_TOK_STRINGOF:
+ if (!dt_node_is_scalar(cp) && !dt_node_is_pointer(cp) &&
+ !dt_node_is_strcompat(cp)) {
+ xyerror(D_STRINGOF_TYPE,
+ "cannot apply stringof to a value of type %s\n",
+ dt_node_type_name(cp, n, sizeof (n)));
+ }
+ dt_node_type_assign(dnp, DT_STR_CTFP(dtp), DT_STR_TYPE(dtp));
+ break;
+
+ case DT_TOK_PREINC:
+ case DT_TOK_POSTINC:
+ case DT_TOK_PREDEC:
+ case DT_TOK_POSTDEC:
+ if (dt_node_is_scalar(cp) == 0) {
+ xyerror(D_OP_SCALAR, "operator %s requires operand of "
+ "scalar type\n", opstr(dnp->dn_op));
+ }
+
+ if (dt_node_is_vfptr(cp)) {
+ xyerror(D_OP_VFPTR, "operator %s requires an operand "
+ "of known size\n", opstr(dnp->dn_op));
+ }
+
+ if (!(cp->dn_flags & DT_NF_LVALUE)) {
+ xyerror(D_OP_LVAL, "operator %s requires modifiable "
+ "lvalue as an operand\n", opstr(dnp->dn_op));
+ }
+
+ if (!(cp->dn_flags & DT_NF_WRITABLE)) {
+ xyerror(D_OP_WRITE, "operator %s can only be applied "
+ "to a writable variable\n", opstr(dnp->dn_op));
+ }
+
+ dt_node_type_propagate(cp, dnp); /* see K&R[A7.4.1] */
+ break;
+
+ default:
+ xyerror(D_UNKNOWN, "invalid unary op %s\n", opstr(dnp->dn_op));
+ }
+
+ dt_node_attr_assign(dnp, cp->dn_attr);
+ return (dnp);
+}
+
+static dt_node_t *
+dt_cook_op2(dt_node_t *dnp, uint_t idflags)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *lp = dnp->dn_left;
+ dt_node_t *rp = dnp->dn_right;
+ int op = dnp->dn_op;
+
+ ctf_membinfo_t m;
+ ctf_file_t *ctfp;
+ ctf_id_t type;
+ int kind, val, uref;
+ dt_ident_t *idp;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ /*
+ * The expression E1[E2] is identical by definition to *((E1)+(E2)) so
+ * we convert "[" to "+" and glue on "*" at the end (see K&R[A7.3.1])
+ * unless the left-hand side is an untyped D scalar, associative array,
+ * or aggregation. In these cases, we proceed to case DT_TOK_LBRAC and
+ * handle associative array and aggregation references there.
+ */
+ if (op == DT_TOK_LBRAC) {
+ if (lp->dn_kind == DT_NODE_IDENT) {
+ dt_idhash_t *dhp;
+ uint_t idkind;
+
+ if (lp->dn_op == DT_TOK_AGG) {
+ dhp = dtp->dt_aggs;
+ idp = dt_idhash_lookup(dhp, lp->dn_string + 1);
+ idkind = DT_IDENT_AGG;
+ } else {
+ dhp = dtp->dt_globals;
+ idp = dt_idstack_lookup(
+ &yypcb->pcb_globals, lp->dn_string);
+ idkind = DT_IDENT_ARRAY;
+ }
+
+ if (idp == NULL || dt_ident_unref(idp))
+ dt_xcook_ident(lp, dhp, idkind, B_TRUE);
+ else
+ dt_xcook_ident(lp, dhp, idp->di_kind, B_FALSE);
+ } else
+ lp = dnp->dn_left = dt_node_cook(lp, 0);
+
+ /*
+ * Switch op to '+' for *(E1 + E2) array mode in these cases:
+ * (a) lp is a DT_IDENT_ARRAY variable that has already been
+ * referenced using [] notation (dn_args != NULL).
+ * (b) lp is a non-ARRAY variable that has already been given
+ * a type by assignment or declaration (!dt_ident_unref())
+ * (c) lp is neither a variable nor an aggregation
+ */
+ if (lp->dn_kind == DT_NODE_VAR) {
+ if (lp->dn_ident->di_kind == DT_IDENT_ARRAY) {
+ if (lp->dn_args != NULL)
+ op = DT_TOK_ADD;
+ } else if (!dt_ident_unref(lp->dn_ident))
+ op = DT_TOK_ADD;
+ } else if (lp->dn_kind != DT_NODE_AGG)
+ op = DT_TOK_ADD;
+ }
+
+ switch (op) {
+ case DT_TOK_BAND:
+ case DT_TOK_XOR:
+ case DT_TOK_BOR:
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ if (!dt_node_is_integer(lp) || !dt_node_is_integer(rp)) {
+ xyerror(D_OP_INT, "operator %s requires operands of "
+ "integral type\n", opstr(op));
+ }
+
+ dt_node_promote(lp, rp, dnp); /* see K&R[A7.11-13] */
+ break;
+
+ case DT_TOK_LSH:
+ case DT_TOK_RSH:
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ if (!dt_node_is_integer(lp) || !dt_node_is_integer(rp)) {
+ xyerror(D_OP_INT, "operator %s requires operands of "
+ "integral type\n", opstr(op));
+ }
+
+ dt_node_type_propagate(lp, dnp); /* see K&R[A7.8] */
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+
+ case DT_TOK_MOD:
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ if (!dt_node_is_integer(lp) || !dt_node_is_integer(rp)) {
+ xyerror(D_OP_INT, "operator %s requires operands of "
+ "integral type\n", opstr(op));
+ }
+
+ dt_node_promote(lp, rp, dnp); /* see K&R[A7.6] */
+ break;
+
+ case DT_TOK_MUL:
+ case DT_TOK_DIV:
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ if (!dt_node_is_arith(lp) || !dt_node_is_arith(rp)) {
+ xyerror(D_OP_ARITH, "operator %s requires operands of "
+ "arithmetic type\n", opstr(op));
+ }
+
+ dt_node_promote(lp, rp, dnp); /* see K&R[A7.6] */
+ break;
+
+ case DT_TOK_LAND:
+ case DT_TOK_LXOR:
+ case DT_TOK_LOR:
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ if (!dt_node_is_scalar(lp) || !dt_node_is_scalar(rp)) {
+ xyerror(D_OP_SCALAR, "operator %s requires operands "
+ "of scalar type\n", opstr(op));
+ }
+
+ dt_node_type_assign(dnp, DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+
+ case DT_TOK_LT:
+ case DT_TOK_LE:
+ case DT_TOK_GT:
+ case DT_TOK_GE:
+ case DT_TOK_EQU:
+ case DT_TOK_NEQ:
+ /*
+ * The D comparison operators provide the ability to transform
+ * a right-hand identifier into a corresponding enum tag value
+ * if the left-hand side is an enum type. To do this, we cook
+ * the left-hand side, and then see if the right-hand side is
+ * an unscoped identifier defined in the enum. If so, we
+ * convert into an integer constant node with the tag's value.
+ */
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+
+ kind = ctf_type_kind(lp->dn_ctfp,
+ ctf_type_resolve(lp->dn_ctfp, lp->dn_type));
+
+ if (kind == CTF_K_ENUM && rp->dn_kind == DT_NODE_IDENT &&
+ strchr(rp->dn_string, '`') == NULL && ctf_enum_value(
+ lp->dn_ctfp, lp->dn_type, rp->dn_string, &val) == 0) {
+
+ if ((idp = dt_idstack_lookup(&yypcb->pcb_globals,
+ rp->dn_string)) != NULL) {
+ xyerror(D_IDENT_AMBIG,
+ "ambiguous use of operator %s: %s is "
+ "both a %s enum tag and a global %s\n",
+ opstr(op), rp->dn_string,
+ dt_node_type_name(lp, n1, sizeof (n1)),
+ dt_idkind_name(idp->di_kind));
+ }
+
+ free(rp->dn_string);
+ rp->dn_string = NULL;
+ rp->dn_kind = DT_NODE_INT;
+ rp->dn_flags |= DT_NF_COOKED;
+ rp->dn_op = DT_TOK_INT;
+ rp->dn_value = (intmax_t)val;
+
+ dt_node_type_assign(rp, lp->dn_ctfp, lp->dn_type);
+ dt_node_attr_assign(rp, _dtrace_symattr);
+ }
+
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ /*
+ * The rules for type checking for the relational operators are
+ * described in the ANSI-C spec (see K&R[A7.9-10]). We perform
+ * the various tests in order from least to most expensive. We
+ * also allow derived strings to be compared as a first-class
+ * type (resulting in a strcmp(3C)-style comparison), and we
+ * slightly relax the A7.9 rules to permit void pointer
+ * comparisons as in A7.10. Our users won't be confused by
+ * this since they understand pointers are just numbers, and
+ * relaxing this constraint simplifies the implementation.
+ */
+ if (ctf_type_compat(lp->dn_ctfp, lp->dn_type,
+ rp->dn_ctfp, rp->dn_type))
+ /*EMPTY*/;
+ else if (dt_node_is_integer(lp) && dt_node_is_integer(rp))
+ /*EMPTY*/;
+ else if (dt_node_is_strcompat(lp) && dt_node_is_strcompat(rp) &&
+ (dt_node_is_string(lp) || dt_node_is_string(rp)))
+ /*EMPTY*/;
+ else if (dt_node_is_ptrcompat(lp, rp, NULL, NULL) == 0) {
+ xyerror(D_OP_INCOMPAT, "operands have "
+ "incompatible types: \"%s\" %s \"%s\"\n",
+ dt_node_type_name(lp, n1, sizeof (n1)), opstr(op),
+ dt_node_type_name(rp, n2, sizeof (n2)));
+ }
+
+ dt_node_type_assign(dnp, DT_INT_CTFP(dtp), DT_INT_TYPE(dtp));
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+
+ case DT_TOK_ADD:
+ case DT_TOK_SUB: {
+ /*
+ * The rules for type checking for the additive operators are
+ * described in the ANSI-C spec (see K&R[A7.7]). Pointers and
+ * integers may be manipulated according to specific rules. In
+ * these cases D permits strings to be treated as pointers.
+ */
+ int lp_is_ptr, lp_is_int, rp_is_ptr, rp_is_int;
+
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ lp_is_ptr = dt_node_is_string(lp) ||
+ (dt_node_is_pointer(lp) && !dt_node_is_vfptr(lp));
+ lp_is_int = dt_node_is_integer(lp);
+
+ rp_is_ptr = dt_node_is_string(rp) ||
+ (dt_node_is_pointer(rp) && !dt_node_is_vfptr(rp));
+ rp_is_int = dt_node_is_integer(rp);
+
+ if (lp_is_int && rp_is_int) {
+ dt_type_promote(lp, rp, &ctfp, &type);
+ uref = 0;
+ } else if (lp_is_ptr && rp_is_int) {
+ ctfp = lp->dn_ctfp;
+ type = lp->dn_type;
+ uref = lp->dn_flags & DT_NF_USERLAND;
+ } else if (lp_is_int && rp_is_ptr && op == DT_TOK_ADD) {
+ ctfp = rp->dn_ctfp;
+ type = rp->dn_type;
+ uref = rp->dn_flags & DT_NF_USERLAND;
+ } else if (lp_is_ptr && rp_is_ptr && op == DT_TOK_SUB &&
+ dt_node_is_ptrcompat(lp, rp, NULL, NULL)) {
+ ctfp = dtp->dt_ddefs->dm_ctfp;
+ type = ctf_lookup_by_name(ctfp, "ptrdiff_t");
+ uref = 0;
+ } else {
+ xyerror(D_OP_INCOMPAT, "operands have incompatible "
+ "types: \"%s\" %s \"%s\"\n",
+ dt_node_type_name(lp, n1, sizeof (n1)), opstr(op),
+ dt_node_type_name(rp, n2, sizeof (n2)));
+ }
+
+ dt_node_type_assign(dnp, ctfp, type);
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+
+ if (uref)
+ dnp->dn_flags |= DT_NF_USERLAND;
+ break;
+ }
+
+ case DT_TOK_OR_EQ:
+ case DT_TOK_XOR_EQ:
+ case DT_TOK_AND_EQ:
+ case DT_TOK_LSH_EQ:
+ case DT_TOK_RSH_EQ:
+ case DT_TOK_MOD_EQ:
+ if (lp->dn_kind == DT_NODE_IDENT) {
+ dt_xcook_ident(lp, dtp->dt_globals,
+ DT_IDENT_SCALAR, B_TRUE);
+ }
+
+ lp = dnp->dn_left =
+ dt_node_cook(lp, DT_IDFLG_REF | DT_IDFLG_MOD);
+
+ rp = dnp->dn_right =
+ dt_node_cook(rp, DT_IDFLG_REF | DT_IDFLG_MOD);
+
+ if (!dt_node_is_integer(lp) || !dt_node_is_integer(rp)) {
+ xyerror(D_OP_INT, "operator %s requires operands of "
+ "integral type\n", opstr(op));
+ }
+ goto asgn_common;
+
+ case DT_TOK_MUL_EQ:
+ case DT_TOK_DIV_EQ:
+ if (lp->dn_kind == DT_NODE_IDENT) {
+ dt_xcook_ident(lp, dtp->dt_globals,
+ DT_IDENT_SCALAR, B_TRUE);
+ }
+
+ lp = dnp->dn_left =
+ dt_node_cook(lp, DT_IDFLG_REF | DT_IDFLG_MOD);
+
+ rp = dnp->dn_right =
+ dt_node_cook(rp, DT_IDFLG_REF | DT_IDFLG_MOD);
+
+ if (!dt_node_is_arith(lp) || !dt_node_is_arith(rp)) {
+ xyerror(D_OP_ARITH, "operator %s requires operands of "
+ "arithmetic type\n", opstr(op));
+ }
+ goto asgn_common;
+
+ case DT_TOK_ASGN:
+ /*
+ * If the left-hand side is an identifier, attempt to resolve
+ * it as either an aggregation or scalar variable. We pass
+ * B_TRUE to dt_xcook_ident to indicate that a new variable can
+ * be created if no matching variable exists in the namespace.
+ */
+ if (lp->dn_kind == DT_NODE_IDENT) {
+ if (lp->dn_op == DT_TOK_AGG) {
+ dt_xcook_ident(lp, dtp->dt_aggs,
+ DT_IDENT_AGG, B_TRUE);
+ } else {
+ dt_xcook_ident(lp, dtp->dt_globals,
+ DT_IDENT_SCALAR, B_TRUE);
+ }
+ }
+
+ lp = dnp->dn_left = dt_node_cook(lp, 0); /* don't set mod yet */
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ /*
+ * If the left-hand side is an aggregation, verify that we are
+ * assigning it the result of an aggregating function. Once
+ * we've done so, hide the func node in the aggregation and
+ * return the aggregation itself up to the parse tree parent.
+ * This transformation is legal since the assigned function
+ * cannot change identity across disjoint cooking passes and
+ * the argument list subtree is retained for later cooking.
+ */
+ if (lp->dn_kind == DT_NODE_AGG) {
+ const char *aname = lp->dn_ident->di_name;
+ dt_ident_t *oid = lp->dn_ident->di_iarg;
+
+ if (rp->dn_kind != DT_NODE_FUNC ||
+ rp->dn_ident->di_kind != DT_IDENT_AGGFUNC) {
+ xyerror(D_AGG_FUNC,
+ "@%s must be assigned the result of "
+ "an aggregating function\n", aname);
+ }
+
+ if (oid != NULL && oid != rp->dn_ident) {
+ xyerror(D_AGG_REDEF,
+ "aggregation redefined: @%s\n\t "
+ "current: @%s = %s( )\n\tprevious: @%s = "
+ "%s( ) : line %d\n", aname, aname,
+ rp->dn_ident->di_name, aname, oid->di_name,
+ lp->dn_ident->di_lineno);
+ } else if (oid == NULL)
+ lp->dn_ident->di_iarg = rp->dn_ident;
+
+ /*
+ * Do not allow multiple aggregation assignments in a
+ * single statement, e.g. (@a = count()) = count();
+ * We produce a message as if the result of aggregating
+ * function does not propagate DT_NF_LVALUE.
+ */
+ if (lp->dn_aggfun != NULL) {
+ xyerror(D_OP_LVAL, "operator = requires "
+ "modifiable lvalue as an operand\n");
+ }
+
+ lp->dn_aggfun = rp;
+ lp = dt_node_cook(lp, DT_IDFLG_MOD);
+
+ dnp->dn_left = dnp->dn_right = NULL;
+ dt_node_free(dnp);
+
+ return (lp);
+ }
+
+ /*
+ * If the right-hand side is a dynamic variable that is the
+ * output of a translator, our result is the translated type.
+ */
+ if ((idp = dt_node_resolve(rp, DT_IDENT_XLSOU)) != NULL) {
+ ctfp = idp->di_ctfp;
+ type = idp->di_type;
+ uref = idp->di_flags & DT_IDFLG_USER;
+ } else {
+ ctfp = rp->dn_ctfp;
+ type = rp->dn_type;
+ uref = rp->dn_flags & DT_NF_USERLAND;
+ }
+
+ /*
+ * If the left-hand side of an assignment statement is a virgin
+ * variable created by this compilation pass, reset the type of
+ * this variable to the type of the right-hand side.
+ */
+ if (lp->dn_kind == DT_NODE_VAR &&
+ dt_ident_unref(lp->dn_ident)) {
+ dt_node_type_assign(lp, ctfp, type);
+ dt_ident_type_assign(lp->dn_ident, ctfp, type);
+
+ if (uref) {
+ lp->dn_flags |= DT_NF_USERLAND;
+ lp->dn_ident->di_flags |= DT_IDFLG_USER;
+ }
+ }
+
+ if (lp->dn_kind == DT_NODE_VAR)
+ lp->dn_ident->di_flags |= DT_IDFLG_MOD;
+
+ /*
+ * The rules for type checking for the assignment operators are
+ * described in the ANSI-C spec (see K&R[A7.17]). We share
+ * most of this code with the argument list checking code.
+ */
+ if (!dt_node_is_string(lp)) {
+ kind = ctf_type_kind(lp->dn_ctfp,
+ ctf_type_resolve(lp->dn_ctfp, lp->dn_type));
+
+ if (kind == CTF_K_ARRAY || kind == CTF_K_FUNCTION) {
+ xyerror(D_OP_ARRFUN, "operator %s may not be "
+ "applied to operand of type \"%s\"\n",
+ opstr(op),
+ dt_node_type_name(lp, n1, sizeof (n1)));
+ }
+ }
+
+ if (idp != NULL && idp->di_kind == DT_IDENT_XLSOU &&
+ ctf_type_compat(lp->dn_ctfp, lp->dn_type, ctfp, type))
+ goto asgn_common;
+
+ if (dt_node_is_argcompat(lp, rp))
+ goto asgn_common;
+
+ xyerror(D_OP_INCOMPAT,
+ "operands have incompatible types: \"%s\" %s \"%s\"\n",
+ dt_node_type_name(lp, n1, sizeof (n1)), opstr(op),
+ dt_node_type_name(rp, n2, sizeof (n2)));
+ /*NOTREACHED*/
+
+ case DT_TOK_ADD_EQ:
+ case DT_TOK_SUB_EQ:
+ if (lp->dn_kind == DT_NODE_IDENT) {
+ dt_xcook_ident(lp, dtp->dt_globals,
+ DT_IDENT_SCALAR, B_TRUE);
+ }
+
+ lp = dnp->dn_left =
+ dt_node_cook(lp, DT_IDFLG_REF | DT_IDFLG_MOD);
+
+ rp = dnp->dn_right =
+ dt_node_cook(rp, DT_IDFLG_REF | DT_IDFLG_MOD);
+
+ if (dt_node_is_string(lp) || dt_node_is_string(rp)) {
+ xyerror(D_OP_INCOMPAT, "operands have "
+ "incompatible types: \"%s\" %s \"%s\"\n",
+ dt_node_type_name(lp, n1, sizeof (n1)), opstr(op),
+ dt_node_type_name(rp, n2, sizeof (n2)));
+ }
+
+ /*
+ * The rules for type checking for the assignment operators are
+ * described in the ANSI-C spec (see K&R[A7.17]). To these
+ * rules we add that only writable D nodes can be modified.
+ */
+ if (dt_node_is_integer(lp) == 0 ||
+ dt_node_is_integer(rp) == 0) {
+ if (!dt_node_is_pointer(lp) || dt_node_is_vfptr(lp)) {
+ xyerror(D_OP_VFPTR,
+ "operator %s requires left-hand scalar "
+ "operand of known size\n", opstr(op));
+ } else if (dt_node_is_integer(rp) == 0 &&
+ dt_node_is_ptrcompat(lp, rp, NULL, NULL) == 0) {
+ xyerror(D_OP_INCOMPAT, "operands have "
+ "incompatible types: \"%s\" %s \"%s\"\n",
+ dt_node_type_name(lp, n1, sizeof (n1)),
+ opstr(op),
+ dt_node_type_name(rp, n2, sizeof (n2)));
+ }
+ }
+asgn_common:
+ if (!(lp->dn_flags & DT_NF_LVALUE)) {
+ xyerror(D_OP_LVAL, "operator %s requires modifiable "
+ "lvalue as an operand\n", opstr(op));
+ /* see K&R[A7.17] */
+ }
+
+ if (!(lp->dn_flags & DT_NF_WRITABLE)) {
+ xyerror(D_OP_WRITE, "operator %s can only be applied "
+ "to a writable variable\n", opstr(op));
+ }
+
+ dt_node_type_propagate(lp, dnp); /* see K&R[A7.17] */
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+
+ case DT_TOK_PTR:
+ /*
+ * If the left-hand side of operator -> is the name "self",
+ * then we permit a TLS variable to be created or referenced.
+ */
+ if (lp->dn_kind == DT_NODE_IDENT &&
+ strcmp(lp->dn_string, "self") == 0) {
+ if (rp->dn_kind != DT_NODE_VAR) {
+ dt_xcook_ident(rp, dtp->dt_tls,
+ DT_IDENT_SCALAR, B_TRUE);
+ }
+
+ if (idflags != 0)
+ rp = dt_node_cook(rp, idflags);
+
+ dnp->dn_right = dnp->dn_left; /* avoid freeing rp */
+ dt_node_free(dnp);
+ return (rp);
+ }
+
+ /*
+ * If the left-hand side of operator -> is the name "this",
+ * then we permit a local variable to be created or referenced.
+ */
+ if (lp->dn_kind == DT_NODE_IDENT &&
+ strcmp(lp->dn_string, "this") == 0) {
+ if (rp->dn_kind != DT_NODE_VAR) {
+ dt_xcook_ident(rp, yypcb->pcb_locals,
+ DT_IDENT_SCALAR, B_TRUE);
+ }
+
+ if (idflags != 0)
+ rp = dt_node_cook(rp, idflags);
+
+ dnp->dn_right = dnp->dn_left; /* avoid freeing rp */
+ dt_node_free(dnp);
+ return (rp);
+ }
+
+ RT_FALL_THRU();
+
+ case DT_TOK_DOT:
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+
+ if (rp->dn_kind != DT_NODE_IDENT) {
+ xyerror(D_OP_IDENT, "operator %s must be followed by "
+ "an identifier\n", opstr(op));
+ }
+
+ if ((idp = dt_node_resolve(lp, DT_IDENT_XLSOU)) != NULL ||
+ (idp = dt_node_resolve(lp, DT_IDENT_XLPTR)) != NULL) {
+ /*
+ * If the left-hand side is a translated struct or ptr,
+ * the type of the left is the translation output type.
+ */
+ dt_xlator_t *dxp = idp->di_data;
+
+ if (dt_xlator_member(dxp, rp->dn_string) == NULL) {
+ xyerror(D_XLATE_NOCONV,
+ "translator does not define conversion "
+ "for member: %s\n", rp->dn_string);
+ }
+
+ ctfp = idp->di_ctfp;
+ type = ctf_type_resolve(ctfp, idp->di_type);
+ uref = idp->di_flags & DT_IDFLG_USER;
+ } else {
+ ctfp = lp->dn_ctfp;
+ type = ctf_type_resolve(ctfp, lp->dn_type);
+ uref = lp->dn_flags & DT_NF_USERLAND;
+ }
+
+ kind = ctf_type_kind(ctfp, type);
+
+ if (op == DT_TOK_PTR) {
+ if (kind != CTF_K_POINTER) {
+ xyerror(D_OP_PTR, "operator %s must be "
+ "applied to a pointer\n", opstr(op));
+ }
+ type = ctf_type_reference(ctfp, type);
+ type = ctf_type_resolve(ctfp, type);
+ kind = ctf_type_kind(ctfp, type);
+ }
+
+ /*
+ * If we follow a reference to a forward declaration tag,
+ * search the entire type space for the actual definition.
+ */
+ while (kind == CTF_K_FORWARD) {
+ char *tag = ctf_type_name(ctfp, type, n1, sizeof (n1));
+ dtrace_typeinfo_t dtt;
+
+ if (tag != NULL && dt_type_lookup(tag, &dtt) == 0 &&
+ (dtt.dtt_ctfp != ctfp || dtt.dtt_type != type)) {
+ ctfp = dtt.dtt_ctfp;
+ type = ctf_type_resolve(ctfp, dtt.dtt_type);
+ kind = ctf_type_kind(ctfp, type);
+ } else {
+ xyerror(D_OP_INCOMPLETE,
+ "operator %s cannot be applied to a "
+ "forward declaration: no %s definition "
+ "is available\n", opstr(op), tag);
+ }
+ }
+
+ if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) {
+ if (op == DT_TOK_PTR) {
+ xyerror(D_OP_SOU, "operator -> cannot be "
+ "applied to pointer to type \"%s\"; must "
+ "be applied to a struct or union pointer\n",
+ ctf_type_name(ctfp, type, n1, sizeof (n1)));
+ } else {
+ xyerror(D_OP_SOU, "operator %s cannot be "
+ "applied to type \"%s\"; must be applied "
+ "to a struct or union\n", opstr(op),
+ ctf_type_name(ctfp, type, n1, sizeof (n1)));
+ }
+ }
+
+ if (ctf_member_info(ctfp, type, rp->dn_string, &m) == CTF_ERR) {
+ xyerror(D_TYPE_MEMBER,
+ "%s is not a member of %s\n", rp->dn_string,
+ ctf_type_name(ctfp, type, n1, sizeof (n1)));
+ }
+
+ type = ctf_type_resolve(ctfp, m.ctm_type);
+ kind = ctf_type_kind(ctfp, type);
+
+ dt_node_type_assign(dnp, ctfp, m.ctm_type);
+ dt_node_attr_assign(dnp, lp->dn_attr);
+
+ if (op == DT_TOK_PTR && (kind != CTF_K_ARRAY ||
+ dt_node_is_string(dnp)))
+ dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.3.3] */
+
+ if (op == DT_TOK_DOT && (lp->dn_flags & DT_NF_LVALUE) &&
+ (kind != CTF_K_ARRAY || dt_node_is_string(dnp)))
+ dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.3.3] */
+
+ if (lp->dn_flags & DT_NF_WRITABLE)
+ dnp->dn_flags |= DT_NF_WRITABLE;
+
+ if (uref && (kind == CTF_K_POINTER ||
+ (dnp->dn_flags & DT_NF_REF)))
+ dnp->dn_flags |= DT_NF_USERLAND;
+ break;
+
+ case DT_TOK_LBRAC: {
+ /*
+ * If op is DT_TOK_LBRAC, we know from the special-case code at
+ * the top that lp is either a D variable or an aggregation.
+ */
+ dt_node_t *lnp;
+
+ /*
+ * If the left-hand side is an aggregation, just set dn_aggtup
+ * to the right-hand side and return the cooked aggregation.
+ * This transformation is legal since we are just collapsing
+ * nodes to simplify later processing, and the entire aggtup
+ * parse subtree is retained for subsequent cooking passes.
+ */
+ if (lp->dn_kind == DT_NODE_AGG) {
+ if (lp->dn_aggtup != NULL) {
+ xyerror(D_AGG_MDIM, "improper attempt to "
+ "reference @%s as a multi-dimensional "
+ "array\n", lp->dn_ident->di_name);
+ }
+
+ lp->dn_aggtup = rp;
+ lp = dt_node_cook(lp, 0);
+
+ dnp->dn_left = dnp->dn_right = NULL;
+ dt_node_free(dnp);
+
+ return (lp);
+ }
+
+ assert(lp->dn_kind == DT_NODE_VAR);
+ idp = lp->dn_ident;
+
+ /*
+ * If the left-hand side is a non-global scalar that hasn't yet
+ * been referenced or modified, it was just created by self->
+ * or this-> and we can convert it from scalar to assoc array.
+ */
+ if (idp->di_kind == DT_IDENT_SCALAR && dt_ident_unref(idp) &&
+ (idp->di_flags & (DT_IDFLG_LOCAL | DT_IDFLG_TLS)) != 0) {
+
+ if (idp->di_flags & DT_IDFLG_LOCAL) {
+ xyerror(D_ARR_LOCAL,
+ "local variables may not be used as "
+ "associative arrays: %s\n", idp->di_name);
+ }
+
+ dt_dprintf("morph variable %s (id %u) from scalar to "
+ "array\n", idp->di_name, idp->di_id);
+
+ dt_ident_morph(idp, DT_IDENT_ARRAY,
+ &dt_idops_assc, NULL);
+ }
+
+ if (idp->di_kind != DT_IDENT_ARRAY) {
+ xyerror(D_IDENT_BADREF, "%s '%s' may not be referenced "
+ "as %s\n", dt_idkind_name(idp->di_kind),
+ idp->di_name, dt_idkind_name(DT_IDENT_ARRAY));
+ }
+
+ /*
+ * Now that we've confirmed our left-hand side is a DT_NODE_VAR
+ * of idkind DT_IDENT_ARRAY, we need to splice the [ node from
+ * the parse tree and leave a cooked DT_NODE_VAR in its place
+ * where dn_args for the VAR node is the right-hand 'rp' tree,
+ * as shown in the parse tree diagram below:
+ *
+ * / /
+ * [ OP2 "[" ]=dnp [ VAR ]=dnp
+ * / \ => |
+ * / \ +- dn_args -> [ ??? ]=rp
+ * [ VAR ]=lp [ ??? ]=rp
+ *
+ * Since the final dt_node_cook(dnp) can fail using longjmp we
+ * must perform the transformations as a group first by over-
+ * writing 'dnp' to become the VAR node, so that the parse tree
+ * is guaranteed to be in a consistent state if the cook fails.
+ */
+ assert(lp->dn_kind == DT_NODE_VAR);
+ assert(lp->dn_args == NULL);
+
+ lnp = dnp->dn_link;
+ bcopy(lp, dnp, sizeof (dt_node_t));
+ dnp->dn_link = lnp;
+
+ dnp->dn_args = rp;
+ dnp->dn_list = NULL;
+
+ dt_node_free(lp);
+ return (dt_node_cook(dnp, idflags));
+ }
+
+ case DT_TOK_XLATE: {
+ dt_xlator_t *dxp;
+
+ assert(lp->dn_kind == DT_NODE_TYPE);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+ dxp = dt_xlator_lookup(dtp, rp, lp, DT_XLATE_FUZZY);
+
+ if (dxp == NULL) {
+ xyerror(D_XLATE_NONE,
+ "cannot translate from \"%s\" to \"%s\"\n",
+ dt_node_type_name(rp, n1, sizeof (n1)),
+ dt_node_type_name(lp, n2, sizeof (n2)));
+ }
+
+ dnp->dn_ident = dt_xlator_ident(dxp, lp->dn_ctfp, lp->dn_type);
+ dt_node_type_assign(dnp, DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+ dt_node_attr_assign(dnp,
+ dt_attr_min(rp->dn_attr, dnp->dn_ident->di_attr));
+ break;
+ }
+
+ case DT_TOK_LPAR: {
+ ctf_id_t ltype, rtype;
+ uint_t lkind, rkind;
+
+ assert(lp->dn_kind == DT_NODE_TYPE);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ ltype = ctf_type_resolve(lp->dn_ctfp, lp->dn_type);
+ lkind = ctf_type_kind(lp->dn_ctfp, ltype);
+
+ rtype = ctf_type_resolve(rp->dn_ctfp, rp->dn_type);
+ rkind = ctf_type_kind(rp->dn_ctfp, rtype);
+
+ /*
+ * The rules for casting are loosely explained in K&R[A7.5]
+ * and K&R[A6]. Basically, we can cast to the same type or
+ * same base type, between any kind of scalar values, from
+ * arrays to pointers, and we can cast anything to void.
+ * To these rules D adds casts from scalars to strings.
+ */
+ if (ctf_type_compat(lp->dn_ctfp, lp->dn_type,
+ rp->dn_ctfp, rp->dn_type))
+ /*EMPTY*/;
+ else if (dt_node_is_scalar(lp) &&
+ (dt_node_is_scalar(rp) || rkind == CTF_K_FUNCTION))
+ /*EMPTY*/;
+ else if (dt_node_is_void(lp))
+ /*EMPTY*/;
+ else if (lkind == CTF_K_POINTER && dt_node_is_pointer(rp))
+ /*EMPTY*/;
+ else if (dt_node_is_string(lp) && (dt_node_is_scalar(rp) ||
+ dt_node_is_pointer(rp) || dt_node_is_strcompat(rp)))
+ /*EMPTY*/;
+ else {
+ xyerror(D_CAST_INVAL,
+ "invalid cast expression: \"%s\" to \"%s\"\n",
+ dt_node_type_name(rp, n1, sizeof (n1)),
+ dt_node_type_name(lp, n2, sizeof (n2)));
+ }
+
+ dt_node_type_propagate(lp, dnp); /* see K&R[A7.5] */
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+ }
+
+ case DT_TOK_COMMA:
+ lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
+
+ if (dt_node_is_dynamic(lp) || dt_node_is_dynamic(rp)) {
+ xyerror(D_OP_DYN, "operator %s operands "
+ "cannot be of dynamic type\n", opstr(op));
+ }
+
+ if (dt_node_is_actfunc(lp) || dt_node_is_actfunc(rp)) {
+ xyerror(D_OP_ACT, "operator %s operands "
+ "cannot be actions\n", opstr(op));
+ }
+
+ dt_node_type_propagate(rp, dnp); /* see K&R[A7.18] */
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ break;
+
+ default:
+ xyerror(D_UNKNOWN, "invalid binary op %s\n", opstr(op));
+ }
+
+ /*
+ * Complete the conversion of E1[E2] to *((E1)+(E2)) that we started
+ * at the top of our switch() above (see K&R[A7.3.1]). Since E2 is
+ * parsed as an argument_expression_list by dt_grammar.y, we can
+ * end up with a comma-separated list inside of a non-associative
+ * array reference. We check for this and report an appropriate error.
+ */
+ if (dnp->dn_op == DT_TOK_LBRAC && op == DT_TOK_ADD) {
+ dt_node_t *pnp;
+
+ if (rp->dn_list != NULL) {
+ xyerror(D_ARR_BADREF,
+ "cannot access %s as an associative array\n",
+ dt_node_name(lp, n1, sizeof (n1)));
+ }
+
+ dnp->dn_op = DT_TOK_ADD;
+ pnp = dt_node_op1(DT_TOK_DEREF, dnp);
+
+ /*
+ * Cook callbacks are not typically permitted to allocate nodes.
+ * When we do, we must insert them in the middle of an existing
+ * allocation list rather than having them appended to the pcb
+ * list because the sub-expression may be part of a definition.
+ */
+ assert(yypcb->pcb_list == pnp);
+ yypcb->pcb_list = pnp->dn_link;
+
+ pnp->dn_link = dnp->dn_link;
+ dnp->dn_link = pnp;
+
+ return (dt_node_cook(pnp, DT_IDFLG_REF));
+ }
+
+ return (dnp);
+}
+
+/*ARGSUSED*/
+static dt_node_t *
+dt_cook_op3(dt_node_t *dnp, uint_t idflags)
+{
+ dt_node_t *lp, *rp;
+ ctf_file_t *ctfp;
+ ctf_id_t type;
+ RT_NOREF1(idflags);
+
+ dnp->dn_expr = dt_node_cook(dnp->dn_expr, DT_IDFLG_REF);
+ lp = dnp->dn_left = dt_node_cook(dnp->dn_left, DT_IDFLG_REF);
+ rp = dnp->dn_right = dt_node_cook(dnp->dn_right, DT_IDFLG_REF);
+
+ if (!dt_node_is_scalar(dnp->dn_expr)) {
+ xyerror(D_OP_SCALAR,
+ "operator ?: expression must be of scalar type\n");
+ }
+
+ if (dt_node_is_dynamic(lp) || dt_node_is_dynamic(rp)) {
+ xyerror(D_OP_DYN,
+ "operator ?: operands cannot be of dynamic type\n");
+ }
+
+ /*
+ * The rules for type checking for the ternary operator are complex and
+ * are described in the ANSI-C spec (see K&R[A7.16]). We implement
+ * the various tests in order from least to most expensive.
+ */
+ if (ctf_type_compat(lp->dn_ctfp, lp->dn_type,
+ rp->dn_ctfp, rp->dn_type)) {
+ ctfp = lp->dn_ctfp;
+ type = lp->dn_type;
+ } else if (dt_node_is_integer(lp) && dt_node_is_integer(rp)) {
+ dt_type_promote(lp, rp, &ctfp, &type);
+ } else if (dt_node_is_strcompat(lp) && dt_node_is_strcompat(rp) &&
+ (dt_node_is_string(lp) || dt_node_is_string(rp))) {
+ ctfp = DT_STR_CTFP(yypcb->pcb_hdl);
+ type = DT_STR_TYPE(yypcb->pcb_hdl);
+ } else if (dt_node_is_ptrcompat(lp, rp, &ctfp, &type) == 0) {
+ xyerror(D_OP_INCOMPAT,
+ "operator ?: operands must have compatible types\n");
+ }
+
+ if (dt_node_is_actfunc(lp) || dt_node_is_actfunc(rp)) {
+ xyerror(D_OP_ACT, "action cannot be "
+ "used in a conditional context\n");
+ }
+
+ dt_node_type_assign(dnp, ctfp, type);
+ dt_node_attr_assign(dnp, dt_attr_min(dnp->dn_expr->dn_attr,
+ dt_attr_min(lp->dn_attr, rp->dn_attr)));
+
+ return (dnp);
+}
+
+static dt_node_t *
+dt_cook_statement(dt_node_t *dnp, uint_t idflags)
+{
+ dnp->dn_expr = dt_node_cook(dnp->dn_expr, idflags);
+ dt_node_attr_assign(dnp, dnp->dn_expr->dn_attr);
+
+ return (dnp);
+}
+
+/*
+ * If dn_aggfun is set, this node is a collapsed aggregation assignment (see
+ * the special case code for DT_TOK_ASGN in dt_cook_op2() above), in which
+ * case we cook both the tuple and the function call. If dn_aggfun is NULL,
+ * this node is just a reference to the aggregation's type and attributes.
+ */
+/*ARGSUSED*/
+static dt_node_t *
+dt_cook_aggregation(dt_node_t *dnp, uint_t idflags)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ RT_NOREF1(idflags);
+
+ if (dnp->dn_aggfun != NULL) {
+ dnp->dn_aggfun = dt_node_cook(dnp->dn_aggfun, DT_IDFLG_REF);
+ dt_node_attr_assign(dnp, dt_ident_cook(dnp,
+ dnp->dn_ident, &dnp->dn_aggtup));
+ } else {
+ dt_node_type_assign(dnp, DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+ dt_node_attr_assign(dnp, dnp->dn_ident->di_attr);
+ }
+
+ return (dnp);
+}
+
+/*
+ * Since D permits new variable identifiers to be instantiated in any program
+ * expression, we may need to cook a clause's predicate either before or after
+ * the action list depending on the program code in question. Consider:
+ *
+ * probe-description-list probe-description-list
+ * /x++/ /x == 0/
+ * { {
+ * trace(x); trace(x++);
+ * } }
+ *
+ * In the left-hand example, the predicate uses operator ++ to instantiate 'x'
+ * as a variable of type int64_t. The predicate must be cooked first because
+ * otherwise the statement trace(x) refers to an unknown identifier. In the
+ * right-hand example, the action list uses ++ to instantiate 'x'; the action
+ * list must be cooked first because otherwise the predicate x == 0 refers to
+ * an unknown identifier. In order to simplify programming, we support both.
+ *
+ * When cooking a clause, we cook the action statements before the predicate by
+ * default, since it seems more common to create or modify identifiers in the
+ * action list. If cooking fails due to an unknown identifier, we attempt to
+ * cook the predicate (i.e. do it first) and then go back and cook the actions.
+ * If this, too, fails (or if we get an error other than D_IDENT_UNDEF) we give
+ * up and report failure back to the user. There are five possible paths:
+ *
+ * cook actions = OK, cook predicate = OK -> OK
+ * cook actions = OK, cook predicate = ERR -> ERR
+ * cook actions = ERR, cook predicate = ERR -> ERR
+ * cook actions = ERR, cook predicate = OK, cook actions = OK -> OK
+ * cook actions = ERR, cook predicate = OK, cook actions = ERR -> ERR
+ *
+ * The programmer can still defeat our scheme by creating circular definition
+ * dependencies between predicates and actions, as in this example clause:
+ *
+ * probe-description-list
+ * /x++ && y == 0/
+ * {
+ * trace(x + y++);
+ * }
+ *
+ * but it doesn't seem worth the complexity to handle such rare cases. The
+ * user can simply use the D variable declaration syntax to work around them.
+ */
+static dt_node_t *
+dt_cook_clause(dt_node_t *dnp, uint_t idflags)
+{
+ volatile int err, tries;
+ jmp_buf ojb;
+
+ /*
+ * Before assigning dn_ctxattr, temporarily assign the probe attribute
+ * to 'dnp' itself to force an attribute check and minimum violation.
+ */
+ dt_node_attr_assign(dnp, yypcb->pcb_pinfo.dtp_attr);
+ dnp->dn_ctxattr = yypcb->pcb_pinfo.dtp_attr;
+
+ bcopy(yypcb->pcb_jmpbuf, ojb, sizeof (jmp_buf));
+ tries = 0;
+
+ if (dnp->dn_pred != NULL && (err = setjmp(yypcb->pcb_jmpbuf)) != 0) {
+ bcopy(ojb, yypcb->pcb_jmpbuf, sizeof (jmp_buf));
+ if (tries++ != 0 || err != EDT_COMPILER || (
+ yypcb->pcb_hdl->dt_errtag != dt_errtag(D_IDENT_UNDEF) &&
+ yypcb->pcb_hdl->dt_errtag != dt_errtag(D_VAR_UNDEF)))
+ longjmp(yypcb->pcb_jmpbuf, err);
+ }
+
+ if (tries == 0) {
+ yylabel("action list");
+
+ dt_node_attr_assign(dnp,
+ dt_node_list_cook(&dnp->dn_acts, idflags));
+
+ bcopy(ojb, yypcb->pcb_jmpbuf, sizeof (jmp_buf));
+ yylabel(NULL);
+ }
+
+ if (dnp->dn_pred != NULL) {
+ yylabel("predicate");
+
+ dnp->dn_pred = dt_node_cook(dnp->dn_pred, idflags);
+ dt_node_attr_assign(dnp,
+ dt_attr_min(dnp->dn_attr, dnp->dn_pred->dn_attr));
+
+ if (!dt_node_is_scalar(dnp->dn_pred)) {
+ xyerror(D_PRED_SCALAR,
+ "predicate result must be of scalar type\n");
+ }
+
+ yylabel(NULL);
+ }
+
+ if (tries != 0) {
+ yylabel("action list");
+
+ dt_node_attr_assign(dnp,
+ dt_node_list_cook(&dnp->dn_acts, idflags));
+
+ yylabel(NULL);
+ }
+
+ return (dnp);
+}
+
+/*ARGSUSED*/
+static dt_node_t *
+dt_cook_inline(dt_node_t *dnp, uint_t idflags)
+{
+ dt_idnode_t *inp = dnp->dn_ident->di_iarg;
+ dt_ident_t *rdp;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+ RT_NOREF1(idflags);
+
+ assert(dnp->dn_ident->di_flags & DT_IDFLG_INLINE);
+ assert(inp->din_root->dn_flags & DT_NF_COOKED);
+
+ /*
+ * If we are inlining a translation, verify that the inline declaration
+ * type exactly matches the type that is returned by the translation.
+ * Otherwise just use dt_node_is_argcompat() to check the types.
+ */
+ if ((rdp = dt_node_resolve(inp->din_root, DT_IDENT_XLSOU)) != NULL ||
+ (rdp = dt_node_resolve(inp->din_root, DT_IDENT_XLPTR)) != NULL) {
+
+ ctf_file_t *lctfp = dnp->dn_ctfp;
+ ctf_id_t ltype = ctf_type_resolve(lctfp, dnp->dn_type);
+
+ dt_xlator_t *dxp = rdp->di_data;
+ ctf_file_t *rctfp = dxp->dx_dst_ctfp;
+ ctf_id_t rtype = dxp->dx_dst_base;
+
+ if (ctf_type_kind(lctfp, ltype) == CTF_K_POINTER) {
+ ltype = ctf_type_reference(lctfp, ltype);
+ ltype = ctf_type_resolve(lctfp, ltype);
+ }
+
+ if (ctf_type_compat(lctfp, ltype, rctfp, rtype) == 0) {
+ dnerror(dnp, D_OP_INCOMPAT,
+ "inline %s definition uses incompatible types: "
+ "\"%s\" = \"%s\"\n", dnp->dn_ident->di_name,
+ dt_type_name(lctfp, ltype, n1, sizeof (n1)),
+ dt_type_name(rctfp, rtype, n2, sizeof (n2)));
+ }
+
+ } else if (dt_node_is_argcompat(dnp, inp->din_root) == 0) {
+ dnerror(dnp, D_OP_INCOMPAT,
+ "inline %s definition uses incompatible types: "
+ "\"%s\" = \"%s\"\n", dnp->dn_ident->di_name,
+ dt_node_type_name(dnp, n1, sizeof (n1)),
+ dt_node_type_name(inp->din_root, n2, sizeof (n2)));
+ }
+
+ return (dnp);
+}
+
+static dt_node_t *
+dt_cook_member(dt_node_t *dnp, uint_t idflags)
+{
+ dnp->dn_membexpr = dt_node_cook(dnp->dn_membexpr, idflags);
+ dt_node_attr_assign(dnp, dnp->dn_membexpr->dn_attr);
+ return (dnp);
+}
+
+/*ARGSUSED*/
+static dt_node_t *
+dt_cook_xlator(dt_node_t *dnp, uint_t idflags)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_xlator_t *dxp = dnp->dn_xlator;
+ dt_node_t *mnp;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ dtrace_attribute_t attr = _dtrace_maxattr;
+ ctf_membinfo_t ctm;
+ RT_NOREF1(idflags);
+
+ /*
+ * Before cooking each translator member, we push a reference to the
+ * hash containing translator-local identifiers on to pcb_globals to
+ * temporarily interpose these identifiers in front of other globals.
+ */
+ dt_idstack_push(&yypcb->pcb_globals, dxp->dx_locals);
+
+ for (mnp = dnp->dn_members; mnp != NULL; mnp = mnp->dn_list) {
+ if (ctf_member_info(dxp->dx_dst_ctfp, dxp->dx_dst_type,
+ mnp->dn_membname, &ctm) == CTF_ERR) {
+ xyerror(D_XLATE_MEMB,
+ "translator member %s is not a member of %s\n",
+ mnp->dn_membname, ctf_type_name(dxp->dx_dst_ctfp,
+ dxp->dx_dst_type, n1, sizeof (n1)));
+ }
+
+ (void) dt_node_cook(mnp, DT_IDFLG_REF);
+ dt_node_type_assign(mnp, dxp->dx_dst_ctfp, ctm.ctm_type);
+ attr = dt_attr_min(attr, mnp->dn_attr);
+
+ if (dt_node_is_argcompat(mnp, mnp->dn_membexpr) == 0) {
+ xyerror(D_XLATE_INCOMPAT,
+ "translator member %s definition uses "
+ "incompatible types: \"%s\" = \"%s\"\n",
+ mnp->dn_membname,
+ dt_node_type_name(mnp, n1, sizeof (n1)),
+ dt_node_type_name(mnp->dn_membexpr,
+ n2, sizeof (n2)));
+ }
+ }
+
+ dt_idstack_pop(&yypcb->pcb_globals, dxp->dx_locals);
+
+ dxp->dx_souid.di_attr = attr;
+ dxp->dx_ptrid.di_attr = attr;
+
+ dt_node_type_assign(dnp, DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+ dt_node_attr_assign(dnp, _dtrace_defattr);
+
+ return (dnp);
+}
+
+static void
+dt_node_provider_cmp_argv(dt_provider_t *pvp, dt_node_t *pnp, const char *kind,
+ uint_t old_argc, dt_node_t *old_argv, uint_t new_argc, dt_node_t *new_argv)
+{
+ dt_probe_t *prp = pnp->dn_ident->di_data;
+ uint_t i;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ if (old_argc != new_argc) {
+ dnerror(pnp, D_PROV_INCOMPAT,
+ "probe %s:%s %s prototype mismatch:\n"
+ "\t current: %u arg%s\n\tprevious: %u arg%s\n",
+ pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, kind,
+ new_argc, new_argc != 1 ? "s" : "",
+ old_argc, old_argc != 1 ? "s" : "");
+ }
+
+ for (i = 0; i < old_argc; i++,
+ old_argv = old_argv->dn_list, new_argv = new_argv->dn_list) {
+ if (ctf_type_cmp(old_argv->dn_ctfp, old_argv->dn_type,
+ new_argv->dn_ctfp, new_argv->dn_type) == 0)
+ continue;
+
+ dnerror(pnp, D_PROV_INCOMPAT,
+ "probe %s:%s %s prototype argument #%u mismatch:\n"
+ "\t current: %s\n\tprevious: %s\n",
+ pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, kind, i + 1,
+ dt_node_type_name(new_argv, n1, sizeof (n1)),
+ dt_node_type_name(old_argv, n2, sizeof (n2)));
+ }
+}
+
+/*
+ * Compare a new probe declaration with an existing probe definition (either
+ * from a previous declaration or cached from the kernel). If the existing
+ * definition and declaration both have an input and output parameter list,
+ * compare both lists. Otherwise compare only the output parameter lists.
+ */
+static void
+dt_node_provider_cmp(dt_provider_t *pvp, dt_node_t *pnp,
+ dt_probe_t *old, dt_probe_t *new)
+{
+ dt_node_provider_cmp_argv(pvp, pnp, "output",
+ old->pr_xargc, old->pr_xargs, new->pr_xargc, new->pr_xargs);
+
+ if (old->pr_nargs != old->pr_xargs && new->pr_nargs != new->pr_xargs) {
+ dt_node_provider_cmp_argv(pvp, pnp, "input",
+ old->pr_nargc, old->pr_nargs, new->pr_nargc, new->pr_nargs);
+ }
+
+ if (old->pr_nargs == old->pr_xargs && new->pr_nargs != new->pr_xargs) {
+ if (pvp->pv_flags & DT_PROVIDER_IMPL) {
+ dnerror(pnp, D_PROV_INCOMPAT,
+ "provider interface mismatch: %s\n"
+ "\t current: probe %s:%s has an output prototype\n"
+ "\tprevious: probe %s:%s has no output prototype\n",
+ pvp->pv_desc.dtvd_name, pvp->pv_desc.dtvd_name,
+ new->pr_ident->di_name, pvp->pv_desc.dtvd_name,
+ old->pr_ident->di_name);
+ }
+
+ if (old->pr_ident->di_gen == yypcb->pcb_hdl->dt_gen)
+ old->pr_ident->di_flags |= DT_IDFLG_ORPHAN;
+
+ dt_idhash_delete(pvp->pv_probes, old->pr_ident);
+ dt_probe_declare(pvp, new);
+ }
+}
+
+static void
+dt_cook_probe(dt_node_t *dnp, dt_provider_t *pvp)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_probe_t *prp = dnp->dn_ident->di_data;
+
+ dt_xlator_t *dxp;
+ uint_t i;
+
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ if (prp->pr_nargs == prp->pr_xargs)
+ return;
+
+ for (i = 0; i < prp->pr_xargc; i++) {
+ dt_node_t *xnp = prp->pr_xargv[i];
+ dt_node_t *nnp = prp->pr_nargv[prp->pr_mapping[i]];
+
+ if ((dxp = dt_xlator_lookup(dtp,
+ nnp, xnp, DT_XLATE_FUZZY)) != NULL) {
+ if (dt_provider_xref(dtp, pvp, dxp->dx_id) != 0)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ continue;
+ }
+
+ if (dt_node_is_argcompat(nnp, xnp))
+ continue; /* no translator defined and none required */
+
+ dnerror(dnp, D_PROV_PRXLATOR, "translator for %s:%s output "
+ "argument #%u from %s to %s is not defined\n",
+ pvp->pv_desc.dtvd_name, dnp->dn_ident->di_name, i + 1,
+ dt_node_type_name(nnp, n1, sizeof (n1)),
+ dt_node_type_name(xnp, n2, sizeof (n2)));
+ }
+}
+
+/*ARGSUSED*/
+static dt_node_t *
+dt_cook_provider(dt_node_t *dnp, uint_t idflags)
+{
+ dt_provider_t *pvp = dnp->dn_provider;
+ dt_node_t *pnp;
+ RT_NOREF1(idflags);
+
+ /*
+ * If we're declaring a provider for the first time and it is unknown
+ * to dtrace(7D), insert the probe definitions into the provider's hash.
+ * If we're redeclaring a known provider, verify the interface matches.
+ */
+ for (pnp = dnp->dn_probes; pnp != NULL; pnp = pnp->dn_list) {
+ const char *probename = pnp->dn_ident->di_name;
+ dt_probe_t *prp = dt_probe_lookup(pvp, probename);
+
+ assert(pnp->dn_kind == DT_NODE_PROBE);
+
+ if (prp != NULL && dnp->dn_provred) {
+ dt_node_provider_cmp(pvp, pnp,
+ prp, pnp->dn_ident->di_data);
+ } else if (prp == NULL && dnp->dn_provred) {
+ dnerror(pnp, D_PROV_INCOMPAT,
+ "provider interface mismatch: %s\n"
+ "\t current: probe %s:%s defined\n"
+ "\tprevious: probe %s:%s not defined\n",
+ dnp->dn_provname, dnp->dn_provname,
+ probename, dnp->dn_provname, probename);
+ } else if (prp != NULL) {
+ dnerror(pnp, D_PROV_PRDUP, "probe redeclared: %s:%s\n",
+ dnp->dn_provname, probename);
+ } else
+ dt_probe_declare(pvp, pnp->dn_ident->di_data);
+
+ dt_cook_probe(pnp, pvp);
+ }
+
+ return (dnp);
+}
+
+/*ARGSUSED*/
+static dt_node_t *
+dt_cook_none(dt_node_t *dnp, uint_t idflags)
+{
+ RT_NOREF1(idflags);
+ return (dnp);
+}
+
+static dt_node_t *(*dt_cook_funcs[])(dt_node_t *, uint_t) = {
+ dt_cook_none, /* DT_NODE_FREE */
+ dt_cook_none, /* DT_NODE_INT */
+ dt_cook_none, /* DT_NODE_STRING */
+ dt_cook_ident, /* DT_NODE_IDENT */
+ dt_cook_var, /* DT_NODE_VAR */
+ dt_cook_none, /* DT_NODE_SYM */
+ dt_cook_none, /* DT_NODE_TYPE */
+ dt_cook_func, /* DT_NODE_FUNC */
+ dt_cook_op1, /* DT_NODE_OP1 */
+ dt_cook_op2, /* DT_NODE_OP2 */
+ dt_cook_op3, /* DT_NODE_OP3 */
+ dt_cook_statement, /* DT_NODE_DEXPR */
+ dt_cook_statement, /* DT_NODE_DFUNC */
+ dt_cook_aggregation, /* DT_NODE_AGG */
+ dt_cook_none, /* DT_NODE_PDESC */
+ dt_cook_clause, /* DT_NODE_CLAUSE */
+ dt_cook_inline, /* DT_NODE_INLINE */
+ dt_cook_member, /* DT_NODE_MEMBER */
+ dt_cook_xlator, /* DT_NODE_XLATOR */
+ dt_cook_none, /* DT_NODE_PROBE */
+ dt_cook_provider, /* DT_NODE_PROVIDER */
+ dt_cook_none /* DT_NODE_PROG */
+};
+
+/*
+ * Recursively cook the parse tree starting at the specified node. The idflags
+ * parameter is used to indicate the type of reference (r/w) and is applied to
+ * the resulting identifier if it is a D variable or D aggregation.
+ */
+dt_node_t *
+dt_node_cook(dt_node_t *dnp, uint_t idflags)
+{
+ int oldlineno = yylineno;
+
+ yylineno = dnp->dn_line;
+
+ dnp = dt_cook_funcs[dnp->dn_kind](dnp, idflags);
+ dnp->dn_flags |= DT_NF_COOKED;
+
+ if (dnp->dn_kind == DT_NODE_VAR || dnp->dn_kind == DT_NODE_AGG)
+ dnp->dn_ident->di_flags |= idflags;
+
+ yylineno = oldlineno;
+ return (dnp);
+}
+
+dtrace_attribute_t
+dt_node_list_cook(dt_node_t **pnp, uint_t idflags)
+{
+ dtrace_attribute_t attr = _dtrace_defattr;
+ dt_node_t *dnp, *nnp;
+
+ for (dnp = (pnp != NULL ? *pnp : NULL); dnp != NULL; dnp = nnp) {
+ nnp = dnp->dn_list;
+ dnp = *pnp = dt_node_cook(dnp, idflags);
+ attr = dt_attr_min(attr, dnp->dn_attr);
+ dnp->dn_list = nnp;
+ pnp = &dnp->dn_list;
+ }
+
+ return (attr);
+}
+
+void
+dt_node_list_free(dt_node_t **pnp)
+{
+ dt_node_t *dnp, *nnp;
+
+ for (dnp = (pnp != NULL ? *pnp : NULL); dnp != NULL; dnp = nnp) {
+ nnp = dnp->dn_list;
+ dt_node_free(dnp);
+ }
+
+ if (pnp != NULL)
+ *pnp = NULL;
+}
+
+void
+dt_node_link_free(dt_node_t **pnp)
+{
+ dt_node_t *dnp, *nnp;
+
+ for (dnp = (pnp != NULL ? *pnp : NULL); dnp != NULL; dnp = nnp) {
+ nnp = dnp->dn_link;
+ dt_node_free(dnp);
+ }
+
+ for (dnp = (pnp != NULL ? *pnp : NULL); dnp != NULL; dnp = nnp) {
+ nnp = dnp->dn_link;
+ free(dnp);
+ }
+
+ if (pnp != NULL)
+ *pnp = NULL;
+}
+
+dt_node_t *
+dt_node_link(dt_node_t *lp, dt_node_t *rp)
+{
+ dt_node_t *dnp;
+
+ if (lp == NULL)
+ return (rp);
+ else if (rp == NULL)
+ return (lp);
+
+ for (dnp = lp; dnp->dn_list != NULL; dnp = dnp->dn_list)
+ continue;
+
+ dnp->dn_list = rp;
+ return (lp);
+}
+
+/*
+ * Compute the DOF dtrace_diftype_t representation of a node's type. This is
+ * called from a variety of places in the library so it cannot assume yypcb
+ * is valid: any references to handle-specific data must be made through 'dtp'.
+ */
+void
+dt_node_diftype(dtrace_hdl_t *dtp, const dt_node_t *dnp, dtrace_diftype_t *tp)
+{
+ if (dnp->dn_ctfp == DT_STR_CTFP(dtp) &&
+ dnp->dn_type == DT_STR_TYPE(dtp)) {
+ tp->dtdt_kind = DIF_TYPE_STRING;
+ tp->dtdt_ckind = CTF_K_UNKNOWN;
+ } else {
+ tp->dtdt_kind = DIF_TYPE_CTF;
+ tp->dtdt_ckind = ctf_type_kind(dnp->dn_ctfp,
+ ctf_type_resolve(dnp->dn_ctfp, dnp->dn_type));
+ }
+
+ tp->dtdt_flags = (dnp->dn_flags & DT_NF_REF) ? DIF_TF_BYREF : 0;
+ tp->dtdt_pad = 0;
+ tp->dtdt_size = ctf_type_size(dnp->dn_ctfp, dnp->dn_type);
+}
+
+void
+dt_node_printr(dt_node_t *dnp, FILE *fp, int depth)
+{
+ char n[DT_TYPE_NAMELEN], buf[BUFSIZ], a[8];
+ const dtrace_syminfo_t *dts;
+ const dt_idnode_t *inp;
+ dt_node_t *arg;
+
+ (void) fprintf(fp, "%*s", depth * 2, "");
+ (void) dt_attr_str(dnp->dn_attr, a, sizeof (a));
+
+ if (dnp->dn_ctfp != NULL && dnp->dn_type != CTF_ERR &&
+ ctf_type_name(dnp->dn_ctfp, dnp->dn_type, n, sizeof (n)) != NULL) {
+ (void) snprintf(buf, BUFSIZ, "type=<%s> attr=%s flags=", n, a);
+ } else {
+ (void) snprintf(buf, BUFSIZ, "type=<%ld> attr=%s flags=",
+ dnp->dn_type, a);
+ }
+
+ if (dnp->dn_flags != 0) {
+ n[0] = '\0';
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ (void) strcat(n, ",SIGN");
+ if (dnp->dn_flags & DT_NF_COOKED)
+ (void) strcat(n, ",COOK");
+ if (dnp->dn_flags & DT_NF_REF)
+ (void) strcat(n, ",REF");
+ if (dnp->dn_flags & DT_NF_LVALUE)
+ (void) strcat(n, ",LVAL");
+ if (dnp->dn_flags & DT_NF_WRITABLE)
+ (void) strcat(n, ",WRITE");
+ if (dnp->dn_flags & DT_NF_BITFIELD)
+ (void) strcat(n, ",BITF");
+ if (dnp->dn_flags & DT_NF_USERLAND)
+ (void) strcat(n, ",USER");
+ (void) strcat(buf, n + 1);
+ } else
+ (void) strcat(buf, "0");
+
+ switch (dnp->dn_kind) {
+ case DT_NODE_FREE:
+ (void) fprintf(fp, "FREE <node %p>\n", (void *)dnp);
+ break;
+
+ case DT_NODE_INT:
+ (void) fprintf(fp, "INT 0x%llx (%s)\n",
+ (u_longlong_t)dnp->dn_value, buf);
+ break;
+
+ case DT_NODE_STRING:
+ (void) fprintf(fp, "STRING \"%s\" (%s)\n", dnp->dn_string, buf);
+ break;
+
+ case DT_NODE_IDENT:
+ (void) fprintf(fp, "IDENT %s (%s)\n", dnp->dn_string, buf);
+ break;
+
+ case DT_NODE_VAR:
+ (void) fprintf(fp, "VARIABLE %s%s (%s)\n",
+ (dnp->dn_ident->di_flags & DT_IDFLG_LOCAL) ? "this->" :
+ (dnp->dn_ident->di_flags & DT_IDFLG_TLS) ? "self->" : "",
+ dnp->dn_ident->di_name, buf);
+
+ if (dnp->dn_args != NULL)
+ (void) fprintf(fp, "%*s[\n", depth * 2, "");
+
+ for (arg = dnp->dn_args; arg != NULL; arg = arg->dn_list) {
+ dt_node_printr(arg, fp, depth + 1);
+ if (arg->dn_list != NULL)
+ (void) fprintf(fp, "%*s,\n", depth * 2, "");
+ }
+
+ if (dnp->dn_args != NULL)
+ (void) fprintf(fp, "%*s]\n", depth * 2, "");
+ break;
+
+ case DT_NODE_SYM:
+ dts = dnp->dn_ident->di_data;
+ (void) fprintf(fp, "SYMBOL %s`%s (%s)\n",
+ dts->dts_object, dts->dts_name, buf);
+ break;
+
+ case DT_NODE_TYPE:
+ if (dnp->dn_string != NULL) {
+ (void) fprintf(fp, "TYPE (%s) %s\n",
+ buf, dnp->dn_string);
+ } else
+ (void) fprintf(fp, "TYPE (%s)\n", buf);
+ break;
+
+ case DT_NODE_FUNC:
+ (void) fprintf(fp, "FUNC %s (%s)\n",
+ dnp->dn_ident->di_name, buf);
+
+ for (arg = dnp->dn_args; arg != NULL; arg = arg->dn_list) {
+ dt_node_printr(arg, fp, depth + 1);
+ if (arg->dn_list != NULL)
+ (void) fprintf(fp, "%*s,\n", depth * 2, "");
+ }
+ break;
+
+ case DT_NODE_OP1:
+ (void) fprintf(fp, "OP1 %s (%s)\n", opstr(dnp->dn_op), buf);
+ dt_node_printr(dnp->dn_child, fp, depth + 1);
+ break;
+
+ case DT_NODE_OP2:
+ (void) fprintf(fp, "OP2 %s (%s)\n", opstr(dnp->dn_op), buf);
+ dt_node_printr(dnp->dn_left, fp, depth + 1);
+ dt_node_printr(dnp->dn_right, fp, depth + 1);
+ break;
+
+ case DT_NODE_OP3:
+ (void) fprintf(fp, "OP3 (%s)\n", buf);
+ dt_node_printr(dnp->dn_expr, fp, depth + 1);
+ (void) fprintf(fp, "%*s?\n", depth * 2, "");
+ dt_node_printr(dnp->dn_left, fp, depth + 1);
+ (void) fprintf(fp, "%*s:\n", depth * 2, "");
+ dt_node_printr(dnp->dn_right, fp, depth + 1);
+ break;
+
+ case DT_NODE_DEXPR:
+ case DT_NODE_DFUNC:
+ (void) fprintf(fp, "D EXPRESSION attr=%s\n", a);
+ dt_node_printr(dnp->dn_expr, fp, depth + 1);
+ break;
+
+ case DT_NODE_AGG:
+ (void) fprintf(fp, "AGGREGATE @%s attr=%s [\n",
+ dnp->dn_ident->di_name, a);
+
+ for (arg = dnp->dn_aggtup; arg != NULL; arg = arg->dn_list) {
+ dt_node_printr(arg, fp, depth + 1);
+ if (arg->dn_list != NULL)
+ (void) fprintf(fp, "%*s,\n", depth * 2, "");
+ }
+
+ if (dnp->dn_aggfun) {
+ (void) fprintf(fp, "%*s] = ", depth * 2, "");
+ dt_node_printr(dnp->dn_aggfun, fp, depth + 1);
+ } else
+ (void) fprintf(fp, "%*s]\n", depth * 2, "");
+
+ if (dnp->dn_aggfun)
+ (void) fprintf(fp, "%*s)\n", depth * 2, "");
+ break;
+
+ case DT_NODE_PDESC:
+ (void) fprintf(fp, "PDESC %s:%s:%s:%s [%u]\n",
+ dnp->dn_desc->dtpd_provider, dnp->dn_desc->dtpd_mod,
+ dnp->dn_desc->dtpd_func, dnp->dn_desc->dtpd_name,
+ dnp->dn_desc->dtpd_id);
+ break;
+
+ case DT_NODE_CLAUSE:
+ (void) fprintf(fp, "CLAUSE attr=%s\n", a);
+
+ for (arg = dnp->dn_pdescs; arg != NULL; arg = arg->dn_list)
+ dt_node_printr(arg, fp, depth + 1);
+
+ (void) fprintf(fp, "%*sCTXATTR %s\n", depth * 2, "",
+ dt_attr_str(dnp->dn_ctxattr, a, sizeof (a)));
+
+ if (dnp->dn_pred != NULL) {
+ (void) fprintf(fp, "%*sPREDICATE /\n", depth * 2, "");
+ dt_node_printr(dnp->dn_pred, fp, depth + 1);
+ (void) fprintf(fp, "%*s/\n", depth * 2, "");
+ }
+
+ for (arg = dnp->dn_acts; arg != NULL; arg = arg->dn_list)
+ dt_node_printr(arg, fp, depth + 1);
+ break;
+
+ case DT_NODE_INLINE:
+ inp = dnp->dn_ident->di_iarg;
+
+ (void) fprintf(fp, "INLINE %s (%s)\n",
+ dnp->dn_ident->di_name, buf);
+ dt_node_printr(inp->din_root, fp, depth + 1);
+ break;
+
+ case DT_NODE_MEMBER:
+ (void) fprintf(fp, "MEMBER %s (%s)\n", dnp->dn_membname, buf);
+ if (dnp->dn_membexpr)
+ dt_node_printr(dnp->dn_membexpr, fp, depth + 1);
+ break;
+
+ case DT_NODE_XLATOR:
+ (void) fprintf(fp, "XLATOR (%s)", buf);
+
+ if (ctf_type_name(dnp->dn_xlator->dx_src_ctfp,
+ dnp->dn_xlator->dx_src_type, n, sizeof (n)) != NULL)
+ (void) fprintf(fp, " from <%s>", n);
+
+ if (ctf_type_name(dnp->dn_xlator->dx_dst_ctfp,
+ dnp->dn_xlator->dx_dst_type, n, sizeof (n)) != NULL)
+ (void) fprintf(fp, " to <%s>", n);
+
+ (void) fprintf(fp, "\n");
+
+ for (arg = dnp->dn_members; arg != NULL; arg = arg->dn_list)
+ dt_node_printr(arg, fp, depth + 1);
+ break;
+
+ case DT_NODE_PROBE:
+ (void) fprintf(fp, "PROBE %s\n", dnp->dn_ident->di_name);
+ break;
+
+ case DT_NODE_PROVIDER:
+ (void) fprintf(fp, "PROVIDER %s (%s)\n",
+ dnp->dn_provname, dnp->dn_provred ? "redecl" : "decl");
+ for (arg = dnp->dn_probes; arg != NULL; arg = arg->dn_list)
+ dt_node_printr(arg, fp, depth + 1);
+ break;
+
+ case DT_NODE_PROG:
+ (void) fprintf(fp, "PROGRAM attr=%s\n", a);
+ for (arg = dnp->dn_list; arg != NULL; arg = arg->dn_list)
+ dt_node_printr(arg, fp, depth + 1);
+ break;
+
+ default:
+ (void) fprintf(fp, "<bad node %p, kind %d>\n",
+ (void *)dnp, dnp->dn_kind);
+ }
+}
+
+int
+dt_node_root(dt_node_t *dnp)
+{
+ yypcb->pcb_root = dnp;
+ return (0);
+}
+
+/*PRINTFLIKE3*/
+DECL_NO_RETURN(void)
+dnerror(const dt_node_t *dnp, dt_errtag_t tag, const char *format, ...)
+{
+ int oldlineno = yylineno;
+ va_list ap;
+
+ yylineno = dnp->dn_line;
+
+ va_start(ap, format);
+ xyvwarn(tag, format, ap);
+ va_end(ap);
+
+ yylineno = oldlineno;
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+}
+
+/*PRINTFLIKE3*/
+void
+dnwarn(const dt_node_t *dnp, dt_errtag_t tag, const char *format, ...)
+{
+ int oldlineno = yylineno;
+ va_list ap;
+
+ yylineno = dnp->dn_line;
+
+ va_start(ap, format);
+ xyvwarn(tag, format, ap);
+ va_end(ap);
+
+ yylineno = oldlineno;
+}
+
+/*PRINTFLIKE2*/
+DECL_NO_RETURN(void)
+xyerror(dt_errtag_t tag, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xyvwarn(tag, format, ap);
+ va_end(ap);
+
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+}
+
+/*PRINTFLIKE2*/
+void
+xywarn(dt_errtag_t tag, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xyvwarn(tag, format, ap);
+ va_end(ap);
+}
+
+void
+xyvwarn(dt_errtag_t tag, const char *format, va_list ap)
+{
+ if (yypcb == NULL)
+ return; /* compiler is not currently active: act as a no-op */
+
+ dt_set_errmsg(yypcb->pcb_hdl, dt_errtag(tag), yypcb->pcb_region,
+ yypcb->pcb_filetag, yypcb->pcb_fileptr ? yylineno : 0, format, ap);
+}
+
+/*PRINTFLIKE1*/
+DECL_NO_RETURN(void)
+yyerror(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ yyvwarn(format, ap);
+ va_end(ap);
+
+ longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
+}
+
+/*PRINTFLIKE1*/
+void
+yywarn(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ yyvwarn(format, ap);
+ va_end(ap);
+}
+
+void
+yyvwarn(const char *format, va_list ap)
+{
+ if (yypcb == NULL)
+ return; /* compiler is not currently active: act as a no-op */
+
+ dt_set_errmsg(yypcb->pcb_hdl, dt_errtag(D_SYNTAX), yypcb->pcb_region,
+ yypcb->pcb_filetag, yypcb->pcb_fileptr ? yylineno : 0, format, ap);
+
+ if (strchr(format, '\n') == NULL) {
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ size_t len = strlen(dtp->dt_errmsg);
+ char *p, *s = dtp->dt_errmsg + len;
+ size_t n = sizeof (dtp->dt_errmsg) - len;
+
+ if (yytext[0] == '\0')
+ (void) snprintf(s, n, " near end of input");
+ else if (yytext[0] == '\n')
+ (void) snprintf(s, n, " near end of line");
+ else {
+ if ((p = strchr(yytext, '\n')) != NULL)
+ *p = '\0'; /* crop at newline */
+ (void) snprintf(s, n, " near \"%s\"", yytext);
+ }
+ }
+}
+
+void
+yylabel(const char *label)
+{
+ dt_dprintf("set label to <%s>\n", label ? label : "NULL");
+ yypcb->pcb_region = label;
+}
+
+int
+yywrap(void)
+{
+ return (1); /* indicate that lex should return a zero token for EOF */
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.h
new file mode 100644
index 00000000..cad26da9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.h
@@ -0,0 +1,290 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_PARSER_H
+#define _DT_PARSER_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/dtrace.h>
+
+#include <libctf.h>
+#include <stdarg.h>
+#include <stdio.h>
+#else /* VBOX */
+# include <sys/dtrace.h>
+# include <stdio.h>
+#endif /* VBOX */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dt_errtags.h>
+#include <dt_ident.h>
+#include <dt_decl.h>
+#include <dt_xlator.h>
+#include <dt_list.h>
+
+typedef struct dt_node {
+ ctf_file_t *dn_ctfp; /* CTF type container for node's type */
+ ctf_id_t dn_type; /* CTF type reference for node's type */
+ uchar_t dn_kind; /* node kind (DT_NODE_*, defined below) */
+ uchar_t dn_flags; /* node flags (DT_NF_*, defined below) */
+ ushort_t dn_op; /* operator (DT_TOK_*, defined by lex) */
+ int dn_line; /* line number for error messages */
+ int dn_reg; /* register allocated by cg */
+ dtrace_attribute_t dn_attr; /* node stability attributes */
+
+ /*
+ * D compiler nodes, as is the usual style, contain a union of the
+ * different sub-elements required by the various kinds of nodes.
+ * These sub-elements are accessed using the macros defined below.
+ */
+ union {
+ struct {
+ uintmax_t _value; /* integer value */
+ char *_string; /* string value */
+ } _const;
+
+ struct {
+ dt_ident_t *_ident; /* identifier reference */
+ struct dt_node *_links[3]; /* child node pointers */
+ } _nodes;
+
+ struct {
+ struct dt_node *_descs; /* list of descriptions */
+ struct dt_node *_pred; /* predicate expression */
+ struct dt_node *_acts; /* action statement list */
+ dt_idhash_t *_locals; /* local variable hash */
+ dtrace_attribute_t _attr; /* context attributes */
+ } _clause;
+
+ struct {
+ char *_spec; /* specifier string (if any) */
+ dtrace_probedesc_t *_desc; /* final probe description */
+ } _pdesc;
+
+ struct {
+ char *_name; /* string name of member */
+ struct dt_node *_expr; /* expression node pointer */
+ dt_xlator_t *_xlator; /* translator reference */
+ uint_t _id; /* member identifier */
+ } _member;
+
+ struct {
+ dt_xlator_t *_xlator; /* translator reference */
+ struct dt_node *_xmemb; /* individual xlator member */
+ struct dt_node *_membs; /* list of member nodes */
+ } _xlator;
+
+ struct {
+ char *_name; /* string name of provider */
+ struct dt_provider *_pvp; /* provider references */
+ struct dt_node *_probes; /* list of probe nodes */
+ int _redecl; /* provider redeclared */
+ } _provider;
+ } dn_u;
+
+ struct dt_node *dn_list; /* parse tree list link */
+ struct dt_node *dn_link; /* allocation list link */
+} dt_node_t;
+
+#define dn_value dn_u._const._value /* DT_NODE_INT */
+#define dn_string dn_u._const._string /* STRING, IDENT, TYPE */
+#define dn_ident dn_u._nodes._ident /* VAR,SYM,FUN,AGG,INL,PROBE */
+#define dn_args dn_u._nodes._links[0] /* DT_NODE_VAR, FUNC */
+#define dn_child dn_u._nodes._links[0] /* DT_NODE_OP1 */
+#define dn_left dn_u._nodes._links[0] /* DT_NODE_OP2, OP3 */
+#define dn_right dn_u._nodes._links[1] /* DT_NODE_OP2, OP3 */
+#define dn_expr dn_u._nodes._links[2] /* DT_NODE_OP3, DEXPR */
+#define dn_aggfun dn_u._nodes._links[0] /* DT_NODE_AGG */
+#define dn_aggtup dn_u._nodes._links[1] /* DT_NODE_AGG */
+#define dn_pdescs dn_u._clause._descs /* DT_NODE_CLAUSE */
+#define dn_pred dn_u._clause._pred /* DT_NODE_CLAUSE */
+#define dn_acts dn_u._clause._acts /* DT_NODE_CLAUSE */
+#define dn_locals dn_u._clause._locals /* DT_NODE_CLAUSE */
+#define dn_ctxattr dn_u._clause._attr /* DT_NODE_CLAUSE */
+#define dn_spec dn_u._pdesc._spec /* DT_NODE_PDESC */
+#define dn_desc dn_u._pdesc._desc /* DT_NODE_PDESC */
+#define dn_membname dn_u._member._name /* DT_NODE_MEMBER */
+#define dn_membexpr dn_u._member._expr /* DT_NODE_MEMBER */
+#define dn_membxlator dn_u._member._xlator /* DT_NODE_MEMBER */
+#define dn_membid dn_u._member._id /* DT_NODE_MEMBER */
+#define dn_xlator dn_u._xlator._xlator /* DT_NODE_XLATOR */
+#define dn_xmember dn_u._xlator._xmemb /* DT_NODE_XLATOR */
+#define dn_members dn_u._xlator._membs /* DT_NODE_XLATOR */
+#define dn_provname dn_u._provider._name /* DT_NODE_PROVIDER */
+#define dn_provider dn_u._provider._pvp /* DT_NODE_PROVIDER */
+#define dn_provred dn_u._provider._redecl /* DT_NODE_PROVIDER */
+#define dn_probes dn_u._provider._probes /* DT_NODE_PROVIDER */
+
+#define DT_NODE_FREE 0 /* unused node (waiting to be freed) */
+#define DT_NODE_INT 1 /* integer value */
+#define DT_NODE_STRING 2 /* string value */
+#define DT_NODE_IDENT 3 /* identifier */
+#define DT_NODE_VAR 4 /* variable reference */
+#define DT_NODE_SYM 5 /* symbol reference */
+#define DT_NODE_TYPE 6 /* type reference or formal parameter */
+#define DT_NODE_FUNC 7 /* function call */
+#define DT_NODE_OP1 8 /* unary operator */
+#define DT_NODE_OP2 9 /* binary operator */
+#define DT_NODE_OP3 10 /* ternary operator */
+#define DT_NODE_DEXPR 11 /* D expression action */
+#define DT_NODE_DFUNC 12 /* D function action */
+#define DT_NODE_AGG 13 /* aggregation */
+#define DT_NODE_PDESC 14 /* probe description */
+#define DT_NODE_CLAUSE 15 /* clause definition */
+#define DT_NODE_INLINE 16 /* inline definition */
+#define DT_NODE_MEMBER 17 /* member definition */
+#define DT_NODE_XLATOR 18 /* translator definition */
+#define DT_NODE_PROBE 19 /* probe definition */
+#define DT_NODE_PROVIDER 20 /* provider definition */
+#define DT_NODE_PROG 21 /* program translation unit */
+
+#define DT_NF_SIGNED 0x01 /* data is a signed quantity (else unsigned) */
+#define DT_NF_COOKED 0x02 /* data is a known type (else still cooking) */
+#define DT_NF_REF 0x04 /* pass by reference (array, struct, union) */
+#define DT_NF_LVALUE 0x08 /* node is an l-value according to ANSI-C */
+#define DT_NF_WRITABLE 0x10 /* node is writable (can be modified) */
+#define DT_NF_BITFIELD 0x20 /* node is an integer bitfield */
+#define DT_NF_USERLAND 0x40 /* data is a userland address */
+
+#define DT_TYPE_NAMELEN 128 /* reasonable size for ctf_type_name() */
+
+extern int dt_node_is_integer(const dt_node_t *);
+extern int dt_node_is_float(const dt_node_t *);
+extern int dt_node_is_scalar(const dt_node_t *);
+extern int dt_node_is_arith(const dt_node_t *);
+extern int dt_node_is_vfptr(const dt_node_t *);
+extern int dt_node_is_dynamic(const dt_node_t *);
+extern int dt_node_is_stack(const dt_node_t *);
+extern int dt_node_is_symaddr(const dt_node_t *);
+extern int dt_node_is_usymaddr(const dt_node_t *);
+extern int dt_node_is_string(const dt_node_t *);
+extern int dt_node_is_strcompat(const dt_node_t *);
+extern int dt_node_is_pointer(const dt_node_t *);
+extern int dt_node_is_void(const dt_node_t *);
+extern int dt_node_is_ptrcompat(const dt_node_t *, const dt_node_t *,
+ ctf_file_t **, ctf_id_t *);
+extern int dt_node_is_argcompat(const dt_node_t *, const dt_node_t *);
+extern int dt_node_is_posconst(const dt_node_t *);
+extern int dt_node_is_actfunc(const dt_node_t *);
+
+extern dt_node_t *dt_node_int(uintmax_t);
+extern dt_node_t *dt_node_string(char *);
+extern dt_node_t *dt_node_ident(char *);
+extern dt_node_t *dt_node_type(dt_decl_t *);
+extern dt_node_t *dt_node_vatype(void);
+extern dt_node_t *dt_node_decl(void);
+extern dt_node_t *dt_node_func(dt_node_t *, dt_node_t *);
+extern dt_node_t *dt_node_offsetof(dt_decl_t *, char *);
+extern dt_node_t *dt_node_op1(int, dt_node_t *);
+extern dt_node_t *dt_node_op2(int, dt_node_t *, dt_node_t *);
+extern dt_node_t *dt_node_op3(dt_node_t *, dt_node_t *, dt_node_t *);
+extern dt_node_t *dt_node_statement(dt_node_t *);
+extern dt_node_t *dt_node_pdesc_by_name(char *);
+extern dt_node_t *dt_node_pdesc_by_id(uintmax_t);
+extern dt_node_t *dt_node_clause(dt_node_t *, dt_node_t *, dt_node_t *);
+extern dt_node_t *dt_node_inline(dt_node_t *);
+extern dt_node_t *dt_node_member(dt_decl_t *, char *, dt_node_t *);
+extern dt_node_t *dt_node_xlator(dt_decl_t *, dt_decl_t *, char *, dt_node_t *);
+extern dt_node_t *dt_node_probe(char *, int, dt_node_t *, dt_node_t *);
+extern dt_node_t *dt_node_provider(char *, dt_node_t *);
+extern dt_node_t *dt_node_program(dt_node_t *);
+
+extern dt_node_t *dt_node_link(dt_node_t *, dt_node_t *);
+extern dt_node_t *dt_node_cook(dt_node_t *, uint_t);
+
+extern dt_node_t *dt_node_xalloc(dtrace_hdl_t *, int);
+extern void dt_node_free(dt_node_t *);
+
+extern dtrace_attribute_t dt_node_list_cook(dt_node_t **, uint_t);
+extern void dt_node_list_free(dt_node_t **);
+extern void dt_node_link_free(dt_node_t **);
+
+extern void dt_node_attr_assign(dt_node_t *, dtrace_attribute_t);
+extern void dt_node_type_assign(dt_node_t *, ctf_file_t *, ctf_id_t);
+extern void dt_node_type_propagate(const dt_node_t *, dt_node_t *);
+extern const char *dt_node_type_name(const dt_node_t *, char *, size_t);
+extern size_t dt_node_type_size(const dt_node_t *);
+
+extern dt_ident_t *dt_node_resolve(const dt_node_t *, uint_t);
+extern size_t dt_node_sizeof(const dt_node_t *);
+extern void dt_node_promote(dt_node_t *, dt_node_t *, dt_node_t *);
+
+extern void dt_node_diftype(dtrace_hdl_t *,
+ const dt_node_t *, dtrace_diftype_t *);
+extern void dt_node_printr(dt_node_t *, FILE *, int);
+extern const char *dt_node_name(const dt_node_t *, char *, size_t);
+extern int dt_node_root(dt_node_t *);
+
+struct dtrace_typeinfo; /* see <dtrace.h> */
+struct dt_pcb; /* see <dt_impl.h> */
+
+#define IS_CHAR(e) \
+ (((e).cte_format & (CTF_INT_CHAR | CTF_INT_SIGNED)) == \
+ (CTF_INT_CHAR | CTF_INT_SIGNED) && (e).cte_bits == NBBY)
+
+#define IS_VOID(e) \
+ ((e).cte_offset == 0 && (e).cte_bits == 0)
+
+extern int dt_type_lookup(const char *, struct dtrace_typeinfo *);
+extern int dt_type_pointer(struct dtrace_typeinfo *);
+extern const char *dt_type_name(ctf_file_t *, ctf_id_t, char *, size_t);
+
+typedef enum {
+ YYS_CLAUSE, /* lex/yacc state for finding program clauses */
+ YYS_DEFINE, /* lex/yacc state for parsing persistent definitions */
+ YYS_EXPR, /* lex/yacc state for parsing D expressions */
+ YYS_DONE, /* lex/yacc state for indicating parse tree is done */
+ YYS_CONTROL /* lex/yacc state for parsing control lines */
+} yystate_t;
+
+extern DECL_NO_RETURN(void) dnerror(const dt_node_t *, dt_errtag_t, const char *, ...);
+extern void dnwarn(const dt_node_t *, dt_errtag_t, const char *, ...);
+
+extern DECL_NO_RETURN(void) xyerror(dt_errtag_t, const char *, ...);
+extern void xywarn(dt_errtag_t, const char *, ...);
+extern void xyvwarn(dt_errtag_t, const char *, va_list);
+
+extern DECL_NO_RETURN(void) yyerror(const char *, ...);
+extern void yywarn(const char *, ...);
+extern void yyvwarn(const char *, va_list);
+
+extern void yylabel(const char *);
+extern void yybegin(yystate_t);
+extern void yyinit(struct dt_pcb *);
+
+extern int yyparse(void);
+extern int yyinput(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PARSER_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.c
new file mode 100644
index 00000000..05a99dd2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.c
@@ -0,0 +1,193 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+/*
+ * DTrace Parsing Control Block
+ *
+ * A DTrace Parsing Control Block (PCB) contains all of the state that is used
+ * by a single pass of the D compiler, other than the global variables used by
+ * lex and yacc. The routines in this file are used to set up and tear down
+ * PCBs, which are kept on a stack pointed to by the libdtrace global 'yypcb'.
+ * The main engine of the compiler, dt_compile(), is located in dt_cc.c and is
+ * responsible for calling these routines to begin and end a compilation pass.
+ *
+ * Sun's lex/yacc are not MT-safe or re-entrant, but we permit limited nested
+ * use of dt_compile() once the entire parse tree has been constructed but has
+ * not yet executed the "cooking" pass (see dt_cc.c for more information). The
+ * PCB design also makes it easier to debug (since all global state is kept in
+ * one place) and could permit us to make the D compiler MT-safe or re-entrant
+ * in the future by adding locks to libdtrace or switching to Flex and Bison.
+ */
+
+#ifndef VBOX
+#include <strings.h>
+#include <stdlib.h>
+#include <assert.h>
+#endif
+
+#include <dt_impl.h>
+#include <dt_program.h>
+#include <dt_provider.h>
+#include <dt_pcb.h>
+
+/*
+ * Initialize the specified PCB by zeroing it and filling in a few default
+ * members, and then pushing it on to the top of the PCB stack and setting
+ * yypcb to point to it. Increment the current handle's generation count.
+ */
+void
+dt_pcb_push(dtrace_hdl_t *dtp, dt_pcb_t *pcb)
+{
+ /*
+ * Since lex/yacc are not re-entrant and we don't implement state save,
+ * assert that if another PCB is active, it is from the same handle and
+ * has completed execution of yyparse(). If the first assertion fires,
+ * the caller is calling libdtrace without proper MT locking. If the
+ * second assertion fires, dt_compile() is being called recursively
+ * from an illegal location in libdtrace, or a dt_pcb_pop() is missing.
+ */
+ if (yypcb != NULL) {
+ assert(yypcb->pcb_hdl == dtp);
+ assert(yypcb->pcb_yystate == YYS_DONE);
+ }
+
+ bzero(pcb, sizeof (dt_pcb_t));
+
+ dt_scope_create(&pcb->pcb_dstack);
+ dt_idstack_push(&pcb->pcb_globals, dtp->dt_globals);
+ dt_irlist_create(&pcb->pcb_ir);
+
+ pcb->pcb_hdl = dtp;
+ pcb->pcb_prev = dtp->dt_pcb;
+
+ dtp->dt_pcb = pcb;
+ dtp->dt_gen++;
+
+#ifndef USING_FLEX /* In case flex starts work too early. Moved to dt_compile. */
+ yyinit(pcb);
+#endif
+}
+
+static int
+dt_pcb_pop_ident(dt_idhash_t *dhp, dt_ident_t *idp, void *arg)
+{
+ dtrace_hdl_t *dtp = arg;
+
+ if (idp->di_gen == dtp->dt_gen)
+ dt_idhash_delete(dhp, idp);
+
+ return (0);
+}
+
+/*
+ * Pop the topmost PCB from the PCB stack and destroy any data structures that
+ * are associated with it. If 'err' is non-zero, destroy any intermediate
+ * state that is left behind as part of a compilation that has failed.
+ */
+void
+dt_pcb_pop(dtrace_hdl_t *dtp, int err)
+{
+ dt_pcb_t *pcb = yypcb;
+ uint_t i;
+
+ assert(pcb != NULL);
+ assert(pcb == dtp->dt_pcb);
+
+ while (pcb->pcb_dstack.ds_next != NULL)
+ (void) dt_scope_pop();
+
+ dt_scope_destroy(&pcb->pcb_dstack);
+ dt_irlist_destroy(&pcb->pcb_ir);
+
+ dt_node_link_free(&pcb->pcb_list);
+ dt_node_link_free(&pcb->pcb_hold);
+
+ if (err != 0) {
+ dt_xlator_t *dxp, *nxp;
+ dt_provider_t *pvp, *nvp;
+
+ if (pcb->pcb_prog != NULL)
+ dt_program_destroy(dtp, pcb->pcb_prog);
+ if (pcb->pcb_stmt != NULL)
+ dtrace_stmt_destroy(dtp, pcb->pcb_stmt);
+ if (pcb->pcb_ecbdesc != NULL)
+ dt_ecbdesc_release(dtp, pcb->pcb_ecbdesc);
+
+ for (dxp = dt_list_next(&dtp->dt_xlators); dxp; dxp = nxp) {
+ nxp = dt_list_next(dxp);
+ if (dxp->dx_gen == dtp->dt_gen)
+ dt_xlator_destroy(dtp, dxp);
+ }
+
+ for (pvp = dt_list_next(&dtp->dt_provlist); pvp; pvp = nvp) {
+ nvp = dt_list_next(pvp);
+ if (pvp->pv_gen == dtp->dt_gen)
+ dt_provider_destroy(dtp, pvp);
+ }
+
+ (void) dt_idhash_iter(dtp->dt_aggs, dt_pcb_pop_ident, dtp);
+ dt_idhash_update(dtp->dt_aggs);
+
+ (void) dt_idhash_iter(dtp->dt_globals, dt_pcb_pop_ident, dtp);
+ dt_idhash_update(dtp->dt_globals);
+
+ (void) dt_idhash_iter(dtp->dt_tls, dt_pcb_pop_ident, dtp);
+ dt_idhash_update(dtp->dt_tls);
+
+ (void) ctf_discard(dtp->dt_cdefs->dm_ctfp);
+ (void) ctf_discard(dtp->dt_ddefs->dm_ctfp);
+ }
+
+ if (pcb->pcb_pragmas != NULL)
+ dt_idhash_destroy(pcb->pcb_pragmas);
+ if (pcb->pcb_locals != NULL)
+ dt_idhash_destroy(pcb->pcb_locals);
+ if (pcb->pcb_idents != NULL)
+ dt_idhash_destroy(pcb->pcb_idents);
+ if (pcb->pcb_inttab != NULL)
+ dt_inttab_destroy(pcb->pcb_inttab);
+ if (pcb->pcb_strtab != NULL)
+ dt_strtab_destroy(pcb->pcb_strtab);
+ if (pcb->pcb_regs != NULL)
+ dt_regset_destroy(pcb->pcb_regs);
+
+ for (i = 0; i < pcb->pcb_asxreflen; i++)
+ dt_free(dtp, pcb->pcb_asxrefs[i]);
+
+ dt_free(dtp, pcb->pcb_asxrefs);
+ dt_difo_free(dtp, pcb->pcb_difo);
+
+ free(pcb->pcb_filetag);
+ free(pcb->pcb_sflagv);
+
+ dtp->dt_pcb = pcb->pcb_prev;
+ bzero(pcb, sizeof (dt_pcb_t));
+ yyinit(dtp->dt_pcb);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.h
new file mode 100644
index 00000000..04f73082
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.h
@@ -0,0 +1,105 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_PCB_H
+#define _DT_PCB_H
+
+#ifndef VBOX
+# pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <dtrace.h>
+#include <setjmp.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dt_parser.h>
+#include <dt_regset.h>
+#include <dt_inttab.h>
+#include <dt_strtab.h>
+#include <dt_decl.h>
+#include <dt_as.h>
+
+typedef struct dt_pcb {
+ dtrace_hdl_t *pcb_hdl; /* pointer to library handle */
+ struct dt_pcb *pcb_prev; /* pointer to previous pcb in stack */
+ FILE *pcb_fileptr; /* pointer to input file (or NULL) */
+ char *pcb_filetag; /* optional file name string (or NULL) */
+ const char *pcb_string; /* pointer to input string (or NULL) */
+ const char *pcb_strptr; /* pointer to input position */
+ size_t pcb_strlen; /* length of pcb_string */
+ int pcb_sargc; /* number of script arguments (if any) */
+ char *const *pcb_sargv; /* script argument strings (if any) */
+ ushort_t *pcb_sflagv; /* script argument flags (DT_IDFLG_* bits) */
+ dt_scope_t pcb_dstack; /* declaration processing stack */
+ dt_node_t *pcb_list; /* list of allocated parse tree nodes */
+ dt_node_t *pcb_hold; /* parse tree nodes on hold until end of defn */
+ dt_node_t *pcb_root; /* root of current parse tree */
+ dt_idstack_t pcb_globals; /* stack of global identifier hash tables */
+ dt_idhash_t *pcb_locals; /* current hash table of local identifiers */
+ dt_idhash_t *pcb_idents; /* current hash table of ambiguous idents */
+ dt_idhash_t *pcb_pragmas; /* current hash table of pending pragmas */
+ dt_inttab_t *pcb_inttab; /* integer table for constant references */
+ dt_strtab_t *pcb_strtab; /* string table for string references */
+ dt_regset_t *pcb_regs; /* register set for code generation */
+ dt_irlist_t pcb_ir; /* list of unrelocated IR instructions */
+ uint_t pcb_asvidx; /* assembler vartab index (see dt_as.c) */
+ ulong_t **pcb_asxrefs; /* assembler imported xlators (see dt_as.c) */
+ uint_t pcb_asxreflen; /* assembler xlator map length (see dt_as.c) */
+ const dtrace_probedesc_t *pcb_pdesc; /* probedesc for current context */
+ struct dt_probe *pcb_probe; /* probe associated with current context */
+ dtrace_probeinfo_t pcb_pinfo; /* info associated with current context */
+ dtrace_attribute_t pcb_amin; /* stability minimum for compilation */
+ dt_node_t *pcb_dret; /* node containing return type for assembler */
+ dtrace_difo_t *pcb_difo; /* intermediate DIF object made by assembler */
+ dtrace_prog_t *pcb_prog; /* intermediate program made by compiler */
+ dtrace_stmtdesc_t *pcb_stmt; /* intermediate stmt made by compiler */
+ dtrace_ecbdesc_t *pcb_ecbdesc; /* intermediate ecbdesc made by cmplr */
+ jmp_buf pcb_jmpbuf; /* setjmp(3C) buffer for error return */
+ const char *pcb_region; /* optional region name for yyerror() suffix */
+ dtrace_probespec_t pcb_pspec; /* probe description evaluation context */
+ uint_t pcb_cflags; /* optional compilation flags (see dtrace.h) */
+ uint_t pcb_idepth; /* preprocessor #include nesting depth */
+ yystate_t pcb_yystate; /* lex/yacc parsing state (see yybegin()) */
+ int pcb_context; /* yyparse() rules context (DT_CTX_* value) */
+ int pcb_token; /* token to be returned by yylex() (if != 0) */
+ int pcb_cstate; /* state to be restored by lexer at state end */
+ int pcb_braces; /* number of open curly braces in lexer */
+ int pcb_brackets; /* number of open square brackets in lexer */
+ int pcb_parens; /* number of open parentheses in lexer */
+} dt_pcb_t;
+
+extern void dt_pcb_push(dtrace_hdl_t *, dt_pcb_t *);
+extern void dt_pcb_pop(dtrace_hdl_t *, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PCB_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.c
new file mode 100644
index 00000000..24180515
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.c
@@ -0,0 +1,757 @@
+/*
+ * 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 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <assert.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ctype.h>
+#include <alloca.h>
+#include <libgen.h>
+#include <stddef.h>
+
+#include <dt_impl.h>
+#include <dt_program.h>
+#include <dt_pid.h>
+#include <dt_string.h>
+
+typedef struct dt_pid_probe {
+ dtrace_hdl_t *dpp_dtp;
+ dt_pcb_t *dpp_pcb;
+ dt_proc_t *dpp_dpr;
+ struct ps_prochandle *dpp_pr;
+ const char *dpp_mod;
+ char *dpp_func;
+ const char *dpp_name;
+ const char *dpp_obj;
+ uintptr_t dpp_pc;
+ size_t dpp_size;
+ Lmid_t dpp_lmid;
+ uint_t dpp_nmatches;
+ uint64_t dpp_stret[4];
+ GElf_Sym dpp_last;
+ uint_t dpp_last_taken;
+} dt_pid_probe_t;
+
+/*
+ * Compose the lmid and object name into the canonical representation. We
+ * omit the lmid for the default link map for convenience.
+ */
+static void
+dt_pid_objname(char *buf, size_t len, Lmid_t lmid, const char *obj)
+{
+ if (lmid == LM_ID_BASE)
+ (void) strncpy(buf, obj, len);
+ else
+ (void) snprintf(buf, len, "LM%lx`%s", lmid, obj);
+}
+
+static int
+dt_pid_error(dtrace_hdl_t *dtp, dt_pcb_t *pcb, dt_proc_t *dpr,
+ fasttrap_probe_spec_t *ftp, dt_errtag_t tag, const char *fmt, ...)
+{
+ va_list ap;
+ int len;
+
+ if (ftp != NULL)
+ dt_free(dtp, ftp);
+
+ va_start(ap, fmt);
+ if (pcb == NULL) {
+ assert(dpr != NULL);
+ len = vsnprintf(dpr->dpr_errmsg, sizeof (dpr->dpr_errmsg),
+ fmt, ap);
+ assert(len >= 2);
+ if (dpr->dpr_errmsg[len - 2] == '\n')
+ dpr->dpr_errmsg[len - 2] = '\0';
+ } else {
+ dt_set_errmsg(dtp, dt_errtag(tag), pcb->pcb_region,
+ pcb->pcb_filetag, pcb->pcb_fileptr ? yylineno : 0, fmt, ap);
+ }
+ va_end(ap);
+
+ return (1);
+}
+
+static int
+dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
+{
+ dtrace_hdl_t *dtp = pp->dpp_dtp;
+ dt_pcb_t *pcb = pp->dpp_pcb;
+ dt_proc_t *dpr = pp->dpp_dpr;
+ fasttrap_probe_spec_t *ftp;
+ uint64_t off;
+ char *end;
+ uint_t nmatches = 0;
+ ulong_t sz;
+ int glob, err;
+ int isdash = strcmp("-", func) == 0;
+ pid_t pid;
+
+ pid = Pstatus(pp->dpp_pr)->pr_pid;
+
+ dt_dprintf("creating probe pid%d:%s:%s:%s\n", (int)pid, pp->dpp_obj,
+ func, pp->dpp_name);
+
+ sz = sizeof (fasttrap_probe_spec_t) + (isdash ? 4 :
+ (symp->st_size - 1) * sizeof (ftp->ftps_offs[0]));
+
+ if ((ftp = dt_alloc(dtp, sz)) == NULL) {
+ dt_dprintf("proc_per_sym: dt_alloc(%lu) failed\n", sz);
+ return (1); /* errno is set for us */
+ }
+
+ ftp->ftps_pid = pid;
+ (void) strncpy(ftp->ftps_func, func, sizeof (ftp->ftps_func));
+
+ dt_pid_objname(ftp->ftps_mod, sizeof (ftp->ftps_mod), pp->dpp_lmid,
+ pp->dpp_obj);
+
+ if (!isdash && gmatch("return", pp->dpp_name)) {
+ if (dt_pid_create_return_probe(pp->dpp_pr, dtp, ftp, symp,
+ pp->dpp_stret) < 0) {
+ return (dt_pid_error(dtp, pcb, dpr, ftp,
+ D_PROC_CREATEFAIL, "failed to create return probe "
+ "for '%s': %s", func,
+ dtrace_errmsg(dtp, dtrace_errno(dtp))));
+ }
+
+ nmatches++;
+ }
+
+ if (!isdash && gmatch("entry", pp->dpp_name)) {
+ if (dt_pid_create_entry_probe(pp->dpp_pr, dtp, ftp, symp) < 0) {
+ return (dt_pid_error(dtp, pcb, dpr, ftp,
+ D_PROC_CREATEFAIL, "failed to create entry probe "
+ "for '%s': %s", func,
+ dtrace_errmsg(dtp, dtrace_errno(dtp))));
+ }
+
+ nmatches++;
+ }
+
+ glob = strisglob(pp->dpp_name);
+ if (!glob && nmatches == 0) {
+ off = strtoull(pp->dpp_name, &end, 16);
+ if (*end != '\0') {
+ return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_NAME,
+ "'%s' is an invalid probe name", pp->dpp_name));
+ }
+
+ if (off >= symp->st_size) {
+ return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_OFF,
+ "offset 0x%llx outside of function '%s'",
+ (u_longlong_t)off, func));
+ }
+
+ err = dt_pid_create_offset_probe(pp->dpp_pr, pp->dpp_dtp, ftp,
+ symp, off);
+
+ if (err == DT_PROC_ERR) {
+ return (dt_pid_error(dtp, pcb, dpr, ftp,
+ D_PROC_CREATEFAIL, "failed to create probe at "
+ "'%s+0x%llx': %s", func, (u_longlong_t)off,
+ dtrace_errmsg(dtp, dtrace_errno(dtp))));
+ }
+
+ if (err == DT_PROC_ALIGN) {
+ return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_ALIGN,
+ "offset 0x%llx is not aligned on an instruction",
+ (u_longlong_t)off));
+ }
+
+ nmatches++;
+
+ } else if (glob && !isdash) {
+ if (dt_pid_create_glob_offset_probes(pp->dpp_pr,
+ pp->dpp_dtp, ftp, symp, pp->dpp_name) < 0) {
+ return (dt_pid_error(dtp, pcb, dpr, ftp,
+ D_PROC_CREATEFAIL,
+ "failed to create offset probes in '%s': %s", func,
+ dtrace_errmsg(dtp, dtrace_errno(dtp))));
+ }
+
+ nmatches++;
+ }
+
+ pp->dpp_nmatches += nmatches;
+
+ dt_free(dtp, ftp);
+
+ return (0);
+}
+
+static int
+dt_pid_sym_filt(void *arg, const GElf_Sym *symp, const char *func)
+{
+ dt_pid_probe_t *pp = arg;
+
+ if (symp->st_shndx == SHN_UNDEF)
+ return (0);
+
+ if (symp->st_size == 0) {
+ dt_dprintf("st_size of %s is zero\n", func);
+ return (0);
+ }
+
+ if (pp->dpp_last_taken == 0 ||
+ symp->st_value != pp->dpp_last.st_value ||
+ symp->st_size != pp->dpp_last.st_size) {
+ /*
+ * Due to 4524008, _init and _fini may have a bloated st_size.
+ * While this bug has been fixed for a while, old binaries
+ * may exist that still exhibit this problem. As a result, we
+ * don't match _init and _fini though we allow users to
+ * specify them explicitly.
+ */
+ if (strcmp(func, "_init") == 0 || strcmp(func, "_fini") == 0)
+ return (0);
+
+ if ((pp->dpp_last_taken = gmatch(func, pp->dpp_func)) != 0) {
+ pp->dpp_last = *symp;
+ return (dt_pid_per_sym(pp, symp, func));
+ }
+ }
+
+ return (0);
+}
+
+static int
+dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)
+{
+ dt_pid_probe_t *pp = arg;
+ dtrace_hdl_t *dtp = pp->dpp_dtp;
+ dt_pcb_t *pcb = pp->dpp_pcb;
+ dt_proc_t *dpr = pp->dpp_dpr;
+ GElf_Sym sym;
+
+ if (obj == NULL)
+ return (0);
+
+ (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid);
+
+ if ((pp->dpp_obj = strrchr(obj, '/')) == NULL)
+ pp->dpp_obj = obj;
+ else
+ pp->dpp_obj++;
+
+ if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret1", &sym,
+ NULL) == 0)
+ pp->dpp_stret[0] = sym.st_value;
+ else
+ pp->dpp_stret[0] = 0;
+
+ if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret2", &sym,
+ NULL) == 0)
+ pp->dpp_stret[1] = sym.st_value;
+ else
+ pp->dpp_stret[1] = 0;
+
+ if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret4", &sym,
+ NULL) == 0)
+ pp->dpp_stret[2] = sym.st_value;
+ else
+ pp->dpp_stret[2] = 0;
+
+ if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret8", &sym,
+ NULL) == 0)
+ pp->dpp_stret[3] = sym.st_value;
+ else
+ pp->dpp_stret[3] = 0;
+
+ dt_dprintf("%s stret %llx %llx %llx %llx\n", obj,
+ (u_longlong_t)pp->dpp_stret[0], (u_longlong_t)pp->dpp_stret[1],
+ (u_longlong_t)pp->dpp_stret[2], (u_longlong_t)pp->dpp_stret[3]);
+
+ /*
+ * If pp->dpp_func contains any globbing meta-characters, we need
+ * to iterate over the symbol table and compare each function name
+ * against the pattern.
+ */
+ if (!strisglob(pp->dpp_func)) {
+ /*
+ * If we fail to lookup the symbol, try interpreting the
+ * function as the special "-" function that indicates that the
+ * probe name should be interpreted as a absolute virtual
+ * address. If that fails and we were matching a specific
+ * function in a specific module, report the error, otherwise
+ * just fail silently in the hopes that some other object will
+ * contain the desired symbol.
+ */
+ if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj,
+ pp->dpp_func, &sym, NULL) != 0) {
+ if (strcmp("-", pp->dpp_func) == 0) {
+ sym.st_name = 0;
+ sym.st_info =
+ GELF_ST_INFO(STB_LOCAL, STT_FUNC);
+ sym.st_other = 0;
+ sym.st_value = 0;
+ sym.st_size = Pstatus(pp->dpp_pr)->pr_dmodel ==
+ PR_MODEL_ILP32 ? -1U : -1ULL;
+
+ } else if (!strisglob(pp->dpp_mod)) {
+ return (dt_pid_error(dtp, pcb, dpr, NULL,
+ D_PROC_FUNC,
+ "failed to lookup '%s' in module '%s'",
+ pp->dpp_func, pp->dpp_mod));
+ } else {
+ return (0);
+ }
+ }
+
+ /*
+ * Only match defined functions of non-zero size.
+ */
+ if (GELF_ST_TYPE(sym.st_info) != STT_FUNC ||
+ sym.st_shndx == SHN_UNDEF || sym.st_size == 0)
+ return (0);
+
+ /*
+ * We don't instrument PLTs -- they're dynamically rewritten,
+ * and, so, inherently dicey to instrument.
+ */
+ if (Ppltdest(pp->dpp_pr, sym.st_value) != NULL)
+ return (0);
+
+ (void) Plookup_by_addr(pp->dpp_pr, sym.st_value, pp->dpp_func,
+ DTRACE_FUNCNAMELEN, &sym);
+
+ return (dt_pid_per_sym(pp, &sym, pp->dpp_func));
+ } else {
+ uint_t nmatches = pp->dpp_nmatches;
+
+ if (Psymbol_iter_by_addr(pp->dpp_pr, obj, PR_SYMTAB,
+ BIND_ANY | TYPE_FUNC, dt_pid_sym_filt, pp) == 1)
+ return (1);
+
+ if (nmatches == pp->dpp_nmatches) {
+ /*
+ * If we didn't match anything in the PR_SYMTAB, try
+ * the PR_DYNSYM.
+ */
+ if (Psymbol_iter_by_addr(pp->dpp_pr, obj, PR_DYNSYM,
+ BIND_ANY | TYPE_FUNC, dt_pid_sym_filt, pp) == 1)
+ return (1);
+ }
+ }
+
+ return (0);
+}
+
+static int
+dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj)
+{
+ char name[DTRACE_MODNAMELEN];
+ dt_pid_probe_t *pp = arg;
+
+ if ((pp->dpp_obj = strrchr(obj, '/')) == NULL)
+ pp->dpp_obj = obj;
+ else
+ pp->dpp_obj++;
+
+ if (gmatch(pp->dpp_obj, pp->dpp_mod))
+ return (dt_pid_per_mod(pp, pmp, obj));
+
+ (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid);
+
+ dt_pid_objname(name, sizeof (name), pp->dpp_lmid, pp->dpp_obj);
+
+ if (gmatch(name, pp->dpp_mod))
+ return (dt_pid_per_mod(pp, pmp, obj));
+
+ return (0);
+}
+
+static const prmap_t *
+dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P)
+{
+ char m[MAXPATHLEN];
+ Lmid_t lmid = PR_LMID_EVERY;
+ const char *obj;
+ const prmap_t *pmp;
+
+ /*
+ * Pick apart the link map from the library name.
+ */
+ if (strchr(pdp->dtpd_mod, '`') != NULL) {
+ char *end;
+
+ if (strncmp(pdp->dtpd_mod, "LM", 2) != 0 ||
+ !isdigit(pdp->dtpd_mod[2]))
+ return (NULL);
+
+ lmid = strtoul(&pdp->dtpd_mod[2], &end, 16);
+
+ obj = end + 1;
+
+ if (*end != '`' || strchr(obj, '`') != NULL)
+ return (NULL);
+
+ } else {
+ obj = pdp->dtpd_mod;
+ }
+
+ if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL)
+ return (NULL);
+
+ (void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m));
+ if ((obj = strrchr(m, '/')) == NULL)
+ obj = &m[0];
+ else
+ obj++;
+
+ (void) Plmid(P, pmp->pr_vaddr, &lmid);
+ dt_pid_objname(pdp->dtpd_mod, sizeof (pdp->dtpd_mod), lmid, obj);
+
+ return (pmp);
+}
+
+
+static int
+dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
+ dt_pcb_t *pcb, dt_proc_t *dpr)
+{
+ dt_pid_probe_t pp;
+ int ret = 0;
+
+ pp.dpp_dtp = dtp;
+ pp.dpp_dpr = dpr;
+ pp.dpp_pr = dpr->dpr_proc;
+ pp.dpp_pcb = pcb;
+
+ /*
+ * We can only trace dynamically-linked executables (since we've
+ * hidden some magic in ld.so.1 as well as libc.so.1).
+ */
+ if (Pname_to_map(pp.dpp_pr, PR_OBJ_LDSO) == NULL) {
+ return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_DYN,
+ "process %s is not a dynamically-linked executable",
+ &pdp->dtpd_provider[3]));
+ }
+
+ pp.dpp_mod = pdp->dtpd_mod[0] != '\0' ? pdp->dtpd_mod : "*";
+ pp.dpp_func = pdp->dtpd_func[0] != '\0' ? pdp->dtpd_func : "*";
+ pp.dpp_name = pdp->dtpd_name[0] != '\0' ? pdp->dtpd_name : "*";
+ pp.dpp_last_taken = 0;
+
+ if (strcmp(pp.dpp_func, "-") == 0) {
+ const prmap_t *aout, *pmp;
+
+ if (pdp->dtpd_mod[0] == '\0') {
+ pp.dpp_mod = pdp->dtpd_mod;
+ (void) strcpy(pdp->dtpd_mod, "a.out");
+ } else if (strisglob(pp.dpp_mod) ||
+ (aout = Pname_to_map(pp.dpp_pr, "a.out")) == NULL ||
+ (pmp = Pname_to_map(pp.dpp_pr, pp.dpp_mod)) == NULL ||
+ aout->pr_vaddr != pmp->pr_vaddr) {
+ return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_LIB,
+ "only the a.out module is valid with the "
+ "'-' function"));
+ }
+
+ if (strisglob(pp.dpp_name)) {
+ return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_NAME,
+ "only individual addresses may be specified "
+ "with the '-' function"));
+ }
+ }
+
+ /*
+ * If pp.dpp_mod contains any globbing meta-characters, we need
+ * to iterate over each module and compare its name against the
+ * pattern. An empty module name is treated as '*'.
+ */
+ if (strisglob(pp.dpp_mod)) {
+ ret = Pobject_iter(pp.dpp_pr, dt_pid_mod_filt, &pp);
+ } else {
+ const prmap_t *pmp;
+ char *obj;
+
+ /*
+ * If we can't find a matching module, don't sweat it -- either
+ * we'll fail the enabling because the probes don't exist or
+ * we'll wait for that module to come along.
+ */
+ if ((pmp = dt_pid_fix_mod(pdp, pp.dpp_pr)) != NULL) {
+ if ((obj = strchr(pdp->dtpd_mod, '`')) == NULL)
+ obj = pdp->dtpd_mod;
+ else
+ obj++;
+
+ ret = dt_pid_per_mod(&pp, pmp, obj);
+ }
+ }
+
+ return (ret);
+}
+
+static int
+dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
+{
+ struct ps_prochandle *P = data;
+ GElf_Sym sym;
+ prsyminfo_t sip;
+ dof_helper_t dh;
+ GElf_Half e_type;
+ const char *mname;
+ const char *syms[] = { "___SUNW_dof", "__SUNW_dof" };
+ int i, fd = -1;
+
+ /*
+ * The symbol ___SUNW_dof is for lazy-loaded DOF sections, and
+ * __SUNW_dof is for actively-loaded DOF sections. We try to force
+ * in both types of DOF section since the process may not yet have
+ * run the code to instantiate these providers.
+ */
+ for (i = 0; i < 2; i++) {
+ if (Pxlookup_by_name(P, PR_LMID_EVERY, oname, syms[i], &sym,
+ &sip) != 0) {
+ continue;
+ }
+
+ if ((mname = strrchr(oname, '/')) == NULL)
+ mname = oname;
+ else
+ mname++;
+
+ dt_dprintf("lookup of %s succeeded for %s\n", syms[i], mname);
+
+ if (Pread(P, &e_type, sizeof (e_type), pmp->pr_vaddr +
+ offsetof(Elf64_Ehdr, e_type)) != sizeof (e_type)) {
+ dt_dprintf("read of ELF header failed");
+ continue;
+ }
+
+ dh.dofhp_dof = sym.st_value;
+ dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr;
+
+ dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod),
+ sip.prs_lmid, mname);
+
+ if (fd == -1 &&
+ (fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) {
+ dt_dprintf("pr_open of helper device failed: %s\n",
+ strerror(errno));
+ return (-1); /* errno is set for us */
+ }
+
+ if (pr_ioctl(P, fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0)
+ dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod);
+ }
+
+ if (fd != -1)
+ (void) pr_close(P, fd);
+
+ return (0);
+}
+
+static int
+dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
+ dt_pcb_t *pcb, dt_proc_t *dpr)
+{
+ struct ps_prochandle *P = dpr->dpr_proc;
+ int ret = 0;
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+
+ (void) Pupdate_maps(P);
+ if (Pobject_iter(P, dt_pid_usdt_mapping, P) != 0) {
+ ret = -1;
+ (void) dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_USDT,
+ "failed to instantiate probes for pid %d: %s",
+ (int)Pstatus(P)->pr_pid, strerror(errno));
+ }
+
+ /*
+ * Put the module name in its canonical form.
+ */
+ (void) dt_pid_fix_mod(pdp, P);
+
+ return (ret);
+}
+
+static pid_t
+dt_pid_get_pid(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb,
+ dt_proc_t *dpr)
+{
+ pid_t pid;
+ char *c, *last = NULL, *end;
+
+ for (c = &pdp->dtpd_provider[0]; *c != '\0'; c++) {
+ if (!isdigit(*c))
+ last = c;
+ }
+
+ if (last == NULL || (*(++last) == '\0')) {
+ (void) dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_BADPROV,
+ "'%s' is not a valid provider", pdp->dtpd_provider);
+ return (-1);
+ }
+
+ errno = 0;
+ pid = strtol(last, &end, 10);
+
+ if (errno != 0 || end == last || end[0] != '\0' || pid <= 0) {
+ (void) dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_BADPID,
+ "'%s' does not contain a valid pid", pdp->dtpd_provider);
+ return (-1);
+ }
+
+ return (pid);
+}
+
+int
+dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
+{
+ char provname[DTRACE_PROVNAMELEN];
+ struct ps_prochandle *P;
+ dt_proc_t *dpr;
+ pid_t pid;
+ int err = 0;
+
+ assert(pcb != NULL);
+
+ if ((pid = dt_pid_get_pid(pdp, dtp, pcb, NULL)) == -1)
+ return (-1);
+
+ if (dtp->dt_ftfd == -1) {
+ if (dtp->dt_fterr == ENOENT) {
+ (void) dt_pid_error(dtp, pcb, NULL, NULL, D_PROC_NODEV,
+ "pid provider is not installed on this system");
+ } else {
+ (void) dt_pid_error(dtp, pcb, NULL, NULL, D_PROC_NODEV,
+ "pid provider is not available: %s",
+ strerror(dtp->dt_fterr));
+ }
+
+ return (-1);
+ }
+
+ (void) snprintf(provname, sizeof (provname), "pid%d", (int)pid);
+
+ if (gmatch(provname, pdp->dtpd_provider) != 0) {
+ if ((P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE,
+ 0)) == NULL) {
+ (void) dt_pid_error(dtp, pcb, NULL, NULL, D_PROC_GRAB,
+ "failed to grab process %d", (int)pid);
+ return (-1);
+ }
+
+ dpr = dt_proc_lookup(dtp, P, 0);
+ assert(dpr != NULL);
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+
+ if ((err = dt_pid_create_pid_probes(pdp, dtp, pcb, dpr)) == 0) {
+ /*
+ * Alert other retained enablings which may match
+ * against the newly created probes.
+ */
+ (void) dt_ioctl(dtp, DTRACEIOC_ENABLE, NULL);
+ }
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ dt_proc_release(dtp, P);
+ }
+
+ /*
+ * If it's not strictly a pid provider, we might match a USDT provider.
+ */
+ if (strcmp(provname, pdp->dtpd_provider) != 0) {
+ if ((P = dt_proc_grab(dtp, pid, 0, 1)) == NULL) {
+ (void) dt_pid_error(dtp, pcb, NULL, NULL, D_PROC_GRAB,
+ "failed to grab process %d", (int)pid);
+ return (-1);
+ }
+
+ dpr = dt_proc_lookup(dtp, P, 0);
+ assert(dpr != NULL);
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+
+ if (!dpr->dpr_usdt) {
+ err = dt_pid_create_usdt_probes(pdp, dtp, pcb, dpr);
+ dpr->dpr_usdt = B_TRUE;
+ }
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ dt_proc_release(dtp, P);
+ }
+
+ return (err ? -1 : 0);
+}
+
+int
+dt_pid_create_probes_module(dtrace_hdl_t *dtp, dt_proc_t *dpr)
+{
+ dtrace_prog_t *pgp;
+ dt_stmt_t *stp;
+ dtrace_probedesc_t *pdp, pd;
+ pid_t pid;
+ int ret = 0, found = B_FALSE;
+ char provname[DTRACE_PROVNAMELEN];
+
+ (void) snprintf(provname, sizeof (provname), "pid%d",
+ (int)dpr->dpr_pid);
+
+ for (pgp = dt_list_next(&dtp->dt_programs); pgp != NULL;
+ pgp = dt_list_next(pgp)) {
+
+ for (stp = dt_list_next(&pgp->dp_stmts); stp != NULL;
+ stp = dt_list_next(stp)) {
+
+ pdp = &stp->ds_desc->dtsd_ecbdesc->dted_probe;
+ pid = dt_pid_get_pid(pdp, dtp, NULL, dpr);
+ if (pid != dpr->dpr_pid)
+ continue;
+
+ found = B_TRUE;
+
+ pd = *pdp;
+
+ if (gmatch(provname, pdp->dtpd_provider) != 0 &&
+ dt_pid_create_pid_probes(&pd, dtp, NULL, dpr) != 0)
+ ret = 1;
+
+ /*
+ * If it's not strictly a pid provider, we might match
+ * a USDT provider.
+ */
+ if (strcmp(provname, pdp->dtpd_provider) != 0 &&
+ dt_pid_create_usdt_probes(&pd, dtp, NULL, dpr) != 0)
+ ret = 1;
+ }
+ }
+
+ if (found) {
+ /*
+ * Give DTrace a shot to the ribs to get it to check
+ * out the newly created probes.
+ */
+ (void) dt_ioctl(dtp, DTRACEIOC_ENABLE, NULL);
+ }
+
+ return (ret);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.h
new file mode 100644
index 00000000..ca7162cc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pid.h
@@ -0,0 +1,66 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_PID_H
+#define _DT_PID_H
+#ifndef VBOX
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <libproc.h>
+#include <sys/fasttrap.h>
+#include <dt_impl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DT_PROC_ERR (-1)
+#define DT_PROC_ALIGN (-2)
+
+extern int dt_pid_create_probes(dtrace_probedesc_t *, dtrace_hdl_t *,
+ dt_pcb_t *pcb);
+extern int dt_pid_create_probes_module(dtrace_hdl_t *, dt_proc_t *);
+
+extern int dt_pid_create_entry_probe(struct ps_prochandle *, dtrace_hdl_t *,
+ fasttrap_probe_spec_t *, const GElf_Sym *);
+
+extern int dt_pid_create_return_probe(struct ps_prochandle *, dtrace_hdl_t *,
+ fasttrap_probe_spec_t *, const GElf_Sym *, uint64_t *);
+
+extern int dt_pid_create_offset_probe(struct ps_prochandle *, dtrace_hdl_t *,
+ fasttrap_probe_spec_t *, const GElf_Sym *, ulong_t);
+
+extern int dt_pid_create_glob_offset_probes(struct ps_prochandle *,
+ dtrace_hdl_t *, fasttrap_probe_spec_t *, const GElf_Sym *, const char *);
+
+#endif /* !VBOX */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PID_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pragma.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pragma.c
new file mode 100644
index 00000000..b84165ab
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pragma.c
@@ -0,0 +1,509 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <assert.h>
+#include <strings.h>
+#include <alloca.h>
+#include <stdlib.h>
+#include <stdio.h>
+#endif
+
+#include <dt_parser.h>
+#include <dt_impl.h>
+#include <dt_provider.h>
+#include <dt_module.h>
+
+/*
+ * This callback function is installed in a given identifier hash to search for
+ * and apply deferred pragmas that are pending for a given new identifier name.
+ * Multiple pragmas may be pending for a given name; we processs all of them.
+ */
+/*ARGSUSED*/
+static void
+dt_pragma_apply(dt_idhash_t *dhp, dt_ident_t *idp)
+{
+ dt_idhash_t *php;
+ dt_ident_t *pdp;
+ RT_NOREF1(dhp);
+
+ if ((php = yypcb->pcb_pragmas) == NULL)
+ return; /* no pragmas pending for current compilation pass */
+
+ while ((pdp = dt_idhash_lookup(php, idp->di_name)) != NULL) {
+ switch (pdp->di_kind) {
+ case DT_IDENT_PRAGAT:
+ idp->di_attr = pdp->di_attr;
+ break;
+ case DT_IDENT_PRAGBN:
+ idp->di_vers = pdp->di_vers;
+ break;
+ }
+ dt_idhash_delete(php, pdp);
+ }
+}
+
+/*
+ * The #pragma attributes directive can be used to reset stability attributes
+ * on a global identifier or inline definition. If the identifier is already
+ * defined, we can just change di_attr. If not, we insert the pragma into a
+ * hash table of the current pcb's deferred pragmas for later processing.
+ */
+static void
+dt_pragma_attributes(const char *prname, dt_node_t *dnp)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dtrace_attribute_t attr, *a VBDTMSC(NULL);
+ dt_provider_t *pvp;
+ const char *name, *part;
+ dt_ident_t *idp;
+
+ if (dnp == NULL || dnp->dn_kind != DT_NODE_IDENT ||
+ dnp->dn_list == NULL || dnp->dn_list->dn_kind != DT_NODE_IDENT) {
+ xyerror(D_PRAGMA_MALFORM, "malformed #pragma %s "
+ "<attributes> <ident>\n", prname);
+ }
+
+ if (dtrace_str2attr(dnp->dn_string, &attr) == -1) {
+ xyerror(D_PRAGMA_INVAL, "invalid attributes "
+ "specified by #pragma %s\n", prname);
+ }
+
+ dnp = dnp->dn_list;
+ name = dnp->dn_string;
+
+ if (strcmp(name, "provider") == 0) {
+ dnp = dnp->dn_list;
+ name = dnp->dn_string;
+
+ dnp = dnp->dn_list;
+ part = dnp->dn_string;
+
+ if ((pvp = dt_provider_lookup(dtp, name)) != NULL) {
+ if (strcmp(part, "provider") == 0) {
+ a = &pvp->pv_desc.dtvd_attr.dtpa_provider;
+ } else if (strcmp(part, "module") == 0) {
+ a = &pvp->pv_desc.dtvd_attr.dtpa_mod;
+ } else if (strcmp(part, "function") == 0) {
+ a = &pvp->pv_desc.dtvd_attr.dtpa_func;
+ } else if (strcmp(part, "name") == 0) {
+ a = &pvp->pv_desc.dtvd_attr.dtpa_name;
+ } else if (strcmp(part, "args") == 0) {
+ a = &pvp->pv_desc.dtvd_attr.dtpa_args;
+ } else {
+ xyerror(D_PRAGMA_INVAL, "invalid component "
+ "\"%s\" in attribute #pragma "
+ "for provider %s\n", name, part);
+ }
+
+ *a = attr;
+ return;
+ }
+
+ } else if ((idp = dt_idstack_lookup(
+ &yypcb->pcb_globals, name)) != NULL) {
+
+ if (idp->di_gen != dtp->dt_gen) {
+ xyerror(D_PRAGMA_SCOPE, "#pragma %s cannot modify "
+ "entity defined outside program scope\n", prname);
+ }
+
+ idp->di_attr = attr;
+ return;
+ }
+
+ if (yypcb->pcb_pragmas == NULL && (yypcb->pcb_pragmas =
+ dt_idhash_create("pragma", NULL, 0, 0)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ idp = dt_idhash_insert(yypcb->pcb_pragmas, name, DT_IDENT_PRAGAT, 0, 0,
+ attr, 0, &dt_idops_thaw, (void *)prname, dtp->dt_gen);
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (dtp->dt_globals->dh_defer == NULL)
+ dtp->dt_globals->dh_defer = &dt_pragma_apply;
+}
+
+/*
+ * The #pragma binding directive can be used to reset the version binding
+ * on a global identifier or inline definition. If the identifier is already
+ * defined, we can just change di_vers. If not, we insert the pragma into a
+ * hash table of the current pcb's deferred pragmas for later processing.
+ */
+static void
+dt_pragma_binding(const char *prname, dt_node_t *dnp)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_version_t vers;
+ const char *name;
+ dt_ident_t *idp;
+
+ if (dnp == NULL || dnp->dn_kind != DT_NODE_STRING ||
+ dnp->dn_list == NULL || dnp->dn_list->dn_kind != DT_NODE_IDENT) {
+ xyerror(D_PRAGMA_MALFORM, "malformed #pragma %s "
+ "\"version\" <ident>\n", prname);
+ }
+
+ if (dt_version_str2num(dnp->dn_string, &vers) == -1) {
+ xyerror(D_PRAGMA_INVAL, "invalid version string "
+ "specified by #pragma %s\n", prname);
+ }
+
+ name = dnp->dn_list->dn_string;
+ idp = dt_idstack_lookup(&yypcb->pcb_globals, name);
+
+ if (idp != NULL) {
+ if (idp->di_gen != dtp->dt_gen) {
+ xyerror(D_PRAGMA_SCOPE, "#pragma %s cannot modify "
+ "entity defined outside program scope\n", prname);
+ }
+ idp->di_vers = vers;
+ return;
+ }
+
+ if (yypcb->pcb_pragmas == NULL && (yypcb->pcb_pragmas =
+ dt_idhash_create("pragma", NULL, 0, 0)) == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ idp = dt_idhash_insert(yypcb->pcb_pragmas, name, DT_IDENT_PRAGBN, 0, 0,
+ _dtrace_defattr, vers, &dt_idops_thaw, (void *)prname, dtp->dt_gen);
+
+ if (idp == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+
+ if (dtp->dt_globals->dh_defer == NULL)
+ dtp->dt_globals->dh_defer = &dt_pragma_apply;
+}
+
+/*
+ * The #pragma depends_on directive can be used to express a dependency on a
+ * module, provider or library which if not present will cause processing to
+ * abort.
+ */
+static void
+dt_pragma_depends(const char *prname, dt_node_t *cnp)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ dt_node_t *nnp = cnp ? cnp->dn_list : NULL;
+ int found VBDTMSC(B_FALSE);
+ dt_lib_depend_t *dld;
+ char lib[MAXPATHLEN];
+
+ if (cnp == NULL || nnp == NULL ||
+ cnp->dn_kind != DT_NODE_IDENT || nnp->dn_kind != DT_NODE_IDENT) {
+ xyerror(D_PRAGMA_MALFORM, "malformed #pragma %s "
+ "<class> <name>\n", prname);
+ }
+
+ if (strcmp(cnp->dn_string, "provider") == 0)
+ found = dt_provider_lookup(dtp, nnp->dn_string) != NULL;
+ else if (strcmp(cnp->dn_string, "module") == 0) {
+ dt_module_t *mp = dt_module_lookup_by_name(dtp, nnp->dn_string);
+ found = mp != NULL && dt_module_getctf(dtp, mp) != NULL;
+ } else if (strcmp(cnp->dn_string, "library") == 0) {
+ if (yypcb->pcb_cflags & DTRACE_C_CTL) {
+ assert(dtp->dt_filetag != NULL);
+
+ /*
+ * We have the file we are working on in dtp->dt_filetag
+ * so find that node and add the dependency in.
+ */
+ dld = dt_lib_depend_lookup(&dtp->dt_lib_dep,
+ dtp->dt_filetag);
+ assert(dld != NULL);
+
+ (void) snprintf(lib, sizeof (lib), "%s%s",
+ dld->dtld_libpath, nnp->dn_string);
+ if ((dt_lib_depend_add(dtp, &dld->dtld_dependencies,
+ lib)) != 0) {
+ xyerror(D_PRAGMA_DEPEND,
+ "failed to add dependency %s:%s\n", lib,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+ } else {
+ /*
+ * By this point we have already performed a topological
+ * sort of the dependencies; we process this directive
+ * as satisfied as long as the dependency was properly
+ * loaded.
+ */
+ if (dtp->dt_filetag == NULL)
+ xyerror(D_PRAGMA_DEPEND, "main program may "
+ "not explicitly depend on a library");
+
+ dld = dt_lib_depend_lookup(&dtp->dt_lib_dep,
+ dtp->dt_filetag);
+ assert(dld != NULL);
+
+ (void) snprintf(lib, sizeof (lib), "%s%s",
+ dld->dtld_libpath, nnp->dn_string);
+ dld = dt_lib_depend_lookup(&dtp->dt_lib_dep_sorted,
+ lib);
+ assert(dld != NULL);
+
+ if (!dld->dtld_loaded)
+ xyerror(D_PRAGMA_DEPEND, "program requires "
+ "library \"%s\" which failed to load",
+ lib);
+ }
+
+ found = B_TRUE;
+ } else {
+ xyerror(D_PRAGMA_INVAL, "invalid class %s "
+ "specified by #pragma %s\n", cnp->dn_string, prname);
+ }
+
+ if (!found) {
+ xyerror(D_PRAGMA_DEPEND, "program requires %s %s\n",
+ cnp->dn_string, nnp->dn_string);
+ }
+}
+
+/*
+ * The #pragma error directive can be followed by any list of tokens, which we
+ * just concatenate and print as part of our error message.
+ */
+static void
+dt_pragma_error(const char *prname, dt_node_t *dnp)
+{
+ dt_node_t *enp;
+ size_t n = 0;
+ char *s;
+
+ for (enp = dnp; enp != NULL; enp = enp->dn_list) {
+ if (enp->dn_kind == DT_NODE_IDENT ||
+ enp->dn_kind == DT_NODE_STRING)
+ n += strlen(enp->dn_string) + 1;
+ }
+
+ s = alloca(n + 1);
+ s[0] = '\0';
+
+ for (enp = dnp; enp != NULL; enp = enp->dn_list) {
+ if (enp->dn_kind == DT_NODE_IDENT ||
+ enp->dn_kind == DT_NODE_STRING) {
+ (void) strcat(s, enp->dn_string);
+ (void) strcat(s, " ");
+ }
+ }
+
+ xyerror(D_PRAGERR, "#%s: %s\n", prname, s);
+}
+
+/*ARGSUSED*/
+static void
+dt_pragma_ident(const char *prname, dt_node_t *dnp)
+{
+ /* ignore any #ident or #pragma ident lines */
+ RT_NOREF2(prname, dnp);
+}
+
+static void
+dt_pragma_option(const char *prname, dt_node_t *dnp)
+{
+ dtrace_hdl_t *dtp = yypcb->pcb_hdl;
+ char *opt, *val;
+
+ if (dnp == NULL || dnp->dn_kind != DT_NODE_IDENT) {
+ xyerror(D_PRAGMA_MALFORM,
+ "malformed #pragma %s <option>=<val>\n", prname);
+ }
+
+ if (dnp->dn_list != NULL) {
+ xyerror(D_PRAGMA_MALFORM,
+ "superfluous arguments specified for #pragma %s\n", prname);
+ }
+
+#ifndef VBOX
+ opt = strdupa(dnp->dn_string);
+#else
+ MY_STRDUPA(opt, dnp->dn_string);
+#endif
+
+ if ((val = strchr(opt, '=')) != NULL)
+ *val++ = '\0';
+
+ if (dtrace_setopt(dtp, opt, val) == -1) {
+ if (val == NULL) {
+ xyerror(D_PRAGMA_OPTSET,
+ "failed to set option '%s': %s\n", opt,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ } else {
+ xyerror(D_PRAGMA_OPTSET,
+ "failed to set option '%s' to '%s': %s\n",
+ opt, val, dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+ }
+}
+
+/*
+ * The #line directive is used to reset the input line number and to optionally
+ * note the file name for use in error messages. Sun cpp(1) also produces a
+ * third integer token after the filename which is one of the following:
+ *
+ * 0 - line change has nothing to do with an #include file
+ * 1 - line change because we just entered a #include file
+ * 2 - line change because we just exited a #include file
+ *
+ * We use these state tokens to adjust pcb_idepth, which in turn controls
+ * whether type lookups access the global type space or not.
+ */
+static void
+dt_pragma_line(const char *prname, dt_node_t *dnp)
+{
+ dt_node_t *fnp = dnp ? dnp->dn_list : NULL;
+ dt_node_t *inp = fnp ? fnp->dn_list : NULL;
+
+ if ((dnp == NULL || dnp->dn_kind != DT_NODE_INT) ||
+ (fnp != NULL && fnp->dn_kind != DT_NODE_STRING) ||
+ (inp != NULL && inp->dn_kind != DT_NODE_INT)) {
+ xyerror(D_PRAGMA_MALFORM, "malformed #%s "
+ "<line> [ [\"file\"] state ]\n", prname);
+ }
+
+ /*
+ * If a file is specified, free any old pcb_filetag and swap fnp's
+ * dn_string into pcb_filetag as the new filename for error messages.
+ */
+ if (fnp != NULL) {
+ if (yypcb->pcb_filetag != NULL)
+ free(yypcb->pcb_filetag);
+
+ /*
+ * This is not pretty, but is a necessary evil until we either
+ * write "dpp" or get a useful standalone cpp from DevPro. If
+ * the filename begins with /dev/fd, we know it's the master
+ * input file (see dt_preproc() in dt_cc.c), so just clear the
+ * dt_filetag pointer so error messages refer to the main file.
+ */
+ if (strncmp(fnp->dn_string, "/dev/fd/", 8) != 0) {
+ yypcb->pcb_filetag = fnp->dn_string;
+ fnp->dn_string = NULL;
+ } else
+ yypcb->pcb_filetag = NULL;
+ }
+
+ if (inp != NULL) {
+ if (inp->dn_value == 1)
+ yypcb->pcb_idepth++;
+ else if (inp->dn_value == 2 && yypcb->pcb_idepth != 0)
+ yypcb->pcb_idepth--;
+ }
+
+ yylineno = dnp->dn_value;
+}
+
+/*
+ * D compiler pragma types range from control directives to common pragmas to
+ * D custom pragmas, in order of specificity. Similar to gcc, we use #pragma D
+ * as a special prefix for our pragmas so they can be used in mixed headers.
+ */
+#define DT_PRAGMA_DIR 0 /* pragma directive may be used after naked # */
+#define DT_PRAGMA_SUB 1 /* pragma directive may be used after #pragma */
+#define DT_PRAGMA_DCP 2 /* pragma may only be used after #pragma D */
+
+static const struct dt_pragmadesc {
+ const char *dpd_name;
+ void (*dpd_func)(const char *, dt_node_t *);
+ int dpd_kind;
+} dt_pragmas[] = {
+ { "attributes", dt_pragma_attributes, DT_PRAGMA_DCP },
+ { "binding", dt_pragma_binding, DT_PRAGMA_DCP },
+ { "depends_on", dt_pragma_depends, DT_PRAGMA_DCP },
+ { "error", dt_pragma_error, DT_PRAGMA_DIR },
+ { "ident", dt_pragma_ident, DT_PRAGMA_DIR },
+ { "line", dt_pragma_line, DT_PRAGMA_DIR },
+ { "option", dt_pragma_option, DT_PRAGMA_DCP },
+ { NULL, NULL }
+};
+
+/*
+ * Process a control line #directive by looking up the directive name in our
+ * lookup table and invoking the corresponding function with the token list.
+ * According to K&R[A12.9], we silently ignore null directive lines.
+ */
+void
+dt_pragma(dt_node_t *pnp)
+{
+ const struct dt_pragmadesc *dpd;
+ dt_node_t *dnp;
+ int kind = DT_PRAGMA_DIR;
+
+ for (dnp = pnp; dnp != NULL; dnp = dnp->dn_list) {
+ if (dnp->dn_kind == DT_NODE_INT) {
+ dt_pragma_line("line", dnp);
+ break;
+ }
+
+ if (dnp->dn_kind != DT_NODE_IDENT)
+ xyerror(D_PRAGCTL_INVAL, "invalid control directive\n");
+
+ if (kind == DT_PRAGMA_DIR &&
+ strcmp(dnp->dn_string, "pragma") == 0) {
+ kind = DT_PRAGMA_SUB;
+ continue;
+ }
+
+ if (kind == DT_PRAGMA_SUB &&
+ strcmp(dnp->dn_string, "D") == 0) {
+ kind = DT_PRAGMA_DCP;
+ continue;
+ }
+
+ for (dpd = dt_pragmas; dpd->dpd_name != NULL; dpd++) {
+ if (dpd->dpd_kind <= kind &&
+ strcmp(dpd->dpd_name, dnp->dn_string) == 0)
+ break;
+ }
+
+ yylineno--; /* since we've already seen \n */
+
+ if (dpd->dpd_name != NULL) {
+ dpd->dpd_func(dpd->dpd_name, dnp->dn_list);
+ yylineno++;
+ break;
+ }
+
+ switch (kind) {
+ case DT_PRAGMA_DIR:
+ xyerror(D_PRAGCTL_INVAL, "invalid control directive: "
+ "#%s\n", dnp->dn_string);
+ /*NOTREACHED*/
+ case DT_PRAGMA_SUB:
+ break; /* K&R[A12.8] says to ignore unknown pragmas */
+ case DT_PRAGMA_DCP:
+ default:
+ xyerror(D_PRAGMA_INVAL, "invalid D pragma: %s\n",
+ dnp->dn_string);
+ }
+
+ yylineno++;
+ break;
+ }
+
+ dt_node_list_free(&pnp);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.c
new file mode 100644
index 00000000..9813291f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.c
@@ -0,0 +1,2057 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <sys/sysmacros.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <alloca.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#else /* VBOX */
+# include <iprt/asm.h>
+# include <ctype.h>
+#endif /* VBOX */
+
+#include <dt_printf.h>
+#include <dt_string.h>
+#include <dt_impl.h>
+
+#ifdef VBOX
+static const char g_aszMonth[12][4] =
+{ "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+static const char g_aszDay[7][4] =
+{ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
+#endif
+
+/*ARGSUSED*/
+static int
+pfcheck_addr(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ return (dt_node_is_pointer(dnp) || dt_node_is_integer(dnp));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_kaddr(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ return (dt_node_is_pointer(dnp) || dt_node_is_integer(dnp) ||
+ dt_node_is_symaddr(dnp));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_uaddr(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ dtrace_hdl_t *dtp = pfv->pfv_dtp;
+ dt_ident_t *idp = dt_idhash_lookup(dtp->dt_macros, "target");
+ RT_NOREF1(pfd);
+
+ if (dt_node_is_usymaddr(dnp))
+ return (1);
+
+ if (idp == NULL || idp->di_id == 0)
+ return (0);
+
+ return (dt_node_is_pointer(dnp) || dt_node_is_integer(dnp));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_stack(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ return (dt_node_is_stack(dnp));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_time(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ return (dt_node_is_integer(dnp) &&
+ dt_node_type_size(dnp) == sizeof (uint64_t));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_str(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ ctf_file_t *ctfp;
+ ctf_encoding_t e;
+ ctf_arinfo_t r;
+ ctf_id_t base;
+ uint_t kind;
+ RT_NOREF2(pfv, pfd);
+
+ if (dt_node_is_string(dnp))
+ return (1);
+
+ ctfp = dnp->dn_ctfp;
+ base = ctf_type_resolve(ctfp, dnp->dn_type);
+ kind = ctf_type_kind(ctfp, base);
+
+ return (kind == CTF_K_ARRAY && ctf_array_info(ctfp, base, &r) == 0 &&
+ (base = ctf_type_resolve(ctfp, r.ctr_contents)) != CTF_ERR &&
+ ctf_type_encoding(ctfp, base, &e) == 0 && IS_CHAR(e));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_wstr(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ ctf_id_t base = ctf_type_resolve(ctfp, dnp->dn_type);
+ uint_t kind = ctf_type_kind(ctfp, base);
+
+ ctf_encoding_t e;
+ ctf_arinfo_t r;
+ RT_NOREF2(pfv, pfd);
+
+ return (kind == CTF_K_ARRAY && ctf_array_info(ctfp, base, &r) == 0 &&
+ (base = ctf_type_resolve(ctfp, r.ctr_contents)) != CTF_ERR &&
+ ctf_type_kind(ctfp, base) == CTF_K_INTEGER &&
+ ctf_type_encoding(ctfp, base, &e) == 0 && e.cte_bits == 32);
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_csi(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ return (dt_node_is_integer(dnp) &&
+ dt_node_type_size(dnp) <= sizeof (int));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_fp(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ return (dt_node_is_float(dnp));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_xint(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ return (dt_node_is_integer(dnp));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_dint(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF2(pfv, pfd);
+ if (dnp->dn_flags & DT_NF_SIGNED)
+ pfd->pfd_flags |= DT_PFCONV_SIGNED;
+ else
+ pfd->pfd_fmt[strlen(pfd->pfd_fmt) - 1] = 'u';
+
+ return (dt_node_is_integer(dnp));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_xshort(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ ctf_id_t type = ctf_type_resolve(ctfp, dnp->dn_type);
+ char n[DT_TYPE_NAMELEN];
+ RT_NOREF2(pfv, pfd);
+
+ return (ctf_type_name(ctfp, type, n, sizeof (n)) != NULL && (
+ strcmp(n, "short") == 0 || strcmp(n, "signed short") == 0 ||
+ strcmp(n, "unsigned short") == 0));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_xlong(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ ctf_id_t type = ctf_type_resolve(ctfp, dnp->dn_type);
+ char n[DT_TYPE_NAMELEN];
+ RT_NOREF2(pfv, pfd);
+
+ return (ctf_type_name(ctfp, type, n, sizeof (n)) != NULL && (
+ strcmp(n, "long") == 0 || strcmp(n, "signed long") == 0 ||
+ strcmp(n, "unsigned long") == 0));
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_xlonglong(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ ctf_file_t *ctfp = dnp->dn_ctfp;
+ ctf_id_t type = dnp->dn_type;
+ char n[DT_TYPE_NAMELEN];
+ RT_NOREF2(pfv, pfd);
+
+ if (ctf_type_name(ctfp, ctf_type_resolve(ctfp, type), n,
+ sizeof (n)) != NULL && (strcmp(n, "long long") == 0 ||
+ strcmp(n, "signed long long") == 0 ||
+ strcmp(n, "unsigned long long") == 0))
+ return (1);
+
+ /*
+ * If the type used for %llx or %llX is not an [unsigned] long long, we
+ * also permit it to be a [u]int64_t or any typedef thereof. We know
+ * that these typedefs are guaranteed to work with %ll[xX] in either
+ * compilation environment even though they alias to "long" in LP64.
+ */
+ while (ctf_type_kind(ctfp, type) == CTF_K_TYPEDEF) {
+ if (ctf_type_name(ctfp, type, n, sizeof (n)) != NULL &&
+ (strcmp(n, "int64_t") == 0 || strcmp(n, "uint64_t") == 0))
+ return (1);
+
+ type = ctf_type_reference(ctfp, type);
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+pfcheck_type(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
+{
+ RT_NOREF1(pfv);
+ return (ctf_type_compat(dnp->dn_ctfp, ctf_type_resolve(dnp->dn_ctfp,
+ dnp->dn_type), pfd->pfd_conv->pfc_dctfp, pfd->pfd_conv->pfc_dtype));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_sint(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t unormal)
+{
+ int64_t normal = (int64_t)unormal;
+ int32_t n = (int32_t)normal;
+ RT_NOREF1(pfd);
+
+ switch (size) {
+ case sizeof (int8_t):
+ return (dt_printf(dtp, fp, format,
+ (int32_t)*((int8_t *)addr) / n));
+ case sizeof (int16_t):
+ return (dt_printf(dtp, fp, format,
+ (int32_t)*((int16_t *)addr) / n));
+ case sizeof (int32_t):
+ return (dt_printf(dtp, fp, format,
+ *((int32_t *)addr) / n));
+ case sizeof (int64_t):
+ return (dt_printf(dtp, fp, format,
+ *((int64_t *)addr) / normal));
+ default:
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+ }
+}
+
+/*ARGSUSED*/
+static int
+pfprint_uint(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ uint32_t n = (uint32_t)normal;
+ RT_NOREF1(pfd);
+
+ switch (size) {
+ case sizeof (uint8_t):
+ return (dt_printf(dtp, fp, format,
+ (uint32_t)*((uint8_t *)addr) / n));
+ case sizeof (uint16_t):
+ return (dt_printf(dtp, fp, format,
+ (uint32_t)*((uint16_t *)addr) / n));
+ case sizeof (uint32_t):
+ return (dt_printf(dtp, fp, format,
+ *((uint32_t *)addr) / n));
+ case sizeof (uint64_t):
+ return (dt_printf(dtp, fp, format,
+ *((uint64_t *)addr) / normal));
+ default:
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+ }
+}
+
+static int
+pfprint_dint(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ if (pfd->pfd_flags & DT_PFCONV_SIGNED)
+ return (pfprint_sint(dtp, fp, format, pfd, addr, size, normal));
+ else
+ return (pfprint_uint(dtp, fp, format, pfd, addr, size, normal));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_fp(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ double n = (double)normal;
+#ifndef _MSC_VER
+ long double ldn = (long double)normal;
+#endif
+ RT_NOREF1(pfd);
+
+ switch (size) {
+ case sizeof (float):
+ return (dt_printf(dtp, fp, format,
+ (double)*((float *)addr) / n));
+ case sizeof (double):
+ return (dt_printf(dtp, fp, format,
+ *((double *)addr) / n));
+#ifndef _MSC_VER
+ case sizeof (long double):
+ return (dt_printf(dtp, fp, format,
+ *((long double *)addr) / ldn));
+#endif
+ default:
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+ }
+}
+
+/*ARGSUSED*/
+static int
+pfprint_addr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ char *s;
+ int n, len = 256;
+ uint64_t val;
+ RT_NOREF2(pfd, normal);
+
+ switch (size) {
+ case sizeof (uint32_t):
+ val = *((uint32_t *)addr);
+ break;
+ case sizeof (uint64_t):
+ val = *((uint64_t *)addr);
+ break;
+ default:
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+ }
+
+ do {
+ n = len;
+ s = alloca(n);
+ } while ((len = dtrace_addr2str(dtp, val, s, n)) > n);
+
+ return (dt_printf(dtp, fp, format, s));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_mod(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ RT_NOREF3(pfd, size, normal);
+ return (dt_print_mod(dtp, fp, format, (caddr_t)addr));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ RT_NOREF3(pfd, size, normal);
+ return (dt_print_umod(dtp, fp, format, (caddr_t)addr));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_uaddr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ char *s;
+ int n, len = 256;
+ uint64_t val, pid = 0;
+
+ dt_ident_t *idp = dt_idhash_lookup(dtp->dt_macros, "target");
+ RT_NOREF2(pfd, normal);
+
+ switch (size) {
+ case sizeof (uint32_t):
+ val = (u_longlong_t)*((uint32_t *)addr);
+ break;
+ case sizeof (uint64_t):
+ val = (u_longlong_t)*((uint64_t *)addr);
+ break;
+ case sizeof (uint64_t) * 2:
+ pid = ((uint64_t *)(uintptr_t)addr)[0];
+ val = ((uint64_t *)(uintptr_t)addr)[1];
+ break;
+ default:
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+ }
+
+ if (pid == 0 && dtp->dt_vector == NULL && idp != NULL)
+ pid = idp->di_id;
+
+ do {
+ n = len;
+ s = alloca(n);
+ } while ((len = dtrace_uaddr2str(dtp, pid, val, s, n)) > n);
+
+ return (dt_printf(dtp, fp, format, s));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_stack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *vaddr, size_t size, uint64_t normal)
+{
+ int width;
+ dtrace_optval_t saved = dtp->dt_options[DTRACEOPT_STACKINDENT];
+ const dtrace_recdesc_t *rec = pfd->pfd_rec;
+ caddr_t addr = (caddr_t)vaddr;
+ int err = 0;
+ RT_NOREF2(size, normal);
+
+ /*
+ * We have stashed the value of the STACKINDENT option, and we will
+ * now override it for the purposes of formatting the stack. If the
+ * field has been specified as left-aligned (i.e. (%-#), we set the
+ * indentation to be the width. This is a slightly odd semantic, but
+ * it's useful functionality -- and it's slightly odd to begin with to
+ * be using a single format specifier to be formatting multiple lines
+ * of text...
+ */
+ if (pfd->pfd_dynwidth < 0) {
+ assert(pfd->pfd_flags & DT_PFCONV_DYNWIDTH);
+ width = -pfd->pfd_dynwidth;
+ } else if (pfd->pfd_flags & DT_PFCONV_LEFT) {
+ width = pfd->pfd_dynwidth ? pfd->pfd_dynwidth : pfd->pfd_width;
+ } else {
+ width = 0;
+ }
+
+ dtp->dt_options[DTRACEOPT_STACKINDENT] = width;
+
+ switch (rec->dtrd_action) {
+ case DTRACEACT_USTACK:
+ case DTRACEACT_JSTACK:
+ err = dt_print_ustack(dtp, fp, format, addr, rec->dtrd_arg);
+ break;
+
+ case DTRACEACT_STACK:
+ err = dt_print_stack(dtp, fp, format, addr, rec->dtrd_arg,
+ rec->dtrd_size / rec->dtrd_arg);
+ break;
+
+ default:
+ assert(0);
+ }
+
+ dtp->dt_options[DTRACEOPT_STACKINDENT] = saved;
+
+ return (err);
+}
+
+/*ARGSUSED*/
+static int
+pfprint_time(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+#ifndef VBOX
+ char src[32], buf[32], *dst = buf;
+ hrtime_t time = *((uint64_t *)addr);
+ time_t sec = (time_t)(time / NANOSEC);
+ int i;
+
+ /*
+ * ctime(3C) returns a string of the form "Dec 3 17:20:00 1973\n\0".
+ * Below, we turn this into the canonical adb/mdb /[yY] format,
+ * "1973 Dec 3 17:20:00".
+ */
+ (void) ctime_r(&sec, src, sizeof (src));
+
+ /*
+ * Place the 4-digit year at the head of the string...
+ */
+ for (i = 20; i < 24; i++)
+ *dst++ = src[i];
+
+ /*
+ * ...and follow it with the remainder (month, day, hh:mm:ss).
+ */
+ for (i = 3; i < 19; i++)
+ *dst++ = src[i];
+
+ *dst = '\0';
+#else
+ RTTIMESPEC TimeSpec;
+ RTTIME Time;
+ char buf[32];
+ RT_NOREF3(pfd, size, normal);
+
+ RTTimeLocalExplode(&Time, RTTimeSpecSetNano(&TimeSpec, *(uint64_t *)addr));
+ RTStrPrintf(buf, sizeof(buf), "%u %s %2u %02u:%02u:%02u",
+ Time.i32Year, g_aszMonth[Time.u8Month - 1],
+ Time.u8MonthDay, Time.u8Hour, Time.u8Minute, Time.u8Second);
+#endif
+ return (dt_printf(dtp, fp, format, buf));
+}
+
+/*
+ * This prints the time in RFC 822 standard form. This is useful for emitting
+ * notions of time that are consumed by standard tools (e.g., as part of an
+ * RSS feed).
+ */
+/*ARGSUSED*/
+static int
+pfprint_time822(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+#ifndef VBOX
+ hrtime_t time = *((uint64_t *)addr);
+ time_t sec = (time_t)(time / NANOSEC);
+ struct tm tm;
+ char buf[64];
+
+ (void) localtime_r(&sec, &tm);
+ (void) strftime(buf, sizeof (buf), "%a, %d %b %G %T %Z", &tm);
+#else
+ RTTIMESPEC TimeSpec;
+ RTTIME Time;
+ char buf[64];
+ RT_NOREF3(pfd, size, normal);
+
+ RTTimeLocalExplode(&Time, RTTimeSpecSetNano(&TimeSpec, *(uint64_t *)addr));
+ RTStrPrintf(buf, sizeof(buf), "%s, %u %s %02u:%02u:%02u %s%d%s",
+ g_aszDay[Time.u8WeekDay], Time.u8MonthDay, g_aszMonth[Time.u8Month - 1],
+ Time.u8Hour, Time.u8Minute, Time.u8Second,
+ Time.offUTC >= 0 ? "UTC+" : "UTC", Time.offUTC / 60,
+ Time.offUTC % 60 == 30 ? ".5" : "");
+#endif
+ return (dt_printf(dtp, fp, format, buf));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_port(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+#ifndef VBOX
+ uint16_t port = htons(*((uint16_t *)addr));
+ char buf[256];
+ struct servent *sv, res;
+
+ if ((sv = getservbyport_r(port, NULL, &res, buf, sizeof (buf))) != NULL)
+ return (dt_printf(dtp, fp, format, sv->s_name));
+
+ (void) snprintf(buf, sizeof (buf), "%d", *((uint16_t *)addr));
+#else
+ uint16_t uPortNet = *(uint16_t *)addr;
+ char buf[32];
+ RT_NOREF3(pfd, size, normal);
+
+ RTStrPrintf(buf, sizeof(buf), "%d", RT_N2H_U16(uPortNet));
+#endif
+ return (dt_printf(dtp, fp, format, buf));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_inetaddr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ char *s = alloca(size + 1);
+#ifndef VBOX
+ struct hostent *host, res;
+ char inetaddr[NS_IN6ADDRSZ];
+ char buf[1024];
+ int e;
+#endif
+ RT_NOREF2(pfd, normal);
+
+ bcopy(addr, s, size);
+ s[size] = '\0';
+
+#ifndef VBOX
+ if (strchr(s, ':') == NULL && inet_pton(AF_INET, s, inetaddr) != -1) {
+ if ((host = gethostbyaddr_r(inetaddr, NS_INADDRSZ,
+ AF_INET, &res, buf, sizeof (buf), &e)) != NULL)
+ return (dt_printf(dtp, fp, format, host->h_name));
+ } else if (inet_pton(AF_INET6, s, inetaddr) != -1) {
+ if ((host = getipnodebyaddr(inetaddr, NS_IN6ADDRSZ,
+ AF_INET6, &e)) != NULL)
+ return (dt_printf(dtp, fp, format, host->h_name));
+ }
+#endif
+
+ return (dt_printf(dtp, fp, format, s));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_cstr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ char *s = alloca(size + 1);
+ RT_NOREF2(pfd, normal);
+
+ bcopy(addr, s, size);
+ s[size] = '\0';
+ return (dt_printf(dtp, fp, format, s));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_wstr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ wchar_t *ws = alloca(size + sizeof (wchar_t));
+ RT_NOREF2(pfd, normal);
+
+ bcopy(addr, ws, size);
+ ws[size / sizeof (wchar_t)] = L'\0';
+ return (dt_printf(dtp, fp, format, ws));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_estr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ char *s;
+ int n;
+ RT_NOREF2(pfd, normal);
+
+ if ((s = strchr2esc(addr, size)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ n = dt_printf(dtp, fp, format, s);
+ free(s);
+ return (n);
+}
+
+static int
+pfprint_echr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ char c;
+
+ switch (size) {
+ case sizeof (int8_t):
+ c = *(int8_t *)addr;
+ break;
+ case sizeof (int16_t):
+ c = *(int16_t *)addr;
+ break;
+ case sizeof (int32_t):
+ c = *(int32_t *)addr;
+ break;
+ default:
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+ }
+
+ return (pfprint_estr(dtp, fp, format, pfd, &c, 1, normal));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_pct(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ RT_NOREF5(format, pfd, addr, size, normal);
+ return (dt_printf(dtp, fp, "%%"));
+}
+
+static const char pfproto_xint[] = "char, short, int, long, or long long";
+static const char pfproto_csi[] = "char, short, or int";
+static const char pfproto_fp[] = "float, double, or long double";
+static const char pfproto_addr[] = "pointer or integer";
+static const char pfproto_uaddr[] =
+ "pointer or integer (with -p/-c) or _usymaddr (without -p/-c)";
+static const char pfproto_cstr[] = "char [] or string (or use stringof)";
+static const char pfproto_wstr[] = "wchar_t []";
+
+/*
+ * Printf format conversion dictionary. This table should match the set of
+ * conversions offered by printf(3C), as well as some additional extensions.
+ * The second parameter is an ASCII string which is either an actual type
+ * name we should look up (if pfcheck_type is specified), or just a descriptive
+ * string of the types expected for use in error messages.
+ */
+static const dt_pfconv_t _dtrace_conversions[] = {
+{ "a", "s", pfproto_addr, pfcheck_kaddr, pfprint_addr },
+{ "A", "s", pfproto_uaddr, pfcheck_uaddr, pfprint_uaddr },
+{ "c", "c", pfproto_csi, pfcheck_csi, pfprint_sint },
+{ "C", "s", pfproto_csi, pfcheck_csi, pfprint_echr },
+{ "d", "d", pfproto_xint, pfcheck_dint, pfprint_dint },
+{ "e", "e", pfproto_fp, pfcheck_fp, pfprint_fp },
+{ "E", "E", pfproto_fp, pfcheck_fp, pfprint_fp },
+{ "f", "f", pfproto_fp, pfcheck_fp, pfprint_fp },
+{ "g", "g", pfproto_fp, pfcheck_fp, pfprint_fp },
+{ "G", "G", pfproto_fp, pfcheck_fp, pfprint_fp },
+{ "hd", "d", "short", pfcheck_type, pfprint_sint },
+{ "hi", "i", "short", pfcheck_type, pfprint_sint },
+{ "ho", "o", "unsigned short", pfcheck_type, pfprint_uint },
+{ "hu", "u", "unsigned short", pfcheck_type, pfprint_uint },
+{ "hx", "x", "short", pfcheck_xshort, pfprint_uint },
+{ "hX", "X", "short", pfcheck_xshort, pfprint_uint },
+{ "i", "i", pfproto_xint, pfcheck_dint, pfprint_dint },
+{ "I", "s", pfproto_cstr, pfcheck_str, pfprint_inetaddr },
+{ "k", "s", "stack", pfcheck_stack, pfprint_stack },
+{ "lc", "lc", "int", pfcheck_type, pfprint_sint }, /* a.k.a. wint_t */
+{ "ld", "d", "long", pfcheck_type, pfprint_sint },
+{ "li", "i", "long", pfcheck_type, pfprint_sint },
+{ "lo", "o", "unsigned long", pfcheck_type, pfprint_uint },
+{ "lu", "u", "unsigned long", pfcheck_type, pfprint_uint },
+{ "ls", "ls", pfproto_wstr, pfcheck_wstr, pfprint_wstr },
+{ "lx", "x", "long", pfcheck_xlong, pfprint_uint },
+{ "lX", "X", "long", pfcheck_xlong, pfprint_uint },
+{ "lld", "d", "long long", pfcheck_type, pfprint_sint },
+{ "lli", "i", "long long", pfcheck_type, pfprint_sint },
+{ "llo", "o", "unsigned long long", pfcheck_type, pfprint_uint },
+{ "llu", "u", "unsigned long long", pfcheck_type, pfprint_uint },
+{ "llx", "x", "long long", pfcheck_xlonglong, pfprint_uint },
+{ "llX", "X", "long long", pfcheck_xlonglong, pfprint_uint },
+{ "Le", "e", "long double", pfcheck_type, pfprint_fp },
+{ "LE", "E", "long double", pfcheck_type, pfprint_fp },
+{ "Lf", "f", "long double", pfcheck_type, pfprint_fp },
+{ "Lg", "g", "long double", pfcheck_type, pfprint_fp },
+{ "LG", "G", "long double", pfcheck_type, pfprint_fp },
+{ "o", "o", pfproto_xint, pfcheck_xint, pfprint_uint },
+{ "p", "x", pfproto_addr, pfcheck_addr, pfprint_uint },
+{ "P", "s", "uint16_t", pfcheck_type, pfprint_port },
+{ "s", "s", "char [] or string (or use stringof)", pfcheck_str, pfprint_cstr },
+{ "S", "s", pfproto_cstr, pfcheck_str, pfprint_estr },
+{ "T", "s", "int64_t", pfcheck_time, pfprint_time822 },
+{ "u", "u", pfproto_xint, pfcheck_xint, pfprint_uint },
+{ "wc", "wc", "int", pfcheck_type, pfprint_sint }, /* a.k.a. wchar_t */
+{ "ws", "ws", pfproto_wstr, pfcheck_wstr, pfprint_wstr },
+{ "x", "x", pfproto_xint, pfcheck_xint, pfprint_uint },
+{ "X", "X", pfproto_xint, pfcheck_xint, pfprint_uint },
+{ "Y", "s", "int64_t", pfcheck_time, pfprint_time },
+{ "%", "%", "void", pfcheck_type, pfprint_pct },
+{ NULL, NULL, NULL, NULL, NULL }
+};
+
+int
+dt_pfdict_create(dtrace_hdl_t *dtp)
+{
+ uint_t n = _dtrace_strbuckets;
+ const dt_pfconv_t *pfd;
+ dt_pfdict_t *pdi;
+
+ if ((pdi = malloc(sizeof (dt_pfdict_t))) == NULL ||
+ (pdi->pdi_buckets = malloc(sizeof (dt_pfconv_t *) * n)) == NULL) {
+ free(pdi);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ dtp->dt_pfdict = pdi;
+ bzero(pdi->pdi_buckets, sizeof (dt_pfconv_t *) * n);
+ pdi->pdi_nbuckets = n;
+
+ for (pfd = _dtrace_conversions; pfd->pfc_name != NULL; pfd++) {
+ dtrace_typeinfo_t dtt;
+ dt_pfconv_t *pfc;
+ uint_t h;
+
+ if ((pfc = malloc(sizeof (dt_pfconv_t))) == NULL) {
+ dt_pfdict_destroy(dtp);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ bcopy(pfd, pfc, sizeof (dt_pfconv_t));
+ h = dt_strtab_hash(pfc->pfc_name, NULL) % n;
+ pfc->pfc_next = pdi->pdi_buckets[h];
+ pdi->pdi_buckets[h] = pfc;
+
+ dtt.dtt_ctfp = NULL;
+ dtt.dtt_type = CTF_ERR;
+
+ /*
+ * The "D" container or its parent must contain a definition of
+ * any type referenced by a printf conversion. If none can be
+ * found, we fail to initialize the printf dictionary.
+ */
+ if (pfc->pfc_check == &pfcheck_type && dtrace_lookup_by_type(
+ dtp, DTRACE_OBJ_DDEFS, pfc->pfc_tstr, &dtt) != 0) {
+ dt_pfdict_destroy(dtp);
+ return (dt_set_errno(dtp, EDT_NOCONV));
+ }
+
+ pfc->pfc_dctfp = dtt.dtt_ctfp;
+ pfc->pfc_dtype = dtt.dtt_type;
+
+ /*
+ * The "C" container may contain an alternate definition of an
+ * explicit conversion type. If it does, use it; otherwise
+ * just set pfc_ctype to pfc_dtype so it is always valid.
+ */
+ if (pfc->pfc_check == &pfcheck_type && dtrace_lookup_by_type(
+ dtp, DTRACE_OBJ_CDEFS, pfc->pfc_tstr, &dtt) == 0) {
+ pfc->pfc_cctfp = dtt.dtt_ctfp;
+ pfc->pfc_ctype = dtt.dtt_type;
+ } else {
+ pfc->pfc_cctfp = pfc->pfc_dctfp;
+ pfc->pfc_ctype = pfc->pfc_dtype;
+ }
+
+ if (pfc->pfc_check == NULL || pfc->pfc_print == NULL ||
+ pfc->pfc_ofmt == NULL || pfc->pfc_tstr == NULL) {
+ dt_pfdict_destroy(dtp);
+ return (dt_set_errno(dtp, EDT_BADCONV));
+ }
+
+ dt_dprintf("loaded printf conversion %%%s\n", pfc->pfc_name);
+ }
+
+ return (0);
+}
+
+void
+dt_pfdict_destroy(dtrace_hdl_t *dtp)
+{
+ dt_pfdict_t *pdi = dtp->dt_pfdict;
+ dt_pfconv_t *pfc, *nfc;
+ uint_t i;
+
+ if (pdi == NULL)
+ return;
+
+ for (i = 0; i < pdi->pdi_nbuckets; i++) {
+ for (pfc = pdi->pdi_buckets[i]; pfc != NULL; pfc = nfc) {
+ nfc = pfc->pfc_next;
+ free(pfc);
+ }
+ }
+
+ free(pdi->pdi_buckets);
+ free(pdi);
+ dtp->dt_pfdict = NULL;
+}
+
+static const dt_pfconv_t *
+dt_pfdict_lookup(dtrace_hdl_t *dtp, const char *name)
+{
+ dt_pfdict_t *pdi = dtp->dt_pfdict;
+ uint_t h = dt_strtab_hash(name, NULL) % pdi->pdi_nbuckets;
+ const dt_pfconv_t *pfc;
+
+ for (pfc = pdi->pdi_buckets[h]; pfc != NULL; pfc = pfc->pfc_next) {
+ if (strcmp(pfc->pfc_name, name) == 0)
+ break;
+ }
+
+ return (pfc);
+}
+
+static dt_pfargv_t *
+dt_printf_error(dtrace_hdl_t *dtp, int err)
+{
+ if (yypcb != NULL)
+ longjmp(yypcb->pcb_jmpbuf, err);
+
+ (void) dt_set_errno(dtp, err);
+ return (NULL);
+}
+
+dt_pfargv_t *
+dt_printf_create(dtrace_hdl_t *dtp, const char *s)
+{
+ dt_pfargd_t *pfd, *nfd = NULL;
+ dt_pfargv_t *pfv;
+ const char *p, *q;
+ char *format;
+
+ if ((pfv = malloc(sizeof (dt_pfargv_t))) == NULL ||
+ (format = strdup(s)) == NULL) {
+ free(pfv);
+ return (dt_printf_error(dtp, EDT_NOMEM));
+ }
+
+ pfv->pfv_format = format;
+ pfv->pfv_argv = NULL;
+ pfv->pfv_argc = 0;
+ pfv->pfv_flags = 0;
+ pfv->pfv_dtp = dtp;
+
+ for (q = format; (p = strchr(q, '%')) != NULL; q = *p ? p + 1 : p) {
+ uint_t namelen = 0;
+ int digits = 0;
+ int dot = 0;
+
+ char name[8];
+ char c;
+ int n;
+
+ if ((pfd = malloc(sizeof (dt_pfargd_t))) == NULL) {
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_NOMEM));
+ }
+
+ if (pfv->pfv_argv != NULL)
+ nfd->pfd_next = pfd;
+ else
+ pfv->pfv_argv = pfd;
+
+ bzero(pfd, sizeof (dt_pfargd_t));
+ pfv->pfv_argc++;
+ nfd = pfd;
+
+ if (p > q) {
+ pfd->pfd_preflen = (size_t)(p - q);
+ pfd->pfd_prefix = q;
+ }
+
+ fmt_switch:
+ switch (c = *++p) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ if (dot == 0 && digits == 0 && c == '0') {
+ pfd->pfd_flags |= DT_PFCONV_ZPAD;
+ pfd->pfd_flags &= ~DT_PFCONV_LEFT;
+ goto fmt_switch;
+ }
+
+ for (n = 0; isdigit(c); c = *++p)
+ n = n * 10 + c - '0';
+
+ if (dot)
+ pfd->pfd_prec = n;
+ else
+ pfd->pfd_width = n;
+
+ p--;
+ digits++;
+ goto fmt_switch;
+
+ case '#':
+ pfd->pfd_flags |= DT_PFCONV_ALT;
+ goto fmt_switch;
+
+ case '*':
+ n = dot ? DT_PFCONV_DYNPREC : DT_PFCONV_DYNWIDTH;
+
+ if (pfd->pfd_flags & n) {
+ yywarn("format conversion #%u has more than "
+ "one '*' specified for the output %s\n",
+ pfv->pfv_argc, n ? "precision" : "width");
+
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_COMPILER));
+ }
+
+ pfd->pfd_flags |= n;
+ goto fmt_switch;
+
+ case '+':
+ pfd->pfd_flags |= DT_PFCONV_SPOS;
+ goto fmt_switch;
+
+ case '-':
+ pfd->pfd_flags |= DT_PFCONV_LEFT;
+ pfd->pfd_flags &= ~DT_PFCONV_ZPAD;
+ goto fmt_switch;
+
+ case '.':
+ if (dot++ != 0) {
+ yywarn("format conversion #%u has more than "
+ "one '.' specified\n", pfv->pfv_argc);
+
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_COMPILER));
+ }
+ digits = 0;
+ goto fmt_switch;
+
+ case '?':
+ if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64)
+ pfd->pfd_width = 16;
+ else
+ pfd->pfd_width = 8;
+ goto fmt_switch;
+
+ case '@':
+ pfd->pfd_flags |= DT_PFCONV_AGG;
+ goto fmt_switch;
+
+ case '\'':
+ pfd->pfd_flags |= DT_PFCONV_GROUP;
+ goto fmt_switch;
+
+ case ' ':
+ pfd->pfd_flags |= DT_PFCONV_SPACE;
+ goto fmt_switch;
+
+ case '$':
+ yywarn("format conversion #%u uses unsupported "
+ "positional format (%%n$)\n", pfv->pfv_argc);
+
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_COMPILER));
+
+ case '%':
+ if (p[-1] == '%')
+ goto default_lbl; /* if %% then use "%" conv */
+
+ yywarn("format conversion #%u cannot be combined "
+ "with other format flags: %%%%\n", pfv->pfv_argc);
+
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_COMPILER));
+
+ case '\0':
+ yywarn("format conversion #%u name expected before "
+ "end of format string\n", pfv->pfv_argc);
+
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_COMPILER));
+
+ case 'h':
+ case 'l':
+ case 'L':
+ case 'w':
+ if (namelen < sizeof (name) - 2)
+ name[namelen++] = c;
+ goto fmt_switch;
+
+ default_lbl:
+ default:
+ name[namelen++] = c;
+ name[namelen] = '\0';
+ }
+
+ pfd->pfd_conv = dt_pfdict_lookup(dtp, name);
+
+ if (pfd->pfd_conv == NULL) {
+ yywarn("format conversion #%u is undefined: %%%s\n",
+ pfv->pfv_argc, name);
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_COMPILER));
+ }
+ }
+
+ if (*q != '\0' || *format == '\0') {
+ if ((pfd = malloc(sizeof (dt_pfargd_t))) == NULL) {
+ dt_printf_destroy(pfv);
+ return (dt_printf_error(dtp, EDT_NOMEM));
+ }
+
+ if (pfv->pfv_argv != NULL)
+ nfd->pfd_next = pfd;
+ else
+ pfv->pfv_argv = pfd;
+
+ bzero(pfd, sizeof (dt_pfargd_t));
+ pfv->pfv_argc++;
+
+ pfd->pfd_prefix = q;
+ pfd->pfd_preflen = strlen(q);
+ }
+
+ return (pfv);
+}
+
+void
+dt_printf_destroy(dt_pfargv_t *pfv)
+{
+ dt_pfargd_t *pfd, *nfd;
+
+ for (pfd = pfv->pfv_argv; pfd != NULL; pfd = nfd) {
+ nfd = pfd->pfd_next;
+ free(pfd);
+ }
+
+ free(pfv->pfv_format);
+ free(pfv);
+}
+
+void
+dt_printf_validate(dt_pfargv_t *pfv, uint_t flags,
+ dt_ident_t *idp, int foff, dtrace_actkind_t kind, dt_node_t *dnp)
+{
+ dt_pfargd_t *pfd = pfv->pfv_argv;
+ const char *func = idp->di_name;
+
+ char n[DT_TYPE_NAMELEN];
+ dtrace_typeinfo_t dtt;
+ const char *aggtype;
+ dt_node_t aggnode;
+ VBDTTYPE(uint_t,int) i, j;
+
+ if (pfv->pfv_format[0] == '\0') {
+ xyerror(D_PRINTF_FMT_EMPTY,
+ "%s( ) format string is empty\n", func);
+ }
+
+ pfv->pfv_flags = flags;
+
+ /*
+ * We fake up a parse node representing the type that can be used with
+ * an aggregation result conversion, which -- for all but count() --
+ * is a signed quantity.
+ */
+ if (kind != DTRACEAGG_COUNT)
+ aggtype = "int64_t";
+ else
+ aggtype = "uint64_t";
+
+ if (dt_type_lookup(aggtype, &dtt) != 0)
+ xyerror(D_TYPE_ERR, "failed to lookup agg type %s\n", aggtype);
+
+ bzero(&aggnode, sizeof (aggnode));
+ dt_node_type_assign(&aggnode, dtt.dtt_ctfp, dtt.dtt_type);
+
+ for (i = 0, j = 0; i < pfv->pfv_argc; i++, pfd = pfd->pfd_next) {
+ const dt_pfconv_t *pfc = pfd->pfd_conv;
+ const char *dyns[2];
+ int dync = 0;
+
+ char vname[64];
+ dt_node_t *vnp VBDTMSC(NULL);
+
+ if (pfc == NULL)
+ continue; /* no checking if argd is just a prefix */
+
+ if (pfc->pfc_print == &pfprint_pct) {
+ (void) strcat(pfd->pfd_fmt, pfc->pfc_ofmt);
+ continue;
+ }
+
+ if (pfd->pfd_flags & DT_PFCONV_DYNPREC)
+ dyns[dync++] = ".*";
+ if (pfd->pfd_flags & DT_PFCONV_DYNWIDTH)
+ dyns[dync++] = "*";
+
+ for (; dync != 0; dync--) {
+ if (dnp == NULL) {
+ xyerror(D_PRINTF_DYN_PROTO,
+ "%s( ) prototype mismatch: conversion "
+ "#%d (%%%s) is missing a corresponding "
+ "\"%s\" argument\n", func, i + 1,
+ pfc->pfc_name, dyns[dync - 1]);
+ }
+
+ if (dt_node_is_integer(dnp) == 0) {
+ xyerror(D_PRINTF_DYN_TYPE,
+ "%s( ) argument #%d is incompatible "
+ "with conversion #%d prototype:\n"
+ "\tconversion: %% %s %s\n"
+ "\t prototype: int\n\t argument: %s\n",
+ func, j + foff + 1, i + 1,
+ dyns[dync - 1], pfc->pfc_name,
+ dt_node_type_name(dnp, n, sizeof (n)));
+ }
+
+ dnp = dnp->dn_list;
+ j++;
+ }
+
+ /*
+ * If this conversion is consuming the aggregation data, set
+ * the value node pointer (vnp) to a fake node based on the
+ * aggregating function result type. Otherwise assign vnp to
+ * the next parse node in the argument list, if there is one.
+ */
+ if (pfd->pfd_flags & DT_PFCONV_AGG) {
+ if (!(flags & DT_PRINTF_AGGREGATION)) {
+ xyerror(D_PRINTF_AGG_CONV,
+ "%%@ conversion requires an aggregation"
+ " and is not for use with %s( )\n", func);
+ }
+ (void) strlcpy(vname, "aggregating action",
+ sizeof (vname));
+ vnp = &aggnode;
+ } else if (dnp == NULL) {
+ xyerror(D_PRINTF_ARG_PROTO,
+ "%s( ) prototype mismatch: conversion #%d (%%"
+ "%s) is missing a corresponding value argument\n",
+ func, i + 1, pfc->pfc_name);
+ } else {
+ (void) snprintf(vname, sizeof (vname),
+ "argument #%d", j + foff + 1);
+ vnp = dnp;
+ dnp = dnp->dn_list;
+ j++;
+ }
+
+ /*
+ * Fill in the proposed final format string by prepending any
+ * size-related prefixes to the pfconv's format string. The
+ * pfc_check() function below may optionally modify the format
+ * as part of validating the type of the input argument.
+ */
+ if (pfc->pfc_print == &pfprint_sint ||
+ pfc->pfc_print == &pfprint_uint ||
+ pfc->pfc_print == &pfprint_dint) {
+ if (dt_node_type_size(vnp) == sizeof (uint64_t))
+ (void) strcpy(pfd->pfd_fmt, "ll");
+ } else if (pfc->pfc_print == &pfprint_fp) {
+ if (dt_node_type_size(vnp) == sizeof (long double))
+ (void) strcpy(pfd->pfd_fmt, "L");
+ }
+
+ (void) strcat(pfd->pfd_fmt, pfc->pfc_ofmt);
+
+ /*
+ * Validate the format conversion against the value node type.
+ * If the conversion is good, create the descriptor format
+ * string by concatenating together any required printf(3C)
+ * size prefixes with the conversion's native format string.
+ */
+ if (pfc->pfc_check(pfv, pfd, vnp) == 0) {
+ xyerror(D_PRINTF_ARG_TYPE,
+ "%s( ) %s is incompatible with "
+ "conversion #%d prototype:\n\tconversion: %%%s\n"
+ "\t prototype: %s\n\t argument: %s\n", func,
+ vname, i + 1, pfc->pfc_name, pfc->pfc_tstr,
+ dt_node_type_name(vnp, n, sizeof (n)));
+ }
+ }
+
+ if ((flags & DT_PRINTF_EXACTLEN) && dnp != NULL) {
+ xyerror(D_PRINTF_ARG_EXTRA,
+ "%s( ) prototype mismatch: only %d arguments "
+ "required by this format string\n", func, j);
+ }
+}
+
+void
+dt_printa_validate(dt_node_t *lhs, dt_node_t *rhs)
+{
+ dt_ident_t *lid, *rid;
+ dt_node_t *lproto, *rproto;
+ int largc, rargc, argn;
+ char n1[DT_TYPE_NAMELEN];
+ char n2[DT_TYPE_NAMELEN];
+
+ assert(lhs->dn_kind == DT_NODE_AGG);
+ assert(rhs->dn_kind == DT_NODE_AGG);
+
+ lid = lhs->dn_ident;
+ rid = rhs->dn_ident;
+
+ lproto = ((dt_idsig_t *)lid->di_data)->dis_args;
+ rproto = ((dt_idsig_t *)rid->di_data)->dis_args;
+
+ /*
+ * First, get an argument count on each side. These must match.
+ */
+ for (largc = 0; lproto != NULL; lproto = lproto->dn_list)
+ largc++;
+
+ for (rargc = 0; rproto != NULL; rproto = rproto->dn_list)
+ rargc++;
+
+ if (largc != rargc) {
+ xyerror(D_PRINTA_AGGKEY, "printa( ): @%s and @%s do not have "
+ "matching key signatures: @%s has %d key%s, @%s has %d "
+ "key%s", lid->di_name, rid->di_name,
+ lid->di_name, largc, largc == 1 ? "" : "s",
+ rid->di_name, rargc, rargc == 1 ? "" : "s");
+ }
+
+ /*
+ * Now iterate over the keys to verify that each type matches.
+ */
+ lproto = ((dt_idsig_t *)lid->di_data)->dis_args;
+ rproto = ((dt_idsig_t *)rid->di_data)->dis_args;
+
+ for (argn = 1; lproto != NULL; argn++, lproto = lproto->dn_list,
+ rproto = rproto->dn_list) {
+ assert(rproto != NULL);
+
+ if (dt_node_is_argcompat(lproto, rproto))
+ continue;
+
+ xyerror(D_PRINTA_AGGPROTO, "printa( ): @%s[ ] key #%d is "
+ "incompatible with @%s:\n%9s key #%d: %s\n"
+ "%9s key #%d: %s\n",
+ rid->di_name, argn, lid->di_name, lid->di_name, argn,
+ dt_node_type_name(lproto, n1, sizeof (n1)), rid->di_name,
+ argn, dt_node_type_name(rproto, n2, sizeof (n2)));
+ }
+}
+
+static int
+dt_printf_getint(dtrace_hdl_t *dtp, const dtrace_recdesc_t *recp,
+ uint_t nrecs, const void *buf, size_t len, int *ip)
+{
+ uintptr_t addr;
+
+ if (nrecs == 0)
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ addr = (uintptr_t)buf + recp->dtrd_offset;
+
+ if (addr + sizeof (int) > (uintptr_t)buf + len)
+ return (dt_set_errno(dtp, EDT_DOFFSET));
+
+ if (addr & (recp->dtrd_alignment - 1))
+ return (dt_set_errno(dtp, EDT_DALIGN));
+
+ switch (recp->dtrd_size) {
+ case sizeof (int8_t):
+ *ip = (int)*((int8_t *)addr);
+ break;
+ case sizeof (int16_t):
+ *ip = (int)*((int16_t *)addr);
+ break;
+ case sizeof (int32_t):
+ *ip = (int)*((int32_t *)addr);
+ break;
+ case sizeof (int64_t):
+ *ip = (int)*((int64_t *)addr);
+ break;
+ default:
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+pfprint_average(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ const uint64_t *data = addr;
+ RT_NOREF1(pfd);
+
+ if (size != sizeof (uint64_t) * 2)
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ return (dt_printf(dtp, fp, format,
+ data[0] ? data[1] / normal / data[0] : 0));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_stddev(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ const uint64_t *data = addr;
+ RT_NOREF1(pfd);
+
+ if (size != sizeof (uint64_t) * 4)
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ return (dt_printf(dtp, fp, format,
+ dt_stddev((uint64_t *)data, normal)));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_quantize(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ RT_NOREF2(pfd, format);
+ return (dt_print_quantize(dtp, fp, addr, size, normal));
+}
+
+/*ARGSUSED*/
+static int
+pfprint_lquantize(dtrace_hdl_t *dtp, FILE *fp, const char *format,
+ const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal)
+{
+ RT_NOREF2(pfd, format);
+ return (dt_print_lquantize(dtp, fp, addr, size, normal));
+}
+
+static int
+dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
+ const dtrace_recdesc_t *recs, uint_t nrecs, const void *buf,
+ size_t len, const dtrace_aggdata_t **aggsdata, int naggvars)
+{
+ dt_pfargd_t *pfd = pfv->pfv_argv;
+ const dtrace_recdesc_t *recp = recs;
+ const dtrace_aggdata_t *aggdata VBDTMSC(NULL);
+ dtrace_aggdesc_t *agg;
+ caddr_t lim = (caddr_t)buf + len, limit;
+ char format[64] = "%";
+ int i, aggrec VBDTMSC(0), curagg = -1;
+ uint64_t normal;
+
+ /*
+ * If we are formatting an aggregation, set 'aggrec' to the index of
+ * the final record description (the aggregation result) so we can use
+ * this record index with any conversion where DT_PFCONV_AGG is set.
+ * (The actual aggregation used will vary as we increment through the
+ * aggregation variables that we have been passed.) Finally, we
+ * decrement nrecs to prevent this record from being used with any
+ * other conversion.
+ */
+ if (pfv->pfv_flags & DT_PRINTF_AGGREGATION) {
+ assert(aggsdata != NULL);
+ assert(naggvars > 0);
+
+ if (nrecs == 0)
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ curagg = naggvars > 1 ? 1 : 0;
+ aggdata = aggsdata[0];
+ aggrec = aggdata->dtada_desc->dtagd_nrecs - 1;
+ nrecs--;
+ }
+
+ for (i = 0; VBDTCAST(uint_t)i < pfv->pfv_argc; i++, pfd = pfd->pfd_next) {
+ const dt_pfconv_t *pfc = pfd->pfd_conv;
+ int width = pfd->pfd_width;
+ int prec = pfd->pfd_prec;
+ int rval;
+
+ char *f = format + 1; /* skip initial '%' */
+ const dtrace_recdesc_t *rec;
+ dt_pfprint_f *func;
+ caddr_t addr;
+ size_t size;
+ uint32_t flags VBDTUNASS(0);
+
+ if (pfd->pfd_preflen != 0) {
+ char *tmp = alloca(pfd->pfd_preflen + 1);
+
+ bcopy(pfd->pfd_prefix, tmp, pfd->pfd_preflen);
+ tmp[pfd->pfd_preflen] = '\0';
+
+ if ((rval = dt_printf(dtp, fp, tmp)) < 0)
+ return (rval);
+
+ if (pfv->pfv_flags & DT_PRINTF_AGGREGATION) {
+ /*
+ * For printa(), we flush the buffer after each
+ * prefix, setting the flags to indicate that
+ * this is part of the printa() format string.
+ */
+ flags = DTRACE_BUFDATA_AGGFORMAT;
+
+ if (pfc == NULL && VBDTCAST(uint_t)i == pfv->pfv_argc - 1)
+ flags |= DTRACE_BUFDATA_AGGLAST;
+
+ if (dt_buffered_flush(dtp, NULL, NULL,
+ aggdata, flags) < 0)
+ return (-1);
+ }
+ }
+
+ if (pfc == NULL) {
+ if (pfv->pfv_argc == 1)
+ return (nrecs != 0);
+ continue;
+ }
+
+ /*
+ * If the conversion is %%, just invoke the print callback
+ * with no data record and continue; it consumes no record.
+ */
+ if (pfc->pfc_print == &pfprint_pct) {
+ if (pfc->pfc_print(dtp, fp, NULL, pfd, NULL, 0, 1) >= 0)
+ continue;
+ return (-1); /* errno is set for us */
+ }
+
+ if (pfd->pfd_flags & DT_PFCONV_DYNWIDTH) {
+ if (dt_printf_getint(dtp, recp++, nrecs--, buf,
+ len, &width) == -1)
+ return (-1); /* errno is set for us */
+ pfd->pfd_dynwidth = width;
+ } else {
+ pfd->pfd_dynwidth = 0;
+ }
+
+ if ((pfd->pfd_flags & DT_PFCONV_DYNPREC) && dt_printf_getint(
+ dtp, recp++, nrecs--, buf, len, &prec) == -1)
+ return (-1); /* errno is set for us */
+
+ if (pfd->pfd_flags & DT_PFCONV_AGG) {
+ /*
+ * This should be impossible -- the compiler shouldn't
+ * create a DT_PFCONV_AGG conversion without an
+ * aggregation present. Still, we'd rather fail
+ * gracefully than blow up...
+ */
+ if (aggsdata == NULL)
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ aggdata = aggsdata[curagg];
+ agg = aggdata->dtada_desc;
+
+ /*
+ * We increment the current aggregation variable, but
+ * not beyond the number of aggregation variables that
+ * we're printing. This has the (desired) effect that
+ * DT_PFCONV_AGG conversions beyond the number of
+ * aggregation variables (re-)convert the aggregation
+ * value of the last aggregation variable.
+ */
+ if (curagg < naggvars - 1)
+ curagg++;
+
+ rec = &agg->dtagd_rec[aggrec];
+ addr = aggdata->dtada_data + rec->dtrd_offset;
+ limit = addr + aggdata->dtada_size;
+ normal = aggdata->dtada_normal;
+ flags = DTRACE_BUFDATA_AGGVAL;
+ } else {
+ if (nrecs == 0)
+ return (dt_set_errno(dtp, EDT_DMISMATCH));
+
+ if (pfv->pfv_flags & DT_PRINTF_AGGREGATION) {
+ /*
+ * When printing aggregation keys, we always
+ * set the aggdata to be the representative
+ * (zeroth) aggregation. The aggdata isn't
+ * actually used here in this case, but it is
+ * passed to the buffer handler and must
+ * therefore still be correct.
+ */
+ aggdata = aggsdata[0];
+ flags = DTRACE_BUFDATA_AGGKEY;
+ }
+
+ rec = recp++;
+ nrecs--;
+ addr = (caddr_t)buf + rec->dtrd_offset;
+ limit = lim;
+ normal = 1;
+ }
+
+ size = rec->dtrd_size;
+
+ if (addr + size > limit) {
+ dt_dprintf("bad size: addr=%p size=0x%x lim=%p\n",
+ (void *)addr, rec->dtrd_size, (void *)lim);
+ return (dt_set_errno(dtp, EDT_DOFFSET));
+ }
+
+ if (rec->dtrd_alignment != 0 &&
+ ((uintptr_t)addr & (rec->dtrd_alignment - 1)) != 0) {
+ dt_dprintf("bad align: addr=%p size=0x%x align=0x%x\n",
+ (void *)addr, rec->dtrd_size, rec->dtrd_alignment);
+ return (dt_set_errno(dtp, EDT_DALIGN));
+ }
+
+ switch (rec->dtrd_action) {
+ case DTRACEAGG_AVG:
+ func = pfprint_average;
+ break;
+ case DTRACEAGG_STDDEV:
+ func = pfprint_stddev;
+ break;
+ case DTRACEAGG_QUANTIZE:
+ func = pfprint_quantize;
+ break;
+ case DTRACEAGG_LQUANTIZE:
+ func = pfprint_lquantize;
+ break;
+ case DTRACEACT_MOD:
+ func = pfprint_mod;
+ break;
+ case DTRACEACT_UMOD:
+ func = pfprint_umod;
+ break;
+ default:
+ func = pfc->pfc_print;
+ break;
+ }
+
+ if (pfd->pfd_flags & DT_PFCONV_ALT)
+ *f++ = '#';
+ if (pfd->pfd_flags & DT_PFCONV_ZPAD)
+ *f++ = '0';
+ if (width < 0 || (pfd->pfd_flags & DT_PFCONV_LEFT))
+ *f++ = '-';
+ if (pfd->pfd_flags & DT_PFCONV_SPOS)
+ *f++ = '+';
+ if (pfd->pfd_flags & DT_PFCONV_GROUP)
+ *f++ = '\'';
+ if (pfd->pfd_flags & DT_PFCONV_SPACE)
+ *f++ = ' ';
+
+ /*
+ * If we're printing a stack and DT_PFCONV_LEFT is set, we
+ * don't add the width to the format string. See the block
+ * comment in pfprint_stack() for a description of the
+ * behavior in this case.
+ */
+ if (func == pfprint_stack && (pfd->pfd_flags & DT_PFCONV_LEFT))
+ width = 0;
+
+ if (width != 0)
+ f += snprintf(f, sizeof (format) - (f - format), "%d", ABS(width));
+
+ if (prec > 0)
+ f += snprintf(f, sizeof (format) - (f - format), ".%d", prec);
+
+ (void) strcpy(f, pfd->pfd_fmt);
+ pfd->pfd_rec = rec;
+
+ if (func(dtp, fp, format, pfd, addr, size, normal) < 0)
+ return (-1); /* errno is set for us */
+
+ if (pfv->pfv_flags & DT_PRINTF_AGGREGATION) {
+ /*
+ * For printa(), we flush the buffer after each tuple
+ * element, inidicating that this is the last record
+ * as appropriate.
+ */
+ if (VBDTCAST(uint_t)i == pfv->pfv_argc - 1)
+ flags |= DTRACE_BUFDATA_AGGLAST;
+
+ if (dt_buffered_flush(dtp, NULL,
+ rec, aggdata, flags) < 0)
+ return (-1);
+ }
+ }
+
+ return ((int)(recp - recs));
+}
+
+int
+dtrace_sprintf(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
+ const dtrace_recdesc_t *recp, uint_t nrecs, const void *buf, size_t len)
+{
+ dtrace_optval_t size;
+ int rval;
+
+ rval = dtrace_getopt(dtp, "strsize", &size);
+ assert(rval == 0);
+ assert(dtp->dt_sprintf_buflen == 0);
+
+ if (dtp->dt_sprintf_buf != NULL)
+ free(dtp->dt_sprintf_buf);
+
+ if ((dtp->dt_sprintf_buf = malloc(size)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ bzero(dtp->dt_sprintf_buf, size);
+ dtp->dt_sprintf_buflen = size;
+ rval = dt_printf_format(dtp, fp, fmtdata, recp, nrecs, buf, len,
+ NULL, 0);
+ dtp->dt_sprintf_buflen = 0;
+
+ if (rval == -1)
+ free(dtp->dt_sprintf_buf);
+
+ return (rval);
+}
+
+/*ARGSUSED*/
+int
+dtrace_system(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
+ const dtrace_probedata_t *data, const dtrace_recdesc_t *recp,
+ uint_t nrecs, const void *buf, size_t len)
+{
+ int rval = dtrace_sprintf(dtp, fp, fmtdata, recp, nrecs, buf, len);
+ RT_NOREF1(data);
+
+ if (rval == -1)
+ return (rval);
+
+ /*
+ * Before we execute the specified command, flush fp to assure that
+ * any prior dt_printf()'s appear before the output of the command
+ * not after it.
+ */
+ (void) fflush(fp);
+
+ if (system(dtp->dt_sprintf_buf) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ return (rval);
+}
+
+int
+dtrace_freopen(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
+ const dtrace_probedata_t *data, const dtrace_recdesc_t *recp,
+ uint_t nrecs, const void *buf, size_t len)
+{
+#ifndef VBOX
+ char selfbuf[40], restorebuf[40], *filename;
+ FILE *nfp;
+ dt_pfargv_t *pfv = fmtdata;
+ dt_pfargd_t *pfd = pfv->pfv_argv;
+#else
+ int rval, errval;
+#endif
+
+ rval = dtrace_sprintf(dtp, fp, fmtdata, recp, nrecs, buf, len);
+
+ if (rval == -1 || fp == NULL)
+ return (rval);
+
+#ifndef VBOX
+ if (pfd->pfd_preflen != 0 &&
+ strcmp(pfd->pfd_prefix, DT_FREOPEN_RESTORE) == 0) {
+ /*
+ * The only way to have the format string set to the value
+ * DT_FREOPEN_RESTORE is via the empty freopen() string --
+ * denoting that we should restore the old stdout.
+ */
+ assert(strcmp(dtp->dt_sprintf_buf, DT_FREOPEN_RESTORE) == 0);
+
+ if (dtp->dt_stdout_fd == -1) {
+ /*
+ * We could complain here by generating an error,
+ * but it seems like overkill: it seems that calling
+ * freopen() to restore stdout when freopen() has
+ * never before been called should just be a no-op,
+ * so we just return in this case.
+ */
+ return (rval);
+ }
+
+ (void) snprintf(restorebuf, sizeof (restorebuf),
+ "/dev/fd/%d", dtp->dt_stdout_fd);
+ filename = restorebuf;
+ } else {
+ filename = dtp->dt_sprintf_buf;
+ }
+
+ /*
+ * freopen(3C) will always close the specified stream and underlying
+ * file descriptor -- even if the specified file can't be opened.
+ * Even for the semantic cesspool that is standard I/O, this is
+ * surprisingly brain-dead behavior: it means that any failure to
+ * open the specified file destroys the specified stream in the
+ * process -- which is particularly relevant when the specified stream
+ * happens (or rather, happened) to be stdout. This could be resolved
+ * were there an "fdreopen()" equivalent of freopen() that allowed one
+ * to pass a file descriptor instead of the name of a file, but there
+ * is no such thing. However, we can effect this ourselves by first
+ * fopen()'ing the desired file, and then (assuming that that works),
+ * freopen()'ing "/dev/fd/[fileno]", where [fileno] is the underlying
+ * file descriptor for the fopen()'d file. This way, if the fopen()
+ * fails, we can fail the operation without destroying stdout.
+ */
+ if ((nfp = fopen(filename, "aF")) == NULL) {
+ char *msg = strerror(errno), *faultstr;
+ int len = 80;
+
+ len += strlen(msg) + strlen(filename);
+ faultstr = alloca(len);
+
+ (void) snprintf(faultstr, len, "couldn't freopen() \"%s\": %s",
+ filename, strerror(errno));
+
+ if ((errval = dt_handle_liberr(dtp, data, faultstr)) == 0)
+ return (rval);
+
+ return (errval);
+ }
+
+ (void) snprintf(selfbuf, sizeof (selfbuf), "/dev/fd/%d", fileno(nfp));
+
+ if (dtp->dt_stdout_fd == -1) {
+ /*
+ * If this is the first time that we're calling freopen(),
+ * we're going to stash away the file descriptor for stdout.
+ * We don't expect the dup(2) to fail, so if it does we must
+ * return failure.
+ */
+ if ((dtp->dt_stdout_fd = dup(fileno(fp))) == -1) {
+ (void) fclose(nfp);
+ return (dt_set_errno(dtp, errno));
+ }
+ }
+
+ if (freopen(selfbuf, "aF", fp) == NULL) {
+ (void) fclose(nfp);
+ return (dt_set_errno(dtp, errno));
+ }
+
+ (void) fclose(nfp);
+
+ return (rval);
+
+#else /* VBOX - the above is not easily portable because of /dev/fd/xxx. */
+ if ((errval = dt_handle_liberr(dtp, data, "reopening stdout is not implemented")) == 0)
+ return (rval);
+ return (errval);
+#endif
+}
+
+/*ARGSUSED*/
+int
+dtrace_fprintf(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
+ const dtrace_probedata_t *data, const dtrace_recdesc_t *recp,
+ uint_t nrecs, const void *buf, size_t len)
+{
+ RT_NOREF1(data);
+ return (dt_printf_format(dtp, fp, fmtdata,
+ recp, nrecs, buf, len, NULL, 0));
+}
+
+void *
+dtrace_printf_create(dtrace_hdl_t *dtp, const char *s)
+{
+ dt_pfargv_t *pfv = dt_printf_create(dtp, s);
+ dt_pfargd_t *pfd;
+ VBDTTYPE(uint_t,int) i;
+
+ if (pfv == NULL)
+ return (NULL); /* errno has been set for us */
+
+ pfd = pfv->pfv_argv;
+
+ for (i = 0; i < pfv->pfv_argc; i++, pfd = pfd->pfd_next) {
+ const dt_pfconv_t *pfc = pfd->pfd_conv;
+
+ if (pfc == NULL)
+ continue;
+
+ /*
+ * If the output format is not %s then we assume that we have
+ * been given a correctly-sized format string, so we copy the
+ * true format name including the size modifier. If the output
+ * format is %s, then either the input format is %s as well or
+ * it is one of our custom formats (e.g. pfprint_addr), so we
+ * must set pfd_fmt to be the output format conversion "s".
+ */
+ if (strcmp(pfc->pfc_ofmt, "s") != 0)
+ (void) strcat(pfd->pfd_fmt, pfc->pfc_name);
+ else
+ (void) strcat(pfd->pfd_fmt, pfc->pfc_ofmt);
+ }
+
+ return (pfv);
+}
+
+void *
+dtrace_printa_create(dtrace_hdl_t *dtp, const char *s)
+{
+ dt_pfargv_t *pfv = dtrace_printf_create(dtp, s);
+
+ if (pfv == NULL)
+ return (NULL); /* errno has been set for us */
+
+ pfv->pfv_flags |= DT_PRINTF_AGGREGATION;
+
+ return (pfv);
+}
+
+/*ARGSUSED*/
+size_t
+dtrace_printf_format(dtrace_hdl_t *dtp, void *fmtdata, char *s, size_t len)
+{
+ dt_pfargv_t *pfv = fmtdata;
+ dt_pfargd_t *pfd = pfv->pfv_argv;
+
+ /*
+ * An upper bound on the string length is the length of the original
+ * format string, plus three times the number of conversions (each
+ * conversion could add up an additional "ll" and/or pfd_width digit
+ * in the case of converting %? to %16) plus one for a terminating \0.
+ */
+ size_t formatlen = strlen(pfv->pfv_format) + 3 * pfv->pfv_argc + 1;
+ char *format = alloca(formatlen);
+ char *f = format;
+#ifndef VBOX
+ int i, j;
+#else
+ uint_t i;
+ size_t j;
+#endif
+ RT_NOREF1(dtp);
+
+ for (i = 0; i < pfv->pfv_argc; i++, pfd = pfd->pfd_next) {
+ const dt_pfconv_t *pfc = pfd->pfd_conv;
+ const char *str;
+ int width = pfd->pfd_width;
+ int prec = pfd->pfd_prec;
+
+ if (pfd->pfd_preflen != 0) {
+ for (j = 0; j < pfd->pfd_preflen; j++)
+ *f++ = pfd->pfd_prefix[j];
+ }
+
+ if (pfc == NULL)
+ continue;
+
+ *f++ = '%';
+
+ if (pfd->pfd_flags & DT_PFCONV_ALT)
+ *f++ = '#';
+ if (pfd->pfd_flags & DT_PFCONV_ZPAD)
+ *f++ = '0';
+ if (pfd->pfd_flags & DT_PFCONV_LEFT)
+ *f++ = '-';
+ if (pfd->pfd_flags & DT_PFCONV_SPOS)
+ *f++ = '+';
+ if (pfd->pfd_flags & DT_PFCONV_DYNWIDTH)
+ *f++ = '*';
+ if (pfd->pfd_flags & DT_PFCONV_DYNPREC) {
+ *f++ = '.';
+ *f++ = '*';
+ }
+ if (pfd->pfd_flags & DT_PFCONV_GROUP)
+ *f++ = '\'';
+ if (pfd->pfd_flags & DT_PFCONV_SPACE)
+ *f++ = ' ';
+ if (pfd->pfd_flags & DT_PFCONV_AGG)
+ *f++ = '@';
+
+ if (width != 0)
+ f += snprintf(f, sizeof (format), "%d", width);
+
+ if (prec != 0)
+ f += snprintf(f, sizeof (format), ".%d", prec);
+
+ /*
+ * If the output format is %s, then either %s is the underlying
+ * conversion or the conversion is one of our customized ones,
+ * e.g. pfprint_addr. In these cases, put the original string
+ * name of the conversion (pfc_name) into the pickled format
+ * string rather than the derived conversion (pfd_fmt).
+ */
+ if (strcmp(pfc->pfc_ofmt, "s") == 0)
+ str = pfc->pfc_name;
+ else
+ str = pfd->pfd_fmt;
+
+ for (j = 0; str[j] != '\0'; j++)
+ *f++ = str[j];
+ }
+
+ *f = '\0'; /* insert nul byte; do not count in return value */
+
+ assert(f < format + formatlen);
+ (void) strncpy(s, format, len);
+
+ return ((size_t)(f - format));
+}
+
+static int
+dt_fprinta(const dtrace_aggdata_t *adp, void *arg)
+{
+ const dtrace_aggdesc_t *agg = adp->dtada_desc;
+ const dtrace_recdesc_t *recp = &agg->dtagd_rec[0];
+ uint_t nrecs = agg->dtagd_nrecs;
+ dt_pfwalk_t *pfw = arg;
+ dtrace_hdl_t *dtp = pfw->pfw_argv->pfv_dtp;
+ int id;
+
+ if (dt_printf_getint(dtp, recp++, nrecs--,
+ adp->dtada_data, adp->dtada_size, &id) != 0 || pfw->pfw_aid != VBDTCAST(uint_t)id)
+ return (0); /* no aggregation id or id does not match */
+
+ if (dt_printf_format(dtp, pfw->pfw_fp, pfw->pfw_argv,
+ recp, nrecs, adp->dtada_data, adp->dtada_size, &adp, 1) == -1)
+ return (pfw->pfw_err = dtp->dt_errno);
+
+ /*
+ * Cast away the const to set the bit indicating that this aggregation
+ * has been printed.
+ */
+ ((dtrace_aggdesc_t *)agg)->dtagd_flags |= DTRACE_AGD_PRINTED;
+
+ return (0);
+}
+
+static int
+dt_fprintas(const dtrace_aggdata_t **aggsdata, int naggvars, void *arg)
+{
+ const dtrace_aggdata_t *aggdata = aggsdata[0];
+ const dtrace_aggdesc_t *agg = aggdata->dtada_desc;
+ const dtrace_recdesc_t *rec = &agg->dtagd_rec[1];
+ uint_t nrecs = agg->dtagd_nrecs - 1;
+ dt_pfwalk_t *pfw = arg;
+ dtrace_hdl_t *dtp = pfw->pfw_argv->pfv_dtp;
+ int i;
+
+ if (dt_printf_format(dtp, pfw->pfw_fp, pfw->pfw_argv,
+ rec, nrecs, aggdata->dtada_data, aggdata->dtada_size,
+ aggsdata, naggvars) == -1)
+ return (pfw->pfw_err = dtp->dt_errno);
+
+ /*
+ * For each aggregation, indicate that it has been printed, casting
+ * away the const as necessary.
+ */
+ for (i = 1; i < naggvars; i++) {
+ agg = aggsdata[i]->dtada_desc;
+ ((dtrace_aggdesc_t *)agg)->dtagd_flags |= DTRACE_AGD_PRINTED;
+ }
+
+ return (0);
+}
+/*ARGSUSED*/
+int
+dtrace_fprinta(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
+ const dtrace_probedata_t *data, const dtrace_recdesc_t *recs,
+ uint_t nrecs, const void *buf, size_t len)
+{
+ dt_pfwalk_t pfw;
+ int i, naggvars = 0;
+ dtrace_aggvarid_t *aggvars;
+ RT_NOREF2(data, len);
+
+ aggvars = alloca(nrecs * sizeof (dtrace_aggvarid_t));
+
+ /*
+ * This might be a printa() with multiple aggregation variables. We
+ * need to scan forward through the records until we find a record from
+ * a different statement.
+ */
+ for (i = 0; VBDTCAST(uint_t)i < nrecs; i++) {
+ const dtrace_recdesc_t *nrec = &recs[i];
+
+ if (nrec->dtrd_uarg != recs->dtrd_uarg)
+ break;
+
+ if (nrec->dtrd_action != recs->dtrd_action)
+ return (dt_set_errno(dtp, EDT_BADAGG));
+
+ aggvars[naggvars++] =
+ /* LINTED - alignment */
+ *((dtrace_aggvarid_t *)((caddr_t)buf + nrec->dtrd_offset));
+ }
+
+ if (naggvars == 0)
+ return (dt_set_errno(dtp, EDT_BADAGG));
+
+ pfw.pfw_argv = fmtdata;
+ pfw.pfw_fp = fp;
+ pfw.pfw_err = 0;
+
+ if (naggvars == 1) {
+ pfw.pfw_aid = aggvars[0];
+
+ if (dtrace_aggregate_walk_sorted(dtp,
+ dt_fprinta, &pfw) == -1 || pfw.pfw_err != 0)
+ return (-1); /* errno is set for us */
+ } else {
+ if (dtrace_aggregate_walk_joined(dtp, aggvars, naggvars,
+ dt_fprintas, &pfw) == -1 || pfw.pfw_err != 0)
+ return (-1); /* errno is set for us */
+ }
+
+ return (i);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.h
new file mode 100644
index 00000000..7f32189f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_printf.h
@@ -0,0 +1,137 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_PRINTF_H
+#define _DT_PRINTF_H
+
+#ifndef VBOX
+# pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#endif
+#include <libctf.h>
+#include <dtrace.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct dt_node;
+struct dt_ident;
+
+struct dt_pfconv;
+struct dt_pfargv;
+struct dt_pfargd;
+
+typedef int dt_pfcheck_f(struct dt_pfargv *,
+ struct dt_pfargd *, struct dt_node *);
+typedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *,
+ const struct dt_pfargd *, const void *, size_t, uint64_t);
+
+typedef struct dt_pfconv {
+ const char *pfc_name; /* string name of input conversion */
+ const char *pfc_ofmt; /* string name of output conversion */
+ const char *pfc_tstr; /* string name for conversion type */
+ dt_pfcheck_f *pfc_check; /* function to use for type checking */
+ dt_pfprint_f *pfc_print; /* function to use for formatting */
+ ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */
+ ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */
+ ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */
+ ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */
+ struct dt_pfconv *pfc_next; /* next conversion in hash chain */
+} dt_pfconv_t;
+
+typedef struct dt_pfdict {
+ dt_pfconv_t **pdi_buckets; /* hash bucket array */
+ uint_t pdi_nbuckets; /* size of hash bucket array */
+} dt_pfdict_t;
+
+typedef struct dt_pfargd {
+ const char *pfd_prefix; /* prefix string pointer (or NULL) */
+ size_t pfd_preflen; /* length of prefix in bytes */
+ char pfd_fmt[8]; /* output format name to use */
+ uint_t pfd_flags; /* format flags (see below) */
+ int pfd_width; /* field width (or 0) */
+ int pfd_dynwidth; /* dynamic field width (or 0) */
+ int pfd_prec; /* field precision (or 0) */
+ const dt_pfconv_t *pfd_conv; /* conversion specification */
+ const dtrace_recdesc_t *pfd_rec; /* pointer to current record */
+ struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */
+} dt_pfargd_t;
+
+#define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */
+#define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */
+#define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */
+#define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */
+#define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */
+#define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */
+#define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */
+#define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */
+#define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */
+#define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */
+
+typedef struct dt_pfargv {
+ dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */
+ char *pfv_format; /* format string pointer */
+ dt_pfargd_t *pfv_argv; /* list of argument descriptors */
+ uint_t pfv_argc; /* number of argument descriptors */
+ uint_t pfv_flags; /* flags used for validation */
+} dt_pfargv_t;
+
+typedef struct dt_pfwalk {
+ const dt_pfargv_t *pfw_argv; /* argument description list */
+ uint_t pfw_aid; /* aggregation variable identifier */
+ FILE *pfw_fp; /* file pointer to use for output */
+ int pfw_err; /* error status code */
+} dt_pfwalk_t;
+
+extern int dt_pfdict_create(dtrace_hdl_t *);
+extern void dt_pfdict_destroy(dtrace_hdl_t *);
+
+extern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *);
+extern void dt_printf_destroy(dt_pfargv_t *);
+
+#define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */
+#define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */
+
+extern void dt_printf_validate(dt_pfargv_t *, uint_t,
+ struct dt_ident *, int, dtrace_actkind_t, struct dt_node *);
+
+extern void dt_printa_validate(struct dt_node *, struct dt_node *);
+
+extern int dt_print_stack(dtrace_hdl_t *, FILE *,
+ const char *, caddr_t, int, int);
+extern int dt_print_ustack(dtrace_hdl_t *, FILE *,
+ const char *, caddr_t, uint64_t);
+extern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t);
+extern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PRINTF_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.c
new file mode 100644
index 00000000..5a46ee31
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.c
@@ -0,0 +1,1111 @@
+/*
+ * 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 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * DTrace Process Control
+ *
+ * This file provides a set of routines that permit libdtrace and its clients
+ * to create and grab process handles using libproc, and to share these handles
+ * between library mechanisms that need libproc access, such as ustack(), and
+ * client mechanisms that need libproc access, such as dtrace(1M) -c and -p.
+ * The library provides several mechanisms in the libproc control layer:
+ *
+ * Reference Counting: The library code and client code can independently grab
+ * the same process handles without interfering with one another. Only when
+ * the reference count drops to zero and the handle is not being cached (see
+ * below for more information on caching) will Prelease() be called on it.
+ *
+ * Handle Caching: If a handle is grabbed PGRAB_RDONLY (e.g. by ustack()) and
+ * the reference count drops to zero, the handle is not immediately released.
+ * Instead, libproc handles are maintained on dph_lrulist in order from most-
+ * recently accessed to least-recently accessed. Idle handles are maintained
+ * until a pre-defined LRU cache limit is exceeded, permitting repeated calls
+ * to ustack() to avoid the overhead of releasing and re-grabbing processes.
+ *
+ * Process Control: For processes that are grabbed for control (~PGRAB_RDONLY)
+ * or created by dt_proc_create(), a control thread is created to provide
+ * callbacks on process exit and symbol table caching on dlopen()s.
+ *
+ * MT-Safety: Libproc is not MT-Safe, so dt_proc_lock() and dt_proc_unlock()
+ * are provided to synchronize access to the libproc handle between libdtrace
+ * code and client code and the control thread's use of the ps_prochandle.
+ *
+ * NOTE: MT-Safety is NOT provided for libdtrace itself, or for use of the
+ * dtrace_proc_grab/dtrace_proc_create mechanisms. Like all exported libdtrace
+ * calls, these are assumed to be MT-Unsafe. MT-Safety is ONLY provided for
+ * synchronization between libdtrace control threads and the client thread.
+ *
+ * The ps_prochandles themselves are maintained along with a dt_proc_t struct
+ * in a hash table indexed by PID. This provides basic locking and reference
+ * counting. The dt_proc_t is also maintained in LRU order on dph_lrulist.
+ * The dph_lrucnt and dph_lrulim count the number of cacheable processes and
+ * the current limit on the number of actively cached entries.
+ *
+ * The control thread for a process establishes breakpoints at the rtld_db
+ * locations of interest, updates mappings and symbol tables at these points,
+ * and handles exec and fork (by always following the parent). The control
+ * thread automatically exits when the process dies or control is lost.
+ *
+ * A simple notification mechanism is provided for libdtrace clients using
+ * dtrace_handle_proc() for notification of PS_UNDEAD or PS_LOST events. If
+ * such an event occurs, the dt_proc_t itself is enqueued on a notification
+ * list and the control thread broadcasts to dph_cv. dtrace_sleep() will wake
+ * up using this condition and will then call the client handler as necessary.
+ */
+
+#ifndef VBOX
+#include <sys/wait.h>
+#include <sys/lwp.h>
+#include <strings.h>
+#include <signal.h>
+#include <assert.h>
+#include <errno.h>
+#endif
+
+#include <dt_proc.h>
+#include <dt_pid.h>
+#include <dt_impl.h>
+
+#ifndef VBOX
+
+#define IS_SYS_EXEC(w) (w == SYS_execve)
+#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_forksys)
+
+static dt_bkpt_t *
+dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data)
+{
+ struct ps_prochandle *P = dpr->dpr_proc;
+ dt_bkpt_t *dbp;
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+
+ if ((dbp = dt_zalloc(dpr->dpr_hdl, sizeof (dt_bkpt_t))) != NULL) {
+ dbp->dbp_func = func;
+ dbp->dbp_data = data;
+ dbp->dbp_addr = addr;
+
+ if (Psetbkpt(P, dbp->dbp_addr, &dbp->dbp_instr) == 0)
+ dbp->dbp_active = B_TRUE;
+
+ dt_list_append(&dpr->dpr_bps, dbp);
+ }
+
+ return (dbp);
+}
+
+static void
+dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts)
+{
+ int state = Pstate(dpr->dpr_proc);
+ dt_bkpt_t *dbp, *nbp;
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+
+ for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = nbp) {
+ if (delbkpts && dbp->dbp_active &&
+ state != PS_LOST && state != PS_UNDEAD) {
+ (void) Pdelbkpt(dpr->dpr_proc,
+ dbp->dbp_addr, dbp->dbp_instr);
+ }
+ nbp = dt_list_next(dbp);
+ dt_list_delete(&dpr->dpr_bps, dbp);
+ dt_free(dpr->dpr_hdl, dbp);
+ }
+}
+
+static void
+dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr)
+{
+ const lwpstatus_t *psp = &Pstatus(dpr->dpr_proc)->pr_lwp;
+ dt_bkpt_t *dbp;
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+
+ for (dbp = dt_list_next(&dpr->dpr_bps);
+ dbp != NULL; dbp = dt_list_next(dbp)) {
+ if (psp->pr_reg[R_PC] == dbp->dbp_addr)
+ break;
+ }
+
+ if (dbp == NULL) {
+ dt_dprintf("pid %d: spurious breakpoint wakeup for %lx\n",
+ (int)dpr->dpr_pid, (ulong_t)psp->pr_reg[R_PC]);
+ return;
+ }
+
+ dt_dprintf("pid %d: hit breakpoint at %lx (%lu)\n",
+ (int)dpr->dpr_pid, (ulong_t)dbp->dbp_addr, ++dbp->dbp_hits);
+
+ dbp->dbp_func(dtp, dpr, dbp->dbp_data);
+ (void) Pxecbkpt(dpr->dpr_proc, dbp->dbp_instr);
+}
+
+static void
+dt_proc_bpenable(dt_proc_t *dpr)
+{
+ dt_bkpt_t *dbp;
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+
+ for (dbp = dt_list_next(&dpr->dpr_bps);
+ dbp != NULL; dbp = dt_list_next(dbp)) {
+ if (!dbp->dbp_active && Psetbkpt(dpr->dpr_proc,
+ dbp->dbp_addr, &dbp->dbp_instr) == 0)
+ dbp->dbp_active = B_TRUE;
+ }
+
+ dt_dprintf("breakpoints enabled\n");
+}
+
+static void
+dt_proc_bpdisable(dt_proc_t *dpr)
+{
+ dt_bkpt_t *dbp;
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+
+ for (dbp = dt_list_next(&dpr->dpr_bps);
+ dbp != NULL; dbp = dt_list_next(dbp)) {
+ if (dbp->dbp_active && Pdelbkpt(dpr->dpr_proc,
+ dbp->dbp_addr, dbp->dbp_instr) == 0)
+ dbp->dbp_active = B_FALSE;
+ }
+
+ dt_dprintf("breakpoints disabled\n");
+}
+
+static void
+dt_proc_notify(dtrace_hdl_t *dtp, dt_proc_hash_t *dph, dt_proc_t *dpr,
+ const char *msg)
+{
+ dt_proc_notify_t *dprn = dt_alloc(dtp, sizeof (dt_proc_notify_t));
+
+ if (dprn == NULL) {
+ dt_dprintf("failed to allocate notification for %d %s\n",
+ (int)dpr->dpr_pid, msg);
+ } else {
+ dprn->dprn_dpr = dpr;
+ if (msg == NULL)
+ dprn->dprn_errmsg[0] = '\0';
+ else
+ (void) strlcpy(dprn->dprn_errmsg, msg,
+ sizeof (dprn->dprn_errmsg));
+
+ (void) pthread_mutex_lock(&dph->dph_lock);
+
+ dprn->dprn_next = dph->dph_notify;
+ dph->dph_notify = dprn;
+
+ (void) pthread_cond_broadcast(&dph->dph_cv);
+ (void) pthread_mutex_unlock(&dph->dph_lock);
+ }
+}
+
+/*
+ * Check to see if the control thread was requested to stop when the victim
+ * process reached a particular event (why) rather than continuing the victim.
+ * If 'why' is set in the stop mask, we wait on dpr_cv for dt_proc_continue().
+ * If 'why' is not set, this function returns immediately and does nothing.
+ */
+static void
+dt_proc_stop(dt_proc_t *dpr, uint8_t why)
+{
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+ assert(why != DT_PROC_STOP_IDLE);
+
+ if (dpr->dpr_stop & why) {
+ dpr->dpr_stop |= DT_PROC_STOP_IDLE;
+ dpr->dpr_stop &= ~why;
+
+ (void) pthread_cond_broadcast(&dpr->dpr_cv);
+
+ /*
+ * We disable breakpoints while stopped to preserve the
+ * integrity of the program text for both our own disassembly
+ * and that of the kernel.
+ */
+ dt_proc_bpdisable(dpr);
+
+ while (dpr->dpr_stop & DT_PROC_STOP_IDLE)
+ (void) pthread_cond_wait(&dpr->dpr_cv, &dpr->dpr_lock);
+
+ dt_proc_bpenable(dpr);
+ }
+}
+
+/*ARGSUSED*/
+static void
+dt_proc_bpmain(dtrace_hdl_t *dtp, dt_proc_t *dpr, const char *fname)
+{
+ dt_dprintf("pid %d: breakpoint at %s()\n", (int)dpr->dpr_pid, fname);
+ dt_proc_stop(dpr, DT_PROC_STOP_MAIN);
+}
+
+static void
+dt_proc_rdevent(dtrace_hdl_t *dtp, dt_proc_t *dpr, const char *evname)
+{
+ rd_event_msg_t rdm;
+ rd_err_e err;
+
+ if ((err = rd_event_getmsg(dpr->dpr_rtld, &rdm)) != RD_OK) {
+ dt_dprintf("pid %d: failed to get %s event message: %s\n",
+ (int)dpr->dpr_pid, evname, rd_errstr(err));
+ return;
+ }
+
+ dt_dprintf("pid %d: rtld event %s type=%d state %d\n",
+ (int)dpr->dpr_pid, evname, rdm.type, rdm.u.state);
+
+ switch (rdm.type) {
+ case RD_DLACTIVITY:
+ if (rdm.u.state != RD_CONSISTENT)
+ break;
+
+ Pupdate_syms(dpr->dpr_proc);
+ if (dt_pid_create_probes_module(dtp, dpr) != 0)
+ dt_proc_notify(dtp, dtp->dt_procs, dpr,
+ dpr->dpr_errmsg);
+
+ break;
+ case RD_PREINIT:
+ Pupdate_syms(dpr->dpr_proc);
+ dt_proc_stop(dpr, DT_PROC_STOP_PREINIT);
+ break;
+ case RD_POSTINIT:
+ Pupdate_syms(dpr->dpr_proc);
+ dt_proc_stop(dpr, DT_PROC_STOP_POSTINIT);
+ break;
+ }
+}
+
+static void
+dt_proc_rdwatch(dt_proc_t *dpr, rd_event_e event, const char *evname)
+{
+ rd_notify_t rdn;
+ rd_err_e err;
+
+ if ((err = rd_event_addr(dpr->dpr_rtld, event, &rdn)) != RD_OK) {
+ dt_dprintf("pid %d: failed to get event address for %s: %s\n",
+ (int)dpr->dpr_pid, evname, rd_errstr(err));
+ return;
+ }
+
+ if (rdn.type != RD_NOTIFY_BPT) {
+ dt_dprintf("pid %d: event %s has unexpected type %d\n",
+ (int)dpr->dpr_pid, evname, rdn.type);
+ return;
+ }
+
+ (void) dt_proc_bpcreate(dpr, rdn.u.bptaddr,
+ (dt_bkpt_f *)dt_proc_rdevent, (void *)evname);
+}
+
+/*
+ * Common code for enabling events associated with the run-time linker after
+ * attaching to a process or after a victim process completes an exec(2).
+ */
+static void
+dt_proc_attach(dt_proc_t *dpr, int exec)
+{
+ const pstatus_t *psp = Pstatus(dpr->dpr_proc);
+ rd_err_e err;
+ GElf_Sym sym;
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+
+ if (exec) {
+ if (psp->pr_lwp.pr_errno != 0)
+ return; /* exec failed: nothing needs to be done */
+
+ dt_proc_bpdestroy(dpr, B_FALSE);
+ Preset_maps(dpr->dpr_proc);
+ }
+
+ if ((dpr->dpr_rtld = Prd_agent(dpr->dpr_proc)) != NULL &&
+ (err = rd_event_enable(dpr->dpr_rtld, B_TRUE)) == RD_OK) {
+ dt_proc_rdwatch(dpr, RD_PREINIT, "RD_PREINIT");
+ dt_proc_rdwatch(dpr, RD_POSTINIT, "RD_POSTINIT");
+ dt_proc_rdwatch(dpr, RD_DLACTIVITY, "RD_DLACTIVITY");
+ } else {
+ dt_dprintf("pid %d: failed to enable rtld events: %s\n",
+ (int)dpr->dpr_pid, dpr->dpr_rtld ? rd_errstr(err) :
+ "rtld_db agent initialization failed");
+ }
+
+ Pupdate_maps(dpr->dpr_proc);
+
+ if (Pxlookup_by_name(dpr->dpr_proc, LM_ID_BASE,
+ "a.out", "main", &sym, NULL) == 0) {
+ (void) dt_proc_bpcreate(dpr, (uintptr_t)sym.st_value,
+ (dt_bkpt_f *)dt_proc_bpmain, "a.out`main");
+ } else {
+ dt_dprintf("pid %d: failed to find a.out`main: %s\n",
+ (int)dpr->dpr_pid, strerror(errno));
+ }
+}
+
+/*
+ * Wait for a stopped process to be set running again by some other debugger.
+ * This is typically not required by /proc-based debuggers, since the usual
+ * model is that one debugger controls one victim. But DTrace, as usual, has
+ * its own needs: the stop() action assumes that prun(1) or some other tool
+ * will be applied to resume the victim process. This could be solved by
+ * adding a PCWRUN directive to /proc, but that seems like overkill unless
+ * other debuggers end up needing this functionality, so we implement a cheap
+ * equivalent to PCWRUN using the set of existing kernel mechanisms.
+ *
+ * Our intent is really not just to wait for the victim to run, but rather to
+ * wait for it to run and then stop again for a reason other than the current
+ * PR_REQUESTED stop. Since PCWSTOP/Pstopstatus() can be applied repeatedly
+ * to a stopped process and will return the same result without affecting the
+ * victim, we can just perform these operations repeatedly until Pstate()
+ * changes, the representative LWP ID changes, or the stop timestamp advances.
+ * dt_proc_control() will then rediscover the new state and continue as usual.
+ * When the process is still stopped in the same exact state, we sleep for a
+ * brief interval before waiting again so as not to spin consuming CPU cycles.
+ */
+static void
+dt_proc_waitrun(dt_proc_t *dpr)
+{
+ struct ps_prochandle *P = dpr->dpr_proc;
+ const lwpstatus_t *psp = &Pstatus(P)->pr_lwp;
+
+ int krflag = psp->pr_flags & (PR_KLC | PR_RLC);
+ timestruc_t tstamp = psp->pr_tstamp;
+ lwpid_t lwpid = psp->pr_lwpid;
+
+ const long wstop = PCWSTOP;
+ int pfd = Pctlfd(P);
+
+ assert(MUTEX_HELD(&dpr->dpr_lock));
+ assert(psp->pr_flags & PR_STOPPED);
+ assert(Pstate(P) == PS_STOP);
+
+ /*
+ * While we are waiting for the victim to run, clear PR_KLC and PR_RLC
+ * so that if the libdtrace client is killed, the victim stays stopped.
+ * dt_proc_destroy() will also observe this and perform PRELEASE_HANG.
+ */
+ (void) Punsetflags(P, krflag);
+ Psync(P);
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+
+ while (!dpr->dpr_quit) {
+ if (write(pfd, &wstop, sizeof (wstop)) == -1 && errno == EINTR)
+ continue; /* check dpr_quit and continue waiting */
+
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+ (void) Pstopstatus(P, PCNULL, 0);
+ psp = &Pstatus(P)->pr_lwp;
+
+ /*
+ * If we've reached a new state, found a new representative, or
+ * the stop timestamp has changed, restore PR_KLC/PR_RLC to its
+ * original setting and then return with dpr_lock held.
+ */
+ if (Pstate(P) != PS_STOP || psp->pr_lwpid != lwpid ||
+ bcmp(&psp->pr_tstamp, &tstamp, sizeof (tstamp)) != 0) {
+ (void) Psetflags(P, krflag);
+ Psync(P);
+ return;
+ }
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ (void) poll(NULL, 0, MILLISEC / 2);
+ }
+
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+}
+
+typedef struct dt_proc_control_data {
+ dtrace_hdl_t *dpcd_hdl; /* DTrace handle */
+ dt_proc_t *dpcd_proc; /* proccess to control */
+} dt_proc_control_data_t;
+
+/*
+ * Main loop for all victim process control threads. We initialize all the
+ * appropriate /proc control mechanisms, and then enter a loop waiting for
+ * the process to stop on an event or die. We process any events by calling
+ * appropriate subroutines, and exit when the victim dies or we lose control.
+ *
+ * The control thread synchronizes the use of dpr_proc with other libdtrace
+ * threads using dpr_lock. We hold the lock for all of our operations except
+ * waiting while the process is running: this is accomplished by writing a
+ * PCWSTOP directive directly to the underlying /proc/<pid>/ctl file. If the
+ * libdtrace client wishes to exit or abort our wait, SIGCANCEL can be used.
+ */
+static void *
+dt_proc_control(void *arg)
+{
+ dt_proc_control_data_t *datap = arg;
+ dtrace_hdl_t *dtp = datap->dpcd_hdl;
+ dt_proc_t *dpr = datap->dpcd_proc;
+ dt_proc_hash_t *dph = dpr->dpr_hdl->dt_procs;
+ struct ps_prochandle *P = dpr->dpr_proc;
+
+ int pfd = Pctlfd(P);
+ int pid = dpr->dpr_pid;
+
+ const long wstop = PCWSTOP;
+ int notify = B_FALSE;
+
+ /*
+ * We disable the POSIX thread cancellation mechanism so that the
+ * client program using libdtrace can't accidentally cancel our thread.
+ * dt_proc_destroy() uses SIGCANCEL explicitly to simply poke us out
+ * of PCWSTOP with EINTR, at which point we will see dpr_quit and exit.
+ */
+ (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+
+ /*
+ * Set up the corresponding process for tracing by libdtrace. We want
+ * to be able to catch breakpoints and efficiently single-step over
+ * them, and we need to enable librtld_db to watch libdl activity.
+ */
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+
+ (void) Punsetflags(P, PR_ASYNC); /* require synchronous mode */
+ (void) Psetflags(P, PR_BPTADJ); /* always adjust eip on x86 */
+ (void) Punsetflags(P, PR_FORK); /* do not inherit on fork */
+
+ (void) Pfault(P, FLTBPT, B_TRUE); /* always trace breakpoints */
+ (void) Pfault(P, FLTTRACE, B_TRUE); /* always trace single-step */
+
+ /*
+ * We must trace exit from exec() system calls so that if the exec is
+ * successful, we can reset our breakpoints and re-initialize libproc.
+ */
+ (void) Psysexit(P, SYS_execve, B_TRUE);
+
+ /*
+ * We must trace entry and exit for fork() system calls in order to
+ * disable our breakpoints temporarily during the fork. We do not set
+ * the PR_FORK flag, so if fork succeeds the child begins executing and
+ * does not inherit any other tracing behaviors or a control thread.
+ */
+ (void) Psysentry(P, SYS_vfork, B_TRUE);
+ (void) Psysexit(P, SYS_vfork, B_TRUE);
+ (void) Psysentry(P, SYS_forksys, B_TRUE);
+ (void) Psysexit(P, SYS_forksys, B_TRUE);
+
+ Psync(P); /* enable all /proc changes */
+ dt_proc_attach(dpr, B_FALSE); /* enable rtld breakpoints */
+
+ /*
+ * If PR_KLC is set, we created the process; otherwise we grabbed it.
+ * Check for an appropriate stop request and wait for dt_proc_continue.
+ */
+ if (Pstatus(P)->pr_flags & PR_KLC)
+ dt_proc_stop(dpr, DT_PROC_STOP_CREATE);
+ else
+ dt_proc_stop(dpr, DT_PROC_STOP_GRAB);
+
+ if (Psetrun(P, 0, 0) == -1) {
+ dt_dprintf("pid %d: failed to set running: %s\n",
+ (int)dpr->dpr_pid, strerror(errno));
+ }
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+
+ /*
+ * Wait for the process corresponding to this control thread to stop,
+ * process the event, and then set it running again. We want to sleep
+ * with dpr_lock *unheld* so that other parts of libdtrace can use the
+ * ps_prochandle in the meantime (e.g. ustack()). To do this, we write
+ * a PCWSTOP directive directly to the underlying /proc/<pid>/ctl file.
+ * Once the process stops, we wake up, grab dpr_lock, and then call
+ * Pwait() (which will return immediately) and do our processing.
+ */
+ while (!dpr->dpr_quit) {
+ const lwpstatus_t *psp;
+
+ if (write(pfd, &wstop, sizeof (wstop)) == -1 && errno == EINTR)
+ continue; /* check dpr_quit and continue waiting */
+
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+pwait_locked:
+ if (Pstopstatus(P, PCNULL, 0) == -1 && errno == EINTR) {
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ continue; /* check dpr_quit and continue waiting */
+ }
+
+ switch (Pstate(P)) {
+ case PS_STOP:
+ psp = &Pstatus(P)->pr_lwp;
+
+ dt_dprintf("pid %d: proc stopped showing %d/%d\n",
+ pid, psp->pr_why, psp->pr_what);
+
+ /*
+ * If the process stops showing PR_REQUESTED, then the
+ * DTrace stop() action was applied to it or another
+ * debugging utility (e.g. pstop(1)) asked it to stop.
+ * In either case, the user's intention is for the
+ * process to remain stopped until another external
+ * mechanism (e.g. prun(1)) is applied. So instead of
+ * setting the process running ourself, we wait for
+ * someone else to do so. Once that happens, we return
+ * to our normal loop waiting for an event of interest.
+ */
+ if (psp->pr_why == PR_REQUESTED) {
+ dt_proc_waitrun(dpr);
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ continue;
+ }
+
+ /*
+ * If the process stops showing one of the events that
+ * we are tracing, perform the appropriate response.
+ * Note that we ignore PR_SUSPENDED, PR_CHECKPOINT, and
+ * PR_JOBCONTROL by design: if one of these conditions
+ * occurs, we will fall through to Psetrun() but the
+ * process will remain stopped in the kernel by the
+ * corresponding mechanism (e.g. job control stop).
+ */
+ if (psp->pr_why == PR_FAULTED && psp->pr_what == FLTBPT)
+ dt_proc_bpmatch(dtp, dpr);
+ else if (psp->pr_why == PR_SYSENTRY &&
+ IS_SYS_FORK(psp->pr_what))
+ dt_proc_bpdisable(dpr);
+ else if (psp->pr_why == PR_SYSEXIT &&
+ IS_SYS_FORK(psp->pr_what))
+ dt_proc_bpenable(dpr);
+ else if (psp->pr_why == PR_SYSEXIT &&
+ IS_SYS_EXEC(psp->pr_what))
+ dt_proc_attach(dpr, B_TRUE);
+ break;
+
+ case PS_LOST:
+ if (Preopen(P) == 0)
+ goto pwait_locked;
+
+ dt_dprintf("pid %d: proc lost: %s\n",
+ pid, strerror(errno));
+
+ dpr->dpr_quit = B_TRUE;
+ notify = B_TRUE;
+ break;
+
+ case PS_UNDEAD:
+ dt_dprintf("pid %d: proc died\n", pid);
+ dpr->dpr_quit = B_TRUE;
+ notify = B_TRUE;
+ break;
+ }
+
+ if (Pstate(P) != PS_UNDEAD && Psetrun(P, 0, 0) == -1) {
+ dt_dprintf("pid %d: failed to set running: %s\n",
+ (int)dpr->dpr_pid, strerror(errno));
+ }
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ }
+
+ /*
+ * If the control thread detected PS_UNDEAD or PS_LOST, then enqueue
+ * the dt_proc_t structure on the dt_proc_hash_t notification list.
+ */
+ if (notify)
+ dt_proc_notify(dtp, dph, dpr, NULL);
+
+ /*
+ * Destroy and remove any remaining breakpoints, set dpr_done and clear
+ * dpr_tid to indicate the control thread has exited, and notify any
+ * waiting thread in dt_proc_destroy() that we have succesfully exited.
+ */
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+
+ dt_proc_bpdestroy(dpr, B_TRUE);
+ dpr->dpr_done = B_TRUE;
+ dpr->dpr_tid = 0;
+
+ (void) pthread_cond_broadcast(&dpr->dpr_cv);
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+
+ return (NULL);
+}
+
+/*PRINTFLIKE3*/
+static struct ps_prochandle *
+dt_proc_error(dtrace_hdl_t *dtp, dt_proc_t *dpr, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ dt_set_errmsg(dtp, NULL, NULL, NULL, 0, format, ap);
+ va_end(ap);
+
+ if (dpr->dpr_proc != NULL)
+ Prelease(dpr->dpr_proc, 0);
+
+ dt_free(dtp, dpr);
+ (void) dt_set_errno(dtp, EDT_COMPILER);
+ return (NULL);
+}
+
+dt_proc_t *
+dt_proc_lookup(dtrace_hdl_t *dtp, struct ps_prochandle *P, int remove)
+{
+ dt_proc_hash_t *dph = dtp->dt_procs;
+ pid_t pid = Pstatus(P)->pr_pid;
+ dt_proc_t *dpr, **dpp = &dph->dph_hash[pid & (dph->dph_hashlen - 1)];
+
+ for (dpr = *dpp; dpr != NULL; dpr = dpr->dpr_hash) {
+ if (dpr->dpr_pid == pid)
+ break;
+ else
+ dpp = &dpr->dpr_hash;
+ }
+
+ assert(dpr != NULL);
+ assert(dpr->dpr_proc == P);
+
+ if (remove)
+ *dpp = dpr->dpr_hash; /* remove from pid hash chain */
+
+ return (dpr);
+}
+
+static void
+dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P)
+{
+ dt_proc_t *dpr = dt_proc_lookup(dtp, P, B_FALSE);
+ dt_proc_hash_t *dph = dtp->dt_procs;
+ dt_proc_notify_t *npr, **npp;
+ int rflag;
+
+ assert(dpr != NULL);
+
+ /*
+ * If neither PR_KLC nor PR_RLC is set, then the process is stopped by
+ * an external debugger and we were waiting in dt_proc_waitrun().
+ * Leave the process in this condition using PRELEASE_HANG.
+ */
+ if (!(Pstatus(dpr->dpr_proc)->pr_flags & (PR_KLC | PR_RLC))) {
+ dt_dprintf("abandoning pid %d\n", (int)dpr->dpr_pid);
+ rflag = PRELEASE_HANG;
+ } else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) {
+ dt_dprintf("killing pid %d\n", (int)dpr->dpr_pid);
+ rflag = PRELEASE_KILL; /* apply kill-on-last-close */
+ } else {
+ dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid);
+ rflag = 0; /* apply run-on-last-close */
+ }
+
+ if (dpr->dpr_tid) {
+ /*
+ * Set the dpr_quit flag to tell the daemon thread to exit. We
+ * send it a SIGCANCEL to poke it out of PCWSTOP or any other
+ * long-term /proc system call. Our daemon threads have POSIX
+ * cancellation disabled, so EINTR will be the only effect. We
+ * then wait for dpr_done to indicate the thread has exited.
+ *
+ * We can't use pthread_kill() to send SIGCANCEL because the
+ * interface forbids it and we can't use pthread_cancel()
+ * because with cancellation disabled it won't actually
+ * send SIGCANCEL to the target thread, so we use _lwp_kill()
+ * to do the job. This is all built on evil knowledge of
+ * the details of the cancellation mechanism in libc.
+ */
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+ dpr->dpr_quit = B_TRUE;
+ (void) _lwp_kill(dpr->dpr_tid, SIGCANCEL);
+
+ /*
+ * If the process is currently idling in dt_proc_stop(), re-
+ * enable breakpoints and poke it into running again.
+ */
+ if (dpr->dpr_stop & DT_PROC_STOP_IDLE) {
+ dt_proc_bpenable(dpr);
+ dpr->dpr_stop &= ~DT_PROC_STOP_IDLE;
+ (void) pthread_cond_broadcast(&dpr->dpr_cv);
+ }
+
+ while (!dpr->dpr_done)
+ (void) pthread_cond_wait(&dpr->dpr_cv, &dpr->dpr_lock);
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ }
+
+ /*
+ * Before we free the process structure, remove this dt_proc_t from the
+ * lookup hash, and then walk the dt_proc_hash_t's notification list
+ * and remove this dt_proc_t if it is enqueued.
+ */
+ (void) pthread_mutex_lock(&dph->dph_lock);
+ (void) dt_proc_lookup(dtp, P, B_TRUE);
+ npp = &dph->dph_notify;
+
+ while ((npr = *npp) != NULL) {
+ if (npr->dprn_dpr == dpr) {
+ *npp = npr->dprn_next;
+ dt_free(dtp, npr);
+ } else {
+ npp = &npr->dprn_next;
+ }
+ }
+
+ (void) pthread_mutex_unlock(&dph->dph_lock);
+
+ /*
+ * Remove the dt_proc_list from the LRU list, release the underlying
+ * libproc handle, and free our dt_proc_t data structure.
+ */
+ if (dpr->dpr_cacheable) {
+ assert(dph->dph_lrucnt != 0);
+ dph->dph_lrucnt--;
+ }
+
+ dt_list_delete(&dph->dph_lrulist, dpr);
+ Prelease(dpr->dpr_proc, rflag);
+ dt_free(dtp, dpr);
+}
+
+static int
+dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop)
+{
+ dt_proc_control_data_t data;
+ sigset_t nset, oset;
+ pthread_attr_t a;
+ int err;
+
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+ dpr->dpr_stop |= stop; /* set bit for initial rendezvous */
+
+ (void) pthread_attr_init(&a);
+ (void) pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
+
+ (void) sigfillset(&nset);
+ (void) sigdelset(&nset, SIGABRT); /* unblocked for assert() */
+ (void) sigdelset(&nset, SIGCANCEL); /* see dt_proc_destroy() */
+
+ data.dpcd_hdl = dtp;
+ data.dpcd_proc = dpr;
+
+ (void) pthread_sigmask(SIG_SETMASK, &nset, &oset);
+ err = pthread_create(&dpr->dpr_tid, &a, dt_proc_control, &data);
+ (void) pthread_sigmask(SIG_SETMASK, &oset, NULL);
+
+ /*
+ * If the control thread was created, then wait on dpr_cv for either
+ * dpr_done to be set (the victim died or the control thread failed)
+ * or DT_PROC_STOP_IDLE to be set, indicating that the victim is now
+ * stopped by /proc and the control thread is at the rendezvous event.
+ * On success, we return with the process and control thread stopped:
+ * the caller can then apply dt_proc_continue() to resume both.
+ */
+ if (err == 0) {
+ while (!dpr->dpr_done && !(dpr->dpr_stop & DT_PROC_STOP_IDLE))
+ (void) pthread_cond_wait(&dpr->dpr_cv, &dpr->dpr_lock);
+
+ /*
+ * If dpr_done is set, the control thread aborted before it
+ * reached the rendezvous event. This is either due to PS_LOST
+ * or PS_UNDEAD (i.e. the process died). We try to provide a
+ * small amount of useful information to help figure it out.
+ */
+ if (dpr->dpr_done) {
+ const psinfo_t *prp = Ppsinfo(dpr->dpr_proc);
+ int stat = prp ? prp->pr_wstat : 0;
+ int pid = dpr->dpr_pid;
+
+ if (Pstate(dpr->dpr_proc) == PS_LOST) {
+ (void) dt_proc_error(dpr->dpr_hdl, dpr,
+ "failed to control pid %d: process exec'd "
+ "set-id or unobservable program\n", pid);
+ } else if (WIFSIGNALED(stat)) {
+ (void) dt_proc_error(dpr->dpr_hdl, dpr,
+ "failed to control pid %d: process died "
+ "from signal %d\n", pid, WTERMSIG(stat));
+ } else {
+ (void) dt_proc_error(dpr->dpr_hdl, dpr,
+ "failed to control pid %d: process exited "
+ "with status %d\n", pid, WEXITSTATUS(stat));
+ }
+
+ err = ESRCH; /* cause grab() or create() to fail */
+ }
+ } else {
+ (void) dt_proc_error(dpr->dpr_hdl, dpr,
+ "failed to create control thread for process-id %d: %s\n",
+ (int)dpr->dpr_pid, strerror(err));
+ }
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+ (void) pthread_attr_destroy(&a);
+
+ return (err);
+}
+
+struct ps_prochandle *
+dt_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv)
+{
+ dt_proc_hash_t *dph = dtp->dt_procs;
+ dt_proc_t *dpr;
+ int err;
+
+ if ((dpr = dt_zalloc(dtp, sizeof (dt_proc_t))) == NULL)
+ return (NULL); /* errno is set for us */
+
+ (void) pthread_mutex_init(&dpr->dpr_lock, NULL);
+ (void) pthread_cond_init(&dpr->dpr_cv, NULL);
+
+ if ((dpr->dpr_proc = Pcreate(file, argv, &err, NULL, 0)) == NULL) {
+ return (dt_proc_error(dtp, dpr,
+ "failed to execute %s: %s\n", file, Pcreate_error(err)));
+ }
+
+ dpr->dpr_hdl = dtp;
+ dpr->dpr_pid = Pstatus(dpr->dpr_proc)->pr_pid;
+
+ (void) Punsetflags(dpr->dpr_proc, PR_RLC);
+ (void) Psetflags(dpr->dpr_proc, PR_KLC);
+
+ if (dt_proc_create_thread(dtp, dpr, dtp->dt_prcmode) != 0)
+ return (NULL); /* dt_proc_error() has been called for us */
+
+ dpr->dpr_hash = dph->dph_hash[dpr->dpr_pid & (dph->dph_hashlen - 1)];
+ dph->dph_hash[dpr->dpr_pid & (dph->dph_hashlen - 1)] = dpr;
+ dt_list_prepend(&dph->dph_lrulist, dpr);
+
+ dt_dprintf("created pid %d\n", (int)dpr->dpr_pid);
+ dpr->dpr_refs++;
+
+ return (dpr->dpr_proc);
+}
+
+struct ps_prochandle *
+dt_proc_grab(dtrace_hdl_t *dtp, pid_t pid, int flags, int nomonitor)
+{
+ dt_proc_hash_t *dph = dtp->dt_procs;
+ uint_t h = pid & (dph->dph_hashlen - 1);
+ dt_proc_t *dpr, *opr;
+ int err;
+
+ /*
+ * Search the hash table for the pid. If it is already grabbed or
+ * created, move the handle to the front of the lrulist, increment
+ * the reference count, and return the existing ps_prochandle.
+ */
+ for (dpr = dph->dph_hash[h]; dpr != NULL; dpr = dpr->dpr_hash) {
+ if (dpr->dpr_pid == pid && !dpr->dpr_stale) {
+ /*
+ * If the cached handle was opened read-only and
+ * this request is for a writeable handle, mark
+ * the cached handle as stale and open a new handle.
+ * Since it's stale, unmark it as cacheable.
+ */
+ if (dpr->dpr_rdonly && !(flags & PGRAB_RDONLY)) {
+ dt_dprintf("upgrading pid %d\n", (int)pid);
+ dpr->dpr_stale = B_TRUE;
+ dpr->dpr_cacheable = B_FALSE;
+ dph->dph_lrucnt--;
+ break;
+ }
+
+ dt_dprintf("grabbed pid %d (cached)\n", (int)pid);
+ dt_list_delete(&dph->dph_lrulist, dpr);
+ dt_list_prepend(&dph->dph_lrulist, dpr);
+ dpr->dpr_refs++;
+ return (dpr->dpr_proc);
+ }
+ }
+
+ if ((dpr = dt_zalloc(dtp, sizeof (dt_proc_t))) == NULL)
+ return (NULL); /* errno is set for us */
+
+ (void) pthread_mutex_init(&dpr->dpr_lock, NULL);
+ (void) pthread_cond_init(&dpr->dpr_cv, NULL);
+
+ if ((dpr->dpr_proc = Pgrab(pid, flags, &err)) == NULL) {
+ return (dt_proc_error(dtp, dpr,
+ "failed to grab pid %d: %s\n", (int)pid, Pgrab_error(err)));
+ }
+
+ dpr->dpr_hdl = dtp;
+ dpr->dpr_pid = pid;
+
+ (void) Punsetflags(dpr->dpr_proc, PR_KLC);
+ (void) Psetflags(dpr->dpr_proc, PR_RLC);
+
+ /*
+ * If we are attempting to grab the process without a monitor
+ * thread, then mark the process cacheable only if it's being
+ * grabbed read-only. If we're currently caching more process
+ * handles than dph_lrulim permits, attempt to find the
+ * least-recently-used handle that is currently unreferenced and
+ * release it from the cache. Otherwise we are grabbing the process
+ * for control: create a control thread for this process and store
+ * its ID in dpr->dpr_tid.
+ */
+ if (nomonitor || (flags & PGRAB_RDONLY)) {
+ if (dph->dph_lrucnt >= dph->dph_lrulim) {
+ for (opr = dt_list_prev(&dph->dph_lrulist);
+ opr != NULL; opr = dt_list_prev(opr)) {
+ if (opr->dpr_cacheable && opr->dpr_refs == 0) {
+ dt_proc_destroy(dtp, opr->dpr_proc);
+ break;
+ }
+ }
+ }
+
+ if (flags & PGRAB_RDONLY) {
+ dpr->dpr_cacheable = B_TRUE;
+ dpr->dpr_rdonly = B_TRUE;
+ dph->dph_lrucnt++;
+ }
+
+ } else if (dt_proc_create_thread(dtp, dpr, DT_PROC_STOP_GRAB) != 0)
+ return (NULL); /* dt_proc_error() has been called for us */
+
+ dpr->dpr_hash = dph->dph_hash[h];
+ dph->dph_hash[h] = dpr;
+ dt_list_prepend(&dph->dph_lrulist, dpr);
+
+ dt_dprintf("grabbed pid %d\n", (int)pid);
+ dpr->dpr_refs++;
+
+ return (dpr->dpr_proc);
+}
+
+void
+dt_proc_release(dtrace_hdl_t *dtp, struct ps_prochandle *P)
+{
+ dt_proc_t *dpr = dt_proc_lookup(dtp, P, B_FALSE);
+ dt_proc_hash_t *dph = dtp->dt_procs;
+
+ assert(dpr != NULL);
+ assert(dpr->dpr_refs != 0);
+
+ if (--dpr->dpr_refs == 0 &&
+ (!dpr->dpr_cacheable || dph->dph_lrucnt > dph->dph_lrulim))
+ dt_proc_destroy(dtp, P);
+}
+
+void
+dt_proc_continue(dtrace_hdl_t *dtp, struct ps_prochandle *P)
+{
+ dt_proc_t *dpr = dt_proc_lookup(dtp, P, B_FALSE);
+
+ (void) pthread_mutex_lock(&dpr->dpr_lock);
+
+ if (dpr->dpr_stop & DT_PROC_STOP_IDLE) {
+ dpr->dpr_stop &= ~DT_PROC_STOP_IDLE;
+ (void) pthread_cond_broadcast(&dpr->dpr_cv);
+ }
+
+ (void) pthread_mutex_unlock(&dpr->dpr_lock);
+}
+
+void
+dt_proc_lock(dtrace_hdl_t *dtp, struct ps_prochandle *P)
+{
+ dt_proc_t *dpr = dt_proc_lookup(dtp, P, B_FALSE);
+ int err = pthread_mutex_lock(&dpr->dpr_lock);
+ assert(err == 0); /* check for recursion */
+}
+
+void
+dt_proc_unlock(dtrace_hdl_t *dtp, struct ps_prochandle *P)
+{
+ dt_proc_t *dpr = dt_proc_lookup(dtp, P, B_FALSE);
+ int err = pthread_mutex_unlock(&dpr->dpr_lock);
+ assert(err == 0); /* check for unheld lock */
+}
+#endif /* !VBOX */
+
+void
+dt_proc_hash_create(dtrace_hdl_t *dtp)
+{
+ if ((dtp->dt_procs = dt_zalloc(dtp, sizeof (dt_proc_hash_t) +
+ sizeof (dt_proc_t *) * _dtrace_pidbuckets - 1)) != NULL) {
+
+#ifndef VBOX /** @todo This needs more work... */
+ (void) pthread_mutex_init(&dtp->dt_procs->dph_lock, NULL);
+ (void) pthread_cond_init(&dtp->dt_procs->dph_cv, NULL);
+#else
+
+#endif
+
+ dtp->dt_procs->dph_hashlen = _dtrace_pidbuckets;
+ dtp->dt_procs->dph_lrulim = _dtrace_pidlrulim;
+ }
+}
+
+void
+dt_proc_hash_destroy(dtrace_hdl_t *dtp)
+{
+ dt_proc_hash_t *dph = dtp->dt_procs;
+#ifndef VBOX
+ dt_proc_t *dpr;
+
+ while ((dpr = dt_list_next(&dph->dph_lrulist)) != NULL)
+ dt_proc_destroy(dtp, dpr->dpr_proc);
+#endif
+
+ dtp->dt_procs = NULL;
+ dt_free(dtp, dph);
+}
+
+#ifndef VBOX
+
+struct ps_prochandle *
+dtrace_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv)
+{
+ dt_ident_t *idp = dt_idhash_lookup(dtp->dt_macros, "target");
+ struct ps_prochandle *P = dt_proc_create(dtp, file, argv);
+
+ if (P != NULL && idp != NULL && idp->di_id == 0)
+ idp->di_id = Pstatus(P)->pr_pid; /* $target = created pid */
+
+ return (P);
+}
+
+struct ps_prochandle *
+dtrace_proc_grab(dtrace_hdl_t *dtp, pid_t pid, int flags)
+{
+ dt_ident_t *idp = dt_idhash_lookup(dtp->dt_macros, "target");
+ struct ps_prochandle *P = dt_proc_grab(dtp, pid, flags, 0);
+
+ if (P != NULL && idp != NULL && idp->di_id == 0)
+ idp->di_id = pid; /* $target = grabbed pid */
+
+ return (P);
+}
+
+void
+dtrace_proc_release(dtrace_hdl_t *dtp, struct ps_prochandle *P)
+{
+ dt_proc_release(dtp, P);
+}
+
+void
+dtrace_proc_continue(dtrace_hdl_t *dtp, struct ps_prochandle *P)
+{
+ dt_proc_continue(dtp, P);
+}
+#endif /* !VBOX */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.h
new file mode 100644
index 00000000..d6c82a0c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_proc.h
@@ -0,0 +1,136 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_PROC_H
+#define _DT_PROC_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <libproc.h>
+#include <dtrace.h>
+#include <pthread.h>
+#include <dt_list.h>
+#else /* VBOX */
+# include <dtrace.h>
+# include <dt_list.h>
+# include <iprt/critsect.h>
+#endif /* VBOX */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dt_proc {
+ dt_list_t dpr_list; /* prev/next pointers for lru chain */
+ struct dt_proc *dpr_hash; /* next pointer for pid hash chain */
+ dtrace_hdl_t *dpr_hdl; /* back pointer to libdtrace handle */
+ struct ps_prochandle *dpr_proc; /* proc handle for libproc calls */
+ char dpr_errmsg[BUFSIZ]; /* error message */
+#ifndef VBOX
+ rd_agent_t *dpr_rtld; /* rtld handle for librtld_db calls */
+ pthread_mutex_t dpr_lock; /* lock for manipulating dpr_hdl */
+ pthread_cond_t dpr_cv; /* cond for dpr_stop/quit/done */
+#else
+ RTCRITSECT dpr_lock;
+ RTSEMEVENT dpr_cv;
+#endif
+ pid_t dpr_pid; /* pid of process */
+ uint_t dpr_refs; /* reference count */
+ uint8_t dpr_cacheable; /* cache handle using lru list */
+ uint8_t dpr_stop; /* stop mask: see flag bits below */
+ uint8_t dpr_quit; /* quit flag: ctl thread should quit */
+ uint8_t dpr_done; /* done flag: ctl thread has exited */
+ uint8_t dpr_usdt; /* usdt flag: usdt initialized */
+ uint8_t dpr_stale; /* proc flag: been deprecated */
+ uint8_t dpr_rdonly; /* proc flag: opened read-only */
+#ifndef VBOX
+ pthread_t dpr_tid; /* control thread (or zero if none) */
+#else
+ RTTHREAD dpr_tid;
+#endif
+ dt_list_t dpr_bps; /* list of dt_bkpt_t structures */
+} dt_proc_t;
+
+typedef struct dt_proc_notify {
+ dt_proc_t *dprn_dpr; /* process associated with the event */
+ char dprn_errmsg[BUFSIZ]; /* error message */
+ struct dt_proc_notify *dprn_next; /* next pointer */
+} dt_proc_notify_t;
+
+#define DT_PROC_STOP_IDLE 0x01 /* idle on owner's stop request */
+#define DT_PROC_STOP_CREATE 0x02 /* wait on dpr_cv at process exec */
+#define DT_PROC_STOP_GRAB 0x04 /* wait on dpr_cv at process grab */
+#define DT_PROC_STOP_PREINIT 0x08 /* wait on dpr_cv at rtld preinit */
+#define DT_PROC_STOP_POSTINIT 0x10 /* wait on dpr_cv at rtld postinit */
+#define DT_PROC_STOP_MAIN 0x20 /* wait on dpr_cv at a.out`main() */
+
+typedef void dt_bkpt_f(dtrace_hdl_t *, dt_proc_t *, void *);
+
+typedef struct dt_bkpt {
+ dt_list_t dbp_list; /* prev/next pointers for bkpt list */
+ dt_bkpt_f *dbp_func; /* callback function to execute */
+ void *dbp_data; /* callback function private data */
+ uintptr_t dbp_addr; /* virtual address of breakpoint */
+ ulong_t dbp_instr; /* saved instruction from breakpoint */
+ ulong_t dbp_hits; /* count of breakpoint hits for debug */
+ int dbp_active; /* flag indicating breakpoint is on */
+} dt_bkpt_t;
+
+typedef struct dt_proc_hash {
+#ifndef VBOX
+ pthread_mutex_t dph_lock; /* lock protecting dph_notify list */
+ pthread_cond_t dph_cv; /* cond for waiting for dph_notify */
+#else
+ RTSEMEVENT dph_event;
+#endif
+ dt_proc_notify_t *dph_notify; /* list of pending proc notifications */
+ dt_list_t dph_lrulist; /* list of dt_proc_t's in lru order */
+ uint_t dph_lrulim; /* limit on number of procs to hold */
+ uint_t dph_lrucnt; /* count of cached process handles */
+ uint_t dph_hashlen; /* size of hash chains array */
+ dt_proc_t *dph_hash[1]; /* hash chains array */
+} dt_proc_hash_t;
+
+extern struct ps_prochandle *dt_proc_create(dtrace_hdl_t *,
+ const char *, char *const *);
+
+extern struct ps_prochandle *dt_proc_grab(dtrace_hdl_t *, pid_t, int, int);
+extern void dt_proc_release(dtrace_hdl_t *, struct ps_prochandle *);
+extern void dt_proc_continue(dtrace_hdl_t *, struct ps_prochandle *);
+extern void dt_proc_lock(dtrace_hdl_t *, struct ps_prochandle *);
+extern void dt_proc_unlock(dtrace_hdl_t *, struct ps_prochandle *);
+extern dt_proc_t *dt_proc_lookup(dtrace_hdl_t *, struct ps_prochandle *, int);
+
+extern void dt_proc_hash_create(dtrace_hdl_t *);
+extern void dt_proc_hash_destroy(dtrace_hdl_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PROC_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.c
new file mode 100644
index 00000000..33e5a8eb
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.c
@@ -0,0 +1,622 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <unistd.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
+#include <ctype.h>
+#include <alloca.h>
+#else
+# include <ctype.h>
+#endif
+
+#include <dt_impl.h>
+#include <dt_program.h>
+#include <dt_printf.h>
+#include <dt_provider.h>
+
+dtrace_prog_t *
+dt_program_create(dtrace_hdl_t *dtp)
+{
+ dtrace_prog_t *pgp = dt_zalloc(dtp, sizeof (dtrace_prog_t));
+
+ if (pgp != NULL) {
+ dt_list_append(&dtp->dt_programs, pgp);
+ } else {
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ return (NULL);
+ }
+
+ /*
+ * By default, programs start with DOF version 1 so that output files
+ * containing DOF are backward compatible. If a program requires new
+ * DOF features, the version is increased as needed.
+ */
+ pgp->dp_dofversion = DOF_VERSION_1;
+
+ return (pgp);
+}
+
+void
+dt_program_destroy(dtrace_hdl_t *dtp, dtrace_prog_t *pgp)
+{
+ dt_stmt_t *stp, *next;
+ uint_t i;
+
+ for (stp = dt_list_next(&pgp->dp_stmts); stp != NULL; stp = next) {
+ next = dt_list_next(stp);
+ dtrace_stmt_destroy(dtp, stp->ds_desc);
+ dt_free(dtp, stp);
+ }
+
+ for (i = 0; i < pgp->dp_xrefslen; i++)
+ dt_free(dtp, pgp->dp_xrefs[i]);
+
+ dt_free(dtp, pgp->dp_xrefs);
+ dt_list_delete(&dtp->dt_programs, pgp);
+ dt_free(dtp, pgp);
+}
+
+/*ARGSUSED*/
+void
+dtrace_program_info(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
+ dtrace_proginfo_t *pip)
+{
+ dt_stmt_t *stp;
+ dtrace_actdesc_t *ap;
+ dtrace_ecbdesc_t *last = NULL;
+ RT_NOREF1(dtp);
+
+ if (pip == NULL)
+ return;
+
+ bzero(pip, sizeof (dtrace_proginfo_t));
+
+ if (dt_list_next(&pgp->dp_stmts) != NULL) {
+ pip->dpi_descattr = _dtrace_maxattr;
+ pip->dpi_stmtattr = _dtrace_maxattr;
+ } else {
+ pip->dpi_descattr = _dtrace_defattr;
+ pip->dpi_stmtattr = _dtrace_defattr;
+ }
+
+ for (stp = dt_list_next(&pgp->dp_stmts); stp; stp = dt_list_next(stp)) {
+ dtrace_ecbdesc_t *edp = stp->ds_desc->dtsd_ecbdesc;
+
+ if (edp == last)
+ continue;
+ last = edp;
+
+ pip->dpi_descattr =
+ dt_attr_min(stp->ds_desc->dtsd_descattr, pip->dpi_descattr);
+
+ pip->dpi_stmtattr =
+ dt_attr_min(stp->ds_desc->dtsd_stmtattr, pip->dpi_stmtattr);
+
+ /*
+ * If there aren't any actions, account for the fact that
+ * recording the epid will generate a record.
+ */
+ if (edp->dted_action == NULL)
+ pip->dpi_recgens++;
+
+ for (ap = edp->dted_action; ap != NULL; ap = ap->dtad_next) {
+ if (ap->dtad_kind == DTRACEACT_SPECULATE) {
+ pip->dpi_speculations++;
+ continue;
+ }
+
+ if (DTRACEACT_ISAGG(ap->dtad_kind)) {
+ pip->dpi_recgens -= ap->dtad_arg;
+ pip->dpi_aggregates++;
+ continue;
+ }
+
+ if (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind))
+ continue;
+
+ if (ap->dtad_kind == DTRACEACT_DIFEXPR &&
+ ap->dtad_difo->dtdo_rtype.dtdt_kind ==
+ DIF_TYPE_CTF &&
+ ap->dtad_difo->dtdo_rtype.dtdt_size == 0)
+ continue;
+
+ pip->dpi_recgens++;
+ }
+ }
+}
+
+int
+dtrace_program_exec(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
+ dtrace_proginfo_t *pip)
+{
+ void *dof;
+ int n, err;
+
+ dtrace_program_info(dtp, pgp, pip);
+
+ if ((dof = dtrace_dof_create(dtp, pgp, DTRACE_D_STRIP)) == NULL)
+ return (-1);
+
+ n = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof);
+ dtrace_dof_destroy(dtp, dof);
+
+ if (n == -1) {
+ switch (errno) {
+ case EINVAL:
+ err = EDT_DIFINVAL;
+ break;
+ case EFAULT:
+ err = EDT_DIFFAULT;
+ break;
+ case E2BIG:
+ err = EDT_DIFSIZE;
+ break;
+ case EBUSY:
+ err = EDT_ENABLING_ERR;
+ break;
+ default:
+ err = errno;
+ }
+
+ return (dt_set_errno(dtp, err));
+ }
+
+ if (pip != NULL)
+ pip->dpi_matches += n;
+
+ return (0);
+}
+
+static void
+dt_ecbdesc_hold(dtrace_ecbdesc_t *edp)
+{
+ edp->dted_refcnt++;
+}
+
+void
+dt_ecbdesc_release(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
+{
+ if (--edp->dted_refcnt > 0)
+ return;
+
+ dt_difo_free(dtp, edp->dted_pred.dtpdd_difo);
+ assert(edp->dted_action == NULL);
+ dt_free(dtp, edp);
+}
+
+dtrace_ecbdesc_t *
+dt_ecbdesc_create(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp)
+{
+ dtrace_ecbdesc_t *edp;
+
+ if ((edp = dt_zalloc(dtp, sizeof (dtrace_ecbdesc_t))) == NULL) {
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ return (NULL);
+ }
+
+ edp->dted_probe = *pdp;
+ dt_ecbdesc_hold(edp);
+ return (edp);
+}
+
+dtrace_stmtdesc_t *
+dtrace_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
+{
+ dtrace_stmtdesc_t *sdp;
+
+ if ((sdp = dt_zalloc(dtp, sizeof (dtrace_stmtdesc_t))) == NULL)
+ return (NULL);
+
+ dt_ecbdesc_hold(edp);
+ sdp->dtsd_ecbdesc = edp;
+ sdp->dtsd_descattr = _dtrace_defattr;
+ sdp->dtsd_stmtattr = _dtrace_defattr;
+
+ return (sdp);
+}
+
+dtrace_actdesc_t *
+dtrace_stmt_action(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_actdesc_t *new;
+ dtrace_ecbdesc_t *edp = sdp->dtsd_ecbdesc;
+
+ if ((new = dt_alloc(dtp, sizeof (dtrace_actdesc_t))) == NULL)
+ return (NULL);
+
+ if (sdp->dtsd_action_last != NULL) {
+ assert(sdp->dtsd_action != NULL);
+ assert(sdp->dtsd_action_last->dtad_next == NULL);
+ sdp->dtsd_action_last->dtad_next = new;
+ } else {
+ dtrace_actdesc_t *ap = edp->dted_action;
+
+ assert(sdp->dtsd_action == NULL);
+ sdp->dtsd_action = new;
+
+ while (ap != NULL && ap->dtad_next != NULL)
+ ap = ap->dtad_next;
+
+ if (ap == NULL)
+ edp->dted_action = new;
+ else
+ ap->dtad_next = new;
+ }
+
+ sdp->dtsd_action_last = new;
+ bzero(new, sizeof (dtrace_actdesc_t));
+ new->dtad_uarg = (uintptr_t)sdp;
+
+ return (new);
+}
+
+int
+dtrace_stmt_add(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, dtrace_stmtdesc_t *sdp)
+{
+ dt_stmt_t *stp = dt_alloc(dtp, sizeof (dt_stmt_t));
+
+ if (stp == NULL)
+ return (-1); /* errno is set for us */
+
+ dt_list_append(&pgp->dp_stmts, stp);
+ stp->ds_desc = sdp;
+
+ return (0);
+}
+
+int
+dtrace_stmt_iter(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
+ dtrace_stmt_f *func, void *data)
+{
+ dt_stmt_t *stp, *next;
+ int status = 0;
+
+ for (stp = dt_list_next(&pgp->dp_stmts); stp != NULL; stp = next) {
+ next = dt_list_next(stp);
+ if ((status = func(dtp, pgp, stp->ds_desc, data)) != 0)
+ break;
+ }
+
+ return (status);
+}
+
+void
+dtrace_stmt_destroy(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp)
+{
+ dtrace_ecbdesc_t *edp = sdp->dtsd_ecbdesc;
+
+ /*
+ * We need to remove any actions that we have on this ECB, and
+ * remove our hold on the ECB itself.
+ */
+ if (sdp->dtsd_action != NULL) {
+ dtrace_actdesc_t *last = sdp->dtsd_action_last;
+ dtrace_actdesc_t *ap, *next;
+
+ assert(last != NULL);
+
+ for (ap = edp->dted_action; ap != NULL; ap = ap->dtad_next) {
+ if (ap == sdp->dtsd_action)
+ break;
+
+ if (ap->dtad_next == sdp->dtsd_action)
+ break;
+ }
+
+ assert(ap != NULL);
+
+ if (ap == edp->dted_action)
+ edp->dted_action = last->dtad_next;
+ else
+ ap->dtad_next = last->dtad_next;
+
+ /*
+ * We have now removed our action list from its ECB; we can
+ * safely destroy the list.
+ */
+ last->dtad_next = NULL;
+
+ for (ap = sdp->dtsd_action; ap != NULL; ap = next) {
+ assert(ap->dtad_uarg == (uintptr_t)sdp);
+ dt_difo_free(dtp, ap->dtad_difo);
+ next = ap->dtad_next;
+ dt_free(dtp, ap);
+ }
+ }
+
+ if (sdp->dtsd_fmtdata != NULL)
+ dt_printf_destroy(sdp->dtsd_fmtdata);
+
+ dt_ecbdesc_release(dtp, sdp->dtsd_ecbdesc);
+ dt_free(dtp, sdp);
+}
+
+typedef struct dt_header_info {
+ dtrace_hdl_t *dthi_dtp; /* consumer handle */
+ FILE *dthi_out; /* output file */
+ char *dthi_pmname; /* provider macro name */
+ char *dthi_pfname; /* provider function name */
+ int dthi_empty; /* should we generate empty macros */
+} dt_header_info_t;
+
+static void
+dt_header_fmt_macro(char *buf, const char *str)
+{
+ for (;;) {
+ if (islower(*str)) {
+ *buf++ = *str++ + 'A' - 'a';
+ } else if (*str == '-') {
+ *buf++ = '_';
+ str++;
+ } else if (*str == '.') {
+ *buf++ = '_';
+ str++;
+ } else if ((*buf++ = *str++) == '\0') {
+ break;
+ }
+ }
+}
+
+static void
+dt_header_fmt_func(char *buf, const char *str)
+{
+ for (;;) {
+ if (*str == '-') {
+ *buf++ = '_';
+ *buf++ = '_';
+ str++;
+ } else if ((*buf++ = *str++) == '\0') {
+ break;
+ }
+ }
+}
+
+/*ARGSUSED*/
+static int
+dt_header_decl(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
+{
+ dt_header_info_t *infop = data;
+ dtrace_hdl_t *dtp = infop->dthi_dtp;
+ dt_probe_t *prp = idp->di_data;
+ dt_node_t *dnp;
+ char buf[DT_TYPE_NAMELEN];
+ char *fname;
+ const char *p;
+ int i;
+ RT_NOREF1(dhp);
+
+ p = prp->pr_name;
+ for (i = 0; (p = strchr(p, '-')) != NULL; i++)
+ p++;
+
+ fname = alloca(strlen(prp->pr_name) + 1 + i);
+ dt_header_fmt_func(fname, prp->pr_name);
+
+ if (fprintf(infop->dthi_out, "extern void __dtrace_%s___%s(",
+ infop->dthi_pfname, fname) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ for (dnp = prp->pr_nargs, i = 0; dnp != NULL; dnp = dnp->dn_list, i++) {
+ if (fprintf(infop->dthi_out, "%s",
+ ctf_type_name(dnp->dn_ctfp, dnp->dn_type,
+ buf, sizeof (buf))) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if ((uint_t)i + 1 != prp->pr_nargc &&
+ fprintf(infop->dthi_out, ", ") < 0)
+ return (dt_set_errno(dtp, errno));
+ }
+
+ if (i == 0 && fprintf(infop->dthi_out, "void") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (fprintf(infop->dthi_out, ");\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (fprintf(infop->dthi_out,
+ "#ifndef\t__sparc\n"
+ "extern int __dtraceenabled_%s___%s(void);\n"
+ "#else\n"
+ "extern int __dtraceenabled_%s___%s(long);\n"
+ "#endif\n",
+ infop->dthi_pfname, fname, infop->dthi_pfname, fname) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dt_header_probe(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
+{
+ dt_header_info_t *infop = data;
+ dtrace_hdl_t *dtp = infop->dthi_dtp;
+ dt_probe_t *prp = idp->di_data;
+ char *mname, *fname;
+ const char *p;
+ VBDTTYPE(uint_t,int) i;
+ RT_NOREF1(dhp);
+
+ p = prp->pr_name;
+ for (i = 0; (p = strchr(p, '-')) != NULL; i++)
+ p++;
+
+ mname = alloca(strlen(prp->pr_name) + 1);
+ dt_header_fmt_macro(mname, prp->pr_name);
+
+ fname = alloca(strlen(prp->pr_name) + 1 + i);
+ dt_header_fmt_func(fname, prp->pr_name);
+
+ if (fprintf(infop->dthi_out, "#define\t%s_%s(",
+ infop->dthi_pmname, mname) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ for (i = 0; i < prp->pr_nargc; i++) {
+ if (fprintf(infop->dthi_out, "arg%d", i) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (i + 1 != prp->pr_nargc &&
+ fprintf(infop->dthi_out, ", ") < 0)
+ return (dt_set_errno(dtp, errno));
+ }
+
+ if (!infop->dthi_empty) {
+ if (fprintf(infop->dthi_out, ") \\\n\t") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (fprintf(infop->dthi_out, "__dtrace_%s___%s(",
+ infop->dthi_pfname, fname) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ for (i = 0; i < prp->pr_nargc; i++) {
+ if (fprintf(infop->dthi_out, "arg%d", i) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (i + 1 != prp->pr_nargc &&
+ fprintf(infop->dthi_out, ", ") < 0)
+ return (dt_set_errno(dtp, errno));
+ }
+ }
+
+ if (fprintf(infop->dthi_out, ")\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (!infop->dthi_empty) {
+ if (fprintf(infop->dthi_out,
+ "#ifndef\t__sparc\n"
+ "#define\t%s_%s_ENABLED() \\\n"
+ "\t__dtraceenabled_%s___%s()\n"
+ "#else\n"
+ "#define\t%s_%s_ENABLED() \\\n"
+ "\t__dtraceenabled_%s___%s(0)\n"
+ "#endif\n",
+ infop->dthi_pmname, mname,
+ infop->dthi_pfname, fname,
+ infop->dthi_pmname, mname,
+ infop->dthi_pfname, fname) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ } else {
+ if (fprintf(infop->dthi_out, "#define\t%s_%s_ENABLED() (0)\n",
+ infop->dthi_pmname, mname) < 0)
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (0);
+}
+
+static int
+dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out)
+{
+ dt_header_info_t info;
+ const char *p;
+ int i;
+
+ if (pvp->pv_flags & DT_PROVIDER_IMPL)
+ return (0);
+
+ /*
+ * Count the instances of the '-' character since we'll need to double
+ * those up.
+ */
+ p = pvp->pv_desc.dtvd_name;
+ for (i = 0; (p = strchr(p, '-')) != NULL; i++)
+ p++;
+
+ info.dthi_dtp = dtp;
+ info.dthi_out = out;
+ info.dthi_empty = 0;
+
+ info.dthi_pmname = alloca(strlen(pvp->pv_desc.dtvd_name) + 1);
+ dt_header_fmt_macro(info.dthi_pmname, pvp->pv_desc.dtvd_name);
+
+ info.dthi_pfname = alloca(strlen(pvp->pv_desc.dtvd_name) + 1 + i);
+ dt_header_fmt_func(info.dthi_pfname, pvp->pv_desc.dtvd_name);
+
+ if (fprintf(out, "#if _DTRACE_VERSION\n\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (dt_idhash_iter(pvp->pv_probes, dt_header_probe, &info) != 0)
+ return (-1); /* dt_errno is set for us */
+ if (fprintf(out, "\n\n") < 0)
+ return (dt_set_errno(dtp, errno));
+ if (dt_idhash_iter(pvp->pv_probes, dt_header_decl, &info) != 0)
+ return (-1); /* dt_errno is set for us */
+
+ if (fprintf(out, "\n#else\n\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ info.dthi_empty = 1;
+
+ if (dt_idhash_iter(pvp->pv_probes, dt_header_probe, &info) != 0)
+ return (-1); /* dt_errno is set for us */
+
+ if (fprintf(out, "\n#endif\n\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ return (0);
+}
+
+int
+dtrace_program_header(dtrace_hdl_t *dtp, FILE *out, const char *fname)
+{
+ dt_provider_t *pvp;
+ char *mfname VBDTMSC(NULL), *p;
+
+ if (fname != NULL) {
+ if ((p = strrchr(fname, '/')) != NULL)
+ fname = p + 1;
+
+ mfname = alloca(strlen(fname) + 1);
+ dt_header_fmt_macro(mfname, fname);
+ if (fprintf(out, "#ifndef\t_%s\n#define\t_%s\n\n",
+ mfname, mfname) < 0)
+ return (dt_set_errno(dtp, errno));
+ }
+
+ if (fprintf(out, "#include <unistd.h>\n\n") < 0)
+ return (-1);
+
+ if (fprintf(out, "#ifdef\t__cplusplus\nextern \"C\" {\n#endif\n\n") < 0)
+ return (-1);
+
+ for (pvp = dt_list_next(&dtp->dt_provlist);
+ pvp != NULL; pvp = dt_list_next(pvp)) {
+ if (dt_header_provider(dtp, pvp, out) != 0)
+ return (-1); /* dt_errno is set for us */
+ }
+
+ if (fprintf(out, "\n#ifdef\t__cplusplus\n}\n#endif\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (fname != NULL && fprintf(out, "\n#endif\t/* _%s */\n", mfname) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ return (0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.h
new file mode 100644
index 00000000..100f3579
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.h
@@ -0,0 +1,65 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_PROGRAM_H
+#define _DT_PROGRAM_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dtrace.h>
+#include <dt_list.h>
+
+typedef struct dt_stmt {
+ dt_list_t ds_list; /* list forward/back pointers */
+ dtrace_stmtdesc_t *ds_desc; /* pointer to statement description */
+} dt_stmt_t;
+
+struct dtrace_prog {
+ dt_list_t dp_list; /* list forward/back pointers */
+ dt_list_t dp_stmts; /* linked list of dt_stmt_t's */
+ ulong_t **dp_xrefs; /* array of translator reference bitmaps */
+ uint_t dp_xrefslen; /* length of dp_xrefs array */
+ uint8_t dp_dofversion; /* DOF version this program requires */
+};
+
+extern dtrace_prog_t *dt_program_create(dtrace_hdl_t *);
+extern void dt_program_destroy(dtrace_hdl_t *, dtrace_prog_t *);
+
+extern dtrace_ecbdesc_t *dt_ecbdesc_create(dtrace_hdl_t *,
+ const dtrace_probedesc_t *);
+extern void dt_ecbdesc_release(dtrace_hdl_t *, dtrace_ecbdesc_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PROGRAM_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.c
new file mode 100644
index 00000000..a0c6bc00
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.c
@@ -0,0 +1,890 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/sysmacros.h>
+
+#include <assert.h>
+#include <limits.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <alloca.h>
+#include <unistd.h>
+#include <errno.h>
+#else /* VBOX */
+# include <iprt/asm.h>
+#endif /* VBOX */
+
+#include <dt_provider.h>
+#include <dt_module.h>
+#include <dt_string.h>
+#include <dt_list.h>
+
+static dt_provider_t *
+dt_provider_insert(dtrace_hdl_t *dtp, dt_provider_t *pvp, uint_t h)
+{
+ dt_list_append(&dtp->dt_provlist, pvp);
+
+ pvp->pv_next = dtp->dt_provs[h];
+ dtp->dt_provs[h] = pvp;
+ dtp->dt_nprovs++;
+
+ return (pvp);
+}
+
+dt_provider_t *
+dt_provider_lookup(dtrace_hdl_t *dtp, const char *name)
+{
+ uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_provbuckets;
+ dtrace_providerdesc_t desc;
+ dt_provider_t *pvp;
+
+ for (pvp = dtp->dt_provs[h]; pvp != NULL; pvp = pvp->pv_next) {
+ if (strcmp(pvp->pv_desc.dtvd_name, name) == 0)
+ return (pvp);
+ }
+
+ if (strisglob(name) || name[0] == '\0') {
+ (void) dt_set_errno(dtp, EDT_NOPROV);
+ return (NULL);
+ }
+
+ bzero(&desc, sizeof (desc));
+ (void) strlcpy(desc.dtvd_name, name, DTRACE_PROVNAMELEN);
+
+ if (dt_ioctl(dtp, DTRACEIOC_PROVIDER, &desc) == -1) {
+ (void) dt_set_errno(dtp, errno == ESRCH ? EDT_NOPROV : errno);
+ return (NULL);
+ }
+
+ if ((pvp = dt_provider_create(dtp, name)) == NULL)
+ return (NULL); /* dt_errno is set for us */
+
+ bcopy(&desc, &pvp->pv_desc, sizeof (desc));
+ pvp->pv_flags |= DT_PROVIDER_IMPL;
+ return (pvp);
+}
+
+dt_provider_t *
+dt_provider_create(dtrace_hdl_t *dtp, const char *name)
+{
+ dt_provider_t *pvp;
+
+ if ((pvp = dt_zalloc(dtp, sizeof (dt_provider_t))) == NULL)
+ return (NULL);
+
+ (void) strlcpy(pvp->pv_desc.dtvd_name, name, DTRACE_PROVNAMELEN);
+ pvp->pv_probes = dt_idhash_create(pvp->pv_desc.dtvd_name, NULL, 0, 0);
+ pvp->pv_gen = dtp->dt_gen;
+ pvp->pv_hdl = dtp;
+
+ if (pvp->pv_probes == NULL) {
+ dt_free(dtp, pvp);
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ return (NULL);
+ }
+
+ pvp->pv_desc.dtvd_attr.dtpa_provider = _dtrace_prvattr;
+ pvp->pv_desc.dtvd_attr.dtpa_mod = _dtrace_prvattr;
+ pvp->pv_desc.dtvd_attr.dtpa_func = _dtrace_prvattr;
+ pvp->pv_desc.dtvd_attr.dtpa_name = _dtrace_prvattr;
+ pvp->pv_desc.dtvd_attr.dtpa_args = _dtrace_prvattr;
+
+ return (dt_provider_insert(dtp, pvp,
+ dt_strtab_hash(name, NULL) % dtp->dt_provbuckets));
+}
+
+void
+dt_provider_destroy(dtrace_hdl_t *dtp, dt_provider_t *pvp)
+{
+ dt_provider_t **pp;
+ uint_t h;
+
+ assert(pvp->pv_hdl == dtp);
+
+ h = dt_strtab_hash(pvp->pv_desc.dtvd_name, NULL) % dtp->dt_provbuckets;
+ pp = &dtp->dt_provs[h];
+
+ while (*pp != NULL && *pp != pvp)
+ pp = &(*pp)->pv_next;
+
+ assert(*pp != NULL && *pp == pvp);
+ *pp = pvp->pv_next;
+
+ dt_list_delete(&dtp->dt_provlist, pvp);
+ dtp->dt_nprovs--;
+
+ if (pvp->pv_probes != NULL)
+ dt_idhash_destroy(pvp->pv_probes);
+
+ dt_node_link_free(&pvp->pv_nodes);
+ dt_free(dtp, pvp->pv_xrefs);
+ dt_free(dtp, pvp);
+}
+
+int
+dt_provider_xref(dtrace_hdl_t *dtp, dt_provider_t *pvp, id_t id)
+{
+ size_t oldsize = BT_SIZEOFMAP(pvp->pv_xrmax);
+ size_t newsize = BT_SIZEOFMAP(dtp->dt_xlatorid);
+
+#ifdef VBOX /* range */
+ assert(id < dtp->dt_xlatorid);
+#else
+ assert(id >= 0 && id < dtp->dt_xlatorid);
+#endif
+
+ if (newsize > oldsize) {
+ ulong_t *xrefs = dt_zalloc(dtp, newsize);
+
+ if (xrefs == NULL)
+ return (-1);
+
+ bcopy(pvp->pv_xrefs, xrefs, oldsize);
+ dt_free(dtp, pvp->pv_xrefs);
+
+ pvp->pv_xrefs = xrefs;
+ pvp->pv_xrmax = dtp->dt_xlatorid;
+ }
+
+ BT_SET(pvp->pv_xrefs, id);
+ return (0);
+}
+
+static uint8_t
+dt_probe_argmap(dt_node_t *xnp, dt_node_t *nnp)
+{
+ uint8_t i;
+
+ for (i = 0; nnp != NULL; i++) {
+ if (nnp->dn_string != NULL &&
+ strcmp(nnp->dn_string, xnp->dn_string) == 0)
+ break;
+ else
+ nnp = nnp->dn_list;
+ }
+
+ return (i);
+}
+
+static dt_node_t *
+dt_probe_alloc_args(dt_provider_t *pvp, int argc)
+{
+ dt_node_t *args = NULL, *pnp = NULL, *dnp;
+ int i;
+
+ for (i = 0; i < argc; i++, pnp = dnp) {
+ if ((dnp = dt_node_xalloc(pvp->pv_hdl, DT_NODE_TYPE)) == NULL)
+ return (NULL);
+
+ dnp->dn_link = pvp->pv_nodes;
+ pvp->pv_nodes = dnp;
+
+ if (args == NULL)
+ args = dnp;
+ else
+ pnp->dn_list = dnp;
+ }
+
+ return (args);
+}
+
+static size_t
+dt_probe_keylen(const dtrace_probedesc_t *pdp)
+{
+ return (strlen(pdp->dtpd_mod) + 1 +
+ strlen(pdp->dtpd_func) + 1 + strlen(pdp->dtpd_name) + 1);
+}
+
+static char *
+dt_probe_key(const dtrace_probedesc_t *pdp, char *s)
+{
+ (void) snprintf(s, INT_MAX, "%s:%s:%s",
+ pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name);
+ return (s);
+}
+
+/*
+ * If a probe was discovered from the kernel, ask dtrace(7D) for a description
+ * of each of its arguments, including native and translated types.
+ */
+static dt_probe_t *
+dt_probe_discover(dt_provider_t *pvp, const dtrace_probedesc_t *pdp)
+{
+ dtrace_hdl_t *dtp = pvp->pv_hdl;
+ char *name = dt_probe_key(pdp, alloca(dt_probe_keylen(pdp)));
+
+ dt_node_t *xargs, *nargs;
+ dt_ident_t *idp;
+ dt_probe_t *prp;
+
+ dtrace_typeinfo_t dtt;
+ int i, nc, xc;
+
+ int adc = _dtrace_argmax;
+ dtrace_argdesc_t *adv = alloca(sizeof (dtrace_argdesc_t) * adc);
+ dtrace_argdesc_t *adp = adv;
+
+ assert(strcmp(pvp->pv_desc.dtvd_name, pdp->dtpd_provider) == 0);
+ assert(pdp->dtpd_id != DTRACE_IDNONE);
+
+ dt_dprintf("discovering probe %s:%s id=%d\n",
+ pvp->pv_desc.dtvd_name, name, pdp->dtpd_id);
+
+ for (nc = -1, i = 0; i < adc; i++, adp++) {
+ bzero(adp, sizeof (dtrace_argdesc_t));
+ adp->dtargd_ndx = i;
+ adp->dtargd_id = pdp->dtpd_id;
+
+ if (dt_ioctl(dtp, DTRACEIOC_PROBEARG, adp) != 0) {
+ (void) dt_set_errno(dtp, errno);
+ return (NULL);
+ }
+
+ if (adp->dtargd_ndx == DTRACE_ARGNONE)
+ break; /* all argument descs have been retrieved */
+
+ nc = MAX(nc, adp->dtargd_mapping);
+ }
+
+ xc = i;
+ nc++;
+
+ /*
+ * Now that we have discovered the number of native and translated
+ * arguments from the argument descriptions, allocate a new probe ident
+ * and corresponding dt_probe_t and hash it into the provider.
+ */
+ xargs = dt_probe_alloc_args(pvp, xc);
+ nargs = dt_probe_alloc_args(pvp, nc);
+
+ if ((xc != 0 && xargs == NULL) || (nc != 0 && nargs == NULL))
+ return (NULL); /* dt_errno is set for us */
+
+ idp = dt_ident_create(name, DT_IDENT_PROBE,
+ DT_IDFLG_ORPHAN, pdp->dtpd_id, _dtrace_defattr, 0,
+ &dt_idops_probe, NULL, dtp->dt_gen);
+
+ if (idp == NULL) {
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ return (NULL);
+ }
+
+ if ((prp = dt_probe_create(dtp, idp, 2,
+ nargs, nc, xargs, xc)) == NULL) {
+ dt_ident_destroy(idp);
+ return (NULL);
+ }
+
+ dt_probe_declare(pvp, prp);
+
+ /*
+ * Once our new dt_probe_t is fully constructed, iterate over the
+ * cached argument descriptions and assign types to prp->pr_nargv[]
+ * and prp->pr_xargv[] and assign mappings to prp->pr_mapping[].
+ */
+ for (adp = adv, i = 0; i < xc; i++, adp++) {
+ if (dtrace_type_strcompile(dtp,
+ adp->dtargd_native, &dtt) != 0) {
+ dt_dprintf("failed to resolve input type %s "
+ "for %s:%s arg #%d: %s\n", adp->dtargd_native,
+ pvp->pv_desc.dtvd_name, name, i + 1,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+
+ dtt.dtt_object = NULL;
+ dtt.dtt_ctfp = NULL;
+ dtt.dtt_type = CTF_ERR;
+ } else {
+ dt_node_type_assign(prp->pr_nargv[adp->dtargd_mapping],
+ dtt.dtt_ctfp, dtt.dtt_type);
+ }
+
+ if (dtt.dtt_type != CTF_ERR && (adp->dtargd_xlate[0] == '\0' ||
+ strcmp(adp->dtargd_native, adp->dtargd_xlate) == 0)) {
+ dt_node_type_propagate(prp->pr_nargv[
+ adp->dtargd_mapping], prp->pr_xargv[i]);
+ } else if (dtrace_type_strcompile(dtp,
+ adp->dtargd_xlate, &dtt) != 0) {
+ dt_dprintf("failed to resolve output type %s "
+ "for %s:%s arg #%d: %s\n", adp->dtargd_xlate,
+ pvp->pv_desc.dtvd_name, name, i + 1,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+
+ dtt.dtt_object = NULL;
+ dtt.dtt_ctfp = NULL;
+ dtt.dtt_type = CTF_ERR;
+ } else {
+ dt_node_type_assign(prp->pr_xargv[i],
+ dtt.dtt_ctfp, dtt.dtt_type);
+ }
+
+ prp->pr_mapping[i] = adp->dtargd_mapping;
+ prp->pr_argv[i] = dtt;
+ }
+
+ return (prp);
+}
+
+/*
+ * Lookup a probe declaration based on a known provider and full or partially
+ * specified module, function, and name. If the probe is not known to us yet,
+ * ask dtrace(7D) to match the description and then cache any useful results.
+ */
+dt_probe_t *
+dt_probe_lookup(dt_provider_t *pvp, const char *s)
+{
+ dtrace_hdl_t *dtp = pvp->pv_hdl;
+ dtrace_probedesc_t pd;
+ dt_ident_t *idp;
+ size_t keylen;
+ char *key;
+
+ if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, s, &pd) != 0)
+ return (NULL); /* dt_errno is set for us */
+
+ keylen = dt_probe_keylen(&pd);
+ key = dt_probe_key(&pd, alloca(keylen));
+
+ /*
+ * If the probe is already declared, then return the dt_probe_t from
+ * the existing identifier. This could come from a static declaration
+ * or it could have been cached from an earlier call to this function.
+ */
+ if ((idp = dt_idhash_lookup(pvp->pv_probes, key)) != NULL)
+ return (idp->di_data);
+
+ /*
+ * If the probe isn't known, use the probe description computed above
+ * to ask dtrace(7D) to find the first matching probe.
+ */
+ if (dt_ioctl(dtp, DTRACEIOC_PROBEMATCH, &pd) == 0)
+ return (dt_probe_discover(pvp, &pd));
+
+ if (errno == ESRCH || errno == EBADF)
+ (void) dt_set_errno(dtp, EDT_NOPROBE);
+ else
+ (void) dt_set_errno(dtp, errno);
+
+ return (NULL);
+}
+
+dt_probe_t *
+dt_probe_create(dtrace_hdl_t *dtp, dt_ident_t *idp, int protoc,
+ dt_node_t *nargs, uint_t nargc, dt_node_t *xargs, uint_t xargc)
+{
+ dt_module_t *dmp;
+ dt_probe_t *prp;
+ const char *p;
+ uint_t i;
+
+ assert(idp->di_kind == DT_IDENT_PROBE);
+ assert(idp->di_data == NULL);
+
+ /*
+ * If only a single prototype is given, set xargc/s to nargc/s to
+ * simplify subsequent use. Note that we can have one or both of nargs
+ * and xargs be specified but set to NULL, indicating a void prototype.
+ */
+ if (protoc < 2) {
+ assert(xargs == NULL);
+ assert(xargc == 0);
+ xargs = nargs;
+ xargc = nargc;
+ }
+
+ if ((prp = dt_alloc(dtp, sizeof (dt_probe_t))) == NULL)
+ return (NULL);
+
+ prp->pr_pvp = NULL;
+ prp->pr_ident = idp;
+
+ p = strrchr(idp->di_name, ':');
+ assert(p != NULL);
+ prp->pr_name = p + 1;
+
+ prp->pr_nargs = nargs;
+ prp->pr_nargv = dt_alloc(dtp, sizeof (dt_node_t *) * nargc);
+ prp->pr_nargc = nargc;
+ prp->pr_xargs = xargs;
+ prp->pr_xargv = dt_alloc(dtp, sizeof (dt_node_t *) * xargc);
+ prp->pr_xargc = xargc;
+ prp->pr_mapping = dt_alloc(dtp, sizeof (uint8_t) * xargc);
+ prp->pr_inst = NULL;
+ prp->pr_argv = dt_alloc(dtp, sizeof (dtrace_typeinfo_t) * xargc);
+ prp->pr_argc = xargc;
+
+ if ((prp->pr_nargc != 0 && prp->pr_nargv == NULL) ||
+ (prp->pr_xargc != 0 && prp->pr_xargv == NULL) ||
+ (prp->pr_xargc != 0 && prp->pr_mapping == NULL) ||
+ (prp->pr_argc != 0 && prp->pr_argv == NULL)) {
+ dt_probe_destroy(prp);
+ return (NULL);
+ }
+
+ for (i = 0; i < xargc; i++, xargs = xargs->dn_list) {
+ if (xargs->dn_string != NULL)
+ prp->pr_mapping[i] = dt_probe_argmap(xargs, nargs);
+ else
+ prp->pr_mapping[i] = i;
+
+ prp->pr_xargv[i] = xargs;
+
+ if ((dmp = dt_module_lookup_by_ctf(dtp,
+ xargs->dn_ctfp)) != NULL)
+ prp->pr_argv[i].dtt_object = dmp->dm_name;
+ else
+ prp->pr_argv[i].dtt_object = NULL;
+
+ prp->pr_argv[i].dtt_ctfp = xargs->dn_ctfp;
+ prp->pr_argv[i].dtt_type = xargs->dn_type;
+ }
+
+ for (i = 0; i < nargc; i++, nargs = nargs->dn_list)
+ prp->pr_nargv[i] = nargs;
+
+ idp->di_data = prp;
+ return (prp);
+}
+
+void
+dt_probe_declare(dt_provider_t *pvp, dt_probe_t *prp)
+{
+ assert(prp->pr_ident->di_kind == DT_IDENT_PROBE);
+ assert(prp->pr_ident->di_data == prp);
+ assert(prp->pr_pvp == NULL);
+
+ if (prp->pr_xargs != prp->pr_nargs)
+ pvp->pv_flags &= ~DT_PROVIDER_INTF;
+
+ prp->pr_pvp = pvp;
+ dt_idhash_xinsert(pvp->pv_probes, prp->pr_ident);
+}
+
+void
+dt_probe_destroy(dt_probe_t *prp)
+{
+ dt_probe_instance_t *pip, *pip_next;
+ dtrace_hdl_t *dtp;
+
+ if (prp->pr_pvp != NULL)
+ dtp = prp->pr_pvp->pv_hdl;
+ else
+ dtp = yypcb->pcb_hdl;
+
+ dt_node_list_free(&prp->pr_nargs);
+ dt_node_list_free(&prp->pr_xargs);
+
+ dt_free(dtp, prp->pr_nargv);
+ dt_free(dtp, prp->pr_xargv);
+
+ for (pip = prp->pr_inst; pip != NULL; pip = pip_next) {
+ pip_next = pip->pi_next;
+ dt_free(dtp, pip->pi_offs);
+ dt_free(dtp, pip->pi_enoffs);
+ dt_free(dtp, pip);
+ }
+
+ dt_free(dtp, prp->pr_mapping);
+ dt_free(dtp, prp->pr_argv);
+ dt_free(dtp, prp);
+}
+
+int
+dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp,
+ const char *fname, const char *rname, uint32_t offset, int isenabled)
+{
+ dtrace_hdl_t *dtp = pvp->pv_hdl;
+ dt_probe_instance_t *pip;
+ uint32_t **offs;
+ uint_t *noffs, *maxoffs;
+
+ assert(fname != NULL);
+
+ for (pip = prp->pr_inst; pip != NULL; pip = pip->pi_next) {
+ if (strcmp(pip->pi_fname, fname) == 0 &&
+ ((rname == NULL && pip->pi_rname[0] == '\0') ||
+ (rname != NULL && strcmp(pip->pi_rname, rname)) == 0))
+ break;
+ }
+
+ if (pip == NULL) {
+ if ((pip = dt_zalloc(dtp, sizeof (*pip))) == NULL)
+ return (-1);
+
+ if ((pip->pi_offs = dt_zalloc(dtp,
+ sizeof (uint32_t))) == NULL) {
+ dt_free(dtp, pip);
+ return (-1);
+ }
+
+ if ((pip->pi_enoffs = dt_zalloc(dtp,
+ sizeof (uint32_t))) == NULL) {
+ dt_free(dtp, pip->pi_offs);
+ dt_free(dtp, pip);
+ return (-1);
+ }
+
+ (void) strlcpy(pip->pi_fname, fname, sizeof (pip->pi_fname));
+ if (rname != NULL) {
+ if (strlen(rname) + 1 > sizeof (pip->pi_rname)) {
+ dt_free(dtp, pip->pi_offs);
+ dt_free(dtp, pip);
+ return (dt_set_errno(dtp, EDT_COMPILER));
+ }
+ (void) strcpy(pip->pi_rname, rname);
+ }
+
+ pip->pi_noffs = 0;
+ pip->pi_maxoffs = 1;
+ pip->pi_nenoffs = 0;
+ pip->pi_maxenoffs = 1;
+
+ pip->pi_next = prp->pr_inst;
+
+ prp->pr_inst = pip;
+ }
+
+ if (isenabled) {
+ offs = &pip->pi_enoffs;
+ noffs = &pip->pi_nenoffs;
+ maxoffs = &pip->pi_maxenoffs;
+ } else {
+ offs = &pip->pi_offs;
+ noffs = &pip->pi_noffs;
+ maxoffs = &pip->pi_maxoffs;
+ }
+
+ if (*noffs == *maxoffs) {
+ uint_t new_max = *maxoffs * 2;
+ uint32_t *new_offs = dt_alloc(dtp, sizeof (uint32_t) * new_max);
+
+ if (new_offs == NULL)
+ return (-1);
+
+ bcopy(*offs, new_offs, sizeof (uint32_t) * *maxoffs);
+
+ dt_free(dtp, *offs);
+ *maxoffs = new_max;
+ *offs = new_offs;
+ }
+
+ dt_dprintf("defined probe %s %s:%s %s() +0x%x (%s)\n",
+ isenabled ? "(is-enabled)" : "",
+ pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, fname, offset,
+ rname != NULL ? rname : fname);
+
+ assert(*noffs < *maxoffs);
+ (*offs)[(*noffs)++] = offset;
+
+ return (0);
+}
+
+/*
+ * Lookup the dynamic translator type tag for the specified probe argument and
+ * assign the type to the specified node. If the type is not yet defined, add
+ * it to the "D" module's type container as a typedef for an unknown type.
+ */
+dt_node_t *
+dt_probe_tag(dt_probe_t *prp, uint_t argn, dt_node_t *dnp)
+{
+ dtrace_hdl_t *dtp = prp->pr_pvp->pv_hdl;
+ dtrace_typeinfo_t dtt;
+ size_t len;
+ char *tag;
+
+ len = snprintf(NULL, 0, "__dtrace_%s___%s_arg%u",
+ prp->pr_pvp->pv_desc.dtvd_name, prp->pr_name, argn);
+
+ tag = alloca(len + 1);
+
+ (void) snprintf(tag, len + 1, "__dtrace_%s___%s_arg%u",
+ prp->pr_pvp->pv_desc.dtvd_name, prp->pr_name, argn);
+
+ if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_DDEFS, tag, &dtt) != 0) {
+ dtt.dtt_object = DTRACE_OBJ_DDEFS;
+ dtt.dtt_ctfp = DT_DYN_CTFP(dtp);
+ dtt.dtt_type = ctf_add_typedef(DT_DYN_CTFP(dtp),
+ CTF_ADD_ROOT, tag, DT_DYN_TYPE(dtp));
+
+ if (dtt.dtt_type == CTF_ERR ||
+ ctf_update(dtt.dtt_ctfp) == CTF_ERR) {
+ xyerror(D_UNKNOWN, "cannot define type %s: %s\n",
+ tag, ctf_errmsg(ctf_errno(dtt.dtt_ctfp)));
+ }
+ }
+
+ bzero(dnp, sizeof (dt_node_t));
+ dnp->dn_kind = DT_NODE_TYPE;
+
+ dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
+ dt_node_attr_assign(dnp, _dtrace_defattr);
+
+ return (dnp);
+}
+
+/*ARGSUSED*/
+static int
+dt_probe_desc(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
+{
+ RT_NOREF1(dtp);
+
+ if (((dtrace_probedesc_t *)arg)->dtpd_id == DTRACE_IDNONE) {
+ bcopy(pdp, arg, sizeof (dtrace_probedesc_t));
+ return (0);
+ }
+
+ return (1);
+}
+
+dt_probe_t *
+dt_probe_info(dtrace_hdl_t *dtp,
+ const dtrace_probedesc_t *pdp, dtrace_probeinfo_t *pip)
+{
+ int m_is_glob = pdp->dtpd_mod[0] == '\0' || strisglob(pdp->dtpd_mod);
+ int f_is_glob = pdp->dtpd_func[0] == '\0' || strisglob(pdp->dtpd_func);
+ int n_is_glob = pdp->dtpd_name[0] == '\0' || strisglob(pdp->dtpd_name);
+
+ dt_probe_t *prp = NULL;
+ const dtrace_pattr_t *pap;
+ dt_provider_t *pvp;
+ dt_ident_t *idp;
+
+ /*
+ * Attempt to lookup the probe in our existing cache for this provider.
+ * If none is found and an explicit probe ID was specified, discover
+ * that specific probe and cache its description and arguments.
+ */
+ if ((pvp = dt_provider_lookup(dtp, pdp->dtpd_provider)) != NULL) {
+ size_t keylen = dt_probe_keylen(pdp);
+ char *key = dt_probe_key(pdp, alloca(keylen));
+
+ if ((idp = dt_idhash_lookup(pvp->pv_probes, key)) != NULL)
+ prp = idp->di_data;
+ else if (pdp->dtpd_id != DTRACE_IDNONE)
+ prp = dt_probe_discover(pvp, pdp);
+ }
+
+ /*
+ * If no probe was found in our cache, convert the caller's partial
+ * probe description into a fully-formed matching probe description by
+ * iterating over up to at most two probes that match 'pdp'. We then
+ * call dt_probe_discover() on the resulting probe identifier.
+ */
+ if (prp == NULL) {
+ dtrace_probedesc_t pd;
+ int m;
+
+ bzero(&pd, sizeof (pd));
+ pd.dtpd_id = DTRACE_IDNONE;
+
+ /*
+ * Call dtrace_probe_iter() to find matching probes. Our
+ * dt_probe_desc() callback will produce the following results:
+ *
+ * m < 0 dtrace_probe_iter() found zero matches (or failed).
+ * m > 0 dtrace_probe_iter() found more than one match.
+ * m = 0 dtrace_probe_iter() found exactly one match.
+ */
+ if ((m = dtrace_probe_iter(dtp, pdp, dt_probe_desc, &pd)) < 0)
+ return (NULL); /* dt_errno is set for us */
+
+ if ((pvp = dt_provider_lookup(dtp, pd.dtpd_provider)) == NULL)
+ return (NULL); /* dt_errno is set for us */
+
+ /*
+ * If more than one probe was matched, then do not report probe
+ * information if either of the following conditions is true:
+ *
+ * (a) The Arguments Data stability of the matched provider is
+ * less than Evolving.
+ *
+ * (b) Any description component that is at least Evolving is
+ * empty or is specified using a globbing expression.
+ *
+ * These conditions imply that providers that provide Evolving
+ * or better Arguments Data stability must guarantee that all
+ * probes with identical field names in a field of Evolving or
+ * better Name stability have identical argument signatures.
+ */
+ if (m > 0) {
+ if (pvp->pv_desc.dtvd_attr.dtpa_args.dtat_data <
+ DTRACE_STABILITY_EVOLVING) {
+ (void) dt_set_errno(dtp, EDT_UNSTABLE);
+ return (NULL);
+ }
+
+
+ if (pvp->pv_desc.dtvd_attr.dtpa_mod.dtat_name >=
+ DTRACE_STABILITY_EVOLVING && m_is_glob) {
+ (void) dt_set_errno(dtp, EDT_UNSTABLE);
+ return (NULL);
+ }
+
+ if (pvp->pv_desc.dtvd_attr.dtpa_func.dtat_name >=
+ DTRACE_STABILITY_EVOLVING && f_is_glob) {
+ (void) dt_set_errno(dtp, EDT_UNSTABLE);
+ return (NULL);
+ }
+
+ if (pvp->pv_desc.dtvd_attr.dtpa_name.dtat_name >=
+ DTRACE_STABILITY_EVOLVING && n_is_glob) {
+ (void) dt_set_errno(dtp, EDT_UNSTABLE);
+ return (NULL);
+ }
+ }
+
+ /*
+ * If we matched a probe exported by dtrace(7D), then discover
+ * the real attributes. Otherwise grab the static declaration.
+ */
+ if (pd.dtpd_id != DTRACE_IDNONE)
+ prp = dt_probe_discover(pvp, &pd);
+ else
+ prp = dt_probe_lookup(pvp, pd.dtpd_name);
+
+ if (prp == NULL)
+ return (NULL); /* dt_errno is set for us */
+ }
+
+ assert(pvp != NULL && prp != NULL);
+
+ /*
+ * Compute the probe description attributes by taking the minimum of
+ * the attributes of the specified fields. If no provider is specified
+ * or a glob pattern is used for the provider, use Unstable attributes.
+ */
+ if (pdp->dtpd_provider[0] == '\0' || strisglob(pdp->dtpd_provider))
+ pap = &_dtrace_prvdesc;
+ else
+ pap = &pvp->pv_desc.dtvd_attr;
+
+ pip->dtp_attr = pap->dtpa_provider;
+
+ if (!m_is_glob)
+ pip->dtp_attr = dt_attr_min(pip->dtp_attr, pap->dtpa_mod);
+ if (!f_is_glob)
+ pip->dtp_attr = dt_attr_min(pip->dtp_attr, pap->dtpa_func);
+ if (!n_is_glob)
+ pip->dtp_attr = dt_attr_min(pip->dtp_attr, pap->dtpa_name);
+
+ pip->dtp_arga = pap->dtpa_args;
+ pip->dtp_argv = prp->pr_argv;
+ pip->dtp_argc = prp->pr_argc;
+
+ return (prp);
+}
+
+int
+dtrace_probe_info(dtrace_hdl_t *dtp,
+ const dtrace_probedesc_t *pdp, dtrace_probeinfo_t *pip)
+{
+ return (dt_probe_info(dtp, pdp, pip) != NULL ? 0 : -1);
+}
+
+/*ARGSUSED*/
+static int
+dt_probe_iter(dt_idhash_t *ihp, dt_ident_t *idp, dt_probe_iter_t *pit)
+{
+ const dt_probe_t *prp = idp->di_data;
+ RT_NOREF1(ihp);
+
+ if (!dt_gmatch(prp->pr_name, pit->pit_pat))
+ return (0); /* continue on and examine next probe in hash */
+
+ (void) strlcpy(pit->pit_desc.dtpd_name, prp->pr_name, DTRACE_NAMELEN);
+ pit->pit_desc.dtpd_id = idp->di_id;
+ pit->pit_matches++;
+
+ return (pit->pit_func(pit->pit_hdl, &pit->pit_desc, pit->pit_arg));
+}
+
+int
+dtrace_probe_iter(dtrace_hdl_t *dtp,
+ const dtrace_probedesc_t *pdp, dtrace_probe_f *func, void *arg)
+{
+ const char *provider = pdp ? pdp->dtpd_provider : NULL;
+ dtrace_id_t id = DTRACE_IDNONE;
+
+ dtrace_probedesc_t pd;
+ dt_probe_iter_t pit;
+ int cmd, rv;
+
+ bzero(&pit, sizeof (pit));
+ pit.pit_hdl = dtp;
+ pit.pit_func = func;
+ pit.pit_arg = arg;
+ pit.pit_pat = pdp ? pdp->dtpd_name : NULL;
+
+ for (pit.pit_pvp = dt_list_next(&dtp->dt_provlist);
+ pit.pit_pvp != NULL; pit.pit_pvp = dt_list_next(pit.pit_pvp)) {
+
+ if (pit.pit_pvp->pv_flags & DT_PROVIDER_IMPL)
+ continue; /* we'll get these later using dt_ioctl() */
+
+ if (!dt_gmatch(pit.pit_pvp->pv_desc.dtvd_name, provider))
+ continue;
+
+ (void) strlcpy(pit.pit_desc.dtpd_provider,
+ pit.pit_pvp->pv_desc.dtvd_name, DTRACE_PROVNAMELEN);
+
+ if ((rv = dt_idhash_iter(pit.pit_pvp->pv_probes,
+ (dt_idhash_f *)dt_probe_iter, &pit)) != 0)
+ return (rv);
+ }
+
+ if (pdp != NULL)
+ cmd = DTRACEIOC_PROBEMATCH;
+ else
+ cmd = DTRACEIOC_PROBES;
+
+ for (;;) {
+ if (pdp != NULL)
+ bcopy(pdp, &pd, sizeof (pd));
+
+ pd.dtpd_id = id;
+
+ if (dt_ioctl(dtp, cmd, &pd) != 0)
+ break;
+ else if ((rv = func(dtp, &pd, arg)) != 0)
+ return (rv);
+
+ pit.pit_matches++;
+ id = pd.dtpd_id + 1;
+ }
+
+ switch (errno) {
+ case ESRCH:
+ case EBADF:
+ return (pit.pit_matches ? 0 : dt_set_errno(dtp, EDT_NOPROBE));
+ case EINVAL:
+ return (dt_set_errno(dtp, EDT_BADPGLOB));
+ default:
+ return (dt_set_errno(dtp, errno));
+ }
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.h
new file mode 100644
index 00000000..c7b51381
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.h
@@ -0,0 +1,120 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_PROVIDER_H
+#define _DT_PROVIDER_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <dt_impl.h>
+#include <dt_ident.h>
+#include <dt_list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dt_provider {
+ dt_list_t pv_list; /* list forward/back pointers */
+ struct dt_provider *pv_next; /* pointer to next provider in hash */
+ dtrace_providerdesc_t pv_desc; /* provider name and attributes */
+ dt_idhash_t *pv_probes; /* probe defs (if user-declared) */
+ dt_node_t *pv_nodes; /* parse node allocation list */
+ ulong_t *pv_xrefs; /* translator reference bitmap */
+ ulong_t pv_xrmax; /* number of valid bits in pv_xrefs */
+ ulong_t pv_gen; /* generation # that created me */
+ dtrace_hdl_t *pv_hdl; /* pointer to containing dtrace_hdl */
+ uint_t pv_flags; /* flags (see below) */
+} dt_provider_t;
+
+#define DT_PROVIDER_INTF 0x1 /* provider interface declaration */
+#define DT_PROVIDER_IMPL 0x2 /* provider implementation is loaded */
+
+typedef struct dt_probe_iter {
+ dtrace_probedesc_t pit_desc; /* description storage */
+ dtrace_hdl_t *pit_hdl; /* libdtrace handle */
+ dt_provider_t *pit_pvp; /* current provider */
+ const char *pit_pat; /* caller's name pattern (or NULL) */
+ dtrace_probe_f *pit_func; /* caller's function */
+ void *pit_arg; /* caller's argument */
+ uint_t pit_matches; /* number of matches */
+} dt_probe_iter_t;
+
+typedef struct dt_probe_instance {
+ char pi_fname[DTRACE_FUNCNAMELEN]; /* function name */
+ char pi_rname[DTRACE_FUNCNAMELEN + 20]; /* mangled relocation name */
+ uint32_t *pi_offs; /* offsets into the function */
+ uint32_t *pi_enoffs; /* is-enabled offsets */
+ uint_t pi_noffs; /* number of offsets */
+ uint_t pi_maxoffs; /* size of pi_offs allocation */
+ uint_t pi_nenoffs; /* number of is-enabled offsets */
+ uint_t pi_maxenoffs; /* size of pi_enoffs allocation */
+ struct dt_probe_instance *pi_next; /* next instance in the list */
+} dt_probe_instance_t;
+
+typedef struct dt_probe {
+ dt_provider_t *pr_pvp; /* pointer to containing provider */
+ dt_ident_t *pr_ident; /* pointer to probe identifier */
+ const char *pr_name; /* pointer to name component */
+ dt_node_t *pr_nargs; /* native argument list */
+ dt_node_t **pr_nargv; /* native argument vector */
+ uint_t pr_nargc; /* native argument count */
+ dt_node_t *pr_xargs; /* translated argument list */
+ dt_node_t **pr_xargv; /* translated argument vector */
+ uint_t pr_xargc; /* translated argument count */
+ uint8_t *pr_mapping; /* translated argument mapping */
+ dt_probe_instance_t *pr_inst; /* list of functions and offsets */
+ dtrace_typeinfo_t *pr_argv; /* output argument types */
+ int pr_argc; /* output argument count */
+} dt_probe_t;
+
+extern dt_provider_t *dt_provider_lookup(dtrace_hdl_t *, const char *);
+extern dt_provider_t *dt_provider_create(dtrace_hdl_t *, const char *);
+extern void dt_provider_destroy(dtrace_hdl_t *, dt_provider_t *);
+extern int dt_provider_xref(dtrace_hdl_t *, dt_provider_t *, id_t);
+
+extern dt_probe_t *dt_probe_create(dtrace_hdl_t *, dt_ident_t *, int,
+ dt_node_t *, uint_t, dt_node_t *, uint_t);
+
+extern dt_probe_t *dt_probe_info(dtrace_hdl_t *,
+ const dtrace_probedesc_t *, dtrace_probeinfo_t *);
+
+extern dt_probe_t *dt_probe_lookup(dt_provider_t *, const char *);
+extern void dt_probe_declare(dt_provider_t *, dt_probe_t *);
+extern void dt_probe_destroy(dt_probe_t *);
+
+extern int dt_probe_define(dt_provider_t *, dt_probe_t *,
+ const char *, const char *, uint32_t, int);
+
+extern dt_node_t *dt_probe_tag(dt_probe_t *, uint_t, dt_node_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PROVIDER_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.c
new file mode 100644
index 00000000..9ae66f99
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.c
@@ -0,0 +1,112 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/bitmap.h>
+#include <assert.h>
+#include <strings.h>
+#include <stdlib.h>
+#else /* VBOX */
+# include <iprt/asm.h>
+# include "VBoxDTraceLibCWrappers.h"
+#endif /* VBOX */
+
+#include <dt_regset.h>
+
+dt_regset_t *
+dt_regset_create(ulong_t size)
+{
+ ulong_t n = BT_BITOUL(size + 1); /* + 1 for %r0 */
+ dt_regset_t *drp = malloc(sizeof (dt_regset_t));
+
+ if (drp == NULL)
+ return (NULL);
+
+ drp->dr_bitmap = malloc(sizeof (ulong_t) * n);
+ drp->dr_size = size + 1;
+
+ if (drp->dr_bitmap == NULL) {
+ dt_regset_destroy(drp);
+ return (NULL);
+ }
+
+ bzero(drp->dr_bitmap, sizeof (ulong_t) * n);
+ return (drp);
+}
+
+void
+dt_regset_destroy(dt_regset_t *drp)
+{
+ free(drp->dr_bitmap);
+ free(drp);
+}
+
+void
+dt_regset_reset(dt_regset_t *drp)
+{
+ bzero(drp->dr_bitmap, sizeof (ulong_t) * BT_BITOUL(drp->dr_size));
+}
+
+int
+dt_regset_alloc(dt_regset_t *drp)
+{
+ ulong_t nbits = drp->dr_size - 1;
+ ulong_t maxw = nbits >> BT_ULSHIFT;
+ ulong_t wx;
+
+ for (wx = 0; wx <= maxw; wx++) {
+ if (drp->dr_bitmap[wx] != ~0UL)
+ break;
+ }
+
+ if (wx <= maxw) {
+ ulong_t maxb = (wx == maxw) ? nbits & BT_ULMASK : BT_NBIPUL - 1;
+ ulong_t word = drp->dr_bitmap[wx];
+ ulong_t bit, bx;
+ int reg;
+
+ for (bit = 1, bx = 0; bx <= maxb; bx++, bit <<= 1) {
+ if ((word & bit) == 0) {
+ reg = (int)((wx << BT_ULSHIFT) | bx);
+ BT_SET(drp->dr_bitmap, reg);
+ return (reg);
+ }
+ }
+ }
+
+ return (-1); /* no available registers */
+}
+
+void
+dt_regset_free(dt_regset_t *drp, int reg)
+{
+ assert(reg > 0 && (unsigned /*vbox*/)reg < drp->dr_size);
+ assert(BT_TEST(drp->dr_bitmap, reg) != 0);
+ BT_CLEAR(drp->dr_bitmap, reg);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.h
new file mode 100644
index 00000000..3dc20d5e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_regset.h
@@ -0,0 +1,57 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_REGSET_H
+#define _DT_REGSET_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#else /* VBOX */
+# include "VBoxDTraceTypes.h"
+#endif /* VBOX */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dt_regset {
+ ulong_t dr_size; /* number of registers in set */
+ ulong_t *dr_bitmap; /* bitmap of active registers */
+} dt_regset_t;
+
+extern dt_regset_t *dt_regset_create(ulong_t);
+extern void dt_regset_destroy(dt_regset_t *);
+extern void dt_regset_reset(dt_regset_t *);
+extern int dt_regset_alloc(dt_regset_t *);
+extern void dt_regset_free(dt_regset_t *, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_REGSET_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.c
new file mode 100644
index 00000000..166bfbfe
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.c
@@ -0,0 +1,348 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <strings.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <ctype.h>
+
+#include <dt_string.h>
+
+#else /* VBOX */
+# include <dt_string.h>
+# include <dt_impl.h>
+# include <iprt/ctype.h>
+# define isalnum(a_ch) RT_C_IS_ALNUM(a_ch)
+#endif /* VBOX */
+
+/*
+ * Transform string s inline, converting each embedded C escape sequence string
+ * to the corresponding character. For example, the substring "\n" is replaced
+ * by an inline '\n' character. The length of the resulting string is returned.
+ */
+size_t
+stresc2chr(char *s)
+{
+ char *p, *q, c;
+ int esc = 0;
+ int x;
+
+ for (p = q = s; (c = *p) != '\0'; p++) {
+ if (esc) {
+ switch (c) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ c -= '0';
+ p++;
+
+ if (*p >= '0' && *p <= '7') {
+ c = c * 8 + *p++ - '0';
+
+ if (*p >= '0' && *p <= '7')
+ c = c * 8 + *p - '0';
+ else
+ p--;
+ } else
+ p--;
+
+ *q++ = c;
+ break;
+
+ case 'a':
+ *q++ = '\a';
+ break;
+ case 'b':
+ *q++ = '\b';
+ break;
+ case 'f':
+ *q++ = '\f';
+ break;
+ case 'n':
+ *q++ = '\n';
+ break;
+ case 'r':
+ *q++ = '\r';
+ break;
+ case 't':
+ *q++ = '\t';
+ break;
+ case 'v':
+ *q++ = '\v';
+ break;
+
+ case 'x':
+ for (x = 0; (c = *++p) != '\0'; ) {
+ if (c >= '0' && c <= '9')
+ x = x * 16 + c - '0';
+ else if (c >= 'a' && c <= 'f')
+ x = x * 16 + c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ x = x * 16 + c - 'A' + 10;
+ else
+ break;
+ }
+ *q++ = (char)x;
+ p--;
+ break;
+
+ case '"':
+ case '\\':
+ *q++ = c;
+ break;
+ default:
+ *q++ = '\\';
+ *q++ = c;
+ }
+
+ esc = 0;
+
+ } else {
+ if ((esc = c == '\\') == 0)
+ *q++ = c;
+ }
+ }
+
+ *q = '\0';
+ return ((size_t)(q - s));
+}
+
+/*
+ * Create a copy of string s in which certain unprintable or special characters
+ * have been converted to the string representation of their C escape sequence.
+ * For example, the newline character is expanded to the string "\n".
+ */
+char *
+strchr2esc(const char *s, size_t n)
+{
+ const char *p;
+ char *q, *s2, c;
+ size_t addl = 0;
+
+ for (p = s; p < s + n; p++) {
+ switch (c = *p) {
+ case '\0':
+ case '\a':
+ case '\b':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ case '\v':
+ case '"':
+ case '\\':
+ addl++; /* 1 add'l char needed to follow \ */
+ break;
+ case ' ':
+ break;
+ default:
+ if (c < '!' || c > '~')
+ addl += 3; /* 3 add'l chars following \ */
+ }
+ }
+
+ if ((s2 = malloc(n + addl + 1)) == NULL)
+ return (NULL);
+
+ for (p = s, q = s2; p < s + n; p++) {
+ switch (c = *p) {
+ case '\0':
+ *q++ = '\\';
+ *q++ = '0';
+ break;
+ case '\a':
+ *q++ = '\\';
+ *q++ = 'a';
+ break;
+ case '\b':
+ *q++ = '\\';
+ *q++ = 'b';
+ break;
+ case '\f':
+ *q++ = '\\';
+ *q++ = 'f';
+ break;
+ case '\n':
+ *q++ = '\\';
+ *q++ = 'n';
+ break;
+ case '\r':
+ *q++ = '\\';
+ *q++ = 'r';
+ break;
+ case '\t':
+ *q++ = '\\';
+ *q++ = 't';
+ break;
+ case '\v':
+ *q++ = '\\';
+ *q++ = 'v';
+ break;
+ case '"':
+ *q++ = '\\';
+ *q++ = '"';
+ break;
+ case '\\':
+ *q++ = '\\';
+ *q++ = '\\';
+ break;
+ case ' ':
+ *q++ = c;
+ break;
+ default:
+ if (c < '!' || c > '~') {
+ *q++ = '\\';
+ *q++ = ((c >> 6) & 3) + '0';
+ *q++ = ((c >> 3) & 7) + '0';
+ *q++ = (c & 7) + '0';
+ } else
+ *q++ = c;
+ }
+
+ if (c == '\0')
+ break; /* don't continue past \0 even if p < s + n */
+ }
+
+ *q = '\0';
+ return (s2);
+}
+
+/*
+ * Return the basename (name after final /) of the given string. We use
+ * strbasename rather than basename to avoid conflicting with libgen.h's
+ * non-const function prototype.
+ */
+const char *
+strbasename(const char *s)
+{
+ const char *p = strrchr(s, '/');
+
+ if (p == NULL)
+ return (s);
+
+ return (++p);
+}
+
+/*
+ * This function tests a string against the regular expression used for idents
+ * and integers in the D lexer, and should match the superset of RGX_IDENT and
+ * RGX_INT in dt_lex.l. If an invalid character is found, the function returns
+ * a pointer to it. Otherwise NULL is returned for a valid string.
+ */
+const char *
+strbadidnum(const char *s)
+{
+#ifndef VBOX
+ char *p;
+#endif
+ int c;
+
+ if (*s == '\0')
+ return (s);
+
+#ifndef VBOX
+ errno = 0;
+ (void) strtoull(s, &p, 0);
+
+ if (errno == 0 && *p == '\0')
+ return (NULL); /* matches RGX_INT */
+#else
+ /* A number? */
+ c = *s;
+ if (RT_C_IS_DIGIT(c)) {
+ s++;
+ if (c == '0') {
+ c = *s;
+ if (c == 'x' || c == 'X') {
+ s++;
+ while ((c = *s++) != '\0') {
+ if (RT_C_IS_XDIGIT(c) == 0)
+ return (s - 1);
+ }
+ } else {
+ while ((c = *s++) != '\0') {
+ if (RT_C_IS_ODIGIT(c) == 0)
+ return (s - 1);
+ }
+ }
+ } else {
+ while ((c = *s++) != '\0') {
+ if (RT_C_IS_DIGIT(c) == 0)
+ return (s - 1);
+ }
+ }
+ return (NULL); /* matches RGX_INT */
+ }
+#endif
+
+ while ((c = *s++) != '\0') {
+ if (isalnum(c) == 0 && c != '_' && c != '`')
+ return (s - 1);
+ }
+
+ return (NULL); /* matches RGX_IDENT */
+}
+
+/*
+ * Determine whether the string contains a glob matching pattern or is just a
+ * simple string. See gmatch(3GEN) and sh(1) for the glob syntax definition.
+ */
+int
+strisglob(const char *s)
+{
+ char c;
+
+ while ((c = *s++) != '\0') {
+ if (c == '[' || c == '?' || c == '*' || c == '\\')
+ return (1);
+ }
+
+ return (0);
+}
+
+/*
+ * Hyphenate a string in-place by converting any instances of "__" to "-",
+ * which we use for probe names to improve readability, and return the string.
+ */
+char *
+strhyphenate(char *s)
+{
+ char *p, *q;
+
+ for (p = s, q = p + strlen(p); p < q; p++) {
+ if (p[0] == '_' && p[1] == '_') {
+ p[0] = '-';
+ bcopy(p + 2, p + 1, (size_t)(q - p) - 1);
+ }
+ }
+
+ return (s);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.h
new file mode 100644
index 00000000..0c9bb40a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_string.h
@@ -0,0 +1,51 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _DT_STRING_H
+#define _DT_STRING_H
+
+#ifndef VBOX
+#include <sys/types.h>
+#include <strings.h>
+#else /* VBOX */
+# include <iprt/string.h>
+#endif /* VBOX */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern size_t stresc2chr(char *);
+extern char *strchr2esc(const char *, size_t);
+extern const char *strbasename(const char *);
+extern const char *strbadidnum(const char *);
+extern int strisglob(const char *);
+extern char *strhyphenate(char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_STRING_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.c
new file mode 100644
index 00000000..c19d1b9d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.c
@@ -0,0 +1,295 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/sysmacros.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <assert.h>
+#endif
+
+#include <dt_strtab.h>
+#include <dt_impl.h>
+
+static int
+dt_strtab_grow(dt_strtab_t *sp)
+{
+ char *ptr, **bufs;
+
+ if ((ptr = malloc(sp->str_bufsz)) == NULL)
+ return (-1);
+
+ bufs = realloc(sp->str_bufs, (sp->str_nbufs + 1) * sizeof (char *));
+
+ if (bufs == NULL) {
+ free(ptr);
+ return (-1);
+ }
+
+ sp->str_nbufs++;
+ sp->str_bufs = bufs;
+ sp->str_ptr = ptr;
+ sp->str_bufs[sp->str_nbufs - 1] = sp->str_ptr;
+
+ return (0);
+}
+
+dt_strtab_t *
+dt_strtab_create(size_t bufsz)
+{
+ dt_strtab_t *sp = malloc(sizeof (dt_strtab_t));
+ uint_t nbuckets = _dtrace_strbuckets;
+
+ assert(bufsz != 0);
+
+ if (sp == NULL)
+ return (NULL);
+
+ bzero(sp, sizeof (dt_strtab_t));
+ sp->str_hash = malloc(nbuckets * sizeof (dt_strhash_t *));
+
+ if (sp->str_hash == NULL)
+ goto err;
+
+ bzero(sp->str_hash, nbuckets * sizeof (dt_strhash_t *));
+ sp->str_hashsz = nbuckets;
+ sp->str_bufs = NULL;
+ sp->str_ptr = NULL;
+ sp->str_nbufs = 0;
+ sp->str_bufsz = bufsz;
+ sp->str_nstrs = 1;
+ sp->str_size = 1;
+
+ if (dt_strtab_grow(sp) == -1)
+ goto err;
+
+ *sp->str_ptr++ = '\0';
+ return (sp);
+
+err:
+ dt_strtab_destroy(sp);
+ return (NULL);
+}
+
+void
+dt_strtab_destroy(dt_strtab_t *sp)
+{
+ dt_strhash_t *hp, *hq;
+ ulong_t i;
+
+ for (i = 0; i < sp->str_hashsz; i++) {
+ for (hp = sp->str_hash[i]; hp != NULL; hp = hq) {
+ hq = hp->str_next;
+ free(hp);
+ }
+ }
+
+ for (i = 0; i < sp->str_nbufs; i++)
+ free(sp->str_bufs[i]);
+
+ if (sp->str_hash != NULL)
+ free(sp->str_hash);
+ if (sp->str_bufs != NULL)
+ free(sp->str_bufs);
+
+ free(sp);
+}
+
+ulong_t
+dt_strtab_hash(const char *key, size_t *len)
+{
+ ulong_t g, h = 0;
+ const char *p;
+ size_t n = 0;
+
+ for (p = key; *p != '\0'; p++, n++) {
+ h = (h << 4) + *p;
+
+ if ((g = (h & 0xf0000000)) != 0) {
+ h ^= (g >> 24);
+ h ^= g;
+ }
+ }
+
+ if (len != NULL)
+ *len = n;
+
+ return (h);
+}
+
+static int
+dt_strtab_compare(dt_strtab_t *sp, dt_strhash_t *hp,
+ const char *str, size_t len)
+{
+ ulong_t b = hp->str_buf;
+ const char *buf = hp->str_data;
+ size_t resid, n;
+ int rv;
+
+ while (len != 0) {
+ if (buf == sp->str_bufs[b] + sp->str_bufsz)
+ buf = sp->str_bufs[++b];
+
+ resid = sp->str_bufs[b] + sp->str_bufsz - buf;
+ n = MIN(resid, len);
+
+ if ((rv = strncmp(buf, str, n)) != 0)
+ return (rv);
+
+ buf += n;
+ str += n;
+ len -= n;
+ }
+
+ return (0);
+}
+
+static int
+dt_strtab_copyin(dt_strtab_t *sp, const char *str, size_t len)
+{
+ char *old_p = sp->str_ptr;
+ ulong_t old_n = sp->str_nbufs;
+
+ ulong_t b = sp->str_nbufs - 1;
+ size_t resid, n;
+
+ while (len != 0) {
+ if (sp->str_ptr == sp->str_bufs[b] + sp->str_bufsz) {
+ if (dt_strtab_grow(sp) == -1)
+ goto err;
+ b++;
+ }
+
+ resid = sp->str_bufs[b] + sp->str_bufsz - sp->str_ptr;
+ n = MIN(resid, len);
+ bcopy(str, sp->str_ptr, n);
+
+ sp->str_ptr += n;
+ str += n;
+ len -= n;
+ }
+
+ return (0);
+
+err:
+ while (sp->str_nbufs != old_n)
+ free(sp->str_bufs[--sp->str_nbufs]);
+
+ sp->str_ptr = old_p;
+ return (-1);
+}
+
+ssize_t
+dt_strtab_index(dt_strtab_t *sp, const char *str)
+{
+ dt_strhash_t *hp;
+ size_t len;
+ ulong_t h;
+
+ if (str == NULL || str[0] == '\0')
+ return (0); /* we keep a \0 at offset 0 to simplify things */
+
+ h = dt_strtab_hash(str, &len) % sp->str_hashsz;
+
+ for (hp = sp->str_hash[h]; hp != NULL; hp = hp->str_next) {
+ if (dt_strtab_compare(sp, hp, str, len + 1) == 0)
+ return (hp->str_off);
+ }
+
+ return (-1);
+}
+
+ssize_t
+dt_strtab_insert(dt_strtab_t *sp, const char *str)
+{
+ dt_strhash_t *hp;
+ size_t len;
+ ssize_t off;
+ ulong_t h;
+
+ if ((off = dt_strtab_index(sp, str)) != -1)
+ return (off);
+
+ h = dt_strtab_hash(str, &len) % sp->str_hashsz;
+
+ /*
+ * Create a new hash bucket, initialize it, and insert it at the front
+ * of the hash chain for the appropriate bucket.
+ */
+ if ((hp = malloc(sizeof (dt_strhash_t))) == NULL)
+ return (-1L);
+
+ hp->str_data = sp->str_ptr;
+ hp->str_buf = sp->str_nbufs - 1;
+ hp->str_off = sp->str_size;
+ hp->str_len = len;
+ hp->str_next = sp->str_hash[h];
+
+ /*
+ * Now copy the string data into our buffer list, and then update
+ * the global counts of strings and bytes. Return str's byte offset.
+ */
+ if (dt_strtab_copyin(sp, str, len + 1) == -1)
+ return (-1L);
+
+ sp->str_nstrs++;
+ sp->str_size += len + 1;
+ sp->str_hash[h] = hp;
+
+ return (hp->str_off);
+}
+
+size_t
+dt_strtab_size(const dt_strtab_t *sp)
+{
+ return (sp->str_size);
+}
+
+ssize_t
+dt_strtab_write(const dt_strtab_t *sp, dt_strtab_write_f *func, void *private)
+{
+ ssize_t res, total = 0;
+ ulong_t i;
+ size_t n;
+
+ for (i = 0; i < sp->str_nbufs; i++, total += res) {
+ if (i == sp->str_nbufs - 1)
+ n = sp->str_ptr - sp->str_bufs[i];
+ else
+ n = sp->str_bufsz;
+
+ if ((res = func(sp->str_bufs[i], n, total, private)) <= 0)
+ break;
+ }
+
+ if (total == 0 && sp->str_size != 0)
+ return (-1);
+
+ return (total);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.h
new file mode 100644
index 00000000..e70da982
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_strtab.h
@@ -0,0 +1,76 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_STRTAB_H
+#define _DT_STRTAB_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#else
+# include "VBoxDTraceTypes.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dt_strhash {
+ const char *str_data; /* pointer to actual string data */
+ ulong_t str_buf; /* index of string data buffer */
+ size_t str_off; /* offset in bytes of this string */
+ size_t str_len; /* length in bytes of this string */
+ struct dt_strhash *str_next; /* next string in hash chain */
+} dt_strhash_t;
+
+typedef struct dt_strtab {
+ dt_strhash_t **str_hash; /* array of hash buckets */
+ ulong_t str_hashsz; /* size of hash bucket array */
+ char **str_bufs; /* array of buffer pointers */
+ char *str_ptr; /* pointer to current buffer location */
+ ulong_t str_nbufs; /* size of buffer pointer array */
+ size_t str_bufsz; /* size of individual buffer */
+ ulong_t str_nstrs; /* total number of strings in strtab */
+ size_t str_size; /* total size of strings in bytes */
+} dt_strtab_t;
+
+typedef ssize_t dt_strtab_write_f(const char *, size_t, size_t, void *);
+
+extern dt_strtab_t *dt_strtab_create(size_t);
+extern void dt_strtab_destroy(dt_strtab_t *);
+extern ssize_t dt_strtab_index(dt_strtab_t *, const char *);
+extern ssize_t dt_strtab_insert(dt_strtab_t *, const char *);
+extern size_t dt_strtab_size(const dt_strtab_t *);
+extern ssize_t dt_strtab_write(const dt_strtab_t *,
+ dt_strtab_write_f *, void *);
+extern ulong_t dt_strtab_hash(const char *, size_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_STRTAB_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_subr.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_subr.c
new file mode 100644
index 00000000..830b9f8f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_subr.c
@@ -0,0 +1,1028 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef VBOX
+#include <sys/sysmacros.h>
+
+#include <strings.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ctype.h>
+#include <alloca.h>
+#include <assert.h>
+#include <libgen.h>
+#include <limits.h>
+#else /* VBOX */
+# include <ctype.h>
+# include <iprt/mp.h>
+# ifdef _MSC_VER
+# include <io.h>
+# else
+# include <unistd.h>
+# endif
+# include <VBox/sup.h>
+# include <VBox/err.h>
+#endif /* VBOX */
+
+#include <dt_impl.h>
+
+static const struct {
+ size_t dtps_offset;
+ size_t dtps_len;
+} dtrace_probespecs[] = {
+ { offsetof(dtrace_probedesc_t, dtpd_provider), DTRACE_PROVNAMELEN },
+ { offsetof(dtrace_probedesc_t, dtpd_mod), DTRACE_MODNAMELEN },
+ { offsetof(dtrace_probedesc_t, dtpd_func), DTRACE_FUNCNAMELEN },
+ { offsetof(dtrace_probedesc_t, dtpd_name), DTRACE_NAMELEN }
+};
+
+int
+dtrace_xstr2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec,
+ const char *s, int argc, char *const argv[], dtrace_probedesc_t *pdp)
+{
+ size_t off, len, vlen, wlen;
+ const char *p, *q, *v, *w;
+
+ char buf[32]; /* for id_t as %d (see below) */
+
+ if (spec < DTRACE_PROBESPEC_NONE || spec > DTRACE_PROBESPEC_NAME)
+ return (dt_set_errno(dtp, EINVAL));
+
+ bzero(pdp, sizeof (dtrace_probedesc_t));
+ p = s + strlen(s) - 1;
+
+ do {
+ for (len = 0; p >= s && *p != ':'; len++)
+ p--; /* move backward until we find a delimiter */
+
+ q = p + 1;
+ vlen = 0;
+ w = NULL;
+ wlen = 0;
+
+ if ((v = strchr(q, '$')) != NULL && v < q + len) {
+ /*
+ * Set vlen to the length of the variable name and then
+ * reset len to the length of the text prior to '$'. If
+ * the name begins with a digit, interpret it using the
+ * the argv[] array. Otherwise we look in dt_macros.
+ * For the moment, all dt_macros variables are of type
+ * id_t (see dtrace_update() for more details on that).
+ */
+ vlen = (size_t)(q + len - v);
+ len = (size_t)(v - q);
+
+ /*
+ * If the variable string begins with $$, skip past the
+ * leading dollar sign since $ and $$ are equivalent
+ * macro reference operators in a probe description.
+ */
+ if (vlen > 2 && v[1] == '$') {
+ vlen--;
+ v++;
+ }
+
+ if (isdigit(v[1])) {
+ long i;
+
+ errno = 0;
+ i = strtol(v + 1, (char **)&w, 10);
+
+ wlen = vlen - (w - v);
+
+ if (i < 0 || i >= argc || errno != 0)
+ return (dt_set_errno(dtp, EDT_BADSPCV));
+
+ v = argv[i];
+ vlen = strlen(v);
+
+ if (yypcb != NULL && yypcb->pcb_sargv == argv)
+ yypcb->pcb_sflagv[i] |= DT_IDFLG_REF;
+
+ } else if (vlen > 1) {
+ char *vstr = alloca(vlen);
+ dt_ident_t *idp;
+
+ (void) strncpy(vstr, v + 1, vlen - 1);
+ vstr[vlen - 1] = '\0';
+ idp = dt_idhash_lookup(dtp->dt_macros, vstr);
+
+ if (idp == NULL)
+ return (dt_set_errno(dtp, EDT_BADSPCV));
+
+ v = buf;
+ vlen = snprintf(buf, 32, "%d", idp->di_id);
+
+ } else
+ return (dt_set_errno(dtp, EDT_BADSPCV));
+ }
+
+ if (spec == DTRACE_PROBESPEC_NONE)
+ return (dt_set_errno(dtp, EDT_BADSPEC));
+
+ if (len + vlen >= dtrace_probespecs[spec].dtps_len)
+ return (dt_set_errno(dtp, ENAMETOOLONG));
+
+ off = dtrace_probespecs[spec--].dtps_offset;
+ bcopy(q, (char *)pdp + off, len);
+ bcopy(v, (char *)pdp + off + len, vlen);
+ bcopy(w, (char *)pdp + off + len + vlen, wlen);
+ } while (--p >= s);
+
+ pdp->dtpd_id = DTRACE_IDNONE;
+ return (0);
+}
+
+int
+dtrace_str2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec,
+ const char *s, dtrace_probedesc_t *pdp)
+{
+ return (dtrace_xstr2desc(dtp, spec, s, 0, NULL, pdp));
+}
+
+int
+dtrace_id2desc(dtrace_hdl_t *dtp, dtrace_id_t id, dtrace_probedesc_t *pdp)
+{
+ bzero(pdp, sizeof (dtrace_probedesc_t));
+ pdp->dtpd_id = id;
+
+ if (dt_ioctl(dtp, DTRACEIOC_PROBES, pdp) == -1 ||
+ pdp->dtpd_id != id)
+ return (dt_set_errno(dtp, EDT_BADID));
+
+ return (0);
+}
+
+char *
+dtrace_desc2str(const dtrace_probedesc_t *pdp, char *buf, size_t len)
+{
+ if (pdp->dtpd_id == 0) {
+ (void) snprintf(buf, len, "%s:%s:%s:%s", pdp->dtpd_provider,
+ pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name);
+ } else
+ (void) snprintf(buf, len, "%u", pdp->dtpd_id);
+
+ return (buf);
+}
+
+char *
+dtrace_attr2str(dtrace_attribute_t attr, char *buf, size_t len)
+{
+ const char *name = dtrace_stability_name(attr.dtat_name);
+ const char *data = dtrace_stability_name(attr.dtat_data);
+ const char *class = dtrace_class_name(attr.dtat_class);
+
+ if (name == NULL || data == NULL || class == NULL)
+ return (NULL); /* one or more invalid attributes */
+
+ (void) snprintf(buf, len, "%s/%s/%s", name, data, class);
+ return (buf);
+}
+
+static char *
+dt_getstrattr(char *p, char **qp)
+{
+ char *q;
+
+ if (*p == '\0')
+ return (NULL);
+
+ if ((q = strchr(p, '/')) == NULL)
+ q = p + strlen(p);
+ else
+ *q++ = '\0';
+
+ *qp = q;
+ return (p);
+}
+
+int
+dtrace_str2attr(const char *str, dtrace_attribute_t *attr)
+{
+ dtrace_stability_t s;
+ dtrace_class_t c;
+ char *p, *q;
+
+ if (str == NULL || attr == NULL)
+ return (-1); /* invalid function arguments */
+
+ *attr = _dtrace_maxattr;
+#ifndef VBOX
+ p = strdupa(str);
+#else
+ MY_STRDUPA(p, str);
+#endif
+
+ if ((p = dt_getstrattr(p, &q)) == NULL)
+ return (0);
+
+ for (s = 0; s <= DTRACE_STABILITY_MAX; s++) {
+ if (strcasecmp(p, dtrace_stability_name(s)) == 0) {
+ attr->dtat_name = s;
+ break;
+ }
+ }
+
+ if (s > DTRACE_STABILITY_MAX)
+ return (-1);
+
+ if ((p = dt_getstrattr(q, &q)) == NULL)
+ return (0);
+
+ for (s = 0; s <= DTRACE_STABILITY_MAX; s++) {
+ if (strcasecmp(p, dtrace_stability_name(s)) == 0) {
+ attr->dtat_data = s;
+ break;
+ }
+ }
+
+ if (s > DTRACE_STABILITY_MAX)
+ return (-1);
+
+ if ((p = dt_getstrattr(q, &q)) == NULL)
+ return (0);
+
+ for (c = 0; c <= DTRACE_CLASS_MAX; c++) {
+ if (strcasecmp(p, dtrace_class_name(c)) == 0) {
+ attr->dtat_class = c;
+ break;
+ }
+ }
+
+ if (c > DTRACE_CLASS_MAX || (p = dt_getstrattr(q, &q)) != NULL)
+ return (-1);
+
+ return (0);
+}
+
+const char *
+dtrace_stability_name(dtrace_stability_t s)
+{
+ switch (s) {
+ case DTRACE_STABILITY_INTERNAL: return ("Internal");
+ case DTRACE_STABILITY_PRIVATE: return ("Private");
+ case DTRACE_STABILITY_OBSOLETE: return ("Obsolete");
+ case DTRACE_STABILITY_EXTERNAL: return ("External");
+ case DTRACE_STABILITY_UNSTABLE: return ("Unstable");
+ case DTRACE_STABILITY_EVOLVING: return ("Evolving");
+ case DTRACE_STABILITY_STABLE: return ("Stable");
+ case DTRACE_STABILITY_STANDARD: return ("Standard");
+ default: return (NULL);
+ }
+}
+
+const char *
+dtrace_class_name(dtrace_class_t c)
+{
+ switch (c) {
+ case DTRACE_CLASS_UNKNOWN: return ("Unknown");
+ case DTRACE_CLASS_CPU: return ("CPU");
+ case DTRACE_CLASS_PLATFORM: return ("Platform");
+ case DTRACE_CLASS_GROUP: return ("Group");
+ case DTRACE_CLASS_ISA: return ("ISA");
+ case DTRACE_CLASS_COMMON: return ("Common");
+ default: return (NULL);
+ }
+}
+
+dtrace_attribute_t
+dt_attr_min(dtrace_attribute_t a1, dtrace_attribute_t a2)
+{
+ dtrace_attribute_t am;
+
+ am.dtat_name = MIN(a1.dtat_name, a2.dtat_name);
+ am.dtat_data = MIN(a1.dtat_data, a2.dtat_data);
+ am.dtat_class = MIN(a1.dtat_class, a2.dtat_class);
+
+ return (am);
+}
+
+dtrace_attribute_t
+dt_attr_max(dtrace_attribute_t a1, dtrace_attribute_t a2)
+{
+ dtrace_attribute_t am;
+
+ am.dtat_name = MAX(a1.dtat_name, a2.dtat_name);
+ am.dtat_data = MAX(a1.dtat_data, a2.dtat_data);
+ am.dtat_class = MAX(a1.dtat_class, a2.dtat_class);
+
+ return (am);
+}
+
+/*
+ * Compare two attributes and return an integer value in the following ranges:
+ *
+ * <0 if any of a1's attributes are less than a2's attributes
+ * =0 if all of a1's attributes are equal to a2's attributes
+ * >0 if all of a1's attributes are greater than or equal to a2's attributes
+ *
+ * To implement this function efficiently, we subtract a2's attributes from
+ * a1's to obtain a negative result if an a1 attribute is less than its a2
+ * counterpart. We then OR the intermediate results together, relying on the
+ * twos-complement property that if any result is negative, the bitwise union
+ * will also be negative since the highest bit will be set in the result.
+ */
+int
+dt_attr_cmp(dtrace_attribute_t a1, dtrace_attribute_t a2)
+{
+ return (((int)a1.dtat_name - a2.dtat_name) |
+ ((int)a1.dtat_data - a2.dtat_data) |
+ ((int)a1.dtat_class - a2.dtat_class));
+}
+
+char *
+dt_attr_str(dtrace_attribute_t a, char *buf, size_t len)
+{
+ static const char stability[] = "ipoxuesS";
+ static const char class[] = "uCpgIc";
+
+ if (a.dtat_name < sizeof (stability) &&
+ a.dtat_data < sizeof (stability) && a.dtat_class < sizeof (class)) {
+ (void) snprintf(buf, len, "[%c/%c/%c]", stability[a.dtat_name],
+ stability[a.dtat_data], class[a.dtat_class]);
+ } else {
+ (void) snprintf(buf, len, "[%u/%u/%u]",
+ a.dtat_name, a.dtat_data, a.dtat_class);
+ }
+
+ return (buf);
+}
+
+char *
+dt_version_num2str(dt_version_t v, char *buf, size_t len)
+{
+ uint_t M = DT_VERSION_MAJOR(v);
+ uint_t m = DT_VERSION_MINOR(v);
+ uint_t u = DT_VERSION_MICRO(v);
+
+ if (u == 0)
+ (void) snprintf(buf, len, "%u.%u", M, m);
+ else
+ (void) snprintf(buf, len, "%u.%u.%u", M, m, u);
+
+ return (buf);
+}
+
+int
+dt_version_str2num(const char *s, dt_version_t *vp)
+{
+ int i = 0, n[3] = { 0, 0, 0 };
+ char c;
+
+ while ((c = *s++) != '\0') {
+ if (isdigit(c))
+ n[i] = n[i] * 10 + c - '0';
+ else if (c != '.' || i++ >= sizeof (n) / sizeof (n[0]) - 1)
+ return (-1);
+ }
+
+ if (n[0] > DT_VERSION_MAJMAX ||
+ n[1] > DT_VERSION_MINMAX ||
+ n[2] > DT_VERSION_MICMAX)
+ return (-1);
+
+ if (vp != NULL)
+ *vp = DT_VERSION_NUMBER(n[0], n[1], n[2]);
+
+ return (0);
+}
+
+int
+dt_version_defined(dt_version_t v)
+{
+ int i;
+
+ for (i = 0; _dtrace_versions[i] != 0; i++) {
+ if (_dtrace_versions[i] == v)
+ return (1);
+ }
+
+ return (0);
+}
+
+char *
+dt_cpp_add_arg(dtrace_hdl_t *dtp, const char *str)
+{
+ char *arg;
+
+ if (dtp->dt_cpp_argc == dtp->dt_cpp_args) {
+ int olds = dtp->dt_cpp_args;
+ int news = olds * 2;
+ char **argv = realloc(dtp->dt_cpp_argv, sizeof (char *) * news);
+
+ if (argv == NULL)
+ return (NULL);
+
+ bzero(&argv[olds], sizeof (char *) * olds);
+ dtp->dt_cpp_argv = argv;
+ dtp->dt_cpp_args = news;
+ }
+
+ if ((arg = strdup(str)) == NULL)
+ return (NULL);
+
+ assert(dtp->dt_cpp_argc < dtp->dt_cpp_args);
+ dtp->dt_cpp_argv[dtp->dt_cpp_argc++] = arg;
+ return (arg);
+}
+
+char *
+dt_cpp_pop_arg(dtrace_hdl_t *dtp)
+{
+ char *arg;
+
+ if (dtp->dt_cpp_argc <= 1)
+ return (NULL); /* dt_cpp_argv[0] cannot be popped */
+
+ arg = dtp->dt_cpp_argv[--dtp->dt_cpp_argc];
+ dtp->dt_cpp_argv[dtp->dt_cpp_argc] = NULL;
+
+ return (arg);
+}
+
+/*PRINTFLIKE1*/
+void
+dt_dprintf(const char *format, ...)
+{
+ if (_dtrace_debug) {
+ va_list alist;
+
+ va_start(alist, format);
+ (void) fputs("libdtrace DEBUG: ", stderr);
+ (void) vfprintf(stderr, format, alist);
+ va_end(alist);
+ }
+}
+
+int
+dt_ioctl(dtrace_hdl_t *dtp, int val, void *arg)
+{
+ const dtrace_vector_t *v = dtp->dt_vector;
+#ifdef VBOX
+ int rc;
+ int32_t iRetVal = 0;
+#endif
+
+ if (v != NULL)
+ return (v->dtv_ioctl(dtp->dt_varg, val, arg));
+
+#ifndef VBOX
+ if (dtp->dt_fd >= 0)
+ return (ioctl(dtp->dt_fd, val, arg));
+
+ errno = EBADF;
+ return (-1);
+#else
+# if 1
+ rc = SUPR3TracerIoCtl(val, (uintptr_t)arg, &iRetVal);
+ if (RT_FAILURE(rc)) {
+ switch (rc) {
+ case VERR_SUPDRV_TRACER_NOT_OPENED: errno = EBADF; break;
+ default:
+ errno = RTErrConvertToErrno(rc);
+ }
+ return (-1);
+ }
+ return iRetVal;
+# else
+ /* Fake ioctl */
+ switch (val) {
+ case DTRACEIOC_CONF: {
+ dtrace_conf_t *pConf = (dtrace_conf_t *)arg;
+ RT_ZERO(*pConf);
+ pConf->dtc_difversion = DIF_VERSION;
+ pConf->dtc_difintregs = DIF_DIR_NREGS;
+ pConf->dtc_diftupregs = DIF_DTR_NREGS;
+ pConf->dtc_ctfmodel = CTF_MODEL_NATIVE;
+ return 0;
+ }
+
+ case DTRACEIOC_PROVIDER: {
+ dtrace_providerdesc_t *pDesc = (dtrace_providerdesc_t *)arg;
+ if (strcmp(pDesc->dtvd_name, "dtrace") == 0) {
+ RT_ZERO(pDesc->dtvd_attr);
+ RT_ZERO(pDesc->dtvd_priv);
+ return 0;
+ }
+ errno = ESRCH;
+ return -1;
+ }
+
+ case DTRACEIOC_PROBES: {
+ /*dtrace_probedesc_t *pDesc = (dtrace_probedesc_t *)arg;*/
+ errno = ESRCH;
+ return -1;
+ }
+
+ case DTRACEIOC_PROBEMATCH: {
+ dtrace_probedesc_t *pDesc = (dtrace_probedesc_t *)arg;
+ if (strcmp(pDesc->dtpd_name, "BEGIN") == 0) {
+ pDesc->dtpd_id = 1;
+ return 0;
+ }
+ errno = ESRCH;
+ return -1;
+ }
+
+ }
+
+ errno = EBADF;
+ return (-1);
+# endif
+#endif
+}
+
+int
+dt_status(dtrace_hdl_t *dtp, processorid_t cpu)
+{
+ const dtrace_vector_t *v = dtp->dt_vector;
+
+ if (v == NULL)
+#ifndef VBOX
+ return (p_online(cpu, P_STATUS));
+#else
+ return RTMpIsCpuOnline(cpu) ? 1
+ : RTMpIsCpuPresent(cpu) ? 0 : -1; /* Only -1 is checked. */
+#endif
+
+ return (v->dtv_status(dtp->dt_varg, cpu));
+}
+
+#ifndef VBOX
+long
+dt_sysconf(dtrace_hdl_t *dtp, int name)
+{
+ const dtrace_vector_t *v = dtp->dt_vector;
+
+ if (v == NULL)
+ return (sysconf(name));
+
+ return (v->dtv_sysconf(dtp->dt_varg, name));
+}
+#endif /* !VBOX */
+
+/*
+ * Wrapper around write(2) to handle partial writes. For maximum safety of
+ * output files and proper error reporting, we continuing writing in the
+ * face of partial writes until write(2) fails or 'buf' is completely written.
+ * We also record any errno in the specified dtrace_hdl_t as well as 'errno'.
+ */
+ssize_t
+dt_write(dtrace_hdl_t *dtp, int fd, const void *buf, size_t n)
+{
+ ssize_t resid = n;
+ ssize_t len;
+
+ while (resid != 0) {
+ if ((len = write(fd, buf, resid)) <= 0)
+ break;
+
+ resid -= len;
+ buf = (char *)buf + len;
+ }
+
+ if ((size_t)resid == n && n != 0)
+ return (dt_set_errno(dtp, errno));
+
+ return (n - resid);
+}
+
+/*
+ * This function handles all output from libdtrace, as well as the
+ * dtrace_sprintf() case. If we're here due to dtrace_sprintf(), then
+ * dt_sprintf_buflen will be non-zero; in this case, we sprintf into the
+ * specified buffer and return. Otherwise, if output is buffered (denoted by
+ * a NULL fp), we sprintf the desired output into the buffered buffer
+ * (expanding the buffer if required). If we don't satisfy either of these
+ * conditions (that is, if we are to actually generate output), then we call
+ * fprintf with the specified fp. In this case, we need to deal with one of
+ * the more annoying peculiarities of libc's printf routines: any failed
+ * write persistently sets an error flag inside the FILE causing every
+ * subsequent write to fail, but only the caller that initiated the error gets
+ * the errno. Since libdtrace clients often intercept SIGINT, this case is
+ * particularly frustrating since we don't want the EINTR on one attempt to
+ * write to the output file to preclude later attempts to write. This
+ * function therefore does a clearerr() if any error occurred, and saves the
+ * errno for the caller inside the specified dtrace_hdl_t.
+ */
+/*PRINTFLIKE3*/
+int
+dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
+{
+ va_list ap;
+ int n;
+
+ va_start(ap, format);
+
+ if (dtp->dt_sprintf_buflen != 0) {
+ int len;
+ char *buf;
+
+ assert(dtp->dt_sprintf_buf != NULL);
+
+ buf = &dtp->dt_sprintf_buf[len = VBDTCAST(int)strlen(dtp->dt_sprintf_buf)];
+ len = dtp->dt_sprintf_buflen - len;
+ assert(len >= 0);
+
+ if ((n = vsnprintf(buf, len, format, ap)) < 0)
+ n = dt_set_errno(dtp, errno);
+
+ va_end(ap);
+
+ return (n);
+ }
+
+ if (fp == NULL) {
+ int needed, rval;
+ size_t avail;
+
+ /*
+ * It's not legal to use buffered ouput if there is not a
+ * handler for buffered output.
+ */
+ if (dtp->dt_bufhdlr == NULL) {
+ va_end(ap);
+ return (dt_set_errno(dtp, EDT_NOBUFFERED));
+ }
+
+ if (dtp->dt_buffered_buf == NULL) {
+ assert(dtp->dt_buffered_size == 0);
+ dtp->dt_buffered_size = 1;
+ dtp->dt_buffered_buf = malloc(dtp->dt_buffered_size);
+
+ if (dtp->dt_buffered_buf == NULL) {
+ va_end(ap);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ dtp->dt_buffered_offs = 0;
+ dtp->dt_buffered_buf[0] = '\0';
+ }
+
+ if ((needed = vsnprintf(NULL, 0, format, ap)) < 0) {
+ rval = dt_set_errno(dtp, errno);
+ va_end(ap);
+ return (rval);
+ }
+
+ if (needed == 0) {
+ va_end(ap);
+ return (0);
+ }
+
+ for (;;) {
+ char *newbuf;
+
+ assert(dtp->dt_buffered_offs < dtp->dt_buffered_size);
+ avail = dtp->dt_buffered_size - dtp->dt_buffered_offs;
+
+ if ((size_t/*vbox*/)needed + 1 < avail)
+ break;
+
+ if ((newbuf = realloc(dtp->dt_buffered_buf,
+ dtp->dt_buffered_size << 1)) == NULL) {
+ va_end(ap);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ dtp->dt_buffered_buf = newbuf;
+ dtp->dt_buffered_size <<= 1;
+ }
+
+ if (vsnprintf(&dtp->dt_buffered_buf[dtp->dt_buffered_offs],
+ avail, format, ap) < 0) {
+ rval = dt_set_errno(dtp, errno);
+ va_end(ap);
+ return (rval);
+ }
+
+ dtp->dt_buffered_offs += needed;
+ assert(dtp->dt_buffered_buf[dtp->dt_buffered_offs] == '\0');
+ return (0);
+ }
+
+ n = vfprintf(fp, format, ap);
+ va_end(ap);
+
+ if (n < 0) {
+ clearerr(fp);
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (n);
+}
+
+int
+dt_buffered_flush(dtrace_hdl_t *dtp, dtrace_probedata_t *pdata,
+ const dtrace_recdesc_t *rec, const dtrace_aggdata_t *agg, uint32_t flags)
+{
+ dtrace_bufdata_t data;
+
+ if (dtp->dt_buffered_offs == 0)
+ return (0);
+
+ data.dtbda_handle = dtp;
+ data.dtbda_buffered = dtp->dt_buffered_buf;
+ data.dtbda_probe = pdata;
+ data.dtbda_recdesc = rec;
+ data.dtbda_aggdata = agg;
+ data.dtbda_flags = flags;
+
+ if ((*dtp->dt_bufhdlr)(&data, dtp->dt_bufarg) == DTRACE_HANDLE_ABORT)
+ return (dt_set_errno(dtp, EDT_DIRABORT));
+
+ dtp->dt_buffered_offs = 0;
+ dtp->dt_buffered_buf[0] = '\0';
+
+ return (0);
+}
+
+void
+dt_buffered_destroy(dtrace_hdl_t *dtp)
+{
+ free(dtp->dt_buffered_buf);
+ dtp->dt_buffered_buf = NULL;
+ dtp->dt_buffered_offs = 0;
+ dtp->dt_buffered_size = 0;
+}
+
+void *
+dt_zalloc(dtrace_hdl_t *dtp, size_t size)
+{
+ void *data;
+
+ if ((data = malloc(size)) == NULL)
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+ else
+ bzero(data, size);
+
+ return (data);
+}
+
+void *
+dt_alloc(dtrace_hdl_t *dtp, size_t size)
+{
+ void *data;
+
+ if ((data = malloc(size)) == NULL)
+ (void) dt_set_errno(dtp, EDT_NOMEM);
+
+ return (data);
+}
+
+void
+dt_free(dtrace_hdl_t *dtp, void *data)
+{
+ RT_NOREF1(dtp);
+ assert(dtp != NULL); /* ensure sane use of this interface */
+ free(data);
+}
+
+void
+dt_difo_free(dtrace_hdl_t *dtp, dtrace_difo_t *dp)
+{
+ if (dp == NULL)
+ return; /* simplify caller code */
+
+ dt_free(dtp, dp->dtdo_buf);
+ dt_free(dtp, dp->dtdo_inttab);
+ dt_free(dtp, dp->dtdo_strtab);
+ dt_free(dtp, dp->dtdo_vartab);
+ dt_free(dtp, dp->dtdo_kreltab);
+ dt_free(dtp, dp->dtdo_ureltab);
+ dt_free(dtp, dp->dtdo_xlmtab);
+
+ dt_free(dtp, dp);
+}
+
+/*
+ * dt_gmatch() is similar to gmatch(3GEN) and dtrace(7D) globbing, but also
+ * implements the behavior that an empty pattern matches any string.
+ */
+int
+dt_gmatch(const char *s, const char *p)
+{
+#ifndef VBOX
+ return (p == NULL || *p == '\0' || gmatch(s, p));
+#else
+ return (p == NULL || *p == '\0' || RTStrSimplePatternMatch(p, s)); /** @todo implement gmatch. */
+#endif
+}
+
+char *
+dt_basename(char *str)
+{
+ char *last = strrchr(str, '/');
+
+ if (last == NULL)
+ return (str);
+
+ return (last + 1);
+}
+
+/*
+ * dt_popc() is a fast implementation of population count. The algorithm is
+ * from "Hacker's Delight" by Henry Warren, Jr with a 64-bit equivalent added.
+ */
+ulong_t
+dt_popc(ulong_t x)
+{
+#ifdef VBOX
+# if ARCH_BITS == 32
+ x = x - ((x >> 1) & UINT32_C(0x55555555));
+ x = (x & UINT32_C(0x33333333)) + ((x >> 2) & UINT32_C(0x33333333));
+ x = (x + (x >> 4)) & UINT32_C(0x0F0F0F0F);
+ x = x + (x >> 8);
+ x = x + (x >> 16);
+ return (x & 0x3F);
+# elif ARCH_BITS == 64
+ x = x - ((x >> 1) & UINT64_C(0x5555555555555555));
+ x = (x & UINT64_C(0x3333333333333333)) + ((x >> 2) & UINT64_C(0x3333333333333333));
+ x = (x + (x >> 4)) & UINT64_C(0x0F0F0F0F0F0F0F0F);
+ x = x + (x >> 8);
+ x = x + (x >> 16);
+ x = x + (x >> 32);
+ return (x & 0x7F);
+# else
+# error "ARCH_BITS"
+# endif
+#else /* !VBOX */
+#ifdef _ILP32
+ x = x - ((x >> 1) & 0x55555555UL);
+ x = (x & 0x33333333UL) + ((x >> 2) & 0x33333333UL);
+ x = (x + (x >> 4)) & 0x0F0F0F0FUL;
+ x = x + (x >> 8);
+ x = x + (x >> 16);
+ return (x & 0x3F);
+#endif
+#ifdef _LP64
+ x = x - ((x >> 1) & 0x5555555555555555ULL);
+ x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
+ x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
+ x = x + (x >> 8);
+ x = x + (x >> 16);
+ x = x + (x >> 32);
+ return (x & 0x7F);
+#endif
+#endif /* !VBOX */
+}
+
+/*
+ * dt_popcb() is a bitmap-based version of population count that returns the
+ * number of one bits in the specified bitmap 'bp' at bit positions below 'n'.
+ */
+ulong_t
+dt_popcb(const ulong_t *bp, ulong_t n)
+{
+ ulong_t maxb = n & BT_ULMASK;
+ ulong_t maxw = n >> BT_ULSHIFT;
+ ulong_t w, popc = 0;
+
+ if (n == 0)
+ return (0);
+
+ for (w = 0; w < maxw; w++)
+ popc += dt_popc(bp[w]);
+
+ return (popc + dt_popc(bp[maxw] & ((1UL << maxb) - 1)));
+}
+
+static int
+dt_string2str(char *s, char *str, int nbytes)
+{
+ int len = VBDTCAST(int)strlen(s);
+
+ if (nbytes == 0) {
+ /*
+ * Like snprintf(3C), we don't check the value of str if the
+ * number of bytes is 0.
+ */
+ return (len);
+ }
+
+ if (nbytes <= len) {
+ (void) strncpy(str, s, nbytes - 1);
+ /*
+ * Like snprintf(3C) (and unlike strncpy(3C)), we guarantee
+ * that the string is null-terminated.
+ */
+ str[nbytes - 1] = '\0';
+ } else {
+ (void) strcpy(str, s);
+ }
+
+ return (len);
+}
+
+int
+dtrace_addr2str(dtrace_hdl_t *dtp, uint64_t addr, char *str, int nbytes)
+{
+ dtrace_syminfo_t dts;
+ GElf_Sym sym;
+
+ size_t n = 20; /* for 0x%llx\0 */
+ char *s;
+ int err;
+
+ if ((err = dtrace_lookup_by_addr(dtp, addr, &sym, &dts)) == 0)
+ n += strlen(dts.dts_object) + strlen(dts.dts_name) + 2; /* +` */
+
+ s = alloca(n);
+
+ if (err == 0 && addr != sym.st_value) {
+ (void) snprintf(s, n, "%s`%s+0x%llx", dts.dts_object,
+ dts.dts_name, (u_longlong_t)addr - sym.st_value);
+ } else if (err == 0) {
+ (void) snprintf(s, n, "%s`%s",
+ dts.dts_object, dts.dts_name);
+ } else {
+ /*
+ * We'll repeat the lookup, but this time we'll specify a NULL
+ * GElf_Sym -- indicating that we're only interested in the
+ * containing module.
+ */
+ if (dtrace_lookup_by_addr(dtp, addr, NULL, &dts) == 0) {
+ (void) snprintf(s, n, "%s`0x%llx", dts.dts_object,
+ (u_longlong_t)addr);
+ } else {
+ (void) snprintf(s, n, "0x%llx", (u_longlong_t)addr);
+ }
+ }
+
+ return (dt_string2str(s, str, nbytes));
+}
+
+int
+dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid,
+ uint64_t addr, char *str, int nbytes)
+{
+#ifndef VBOX
+ char name[PATH_MAX], objname[PATH_MAX], c[PATH_MAX * 2];
+ struct ps_prochandle *P = NULL;
+ GElf_Sym sym;
+ char *obj;
+
+ if (pid != 0)
+ P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0);
+
+ if (P == NULL) {
+ (void) snprintf(c, sizeof (c), "0x%llx", addr);
+ return (dt_string2str(c, str, nbytes));
+ }
+
+ dt_proc_lock(dtp, P);
+
+ if (Plookup_by_addr(P, addr, name, sizeof (name), &sym) == 0) {
+ (void) Pobjname(P, addr, objname, sizeof (objname));
+
+ obj = dt_basename(objname);
+
+ if (addr > sym.st_value) {
+ (void) snprintf(c, sizeof (c), "%s`%s+0x%llx", obj,
+ name, (u_longlong_t)(addr - sym.st_value));
+ } else {
+ (void) snprintf(c, sizeof (c), "%s`%s", obj, name);
+ }
+ } else if (Pobjname(P, addr, objname, sizeof (objname)) != NULL) {
+ (void) snprintf(c, sizeof (c), "%s`0x%llx",
+ dt_basename(objname), addr);
+ } else {
+ (void) snprintf(c, sizeof (c), "0x%llx", addr);
+ }
+
+ dt_proc_unlock(dtp, P);
+ dt_proc_release(dtp, P);
+#else
+ char c[32];
+ RT_NOREF2(dtp, pid);
+ RTStrPrintf(c, sizeof (c), "0x%llx", addr);
+#endif
+
+ return (dt_string2str(c, str, nbytes));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_work.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_work.c
new file mode 100644
index 00000000..02a240a5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_work.c
@@ -0,0 +1,322 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <dt_impl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <assert.h>
+#include <time.h>
+#else /* VBOX */
+# include <dt_impl.h>
+/*# include <stddef.h>
+# include <time.h> */
+# include <iprt/semaphore.h>
+#endif /* VBOX */
+
+static const struct {
+ int dtslt_option;
+ size_t dtslt_offs;
+} _dtrace_sleeptab[] = {
+ { DTRACEOPT_STATUSRATE, offsetof(dtrace_hdl_t, dt_laststatus) },
+ { DTRACEOPT_AGGRATE, offsetof(dtrace_hdl_t, dt_lastagg) },
+ { DTRACEOPT_SWITCHRATE, offsetof(dtrace_hdl_t, dt_lastswitch) },
+ { DTRACEOPT_MAX, 0 }
+};
+
+void
+dtrace_sleep(dtrace_hdl_t *dtp)
+{
+ dt_proc_hash_t *dph = dtp->dt_procs;
+ dtrace_optval_t policy = dtp->dt_options[DTRACEOPT_BUFPOLICY];
+ dt_proc_notify_t *dprn;
+
+ hrtime_t earliest = INT64_MAX;
+#ifndef VBOX
+ struct timespec tv;
+#endif
+ hrtime_t now;
+ int i;
+
+ for (i = 0; _dtrace_sleeptab[i].dtslt_option < DTRACEOPT_MAX; i++) {
+ uintptr_t a = (uintptr_t)dtp + _dtrace_sleeptab[i].dtslt_offs;
+ int opt = _dtrace_sleeptab[i].dtslt_option;
+ dtrace_optval_t interval = dtp->dt_options[opt];
+
+ /*
+ * If the buffering policy is set to anything other than
+ * "switch", we ignore the aggrate and switchrate -- they're
+ * meaningless.
+ */
+ if (policy != DTRACEOPT_BUFPOLICY_SWITCH &&
+ _dtrace_sleeptab[i].dtslt_option != DTRACEOPT_STATUSRATE)
+ continue;
+
+ if (*((hrtime_t *)a) + interval < earliest)
+ earliest = *((hrtime_t *)a) + interval;
+ }
+
+#ifndef VBOX
+ (void) pthread_mutex_lock(&dph->dph_lock);
+#endif
+
+ now = gethrtime();
+
+ if (earliest < now) {
+#ifndef VBOX
+ (void) pthread_mutex_unlock(&dph->dph_lock);
+#endif
+ return; /* sleep duration has already past */
+ }
+
+#ifndef VBOX
+ tv.tv_sec = (earliest - now) / NANOSEC;
+ tv.tv_nsec = (earliest - now) % NANOSEC;
+#endif
+
+ /*
+ * Wait for either 'tv' nanoseconds to pass or to receive notification
+ * that a process is in an interesting state. Regardless of why we
+ * awaken, iterate over any pending notifications and process them.
+ */
+#ifndef VBOX
+ (void) pthread_cond_reltimedwait_np(&dph->dph_cv, &dph->dph_lock, &tv);
+#else
+ if (dph->dph_event)
+ RTSemEventWait(dph->dph_event, (earliest - now) / RT_NS_1MS);
+ else
+ RTThreadSleep((earliest - now) / RT_NS_1MS);
+#endif
+
+ while ((dprn = dph->dph_notify) != NULL) {
+ if (dtp->dt_prochdlr != NULL) {
+ char *err = dprn->dprn_errmsg;
+ if (*err == '\0')
+ err = NULL;
+
+ dtp->dt_prochdlr(dprn->dprn_dpr->dpr_proc, err,
+ dtp->dt_procarg);
+ }
+
+ dph->dph_notify = dprn->dprn_next;
+ dt_free(dtp, dprn);
+ }
+
+#ifndef VBOX
+ (void) pthread_mutex_unlock(&dph->dph_lock);
+#endif
+}
+
+int
+dtrace_status(dtrace_hdl_t *dtp)
+{
+ int gen = dtp->dt_statusgen;
+ dtrace_optval_t interval = dtp->dt_options[DTRACEOPT_STATUSRATE];
+ hrtime_t now = gethrtime();
+
+ if (!dtp->dt_active)
+ return (DTRACE_STATUS_NONE);
+
+ if (dtp->dt_stopped)
+ return (DTRACE_STATUS_STOPPED);
+
+ if (dtp->dt_laststatus != 0) {
+ if (now - dtp->dt_laststatus < VBDTCAST(hrtime_t)interval)
+ return (DTRACE_STATUS_NONE);
+
+ dtp->dt_laststatus += interval;
+ } else {
+ dtp->dt_laststatus = now;
+ }
+
+ if (dt_ioctl(dtp, DTRACEIOC_STATUS, &dtp->dt_status[gen]) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ dtp->dt_statusgen ^= 1;
+
+ if (dt_handle_status(dtp, &dtp->dt_status[dtp->dt_statusgen],
+ &dtp->dt_status[gen]) == -1)
+ return (-1);
+
+ if (dtp->dt_status[gen].dtst_exiting) {
+ if (!dtp->dt_stopped)
+ (void) dtrace_stop(dtp);
+
+ return (DTRACE_STATUS_EXITED);
+ }
+
+ if (dtp->dt_status[gen].dtst_filled == 0)
+ return (DTRACE_STATUS_OKAY);
+
+ if (dtp->dt_options[DTRACEOPT_BUFPOLICY] != DTRACEOPT_BUFPOLICY_FILL)
+ return (DTRACE_STATUS_OKAY);
+
+ if (!dtp->dt_stopped) {
+ if (dtrace_stop(dtp) == -1)
+ return (-1);
+ }
+
+ return (DTRACE_STATUS_FILLED);
+}
+
+int
+dtrace_go(dtrace_hdl_t *dtp)
+{
+ void *dof;
+ int err;
+
+ if (dtp->dt_active)
+ return (dt_set_errno(dtp, EINVAL));
+
+ /*
+ * If a dtrace:::ERROR program and callback are registered, enable the
+ * program before we start tracing. If this fails for a vector open
+ * with ENOTTY, we permit dtrace_go() to succeed so that vector clients
+ * such as mdb's dtrace module can execute the rest of dtrace_go() even
+ * though they do not provide support for the DTRACEIOC_ENABLE ioctl.
+ */
+ if (dtp->dt_errprog != NULL &&
+ dtrace_program_exec(dtp, dtp->dt_errprog, NULL) == -1 && (
+ dtp->dt_errno != ENOTTY || dtp->dt_vector == NULL))
+ return (-1); /* dt_errno has been set for us */
+
+ if ((dof = dtrace_getopt_dof(dtp)) == NULL)
+ return (-1); /* dt_errno has been set for us */
+
+ err = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof);
+ dtrace_dof_destroy(dtp, dof);
+
+ if (err == -1 && (errno != ENOTTY || dtp->dt_vector == NULL))
+ return (dt_set_errno(dtp, errno));
+
+ if (dt_ioctl(dtp, DTRACEIOC_GO, &dtp->dt_beganon) == -1) {
+ if (errno == EACCES)
+ return (dt_set_errno(dtp, EDT_DESTRUCTIVE));
+
+ if (errno == EALREADY)
+ return (dt_set_errno(dtp, EDT_ISANON));
+
+ if (errno == ENOENT)
+ return (dt_set_errno(dtp, EDT_NOANON));
+
+ if (errno == E2BIG)
+ return (dt_set_errno(dtp, EDT_ENDTOOBIG));
+
+ if (errno == ENOSPC)
+ return (dt_set_errno(dtp, EDT_BUFTOOSMALL));
+
+ return (dt_set_errno(dtp, errno));
+ }
+
+ dtp->dt_active = 1;
+
+ if (dt_options_load(dtp) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ return (dt_aggregate_go(dtp));
+}
+
+int
+dtrace_stop(dtrace_hdl_t *dtp)
+{
+ int gen = dtp->dt_statusgen;
+
+ if (dtp->dt_stopped)
+ return (0);
+
+ if (dt_ioctl(dtp, DTRACEIOC_STOP, &dtp->dt_endedon) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ dtp->dt_stopped = 1;
+
+ /*
+ * Now that we're stopped, we're going to get status one final time.
+ */
+ if (dt_ioctl(dtp, DTRACEIOC_STATUS, &dtp->dt_status[gen]) == -1)
+ return (dt_set_errno(dtp, errno));
+
+ if (dt_handle_status(dtp, &dtp->dt_status[gen ^ 1],
+ &dtp->dt_status[gen]) == -1)
+ return (-1);
+
+ return (0);
+}
+
+
+dtrace_workstatus_t
+dtrace_work(dtrace_hdl_t *dtp, FILE *fp,
+ dtrace_consume_probe_f *pfunc, dtrace_consume_rec_f *rfunc, void *arg)
+{
+ int status = dtrace_status(dtp);
+ dtrace_optval_t policy = dtp->dt_options[DTRACEOPT_BUFPOLICY];
+ dtrace_workstatus_t rval VBDTMSC(DTRACE_WORKSTATUS_ERROR);
+
+ switch (status) {
+ case DTRACE_STATUS_EXITED:
+ case DTRACE_STATUS_FILLED:
+ case DTRACE_STATUS_STOPPED:
+ /*
+ * Tracing is stopped. We now want to force dtrace_consume()
+ * and dtrace_aggregate_snap() to proceed, regardless of
+ * switchrate and aggrate. We do this by clearing the times.
+ */
+ dtp->dt_lastswitch = 0;
+ dtp->dt_lastagg = 0;
+ rval = DTRACE_WORKSTATUS_DONE;
+ break;
+
+ case DTRACE_STATUS_NONE:
+ case DTRACE_STATUS_OKAY:
+ rval = DTRACE_WORKSTATUS_OKAY;
+ break;
+
+ case -1:
+ return (DTRACE_WORKSTATUS_ERROR);
+ }
+
+ if ((status == DTRACE_STATUS_NONE || status == DTRACE_STATUS_OKAY) &&
+ policy != DTRACEOPT_BUFPOLICY_SWITCH) {
+ /*
+ * There either isn't any status or things are fine -- and
+ * this is a "ring" or "fill" buffer. We don't want to consume
+ * any of the trace data or snapshot the aggregations; we just
+ * return.
+ */
+ assert(rval == DTRACE_WORKSTATUS_OKAY);
+ return (rval);
+ }
+
+ if (dtrace_aggregate_snap(dtp) == -1)
+ return (DTRACE_WORKSTATUS_ERROR);
+
+ if (dtrace_consume(dtp, fp, pfunc, rfunc, arg) == -1)
+ return (DTRACE_WORKSTATUS_ERROR);
+
+ return (rval);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.c
new file mode 100644
index 00000000..dcd846f8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.c
@@ -0,0 +1,390 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <strings.h>
+#include <assert.h>
+#endif
+
+#include <dt_xlator.h>
+#include <dt_parser.h>
+#include <dt_grammar.h>
+#include <dt_module.h>
+#include <dt_impl.h>
+
+/*
+ * Create a member node corresponding to one of the output members of a dynamic
+ * translator. We set the member's dn_membexpr to a DT_NODE_XLATOR node that
+ * has dn_op set to DT_TOK_XLATE and refers back to the translator itself. The
+ * code generator will then use this as the indicator for dynamic translation.
+ */
+/*ARGSUSED*/
+static int
+dt_xlator_create_member(const char *name, ctf_id_t type, ulong_t off, void *arg)
+{
+ dt_xlator_t *dxp = arg;
+ dtrace_hdl_t *dtp = dxp->dx_hdl;
+ dt_node_t *enp, *mnp;
+ RT_NOREF1(off);
+
+ if ((enp = dt_node_xalloc(dtp, DT_NODE_XLATOR)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ enp->dn_link = dxp->dx_nodes;
+ dxp->dx_nodes = enp;
+
+ if ((mnp = dt_node_xalloc(dtp, DT_NODE_MEMBER)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ mnp->dn_link = dxp->dx_nodes;
+ dxp->dx_nodes = mnp;
+
+ /*
+ * For the member expression, we use a DT_NODE_XLATOR/TOK_XLATE whose
+ * xlator refers back to the translator and whose dn_xmember refers to
+ * the current member. These refs will be used by dt_cg.c and dt_as.c.
+ */
+ enp->dn_op = DT_TOK_XLATE;
+ enp->dn_xlator = dxp;
+ enp->dn_xmember = mnp;
+ dt_node_type_assign(enp, dxp->dx_dst_ctfp, type);
+
+ /*
+ * For the member itself, we use a DT_NODE_MEMBER as usual with the
+ * appropriate name, output type, and member expression set to 'enp'.
+ */
+ if (dxp->dx_members != NULL) {
+ assert(enp->dn_link->dn_kind == DT_NODE_MEMBER);
+ enp->dn_link->dn_list = mnp;
+ } else
+ dxp->dx_members = mnp;
+
+ mnp->dn_membname = strdup(name);
+ mnp->dn_membexpr = enp;
+ dt_node_type_assign(mnp, dxp->dx_dst_ctfp, type);
+
+ if (mnp->dn_membname == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ return (0);
+}
+
+dt_xlator_t *
+dt_xlator_create(dtrace_hdl_t *dtp,
+ const dtrace_typeinfo_t *src, const dtrace_typeinfo_t *dst,
+ const char *name, dt_node_t *members, dt_node_t *nodes)
+{
+ dt_xlator_t *dxp = dt_zalloc(dtp, sizeof (dt_xlator_t));
+ dtrace_typeinfo_t ptr = *dst;
+ dt_xlator_t **map;
+ dt_node_t *dnp;
+ uint_t kind;
+
+ if (dxp == NULL)
+ return (NULL);
+
+ dxp->dx_hdl = dtp;
+ dxp->dx_id = dtp->dt_xlatorid++;
+ dxp->dx_gen = dtp->dt_gen;
+ dxp->dx_arg = -1;
+
+ if ((map = dt_alloc(dtp, sizeof (void *) * (dxp->dx_id + 1))) == NULL) {
+ dt_free(dtp, dxp);
+ return (NULL);
+ }
+
+ dt_list_append(&dtp->dt_xlators, dxp);
+ bcopy(dtp->dt_xlatormap, map, sizeof (void *) * dxp->dx_id);
+ dt_free(dtp, dtp->dt_xlatormap);
+ dtp->dt_xlatormap = map;
+ dtp->dt_xlatormap[dxp->dx_id] = dxp;
+
+ if (dt_type_pointer(&ptr) == -1) {
+ ptr.dtt_ctfp = NULL;
+ ptr.dtt_type = CTF_ERR;
+ }
+
+ dxp->dx_ident = dt_ident_create(name ? name : "T",
+ DT_IDENT_SCALAR, DT_IDFLG_REF | DT_IDFLG_ORPHAN, 0,
+ _dtrace_defattr, 0, &dt_idops_thaw, NULL, dtp->dt_gen);
+
+ if (dxp->dx_ident == NULL)
+ goto err; /* no memory for identifier */
+
+ dxp->dx_ident->di_ctfp = src->dtt_ctfp;
+ dxp->dx_ident->di_type = src->dtt_type;
+
+ /*
+ * If an input parameter name is given, this is a static translator
+ * definition: create an idhash and identifier for the parameter.
+ */
+ if (name != NULL) {
+ dxp->dx_locals = dt_idhash_create("xlparams", NULL, 0, 0);
+
+ if (dxp->dx_locals == NULL)
+ goto err; /* no memory for identifier hash */
+
+ dt_idhash_xinsert(dxp->dx_locals, dxp->dx_ident);
+ }
+
+ dxp->dx_souid.di_name = "translator";
+ dxp->dx_souid.di_kind = DT_IDENT_XLSOU;
+ dxp->dx_souid.di_flags = DT_IDFLG_REF;
+ dxp->dx_souid.di_id = dxp->dx_id;
+ dxp->dx_souid.di_attr = _dtrace_defattr;
+ dxp->dx_souid.di_ops = &dt_idops_thaw;
+ dxp->dx_souid.di_data = dxp;
+ dxp->dx_souid.di_ctfp = dst->dtt_ctfp;
+ dxp->dx_souid.di_type = dst->dtt_type;
+ dxp->dx_souid.di_gen = dtp->dt_gen;
+
+ dxp->dx_ptrid.di_name = "translator";
+ dxp->dx_ptrid.di_kind = DT_IDENT_XLPTR;
+ dxp->dx_ptrid.di_flags = DT_IDFLG_REF;
+ dxp->dx_ptrid.di_id = dxp->dx_id;
+ dxp->dx_ptrid.di_attr = _dtrace_defattr;
+ dxp->dx_ptrid.di_ops = &dt_idops_thaw;
+ dxp->dx_ptrid.di_data = dxp;
+ dxp->dx_ptrid.di_ctfp = ptr.dtt_ctfp;
+ dxp->dx_ptrid.di_type = ptr.dtt_type;
+ dxp->dx_ptrid.di_gen = dtp->dt_gen;
+
+ /*
+ * If a deferred pragma is pending on the keyword "translator", run all
+ * the deferred pragmas on dx_souid and then copy results to dx_ptrid.
+ * See the code in dt_pragma.c for details on deferred ident pragmas.
+ */
+ if (dtp->dt_globals->dh_defer != NULL && yypcb->pcb_pragmas != NULL &&
+ dt_idhash_lookup(yypcb->pcb_pragmas, "translator") != NULL) {
+ dtp->dt_globals->dh_defer(dtp->dt_globals, &dxp->dx_souid);
+ dxp->dx_ptrid.di_attr = dxp->dx_souid.di_attr;
+ dxp->dx_ptrid.di_vers = dxp->dx_souid.di_vers;
+ }
+
+ dxp->dx_src_ctfp = src->dtt_ctfp;
+ dxp->dx_src_type = src->dtt_type;
+ dxp->dx_src_base = ctf_type_resolve(src->dtt_ctfp, src->dtt_type);
+
+ dxp->dx_dst_ctfp = dst->dtt_ctfp;
+ dxp->dx_dst_type = dst->dtt_type;
+ dxp->dx_dst_base = ctf_type_resolve(dst->dtt_ctfp, dst->dtt_type);
+
+ kind = ctf_type_kind(dst->dtt_ctfp, dxp->dx_dst_base);
+ assert(kind == CTF_K_STRUCT || kind == CTF_K_UNION);
+
+ /*
+ * If no input parameter is given, we're making a dynamic translator:
+ * create member nodes for every member of the output type. Otherwise
+ * retain the member and allocation node lists presented by the parser.
+ */
+ if (name == NULL) {
+ if (ctf_member_iter(dxp->dx_dst_ctfp, dxp->dx_dst_base,
+ dt_xlator_create_member, dxp) != 0)
+ goto err;
+ } else {
+ dxp->dx_members = members;
+ dxp->dx_nodes = nodes;
+ }
+
+ /*
+ * Assign member IDs to each member and allocate space for DIFOs
+ * if and when this translator is eventually compiled.
+ */
+ for (dnp = dxp->dx_members; dnp != NULL; dnp = dnp->dn_list) {
+ dnp->dn_membxlator = dxp;
+ dnp->dn_membid = dxp->dx_nmembers++;
+ }
+
+ dxp->dx_membdif = dt_zalloc(dtp,
+ sizeof (dtrace_difo_t *) * dxp->dx_nmembers);
+
+ if (dxp->dx_membdif == NULL) {
+ dxp->dx_nmembers = 0;
+ goto err;
+ }
+
+ return (dxp);
+
+err:
+ dt_xlator_destroy(dtp, dxp);
+ return (NULL);
+}
+
+void
+dt_xlator_destroy(dtrace_hdl_t *dtp, dt_xlator_t *dxp)
+{
+ uint_t i;
+
+ dt_node_link_free(&dxp->dx_nodes);
+
+ if (dxp->dx_locals != NULL)
+ dt_idhash_destroy(dxp->dx_locals);
+ else if (dxp->dx_ident != NULL)
+ dt_ident_destroy(dxp->dx_ident);
+
+ for (i = 0; i < dxp->dx_nmembers; i++)
+ dt_difo_free(dtp, dxp->dx_membdif[i]);
+
+ dt_free(dtp, dxp->dx_membdif);
+ dt_list_delete(&dtp->dt_xlators, dxp);
+ dt_free(dtp, dxp);
+}
+
+dt_xlator_t *
+dt_xlator_lookup(dtrace_hdl_t *dtp, dt_node_t *src, dt_node_t *dst, int flags)
+{
+ ctf_file_t *src_ctfp = src->dn_ctfp;
+ ctf_id_t src_type = src->dn_type;
+ ctf_id_t src_base = ctf_type_resolve(src_ctfp, src_type);
+
+ ctf_file_t *dst_ctfp = dst->dn_ctfp;
+ ctf_id_t dst_type = dst->dn_type;
+ ctf_id_t dst_base = ctf_type_resolve(dst_ctfp, dst_type);
+ uint_t dst_kind = ctf_type_kind(dst_ctfp, dst_base);
+
+ int ptr = dst_kind == CTF_K_POINTER;
+ dtrace_typeinfo_t src_dtt, dst_dtt;
+ dt_node_t xn = { 0 };
+ dt_xlator_t *dxp = NULL;
+
+ if (src_base == CTF_ERR || dst_base == CTF_ERR)
+ return (NULL); /* fail if these are unresolvable types */
+
+ /*
+ * Translators are always defined using a struct or union type, so if
+ * we are attempting to translate to type "T *", we internally look
+ * for a translation to type "T" by following the pointer reference.
+ */
+ if (ptr) {
+ dst_type = ctf_type_reference(dst_ctfp, dst_type);
+ dst_base = ctf_type_resolve(dst_ctfp, dst_type);
+ dst_kind = ctf_type_kind(dst_ctfp, dst_base);
+ }
+
+ if (dst_kind != CTF_K_UNION && dst_kind != CTF_K_STRUCT)
+ return (NULL); /* fail if the output isn't a struct or union */
+
+ /*
+ * In order to find a matching translator, we iterate over the set of
+ * available translators in three passes. First, we look for a
+ * translation from the exact source type to the resolved destination.
+ * Second, we look for a translation from the resolved source type to
+ * the resolved destination. Third, we look for a translation from a
+ * compatible source type (using the same rules as parameter formals)
+ * to the resolved destination. If all passes fail, return NULL.
+ */
+ for (dxp = dt_list_next(&dtp->dt_xlators); dxp != NULL;
+ dxp = dt_list_next(dxp)) {
+ if (ctf_type_compat(dxp->dx_src_ctfp, dxp->dx_src_type,
+ src_ctfp, src_type) &&
+ ctf_type_compat(dxp->dx_dst_ctfp, dxp->dx_dst_base,
+ dst_ctfp, dst_base))
+ goto out;
+ }
+
+ if (flags & DT_XLATE_EXACT)
+ goto out; /* skip remaining passes if exact match required */
+
+ for (dxp = dt_list_next(&dtp->dt_xlators); dxp != NULL;
+ dxp = dt_list_next(dxp)) {
+ if (ctf_type_compat(dxp->dx_src_ctfp, dxp->dx_src_base,
+ src_ctfp, src_type) &&
+ ctf_type_compat(dxp->dx_dst_ctfp, dxp->dx_dst_base,
+ dst_ctfp, dst_base))
+ goto out;
+ }
+
+ for (dxp = dt_list_next(&dtp->dt_xlators); dxp != NULL;
+ dxp = dt_list_next(dxp)) {
+ dt_node_type_assign(&xn, dxp->dx_src_ctfp, dxp->dx_src_type);
+ if (ctf_type_compat(dxp->dx_dst_ctfp, dxp->dx_dst_base,
+ dst_ctfp, dst_base) && dt_node_is_argcompat(src, &xn))
+ goto out;
+ }
+
+out:
+ if (ptr && dxp != NULL && dxp->dx_ptrid.di_type == CTF_ERR)
+ return (NULL); /* no translation available to pointer type */
+
+ if (dxp != NULL || !(flags & DT_XLATE_EXTERN) ||
+ dtp->dt_xlatemode == DT_XL_STATIC)
+ return (dxp); /* we succeeded or not allowed to extern */
+
+ /*
+ * If we get here, then we didn't find an existing translator, but the
+ * caller and xlatemode permit us to create an extern to a dynamic one.
+ */
+ src_dtt.dtt_object = dt_module_lookup_by_ctf(dtp, src_ctfp)->dm_name;
+ src_dtt.dtt_ctfp = src_ctfp;
+ src_dtt.dtt_type = src_type;
+
+ dst_dtt.dtt_object = dt_module_lookup_by_ctf(dtp, dst_ctfp)->dm_name;
+ dst_dtt.dtt_ctfp = dst_ctfp;
+ dst_dtt.dtt_type = dst_type;
+
+ return (dt_xlator_create(dtp, &src_dtt, &dst_dtt, NULL, NULL, NULL));
+}
+
+dt_xlator_t *
+dt_xlator_lookup_id(dtrace_hdl_t *dtp, id_t id)
+{
+#ifdef VBOX /* range */
+ assert(id < dtp->dt_xlatorid);
+#else
+ assert(id >= 0 && id < dtp->dt_xlatorid);
+#endif
+ return (dtp->dt_xlatormap[id]);
+}
+
+dt_ident_t *
+dt_xlator_ident(dt_xlator_t *dxp, ctf_file_t *ctfp, ctf_id_t type)
+{
+ if (ctf_type_kind(ctfp, ctf_type_resolve(ctfp, type)) == CTF_K_POINTER)
+ return (&dxp->dx_ptrid);
+ else
+ return (&dxp->dx_souid);
+}
+
+dt_node_t *
+dt_xlator_member(dt_xlator_t *dxp, const char *name)
+{
+ dt_node_t *dnp;
+
+ for (dnp = dxp->dx_members; dnp != NULL; dnp = dnp->dn_list) {
+ if (strcmp(dnp->dn_membname, name) == 0)
+ return (dnp);
+ }
+
+ return (NULL);
+}
+
+int
+dt_xlator_dynamic(const dt_xlator_t *dxp)
+{
+ return (dxp->dx_locals == NULL);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.h
new file mode 100644
index 00000000..01d047d4
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.h
@@ -0,0 +1,89 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DT_XLATOR_H
+#define _DT_XLATOR_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#include <libctf.h>
+#include <dtrace.h>
+#include <dt_ident.h>
+#include <dt_list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct dt_node;
+
+typedef struct dt_xlator {
+ dt_list_t dx_list; /* list forward/back pointers */
+ dt_idhash_t *dx_locals; /* hash of local scope identifiers */
+ dt_ident_t *dx_ident; /* identifier ref for input param */
+ dt_ident_t dx_souid; /* fake identifier for sou output */
+ dt_ident_t dx_ptrid; /* fake identifier for ptr output */
+ ctf_file_t *dx_src_ctfp; /* CTF container for input type */
+ ctf_id_t dx_src_type; /* CTF reference for input type */
+ ctf_id_t dx_src_base; /* CTF reference for input base */
+ ctf_file_t *dx_dst_ctfp; /* CTF container for output type */
+ ctf_id_t dx_dst_type; /* CTF reference for output type */
+ ctf_id_t dx_dst_base; /* CTF reference for output base */
+ struct dt_node *dx_members; /* list of member translations */
+ uint_t dx_nmembers; /* length of dx_members list */
+ dtrace_difo_t **dx_membdif; /* DIF for member expressions */
+ struct dt_node *dx_nodes; /* list of parse tree nodes */
+ dtrace_hdl_t *dx_hdl; /* back pointer to containing handle */
+ ulong_t dx_gen; /* generation number that created me */
+ id_t dx_id; /* global translator id */
+ int dx_arg; /* dynamic argument index */
+} dt_xlator_t;
+
+extern dt_xlator_t *dt_xlator_create(dtrace_hdl_t *,
+ const dtrace_typeinfo_t *, const dtrace_typeinfo_t *,
+ const char *, struct dt_node *, struct dt_node *);
+
+extern void dt_xlator_destroy(dtrace_hdl_t *, dt_xlator_t *);
+
+#define DT_XLATE_FUZZY 0x0 /* lookup any matching translator */
+#define DT_XLATE_EXACT 0x1 /* lookup only exact type matches */
+#define DT_XLATE_EXTERN 0x2 /* extern translator if none exists */
+
+extern dt_xlator_t *dt_xlator_lookup(dtrace_hdl_t *,
+ struct dt_node *, struct dt_node *, int);
+
+extern dt_xlator_t *dt_xlator_lookup_id(dtrace_hdl_t *, id_t);
+extern dt_ident_t *dt_xlator_ident(dt_xlator_t *, ctf_file_t *, ctf_id_t);
+extern struct dt_node *dt_xlator_member(dt_xlator_t *, const char *);
+extern int dt_xlator_dynamic(const dt_xlator_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_XLATOR_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dtrace.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dtrace.h
new file mode 100644
index 00000000..373b6727
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dtrace.h
@@ -0,0 +1,595 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _DTRACE_H
+#define _DTRACE_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/dtrace.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <gelf.h>
+#else /* VBOX */
+# include <sys/dtrace.h>
+# include <stdio.h>
+#endif /* VBOX */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * DTrace Dynamic Tracing Software: Library Interfaces
+ *
+ * Note: The contents of this file are private to the implementation of the
+ * Solaris system and DTrace subsystem and are subject to change at any time
+ * without notice. Applications and drivers using these interfaces will fail
+ * to run on future releases. These interfaces should not be used for any
+ * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
+ * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
+ */
+
+#define DTRACE_VERSION 3 /* library ABI interface version */
+
+struct ps_prochandle;
+typedef struct dtrace_hdl dtrace_hdl_t;
+typedef struct dtrace_prog dtrace_prog_t;
+typedef struct dtrace_vector dtrace_vector_t;
+typedef struct dtrace_aggdata dtrace_aggdata_t;
+
+#define DTRACE_O_NODEV 0x01 /* do not open dtrace(7D) device */
+#define DTRACE_O_NOSYS 0x02 /* do not load /system/object modules */
+#define DTRACE_O_LP64 0x04 /* force D compiler to be LP64 */
+#define DTRACE_O_ILP32 0x08 /* force D compiler to be ILP32 */
+#define DTRACE_O_MASK 0x0f /* mask of valid flags to dtrace_open */
+
+extern dtrace_hdl_t *dtrace_open(int, int, int *);
+extern dtrace_hdl_t *dtrace_vopen(int, int, int *,
+ const dtrace_vector_t *, void *);
+
+extern int dtrace_go(dtrace_hdl_t *);
+extern int dtrace_stop(dtrace_hdl_t *);
+extern void dtrace_sleep(dtrace_hdl_t *);
+extern void dtrace_close(dtrace_hdl_t *);
+
+extern int dtrace_errno(dtrace_hdl_t *);
+extern const char *dtrace_errmsg(dtrace_hdl_t *, int);
+extern const char *dtrace_faultstr(dtrace_hdl_t *, int);
+extern const char *dtrace_subrstr(dtrace_hdl_t *, int);
+
+extern int dtrace_setopt(dtrace_hdl_t *, const char *, const char *);
+extern int dtrace_getopt(dtrace_hdl_t *, const char *, dtrace_optval_t *);
+
+extern void dtrace_update(dtrace_hdl_t *);
+extern int dtrace_ctlfd(dtrace_hdl_t *);
+
+/*
+ * DTrace Program Interface
+ *
+ * DTrace programs can be created by compiling ASCII text files containing
+ * D programs or by compiling in-memory C strings that specify a D program.
+ * Once created, callers can examine the list of program statements and
+ * enable the probes and actions described by these statements.
+ */
+
+typedef struct dtrace_proginfo {
+ dtrace_attribute_t dpi_descattr; /* minimum probedesc attributes */
+ dtrace_attribute_t dpi_stmtattr; /* minimum statement attributes */
+ uint_t dpi_aggregates; /* number of aggregates specified in program */
+ uint_t dpi_recgens; /* number of record generating probes in prog */
+ uint_t dpi_matches; /* number of probes matched by program */
+ uint_t dpi_speculations; /* number of speculations specified in prog */
+} dtrace_proginfo_t;
+
+#define DTRACE_C_DIFV 0x0001 /* DIF verbose mode: show each compiled DIFO */
+#define DTRACE_C_EMPTY 0x0002 /* Permit compilation of empty D source files */
+#define DTRACE_C_ZDEFS 0x0004 /* Permit probe defs that match zero probes */
+#define DTRACE_C_EATTR 0x0008 /* Error if program attributes less than min */
+#define DTRACE_C_CPP 0x0010 /* Preprocess input file with cpp(1) utility */
+#define DTRACE_C_KNODEF 0x0020 /* Permit unresolved kernel symbols in DIFO */
+#define DTRACE_C_UNODEF 0x0040 /* Permit unresolved user symbols in DIFO */
+#define DTRACE_C_PSPEC 0x0080 /* Intepret ambiguous specifiers as probes */
+#define DTRACE_C_ETAGS 0x0100 /* Prefix error messages with error tags */
+#define DTRACE_C_ARGREF 0x0200 /* Do not require all macro args to be used */
+#define DTRACE_C_DEFARG 0x0800 /* Use 0/"" as value for unspecified args */
+#define DTRACE_C_NOLIBS 0x1000 /* Do not process D system libraries */
+#define DTRACE_C_CTL 0x2000 /* Only process control directives */
+#define DTRACE_C_MASK 0x3bff /* mask of all valid flags to dtrace_*compile */
+
+extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *,
+ const char *, dtrace_probespec_t, uint_t, int, char *const []);
+
+extern dtrace_prog_t *dtrace_program_fcompile(dtrace_hdl_t *,
+ FILE *, uint_t, int, char *const []);
+
+extern int dtrace_program_exec(dtrace_hdl_t *, dtrace_prog_t *,
+ dtrace_proginfo_t *);
+extern void dtrace_program_info(dtrace_hdl_t *, dtrace_prog_t *,
+ dtrace_proginfo_t *);
+
+#define DTRACE_D_STRIP 0x01 /* strip non-loadable sections from program */
+#define DTRACE_D_PROBES 0x02 /* include provider and probe definitions */
+#define DTRACE_D_MASK 0x03 /* mask of valid flags to dtrace_dof_create */
+
+extern int dtrace_program_link(dtrace_hdl_t *, dtrace_prog_t *,
+ uint_t, const char *, int, char *const []);
+
+extern int dtrace_program_header(dtrace_hdl_t *, FILE *, const char *);
+
+extern void *dtrace_dof_create(dtrace_hdl_t *, dtrace_prog_t *, uint_t);
+extern void dtrace_dof_destroy(dtrace_hdl_t *, void *);
+
+extern void *dtrace_getopt_dof(dtrace_hdl_t *);
+extern void *dtrace_geterr_dof(dtrace_hdl_t *);
+
+typedef struct dtrace_stmtdesc {
+ dtrace_ecbdesc_t *dtsd_ecbdesc; /* ECB description */
+ dtrace_actdesc_t *dtsd_action; /* action list */
+ dtrace_actdesc_t *dtsd_action_last; /* last action in action list */
+ void *dtsd_aggdata; /* aggregation data */
+ void *dtsd_fmtdata; /* type-specific output data */
+ void (*dtsd_callback)(void); /* callback function for EPID */
+ void *dtsd_data; /* callback data pointer */
+ dtrace_attribute_t dtsd_descattr; /* probedesc attributes */
+ dtrace_attribute_t dtsd_stmtattr; /* statement attributes */
+#if defined(VBOX) && defined(__GNUC__) && defined(RT_ARCH_AMD64)
+ /* gcc 4.4.5 p1.3 hass been seen doing a 64-bit access to read
+ dtsd_stmtattr (which is 3 bytes), thereby accessing bytes beyond the
+ end of the structure. */
+ uint32_t u32Padding;
+#endif
+} dtrace_stmtdesc_t;
+
+typedef int dtrace_stmt_f(dtrace_hdl_t *, dtrace_prog_t *,
+ dtrace_stmtdesc_t *, void *);
+
+extern dtrace_stmtdesc_t *dtrace_stmt_create(dtrace_hdl_t *,
+ dtrace_ecbdesc_t *);
+extern dtrace_actdesc_t *dtrace_stmt_action(dtrace_hdl_t *,
+ dtrace_stmtdesc_t *);
+extern int dtrace_stmt_add(dtrace_hdl_t *, dtrace_prog_t *,
+ dtrace_stmtdesc_t *);
+extern int dtrace_stmt_iter(dtrace_hdl_t *, dtrace_prog_t *,
+ dtrace_stmt_f *, void *);
+extern void dtrace_stmt_destroy(dtrace_hdl_t *, dtrace_stmtdesc_t *);
+
+/*
+ * DTrace Data Consumption Interface
+ */
+typedef enum {
+ DTRACEFLOW_ENTRY,
+ DTRACEFLOW_RETURN,
+ DTRACEFLOW_NONE
+} dtrace_flowkind_t;
+
+#define DTRACE_CONSUME_ERROR -1 /* error while processing */
+#define DTRACE_CONSUME_THIS 0 /* consume this probe/record */
+#define DTRACE_CONSUME_NEXT 1 /* advance to next probe/rec */
+#define DTRACE_CONSUME_ABORT 2 /* abort consumption */
+
+typedef struct dtrace_probedata {
+ dtrace_hdl_t *dtpda_handle; /* handle to DTrace library */
+ dtrace_eprobedesc_t *dtpda_edesc; /* enabled probe description */
+ dtrace_probedesc_t *dtpda_pdesc; /* probe description */
+ processorid_t dtpda_cpu; /* CPU for data */
+ caddr_t dtpda_data; /* pointer to raw data */
+ dtrace_flowkind_t dtpda_flow; /* flow kind */
+ const char *dtpda_prefix; /* recommended flow prefix */
+ int dtpda_indent; /* recommended flow indent */
+} dtrace_probedata_t;
+
+typedef int dtrace_consume_probe_f(const dtrace_probedata_t *, void *);
+typedef int dtrace_consume_rec_f(const dtrace_probedata_t *,
+ const dtrace_recdesc_t *, void *);
+
+extern int dtrace_consume(dtrace_hdl_t *, FILE *,
+ dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
+
+#define DTRACE_STATUS_NONE 0 /* no status; not yet time */
+#define DTRACE_STATUS_OKAY 1 /* status okay */
+#define DTRACE_STATUS_EXITED 2 /* exit() was called; tracing stopped */
+#define DTRACE_STATUS_FILLED 3 /* fill buffer filled; tracing stoped */
+#define DTRACE_STATUS_STOPPED 4 /* tracing already stopped */
+
+extern int dtrace_status(dtrace_hdl_t *);
+
+/*
+ * DTrace Formatted Output Interfaces
+ *
+ * To format output associated with a given dtrace_stmtdesc, the caller can
+ * invoke one of the following functions, passing the opaque dtsd_fmtdata and a
+ * list of record descriptions. These functions return either -1 to indicate
+ * an error, or a positive integer indicating the number of records consumed.
+ * For anonymous enablings, the consumer can use the dtrd_format member of
+ * the record description to obtain a format description. The dtfd_string
+ * member of the format description may be passed to dtrace_print{fa}_create()
+ * to create the opaque format data.
+ */
+extern void *dtrace_printf_create(dtrace_hdl_t *, const char *);
+extern void *dtrace_printa_create(dtrace_hdl_t *, const char *);
+extern size_t dtrace_printf_format(dtrace_hdl_t *, void *, char *, size_t);
+
+extern int dtrace_fprintf(dtrace_hdl_t *, FILE *, void *,
+ const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
+ const void *, size_t);
+
+extern int dtrace_fprinta(dtrace_hdl_t *, FILE *, void *,
+ const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
+ const void *, size_t);
+
+extern int dtrace_system(dtrace_hdl_t *, FILE *, void *,
+ const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
+ const void *, size_t);
+
+extern int dtrace_freopen(dtrace_hdl_t *, FILE *, void *,
+ const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
+ const void *, size_t);
+
+/*
+ * DTrace Work Interface
+ */
+typedef enum {
+ DTRACE_WORKSTATUS_ERROR = -1,
+ DTRACE_WORKSTATUS_OKAY,
+ DTRACE_WORKSTATUS_DONE
+} dtrace_workstatus_t;
+
+extern dtrace_workstatus_t dtrace_work(dtrace_hdl_t *, FILE *,
+ dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
+
+/*
+ * DTrace Handler Interface
+ */
+#define DTRACE_HANDLE_ABORT -1 /* abort current operation */
+#define DTRACE_HANDLE_OK 0 /* handled okay; continue */
+
+typedef struct dtrace_errdata {
+ dtrace_hdl_t *dteda_handle; /* handle to DTrace library */
+ dtrace_eprobedesc_t *dteda_edesc; /* enabled probe inducing err */
+ dtrace_probedesc_t *dteda_pdesc; /* probe inducing error */
+ processorid_t dteda_cpu; /* CPU of error */
+ int dteda_action; /* action inducing error */
+ int dteda_offset; /* offset in DIFO of error */
+ int dteda_fault; /* specific fault */
+ uint64_t dteda_addr; /* address of fault, if any */
+ const char *dteda_msg; /* preconstructed message */
+} dtrace_errdata_t;
+
+typedef int dtrace_handle_err_f(const dtrace_errdata_t *, void *);
+extern int dtrace_handle_err(dtrace_hdl_t *, dtrace_handle_err_f *, void *);
+
+typedef enum {
+ DTRACEDROP_PRINCIPAL, /* drop to principal buffer */
+ DTRACEDROP_AGGREGATION, /* drop to aggregation buffer */
+ DTRACEDROP_DYNAMIC, /* dynamic drop */
+ DTRACEDROP_DYNRINSE, /* dyn drop due to rinsing */
+ DTRACEDROP_DYNDIRTY, /* dyn drop due to dirty */
+ DTRACEDROP_SPEC, /* speculative drop */
+ DTRACEDROP_SPECBUSY, /* spec drop due to busy */
+ DTRACEDROP_SPECUNAVAIL, /* spec drop due to unavail */
+ DTRACEDROP_STKSTROVERFLOW, /* stack string tab overflow */
+ DTRACEDROP_DBLERROR /* error in ERROR probe */
+} dtrace_dropkind_t;
+
+typedef struct dtrace_dropdata {
+ dtrace_hdl_t *dtdda_handle; /* handle to DTrace library */
+ processorid_t dtdda_cpu; /* CPU, if any */
+ dtrace_dropkind_t dtdda_kind; /* kind of drop */
+ uint64_t dtdda_drops; /* number of drops */
+ uint64_t dtdda_total; /* total drops */
+ const char *dtdda_msg; /* preconstructed message */
+} dtrace_dropdata_t;
+
+typedef int dtrace_handle_drop_f(const dtrace_dropdata_t *, void *);
+extern int dtrace_handle_drop(dtrace_hdl_t *, dtrace_handle_drop_f *, void *);
+
+typedef void dtrace_handle_proc_f(struct ps_prochandle *, const char *, void *);
+extern int dtrace_handle_proc(dtrace_hdl_t *, dtrace_handle_proc_f *, void *);
+
+#define DTRACE_BUFDATA_AGGKEY 0x0001 /* aggregation key */
+#define DTRACE_BUFDATA_AGGVAL 0x0002 /* aggregation value */
+#define DTRACE_BUFDATA_AGGFORMAT 0x0004 /* aggregation format data */
+#define DTRACE_BUFDATA_AGGLAST 0x0008 /* last for this key/val */
+
+typedef struct dtrace_bufdata {
+ dtrace_hdl_t *dtbda_handle; /* handle to DTrace library */
+ const char *dtbda_buffered; /* buffered output */
+ dtrace_probedata_t *dtbda_probe; /* probe data */
+ const dtrace_recdesc_t *dtbda_recdesc; /* record description */
+ const dtrace_aggdata_t *dtbda_aggdata; /* aggregation data, if agg. */
+ uint32_t dtbda_flags; /* flags; see above */
+} dtrace_bufdata_t;
+
+typedef int dtrace_handle_buffered_f(const dtrace_bufdata_t *, void *);
+extern int dtrace_handle_buffered(dtrace_hdl_t *,
+ dtrace_handle_buffered_f *, void *);
+
+typedef struct dtrace_setoptdata {
+ dtrace_hdl_t *dtsda_handle; /* handle to DTrace library */
+ const dtrace_probedata_t *dtsda_probe; /* probe data */
+ const char *dtsda_option; /* option that was set */
+ dtrace_optval_t dtsda_oldval; /* old value */
+ dtrace_optval_t dtsda_newval; /* new value */
+} dtrace_setoptdata_t;
+
+typedef int dtrace_handle_setopt_f(const dtrace_setoptdata_t *, void *);
+extern int dtrace_handle_setopt(dtrace_hdl_t *,
+ dtrace_handle_setopt_f *, void *);
+
+/*
+ * DTrace Aggregate Interface
+ */
+
+#define DTRACE_A_PERCPU 0x0001
+#define DTRACE_A_KEEPDELTA 0x0002
+#define DTRACE_A_ANONYMOUS 0x0004
+
+#define DTRACE_AGGWALK_ERROR -1 /* error while processing */
+#define DTRACE_AGGWALK_NEXT 0 /* proceed to next element */
+#define DTRACE_AGGWALK_ABORT 1 /* abort aggregation walk */
+#define DTRACE_AGGWALK_CLEAR 2 /* clear this element */
+#define DTRACE_AGGWALK_NORMALIZE 3 /* normalize this element */
+#define DTRACE_AGGWALK_DENORMALIZE 4 /* denormalize this element */
+#define DTRACE_AGGWALK_REMOVE 5 /* remove this element */
+
+struct dtrace_aggdata {
+ dtrace_hdl_t *dtada_handle; /* handle to DTrace library */
+ dtrace_aggdesc_t *dtada_desc; /* aggregation description */
+ dtrace_eprobedesc_t *dtada_edesc; /* enabled probe description */
+ dtrace_probedesc_t *dtada_pdesc; /* probe description */
+ caddr_t dtada_data; /* pointer to raw data */
+ uint64_t dtada_normal; /* the normal -- 1 for denorm */
+ size_t dtada_size; /* total size of the data */
+ caddr_t dtada_delta; /* delta data, if available */
+ caddr_t *dtada_percpu; /* per CPU data, if avail */
+ caddr_t *dtada_percpu_delta; /* per CPU delta, if avail */
+};
+
+typedef int dtrace_aggregate_f(const dtrace_aggdata_t *, void *);
+typedef int dtrace_aggregate_walk_f(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+typedef int dtrace_aggregate_walk_joined_f(const dtrace_aggdata_t **,
+ const int, void *);
+
+extern void dtrace_aggregate_clear(dtrace_hdl_t *);
+extern int dtrace_aggregate_snap(dtrace_hdl_t *);
+extern int dtrace_aggregate_print(dtrace_hdl_t *, FILE *,
+ dtrace_aggregate_walk_f *);
+
+extern int dtrace_aggregate_walk(dtrace_hdl_t *, dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_joined(dtrace_hdl_t *,
+ dtrace_aggvarid_t *, int, dtrace_aggregate_walk_joined_f *, void *);
+
+extern int dtrace_aggregate_walk_sorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_keysorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_valsorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_keyvarsorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_valvarsorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_keyrevsorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_valrevsorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_keyvarrevsorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+extern int dtrace_aggregate_walk_valvarrevsorted(dtrace_hdl_t *,
+ dtrace_aggregate_f *, void *);
+
+#define DTRACE_AGD_PRINTED 0x1 /* aggregation printed in program */
+
+/*
+ * DTrace Process Control Interface
+ *
+ * Library clients who wish to have libdtrace create or grab processes for
+ * monitoring of their symbol table changes may use these interfaces to
+ * request that libdtrace obtain control of the process using libproc.
+ */
+
+extern struct ps_prochandle *dtrace_proc_create(dtrace_hdl_t *,
+ const char *, char *const *);
+
+extern struct ps_prochandle *dtrace_proc_grab(dtrace_hdl_t *, pid_t, int);
+extern void dtrace_proc_release(dtrace_hdl_t *, struct ps_prochandle *);
+extern void dtrace_proc_continue(dtrace_hdl_t *, struct ps_prochandle *);
+
+/*
+ * DTrace Object, Symbol, and Type Interfaces
+ *
+ * Library clients can use libdtrace to perform symbol and C type information
+ * lookups by symbol name, symbol address, or C type name, or to lookup meta-
+ * information cached for each of the program objects in use by DTrace. The
+ * resulting struct contain pointers to arbitrary-length strings, including
+ * object, symbol, and type names, that are persistent until the next call to
+ * dtrace_update(). Once dtrace_update() is called, any cached values must
+ * be flushed and not used subsequently by the client program.
+ */
+
+#define DTRACE_OBJ_INT_EXEC (0L) /* primary executable file */
+#define DTRACE_OBJ_INT_RTLD (1L) /* run-time link-editor */
+#define DTRACE_OBJ_INT_CDEFS (2L) /* C include definitions */
+#define DTRACE_OBJ_INT_DDEFS (3L) /* D program definitions */
+#define DTRACE_OBJ_INT_EVERY (-1L) /* all known objects */
+#define DTRACE_OBJ_INT_KMODS (-2L) /* all kernel objects */
+#define DTRACE_OBJ_INT_UMODS (-3L) /* all user objects */
+
+#define DTRACE_OBJ_EXEC ((const char *)(intptr_t)DTRACE_OBJ_INT_EXEC ) /* primary executable file */
+#define DTRACE_OBJ_RTLD ((const char *)(intptr_t)DTRACE_OBJ_INT_RTLD ) /* run-time link-editor */
+#define DTRACE_OBJ_CDEFS ((const char *)(intptr_t)DTRACE_OBJ_INT_CDEFS) /* C include definitions */
+#define DTRACE_OBJ_DDEFS ((const char *)(intptr_t)DTRACE_OBJ_INT_DDEFS) /* D program definitions */
+#define DTRACE_OBJ_EVERY ((const char *)(intptr_t)DTRACE_OBJ_INT_EVERY) /* all known objects */
+#define DTRACE_OBJ_KMODS ((const char *)(intptr_t)DTRACE_OBJ_INT_KMODS) /* all kernel objects */
+#define DTRACE_OBJ_UMODS ((const char *)(intptr_t)DTRACE_OBJ_INT_UMODS) /* all user objects */
+
+typedef struct dtrace_objinfo {
+ const char *dto_name; /* object file scope name */
+ const char *dto_file; /* object file path (if any) */
+ int dto_id; /* object file id (if any) */
+ uint_t dto_flags; /* object flags (see below) */
+
+ GElf_Addr dto_text_va; /* address of text section */
+ GElf_Xword dto_text_size; /* size of text section */
+ GElf_Addr dto_data_va; /* address of data section */
+ GElf_Xword dto_data_size; /* size of data section */
+ GElf_Addr dto_bss_va; /* address of BSS */
+ GElf_Xword dto_bss_size; /* size of BSS */
+} dtrace_objinfo_t;
+
+#define DTRACE_OBJ_F_KERNEL 0x1 /* object is a kernel module */
+#define DTRACE_OBJ_F_PRIMARY 0x2 /* object is a primary module */
+
+typedef int dtrace_obj_f(dtrace_hdl_t *, const dtrace_objinfo_t *, void *);
+
+extern int dtrace_object_iter(dtrace_hdl_t *, dtrace_obj_f *, void *);
+extern int dtrace_object_info(dtrace_hdl_t *, const char *, dtrace_objinfo_t *);
+
+typedef struct dtrace_syminfo {
+ const char *dts_object; /* object name */
+ const char *dts_name; /* symbol name */
+ ulong_t dts_id; /* symbol id */
+} dtrace_syminfo_t;
+
+extern int dtrace_lookup_by_name(dtrace_hdl_t *, const char *, const char *,
+ GElf_Sym *, dtrace_syminfo_t *);
+
+extern int dtrace_lookup_by_addr(dtrace_hdl_t *, GElf_Addr addr,
+ GElf_Sym *, dtrace_syminfo_t *);
+
+typedef struct dtrace_typeinfo {
+ const char *dtt_object; /* object containing type */
+ ctf_file_t *dtt_ctfp; /* CTF container handle */
+ ctf_id_t dtt_type; /* CTF type identifier */
+} dtrace_typeinfo_t;
+
+extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *,
+ dtrace_typeinfo_t *);
+
+extern int dtrace_symbol_type(dtrace_hdl_t *, const GElf_Sym *,
+ const dtrace_syminfo_t *, dtrace_typeinfo_t *);
+
+extern int dtrace_type_strcompile(dtrace_hdl_t *,
+ const char *, dtrace_typeinfo_t *);
+
+extern int dtrace_type_fcompile(dtrace_hdl_t *,
+ FILE *, dtrace_typeinfo_t *);
+
+/*
+ * DTrace Probe Interface
+ *
+ * Library clients can use these functions to iterate over the set of available
+ * probe definitions and inquire as to their attributes. The probe iteration
+ * interfaces report probes that are declared as well as those from dtrace(7D).
+ */
+typedef struct dtrace_probeinfo {
+ dtrace_attribute_t dtp_attr; /* name attributes */
+ dtrace_attribute_t dtp_arga; /* arg attributes */
+ const dtrace_typeinfo_t *dtp_argv; /* arg types */
+ int dtp_argc; /* arg count */
+} dtrace_probeinfo_t;
+
+typedef int dtrace_probe_f(dtrace_hdl_t *, const dtrace_probedesc_t *, void *);
+
+extern int dtrace_probe_iter(dtrace_hdl_t *,
+ const dtrace_probedesc_t *pdp, dtrace_probe_f *, void *);
+
+extern int dtrace_probe_info(dtrace_hdl_t *,
+ const dtrace_probedesc_t *, dtrace_probeinfo_t *);
+
+/*
+ * DTrace Vector Interface
+ *
+ * The DTrace library normally speaks directly to dtrace(7D). However,
+ * this communication may be vectored elsewhere. Consumers who wish to
+ * perform a vectored open must fill in the vector, and use the dtrace_vopen()
+ * entry point to obtain a library handle.
+ */
+struct dtrace_vector {
+ int (*dtv_ioctl)(void *, int, void *);
+ int (*dtv_lookup_by_addr)(void *, GElf_Addr, GElf_Sym *,
+ dtrace_syminfo_t *);
+ int (*dtv_status)(void *, processorid_t);
+ long (*dtv_sysconf)(void *, int);
+};
+
+/*
+ * DTrace Utility Functions
+ *
+ * Library clients can use these functions to convert addresses strings, to
+ * convert between string and integer probe descriptions and the
+ * dtrace_probedesc_t representation, and to perform similar conversions on
+ * stability attributes.
+ */
+extern int dtrace_addr2str(dtrace_hdl_t *, uint64_t, char *, int);
+extern int dtrace_uaddr2str(dtrace_hdl_t *, pid_t, uint64_t, char *, int);
+
+extern int dtrace_xstr2desc(dtrace_hdl_t *, dtrace_probespec_t,
+ const char *, int, char *const [], dtrace_probedesc_t *);
+
+extern int dtrace_str2desc(dtrace_hdl_t *, dtrace_probespec_t,
+ const char *, dtrace_probedesc_t *);
+
+extern int dtrace_id2desc(dtrace_hdl_t *, dtrace_id_t, dtrace_probedesc_t *);
+
+#define DTRACE_DESC2STR_MAX 1024 /* min buf size for dtrace_desc2str() */
+
+extern char *dtrace_desc2str(const dtrace_probedesc_t *, char *, size_t);
+
+#define DTRACE_ATTR2STR_MAX 64 /* min buf size for dtrace_attr2str() */
+
+extern char *dtrace_attr2str(dtrace_attribute_t, char *, size_t);
+extern int dtrace_str2attr(const char *, dtrace_attribute_t *);
+
+extern const char *dtrace_stability_name(dtrace_stability_t);
+extern const char *dtrace_class_name(dtrace_class_t);
+
+extern int dtrace_provider_modules(dtrace_hdl_t *, const char **, int);
+
+extern const char *const _dtrace_version;
+extern int _dtrace_debug;
+
+#ifdef VBOX
+extern void dtrace_init(void);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DTRACE_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/fc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/fc.d
new file mode 100644
index 00000000..433e645c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/fc.d
@@ -0,0 +1,183 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D depends_on library net.d
+#pragma D depends_on library scsi.d
+#pragma D depends_on module genunix
+#pragma D depends_on module fct
+
+/*
+ * FC port information.
+ */
+typedef struct fc_port_info {
+ string fcp_node_wwn; /* node WWN */
+ string fcp_sym_node_name; /* node symbolic name */
+ string fcp_sym_port_name; /* port symbolic name */
+ uint32_t fcp_port_hard_address; /* port hard address */
+} fc_port_info_t;
+
+/*
+ * FC transfer info (somewhat analogous to iscsiinfo_t)
+ * Represents data transfer details.
+ */
+typedef struct fc_xferinfo {
+ uint32_t fcx_len;
+ uint32_t fcx_offset;
+ uint16_t fcx_flags; /* db_flags as defined in sys/stmf.h */
+} fc_xferinfo_t;
+
+/*
+ * conninfo translators
+ */
+
+/*
+ * Translator for conninfo, translating from the local port.
+ */
+#pragma D binding "1.5" translator
+translator conninfo_t < fct_local_port_t *P > {
+ ci_local = P->port_pwwn_str[0] ?
+ P->port_pwwn_str : "<unknown>";
+ ci_remote = "<unknown>";
+ ci_protocol = "fc";
+};
+
+/*
+ * Translator for conninfo, translating from the local port implementation.
+ */
+#pragma D binding "1.5" translator
+translator conninfo_t < fct_i_local_port_t *P > {
+ ci_local = P->iport_port->port_pwwn_str[0] ?
+ P->iport_port->port_pwwn_str : "<unknown>";
+ ci_remote = "<unknown>";
+ ci_protocol = "fc";
+};
+
+/*
+ * Translator for conninfo, translating from fct cmd struct.
+ */
+#pragma D binding "1.5" translator
+translator conninfo_t < fct_cmd_t *C > {
+ ci_local = (C->cmd_port ?
+ (C->cmd_port->port_pwwn_str[0] ?
+ C->cmd_port->port_pwwn_str : "<unknown>") :
+ "<unknown>");
+
+ ci_remote = (C->cmd_rp ?
+ (C->cmd_rp->rp_pwwn_str[0] ?
+ C->cmd_rp->rp_pwwn_str : "<unknown>") :
+ "<unknown>");
+
+ ci_protocol = "fc";
+};
+
+
+/*
+ * fc_port_info_t translators.
+ */
+
+/*
+ * Translator for fc_port_info_t, translating from the local port.
+ */
+#pragma D binding "1.5" translator
+translator fc_port_info_t < fct_local_port_t *P > {
+ /* node WWN */
+ fcp_node_wwn = P->port_nwwn_str[0] ?
+ P->port_nwwn_str : "<unknown>";
+
+ /* node symbolic name */
+ fcp_sym_node_name = P->port_sym_node_name ?
+ P->port_sym_node_name : `utsname.nodename;
+
+ /* port symbolic name */
+ fcp_sym_port_name = P->port_sym_port_name ?
+ P->port_sym_port_name : "<unknown>";
+
+ /* port hard address */
+ fcp_port_hard_address = P->port_hard_address;
+};
+
+
+/*
+ * Translator for fc_port_info_t, translating from the local port impl.
+ */
+#pragma D binding "1.5" translator
+translator fc_port_info_t < fct_i_local_port_t *P > {
+ /* node WWN */
+
+ fcp_node_wwn = (P->iport_port ?
+ (P->iport_port->port_nwwn_str[0] ?
+ P->iport_port->port_nwwn_str :
+ "<unknown>") :
+ "<bad iport_port ptr>");
+
+ fcp_sym_node_name =
+ (P->iport_port ?
+ (P->iport_port->port_sym_node_name ?
+ P->iport_port->port_sym_node_name : "<unknown>") :
+ "<bad iport_port ptr>");
+
+ fcp_sym_port_name =
+ (P->iport_port ?
+ (P->iport_port->port_sym_port_name ?
+ P->iport_port->port_sym_port_name : "<unknown>") :
+ "<bad iport_port ptr>");
+
+ fcp_port_hard_address =
+ (P->iport_port ?
+ P->iport_port->port_hard_address : 0);
+};
+
+/*
+ * Translator for fc_port_info, translating from the remote port impl
+ */
+#pragma D binding "1.5" translator
+translator fc_port_info_t < fct_i_remote_port_t *P > {
+
+ /* node WWN */
+ fcp_node_wwn = P->irp_rp ?
+ (P->irp_rp->rp_nwwn_str[0] ?
+ P->irp_rp->rp_nwwn_str : "<unknown>") :
+ "<unknown>";
+
+ /* node symbolic name */
+ fcp_sym_node_name = P->irp_snn ? P->irp_snn : "<unknown>";
+
+ /* port symbolic name */
+ fcp_sym_port_name = P->irp_spn ? P->irp_spn : "<unknown>";
+
+ /* port hard address */
+ fcp_port_hard_address = P->irp_rp ? P->irp_rp->rp_id : 0;
+};
+
+/*
+ * Translator for fc_xferinfo, translating from stmf_data_buf_t.
+ */
+#pragma D binding "1.5" translator
+translator fc_xferinfo_t < stmf_data_buf_t *B > {
+ fcx_len = B->db_data_size;
+ fcx_offset = B->db_relative_offset;
+ fcx_flags = B->db_flags;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.d.in
new file mode 100644
index 00000000..cb1e32cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.d.in
@@ -0,0 +1,218 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D depends_on module unix
+#pragma D depends_on provider io
+
+inline int B_BUSY = @B_BUSY@;
+#pragma D binding "1.0" B_BUSY
+inline int B_DONE = @B_DONE@;
+#pragma D binding "1.0" B_DONE
+inline int B_ERROR = @B_ERROR@;
+#pragma D binding "1.0" B_ERROR
+inline int B_PAGEIO = @B_PAGEIO@;
+#pragma D binding "1.0" B_PAGEIO
+inline int B_PHYS = @B_PHYS@;
+#pragma D binding "1.0" B_PHYS
+inline int B_READ = @B_READ@;
+#pragma D binding "1.0" B_READ
+inline int B_WRITE = @B_WRITE@;
+#pragma D binding "1.0" B_WRITE
+inline int B_ASYNC = @B_ASYNC@;
+#pragma D binding "1.0" B_ASYNC
+
+typedef struct bufinfo {
+ int b_flags; /* buffer status */
+ size_t b_bcount; /* number of bytes */
+ caddr_t b_addr; /* buffer address */
+ uint64_t b_lblkno; /* block # on device */
+ uint64_t b_blkno; /* expanded block # on device */
+ size_t b_resid; /* # of bytes not transferred */
+ size_t b_bufsize; /* size of allocated buffer */
+ caddr_t b_iodone; /* I/O completion routine */
+ int b_error; /* expanded error field */
+ dev_t b_edev; /* extended device */
+} bufinfo_t;
+
+#pragma D binding "1.0" translator
+translator bufinfo_t < struct buf *B > {
+ b_flags = B->b_flags;
+ b_addr = B->b_un.b_addr;
+ b_bcount = B->b_bcount;
+ b_lblkno = B->_b_blkno._f;
+ b_blkno = sizeof (long) == 8 ? B->_b_blkno._f : B->_b_blkno._p._l;
+ b_resid = B->b_resid;
+ b_bufsize = B->b_bufsize;
+ b_iodone = (caddr_t)B->b_iodone;
+ b_error = B->b_error;
+ b_edev = B->b_edev;
+};
+
+typedef struct devinfo {
+ int dev_major; /* major number */
+ int dev_minor; /* minor number */
+ int dev_instance; /* instance number */
+ string dev_name; /* name of device */
+ string dev_statname; /* name of device + instance/minor */
+ string dev_pathname; /* pathname of device */
+} devinfo_t;
+
+#pragma D binding "1.0" translator
+translator devinfo_t < struct buf *B > {
+ dev_major = B->b_dip != NULL ? getmajor(B->b_edev) :
+ getmajor(B->b_file->v_vfsp->vfs_dev);
+ dev_minor = B->b_dip != NULL ? getminor(B->b_edev) :
+ getminor(B->b_file->v_vfsp->vfs_dev);
+ dev_instance = B->b_dip == NULL ?
+ getminor(B->b_file->v_vfsp->vfs_dev) :
+ ((struct dev_info *)B->b_dip)->devi_instance;
+ dev_name = B->b_dip == NULL ? "nfs" :
+ stringof(`devnamesp[getmajor(B->b_edev)].dn_name);
+ dev_statname = strjoin(B->b_dip == NULL ? "nfs" :
+ stringof(`devnamesp[getmajor(B->b_edev)].dn_name),
+ lltostr(B->b_dip == NULL ? getminor(B->b_file->v_vfsp->vfs_dev) :
+ ((struct dev_info *)B->b_dip)->devi_instance == 0 &&
+ ((struct dev_info *)B->b_dip)->devi_parent != NULL &&
+ ((struct dev_info *)B->b_dip)->devi_parent->devi_node_name ==
+ "pseudo" ? getminor(B->b_edev) :
+ ((struct dev_info *)B->b_dip)->devi_instance));
+ dev_pathname = B->b_dip == NULL ? "<nfs>" :
+ ddi_pathname(B->b_dip, getminor(B->b_edev));
+};
+
+typedef struct fileinfo {
+ string fi_name; /* name (basename of fi_pathname) */
+ string fi_dirname; /* directory (dirname of fi_pathname) */
+ string fi_pathname; /* full pathname */
+ offset_t fi_offset; /* offset within file */
+ string fi_fs; /* filesystem */
+ string fi_mount; /* mount point of file system */
+ int fi_oflags; /* open(2) flags for file descriptor */
+} fileinfo_t;
+
+#pragma D binding "1.0" translator
+translator fileinfo_t < struct buf *B > {
+ fi_name = B->b_file == NULL ? "<none>" :
+ B->b_file->v_path == NULL ? "<unknown>" :
+ basename(cleanpath(B->b_file->v_path));
+ fi_dirname = B->b_file == NULL ? "<none>" :
+ B->b_file->v_path == NULL ? "<unknown>" :
+ dirname(cleanpath(B->b_file->v_path));
+ fi_pathname = B->b_file == NULL ? "<none>" :
+ B->b_file->v_path == NULL ? "<unknown>" :
+ cleanpath(B->b_file->v_path);
+ fi_offset = B->b_offset;
+ fi_fs = B->b_file == NULL ? "<none>" :
+ stringof(B->b_file->v_op->vnop_name);
+ fi_mount = B->b_file == NULL ? "<none>" :
+ B->b_file->v_vfsp->vfs_vnodecovered == NULL ? "/" :
+ B->b_file->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
+ cleanpath(B->b_file->v_vfsp->vfs_vnodecovered->v_path);
+ fi_oflags = 0;
+};
+
+/*
+ * The following inline constants can be used to examine fi_oflags when using
+ * the fds[] array or a translated fileinfo_t. Note that the various open
+ * flags behave as a bit-field *except* for O_RDONLY, O_WRONLY, and O_RDWR.
+ * To test the open mode, you write code similar to that used with the fcntl(2)
+ * F_GET[X]FL command, such as: if ((fi_oflags & O_ACCMODE) == O_WRONLY).
+ */
+inline int O_ACCMODE = @O_ACCMODE@;
+#pragma D binding "1.1" O_ACCMODE
+
+inline int O_RDONLY = @O_RDONLY@;
+#pragma D binding "1.1" O_RDONLY
+inline int O_WRONLY = @O_WRONLY@;
+#pragma D binding "1.1" O_WRONLY
+inline int O_RDWR = @O_RDWR@;
+#pragma D binding "1.1" O_RDWR
+
+inline int O_APPEND = @O_APPEND@;
+#pragma D binding "1.1" O_APPEND
+inline int O_CREAT = @O_CREAT@;
+#pragma D binding "1.1" O_CREAT
+inline int O_DSYNC = @O_DSYNC@;
+#pragma D binding "1.1" O_DSYNC
+inline int O_EXCL = @O_EXCL@;
+#pragma D binding "1.1" O_EXCL
+inline int O_LARGEFILE = @O_LARGEFILE@;
+#pragma D binding "1.1" O_LARGEFILE
+inline int O_NOCTTY = @O_NOCTTY@;
+#pragma D binding "1.1" O_NOCTTY
+inline int O_NONBLOCK = @O_NONBLOCK@;
+#pragma D binding "1.1" O_NONBLOCK
+inline int O_NDELAY = @O_NDELAY@;
+#pragma D binding "1.1" O_NDELAY
+inline int O_RSYNC = @O_RSYNC@;
+#pragma D binding "1.1" O_RSYNC
+inline int O_SYNC = @O_SYNC@;
+#pragma D binding "1.1" O_SYNC
+inline int O_TRUNC = @O_TRUNC@;
+#pragma D binding "1.1" O_TRUNC
+inline int O_XATTR = @O_XATTR@;
+#pragma D binding "1.1" O_XATTR
+
+#pragma D binding "1.1" translator
+translator fileinfo_t < struct file *F > {
+ fi_name = F == NULL ? "<none>" :
+ F->f_vnode->v_path == NULL ? "<unknown>" :
+ basename(cleanpath(F->f_vnode->v_path));
+ fi_dirname = F == NULL ? "<none>" :
+ F->f_vnode->v_path == NULL ? "<unknown>" :
+ dirname(cleanpath(F->f_vnode->v_path));
+ fi_pathname = F == NULL ? "<none>" :
+ F->f_vnode->v_path == NULL ? "<unknown>" :
+ cleanpath(F->f_vnode->v_path);
+ fi_offset = F == NULL ? 0 : F->f_offset;
+ fi_fs = F == NULL ? "<none>" : stringof(F->f_vnode->v_op->vnop_name);
+ fi_mount = F == NULL ? "<none>" :
+ F->f_vnode->v_vfsp->vfs_vnodecovered == NULL ? "/" :
+ F->f_vnode->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
+ cleanpath(F->f_vnode->v_vfsp->vfs_vnodecovered->v_path);
+ fi_oflags = F == NULL ? 0 : F->f_flag + (int)@FOPEN@;
+};
+
+inline fileinfo_t fds[int fd] = xlate <fileinfo_t> (
+ fd >= 0 && fd < curthread->t_procp->p_user.u_finfo.fi_nfiles ?
+ curthread->t_procp->p_user.u_finfo.fi_list[fd].uf_file : NULL);
+
+#pragma D attributes Stable/Stable/Common fds
+#pragma D binding "1.1" fds
+
+#pragma D binding "1.2" translator
+translator fileinfo_t < struct vnode *V > {
+ fi_name = V->v_path == NULL ? "<unknown>" :
+ basename(cleanpath(V->v_path));
+ fi_dirname = V->v_path == NULL ? "<unknown>" :
+ dirname(cleanpath(V->v_path));
+ fi_pathname = V->v_path == NULL ? "<unknown>" : cleanpath(V->v_path);
+ fi_fs = stringof(V->v_op->vnop_name);
+ fi_mount = V->v_vfsp->vfs_vnodecovered == NULL ? "/" :
+ V->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
+ cleanpath(V->v_vfsp->vfs_vnodecovered->v_path);
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.sed.in
new file mode 100644
index 00000000..87fad5ba
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/io.sed.in
@@ -0,0 +1,69 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * This file is a sed script which is first preprocessed by cpp or cc -E to
+ * define a set of sed directives which replace #define tokens with their
+ * values. After preprocessing, the sed script is run over io.d.in to
+ * replace the #define tokens listed below to create the finished io.d.
+ * Refer to the rules in libdtrace/Makefile.com for more information.
+ */
+
+#include <sys/buf.h>
+#include <sys/file.h>
+#include <sys/fcntl.h>
+
+#define SED_REPLACE(x) s/#x/x/g
+
+SED_REPLACE(B_BUSY)
+SED_REPLACE(B_DONE)
+SED_REPLACE(B_ERROR)
+SED_REPLACE(B_PAGEIO)
+SED_REPLACE(B_PHYS)
+SED_REPLACE(B_READ)
+SED_REPLACE(B_WRITE)
+SED_REPLACE(B_ASYNC)
+
+SED_REPLACE(FOPEN)
+
+SED_REPLACE(O_ACCMODE)
+SED_REPLACE(O_RDONLY)
+SED_REPLACE(O_WRONLY)
+SED_REPLACE(O_RDWR)
+SED_REPLACE(O_APPEND)
+SED_REPLACE(O_CREAT)
+SED_REPLACE(O_DSYNC)
+SED_REPLACE(O_EXCL)
+SED_REPLACE(O_LARGEFILE)
+SED_REPLACE(O_NOCTTY)
+SED_REPLACE(O_NONBLOCK)
+SED_REPLACE(O_NDELAY)
+SED_REPLACE(O_RSYNC)
+SED_REPLACE(O_SYNC)
+SED_REPLACE(O_TRUNC)
+SED_REPLACE(O_XATTR)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.d.in
new file mode 100644
index 00000000..f1e63325
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.d.in
@@ -0,0 +1,374 @@
+/*
+ * 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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#pragma D depends_on module ip
+#pragma D depends_on provider ip
+
+inline int IPH_DF = @IPH_DF@;
+#pragma D binding "1.5" IPH_DF
+inline int IPH_MF = @IPH_MF@;
+#pragma D binding "1.5" IPH_MF
+
+#pragma D binding "1.5" IPPROTO_IP
+inline int IPPROTO_IP = @IPPROTO_IP@;
+#pragma D binding "1.5" IPPROTO_HOPOPTS
+inline int IPPROTO_HOPOPTS = @IPPROTO_HOPOPTS@;
+#pragma D binding "1.5" IPPROTO_ICMP
+inline int IPPROTO_ICMP = @IPPROTO_ICMP@;
+#pragma D binding "1.5" IPPROTO_IGMP
+inline int IPPROTO_IGMP = @IPPROTO_IGMP@;
+#pragma D binding "1.5" IPPROTO_GGP
+inline int IPPROTO_GGP = @IPPROTO_GGP@;
+#pragma D binding "1.5" IPPROTO_ENCAP
+inline int IPPROTO_ENCAP = @IPPROTO_ENCAP@;
+#pragma D binding "1.5" IPPROTO_TCP
+inline int IPPROTO_TCP = @IPPROTO_TCP@;
+#pragma D binding "1.5" IPPROTO_EGP
+inline int IPPROTO_EGP = @IPPROTO_EGP@;
+#pragma D binding "1.5" IPPROTO_PUP
+inline int IPPROTO_PUP = @IPPROTO_PUP@;
+#pragma D binding "1.5" IPPROTO_UDP
+inline int IPPROTO_UDP = @IPPROTO_UDP@;
+#pragma D binding "1.5" IPPROTO_IDP
+inline int IPPROTO_IDP = @IPPROTO_IDP@;
+#pragma D binding "1.5" IPPROTO_IPV6
+inline int IPPROTO_IPV6 = @IPPROTO_IPV6@;
+#pragma D binding "1.5" IPPROTO_ROUTING
+inline int IPPROTO_ROUTING = @IPPROTO_ROUTING@;
+#pragma D binding "1.5" IPPROTO_FRAGMENT
+inline int IPPROTO_FRAGMENT = @IPPROTO_FRAGMENT@;
+#pragma D binding "1.5" IPPROTO_RSVP
+inline int IPPROTO_RSVP = @IPPROTO_RSVP@;
+#pragma D binding "1.5" IPPROTO_ESP
+inline int IPPROTO_ESP = @IPPROTO_ESP@;
+#pragma D binding "1.5" IPPROTO_AH
+inline int IPPROTO_AH = @IPPROTO_AH@;
+#pragma D binding "1.5" IPPROTO_ICMPV6
+inline int IPPROTO_ICMPV6 = @IPPROTO_ICMPV6@;
+#pragma D binding "1.5" IPPROTO_NONE
+inline int IPPROTO_NONE = @IPPROTO_NONE@;
+#pragma D binding "1.5" IPPROTO_DSTOPTS
+inline int IPPROTO_DSTOPTS = @IPPROTO_DSTOPTS@;
+#pragma D binding "1.5" IPPROTO_HELLO
+inline int IPPROTO_HELLO = @IPPROTO_HELLO@;
+#pragma D binding "1.5" IPPROTO_ND
+inline int IPPROTO_ND = @IPPROTO_ND@;
+#pragma D binding "1.5" IPPROTO_EON
+inline int IPPROTO_EON = @IPPROTO_EON@;
+#pragma D binding "1.5" IPPROTO_OSPF
+inline int IPPROTO_OSPF = @IPPROTO_OSPF@;
+#pragma D binding "1.5" IPPROTO_PIM
+inline int IPPROTO_PIM = @IPPROTO_PIM@;
+#pragma D binding "1.5" IPPROTO_SCTP
+inline int IPPROTO_SCTP = @IPPROTO_SCTP@;
+#pragma D binding "1.5" IPPROTO_RAW
+inline int IPPROTO_RAW = @IPPROTO_RAW@;
+#pragma D binding "1.5" IPPROTO_MAX
+inline int IPPROTO_MAX = @IPPROTO_MAX@;
+
+/*
+ * pktinfo is where packet ID info can be made available for deeper
+ * analysis if packet IDs become supported by the kernel in the future.
+ * The pkt_addr member is currently always NULL.
+ */
+typedef struct pktinfo {
+ uintptr_t pkt_addr;
+} pktinfo_t;
+
+/*
+ * csinfo is where connection state info is made available.
+ */
+typedef struct csinfo {
+ uintptr_t cs_addr;
+ uint64_t cs_cid;
+ pid_t cs_pid;
+ zoneid_t cs_zoneid;
+} csinfo_t;
+
+/*
+ * ipinfo contains common IP info for both IPv4 and IPv6.
+ */
+typedef struct ipinfo {
+ uint8_t ip_ver; /* IP version (4, 6) */
+ uint32_t ip_plength; /* payload length */
+ string ip_saddr; /* source address */
+ string ip_daddr; /* destination address */
+} ipinfo_t;
+
+/*
+ * ifinfo contains network interface info.
+ */
+typedef struct ifinfo {
+ string if_name; /* interface name */
+ int8_t if_local; /* is delivered locally */
+ netstackid_t if_ipstack; /* ipstack ID */
+ uintptr_t if_addr; /* pointer to raw ill_t */
+} ifinfo_t;
+
+/*
+ * ipv4info is a translated version of the IPv4 header (with raw pointer).
+ * These values are NULL if the packet is not IPv4.
+ */
+typedef struct ipv4info {
+ uint8_t ipv4_ver; /* IP version (4) */
+ uint8_t ipv4_ihl; /* header length, bytes */
+ uint8_t ipv4_tos; /* type of service field */
+ uint16_t ipv4_length; /* length (header + payload) */
+ uint16_t ipv4_ident; /* identification */
+ uint8_t ipv4_flags; /* IP flags */
+ uint16_t ipv4_offset; /* fragment offset */
+ uint8_t ipv4_ttl; /* time to live */
+ uint8_t ipv4_protocol; /* next level protocol */
+ string ipv4_protostr; /* next level protocol, as a string */
+ uint16_t ipv4_checksum; /* header checksum */
+ ipaddr_t ipv4_src; /* source address */
+ ipaddr_t ipv4_dst; /* destination address */
+ string ipv4_saddr; /* source address, string */
+ string ipv4_daddr; /* destination address, string */
+ ipha_t *ipv4_hdr; /* pointer to raw header */
+} ipv4info_t;
+
+/*
+ * ipv6info is a translated version of the IPv6 header (with raw pointer).
+ * These values are NULL if the packet is not IPv6.
+ */
+typedef struct ipv6info {
+ uint8_t ipv6_ver; /* IP version (6) */
+ uint8_t ipv6_tclass; /* traffic class */
+ uint32_t ipv6_flow; /* flow label */
+ uint16_t ipv6_plen; /* payload length */
+ uint8_t ipv6_nexthdr; /* next header protocol */
+ string ipv6_nextstr; /* next header protocol, as a string */
+ uint8_t ipv6_hlim; /* hop limit */
+ in6_addr_t *ipv6_src; /* source address */
+ in6_addr_t *ipv6_dst; /* destination address */
+ string ipv6_saddr; /* source address, string */
+ string ipv6_daddr; /* destination address, string */
+ ip6_t *ipv6_hdr; /* pointer to raw header */
+} ipv6info_t;
+
+/*
+ * void_ip_t is a void pointer to either an IPv4 or IPv6 header. It has
+ * its own type name so that a translator can be determined.
+ */
+typedef uintptr_t void_ip_t;
+
+/*
+ * __dtrace_ipsr_ill_t is used by the translator to take an ill_t plus an
+ * additional arg6 from the ip:::send and ip:::recieve probes, and translate
+ * them to an ifinfo_t.
+ */
+typedef ill_t __dtrace_ipsr_ill_t;
+
+/*
+ * __dtrace_tcp_void_ip_t is used by the translator to take either the
+ * non-NULL void_ip_t * passed in or, if it is NULL, uses arg3 (tcp_t *)
+ * from the tcp:::send and tcp:::recieve probes to translate to an ipinfo_t.
+ * When no headers are available in the TCP fusion case for tcp:::send
+ * and tcp:::receive case, this allows us to present the consumer with header
+ * data based on the tcp_t * content in order to hide the implementation
+ * details of TCP fusion.
+ */
+typedef void * __dtrace_tcp_void_ip_t;
+
+#pragma D binding "1.5" translator
+translator pktinfo_t < mblk_t *M > {
+ pkt_addr = NULL;
+};
+
+#pragma D binding "1.5" translator
+translator csinfo_t < conn_t *C > {
+ cs_addr = NULL;
+};
+
+#pragma D binding "1.6.3" translator
+translator csinfo_t < ip_xmit_attr_t *C > {
+ cs_addr = (uintptr_t)C;
+ cs_cid = C ? C->ixa_conn_id : NULL;
+ cs_pid = C ? C->ixa_cpid : -1;
+ cs_zoneid = C ?
+ (C->ixa_ipst == NULL || C->ixa_ipst->ips_netstack == NULL ||
+ C->ixa_ipst->ips_netstack->netstack_stackid ==
+ @GLOBAL_NETSTACKID@ ||
+ C->ixa_cred == NULL ||
+ C->ixa_cred->cr_zone == NULL ||
+ C->ixa_cred->cr_uid == -1 ?
+ C->ixa_zoneid : C->ixa_cred->cr_zone->zone_id) : -1;
+};
+
+#pragma D binding "1.5" translator
+translator ipinfo_t < ipha_t *I > {
+ ip_ver = I->ipha_version_and_hdr_length >> 4;
+ ip_plength = ntohs(I->ipha_length) -
+ ((I->ipha_version_and_hdr_length & 0xf) << 2);
+ ip_saddr = inet_ntoa(&I->ipha_src);
+ ip_daddr = inet_ntoa(&I->ipha_dst);
+};
+
+#pragma D binding "1.5" translator
+translator ipinfo_t < ip6_t *I > {
+ ip_ver = *(uint8_t *)I >> 4;
+ ip_plength = ntohs(I->ip6_ctlun.ip6_un1.ip6_un1_plen);
+ ip_saddr = inet_ntoa6(&I->ip6_src);
+ ip_daddr = inet_ntoa6(&I->ip6_dst);
+};
+
+#pragma D binding "1.5" translator
+translator ipinfo_t < void_ip_t *I > {
+ ip_ver = I != NULL ? *(uint8_t *)I >> 4 : 0;
+ ip_plength = I != NULL ? (*(uint8_t *)I >> 4 == 4 ?
+ ntohs(((ipha_t *)I)->ipha_length) -
+ ((((ipha_t *)I)->ipha_version_and_hdr_length & 0xf) << 2) :
+ *(uint8_t *)I >> 4 == 6 ?
+ ntohs(((ip6_t *)I)->ip6_ctlun.ip6_un1.ip6_un1_plen) : 0) : 0;
+ ip_saddr = I != NULL ? (*(uint8_t *)I >> 4 == 4 ?
+ inet_ntoa(&((ipha_t *)I)->ipha_src) : *(uint8_t *)I >> 4 == 6 ?
+ inet_ntoa6(&((ip6_t *)I)->ip6_src) : "<unknown>") : "<unknown>";
+ ip_daddr = I != NULL ? (*(uint8_t *)I >> 4 == 4 ?
+ inet_ntoa(&((ipha_t *)I)->ipha_dst) : *(uint8_t *)I >> 4 == 6 ?
+ inet_ntoa6(&((ip6_t *)I)->ip6_dst) : "<unknown>") : "<unknown>";
+};
+
+#pragma D binding "1.5" translator
+translator ifinfo_t < __dtrace_ipsr_ill_t *I > {
+ if_name = I != NULL ? stringof(I->ill_name) : "<null>";
+ if_ipstack = I != NULL ? I->ill_ipst->ips_netstack->netstack_stackid
+ : 0;
+ if_local = arg6; /* probe dependent */
+ if_addr = (uintptr_t)I;
+};
+
+/*
+ * Translate to an ipinfo_t * from either the non-NULL void_ip_t * passed in,
+ * or use arg3 (tcp_t *) to fabricate ip header info.
+ */
+#pragma D binding "1.6.3" translator
+translator ipinfo_t < __dtrace_tcp_void_ip_t *I > {
+ ip_ver = I != NULL ? *(uint8_t *)I >> 4 :
+ arg3 != NULL ? ((tcp_t *)arg3)->tcp_connp->conn_ipversion : 0;
+ ip_plength =
+ I != NULL && *(uint8_t *)I >> 4 == 4 ?
+ ntohs(((ipha_t *)I)->ipha_length) -
+ ((((ipha_t *)I)->ipha_version_and_hdr_length & 0xf) << 2) :
+ I != NULL && *(uint8_t *)I >> 4 == 6 ?
+ ntohs(((ip6_t *)I)->ip6_ctlun.ip6_un1.ip6_un1_plen) :
+ I != NULL ? 0 :
+ arg3 != NULL && probename == "send" ?
+ ((tcp_t *)arg3)->tcp_last_sent_len + @TCP_MIN_HEADER_LENGTH@ :
+ arg3 != NULL && probename == "receive" ?
+ ((tcp_t *)arg3)->tcp_last_recv_len + @TCP_MIN_HEADER_LENGTH@ :
+ 0;
+ ip_saddr =
+ I != NULL && *(uint8_t *)I >> 4 == 4 ?
+ inet_ntoa(&((ipha_t *)I)->ipha_src) :
+ I != NULL && *(uint8_t *)I >> 4 == 6 ?
+ inet_ntoa6(&((ip6_t *)I)->ip6_src) :
+ I != NULL ? "<unknown>" :
+ arg3 != NULL && probename == "send" ?
+ inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_laddr):
+ arg3 != NULL && probename == "receive" ?
+ inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_faddr):
+ "<unknown>";
+ ip_daddr =
+ I != NULL && *(uint8_t *)I >> 4 == 4 ?
+ inet_ntoa(&((ipha_t *)I)->ipha_dst) :
+ I != NULL && *(uint8_t *)I >> 4 == 6 ?
+ inet_ntoa6(&((ip6_t *)I)->ip6_dst) :
+ I != NULL ? "<unknown>" :
+ arg3 != NULL && probename == "send" ?
+ inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_faddr):
+ arg3 != NULL && probename == "receive" ?
+ inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_laddr):
+ "<unknown>";
+};
+
+#pragma D binding "1.5" translator
+translator ipv4info_t < ipha_t *I > {
+ ipv4_ver = I != NULL ? I->ipha_version_and_hdr_length >> 4 : 0;
+ ipv4_ihl = I != NULL ? (I->ipha_version_and_hdr_length & 0xf) << 2 : 0;
+ ipv4_tos = I != NULL ? I->ipha_type_of_service : 0;
+ ipv4_length = I != NULL ? ntohs(I->ipha_length) : 0;
+ ipv4_ident = I != NULL ? ntohs(I->ipha_ident) : 0;
+ ipv4_flags = I != NULL ? ntohs(I->ipha_fragment_offset_and_flags) >>
+ 12 : 0;
+ ipv4_offset = I != NULL ? ntohs(I->ipha_fragment_offset_and_flags) &
+ 0x0fff : 0;
+ ipv4_ttl = I != NULL ? I->ipha_ttl : 0;
+ ipv4_protocol = I != NULL ? I->ipha_protocol : 0;
+ ipv4_protostr = I == NULL ? "<null>" :
+ I->ipha_protocol == IPPROTO_TCP ? "TCP" :
+ I->ipha_protocol == IPPROTO_UDP ? "UDP" :
+ I->ipha_protocol == IPPROTO_IP ? "IP" :
+ I->ipha_protocol == IPPROTO_ICMP ? "ICMP" :
+ I->ipha_protocol == IPPROTO_IGMP ? "IGMP" :
+ I->ipha_protocol == IPPROTO_EGP ? "EGP" :
+ I->ipha_protocol == IPPROTO_IPV6 ? "IPv6" :
+ I->ipha_protocol == IPPROTO_ROUTING ? "ROUTE" :
+ I->ipha_protocol == IPPROTO_ESP ? "ESP" :
+ I->ipha_protocol == IPPROTO_AH ? "AH" :
+ I->ipha_protocol == IPPROTO_ICMPV6 ? "ICMPv6" :
+ I->ipha_protocol == IPPROTO_OSPF ? "OSPF" :
+ I->ipha_protocol == IPPROTO_SCTP ? "SCTP" :
+ I->ipha_protocol == IPPROTO_RAW ? "RAW" :
+ lltostr((uint64_t)I->ipha_protocol);
+ ipv4_checksum = I != NULL ? ntohs(I->ipha_hdr_checksum) : 0;
+ ipv4_src = I != NULL ? I->ipha_src : 0;
+ ipv4_dst = I != NULL ? I->ipha_dst : 0;
+ ipv4_saddr = I != NULL ? inet_ntoa(&I->ipha_src) : "<null>";
+ ipv4_daddr = I != NULL ? inet_ntoa(&I->ipha_dst) : "<null>";
+ ipv4_hdr = I;
+};
+
+#pragma D binding "1.5" translator
+translator ipv6info_t < ip6_t *I > {
+ ipv6_ver = I != NULL ? I->ip6_ctlun.ip6_un2_vfc >> 4 : 0;
+ ipv6_tclass = I != NULL ? ((I->ip6_ctlun.ip6_un1.ip6_un1_flow &&
+ 0x0fffffff) >> 20) : 0;
+ ipv6_flow = I != NULL ? I->ip6_ctlun.ip6_un1.ip6_un1_flow &&
+ 0x000fffff : 0;
+ ipv6_plen = I != NULL ? ntohs(I->ip6_ctlun.ip6_un1.ip6_un1_plen) : 0;
+ ipv6_nexthdr = I != NULL ? I->ip6_ctlun.ip6_un1.ip6_un1_nxt : 0;
+ ipv6_nextstr = I == NULL ? "<null>" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_TCP ? "TCP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_UDP ? "UDP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_IP ? "IP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ICMP ? "ICMP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_IGMP ? "IGMP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_EGP ? "EGP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_IPV6 ? "IPv6" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ROUTING ? "ROUTE" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ESP ? "ESP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_AH ? "AH" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ICMPV6 ? "ICMPv6" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_OSPF ? "OSPF" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_SCTP ? "SCTP" :
+ I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_RAW ? "RAW" :
+ lltostr((uint64_t)I->ip6_ctlun.ip6_un1.ip6_un1_nxt);
+ ipv6_hlim = I != NULL ? I->ip6_ctlun.ip6_un1.ip6_un1_hlim : 0;
+ ipv6_src = I != NULL ? &I->ip6_src : 0;
+ ipv6_dst = I != NULL ? &I->ip6_dst : 0;
+ ipv6_saddr = I != NULL ? inet_ntoa6(&I->ip6_src) : "<null>";
+ ipv6_daddr = I != NULL ? inet_ntoa6(&I->ip6_dst) : "<null>";
+ ipv6_hdr = I;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.sed.in
new file mode 100644
index 00000000..5d514e36
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/ip.sed.in
@@ -0,0 +1,78 @@
+/*
+ * 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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * This file is a sed script which is first preprocessed by cpp or cc -E to
+ * define a set of sed directives which replace #define tokens with their
+ * values. After preprocessing, the sed script is run over ip.d.in to
+ * replace the #define tokens listed below to create the finished ip.d.
+ * Refer to the rules in libdtrace/Makefile.com for more information.
+ */
+
+#include <sys/netstack.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <inet/ip.h>
+#include <inet/tcp.h>
+
+#define SED_REPLACE(x) s/#x/x/g
+
+SED_REPLACE(AF_INET)
+SED_REPLACE(AF_INET6)
+
+SED_REPLACE(IPH_DF)
+SED_REPLACE(IPH_MF)
+
+SED_REPLACE(IPPROTO_IP)
+SED_REPLACE(IPPROTO_HOPOPTS)
+SED_REPLACE(IPPROTO_ICMP)
+SED_REPLACE(IPPROTO_IGMP)
+SED_REPLACE(IPPROTO_GGP)
+SED_REPLACE(IPPROTO_ENCAP)
+SED_REPLACE(IPPROTO_TCP)
+SED_REPLACE(IPPROTO_EGP)
+SED_REPLACE(IPPROTO_PUP)
+SED_REPLACE(IPPROTO_UDP)
+SED_REPLACE(IPPROTO_IDP)
+SED_REPLACE(IPPROTO_IPV6)
+SED_REPLACE(IPPROTO_ROUTING)
+SED_REPLACE(IPPROTO_FRAGMENT)
+SED_REPLACE(IPPROTO_RSVP)
+SED_REPLACE(IPPROTO_ESP)
+SED_REPLACE(IPPROTO_AH)
+SED_REPLACE(IPPROTO_ICMPV6)
+SED_REPLACE(IPPROTO_NONE)
+SED_REPLACE(IPPROTO_DSTOPTS)
+SED_REPLACE(IPPROTO_HELLO)
+SED_REPLACE(IPPROTO_ND)
+SED_REPLACE(IPPROTO_EON)
+SED_REPLACE(IPPROTO_OSPF)
+SED_REPLACE(IPPROTO_PIM)
+SED_REPLACE(IPPROTO_SCTP)
+SED_REPLACE(IPPROTO_RAW)
+SED_REPLACE(IPPROTO_MAX)
+
+SED_REPLACE(TCP_MIN_HEADER_LENGTH)
+
+SED_REPLACE(GLOBAL_NETSTACKID)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/iscsit.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/iscsit.d
new file mode 100644
index 00000000..fba5e20e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/iscsit.d
@@ -0,0 +1,454 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D depends_on library ip.d
+#pragma D depends_on library net.d /* conninfo_t */
+#pragma D depends_on library scsi.d /* scsicmd_t and iscsiinfo_t */
+#pragma D depends_on module genunix
+#pragma D depends_on module iscsit
+#pragma D depends_on module idm
+
+#pragma D binding "1.5" translator
+translator conninfo_t < idm_conn_t *P > {
+ ci_local = (P->ic_laddr.ss_family == AF_INET) ?
+ inet_ntoa((ipaddr_t *)
+ &((struct sockaddr_in *)&P->ic_laddr)->sin_addr) :
+ inet_ntoa6(&((struct sockaddr_in6 *)&P->ic_laddr)->sin6_addr);
+
+ ci_remote = (P->ic_raddr.ss_family == AF_INET) ?
+ inet_ntoa((ipaddr_t *)
+ &((struct sockaddr_in *)&P->ic_raddr)->sin_addr) :
+ inet_ntoa6(&((struct sockaddr_in6 *)&P->ic_raddr)->sin6_addr);
+
+ ci_protocol = (P->ic_laddr.ss_family == AF_INET) ? "ipv4" : "ipv6";
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_async_evt_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = (((uint64_t)P->lun[0] << (64 - 0*8 - 8)) +
+ ((uint64_t)P->lun[1] << (64 - 1*8 - 8)) +
+ ((uint64_t)P->lun[2] << (64 - 2*8 - 8)) +
+ ((uint64_t)P->lun[3] << (64 - 3*8 - 8)) +
+ ((uint64_t)P->lun[4] << (64 - 4*8 - 8)) +
+ ((uint64_t)P->lun[5] << (64 - 5*8 - 8)) +
+ ((uint64_t)P->lun[6] << (64 - 6*8 - 8)) +
+ ((uint64_t)P->lun[7] << (64 - 7*8 - 8)));
+ ii_itt = 0;
+ ii_ttt = 0;
+ ii_cmdsn = 0;
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_login_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = 0xffffffff;
+ ii_cmdsn = ntohl(P->cmdsn);
+ ii_statsn = ntohl(P->expstatsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_login_rsp_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = 0xffffffff;
+ ii_cmdsn = ntohl(P->expcmdsn);
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_logout_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = 0xffffffff;
+ ii_cmdsn = ntohl(P->cmdsn);
+ ii_statsn = ntohl(P->expstatsn);
+ ii_datasn = 0;
+ ii_datalen = 0;
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_logout_rsp_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = 0xffffffff;
+ ii_cmdsn = 0;
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = 0;
+ ii_datalen = 0;
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_rtt_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->ttt);
+ ii_cmdsn = ntohl(P->expcmdsn);
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = ntohl(P->rttsn);
+ ii_datalen = 0;
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_data_rsp_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = (((uint64_t)P->lun[0] << (64 - 0*8 - 8)) +
+ ((uint64_t)P->lun[1] << (64 - 1*8 - 8)) +
+ ((uint64_t)P->lun[2] << (64 - 2*8 - 8)) +
+ ((uint64_t)P->lun[3] << (64 - 3*8 - 8)) +
+ ((uint64_t)P->lun[4] << (64 - 4*8 - 8)) +
+ ((uint64_t)P->lun[5] << (64 - 5*8 - 8)) +
+ ((uint64_t)P->lun[6] << (64 - 6*8 - 8)) +
+ ((uint64_t)P->lun[7] << (64 - 7*8 - 8)));
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->ttt);
+ ii_cmdsn = ntohl(P->expcmdsn);
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = ntohl(P->datasn);
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_data_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = (((uint64_t)P->lun[0] << (64 - 0*8 - 8)) +
+ ((uint64_t)P->lun[1] << (64 - 1*8 - 8)) +
+ ((uint64_t)P->lun[2] << (64 - 2*8 - 8)) +
+ ((uint64_t)P->lun[3] << (64 - 3*8 - 8)) +
+ ((uint64_t)P->lun[4] << (64 - 4*8 - 8)) +
+ ((uint64_t)P->lun[5] << (64 - 5*8 - 8)) +
+ ((uint64_t)P->lun[6] << (64 - 6*8 - 8)) +
+ ((uint64_t)P->lun[7] << (64 - 7*8 - 8)));
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->ttt);
+ ii_cmdsn = 0;
+ ii_statsn = ntohl(P->expstatsn);
+ ii_datasn = ntohl(P->datasn);
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_nop_in_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = (((uint64_t)P->lun[0] << (64 - 0*8 - 8)) +
+ ((uint64_t)P->lun[1] << (64 - 1*8 - 8)) +
+ ((uint64_t)P->lun[2] << (64 - 2*8 - 8)) +
+ ((uint64_t)P->lun[3] << (64 - 3*8 - 8)) +
+ ((uint64_t)P->lun[4] << (64 - 4*8 - 8)) +
+ ((uint64_t)P->lun[5] << (64 - 5*8 - 8)) +
+ ((uint64_t)P->lun[6] << (64 - 6*8 - 8)) +
+ ((uint64_t)P->lun[7] << (64 - 7*8 - 8)));
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->ttt);
+ ii_cmdsn = ntohl(P->expcmdsn);
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_nop_out_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = (((uint64_t)P->lun[0] << (64 - 0*8 - 8)) +
+ ((uint64_t)P->lun[1] << (64 - 1*8 - 8)) +
+ ((uint64_t)P->lun[2] << (64 - 2*8 - 8)) +
+ ((uint64_t)P->lun[3] << (64 - 3*8 - 8)) +
+ ((uint64_t)P->lun[4] << (64 - 4*8 - 8)) +
+ ((uint64_t)P->lun[5] << (64 - 5*8 - 8)) +
+ ((uint64_t)P->lun[6] << (64 - 6*8 - 8)) +
+ ((uint64_t)P->lun[7] << (64 - 7*8 - 8)));
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->ttt);
+ ii_cmdsn = ntohl(P->cmdsn);
+ ii_statsn = ntohl(P->expstatsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_scsi_cmd_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = (((uint64_t)P->lun[0] << (64 - 0*8 - 8)) +
+ ((uint64_t)P->lun[1] << (64 - 1*8 - 8)) +
+ ((uint64_t)P->lun[2] << (64 - 2*8 - 8)) +
+ ((uint64_t)P->lun[3] << (64 - 3*8 - 8)) +
+ ((uint64_t)P->lun[4] << (64 - 4*8 - 8)) +
+ ((uint64_t)P->lun[5] << (64 - 5*8 - 8)) +
+ ((uint64_t)P->lun[6] << (64 - 6*8 - 8)) +
+ ((uint64_t)P->lun[7] << (64 - 7*8 - 8)));
+ ii_itt = ntohl(P->itt);
+ ii_ttt = 0xffffffff;
+ ii_cmdsn = ntohl(P->cmdsn);
+ ii_statsn = ntohl(P->expstatsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_scsi_rsp_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = 0xffffffff;
+ ii_cmdsn = ntohl(P->expcmdsn);
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = ntohl(P->expdatasn);
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_scsi_task_mgt_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = (((uint64_t)P->lun[0] << (64 - 0*8 - 8)) +
+ ((uint64_t)P->lun[1] << (64 - 1*8 - 8)) +
+ ((uint64_t)P->lun[2] << (64 - 2*8 - 8)) +
+ ((uint64_t)P->lun[3] << (64 - 3*8 - 8)) +
+ ((uint64_t)P->lun[4] << (64 - 4*8 - 8)) +
+ ((uint64_t)P->lun[5] << (64 - 5*8 - 8)) +
+ ((uint64_t)P->lun[6] << (64 - 6*8 - 8)) +
+ ((uint64_t)P->lun[7] << (64 - 7*8 - 8)));
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->rtt);
+ ii_cmdsn = ntohl(P->cmdsn);
+ ii_statsn = ntohl(P->expstatsn);
+ ii_datasn = 0;
+ ii_datalen = 0;
+ ii_flags = 0;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_scsi_task_mgt_rsp_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->rtt);
+ ii_cmdsn = ntohl(P->expcmdsn);
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_text_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->ttt);
+ ii_cmdsn = ntohl(P->cmdsn);
+ ii_statsn = ntohl(P->expstatsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < iscsi_text_rsp_hdr_t *P > {
+ ii_initiator = ((idm_conn_t *)arg0)->ic_initiator_name;
+ ii_target = ((idm_conn_t *)arg0)->ic_target_name;
+ ii_isid = ((idm_conn_t *)arg0)->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (((idm_conn_t *)arg0)->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0; /* NA */
+ ii_itt = ntohl(P->itt);
+ ii_ttt = ntohl(P->ttt);
+ ii_cmdsn = ntohl(P->expcmdsn);
+ ii_statsn = ntohl(P->statsn);
+ ii_datasn = 0;
+ ii_datalen = P->dlength[0] << 16 | P->dlength[1] << 8 | P->dlength[2];
+ ii_flags = P->flags;
+};
+
+#pragma D binding "1.5" translator
+translator iscsiinfo_t < idm_conn_t *P > {
+ ii_initiator = P->ic_initiator_name;
+ ii_target = P->ic_target_name;
+ ii_isid = P->ic_isid;
+ ii_tsih = ((idm_conn_t *)arg0)->ic_tsih;
+ ii_transport = (P->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_ISER) ? "iser-ib" :
+ (P->ic_transport_type ==
+ IDM_TRANSPORT_TYPE_SOCKETS) ? "sockets" : "Unknown";
+ ii_lun = 0;
+ ii_itt = 0;
+ ii_ttt = 0;
+ ii_cmdsn = 0;
+ ii_statsn = 0;
+ ii_datasn = 0;
+ ii_datalen = 0;
+ ii_flags = 0;
+};
+
+#pragma D binding "1.5" translator
+translator xferinfo_t < uintptr_t P > {
+ xfer_laddr = (arg1 == NULL) ? 0xffffffff : (uintptr_t)arg1;
+ xfer_loffset = arg2;
+ xfer_lkey = 0; /* not used */
+ xfer_len = arg6;
+ xfer_raddr = arg3;
+ xfer_roffset = arg4;
+ xfer_rkey = arg5;
+ xfer_type = arg7;
+};
+
+inline int IDM_TRANSPORT_TYPE_ISER = 0;
+#pragma D binding "1.5" IDM_TRANSPORT_TYPE_ISER
+inline int IDM_TRANSPORT_TYPE_SOCKETS = 1;
+#pragma D binding "1.5" IDM_TRANSPORT_TYPE_SOCKETS
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/llib-ldtrace b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/llib-ldtrace
new file mode 100644
index 00000000..313e78c5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/llib-ldtrace
@@ -0,0 +1,32 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include <dtrace.h>
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mapfile-vers b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mapfile-vers
new file mode 100644
index 00000000..c46ac0ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mapfile-vers
@@ -0,0 +1,127 @@
+#
+# 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) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION SUNWprivate_1.1 {
+ global:
+ dtrace_addr2str;
+ dtrace_aggregate_clear;
+ dtrace_aggregate_print;
+ dtrace_aggregate_snap;
+ dtrace_aggregate_walk;
+ dtrace_aggregate_walk_joined;
+ dtrace_aggregate_walk_keyrevsorted;
+ dtrace_aggregate_walk_keysorted;
+ dtrace_aggregate_walk_keyvarrevsorted;
+ dtrace_aggregate_walk_keyvarsorted;
+ dtrace_aggregate_walk_valrevsorted;
+ dtrace_aggregate_walk_valsorted;
+ dtrace_aggregate_walk_valvarrevsorted;
+ dtrace_aggregate_walk_valvarsorted;
+ dtrace_attr2str;
+ dtrace_class_name;
+ dtrace_close;
+ dtrace_consume;
+ dtrace_ctlfd;
+ _dtrace_debug;
+ dtrace_desc2str;
+ dtrace_dof_create;
+ dtrace_dof_destroy;
+ dtrace_errmsg;
+ dtrace_errno;
+ dtrace_faultstr;
+ dtrace_fprinta;
+ dtrace_fprintf;
+ dtrace_geterr_dof;
+ dtrace_getopt;
+ dtrace_getopt_dof;
+ dtrace_go;
+ dtrace_handle_buffered;
+ dtrace_handle_drop;
+ dtrace_handle_err;
+ dtrace_handle_proc;
+ dtrace_handle_setopt;
+ dtrace_id2desc;
+ dtrace_lookup_by_addr;
+ dtrace_lookup_by_name;
+ dtrace_lookup_by_type;
+ dtrace_object_info;
+ dtrace_object_iter;
+ dtrace_open;
+ dtrace_printa_create;
+ dtrace_printf_create;
+ dtrace_printf_format;
+ dtrace_probe_info;
+ dtrace_probe_iter;
+ dtrace_proc_continue;
+ dtrace_proc_create;
+ dtrace_proc_grab;
+ dtrace_proc_release;
+ dtrace_program_exec;
+ dtrace_program_fcompile;
+ dtrace_program_header;
+ dtrace_program_info;
+ dtrace_program_link;
+ dtrace_program_strcompile;
+ dtrace_provider_modules;
+ dtrace_setopt;
+ dtrace_sleep;
+ dtrace_stability_name;
+ dtrace_status;
+ dtrace_stmt_action;
+ dtrace_stmt_add;
+ dtrace_stmt_create;
+ dtrace_stmt_destroy;
+ dtrace_stmt_iter;
+ dtrace_stop;
+ dtrace_str2attr;
+ dtrace_str2desc;
+ dtrace_subrstr;
+ dtrace_symbol_type;
+ dtrace_type_fcompile;
+ dtrace_type_strcompile;
+ dtrace_uaddr2str;
+ dtrace_update;
+ _dtrace_version;
+ dtrace_vopen;
+ dtrace_work;
+ dtrace_xstr2desc;
+ local:
+ *;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrno.sh b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrno.sh
new file mode 100755
index 00000000..50b7f1c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrno.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+echo "\
+/*\n\
+ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n\
+ * Use is subject to license terms.\n\
+ */\n\
+\n\
+#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n"
+
+pattern='^#define[ ]\(E[A-Z0-9]*\)[ ]*\([A-Z0-9]*\).*$'
+replace='inline int \1 = \2;@#pragma D binding "1.0" \1'
+
+sed -n "s/$pattern/$replace/p" | tr '@' '\n'
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sed b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sed
new file mode 100644
index 00000000..2da2290d
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sed
@@ -0,0 +1,33 @@
+#$Id: mkerrtags.sed $
+## @file
+# pure sed version of mkerrtags.sh.
+#
+
+1b heading
+$b footer
+s/^[[:space:]][[:space:]]*\(D_[A-Z0-9_]*\)\(,*\).*$/ "\1"\2/p
+b end
+
+
+:heading
+i\/* Autogenerated source file - DO NOT EDIT! */
+i\/*
+i\ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+i\ * Use is subject to license terms.
+i\ */
+i\#include <dt_errtags.h>
+i\static const char * const _dt_errtags[] = {
+b end
+
+:footer
+i\};
+i\const char *dt_errtag(dt_errtag_t tag)
+i\{
+i\ if ((unsigned)tag >= sizeof(_dt_errtags)/sizeof(_dt_errtags[0]))
+i\ return _dt_errtags[0];
+i\ return _dt_errtags[tag];
+i\}
+b end
+
+
+:end
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sh b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sh
new file mode 100644
index 00000000..5263fb68
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mkerrtags.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env kmk_ash
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+
+echo "\
+/*\n\
+ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n\
+ * Use is subject to license terms.\n\
+ */\n\
+\n\
+#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n\
+\n\
+#include <dt_errtags.h>
+\n\
+static const char *const _dt_errtags[] = {"
+
+# WARNING: Tabs in expressions.
+#pattern='^ \(D_[A-Z0-9_]*\),*'
+#replace=' "\1",'
+#
+#sed -n "s/$pattern/$replace/p" || exit 1
+set -x
+kmk_sed --lang_c -n 's/^[[:space:]]*\(D_[A-Z0-9_]*\),*/ "\1",/p' $1 || exit 1
+
+echo "\
+};\n\
+\n\
+static const int _dt_ntag = sizeof (_dt_errtags) / sizeof (_dt_errtags[0]);\n\
+\n\
+const char *
+dt_errtag(dt_errtag_t tag)
+{
+ return (_dt_errtags[(tag > 0 && tag < _dt_ntag) ? tag : 0]);
+}"
+
+exit 0
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sed b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sed
new file mode 100644
index 00000000..275b4fb2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sed
@@ -0,0 +1,38 @@
+#$Id: mknames.sed $
+## @file
+# pure sed version of mknames.sh.
+#
+
+1b heading
+$b footer
+/DIF_SUBR_MAX/b end
+s/^#[[:space:]]*define[[:space:]][[:space:]]*\(DIF_SUBR_[a-zA-Z0-9_]*\).*$/ case \1: \
+ return "\L\1";/p
+b end
+
+:heading
+i\/* Autogenerated source file - DO NOT EDIT! */
+i\/*
+i\ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+i\ * Use is subject to license terms.
+i\ */
+i\#include <dtrace.h>
+i\const char *dtrace_subrstr(dtrace_hdl_t *dtp, int subr)
+i\{
+i\ (void)dtp;
+i\ switch (subr)
+i\ {
+b end
+
+:footer
+i\ default:
+i\ return "unknown";
+i\ }
+i\}
+b end
+
+
+
+
+:end
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sh b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sh
new file mode 100755
index 00000000..7f90b7dd
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mknames.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+echo "\
+/*\n\
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.\n\
+ * Use is subject to license terms.\n\
+ */\n\
+\n\
+#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n\
+\n\
+#include <dtrace.h>\n\
+\n\
+/*ARGSUSED*/
+const char *\n\
+dtrace_subrstr(dtrace_hdl_t *dtp, int subr)\n\
+{\n\
+ switch (subr) {"
+
+nawk '
+/^#define[ ]*DIF_SUBR_/ && $2 != "DIF_SUBR_MAX" {
+ printf("\tcase %s: return (\"%s\");\n", $2, tolower(substr($2, 10)));
+}'
+
+echo "\
+ default: return (\"unknown\");\n\
+ }\n\
+}"
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mksignal.sh b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mksignal.sh
new file mode 100755
index 00000000..1bffa646
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/mksignal.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+echo "\
+/*\n\
+ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n\
+ * Use is subject to license terms.\n\
+ */\n\
+\n\
+#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n"
+
+pattern='^#define[ ]*_*\(SIG[A-Z0-9]*\)[ ]\{1,\}\([A-Z0-9]*\).*$'
+replace='inline int \1 = \2;@#pragma D binding "1.0" \1'
+
+sed -n "s/$pattern/$replace/p;/SIGRTMAX/q" | tr '@' '\n'
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.d.in
new file mode 100644
index 00000000..be7343ac
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.d.in
@@ -0,0 +1,44 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+inline int AF_INET = @AF_INET@;
+#pragma D binding "1.0" AF_INET
+inline int AF_INET6 = @AF_INET6@;
+#pragma D binding "1.0" AF_INET6
+
+/*
+ * The conninfo_t structure should be used by all application protocol
+ * providers as the first arguments to indicate some basic information
+ * about the connection. This structure may be augmented to accomodate
+ * the particularities of additional protocols in the future.
+ */
+typedef struct conninfo {
+ string ci_local; /* local host address */
+ string ci_remote; /* remote host address */
+ string ci_protocol; /* protocol (ipv4, ipv6, etc) */
+} conninfo_t;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.sed.in
new file mode 100644
index 00000000..68c6e1c7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/net.sed.in
@@ -0,0 +1,41 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * This file is a sed script which is first preprocessed by cpp or cc -E to
+ * define a set of sed directives which replace #define tokens with their
+ * values. After preprocessing, the sed script is run over net.d.in to
+ * replace the #define tokens listed below to create the finished net.d.
+ * Refer to the rules in libdtrace/Makefile.com for more information.
+ */
+
+#include <sys/socket.h>
+
+#define SED_REPLACE(x) s/#x/x/g
+
+SED_REPLACE(AF_INET)
+SED_REPLACE(AF_INET6)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/nfs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/nfs.d
new file mode 100644
index 00000000..c1552fdc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/nfs.d
@@ -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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D depends_on library ip.d
+#pragma D depends_on library net.d
+#pragma D depends_on module genunix
+
+inline int T_RDMA = 4;
+#pragma D binding "1.5" T_RDMA
+
+typedef struct nfsv4opinfo {
+ uint64_t noi_xid; /* unique transation ID */
+ cred_t *noi_cred; /* credentials for operation */
+ string noi_curpath; /* current file handle path (if any) */
+} nfsv4opinfo_t;
+
+typedef struct nfsv4cbinfo {
+ string nci_curpath; /* current file handle path (if any) */
+} nfsv4cbinfo_t;
+
+#pragma D binding "1.5" translator
+translator conninfo_t < struct svc_req *P > {
+ ci_protocol = P->rq_xprt->xp_xpc.xpc_type == T_RDMA ? "rdma" :
+ P->rq_xprt->xp_xpc.xpc_netid == "tcp" ? "ipv4" :
+ P->rq_xprt->xp_xpc.xpc_netid == "udp" ? "ipv4" :
+ P->rq_xprt->xp_xpc.xpc_netid == "tcp6" ? "ipv6" :
+ P->rq_xprt->xp_xpc.xpc_netid == "udp6" ? "ipv6" :
+ "<unknown>";
+
+ ci_local = (P->rq_xprt->xp_xpc.xpc_netid == "tcp" ||
+ P->rq_xprt->xp_xpc.xpc_netid == "udp") ?
+ inet_ntoa(&((struct sockaddr_in *)
+ P->rq_xprt->xp_xpc.xpc_lcladdr.buf)->sin_addr.S_un.S_addr) :
+ (P->rq_xprt->xp_xpc.xpc_netid == "tcp6" ||
+ P->rq_xprt->xp_xpc.xpc_netid == "udp6") ?
+ inet_ntoa6(&((struct sockaddr_in6 *)
+ P->rq_xprt->xp_xpc.xpc_lcladdr.buf)->sin6_addr) :
+ "unknown";
+
+ ci_remote = (P->rq_xprt->xp_xpc.xpc_netid == "tcp" ||
+ P->rq_xprt->xp_xpc.xpc_netid == "udp") ?
+ inet_ntoa(&((struct sockaddr_in *)
+ P->rq_xprt->xp_xpc.xpc_rtaddr.buf)->sin_addr.S_un.S_addr) :
+ (P->rq_xprt->xp_xpc.xpc_netid == "tcp6" ||
+ P->rq_xprt->xp_xpc.xpc_netid == "udp6") ?
+ inet_ntoa6(&((struct sockaddr_in6 *)
+ P->rq_xprt->xp_xpc.xpc_rtaddr.buf)->sin6_addr) :
+ "unknown";
+};
+
+#pragma D binding "1.5" translator
+translator conninfo_t < struct compound_state *P > {
+ ci_protocol = P->req->rq_xprt->xp_xpc.xpc_type == T_RDMA ? "rdma" :
+ P->req->rq_xprt->xp_xpc.xpc_netid == "tcp" ? "ipv4" :
+ P->req->rq_xprt->xp_xpc.xpc_netid == "tcp6" ? "ipv6" :
+ "<unknown>";
+
+ ci_local = (P->req->rq_xprt->xp_xpc.xpc_netid == "tcp") ?
+ inet_ntoa(&((struct sockaddr_in *)
+ P->req->rq_xprt->xp_xpc.xpc_lcladdr.buf)->sin_addr.S_un.S_addr) :
+ (P->req->rq_xprt->xp_xpc.xpc_netid == "tcp6") ?
+ inet_ntoa6(&((struct sockaddr_in6 *)
+ P->req->rq_xprt->xp_xpc.xpc_lcladdr.buf)->sin6_addr) :
+ "unknown";
+
+ ci_remote = (P->req->rq_xprt->xp_xpc.xpc_netid == "tcp") ?
+ inet_ntoa(&((struct sockaddr_in *)
+ P->req->rq_xprt->xp_xpc.xpc_rtaddr.buf)->sin_addr.S_un.S_addr) :
+ (P->req->rq_xprt->xp_xpc.xpc_netid == "tcp6") ?
+ inet_ntoa6(&((struct sockaddr_in6 *)
+ P->req->rq_xprt->xp_xpc.xpc_rtaddr.buf)->sin6_addr) :
+ "unknown";
+
+};
+
+#pragma D binding "1.5" translator
+translator nfsv4opinfo_t < struct compound_state *P > {
+ noi_xid = P->req->rq_xprt->xp_xid;
+ noi_cred = P->basecr;
+ noi_curpath = (P->vp == NULL) ? "<unknown>" : P->vp->v_path;
+};
+
+#pragma D binding "1.5" translator
+translator conninfo_t < rfs4_client_t *P > {
+ ci_protocol = (P->rc_addr.ss_family == AF_INET) ? "ipv4" : "ipv6";
+
+ ci_local = "<unknown>";
+
+ ci_remote = (P->rc_addr.ss_family == AF_INET) ?
+ inet_ntoa((ipaddr_t *)
+ &((struct sockaddr_in *)&P->rc_addr)->sin_addr) :
+ inet_ntoa6(&((struct sockaddr_in6 *)&P->rc_addr)->sin6_addr);
+};
+
+#pragma D binding "1.5" translator
+translator nfsv4cbinfo_t < rfs4_deleg_state_t *P > {
+ nci_curpath = (P->rds_finfo->rf_vp == NULL) ? "<unknown>" :
+ P->rds_finfo->rf_vp->v_path;
+};
+
+typedef struct nfsv3opinfo {
+ uint64_t noi_xid; /* unique transation ID */
+ cred_t *noi_cred; /* credentials for operation */
+ string noi_curpath; /* current file handle path (if any) */
+} nfsv3opinfo_t;
+
+typedef struct nfsv3oparg nfsv3oparg_t;
+
+#pragma D binding "1.5" translator
+translator nfsv3opinfo_t < nfsv3oparg_t *P > {
+ noi_xid = ((struct svc_req *)arg0)->rq_xprt->xp_xid;
+ noi_cred = (cred_t *)arg1;
+ noi_curpath = (arg2 == 0 || ((vnode_t *)arg2)->v_path == NULL) ?
+ "<unknown>" : ((vnode_t *)arg2)->v_path;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.d.in
new file mode 100644
index 00000000..9381e1ec
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.d.in
@@ -0,0 +1,365 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * This file defines the standard set of inlines and translators to be made
+ * available for all D programs to use to examine process model state.
+ */
+
+#pragma D depends_on module procfs
+
+/*
+ * The following miscellaneous constants are used by the proc(4) translators
+ * defined below. These are assigned the latest values from the system .h's.
+ */
+inline char SSLEEP = @SSLEEP@;
+#pragma D binding "1.0" SSLEEP
+inline char SRUN = @SRUN@;
+#pragma D binding "1.0" SRUN
+inline char SZOMB = @SZOMB@;
+#pragma D binding "1.0" SZOMB
+inline char SSTOP = @SSTOP@;
+#pragma D binding "1.0" SSTOP
+inline char SIDL = @SIDL@;
+#pragma D binding "1.0" SIDL
+inline char SONPROC = @SONPROC@;
+#pragma D binding "1.0" SONPROC
+inline char SWAIT = @SWAIT@;
+#pragma D binding "1.0" SWAIT
+
+inline int PR_STOPPED = @PR_STOPPED@;
+#pragma D binding "1.0" PR_STOPPED
+inline int PR_ISTOP = @PR_ISTOP@;
+#pragma D binding "1.0" PR_ISTOP
+inline int PR_DSTOP = @PR_DSTOP@;
+#pragma D binding "1.0" PR_DSTOP
+inline int PR_STEP = @PR_STEP@;
+#pragma D binding "1.0" PR_STEP
+inline int PR_ASLEEP = @PR_ASLEEP@;
+#pragma D binding "1.0" PR_ASLEEP
+inline int PR_PCINVAL = @PR_PCINVAL@;
+#pragma D binding "1.0" PR_PCINVAL
+inline int PR_ASLWP = @PR_ASLWP@;
+#pragma D binding "1.0" PR_ASLWP
+inline int PR_AGENT = @PR_AGENT@;
+#pragma D binding "1.0" PR_AGENT
+inline int PR_DETACH = @PR_DETACH@;
+#pragma D binding "1.0" PR_DETACH
+inline int PR_DAEMON = @PR_DAEMON@;
+#pragma D binding "1.0" PR_DAEMON
+inline int PR_IDLE = @PR_IDLE@;
+#pragma D binding "1.4" PR_IDLE
+inline int PR_ISSYS = @PR_ISSYS@;
+#pragma D binding "1.0" PR_ISSYS
+inline int PR_VFORKP = @PR_VFORKP@;
+#pragma D binding "1.0" PR_VFORKP
+inline int PR_ORPHAN = @PR_ORPHAN@;
+#pragma D binding "1.0" PR_ORPHAN
+inline int PR_NOSIGCHLD = @PR_NOSIGCHLD@;
+#pragma D binding "1.4" PR_NOSIGCHLD
+inline int PR_WAITPID = @PR_WAITPID@;
+#pragma D binding "1.4" PR_WAITPID
+inline int PR_FORK = @PR_FORK@;
+#pragma D binding "1.0" PR_FORK
+inline int PR_RLC = @PR_RLC@;
+#pragma D binding "1.0" PR_RLC
+inline int PR_KLC = @PR_KLC@;
+#pragma D binding "1.0" PR_KLC
+inline int PR_ASYNC = @PR_ASYNC@;
+#pragma D binding "1.0" PR_ASYNC
+inline int PR_MSACCT = @PR_MSACCT@;
+#pragma D binding "1.0" PR_MSACCT
+inline int PR_BPTADJ = @PR_BPTADJ@;
+#pragma D binding "1.0" PR_BPTADJ
+inline int PR_PTRACE = @PR_PTRACE@;
+#pragma D binding "1.0" PR_PTRACE
+inline int PR_MSFORK = @PR_MSFORK@;
+#pragma D binding "1.0" PR_MSFORK
+
+inline char PR_MODEL_ILP32 = @PR_MODEL_ILP32@;
+#pragma D binding "1.0" PR_MODEL_ILP32
+inline char PR_MODEL_LP64 = @PR_MODEL_LP64@;
+#pragma D binding "1.0" PR_MODEL_LP64
+
+inline char SOBJ_NONE = @SOBJ_NONE@;
+#pragma D binding "1.0" SOBJ_NONE
+inline char SOBJ_MUTEX = @SOBJ_MUTEX@;
+#pragma D binding "1.0" SOBJ_MUTEX
+inline char SOBJ_RWLOCK = @SOBJ_RWLOCK@;
+#pragma D binding "1.0" SOBJ_RWLOCK
+inline char SOBJ_CV = @SOBJ_CV@;
+#pragma D binding "1.0" SOBJ_CV
+inline char SOBJ_SEMA = @SOBJ_SEMA@;
+#pragma D binding "1.0" SOBJ_SEMA
+inline char SOBJ_USER = @SOBJ_USER@;
+#pragma D binding "1.0" SOBJ_USER
+inline char SOBJ_USER_PI = @SOBJ_USER_PI@;
+#pragma D binding "1.0" SOBJ_USER_PI
+inline char SOBJ_SHUTTLE = @SOBJ_SHUTTLE@;
+#pragma D binding "1.0" SOBJ_SHUTTLE
+
+inline int SI_USER = @SI_USER@;
+#pragma D binding "1.0" SI_USER
+inline int SI_LWP = @SI_LWP@;
+#pragma D binding "1.0" SI_LWP
+inline int SI_QUEUE = @SI_QUEUE@;
+#pragma D binding "1.0" SI_QUEUE
+inline int SI_TIMER = @SI_TIMER@;
+#pragma D binding "1.0" SI_TIMER
+inline int SI_ASYNCIO = @SI_ASYNCIO@;
+#pragma D binding "1.0" SI_ASYNCIO
+inline int SI_MESGQ = @SI_MESGQ@;
+#pragma D binding "1.0" SI_MESGQ
+inline int SI_RCTL = @SI_RCTL@;
+#pragma D binding "1.0" SI_RCTL
+inline int ILL_ILLOPC = @ILL_ILLOPC@;
+#pragma D binding "1.0" ILL_ILLOPC
+inline int ILL_ILLOPN = @ILL_ILLOPN@;
+#pragma D binding "1.0" ILL_ILLOPN
+inline int ILL_ILLADR = @ILL_ILLADR@;
+#pragma D binding "1.0" ILL_ILLADR
+inline int ILL_ILLTRP = @ILL_ILLTRP@;
+#pragma D binding "1.0" ILL_ILLTRP
+inline int ILL_PRVOPC = @ILL_PRVOPC@;
+#pragma D binding "1.0" ILL_PRVOPC
+inline int ILL_PRVREG = @ILL_PRVREG@;
+#pragma D binding "1.0" ILL_PRVREG
+inline int ILL_COPROC = @ILL_COPROC@;
+#pragma D binding "1.0" ILL_COPROC
+inline int ILL_BADSTK = @ILL_BADSTK@;
+#pragma D binding "1.0" ILL_BADSTK
+inline int FPE_INTDIV = @FPE_INTDIV@;
+#pragma D binding "1.0" FPE_INTDIV
+inline int FPE_INTOVF = @FPE_INTOVF@;
+#pragma D binding "1.0" FPE_INTOVF
+inline int FPE_FLTDIV = @FPE_FLTDIV@;
+#pragma D binding "1.0" FPE_FLTDIV
+inline int FPE_FLTOVF = @FPE_FLTOVF@;
+#pragma D binding "1.0" FPE_FLTOVF
+inline int FPE_FLTUND = @FPE_FLTUND@;
+#pragma D binding "1.0" FPE_FLTUND
+inline int FPE_FLTRES = @FPE_FLTRES@;
+#pragma D binding "1.0" FPE_FLTRES
+inline int FPE_FLTINV = @FPE_FLTINV@;
+#pragma D binding "1.0" FPE_FLTINV
+inline int FPE_FLTSUB = @FPE_FLTSUB@;
+#pragma D binding "1.0" FPE_FLTSUB
+inline int SEGV_MAPERR = @SEGV_MAPERR@;
+#pragma D binding "1.0" SEGV_MAPERR
+inline int SEGV_ACCERR = @SEGV_ACCERR@;
+#pragma D binding "1.0" SEGV_ACCERR
+inline int BUS_ADRALN = @BUS_ADRALN@;
+#pragma D binding "1.0" BUS_ADRALN
+inline int BUS_ADRERR = @BUS_ADRERR@;
+#pragma D binding "1.0" BUS_ADRERR
+inline int BUS_OBJERR = @BUS_OBJERR@;
+#pragma D binding "1.0" BUS_OBJERR
+inline int TRAP_BRKPT = @TRAP_BRKPT@;
+#pragma D binding "1.0" TRAP_BRKPT
+inline int TRAP_TRACE = @TRAP_TRACE@;
+#pragma D binding "1.0" TRAP_TRACE
+inline int CLD_EXITED = @CLD_EXITED@;
+#pragma D binding "1.0" CLD_EXITED
+inline int CLD_KILLED = @CLD_KILLED@;
+#pragma D binding "1.0" CLD_KILLED
+inline int CLD_DUMPED = @CLD_DUMPED@;
+#pragma D binding "1.0" CLD_DUMPED
+inline int CLD_TRAPPED = @CLD_TRAPPED@;
+#pragma D binding "1.0" CLD_TRAPPED
+inline int CLD_STOPPED = @CLD_STOPPED@;
+#pragma D binding "1.0" CLD_STOPPED
+inline int CLD_CONTINUED = @CLD_CONTINUED@;
+#pragma D binding "1.0" CLD_CONTINUED
+inline int POLL_IN = @POLL_IN@;
+#pragma D binding "1.0" POLL_IN
+inline int POLL_OUT = @POLL_OUT@;
+#pragma D binding "1.0" POLL_OUT
+inline int POLL_MSG = @POLL_MSG@;
+#pragma D binding "1.0" POLL_MSG
+inline int POLL_ERR = @POLL_ERR@;
+#pragma D binding "1.0" POLL_ERR
+inline int POLL_PRI = @POLL_PRI@;
+#pragma D binding "1.0" POLL_PRI
+inline int POLL_HUP = @POLL_HUP@;
+#pragma D binding "1.0" POLL_HUP
+
+/*
+ * Translate from the kernel's proc_t structure to a proc(4) psinfo_t struct.
+ * We do not provide support for pr_size, pr_rssize, pr_pctcpu, and pr_pctmem.
+ * We also do not fill in pr_lwp (the lwpsinfo_t for the representative LWP)
+ * because we do not have the ability to select and stop any representative.
+ * Also, for the moment, pr_wstat, pr_time, and pr_ctime are not supported,
+ * but these could be supported by DTrace in the future using subroutines.
+ * Note that any member added to this translator should also be added to the
+ * kthread_t-to-psinfo_t translator, below.
+ */
+#pragma D binding "1.0" translator
+translator psinfo_t < proc_t *T > {
+ pr_nlwp = T->p_lwpcnt;
+ pr_pid = T->p_pidp->pid_id;
+ pr_ppid = T->p_ppid;
+ pr_pgid = T->p_pgidp->pid_id;
+ pr_sid = T->p_sessp->s_sidp->pid_id;
+ pr_uid = T->p_cred->cr_ruid;
+ pr_euid = T->p_cred->cr_uid;
+ pr_gid = T->p_cred->cr_rgid;
+ pr_egid = T->p_cred->cr_gid;
+ pr_addr = (uintptr_t)T;
+
+ pr_ttydev = (T->p_sessp->s_vp == NULL) ? (dev_t)-1 :
+ (T->p_sessp->s_dev == `rwsconsdev) ? `uconsdev :
+ (T->p_sessp->s_dev == `rconsdev) ? `uconsdev : T->p_sessp->s_dev;
+
+ pr_start = T->p_user.u_start;
+ pr_fname = T->p_user.u_comm;
+ pr_psargs = T->p_user.u_psargs;
+ pr_argc = T->p_user.u_argc;
+ pr_argv = T->p_user.u_argv;
+ pr_envp = T->p_user.u_envp;
+
+ pr_dmodel = (T->p_model == @DATAMODEL_ILP32@) ?
+ PR_MODEL_ILP32 : PR_MODEL_LP64;
+
+ pr_taskid = T->p_task->tk_tkid;
+ pr_projid = T->p_task->tk_proj->kpj_id;
+ pr_poolid = T->p_pool->pool_id;
+ pr_zoneid = T->p_zone->zone_id;
+ pr_contract = (T->p_ct_process == NULL) ? -1 :
+ T->p_ct_process->conp_contract.ct_id;
+};
+
+/*
+ * Translate from the kernel's kthread_t structure to a proc(4) psinfo_t
+ * struct. Lacking a facility to define one translator only in terms of
+ * another, we explicitly define each member by using the proc_t-to-psinfo_t
+ * translator, above; any members added to that translator should also be
+ * added here. (The only exception to this is pr_start, which -- due to it
+ * being a structure -- cannot be defined in terms of a translator at all.)
+ */
+#pragma D binding "1.0" translator
+translator psinfo_t < kthread_t *T > {
+ pr_nlwp = xlate <psinfo_t> (T->t_procp).pr_nlwp;
+ pr_pid = xlate <psinfo_t> (T->t_procp).pr_pid;
+ pr_ppid = xlate <psinfo_t> (T->t_procp).pr_ppid;
+ pr_pgid = xlate <psinfo_t> (T->t_procp).pr_pgid;
+ pr_sid = xlate <psinfo_t> (T->t_procp).pr_sid;
+ pr_uid = xlate <psinfo_t> (T->t_procp).pr_uid;
+ pr_euid = xlate <psinfo_t> (T->t_procp).pr_euid;
+ pr_gid = xlate <psinfo_t> (T->t_procp).pr_gid;
+ pr_egid = xlate <psinfo_t> (T->t_procp).pr_egid;
+ pr_addr = xlate <psinfo_t> (T->t_procp).pr_addr;
+ pr_ttydev = xlate <psinfo_t> (T->t_procp).pr_ttydev;
+ pr_start = (timestruc_t)xlate <psinfo_t> (T->t_procp).pr_start;
+ pr_fname = xlate <psinfo_t> (T->t_procp).pr_fname;
+ pr_psargs = xlate <psinfo_t> (T->t_procp).pr_psargs;
+ pr_argc = xlate <psinfo_t> (T->t_procp).pr_argc;
+ pr_argv = xlate <psinfo_t> (T->t_procp).pr_argv;
+ pr_envp = xlate <psinfo_t> (T->t_procp).pr_envp;
+ pr_dmodel = xlate <psinfo_t> (T->t_procp).pr_dmodel;
+ pr_taskid = xlate <psinfo_t> (T->t_procp).pr_taskid;
+ pr_projid = xlate <psinfo_t> (T->t_procp).pr_projid;
+ pr_poolid = xlate <psinfo_t> (T->t_procp).pr_poolid;
+ pr_zoneid = xlate <psinfo_t> (T->t_procp).pr_zoneid;
+ pr_contract = xlate <psinfo_t> (T->t_procp).pr_contract;
+};
+
+/*
+ * Translate from the kernel's kthread_t structure to a proc(4) lwpsinfo_t.
+ * We do not provide support for pr_nice, pr_oldpri, pr_cpu, or pr_pctcpu.
+ * Also, for the moment, pr_start and pr_time are not supported, but these
+ * could be supported by DTrace in the future using subroutines.
+ */
+#pragma D binding "1.0" translator
+translator lwpsinfo_t < kthread_t *T > {
+ pr_flag = ((T->t_state == @TS_STOPPED@) ? (PR_STOPPED |
+ ((!(T->t_schedflag & @TS_PSTART@)) ? PR_ISTOP : 0)) :
+ ((T->t_proc_flag & @TP_PRVSTOP@) ? PR_STOPPED | PR_ISTOP : 0)) |
+ ((T == T->t_procp->p_agenttp) ? PR_AGENT : 0) |
+ ((!(T->t_proc_flag & @TP_TWAIT@)) ? PR_DETACH : 0) |
+ ((T->t_proc_flag & @TP_DAEMON@) ? PR_DAEMON : 0) |
+ ((T->t_procp->p_pidflag & @CLDNOSIGCHLD@) ? PR_NOSIGCHLD : 0) |
+ ((T->t_procp->p_pidflag & @CLDWAITPID@) ? PR_WAITPID : 0) |
+ ((T->t_procp->p_proc_flag & @P_PR_FORK@) ? PR_FORK : 0) |
+ ((T->t_procp->p_proc_flag & @P_PR_RUNLCL@) ? PR_RLC : 0) |
+ ((T->t_procp->p_proc_flag & @P_PR_KILLCL@) ? PR_KLC : 0) |
+ ((T->t_procp->p_proc_flag & @P_PR_ASYNC@) ? PR_ASYNC : 0) |
+ ((T->t_procp->p_proc_flag & @P_PR_BPTADJ@) ? PR_BPTADJ : 0) |
+ ((T->t_procp->p_proc_flag & @P_PR_PTRACE@) ? PR_PTRACE : 0) |
+ ((T->t_procp->p_flag & @SMSACCT@) ? PR_MSACCT : 0) |
+ ((T->t_procp->p_flag & @SMSFORK@) ? PR_MSFORK : 0) |
+ ((T->t_procp->p_flag & @SVFWAIT@) ? PR_VFORKP : 0) |
+ (((T->t_procp->p_flag & @SSYS@) ||
+ (T->t_procp->p_as == &`kas)) ? PR_ISSYS : 0) |
+ ((T == T->t_cpu->cpu_idle_thread) ? PR_IDLE : 0);
+
+ pr_lwpid = T->t_tid;
+ pr_addr = (uintptr_t)T;
+ pr_wchan = (uintptr_t)T->t_lwpchan.lc_wchan;
+ pr_stype = T->t_sobj_ops ? T->t_sobj_ops->sobj_type : 0;
+
+ pr_state = (T->t_proc_flag & @TP_PRVSTOP@) ? SSTOP :
+ (T->t_state == @TS_SLEEP@) ? SSLEEP :
+ (T->t_state == @TS_RUN@) ? SRUN :
+ (T->t_state == @TS_ONPROC@) ? SONPROC :
+ (T->t_state == @TS_ZOMB@) ? SZOMB :
+ (T->t_state == @TS_STOPPED@) ? SSTOP :
+ (T->t_state == @TS_WAIT@) ? SWAIT : 0;
+
+ pr_sname = (T->t_proc_flag & @TP_PRVSTOP@) ? 'T' :
+ (T->t_state == @TS_SLEEP@) ? 'S' :
+ (T->t_state == @TS_RUN@) ? 'R' :
+ (T->t_state == @TS_ONPROC@) ? 'O' :
+ (T->t_state == @TS_ZOMB@) ? 'Z' :
+ (T->t_state == @TS_STOPPED@) ? 'T' :
+ (T->t_state == @TS_WAIT@) ? 'W' : '?';
+
+ pr_syscall = T->t_sysnum;
+ pr_pri = T->t_pri;
+ pr_clname = `sclass[T->t_cid].cl_name;
+ pr_onpro = T->t_cpu->cpu_id;
+ pr_bindpro = T->t_bind_cpu;
+ pr_bindpset = T->t_bind_pset;
+ pr_lgrp = T->t_lpl->lpl_lgrpid;
+};
+
+inline psinfo_t *curpsinfo = xlate <psinfo_t *> (curthread->t_procp);
+#pragma D attributes Stable/Stable/Common curpsinfo
+#pragma D binding "1.0" curpsinfo
+
+inline lwpsinfo_t *curlwpsinfo = xlate <lwpsinfo_t *> (curthread);
+#pragma D attributes Stable/Stable/Common curlwpsinfo
+#pragma D binding "1.0" curlwpsinfo
+
+inline string cwd = curthread->t_procp->p_user.u_cdir->v_path == NULL ?
+ "<unknown>" : stringof(curthread->t_procp->p_user.u_cdir->v_path);
+#pragma D attributes Stable/Stable/Common cwd
+#pragma D binding "1.0" cwd
+
+inline string root = curthread->t_procp->p_user.u_rdir == NULL ? "/" :
+ curthread->t_procp->p_user.u_rdir->v_path == NULL ? "<unknown>" :
+ stringof(curthread->t_procp->p_user.u_rdir->v_path);
+#pragma D attributes Stable/Stable/Common root
+#pragma D binding "1.0" root
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.sed.in
new file mode 100644
index 00000000..b4a7087a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/procfs.sed.in
@@ -0,0 +1,163 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * This file is a sed script which is first preprocessed by cpp or cc -E to
+ * define a set of sed directives which replace #define tokens with their
+ * values. After preprocessing, the sed script is run over procfs.d.in to
+ * replace the #define tokens listed below to create the finished procfs.d.
+ * Refer to the rules in libdtrace/Makefile.com for more information.
+ */
+
+#include <sys/model.h>
+#include <sys/thread.h>
+#include <sys/proc.h>
+#include <sys/procfs.h>
+#include <sys/sobject.h>
+#include <sys/siginfo.h>
+
+#define SED_REPLACE(x) s/#x/x/g
+
+SED_REPLACE(DATAMODEL_ILP32)
+SED_REPLACE(DATAMODEL_LP64)
+
+SED_REPLACE(TP_DAEMON)
+SED_REPLACE(TP_TWAIT)
+SED_REPLACE(TP_PRVSTOP)
+SED_REPLACE(TS_PSTART)
+SED_REPLACE(TS_FREE)
+SED_REPLACE(TS_SLEEP)
+SED_REPLACE(TS_RUN)
+SED_REPLACE(TS_ONPROC)
+SED_REPLACE(TS_ZOMB)
+SED_REPLACE(TS_STOPPED)
+SED_REPLACE(TS_WAIT)
+
+SED_REPLACE(P_PR_FORK)
+SED_REPLACE(P_PR_RUNLCL)
+SED_REPLACE(P_PR_KILLCL)
+SED_REPLACE(P_PR_ASYNC)
+SED_REPLACE(P_PR_BPTADJ)
+SED_REPLACE(P_PR_PTRACE)
+
+SED_REPLACE(SSYS)
+SED_REPLACE(SMSACCT)
+SED_REPLACE(SMSFORK)
+SED_REPLACE(SVFWAIT)
+
+SED_REPLACE(SSLEEP)
+SED_REPLACE(SRUN)
+SED_REPLACE(SZOMB)
+SED_REPLACE(SSTOP)
+SED_REPLACE(SIDL)
+SED_REPLACE(SONPROC)
+SED_REPLACE(SWAIT)
+
+SED_REPLACE(CLDNOSIGCHLD)
+SED_REPLACE(CLDWAITPID)
+
+SED_REPLACE(PR_STOPPED)
+SED_REPLACE(PR_ISTOP)
+SED_REPLACE(PR_DSTOP)
+SED_REPLACE(PR_STEP)
+SED_REPLACE(PR_ASLEEP)
+SED_REPLACE(PR_PCINVAL)
+SED_REPLACE(PR_ASLWP)
+SED_REPLACE(PR_AGENT)
+SED_REPLACE(PR_DETACH)
+SED_REPLACE(PR_DAEMON)
+SED_REPLACE(PR_IDLE)
+SED_REPLACE(PR_ISSYS)
+SED_REPLACE(PR_VFORKP)
+SED_REPLACE(PR_ORPHAN)
+SED_REPLACE(PR_NOSIGCHLD)
+SED_REPLACE(PR_WAITPID)
+SED_REPLACE(PR_FORK)
+SED_REPLACE(PR_RLC)
+SED_REPLACE(PR_KLC)
+SED_REPLACE(PR_ASYNC)
+SED_REPLACE(PR_MSACCT)
+SED_REPLACE(PR_BPTADJ)
+SED_REPLACE(PR_PTRACE)
+SED_REPLACE(PR_MSFORK)
+
+SED_REPLACE(PR_MODEL_ILP32)
+SED_REPLACE(PR_MODEL_LP64)
+
+SED_REPLACE(SOBJ_NONE)
+SED_REPLACE(SOBJ_MUTEX)
+SED_REPLACE(SOBJ_RWLOCK)
+SED_REPLACE(SOBJ_CV)
+SED_REPLACE(SOBJ_SEMA)
+SED_REPLACE(SOBJ_USER)
+SED_REPLACE(SOBJ_USER_PI)
+SED_REPLACE(SOBJ_SHUTTLE)
+
+SED_REPLACE(SI_USER)
+SED_REPLACE(SI_LWP)
+SED_REPLACE(SI_QUEUE)
+SED_REPLACE(SI_TIMER)
+SED_REPLACE(SI_ASYNCIO)
+SED_REPLACE(SI_MESGQ)
+SED_REPLACE(SI_RCTL)
+SED_REPLACE(ILL_ILLOPC)
+SED_REPLACE(ILL_ILLOPN)
+SED_REPLACE(ILL_ILLOPN)
+SED_REPLACE(ILL_ILLADR)
+SED_REPLACE(ILL_ILLTRP)
+SED_REPLACE(ILL_PRVOPC)
+SED_REPLACE(ILL_PRVREG)
+SED_REPLACE(ILL_COPROC)
+SED_REPLACE(ILL_BADSTK)
+SED_REPLACE(FPE_INTDIV)
+SED_REPLACE(FPE_INTOVF)
+SED_REPLACE(FPE_FLTDIV)
+SED_REPLACE(FPE_FLTOVF)
+SED_REPLACE(FPE_FLTUND)
+SED_REPLACE(FPE_FLTRES)
+SED_REPLACE(FPE_FLTINV)
+SED_REPLACE(FPE_FLTSUB)
+SED_REPLACE(SEGV_MAPERR)
+SED_REPLACE(SEGV_ACCERR)
+SED_REPLACE(BUS_ADRALN)
+SED_REPLACE(BUS_ADRERR)
+SED_REPLACE(BUS_OBJERR)
+SED_REPLACE(TRAP_BRKPT)
+SED_REPLACE(TRAP_TRACE)
+SED_REPLACE(CLD_EXITED)
+SED_REPLACE(CLD_KILLED)
+SED_REPLACE(CLD_DUMPED)
+SED_REPLACE(CLD_TRAPPED)
+SED_REPLACE(CLD_STOPPED)
+SED_REPLACE(CLD_CONTINUED)
+SED_REPLACE(POLL_IN)
+SED_REPLACE(POLL_OUT)
+SED_REPLACE(POLL_MSG)
+SED_REPLACE(POLL_ERR)
+SED_REPLACE(POLL_PRI)
+SED_REPLACE(POLL_HUP)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sched.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sched.d
new file mode 100644
index 00000000..722b58ae
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sched.d
@@ -0,0 +1,82 @@
+/*
+ * 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 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D depends_on module unix
+#pragma D depends_on provider sched
+
+struct cpuinfo {
+ processorid_t cpu_id; /* CPU identifier */
+ psetid_t cpu_pset; /* processor set identifier */
+ chipid_t cpu_chip; /* chip identifier */
+ lgrp_id_t cpu_lgrp; /* locality group identifer */
+ processor_info_t cpu_info; /* CPU information */
+};
+
+typedef struct cpuinfo cpuinfo_t;
+
+translator cpuinfo_t < cpu_t *C > {
+ cpu_id = C->cpu_id;
+ cpu_pset = C->cpu_part->cp_id;
+ cpu_chip = C->cpu_physid->cpu_chipid;
+ cpu_lgrp = C->cpu_lpl->lpl_lgrpid;
+ cpu_info = (processor_info_t)C->cpu_type_info;
+};
+
+translator cpuinfo_t < disp_t *D > {
+ cpu_id = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_id;
+ cpu_pset = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_pset;
+ cpu_chip = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_chip;
+ cpu_lgrp = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_lgrp;
+ cpu_info = D->disp_cpu == NULL ?
+ *((processor_info_t *)dtrace`dtrace_zero) :
+ (processor_info_t)xlate <cpuinfo_t> (D->disp_cpu).cpu_info;
+};
+
+inline cpuinfo_t *curcpu = xlate <cpuinfo_t *> (curthread->t_cpu);
+#pragma D attributes Stable/Stable/Common curcpu
+#pragma D binding "1.0" curcpu
+
+inline processorid_t cpu = curcpu->cpu_id;
+#pragma D attributes Stable/Stable/Common cpu
+#pragma D binding "1.0" cpu
+
+inline psetid_t pset = curcpu->cpu_pset;
+#pragma D attributes Stable/Stable/Common pset
+#pragma D binding "1.0" pset
+
+inline chipid_t chip = curcpu->cpu_chip;
+#pragma D attributes Stable/Stable/Common chip
+#pragma D binding "1.0" chip
+
+inline lgrp_id_t lgrp = curcpu->cpu_lgrp;
+#pragma D attributes Stable/Stable/Common lgrp
+#pragma D binding "1.0" lgrp
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/scsi.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/scsi.d
new file mode 100644
index 00000000..5a6e04f3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/scsi.d
@@ -0,0 +1,89 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D depends_on module genunix
+#pragma D depends_on module stmf
+
+/*
+ * The scsicmd_t structure should be used by providers
+ * to represent a SCSI command block (cdb).
+ */
+typedef struct scsicmd {
+ uint64_t ic_len; /* CDB length */
+ uint8_t *ic_cdb; /* CDB data */
+} scsicmd_t;
+
+/*
+ * Translator for scsicmd_t, translating from a scsi_task_t
+ */
+#pragma D binding "1.5" translator
+translator scsicmd_t < scsi_task_t *T > {
+ ic_len = T->task_cdb_length;
+ ic_cdb = T->task_cdb;
+};
+
+/*
+ * The xferinfo_t structure can be used by providers to
+ * represent transfer information related to a single
+ * buffer. The members describing the remote memory
+ * are only valid if the transport layer is an RDMA-
+ * capable transport like Infiniband
+ */
+typedef struct xferinfo {
+ uintptr_t xfer_laddr; /* local buffer address */
+ uint32_t xfer_loffset;
+ uint32_t xfer_lkey; /* access control to local memory */
+ uintptr_t xfer_raddr; /* remote virtual address */
+ uint32_t xfer_roffset; /* offset from the remote address */
+ uint32_t xfer_rkey; /* access control to remote virtual address */
+ uint32_t xfer_len; /* transfer length */
+ uint32_t xfer_type; /* Read (0) or Write (1) */
+} xferinfo_t;
+
+/*
+ * the iscsiinfo_t is used to provide identifying information about
+ * the target and the initiator and also some PDU level information
+ * such as lun, data length and sequence numbers.
+ */
+typedef struct iscsiinfo {
+ string ii_target; /* target iqn */
+ string ii_initiator; /* initiator iqn */
+ string ii_isid; /* initiator session identifier */
+ string ii_tsih; /* target session identifying handle */
+ string ii_transport; /* transport type ("iser-ib", "sockets") */
+
+ uint64_t ii_lun; /* target logical unit number */
+
+ uint32_t ii_itt; /* initiator task tag */
+ uint32_t ii_ttt; /* target transfer tag */
+
+ uint32_t ii_cmdsn; /* command sequence number */
+ uint32_t ii_statsn; /* status sequence number */
+ uint32_t ii_datasn; /* data sequence number */
+
+ uint32_t ii_datalen; /* length of data payload */
+ uint32_t ii_flags; /* probe-specific flags */
+} iscsiinfo_t;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/srp.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/srp.d
new file mode 100644
index 00000000..70cb2307
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/srp.d
@@ -0,0 +1,168 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D depends_on library net.d
+#pragma D depends_on library scsi.d
+#pragma D depends_on module genunix
+#pragma D depends_on module srpt
+
+typedef struct srp_portinfo {
+ /* initiator */
+ string pi_initiator; /* Initiator: eui.xxxxxxxxxxxxxxx */
+ string pi_i_sid; /* Initiator session id */
+
+ /* target */
+ string pi_target; /* Target: eui.xxxxxxxxxxxxxxx */
+ string pi_t_sid; /* Target session id */
+
+ uintptr_t pi_chan_id; /* Channel identifier */
+} srp_portinfo_t;
+
+#pragma D binding "1.5" translator
+translator conninfo_t < srpt_session_t *P > {
+ ci_local = P->ss_t_gid;
+ ci_remote = P->ss_i_gid;
+ ci_protocol = "ib";
+};
+
+#pragma D binding "1.5" translator
+translator srp_portinfo_t < srpt_session_t *P > {
+ pi_initiator = P->ss_i_name;
+ pi_i_sid = P->ss_i_alias;
+ pi_target = P->ss_t_name;
+ pi_t_sid = P->ss_t_alias;
+ pi_chan_id = 0;
+};
+
+#pragma D binding "1.5" translator
+translator conninfo_t < srpt_channel_t *P > {
+ ci_local = P->ch_session->ss_i_gid;
+ ci_remote = P->ch_session->ss_t_gid;
+};
+
+#pragma D binding "1.5" translator
+translator srp_portinfo_t < srpt_channel_t *P > {
+ pi_initiator = P->ch_session->ss_i_name;
+ pi_i_sid = P->ch_session->ss_i_alias;
+ pi_target = P->ch_session->ss_t_name;
+ pi_t_sid = P->ch_session->ss_t_alias;
+ pi_chan_id = (uintptr_t)P->ch_chan_hdl;
+};
+
+typedef struct srp_logininfo {
+ uint64_t li_task_tag; /* SRP task tag */
+ uint32_t li_max_it_iu_len; /* Maximum iu length that initiator can
+ send to target */
+ uint32_t li_max_ti_iu_len; /* Maximum iu length that target can
+ send to initiator */
+ uint32_t li_request_limit; /* Maximun number of SRP requests
+ that initiator can send on a channel */
+ uint32_t li_reason_code; /* Reason code */
+} srp_logininfo_t;
+
+#pragma D binding "1.5" translator
+translator srp_logininfo_t < srp_login_req_t *P > {
+ li_task_tag = P->lreq_tag;
+ li_max_it_iu_len = ntohl(P->lreq_req_it_iu_len);
+ li_max_ti_iu_len = 0;
+ li_request_limit = 0;
+ li_reason_code = 0;
+};
+
+#pragma D binding "1.5" translator
+translator srp_logininfo_t < srp_login_rsp_t *P > {
+ li_task_tag = P->lrsp_tag;
+ li_max_it_iu_len = ntohl(P->lrsp_max_it_iu_len);
+ li_max_ti_iu_len = ntohl(P->lrsp_max_ti_iu_len);
+ li_request_limit = ntohl(P->lrsp_req_limit_delta);
+ li_reason_code = ntohl(((srp_login_rej_t *)arg2)->lrej_reason);
+};
+
+typedef struct srp_taskinfo {
+ uint64_t ti_task_tag; /* SRP task tag */
+ uint64_t ti_lun; /* Target logical unit number */
+ uint8_t ti_function; /* Task management function */
+ uint32_t ti_req_limit_delta; /* Increment of channel's request limit */
+ uint8_t ti_flag; /* bit 2: DOOVER */
+ /* bit 3: DOUNDER */
+ /* bit 4: DIOVER */
+ /* bit 5: DIUNDER */
+ uint32_t ti_do_resid_cnt; /* Data-out residual count */
+ uint32_t ti_di_resid_cnt; /* Data-in residual count */
+ uint8_t ti_status; /* Status of this task */
+} srp_taskinfo_t;
+
+#pragma D binding "1.5" translator
+translator srp_taskinfo_t < srp_cmd_req_t *P > {
+ ti_task_tag = P->cr_tag;
+ ti_lun = (ntohl(*((uint32_t *)P->cr_lun)) << 32) +
+ ntohl(*((uint32_t *)&P->cr_lun[4]));
+ ti_function = P->cr_type == 1 ? /* 1: MGMT CMD 2: SRP CMD */
+ ((srp_tsk_mgmt_t *)P)->tm_function : 0;
+ ti_req_limit_delta = 0;
+ ti_flag = 0;
+ ti_do_resid_cnt = 0;
+ ti_di_resid_cnt = 0;
+ ti_status = 0;
+};
+
+#pragma D binding "1.5" translator
+translator srp_taskinfo_t < srp_rsp_t *P > {
+ ti_task_tag = P->rsp_tag;
+ ti_lun = ntohll(*(uint64_t *)((scsi_task_t *)arg2)->task_lun_no);
+ ti_function = ((scsi_task_t *)arg2)->task_mgmt_function;
+ ti_req_limit_delta = ntohl(P->rsp_req_limit_delta);
+ ti_flag = P->rsp_flags;
+ ti_do_resid_cnt = ntohl(P->rsp_do_resid_cnt);
+ ti_di_resid_cnt = ntohl(P->rsp_di_resid_cnt);
+ ti_status = arg3;
+};
+
+#pragma D binding "1.5" translator
+translator srp_taskinfo_t < srpt_iu_t *P > {
+ ti_task_tag = P->iu_tag;
+ ti_lun = ntohll(*(uint64_t *)P->iu_stmf_task->task_lun_no);
+ ti_function = 0;
+ ti_req_limit_delta = 0;
+ ti_flag = 0;
+ ti_do_resid_cnt = 0;
+ ti_di_resid_cnt = 0;
+ ti_status = 0;
+};
+
+#pragma D binding "1.5" translator
+translator xferinfo_t < ibt_wr_ds_t *P > {
+ xfer_laddr = P->ds_va + arg4;
+ xfer_lkey = P->ds_key;
+ xfer_raddr = (arg3 == 0) ? 0 :
+ ((ibt_send_wr_t *)arg3)->wr.rc.rcwr.rdma.rdma_raddr;
+ xfer_rkey = (arg3 == 0) ? 0 :
+ ((ibt_send_wr_t *)arg3)->wr.rc.rcwr.rdma.rdma_rkey;
+ xfer_len = arg4;
+ xfer_loffset = arg5;
+ xfer_roffset = arg6;
+ xfer_type = arg7;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.d.in
new file mode 100644
index 00000000..135dfa30
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.d.in
@@ -0,0 +1,50 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D depends_on module unix
+
+typedef struct syseventinfo {
+ string se_class; /* event class */
+ string se_subclass; /* event subclass */
+ string se_publisher; /* event publisher */
+} syseventinfo_t;
+
+#pragma D binding "1.0" translator
+translator syseventinfo_t < sysevent_impl_t *ev > {
+ se_class = stringof(@SE_CLASS_NAME@(ev));
+ se_subclass = stringof(@SE_SUBCLASS_NAME@(ev));
+ se_publisher = stringof(@SE_PUB_NAME@(ev));
+};
+
+typedef struct syseventchaninfo {
+ string ec_name; /* channel name, or NULL if default */
+} syseventchaninfo_t;
+
+#pragma D binding "1.0" translator
+translator syseventchaninfo_t < evch_bind_t *bind > {
+ ec_name = (bind ? stringof(bind->bd_channel->ch_name) : NULL);
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.sed.in
new file mode 100644
index 00000000..5d9f9583
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/sysevent.sed.in
@@ -0,0 +1,34 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/sysevent_impl.h>
+
+#define SED_MACRO(x) s/#x(ev)/x(ev)/g
+
+SED_MACRO(SE_CLASS_NAME)
+SED_MACRO(SE_SUBCLASS_NAME)
+SED_MACRO(SE_PUB_NAME)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.d.in
new file mode 100644
index 00000000..2733e526
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.d.in
@@ -0,0 +1,269 @@
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#pragma D depends_on module unix
+#pragma D depends_on provider tcp
+
+inline int TH_FIN = @TH_FIN@;
+#pragma D binding "1.6.3" TH_FIN
+inline int TH_SYN = @TH_SYN@;
+#pragma D binding "1.6.3" TH_SYN
+inline int TH_RST = @TH_RST@;
+#pragma D binding "1.6.3" TH_RST
+inline int TH_PUSH = @TH_PUSH@;
+#pragma D binding "1.6.3" TH_PUSH
+inline int TH_ACK = @TH_ACK@;
+#pragma D binding "1.6.3" TH_ACK
+inline int TH_URG = @TH_URG@;
+#pragma D binding "1.6.3" TH_URG
+inline int TH_ECE = @TH_ECE@;
+#pragma D binding "1.6.3" TH_ECE
+inline int TH_CWR = @TH_CWR@;
+#pragma D binding "1.6.3" TH_CWR
+
+inline int32_t TCP_STATE_CLOSED = @TCPS_CLOSED@;
+#pragma D binding "1.6.3" TCP_STATE_CLOSED
+inline int32_t TCP_STATE_IDLE = @TCPS_IDLE@;
+#pragma D binding "1.6.3" TCP_STATE_IDLE
+inline int32_t TCP_STATE_BOUND = @TCPS_BOUND@;
+#pragma D binding "1.6.3" TCP_STATE_BOUND
+inline int32_t TCP_STATE_LISTEN = @TCPS_LISTEN@;
+#pragma D binding "1.6.3" TCP_STATE_LISTEN
+inline int32_t TCP_STATE_SYN_SENT = @TCPS_SYN_SENT@;
+#pragma D binding "1.6.3" TCP_STATE_SYN_SENT
+inline int32_t TCP_STATE_SYN_RECEIVED = @TCPS_SYN_RCVD@;
+#pragma D binding "1.6.3" TCP_STATE_SYN_RECEIVED
+inline int32_t TCP_STATE_ESTABLISHED = @TCPS_ESTABLISHED@;
+#pragma D binding "1.6.3" TCP_STATE_ESTABLISHED
+inline int32_t TCP_STATE_CLOSE_WAIT = @TCPS_CLOSE_WAIT@;
+#pragma D binding "1.6.3" TCP_STATE_CLOSE_WAIT
+inline int32_t TCP_STATE_FIN_WAIT_1 = @TCPS_FIN_WAIT_1@;
+#pragma D binding "1.6.3" TCP_STATE_FIN_WAIT_1
+inline int32_t TCP_STATE_CLOSING = @TCPS_CLOSING@;
+#pragma D binding "1.6.3" TCP_STATE_CLOSING
+inline int32_t TCP_STATE_LAST_ACK = @TCPS_LAST_ACK@;
+#pragma D binding "1.6.3" TCP_STATE_LAST_ACK
+inline int32_t TCP_STATE_FIN_WAIT_2 = @TCPS_FIN_WAIT_2@;
+#pragma D binding "1.6.3" TCP_STATE_FIN_WAIT_2
+inline int32_t TCP_STATE_TIME_WAIT = @TCPS_TIME_WAIT@;
+#pragma D binding "1.6.3" TCP_STATE_TIME_WAIT
+
+/*
+ * Convert a TCP state value to a string.
+ */
+inline string tcp_state_string[int32_t state] =
+ state == TCP_STATE_CLOSED ? "state-closed" :
+ state == TCP_STATE_IDLE ? "state-idle" :
+ state == TCP_STATE_BOUND ? "state-bound" :
+ state == TCP_STATE_LISTEN ? "state-listen" :
+ state == TCP_STATE_SYN_SENT ? "state-syn-sent" :
+ state == TCP_STATE_SYN_RECEIVED ? "state-syn-received" :
+ state == TCP_STATE_ESTABLISHED ? "state-established" :
+ state == TCP_STATE_CLOSE_WAIT ? "state-close-wait" :
+ state == TCP_STATE_FIN_WAIT_1 ? "state-fin-wait-1" :
+ state == TCP_STATE_CLOSING ? "state-closing" :
+ state == TCP_STATE_LAST_ACK ? "state-last-ack" :
+ state == TCP_STATE_FIN_WAIT_2 ? "state-fin-wait-2" :
+ state == TCP_STATE_TIME_WAIT ? "state-time-wait" :
+ "<unknown>";
+#pragma D binding "1.6.3" tcp_state_string
+
+/*
+ * tcpinfo is the TCP header fields.
+ */
+typedef struct tcpinfo {
+ uint16_t tcp_sport; /* source port */
+ uint16_t tcp_dport; /* destination port */
+ uint32_t tcp_seq; /* sequence number */
+ uint32_t tcp_ack; /* acknowledgment number */
+ uint8_t tcp_offset; /* data offset, in bytes */
+ uint8_t tcp_flags; /* flags */
+ uint16_t tcp_window; /* window size */
+ uint16_t tcp_checksum; /* checksum */
+ uint16_t tcp_urgent; /* urgent data pointer */
+ tcph_t *tcp_hdr; /* raw TCP header */
+} tcpinfo_t;
+
+/*
+ * tcpsinfo contains stable TCP details from tcp_t.
+ */
+typedef struct tcpsinfo {
+ uintptr_t tcps_addr;
+ int tcps_local; /* is delivered locally, boolean */
+ int tcps_active; /* active open (from here), boolean */
+ uint16_t tcps_lport; /* local port */
+ uint16_t tcps_rport; /* remote port */
+ string tcps_laddr; /* local address, as a string */
+ string tcps_raddr; /* remote address, as a string */
+ int32_t tcps_state; /* TCP state */
+ uint32_t tcps_iss; /* Initial sequence # sent */
+ uint32_t tcps_suna; /* sequence # sent but unacked */
+ uint32_t tcps_snxt; /* next sequence # to send */
+ uint32_t tcps_rack; /* sequence # we have acked */
+ uint32_t tcps_rnxt; /* next sequence # expected */
+ uint32_t tcps_swnd; /* send window size */
+ int32_t tcps_snd_ws; /* send window scaling */
+ uint32_t tcps_rwnd; /* receive window size */
+ int32_t tcps_rcv_ws; /* receive window scaling */
+ uint32_t tcps_cwnd; /* congestion window */
+ uint32_t tcps_cwnd_ssthresh; /* threshold for congestion avoidance */
+ uint32_t tcps_sack_fack; /* SACK sequence # we have acked */
+ uint32_t tcps_sack_snxt; /* next SACK seq # for retransmission */
+ uint32_t tcps_rto; /* round-trip timeout, msec */
+ uint32_t tcps_mss; /* max segment size */
+ int tcps_retransmit; /* retransmit send event, boolean */
+} tcpsinfo_t;
+
+/*
+ * tcplsinfo provides the old tcp state for state changes.
+ */
+typedef struct tcplsinfo {
+ int32_t tcps_state; /* previous TCP state */
+} tcplsinfo_t;
+
+/*
+ * __dtrace_tcp_tcph_t is used by the tcpinfo_t * translator to take either
+ * the non-NULL tcph_t * passed in or, if it is NULL, uses arg3 (tcp_t *)
+ * from the tcp:::send and tcp:::recieve probes and translates the tcp_t *
+ * into the tcpinfo_t. When no headers are available - as is the case for
+ * TCP fusion tcp:::send and tcp:::receive - this allows us to present the
+ * consumer with header data based on tcp_t * content and hide TCP fusion
+ * implementation details.
+ */
+typedef tcph_t * __dtrace_tcp_tcph_t;
+
+#pragma D binding "1.6.3" translator
+translator tcpinfo_t < tcph_t *T > {
+ tcp_sport = ntohs(*(uint16_t *)T->th_lport);
+ tcp_dport = ntohs(*(uint16_t *)T->th_fport);
+ tcp_seq = ntohl(*(uint32_t *)T->th_seq);
+ tcp_ack = ntohl(*(uint32_t *)T->th_ack);
+ tcp_offset = (*(uint8_t *)T->th_offset_and_rsrvd & 0xf0) >> 2;
+ tcp_flags = *(uint8_t *)T->th_flags;
+ tcp_window = ntohs(*(uint16_t *)T->th_win);
+ tcp_checksum = ntohs(*(uint16_t *)T->th_sum);
+ tcp_urgent = ntohs(*(uint16_t *)T->th_urp);
+ tcp_hdr = T;
+};
+
+#pragma D binding "1.6.3" translator
+translator tcpinfo_t < __dtrace_tcp_tcph_t *T > {
+ tcp_sport =
+ T != NULL ? ntohs(*(uint16_t *)((tcph_t *)T)->th_lport) :
+ arg3 != NULL && probename == "send" ?
+ ntohs(((tcp_t *)arg3)->tcp_connp->u_port.connu_ports.connu_lport) :
+ arg3 != NULL && probename == "receive" ?
+ ntohs(((tcp_t *)arg3)->tcp_connp->u_port.connu_ports.connu_fport) :
+ 0;
+ tcp_dport =
+ T != NULL ? ntohs(*(uint16_t *)((tcph_t *)T)->th_fport) :
+ arg3 != NULL && probename == "send" ?
+ ntohs(((tcp_t *)arg3)->tcp_connp->u_port.connu_ports.connu_fport) :
+ arg3 != NULL && probename == "receive" ?
+ ntohs(((tcp_t *)arg3)->tcp_connp->u_port.connu_ports.connu_lport) :
+ 0;
+ tcp_seq =
+ T != NULL ? ntohl(*(uint32_t *)((tcph_t *)T)->th_seq) :
+ arg3 != NULL && probename == "send" ?
+ ((tcp_t *)arg3)->tcp_snxt - ((tcp_t *)arg3)->tcp_last_sent_len :
+ arg3 != NULL && probename == "receive" ?
+ ((tcp_t *)arg3)->tcp_rnxt - ((tcp_t *)arg3)->tcp_last_recv_len :
+ 0;
+ tcp_ack =
+ T != NULL ? ntohl(*(uint32_t *)((tcph_t *)T)->th_ack) :
+ arg3 != NULL && probename == "send" ?
+ ((tcp_t *)arg3)->tcp_rnxt :
+ arg3 != NULL && probename == "receive" ?
+ ((tcp_t *)arg3)->tcp_snxt :
+ 0;
+ tcp_offset = T != NULL ?
+ (*(uint8_t *)((tcph_t *)T)->th_offset_and_rsrvd & 0xf0) >> 2 :
+ @TCP_MIN_HEADER_LENGTH@;
+ tcp_flags = T != NULL ? *(uint8_t *)((tcph_t *)T)->th_flags : TH_ACK;
+ tcp_window = T != NULL ? ntohs(*(uint16_t *)((tcph_t *)T)->th_win) :
+ arg3 != NULL ? ((tcp_t *)arg3)->tcp_swnd : 0;
+ tcp_checksum = T != NULL ? ntohs(*(uint16_t *)((tcph_t *)T)->th_sum) :
+ 0;
+ tcp_urgent = T != NULL ? ntohs(*(uint16_t *)((tcph_t *)T)->th_urp) : 0;
+ tcp_hdr = NULL;
+};
+
+#pragma D binding "1.6.3" translator
+translator tcpsinfo_t < tcp_t *T > {
+ tcps_addr = (uintptr_t)T;
+ /*
+ * The following two members should just use tcp_t->tcp_loopback
+ * and tcp_t->tcp_active_open, however these are bit fields and
+ * can't be used until CR 6876830 is fixed. Meanwhile we source
+ * them a different way.
+ */
+ tcps_local = T ? T->tcp_ipha ?
+ T->tcp_ipha->ipha_src == T->tcp_ipha->ipha_dst : 1 : 0;
+ tcps_active = T ? !T->tcp_saved_listener : 0;
+ tcps_lport = T ?
+ ntohs(T->tcp_connp->u_port.connu_ports.connu_lport) : 0;
+ tcps_rport = T ?
+ ntohs(T->tcp_connp->u_port.connu_ports.connu_fport) : 0;
+ tcps_laddr = T ?
+ inet_ntoa6(&T->tcp_connp->connua_v6addr.connua_laddr) : "<unknown>";
+ tcps_raddr = T ?
+ inet_ntoa6(&T->tcp_connp->connua_v6addr.connua_faddr) : "<unknown>";
+ tcps_state = T ? T->tcp_state : TCP_STATE_CLOSED;
+ tcps_iss = T ? T->tcp_iss : 0;
+ tcps_suna = T ? T->tcp_suna : 0;
+ tcps_snxt = T ? T->tcp_snxt : 0;
+ tcps_rack = T ? T->tcp_rack : 0;
+ tcps_rnxt = T ? T->tcp_rnxt : 0;
+ tcps_swnd = T ? T->tcp_swnd : 0;
+ tcps_snd_ws = T ? T->tcp_snd_ws : 0;
+ tcps_rwnd = T ? T->tcp_rwnd : 0;
+ tcps_rcv_ws = T ? T->tcp_rcv_ws : 0;
+ tcps_cwnd = T ? T->tcp_cwnd : 0;
+ tcps_cwnd_ssthresh = T ? T->tcp_cwnd_ssthresh : 0;
+ tcps_sack_fack = T ? T->tcp_sack_info.tcp_fack : 0;
+ tcps_sack_snxt = T ? T->tcp_sack_info.tcp_sack_snxt : 0;
+ tcps_rto = T ? T->tcp_rto : 0;
+ tcps_mss = T ? T->tcp_mss : 0;
+ /*
+ * Determine if send is a retransmission by comparing the seq # to
+ * tcp_rexmit_nxt/tcp_rexmit_max - if the value is >= rexmit_nxt and
+ * < rexmit_max, this is a retransmission. Cannot use tcp_rexmit
+ * bitfield value due to CR 6876830.
+ */
+ tcps_retransmit = T && probename == "send" && arg4 != NULL &&
+ ntohl(*(uint32_t *)((tcph_t *)arg4)->th_seq) >= T->tcp_rexmit_nxt &&
+ ntohl(*(uint32_t *)((tcph_t *)arg4)->th_seq) < T->tcp_rexmit_max ?
+ 1 : 0;
+};
+
+/*
+ * Note: although we specify that the old state argument used as the
+ * input to the tcplsinfo_t translator is an int32_t, it reaches us as an
+ * int64_t (since it is a probe argument) so explicitly cast it back to
+ * interpret the negatively-valued states correctly.
+ */
+#pragma D binding "1.6.3" translator
+translator tcplsinfo_t < int64_t I > {
+ tcps_state = (int32_t) I;
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.sed.in
new file mode 100644
index 00000000..230264be
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/tcp.sed.in
@@ -0,0 +1,53 @@
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <inet/tcp.h>
+#include <sys/netstack.h>
+
+#define SED_REPLACE(x) s/#x/x/g
+
+SED_REPLACE(TH_FIN)
+SED_REPLACE(TH_SYN)
+SED_REPLACE(TH_RST)
+SED_REPLACE(TH_PUSH)
+SED_REPLACE(TH_ACK)
+SED_REPLACE(TH_URG)
+SED_REPLACE(TH_ECE)
+SED_REPLACE(TH_CWR)
+
+SED_REPLACE(TCPS_CLOSED)
+SED_REPLACE(TCPS_IDLE)
+SED_REPLACE(TCPS_BOUND)
+SED_REPLACE(TCPS_LISTEN)
+SED_REPLACE(TCPS_SYN_SENT)
+SED_REPLACE(TCPS_SYN_RCVD)
+SED_REPLACE(TCPS_ESTABLISHED)
+SED_REPLACE(TCPS_CLOSE_WAIT)
+SED_REPLACE(TCPS_FIN_WAIT_1)
+SED_REPLACE(TCPS_CLOSING)
+SED_REPLACE(TCPS_LAST_ACK)
+SED_REPLACE(TCPS_FIN_WAIT_2)
+SED_REPLACE(TCPS_TIME_WAIT)
+
+SED_REPLACE(TCP_MIN_HEADER_LENGTH)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.d.in
new file mode 100644
index 00000000..c2159016
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.d.in
@@ -0,0 +1,73 @@
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#pragma D depends_on module unix
+#pragma D depends_on provider udp
+
+inline int UDPH_SIZE = @UDPH_SIZE@;
+#pragma D binding "1.6.3" UDPH_SIZE
+
+/*
+ * udpinfo is the UDP header fields.
+ */
+typedef struct udpinfo {
+ uint16_t udp_sport; /* source port */
+ uint16_t udp_dport; /* destination port */
+ uint16_t udp_length; /* total length */
+ uint16_t udp_checksum; /* headers + data checksum */
+ udpha_t *udp_hdr; /* raw UDP header */
+} udpinfo_t;
+
+/*
+ * udpsinfo contains stable UDP details from udp_t.
+ */
+typedef struct udpsinfo {
+ uintptr_t udps_addr;
+ uint16_t udps_lport; /* local port */
+ uint16_t udps_rport; /* remote port */
+ string udps_laddr; /* local address, as a string */
+ string udps_raddr; /* remote address, as a string */
+} udpsinfo_t;
+
+#pragma D binding "1.6.3" translator
+translator udpinfo_t < udpha_t *U > {
+ udp_sport = ntohs(U->uha_src_port);
+ udp_dport = ntohs(U->uha_dst_port);
+ udp_length = ntohs(U->uha_length);
+ udp_checksum = ntohs(U->uha_checksum);
+ udp_hdr = U;
+};
+
+#pragma D binding "1.6.3" translator
+translator udpsinfo_t < udp_t *U > {
+ udps_addr = (uintptr_t)U;
+ udps_lport = U ?
+ ntohs(U->udp_connp->u_port.connu_ports.connu_lport) : 0;
+ udps_rport = U ?
+ ntohs(U->udp_connp->u_port.connu_ports.connu_fport) : 0;
+ udps_laddr = U ?
+ inet_ntoa6(&U->udp_connp->connua_v6addr.connua_laddr) : "<unknown>";
+ udps_raddr = U ?
+ inet_ntoa6(&U->udp_connp->connua_v6addr.connua_faddr) : "<unknown>";
+};
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.sed.in
new file mode 100644
index 00000000..9c23a96a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/udp.sed.in
@@ -0,0 +1,29 @@
+/*
+ * 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) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <inet/ip.h>
+
+#define SED_REPLACE(x) s/#x/x/g
+
+SED_REPLACE(UDPH_SIZE)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/unistd.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/unistd.d
new file mode 100644
index 00000000..c561ad33
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/unistd.d
@@ -0,0 +1,56 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+inline int DTRACEFLT_UNKNOWN = 0; /* Unknown fault */
+#pragma D binding "1.0" DTRACEFLT_UNKNOWN
+
+inline int DTRACEFLT_BADADDR = 1; /* Bad address */
+#pragma D binding "1.0" DTRACEFLT_BADADDR
+
+inline int DTRACEFLT_BADALIGN = 2; /* Bad alignment */
+#pragma D binding "1.0" DTRACEFLT_BADALIGN
+
+inline int DTRACEFLT_ILLOP = 3; /* Illegal operation */
+#pragma D binding "1.0" DTRACEFLT_ILLOP
+
+inline int DTRACEFLT_DIVZERO = 4; /* Divide-by-zero */
+#pragma D binding "1.0" DTRACEFLT_DIVZERO
+
+inline int DTRACEFLT_NOSCRATCH = 5; /* Out of scratch space */
+#pragma D binding "1.0" DTRACEFLT_NOSCRATCH
+
+inline int DTRACEFLT_KPRIV = 6; /* Illegal kernel access */
+#pragma D binding "1.0" DTRACEFLT_KPRIV
+
+inline int DTRACEFLT_UPRIV = 7; /* Illegal user access */
+#pragma D binding "1.0" DTRACEFLT_UPRIV
+
+inline int DTRACEFLT_TUPOFLOW = 8; /* Tuple stack overflow */
+#pragma D binding "1.0" DTRACEFLT_TUPOFLOW
+
+inline int DTRACEFLT_BADSTACK = 9; /* Bad stack */
+#pragma D binding "1.4.1" DTRACEFLT_BADSTACK
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile
new file mode 100644
index 00000000..6c479392
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile
@@ -0,0 +1,54 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+ASFLAGS += $(AS_PICFLAGS) -P -D_ASM
+
+MACHOBJS = dis_tables.o
+DLIBSRCS = regs.d
+
+include ../Makefile.com
+
+SRCS += $(SRC)/common/dis/i386/dis_tables.c
+CPPFLAGS += -I$(SRC)/common/dis/i386
+
+LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN
+
+CLEANFILES += regs.sed regs.d
+
+%.sed: %.sed.in
+ $(COMPILE.cpp) -D_KERNEL $< | \
+ tr -d ' ' | tr '@' ' ' | tr '"' '@' | grep '^s/' > $@
+
+../$(MACH)/regs.d: regs.sed regs.d.in
+ sed -f regs.sed < regs.d.in > $@
+
+pics/%.o: $(SRC)/common/dis/i386/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+install yydebug: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) \
+ $(ROOTDLIBS) $(ROOTDOBJS)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/dt_isadep.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/dt_isadep.c
new file mode 100644
index 00000000..c1484a40
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/dt_isadep.c
@@ -0,0 +1,488 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <libgen.h>
+
+#include <dt_impl.h>
+#include <dt_pid.h>
+
+#include <dis_tables.h>
+
+#define DT_POPL_EBP 0x5d
+#define DT_RET 0xc3
+#define DT_RET16 0xc2
+#define DT_LEAVE 0xc9
+#define DT_JMP32 0xe9
+#define DT_JMP8 0xeb
+#define DT_REP 0xf3
+
+#define DT_MOVL_EBP_ESP 0xe58b
+
+#define DT_ISJ32(op16) (((op16) & 0xfff0) == 0x0f80)
+#define DT_ISJ8(op8) (((op8) & 0xf0) == 0x70)
+
+#define DT_MODRM_REG(modrm) (((modrm) >> 3) & 0x7)
+
+static int dt_instr_size(uchar_t *, dtrace_hdl_t *, pid_t, uintptr_t, char);
+
+/*ARGSUSED*/
+int
+dt_pid_create_entry_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp)
+{
+ ftp->ftps_type = DTFTP_ENTRY;
+ ftp->ftps_pc = (uintptr_t)symp->st_value;
+ ftp->ftps_size = (size_t)symp->st_size;
+ ftp->ftps_noffs = 1;
+ ftp->ftps_offs[0] = 0;
+
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (1);
+}
+
+static int
+dt_pid_has_jump_table(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ uint8_t *text, fasttrap_probe_spec_t *ftp, const GElf_Sym *symp)
+{
+ ulong_t i;
+ int size;
+ pid_t pid = Pstatus(P)->pr_pid;
+ char dmodel = Pstatus(P)->pr_dmodel;
+
+ /*
+ * Take a pass through the function looking for a register-dependant
+ * jmp instruction. This could be a jump table so we have to be
+ * ultra conservative.
+ */
+ for (i = 0; i < ftp->ftps_size; i += size) {
+ size = dt_instr_size(&text[i], dtp, pid, symp->st_value + i,
+ dmodel);
+
+ /*
+ * Assume the worst if we hit an illegal instruction.
+ */
+ if (size <= 0) {
+ dt_dprintf("error at %#lx (assuming jump table)\n", i);
+ return (1);
+ }
+
+ /*
+ * Register-dependant jmp instructions start with a 0xff byte
+ * and have the modrm.reg field set to 4. They can have an
+ * optional REX prefix on the 64-bit ISA.
+ */
+ if ((text[i] == 0xff && DT_MODRM_REG(text[i + 1]) == 4) ||
+ (dmodel == PR_MODEL_LP64 && (text[i] & 0xf0) == 0x40 &&
+ text[i + 1] == 0xff && DT_MODRM_REG(text[i + 2]) == 4)) {
+ dt_dprintf("found a suspected jump table at %s:%lx\n",
+ ftp->ftps_func, i);
+ return (1);
+ }
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+int
+dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, uint64_t *stret)
+{
+ uint8_t *text;
+ ulong_t i, end;
+ int size;
+ pid_t pid = Pstatus(P)->pr_pid;
+ char dmodel = Pstatus(P)->pr_dmodel;
+
+ /*
+ * We allocate a few extra bytes at the end so we don't have to check
+ * for overrunning the buffer.
+ */
+ if ((text = calloc(1, symp->st_size + 4)) == NULL) {
+ dt_dprintf("mr sparkle: malloc() failed\n");
+ return (DT_PROC_ERR);
+ }
+
+ if (Pread(P, text, symp->st_size, symp->st_value) != symp->st_size) {
+ dt_dprintf("mr sparkle: Pread() failed\n");
+ free(text);
+ return (DT_PROC_ERR);
+ }
+
+ ftp->ftps_type = DTFTP_RETURN;
+ ftp->ftps_pc = (uintptr_t)symp->st_value;
+ ftp->ftps_size = (size_t)symp->st_size;
+ ftp->ftps_noffs = 0;
+
+ /*
+ * If there's a jump table in the function we're only willing to
+ * instrument these specific (and equivalent) instruction sequences:
+ * leave
+ * [rep] ret
+ * and
+ * movl %ebp,%esp
+ * popl %ebp
+ * [rep] ret
+ *
+ * We do this to avoid accidentally interpreting jump table
+ * offsets as actual instructions.
+ */
+ if (dt_pid_has_jump_table(P, dtp, text, ftp, symp)) {
+ for (i = 0, end = ftp->ftps_size; i < end; i += size) {
+ size = dt_instr_size(&text[i], dtp, pid,
+ symp->st_value + i, dmodel);
+
+ /* bail if we hit an invalid opcode */
+ if (size <= 0)
+ break;
+
+ if (text[i] == DT_LEAVE && text[i + 1] == DT_RET) {
+ dt_dprintf("leave/ret at %lx\n", i + 1);
+ ftp->ftps_offs[ftp->ftps_noffs++] = i + 1;
+ size = 2;
+ } else if (text[i] == DT_LEAVE &&
+ text[i + 1] == DT_REP && text[i + 2] == DT_RET) {
+ dt_dprintf("leave/rep ret at %lx\n", i + 1);
+ ftp->ftps_offs[ftp->ftps_noffs++] = i + 1;
+ size = 3;
+ } else if (*(uint16_t *)&text[i] == DT_MOVL_EBP_ESP &&
+ text[i + 2] == DT_POPL_EBP &&
+ text[i + 3] == DT_RET) {
+ dt_dprintf("movl/popl/ret at %lx\n", i + 3);
+ ftp->ftps_offs[ftp->ftps_noffs++] = i + 3;
+ size = 4;
+ } else if (*(uint16_t *)&text[i] == DT_MOVL_EBP_ESP &&
+ text[i + 2] == DT_POPL_EBP &&
+ text[i + 3] == DT_REP &&
+ text[i + 4] == DT_RET) {
+ dt_dprintf("movl/popl/rep ret at %lx\n", i + 3);
+ ftp->ftps_offs[ftp->ftps_noffs++] = i + 3;
+ size = 5;
+ }
+ }
+ } else {
+ for (i = 0, end = ftp->ftps_size; i < end; i += size) {
+ size = dt_instr_size(&text[i], dtp, pid,
+ symp->st_value + i, dmodel);
+
+ /* bail if we hit an invalid opcode */
+ if (size <= 0)
+ break;
+
+ /* ordinary ret */
+ if (size == 1 && text[i] == DT_RET)
+ goto is_ret;
+
+ /* two-byte ret */
+ if (size == 2 && text[i] == DT_REP &&
+ text[i + 1] == DT_RET)
+ goto is_ret;
+
+ /* ret <imm16> */
+ if (size == 3 && text[i] == DT_RET16)
+ goto is_ret;
+
+ /* two-byte ret <imm16> */
+ if (size == 4 && text[i] == DT_REP &&
+ text[i + 1] == DT_RET16)
+ goto is_ret;
+
+ /* 32-bit displacement jmp outside of the function */
+ if (size == 5 && text[i] == DT_JMP32 && symp->st_size <=
+ (uintptr_t)(i + size + *(int32_t *)&text[i + 1]))
+ goto is_ret;
+
+ /* 8-bit displacement jmp outside of the function */
+ if (size == 2 && text[i] == DT_JMP8 && symp->st_size <=
+ (uintptr_t)(i + size + *(int8_t *)&text[i + 1]))
+ goto is_ret;
+
+ /* 32-bit disp. conditional jmp outside of the func. */
+ if (size == 6 && DT_ISJ32(*(uint16_t *)&text[i]) &&
+ symp->st_size <=
+ (uintptr_t)(i + size + *(int32_t *)&text[i + 2]))
+ goto is_ret;
+
+ /* 8-bit disp. conditional jmp outside of the func. */
+ if (size == 2 && DT_ISJ8(text[i]) && symp->st_size <=
+ (uintptr_t)(i + size + *(int8_t *)&text[i + 1]))
+ goto is_ret;
+
+ continue;
+is_ret:
+ dt_dprintf("return at offset %lx\n", i);
+ ftp->ftps_offs[ftp->ftps_noffs++] = i;
+ }
+ }
+
+ free(text);
+ if (ftp->ftps_noffs > 0) {
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+ }
+
+ return (ftp->ftps_noffs);
+}
+
+/*ARGSUSED*/
+int
+dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, ulong_t off)
+{
+ ftp->ftps_type = DTFTP_OFFSETS;
+ ftp->ftps_pc = (uintptr_t)symp->st_value;
+ ftp->ftps_size = (size_t)symp->st_size;
+ ftp->ftps_noffs = 1;
+
+ if (strcmp("-", ftp->ftps_func) == 0) {
+ ftp->ftps_offs[0] = off;
+ } else {
+ uint8_t *text;
+ ulong_t i;
+ int size;
+ pid_t pid = Pstatus(P)->pr_pid;
+ char dmodel = Pstatus(P)->pr_dmodel;
+
+ if ((text = malloc(symp->st_size)) == NULL) {
+ dt_dprintf("mr sparkle: malloc() failed\n");
+ return (DT_PROC_ERR);
+ }
+
+ if (Pread(P, text, symp->st_size, symp->st_value) !=
+ symp->st_size) {
+ dt_dprintf("mr sparkle: Pread() failed\n");
+ free(text);
+ return (DT_PROC_ERR);
+ }
+
+ /*
+ * We can't instrument offsets in functions with jump tables
+ * as we might interpret a jump table offset as an
+ * instruction.
+ */
+ if (dt_pid_has_jump_table(P, dtp, text, ftp, symp)) {
+ free(text);
+ return (0);
+ }
+
+ for (i = 0; i < symp->st_size; i += size) {
+ if (i == off) {
+ ftp->ftps_offs[0] = i;
+ break;
+ }
+
+ /*
+ * If we've passed the desired offset without a
+ * match, then the given offset must not lie on a
+ * instruction boundary.
+ */
+ if (i > off) {
+ free(text);
+ return (DT_PROC_ALIGN);
+ }
+
+ size = dt_instr_size(&text[i], dtp, pid,
+ symp->st_value + i, dmodel);
+
+ /*
+ * If we hit an invalid instruction, bail as if we
+ * couldn't find the offset.
+ */
+ if (size <= 0) {
+ free(text);
+ return (DT_PROC_ALIGN);
+ }
+ }
+
+ free(text);
+ }
+
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (ftp->ftps_noffs);
+}
+
+/*ARGSUSED*/
+int
+dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, const char *pattern)
+{
+ uint8_t *text;
+ int size;
+ ulong_t i, end = symp->st_size;
+ pid_t pid = Pstatus(P)->pr_pid;
+ char dmodel = Pstatus(P)->pr_dmodel;
+
+ ftp->ftps_type = DTFTP_OFFSETS;
+ ftp->ftps_pc = (uintptr_t)symp->st_value;
+ ftp->ftps_size = (size_t)symp->st_size;
+ ftp->ftps_noffs = 0;
+
+ if ((text = malloc(symp->st_size)) == NULL) {
+ dt_dprintf("mr sparkle: malloc() failed\n");
+ return (DT_PROC_ERR);
+ }
+
+ if (Pread(P, text, symp->st_size, symp->st_value) != symp->st_size) {
+ dt_dprintf("mr sparkle: Pread() failed\n");
+ free(text);
+ return (DT_PROC_ERR);
+ }
+
+ /*
+ * We can't instrument offsets in functions with jump tables as
+ * we might interpret a jump table offset as an instruction.
+ */
+ if (dt_pid_has_jump_table(P, dtp, text, ftp, symp)) {
+ free(text);
+ return (0);
+ }
+
+ if (strcmp("*", pattern) == 0) {
+ for (i = 0; i < end; i += size) {
+ ftp->ftps_offs[ftp->ftps_noffs++] = i;
+
+ size = dt_instr_size(&text[i], dtp, pid,
+ symp->st_value + i, dmodel);
+
+ /* bail if we hit an invalid opcode */
+ if (size <= 0)
+ break;
+ }
+ } else {
+ char name[sizeof (i) * 2 + 1];
+
+ for (i = 0; i < end; i += size) {
+ (void) snprintf(name, sizeof (name), "%x", i);
+ if (gmatch(name, pattern))
+ ftp->ftps_offs[ftp->ftps_noffs++] = i;
+
+ size = dt_instr_size(&text[i], dtp, pid,
+ symp->st_value + i, dmodel);
+
+ /* bail if we hit an invalid opcode */
+ if (size <= 0)
+ break;
+ }
+ }
+
+ free(text);
+ if (ftp->ftps_noffs > 0) {
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+ }
+
+ return (ftp->ftps_noffs);
+}
+
+typedef struct dtrace_dis {
+ uchar_t *instr;
+ dtrace_hdl_t *dtp;
+ pid_t pid;
+ uintptr_t addr;
+} dtrace_dis_t;
+
+static int
+dt_getbyte(void *data)
+{
+ dtrace_dis_t *dis = data;
+ int ret = *dis->instr;
+
+ if (ret == FASTTRAP_INSTR) {
+ fasttrap_instr_query_t instr;
+
+ instr.ftiq_pid = dis->pid;
+ instr.ftiq_pc = dis->addr;
+
+ /*
+ * If we hit a byte that looks like the fasttrap provider's
+ * trap instruction (which doubles as the breakpoint
+ * instruction for debuggers) we need to query the kernel
+ * for the real value. This may just be part of an immediate
+ * value so there's no need to return an error if the
+ * kernel doesn't know about this address.
+ */
+ if (ioctl(dis->dtp->dt_ftfd, FASTTRAPIOC_GETINSTR, &instr) == 0)
+ ret = instr.ftiq_instr;
+ }
+
+ dis->addr++;
+ dis->instr++;
+
+ return (ret);
+}
+
+static int
+dt_instr_size(uchar_t *instr, dtrace_hdl_t *dtp, pid_t pid, uintptr_t addr,
+ char dmodel)
+{
+ dtrace_dis_t data;
+ dis86_t x86dis;
+ uint_t cpu_mode;
+
+ data.instr = instr;
+ data.dtp = dtp;
+ data.pid = pid;
+ data.addr = addr;
+
+ x86dis.d86_data = &data;
+ x86dis.d86_get_byte = dt_getbyte;
+ x86dis.d86_check_func = NULL;
+
+ cpu_mode = (dmodel == PR_MODEL_ILP32) ? SIZE32 : SIZE64;
+
+ if (dtrace_disx86(&x86dis, cpu_mode) != 0)
+ return (-1);
+
+ /*
+ * If the instruction was a single-byte breakpoint, there may be
+ * another debugger attached to this process. The original instruction
+ * can't be recovered so this must fail.
+ */
+ if (x86dis.d86_len == 1 && instr[0] == FASTTRAP_INSTR)
+ return (-1);
+
+ return (x86dis.d86_len);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.d.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.d.in
new file mode 100644
index 00000000..3328f335
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.d.in
@@ -0,0 +1,117 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+inline int R_GS = @GS@;
+#pragma D binding "1.0" R_GS
+inline int R_FS = @FS@;
+#pragma D binding "1.0" R_FS
+inline int R_ES = @ES@;
+#pragma D binding "1.0" R_ES
+inline int R_DS = @DS@;
+#pragma D binding "1.0" R_DS
+
+inline int R_EDI = @EDI@;
+#pragma D binding "1.0" R_EDI
+inline int R_ESI = @ESI@;
+#pragma D binding "1.0" R_ESI
+inline int R_EBP = @EBP@;
+#pragma D binding "1.0" R_EBP
+inline int R_ESP = @ESP@;
+#pragma D binding "1.0" R_ESP
+inline int R_EBX = @EBX@;
+#pragma D binding "1.0" R_EBX
+inline int R_EDX = @EDX@;
+#pragma D binding "1.0" R_EDX
+inline int R_ECX = @ECX@;
+#pragma D binding "1.0" R_ECX
+inline int R_EAX = @EAX@;
+#pragma D binding "1.0" R_EAX
+
+inline int R_TRAPNO = @TRAPNO@;
+#pragma D binding "1.0" R_TRAPNO
+inline int R_ERR = @ERR@;
+#pragma D binding "1.0" R_ERR
+inline int R_EIP = @EIP@;
+#pragma D binding "1.0" R_EIP
+inline int R_CS = @CS@;
+#pragma D binding "1.0" R_CS
+inline int R_EFL = @EFL@;
+#pragma D binding "1.0" R_EFL
+inline int R_UESP = @UESP@;
+#pragma D binding "1.0" R_UESP
+inline int R_SS = @SS@;
+#pragma D binding "1.0" R_SS
+
+inline int R_PC = R_EIP;
+#pragma D binding "1.0" R_PC
+inline int R_SP = R_UESP;
+#pragma D binding "1.0" R_SP
+inline int R_PS = R_EFL;
+#pragma D binding "1.0" R_PS
+inline int R_R0 = R_EAX;
+#pragma D binding "1.0" R_R0
+inline int R_R1 = R_EBX;
+#pragma D binding "1.0" R_R1
+
+inline int R_RSP = @REG_RSP@;
+#pragma D binding "1.0" R_RSP
+inline int R_RFL = @REG_RFL@;
+#pragma D binding "1.0" R_RFL
+inline int R_RIP = @REG_RIP@;
+#pragma D binding "1.0" R_RIP
+inline int R_RAX = @REG_RAX@;
+#pragma D binding "1.0" R_RAX
+inline int R_RCX = @REG_RCX@;
+#pragma D binding "1.0" R_RCX
+inline int R_RDX = @REG_RDX@;
+#pragma D binding "1.0" R_RDX
+inline int R_RBX = @REG_RBX@;
+#pragma D binding "1.0" R_RBX
+inline int R_RBP = @REG_RBP@;
+#pragma D binding "1.0" R_RBP
+inline int R_RSI = @REG_RSI@;
+#pragma D binding "1.0" R_RSI
+inline int R_RDI = @REG_RDI@;
+#pragma D binding "1.0" R_RDI
+inline int R_R8 = @REG_R8@;
+#pragma D binding "1.0" R_R8
+inline int R_R9 = @REG_R9@;
+#pragma D binding "1.0" R_R9
+inline int R_R10 = @REG_R10@;
+#pragma D binding "1.0" R_R10
+inline int R_R11 = @REG_R11@;
+#pragma D binding "1.0" R_R11
+inline int R_R12 = @REG_R12@;
+#pragma D binding "1.0" R_R12
+inline int R_R13 = @REG_R13@;
+#pragma D binding "1.0" R_R13
+inline int R_R14 = @REG_R14@;
+#pragma D binding "1.0" R_R14
+inline int R_R15 = @REG_R15@;
+#pragma D binding "1.0" R_R15
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.sed.in b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.sed.in
new file mode 100644
index 00000000..2b2080fc
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/i386/regs.sed.in
@@ -0,0 +1,82 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * This file is a sed script which is first preprocessed by cpp or cc -E to
+ * define a set of sed directives which replace #define tokens with their
+ * values. After preprocessing, whitespace is eliminated, and any @ symbols
+ * are translated into single space. The resulting sed script is then run
+ * over regs.d.in to replace the #define tokens listed below to create the
+ * finished regs.d. Refer to the rules in libdtrace/i386/Makefile for more
+ * information.
+ */
+
+#include <sys/regset.h>
+
+#define SED_REPLACE(x) s/#x/x/g
+#define SED_REPLACE64(x) s/#x/SS @+@1@+@ x/g
+
+SED_REPLACE(GS)
+SED_REPLACE(FS)
+SED_REPLACE(ES)
+SED_REPLACE(DS)
+SED_REPLACE(EDI)
+SED_REPLACE(ESI)
+SED_REPLACE(EBP)
+SED_REPLACE(ESP)
+SED_REPLACE(EBX)
+SED_REPLACE(EDX)
+SED_REPLACE(ECX)
+SED_REPLACE(EAX)
+SED_REPLACE(TRAPNO)
+SED_REPLACE(ERR)
+SED_REPLACE(EIP)
+SED_REPLACE(CS)
+SED_REPLACE(EFL)
+SED_REPLACE(UESP)
+SED_REPLACE(SS)
+
+SED_REPLACE64(REG_RSP)
+SED_REPLACE64(REG_RFL)
+SED_REPLACE64(REG_RIP)
+SED_REPLACE64(REG_RAX)
+SED_REPLACE64(REG_RCX)
+SED_REPLACE64(REG_RDX)
+SED_REPLACE64(REG_RBX)
+SED_REPLACE64(REG_RBP)
+SED_REPLACE64(REG_RSI)
+SED_REPLACE64(REG_RDI)
+SED_REPLACE64(REG_R8)
+SED_REPLACE64(REG_R9)
+SED_REPLACE64(REG_R10)
+SED_REPLACE64(REG_R11)
+SED_REPLACE64(REG_R12)
+SED_REPLACE64(REG_R13)
+SED_REPLACE64(REG_R14)
+SED_REPLACE64(REG_R15)
+
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile
new file mode 100644
index 00000000..99c63ef9
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile
@@ -0,0 +1,33 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+ASFLAGS += -D_ASM -K PIC -P
+
+include ../Makefile.com
+
+install yydebug: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) \
+ $(ROOTDLIBS) $(ROOTDOBJS)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/dt_isadep.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/dt_isadep.c
new file mode 100644
index 00000000..ed05275e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/dt_isadep.c
@@ -0,0 +1,338 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <libgen.h>
+
+#include <dt_impl.h>
+#include <dt_pid.h>
+
+#define OP(x) ((x) >> 30)
+#define OP2(x) (((x) >> 22) & 0x07)
+#define COND(x) (((x) >> 25) & 0x0f)
+#define A(x) (((x) >> 29) & 0x01)
+
+#define OP_BRANCH 0
+
+#define OP2_BPcc 0x1
+#define OP2_Bicc 0x2
+#define OP2_BPr 0x3
+#define OP2_FBPfcc 0x5
+#define OP2_FBfcc 0x6
+
+/*ARGSUSED*/
+int
+dt_pid_create_entry_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp)
+{
+ ftp->ftps_type = DTFTP_ENTRY;
+ ftp->ftps_pc = (uintptr_t)symp->st_value;
+ ftp->ftps_size = (size_t)symp->st_size;
+ ftp->ftps_noffs = 1;
+ ftp->ftps_offs[0] = 0;
+
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (1);
+}
+
+int
+dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, uint64_t *stret)
+{
+
+ uint32_t *text;
+ int i;
+ int srdepth = 0;
+
+ if ((text = malloc(symp->st_size + 4)) == NULL) {
+ dt_dprintf("mr sparkle: malloc() failed\n");
+ return (DT_PROC_ERR);
+ }
+
+ if (Pread(P, text, symp->st_size, symp->st_value) != symp->st_size) {
+ dt_dprintf("mr sparkle: Pread() failed\n");
+ free(text);
+ return (DT_PROC_ERR);
+ }
+
+ /*
+ * Leave a dummy instruction in the last slot to simplify edge
+ * conditions.
+ */
+ text[symp->st_size / 4] = 0;
+
+ ftp->ftps_type = DTFTP_RETURN;
+ ftp->ftps_pc = symp->st_value;
+ ftp->ftps_size = symp->st_size;
+ ftp->ftps_noffs = 0;
+
+ for (i = 0; i < symp->st_size / 4; i++) {
+ /*
+ * If we encounter an existing tracepoint, query the
+ * kernel to find out the instruction that was
+ * replaced at this spot.
+ */
+ while (text[i] == FASTTRAP_INSTR) {
+ fasttrap_instr_query_t instr;
+
+ instr.ftiq_pid = Pstatus(P)->pr_pid;
+ instr.ftiq_pc = symp->st_value + i * 4;
+
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_GETINSTR,
+ &instr) != 0) {
+
+ if (errno == ESRCH || errno == ENOENT) {
+ if (Pread(P, &text[i], 4,
+ instr.ftiq_pc) != 4) {
+ dt_dprintf("mr sparkle: "
+ "Pread() failed\n");
+ free(text);
+ return (DT_PROC_ERR);
+ }
+ continue;
+ }
+
+ free(text);
+ dt_dprintf("mr sparkle: getinstr query "
+ "failed: %s\n", strerror(errno));
+ return (DT_PROC_ERR);
+ }
+
+ text[i] = instr.ftiq_instr;
+ break;
+ }
+
+ /* save */
+ if ((text[i] & 0xc1f80000) == 0x81e00000) {
+ srdepth++;
+ continue;
+ }
+
+ /* restore */
+ if ((text[i] & 0xc1f80000) == 0x81e80000) {
+ srdepth--;
+ continue;
+ }
+
+ if (srdepth > 0) {
+ /* ret */
+ if (text[i] == 0x81c7e008)
+ goto is_ret;
+
+ /* return */
+ if (text[i] == 0x81cfe008)
+ goto is_ret;
+
+ /* call or jmpl w/ restore in the slot */
+ if (((text[i] & 0xc0000000) == 0x40000000 ||
+ (text[i] & 0xc1f80000) == 0x81c00000) &&
+ (text[i + 1] & 0xc1f80000) == 0x81e80000)
+ goto is_ret;
+
+ /* call to one of the stret routines */
+ if ((text[i] & 0xc0000000) == 0x40000000) {
+ int32_t disp = text[i] << 2;
+ uint64_t dest = ftp->ftps_pc + i * 4 + disp;
+
+ dt_dprintf("dest = %llx\n", (u_longlong_t)dest);
+
+ if (dest == stret[0] || dest == stret[1] ||
+ dest == stret[2] || dest == stret[3])
+ goto is_ret;
+ }
+ } else {
+ /* external call */
+ if ((text[i] & 0xc0000000) == 0x40000000) {
+ int32_t dst = text[i] << 2;
+
+ dst += i * 4;
+
+ if ((uintptr_t)dst >= (uintptr_t)symp->st_size)
+ goto is_ret;
+ }
+
+ /* jmpl into %g0 -- this includes the retl pseudo op */
+ if ((text[i] & 0xfff80000) == 0x81c00000)
+ goto is_ret;
+
+ /* external branch -- possible return site */
+ if (OP(text[i]) == OP_BRANCH) {
+ int32_t dst;
+ int baa;
+
+ switch (OP2(text[i])) {
+ case OP2_BPcc:
+ dst = text[i] & 0x7ffff;
+ dst <<= 13;
+ dst >>= 11;
+
+ baa = COND(text[i]) == 8 && A(text[i]);
+ break;
+ case OP2_Bicc:
+ dst = text[i] & 0x3fffff;
+ dst <<= 10;
+ dst >>= 8;
+
+ baa = COND(text[i]) == 8 && A(text[i]);
+ break;
+ case OP2_BPr:
+ dst = (((text[i]) >> 6) & 0xc000) |
+ ((text[i]) & 0x3fff);
+ dst <<= 16;
+ dst >>= 14;
+
+ baa = 0;
+ break;
+ case OP2_FBPfcc:
+ dst = text[i] & 0x7ffff;
+ dst <<= 13;
+ dst >>= 11;
+
+ baa = COND(text[i]) == 8 && A(text[i]);
+ break;
+ case OP2_FBfcc:
+ dst = text[i] & 0x3fffff;
+ dst <<= 10;
+ dst >>= 8;
+
+ baa = COND(text[i]) == 8 && A(text[i]);
+ break;
+ default:
+ continue;
+ }
+
+ dst += i * 4;
+
+ /*
+ * Interpret branches outside of the function's
+ * bounds as potential return sites. If the
+ * branch is a ba,a don't skip the instruction
+ * in the delay slot.
+ */
+ if ((uintptr_t)dst >=
+ (uintptr_t)symp->st_size) {
+ if (baa)
+ goto is_ret_baa;
+ else
+ goto is_ret;
+ }
+ }
+ }
+
+ continue;
+is_ret:
+ i++;
+is_ret_baa:
+ dt_dprintf("return at offset %x\n", i * 4);
+ ftp->ftps_offs[ftp->ftps_noffs++] = i * 4;
+ }
+
+ free(text);
+ if (ftp->ftps_noffs > 0) {
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+ }
+
+
+ return (ftp->ftps_noffs);
+}
+
+/*ARGSUSED*/
+int
+dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, ulong_t off)
+{
+ if (off & 0x3)
+ return (DT_PROC_ALIGN);
+
+ ftp->ftps_type = DTFTP_OFFSETS;
+ ftp->ftps_pc = (uintptr_t)symp->st_value;
+ ftp->ftps_size = (size_t)symp->st_size;
+ ftp->ftps_noffs = 1;
+ ftp->ftps_offs[0] = off;
+
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (1);
+}
+
+/*ARGSUSED*/
+int
+dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp,
+ fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, const char *pattern)
+{
+ ulong_t i;
+
+ ftp->ftps_type = DTFTP_OFFSETS;
+ ftp->ftps_pc = (uintptr_t)symp->st_value;
+ ftp->ftps_size = (size_t)symp->st_size;
+ ftp->ftps_noffs = 0;
+
+ /*
+ * If we're matching against everything, just iterate through each
+ * instruction in the function, otherwise look for matching offset
+ * names by constructing the string and comparing it against the
+ * pattern.
+ */
+ if (strcmp("*", pattern) == 0) {
+ for (i = 0; i < symp->st_size; i += 4) {
+ ftp->ftps_offs[ftp->ftps_noffs++] = i;
+ }
+ } else {
+ char name[sizeof (i) * 2 + 1];
+
+ for (i = 0; i < symp->st_size; i += 4) {
+ (void) sprintf(name, "%lx", i);
+ if (gmatch(name, pattern))
+ ftp->ftps_offs[ftp->ftps_noffs++] = i;
+ }
+ }
+
+ if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
+ dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
+ strerror(errno));
+ return (dt_set_errno(dtp, errno));
+ }
+
+ return (ftp->ftps_noffs);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/regs.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/regs.d
new file mode 100644
index 00000000..7c4bc0fa
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparc/regs.d
@@ -0,0 +1,120 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+inline int R_G0 = 0;
+#pragma D binding "1.0" R_G0
+inline int R_G1 = 1;
+#pragma D binding "1.0" R_G1
+inline int R_G2 = 2;
+#pragma D binding "1.0" R_G2
+inline int R_G3 = 3;
+#pragma D binding "1.0" R_G3
+inline int R_G4 = 4;
+#pragma D binding "1.0" R_G4
+inline int R_G5 = 5;
+#pragma D binding "1.0" R_G5
+inline int R_G6 = 6;
+#pragma D binding "1.0" R_G6
+inline int R_G7 = 7;
+#pragma D binding "1.0" R_G7
+
+inline int R_O0 = 8;
+#pragma D binding "1.0" R_O0
+inline int R_O1 = 9;
+#pragma D binding "1.0" R_O1
+inline int R_O2 = 10;
+#pragma D binding "1.0" R_O2
+inline int R_O3 = 11;
+#pragma D binding "1.0" R_O3
+inline int R_O4 = 12;
+#pragma D binding "1.0" R_O4
+inline int R_O5 = 13;
+#pragma D binding "1.0" R_O5
+inline int R_O6 = 14;
+#pragma D binding "1.0" R_O6
+inline int R_O7 = 15;
+#pragma D binding "1.0" R_O7
+
+inline int R_L0 = 16;
+#pragma D binding "1.0" R_L0
+inline int R_L1 = 17;
+#pragma D binding "1.0" R_L1
+inline int R_L2 = 18;
+#pragma D binding "1.0" R_L2
+inline int R_L3 = 19;
+#pragma D binding "1.0" R_L3
+inline int R_L4 = 20;
+#pragma D binding "1.0" R_L4
+inline int R_L5 = 21;
+#pragma D binding "1.0" R_L5
+inline int R_L6 = 22;
+#pragma D binding "1.0" R_L6
+inline int R_L7 = 23;
+#pragma D binding "1.0" R_L7
+
+inline int R_I0 = 24;
+#pragma D binding "1.0" R_I0
+inline int R_I1 = 25;
+#pragma D binding "1.0" R_I1
+inline int R_I2 = 26;
+#pragma D binding "1.0" R_I2
+inline int R_I3 = 27;
+#pragma D binding "1.0" R_I3
+inline int R_I4 = 28;
+#pragma D binding "1.0" R_I4
+inline int R_I5 = 29;
+#pragma D binding "1.0" R_I5
+inline int R_I6 = 30;
+#pragma D binding "1.0" R_I6
+inline int R_I7 = 31;
+#pragma D binding "1.0" R_I7
+
+inline int R_CCR = 32;
+#pragma D binding "1.0" R_CCR
+inline int R_PC = 33;
+#pragma D binding "1.0" R_PC
+inline int R_nPC = 34;
+#pragma D binding "1.0" R_nPC
+inline int R_NPC = R_nPC;
+#pragma D binding "1.0" R_NPC
+inline int R_Y = 35;
+#pragma D binding "1.0" R_Y
+inline int R_ASI = 36;
+#pragma D binding "1.0" R_ASI
+inline int R_FPRS = 37;
+#pragma D binding "1.0" R_FPRS
+inline int R_PS = R_CCR;
+#pragma D binding "1.0" R_PS
+inline int R_SP = R_O6;
+#pragma D binding "1.0" R_SP
+inline int R_FP = R_I6;
+#pragma D binding "1.0" R_FP
+inline int R_R0 = R_O0;
+#pragma D binding "1.0" R_R0
+inline int R_R1 = R_O1;
+#pragma D binding "1.0" R_R1
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile
new file mode 100644
index 00000000..0e3892db
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile
@@ -0,0 +1,36 @@
+#
+# 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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+ASFLAGS += -D_ASM -K PIC -P
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+CPPFLAGS += -D_ELF64
+
+install yydebug: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) \
+ $(ROOTDLIBS) $(ROOTDOBJS64)
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/sparcv9/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.c
new file mode 100644
index 00000000..d4ca1d30
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.c
@@ -0,0 +1,1214 @@
+/*
+ * 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 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <sys/errno.h>
+#include <sys/cpuvar.h>
+#include <sys/stat.h>
+#include <sys/modctl.h>
+#include <sys/cmn_err.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/ksynch.h>
+#include <sys/conf.h>
+#include <sys/kmem.h>
+#include <sys/kcpc.h>
+#include <sys/cap_util.h>
+#include <sys/cpc_pcbe.h>
+#include <sys/cpc_impl.h>
+#include <sys/dtrace_impl.h>
+
+/*
+ * DTrace CPU Performance Counter Provider
+ * ---------------------------------------
+ *
+ * The DTrace cpc provider allows DTrace consumers to access the CPU
+ * performance counter overflow mechanism of a CPU. The configuration
+ * presented in a probe specification is programmed into the performance
+ * counter hardware of all available CPUs on a system. Programming the
+ * hardware causes a counter on each CPU to begin counting events of the
+ * given type. When the specified number of events have occurred, an overflow
+ * interrupt will be generated and the probe is fired.
+ *
+ * The required configuration for the performance counter is encoded into
+ * the probe specification and this includes the performance counter event
+ * name, processor mode, overflow rate and an optional unit mask.
+ *
+ * Most processors provide several counters (PICs) which can count all or a
+ * subset of the events available for a given CPU. However, when overflow
+ * profiling is being used, not all CPUs can detect which counter generated the
+ * overflow interrupt. In this case we cannot reliably determine which counter
+ * overflowed and we therefore only allow such CPUs to configure one event at
+ * a time. Processors that can determine the counter which overflowed are
+ * allowed to program as many events at one time as possible (in theory up to
+ * the number of instrumentation counters supported by that platform).
+ * Therefore, multiple consumers can enable multiple probes at the same time
+ * on such platforms. Platforms which cannot determine the source of an
+ * overflow interrupt are only allowed to program a single event at one time.
+ *
+ * The performance counter hardware is made available to consumers on a
+ * first-come, first-served basis. Only a finite amount of hardware resource
+ * is available and, while we make every attempt to accomodate requests from
+ * consumers, we must deny requests when hardware resources have been exhausted.
+ * A consumer will fail to enable probes when resources are currently in use.
+ *
+ * The cpc provider contends for shared hardware resources along with other
+ * consumers of the kernel CPU performance counter subsystem (e.g. cpustat(1M)).
+ * Only one such consumer can use the performance counters at any one time and
+ * counters are made available on a first-come, first-served basis. As with
+ * cpustat, the cpc provider has priority over per-LWP libcpc usage (e.g.
+ * cputrack(1)). Invoking the cpc provider will cause all existing per-LWP
+ * counter contexts to be invalidated.
+ */
+
+typedef struct dcpc_probe {
+ char dcpc_event_name[CPC_MAX_EVENT_LEN];
+ int dcpc_flag; /* flags (USER/SYS) */
+ uint32_t dcpc_ovfval; /* overflow value */
+ int64_t dcpc_umask; /* umask/emask for this event */
+ int dcpc_picno; /* pic this event is programmed in */
+ int dcpc_enabled; /* probe is actually enabled? */
+ int dcpc_disabling; /* probe is currently being disabled */
+ dtrace_id_t dcpc_id; /* probeid this request is enabling */
+ int dcpc_actv_req_idx; /* idx into dcpc_actv_reqs[] */
+} dcpc_probe_t;
+
+static dev_info_t *dcpc_devi;
+static dtrace_provider_id_t dcpc_pid;
+static dcpc_probe_t **dcpc_actv_reqs;
+static uint32_t dcpc_enablings = 0;
+static int dcpc_ovf_mask = 0;
+static int dcpc_mult_ovf_cap = 0;
+static int dcpc_mask_type = 0;
+
+/*
+ * When the dcpc provider is loaded, dcpc_min_overflow is set to either
+ * DCPC_MIN_OVF_DEFAULT or the value that dcpc-min-overflow is set to in
+ * the dcpc.conf file. Decrease this value to set probes with smaller
+ * overflow values. Remember that very small values could render a system
+ * unusable with frequently occurring events.
+ */
+#define DCPC_MIN_OVF_DEFAULT 5000
+static uint32_t dcpc_min_overflow;
+
+static int dcpc_aframes = 0; /* override for artificial frame setting */
+#if defined(__x86)
+#define DCPC_ARTIFICIAL_FRAMES 8
+#elif defined(__sparc)
+#define DCPC_ARTIFICIAL_FRAMES 2
+#endif
+
+/*
+ * Called from the platform overflow interrupt handler. 'bitmap' is a mask
+ * which contains the pic(s) that have overflowed.
+ */
+static void
+dcpc_fire(uint64_t bitmap)
+{
+ int i;
+
+ /*
+ * No counter was marked as overflowing. Shout about it and get out.
+ */
+ if ((bitmap & dcpc_ovf_mask) == 0) {
+ cmn_err(CE_NOTE, "dcpc_fire: no counter overflow found\n");
+ return;
+ }
+
+ /*
+ * This is the common case of a processor that doesn't support
+ * multiple overflow events. Such systems are only allowed a single
+ * enabling and therefore we just look for the first entry in
+ * the active request array.
+ */
+ if (!dcpc_mult_ovf_cap) {
+ for (i = 0; i < cpc_ncounters; i++) {
+ if (dcpc_actv_reqs[i] != NULL) {
+ dtrace_probe(dcpc_actv_reqs[i]->dcpc_id,
+ CPU->cpu_cpcprofile_pc,
+ CPU->cpu_cpcprofile_upc, 0, 0, 0);
+ return;
+ }
+ }
+ return;
+ }
+
+ /*
+ * This is a processor capable of handling multiple overflow events.
+ * Iterate over the array of active requests and locate the counters
+ * that overflowed (note: it is possible for more than one counter to
+ * have overflowed at the same time).
+ */
+ for (i = 0; i < cpc_ncounters; i++) {
+ if (dcpc_actv_reqs[i] != NULL &&
+ (bitmap & (1ULL << dcpc_actv_reqs[i]->dcpc_picno))) {
+ dtrace_probe(dcpc_actv_reqs[i]->dcpc_id,
+ CPU->cpu_cpcprofile_pc,
+ CPU->cpu_cpcprofile_upc, 0, 0, 0);
+ }
+ }
+}
+
+static void
+dcpc_create_probe(dtrace_provider_id_t id, const char *probename,
+ char *eventname, int64_t umask, uint32_t ovfval, char flag)
+{
+ dcpc_probe_t *pp;
+ int nr_frames = DCPC_ARTIFICIAL_FRAMES + dtrace_mach_aframes();
+
+ if (dcpc_aframes)
+ nr_frames = dcpc_aframes;
+
+ if (dtrace_probe_lookup(id, NULL, NULL, probename) != 0)
+ return;
+
+ pp = kmem_zalloc(sizeof (dcpc_probe_t), KM_SLEEP);
+ (void) strncpy(pp->dcpc_event_name, eventname,
+ sizeof (pp->dcpc_event_name) - 1);
+ pp->dcpc_event_name[sizeof (pp->dcpc_event_name) - 1] = '\0';
+ pp->dcpc_flag = flag | CPC_OVF_NOTIFY_EMT;
+ pp->dcpc_ovfval = ovfval;
+ pp->dcpc_umask = umask;
+ pp->dcpc_actv_req_idx = pp->dcpc_picno = pp->dcpc_disabling = -1;
+
+ pp->dcpc_id = dtrace_probe_create(id, NULL, NULL, probename,
+ nr_frames, pp);
+}
+
+/*ARGSUSED*/
+static void
+dcpc_provide(void *arg, const dtrace_probedesc_t *desc)
+{
+ /*
+ * The format of a probe is:
+ *
+ * event_name-mode-{optional_umask}-overflow_rate
+ * e.g.
+ * DC_refill_from_system-user-0x1e-50000, or,
+ * DC_refill_from_system-all-10000
+ *
+ */
+ char *str, *end, *p;
+ int i, flag = 0;
+ char event[CPC_MAX_EVENT_LEN];
+ long umask = -1, val = 0;
+ size_t evlen, len;
+
+ /*
+ * The 'cpc' provider offers no probes by default.
+ */
+ if (desc == NULL)
+ return;
+
+ len = strlen(desc->dtpd_name);
+ p = str = kmem_alloc(len + 1, KM_SLEEP);
+ (void) strcpy(str, desc->dtpd_name);
+
+ /*
+ * We have a poor man's strtok() going on here. Replace any hyphens
+ * in the the probe name with NULL characters in order to make it
+ * easy to parse the string with regular string functions.
+ */
+ for (i = 0; i < len; i++) {
+ if (str[i] == '-')
+ str[i] = '\0';
+ }
+
+ /*
+ * The first part of the string must be either a platform event
+ * name or a generic event name.
+ */
+ evlen = strlen(p);
+ (void) strncpy(event, p, CPC_MAX_EVENT_LEN - 1);
+ event[CPC_MAX_EVENT_LEN - 1] = '\0';
+
+ /*
+ * The next part of the name is the mode specification. Valid
+ * settings are "user", "kernel" or "all".
+ */
+ p += evlen + 1;
+
+ if (strcmp(p, "user") == 0)
+ flag |= CPC_COUNT_USER;
+ else if (strcmp(p, "kernel") == 0)
+ flag |= CPC_COUNT_SYSTEM;
+ else if (strcmp(p, "all") == 0)
+ flag |= CPC_COUNT_USER | CPC_COUNT_SYSTEM;
+ else
+ goto err;
+
+ /*
+ * Next we either have a mask specification followed by an overflow
+ * rate or just an overflow rate on its own.
+ */
+ p += strlen(p) + 1;
+ if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
+ /*
+ * A unit mask can only be specified if:
+ * 1) this performance counter back end supports masks.
+ * 2) the specified event is platform specific.
+ * 3) a valid hex number is converted.
+ * 4) no extraneous characters follow the mask specification.
+ */
+ if (dcpc_mask_type != 0 && strncmp(event, "PAPI", 4) != 0 &&
+ ddi_strtol(p, &end, 16, &umask) == 0 &&
+ end == p + strlen(p)) {
+ p += strlen(p) + 1;
+ } else {
+ goto err;
+ }
+ }
+
+ /*
+ * This final part must be an overflow value which has to be greater
+ * than the minimum permissible overflow rate.
+ */
+ if ((ddi_strtol(p, &end, 10, &val) != 0) || end != p + strlen(p) ||
+ val < dcpc_min_overflow)
+ goto err;
+
+ /*
+ * Validate the event and create the probe.
+ */
+ for (i = 0; i < cpc_ncounters; i++) {
+ char *events, *cp, *p, *end;
+ int found = 0, j;
+ size_t llen;
+
+ if ((events = kcpc_list_events(i)) == NULL)
+ goto err;
+
+ llen = strlen(events);
+ p = cp = ddi_strdup(events, KM_NOSLEEP);
+ end = cp + llen;
+
+ for (j = 0; j < llen; j++) {
+ if (cp[j] == ',')
+ cp[j] = '\0';
+ }
+
+ while (p < end && found == 0) {
+ if (strcmp(p, event) == 0) {
+ dcpc_create_probe(dcpc_pid, desc->dtpd_name,
+ event, umask, (uint32_t)val, flag);
+ found = 1;
+ }
+ p += strlen(p) + 1;
+ }
+ kmem_free(cp, llen + 1);
+
+ if (found)
+ break;
+ }
+
+err:
+ kmem_free(str, len + 1);
+}
+
+/*ARGSUSED*/
+static void
+dcpc_destroy(void *arg, dtrace_id_t id, void *parg)
+{
+ dcpc_probe_t *pp = parg;
+
+ ASSERT(pp->dcpc_enabled == 0);
+ kmem_free(pp, sizeof (dcpc_probe_t));
+}
+
+/*ARGSUSED*/
+static int
+dcpc_usermode(void *arg, dtrace_id_t id, void *parg)
+{
+ return (CPU->cpu_cpcprofile_pc == 0);
+}
+
+static void
+dcpc_populate_set(cpu_t *c, dcpc_probe_t *pp, kcpc_set_t *set, int reqno)
+{
+ kcpc_set_t *oset;
+ int i;
+
+ (void) strncpy(set->ks_req[reqno].kr_event, pp->dcpc_event_name,
+ CPC_MAX_EVENT_LEN);
+ set->ks_req[reqno].kr_config = NULL;
+ set->ks_req[reqno].kr_index = reqno;
+ set->ks_req[reqno].kr_picnum = -1;
+ set->ks_req[reqno].kr_flags = pp->dcpc_flag;
+
+ /*
+ * If a unit mask has been specified then detect which attribute
+ * the platform needs. For now, it's either "umask" or "emask".
+ */
+ if (pp->dcpc_umask >= 0) {
+ set->ks_req[reqno].kr_attr =
+ kmem_zalloc(sizeof (kcpc_attr_t), KM_SLEEP);
+ set->ks_req[reqno].kr_nattrs = 1;
+ if (dcpc_mask_type & DCPC_UMASK)
+ (void) strncpy(set->ks_req[reqno].kr_attr->ka_name,
+ "umask", 5);
+ else
+ (void) strncpy(set->ks_req[reqno].kr_attr->ka_name,
+ "emask", 5);
+ set->ks_req[reqno].kr_attr->ka_val = pp->dcpc_umask;
+ } else {
+ set->ks_req[reqno].kr_attr = NULL;
+ set->ks_req[reqno].kr_nattrs = 0;
+ }
+
+ /*
+ * If this probe is enabled, obtain its current countdown value
+ * and use that. The CPUs cpc context might not exist yet if we
+ * are dealing with a CPU that is just coming online.
+ */
+ if (pp->dcpc_enabled && (c->cpu_cpc_ctx != NULL)) {
+ oset = c->cpu_cpc_ctx->kc_set;
+
+ for (i = 0; i < oset->ks_nreqs; i++) {
+ if (strcmp(oset->ks_req[i].kr_event,
+ set->ks_req[reqno].kr_event) == 0) {
+ set->ks_req[reqno].kr_preset =
+ *(oset->ks_req[i].kr_data);
+ }
+ }
+ } else {
+ set->ks_req[reqno].kr_preset = UINT64_MAX - pp->dcpc_ovfval;
+ }
+
+ set->ks_nreqs++;
+}
+
+
+/*
+ * Create a fresh request set for the enablings represented in the
+ * 'dcpc_actv_reqs' array which contains the probes we want to be
+ * in the set. This can be called for several reasons:
+ *
+ * 1) We are on a single or multi overflow platform and we have no
+ * current events so we can just create the set and initialize it.
+ * 2) We are on a multi-overflow platform and we already have one or
+ * more existing events and we are adding a new enabling. Create a
+ * new set and copy old requests in and then add the new request.
+ * 3) We are on a multi-overflow platform and we have just removed an
+ * enabling but we still have enablings whch are valid. Create a new
+ * set and copy in still valid requests.
+ */
+static kcpc_set_t *
+dcpc_create_set(cpu_t *c)
+{
+ int i, reqno = 0;
+ int active_requests = 0;
+ kcpc_set_t *set;
+
+ /*
+ * First get a count of the number of currently active requests.
+ * Note that dcpc_actv_reqs[] should always reflect which requests
+ * we want to be in the set that is to be created. It is the
+ * responsibility of the caller of dcpc_create_set() to adjust that
+ * array accordingly beforehand.
+ */
+ for (i = 0; i < cpc_ncounters; i++) {
+ if (dcpc_actv_reqs[i] != NULL)
+ active_requests++;
+ }
+
+ set = kmem_zalloc(sizeof (kcpc_set_t), KM_SLEEP);
+
+ set->ks_req =
+ kmem_zalloc(sizeof (kcpc_request_t) * active_requests, KM_SLEEP);
+
+ set->ks_data =
+ kmem_zalloc(active_requests * sizeof (uint64_t), KM_SLEEP);
+
+ /*
+ * Look for valid entries in the active requests array and populate
+ * the request set for any entries found.
+ */
+ for (i = 0; i < cpc_ncounters; i++) {
+ if (dcpc_actv_reqs[i] != NULL) {
+ dcpc_populate_set(c, dcpc_actv_reqs[i], set, reqno);
+ reqno++;
+ }
+ }
+
+ return (set);
+}
+
+static int
+dcpc_program_cpu_event(cpu_t *c)
+{
+ int i, j, subcode;
+ kcpc_ctx_t *ctx, *octx;
+ kcpc_set_t *set;
+
+ set = dcpc_create_set(c);
+
+ set->ks_ctx = ctx = kcpc_ctx_alloc(KM_SLEEP);
+ ctx->kc_set = set;
+ ctx->kc_cpuid = c->cpu_id;
+
+ if (kcpc_assign_reqs(set, ctx) != 0)
+ goto err;
+
+ if (kcpc_configure_reqs(ctx, set, &subcode) != 0)
+ goto err;
+
+ for (i = 0; i < set->ks_nreqs; i++) {
+ for (j = 0; j < cpc_ncounters; j++) {
+ if (dcpc_actv_reqs[j] != NULL &&
+ strcmp(set->ks_req[i].kr_event,
+ dcpc_actv_reqs[j]->dcpc_event_name) == 0) {
+ dcpc_actv_reqs[j]->dcpc_picno =
+ set->ks_req[i].kr_picnum;
+ }
+ }
+ }
+
+ /*
+ * If we already have an active enabling then save the current cpc
+ * context away.
+ */
+ octx = c->cpu_cpc_ctx;
+
+ kcpc_cpu_program(c, ctx);
+
+ if (octx != NULL) {
+ kcpc_set_t *oset = octx->kc_set;
+ kmem_free(oset->ks_data, oset->ks_nreqs * sizeof (uint64_t));
+ kcpc_free_configs(oset);
+ kcpc_free_set(oset);
+ kcpc_ctx_free(octx);
+ }
+
+ return (0);
+
+err:
+ /*
+ * We failed to configure this request up so free things up and
+ * get out.
+ */
+ kcpc_free_configs(set);
+ kmem_free(set->ks_data, set->ks_nreqs * sizeof (uint64_t));
+ kcpc_free_set(set);
+ kcpc_ctx_free(ctx);
+
+ return (-1);
+}
+
+static void
+dcpc_disable_cpu(cpu_t *c)
+{
+ kcpc_ctx_t *ctx;
+ kcpc_set_t *set;
+
+ /*
+ * Leave this CPU alone if it's already offline.
+ */
+ if (c->cpu_flags & CPU_OFFLINE)
+ return;
+
+ /*
+ * Grab CPUs CPC context before kcpc_cpu_stop() stops counters and
+ * changes it.
+ */
+ ctx = c->cpu_cpc_ctx;
+
+ kcpc_cpu_stop(c, B_FALSE);
+
+ set = ctx->kc_set;
+
+ kcpc_free_configs(set);
+ kmem_free(set->ks_data, set->ks_nreqs * sizeof (uint64_t));
+ kcpc_free_set(set);
+ kcpc_ctx_free(ctx);
+}
+
+/*
+ * The dcpc_*_interrupts() routines are responsible for manipulating the
+ * per-CPU dcpc interrupt state byte. The purpose of the state byte is to
+ * synchronize processing of hardware overflow interrupts wth configuration
+ * changes made to the CPU performance counter subsystem by the dcpc provider.
+ *
+ * The dcpc provider claims ownership of the overflow interrupt mechanism
+ * by transitioning the state byte from DCPC_INTR_INACTIVE (indicating the
+ * dcpc provider is not in use) to DCPC_INTR_FREE (the dcpc provider owns the
+ * overflow mechanism and interrupts may be processed). Before modifying
+ * a CPUs configuration state the state byte is transitioned from
+ * DCPC_INTR_FREE to DCPC_INTR_CONFIG ("configuration in process" state).
+ * The hardware overflow handler, kcpc_hw_overflow_intr(), will only process
+ * an interrupt when a configuration is not in process (i.e. the state is
+ * marked as free). During interrupt processing the state is set to
+ * DCPC_INTR_PROCESSING by the overflow handler. When the last dcpc based
+ * enabling is removed, the state byte is set to DCPC_INTR_INACTIVE to indicate
+ * the dcpc provider is no longer interested in overflow interrupts.
+ */
+static void
+dcpc_block_interrupts(void)
+{
+ cpu_t *c = cpu_list;
+ uint8_t *state;
+
+ ASSERT(cpu_core[c->cpu_id].cpuc_dcpc_intr_state != DCPC_INTR_INACTIVE);
+
+ do {
+ state = &cpu_core[c->cpu_id].cpuc_dcpc_intr_state;
+
+ while (atomic_cas_8(state, DCPC_INTR_FREE,
+ DCPC_INTR_CONFIG) != DCPC_INTR_FREE)
+ continue;
+
+ } while ((c = c->cpu_next) != cpu_list);
+}
+
+/*
+ * Set all CPUs dcpc interrupt state to DCPC_INTR_FREE to indicate that
+ * overflow interrupts can be processed safely.
+ */
+static void
+dcpc_release_interrupts(void)
+{
+ cpu_t *c = cpu_list;
+
+ ASSERT(cpu_core[c->cpu_id].cpuc_dcpc_intr_state != DCPC_INTR_INACTIVE);
+
+ do {
+ cpu_core[c->cpu_id].cpuc_dcpc_intr_state = DCPC_INTR_FREE;
+ membar_producer();
+ } while ((c = c->cpu_next) != cpu_list);
+}
+
+/*
+ * Transition all CPUs dcpc interrupt state from DCPC_INTR_INACTIVE to
+ * to DCPC_INTR_FREE. This indicates that the dcpc provider is now
+ * responsible for handling all overflow interrupt activity. Should only be
+ * called before enabling the first dcpc based probe.
+ */
+static void
+dcpc_claim_interrupts(void)
+{
+ cpu_t *c = cpu_list;
+
+ ASSERT(cpu_core[c->cpu_id].cpuc_dcpc_intr_state == DCPC_INTR_INACTIVE);
+
+ do {
+ cpu_core[c->cpu_id].cpuc_dcpc_intr_state = DCPC_INTR_FREE;
+ membar_producer();
+ } while ((c = c->cpu_next) != cpu_list);
+}
+
+/*
+ * Set all CPUs dcpc interrupt state to DCPC_INTR_INACTIVE to indicate that
+ * the dcpc provider is no longer processing overflow interrupts. Only called
+ * during removal of the last dcpc based enabling.
+ */
+static void
+dcpc_surrender_interrupts(void)
+{
+ cpu_t *c = cpu_list;
+
+ ASSERT(cpu_core[c->cpu_id].cpuc_dcpc_intr_state != DCPC_INTR_INACTIVE);
+
+ do {
+ cpu_core[c->cpu_id].cpuc_dcpc_intr_state = DCPC_INTR_INACTIVE;
+ membar_producer();
+ } while ((c = c->cpu_next) != cpu_list);
+}
+
+/*
+ * dcpc_program_event() can be called owing to a new enabling or if a multi
+ * overflow platform has disabled a request but needs to program the requests
+ * that are still valid.
+ *
+ * Every invocation of dcpc_program_event() will create a new kcpc_ctx_t
+ * and a new request set which contains the new enabling and any old enablings
+ * which are still valid (possible with multi-overflow platforms).
+ */
+static int
+dcpc_program_event(dcpc_probe_t *pp)
+{
+ cpu_t *c;
+ int ret = 0;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ kpreempt_disable();
+
+ dcpc_block_interrupts();
+
+ c = cpu_list;
+
+ do {
+ /*
+ * Skip CPUs that are currently offline.
+ */
+ if (c->cpu_flags & CPU_OFFLINE)
+ continue;
+
+ /*
+ * Stop counters but preserve existing DTrace CPC context
+ * if there is one.
+ *
+ * If we come here when the first event is programmed for a CPU,
+ * there should be no DTrace CPC context installed. In this
+ * case, kcpc_cpu_stop() will ensure that there is no other
+ * context on the CPU.
+ *
+ * If we add new enabling to the original one, the CPU should
+ * have the old DTrace CPC context which we need to keep around
+ * since dcpc_program_event() will add to it.
+ */
+ if (c->cpu_cpc_ctx != NULL)
+ kcpc_cpu_stop(c, B_TRUE);
+ } while ((c = c->cpu_next) != cpu_list);
+
+ dcpc_release_interrupts();
+
+ /*
+ * If this enabling is being removed (in the case of a multi event
+ * capable system with more than one active enabling), we can now
+ * update the active request array to reflect the enablings that need
+ * to be reprogrammed.
+ */
+ if (pp->dcpc_disabling == 1)
+ dcpc_actv_reqs[pp->dcpc_actv_req_idx] = NULL;
+
+ do {
+ /*
+ * Skip CPUs that are currently offline.
+ */
+ if (c->cpu_flags & CPU_OFFLINE)
+ continue;
+
+ ret = dcpc_program_cpu_event(c);
+ } while ((c = c->cpu_next) != cpu_list && ret == 0);
+
+ /*
+ * If dcpc_program_cpu_event() fails then it is because we couldn't
+ * configure the requests in the set for the CPU and not because of
+ * an error programming the hardware. If we have a failure here then
+ * we assume no CPUs have been programmed in the above step as they
+ * are all configured identically.
+ */
+ if (ret != 0) {
+ pp->dcpc_enabled = 0;
+ kpreempt_enable();
+ return (-1);
+ }
+
+ if (pp->dcpc_disabling != 1)
+ pp->dcpc_enabled = 1;
+
+ kpreempt_enable();
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dcpc_enable(void *arg, dtrace_id_t id, void *parg)
+{
+ dcpc_probe_t *pp = parg;
+ int i, found = 0;
+ cpu_t *c;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ /*
+ * Bail out if the counters are being used by a libcpc consumer.
+ */
+ rw_enter(&kcpc_cpuctx_lock, RW_READER);
+ if (kcpc_cpuctx > 0) {
+ rw_exit(&kcpc_cpuctx_lock);
+ return (-1);
+ }
+
+ dtrace_cpc_in_use++;
+ rw_exit(&kcpc_cpuctx_lock);
+
+ /*
+ * Locate this enabling in the first free entry of the active
+ * request array.
+ */
+ for (i = 0; i < cpc_ncounters; i++) {
+ if (dcpc_actv_reqs[i] == NULL) {
+ dcpc_actv_reqs[i] = pp;
+ pp->dcpc_actv_req_idx = i;
+ found = 1;
+ break;
+ }
+ }
+
+ /*
+ * If we couldn't find a slot for this probe then there is no
+ * room at the inn.
+ */
+ if (!found) {
+ dtrace_cpc_in_use--;
+ return (-1);
+ }
+
+ ASSERT(pp->dcpc_actv_req_idx >= 0);
+
+ /*
+ * DTrace is taking over CPC contexts, so stop collecting
+ * capacity/utilization data for all CPUs.
+ */
+ if (dtrace_cpc_in_use == 1)
+ cu_disable();
+
+ /*
+ * The following must hold true if we are to (attempt to) enable
+ * this request:
+ *
+ * 1) No enablings currently exist. We allow all platforms to
+ * proceed if this is true.
+ *
+ * OR
+ *
+ * 2) If the platform is multi overflow capable and there are
+ * less valid enablings than there are counters. There is no
+ * guarantee that a platform can accommodate as many events as
+ * it has counters for but we will at least try to program
+ * up to that many requests.
+ *
+ * The 'dcpc_enablings' variable is implictly protected by locking
+ * provided by the DTrace framework and the cpu management framework.
+ */
+ if (dcpc_enablings == 0 || (dcpc_mult_ovf_cap &&
+ dcpc_enablings < cpc_ncounters)) {
+ /*
+ * Before attempting to program the first enabling we need to
+ * invalidate any lwp-based contexts and lay claim to the
+ * overflow interrupt mechanism.
+ */
+ if (dcpc_enablings == 0) {
+ kcpc_invalidate_all();
+ dcpc_claim_interrupts();
+ }
+
+ if (dcpc_program_event(pp) == 0) {
+ dcpc_enablings++;
+ return (0);
+ }
+ }
+
+ /*
+ * If active enablings existed before we failed to enable this probe
+ * on a multi event capable platform then we need to restart counters
+ * as they will have been stopped in the attempted configuration. The
+ * context should now just contain the request prior to this failed
+ * enabling.
+ */
+ if (dcpc_enablings > 0 && dcpc_mult_ovf_cap) {
+ c = cpu_list;
+
+ ASSERT(dcpc_mult_ovf_cap == 1);
+ do {
+ /*
+ * Skip CPUs that are currently offline.
+ */
+ if (c->cpu_flags & CPU_OFFLINE)
+ continue;
+
+ kcpc_cpu_program(c, c->cpu_cpc_ctx);
+ } while ((c = c->cpu_next) != cpu_list);
+ }
+
+ /*
+ * Give up any claim to the overflow interrupt mechanism if no
+ * dcpc based enablings exist.
+ */
+ if (dcpc_enablings == 0)
+ dcpc_surrender_interrupts();
+
+ dtrace_cpc_in_use--;
+ dcpc_actv_reqs[pp->dcpc_actv_req_idx] = NULL;
+ pp->dcpc_actv_req_idx = pp->dcpc_picno = -1;
+
+ /*
+ * If all probes are removed, enable capacity/utilization data
+ * collection for every CPU.
+ */
+ if (dtrace_cpc_in_use == 0)
+ cu_enable();
+
+ return (-1);
+}
+
+/*
+ * If only one enabling is active then remove the context and free
+ * everything up. If there are multiple enablings active then remove this
+ * one, its associated meta-data and re-program the hardware.
+ */
+/*ARGSUSED*/
+static void
+dcpc_disable(void *arg, dtrace_id_t id, void *parg)
+{
+ cpu_t *c;
+ dcpc_probe_t *pp = parg;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ kpreempt_disable();
+
+ /*
+ * This probe didn't actually make it as far as being fully enabled
+ * so we needn't do anything with it.
+ */
+ if (pp->dcpc_enabled == 0) {
+ /*
+ * If we actually allocated this request a slot in the
+ * request array but failed to enabled it then remove the
+ * entry in the array.
+ */
+ if (pp->dcpc_actv_req_idx >= 0) {
+ dcpc_actv_reqs[pp->dcpc_actv_req_idx] = NULL;
+ pp->dcpc_actv_req_idx = pp->dcpc_picno =
+ pp->dcpc_disabling = -1;
+ }
+
+ kpreempt_enable();
+ return;
+ }
+
+ /*
+ * If this is the only enabling then stop all the counters and
+ * free up the meta-data.
+ */
+ if (dcpc_enablings == 1) {
+ ASSERT(dtrace_cpc_in_use == 1);
+
+ dcpc_block_interrupts();
+
+ c = cpu_list;
+
+ do {
+ dcpc_disable_cpu(c);
+ } while ((c = c->cpu_next) != cpu_list);
+
+ dcpc_actv_reqs[pp->dcpc_actv_req_idx] = NULL;
+ dcpc_surrender_interrupts();
+ } else {
+ /*
+ * This platform can support multiple overflow events and
+ * the enabling being disabled is not the last one. Remove this
+ * enabling and re-program the hardware with the new config.
+ */
+ ASSERT(dcpc_mult_ovf_cap);
+ ASSERT(dcpc_enablings > 1);
+
+ pp->dcpc_disabling = 1;
+ (void) dcpc_program_event(pp);
+ }
+
+ kpreempt_enable();
+
+ dcpc_enablings--;
+ dtrace_cpc_in_use--;
+ pp->dcpc_enabled = 0;
+ pp->dcpc_actv_req_idx = pp->dcpc_picno = pp->dcpc_disabling = -1;
+
+ /*
+ * If all probes are removed, enable capacity/utilization data
+ * collection for every CPU
+ */
+ if (dtrace_cpc_in_use == 0)
+ cu_enable();
+}
+
+/*ARGSUSED*/
+static int
+dcpc_cpu_setup(cpu_setup_t what, processorid_t cpu, void *arg)
+{
+ cpu_t *c;
+ uint8_t *state;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ switch (what) {
+ case CPU_OFF:
+ /*
+ * Offline CPUs are not allowed to take part so remove this
+ * CPU if we are actively tracing.
+ */
+ if (dtrace_cpc_in_use) {
+ c = cpu_get(cpu);
+ state = &cpu_core[c->cpu_id].cpuc_dcpc_intr_state;
+
+ /*
+ * Indicate that a configuration is in process in
+ * order to stop overflow interrupts being processed
+ * on this CPU while we disable it.
+ */
+ while (atomic_cas_8(state, DCPC_INTR_FREE,
+ DCPC_INTR_CONFIG) != DCPC_INTR_FREE)
+ continue;
+
+ dcpc_disable_cpu(c);
+
+ /*
+ * Reset this CPUs interrupt state as the configuration
+ * has ended.
+ */
+ cpu_core[c->cpu_id].cpuc_dcpc_intr_state =
+ DCPC_INTR_FREE;
+ membar_producer();
+ }
+ break;
+
+ case CPU_ON:
+ case CPU_SETUP:
+ /*
+ * This CPU is being initialized or brought online so program
+ * it with the current request set if we are actively tracing.
+ */
+ if (dtrace_cpc_in_use) {
+ c = cpu_get(cpu);
+ (void) dcpc_program_cpu_event(c);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return (0);
+}
+
+static dtrace_pattr_t dcpc_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_CPU },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+};
+
+static dtrace_pops_t dcpc_pops = {
+ dcpc_provide,
+ NULL,
+ dcpc_enable,
+ dcpc_disable,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ dcpc_usermode,
+ dcpc_destroy
+};
+
+/*ARGSUSED*/
+static int
+dcpc_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+{
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+dcpc_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *)dcpc_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+static int
+dcpc_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (dtrace_unregister(dcpc_pid) != 0)
+ return (DDI_FAILURE);
+
+ ddi_remove_minor_node(devi, NULL);
+
+ mutex_enter(&cpu_lock);
+ unregister_cpu_setup_func(dcpc_cpu_setup, NULL);
+ mutex_exit(&cpu_lock);
+
+ kmem_free(dcpc_actv_reqs, cpc_ncounters * sizeof (dcpc_probe_t *));
+
+ kcpc_unregister_dcpc();
+
+ return (DDI_SUCCESS);
+}
+
+static int
+dcpc_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+{
+ uint_t caps;
+ char *attrs;
+
+ switch (cmd) {
+ case DDI_ATTACH:
+ break;
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (kcpc_pcbe_loaded() == -1)
+ return (DDI_FAILURE);
+
+ caps = kcpc_pcbe_capabilities();
+
+ if (!(caps & CPC_CAP_OVERFLOW_INTERRUPT)) {
+ cmn_err(CE_NOTE, "!dcpc: Counter Overflow not supported"\
+ " on this processor");
+ return (DDI_FAILURE);
+ }
+
+ if (ddi_create_minor_node(devi, "dcpc", S_IFCHR, 0,
+ DDI_PSEUDO, NULL) == DDI_FAILURE ||
+ dtrace_register("cpc", &dcpc_attr, DTRACE_PRIV_KERNEL,
+ NULL, &dcpc_pops, NULL, &dcpc_pid) != 0) {
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_FAILURE);
+ }
+
+ mutex_enter(&cpu_lock);
+ register_cpu_setup_func(dcpc_cpu_setup, NULL);
+ mutex_exit(&cpu_lock);
+
+ dcpc_ovf_mask = (1 << cpc_ncounters) - 1;
+ ASSERT(dcpc_ovf_mask != 0);
+
+ if (caps & CPC_CAP_OVERFLOW_PRECISE)
+ dcpc_mult_ovf_cap = 1;
+
+ /*
+ * Determine which, if any, mask attribute the back-end can use.
+ */
+ attrs = kcpc_list_attrs();
+ if (strstr(attrs, "umask") != NULL)
+ dcpc_mask_type |= DCPC_UMASK;
+ else if (strstr(attrs, "emask") != NULL)
+ dcpc_mask_type |= DCPC_EMASK;
+
+ /*
+ * The dcpc_actv_reqs array is used to store the requests that
+ * we currently have programmed. The order of requests in this
+ * array is not necessarily the order that the event appears in
+ * the kcpc_request_t array. Once entered into a slot in the array
+ * the entry is not moved until it's removed.
+ */
+ dcpc_actv_reqs =
+ kmem_zalloc(cpc_ncounters * sizeof (dcpc_probe_t *), KM_SLEEP);
+
+ dcpc_min_overflow = ddi_prop_get_int(DDI_DEV_T_ANY, devi,
+ DDI_PROP_DONTPASS, "dcpc-min-overflow", DCPC_MIN_OVF_DEFAULT);
+
+ kcpc_register_dcpc(dcpc_fire);
+
+ ddi_report_dev(devi);
+ dcpc_devi = devi;
+
+ return (DDI_SUCCESS);
+}
+
+static struct cb_ops dcpc_cb_ops = {
+ dcpc_open, /* open */
+ nodev, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ nodev, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_NEW | D_MP /* Driver compatibility flag */
+};
+
+static struct dev_ops dcpc_ops = {
+ DEVO_REV, /* devo_rev, */
+ 0, /* refcnt */
+ dcpc_info, /* get_dev_info */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ dcpc_attach, /* attach */
+ dcpc_detach, /* detach */
+ nodev, /* reset */
+ &dcpc_cb_ops, /* driver operations */
+ NULL, /* bus operations */
+ nodev, /* dev power */
+ ddi_quiesce_not_needed /* quiesce */
+};
+
+/*
+ * Module linkage information for the kernel.
+ */
+static struct modldrv modldrv = {
+ &mod_driverops, /* module type */
+ "DTrace CPC Module", /* name of module */
+ &dcpc_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1,
+ (void *)&modldrv,
+ NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.conf
new file mode 100644
index 00000000..3f186940
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dcpc.conf
@@ -0,0 +1,33 @@
+#
+# 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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+name="dcpc" parent="pseudo" instance=0;
+
+#
+# dcpc-min-overflow is the lower limit on the rate of overflow that can be
+# set on a probe. The default value is 5000. Decrease this value to create
+# probes with lower overflow values. Setting this value too low on a rapidly
+# increasing event could render a system unusable.
+#
+#dcpc-min-overflow=5000;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.c
new file mode 100644
index 00000000..201ce497
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.c
@@ -0,0 +1,16292 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * DTrace - Dynamic Tracing for Solaris
+ *
+ * This is the implementation of the Solaris Dynamic Tracing framework
+ * (DTrace). The user-visible interface to DTrace is described at length in
+ * the "Solaris Dynamic Tracing Guide". The interfaces between the libdtrace
+ * library, the in-kernel DTrace framework, and the DTrace providers are
+ * described in the block comments in the <sys/dtrace.h> header file. The
+ * internal architecture of DTrace is described in the block comments in the
+ * <sys/dtrace_impl.h> header file. The comments contained within the DTrace
+ * implementation very much assume mastery of all of these sources; if one has
+ * an unanswered question about the implementation, one should consult them
+ * first.
+ *
+ * The functions here are ordered roughly as follows:
+ *
+ * - Probe context functions
+ * - Probe hashing functions
+ * - Non-probe context utility functions
+ * - Matching functions
+ * - Provider-to-Framework API functions
+ * - Probe management functions
+ * - DIF object functions
+ * - Format functions
+ * - Predicate functions
+ * - ECB functions
+ * - Buffer functions
+ * - Enabling functions
+ * - DOF functions
+ * - Anonymous enabling functions
+ * - Consumer state functions
+ * - Helper functions
+ * - Hook functions
+ * - Driver cookbook functions
+ *
+ * Each group of functions begins with a block comment labelled the "DTrace
+ * [Group] Functions", allowing one to find each block by searching forward
+ * on capital-f functions.
+ */
+#ifndef VBOX
+#include <sys/errno.h>
+#include <sys/stat.h>
+#include <sys/modctl.h>
+#include <sys/conf.h>
+#include <sys/systm.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/cpuvar.h>
+#include <sys/kmem.h>
+#include <sys/strsubr.h>
+#include <sys/sysmacros.h>
+#include <sys/dtrace_impl.h>
+#include <sys/atomic.h>
+#include <sys/cmn_err.h>
+#include <sys/mutex_impl.h>
+#include <sys/rwlock_impl.h>
+#include <sys/ctf_api.h>
+#include <sys/panic.h>
+#include <sys/priv_impl.h>
+#include <sys/policy.h>
+#include <sys/cred_impl.h>
+#include <sys/procfs_isa.h>
+#include <sys/taskq.h>
+#include <sys/mkdev.h>
+#include <sys/kdi.h>
+#include <sys/zone.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#else /* VBOX */
+# include <sys/dtrace_impl.h>
+# include <VBox/sup.h>
+# include <iprt/assert.h>
+# include <iprt/cpuset.h>
+# include <iprt/err.h>
+# include <iprt/mem.h>
+# include <iprt/mp.h>
+# include <iprt/string.h>
+# include <iprt/process.h>
+# include <iprt/thread.h>
+# include <iprt/timer.h>
+# include <limits.h>
+
+# undef offsetof
+# define offsetof RT_OFFSETOF
+
+/*
+ * Use asm.h to implemente some of the simple stuff in dtrace_asm.s.
+ */
+# include <iprt/asm.h>
+# include <iprt/asm-amd64-x86.h>
+# define dtrace_casptr(a_ppvDst, a_pvOld, a_pvNew) \
+ VBoxDtCompareAndSwapPtr((void * volatile *)a_ppvDst, a_pvOld, a_pvNew)
+DECLINLINE(void *) VBoxDtCompareAndSwapPtr(void * volatile *ppvDst, void *pvOld, void *pvNew)
+{
+ void *pvRet;
+ ASMAtomicCmpXchgExPtrVoid(ppvDst, pvNew, pvOld, &pvRet);
+ return pvRet;
+}
+
+# define dtrace_cas32(a_pu32Dst, a_pu32Old, a_pu32New) \
+ VBoxDtCompareAndSwapU32(a_pu32Dst, a_pu32Old, a_pu32New)
+DECLINLINE(uint32_t) VBoxDtCompareAndSwapU32(uint32_t volatile *pu32Dst, uint32_t u32Old, uint32_t u32New)
+{
+ uint32_t u32Ret;
+ ASMAtomicCmpXchgExU32(pu32Dst, u32New, u32Old, &u32Ret);
+ return u32Ret;
+}
+
+#define dtrace_membar_consumer() ASMReadFence()
+#define dtrace_membar_producer() ASMWriteFence()
+#define dtrace_interrupt_disable() ASMIntDisableFlags()
+#define dtrace_interrupt_enable(a_EFL) ASMSetFlags(a_EFL)
+
+/*
+ * NULL must be set to 0 or we'll end up with a billion warnings(=errors).
+ */
+# undef NULL
+# define NULL (0)
+#endif /* VBOX */
+
+/** Check if the given address is a valid kernel address.
+ * The value can be uintptr_t or uint64_t. */
+#ifndef VBOX
+# define VBDT_IS_VALID_KRNL_ADDR(a_uAddr) ((a_uAddr) >= KERNELBASE)
+#else
+# define VBDT_IS_VALID_KRNL_ADDR(a_uAddr) \
+ ( (sizeof(a_uAddr) == sizeof(uintptr_t) || (uintptr_t)(a_uAddr) == (a_uAddr)) \
+ && RTR0MemKernelIsValidAddr((void *)(uintptr_t)(a_uAddr)) )
+#endif
+
+
+/*
+ * DTrace Tunable Variables
+ *
+ * The following variables may be tuned by adding a line to /etc/system that
+ * includes both the name of the DTrace module ("dtrace") and the name of the
+ * variable. For example:
+ *
+ * set dtrace:dtrace_destructive_disallow = 1
+ *
+ * In general, the only variables that one should be tuning this way are those
+ * that affect system-wide DTrace behavior, and for which the default behavior
+ * is undesirable. Most of these variables are tunable on a per-consumer
+ * basis using DTrace options, and need not be tuned on a system-wide basis.
+ * When tuning these variables, avoid pathological values; while some attempt
+ * is made to verify the integrity of these variables, they are not considered
+ * part of the supported interface to DTrace, and they are therefore not
+ * checked comprehensively. Further, these variables should not be tuned
+ * dynamically via "mdb -kw" or other means; they should only be tuned via
+ * /etc/system.
+ */
+int dtrace_destructive_disallow = 0;
+dtrace_optval_t dtrace_nonroot_maxsize = (16 * 1024 * 1024);
+size_t dtrace_difo_maxsize = (256 * 1024);
+dtrace_optval_t dtrace_dof_maxsize = (256 * 1024);
+size_t dtrace_global_maxsize = (16 * 1024);
+size_t dtrace_actions_max = (16 * 1024);
+size_t dtrace_retain_max = 1024;
+dtrace_optval_t dtrace_helper_actions_max = 32;
+dtrace_optval_t dtrace_helper_providers_max = 32;
+dtrace_optval_t dtrace_dstate_defsize = (1 * 1024 * 1024);
+size_t dtrace_strsize_default = 256;
+dtrace_optval_t dtrace_cleanrate_default = 9900990; /* 101 hz */
+dtrace_optval_t dtrace_cleanrate_min = 200000; /* 5000 hz */
+dtrace_optval_t dtrace_cleanrate_max = (uint64_t)60 * NANOSEC; /* 1/minute */
+dtrace_optval_t dtrace_aggrate_default = NANOSEC; /* 1 hz */
+dtrace_optval_t dtrace_statusrate_default = NANOSEC; /* 1 hz */
+dtrace_optval_t dtrace_statusrate_max = (hrtime_t)10 * NANOSEC; /* 6/minute */
+dtrace_optval_t dtrace_switchrate_default = NANOSEC; /* 1 hz */
+dtrace_optval_t dtrace_nspec_default = 1;
+dtrace_optval_t dtrace_specsize_default = 32 * 1024;
+dtrace_optval_t dtrace_stackframes_default = 20;
+dtrace_optval_t dtrace_ustackframes_default = 20;
+dtrace_optval_t dtrace_jstackframes_default = 50;
+dtrace_optval_t dtrace_jstackstrsize_default = 512;
+int dtrace_msgdsize_max = 128;
+hrtime_t dtrace_chill_max = 500 * (NANOSEC / MILLISEC); /* 500 ms */
+hrtime_t dtrace_chill_interval = NANOSEC; /* 1000 ms */
+int dtrace_devdepth_max = 32;
+int dtrace_err_verbose;
+hrtime_t dtrace_deadman_interval = NANOSEC;
+hrtime_t dtrace_deadman_timeout = (hrtime_t)10 * NANOSEC;
+hrtime_t dtrace_deadman_user = (hrtime_t)30 * NANOSEC;
+
+/*
+ * DTrace External Variables
+ *
+ * As dtrace(7D) is a kernel module, any DTrace variables are obviously
+ * available to DTrace consumers via the backtick (`) syntax. One of these,
+ * dtrace_zero, is made deliberately so: it is provided as a source of
+ * well-known, zero-filled memory. While this variable is not documented,
+ * it is used by some translators as an implementation detail.
+ */
+const char dtrace_zero[256] = { 0 }; /* zero-filled memory */
+
+/*
+ * DTrace Internal Variables
+ */
+#ifndef VBOX
+static dev_info_t *dtrace_devi; /* device info */
+#endif
+static vmem_t *dtrace_arena; /* probe ID arena */
+#ifndef VBOX
+static vmem_t *dtrace_minor; /* minor number arena */
+static taskq_t *dtrace_taskq; /* task queue */
+#endif
+static dtrace_probe_t **dtrace_probes; /* array of all probes */
+static VBDTTYPE(uint32_t,int) dtrace_nprobes; /* number of probes */
+static dtrace_provider_t *dtrace_provider; /* provider list */
+static dtrace_meta_t *dtrace_meta_pid; /* user-land meta provider */
+static int dtrace_opens; /* number of opens */
+static int dtrace_helpers; /* number of helpers */
+#ifndef VBOX
+static void *dtrace_softstate; /* softstate pointer */
+#endif
+static dtrace_hash_t *dtrace_bymod; /* probes hashed by module */
+static dtrace_hash_t *dtrace_byfunc; /* probes hashed by function */
+static dtrace_hash_t *dtrace_byname; /* probes hashed by name */
+static dtrace_toxrange_t *dtrace_toxrange; /* toxic range array */
+static int dtrace_toxranges; /* number of toxic ranges */
+static int dtrace_toxranges_max; /* size of toxic range array */
+static dtrace_anon_t dtrace_anon; /* anonymous enabling */
+static kmem_cache_t *dtrace_state_cache; /* cache for dynamic state */
+static uint64_t dtrace_vtime_references; /* number of vtimestamp refs */
+#ifndef VBOX
+static kthread_t *dtrace_panicked; /* panicking thread */
+#endif
+static dtrace_ecb_t *dtrace_ecb_create_cache; /* cached created ECB */
+static dtrace_genid_t dtrace_probegen; /* current probe generation */
+static dtrace_helpers_t *dtrace_deferred_pid; /* deferred helper list */
+static dtrace_enabling_t *dtrace_retained; /* list of retained enablings */
+static dtrace_genid_t dtrace_retained_gen; /* current retained enab gen */
+static dtrace_dynvar_t dtrace_dynhash_sink; /* end of dynamic hash chains */
+static int dtrace_dynvar_failclean; /* dynvars failed to clean */
+
+/*
+ * DTrace Locking
+ * DTrace is protected by three (relatively coarse-grained) locks:
+ *
+ * (1) dtrace_lock is required to manipulate essentially any DTrace state,
+ * including enabling state, probes, ECBs, consumer state, helper state,
+ * etc. Importantly, dtrace_lock is _not_ required when in probe context;
+ * probe context is lock-free -- synchronization is handled via the
+ * dtrace_sync() cross call mechanism.
+ *
+ * (2) dtrace_provider_lock is required when manipulating provider state, or
+ * when provider state must be held constant.
+ *
+ * (3) dtrace_meta_lock is required when manipulating meta provider state, or
+ * when meta provider state must be held constant.
+ *
+ * The lock ordering between these three locks is dtrace_meta_lock before
+ * dtrace_provider_lock before dtrace_lock. (In particular, there are
+ * several places where dtrace_provider_lock is held by the framework as it
+ * calls into the providers -- which then call back into the framework,
+ * grabbing dtrace_lock.)
+ *
+ * There are two other locks in the mix: mod_lock and cpu_lock. With respect
+ * to dtrace_provider_lock and dtrace_lock, cpu_lock continues its historical
+ * role as a coarse-grained lock; it is acquired before both of these locks.
+ * With respect to dtrace_meta_lock, its behavior is stranger: cpu_lock must
+ * be acquired _between_ dtrace_meta_lock and any other DTrace locks.
+ * mod_lock is similar with respect to dtrace_provider_lock in that it must be
+ * acquired _between_ dtrace_provider_lock and dtrace_lock.
+ */
+static kmutex_t dtrace_lock; /* probe state lock */
+static kmutex_t dtrace_provider_lock; /* provider state lock */
+static kmutex_t dtrace_meta_lock; /* meta-provider state lock */
+
+/*
+ * DTrace Provider Variables
+ *
+ * These are the variables relating to DTrace as a provider (that is, the
+ * provider of the BEGIN, END, and ERROR probes).
+ */
+static dtrace_pattr_t dtrace_provider_attr = {
+{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON },
+};
+
+static void
+dtrace_nullop(void)
+{}
+
+static int
+dtrace_enable_nullop(void)
+{
+ return (0);
+}
+
+static dtrace_pops_t dtrace_provider_ops = {
+ (void (*)(void *, const dtrace_probedesc_t *))dtrace_nullop,
+ (void (*)(void *, struct modctl *))dtrace_nullop,
+ (int (*)(void *, dtrace_id_t, void *))(uintptr_t)dtrace_enable_nullop,
+ (void (*)(void *, dtrace_id_t, void *))dtrace_nullop,
+ (void (*)(void *, dtrace_id_t, void *))dtrace_nullop,
+ (void (*)(void *, dtrace_id_t, void *))dtrace_nullop,
+ NULL,
+ NULL,
+ NULL,
+ (void (*)(void *, dtrace_id_t, void *))dtrace_nullop
+};
+
+static dtrace_id_t dtrace_probeid_begin; /* special BEGIN probe */
+static dtrace_id_t dtrace_probeid_end; /* special END probe */
+dtrace_id_t dtrace_probeid_error; /* special ERROR probe */
+
+/*
+ * DTrace Helper Tracing Variables
+ */
+uint32_t dtrace_helptrace_next = 0;
+uint32_t dtrace_helptrace_nlocals;
+char *dtrace_helptrace_buffer;
+int dtrace_helptrace_bufsize = 512 * 1024;
+
+#ifdef DEBUG
+int dtrace_helptrace_enabled = 1;
+#else
+int dtrace_helptrace_enabled = 0;
+#endif
+
+/*
+ * DTrace Error Hashing
+ *
+ * On DEBUG kernels, DTrace will track the errors that has seen in a hash
+ * table. This is very useful for checking coverage of tests that are
+ * expected to induce DIF or DOF processing errors, and may be useful for
+ * debugging problems in the DIF code generator or in DOF generation . The
+ * error hash may be examined with the ::dtrace_errhash MDB dcmd.
+ */
+#ifdef DEBUG
+static dtrace_errhash_t dtrace_errhash[DTRACE_ERRHASHSZ];
+static const char *dtrace_errlast;
+static kthread_t *dtrace_errthread;
+static kmutex_t dtrace_errlock;
+#endif
+
+/*
+ * DTrace Macros and Constants
+ *
+ * These are various macros that are useful in various spots in the
+ * implementation, along with a few random constants that have no meaning
+ * outside of the implementation. There is no real structure to this cpp
+ * mishmash -- but is there ever?
+ */
+#define DTRACE_HASHSTR(hash, probe) \
+ dtrace_hash_str(*((char **)((uintptr_t)(probe) + (hash)->dth_stroffs)))
+
+#define DTRACE_HASHNEXT(hash, probe) \
+ (dtrace_probe_t **)((uintptr_t)(probe) + (hash)->dth_nextoffs)
+
+#define DTRACE_HASHPREV(hash, probe) \
+ (dtrace_probe_t **)((uintptr_t)(probe) + (hash)->dth_prevoffs)
+
+#define DTRACE_HASHEQ(hash, lhs, rhs) \
+ (strcmp(*((char **)((uintptr_t)(lhs) + (hash)->dth_stroffs)), \
+ *((char **)((uintptr_t)(rhs) + (hash)->dth_stroffs))) == 0)
+
+#define DTRACE_AGGHASHSIZE_SLEW 17
+
+#define DTRACE_V4MAPPED_OFFSET (sizeof (uint32_t) * 3)
+
+/*
+ * The key for a thread-local variable consists of the lower 61 bits of the
+ * t_did, plus the 3 bits of the highest active interrupt above LOCK_LEVEL.
+ * We add DIF_VARIABLE_MAX to t_did to assure that the thread key is never
+ * equal to a variable identifier. This is necessary (but not sufficient) to
+ * assure that global associative arrays never collide with thread-local
+ * variables. To guarantee that they cannot collide, we must also define the
+ * order for keying dynamic variables. That order is:
+ *
+ * [ key0 ] ... [ keyn ] [ variable-key ] [ tls-key ]
+ *
+ * Because the variable-key and the tls-key are in orthogonal spaces, there is
+ * no way for a global variable key signature to match a thread-local key
+ * signature.
+ */
+#ifndef VBOX
+#define DTRACE_TLS_THRKEY(where) { \
+ uint_t intr = 0; \
+ uint_t actv = CPU->cpu_intr_actv >> (LOCK_LEVEL + 1); \
+ for (; actv; actv >>= 1) \
+ intr++; \
+ ASSERT(intr < (1 << 3)); \
+ (where) = ((curthread->t_did + DIF_VARIABLE_MAX) & \
+ (((uint64_t)1 << 61) - 1)) | ((uint64_t)intr << 61); \
+}
+#else
+#define DTRACE_TLS_THRKEY(where) do { \
+ (where) = (((uintptr_t)RTThreadNativeSelf() + DIF_VARIABLE_MAX) & (RT_BIT_64(61) - 1)) \
+ | (RTThreadIsInInterrupt(NIL_RTTHREAD) ? RT_BIT_64(61) : 0); \
+} while (0)
+#endif
+
+#define DT_BSWAP_8(x) ((x) & 0xff)
+#define DT_BSWAP_16(x) ((DT_BSWAP_8(x) << 8) | DT_BSWAP_8((x) >> 8))
+#define DT_BSWAP_32(x) ((DT_BSWAP_16(x) << 16) | DT_BSWAP_16((x) >> 16))
+#define DT_BSWAP_64(x) ((DT_BSWAP_32(x) << 32) | DT_BSWAP_32((x) >> 32))
+
+#define DT_MASK_LO 0x00000000FFFFFFFFULL
+
+#define DTRACE_STORE(type, tomax, offset, what) \
+ *((type *)((uintptr_t)(tomax) + (uintptr_t)offset)) = (type)(what);
+
+#ifndef __i386
+#define DTRACE_ALIGNCHECK(addr, size, flags) \
+ if (addr & (size - 1)) { \
+ *flags |= CPU_DTRACE_BADALIGN; \
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = addr; \
+ return (0); \
+ }
+#else
+#define DTRACE_ALIGNCHECK(addr, size, flags)
+#endif
+
+/*
+ * Test whether a range of memory starting at testaddr of size testsz falls
+ * within the range of memory described by addr, sz. We take care to avoid
+ * problems with overflow and underflow of the unsigned quantities, and
+ * disallow all negative sizes. Ranges of size 0 are allowed.
+ */
+#define DTRACE_INRANGE(testaddr, testsz, baseaddr, basesz) \
+ ((testaddr) - (baseaddr) < (basesz) && \
+ (testaddr) + (testsz) - (baseaddr) <= (basesz) && \
+ (testaddr) + (testsz) >= (testaddr))
+
+/*
+ * Test whether alloc_sz bytes will fit in the scratch region. We isolate
+ * alloc_sz on the righthand side of the comparison in order to avoid overflow
+ * or underflow in the comparison with it. This is simpler than the INRANGE
+ * check above, because we know that the dtms_scratch_ptr is valid in the
+ * range. Allocations of size zero are allowed.
+ */
+#define DTRACE_INSCRATCH(mstate, alloc_sz) \
+ ((mstate)->dtms_scratch_base + (mstate)->dtms_scratch_size - \
+ (mstate)->dtms_scratch_ptr >= (alloc_sz))
+
+#ifndef VBOX
+#define DTRACE_LOADFUNC(bits) \
+/*CSTYLED*/ \
+VBDTSTATIC uint##bits##_t \
+dtrace_load##bits(uintptr_t addr) \
+{ \
+ size_t size = bits / NBBY; \
+ /*CSTYLED*/ \
+ uint##bits##_t rval; \
+ int i; \
+ processorid_t me = VBDT_GET_CPUID(); \
+ volatile uint16_t *flags = (volatile uint16_t *) \
+ &cpu_core[me].cpuc_dtrace_flags; \
+ \
+ DTRACE_ALIGNCHECK(addr, size, flags); \
+ \
+ for (i = 0; i < dtrace_toxranges; i++) { \
+ if (addr >= dtrace_toxrange[i].dtt_limit) \
+ continue; \
+ \
+ if (addr + size <= dtrace_toxrange[i].dtt_base) \
+ continue; \
+ \
+ /* \
+ * This address falls within a toxic region; return 0. \
+ */ \
+ *flags |= CPU_DTRACE_BADADDR; \
+ cpu_core[me].cpuc_dtrace_illval = addr; \
+ return (0); \
+ } \
+ \
+ *flags |= CPU_DTRACE_NOFAULT; \
+ /*CSTYLED*/ \
+ rval = *((volatile uint##bits##_t *)addr); \
+ *flags &= ~CPU_DTRACE_NOFAULT; \
+ \
+ return (!(*flags & CPU_DTRACE_FAULT) ? rval : 0); \
+}
+#else /* VBOX */
+# define DTRACE_LOADFUNC(bits) \
+VBDTSTATIC uint##bits##_t \
+dtrace_load##bits(uintptr_t addr) \
+{ \
+ size_t const size = bits / NBBY; \
+ uint##bits##_t rval; \
+ processorid_t me; \
+ int i, rc; \
+ \
+ /*DTRACE_ALIGNCHECK(addr, size, flags);*/ \
+ \
+ for (i = 0; i < dtrace_toxranges; i++) { \
+ if (addr >= dtrace_toxrange[i].dtt_limit) \
+ continue; \
+ \
+ if (addr + size <= dtrace_toxrange[i].dtt_base) \
+ continue; \
+ \
+ /* \
+ * This address falls within a toxic region; return 0. \
+ */ \
+ me = VBDT_GET_CPUID(); \
+ cpu_core[me].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR; \
+ cpu_core[me].cpuc_dtrace_illval = addr; \
+ return (0); \
+ } \
+ \
+ rc = RTR0MemKernelCopyFrom(&rval, (void const *)addr, size); \
+ if (RT_SUCCESS(rc)) \
+ return rval; \
+ \
+ /* \
+ * If not supported, pray it won't fault... \
+ */ \
+ if (rc == VERR_NOT_SUPPORTED) \
+ return *(uint##bits##_t const *)addr; \
+ \
+ me = VBDT_GET_CPUID(); \
+ cpu_core[me].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR; \
+ cpu_core[me].cpuc_dtrace_illval = addr; \
+ return (0); \
+}
+
+#endif /* VBOX */
+
+#ifdef _LP64
+#define dtrace_loadptr dtrace_load64
+#else
+#define dtrace_loadptr dtrace_load32
+#endif
+
+#define DTRACE_DYNHASH_FREE 0
+#define DTRACE_DYNHASH_SINK 1
+#define DTRACE_DYNHASH_VALID 2
+
+#define DTRACE_MATCH_FAIL -1
+#define DTRACE_MATCH_NEXT 0
+#define DTRACE_MATCH_DONE 1
+#define DTRACE_ANCHORED(probe) ((probe)->dtpr_func[0] != '\0')
+#define DTRACE_STATE_ALIGN 64
+
+#define DTRACE_FLAGS2FLT(flags) \
+ (((flags) & CPU_DTRACE_BADADDR) ? DTRACEFLT_BADADDR : \
+ ((flags) & CPU_DTRACE_ILLOP) ? DTRACEFLT_ILLOP : \
+ ((flags) & CPU_DTRACE_DIVZERO) ? DTRACEFLT_DIVZERO : \
+ ((flags) & CPU_DTRACE_KPRIV) ? DTRACEFLT_KPRIV : \
+ ((flags) & CPU_DTRACE_UPRIV) ? DTRACEFLT_UPRIV : \
+ ((flags) & CPU_DTRACE_TUPOFLOW) ? DTRACEFLT_TUPOFLOW : \
+ ((flags) & CPU_DTRACE_BADALIGN) ? DTRACEFLT_BADALIGN : \
+ ((flags) & CPU_DTRACE_NOSCRATCH) ? DTRACEFLT_NOSCRATCH : \
+ ((flags) & CPU_DTRACE_BADSTACK) ? DTRACEFLT_BADSTACK : \
+ DTRACEFLT_UNKNOWN)
+
+#define DTRACEACT_ISSTRING(act) \
+ ((act)->dta_kind == DTRACEACT_DIFEXPR && \
+ (act)->dta_difo->dtdo_rtype.dtdt_kind == DIF_TYPE_STRING)
+
+static size_t dtrace_strlen(const char *, size_t);
+static dtrace_probe_t *dtrace_probe_lookup_id(dtrace_id_t id);
+static void dtrace_enabling_provide(dtrace_provider_t *);
+static int dtrace_enabling_match(dtrace_enabling_t *, int *);
+static void dtrace_enabling_matchall(void);
+static dtrace_state_t *dtrace_anon_grab(void);
+#ifndef VBOX
+static uint64_t dtrace_helper(int, dtrace_mstate_t *,
+ dtrace_state_t *, uint64_t, uint64_t);
+static dtrace_helpers_t *dtrace_helpers_create(proc_t *);
+#endif
+static void dtrace_buffer_drop(dtrace_buffer_t *);
+static intptr_t dtrace_buffer_reserve(dtrace_buffer_t *, size_t, size_t,
+ dtrace_state_t *, dtrace_mstate_t *);
+static int dtrace_state_option(dtrace_state_t *, dtrace_optid_t,
+ dtrace_optval_t);
+static int dtrace_ecb_create_enable(dtrace_probe_t *, void *);
+#ifndef VBOX
+static void dtrace_helper_provider_destroy(dtrace_helper_provider_t *);
+#endif
+
+/*
+ * DTrace Probe Context Functions
+ *
+ * These functions are called from probe context. Because probe context is
+ * any context in which C may be called, arbitrarily locks may be held,
+ * interrupts may be disabled, we may be in arbitrary dispatched state, etc.
+ * As a result, functions called from probe context may only call other DTrace
+ * support functions -- they may not interact at all with the system at large.
+ * (Note that the ASSERT macro is made probe-context safe by redefining it in
+ * terms of dtrace_assfail(), a probe-context safe function.) If arbitrary
+ * loads are to be performed from probe context, they _must_ be in terms of
+ * the safe dtrace_load*() variants.
+ *
+ * Some functions in this block are not actually called from probe context;
+ * for these functions, there will be a comment above the function reading
+ * "Note: not called from probe context."
+ */
+void
+dtrace_panic(const char *format, ...)
+{
+ va_list alist;
+
+ va_start(alist, format);
+ dtrace_vpanic(format, alist);
+ va_end(alist);
+}
+
+#ifndef VBOX /* We have our own assertion machinery. */
+int
+dtrace_assfail(const char *a, const char *f, int l)
+{
+ dtrace_panic("assertion failed: %s, file: %s, line: %d", a, f, l);
+
+ /*
+ * We just need something here that even the most clever compiler
+ * cannot optimize away.
+ */
+ return (a[(uintptr_t)f]);
+}
+#endif
+
+/*
+ * Atomically increment a specified error counter from probe context.
+ */
+static void
+dtrace_error(uint32_t *counter)
+{
+ /*
+ * Most counters stored to in probe context are per-CPU counters.
+ * However, there are some error conditions that are sufficiently
+ * arcane that they don't merit per-CPU storage. If these counters
+ * are incremented concurrently on different CPUs, scalability will be
+ * adversely affected -- but we don't expect them to be white-hot in a
+ * correctly constructed enabling...
+ */
+ uint32_t oval, nval;
+
+ do {
+ oval = *counter;
+
+ if ((nval = oval + 1) == 0) {
+ /*
+ * If the counter would wrap, set it to 1 -- assuring
+ * that the counter is never zero when we have seen
+ * errors. (The counter must be 32-bits because we
+ * aren't guaranteed a 64-bit compare&swap operation.)
+ * To save this code both the infamy of being fingered
+ * by a priggish news story and the indignity of being
+ * the target of a neo-puritan witch trial, we're
+ * carefully avoiding any colorful description of the
+ * likelihood of this condition -- but suffice it to
+ * say that it is only slightly more likely than the
+ * overflow of predicate cache IDs, as discussed in
+ * dtrace_predicate_create().
+ */
+ nval = 1;
+ }
+ } while (dtrace_cas32(counter, oval, nval) != oval);
+}
+
+/*
+ * Use the DTRACE_LOADFUNC macro to define functions for each of loading a
+ * uint8_t, a uint16_t, a uint32_t and a uint64_t.
+ */
+DTRACE_LOADFUNC(8)
+DTRACE_LOADFUNC(16)
+DTRACE_LOADFUNC(32)
+DTRACE_LOADFUNC(64)
+
+static int
+dtrace_inscratch(uintptr_t dest, size_t size, dtrace_mstate_t *mstate)
+{
+ if (dest < mstate->dtms_scratch_base)
+ return (0);
+
+ if (dest + size < dest)
+ return (0);
+
+ if (dest + size > mstate->dtms_scratch_ptr)
+ return (0);
+
+ return (1);
+}
+
+static int
+dtrace_canstore_statvar(uint64_t addr, size_t sz,
+ dtrace_statvar_t **svars, int nsvars)
+{
+ int i;
+
+ for (i = 0; i < nsvars; i++) {
+ dtrace_statvar_t *svar = svars[i];
+
+ if (svar == NULL || svar->dtsv_size == 0)
+ continue;
+
+ if (DTRACE_INRANGE(addr, sz, svar->dtsv_data, svar->dtsv_size))
+ return (1);
+ }
+
+ return (0);
+}
+
+/*
+ * Check to see if the address is within a memory region to which a store may
+ * be issued. This includes the DTrace scratch areas, and any DTrace variable
+ * region. The caller of dtrace_canstore() is responsible for performing any
+ * alignment checks that are needed before stores are actually executed.
+ */
+static int
+dtrace_canstore(uint64_t addr, size_t sz, dtrace_mstate_t *mstate,
+ dtrace_vstate_t *vstate)
+{
+ /*
+ * First, check to see if the address is in scratch space...
+ */
+ if (DTRACE_INRANGE(addr, sz, mstate->dtms_scratch_base,
+ mstate->dtms_scratch_size))
+ return (1);
+
+ /*
+ * Now check to see if it's a dynamic variable. This check will pick
+ * up both thread-local variables and any global dynamically-allocated
+ * variables.
+ */
+ if (DTRACE_INRANGE(addr, sz, (uintptr_t)vstate->dtvs_dynvars.dtds_base,
+ vstate->dtvs_dynvars.dtds_size)) {
+ dtrace_dstate_t *dstate = &vstate->dtvs_dynvars;
+ uintptr_t base = (uintptr_t)dstate->dtds_base +
+ (dstate->dtds_hashsize * sizeof (dtrace_dynhash_t));
+ uintptr_t chunkoffs;
+
+ /*
+ * Before we assume that we can store here, we need to make
+ * sure that it isn't in our metadata -- storing to our
+ * dynamic variable metadata would corrupt our state. For
+ * the range to not include any dynamic variable metadata,
+ * it must:
+ *
+ * (1) Start above the hash table that is at the base of
+ * the dynamic variable space
+ *
+ * (2) Have a starting chunk offset that is beyond the
+ * dtrace_dynvar_t that is at the base of every chunk
+ *
+ * (3) Not span a chunk boundary
+ *
+ */
+ if (addr < base)
+ return (0);
+
+ chunkoffs = (addr - base) % dstate->dtds_chunksize;
+
+ if (chunkoffs < sizeof (dtrace_dynvar_t))
+ return (0);
+
+ if (chunkoffs + sz > dstate->dtds_chunksize)
+ return (0);
+
+ return (1);
+ }
+
+ /*
+ * Finally, check the static local and global variables. These checks
+ * take the longest, so we perform them last.
+ */
+ if (dtrace_canstore_statvar(addr, sz,
+ vstate->dtvs_locals, vstate->dtvs_nlocals))
+ return (1);
+
+ if (dtrace_canstore_statvar(addr, sz,
+ vstate->dtvs_globals, vstate->dtvs_nglobals))
+ return (1);
+
+ return (0);
+}
+
+
+/*
+ * Convenience routine to check to see if the address is within a memory
+ * region in which a load may be issued given the user's privilege level;
+ * if not, it sets the appropriate error flags and loads 'addr' into the
+ * illegal value slot.
+ *
+ * DTrace subroutines (DIF_SUBR_*) should use this helper to implement
+ * appropriate memory access protection.
+ */
+static int
+dtrace_canload(uint64_t addr, size_t sz, dtrace_mstate_t *mstate,
+ dtrace_vstate_t *vstate)
+{
+ volatile uintptr_t *illval = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
+
+ /*
+ * If we hold the privilege to read from kernel memory, then
+ * everything is readable.
+ */
+ if ((mstate->dtms_access & DTRACE_ACCESS_KERNEL) != 0)
+ return (1);
+
+ /*
+ * You can obviously read that which you can store.
+ */
+ if (dtrace_canstore(addr, sz, mstate, vstate))
+ return (1);
+
+ /*
+ * We're allowed to read from our own string table.
+ */
+ if (DTRACE_INRANGE(addr, sz, (uintptr_t)mstate->dtms_difo->dtdo_strtab,
+ mstate->dtms_difo->dtdo_strlen))
+ return (1);
+
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_KPRIV);
+ *illval = addr;
+ return (0);
+}
+
+/*
+ * Convenience routine to check to see if a given string is within a memory
+ * region in which a load may be issued given the user's privilege level;
+ * this exists so that we don't need to issue unnecessary dtrace_strlen()
+ * calls in the event that the user has all privileges.
+ */
+static int
+dtrace_strcanload(uint64_t addr, size_t sz, dtrace_mstate_t *mstate,
+ dtrace_vstate_t *vstate)
+{
+ size_t strsz;
+
+ /*
+ * If we hold the privilege to read from kernel memory, then
+ * everything is readable.
+ */
+ if ((mstate->dtms_access & DTRACE_ACCESS_KERNEL) != 0)
+ return (1);
+
+ strsz = 1 + dtrace_strlen((char *)(uintptr_t)addr, sz);
+ if (dtrace_canload(addr, strsz, mstate, vstate))
+ return (1);
+
+ return (0);
+}
+
+/*
+ * Convenience routine to check to see if a given variable is within a memory
+ * region in which a load may be issued given the user's privilege level.
+ */
+static int
+dtrace_vcanload(void *src, dtrace_diftype_t *type, dtrace_mstate_t *mstate,
+ dtrace_vstate_t *vstate)
+{
+ size_t sz;
+ ASSERT(type->dtdt_flags & DIF_TF_BYREF);
+
+ /*
+ * If we hold the privilege to read from kernel memory, then
+ * everything is readable.
+ */
+ if ((mstate->dtms_access & DTRACE_ACCESS_KERNEL) != 0)
+ return (1);
+
+ if (type->dtdt_kind == DIF_TYPE_STRING)
+ sz = dtrace_strlen(src,
+ vstate->dtvs_state->dts_options[DTRACEOPT_STRSIZE]) + 1;
+ else
+ sz = type->dtdt_size;
+
+ return (dtrace_canload((uintptr_t)src, sz, mstate, vstate));
+}
+
+/*
+ * Compare two strings using safe loads.
+ */
+static int
+dtrace_strncmp(char *s1, char *s2, size_t limit)
+{
+ uint8_t c1, c2;
+ volatile uint16_t *flags;
+
+ if (s1 == s2 || limit == 0)
+ return (0);
+
+ flags = (volatile uint16_t *)&cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+
+ do {
+ if (s1 == NULL) {
+ c1 = '\0';
+ } else {
+ c1 = dtrace_load8((uintptr_t)s1++);
+ }
+
+ if (s2 == NULL) {
+ c2 = '\0';
+ } else {
+ c2 = dtrace_load8((uintptr_t)s2++);
+ }
+
+ if (c1 != c2)
+ return (c1 - c2);
+ } while (--limit && c1 != '\0' && !(*flags & CPU_DTRACE_FAULT));
+
+ return (0);
+}
+
+/*
+ * Compute strlen(s) for a string using safe memory accesses. The additional
+ * len parameter is used to specify a maximum length to ensure completion.
+ */
+static size_t
+dtrace_strlen(const char *s, size_t lim)
+{
+ uint_t len;
+
+ for (len = 0; len != lim; len++) {
+ if (dtrace_load8((uintptr_t)s++) == '\0')
+ break;
+ }
+
+ return (len);
+}
+
+/*
+ * Check if an address falls within a toxic region.
+ */
+static int
+dtrace_istoxic(uintptr_t kaddr, size_t size)
+{
+ uintptr_t taddr, tsize;
+ int i;
+
+ for (i = 0; i < dtrace_toxranges; i++) {
+ taddr = dtrace_toxrange[i].dtt_base;
+ tsize = dtrace_toxrange[i].dtt_limit - taddr;
+
+ if (kaddr - taddr < tsize) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = kaddr;
+ return (1);
+ }
+
+ if (taddr - kaddr < size) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = taddr;
+ return (1);
+ }
+ }
+
+ return (0);
+}
+
+/*
+ * Copy src to dst using safe memory accesses. The src is assumed to be unsafe
+ * memory specified by the DIF program. The dst is assumed to be safe memory
+ * that we can store to directly because it is managed by DTrace. As with
+ * standard bcopy, overlapping copies are handled properly.
+ */
+static void
+dtrace_bcopy(const void *src, void *dst, size_t len)
+{
+ if (len != 0) {
+ uint8_t *s1 = dst;
+ const uint8_t *s2 = src;
+
+ if (s1 <= s2) {
+ do {
+ *s1++ = dtrace_load8((uintptr_t)s2++);
+ } while (--len != 0);
+ } else {
+ s2 += len;
+ s1 += len;
+
+ do {
+ *--s1 = dtrace_load8((uintptr_t)--s2);
+ } while (--len != 0);
+ }
+ }
+}
+
+/*
+ * Copy src to dst using safe memory accesses, up to either the specified
+ * length, or the point that a nul byte is encountered. The src is assumed to
+ * be unsafe memory specified by the DIF program. The dst is assumed to be
+ * safe memory that we can store to directly because it is managed by DTrace.
+ * Unlike dtrace_bcopy(), overlapping regions are not handled.
+ */
+static void
+dtrace_strcpy(const void *src, void *dst, size_t len)
+{
+ if (len != 0) {
+ uint8_t *s1 = dst, c;
+ const uint8_t *s2 = src;
+
+ do {
+ *s1++ = c = dtrace_load8((uintptr_t)s2++);
+ } while (--len != 0 && c != '\0');
+ }
+}
+
+/*
+ * Copy src to dst, deriving the size and type from the specified (BYREF)
+ * variable type. The src is assumed to be unsafe memory specified by the DIF
+ * program. The dst is assumed to be DTrace variable memory that is of the
+ * specified type; we assume that we can store to directly.
+ */
+static void
+dtrace_vcopy(void *src, void *dst, dtrace_diftype_t *type)
+{
+ ASSERT(type->dtdt_flags & DIF_TF_BYREF);
+
+ if (type->dtdt_kind == DIF_TYPE_STRING) {
+ dtrace_strcpy(src, dst, type->dtdt_size);
+ } else {
+ dtrace_bcopy(src, dst, type->dtdt_size);
+ }
+}
+
+/*
+ * Compare s1 to s2 using safe memory accesses. The s1 data is assumed to be
+ * unsafe memory specified by the DIF program. The s2 data is assumed to be
+ * safe memory that we can access directly because it is managed by DTrace.
+ */
+static int
+dtrace_bcmp(const void *s1, const void *s2, size_t len)
+{
+ volatile uint16_t *flags;
+
+ flags = (volatile uint16_t *)&cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+
+ if (s1 == s2)
+ return (0);
+
+ if (s1 == NULL || s2 == NULL)
+ return (1);
+
+ if (s1 != s2 && len != 0) {
+ const uint8_t *ps1 = s1;
+ const uint8_t *ps2 = s2;
+
+ do {
+ if (dtrace_load8((uintptr_t)ps1++) != *ps2++)
+ return (1);
+ } while (--len != 0 && !(*flags & CPU_DTRACE_FAULT));
+ }
+ return (0);
+}
+
+/*
+ * Zero the specified region using a simple byte-by-byte loop. Note that this
+ * is for safe DTrace-managed memory only.
+ */
+static void
+dtrace_bzero(void *dst, size_t len)
+{
+ uchar_t *cp;
+
+ for (cp = dst; len != 0; len--)
+ *cp++ = 0;
+}
+
+static void
+dtrace_add_128(uint64_t *addend1, uint64_t *addend2, uint64_t *sum)
+{
+ uint64_t result[2];
+
+ result[0] = addend1[0] + addend2[0];
+ result[1] = addend1[1] + addend2[1] +
+ (result[0] < addend1[0] || result[0] < addend2[0] ? 1 : 0);
+
+ sum[0] = result[0];
+ sum[1] = result[1];
+}
+
+/*
+ * Shift the 128-bit value in a by b. If b is positive, shift left.
+ * If b is negative, shift right.
+ */
+static void
+dtrace_shift_128(uint64_t *a, int b)
+{
+ uint64_t mask;
+
+ if (b == 0)
+ return;
+
+ if (b < 0) {
+ b = -b;
+ if (b >= 64) {
+ a[0] = a[1] >> (b - 64);
+ a[1] = 0;
+ } else {
+ a[0] >>= b;
+ mask = 1LL << (64 - b);
+ mask -= 1;
+ a[0] |= ((a[1] & mask) << (64 - b));
+ a[1] >>= b;
+ }
+ } else {
+ if (b >= 64) {
+ a[1] = a[0] << (b - 64);
+ a[0] = 0;
+ } else {
+ a[1] <<= b;
+ mask = a[0] >> (64 - b);
+ a[1] |= mask;
+ a[0] <<= b;
+ }
+ }
+}
+
+/*
+ * The basic idea is to break the 2 64-bit values into 4 32-bit values,
+ * use native multiplication on those, and then re-combine into the
+ * resulting 128-bit value.
+ *
+ * (hi1 << 32 + lo1) * (hi2 << 32 + lo2) =
+ * hi1 * hi2 << 64 +
+ * hi1 * lo2 << 32 +
+ * hi2 * lo1 << 32 +
+ * lo1 * lo2
+ */
+static void
+dtrace_multiply_128(uint64_t factor1, uint64_t factor2, uint64_t *product)
+{
+ uint64_t hi1, hi2, lo1, lo2;
+ uint64_t tmp[2];
+
+ hi1 = factor1 >> 32;
+ hi2 = factor2 >> 32;
+
+ lo1 = factor1 & DT_MASK_LO;
+ lo2 = factor2 & DT_MASK_LO;
+
+ product[0] = lo1 * lo2;
+ product[1] = hi1 * hi2;
+
+ tmp[0] = hi1 * lo2;
+ tmp[1] = 0;
+ dtrace_shift_128(tmp, 32);
+ dtrace_add_128(product, tmp, product);
+
+ tmp[0] = hi2 * lo1;
+ tmp[1] = 0;
+ dtrace_shift_128(tmp, 32);
+ dtrace_add_128(product, tmp, product);
+}
+
+/*
+ * This privilege check should be used by actions and subroutines to
+ * verify that the user credentials of the process that enabled the
+ * invoking ECB match the target credentials
+ */
+static int
+dtrace_priv_proc_common_user(dtrace_state_t *state)
+{
+ cred_t *cr, *s_cr = state->dts_cred.dcr_cred;
+
+ /*
+ * We should always have a non-NULL state cred here, since if cred
+ * is null (anonymous tracing), we fast-path bypass this routine.
+ */
+ ASSERT(s_cr != NULL);
+
+ if ((cr = CRED()) != NULL &&
+ s_cr->cr_uid == cr->cr_uid &&
+ s_cr->cr_uid == cr->cr_ruid &&
+ s_cr->cr_uid == cr->cr_suid &&
+ s_cr->cr_gid == cr->cr_gid &&
+ s_cr->cr_gid == cr->cr_rgid &&
+ s_cr->cr_gid == cr->cr_sgid)
+ return (1);
+
+ return (0);
+}
+
+/*
+ * This privilege check should be used by actions and subroutines to
+ * verify that the zone of the process that enabled the invoking ECB
+ * matches the target credentials
+ */
+static int
+dtrace_priv_proc_common_zone(dtrace_state_t *state)
+{
+ cred_t *cr, *s_cr = state->dts_cred.dcr_cred;
+
+ /*
+ * We should always have a non-NULL state cred here, since if cred
+ * is null (anonymous tracing), we fast-path bypass this routine.
+ */
+ ASSERT(s_cr != NULL);
+
+ if ((cr = CRED()) != NULL &&
+ s_cr->cr_zone == cr->cr_zone)
+ return (1);
+
+ return (0);
+}
+
+/*
+ * This privilege check should be used by actions and subroutines to
+ * verify that the process has not setuid or changed credentials.
+ */
+static int
+dtrace_priv_proc_common_nocd(VBDTVOID)
+{
+#ifndef VBOX
+ proc_t *proc;
+
+ if ((proc = VBDT_GET_PROC()) != NULL &&
+ !(proc->p_flag & SNOCD))
+ return (1);
+
+ return (0);
+#else
+ return (1);
+#endif
+}
+
+#ifndef VBOX
+static int
+dtrace_priv_proc_destructive(dtrace_state_t *state)
+{
+ int action = state->dts_cred.dcr_action;
+
+ if (((action & DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE) == 0) &&
+ dtrace_priv_proc_common_zone(state) == 0)
+ goto bad;
+
+ if (((action & DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER) == 0) &&
+ dtrace_priv_proc_common_user(state) == 0)
+ goto bad;
+
+ if (((action & DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG) == 0) &&
+ dtrace_priv_proc_common_nocd() == 0)
+ goto bad;
+
+ return (1);
+
+bad:
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
+
+ return (0);
+}
+#endif /* !VBOX */
+
+static int
+dtrace_priv_proc_control(dtrace_state_t *state)
+{
+ if (state->dts_cred.dcr_action & DTRACE_CRA_PROC_CONTROL)
+ return (1);
+
+ if (dtrace_priv_proc_common_zone(state) &&
+ dtrace_priv_proc_common_user(state) &&
+ dtrace_priv_proc_common_nocd())
+ return (1);
+
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
+
+ return (0);
+}
+
+static int
+dtrace_priv_proc(dtrace_state_t *state)
+{
+ if (state->dts_cred.dcr_action & DTRACE_CRA_PROC)
+ return (1);
+
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
+
+ return (0);
+}
+
+static int
+dtrace_priv_kernel(dtrace_state_t *state)
+{
+ if (state->dts_cred.dcr_action & DTRACE_CRA_KERNEL)
+ return (1);
+
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV;
+
+ return (0);
+}
+
+static int
+dtrace_priv_kernel_destructive(dtrace_state_t *state)
+{
+ if (state->dts_cred.dcr_action & DTRACE_CRA_KERNEL_DESTRUCTIVE)
+ return (1);
+
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV;
+
+ return (0);
+}
+
+/*
+ * Note: not called from probe context. This function is called
+ * asynchronously (and at a regular interval) from outside of probe context to
+ * clean the dirty dynamic variable lists on all CPUs. Dynamic variable
+ * cleaning is explained in detail in <sys/dtrace_impl.h>.
+ */
+VBDTSTATIC void
+dtrace_dynvar_clean(dtrace_dstate_t *dstate)
+{
+ dtrace_dynvar_t *dirty;
+ dtrace_dstate_percpu_t *dcpu;
+ dtrace_dynvar_t **rinsep;
+ int i, j, work = 0;
+
+ for (i = 0; i < NCPU; i++) {
+ dcpu = &dstate->dtds_percpu[i];
+ rinsep = &dcpu->dtdsc_rinsing;
+
+ /*
+ * If the dirty list is NULL, there is no dirty work to do.
+ */
+ if (dcpu->dtdsc_dirty == NULL)
+ continue;
+
+ if (dcpu->dtdsc_rinsing != NULL) {
+ /*
+ * If the rinsing list is non-NULL, then it is because
+ * this CPU was selected to accept another CPU's
+ * dirty list -- and since that time, dirty buffers
+ * have accumulated. This is a highly unlikely
+ * condition, but we choose to ignore the dirty
+ * buffers -- they'll be picked up a future cleanse.
+ */
+ continue;
+ }
+
+ if (dcpu->dtdsc_clean != NULL) {
+ /*
+ * If the clean list is non-NULL, then we're in a
+ * situation where a CPU has done deallocations (we
+ * have a non-NULL dirty list) but no allocations (we
+ * also have a non-NULL clean list). We can't simply
+ * move the dirty list into the clean list on this
+ * CPU, yet we also don't want to allow this condition
+ * to persist, lest a short clean list prevent a
+ * massive dirty list from being cleaned (which in
+ * turn could lead to otherwise avoidable dynamic
+ * drops). To deal with this, we look for some CPU
+ * with a NULL clean list, NULL dirty list, and NULL
+ * rinsing list -- and then we borrow this CPU to
+ * rinse our dirty list.
+ */
+ for (j = 0; j < NCPU; j++) {
+ dtrace_dstate_percpu_t *rinser;
+
+ rinser = &dstate->dtds_percpu[j];
+
+ if (rinser->dtdsc_rinsing != NULL)
+ continue;
+
+ if (rinser->dtdsc_dirty != NULL)
+ continue;
+
+ if (rinser->dtdsc_clean != NULL)
+ continue;
+
+ rinsep = &rinser->dtdsc_rinsing;
+ break;
+ }
+
+ if (j == NCPU) {
+ /*
+ * We were unable to find another CPU that
+ * could accept this dirty list -- we are
+ * therefore unable to clean it now.
+ */
+ dtrace_dynvar_failclean++;
+ continue;
+ }
+ }
+
+ work = 1;
+
+ /*
+ * Atomically move the dirty list aside.
+ */
+ do {
+ dirty = dcpu->dtdsc_dirty;
+
+ /*
+ * Before we zap the dirty list, set the rinsing list.
+ * (This allows for a potential assertion in
+ * dtrace_dynvar(): if a free dynamic variable appears
+ * on a hash chain, either the dirty list or the
+ * rinsing list for some CPU must be non-NULL.)
+ */
+ *rinsep = dirty;
+ dtrace_membar_producer();
+ } while (dtrace_casptr(&dcpu->dtdsc_dirty,
+ dirty, NULL) != dirty);
+ }
+
+ if (!work) {
+ /*
+ * We have no work to do; we can simply return.
+ */
+ return;
+ }
+
+ dtrace_sync();
+
+ for (i = 0; i < NCPU; i++) {
+ dcpu = &dstate->dtds_percpu[i];
+
+ if (dcpu->dtdsc_rinsing == NULL)
+ continue;
+
+ /*
+ * We are now guaranteed that no hash chain contains a pointer
+ * into this dirty list; we can make it clean.
+ */
+ ASSERT(dcpu->dtdsc_clean == NULL);
+ dcpu->dtdsc_clean = dcpu->dtdsc_rinsing;
+ dcpu->dtdsc_rinsing = NULL;
+ }
+
+ /*
+ * Before we actually set the state to be DTRACE_DSTATE_CLEAN, make
+ * sure that all CPUs have seen all of the dtdsc_clean pointers.
+ * This prevents a race whereby a CPU incorrectly decides that
+ * the state should be something other than DTRACE_DSTATE_CLEAN
+ * after dtrace_dynvar_clean() has completed.
+ */
+ dtrace_sync();
+
+ dstate->dtds_state = DTRACE_DSTATE_CLEAN;
+}
+
+/*
+ * Depending on the value of the op parameter, this function looks-up,
+ * allocates or deallocates an arbitrarily-keyed dynamic variable. If an
+ * allocation is requested, this function will return a pointer to a
+ * dtrace_dynvar_t corresponding to the allocated variable -- or NULL if no
+ * variable can be allocated. If NULL is returned, the appropriate counter
+ * will be incremented.
+ */
+VBDTSTATIC dtrace_dynvar_t *
+dtrace_dynvar(dtrace_dstate_t *dstate, uint_t nkeys,
+ dtrace_key_t *key, size_t dsize, dtrace_dynvar_op_t op,
+ dtrace_mstate_t *mstate, dtrace_vstate_t *vstate)
+{
+ uint64_t hashval = DTRACE_DYNHASH_VALID;
+ dtrace_dynhash_t *hash = dstate->dtds_hash;
+ dtrace_dynvar_t *free, *new_free, *next, *dvar, *start, *prev = NULL;
+ processorid_t me = VBDT_GET_CPUID(), cpu = me;
+ dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[me];
+ size_t bucket, ksize;
+ size_t chunksize = dstate->dtds_chunksize;
+ uintptr_t kdata, lock, nstate;
+ uint_t i;
+
+ ASSERT(nkeys != 0);
+
+ /*
+ * Hash the key. As with aggregations, we use Jenkins' "One-at-a-time"
+ * algorithm. For the by-value portions, we perform the algorithm in
+ * 16-bit chunks (as opposed to 8-bit chunks). This speeds things up a
+ * bit, and seems to have only a minute effect on distribution. For
+ * the by-reference data, we perform "One-at-a-time" iterating (safely)
+ * over each referenced byte. It's painful to do this, but it's much
+ * better than pathological hash distribution. The efficacy of the
+ * hashing algorithm (and a comparison with other algorithms) may be
+ * found by running the ::dtrace_dynstat MDB dcmd.
+ */
+ for (i = 0; i < nkeys; i++) {
+ if (key[i].dttk_size == 0) {
+ uint64_t val = key[i].dttk_value;
+
+ hashval += (val >> 48) & 0xffff;
+ hashval += (hashval << 10);
+ hashval ^= (hashval >> 6);
+
+ hashval += (val >> 32) & 0xffff;
+ hashval += (hashval << 10);
+ hashval ^= (hashval >> 6);
+
+ hashval += (val >> 16) & 0xffff;
+ hashval += (hashval << 10);
+ hashval ^= (hashval >> 6);
+
+ hashval += val & 0xffff;
+ hashval += (hashval << 10);
+ hashval ^= (hashval >> 6);
+ } else {
+ /*
+ * This is incredibly painful, but it beats the hell
+ * out of the alternative.
+ */
+ uint64_t j, size = key[i].dttk_size;
+ uintptr_t base = (uintptr_t)key[i].dttk_value;
+
+ if (!dtrace_canload(base, size, mstate, vstate))
+ break;
+
+ for (j = 0; j < size; j++) {
+ hashval += dtrace_load8(base + j);
+ hashval += (hashval << 10);
+ hashval ^= (hashval >> 6);
+ }
+ }
+ }
+
+ if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_FAULT))
+ return (NULL);
+
+ hashval += (hashval << 3);
+ hashval ^= (hashval >> 11);
+ hashval += (hashval << 15);
+
+ /*
+ * There is a remote chance (ideally, 1 in 2^31) that our hashval
+ * comes out to be one of our two sentinel hash values. If this
+ * actually happens, we set the hashval to be a value known to be a
+ * non-sentinel value.
+ */
+ if (hashval == DTRACE_DYNHASH_FREE || hashval == DTRACE_DYNHASH_SINK)
+ hashval = DTRACE_DYNHASH_VALID;
+
+ /*
+ * Yes, it's painful to do a divide here. If the cycle count becomes
+ * important here, tricks can be pulled to reduce it. (However, it's
+ * critical that hash collisions be kept to an absolute minimum;
+ * they're much more painful than a divide.) It's better to have a
+ * solution that generates few collisions and still keeps things
+ * relatively simple.
+ */
+ bucket = hashval % dstate->dtds_hashsize;
+
+ if (op == DTRACE_DYNVAR_DEALLOC) {
+ volatile uintptr_t *lockp = &hash[bucket].dtdh_lock;
+
+ for (;;) {
+ while ((lock = *lockp) & 1)
+ continue;
+
+ if (dtrace_casptr((void *)lockp,
+ (void *)lock, (void *)(lock + 1)) == (void *)lock)
+ break;
+ }
+
+ dtrace_membar_producer();
+ }
+
+top:
+ prev = NULL;
+ lock = hash[bucket].dtdh_lock;
+
+ dtrace_membar_consumer();
+
+ start = hash[bucket].dtdh_chain;
+ ASSERT(start != NULL && (start->dtdv_hashval == DTRACE_DYNHASH_SINK ||
+ start->dtdv_hashval != DTRACE_DYNHASH_FREE ||
+ op != DTRACE_DYNVAR_DEALLOC));
+
+ for (dvar = start; dvar != NULL; dvar = dvar->dtdv_next) {
+ dtrace_tuple_t *dtuple = &dvar->dtdv_tuple;
+ dtrace_key_t *dkey = &dtuple->dtt_key[0];
+
+ if (dvar->dtdv_hashval != hashval) {
+ if (dvar->dtdv_hashval == DTRACE_DYNHASH_SINK) {
+ /*
+ * We've reached the sink, and therefore the
+ * end of the hash chain; we can kick out of
+ * the loop knowing that we have seen a valid
+ * snapshot of state.
+ */
+ ASSERT(dvar->dtdv_next == NULL);
+ ASSERT(dvar == &dtrace_dynhash_sink);
+ break;
+ }
+
+ if (dvar->dtdv_hashval == DTRACE_DYNHASH_FREE) {
+ /*
+ * We've gone off the rails: somewhere along
+ * the line, one of the members of this hash
+ * chain was deleted. Note that we could also
+ * detect this by simply letting this loop run
+ * to completion, as we would eventually hit
+ * the end of the dirty list. However, we
+ * want to avoid running the length of the
+ * dirty list unnecessarily (it might be quite
+ * long), so we catch this as early as
+ * possible by detecting the hash marker. In
+ * this case, we simply set dvar to NULL and
+ * break; the conditional after the loop will
+ * send us back to top.
+ */
+ dvar = NULL;
+ break;
+ }
+
+ goto next;
+ }
+
+ if (dtuple->dtt_nkeys != nkeys)
+ goto next;
+
+ for (i = 0; i < nkeys; i++, dkey++) {
+ if (dkey->dttk_size != key[i].dttk_size)
+ goto next; /* size or type mismatch */
+
+ if (dkey->dttk_size != 0) {
+ if (dtrace_bcmp(
+ (void *)(uintptr_t)key[i].dttk_value,
+ (void *)(uintptr_t)dkey->dttk_value,
+ dkey->dttk_size))
+ goto next;
+ } else {
+ if (dkey->dttk_value != key[i].dttk_value)
+ goto next;
+ }
+ }
+
+ if (op != DTRACE_DYNVAR_DEALLOC)
+ return (dvar);
+
+ ASSERT(dvar->dtdv_next == NULL ||
+ dvar->dtdv_next->dtdv_hashval != DTRACE_DYNHASH_FREE);
+
+ if (prev != NULL) {
+ ASSERT(hash[bucket].dtdh_chain != dvar);
+ ASSERT(start != dvar);
+ ASSERT(prev->dtdv_next == dvar);
+ prev->dtdv_next = dvar->dtdv_next;
+ } else {
+ if (dtrace_casptr(&hash[bucket].dtdh_chain,
+ start, dvar->dtdv_next) != start) {
+ /*
+ * We have failed to atomically swing the
+ * hash table head pointer, presumably because
+ * of a conflicting allocation on another CPU.
+ * We need to reread the hash chain and try
+ * again.
+ */
+ goto top;
+ }
+ }
+
+ dtrace_membar_producer();
+
+ /*
+ * Now set the hash value to indicate that it's free.
+ */
+ ASSERT(hash[bucket].dtdh_chain != dvar);
+ dvar->dtdv_hashval = DTRACE_DYNHASH_FREE;
+
+ dtrace_membar_producer();
+
+ /*
+ * Set the next pointer to point at the dirty list, and
+ * atomically swing the dirty pointer to the newly freed dvar.
+ */
+ do {
+ next = dcpu->dtdsc_dirty;
+ dvar->dtdv_next = next;
+ } while (dtrace_casptr(&dcpu->dtdsc_dirty, next, dvar) != next);
+
+ /*
+ * Finally, unlock this hash bucket.
+ */
+ ASSERT(hash[bucket].dtdh_lock == lock);
+ ASSERT(lock & 1);
+ hash[bucket].dtdh_lock++;
+
+ return (NULL);
+next:
+ prev = dvar;
+ continue;
+ }
+
+ if (dvar == NULL) {
+ /*
+ * If dvar is NULL, it is because we went off the rails:
+ * one of the elements that we traversed in the hash chain
+ * was deleted while we were traversing it. In this case,
+ * we assert that we aren't doing a dealloc (deallocs lock
+ * the hash bucket to prevent themselves from racing with
+ * one another), and retry the hash chain traversal.
+ */
+ ASSERT(op != DTRACE_DYNVAR_DEALLOC);
+ goto top;
+ }
+
+ if (op != DTRACE_DYNVAR_ALLOC) {
+ /*
+ * If we are not to allocate a new variable, we want to
+ * return NULL now. Before we return, check that the value
+ * of the lock word hasn't changed. If it has, we may have
+ * seen an inconsistent snapshot.
+ */
+ if (op == DTRACE_DYNVAR_NOALLOC) {
+ if (hash[bucket].dtdh_lock != lock)
+ goto top;
+ } else {
+ ASSERT(op == DTRACE_DYNVAR_DEALLOC);
+ ASSERT(hash[bucket].dtdh_lock == lock);
+ ASSERT(lock & 1);
+ hash[bucket].dtdh_lock++;
+ }
+
+ return (NULL);
+ }
+
+ /*
+ * We need to allocate a new dynamic variable. The size we need is the
+ * size of dtrace_dynvar plus the size of nkeys dtrace_key_t's plus the
+ * size of any auxiliary key data (rounded up to 8-byte alignment) plus
+ * the size of any referred-to data (dsize). We then round the final
+ * size up to the chunksize for allocation.
+ */
+ for (ksize = 0, i = 0; i < nkeys; i++)
+ ksize += P2ROUNDUP(key[i].dttk_size, sizeof (uint64_t));
+
+ /*
+ * This should be pretty much impossible, but could happen if, say,
+ * strange DIF specified the tuple. Ideally, this should be an
+ * assertion and not an error condition -- but that requires that the
+ * chunksize calculation in dtrace_difo_chunksize() be absolutely
+ * bullet-proof. (That is, it must not be able to be fooled by
+ * malicious DIF.) Given the lack of backwards branches in DIF,
+ * solving this would presumably not amount to solving the Halting
+ * Problem -- but it still seems awfully hard.
+ */
+ if (sizeof (dtrace_dynvar_t) + sizeof (dtrace_key_t) * (nkeys - 1) +
+ ksize + dsize > chunksize) {
+ dcpu->dtdsc_drops++;
+ return (NULL);
+ }
+
+ nstate = DTRACE_DSTATE_EMPTY;
+
+ do {
+retry:
+ free = dcpu->dtdsc_free;
+
+ if (free == NULL) {
+ dtrace_dynvar_t *clean = dcpu->dtdsc_clean;
+ void *rval;
+
+ if (clean == NULL) {
+ /*
+ * We're out of dynamic variable space on
+ * this CPU. Unless we have tried all CPUs,
+ * we'll try to allocate from a different
+ * CPU.
+ */
+ switch (dstate->dtds_state) {
+ case DTRACE_DSTATE_CLEAN: {
+ void *sp = &dstate->dtds_state;
+
+ if (++cpu >= NCPU)
+ cpu = 0;
+
+ if (dcpu->dtdsc_dirty != NULL &&
+ nstate == DTRACE_DSTATE_EMPTY)
+ nstate = DTRACE_DSTATE_DIRTY;
+
+ if (dcpu->dtdsc_rinsing != NULL)
+ nstate = DTRACE_DSTATE_RINSING;
+
+ dcpu = &dstate->dtds_percpu[cpu];
+
+ if (cpu != me)
+ goto retry;
+
+ (void) dtrace_cas32(sp,
+ DTRACE_DSTATE_CLEAN, nstate);
+
+ /*
+ * To increment the correct bean
+ * counter, take another lap.
+ */
+ goto retry;
+ }
+
+ case DTRACE_DSTATE_DIRTY:
+ dcpu->dtdsc_dirty_drops++;
+ break;
+
+ case DTRACE_DSTATE_RINSING:
+ dcpu->dtdsc_rinsing_drops++;
+ break;
+
+ case DTRACE_DSTATE_EMPTY:
+ dcpu->dtdsc_drops++;
+ break;
+ }
+
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_DROP);
+ return (NULL);
+ }
+
+ /*
+ * The clean list appears to be non-empty. We want to
+ * move the clean list to the free list; we start by
+ * moving the clean pointer aside.
+ */
+ if (dtrace_casptr(&dcpu->dtdsc_clean,
+ clean, NULL) != clean) {
+ /*
+ * We are in one of two situations:
+ *
+ * (a) The clean list was switched to the
+ * free list by another CPU.
+ *
+ * (b) The clean list was added to by the
+ * cleansing cyclic.
+ *
+ * In either of these situations, we can
+ * just reattempt the free list allocation.
+ */
+ goto retry;
+ }
+
+ ASSERT(clean->dtdv_hashval == DTRACE_DYNHASH_FREE);
+
+ /*
+ * Now we'll move the clean list to our free list.
+ * It's impossible for this to fail: the only way
+ * the free list can be updated is through this
+ * code path, and only one CPU can own the clean list.
+ * Thus, it would only be possible for this to fail if
+ * this code were racing with dtrace_dynvar_clean().
+ * (That is, if dtrace_dynvar_clean() updated the clean
+ * list, and we ended up racing to update the free
+ * list.) This race is prevented by the dtrace_sync()
+ * in dtrace_dynvar_clean() -- which flushes the
+ * owners of the clean lists out before resetting
+ * the clean lists.
+ */
+ dcpu = &dstate->dtds_percpu[me];
+ rval = dtrace_casptr(&dcpu->dtdsc_free, NULL, clean);
+ ASSERT(rval == NULL);
+ goto retry;
+ }
+
+ dvar = free;
+ new_free = dvar->dtdv_next;
+ } while (dtrace_casptr(&dcpu->dtdsc_free, free, new_free) != free);
+
+ /*
+ * We have now allocated a new chunk. We copy the tuple keys into the
+ * tuple array and copy any referenced key data into the data space
+ * following the tuple array. As we do this, we relocate dttk_value
+ * in the final tuple to point to the key data address in the chunk.
+ */
+ kdata = (uintptr_t)&dvar->dtdv_tuple.dtt_key[nkeys];
+ dvar->dtdv_data = (void *)(kdata + ksize);
+ dvar->dtdv_tuple.dtt_nkeys = nkeys;
+
+ for (i = 0; i < nkeys; i++) {
+ dtrace_key_t *dkey = &dvar->dtdv_tuple.dtt_key[i];
+ size_t kesize = key[i].dttk_size;
+
+ if (kesize != 0) {
+ dtrace_bcopy(
+ (const void *)(uintptr_t)key[i].dttk_value,
+ (void *)kdata, kesize);
+ dkey->dttk_value = kdata;
+ kdata += P2ROUNDUP(kesize, sizeof (uint64_t));
+ } else {
+ dkey->dttk_value = key[i].dttk_value;
+ }
+
+ dkey->dttk_size = kesize;
+ }
+
+ ASSERT(dvar->dtdv_hashval == DTRACE_DYNHASH_FREE);
+ dvar->dtdv_hashval = hashval;
+ dvar->dtdv_next = start;
+
+ if (dtrace_casptr(&hash[bucket].dtdh_chain, start, dvar) == start)
+ return (dvar);
+
+ /*
+ * The cas has failed. Either another CPU is adding an element to
+ * this hash chain, or another CPU is deleting an element from this
+ * hash chain. The simplest way to deal with both of these cases
+ * (though not necessarily the most efficient) is to free our
+ * allocated block and tail-call ourselves. Note that the free is
+ * to the dirty list and _not_ to the free list. This is to prevent
+ * races with allocators, above.
+ */
+ dvar->dtdv_hashval = DTRACE_DYNHASH_FREE;
+
+ dtrace_membar_producer();
+
+ do {
+ free = dcpu->dtdsc_dirty;
+ dvar->dtdv_next = free;
+ } while (dtrace_casptr(&dcpu->dtdsc_dirty, free, dvar) != free);
+
+ return (dtrace_dynvar(dstate, nkeys, key, dsize, op, mstate, vstate));
+}
+
+/*ARGSUSED*/
+static void
+dtrace_aggregate_min(uint64_t *oval, uint64_t nval, uint64_t arg)
+{
+ RT_NOREF_PV(arg);
+ if ((int64_t)nval < (int64_t)*oval)
+ *oval = nval;
+}
+
+/*ARGSUSED*/
+static void
+dtrace_aggregate_max(uint64_t *oval, uint64_t nval, uint64_t arg)
+{
+ RT_NOREF_PV(arg);
+ if ((int64_t)nval > (int64_t)*oval)
+ *oval = nval;
+}
+
+static void
+dtrace_aggregate_quantize(uint64_t *quanta, uint64_t nval, uint64_t incr)
+{
+ int i, zero = DTRACE_QUANTIZE_ZEROBUCKET;
+ int64_t val = (int64_t)nval;
+
+ if (val < 0) {
+ for (i = 0; i < zero; i++) {
+ if (val <= DTRACE_QUANTIZE_BUCKETVAL(i)) {
+ quanta[i] += incr;
+ return;
+ }
+ }
+ } else {
+ for (i = zero + 1; i < VBDTCAST(int)DTRACE_QUANTIZE_NBUCKETS; i++) {
+ if (val < DTRACE_QUANTIZE_BUCKETVAL(i)) {
+ quanta[i - 1] += incr;
+ return;
+ }
+ }
+
+ quanta[DTRACE_QUANTIZE_NBUCKETS - 1] += incr;
+ return;
+ }
+
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalFailed();
+#endif
+}
+
+static void
+dtrace_aggregate_lquantize(uint64_t *lquanta, uint64_t nval, uint64_t incr)
+{
+ uint64_t arg = *lquanta++;
+ int32_t base = DTRACE_LQUANTIZE_BASE(arg);
+ uint16_t step = DTRACE_LQUANTIZE_STEP(arg);
+ uint16_t levels = DTRACE_LQUANTIZE_LEVELS(arg);
+ int32_t val = (int32_t)nval, level;
+
+ ASSERT(step != 0);
+ ASSERT(levels != 0);
+
+ if (val < base) {
+ /*
+ * This is an underflow.
+ */
+ lquanta[0] += incr;
+ return;
+ }
+
+ level = (val - base) / step;
+
+ if (level < levels) {
+ lquanta[level + 1] += incr;
+ return;
+ }
+
+ /*
+ * This is an overflow.
+ */
+ lquanta[levels + 1] += incr;
+}
+
+/*ARGSUSED*/
+static void
+dtrace_aggregate_avg(uint64_t *data, uint64_t nval, uint64_t arg)
+{
+ RT_NOREF_PV(arg);
+ data[0]++;
+ data[1] += nval;
+}
+
+/*ARGSUSED*/
+static void
+dtrace_aggregate_stddev(uint64_t *data, uint64_t nval, uint64_t arg)
+{
+ int64_t snval = (int64_t)nval;
+ uint64_t tmp[2];
+ RT_NOREF_PV(arg);
+
+ data[0]++;
+ data[1] += nval;
+
+ /*
+ * What we want to say here is:
+ *
+ * data[2] += nval * nval;
+ *
+ * But given that nval is 64-bit, we could easily overflow, so
+ * we do this as 128-bit arithmetic.
+ */
+ if (snval < 0)
+ snval = -snval;
+
+ dtrace_multiply_128((uint64_t)snval, (uint64_t)snval, tmp);
+ dtrace_add_128(data + 2, tmp, data + 2);
+}
+
+/*ARGSUSED*/
+static void
+dtrace_aggregate_count(uint64_t *oval, uint64_t nval, uint64_t arg)
+{
+ RT_NOREF_PV(arg); RT_NOREF_PV(nval);
+
+ *oval = *oval + 1;
+}
+
+/*ARGSUSED*/
+static void
+dtrace_aggregate_sum(uint64_t *oval, uint64_t nval, uint64_t arg)
+{
+ RT_NOREF_PV(arg);
+ *oval += nval;
+}
+
+/*
+ * Aggregate given the tuple in the principal data buffer, and the aggregating
+ * action denoted by the specified dtrace_aggregation_t. The aggregation
+ * buffer is specified as the buf parameter. This routine does not return
+ * failure; if there is no space in the aggregation buffer, the data will be
+ * dropped, and a corresponding counter incremented.
+ */
+static void
+dtrace_aggregate(dtrace_aggregation_t *agg, dtrace_buffer_t *dbuf,
+ intptr_t offset, dtrace_buffer_t *buf, uint64_t expr, uint64_t arg)
+{
+ dtrace_recdesc_t *rec = &agg->dtag_action.dta_rec;
+ uint32_t i, ndx, size, fsize;
+ uint32_t align = sizeof (uint64_t) - 1;
+ dtrace_aggbuffer_t *agb;
+ dtrace_aggkey_t *key;
+ uint32_t hashval = 0, limit, isstr;
+ caddr_t tomax, data, kdata;
+ dtrace_actkind_t action;
+ dtrace_action_t *act;
+ uintptr_t offs;
+
+ if (buf == NULL)
+ return;
+
+ if (!agg->dtag_hasarg) {
+ /*
+ * Currently, only quantize() and lquantize() take additional
+ * arguments, and they have the same semantics: an increment
+ * value that defaults to 1 when not present. If additional
+ * aggregating actions take arguments, the setting of the
+ * default argument value will presumably have to become more
+ * sophisticated...
+ */
+ arg = 1;
+ }
+
+ action = agg->dtag_action.dta_kind - DTRACEACT_AGGREGATION;
+ size = rec->dtrd_offset - agg->dtag_base;
+ fsize = size + rec->dtrd_size;
+
+ ASSERT(dbuf->dtb_tomax != NULL);
+ data = dbuf->dtb_tomax + offset + agg->dtag_base;
+
+ if ((tomax = buf->dtb_tomax) == NULL) {
+ dtrace_buffer_drop(buf);
+ return;
+ }
+
+ /*
+ * The metastructure is always at the bottom of the buffer.
+ */
+ agb = (dtrace_aggbuffer_t *)(tomax + buf->dtb_size -
+ sizeof (dtrace_aggbuffer_t));
+
+ if (buf->dtb_offset == 0) {
+ /*
+ * We just kludge up approximately 1/8th of the size to be
+ * buckets. If this guess ends up being routinely
+ * off-the-mark, we may need to dynamically readjust this
+ * based on past performance.
+ */
+ uintptr_t hashsize = (buf->dtb_size >> 3) / sizeof (uintptr_t);
+
+ if ((uintptr_t)agb - hashsize * sizeof (dtrace_aggkey_t *) <
+ (uintptr_t)tomax || hashsize == 0) {
+ /*
+ * We've been given a ludicrously small buffer;
+ * increment our drop count and leave.
+ */
+ dtrace_buffer_drop(buf);
+ return;
+ }
+
+ /*
+ * And now, a pathetic attempt to try to get a an odd (or
+ * perchance, a prime) hash size for better hash distribution.
+ */
+ if (hashsize > (DTRACE_AGGHASHSIZE_SLEW << 3))
+ hashsize -= DTRACE_AGGHASHSIZE_SLEW;
+
+ agb->dtagb_hashsize = hashsize;
+ agb->dtagb_hash = (dtrace_aggkey_t **)((uintptr_t)agb -
+ agb->dtagb_hashsize * sizeof (dtrace_aggkey_t *));
+ agb->dtagb_free = (uintptr_t)agb->dtagb_hash;
+
+ for (i = 0; i < agb->dtagb_hashsize; i++)
+ agb->dtagb_hash[i] = NULL;
+ }
+
+ ASSERT(agg->dtag_first != NULL);
+ ASSERT(agg->dtag_first->dta_intuple);
+
+ /*
+ * Calculate the hash value based on the key. Note that we _don't_
+ * include the aggid in the hashing (but we will store it as part of
+ * the key). The hashing algorithm is Bob Jenkins' "One-at-a-time"
+ * algorithm: a simple, quick algorithm that has no known funnels, and
+ * gets good distribution in practice. The efficacy of the hashing
+ * algorithm (and a comparison with other algorithms) may be found by
+ * running the ::dtrace_aggstat MDB dcmd.
+ */
+ for (act = agg->dtag_first; act->dta_intuple; act = act->dta_next) {
+ i = act->dta_rec.dtrd_offset - agg->dtag_base;
+ limit = i + act->dta_rec.dtrd_size;
+ ASSERT(limit <= size);
+ isstr = DTRACEACT_ISSTRING(act);
+
+ for (; i < limit; i++) {
+ hashval += data[i];
+ hashval += (hashval << 10);
+ hashval ^= (hashval >> 6);
+
+ if (isstr && data[i] == '\0')
+ break;
+ }
+ }
+
+ hashval += (hashval << 3);
+ hashval ^= (hashval >> 11);
+ hashval += (hashval << 15);
+
+ /*
+ * Yes, the divide here is expensive -- but it's generally the least
+ * of the performance issues given the amount of data that we iterate
+ * over to compute hash values, compare data, etc.
+ */
+ ndx = hashval % agb->dtagb_hashsize;
+
+ for (key = agb->dtagb_hash[ndx]; key != NULL; key = key->dtak_next) {
+ ASSERT((caddr_t)key >= tomax);
+ ASSERT((caddr_t)key < tomax + buf->dtb_size);
+
+ if (hashval != key->dtak_hashval || key->dtak_size != size)
+ continue;
+
+ kdata = key->dtak_data;
+ ASSERT(kdata >= tomax && kdata < tomax + buf->dtb_size);
+
+ for (act = agg->dtag_first; act->dta_intuple;
+ act = act->dta_next) {
+ i = act->dta_rec.dtrd_offset - agg->dtag_base;
+ limit = i + act->dta_rec.dtrd_size;
+ ASSERT(limit <= size);
+ isstr = DTRACEACT_ISSTRING(act);
+
+ for (; i < limit; i++) {
+ if (kdata[i] != data[i])
+ goto next;
+
+ if (isstr && data[i] == '\0')
+ break;
+ }
+ }
+
+ if (action != key->dtak_action) {
+ /*
+ * We are aggregating on the same value in the same
+ * aggregation with two different aggregating actions.
+ * (This should have been picked up in the compiler,
+ * so we may be dealing with errant or devious DIF.)
+ * This is an error condition; we indicate as much,
+ * and return.
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return;
+ }
+
+ /*
+ * This is a hit: we need to apply the aggregator to
+ * the value at this key.
+ */
+ agg->dtag_aggregate((uint64_t *)(kdata + size), expr, arg);
+ return;
+next:
+ continue;
+ }
+
+ /*
+ * We didn't find it. We need to allocate some zero-filled space,
+ * link it into the hash table appropriately, and apply the aggregator
+ * to the (zero-filled) value.
+ */
+ offs = buf->dtb_offset;
+ while (offs & (align - 1))
+ offs += sizeof (uint32_t);
+
+ /*
+ * If we don't have enough room to both allocate a new key _and_
+ * its associated data, increment the drop count and return.
+ */
+ if ((uintptr_t)tomax + offs + fsize >
+ agb->dtagb_free - sizeof (dtrace_aggkey_t)) {
+ dtrace_buffer_drop(buf);
+ return;
+ }
+
+ /*CONSTCOND*/
+ ASSERT(!(sizeof (dtrace_aggkey_t) & (sizeof (uintptr_t) - 1)));
+ key = (dtrace_aggkey_t *)(agb->dtagb_free - sizeof (dtrace_aggkey_t));
+ agb->dtagb_free -= sizeof (dtrace_aggkey_t);
+
+ key->dtak_data = kdata = tomax + offs;
+ buf->dtb_offset = offs + fsize;
+
+ /*
+ * Now copy the data across.
+ */
+ *((dtrace_aggid_t *)kdata) = agg->dtag_id;
+
+ for (i = sizeof (dtrace_aggid_t); i < size; i++)
+ kdata[i] = data[i];
+
+ /*
+ * Because strings are not zeroed out by default, we need to iterate
+ * looking for actions that store strings, and we need to explicitly
+ * pad these strings out with zeroes.
+ */
+ for (act = agg->dtag_first; act->dta_intuple; act = act->dta_next) {
+ int nul;
+
+ if (!DTRACEACT_ISSTRING(act))
+ continue;
+
+ i = act->dta_rec.dtrd_offset - agg->dtag_base;
+ limit = i + act->dta_rec.dtrd_size;
+ ASSERT(limit <= size);
+
+ for (nul = 0; i < limit; i++) {
+ if (nul) {
+ kdata[i] = '\0';
+ continue;
+ }
+
+ if (data[i] != '\0')
+ continue;
+
+ nul = 1;
+ }
+ }
+
+ for (i = size; i < fsize; i++)
+ kdata[i] = 0;
+
+ key->dtak_hashval = hashval;
+ key->dtak_size = size;
+ key->dtak_action = action;
+ key->dtak_next = agb->dtagb_hash[ndx];
+ agb->dtagb_hash[ndx] = key;
+
+ /*
+ * Finally, apply the aggregator.
+ */
+ *((uint64_t *)(key->dtak_data + size)) = agg->dtag_initial;
+ agg->dtag_aggregate((uint64_t *)(key->dtak_data + size), expr, arg);
+}
+
+/*
+ * Given consumer state, this routine finds a speculation in the INACTIVE
+ * state and transitions it into the ACTIVE state. If there is no speculation
+ * in the INACTIVE state, 0 is returned. In this case, no error counter is
+ * incremented -- it is up to the caller to take appropriate action.
+ */
+static int
+dtrace_speculation(dtrace_state_t *state)
+{
+ int i = 0;
+ dtrace_speculation_state_t current;
+ uint32_t *stat = &state->dts_speculations_unavail, count;
+
+ while (i < state->dts_nspeculations) {
+ dtrace_speculation_t *spec = &state->dts_speculations[i];
+
+ current = spec->dtsp_state;
+
+ if (current != DTRACESPEC_INACTIVE) {
+ if (current == DTRACESPEC_COMMITTINGMANY ||
+ current == DTRACESPEC_COMMITTING ||
+ current == DTRACESPEC_DISCARDING)
+ stat = &state->dts_speculations_busy;
+ i++;
+ continue;
+ }
+
+ if ( (dtrace_speculation_state_t)dtrace_cas32((uint32_t *)&spec->dtsp_state, current, DTRACESPEC_ACTIVE)
+ == current)
+ return (i + 1);
+ }
+
+ /*
+ * We couldn't find a speculation. If we found as much as a single
+ * busy speculation buffer, we'll attribute this failure as "busy"
+ * instead of "unavail".
+ */
+ do {
+ count = *stat;
+ } while (dtrace_cas32(stat, count, count + 1) != count);
+
+ return (0);
+}
+
+/*
+ * This routine commits an active speculation. If the specified speculation
+ * is not in a valid state to perform a commit(), this routine will silently do
+ * nothing. The state of the specified speculation is transitioned according
+ * to the state transition diagram outlined in <sys/dtrace_impl.h>
+ */
+static void
+dtrace_speculation_commit(dtrace_state_t *state, processorid_t cpu,
+ dtrace_specid_t which)
+{
+ dtrace_speculation_t *spec;
+ dtrace_buffer_t *src, *dest;
+ uintptr_t daddr, saddr, dlimit;
+ dtrace_speculation_state_t current, new VBDTUNASS(-1);
+ intptr_t offs;
+
+ if (which == 0)
+ return;
+
+ if (which > VBDTCAST(unsigned)state->dts_nspeculations) {
+ cpu_core[cpu].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return;
+ }
+
+ spec = &state->dts_speculations[which - 1];
+ src = &spec->dtsp_buffer[cpu];
+ dest = &state->dts_buffer[cpu];
+
+ do {
+ current = spec->dtsp_state;
+
+ if (current == DTRACESPEC_COMMITTINGMANY)
+ break;
+
+ switch (current) {
+ case DTRACESPEC_INACTIVE:
+ case DTRACESPEC_DISCARDING:
+ return;
+
+ case DTRACESPEC_COMMITTING:
+ /*
+ * This is only possible if we are (a) commit()'ing
+ * without having done a prior speculate() on this CPU
+ * and (b) racing with another commit() on a different
+ * CPU. There's nothing to do -- we just assert that
+ * our offset is 0.
+ */
+ ASSERT(src->dtb_offset == 0);
+ return;
+
+ case DTRACESPEC_ACTIVE:
+ new = DTRACESPEC_COMMITTING;
+ break;
+
+ case DTRACESPEC_ACTIVEONE:
+ /*
+ * This speculation is active on one CPU. If our
+ * buffer offset is non-zero, we know that the one CPU
+ * must be us. Otherwise, we are committing on a
+ * different CPU from the speculate(), and we must
+ * rely on being asynchronously cleaned.
+ */
+ if (src->dtb_offset != 0) {
+ new = DTRACESPEC_COMMITTING;
+ break;
+ }
+ RT_FALL_THRU();
+
+ case DTRACESPEC_ACTIVEMANY:
+ new = DTRACESPEC_COMMITTINGMANY;
+ break;
+
+ default:
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalMsgFailed(("%d\n", current));
+#endif
+ }
+ } while ((dtrace_speculation_state_t)dtrace_cas32((uint32_t *)&spec->dtsp_state, current, new) != current);
+
+ /*
+ * We have set the state to indicate that we are committing this
+ * speculation. Now reserve the necessary space in the destination
+ * buffer.
+ */
+ if ((offs = dtrace_buffer_reserve(dest, src->dtb_offset,
+ sizeof (uint64_t), state, NULL)) < 0) {
+ dtrace_buffer_drop(dest);
+ goto out;
+ }
+
+ /*
+ * We have the space; copy the buffer across. (Note that this is a
+ * highly subobtimal bcopy(); in the unlikely event that this becomes
+ * a serious performance issue, a high-performance DTrace-specific
+ * bcopy() should obviously be invented.)
+ */
+ daddr = (uintptr_t)dest->dtb_tomax + offs;
+ dlimit = daddr + src->dtb_offset;
+ saddr = (uintptr_t)src->dtb_tomax;
+
+ /*
+ * First, the aligned portion.
+ */
+ while (dlimit - daddr >= sizeof (uint64_t)) {
+ *((uint64_t *)daddr) = *((uint64_t *)saddr);
+
+ daddr += sizeof (uint64_t);
+ saddr += sizeof (uint64_t);
+ }
+
+ /*
+ * Now any left-over bit...
+ */
+ while (dlimit - daddr)
+ *((uint8_t *)daddr++) = *((uint8_t *)saddr++);
+
+ /*
+ * Finally, commit the reserved space in the destination buffer.
+ */
+ dest->dtb_offset = offs + src->dtb_offset;
+
+out:
+ /*
+ * If we're lucky enough to be the only active CPU on this speculation
+ * buffer, we can just set the state back to DTRACESPEC_INACTIVE.
+ */
+ if (current == DTRACESPEC_ACTIVE ||
+ (current == DTRACESPEC_ACTIVEONE && new == DTRACESPEC_COMMITTING)) {
+ uint32_t rval = dtrace_cas32((uint32_t *)&spec->dtsp_state,
+ DTRACESPEC_COMMITTING, DTRACESPEC_INACTIVE);
+
+ ASSERT(rval == DTRACESPEC_COMMITTING); NOREF(rval);
+ }
+
+ src->dtb_offset = 0;
+ src->dtb_xamot_drops += src->dtb_drops;
+ src->dtb_drops = 0;
+}
+
+/*
+ * This routine discards an active speculation. If the specified speculation
+ * is not in a valid state to perform a discard(), this routine will silently
+ * do nothing. The state of the specified speculation is transitioned
+ * according to the state transition diagram outlined in <sys/dtrace_impl.h>
+ */
+static void
+dtrace_speculation_discard(dtrace_state_t *state, processorid_t cpu,
+ dtrace_specid_t which)
+{
+ dtrace_speculation_t *spec;
+ dtrace_speculation_state_t current, new;
+ dtrace_buffer_t *buf;
+
+ if (which == 0)
+ return;
+
+ if (which > VBDTCAST(unsigned)state->dts_nspeculations) {
+ cpu_core[cpu].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return;
+ }
+
+ spec = &state->dts_speculations[which - 1];
+ buf = &spec->dtsp_buffer[cpu];
+
+ do {
+ current = spec->dtsp_state;
+
+ switch (current) {
+ case DTRACESPEC_INACTIVE:
+ case DTRACESPEC_COMMITTINGMANY:
+ case DTRACESPEC_COMMITTING:
+ case DTRACESPEC_DISCARDING:
+ return;
+
+ case DTRACESPEC_ACTIVE:
+ case DTRACESPEC_ACTIVEMANY:
+ new = DTRACESPEC_DISCARDING;
+ break;
+
+ case DTRACESPEC_ACTIVEONE:
+ if (buf->dtb_offset != 0) {
+ new = DTRACESPEC_INACTIVE;
+ } else {
+ new = DTRACESPEC_DISCARDING;
+ }
+ break;
+
+ default:
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalMsgFailed(("%d\n", current));
+#endif
+ }
+ } while ((dtrace_speculation_state_t)dtrace_cas32((uint32_t *)&spec->dtsp_state, current, new) != current);
+
+ buf->dtb_offset = 0;
+ buf->dtb_drops = 0;
+}
+
+/*
+ * Note: not called from probe context. This function is called
+ * asynchronously from cross call context to clean any speculations that are
+ * in the COMMITTINGMANY or DISCARDING states. These speculations may not be
+ * transitioned back to the INACTIVE state until all CPUs have cleaned the
+ * speculation.
+ */
+static void
+dtrace_speculation_clean_here(dtrace_state_t *state)
+{
+ dtrace_icookie_t cookie;
+ processorid_t cpu = VBDT_GET_CPUID();
+ dtrace_buffer_t *dest = &state->dts_buffer[cpu];
+ dtrace_specid_t i;
+
+ cookie = dtrace_interrupt_disable();
+
+ if (dest->dtb_tomax == NULL) {
+ dtrace_interrupt_enable(cookie);
+ return;
+ }
+
+ for (i = 0; i < VBDTCAST(unsigned)state->dts_nspeculations; i++) {
+ dtrace_speculation_t *spec = &state->dts_speculations[i];
+ dtrace_buffer_t *src = &spec->dtsp_buffer[cpu];
+
+ if (src->dtb_tomax == NULL)
+ continue;
+
+ if (spec->dtsp_state == DTRACESPEC_DISCARDING) {
+ src->dtb_offset = 0;
+ continue;
+ }
+
+ if (spec->dtsp_state != DTRACESPEC_COMMITTINGMANY)
+ continue;
+
+ if (src->dtb_offset == 0)
+ continue;
+
+ dtrace_speculation_commit(state, cpu, i + 1);
+ }
+
+ dtrace_interrupt_enable(cookie);
+}
+
+#ifdef VBOX
+/** */
+static DECLCALLBACK(void) dtrace_speculation_clean_here_wrapper(RTCPUID idCpu, void *pvUser1, void *pvUser2)
+{
+ dtrace_speculation_clean_here((dtrace_state_t *)pvUser1);
+ NOREF(pvUser2); NOREF(idCpu);
+}
+#endif
+
+/*
+ * Note: not called from probe context. This function is called
+ * asynchronously (and at a regular interval) to clean any speculations that
+ * are in the COMMITTINGMANY or DISCARDING states. If it discovers that there
+ * is work to be done, it cross calls all CPUs to perform that work;
+ * COMMITMANY and DISCARDING speculations may not be transitioned back to the
+ * INACTIVE state until they have been cleaned by all CPUs.
+ */
+static void
+dtrace_speculation_clean(dtrace_state_t *state)
+{
+ int work = 0, rv;
+ dtrace_specid_t i;
+
+ for (i = 0; i < VBDTCAST(unsigned)state->dts_nspeculations; i++) {
+ dtrace_speculation_t *spec = &state->dts_speculations[i];
+
+ ASSERT(!spec->dtsp_cleaning);
+
+ if (spec->dtsp_state != DTRACESPEC_DISCARDING &&
+ spec->dtsp_state != DTRACESPEC_COMMITTINGMANY)
+ continue;
+
+ work++;
+ spec->dtsp_cleaning = 1;
+ }
+
+ if (!work)
+ return;
+
+#ifndef VBOX
+ dtrace_xcall(DTRACE_CPUALL,
+ (dtrace_xcall_t)dtrace_speculation_clean_here, state);
+#else
+ RTMpOnAll(dtrace_speculation_clean_here_wrapper, state, NULL);
+#endif
+
+ /*
+ * We now know that all CPUs have committed or discarded their
+ * speculation buffers, as appropriate. We can now set the state
+ * to inactive.
+ */
+ for (i = 0; i < VBDTCAST(unsigned)state->dts_nspeculations; i++) {
+ dtrace_speculation_t *spec = &state->dts_speculations[i];
+ dtrace_speculation_state_t current, new;
+
+ if (!spec->dtsp_cleaning)
+ continue;
+
+ current = spec->dtsp_state;
+ ASSERT(current == DTRACESPEC_DISCARDING ||
+ current == DTRACESPEC_COMMITTINGMANY);
+
+ new = DTRACESPEC_INACTIVE;
+
+ rv = dtrace_cas32((uint32_t *)&spec->dtsp_state, current, new);
+ ASSERT(VBDTCAST(dtrace_speculation_state_t)rv == current);
+ spec->dtsp_cleaning = 0;
+ }
+}
+
+/*
+ * Called as part of a speculate() to get the speculative buffer associated
+ * with a given speculation. Returns NULL if the specified speculation is not
+ * in an ACTIVE state. If the speculation is in the ACTIVEONE state -- and
+ * the active CPU is not the specified CPU -- the speculation will be
+ * atomically transitioned into the ACTIVEMANY state.
+ */
+static dtrace_buffer_t *
+dtrace_speculation_buffer(dtrace_state_t *state, processorid_t cpuid,
+ dtrace_specid_t which)
+{
+ dtrace_speculation_t *spec;
+ dtrace_speculation_state_t current, new VBDTUNASS(-1);
+ dtrace_buffer_t *buf;
+
+ if (which == 0)
+ return (NULL);
+
+ if (which > VBDTCAST(unsigned)state->dts_nspeculations) {
+ cpu_core[cpuid].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (NULL);
+ }
+
+ spec = &state->dts_speculations[which - 1];
+ buf = &spec->dtsp_buffer[cpuid];
+
+ do {
+ current = spec->dtsp_state;
+
+ switch (current) {
+ case DTRACESPEC_INACTIVE:
+ case DTRACESPEC_COMMITTINGMANY:
+ case DTRACESPEC_DISCARDING:
+ return (NULL);
+
+ case DTRACESPEC_COMMITTING:
+ ASSERT(buf->dtb_offset == 0);
+ return (NULL);
+
+ case DTRACESPEC_ACTIVEONE:
+ /*
+ * This speculation is currently active on one CPU.
+ * Check the offset in the buffer; if it's non-zero,
+ * that CPU must be us (and we leave the state alone).
+ * If it's zero, assume that we're starting on a new
+ * CPU -- and change the state to indicate that the
+ * speculation is active on more than one CPU.
+ */
+ if (buf->dtb_offset != 0)
+ return (buf);
+
+ new = DTRACESPEC_ACTIVEMANY;
+ break;
+
+ case DTRACESPEC_ACTIVEMANY:
+ return (buf);
+
+ case DTRACESPEC_ACTIVE:
+ new = DTRACESPEC_ACTIVEONE;
+ break;
+
+ default:
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalMsgFailed(("%d\n", current));
+#endif
+ }
+ } while ((dtrace_speculation_state_t)dtrace_cas32((uint32_t *)&spec->dtsp_state, current, new) != current);
+
+ ASSERT(new == DTRACESPEC_ACTIVEONE || new == DTRACESPEC_ACTIVEMANY);
+ return (buf);
+}
+
+/*
+ * Return a string. In the event that the user lacks the privilege to access
+ * arbitrary kernel memory, we copy the string out to scratch memory so that we
+ * don't fail access checking.
+ *
+ * dtrace_dif_variable() uses this routine as a helper for various
+ * builtin values such as 'execname' and 'probefunc.'
+ */
+VBDTSTATIC uintptr_t
+dtrace_dif_varstr(uintptr_t addr, dtrace_state_t *state,
+ dtrace_mstate_t *mstate)
+{
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ uintptr_t ret;
+ size_t strsz;
+
+ /*
+ * The easy case: this probe is allowed to read all of memory, so
+ * we can just return this as a vanilla pointer.
+ */
+ if ((mstate->dtms_access & DTRACE_ACCESS_KERNEL) != 0)
+ return (addr);
+
+ /*
+ * This is the tougher case: we copy the string in question from
+ * kernel memory into scratch memory and return it that way: this
+ * ensures that we won't trip up when access checking tests the
+ * BYREF return value.
+ */
+ strsz = dtrace_strlen((char *)addr, size) + 1;
+
+ if (mstate->dtms_scratch_ptr + strsz >
+ mstate->dtms_scratch_base + mstate->dtms_scratch_size) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ return (NULL);
+ }
+
+ dtrace_strcpy((const void *)addr, (void *)mstate->dtms_scratch_ptr,
+ strsz);
+ ret = mstate->dtms_scratch_ptr;
+ mstate->dtms_scratch_ptr += strsz;
+ return (ret);
+}
+
+/*
+ * This function implements the DIF emulator's variable lookups. The emulator
+ * passes a reserved variable identifier and optional built-in array index.
+ */
+static uint64_t
+dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
+ uint64_t ndx)
+{
+ /*
+ * If we're accessing one of the uncached arguments, we'll turn this
+ * into a reference in the args array.
+ */
+ if (v >= DIF_VAR_ARG0 && v <= DIF_VAR_ARG9) {
+ ndx = v - DIF_VAR_ARG0;
+ v = DIF_VAR_ARGS;
+ }
+
+ switch (v) {
+ case DIF_VAR_ARGS:
+ ASSERT(mstate->dtms_present & DTRACE_MSTATE_ARGS);
+ if (ndx >= sizeof (mstate->dtms_arg) /
+ sizeof (mstate->dtms_arg[0])) {
+ int aframes = mstate->dtms_probe->dtpr_aframes + 2;
+ dtrace_provider_t *pv;
+ uint64_t val;
+
+ pv = mstate->dtms_probe->dtpr_provider;
+ if (pv->dtpv_pops.dtps_getargval != NULL)
+ val = pv->dtpv_pops.dtps_getargval(pv->dtpv_arg,
+ mstate->dtms_probe->dtpr_id,
+ mstate->dtms_probe->dtpr_arg, ndx, aframes);
+ else
+ val = dtrace_getarg(ndx, aframes);
+
+ /*
+ * This is regrettably required to keep the compiler
+ * from tail-optimizing the call to dtrace_getarg().
+ * The condition always evaluates to true, but the
+ * compiler has no way of figuring that out a priori.
+ * (None of this would be necessary if the compiler
+ * could be relied upon to _always_ tail-optimize
+ * the call to dtrace_getarg() -- but it can't.)
+ */
+ if (mstate->dtms_probe != NULL)
+ return (val);
+
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalFailed();
+#endif
+ }
+
+ return (mstate->dtms_arg[ndx]);
+
+ case DIF_VAR_UREGS: {
+#ifndef VBOX
+ klwp_t *lwp;
+
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+ if ((lwp = curthread->t_lwp) == NULL) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = NULL;
+ return (0);
+ }
+
+ return (dtrace_getreg(lwp->lwp_regs, ndx));
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0);
+#endif
+ }
+
+ case DIF_VAR_CURTHREAD:
+ if (!dtrace_priv_kernel(state))
+ return (0);
+#ifndef VBOX
+ return ((uint64_t)(uintptr_t)curthread);
+#else
+ return ((uintptr_t)RTThreadNativeSelf());
+#endif
+
+ case DIF_VAR_TIMESTAMP:
+ if (!(mstate->dtms_present & DTRACE_MSTATE_TIMESTAMP)) {
+ mstate->dtms_timestamp = dtrace_gethrtime();
+ mstate->dtms_present |= DTRACE_MSTATE_TIMESTAMP;
+ }
+ return (mstate->dtms_timestamp);
+
+ case DIF_VAR_VTIMESTAMP:
+#ifndef VBOX
+ ASSERT(dtrace_vtime_references != 0);
+ return (curthread->t_dtrace_vtime);
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0);
+#endif
+
+ case DIF_VAR_WALLTIMESTAMP:
+ if (!(mstate->dtms_present & DTRACE_MSTATE_WALLTIMESTAMP)) {
+ mstate->dtms_walltimestamp = dtrace_gethrestime();
+ mstate->dtms_present |= DTRACE_MSTATE_WALLTIMESTAMP;
+ }
+ return (mstate->dtms_walltimestamp);
+
+ case DIF_VAR_IPL:
+ if (!dtrace_priv_kernel(state))
+ return (0);
+ if (!(mstate->dtms_present & DTRACE_MSTATE_IPL)) {
+ mstate->dtms_ipl = dtrace_getipl();
+ mstate->dtms_present |= DTRACE_MSTATE_IPL;
+ }
+ return (mstate->dtms_ipl);
+
+ case DIF_VAR_EPID:
+ ASSERT(mstate->dtms_present & DTRACE_MSTATE_EPID);
+ return (mstate->dtms_epid);
+
+ case DIF_VAR_ID:
+ ASSERT(mstate->dtms_present & DTRACE_MSTATE_PROBE);
+ return (mstate->dtms_probe->dtpr_id);
+
+ case DIF_VAR_STACKDEPTH:
+ if (!dtrace_priv_kernel(state))
+ return (0);
+ if (!(mstate->dtms_present & DTRACE_MSTATE_STACKDEPTH)) {
+ int aframes = mstate->dtms_probe->dtpr_aframes + 2;
+
+ mstate->dtms_stackdepth = dtrace_getstackdepth(aframes);
+ mstate->dtms_present |= DTRACE_MSTATE_STACKDEPTH;
+ }
+ return (mstate->dtms_stackdepth);
+
+ case DIF_VAR_USTACKDEPTH:
+ if (!dtrace_priv_proc(state))
+ return (0);
+ if (!(mstate->dtms_present & DTRACE_MSTATE_USTACKDEPTH)) {
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) &&
+ CPU_ON_INTR(CPU)) {
+ mstate->dtms_ustackdepth = 0;
+ } else {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ mstate->dtms_ustackdepth =
+ dtrace_getustackdepth();
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+ }
+ mstate->dtms_present |= DTRACE_MSTATE_USTACKDEPTH;
+ }
+ return (mstate->dtms_ustackdepth);
+
+ case DIF_VAR_CALLER:
+ if (!dtrace_priv_kernel(state))
+ return (0);
+ if (!(mstate->dtms_present & DTRACE_MSTATE_CALLER)) {
+ int aframes = mstate->dtms_probe->dtpr_aframes + 2;
+
+ if (!DTRACE_ANCHORED(mstate->dtms_probe)) {
+ /*
+ * If this is an unanchored probe, we are
+ * required to go through the slow path:
+ * dtrace_caller() only guarantees correct
+ * results for anchored probes.
+ */
+ pc_t caller[2];
+
+ dtrace_getpcstack(caller, 2, aframes,
+ (uint32_t *)(uintptr_t)mstate->dtms_arg[0]);
+ mstate->dtms_caller = caller[1];
+ } else if ((mstate->dtms_caller =
+ dtrace_caller(aframes)) == VBDTCAST(uintptr_t)-1) {
+ /*
+ * We have failed to do this the quick way;
+ * we must resort to the slower approach of
+ * calling dtrace_getpcstack().
+ */
+ pc_t caller;
+
+ dtrace_getpcstack(&caller, 1, aframes, NULL);
+ mstate->dtms_caller = caller;
+ }
+
+ mstate->dtms_present |= DTRACE_MSTATE_CALLER;
+ }
+ return (mstate->dtms_caller);
+
+ case DIF_VAR_UCALLER:
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+ if (!(mstate->dtms_present & DTRACE_MSTATE_UCALLER)) {
+ uint64_t ustack[3];
+
+ /*
+ * dtrace_getupcstack() fills in the first uint64_t
+ * with the current PID. The second uint64_t will
+ * be the program counter at user-level. The third
+ * uint64_t will contain the caller, which is what
+ * we're after.
+ */
+ ustack[2] = NULL;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_getupcstack(ustack, 3);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+ mstate->dtms_ucaller = ustack[2];
+ mstate->dtms_present |= DTRACE_MSTATE_UCALLER;
+ }
+
+ return (mstate->dtms_ucaller);
+
+ case DIF_VAR_PROBEPROV:
+ ASSERT(mstate->dtms_present & DTRACE_MSTATE_PROBE);
+ return (dtrace_dif_varstr(
+ (uintptr_t)mstate->dtms_probe->dtpr_provider->dtpv_name,
+ state, mstate));
+
+ case DIF_VAR_PROBEMOD:
+ ASSERT(mstate->dtms_present & DTRACE_MSTATE_PROBE);
+ return (dtrace_dif_varstr(
+ (uintptr_t)mstate->dtms_probe->dtpr_mod,
+ state, mstate));
+
+ case DIF_VAR_PROBEFUNC:
+ ASSERT(mstate->dtms_present & DTRACE_MSTATE_PROBE);
+ return (dtrace_dif_varstr(
+ (uintptr_t)mstate->dtms_probe->dtpr_func,
+ state, mstate));
+
+ case DIF_VAR_PROBENAME:
+ ASSERT(mstate->dtms_present & DTRACE_MSTATE_PROBE);
+ return (dtrace_dif_varstr(
+ (uintptr_t)mstate->dtms_probe->dtpr_name,
+ state, mstate));
+
+ case DIF_VAR_PID:
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+#ifndef VBOX
+ /*
+ * Note that we are assuming that an unanchored probe is
+ * always due to a high-level interrupt. (And we're assuming
+ * that there is only a single high level interrupt.)
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return (pid0.pid_id);
+
+ /*
+ * It is always safe to dereference one's own t_procp pointer:
+ * it always points to a valid, allocated proc structure.
+ * Further, it is always safe to dereference the p_pidp member
+ * of one's own proc structure. (These are truisms becuase
+ * threads and processes don't clean up their own state --
+ * they leave that task to whomever reaps them.)
+ */
+ return ((uint64_t)curthread->t_procp->p_pidp->pid_id);
+#else
+ return (RTProcSelf());
+#endif
+
+ case DIF_VAR_PPID:
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+#ifndef VBOX
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return (pid0.pid_id);
+
+ /*
+ * It is always safe to dereference one's own t_procp pointer:
+ * it always points to a valid, allocated proc structure.
+ * (This is true because threads don't clean up their own
+ * state -- they leave that task to whomever reaps them.)
+ */
+ return ((uint64_t)curthread->t_procp->p_ppid);
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0); /** @todo parent pid? */
+#endif
+
+ case DIF_VAR_TID:
+#ifndef VBOX
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return (0);
+
+ return ((uint64_t)curthread->t_tid);
+#else
+ return (RTThreadNativeSelf()); /** @todo proper tid? */
+#endif
+
+ case DIF_VAR_EXECNAME:
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+#ifndef VBOX
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return ((uint64_t)(uintptr_t)p0.p_user.u_comm);
+
+ /*
+ * It is always safe to dereference one's own t_procp pointer:
+ * it always points to a valid, allocated proc structure.
+ * (This is true because threads don't clean up their own
+ * state -- they leave that task to whomever reaps them.)
+ */
+ return (dtrace_dif_varstr(
+ (uintptr_t)curthread->t_procp->p_user.u_comm,
+ state, mstate));
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0); /** @todo execname */
+#endif
+
+ case DIF_VAR_ZONENAME:
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+#ifndef VBOX
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return ((uint64_t)(uintptr_t)p0.p_zone->zone_name);
+
+ /*
+ * It is always safe to dereference one's own t_procp pointer:
+ * it always points to a valid, allocated proc structure.
+ * (This is true because threads don't clean up their own
+ * state -- they leave that task to whomever reaps them.)
+ */
+ return (dtrace_dif_varstr(
+ (uintptr_t)curthread->t_procp->p_zone->zone_name,
+ state, mstate));
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0);
+#endif
+
+ case DIF_VAR_UID:
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+#ifndef VBOX
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return ((uint64_t)p0.p_cred->cr_uid);
+
+ /*
+ * It is always safe to dereference one's own t_procp pointer:
+ * it always points to a valid, allocated proc structure.
+ * (This is true because threads don't clean up their own
+ * state -- they leave that task to whomever reaps them.)
+ *
+ * Additionally, it is safe to dereference one's own process
+ * credential, since this is never NULL after process birth.
+ */
+ return ((uint64_t)curthread->t_procp->p_cred->cr_uid);
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0);
+#endif
+
+ case DIF_VAR_GID:
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+#ifndef VBOX
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return ((uint64_t)p0.p_cred->cr_gid);
+
+ /*
+ * It is always safe to dereference one's own t_procp pointer:
+ * it always points to a valid, allocated proc structure.
+ * (This is true because threads don't clean up their own
+ * state -- they leave that task to whomever reaps them.)
+ *
+ * Additionally, it is safe to dereference one's own process
+ * credential, since this is never NULL after process birth.
+ */
+ return ((uint64_t)curthread->t_procp->p_cred->cr_gid);
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0);
+#endif
+
+ case DIF_VAR_ERRNO: {
+#ifndef VBOX
+ klwp_t *lwp;
+#endif
+ if (!dtrace_priv_proc(state))
+ return (0);
+
+#ifndef VBOX
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+ return (0);
+
+ /*
+ * It is always safe to dereference one's own t_lwp pointer in
+ * the event that this pointer is non-NULL. (This is true
+ * because threads and lwps don't clean up their own state --
+ * they leave that task to whomever reaps them.)
+ */
+ if ((lwp = curthread->t_lwp) == NULL)
+ return (0);
+
+ return ((uint64_t)lwp->lwp_errno);
+#else
+ cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
+ return (0);
+#endif
+ }
+ default:
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return (0);
+ }
+}
+
+/*
+ * Emulate the execution of DTrace ID subroutines invoked by the call opcode.
+ * Notice that we don't bother validating the proper number of arguments or
+ * their types in the tuple stack. This isn't needed because all argument
+ * interpretation is safe because of our load safety -- the worst that can
+ * happen is that a bogus program can obtain bogus results.
+ */
+static void
+dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
+ dtrace_key_t *tupregs, int nargs,
+ dtrace_mstate_t *mstate, dtrace_state_t *state)
+{
+ volatile uint16_t *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+ volatile uintptr_t *illval = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
+ dtrace_vstate_t *vstate = &state->dts_vstate;
+
+#ifndef VBOX
+ union {
+ mutex_impl_t mi;
+ uint64_t mx;
+ } m;
+
+ union {
+ krwlock_t ri;
+ uintptr_t rw;
+ } r;
+#endif
+
+ switch (subr) {
+ case DIF_SUBR_RAND:
+ regs[rd] = (dtrace_gethrtime() * 2416 + 374441) % 1771875;
+ break;
+
+ case DIF_SUBR_MUTEX_OWNED:
+#ifndef VBOX
+ if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t),
+ mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ m.mx = dtrace_load64(tupregs[0].dttk_value);
+ if (MUTEX_TYPE_ADAPTIVE(&m.mi))
+ regs[rd] = MUTEX_OWNER(&m.mi) != MUTEX_NO_OWNER;
+ else
+ regs[rd] = LOCK_HELD(&m.mi.m_spin.m_spinlock);
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_MUTEX_OWNER:
+#ifndef VBOX
+ if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t),
+ mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ m.mx = dtrace_load64(tupregs[0].dttk_value);
+ if (MUTEX_TYPE_ADAPTIVE(&m.mi) &&
+ MUTEX_OWNER(&m.mi) != MUTEX_NO_OWNER)
+ regs[rd] = (uintptr_t)MUTEX_OWNER(&m.mi);
+ else
+ regs[rd] = 0;
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_MUTEX_TYPE_ADAPTIVE:
+#ifndef VBOX
+ if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t),
+ mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ m.mx = dtrace_load64(tupregs[0].dttk_value);
+ regs[rd] = MUTEX_TYPE_ADAPTIVE(&m.mi);
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_MUTEX_TYPE_SPIN:
+#ifndef VBOX
+ if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t),
+ mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ m.mx = dtrace_load64(tupregs[0].dttk_value);
+ regs[rd] = MUTEX_TYPE_SPIN(&m.mi);
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_RW_READ_HELD: {
+#ifndef VBOX
+ uintptr_t tmp;
+
+ if (!dtrace_canload(tupregs[0].dttk_value, sizeof (uintptr_t),
+ mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ r.rw = dtrace_loadptr(tupregs[0].dttk_value);
+ regs[rd] = _RW_READ_HELD(&r.ri, tmp);
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+ }
+
+ case DIF_SUBR_RW_WRITE_HELD:
+#ifndef VBOX
+ if (!dtrace_canload(tupregs[0].dttk_value, sizeof (krwlock_t),
+ mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ r.rw = dtrace_loadptr(tupregs[0].dttk_value);
+ regs[rd] = _RW_WRITE_HELD(&r.ri);
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_RW_ISWRITER:
+#ifndef VBOX
+ if (!dtrace_canload(tupregs[0].dttk_value, sizeof (krwlock_t),
+ mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ r.rw = dtrace_loadptr(tupregs[0].dttk_value);
+ regs[rd] = _RW_ISWRITER(&r.ri);
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_BCOPY: {
+ /*
+ * We need to be sure that the destination is in the scratch
+ * region -- no other region is allowed.
+ */
+ uintptr_t src = tupregs[0].dttk_value;
+ uintptr_t dest = tupregs[1].dttk_value;
+ size_t size = tupregs[2].dttk_value;
+
+ if (!dtrace_inscratch(dest, size, mstate)) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = regs[rd];
+ break;
+ }
+
+ if (!dtrace_canload(src, size, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ dtrace_bcopy((void *)src, (void *)dest, size);
+ break;
+ }
+
+ case DIF_SUBR_ALLOCA:
+ case DIF_SUBR_COPYIN: {
+ uintptr_t dest = P2ROUNDUP(mstate->dtms_scratch_ptr, 8);
+ uint64_t size =
+ tupregs[subr == DIF_SUBR_ALLOCA ? 0 : 1].dttk_value;
+ size_t scratch_size = (dest - mstate->dtms_scratch_ptr) + size;
+
+ /*
+ * This action doesn't require any credential checks since
+ * probes will not activate in user contexts to which the
+ * enabling user does not have permissions.
+ */
+
+ /*
+ * Rounding up the user allocation size could have overflowed
+ * a large, bogus allocation (like -1ULL) to 0.
+ */
+ if (scratch_size < size ||
+ !DTRACE_INSCRATCH(mstate, scratch_size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (subr == DIF_SUBR_COPYIN) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_copyin(tupregs[0].dttk_value, dest, size, flags);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+ }
+
+ mstate->dtms_scratch_ptr += scratch_size;
+ regs[rd] = dest;
+ break;
+ }
+
+ case DIF_SUBR_COPYINTO: {
+ uint64_t size = tupregs[1].dttk_value;
+ uintptr_t dest = tupregs[2].dttk_value;
+
+ /*
+ * This action doesn't require any credential checks since
+ * probes will not activate in user contexts to which the
+ * enabling user does not have permissions.
+ */
+ if (!dtrace_inscratch(dest, size, mstate)) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = regs[rd];
+ break;
+ }
+
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_copyin(tupregs[0].dttk_value, dest, size, flags);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+ break;
+ }
+
+ case DIF_SUBR_COPYINSTR: {
+ uintptr_t dest = mstate->dtms_scratch_ptr;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+
+ if (nargs > 1 && tupregs[1].dttk_value < size)
+ size = tupregs[1].dttk_value + 1;
+
+ /*
+ * This action doesn't require any credential checks since
+ * probes will not activate in user contexts to which the
+ * enabling user does not have permissions.
+ */
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_copyinstr(tupregs[0].dttk_value, dest, size, flags);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+
+ ((char *)dest)[size - 1] = '\0';
+ mstate->dtms_scratch_ptr += size;
+ regs[rd] = dest;
+ break;
+ }
+
+ case DIF_SUBR_MSGSIZE:
+ case DIF_SUBR_MSGDSIZE: {
+#ifndef VBOX
+ uintptr_t baddr = tupregs[0].dttk_value, daddr;
+ uintptr_t wptr, rptr;
+ size_t count = 0;
+ int cont = 0;
+
+ while (baddr != NULL && !(*flags & CPU_DTRACE_FAULT)) {
+
+ if (!dtrace_canload(baddr, sizeof (mblk_t), mstate,
+ vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ wptr = dtrace_loadptr(baddr +
+ offsetof(mblk_t, b_wptr));
+
+ rptr = dtrace_loadptr(baddr +
+ offsetof(mblk_t, b_rptr));
+
+ if (wptr < rptr) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = tupregs[0].dttk_value;
+ break;
+ }
+
+ daddr = dtrace_loadptr(baddr +
+ offsetof(mblk_t, b_datap));
+
+ baddr = dtrace_loadptr(baddr +
+ offsetof(mblk_t, b_cont));
+
+ /*
+ * We want to prevent against denial-of-service here,
+ * so we're only going to search the list for
+ * dtrace_msgdsize_max mblks.
+ */
+ if (cont++ > dtrace_msgdsize_max) {
+ *flags |= CPU_DTRACE_ILLOP;
+ break;
+ }
+
+ if (subr == DIF_SUBR_MSGDSIZE) {
+ if (dtrace_load8(daddr +
+ offsetof(dblk_t, db_type)) != M_DATA)
+ continue;
+ }
+
+ count += wptr - rptr;
+ }
+
+ if (!(*flags & CPU_DTRACE_FAULT))
+ regs[rd] = count;
+
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+ }
+
+ case DIF_SUBR_PROGENYOF: {
+#ifndef VBOX
+ pid_t pid = tupregs[0].dttk_value;
+ proc_t *p;
+ int rval = 0;
+
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+
+ for (p = curthread->t_procp; p != NULL; p = p->p_parent) {
+ if (p->p_pidp->pid_id == pid) {
+ rval = 1;
+ break;
+ }
+ }
+
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+
+ regs[rd] = rval;
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+ }
+
+ case DIF_SUBR_SPECULATION:
+ regs[rd] = dtrace_speculation(state);
+ break;
+
+ case DIF_SUBR_COPYOUT: {
+ uintptr_t kaddr = tupregs[0].dttk_value;
+ uintptr_t uaddr = tupregs[1].dttk_value;
+ uint64_t size = tupregs[2].dttk_value;
+
+ if (!dtrace_destructive_disallow &&
+ dtrace_priv_proc_control(state) &&
+ !dtrace_istoxic(kaddr, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_copyout(kaddr, uaddr, size, flags);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+ }
+ break;
+ }
+
+ case DIF_SUBR_COPYOUTSTR: {
+ uintptr_t kaddr = tupregs[0].dttk_value;
+ uintptr_t uaddr = tupregs[1].dttk_value;
+ uint64_t size = tupregs[2].dttk_value;
+
+ if (!dtrace_destructive_disallow &&
+ dtrace_priv_proc_control(state) &&
+ !dtrace_istoxic(kaddr, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_copyoutstr(kaddr, uaddr, size, flags);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+ }
+ break;
+ }
+
+ case DIF_SUBR_STRLEN: {
+ size_t sz;
+ uintptr_t addr = (uintptr_t)tupregs[0].dttk_value;
+ sz = dtrace_strlen((char *)addr,
+ state->dts_options[DTRACEOPT_STRSIZE]);
+
+ if (!dtrace_canload(addr, sz + 1, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ regs[rd] = sz;
+
+ break;
+ }
+
+ case DIF_SUBR_STRCHR:
+ case DIF_SUBR_STRRCHR: {
+ /*
+ * We're going to iterate over the string looking for the
+ * specified character. We will iterate until we have reached
+ * the string length or we have found the character. If this
+ * is DIF_SUBR_STRRCHR, we will look for the last occurrence
+ * of the specified character instead of the first.
+ */
+ uintptr_t saddr = tupregs[0].dttk_value;
+ uintptr_t addr = tupregs[0].dttk_value;
+ uintptr_t limit = addr + state->dts_options[DTRACEOPT_STRSIZE];
+ char c, target = (char)tupregs[1].dttk_value;
+
+ for (regs[rd] = NULL; addr < limit; addr++) {
+ if ((c = dtrace_load8(addr)) == target) {
+ regs[rd] = addr;
+
+ if (subr == DIF_SUBR_STRCHR)
+ break;
+ }
+
+ if (c == '\0')
+ break;
+ }
+
+ if (!dtrace_canload(saddr, addr - saddr, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ break;
+ }
+
+ case DIF_SUBR_STRSTR:
+ case DIF_SUBR_INDEX:
+ case DIF_SUBR_RINDEX: {
+ /*
+ * We're going to iterate over the string looking for the
+ * specified string. We will iterate until we have reached
+ * the string length or we have found the string. (Yes, this
+ * is done in the most naive way possible -- but considering
+ * that the string we're searching for is likely to be
+ * relatively short, the complexity of Rabin-Karp or similar
+ * hardly seems merited.)
+ */
+ char *addr = (char *)(uintptr_t)tupregs[0].dttk_value;
+ char *substr = (char *)(uintptr_t)tupregs[1].dttk_value;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ size_t len = dtrace_strlen(addr, size);
+ size_t sublen = dtrace_strlen(substr, size);
+ char *limit = addr + len, *orig = addr;
+ int notfound = subr == DIF_SUBR_STRSTR ? 0 : -1;
+ int inc = 1;
+
+ regs[rd] = notfound;
+
+ if (!dtrace_canload((uintptr_t)addr, len + 1, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (!dtrace_canload((uintptr_t)substr, sublen + 1, mstate,
+ vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ /*
+ * strstr() and index()/rindex() have similar semantics if
+ * both strings are the empty string: strstr() returns a
+ * pointer to the (empty) string, and index() and rindex()
+ * both return index 0 (regardless of any position argument).
+ */
+ if (sublen == 0 && len == 0) {
+ if (subr == DIF_SUBR_STRSTR)
+ regs[rd] = (uintptr_t)addr;
+ else
+ regs[rd] = 0;
+ break;
+ }
+
+ if (subr != DIF_SUBR_STRSTR) {
+ if (subr == DIF_SUBR_RINDEX) {
+ limit = orig - 1;
+ addr += len;
+ inc = -1;
+ }
+
+ /*
+ * Both index() and rindex() take an optional position
+ * argument that denotes the starting position.
+ */
+ if (nargs == 3) {
+ int64_t pos = (int64_t)tupregs[2].dttk_value;
+
+ /*
+ * If the position argument to index() is
+ * negative, Perl implicitly clamps it at
+ * zero. This semantic is a little surprising
+ * given the special meaning of negative
+ * positions to similar Perl functions like
+ * substr(), but it appears to reflect a
+ * notion that index() can start from a
+ * negative index and increment its way up to
+ * the string. Given this notion, Perl's
+ * rindex() is at least self-consistent in
+ * that it implicitly clamps positions greater
+ * than the string length to be the string
+ * length. Where Perl completely loses
+ * coherence, however, is when the specified
+ * substring is the empty string (""). In
+ * this case, even if the position is
+ * negative, rindex() returns 0 -- and even if
+ * the position is greater than the length,
+ * index() returns the string length. These
+ * semantics violate the notion that index()
+ * should never return a value less than the
+ * specified position and that rindex() should
+ * never return a value greater than the
+ * specified position. (One assumes that
+ * these semantics are artifacts of Perl's
+ * implementation and not the results of
+ * deliberate design -- it beggars belief that
+ * even Larry Wall could desire such oddness.)
+ * While in the abstract one would wish for
+ * consistent position semantics across
+ * substr(), index() and rindex() -- or at the
+ * very least self-consistent position
+ * semantics for index() and rindex() -- we
+ * instead opt to keep with the extant Perl
+ * semantics, in all their broken glory. (Do
+ * we have more desire to maintain Perl's
+ * semantics than Perl does? Probably.)
+ */
+ if (subr == DIF_SUBR_RINDEX) {
+ if (pos < 0) {
+ if (sublen == 0)
+ regs[rd] = 0;
+ break;
+ }
+
+ if (VBDTCAST(uint64_t)pos > len)
+ pos = len;
+ } else {
+ if (pos < 0)
+ pos = 0;
+
+ if (VBDTCAST(uint64_t)pos >= len) {
+ if (sublen == 0)
+ regs[rd] = len;
+ break;
+ }
+ }
+
+ addr = orig + pos;
+ }
+ }
+
+ for (regs[rd] = notfound; addr != limit; addr += inc) {
+ if (dtrace_strncmp(addr, substr, sublen) == 0) {
+ if (subr != DIF_SUBR_STRSTR) {
+ /*
+ * As D index() and rindex() are
+ * modeled on Perl (and not on awk),
+ * we return a zero-based (and not a
+ * one-based) index. (For you Perl
+ * weenies: no, we're not going to add
+ * $[ -- and shouldn't you be at a con
+ * or something?)
+ */
+ regs[rd] = (uintptr_t)(addr - orig);
+ break;
+ }
+
+ ASSERT(subr == DIF_SUBR_STRSTR);
+ regs[rd] = (uintptr_t)addr;
+ break;
+ }
+ }
+
+ break;
+ }
+
+ case DIF_SUBR_STRTOK: {
+ uintptr_t addr = tupregs[0].dttk_value;
+ uintptr_t tokaddr = tupregs[1].dttk_value;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ uintptr_t limit, toklimit = tokaddr + size;
+ uint8_t c VBDTUNASS(0), tokmap[32]; /* 256 / 8 */
+ char *dest = (char *)mstate->dtms_scratch_ptr;
+ VBDTTYPE(unsigned,int) i;
+
+ /*
+ * Check both the token buffer and (later) the input buffer,
+ * since both could be non-scratch addresses.
+ */
+ if (!dtrace_strcanload(tokaddr, size, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (addr == NULL) {
+ /*
+ * If the address specified is NULL, we use our saved
+ * strtok pointer from the mstate. Note that this
+ * means that the saved strtok pointer is _only_
+ * valid within multiple enablings of the same probe --
+ * it behaves like an implicit clause-local variable.
+ */
+ addr = mstate->dtms_strtok;
+ } else {
+ /*
+ * If the user-specified address is non-NULL we must
+ * access check it. This is the only time we have
+ * a chance to do so, since this address may reside
+ * in the string table of this clause-- future calls
+ * (when we fetch addr from mstate->dtms_strtok)
+ * would fail this access check.
+ */
+ if (!dtrace_strcanload(addr, size, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+ }
+
+ /*
+ * First, zero the token map, and then process the token
+ * string -- setting a bit in the map for every character
+ * found in the token string.
+ */
+ for (i = 0; i < sizeof (tokmap); i++)
+ tokmap[i] = 0;
+
+ for (; tokaddr < toklimit; tokaddr++) {
+ if ((c = dtrace_load8(tokaddr)) == '\0')
+ break;
+
+ ASSERT((c >> 3) < sizeof (tokmap));
+ tokmap[c >> 3] |= (1 << (c & 0x7));
+ }
+
+ for (limit = addr + size; addr < limit; addr++) {
+ /*
+ * We're looking for a character that is _not_ contained
+ * in the token string.
+ */
+ if ((c = dtrace_load8(addr)) == '\0')
+ break;
+
+ if (!(tokmap[c >> 3] & (1 << (c & 0x7))))
+ break;
+ }
+
+ if (c == '\0') {
+ /*
+ * We reached the end of the string without finding
+ * any character that was not in the token string.
+ * We return NULL in this case, and we set the saved
+ * address to NULL as well.
+ */
+ regs[rd] = NULL;
+ mstate->dtms_strtok = NULL;
+ break;
+ }
+
+ /*
+ * From here on, we're copying into the destination string.
+ */
+ for (i = 0; addr < limit && i < size - 1; addr++) {
+ if ((c = dtrace_load8(addr)) == '\0')
+ break;
+
+ if (tokmap[c >> 3] & (1 << (c & 0x7)))
+ break;
+
+ ASSERT(i < size);
+ dest[i++] = c;
+ }
+
+ ASSERT(i < size);
+ dest[i] = '\0';
+ regs[rd] = (uintptr_t)dest;
+ mstate->dtms_scratch_ptr += size;
+ mstate->dtms_strtok = addr;
+ break;
+ }
+
+ case DIF_SUBR_SUBSTR: {
+ uintptr_t s = tupregs[0].dttk_value;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ char *d = (char *)mstate->dtms_scratch_ptr;
+ int64_t index = (int64_t)tupregs[1].dttk_value;
+ int64_t remaining = (int64_t)tupregs[2].dttk_value;
+ size_t len = dtrace_strlen((char *)s, size);
+ int64_t i;
+
+ if (!dtrace_canload(s, len + 1, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (nargs <= 2)
+ remaining = (int64_t)size;
+
+ if (index < 0) {
+ index += len;
+
+ if (index < 0 && index + remaining > 0) {
+ remaining += index;
+ index = 0;
+ }
+ }
+
+ if (VBDTCAST(uint64_t)index >= len || index < 0) {
+ remaining = 0;
+ } else if (remaining < 0) {
+ remaining += len - index;
+ } else if (VBDTCAST(uint64_t)index + remaining > size) {
+ remaining = size - index;
+ }
+
+ for (i = 0; i < remaining; i++) {
+ if ((d[i] = dtrace_load8(s + index + i)) == '\0')
+ break;
+ }
+
+ d[i] = '\0';
+
+ mstate->dtms_scratch_ptr += size;
+ regs[rd] = (uintptr_t)d;
+ break;
+ }
+
+ case DIF_SUBR_GETMAJOR:
+#ifndef VBOX
+#ifdef _LP64
+ regs[rd] = (tupregs[0].dttk_value >> NBITSMINOR64) & MAXMAJ64;
+#else
+ regs[rd] = (tupregs[0].dttk_value >> NBITSMINOR) & MAXMAJ;
+#endif
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_GETMINOR:
+#ifndef VBOX
+#ifdef _LP64
+ regs[rd] = tupregs[0].dttk_value & MAXMIN64;
+#else
+ regs[rd] = tupregs[0].dttk_value & MAXMIN;
+#endif
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+
+ case DIF_SUBR_DDI_PATHNAME: {
+#ifndef VBOX
+ /*
+ * This one is a galactic mess. We are going to roughly
+ * emulate ddi_pathname(), but it's made more complicated
+ * by the fact that we (a) want to include the minor name and
+ * (b) must proceed iteratively instead of recursively.
+ */
+ uintptr_t dest = mstate->dtms_scratch_ptr;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ char *start = (char *)dest, *end = start + size - 1;
+ uintptr_t daddr = tupregs[0].dttk_value;
+ int64_t minor = (int64_t)tupregs[1].dttk_value;
+ char *s;
+ int i, len, depth = 0;
+
+ /*
+ * Due to all the pointer jumping we do and context we must
+ * rely upon, we just mandate that the user must have kernel
+ * read privileges to use this routine.
+ */
+ if ((mstate->dtms_access & DTRACE_ACCESS_KERNEL) == 0) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = daddr;
+ regs[rd] = NULL;
+ }
+
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ *end = '\0';
+
+ /*
+ * We want to have a name for the minor. In order to do this,
+ * we need to walk the minor list from the devinfo. We want
+ * to be sure that we don't infinitely walk a circular list,
+ * so we check for circularity by sending a scout pointer
+ * ahead two elements for every element that we iterate over;
+ * if the list is circular, these will ultimately point to the
+ * same element. You may recognize this little trick as the
+ * answer to a stupid interview question -- one that always
+ * seems to be asked by those who had to have it laboriously
+ * explained to them, and who can't even concisely describe
+ * the conditions under which one would be forced to resort to
+ * this technique. Needless to say, those conditions are
+ * found here -- and probably only here. Is this the only use
+ * of this infamous trick in shipping, production code? If it
+ * isn't, it probably should be...
+ */
+ if (minor != -1) {
+ uintptr_t maddr = dtrace_loadptr(daddr +
+ offsetof(struct dev_info, devi_minor));
+
+ uintptr_t next = offsetof(struct ddi_minor_data, next);
+ uintptr_t name = offsetof(struct ddi_minor_data,
+ d_minor) + offsetof(struct ddi_minor, name);
+ uintptr_t dev = offsetof(struct ddi_minor_data,
+ d_minor) + offsetof(struct ddi_minor, dev);
+ uintptr_t scout;
+
+ if (maddr != NULL)
+ scout = dtrace_loadptr(maddr + next);
+
+ while (maddr != NULL && !(*flags & CPU_DTRACE_FAULT)) {
+ uint64_t m;
+#ifdef _LP64
+ m = dtrace_load64(maddr + dev) & MAXMIN64;
+#else
+ m = dtrace_load32(maddr + dev) & MAXMIN;
+#endif
+ if (m != minor) {
+ maddr = dtrace_loadptr(maddr + next);
+
+ if (scout == NULL)
+ continue;
+
+ scout = dtrace_loadptr(scout + next);
+
+ if (scout == NULL)
+ continue;
+
+ scout = dtrace_loadptr(scout + next);
+
+ if (scout == NULL)
+ continue;
+
+ if (scout == maddr) {
+ *flags |= CPU_DTRACE_ILLOP;
+ break;
+ }
+
+ continue;
+ }
+
+ /*
+ * We have the minor data. Now we need to
+ * copy the minor's name into the end of the
+ * pathname.
+ */
+ s = (char *)dtrace_loadptr(maddr + name);
+ len = dtrace_strlen(s, size);
+
+ if (*flags & CPU_DTRACE_FAULT)
+ break;
+
+ if (len != 0) {
+ if ((end -= (len + 1)) < start)
+ break;
+
+ *end = ':';
+ }
+
+ for (i = 1; i <= len; i++)
+ end[i] = dtrace_load8((uintptr_t)s++);
+ break;
+ }
+ }
+
+ while (daddr != NULL && !(*flags & CPU_DTRACE_FAULT)) {
+ ddi_node_state_t devi_state;
+
+ devi_state = dtrace_load32(daddr +
+ offsetof(struct dev_info, devi_node_state));
+
+ if (*flags & CPU_DTRACE_FAULT)
+ break;
+
+ if (devi_state >= DS_INITIALIZED) {
+ s = (char *)dtrace_loadptr(daddr +
+ offsetof(struct dev_info, devi_addr));
+ len = dtrace_strlen(s, size);
+
+ if (*flags & CPU_DTRACE_FAULT)
+ break;
+
+ if (len != 0) {
+ if ((end -= (len + 1)) < start)
+ break;
+
+ *end = '@';
+ }
+
+ for (i = 1; i <= len; i++)
+ end[i] = dtrace_load8((uintptr_t)s++);
+ }
+
+ /*
+ * Now for the node name...
+ */
+ s = (char *)dtrace_loadptr(daddr +
+ offsetof(struct dev_info, devi_node_name));
+
+ daddr = dtrace_loadptr(daddr +
+ offsetof(struct dev_info, devi_parent));
+
+ /*
+ * If our parent is NULL (that is, if we're the root
+ * node), we're going to use the special path
+ * "devices".
+ */
+ if (daddr == NULL)
+ s = "devices";
+
+ len = dtrace_strlen(s, size);
+ if (*flags & CPU_DTRACE_FAULT)
+ break;
+
+ if ((end -= (len + 1)) < start)
+ break;
+
+ for (i = 1; i <= len; i++)
+ end[i] = dtrace_load8((uintptr_t)s++);
+ *end = '/';
+
+ if (depth++ > dtrace_devdepth_max) {
+ *flags |= CPU_DTRACE_ILLOP;
+ break;
+ }
+ }
+
+ if (end < start)
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+
+ if (daddr == NULL) {
+ regs[rd] = (uintptr_t)end;
+ mstate->dtms_scratch_ptr += size;
+ }
+
+#else
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ break;
+ }
+
+ case DIF_SUBR_STRJOIN: {
+ char *d = (char *)mstate->dtms_scratch_ptr;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ uintptr_t s1 = tupregs[0].dttk_value;
+ uintptr_t s2 = tupregs[1].dttk_value;
+ VBDTTYPE(unsigned,int) i = 0;
+
+ if (!dtrace_strcanload(s1, size, mstate, vstate) ||
+ !dtrace_strcanload(s2, size, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ for (;;) {
+ if (i >= size) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ if ((d[i++] = dtrace_load8(s1++)) == '\0') {
+ i--;
+ break;
+ }
+ }
+
+ for (;;) {
+ if (i >= size) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ if ((d[i++] = dtrace_load8(s2++)) == '\0')
+ break;
+ }
+
+ if (i < size) {
+ mstate->dtms_scratch_ptr += i;
+ regs[rd] = (uintptr_t)d;
+ }
+
+ break;
+ }
+
+ case DIF_SUBR_LLTOSTR: {
+ int64_t i = (int64_t)tupregs[0].dttk_value;
+ int64_t val = i < 0 ? i * -1 : i;
+ uint64_t size = 22; /* enough room for 2^64 in decimal */
+ char *end = (char *)mstate->dtms_scratch_ptr + size - 1;
+
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ for (*end-- = '\0'; val; val /= 10)
+ *end-- = '0' + (val % 10);
+
+ if (i == 0)
+ *end-- = '0';
+
+ if (i < 0)
+ *end-- = '-';
+
+ regs[rd] = (uintptr_t)end + 1;
+ mstate->dtms_scratch_ptr += size;
+ break;
+ }
+
+ case DIF_SUBR_HTONS:
+ case DIF_SUBR_NTOHS:
+#ifdef _BIG_ENDIAN
+ regs[rd] = (uint16_t)tupregs[0].dttk_value;
+#else
+ regs[rd] = DT_BSWAP_16((uint16_t)tupregs[0].dttk_value);
+#endif
+ break;
+
+
+ case DIF_SUBR_HTONL:
+ case DIF_SUBR_NTOHL:
+#ifdef _BIG_ENDIAN
+ regs[rd] = (uint32_t)tupregs[0].dttk_value;
+#else
+ regs[rd] = DT_BSWAP_32((uint32_t)tupregs[0].dttk_value);
+#endif
+ break;
+
+
+ case DIF_SUBR_HTONLL:
+ case DIF_SUBR_NTOHLL:
+#ifdef _BIG_ENDIAN
+ regs[rd] = (uint64_t)tupregs[0].dttk_value;
+#else
+ regs[rd] = DT_BSWAP_64((uint64_t)tupregs[0].dttk_value);
+#endif
+ break;
+
+
+ case DIF_SUBR_DIRNAME:
+ case DIF_SUBR_BASENAME: {
+ char *dest = (char *)mstate->dtms_scratch_ptr;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ uintptr_t src = tupregs[0].dttk_value;
+ int i, j, len = VBDTCAST(int)dtrace_strlen((char *)src, size);
+ int lastbase = -1, firstbase = -1, lastdir = -1;
+ int start, end;
+
+ if (!dtrace_canload(src, len + 1, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ /*
+ * The basename and dirname for a zero-length string is
+ * defined to be "."
+ */
+ if (len == 0) {
+ len = 1;
+ src = (uintptr_t)".";
+ }
+
+ /*
+ * Start from the back of the string, moving back toward the
+ * front until we see a character that isn't a slash. That
+ * character is the last character in the basename.
+ */
+ for (i = len - 1; i >= 0; i--) {
+ if (dtrace_load8(src + i) != '/')
+ break;
+ }
+
+ if (i >= 0)
+ lastbase = i;
+
+ /*
+ * Starting from the last character in the basename, move
+ * towards the front until we find a slash. The character
+ * that we processed immediately before that is the first
+ * character in the basename.
+ */
+ for (; i >= 0; i--) {
+ if (dtrace_load8(src + i) == '/')
+ break;
+ }
+
+ if (i >= 0)
+ firstbase = i + 1;
+
+ /*
+ * Now keep going until we find a non-slash character. That
+ * character is the last character in the dirname.
+ */
+ for (; i >= 0; i--) {
+ if (dtrace_load8(src + i) != '/')
+ break;
+ }
+
+ if (i >= 0)
+ lastdir = i;
+
+ ASSERT(!(lastbase == -1 && firstbase != -1));
+ ASSERT(!(firstbase == -1 && lastdir != -1));
+
+ if (lastbase == -1) {
+ /*
+ * We didn't find a non-slash character. We know that
+ * the length is non-zero, so the whole string must be
+ * slashes. In either the dirname or the basename
+ * case, we return '/'.
+ */
+ ASSERT(firstbase == -1);
+ firstbase = lastbase = lastdir = 0;
+ }
+
+ if (firstbase == -1) {
+ /*
+ * The entire string consists only of a basename
+ * component. If we're looking for dirname, we need
+ * to change our string to be just "."; if we're
+ * looking for a basename, we'll just set the first
+ * character of the basename to be 0.
+ */
+ if (subr == DIF_SUBR_DIRNAME) {
+ ASSERT(lastdir == -1);
+ src = (uintptr_t)".";
+ lastdir = 0;
+ } else {
+ firstbase = 0;
+ }
+ }
+
+ if (subr == DIF_SUBR_DIRNAME) {
+ if (lastdir == -1) {
+ /*
+ * We know that we have a slash in the name --
+ * or lastdir would be set to 0, above. And
+ * because lastdir is -1, we know that this
+ * slash must be the first character. (That
+ * is, the full string must be of the form
+ * "/basename".) In this case, the last
+ * character of the directory name is 0.
+ */
+ lastdir = 0;
+ }
+
+ start = 0;
+ end = lastdir;
+ } else {
+ ASSERT(subr == DIF_SUBR_BASENAME);
+ ASSERT(firstbase != -1 && lastbase != -1);
+ start = firstbase;
+ end = lastbase;
+ }
+
+ for (i = start, j = 0; i <= end && VBDTCAST(unsigned)j < size - 1; i++, j++)
+ dest[j] = dtrace_load8(src + i);
+
+ dest[j] = '\0';
+ regs[rd] = (uintptr_t)dest;
+ mstate->dtms_scratch_ptr += size;
+ break;
+ }
+
+ case DIF_SUBR_CLEANPATH: {
+ char *dest = (char *)mstate->dtms_scratch_ptr, c;
+ uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
+ uintptr_t src = tupregs[0].dttk_value;
+ int i = 0, j = 0;
+
+ if (!dtrace_strcanload(src, size, mstate, vstate)) {
+ regs[rd] = NULL;
+ break;
+ }
+
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ /*
+ * Move forward, loading each character.
+ */
+ do {
+ c = dtrace_load8(src + i++);
+next:
+ if (j + 5 >= VBDTCAST(int64_t)size) /* 5 = strlen("/..c\0") */
+ break;
+
+ if (c != '/') {
+ dest[j++] = c;
+ continue;
+ }
+
+ c = dtrace_load8(src + i++);
+
+ if (c == '/') {
+ /*
+ * We have two slashes -- we can just advance
+ * to the next character.
+ */
+ goto next;
+ }
+
+ if (c != '.') {
+ /*
+ * This is not "." and it's not ".." -- we can
+ * just store the "/" and this character and
+ * drive on.
+ */
+ dest[j++] = '/';
+ dest[j++] = c;
+ continue;
+ }
+
+ c = dtrace_load8(src + i++);
+
+ if (c == '/') {
+ /*
+ * This is a "/./" component. We're not going
+ * to store anything in the destination buffer;
+ * we're just going to go to the next component.
+ */
+ goto next;
+ }
+
+ if (c != '.') {
+ /*
+ * This is not ".." -- we can just store the
+ * "/." and this character and continue
+ * processing.
+ */
+ dest[j++] = '/';
+ dest[j++] = '.';
+ dest[j++] = c;
+ continue;
+ }
+
+ c = dtrace_load8(src + i++);
+
+ if (c != '/' && c != '\0') {
+ /*
+ * This is not ".." -- it's "..[mumble]".
+ * We'll store the "/.." and this character
+ * and continue processing.
+ */
+ dest[j++] = '/';
+ dest[j++] = '.';
+ dest[j++] = '.';
+ dest[j++] = c;
+ continue;
+ }
+
+ /*
+ * This is "/../" or "/..\0". We need to back up
+ * our destination pointer until we find a "/".
+ */
+ i--;
+ while (j != 0 && dest[--j] != '/')
+ continue;
+
+ if (c == '\0')
+ dest[++j] = '/';
+ } while (c != '\0');
+
+ dest[j] = '\0';
+ regs[rd] = (uintptr_t)dest;
+ mstate->dtms_scratch_ptr += size;
+ break;
+ }
+
+ case DIF_SUBR_INET_NTOA:
+ case DIF_SUBR_INET_NTOA6:
+ case DIF_SUBR_INET_NTOP: {
+#ifndef VBOX
+ size_t size;
+ int af, argi, i;
+ char *base, *end;
+
+ if (subr == DIF_SUBR_INET_NTOP) {
+ af = (int)tupregs[0].dttk_value;
+ argi = 1;
+ } else {
+ af = subr == DIF_SUBR_INET_NTOA ? AF_INET: AF_INET6;
+ argi = 0;
+ }
+
+ if (af == AF_INET) {
+ ipaddr_t ip4;
+ uint8_t *ptr8, val;
+
+ /*
+ * Safely load the IPv4 address.
+ */
+ ip4 = dtrace_load32(tupregs[argi].dttk_value);
+
+ /*
+ * Check an IPv4 string will fit in scratch.
+ */
+ size = INET_ADDRSTRLEN;
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+ base = (char *)mstate->dtms_scratch_ptr;
+ end = (char *)mstate->dtms_scratch_ptr + size - 1;
+
+ /*
+ * Stringify as a dotted decimal quad.
+ */
+ *end-- = '\0';
+ ptr8 = (uint8_t *)&ip4;
+ for (i = 3; i >= 0; i--) {
+ val = ptr8[i];
+
+ if (val == 0) {
+ *end-- = '0';
+ } else {
+ for (; val; val /= 10) {
+ *end-- = '0' + (val % 10);
+ }
+ }
+
+ if (i > 0)
+ *end-- = '.';
+ }
+ ASSERT(end + 1 >= base);
+
+ } else if (af == AF_INET6) {
+ struct in6_addr ip6;
+ int firstzero, tryzero, numzero, v6end;
+ uint16_t val;
+ const char digits[] = "0123456789abcdef";
+
+ /*
+ * Stringify using RFC 1884 convention 2 - 16 bit
+ * hexadecimal values with a zero-run compression.
+ * Lower case hexadecimal digits are used.
+ * eg, fe80::214:4fff:fe0b:76c8.
+ * The IPv4 embedded form is returned for inet_ntop,
+ * just the IPv4 string is returned for inet_ntoa6.
+ */
+
+ /*
+ * Safely load the IPv6 address.
+ */
+ dtrace_bcopy(
+ (void *)(uintptr_t)tupregs[argi].dttk_value,
+ (void *)(uintptr_t)&ip6, sizeof (struct in6_addr));
+
+ /*
+ * Check an IPv6 string will fit in scratch.
+ */
+ size = INET6_ADDRSTRLEN;
+ if (!DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+ base = (char *)mstate->dtms_scratch_ptr;
+ end = (char *)mstate->dtms_scratch_ptr + size - 1;
+ *end-- = '\0';
+
+ /*
+ * Find the longest run of 16 bit zero values
+ * for the single allowed zero compression - "::".
+ */
+ firstzero = -1;
+ tryzero = -1;
+ numzero = 1;
+ for (i = 0; i < sizeof (struct in6_addr); i++) {
+ if (ip6._S6_un._S6_u8[i] == 0 &&
+ tryzero == -1 && i % 2 == 0) {
+ tryzero = i;
+ continue;
+ }
+
+ if (tryzero != -1 &&
+ (ip6._S6_un._S6_u8[i] != 0 ||
+ i == sizeof (struct in6_addr) - 1)) {
+
+ if (i - tryzero <= numzero) {
+ tryzero = -1;
+ continue;
+ }
+
+ firstzero = tryzero;
+ numzero = i - i % 2 - tryzero;
+ tryzero = -1;
+
+ if (ip6._S6_un._S6_u8[i] == 0 &&
+ i == sizeof (struct in6_addr) - 1)
+ numzero += 2;
+ }
+ }
+ ASSERT(firstzero + numzero <= sizeof (struct in6_addr));
+
+ /*
+ * Check for an IPv4 embedded address.
+ */
+ v6end = sizeof (struct in6_addr) - 2;
+ if (IN6_IS_ADDR_V4MAPPED(&ip6) ||
+ IN6_IS_ADDR_V4COMPAT(&ip6)) {
+ for (i = sizeof (struct in6_addr) - 1;
+ i >= DTRACE_V4MAPPED_OFFSET; i--) {
+ ASSERT(end >= base);
+
+ val = ip6._S6_un._S6_u8[i];
+
+ if (val == 0) {
+ *end-- = '0';
+ } else {
+ for (; val; val /= 10) {
+ *end-- = '0' + val % 10;
+ }
+ }
+
+ if (i > DTRACE_V4MAPPED_OFFSET)
+ *end-- = '.';
+ }
+
+ if (subr == DIF_SUBR_INET_NTOA6)
+ goto inetout;
+
+ /*
+ * Set v6end to skip the IPv4 address that
+ * we have already stringified.
+ */
+ v6end = 10;
+ }
+
+ /*
+ * Build the IPv6 string by working through the
+ * address in reverse.
+ */
+ for (i = v6end; i >= 0; i -= 2) {
+ ASSERT(end >= base);
+
+ if (i == firstzero + numzero - 2) {
+ *end-- = ':';
+ *end-- = ':';
+ i -= numzero - 2;
+ continue;
+ }
+
+ if (i < 14 && i != firstzero - 2)
+ *end-- = ':';
+
+ val = (ip6._S6_un._S6_u8[i] << 8) +
+ ip6._S6_un._S6_u8[i + 1];
+
+ if (val == 0) {
+ *end-- = '0';
+ } else {
+ for (; val; val /= 16) {
+ *end-- = digits[val % 16];
+ }
+ }
+ }
+ ASSERT(end + 1 >= base);
+
+ } else {
+ /*
+ * The user didn't use AH_INET or AH_INET6.
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ regs[rd] = NULL;
+ break;
+ }
+
+inetout: regs[rd] = (uintptr_t)end + 1;
+ mstate->dtms_scratch_ptr += size;
+#else /* VBOX */
+ regs[rd] = 0;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif /* VBOX */
+ break;
+ }
+
+ }
+}
+
+/*
+ * Emulate the execution of DTrace IR instructions specified by the given
+ * DIF object. This function is deliberately void of assertions as all of
+ * the necessary checks are handled by a call to dtrace_difo_validate().
+ */
+static uint64_t
+dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate,
+ dtrace_vstate_t *vstate, dtrace_state_t *state)
+{
+ const dif_instr_t *text = difo->dtdo_buf;
+ const uint_t textlen = difo->dtdo_len;
+ const char *strtab = difo->dtdo_strtab;
+ const uint64_t *inttab = difo->dtdo_inttab;
+
+ uint64_t rval = 0;
+ dtrace_statvar_t *svar;
+ dtrace_dstate_t *dstate = &vstate->dtvs_dynvars;
+ dtrace_difv_t *v;
+ volatile uint16_t *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+ volatile uintptr_t *illval = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
+
+ dtrace_key_t tupregs[DIF_DTR_NREGS + 2]; /* +2 for thread and id */
+ uint64_t regs[DIF_DIR_NREGS];
+ uint64_t *tmp;
+
+ uint8_t cc_n = 0, cc_z = 0, cc_v = 0, cc_c = 0;
+ int64_t cc_r;
+ uint_t pc = 0, id, opc VBDTUNASS(0);
+ uint8_t ttop = 0;
+ dif_instr_t instr;
+ uint_t r1, r2, rd;
+
+ /*
+ * We stash the current DIF object into the machine state: we need it
+ * for subsequent access checking.
+ */
+ mstate->dtms_difo = difo;
+
+ regs[DIF_REG_R0] = 0; /* %r0 is fixed at zero */
+
+ while (pc < textlen && !(*flags & CPU_DTRACE_FAULT)) {
+ opc = pc;
+
+ instr = text[pc++];
+ r1 = DIF_INSTR_R1(instr);
+ r2 = DIF_INSTR_R2(instr);
+ rd = DIF_INSTR_RD(instr);
+
+ switch (DIF_INSTR_OP(instr)) {
+ case DIF_OP_OR:
+ regs[rd] = regs[r1] | regs[r2];
+ break;
+ case DIF_OP_XOR:
+ regs[rd] = regs[r1] ^ regs[r2];
+ break;
+ case DIF_OP_AND:
+ regs[rd] = regs[r1] & regs[r2];
+ break;
+ case DIF_OP_SLL:
+ regs[rd] = regs[r1] << regs[r2];
+ break;
+ case DIF_OP_SRL:
+ regs[rd] = regs[r1] >> regs[r2];
+ break;
+ case DIF_OP_SUB:
+ regs[rd] = regs[r1] - regs[r2];
+ break;
+ case DIF_OP_ADD:
+ regs[rd] = regs[r1] + regs[r2];
+ break;
+ case DIF_OP_MUL:
+ regs[rd] = regs[r1] * regs[r2];
+ break;
+ case DIF_OP_SDIV:
+ if (regs[r2] == 0) {
+ regs[rd] = 0;
+ *flags |= CPU_DTRACE_DIVZERO;
+ } else {
+ regs[rd] = (int64_t)regs[r1] /
+ (int64_t)regs[r2];
+ }
+ break;
+
+ case DIF_OP_UDIV:
+ if (regs[r2] == 0) {
+ regs[rd] = 0;
+ *flags |= CPU_DTRACE_DIVZERO;
+ } else {
+ regs[rd] = regs[r1] / regs[r2];
+ }
+ break;
+
+ case DIF_OP_SREM:
+ if (regs[r2] == 0) {
+ regs[rd] = 0;
+ *flags |= CPU_DTRACE_DIVZERO;
+ } else {
+ regs[rd] = (int64_t)regs[r1] %
+ (int64_t)regs[r2];
+ }
+ break;
+
+ case DIF_OP_UREM:
+ if (regs[r2] == 0) {
+ regs[rd] = 0;
+ *flags |= CPU_DTRACE_DIVZERO;
+ } else {
+ regs[rd] = regs[r1] % regs[r2];
+ }
+ break;
+
+ case DIF_OP_NOT:
+ regs[rd] = ~regs[r1];
+ break;
+ case DIF_OP_MOV:
+ regs[rd] = regs[r1];
+ break;
+ case DIF_OP_CMP:
+ cc_r = regs[r1] - regs[r2];
+ cc_n = cc_r < 0;
+ cc_z = cc_r == 0;
+ cc_v = 0;
+ cc_c = regs[r1] < regs[r2];
+ break;
+ case DIF_OP_TST:
+ cc_n = cc_v = cc_c = 0;
+ cc_z = regs[r1] == 0;
+ break;
+ case DIF_OP_BA:
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BE:
+ if (cc_z)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BNE:
+ if (cc_z == 0)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BG:
+ if ((cc_z | (cc_n ^ cc_v)) == 0)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BGU:
+ if ((cc_c | cc_z) == 0)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BGE:
+ if ((cc_n ^ cc_v) == 0)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BGEU:
+ if (cc_c == 0)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BL:
+ if (cc_n ^ cc_v)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BLU:
+ if (cc_c)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BLE:
+ if (cc_z | (cc_n ^ cc_v))
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_BLEU:
+ if (cc_c | cc_z)
+ pc = DIF_INSTR_LABEL(instr);
+ break;
+ case DIF_OP_RLDSB:
+ if (!dtrace_canstore(regs[r1], 1, mstate, vstate)) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = regs[r1];
+ break;
+ }
+ RT_FALL_THRU();
+ case DIF_OP_LDSB:
+ regs[rd] = (int8_t)dtrace_load8(regs[r1]);
+ break;
+ case DIF_OP_RLDSH:
+ if (!dtrace_canstore(regs[r1], 2, mstate, vstate)) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = regs[r1];
+ break;
+ }
+ RT_FALL_THRU();
+ case DIF_OP_LDSH:
+ regs[rd] = (int16_t)dtrace_load16(regs[r1]);
+ break;
+ case DIF_OP_RLDSW:
+ if (!dtrace_canstore(regs[r1], 4, mstate, vstate)) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = regs[r1];
+ break;
+ }
+ RT_FALL_THRU();
+ case DIF_OP_LDSW:
+ regs[rd] = (int32_t)dtrace_load32(regs[r1]);
+ break;
+ case DIF_OP_RLDUB:
+ if (!dtrace_canstore(regs[r1], 1, mstate, vstate)) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = regs[r1];
+ break;
+ }
+ RT_FALL_THRU();
+ case DIF_OP_LDUB:
+ regs[rd] = dtrace_load8(regs[r1]);
+ break;
+ case DIF_OP_RLDUH:
+ if (!dtrace_canstore(regs[r1], 2, mstate, vstate)) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = regs[r1];
+ break;
+ }
+ RT_FALL_THRU();
+ case DIF_OP_LDUH:
+ regs[rd] = dtrace_load16(regs[r1]);
+ break;
+ case DIF_OP_RLDUW:
+ if (!dtrace_canstore(regs[r1], 4, mstate, vstate)) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = regs[r1];
+ break;
+ }
+ RT_FALL_THRU();
+ case DIF_OP_LDUW:
+ regs[rd] = dtrace_load32(regs[r1]);
+ break;
+ case DIF_OP_RLDX:
+ if (!dtrace_canstore(regs[r1], 8, mstate, vstate)) {
+ *flags |= CPU_DTRACE_KPRIV;
+ *illval = regs[r1];
+ break;
+ }
+ RT_FALL_THRU();
+ case DIF_OP_LDX:
+ regs[rd] = dtrace_load64(regs[r1]);
+ break;
+ case DIF_OP_ULDSB:
+ regs[rd] = (int8_t)
+ dtrace_fuword8((void *)(uintptr_t)regs[r1]);
+ break;
+ case DIF_OP_ULDSH:
+ regs[rd] = (int16_t)
+ dtrace_fuword16((void *)(uintptr_t)regs[r1]);
+ break;
+ case DIF_OP_ULDSW:
+ regs[rd] = (int32_t)
+ dtrace_fuword32((void *)(uintptr_t)regs[r1]);
+ break;
+ case DIF_OP_ULDUB:
+ regs[rd] =
+ dtrace_fuword8((void *)(uintptr_t)regs[r1]);
+ break;
+ case DIF_OP_ULDUH:
+ regs[rd] =
+ dtrace_fuword16((void *)(uintptr_t)regs[r1]);
+ break;
+ case DIF_OP_ULDUW:
+ regs[rd] =
+ dtrace_fuword32((void *)(uintptr_t)regs[r1]);
+ break;
+ case DIF_OP_ULDX:
+ regs[rd] =
+ dtrace_fuword64((void *)(uintptr_t)regs[r1]);
+ break;
+ case DIF_OP_RET:
+ rval = regs[rd];
+ pc = textlen;
+ break;
+ case DIF_OP_NOP:
+ break;
+ case DIF_OP_SETX:
+ regs[rd] = inttab[DIF_INSTR_INTEGER(instr)];
+ break;
+ case DIF_OP_SETS:
+ regs[rd] = (uint64_t)(uintptr_t)
+ (strtab + DIF_INSTR_STRING(instr));
+ break;
+ case DIF_OP_SCMP: {
+ size_t sz = state->dts_options[DTRACEOPT_STRSIZE];
+ uintptr_t s1 = regs[r1];
+ uintptr_t s2 = regs[r2];
+
+ if (s1 != NULL &&
+ !dtrace_strcanload(s1, sz, mstate, vstate))
+ break;
+ if (s2 != NULL &&
+ !dtrace_strcanload(s2, sz, mstate, vstate))
+ break;
+
+ cc_r = dtrace_strncmp((char *)s1, (char *)s2, sz);
+
+ cc_n = cc_r < 0;
+ cc_z = cc_r == 0;
+ cc_v = cc_c = 0;
+ break;
+ }
+ case DIF_OP_LDGA:
+ regs[rd] = dtrace_dif_variable(mstate, state,
+ r1, regs[r2]);
+ break;
+ case DIF_OP_LDGS:
+ id = DIF_INSTR_VAR(instr);
+
+ if (id >= DIF_VAR_OTHER_UBASE) {
+ uintptr_t a;
+
+ id -= DIF_VAR_OTHER_UBASE;
+ svar = vstate->dtvs_globals[id];
+ ASSERT(svar != NULL);
+ v = &svar->dtsv_var;
+
+ if (!(v->dtdv_type.dtdt_flags & DIF_TF_BYREF)) {
+ regs[rd] = svar->dtsv_data;
+ break;
+ }
+
+ a = (uintptr_t)svar->dtsv_data;
+
+ if (*(uint8_t *)a == UINT8_MAX) {
+ /*
+ * If the 0th byte is set to UINT8_MAX
+ * then this is to be treated as a
+ * reference to a NULL variable.
+ */
+ regs[rd] = NULL;
+ } else {
+ regs[rd] = a + sizeof (uint64_t);
+ }
+
+ break;
+ }
+
+ regs[rd] = dtrace_dif_variable(mstate, state, id, 0);
+ break;
+
+ case DIF_OP_STGS:
+ id = DIF_INSTR_VAR(instr);
+
+ ASSERT(id >= DIF_VAR_OTHER_UBASE);
+ id -= DIF_VAR_OTHER_UBASE;
+
+ svar = vstate->dtvs_globals[id];
+ ASSERT(svar != NULL);
+ v = &svar->dtsv_var;
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF) {
+ uintptr_t a = (uintptr_t)svar->dtsv_data;
+
+ ASSERT(a != NULL);
+ ASSERT(svar->dtsv_size != 0);
+
+ if (regs[rd] == NULL) {
+ *(uint8_t *)a = UINT8_MAX;
+ break;
+ } else {
+ *(uint8_t *)a = 0;
+ a += sizeof (uint64_t);
+ }
+ if (!dtrace_vcanload(
+ (void *)(uintptr_t)regs[rd], &v->dtdv_type,
+ mstate, vstate))
+ break;
+
+ dtrace_vcopy((void *)(uintptr_t)regs[rd],
+ (void *)a, &v->dtdv_type);
+ break;
+ }
+
+ svar->dtsv_data = regs[rd];
+ break;
+
+ case DIF_OP_LDTA:
+ /*
+ * There are no DTrace built-in thread-local arrays at
+ * present. This opcode is saved for future work.
+ */
+ *flags |= CPU_DTRACE_ILLOP;
+ regs[rd] = 0;
+ break;
+
+ case DIF_OP_LDLS:
+ id = DIF_INSTR_VAR(instr);
+
+ if (id < DIF_VAR_OTHER_UBASE) {
+ /*
+ * For now, this has no meaning.
+ */
+ regs[rd] = 0;
+ break;
+ }
+
+ id -= DIF_VAR_OTHER_UBASE;
+
+ ASSERT(VBDTCAST(int64_t)id < vstate->dtvs_nlocals);
+ ASSERT(vstate->dtvs_locals != NULL);
+
+ svar = vstate->dtvs_locals[id];
+ ASSERT(svar != NULL);
+ v = &svar->dtsv_var;
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF) {
+ uintptr_t a = (uintptr_t)svar->dtsv_data;
+ size_t sz = v->dtdv_type.dtdt_size;
+
+ sz += sizeof (uint64_t);
+ ASSERT(svar->dtsv_size == NCPU * sz);
+ a += VBDT_GET_CPUID() * sz;
+
+ if (*(uint8_t *)a == UINT8_MAX) {
+ /*
+ * If the 0th byte is set to UINT8_MAX
+ * then this is to be treated as a
+ * reference to a NULL variable.
+ */
+ regs[rd] = NULL;
+ } else {
+ regs[rd] = a + sizeof (uint64_t);
+ }
+
+ break;
+ }
+
+ ASSERT(svar->dtsv_size == NCPU * sizeof (uint64_t));
+ tmp = (uint64_t *)(uintptr_t)svar->dtsv_data;
+ regs[rd] = tmp[VBDT_GET_CPUID()];
+ break;
+
+ case DIF_OP_STLS:
+ id = DIF_INSTR_VAR(instr);
+
+ ASSERT(id >= DIF_VAR_OTHER_UBASE);
+ id -= DIF_VAR_OTHER_UBASE;
+ ASSERT(VBDTCAST(int64_t)id < vstate->dtvs_nlocals);
+
+ ASSERT(vstate->dtvs_locals != NULL);
+ svar = vstate->dtvs_locals[id];
+ ASSERT(svar != NULL);
+ v = &svar->dtsv_var;
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF) {
+ uintptr_t a = (uintptr_t)svar->dtsv_data;
+ size_t sz = v->dtdv_type.dtdt_size;
+
+ sz += sizeof (uint64_t);
+ ASSERT(svar->dtsv_size == NCPU * sz);
+ a += VBDT_GET_CPUID() * sz;
+
+ if (regs[rd] == NULL) {
+ *(uint8_t *)a = UINT8_MAX;
+ break;
+ } else {
+ *(uint8_t *)a = 0;
+ a += sizeof (uint64_t);
+ }
+
+ if (!dtrace_vcanload(
+ (void *)(uintptr_t)regs[rd], &v->dtdv_type,
+ mstate, vstate))
+ break;
+
+ dtrace_vcopy((void *)(uintptr_t)regs[rd],
+ (void *)a, &v->dtdv_type);
+ break;
+ }
+
+ ASSERT(svar->dtsv_size == NCPU * sizeof (uint64_t));
+ tmp = (uint64_t *)(uintptr_t)svar->dtsv_data;
+ tmp[VBDT_GET_CPUID()] = regs[rd];
+ break;
+
+ case DIF_OP_LDTS: {
+ dtrace_dynvar_t *dvar;
+ dtrace_key_t *key;
+
+ id = DIF_INSTR_VAR(instr);
+ ASSERT(id >= DIF_VAR_OTHER_UBASE);
+ id -= DIF_VAR_OTHER_UBASE;
+ v = &vstate->dtvs_tlocals[id];
+
+ key = &tupregs[DIF_DTR_NREGS];
+ key[0].dttk_value = (uint64_t)id;
+ key[0].dttk_size = 0;
+ DTRACE_TLS_THRKEY(key[1].dttk_value);
+ key[1].dttk_size = 0;
+
+ dvar = dtrace_dynvar(dstate, 2, key,
+ sizeof (uint64_t), DTRACE_DYNVAR_NOALLOC,
+ mstate, vstate);
+
+ if (dvar == NULL) {
+ regs[rd] = 0;
+ break;
+ }
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF) {
+ regs[rd] = (uint64_t)(uintptr_t)dvar->dtdv_data;
+ } else {
+ regs[rd] = *((uint64_t *)dvar->dtdv_data);
+ }
+
+ break;
+ }
+
+ case DIF_OP_STTS: {
+ dtrace_dynvar_t *dvar;
+ dtrace_key_t *key;
+
+ id = DIF_INSTR_VAR(instr);
+ ASSERT(id >= DIF_VAR_OTHER_UBASE);
+ id -= DIF_VAR_OTHER_UBASE;
+
+ key = &tupregs[DIF_DTR_NREGS];
+ key[0].dttk_value = (uint64_t)id;
+ key[0].dttk_size = 0;
+ DTRACE_TLS_THRKEY(key[1].dttk_value);
+ key[1].dttk_size = 0;
+ v = &vstate->dtvs_tlocals[id];
+
+ dvar = dtrace_dynvar(dstate, 2, key,
+ v->dtdv_type.dtdt_size > sizeof (uint64_t) ?
+ v->dtdv_type.dtdt_size : sizeof (uint64_t),
+ regs[rd] ? DTRACE_DYNVAR_ALLOC :
+ DTRACE_DYNVAR_DEALLOC, mstate, vstate);
+
+ /*
+ * Given that we're storing to thread-local data,
+ * we need to flush our predicate cache.
+ */
+ curthread->t_predcache = NULL;
+
+ if (dvar == NULL)
+ break;
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF) {
+ if (!dtrace_vcanload(
+ (void *)(uintptr_t)regs[rd],
+ &v->dtdv_type, mstate, vstate))
+ break;
+
+ dtrace_vcopy((void *)(uintptr_t)regs[rd],
+ dvar->dtdv_data, &v->dtdv_type);
+ } else {
+ *((uint64_t *)dvar->dtdv_data) = regs[rd];
+ }
+
+ break;
+ }
+
+ case DIF_OP_SRA:
+ regs[rd] = (int64_t)regs[r1] >> regs[r2];
+ break;
+
+ case DIF_OP_CALL:
+ dtrace_dif_subr(DIF_INSTR_SUBR(instr), rd,
+ regs, tupregs, ttop, mstate, state);
+ break;
+
+ case DIF_OP_PUSHTR:
+ if (ttop == DIF_DTR_NREGS) {
+ *flags |= CPU_DTRACE_TUPOFLOW;
+ break;
+ }
+
+ if (r1 == DIF_TYPE_STRING) {
+ /*
+ * If this is a string type and the size is 0,
+ * we'll use the system-wide default string
+ * size. Note that we are _not_ looking at
+ * the value of the DTRACEOPT_STRSIZE option;
+ * had this been set, we would expect to have
+ * a non-zero size value in the "pushtr".
+ */
+ tupregs[ttop].dttk_size =
+ dtrace_strlen((char *)(uintptr_t)regs[rd],
+ regs[r2] ? regs[r2] :
+ dtrace_strsize_default) + 1;
+ } else {
+ tupregs[ttop].dttk_size = regs[r2];
+ }
+
+ tupregs[ttop++].dttk_value = regs[rd];
+ break;
+
+ case DIF_OP_PUSHTV:
+ if (ttop == DIF_DTR_NREGS) {
+ *flags |= CPU_DTRACE_TUPOFLOW;
+ break;
+ }
+
+ tupregs[ttop].dttk_value = regs[rd];
+ tupregs[ttop++].dttk_size = 0;
+ break;
+
+ case DIF_OP_POPTS:
+ if (ttop != 0)
+ ttop--;
+ break;
+
+ case DIF_OP_FLUSHTS:
+ ttop = 0;
+ break;
+
+ case DIF_OP_LDGAA:
+ case DIF_OP_LDTAA: {
+ dtrace_dynvar_t *dvar;
+ dtrace_key_t *key = tupregs;
+ uint_t nkeys = ttop;
+
+ id = DIF_INSTR_VAR(instr);
+ ASSERT(id >= DIF_VAR_OTHER_UBASE);
+ id -= DIF_VAR_OTHER_UBASE;
+
+ key[nkeys].dttk_value = (uint64_t)id;
+ key[nkeys++].dttk_size = 0;
+
+ if (DIF_INSTR_OP(instr) == DIF_OP_LDTAA) {
+ DTRACE_TLS_THRKEY(key[nkeys].dttk_value);
+ key[nkeys++].dttk_size = 0;
+ v = &vstate->dtvs_tlocals[id];
+ } else {
+ v = &vstate->dtvs_globals[id]->dtsv_var;
+ }
+
+ dvar = dtrace_dynvar(dstate, nkeys, key,
+ v->dtdv_type.dtdt_size > sizeof (uint64_t) ?
+ v->dtdv_type.dtdt_size : sizeof (uint64_t),
+ DTRACE_DYNVAR_NOALLOC, mstate, vstate);
+
+ if (dvar == NULL) {
+ regs[rd] = 0;
+ break;
+ }
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF) {
+ regs[rd] = (uint64_t)(uintptr_t)dvar->dtdv_data;
+ } else {
+ regs[rd] = *((uint64_t *)dvar->dtdv_data);
+ }
+
+ break;
+ }
+
+ case DIF_OP_STGAA:
+ case DIF_OP_STTAA: {
+ dtrace_dynvar_t *dvar;
+ dtrace_key_t *key = tupregs;
+ uint_t nkeys = ttop;
+
+ id = DIF_INSTR_VAR(instr);
+ ASSERT(id >= DIF_VAR_OTHER_UBASE);
+ id -= DIF_VAR_OTHER_UBASE;
+
+ key[nkeys].dttk_value = (uint64_t)id;
+ key[nkeys++].dttk_size = 0;
+
+ if (DIF_INSTR_OP(instr) == DIF_OP_STTAA) {
+ DTRACE_TLS_THRKEY(key[nkeys].dttk_value);
+ key[nkeys++].dttk_size = 0;
+ v = &vstate->dtvs_tlocals[id];
+ } else {
+ v = &vstate->dtvs_globals[id]->dtsv_var;
+ }
+
+ dvar = dtrace_dynvar(dstate, nkeys, key,
+ v->dtdv_type.dtdt_size > sizeof (uint64_t) ?
+ v->dtdv_type.dtdt_size : sizeof (uint64_t),
+ regs[rd] ? DTRACE_DYNVAR_ALLOC :
+ DTRACE_DYNVAR_DEALLOC, mstate, vstate);
+
+ if (dvar == NULL)
+ break;
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF) {
+ if (!dtrace_vcanload(
+ (void *)(uintptr_t)regs[rd], &v->dtdv_type,
+ mstate, vstate))
+ break;
+
+ dtrace_vcopy((void *)(uintptr_t)regs[rd],
+ dvar->dtdv_data, &v->dtdv_type);
+ } else {
+ *((uint64_t *)dvar->dtdv_data) = regs[rd];
+ }
+
+ break;
+ }
+
+ case DIF_OP_ALLOCS: {
+ uintptr_t ptr = P2ROUNDUP(mstate->dtms_scratch_ptr, 8);
+ size_t size = ptr - mstate->dtms_scratch_ptr + regs[r1];
+
+ /*
+ * Rounding up the user allocation size could have
+ * overflowed large, bogus allocations (like -1ULL) to
+ * 0.
+ */
+ if (size < regs[r1] ||
+ !DTRACE_INSCRATCH(mstate, size)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ regs[rd] = NULL;
+ break;
+ }
+
+ dtrace_bzero((void *) mstate->dtms_scratch_ptr, size);
+ mstate->dtms_scratch_ptr += size;
+ regs[rd] = ptr;
+ break;
+ }
+
+ case DIF_OP_COPYS:
+ if (!dtrace_canstore(regs[rd], regs[r2],
+ mstate, vstate)) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = regs[rd];
+ break;
+ }
+
+ if (!dtrace_canload(regs[r1], regs[r2], mstate, vstate))
+ break;
+
+ dtrace_bcopy((void *)(uintptr_t)regs[r1],
+ (void *)(uintptr_t)regs[rd], (size_t)regs[r2]);
+ break;
+
+ case DIF_OP_STB:
+ if (!dtrace_canstore(regs[rd], 1, mstate, vstate)) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = regs[rd];
+ break;
+ }
+ *((uint8_t *)(uintptr_t)regs[rd]) = (uint8_t)regs[r1];
+ break;
+
+ case DIF_OP_STH:
+ if (!dtrace_canstore(regs[rd], 2, mstate, vstate)) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = regs[rd];
+ break;
+ }
+ if (regs[rd] & 1) {
+ *flags |= CPU_DTRACE_BADALIGN;
+ *illval = regs[rd];
+ break;
+ }
+ *((uint16_t *)(uintptr_t)regs[rd]) = (uint16_t)regs[r1];
+ break;
+
+ case DIF_OP_STW:
+ if (!dtrace_canstore(regs[rd], 4, mstate, vstate)) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = regs[rd];
+ break;
+ }
+ if (regs[rd] & 3) {
+ *flags |= CPU_DTRACE_BADALIGN;
+ *illval = regs[rd];
+ break;
+ }
+ *((uint32_t *)(uintptr_t)regs[rd]) = (uint32_t)regs[r1];
+ break;
+
+ case DIF_OP_STX:
+ if (!dtrace_canstore(regs[rd], 8, mstate, vstate)) {
+ *flags |= CPU_DTRACE_BADADDR;
+ *illval = regs[rd];
+ break;
+ }
+ if (regs[rd] & 7) {
+ *flags |= CPU_DTRACE_BADALIGN;
+ *illval = regs[rd];
+ break;
+ }
+ *((uint64_t *)(uintptr_t)regs[rd]) = regs[r1];
+ break;
+ }
+ }
+
+ if (!(*flags & CPU_DTRACE_FAULT))
+ return (rval);
+
+ mstate->dtms_fltoffs = opc * sizeof (dif_instr_t);
+ mstate->dtms_present |= DTRACE_MSTATE_FLTOFFS;
+
+ return (0);
+}
+
+#ifndef VBOX /* no destructive stuff */
+
+static void
+dtrace_action_breakpoint(dtrace_ecb_t *ecb)
+{
+ dtrace_probe_t *probe = ecb->dte_probe;
+ dtrace_provider_t *prov = probe->dtpr_provider;
+ char c[DTRACE_FULLNAMELEN + 80], *str;
+ char *msg = "dtrace: breakpoint action at probe ";
+ char *ecbmsg = " (ecb ";
+ uintptr_t mask = (0xf << (sizeof (uintptr_t) * NBBY / 4));
+ uintptr_t val = (uintptr_t)ecb;
+ int shift = (sizeof (uintptr_t) * NBBY) - 4, i = 0;
+
+ if (dtrace_destructive_disallow)
+ return;
+
+ /*
+ * It's impossible to be taking action on the NULL probe.
+ */
+ ASSERT(probe != NULL);
+
+ /*
+ * This is a poor man's (destitute man's?) sprintf(): we want to
+ * print the provider name, module name, function name and name of
+ * the probe, along with the hex address of the ECB with the breakpoint
+ * action -- all of which we must place in the character buffer by
+ * hand.
+ */
+ while (*msg != '\0')
+ c[i++] = *msg++;
+
+ for (str = prov->dtpv_name; *str != '\0'; str++)
+ c[i++] = *str;
+ c[i++] = ':';
+
+ for (str = probe->dtpr_mod; *str != '\0'; str++)
+ c[i++] = *str;
+ c[i++] = ':';
+
+ for (str = probe->dtpr_func; *str != '\0'; str++)
+ c[i++] = *str;
+ c[i++] = ':';
+
+ for (str = probe->dtpr_name; *str != '\0'; str++)
+ c[i++] = *str;
+
+ while (*ecbmsg != '\0')
+ c[i++] = *ecbmsg++;
+
+ while (shift >= 0) {
+ mask = (uintptr_t)0xf << shift;
+
+ if (val >= ((uintptr_t)1 << shift))
+ c[i++] = "0123456789abcdef"[(val & mask) >> shift];
+ shift -= 4;
+ }
+
+ c[i++] = ')';
+ c[i] = '\0';
+
+ debug_enter(c);
+}
+
+static void
+dtrace_action_panic(dtrace_ecb_t *ecb)
+{
+ dtrace_probe_t *probe = ecb->dte_probe;
+
+ /*
+ * It's impossible to be taking action on the NULL probe.
+ */
+ ASSERT(probe != NULL);
+
+ if (dtrace_destructive_disallow)
+ return;
+
+ if (dtrace_panicked != NULL)
+ return;
+
+ if (dtrace_casptr(&dtrace_panicked, NULL, curthread) != NULL)
+ return;
+
+ /*
+ * We won the right to panic. (We want to be sure that only one
+ * thread calls panic() from dtrace_probe(), and that panic() is
+ * called exactly once.)
+ */
+ dtrace_panic("dtrace: panic action at probe %s:%s:%s:%s (ecb %p)",
+ probe->dtpr_provider->dtpv_name, probe->dtpr_mod,
+ probe->dtpr_func, probe->dtpr_name, (void *)ecb);
+}
+
+static void
+dtrace_action_raise(uint64_t sig)
+{
+ if (dtrace_destructive_disallow)
+ return;
+
+ if (sig >= NSIG) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return;
+ }
+
+ /*
+ * raise() has a queue depth of 1 -- we ignore all subsequent
+ * invocations of the raise() action.
+ */
+ if (curthread->t_dtrace_sig == 0)
+ curthread->t_dtrace_sig = (uint8_t)sig;
+
+ curthread->t_sig_check = 1;
+ aston(curthread);
+}
+
+static void
+dtrace_action_stop(void)
+{
+ if (dtrace_destructive_disallow)
+ return;
+
+ if (!curthread->t_dtrace_stop) {
+ curthread->t_dtrace_stop = 1;
+ curthread->t_sig_check = 1;
+ aston(curthread);
+ }
+}
+
+static void
+dtrace_action_chill(dtrace_mstate_t *mstate, hrtime_t val)
+{
+ hrtime_t now;
+ volatile uint16_t *flags;
+ cpu_t *cpu = CPU;
+
+ if (dtrace_destructive_disallow)
+ return;
+
+ flags = (volatile uint16_t *)&cpu_core[cpu->cpu_id].cpuc_dtrace_flags;
+
+ now = dtrace_gethrtime();
+
+ if (now - cpu->cpu_dtrace_chillmark > dtrace_chill_interval) {
+ /*
+ * We need to advance the mark to the current time.
+ */
+ cpu->cpu_dtrace_chillmark = now;
+ cpu->cpu_dtrace_chilled = 0;
+ }
+
+ /*
+ * Now check to see if the requested chill time would take us over
+ * the maximum amount of time allowed in the chill interval. (Or
+ * worse, if the calculation itself induces overflow.)
+ */
+ if (cpu->cpu_dtrace_chilled + val > dtrace_chill_max ||
+ cpu->cpu_dtrace_chilled + val < cpu->cpu_dtrace_chilled) {
+ *flags |= CPU_DTRACE_ILLOP;
+ return;
+ }
+
+ while (dtrace_gethrtime() - now < val)
+ continue;
+
+ /*
+ * Normally, we assure that the value of the variable "timestamp" does
+ * not change within an ECB. The presence of chill() represents an
+ * exception to this rule, however.
+ */
+ mstate->dtms_present &= ~DTRACE_MSTATE_TIMESTAMP;
+ cpu->cpu_dtrace_chilled += val;
+}
+
+#endif /* !VBOX */
+
+#ifndef VBOX
+static void
+dtrace_action_ustack(dtrace_mstate_t *mstate, dtrace_state_t *state,
+ uint64_t *buf, uint64_t arg)
+{
+ int nframes = DTRACE_USTACK_NFRAMES(arg);
+ int strsize = DTRACE_USTACK_STRSIZE(arg);
+ uint64_t *pcs = &buf[1], *fps;
+ char *str = (char *)&pcs[nframes];
+ int size, offs = 0, i, j;
+ uintptr_t old = mstate->dtms_scratch_ptr, saved;
+#ifndef VBOX
+ uint16_t *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+#else
+ uint16_t volatile *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+#endif
+ char *sym;
+
+ /*
+ * Should be taking a faster path if string space has not been
+ * allocated.
+ */
+ ASSERT(strsize != 0);
+
+ /*
+ * We will first allocate some temporary space for the frame pointers.
+ */
+ fps = (uint64_t *)P2ROUNDUP(mstate->dtms_scratch_ptr, 8);
+ size = (uintptr_t)fps - mstate->dtms_scratch_ptr +
+ (nframes * sizeof (uint64_t));
+
+ if (!DTRACE_INSCRATCH(mstate, VBDTCAST(unsigned)size)) {
+ /*
+ * Not enough room for our frame pointers -- need to indicate
+ * that we ran out of scratch space.
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+ return;
+ }
+
+ mstate->dtms_scratch_ptr += size;
+ saved = mstate->dtms_scratch_ptr;
+
+ /*
+ * Now get a stack with both program counters and frame pointers.
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_getufpstack(buf, fps, nframes + 1);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+
+ /*
+ * If that faulted, we're cooked.
+ */
+ if (*flags & CPU_DTRACE_FAULT)
+ goto out;
+
+ /*
+ * Now we want to walk up the stack, calling the USTACK helper. For
+ * each iteration, we restore the scratch pointer.
+ */
+ for (i = 0; i < nframes; i++) {
+ mstate->dtms_scratch_ptr = saved;
+
+ if (offs >= strsize)
+ break;
+
+#ifndef VBOX
+ sym = (char *)(uintptr_t)dtrace_helper(
+ DTRACE_HELPER_ACTION_USTACK,
+ mstate, state, pcs[i], fps[i]);
+#else
+ sym = NULL;
+#endif
+
+ /*
+ * If we faulted while running the helper, we're going to
+ * clear the fault and null out the corresponding string.
+ */
+ if (*flags & CPU_DTRACE_FAULT) {
+ *flags &= ~CPU_DTRACE_FAULT;
+ str[offs++] = '\0';
+ continue;
+ }
+
+ if (sym == NULL) {
+ str[offs++] = '\0';
+ continue;
+ }
+
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+
+ /*
+ * Now copy in the string that the helper returned to us.
+ */
+ for (j = 0; offs + j < strsize; j++) {
+ if ((str[offs + j] = sym[j]) == '\0')
+ break;
+ }
+
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+
+ offs += j + 1;
+ }
+
+ if (offs >= strsize) {
+ /*
+ * If we didn't have room for all of the strings, we don't
+ * abort processing -- this needn't be a fatal error -- but we
+ * still want to increment a counter (dts_stkstroverflows) to
+ * allow this condition to be warned about. (If this is from
+ * a jstack() action, it is easily tuned via jstackstrsize.)
+ */
+ dtrace_error(&state->dts_stkstroverflows);
+ }
+
+ while (offs < strsize)
+ str[offs++] = '\0';
+
+out:
+ mstate->dtms_scratch_ptr = old;
+}
+#endif /* !VBOX */
+
+#ifdef VBOX
+extern void dtrace_probe6(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
+ uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5);
+# define dtrace_probe_error(a1, a2, a3, a4, a5, a6) \
+ dtrace_probe6(dtrace_probeid_error, (uintptr_t)a1, a2, a3, a4, a5, a6)
+#endif
+
+/*
+ * If you're looking for the epicenter of DTrace, you just found it. This
+ * is the function called by the provider to fire a probe -- from which all
+ * subsequent probe-context DTrace activity emanates.
+ */
+void
+dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
+ uintptr_t arg2, uintptr_t arg3, uintptr_t arg4)
+{
+ processorid_t cpuid;
+ dtrace_icookie_t cookie;
+ dtrace_probe_t *probe;
+ dtrace_mstate_t mstate;
+ dtrace_ecb_t *ecb;
+ dtrace_action_t *act;
+ intptr_t offs;
+ size_t size;
+ int vtime, onintr;
+ volatile uint16_t *flags;
+ hrtime_t now;
+
+#ifndef VBOX
+ /*
+ * Kick out immediately if this CPU is still being born (in which case
+ * curthread will be set to -1) or the current thread can't allow
+ * probes in its current context.
+ */
+ if (((uintptr_t)curthread & 1) || (curthread->t_flag & T_DONTDTRACE))
+ return;
+#endif
+
+ cookie = dtrace_interrupt_disable();
+ probe = dtrace_probes[id - 1];
+ cpuid = VBDT_GET_CPUID();
+ onintr = CPU_ON_INTR(CPU);
+
+ if (!onintr && probe->dtpr_predcache != DTRACE_CACHEIDNONE &&
+ probe->dtpr_predcache == curthread->t_predcache) {
+ /*
+ * We have hit in the predicate cache; we know that
+ * this predicate would evaluate to be false.
+ */
+ dtrace_interrupt_enable(cookie);
+ return;
+ }
+
+#ifndef VBOX
+ if (panic_quiesce) {
+ /*
+ * We don't trace anything if we're panicking.
+ */
+ dtrace_interrupt_enable(cookie);
+ return;
+ }
+#endif
+
+ now = dtrace_gethrtime();
+ vtime = dtrace_vtime_references != 0;
+
+ if (vtime && curthread->t_dtrace_start)
+ curthread->t_dtrace_vtime += now - curthread->t_dtrace_start;
+
+ mstate.dtms_difo = NULL;
+ mstate.dtms_probe = probe;
+ mstate.dtms_strtok = NULL;
+ mstate.dtms_arg[0] = arg0;
+ mstate.dtms_arg[1] = arg1;
+ mstate.dtms_arg[2] = arg2;
+ mstate.dtms_arg[3] = arg3;
+ mstate.dtms_arg[4] = arg4;
+
+ flags = (volatile uint16_t *)&cpu_core[cpuid].cpuc_dtrace_flags;
+
+ for (ecb = probe->dtpr_ecb; ecb != NULL; ecb = ecb->dte_next) {
+ dtrace_predicate_t *pred = ecb->dte_predicate;
+ dtrace_state_t *state = ecb->dte_state;
+ dtrace_buffer_t *buf = &state->dts_buffer[cpuid];
+ dtrace_buffer_t *aggbuf = &state->dts_aggbuffer[cpuid];
+ dtrace_vstate_t *vstate = &state->dts_vstate;
+ dtrace_provider_t *prov = probe->dtpr_provider;
+ int committed = 0;
+ caddr_t tomax;
+
+ /*
+ * A little subtlety with the following (seemingly innocuous)
+ * declaration of the automatic 'val': by looking at the
+ * code, you might think that it could be declared in the
+ * action processing loop, below. (That is, it's only used in
+ * the action processing loop.) However, it must be declared
+ * out of that scope because in the case of DIF expression
+ * arguments to aggregating actions, one iteration of the
+ * action loop will use the last iteration's value.
+ */
+#ifdef lint
+ uint64_t val = 0;
+#else
+ uint64_t val VBDTUNASS(0);
+#endif
+
+ mstate.dtms_present = DTRACE_MSTATE_ARGS | DTRACE_MSTATE_PROBE;
+ *flags &= ~CPU_DTRACE_ERROR;
+
+ if (prov == dtrace_provider) {
+ /*
+ * If dtrace itself is the provider of this probe,
+ * we're only going to continue processing the ECB if
+ * arg0 (the dtrace_state_t) is equal to the ECB's
+ * creating state. (This prevents disjoint consumers
+ * from seeing one another's metaprobes.)
+ */
+ if (arg0 != (uint64_t)(uintptr_t)state)
+ continue;
+ }
+
+ if (state->dts_activity != DTRACE_ACTIVITY_ACTIVE) {
+ /*
+ * We're not currently active. If our provider isn't
+ * the dtrace pseudo provider, we're not interested.
+ */
+ if (prov != dtrace_provider)
+ continue;
+
+ /*
+ * Now we must further check if we are in the BEGIN
+ * probe. If we are, we will only continue processing
+ * if we're still in WARMUP -- if one BEGIN enabling
+ * has invoked the exit() action, we don't want to
+ * evaluate subsequent BEGIN enablings.
+ */
+ if (probe->dtpr_id == dtrace_probeid_begin &&
+ state->dts_activity != DTRACE_ACTIVITY_WARMUP) {
+ ASSERT(state->dts_activity ==
+ DTRACE_ACTIVITY_DRAINING);
+ continue;
+ }
+ }
+
+ if (ecb->dte_cond) {
+ /*
+ * If the dte_cond bits indicate that this
+ * consumer is only allowed to see user-mode firings
+ * of this probe, call the provider's dtps_usermode()
+ * entry point to check that the probe was fired
+ * while in a user context. Skip this ECB if that's
+ * not the case.
+ */
+ if ((ecb->dte_cond & DTRACE_COND_USERMODE) &&
+ prov->dtpv_pops.dtps_usermode(prov->dtpv_arg,
+ probe->dtpr_id, probe->dtpr_arg) == 0)
+ continue;
+
+ /*
+ * This is more subtle than it looks. We have to be
+ * absolutely certain that CRED() isn't going to
+ * change out from under us so it's only legit to
+ * examine that structure if we're in constrained
+ * situations. Currently, the only times we'll this
+ * check is if a non-super-user has enabled the
+ * profile or syscall providers -- providers that
+ * allow visibility of all processes. For the
+ * profile case, the check above will ensure that
+ * we're examining a user context.
+ */
+ if (ecb->dte_cond & DTRACE_COND_OWNER) {
+ cred_t *cr;
+ cred_t *s_cr =
+ ecb->dte_state->dts_cred.dcr_cred;
+#ifndef VBOX
+ proc_t *proc;
+#endif
+
+ ASSERT(s_cr != NULL);
+
+ if ((cr = CRED()) == NULL ||
+ s_cr->cr_uid != cr->cr_uid ||
+ s_cr->cr_uid != cr->cr_ruid ||
+ s_cr->cr_uid != cr->cr_suid ||
+ s_cr->cr_gid != cr->cr_gid ||
+ s_cr->cr_gid != cr->cr_rgid ||
+ s_cr->cr_gid != cr->cr_sgid ||
+#ifndef VBOX
+ (proc = VBDT_GET_PROC()) == NULL ||
+ (proc->p_flag & SNOCD))
+#else
+ 0)
+
+#endif
+ continue;
+ }
+
+#ifndef VBOX
+ if (ecb->dte_cond & DTRACE_COND_ZONEOWNER) {
+ cred_t *cr;
+ cred_t *s_cr =
+ ecb->dte_state->dts_cred.dcr_cred;
+
+ ASSERT(s_cr != NULL);
+
+ if ((cr = CRED()) == NULL ||
+ s_cr->cr_zone->zone_id !=
+ cr->cr_zone->zone_id)
+ continue;
+ }
+#endif
+ }
+
+ if (now - state->dts_alive > dtrace_deadman_timeout) {
+ /*
+ * We seem to be dead. Unless we (a) have kernel
+ * destructive permissions (b) have expicitly enabled
+ * destructive actions and (c) destructive actions have
+ * not been disabled, we're going to transition into
+ * the KILLED state, from which no further processing
+ * on this state will be performed.
+ */
+ if (!dtrace_priv_kernel_destructive(state) ||
+ !state->dts_cred.dcr_destructive ||
+ dtrace_destructive_disallow) {
+ void *activity = &state->dts_activity;
+ dtrace_activity_t current;
+
+ do {
+ current = state->dts_activity;
+ } while ( (dtrace_activity_t)dtrace_cas32(activity, current, DTRACE_ACTIVITY_KILLED)
+ != current);
+
+ continue;
+ }
+ }
+
+ if ((offs = dtrace_buffer_reserve(buf, ecb->dte_needed,
+ ecb->dte_alignment, state, &mstate)) < 0)
+ continue;
+
+ tomax = buf->dtb_tomax;
+ ASSERT(tomax != NULL);
+
+ if (ecb->dte_size != 0)
+ DTRACE_STORE(uint32_t, tomax, offs, ecb->dte_epid);
+
+ mstate.dtms_epid = ecb->dte_epid;
+ mstate.dtms_present |= DTRACE_MSTATE_EPID;
+
+ if (state->dts_cred.dcr_visible & DTRACE_CRV_KERNEL)
+ mstate.dtms_access = DTRACE_ACCESS_KERNEL;
+ else
+ mstate.dtms_access = 0;
+
+ if (pred != NULL) {
+ dtrace_difo_t *dp = pred->dtp_difo;
+ int rval;
+
+ rval = dtrace_dif_emulate(dp, &mstate, vstate, state);
+
+ if (!(*flags & CPU_DTRACE_ERROR) && !rval) {
+ dtrace_cacheid_t cid = probe->dtpr_predcache;
+
+ if (cid != DTRACE_CACHEIDNONE && !onintr) {
+ /*
+ * Update the predicate cache...
+ */
+ ASSERT(cid == pred->dtp_cacheid);
+ curthread->t_predcache = cid;
+ }
+
+ continue;
+ }
+ }
+
+ for (act = ecb->dte_action; !(*flags & CPU_DTRACE_ERROR) &&
+ act != NULL; act = act->dta_next) {
+ size_t valoffs;
+ dtrace_difo_t *dp;
+ dtrace_recdesc_t *rec = &act->dta_rec;
+
+ size = rec->dtrd_size;
+ valoffs = offs + rec->dtrd_offset;
+
+ if (DTRACEACT_ISAGG(act->dta_kind)) {
+ uint64_t v = 0xbad;
+ dtrace_aggregation_t *agg;
+
+ agg = (dtrace_aggregation_t *)act;
+
+ if ((dp = act->dta_difo) != NULL)
+ v = dtrace_dif_emulate(dp,
+ &mstate, vstate, state);
+
+ if (*flags & CPU_DTRACE_ERROR)
+ continue;
+
+ /*
+ * Note that we always pass the expression
+ * value from the previous iteration of the
+ * action loop. This value will only be used
+ * if there is an expression argument to the
+ * aggregating action, denoted by the
+ * dtag_hasarg field.
+ */
+ dtrace_aggregate(agg, buf,
+ offs, aggbuf, v, val);
+ continue;
+ }
+
+ switch (act->dta_kind) {
+ case DTRACEACT_STOP:
+#ifndef VBOX
+ if (dtrace_priv_proc_destructive(state))
+ dtrace_action_stop();
+#else
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ continue;
+
+ case DTRACEACT_BREAKPOINT:
+#ifndef VBOX
+ if (dtrace_priv_kernel_destructive(state))
+ dtrace_action_breakpoint(ecb);
+#else
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ continue;
+
+ case DTRACEACT_PANIC:
+#ifndef VBOX
+ if (dtrace_priv_kernel_destructive(state))
+ dtrace_action_panic(ecb);
+#endif
+ continue;
+
+ case DTRACEACT_STACK:
+ if (!dtrace_priv_kernel(state))
+ continue;
+
+ dtrace_getpcstack((pc_t *)(tomax + valoffs),
+ VBDTCAST(int)(size / sizeof (pc_t)), probe->dtpr_aframes,
+ DTRACE_ANCHORED(probe) ? NULL :
+ (uint32_t *)arg0);
+
+ continue;
+
+ case DTRACEACT_JSTACK:
+ case DTRACEACT_USTACK:
+ if (!dtrace_priv_proc(state))
+ continue;
+
+ /*
+ * See comment in DIF_VAR_PID.
+ */
+ if (DTRACE_ANCHORED(mstate.dtms_probe) &&
+ CPU_ON_INTR(CPU)) {
+ int depth = DTRACE_USTACK_NFRAMES(
+ rec->dtrd_arg) + 1;
+
+ dtrace_bzero((void *)(tomax + valoffs),
+ DTRACE_USTACK_STRSIZE(rec->dtrd_arg)
+ + depth * sizeof (uint64_t));
+
+ continue;
+ }
+
+#ifndef VBOX /* no helpers */
+ if (DTRACE_USTACK_STRSIZE(rec->dtrd_arg) != 0 &&
+ curproc->p_dtrace_helpers != NULL) {
+ /*
+ * This is the slow path -- we have
+ * allocated string space, and we're
+ * getting the stack of a process that
+ * has helpers. Call into a separate
+ * routine to perform this processing.
+ */
+ dtrace_action_ustack(&mstate, state,
+ (uint64_t *)(tomax + valoffs),
+ rec->dtrd_arg);
+ continue;
+ }
+#endif
+
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ dtrace_getupcstack((uint64_t *)
+ (tomax + valoffs),
+ DTRACE_USTACK_NFRAMES(rec->dtrd_arg) + 1);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+ continue;
+
+ default:
+ break;
+ }
+
+ dp = act->dta_difo;
+ ASSERT(dp != NULL);
+
+ val = dtrace_dif_emulate(dp, &mstate, vstate, state);
+
+ if (*flags & CPU_DTRACE_ERROR)
+ continue;
+
+ switch (act->dta_kind) {
+ case DTRACEACT_SPECULATE:
+ ASSERT(buf == &state->dts_buffer[cpuid]);
+ buf = dtrace_speculation_buffer(state,
+ cpuid, val);
+
+ if (buf == NULL) {
+ *flags |= CPU_DTRACE_DROP;
+ continue;
+ }
+
+ offs = dtrace_buffer_reserve(buf,
+ ecb->dte_needed, ecb->dte_alignment,
+ state, NULL);
+
+ if (offs < 0) {
+ *flags |= CPU_DTRACE_DROP;
+ continue;
+ }
+
+ tomax = buf->dtb_tomax;
+ ASSERT(tomax != NULL);
+
+ if (ecb->dte_size != 0)
+ DTRACE_STORE(uint32_t, tomax, offs,
+ ecb->dte_epid);
+ continue;
+
+ case DTRACEACT_CHILL:
+#ifndef VBOX
+ if (dtrace_priv_kernel_destructive(state))
+ dtrace_action_chill(&mstate, val);
+#else
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ continue;
+
+ case DTRACEACT_RAISE:
+#ifndef VBOX
+ if (dtrace_priv_proc_destructive(state))
+ dtrace_action_raise(val);
+#else
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+#endif
+ continue;
+
+ case DTRACEACT_COMMIT:
+ ASSERT(!committed);
+
+ /*
+ * We need to commit our buffer state.
+ */
+ if (ecb->dte_size)
+ buf->dtb_offset = offs + ecb->dte_size;
+ buf = &state->dts_buffer[cpuid];
+ dtrace_speculation_commit(state, cpuid, val);
+ committed = 1;
+ continue;
+
+ case DTRACEACT_DISCARD:
+ dtrace_speculation_discard(state, cpuid, val);
+ continue;
+
+ case DTRACEACT_DIFEXPR:
+ case DTRACEACT_LIBACT:
+ case DTRACEACT_PRINTF:
+ case DTRACEACT_PRINTA:
+ case DTRACEACT_SYSTEM:
+ case DTRACEACT_FREOPEN:
+ break;
+
+ case DTRACEACT_SYM:
+ case DTRACEACT_MOD:
+ if (!dtrace_priv_kernel(state))
+ continue;
+ break;
+
+ case DTRACEACT_USYM:
+ case DTRACEACT_UMOD:
+ case DTRACEACT_UADDR: {
+#ifndef VBOX
+ struct pid *pid = curthread->t_procp->p_pidp;
+
+ if (!dtrace_priv_proc(state))
+ continue;
+
+ DTRACE_STORE(uint64_t, tomax,
+ valoffs, (uint64_t)pid->pid_id);
+ DTRACE_STORE(uint64_t, tomax,
+ valoffs + sizeof (uint64_t), val);
+#else
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_UPRIV);
+#endif
+ continue;
+ }
+
+ case DTRACEACT_EXIT: {
+ /*
+ * For the exit action, we are going to attempt
+ * to atomically set our activity to be
+ * draining. If this fails (either because
+ * another CPU has beat us to the exit action,
+ * or because our current activity is something
+ * other than ACTIVE or WARMUP), we will
+ * continue. This assures that the exit action
+ * can be successfully recorded at most once
+ * when we're in the ACTIVE state. If we're
+ * encountering the exit() action while in
+ * COOLDOWN, however, we want to honor the new
+ * status code. (We know that we're the only
+ * thread in COOLDOWN, so there is no race.)
+ */
+ void *activity = &state->dts_activity;
+ dtrace_activity_t current = state->dts_activity;
+
+ if (current == DTRACE_ACTIVITY_COOLDOWN)
+ break;
+
+ if (current != DTRACE_ACTIVITY_WARMUP)
+ current = DTRACE_ACTIVITY_ACTIVE;
+
+ if ( (dtrace_activity_t)dtrace_cas32(activity, current, DTRACE_ACTIVITY_DRAINING)
+ != current) {
+ *flags |= CPU_DTRACE_DROP;
+ continue;
+ }
+
+ break;
+ }
+
+ default:
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalMsgFailed(("%d\n", act->dta_kind));
+#endif
+ }
+
+ if (dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF) {
+ uintptr_t end = valoffs + size;
+
+ if (!dtrace_vcanload((void *)(uintptr_t)val,
+ &dp->dtdo_rtype, &mstate, vstate))
+ continue;
+
+ /*
+ * If this is a string, we're going to only
+ * load until we find the zero byte -- after
+ * which we'll store zero bytes.
+ */
+ if (dp->dtdo_rtype.dtdt_kind ==
+ DIF_TYPE_STRING) {
+ char c = '\0' + 1;
+ int intuple = act->dta_intuple;
+ size_t s;
+
+ for (s = 0; s < size; s++) {
+ if (c != '\0')
+ c = dtrace_load8(val++);
+
+ DTRACE_STORE(uint8_t, tomax,
+ valoffs++, c);
+
+ if (c == '\0' && intuple)
+ break;
+ }
+
+ continue;
+ }
+
+ while (valoffs < end) {
+ DTRACE_STORE(uint8_t, tomax, valoffs++,
+ dtrace_load8(val++));
+ }
+
+ continue;
+ }
+
+ switch (size) {
+ case 0:
+ break;
+
+ case sizeof (uint8_t):
+ DTRACE_STORE(uint8_t, tomax, valoffs, val);
+ break;
+ case sizeof (uint16_t):
+ DTRACE_STORE(uint16_t, tomax, valoffs, val);
+ break;
+ case sizeof (uint32_t):
+ DTRACE_STORE(uint32_t, tomax, valoffs, val);
+ break;
+ case sizeof (uint64_t):
+ DTRACE_STORE(uint64_t, tomax, valoffs, val);
+ break;
+ default:
+ /*
+ * Any other size should have been returned by
+ * reference, not by value.
+ */
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalMsgFailed(("%zu\n", size));
+#endif
+ break;
+ }
+ }
+
+ if (*flags & CPU_DTRACE_DROP)
+ continue;
+
+ if (*flags & CPU_DTRACE_FAULT) {
+ int ndx;
+ dtrace_action_t *err;
+
+ buf->dtb_errors++;
+
+ if (probe->dtpr_id == dtrace_probeid_error) {
+ /*
+ * There's nothing we can do -- we had an
+ * error on the error probe. We bump an
+ * error counter to at least indicate that
+ * this condition happened.
+ */
+ dtrace_error(&state->dts_dblerrors);
+ continue;
+ }
+
+ if (vtime) {
+ /*
+ * Before recursing on dtrace_probe(), we
+ * need to explicitly clear out our start
+ * time to prevent it from being accumulated
+ * into t_dtrace_vtime.
+ */
+ curthread->t_dtrace_start = 0;
+ }
+
+ /*
+ * Iterate over the actions to figure out which action
+ * we were processing when we experienced the error.
+ * Note that act points _past_ the faulting action; if
+ * act is ecb->dte_action, the fault was in the
+ * predicate, if it's ecb->dte_action->dta_next it's
+ * in action #1, and so on.
+ */
+ for (err = ecb->dte_action, ndx = 0;
+ err != act; err = err->dta_next, ndx++)
+ continue;
+
+ dtrace_probe_error(state, ecb->dte_epid, ndx,
+ (mstate.dtms_present & DTRACE_MSTATE_FLTOFFS) ?
+ mstate.dtms_fltoffs : -1, DTRACE_FLAGS2FLT(*flags),
+ cpu_core[cpuid].cpuc_dtrace_illval);
+
+ continue;
+ }
+
+ if (!committed)
+ buf->dtb_offset = offs + ecb->dte_size;
+ }
+
+ if (vtime)
+ curthread->t_dtrace_start = dtrace_gethrtime();
+
+ dtrace_interrupt_enable(cookie);
+}
+
+/*
+ * DTrace Probe Hashing Functions
+ *
+ * The functions in this section (and indeed, the functions in remaining
+ * sections) are not _called_ from probe context. (Any exceptions to this are
+ * marked with a "Note:".) Rather, they are called from elsewhere in the
+ * DTrace framework to look-up probes in, add probes to and remove probes from
+ * the DTrace probe hashes. (Each probe is hashed by each element of the
+ * probe tuple -- allowing for fast lookups, regardless of what was
+ * specified.)
+ */
+static uint_t
+dtrace_hash_str(char *p)
+{
+ unsigned int g;
+ uint_t hval = 0;
+
+ while (*p) {
+ hval = (hval << 4) + *p++;
+ if ((g = (hval & 0xf0000000)) != 0)
+ hval ^= g >> 24;
+ hval &= ~g;
+ }
+ return (hval);
+}
+
+static dtrace_hash_t *
+dtrace_hash_create(uintptr_t stroffs, uintptr_t nextoffs, uintptr_t prevoffs)
+{
+ dtrace_hash_t *hash = kmem_zalloc(sizeof (dtrace_hash_t), KM_SLEEP);
+
+ hash->dth_stroffs = stroffs;
+ hash->dth_nextoffs = nextoffs;
+ hash->dth_prevoffs = prevoffs;
+
+ hash->dth_size = 1;
+ hash->dth_mask = hash->dth_size - 1;
+
+ hash->dth_tab = kmem_zalloc(hash->dth_size *
+ sizeof (dtrace_hashbucket_t *), KM_SLEEP);
+
+ return (hash);
+}
+
+static void
+dtrace_hash_destroy(dtrace_hash_t *hash)
+{
+#ifdef DEBUG
+ int i;
+
+ for (i = 0; i < hash->dth_size; i++)
+ ASSERT(hash->dth_tab[i] == NULL);
+#endif
+
+ kmem_free(hash->dth_tab,
+ hash->dth_size * sizeof (dtrace_hashbucket_t *));
+ kmem_free(hash, sizeof (dtrace_hash_t));
+}
+
+static void
+dtrace_hash_resize(dtrace_hash_t *hash)
+{
+ int size = hash->dth_size, i, ndx;
+ int new_size = hash->dth_size << 1;
+ int new_mask = new_size - 1;
+ dtrace_hashbucket_t **new_tab, *bucket, *next;
+
+ ASSERT((new_size & new_mask) == 0);
+
+ new_tab = kmem_zalloc(new_size * sizeof (void *), KM_SLEEP);
+
+ for (i = 0; i < size; i++) {
+ for (bucket = hash->dth_tab[i]; bucket != NULL; bucket = next) {
+ dtrace_probe_t *probe = bucket->dthb_chain;
+
+ ASSERT(probe != NULL);
+ ndx = DTRACE_HASHSTR(hash, probe) & new_mask;
+
+ next = bucket->dthb_next;
+ bucket->dthb_next = new_tab[ndx];
+ new_tab[ndx] = bucket;
+ }
+ }
+
+ kmem_free(hash->dth_tab, hash->dth_size * sizeof (void *));
+ hash->dth_tab = new_tab;
+ hash->dth_size = new_size;
+ hash->dth_mask = new_mask;
+}
+
+static void
+dtrace_hash_add(dtrace_hash_t *hash, dtrace_probe_t *new)
+{
+ int hashval = DTRACE_HASHSTR(hash, new);
+ int ndx = hashval & hash->dth_mask;
+ dtrace_hashbucket_t *bucket = hash->dth_tab[ndx];
+ dtrace_probe_t **nextp, **prevp;
+
+ for (; bucket != NULL; bucket = bucket->dthb_next) {
+ if (DTRACE_HASHEQ(hash, bucket->dthb_chain, new))
+ goto add;
+ }
+
+ if ((hash->dth_nbuckets >> 1) > hash->dth_size) {
+ dtrace_hash_resize(hash);
+ dtrace_hash_add(hash, new);
+ return;
+ }
+
+ bucket = kmem_zalloc(sizeof (dtrace_hashbucket_t), KM_SLEEP);
+ bucket->dthb_next = hash->dth_tab[ndx];
+ hash->dth_tab[ndx] = bucket;
+ hash->dth_nbuckets++;
+
+add:
+ nextp = DTRACE_HASHNEXT(hash, new);
+ ASSERT(*nextp == NULL && *(DTRACE_HASHPREV(hash, new)) == NULL);
+ *nextp = bucket->dthb_chain;
+
+ if (bucket->dthb_chain != NULL) {
+ prevp = DTRACE_HASHPREV(hash, bucket->dthb_chain);
+ ASSERT(*prevp == NULL);
+ *prevp = new;
+ }
+
+ bucket->dthb_chain = new;
+ bucket->dthb_len++;
+}
+
+static dtrace_probe_t *
+dtrace_hash_lookup(dtrace_hash_t *hash, dtrace_probe_t *template)
+{
+ int hashval = DTRACE_HASHSTR(hash, template);
+ int ndx = hashval & hash->dth_mask;
+ dtrace_hashbucket_t *bucket = hash->dth_tab[ndx];
+
+ for (; bucket != NULL; bucket = bucket->dthb_next) {
+ if (DTRACE_HASHEQ(hash, bucket->dthb_chain, template))
+ return (bucket->dthb_chain);
+ }
+
+ return (NULL);
+}
+
+static int
+dtrace_hash_collisions(dtrace_hash_t *hash, dtrace_probe_t *template)
+{
+ int hashval = DTRACE_HASHSTR(hash, template);
+ int ndx = hashval & hash->dth_mask;
+ dtrace_hashbucket_t *bucket = hash->dth_tab[ndx];
+
+ for (; bucket != NULL; bucket = bucket->dthb_next) {
+ if (DTRACE_HASHEQ(hash, bucket->dthb_chain, template))
+ return (bucket->dthb_len);
+ }
+
+ return (NULL);
+}
+
+static void
+dtrace_hash_remove(dtrace_hash_t *hash, dtrace_probe_t *probe)
+{
+ int ndx = DTRACE_HASHSTR(hash, probe) & hash->dth_mask;
+ dtrace_hashbucket_t *bucket = hash->dth_tab[ndx];
+
+ dtrace_probe_t **prevp = DTRACE_HASHPREV(hash, probe);
+ dtrace_probe_t **nextp = DTRACE_HASHNEXT(hash, probe);
+
+ /*
+ * Find the bucket that we're removing this probe from.
+ */
+ for (; bucket != NULL; bucket = bucket->dthb_next) {
+ if (DTRACE_HASHEQ(hash, bucket->dthb_chain, probe))
+ break;
+ }
+
+ ASSERT(bucket != NULL);
+
+ if (*prevp == NULL) {
+ if (*nextp == NULL) {
+ /*
+ * The removed probe was the only probe on this
+ * bucket; we need to remove the bucket.
+ */
+ dtrace_hashbucket_t *b = hash->dth_tab[ndx];
+
+ ASSERT(bucket->dthb_chain == probe);
+ ASSERT(b != NULL);
+
+ if (b == bucket) {
+ hash->dth_tab[ndx] = bucket->dthb_next;
+ } else {
+ while (b->dthb_next != bucket)
+ b = b->dthb_next;
+ b->dthb_next = bucket->dthb_next;
+ }
+
+ ASSERT(hash->dth_nbuckets > 0);
+ hash->dth_nbuckets--;
+ kmem_free(bucket, sizeof (dtrace_hashbucket_t));
+ return;
+ }
+
+ bucket->dthb_chain = *nextp;
+ } else {
+ *(DTRACE_HASHNEXT(hash, *prevp)) = *nextp;
+ }
+
+ if (*nextp != NULL)
+ *(DTRACE_HASHPREV(hash, *nextp)) = *prevp;
+}
+
+/*
+ * DTrace Utility Functions
+ *
+ * These are random utility functions that are _not_ called from probe context.
+ */
+static int
+dtrace_badattr(const dtrace_attribute_t *a)
+{
+ return (a->dtat_name > DTRACE_STABILITY_MAX ||
+ a->dtat_data > DTRACE_STABILITY_MAX ||
+ a->dtat_class > DTRACE_CLASS_MAX);
+}
+
+/*
+ * Return a duplicate copy of a string. If the specified string is NULL,
+ * this function returns a zero-length string.
+ */
+static char *
+dtrace_strdup(const char *str)
+{
+ char *new = kmem_zalloc((str != NULL ? strlen(str) : 0) + 1, KM_SLEEP);
+
+ if (str != NULL)
+ (void) strcpy(new, str);
+
+ return (new);
+}
+
+#define DTRACE_ISALPHA(c) \
+ (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
+
+static int
+dtrace_badname(const char *s)
+{
+ char c;
+
+ if (s == NULL || (c = *s++) == '\0')
+ return (0);
+
+ if (!DTRACE_ISALPHA(c) && c != '-' && c != '_' && c != '.')
+ return (1);
+
+ while ((c = *s++) != '\0') {
+ if (!DTRACE_ISALPHA(c) && (c < '0' || c > '9') &&
+ c != '-' && c != '_' && c != '.' && c != '`')
+ return (1);
+ }
+
+ return (0);
+}
+
+static void
+dtrace_cred2priv(cred_t *cr, uint32_t *privp, uid_t *uidp, zoneid_t *zoneidp)
+{
+ uint32_t priv;
+
+ if (cr == NULL || PRIV_POLICY_ONLY(cr, PRIV_ALL, B_FALSE)) {
+ /*
+ * For DTRACE_PRIV_ALL, the uid and zoneid don't matter.
+ */
+ priv = DTRACE_PRIV_ALL;
+#ifdef VBOX
+ *uidp = UINT32_MAX;
+ *zoneidp = 0;
+#endif
+ } else {
+ *uidp = crgetuid(cr);
+ *zoneidp = crgetzoneid(cr);
+
+ priv = 0;
+ if (PRIV_POLICY_ONLY(cr, PRIV_DTRACE_KERNEL, B_FALSE))
+ priv |= DTRACE_PRIV_KERNEL | DTRACE_PRIV_USER;
+ else if (PRIV_POLICY_ONLY(cr, PRIV_DTRACE_USER, B_FALSE))
+ priv |= DTRACE_PRIV_USER;
+ if (PRIV_POLICY_ONLY(cr, PRIV_DTRACE_PROC, B_FALSE))
+ priv |= DTRACE_PRIV_PROC;
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_OWNER, B_FALSE))
+ priv |= DTRACE_PRIV_OWNER;
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_ZONE, B_FALSE))
+ priv |= DTRACE_PRIV_ZONEOWNER;
+ }
+
+ *privp = priv;
+}
+
+#ifdef DTRACE_ERRDEBUG
+static void
+dtrace_errdebug(const char *str)
+{
+ int hval = dtrace_hash_str((char *)str) % DTRACE_ERRHASHSZ;
+ int occupied = 0;
+
+ mutex_enter(&dtrace_errlock);
+ dtrace_errlast = str;
+ dtrace_errthread = curthread;
+
+ while (occupied++ < DTRACE_ERRHASHSZ) {
+ if (dtrace_errhash[hval].dter_msg == str) {
+ dtrace_errhash[hval].dter_count++;
+ goto out;
+ }
+
+ if (dtrace_errhash[hval].dter_msg != NULL) {
+ hval = (hval + 1) % DTRACE_ERRHASHSZ;
+ continue;
+ }
+
+ dtrace_errhash[hval].dter_msg = str;
+ dtrace_errhash[hval].dter_count = 1;
+ goto out;
+ }
+
+ panic("dtrace: undersized error hash");
+out:
+ mutex_exit(&dtrace_errlock);
+}
+#endif
+
+/*
+ * DTrace Matching Functions
+ *
+ * These functions are used to match groups of probes, given some elements of
+ * a probe tuple, or some globbed expressions for elements of a probe tuple.
+ */
+static int
+dtrace_match_priv(const dtrace_probe_t *prp, uint32_t priv, uid_t uid,
+ zoneid_t zoneid)
+{
+ if (priv != DTRACE_PRIV_ALL) {
+ uint32_t ppriv = prp->dtpr_provider->dtpv_priv.dtpp_flags;
+ uint32_t match = priv & ppriv;
+
+ /*
+ * No PRIV_DTRACE_* privileges...
+ */
+ if ((priv & (DTRACE_PRIV_PROC | DTRACE_PRIV_USER |
+ DTRACE_PRIV_KERNEL)) == 0)
+ return (0);
+
+ /*
+ * No matching bits, but there were bits to match...
+ */
+ if (match == 0 && ppriv != 0)
+ return (0);
+
+ /*
+ * Need to have permissions to the process, but don't...
+ */
+ if (((ppriv & ~match) & DTRACE_PRIV_OWNER) != 0 &&
+ uid != prp->dtpr_provider->dtpv_priv.dtpp_uid) {
+ return (0);
+ }
+
+ /*
+ * Need to be in the same zone unless we possess the
+ * privilege to examine all zones.
+ */
+ if (((ppriv & ~match) & DTRACE_PRIV_ZONEOWNER) != 0 &&
+ zoneid != prp->dtpr_provider->dtpv_priv.dtpp_zoneid) {
+ return (0);
+ }
+ }
+
+ return (1);
+}
+
+/*
+ * dtrace_match_probe compares a dtrace_probe_t to a pre-compiled key, which
+ * consists of input pattern strings and an ops-vector to evaluate them.
+ * This function returns >0 for match, 0 for no match, and <0 for error.
+ */
+static int
+dtrace_match_probe(const dtrace_probe_t *prp, const dtrace_probekey_t *pkp,
+ uint32_t priv, uid_t uid, zoneid_t zoneid)
+{
+ dtrace_provider_t *pvp = prp->dtpr_provider;
+ int rv;
+
+ if (pvp->dtpv_defunct)
+ return (0);
+
+ if ((rv = pkp->dtpk_pmatch(pvp->dtpv_name, pkp->dtpk_prov, 0)) <= 0)
+ return (rv);
+
+ if ((rv = pkp->dtpk_mmatch(prp->dtpr_mod, pkp->dtpk_mod, 0)) <= 0)
+ return (rv);
+
+ if ((rv = pkp->dtpk_fmatch(prp->dtpr_func, pkp->dtpk_func, 0)) <= 0)
+ return (rv);
+
+ if ((rv = pkp->dtpk_nmatch(prp->dtpr_name, pkp->dtpk_name, 0)) <= 0)
+ return (rv);
+
+ if (dtrace_match_priv(prp, priv, uid, zoneid) == 0)
+ return (0);
+
+ return (rv);
+}
+
+/*
+ * dtrace_match_glob() is a safe kernel implementation of the gmatch(3GEN)
+ * interface for matching a glob pattern 'p' to an input string 's'. Unlike
+ * libc's version, the kernel version only applies to 8-bit ASCII strings.
+ * In addition, all of the recursion cases except for '*' matching have been
+ * unwound. For '*', we still implement recursive evaluation, but a depth
+ * counter is maintained and matching is aborted if we recurse too deep.
+ * The function returns 0 if no match, >0 if match, and <0 if recursion error.
+ */
+static int
+dtrace_match_glob(const char *s, const char *p, int depth)
+{
+ const char *olds;
+ char s1, c;
+ int gs;
+
+ if (depth > DTRACE_PROBEKEY_MAXDEPTH)
+ return (-1);
+
+ if (s == NULL)
+ s = ""; /* treat NULL as empty string */
+
+top:
+ olds = s;
+ s1 = *s++;
+
+ if (p == NULL)
+ return (0);
+
+ if ((c = *p++) == '\0')
+ return (s1 == '\0');
+
+ switch (c) {
+ case '[': {
+ int ok = 0, notflag = 0;
+ char lc = '\0';
+
+ if (s1 == '\0')
+ return (0);
+
+ if (*p == '!') {
+ notflag = 1;
+ p++;
+ }
+
+ if ((c = *p++) == '\0')
+ return (0);
+
+ do {
+ if (c == '-' && lc != '\0' && *p != ']') {
+ if ((c = *p++) == '\0')
+ return (0);
+ if (c == '\\' && (c = *p++) == '\0')
+ return (0);
+
+ if (notflag) {
+ if (s1 < lc || s1 > c)
+ ok++;
+ else
+ return (0);
+ } else if (lc <= s1 && s1 <= c)
+ ok++;
+
+ } else if (c == '\\' && (c = *p++) == '\0')
+ return (0);
+
+ lc = c; /* save left-hand 'c' for next iteration */
+
+ if (notflag) {
+ if (s1 != c)
+ ok++;
+ else
+ return (0);
+ } else if (s1 == c)
+ ok++;
+
+ if ((c = *p++) == '\0')
+ return (0);
+
+ } while (c != ']');
+
+ if (ok)
+ goto top;
+
+ return (0);
+ }
+
+ case '\\':
+ if ((c = *p++) == '\0')
+ return (0);
+ RT_FALL_THRU();
+
+ default:
+ if (c != s1)
+ return (0);
+ RT_FALL_THRU();
+
+ case '?':
+ if (s1 != '\0')
+ goto top;
+ return (0);
+
+ case '*':
+ while (*p == '*')
+ p++; /* consecutive *'s are identical to a single one */
+
+ if (*p == '\0')
+ return (1);
+
+ for (s = olds; *s != '\0'; s++) {
+ if ((gs = dtrace_match_glob(s, p, depth + 1)) != 0)
+ return (gs);
+ }
+
+ return (0);
+ }
+}
+
+/*ARGSUSED*/
+static int
+dtrace_match_string(const char *s, const char *p, int depth)
+{
+ RT_NOREF_PV(depth);
+ return (s != NULL && strcmp(s, p) == 0);
+}
+
+/*ARGSUSED*/
+static int
+dtrace_match_nul(const char *s, const char *p, int depth)
+{
+ RT_NOREF_PV(s); RT_NOREF_PV(p); RT_NOREF_PV(depth);
+ return (1); /* always match the empty pattern */
+}
+
+/*ARGSUSED*/
+static int
+dtrace_match_nonzero(const char *s, const char *p, int depth)
+{
+ RT_NOREF_PV(p); RT_NOREF_PV(depth);
+ return (s != NULL && s[0] != '\0');
+}
+
+static int
+dtrace_match(const dtrace_probekey_t *pkp, uint32_t priv, uid_t uid,
+ zoneid_t zoneid, int (*matched)(dtrace_probe_t *, void *), void *arg)
+{
+ dtrace_probe_t template, *probe;
+ dtrace_hash_t *hash = NULL;
+ int len, rc, best = INT_MAX, nmatched = 0;
+ dtrace_id_t i;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ /*
+ * If the probe ID is specified in the key, just lookup by ID and
+ * invoke the match callback once if a matching probe is found.
+ */
+ if (pkp->dtpk_id != DTRACE_IDNONE) {
+ if ((probe = dtrace_probe_lookup_id(pkp->dtpk_id)) != NULL &&
+ dtrace_match_probe(probe, pkp, priv, uid, zoneid) > 0) {
+ if ((*matched)(probe, arg) == DTRACE_MATCH_FAIL)
+ return (DTRACE_MATCH_FAIL);
+ nmatched++;
+ }
+ return (nmatched);
+ }
+
+ template.dtpr_mod = (char *)pkp->dtpk_mod;
+ template.dtpr_func = (char *)pkp->dtpk_func;
+ template.dtpr_name = (char *)pkp->dtpk_name;
+
+ /*
+ * We want to find the most distinct of the module name, function
+ * name, and name. So for each one that is not a glob pattern or
+ * empty string, we perform a lookup in the corresponding hash and
+ * use the hash table with the fewest collisions to do our search.
+ */
+ if (pkp->dtpk_mmatch == &dtrace_match_string &&
+ (len = dtrace_hash_collisions(dtrace_bymod, &template)) < best) {
+ best = len;
+ hash = dtrace_bymod;
+ }
+
+ if (pkp->dtpk_fmatch == &dtrace_match_string &&
+ (len = dtrace_hash_collisions(dtrace_byfunc, &template)) < best) {
+ best = len;
+ hash = dtrace_byfunc;
+ }
+
+ if (pkp->dtpk_nmatch == &dtrace_match_string &&
+ (len = dtrace_hash_collisions(dtrace_byname, &template)) < best) {
+ best = len;
+ hash = dtrace_byname;
+ }
+
+ /*
+ * If we did not select a hash table, iterate over every probe and
+ * invoke our callback for each one that matches our input probe key.
+ */
+ if (hash == NULL) {
+ for (i = 0; i < VBDTCAST(dtrace_id_t)dtrace_nprobes; i++) {
+ if ((probe = dtrace_probes[i]) == NULL ||
+ dtrace_match_probe(probe, pkp, priv, uid,
+ zoneid) <= 0)
+ continue;
+
+ nmatched++;
+
+ if ((rc = (*matched)(probe, arg)) !=
+ DTRACE_MATCH_NEXT) {
+ if (rc == DTRACE_MATCH_FAIL)
+ return (DTRACE_MATCH_FAIL);
+ break;
+ }
+ }
+
+ return (nmatched);
+ }
+
+ /*
+ * If we selected a hash table, iterate over each probe of the same key
+ * name and invoke the callback for every probe that matches the other
+ * attributes of our input probe key.
+ */
+ for (probe = dtrace_hash_lookup(hash, &template); probe != NULL;
+ probe = *(DTRACE_HASHNEXT(hash, probe))) {
+
+ if (dtrace_match_probe(probe, pkp, priv, uid, zoneid) <= 0)
+ continue;
+
+ nmatched++;
+
+ if ((rc = (*matched)(probe, arg)) != DTRACE_MATCH_NEXT) {
+ if (rc == DTRACE_MATCH_FAIL)
+ return (DTRACE_MATCH_FAIL);
+ break;
+ }
+ }
+
+ return (nmatched);
+}
+
+/*
+ * Return the function pointer dtrace_probecmp() should use to compare the
+ * specified pattern with a string. For NULL or empty patterns, we select
+ * dtrace_match_nul(). For glob pattern strings, we use dtrace_match_glob().
+ * For non-empty non-glob strings, we use dtrace_match_string().
+ */
+static dtrace_probekey_f *
+dtrace_probekey_func(const char *p)
+{
+ char c;
+
+ if (p == NULL || *p == '\0')
+ return (&dtrace_match_nul);
+
+ while ((c = *p++) != '\0') {
+ if (c == '[' || c == '?' || c == '*' || c == '\\')
+ return (&dtrace_match_glob);
+ }
+
+ return (&dtrace_match_string);
+}
+
+/*
+ * Build a probe comparison key for use with dtrace_match_probe() from the
+ * given probe description. By convention, a null key only matches anchored
+ * probes: if each field is the empty string, reset dtpk_fmatch to
+ * dtrace_match_nonzero().
+ */
+static void
+dtrace_probekey(const dtrace_probedesc_t *pdp, dtrace_probekey_t *pkp)
+{
+ pkp->dtpk_prov = pdp->dtpd_provider;
+ pkp->dtpk_pmatch = dtrace_probekey_func(pdp->dtpd_provider);
+
+ pkp->dtpk_mod = pdp->dtpd_mod;
+ pkp->dtpk_mmatch = dtrace_probekey_func(pdp->dtpd_mod);
+
+ pkp->dtpk_func = pdp->dtpd_func;
+ pkp->dtpk_fmatch = dtrace_probekey_func(pdp->dtpd_func);
+
+ pkp->dtpk_name = pdp->dtpd_name;
+ pkp->dtpk_nmatch = dtrace_probekey_func(pdp->dtpd_name);
+
+ pkp->dtpk_id = pdp->dtpd_id;
+
+ if (pkp->dtpk_id == DTRACE_IDNONE &&
+ pkp->dtpk_pmatch == &dtrace_match_nul &&
+ pkp->dtpk_mmatch == &dtrace_match_nul &&
+ pkp->dtpk_fmatch == &dtrace_match_nul &&
+ pkp->dtpk_nmatch == &dtrace_match_nul)
+ pkp->dtpk_fmatch = &dtrace_match_nonzero;
+}
+
+/*
+ * DTrace Provider-to-Framework API Functions
+ *
+ * These functions implement much of the Provider-to-Framework API, as
+ * described in <sys/dtrace.h>. The parts of the API not in this section are
+ * the functions in the API for probe management (found below), and
+ * dtrace_probe() itself (found above).
+ */
+
+/*
+ * Register the calling provider with the DTrace framework. This should
+ * generally be called by DTrace providers in their attach(9E) entry point.
+ */
+int
+dtrace_register(const char *name, const dtrace_pattr_t *pap, uint32_t priv,
+ cred_t *cr, const dtrace_pops_t *pops, void *arg, dtrace_provider_id_t *idp)
+{
+ dtrace_provider_t *provider;
+
+ if (name == NULL || pap == NULL || pops == NULL || idp == NULL) {
+ cmn_err(CE_WARN, "failed to register provider '%s': invalid "
+ "arguments", name ? name : "<NULL>");
+ return (EINVAL);
+ }
+
+ if (name[0] == '\0' || dtrace_badname(name)) {
+ cmn_err(CE_WARN, "failed to register provider '%s': invalid "
+ "provider name", name);
+ return (EINVAL);
+ }
+
+ if ((pops->dtps_provide == NULL && pops->dtps_provide_module == NULL) ||
+ pops->dtps_enable == NULL || pops->dtps_disable == NULL ||
+ pops->dtps_destroy == NULL ||
+ ((pops->dtps_resume == NULL) != (pops->dtps_suspend == NULL))) {
+ cmn_err(CE_WARN, "failed to register provider '%s': invalid "
+ "provider ops", name);
+ return (EINVAL);
+ }
+
+ if (dtrace_badattr(&pap->dtpa_provider) ||
+ dtrace_badattr(&pap->dtpa_mod) ||
+ dtrace_badattr(&pap->dtpa_func) ||
+ dtrace_badattr(&pap->dtpa_name) ||
+ dtrace_badattr(&pap->dtpa_args)) {
+ cmn_err(CE_WARN, "failed to register provider '%s': invalid "
+ "provider attributes", name);
+ return (EINVAL);
+ }
+
+ if (priv & ~DTRACE_PRIV_ALL) {
+ cmn_err(CE_WARN, "failed to register provider '%s': invalid "
+ "privilege attributes", name);
+ return (EINVAL);
+ }
+
+ if ((priv & DTRACE_PRIV_KERNEL) &&
+ (priv & (DTRACE_PRIV_USER | DTRACE_PRIV_OWNER)) &&
+ pops->dtps_usermode == NULL) {
+ cmn_err(CE_WARN, "failed to register provider '%s': need "
+ "dtps_usermode() op for given privilege attributes", name);
+ return (EINVAL);
+ }
+
+ provider = kmem_zalloc(sizeof (dtrace_provider_t), KM_SLEEP);
+ provider->dtpv_name = kmem_alloc(strlen(name) + 1, KM_SLEEP);
+ (void) strcpy(provider->dtpv_name, name);
+
+ provider->dtpv_attr = *pap;
+ provider->dtpv_priv.dtpp_flags = priv;
+ if (cr != NULL) {
+ provider->dtpv_priv.dtpp_uid = crgetuid(cr);
+ provider->dtpv_priv.dtpp_zoneid = crgetzoneid(cr);
+ }
+ provider->dtpv_pops = *pops;
+
+ if (pops->dtps_provide == NULL) {
+ ASSERT(pops->dtps_provide_module != NULL);
+ provider->dtpv_pops.dtps_provide =
+ (void (*)(void *, const dtrace_probedesc_t *))dtrace_nullop;
+ }
+
+ if (pops->dtps_provide_module == NULL) {
+ ASSERT(pops->dtps_provide != NULL);
+ provider->dtpv_pops.dtps_provide_module =
+ (void (*)(void *, struct modctl *))dtrace_nullop;
+ }
+
+ if (pops->dtps_suspend == NULL) {
+ ASSERT(pops->dtps_resume == NULL);
+ provider->dtpv_pops.dtps_suspend =
+ (void (*)(void *, dtrace_id_t, void *))dtrace_nullop;
+ provider->dtpv_pops.dtps_resume =
+ (void (*)(void *, dtrace_id_t, void *))dtrace_nullop;
+ }
+
+ provider->dtpv_arg = arg;
+ *idp = (dtrace_provider_id_t)provider;
+
+ if (pops == &dtrace_provider_ops) {
+ ASSERT(MUTEX_HELD(&dtrace_provider_lock));
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(dtrace_anon.dta_enabling == NULL);
+
+ /*
+ * We make sure that the DTrace provider is at the head of
+ * the provider chain.
+ */
+ provider->dtpv_next = dtrace_provider;
+ dtrace_provider = provider;
+ return (0);
+ }
+
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&dtrace_lock);
+
+ /*
+ * If there is at least one provider registered, we'll add this
+ * provider after the first provider.
+ */
+ if (dtrace_provider != NULL) {
+ provider->dtpv_next = dtrace_provider->dtpv_next;
+ dtrace_provider->dtpv_next = provider;
+ } else {
+ dtrace_provider = provider;
+ }
+
+ if (dtrace_retained != NULL) {
+ dtrace_enabling_provide(provider);
+
+ /*
+ * Now we need to call dtrace_enabling_matchall() -- which
+ * will acquire cpu_lock and dtrace_lock. We therefore need
+ * to drop all of our locks before calling into it...
+ */
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_provider_lock);
+ dtrace_enabling_matchall();
+
+ return (0);
+ }
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_provider_lock);
+
+ return (0);
+}
+
+/*
+ * Unregister the specified provider from the DTrace framework. This should
+ * generally be called by DTrace providers in their detach(9E) entry point.
+ */
+int
+dtrace_unregister(dtrace_provider_id_t id)
+{
+ dtrace_provider_t *old = (dtrace_provider_t *)id;
+ dtrace_provider_t *prev = NULL;
+ VBDTTYPE(uint32_t,int) i, self = 0;
+ dtrace_probe_t *probe, *first = NULL;
+
+ if (old->dtpv_pops.dtps_enable ==
+ (int (*)(void *, dtrace_id_t, void *))(uintptr_t)dtrace_enable_nullop) {
+ /*
+ * If DTrace itself is the provider, we're called with locks
+ * already held.
+ */
+ ASSERT(old == dtrace_provider);
+#ifndef VBOX
+ ASSERT(dtrace_devi != NULL);
+#endif
+ ASSERT(MUTEX_HELD(&dtrace_provider_lock));
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ self = 1;
+
+ if (dtrace_provider->dtpv_next != NULL) {
+ /*
+ * There's another provider here; return failure.
+ */
+ return (EBUSY);
+ }
+ } else {
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&mod_lock);
+ mutex_enter(&dtrace_lock);
+ }
+
+ /*
+ * If anyone has /dev/dtrace open, or if there are anonymous enabled
+ * probes, we refuse to let providers slither away, unless this
+ * provider has already been explicitly invalidated.
+ */
+ if (!old->dtpv_defunct &&
+ (dtrace_opens || (dtrace_anon.dta_state != NULL &&
+ dtrace_anon.dta_state->dts_necbs > 0))) {
+ if (!self) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+ }
+ return (EBUSY);
+ }
+
+ /*
+ * Attempt to destroy the probes associated with this provider.
+ */
+ for (i = 0; i < dtrace_nprobes; i++) {
+ if ((probe = dtrace_probes[i]) == NULL)
+ continue;
+
+ if (probe->dtpr_provider != old)
+ continue;
+
+ if (probe->dtpr_ecb == NULL)
+ continue;
+
+ /*
+ * We have at least one ECB; we can't remove this provider.
+ */
+ if (!self) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+ }
+ return (EBUSY);
+ }
+
+ /*
+ * All of the probes for this provider are disabled; we can safely
+ * remove all of them from their hash chains and from the probe array.
+ */
+ for (i = 0; i < dtrace_nprobes; i++) {
+ if ((probe = dtrace_probes[i]) == NULL)
+ continue;
+
+ if (probe->dtpr_provider != old)
+ continue;
+
+ dtrace_probes[i] = NULL;
+
+ dtrace_hash_remove(dtrace_bymod, probe);
+ dtrace_hash_remove(dtrace_byfunc, probe);
+ dtrace_hash_remove(dtrace_byname, probe);
+
+ if (first == NULL) {
+ first = probe;
+ probe->dtpr_nextmod = NULL;
+ } else {
+ probe->dtpr_nextmod = first;
+ first = probe;
+ }
+ }
+
+ /*
+ * The provider's probes have been removed from the hash chains and
+ * from the probe array. Now issue a dtrace_sync() to be sure that
+ * everyone has cleared out from any probe array processing.
+ */
+ dtrace_sync();
+
+ for (probe = first; probe != NULL; probe = first) {
+ first = probe->dtpr_nextmod;
+
+ old->dtpv_pops.dtps_destroy(old->dtpv_arg, probe->dtpr_id,
+ probe->dtpr_arg);
+ kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
+ kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
+ kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
+ vmem_free(dtrace_arena, (void *)(uintptr_t)(probe->dtpr_id), 1);
+ kmem_free(probe, sizeof (dtrace_probe_t));
+ }
+
+ if ((prev = dtrace_provider) == old) {
+#ifndef VBOX
+ ASSERT(self || dtrace_devi == NULL);
+ ASSERT(old->dtpv_next == NULL || dtrace_devi == NULL);
+#endif
+ dtrace_provider = old->dtpv_next;
+ } else {
+ while (prev != NULL && prev->dtpv_next != old)
+ prev = prev->dtpv_next;
+
+ if (prev == NULL) {
+ panic("attempt to unregister non-existent "
+ "dtrace provider %p\n", (void *)id);
+ }
+
+ prev->dtpv_next = old->dtpv_next;
+ }
+
+ if (!self) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+ }
+
+ kmem_free(old->dtpv_name, strlen(old->dtpv_name) + 1);
+ kmem_free(old, sizeof (dtrace_provider_t));
+
+ return (0);
+}
+
+/*
+ * Invalidate the specified provider. All subsequent probe lookups for the
+ * specified provider will fail, but its probes will not be removed.
+ */
+void
+dtrace_invalidate(dtrace_provider_id_t id)
+{
+ dtrace_provider_t *pvp = (dtrace_provider_t *)id;
+
+ ASSERT(pvp->dtpv_pops.dtps_enable !=
+ (int (*)(void *, dtrace_id_t, void *))(uintptr_t)dtrace_enable_nullop);
+
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&dtrace_lock);
+
+ pvp->dtpv_defunct = 1;
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_provider_lock);
+}
+
+/*
+ * Indicate whether or not DTrace has attached.
+ */
+int
+dtrace_attached(void)
+{
+ /*
+ * dtrace_provider will be non-NULL iff the DTrace driver has
+ * attached. (It's non-NULL because DTrace is always itself a
+ * provider.)
+ */
+ return (dtrace_provider != NULL);
+}
+
+/*
+ * Remove all the unenabled probes for the given provider. This function is
+ * not unlike dtrace_unregister(), except that it doesn't remove the provider
+ * -- just as many of its associated probes as it can.
+ */
+int
+dtrace_condense(dtrace_provider_id_t id)
+{
+ dtrace_provider_t *prov = (dtrace_provider_t *)id;
+ VBDTTYPE(uint32_t,int) i;
+ dtrace_probe_t *probe;
+
+ /*
+ * Make sure this isn't the dtrace provider itself.
+ */
+ ASSERT(prov->dtpv_pops.dtps_enable !=
+ (int (*)(void *, dtrace_id_t, void *))(uintptr_t)dtrace_enable_nullop);
+
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&dtrace_lock);
+
+ /*
+ * Attempt to destroy the probes associated with this provider.
+ */
+ for (i = 0; i < dtrace_nprobes; i++) {
+ if ((probe = dtrace_probes[i]) == NULL)
+ continue;
+
+ if (probe->dtpr_provider != prov)
+ continue;
+
+ if (probe->dtpr_ecb != NULL)
+ continue;
+
+ dtrace_probes[i] = NULL;
+
+ dtrace_hash_remove(dtrace_bymod, probe);
+ dtrace_hash_remove(dtrace_byfunc, probe);
+ dtrace_hash_remove(dtrace_byname, probe);
+
+ prov->dtpv_pops.dtps_destroy(prov->dtpv_arg, i + 1,
+ probe->dtpr_arg);
+ kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
+ kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
+ kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
+ kmem_free(probe, sizeof (dtrace_probe_t));
+ vmem_free(dtrace_arena, (void *)((uintptr_t)i + 1), 1);
+ }
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_provider_lock);
+
+ return (0);
+}
+
+/*
+ * DTrace Probe Management Functions
+ *
+ * The functions in this section perform the DTrace probe management,
+ * including functions to create probes, look-up probes, and call into the
+ * providers to request that probes be provided. Some of these functions are
+ * in the Provider-to-Framework API; these functions can be identified by the
+ * fact that they are not declared "static".
+ */
+
+/*
+ * Create a probe with the specified module name, function name, and name.
+ */
+dtrace_id_t
+dtrace_probe_create(dtrace_provider_id_t prov, const char *mod,
+ const char *func, const char *name, int aframes, void *arg)
+{
+ dtrace_probe_t *probe, **probes;
+ dtrace_provider_t *provider = (dtrace_provider_t *)prov;
+ dtrace_id_t id;
+
+ if (provider == dtrace_provider) {
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ } else {
+ mutex_enter(&dtrace_lock);
+ }
+
+ id = (dtrace_id_t)(uintptr_t)vmem_alloc(dtrace_arena, 1,
+ VM_BESTFIT | VM_SLEEP);
+ probe = kmem_zalloc(sizeof (dtrace_probe_t), KM_SLEEP);
+
+ probe->dtpr_id = id;
+ probe->dtpr_gen = dtrace_probegen++;
+ probe->dtpr_mod = dtrace_strdup(mod);
+ probe->dtpr_func = dtrace_strdup(func);
+ probe->dtpr_name = dtrace_strdup(name);
+ probe->dtpr_arg = arg;
+ probe->dtpr_aframes = aframes;
+ probe->dtpr_provider = provider;
+
+ dtrace_hash_add(dtrace_bymod, probe);
+ dtrace_hash_add(dtrace_byfunc, probe);
+ dtrace_hash_add(dtrace_byname, probe);
+
+ if (id - 1 >= dtrace_nprobes) {
+ size_t osize = dtrace_nprobes * sizeof (dtrace_probe_t *);
+ size_t nsize = osize << 1;
+
+ if (nsize == 0) {
+ ASSERT(osize == 0);
+ ASSERT(dtrace_probes == NULL);
+ nsize = sizeof (dtrace_probe_t *);
+ }
+
+ probes = kmem_zalloc(nsize, KM_SLEEP);
+
+ if (dtrace_probes == NULL) {
+ ASSERT(osize == 0);
+ dtrace_probes = probes;
+ dtrace_nprobes = 1;
+ } else {
+ dtrace_probe_t **oprobes = dtrace_probes;
+
+ bcopy(oprobes, probes, osize);
+ dtrace_membar_producer();
+ dtrace_probes = probes;
+
+ dtrace_sync();
+
+ /*
+ * All CPUs are now seeing the new probes array; we can
+ * safely free the old array.
+ */
+ kmem_free(oprobes, osize);
+ dtrace_nprobes <<= 1;
+ }
+
+ ASSERT(id - 1 < dtrace_nprobes);
+ }
+
+ ASSERT(dtrace_probes[id - 1] == NULL);
+ dtrace_probes[id - 1] = probe;
+
+ if (provider != dtrace_provider)
+ mutex_exit(&dtrace_lock);
+
+ return (id);
+}
+
+static dtrace_probe_t *
+dtrace_probe_lookup_id(dtrace_id_t id)
+{
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (id == 0 || id > dtrace_nprobes)
+ return (NULL);
+
+ return (dtrace_probes[id - 1]);
+}
+
+static int
+dtrace_probe_lookup_match(dtrace_probe_t *probe, void *arg)
+{
+ *((dtrace_id_t *)arg) = probe->dtpr_id;
+
+ return (DTRACE_MATCH_DONE);
+}
+
+/*
+ * Look up a probe based on provider and one or more of module name, function
+ * name and probe name.
+ */
+dtrace_id_t
+dtrace_probe_lookup(dtrace_provider_id_t prid, const char *mod,
+ const char *func, const char *name)
+{
+ dtrace_probekey_t pkey;
+ dtrace_id_t id;
+ int match;
+
+ pkey.dtpk_prov = ((dtrace_provider_t *)prid)->dtpv_name;
+ pkey.dtpk_pmatch = &dtrace_match_string;
+ pkey.dtpk_mod = mod;
+ pkey.dtpk_mmatch = mod ? &dtrace_match_string : &dtrace_match_nul;
+ pkey.dtpk_func = func;
+ pkey.dtpk_fmatch = func ? &dtrace_match_string : &dtrace_match_nul;
+ pkey.dtpk_name = name;
+ pkey.dtpk_nmatch = name ? &dtrace_match_string : &dtrace_match_nul;
+ pkey.dtpk_id = DTRACE_IDNONE;
+
+ mutex_enter(&dtrace_lock);
+ match = dtrace_match(&pkey, DTRACE_PRIV_ALL, 0, 0,
+ dtrace_probe_lookup_match, &id);
+ mutex_exit(&dtrace_lock);
+
+ ASSERT(match == 1 || match == 0);
+ return (match ? id : 0);
+}
+
+/*
+ * Returns the probe argument associated with the specified probe.
+ */
+void *
+dtrace_probe_arg(dtrace_provider_id_t id, dtrace_id_t pid)
+{
+ dtrace_probe_t *probe;
+ void *rval = NULL;
+
+ mutex_enter(&dtrace_lock);
+
+ if ((probe = dtrace_probe_lookup_id(pid)) != NULL &&
+ probe->dtpr_provider == (dtrace_provider_t *)id)
+ rval = probe->dtpr_arg;
+
+ mutex_exit(&dtrace_lock);
+
+ return (rval);
+}
+
+/*
+ * Copy a probe into a probe description.
+ */
+static void
+dtrace_probe_description(const dtrace_probe_t *prp, dtrace_probedesc_t *pdp)
+{
+ bzero(pdp, sizeof (dtrace_probedesc_t));
+ pdp->dtpd_id = prp->dtpr_id;
+
+ (void) strncpy(pdp->dtpd_provider,
+ prp->dtpr_provider->dtpv_name, DTRACE_PROVNAMELEN - 1);
+
+ (void) strncpy(pdp->dtpd_mod, prp->dtpr_mod, DTRACE_MODNAMELEN - 1);
+ (void) strncpy(pdp->dtpd_func, prp->dtpr_func, DTRACE_FUNCNAMELEN - 1);
+ (void) strncpy(pdp->dtpd_name, prp->dtpr_name, DTRACE_NAMELEN - 1);
+}
+
+/*
+ * Called to indicate that a probe -- or probes -- should be provided by a
+ * specfied provider. If the specified description is NULL, the provider will
+ * be told to provide all of its probes. (This is done whenever a new
+ * consumer comes along, or whenever a retained enabling is to be matched.) If
+ * the specified description is non-NULL, the provider is given the
+ * opportunity to dynamically provide the specified probe, allowing providers
+ * to support the creation of probes on-the-fly. (So-called _autocreated_
+ * probes.) If the provider is NULL, the operations will be applied to all
+ * providers; if the provider is non-NULL the operations will only be applied
+ * to the specified provider. The dtrace_provider_lock must be held, and the
+ * dtrace_lock must _not_ be held -- the provider's dtps_provide() operation
+ * will need to grab the dtrace_lock when it reenters the framework through
+ * dtrace_probe_lookup(), dtrace_probe_create(), etc.
+ */
+static void
+dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv)
+{
+#ifndef VBOX
+ struct modctl *ctl;
+#endif
+ int all = 0;
+
+ ASSERT(MUTEX_HELD(&dtrace_provider_lock));
+
+ if (prv == NULL) {
+ all = 1;
+ prv = dtrace_provider;
+ }
+
+ do {
+ /*
+ * First, call the blanket provide operation.
+ */
+ prv->dtpv_pops.dtps_provide(prv->dtpv_arg, desc);
+
+#ifndef VBOX
+ /*
+ * Now call the per-module provide operation. We will grab
+ * mod_lock to prevent the list from being modified. Note
+ * that this also prevents the mod_busy bits from changing.
+ * (mod_busy can only be changed with mod_lock held.)
+ */
+ mutex_enter(&mod_lock);
+
+ ctl = &modules;
+ do {
+ if (ctl->mod_busy || ctl->mod_mp == NULL)
+ continue;
+
+ prv->dtpv_pops.dtps_provide_module(prv->dtpv_arg, ctl);
+
+ } while ((ctl = ctl->mod_next) != &modules);
+
+ mutex_exit(&mod_lock);
+#endif
+ } while (all && (prv = prv->dtpv_next) != NULL);
+}
+
+#ifndef VBOX
+/*
+ * Iterate over each probe, and call the Framework-to-Provider API function
+ * denoted by offs.
+ */
+static void
+dtrace_probe_foreach(uintptr_t offs)
+{
+ dtrace_provider_t *prov;
+ void (*func)(void *, dtrace_id_t, void *);
+ dtrace_probe_t *probe;
+ dtrace_icookie_t cookie;
+ VBDTTYPE(uint32_t,int) i;
+
+ /*
+ * We disable interrupts to walk through the probe array. This is
+ * safe -- the dtrace_sync() in dtrace_unregister() assures that we
+ * won't see stale data.
+ */
+ cookie = dtrace_interrupt_disable();
+
+ for (i = 0; i < dtrace_nprobes; i++) {
+ if ((probe = dtrace_probes[i]) == NULL)
+ continue;
+
+ if (probe->dtpr_ecb == NULL) {
+ /*
+ * This probe isn't enabled -- don't call the function.
+ */
+ continue;
+ }
+
+ prov = probe->dtpr_provider;
+ func = *((void(**)(void *, dtrace_id_t, void *))
+ ((uintptr_t)&prov->dtpv_pops + offs));
+
+ func(prov->dtpv_arg, i + 1, probe->dtpr_arg);
+ }
+
+ dtrace_interrupt_enable(cookie);
+}
+#endif /* !VBOX */
+
+static int
+dtrace_probe_enable(const dtrace_probedesc_t *desc, dtrace_enabling_t *enab)
+{
+ dtrace_probekey_t pkey;
+ uint32_t priv;
+ uid_t uid;
+ zoneid_t zoneid;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ dtrace_ecb_create_cache = NULL;
+
+ if (desc == NULL) {
+ /*
+ * If we're passed a NULL description, we're being asked to
+ * create an ECB with a NULL probe.
+ */
+ (void) dtrace_ecb_create_enable(NULL, enab);
+ return (0);
+ }
+
+ dtrace_probekey(desc, &pkey);
+ dtrace_cred2priv(enab->dten_vstate->dtvs_state->dts_cred.dcr_cred,
+ &priv, &uid, &zoneid);
+
+ return (dtrace_match(&pkey, priv, uid, zoneid, dtrace_ecb_create_enable,
+ enab));
+}
+
+/*
+ * DTrace Helper Provider Functions
+ */
+static void
+dtrace_dofattr2attr(dtrace_attribute_t *attr, const dof_attr_t dofattr)
+{
+ attr->dtat_name = DOF_ATTR_NAME(dofattr);
+ attr->dtat_data = DOF_ATTR_DATA(dofattr);
+ attr->dtat_class = DOF_ATTR_CLASS(dofattr);
+}
+
+static void
+dtrace_dofprov2hprov(dtrace_helper_provdesc_t *hprov,
+ const dof_provider_t *dofprov, char *strtab)
+{
+ hprov->dthpv_provname = strtab + dofprov->dofpv_name;
+ dtrace_dofattr2attr(&hprov->dthpv_pattr.dtpa_provider,
+ dofprov->dofpv_provattr);
+ dtrace_dofattr2attr(&hprov->dthpv_pattr.dtpa_mod,
+ dofprov->dofpv_modattr);
+ dtrace_dofattr2attr(&hprov->dthpv_pattr.dtpa_func,
+ dofprov->dofpv_funcattr);
+ dtrace_dofattr2attr(&hprov->dthpv_pattr.dtpa_name,
+ dofprov->dofpv_nameattr);
+ dtrace_dofattr2attr(&hprov->dthpv_pattr.dtpa_args,
+ dofprov->dofpv_argsattr);
+}
+
+static void
+dtrace_helper_provide_one(dof_helper_t *dhp, dof_sec_t *sec, pid_t pid)
+{
+ uintptr_t daddr = (uintptr_t)dhp->dofhp_dof;
+ dof_hdr_t *dof = (dof_hdr_t *)daddr;
+ dof_sec_t *str_sec, *prb_sec, *arg_sec, *off_sec, *enoff_sec;
+ dof_provider_t *provider;
+ dof_probe_t *probe;
+ uint32_t *off, *enoff;
+ uint8_t *arg;
+ char *strtab;
+ uint_t i, nprobes;
+ dtrace_helper_provdesc_t dhpv;
+ dtrace_helper_probedesc_t dhpb;
+ dtrace_meta_t *meta = dtrace_meta_pid;
+ dtrace_mops_t *mops = &meta->dtm_mops;
+ void *parg;
+
+ provider = (dof_provider_t *)(uintptr_t)(daddr + sec->dofs_offset);
+ str_sec = (dof_sec_t *)(uintptr_t)(daddr + dof->dofh_secoff +
+ provider->dofpv_strtab * dof->dofh_secsize);
+ prb_sec = (dof_sec_t *)(uintptr_t)(daddr + dof->dofh_secoff +
+ provider->dofpv_probes * dof->dofh_secsize);
+ arg_sec = (dof_sec_t *)(uintptr_t)(daddr + dof->dofh_secoff +
+ provider->dofpv_prargs * dof->dofh_secsize);
+ off_sec = (dof_sec_t *)(uintptr_t)(daddr + dof->dofh_secoff +
+ provider->dofpv_proffs * dof->dofh_secsize);
+
+ strtab = (char *)(uintptr_t)(daddr + str_sec->dofs_offset);
+ off = (uint32_t *)(uintptr_t)(daddr + off_sec->dofs_offset);
+ arg = (uint8_t *)(uintptr_t)(daddr + arg_sec->dofs_offset);
+ enoff = NULL;
+
+ /*
+ * See dtrace_helper_provider_validate().
+ */
+ if (dof->dofh_ident[DOF_ID_VERSION] != DOF_VERSION_1 &&
+ provider->dofpv_prenoffs != DOF_SECT_NONE) {
+ enoff_sec = (dof_sec_t *)(uintptr_t)(daddr + dof->dofh_secoff +
+ provider->dofpv_prenoffs * dof->dofh_secsize);
+ enoff = (uint32_t *)(uintptr_t)(daddr + enoff_sec->dofs_offset);
+ }
+
+ nprobes = prb_sec->dofs_size / prb_sec->dofs_entsize;
+
+ /*
+ * Create the provider.
+ */
+ dtrace_dofprov2hprov(&dhpv, provider, strtab);
+
+ if ((parg = mops->dtms_provide_pid(meta->dtm_arg, &dhpv, pid)) == NULL)
+ return;
+
+ meta->dtm_count++;
+
+ /*
+ * Create the probes.
+ */
+ for (i = 0; i < nprobes; i++) {
+ probe = (dof_probe_t *)(uintptr_t)(daddr +
+ prb_sec->dofs_offset + i * prb_sec->dofs_entsize);
+
+ dhpb.dthpb_mod = dhp->dofhp_mod;
+ dhpb.dthpb_func = strtab + probe->dofpr_func;
+ dhpb.dthpb_name = strtab + probe->dofpr_name;
+ dhpb.dthpb_base = probe->dofpr_addr;
+ dhpb.dthpb_offs = off + probe->dofpr_offidx;
+ dhpb.dthpb_noffs = probe->dofpr_noffs;
+ if (enoff != NULL) {
+ dhpb.dthpb_enoffs = enoff + probe->dofpr_enoffidx;
+ dhpb.dthpb_nenoffs = probe->dofpr_nenoffs;
+ } else {
+ dhpb.dthpb_enoffs = NULL;
+ dhpb.dthpb_nenoffs = 0;
+ }
+ dhpb.dthpb_args = arg + probe->dofpr_argidx;
+ dhpb.dthpb_nargc = probe->dofpr_nargc;
+ dhpb.dthpb_xargc = probe->dofpr_xargc;
+ dhpb.dthpb_ntypes = strtab + probe->dofpr_nargv;
+ dhpb.dthpb_xtypes = strtab + probe->dofpr_xargv;
+
+ mops->dtms_create_probe(meta->dtm_arg, parg, &dhpb);
+ }
+}
+
+static void
+dtrace_helper_provide(dof_helper_t *dhp, pid_t pid)
+{
+ uintptr_t daddr = (uintptr_t)dhp->dofhp_dof;
+ dof_hdr_t *dof = (dof_hdr_t *)daddr;
+ VBDTTYPE(uint32_t,int) i;
+
+ ASSERT(MUTEX_HELD(&dtrace_meta_lock));
+
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)(uintptr_t)(daddr +
+ dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (sec->dofs_type != DOF_SECT_PROVIDER)
+ continue;
+
+ dtrace_helper_provide_one(dhp, sec, pid);
+ }
+
+ /*
+ * We may have just created probes, so we must now rematch against
+ * any retained enablings. Note that this call will acquire both
+ * cpu_lock and dtrace_lock; the fact that we are holding
+ * dtrace_meta_lock now is what defines the ordering with respect to
+ * these three locks.
+ */
+ dtrace_enabling_matchall();
+}
+
+#ifndef VBOX
+
+static void
+dtrace_helper_provider_remove_one(dof_helper_t *dhp, dof_sec_t *sec, pid_t pid)
+{
+ uintptr_t daddr = (uintptr_t)dhp->dofhp_dof;
+ dof_hdr_t *dof = (dof_hdr_t *)daddr;
+ dof_sec_t *str_sec;
+ dof_provider_t *provider;
+ char *strtab;
+ dtrace_helper_provdesc_t dhpv;
+ dtrace_meta_t *meta = dtrace_meta_pid;
+ dtrace_mops_t *mops = &meta->dtm_mops;
+
+ provider = (dof_provider_t *)(uintptr_t)(daddr + sec->dofs_offset);
+ str_sec = (dof_sec_t *)(uintptr_t)(daddr + dof->dofh_secoff +
+ provider->dofpv_strtab * dof->dofh_secsize);
+
+ strtab = (char *)(uintptr_t)(daddr + str_sec->dofs_offset);
+
+ /*
+ * Create the provider.
+ */
+ dtrace_dofprov2hprov(&dhpv, provider, strtab);
+
+ mops->dtms_remove_pid(meta->dtm_arg, &dhpv, pid);
+
+ meta->dtm_count--;
+}
+
+static void
+dtrace_helper_provider_remove(dof_helper_t *dhp, pid_t pid)
+{
+ uintptr_t daddr = (uintptr_t)dhp->dofhp_dof;
+ dof_hdr_t *dof = (dof_hdr_t *)daddr;
+ VBDTTYPE(uint32_t,int) i;
+
+ ASSERT(MUTEX_HELD(&dtrace_meta_lock));
+
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)(uintptr_t)(daddr +
+ dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (sec->dofs_type != DOF_SECT_PROVIDER)
+ continue;
+
+ dtrace_helper_provider_remove_one(dhp, sec, pid);
+ }
+}
+
+#endif /* !VBOX */
+
+/*
+ * DTrace Meta Provider-to-Framework API Functions
+ *
+ * These functions implement the Meta Provider-to-Framework API, as described
+ * in <sys/dtrace.h>.
+ */
+int
+dtrace_meta_register(const char *name, const dtrace_mops_t *mops, void *arg,
+ dtrace_meta_provider_id_t *idp)
+{
+ dtrace_meta_t *meta;
+ dtrace_helpers_t *help, *next;
+ VBDTTYPE(uint32_t,int) i;
+
+ *idp = DTRACE_METAPROVNONE;
+
+ /*
+ * We strictly don't need the name, but we hold onto it for
+ * debuggability. All hail error queues!
+ */
+ if (name == NULL) {
+ cmn_err(CE_WARN, "failed to register meta-provider: "
+ "invalid name");
+ return (EINVAL);
+ }
+
+ if (mops == NULL ||
+ mops->dtms_create_probe == NULL ||
+ mops->dtms_provide_pid == NULL ||
+ mops->dtms_remove_pid == NULL) {
+ cmn_err(CE_WARN, "failed to register meta-register %s: "
+ "invalid ops", name);
+ return (EINVAL);
+ }
+
+ meta = kmem_zalloc(sizeof (dtrace_meta_t), KM_SLEEP);
+ meta->dtm_mops = *mops;
+ meta->dtm_name = kmem_alloc(strlen(name) + 1, KM_SLEEP);
+ (void) strcpy(meta->dtm_name, name);
+ meta->dtm_arg = arg;
+
+ mutex_enter(&dtrace_meta_lock);
+ mutex_enter(&dtrace_lock);
+
+ if (dtrace_meta_pid != NULL) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_meta_lock);
+ cmn_err(CE_WARN, "failed to register meta-register %s: "
+ "user-land meta-provider exists", name);
+ kmem_free(meta->dtm_name, strlen(meta->dtm_name) + 1);
+ kmem_free(meta, sizeof (dtrace_meta_t));
+ return (EINVAL);
+ }
+
+ dtrace_meta_pid = meta;
+ *idp = (dtrace_meta_provider_id_t)meta;
+
+ /*
+ * If there are providers and probes ready to go, pass them
+ * off to the new meta provider now.
+ */
+
+ help = dtrace_deferred_pid;
+ dtrace_deferred_pid = NULL;
+
+ mutex_exit(&dtrace_lock);
+
+ while (help != NULL) {
+ for (i = 0; i < help->dthps_nprovs; i++) {
+ dtrace_helper_provide(&help->dthps_provs[i]->dthp_prov,
+ help->dthps_pid);
+ }
+
+ next = help->dthps_next;
+ help->dthps_next = NULL;
+ help->dthps_prev = NULL;
+ help->dthps_deferred = 0;
+ help = next;
+ }
+
+ mutex_exit(&dtrace_meta_lock);
+
+ return (0);
+}
+
+int
+dtrace_meta_unregister(dtrace_meta_provider_id_t id)
+{
+ dtrace_meta_t **pp, *old = (dtrace_meta_t *)id;
+
+ mutex_enter(&dtrace_meta_lock);
+ mutex_enter(&dtrace_lock);
+
+ if (old == dtrace_meta_pid) {
+ pp = &dtrace_meta_pid;
+ } else {
+ panic("attempt to unregister non-existent "
+ "dtrace meta-provider %p\n", (void *)old);
+#ifdef VBOX
+ return EINVAL;
+#endif
+ }
+
+ if (old->dtm_count != 0) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_meta_lock);
+ return (EBUSY);
+ }
+
+ *pp = NULL;
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_meta_lock);
+
+ kmem_free(old->dtm_name, strlen(old->dtm_name) + 1);
+ kmem_free(old, sizeof (dtrace_meta_t));
+
+ return (0);
+}
+
+
+/*
+ * DTrace DIF Object Functions
+ */
+static int
+dtrace_difo_err(uint_t pc, const char *format, ...)
+{
+ if (dtrace_err_verbose) {
+ va_list alist;
+
+ (void) uprintf("dtrace DIF object error: [%u]: ", pc);
+ va_start(alist, format);
+ (void) vuprintf(format, alist);
+ va_end(alist);
+ }
+
+#ifdef DTRACE_ERRDEBUG
+ dtrace_errdebug(format);
+#endif
+ return (1);
+}
+
+/*
+ * Validate a DTrace DIF object by checking the IR instructions. The following
+ * rules are currently enforced by dtrace_difo_validate():
+ *
+ * 1. Each instruction must have a valid opcode
+ * 2. Each register, string, variable, or subroutine reference must be valid
+ * 3. No instruction can modify register %r0 (must be zero)
+ * 4. All instruction reserved bits must be set to zero
+ * 5. The last instruction must be a "ret" instruction
+ * 6. All branch targets must reference a valid instruction _after_ the branch
+ */
+static int
+dtrace_difo_validate(dtrace_difo_t *dp, dtrace_vstate_t *vstate, uint_t nregs,
+ cred_t *cr)
+{
+#ifndef VBOX
+ int err = 0, i;
+#else
+ int err = 0;
+ uint_t i;
+#endif
+ int (*efunc)(uint_t pc, const char *, ...) = dtrace_difo_err;
+ int kcheckload;
+ uint_t pc;
+
+ kcheckload = cr == NULL ||
+ (vstate->dtvs_state->dts_cred.dcr_visible & DTRACE_CRV_KERNEL) == 0;
+
+ dp->dtdo_destructive = 0;
+
+ for (pc = 0; pc < dp->dtdo_len && err == 0; pc++) {
+ dif_instr_t instr = dp->dtdo_buf[pc];
+
+ uint_t r1 = DIF_INSTR_R1(instr);
+ uint_t r2 = DIF_INSTR_R2(instr);
+ uint_t rd = DIF_INSTR_RD(instr);
+ uint_t rs = DIF_INSTR_RS(instr);
+ uint_t label = DIF_INSTR_LABEL(instr);
+ uint_t v = DIF_INSTR_VAR(instr);
+ uint_t subr = DIF_INSTR_SUBR(instr);
+ uint_t type = DIF_INSTR_TYPE(instr);
+ uint_t op = DIF_INSTR_OP(instr);
+
+ switch (op) {
+ case DIF_OP_OR:
+ case DIF_OP_XOR:
+ case DIF_OP_AND:
+ case DIF_OP_SLL:
+ case DIF_OP_SRL:
+ case DIF_OP_SRA:
+ case DIF_OP_SUB:
+ case DIF_OP_ADD:
+ case DIF_OP_MUL:
+ case DIF_OP_SDIV:
+ case DIF_OP_UDIV:
+ case DIF_OP_SREM:
+ case DIF_OP_UREM:
+ case DIF_OP_COPYS:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r2);
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_NOT:
+ case DIF_OP_MOV:
+ case DIF_OP_ALLOCS:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_LDSB:
+ case DIF_OP_LDSH:
+ case DIF_OP_LDSW:
+ case DIF_OP_LDUB:
+ case DIF_OP_LDUH:
+ case DIF_OP_LDUW:
+ case DIF_OP_LDX:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ if (kcheckload)
+ dp->dtdo_buf[pc] = DIF_INSTR_LOAD(op +
+ DIF_OP_RLDSB - DIF_OP_LDSB, r1, rd);
+ break;
+ case DIF_OP_RLDSB:
+ case DIF_OP_RLDSH:
+ case DIF_OP_RLDSW:
+ case DIF_OP_RLDUB:
+ case DIF_OP_RLDUH:
+ case DIF_OP_RLDUW:
+ case DIF_OP_RLDX:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_ULDSB:
+ case DIF_OP_ULDSH:
+ case DIF_OP_ULDSW:
+ case DIF_OP_ULDUB:
+ case DIF_OP_ULDUH:
+ case DIF_OP_ULDUW:
+ case DIF_OP_ULDX:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_STB:
+ case DIF_OP_STH:
+ case DIF_OP_STW:
+ case DIF_OP_STX:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to 0 address\n");
+ break;
+ case DIF_OP_CMP:
+ case DIF_OP_SCMP:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r2);
+ if (rd != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ break;
+ case DIF_OP_TST:
+ if (r1 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r1);
+ if (r2 != 0 || rd != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ break;
+ case DIF_OP_BA:
+ case DIF_OP_BE:
+ case DIF_OP_BNE:
+ case DIF_OP_BG:
+ case DIF_OP_BGU:
+ case DIF_OP_BGE:
+ case DIF_OP_BGEU:
+ case DIF_OP_BL:
+ case DIF_OP_BLU:
+ case DIF_OP_BLE:
+ case DIF_OP_BLEU:
+ if (label >= dp->dtdo_len) {
+ err += efunc(pc, "invalid branch target %u\n",
+ label);
+ }
+ if (label <= pc) {
+ err += efunc(pc, "backward branch to %u\n",
+ label);
+ }
+ break;
+ case DIF_OP_RET:
+ if (r1 != 0 || r2 != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ break;
+ case DIF_OP_NOP:
+ case DIF_OP_POPTS:
+ case DIF_OP_FLUSHTS:
+ if (r1 != 0 || r2 != 0 || rd != 0)
+ err += efunc(pc, "non-zero reserved bits\n");
+ break;
+ case DIF_OP_SETX:
+ if (DIF_INSTR_INTEGER(instr) >= dp->dtdo_intlen) {
+ err += efunc(pc, "invalid integer ref %u\n",
+ DIF_INSTR_INTEGER(instr));
+ }
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_SETS:
+ if (DIF_INSTR_STRING(instr) >= dp->dtdo_strlen) {
+ err += efunc(pc, "invalid string ref %u\n",
+ DIF_INSTR_STRING(instr));
+ }
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_LDGA:
+ case DIF_OP_LDTA:
+ if (r1 > DIF_VAR_ARRAY_MAX)
+ err += efunc(pc, "invalid array %u\n", r1);
+ if (r2 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r2);
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_LDGS:
+ case DIF_OP_LDTS:
+ case DIF_OP_LDLS:
+ case DIF_OP_LDGAA:
+ case DIF_OP_LDTAA:
+ if (v < DIF_VAR_OTHER_MIN || v > DIF_VAR_OTHER_MAX)
+ err += efunc(pc, "invalid variable %u\n", v);
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+ break;
+ case DIF_OP_STGS:
+ case DIF_OP_STTS:
+ case DIF_OP_STLS:
+ case DIF_OP_STGAA:
+ case DIF_OP_STTAA:
+ if (v < DIF_VAR_OTHER_UBASE || v > DIF_VAR_OTHER_MAX)
+ err += efunc(pc, "invalid variable %u\n", v);
+ if (rs >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ break;
+ case DIF_OP_CALL:
+ if (subr > DIF_SUBR_MAX)
+ err += efunc(pc, "invalid subr %u\n", subr);
+ if (rd >= nregs)
+ err += efunc(pc, "invalid register %u\n", rd);
+ if (rd == 0)
+ err += efunc(pc, "cannot write to %r0\n");
+
+ if (subr == DIF_SUBR_COPYOUT ||
+ subr == DIF_SUBR_COPYOUTSTR) {
+ dp->dtdo_destructive = 1;
+ }
+ break;
+ case DIF_OP_PUSHTR:
+ if (type != DIF_TYPE_STRING && type != DIF_TYPE_CTF)
+ err += efunc(pc, "invalid ref type %u\n", type);
+ if (r2 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r2);
+ if (rs >= nregs)
+ err += efunc(pc, "invalid register %u\n", rs);
+ break;
+ case DIF_OP_PUSHTV:
+ if (type != DIF_TYPE_CTF)
+ err += efunc(pc, "invalid val type %u\n", type);
+ if (r2 >= nregs)
+ err += efunc(pc, "invalid register %u\n", r2);
+ if (rs >= nregs)
+ err += efunc(pc, "invalid register %u\n", rs);
+ break;
+ default:
+ err += efunc(pc, "invalid opcode %u\n",
+ DIF_INSTR_OP(instr));
+ }
+ }
+
+ if (dp->dtdo_len != 0 &&
+ DIF_INSTR_OP(dp->dtdo_buf[dp->dtdo_len - 1]) != DIF_OP_RET) {
+ err += efunc(dp->dtdo_len - 1,
+ "expected 'ret' as last DIF instruction\n");
+ }
+
+ if (!(dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF)) {
+ /*
+ * If we're not returning by reference, the size must be either
+ * 0 or the size of one of the base types.
+ */
+ switch (dp->dtdo_rtype.dtdt_size) {
+ case 0:
+ case sizeof (uint8_t):
+ case sizeof (uint16_t):
+ case sizeof (uint32_t):
+ case sizeof (uint64_t):
+ break;
+
+ default:
+ err += efunc(dp->dtdo_len - 1, "bad return size\n");
+ }
+ }
+
+ for (i = 0; i < dp->dtdo_varlen && err == 0; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i], *existing = NULL;
+ dtrace_diftype_t *vt, *et;
+ uint_t id, ndx;
+
+ if (v->dtdv_scope != DIFV_SCOPE_GLOBAL &&
+ v->dtdv_scope != DIFV_SCOPE_THREAD &&
+ v->dtdv_scope != DIFV_SCOPE_LOCAL) {
+ err += efunc(i, "unrecognized variable scope %d\n",
+ v->dtdv_scope);
+ break;
+ }
+
+ if (v->dtdv_kind != DIFV_KIND_ARRAY &&
+ v->dtdv_kind != DIFV_KIND_SCALAR) {
+ err += efunc(i, "unrecognized variable type %d\n",
+ v->dtdv_kind);
+ break;
+ }
+
+ if ((id = v->dtdv_id) > DIF_VARIABLE_MAX) {
+ err += efunc(i, "%d exceeds variable id limit\n", id);
+ break;
+ }
+
+ if (id < DIF_VAR_OTHER_UBASE)
+ continue;
+
+ /*
+ * For user-defined variables, we need to check that this
+ * definition is identical to any previous definition that we
+ * encountered.
+ */
+ ndx = id - DIF_VAR_OTHER_UBASE;
+
+ switch (v->dtdv_scope) {
+ case DIFV_SCOPE_GLOBAL:
+ if (VBDTCAST(int64_t)ndx < vstate->dtvs_nglobals) {
+ dtrace_statvar_t *svar;
+
+ if ((svar = vstate->dtvs_globals[ndx]) != NULL)
+ existing = &svar->dtsv_var;
+ }
+
+ break;
+
+ case DIFV_SCOPE_THREAD:
+ if (VBDTCAST(int64_t)ndx < vstate->dtvs_ntlocals)
+ existing = &vstate->dtvs_tlocals[ndx];
+ break;
+
+ case DIFV_SCOPE_LOCAL:
+ if (VBDTCAST(int64_t)ndx < vstate->dtvs_nlocals) {
+ dtrace_statvar_t *svar;
+
+ if ((svar = vstate->dtvs_locals[ndx]) != NULL)
+ existing = &svar->dtsv_var;
+ }
+
+ break;
+ }
+
+ vt = &v->dtdv_type;
+
+ if (vt->dtdt_flags & DIF_TF_BYREF) {
+ if (vt->dtdt_size == 0) {
+ err += efunc(i, "zero-sized variable\n");
+ break;
+ }
+
+ if (v->dtdv_scope == DIFV_SCOPE_GLOBAL &&
+ vt->dtdt_size > dtrace_global_maxsize) {
+ err += efunc(i, "oversized by-ref global\n");
+ break;
+ }
+ }
+
+ if (existing == NULL || existing->dtdv_id == 0)
+ continue;
+
+ ASSERT(existing->dtdv_id == v->dtdv_id);
+ ASSERT(existing->dtdv_scope == v->dtdv_scope);
+
+ if (existing->dtdv_kind != v->dtdv_kind)
+ err += efunc(i, "%d changed variable kind\n", id);
+
+ et = &existing->dtdv_type;
+
+ if (vt->dtdt_flags != et->dtdt_flags) {
+ err += efunc(i, "%d changed variable type flags\n", id);
+ break;
+ }
+
+ if (vt->dtdt_size != 0 && vt->dtdt_size != et->dtdt_size) {
+ err += efunc(i, "%d changed variable type size\n", id);
+ break;
+ }
+ }
+
+ return (err);
+}
+
+#ifndef VBOX
+/*
+ * Validate a DTrace DIF object that it is to be used as a helper. Helpers
+ * are much more constrained than normal DIFOs. Specifically, they may
+ * not:
+ *
+ * 1. Make calls to subroutines other than copyin(), copyinstr() or
+ * miscellaneous string routines
+ * 2. Access DTrace variables other than the args[] array, and the
+ * curthread, pid, ppid, tid, execname, zonename, uid and gid variables.
+ * 3. Have thread-local variables.
+ * 4. Have dynamic variables.
+ */
+static int
+dtrace_difo_validate_helper(dtrace_difo_t *dp)
+{
+ int (*efunc)(uint_t pc, const char *, ...) = dtrace_difo_err;
+ int err = 0;
+ uint_t pc;
+
+ for (pc = 0; pc < dp->dtdo_len; pc++) {
+ dif_instr_t instr = dp->dtdo_buf[pc];
+
+ uint_t v = DIF_INSTR_VAR(instr);
+ uint_t subr = DIF_INSTR_SUBR(instr);
+ uint_t op = DIF_INSTR_OP(instr);
+
+ switch (op) {
+ case DIF_OP_OR:
+ case DIF_OP_XOR:
+ case DIF_OP_AND:
+ case DIF_OP_SLL:
+ case DIF_OP_SRL:
+ case DIF_OP_SRA:
+ case DIF_OP_SUB:
+ case DIF_OP_ADD:
+ case DIF_OP_MUL:
+ case DIF_OP_SDIV:
+ case DIF_OP_UDIV:
+ case DIF_OP_SREM:
+ case DIF_OP_UREM:
+ case DIF_OP_COPYS:
+ case DIF_OP_NOT:
+ case DIF_OP_MOV:
+ case DIF_OP_RLDSB:
+ case DIF_OP_RLDSH:
+ case DIF_OP_RLDSW:
+ case DIF_OP_RLDUB:
+ case DIF_OP_RLDUH:
+ case DIF_OP_RLDUW:
+ case DIF_OP_RLDX:
+ case DIF_OP_ULDSB:
+ case DIF_OP_ULDSH:
+ case DIF_OP_ULDSW:
+ case DIF_OP_ULDUB:
+ case DIF_OP_ULDUH:
+ case DIF_OP_ULDUW:
+ case DIF_OP_ULDX:
+ case DIF_OP_STB:
+ case DIF_OP_STH:
+ case DIF_OP_STW:
+ case DIF_OP_STX:
+ case DIF_OP_ALLOCS:
+ case DIF_OP_CMP:
+ case DIF_OP_SCMP:
+ case DIF_OP_TST:
+ case DIF_OP_BA:
+ case DIF_OP_BE:
+ case DIF_OP_BNE:
+ case DIF_OP_BG:
+ case DIF_OP_BGU:
+ case DIF_OP_BGE:
+ case DIF_OP_BGEU:
+ case DIF_OP_BL:
+ case DIF_OP_BLU:
+ case DIF_OP_BLE:
+ case DIF_OP_BLEU:
+ case DIF_OP_RET:
+ case DIF_OP_NOP:
+ case DIF_OP_POPTS:
+ case DIF_OP_FLUSHTS:
+ case DIF_OP_SETX:
+ case DIF_OP_SETS:
+ case DIF_OP_LDGA:
+ case DIF_OP_LDLS:
+ case DIF_OP_STGS:
+ case DIF_OP_STLS:
+ case DIF_OP_PUSHTR:
+ case DIF_OP_PUSHTV:
+ break;
+
+ case DIF_OP_LDGS:
+ if (v >= DIF_VAR_OTHER_UBASE)
+ break;
+
+ if (v >= DIF_VAR_ARG0 && v <= DIF_VAR_ARG9)
+ break;
+
+ if (v == DIF_VAR_CURTHREAD || v == DIF_VAR_PID ||
+ v == DIF_VAR_PPID || v == DIF_VAR_TID ||
+ v == DIF_VAR_EXECNAME || v == DIF_VAR_ZONENAME ||
+ v == DIF_VAR_UID || v == DIF_VAR_GID)
+ break;
+
+ err += efunc(pc, "illegal variable %u\n", v);
+ break;
+
+ case DIF_OP_LDTA:
+ case DIF_OP_LDTS:
+ case DIF_OP_LDGAA:
+ case DIF_OP_LDTAA:
+ err += efunc(pc, "illegal dynamic variable load\n");
+ break;
+
+ case DIF_OP_STTS:
+ case DIF_OP_STGAA:
+ case DIF_OP_STTAA:
+ err += efunc(pc, "illegal dynamic variable store\n");
+ break;
+
+ case DIF_OP_CALL:
+ if (subr == DIF_SUBR_ALLOCA ||
+ subr == DIF_SUBR_BCOPY ||
+ subr == DIF_SUBR_COPYIN ||
+ subr == DIF_SUBR_COPYINTO ||
+ subr == DIF_SUBR_COPYINSTR ||
+ subr == DIF_SUBR_INDEX ||
+ subr == DIF_SUBR_INET_NTOA ||
+ subr == DIF_SUBR_INET_NTOA6 ||
+ subr == DIF_SUBR_INET_NTOP ||
+ subr == DIF_SUBR_LLTOSTR ||
+ subr == DIF_SUBR_RINDEX ||
+ subr == DIF_SUBR_STRCHR ||
+ subr == DIF_SUBR_STRJOIN ||
+ subr == DIF_SUBR_STRRCHR ||
+ subr == DIF_SUBR_STRSTR ||
+ subr == DIF_SUBR_HTONS ||
+ subr == DIF_SUBR_HTONL ||
+ subr == DIF_SUBR_HTONLL ||
+ subr == DIF_SUBR_NTOHS ||
+ subr == DIF_SUBR_NTOHL ||
+ subr == DIF_SUBR_NTOHLL)
+ break;
+
+ err += efunc(pc, "invalid subr %u\n", subr);
+ break;
+
+ default:
+ err += efunc(pc, "invalid opcode %u\n",
+ DIF_INSTR_OP(instr));
+ }
+ }
+
+ return (err);
+}
+#endif /* !VBOX */
+
+/*
+ * Returns 1 if the expression in the DIF object can be cached on a per-thread
+ * basis; 0 if not.
+ */
+static int
+dtrace_difo_cacheable(dtrace_difo_t *dp)
+{
+ VBDTTYPE(uint_t,int) i;
+
+ if (dp == NULL)
+ return (0);
+
+ for (i = 0; i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+
+ if (v->dtdv_scope != DIFV_SCOPE_GLOBAL)
+ continue;
+
+ switch (v->dtdv_id) {
+ case DIF_VAR_CURTHREAD:
+ case DIF_VAR_PID:
+ case DIF_VAR_TID:
+ case DIF_VAR_EXECNAME:
+ case DIF_VAR_ZONENAME:
+ break;
+
+ default:
+ return (0);
+ }
+ }
+
+ /*
+ * This DIF object may be cacheable. Now we need to look for any
+ * array loading instructions, any memory loading instructions, or
+ * any stores to thread-local variables.
+ */
+ for (i = 0; i < dp->dtdo_len; i++) {
+ uint_t op = DIF_INSTR_OP(dp->dtdo_buf[i]);
+
+ if ((op >= DIF_OP_LDSB && op <= DIF_OP_LDX) ||
+ (op >= DIF_OP_ULDSB && op <= DIF_OP_ULDX) ||
+ (op >= DIF_OP_RLDSB && op <= DIF_OP_RLDX) ||
+ op == DIF_OP_LDGA || op == DIF_OP_STTS)
+ return (0);
+ }
+
+ return (1);
+}
+
+static void
+dtrace_difo_hold(dtrace_difo_t *dp)
+{
+#ifndef VBOX
+ VBDTTYPE(uint_t,int) i;
+#endif
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ dp->dtdo_refcnt++;
+ ASSERT(dp->dtdo_refcnt != 0);
+
+#ifndef VBOX
+ /*
+ * We need to check this DIF object for references to the variable
+ * DIF_VAR_VTIMESTAMP.
+ */
+ for (i = 0; i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+
+ if (v->dtdv_id != DIF_VAR_VTIMESTAMP)
+ continue;
+
+ if (dtrace_vtime_references++ == 0)
+ dtrace_vtime_enable();
+ }
+#endif
+}
+
+/*
+ * This routine calculates the dynamic variable chunksize for a given DIF
+ * object. The calculation is not fool-proof, and can probably be tricked by
+ * malicious DIF -- but it works for all compiler-generated DIF. Because this
+ * calculation is likely imperfect, dtrace_dynvar() is able to gracefully fail
+ * if a dynamic variable size exceeds the chunksize.
+ */
+static void
+dtrace_difo_chunksize(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
+{
+ uint64_t sval VBDTGCC(0);
+ dtrace_key_t tupregs[DIF_DTR_NREGS + 2]; /* +2 for thread and id */
+ const dif_instr_t *text = dp->dtdo_buf;
+ uint_t pc, srd = 0;
+ uint_t ttop = 0;
+ size_t size, ksize;
+ uint_t id, i;
+
+ for (pc = 0; pc < dp->dtdo_len; pc++) {
+ dif_instr_t instr = text[pc];
+ uint_t op = DIF_INSTR_OP(instr);
+ uint_t rd = DIF_INSTR_RD(instr);
+ uint_t r1 = DIF_INSTR_R1(instr);
+ uint_t nkeys = 0;
+ uchar_t scope VBDTGCC(0);
+
+ dtrace_key_t *key = tupregs;
+
+ switch (op) {
+ case DIF_OP_SETX:
+ sval = dp->dtdo_inttab[DIF_INSTR_INTEGER(instr)];
+ srd = rd;
+ continue;
+
+ case DIF_OP_STTS:
+ key = &tupregs[DIF_DTR_NREGS];
+ key[0].dttk_size = 0;
+ key[1].dttk_size = 0;
+ nkeys = 2;
+ scope = DIFV_SCOPE_THREAD;
+ break;
+
+ case DIF_OP_STGAA:
+ case DIF_OP_STTAA:
+ nkeys = ttop;
+
+ if (DIF_INSTR_OP(instr) == DIF_OP_STTAA)
+ key[nkeys++].dttk_size = 0;
+
+ key[nkeys++].dttk_size = 0;
+
+ if (op == DIF_OP_STTAA) {
+ scope = DIFV_SCOPE_THREAD;
+ } else {
+ scope = DIFV_SCOPE_GLOBAL;
+ }
+
+ break;
+
+ case DIF_OP_PUSHTR:
+ if (ttop == DIF_DTR_NREGS)
+ return;
+
+ if ((srd == 0 || sval == 0) && r1 == DIF_TYPE_STRING) {
+ /*
+ * If the register for the size of the "pushtr"
+ * is %r0 (or the value is 0) and the type is
+ * a string, we'll use the system-wide default
+ * string size.
+ */
+ tupregs[ttop++].dttk_size =
+ dtrace_strsize_default;
+ } else {
+ if (srd == 0)
+ return;
+
+ tupregs[ttop++].dttk_size = sval;
+ }
+
+ break;
+
+ case DIF_OP_PUSHTV:
+ if (ttop == DIF_DTR_NREGS)
+ return;
+
+ tupregs[ttop++].dttk_size = 0;
+ break;
+
+ case DIF_OP_FLUSHTS:
+ ttop = 0;
+ break;
+
+ case DIF_OP_POPTS:
+ if (ttop != 0)
+ ttop--;
+ break;
+ }
+
+ sval = 0;
+ srd = 0;
+
+ if (nkeys == 0)
+ continue;
+
+ /*
+ * We have a dynamic variable allocation; calculate its size.
+ */
+ for (ksize = 0, i = 0; i < nkeys; i++)
+ ksize += P2ROUNDUP(key[i].dttk_size, sizeof (uint64_t));
+
+ size = sizeof (dtrace_dynvar_t);
+ size += sizeof (dtrace_key_t) * (nkeys - 1);
+ size += ksize;
+
+ /*
+ * Now we need to determine the size of the stored data.
+ */
+ id = DIF_INSTR_VAR(instr);
+
+ for (i = 0; i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+
+ if (v->dtdv_id == id && v->dtdv_scope == scope) {
+ size += v->dtdv_type.dtdt_size;
+ break;
+ }
+ }
+
+ if (i == dp->dtdo_varlen)
+ return;
+
+ /*
+ * We have the size. If this is larger than the chunk size
+ * for our dynamic variable state, reset the chunk size.
+ */
+ size = P2ROUNDUP(size, sizeof (uint64_t));
+
+ if (size > vstate->dtvs_dynvars.dtds_chunksize)
+ vstate->dtvs_dynvars.dtds_chunksize = size;
+ }
+}
+
+static void
+dtrace_difo_init(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
+{
+#ifndef VBOX
+ int i, oldsvars, osz, nsz, otlocals, ntlocals;
+#else
+ int oldsvars, osz, nsz, otlocals, ntlocals;
+ uint_t i;
+#endif
+ uint_t id;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(dp->dtdo_buf != NULL && dp->dtdo_len != 0);
+
+ for (i = 0; i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+ dtrace_statvar_t *svar, ***svarp;
+ size_t dsize = 0;
+ uint8_t scope = v->dtdv_scope;
+ int *np;
+
+ if ((id = v->dtdv_id) < DIF_VAR_OTHER_UBASE)
+ continue;
+
+ id -= DIF_VAR_OTHER_UBASE;
+
+ switch (scope) {
+ case DIFV_SCOPE_THREAD:
+ while (VBDTCAST(int64_t)id >= (otlocals = vstate->dtvs_ntlocals)) {
+ dtrace_difv_t *tlocals;
+
+ if ((ntlocals = (otlocals << 1)) == 0)
+ ntlocals = 1;
+
+ osz = otlocals * sizeof (dtrace_difv_t);
+ nsz = ntlocals * sizeof (dtrace_difv_t);
+
+ tlocals = kmem_zalloc(nsz, KM_SLEEP);
+
+ if (osz != 0) {
+ bcopy(vstate->dtvs_tlocals,
+ tlocals, osz);
+ kmem_free(vstate->dtvs_tlocals, osz);
+ }
+
+ vstate->dtvs_tlocals = tlocals;
+ vstate->dtvs_ntlocals = ntlocals;
+ }
+
+ vstate->dtvs_tlocals[id] = *v;
+ continue;
+
+ case DIFV_SCOPE_LOCAL:
+ np = &vstate->dtvs_nlocals;
+ svarp = &vstate->dtvs_locals;
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF)
+ dsize = NCPU * (v->dtdv_type.dtdt_size +
+ sizeof (uint64_t));
+ else
+ dsize = NCPU * sizeof (uint64_t);
+
+ break;
+
+ case DIFV_SCOPE_GLOBAL:
+ np = &vstate->dtvs_nglobals;
+ svarp = &vstate->dtvs_globals;
+
+ if (v->dtdv_type.dtdt_flags & DIF_TF_BYREF)
+ dsize = v->dtdv_type.dtdt_size +
+ sizeof (uint64_t);
+
+ break;
+
+ default:
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalMsgFailed(("%d\n", scope));
+#endif
+ }
+
+ while (VBDTCAST(int64_t)id >= (oldsvars = *np)) {
+ dtrace_statvar_t **statics;
+ int newsvars, oldsize, newsize;
+
+ if ((newsvars = (oldsvars << 1)) == 0)
+ newsvars = 1;
+
+ oldsize = oldsvars * sizeof (dtrace_statvar_t *);
+ newsize = newsvars * sizeof (dtrace_statvar_t *);
+
+ statics = kmem_zalloc(newsize, KM_SLEEP);
+
+ if (oldsize != 0) {
+ bcopy(*svarp, statics, oldsize);
+ kmem_free(*svarp, oldsize);
+ }
+
+ *svarp = statics;
+ *np = newsvars;
+ }
+
+ if ((svar = (*svarp)[id]) == NULL) {
+ svar = kmem_zalloc(sizeof (dtrace_statvar_t), KM_SLEEP);
+ svar->dtsv_var = *v;
+
+ if ((svar->dtsv_size = dsize) != 0) {
+ svar->dtsv_data = (uint64_t)(uintptr_t)
+ kmem_zalloc(dsize, KM_SLEEP);
+ }
+
+ (*svarp)[id] = svar;
+ }
+
+ svar->dtsv_refcnt++;
+ }
+
+ dtrace_difo_chunksize(dp, vstate);
+ dtrace_difo_hold(dp);
+}
+
+#ifndef VBOX
+static dtrace_difo_t *
+dtrace_difo_duplicate(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
+{
+ dtrace_difo_t *new;
+ size_t sz;
+
+ ASSERT(dp->dtdo_buf != NULL);
+ ASSERT(dp->dtdo_refcnt != 0);
+
+ new = kmem_zalloc(sizeof (dtrace_difo_t), KM_SLEEP);
+
+ ASSERT(dp->dtdo_buf != NULL);
+ sz = dp->dtdo_len * sizeof (dif_instr_t);
+ new->dtdo_buf = kmem_alloc(sz, KM_SLEEP);
+ bcopy(dp->dtdo_buf, new->dtdo_buf, sz);
+ new->dtdo_len = dp->dtdo_len;
+
+ if (dp->dtdo_strtab != NULL) {
+ ASSERT(dp->dtdo_strlen != 0);
+ new->dtdo_strtab = kmem_alloc(dp->dtdo_strlen, KM_SLEEP);
+ bcopy(dp->dtdo_strtab, new->dtdo_strtab, dp->dtdo_strlen);
+ new->dtdo_strlen = dp->dtdo_strlen;
+ }
+
+ if (dp->dtdo_inttab != NULL) {
+ ASSERT(dp->dtdo_intlen != 0);
+ sz = dp->dtdo_intlen * sizeof (uint64_t);
+ new->dtdo_inttab = kmem_alloc(sz, KM_SLEEP);
+ bcopy(dp->dtdo_inttab, new->dtdo_inttab, sz);
+ new->dtdo_intlen = dp->dtdo_intlen;
+ }
+
+ if (dp->dtdo_vartab != NULL) {
+ ASSERT(dp->dtdo_varlen != 0);
+ sz = dp->dtdo_varlen * sizeof (dtrace_difv_t);
+ new->dtdo_vartab = kmem_alloc(sz, KM_SLEEP);
+ bcopy(dp->dtdo_vartab, new->dtdo_vartab, sz);
+ new->dtdo_varlen = dp->dtdo_varlen;
+ }
+
+ dtrace_difo_init(new, vstate);
+ return (new);
+}
+#endif
+
+static void
+dtrace_difo_destroy(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
+{
+ VBDTTYPE(uint_t,int) i;
+
+ ASSERT(dp->dtdo_refcnt == 0);
+
+ for (i = 0; i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+ dtrace_statvar_t *svar, **svarp;
+ uint_t id;
+ uint8_t scope = v->dtdv_scope;
+ int *np;
+
+ switch (scope) {
+ case DIFV_SCOPE_THREAD:
+ continue;
+
+ case DIFV_SCOPE_LOCAL:
+ np = &vstate->dtvs_nlocals;
+ svarp = vstate->dtvs_locals;
+ break;
+
+ case DIFV_SCOPE_GLOBAL:
+ np = &vstate->dtvs_nglobals;
+ svarp = vstate->dtvs_globals;
+ break;
+
+ default:
+#ifndef VBOX
+ ASSERT(0);
+#else
+ AssertFatalMsgFailed(("%d\n", scope));
+#endif
+ }
+
+ if ((id = v->dtdv_id) < DIF_VAR_OTHER_UBASE)
+ continue;
+
+ id -= DIF_VAR_OTHER_UBASE;
+ ASSERT(VBDTCAST(int64_t)id < *np);
+
+ svar = svarp[id];
+ ASSERT(svar != NULL);
+ ASSERT(svar->dtsv_refcnt > 0);
+
+ if (--svar->dtsv_refcnt > 0)
+ continue;
+
+ if (svar->dtsv_size != 0) {
+ ASSERT(svar->dtsv_data != NULL);
+ kmem_free((void *)(uintptr_t)svar->dtsv_data,
+ svar->dtsv_size);
+ }
+
+ kmem_free(svar, sizeof (dtrace_statvar_t));
+ svarp[id] = NULL;
+ }
+
+ kmem_free(dp->dtdo_buf, dp->dtdo_len * sizeof (dif_instr_t));
+ kmem_free(dp->dtdo_inttab, dp->dtdo_intlen * sizeof (uint64_t));
+ kmem_free(dp->dtdo_strtab, dp->dtdo_strlen);
+ kmem_free(dp->dtdo_vartab, dp->dtdo_varlen * sizeof (dtrace_difv_t));
+
+ kmem_free(dp, sizeof (dtrace_difo_t));
+}
+
+static void
+dtrace_difo_release(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
+{
+#ifndef VBOX
+ VBDTTYPE(uint_t,int) i;
+#endif
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(dp->dtdo_refcnt != 0);
+
+#ifndef VBOX
+ for (i = 0; i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+
+ if (v->dtdv_id != DIF_VAR_VTIMESTAMP)
+ continue;
+
+ ASSERT(dtrace_vtime_references > 0);
+ if (--dtrace_vtime_references == 0)
+ dtrace_vtime_disable();
+ }
+#endif
+
+ if (--dp->dtdo_refcnt == 0)
+ dtrace_difo_destroy(dp, vstate);
+}
+
+/*
+ * DTrace Format Functions
+ */
+static uint16_t
+dtrace_format_add(dtrace_state_t *state, char *str)
+{
+ char *fmt, **new;
+ uint16_t ndx, len = VBDTCAST(uint16_t)strlen(str) + 1;
+
+ fmt = kmem_zalloc(len, KM_SLEEP);
+ bcopy(str, fmt, len);
+
+ for (ndx = 0; ndx < state->dts_nformats; ndx++) {
+ if (state->dts_formats[ndx] == NULL) {
+ state->dts_formats[ndx] = fmt;
+ return (ndx + 1);
+ }
+ }
+
+ if (state->dts_nformats == USHRT_MAX) {
+ /*
+ * This is only likely if a denial-of-service attack is being
+ * attempted. As such, it's okay to fail silently here.
+ */
+ kmem_free(fmt, len);
+ return (0);
+ }
+
+ /*
+ * For simplicity, we always resize the formats array to be exactly the
+ * number of formats.
+ */
+ ndx = state->dts_nformats++;
+ new = kmem_alloc((ndx + 1) * sizeof (char *), KM_SLEEP);
+
+ if (state->dts_formats != NULL) {
+ ASSERT(ndx != 0);
+ bcopy(state->dts_formats, new, ndx * sizeof (char *));
+ kmem_free(state->dts_formats, ndx * sizeof (char *));
+ }
+
+ state->dts_formats = new;
+ state->dts_formats[ndx] = fmt;
+
+ return (ndx + 1);
+}
+
+static void
+dtrace_format_remove(dtrace_state_t *state, uint16_t format)
+{
+ char *fmt;
+
+ ASSERT(state->dts_formats != NULL);
+ ASSERT(format <= state->dts_nformats);
+ ASSERT(state->dts_formats[format - 1] != NULL);
+
+ fmt = state->dts_formats[format - 1];
+ kmem_free(fmt, strlen(fmt) + 1);
+ state->dts_formats[format - 1] = NULL;
+}
+
+static void
+dtrace_format_destroy(dtrace_state_t *state)
+{
+ int i;
+
+ if (state->dts_nformats == 0) {
+ ASSERT(state->dts_formats == NULL);
+ return;
+ }
+
+ ASSERT(state->dts_formats != NULL);
+
+ for (i = 0; i < state->dts_nformats; i++) {
+ char *fmt = state->dts_formats[i];
+
+ if (fmt == NULL)
+ continue;
+
+ kmem_free(fmt, strlen(fmt) + 1);
+ }
+
+ kmem_free(state->dts_formats, state->dts_nformats * sizeof (char *));
+ state->dts_nformats = 0;
+ state->dts_formats = NULL;
+}
+
+/*
+ * DTrace Predicate Functions
+ */
+static dtrace_predicate_t *
+dtrace_predicate_create(dtrace_difo_t *dp)
+{
+ dtrace_predicate_t *pred;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(dp->dtdo_refcnt != 0);
+
+ pred = kmem_zalloc(sizeof (dtrace_predicate_t), KM_SLEEP);
+ pred->dtp_difo = dp;
+ pred->dtp_refcnt = 1;
+
+ if (!dtrace_difo_cacheable(dp))
+ return (pred);
+
+ if (dtrace_predcache_id == DTRACE_CACHEIDNONE) {
+ /*
+ * This is only theoretically possible -- we have had 2^32
+ * cacheable predicates on this machine. We cannot allow any
+ * more predicates to become cacheable: as unlikely as it is,
+ * there may be a thread caching a (now stale) predicate cache
+ * ID. (N.B.: the temptation is being successfully resisted to
+ * have this cmn_err() "Holy shit -- we executed this code!")
+ */
+ return (pred);
+ }
+
+ pred->dtp_cacheid = dtrace_predcache_id++;
+
+ return (pred);
+}
+
+static void
+dtrace_predicate_hold(dtrace_predicate_t *pred)
+{
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(pred->dtp_difo != NULL && pred->dtp_difo->dtdo_refcnt != 0);
+ ASSERT(pred->dtp_refcnt > 0);
+
+ pred->dtp_refcnt++;
+}
+
+static void
+dtrace_predicate_release(dtrace_predicate_t *pred, dtrace_vstate_t *vstate)
+{
+#ifdef VBOX_STRICT
+ dtrace_difo_t *dp = pred->dtp_difo;
+#endif
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(dp != NULL && dp->dtdo_refcnt != 0);
+ ASSERT(pred->dtp_refcnt > 0);
+
+ if (--pred->dtp_refcnt == 0) {
+ dtrace_difo_release(pred->dtp_difo, vstate);
+ kmem_free(pred, sizeof (dtrace_predicate_t));
+ }
+}
+
+/*
+ * DTrace Action Description Functions
+ */
+static dtrace_actdesc_t *
+dtrace_actdesc_create(dtrace_actkind_t kind, uint32_t ntuple,
+ uint64_t uarg, uint64_t arg)
+{
+ dtrace_actdesc_t *act;
+
+ ASSERT(!DTRACEACT_ISPRINTFLIKE(kind) || (arg != NULL &&
+ VBDT_IS_VALID_KRNL_ADDR(arg)) || (arg == NULL && kind == DTRACEACT_PRINTA));
+
+ act = kmem_zalloc(sizeof (dtrace_actdesc_t), KM_SLEEP);
+ act->dtad_kind = kind;
+ act->dtad_ntuple = ntuple;
+ act->dtad_uarg = uarg;
+ act->dtad_arg = arg;
+ act->dtad_refcnt = 1;
+
+ return (act);
+}
+
+static void
+dtrace_actdesc_hold(dtrace_actdesc_t *act)
+{
+ ASSERT(act->dtad_refcnt >= 1);
+ act->dtad_refcnt++;
+}
+
+static void
+dtrace_actdesc_release(dtrace_actdesc_t *act, dtrace_vstate_t *vstate)
+{
+ dtrace_actkind_t kind = act->dtad_kind;
+ dtrace_difo_t *dp;
+
+ ASSERT(act->dtad_refcnt >= 1);
+
+ if (--act->dtad_refcnt != 0)
+ return;
+
+ if ((dp = act->dtad_difo) != NULL)
+ dtrace_difo_release(dp, vstate);
+
+ if (DTRACEACT_ISPRINTFLIKE(kind)) {
+ char *str = (char *)(uintptr_t)act->dtad_arg;
+
+ ASSERT((str != NULL && VBDT_IS_VALID_KRNL_ADDR((uintptr_t)str)) ||
+ (str == NULL && act->dtad_kind == DTRACEACT_PRINTA));
+
+ if (str != NULL)
+ kmem_free(str, strlen(str) + 1);
+ }
+
+ kmem_free(act, sizeof (dtrace_actdesc_t));
+}
+
+/*
+ * DTrace ECB Functions
+ */
+static dtrace_ecb_t *
+dtrace_ecb_add(dtrace_state_t *state, dtrace_probe_t *probe)
+{
+ dtrace_ecb_t *ecb;
+ dtrace_epid_t epid;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ ecb = kmem_zalloc(sizeof (dtrace_ecb_t), KM_SLEEP);
+ ecb->dte_predicate = NULL;
+ ecb->dte_probe = probe;
+
+ /*
+ * The default size is the size of the default action: recording
+ * the epid.
+ */
+ ecb->dte_size = ecb->dte_needed = sizeof (dtrace_epid_t);
+ ecb->dte_alignment = sizeof (dtrace_epid_t);
+
+ epid = state->dts_epid++;
+
+ if (VBDTCAST(int64_t)epid - 1 >= state->dts_necbs) {
+ dtrace_ecb_t **oecbs = state->dts_ecbs, **ecbs;
+ int necbs = state->dts_necbs << 1;
+
+ ASSERT(epid == VBDTCAST(dtrace_epid_t)state->dts_necbs + 1);
+
+ if (necbs == 0) {
+ ASSERT(oecbs == NULL);
+ necbs = 1;
+ }
+
+ ecbs = kmem_zalloc(necbs * sizeof (*ecbs), KM_SLEEP);
+
+ if (oecbs != NULL)
+ bcopy(oecbs, ecbs, state->dts_necbs * sizeof (*ecbs));
+
+ dtrace_membar_producer();
+ state->dts_ecbs = ecbs;
+
+ if (oecbs != NULL) {
+ /*
+ * If this state is active, we must dtrace_sync()
+ * before we can free the old dts_ecbs array: we're
+ * coming in hot, and there may be active ring
+ * buffer processing (which indexes into the dts_ecbs
+ * array) on another CPU.
+ */
+ if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE)
+ dtrace_sync();
+
+ kmem_free(oecbs, state->dts_necbs * sizeof (*ecbs));
+ }
+
+ dtrace_membar_producer();
+ state->dts_necbs = necbs;
+ }
+
+ ecb->dte_state = state;
+
+ ASSERT(state->dts_ecbs[epid - 1] == NULL);
+ dtrace_membar_producer();
+ state->dts_ecbs[(ecb->dte_epid = epid) - 1] = ecb;
+
+ return (ecb);
+}
+
+static int
+dtrace_ecb_enable(dtrace_ecb_t *ecb)
+{
+ dtrace_probe_t *probe = ecb->dte_probe;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(ecb->dte_next == NULL);
+
+ if (probe == NULL) {
+ /*
+ * This is the NULL probe -- there's nothing to do.
+ */
+ return (0);
+ }
+
+ if (probe->dtpr_ecb == NULL) {
+ dtrace_provider_t *prov = probe->dtpr_provider;
+
+ /*
+ * We're the first ECB on this probe.
+ */
+ probe->dtpr_ecb = probe->dtpr_ecb_last = ecb;
+
+ if (ecb->dte_predicate != NULL)
+ probe->dtpr_predcache = ecb->dte_predicate->dtp_cacheid;
+
+ return (prov->dtpv_pops.dtps_enable(prov->dtpv_arg,
+ probe->dtpr_id, probe->dtpr_arg));
+ } else {
+ /*
+ * This probe is already active. Swing the last pointer to
+ * point to the new ECB, and issue a dtrace_sync() to assure
+ * that all CPUs have seen the change.
+ */
+ ASSERT(probe->dtpr_ecb_last != NULL);
+ probe->dtpr_ecb_last->dte_next = ecb;
+ probe->dtpr_ecb_last = ecb;
+ probe->dtpr_predcache = 0;
+
+ dtrace_sync();
+ return (0);
+ }
+}
+
+static void
+dtrace_ecb_resize(dtrace_ecb_t *ecb)
+{
+ uint32_t maxalign = sizeof (dtrace_epid_t);
+ uint32_t align = sizeof (uint8_t), offs, diff;
+ dtrace_action_t *act;
+ int wastuple = 0;
+ uint32_t aggbase = UINT32_MAX;
+ dtrace_state_t *state = ecb->dte_state;
+
+ /*
+ * If we record anything, we always record the epid. (And we always
+ * record it first.)
+ */
+ offs = sizeof (dtrace_epid_t);
+ ecb->dte_size = ecb->dte_needed = sizeof (dtrace_epid_t);
+
+ for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
+ dtrace_recdesc_t *rec = &act->dta_rec;
+
+ if ((align = rec->dtrd_alignment) > maxalign)
+ maxalign = align;
+
+ if (!wastuple && act->dta_intuple) {
+ /*
+ * This is the first record in a tuple. Align the
+ * offset to be at offset 4 in an 8-byte aligned
+ * block.
+ */
+ diff = offs + sizeof (dtrace_aggid_t);
+
+ if ((diff = (diff & (sizeof (uint64_t) - 1))))
+ offs += sizeof (uint64_t) - diff;
+
+ aggbase = offs - sizeof (dtrace_aggid_t);
+ ASSERT(!(aggbase & (sizeof (uint64_t) - 1)));
+ }
+
+ /*LINTED*/
+ if (rec->dtrd_size != 0 && (diff = (offs & (align - 1)))) {
+ /*
+ * The current offset is not properly aligned; align it.
+ */
+ offs += align - diff;
+ }
+
+ rec->dtrd_offset = offs;
+
+ if (offs + rec->dtrd_size > ecb->dte_needed) {
+ ecb->dte_needed = offs + rec->dtrd_size;
+
+ if (ecb->dte_needed > state->dts_needed)
+ state->dts_needed = ecb->dte_needed;
+ }
+
+ if (DTRACEACT_ISAGG(act->dta_kind)) {
+ dtrace_aggregation_t *agg = (dtrace_aggregation_t *)act;
+ dtrace_action_t *first = agg->dtag_first, *prev;
+
+ ASSERT(rec->dtrd_size != 0 && first != NULL);
+ ASSERT(wastuple);
+ ASSERT(aggbase != UINT32_MAX);
+
+ agg->dtag_base = aggbase;
+
+ while ((prev = first->dta_prev) != NULL &&
+ DTRACEACT_ISAGG(prev->dta_kind)) {
+ agg = (dtrace_aggregation_t *)prev;
+ first = agg->dtag_first;
+ }
+
+ if (prev != NULL) {
+ offs = prev->dta_rec.dtrd_offset +
+ prev->dta_rec.dtrd_size;
+ } else {
+ offs = sizeof (dtrace_epid_t);
+ }
+ wastuple = 0;
+ } else {
+ if (!act->dta_intuple)
+ ecb->dte_size = offs + rec->dtrd_size;
+
+ offs += rec->dtrd_size;
+ }
+
+ wastuple = act->dta_intuple;
+ }
+
+ if ((act = ecb->dte_action) != NULL &&
+ !(act->dta_kind == DTRACEACT_SPECULATE && act->dta_next == NULL) &&
+ ecb->dte_size == sizeof (dtrace_epid_t)) {
+ /*
+ * If the size is still sizeof (dtrace_epid_t), then all
+ * actions store no data; set the size to 0.
+ */
+ ecb->dte_alignment = maxalign;
+ ecb->dte_size = 0;
+
+ /*
+ * If the needed space is still sizeof (dtrace_epid_t), then
+ * all actions need no additional space; set the needed
+ * size to 0.
+ */
+ if (ecb->dte_needed == sizeof (dtrace_epid_t))
+ ecb->dte_needed = 0;
+
+ return;
+ }
+
+ /*
+ * Set our alignment, and make sure that the dte_size and dte_needed
+ * are aligned to the size of an EPID.
+ */
+ ecb->dte_alignment = maxalign;
+ ecb->dte_size = (ecb->dte_size + (sizeof (dtrace_epid_t) - 1)) &
+ ~(sizeof (dtrace_epid_t) - 1);
+ ecb->dte_needed = (ecb->dte_needed + (sizeof (dtrace_epid_t) - 1)) &
+ ~(sizeof (dtrace_epid_t) - 1);
+ ASSERT(ecb->dte_size <= ecb->dte_needed);
+}
+
+static dtrace_action_t *
+dtrace_ecb_aggregation_create(dtrace_ecb_t *ecb, dtrace_actdesc_t *desc)
+{
+ dtrace_aggregation_t *agg;
+ size_t size = sizeof (uint64_t);
+ int ntuple = desc->dtad_ntuple;
+ dtrace_action_t *act;
+ dtrace_recdesc_t *frec;
+ dtrace_aggid_t aggid;
+ dtrace_state_t *state = ecb->dte_state;
+
+ agg = kmem_zalloc(sizeof (dtrace_aggregation_t), KM_SLEEP);
+ agg->dtag_ecb = ecb;
+
+ ASSERT(DTRACEACT_ISAGG(desc->dtad_kind));
+
+ switch (desc->dtad_kind) {
+ case DTRACEAGG_MIN:
+ agg->dtag_initial = INT64_MAX;
+ agg->dtag_aggregate = dtrace_aggregate_min;
+ break;
+
+ case DTRACEAGG_MAX:
+ agg->dtag_initial = (uint64_t)INT64_MIN;
+ agg->dtag_aggregate = dtrace_aggregate_max;
+ break;
+
+ case DTRACEAGG_COUNT:
+ agg->dtag_aggregate = dtrace_aggregate_count;
+ break;
+
+ case DTRACEAGG_QUANTIZE:
+ agg->dtag_aggregate = dtrace_aggregate_quantize;
+ size = (((sizeof (uint64_t) * NBBY) - 1) * 2 + 1) *
+ sizeof (uint64_t);
+ break;
+
+ case DTRACEAGG_LQUANTIZE: {
+ uint16_t step = DTRACE_LQUANTIZE_STEP(desc->dtad_arg);
+ uint16_t levels = DTRACE_LQUANTIZE_LEVELS(desc->dtad_arg);
+
+ agg->dtag_initial = desc->dtad_arg;
+ agg->dtag_aggregate = dtrace_aggregate_lquantize;
+
+ if (step == 0 || levels == 0)
+ goto err;
+
+ size = levels * sizeof (uint64_t) + 3 * sizeof (uint64_t);
+ break;
+ }
+
+ case DTRACEAGG_AVG:
+ agg->dtag_aggregate = dtrace_aggregate_avg;
+ size = sizeof (uint64_t) * 2;
+ break;
+
+ case DTRACEAGG_STDDEV:
+ agg->dtag_aggregate = dtrace_aggregate_stddev;
+ size = sizeof (uint64_t) * 4;
+ break;
+
+ case DTRACEAGG_SUM:
+ agg->dtag_aggregate = dtrace_aggregate_sum;
+ break;
+
+ default:
+ goto err;
+ }
+
+ agg->dtag_action.dta_rec.dtrd_size = VBDTCAST(uint32_t)size;
+
+ if (ntuple == 0)
+ goto err;
+
+ /*
+ * We must make sure that we have enough actions for the n-tuple.
+ */
+ for (act = ecb->dte_action_last; act != NULL; act = act->dta_prev) {
+ if (DTRACEACT_ISAGG(act->dta_kind))
+ break;
+
+ if (--ntuple == 0) {
+ /*
+ * This is the action with which our n-tuple begins.
+ */
+ agg->dtag_first = act;
+ goto success;
+ }
+ }
+
+ /*
+ * This n-tuple is short by ntuple elements. Return failure.
+ */
+ ASSERT(ntuple != 0);
+err:
+ kmem_free(agg, sizeof (dtrace_aggregation_t));
+ return (NULL);
+
+success:
+ /*
+ * If the last action in the tuple has a size of zero, it's actually
+ * an expression argument for the aggregating action.
+ */
+ ASSERT(ecb->dte_action_last != NULL);
+ act = ecb->dte_action_last;
+
+ if (act->dta_kind == DTRACEACT_DIFEXPR) {
+ ASSERT(act->dta_difo != NULL);
+
+ if (act->dta_difo->dtdo_rtype.dtdt_size == 0)
+ agg->dtag_hasarg = 1;
+ }
+
+ /*
+ * We need to allocate an id for this aggregation.
+ */
+ aggid = (dtrace_aggid_t)(uintptr_t)vmem_alloc(state->dts_aggid_arena, 1,
+ VM_BESTFIT | VM_SLEEP);
+
+ if (VBDTCAST(int64_t)aggid - 1 >= state->dts_naggregations) {
+ dtrace_aggregation_t **oaggs = state->dts_aggregations;
+ dtrace_aggregation_t **aggs;
+ int naggs = state->dts_naggregations << 1;
+ int onaggs = state->dts_naggregations;
+
+ ASSERT(aggid == VBDTCAST(dtrace_aggid_t)state->dts_naggregations + 1);
+
+ if (naggs == 0) {
+ ASSERT(oaggs == NULL);
+ naggs = 1;
+ }
+
+ aggs = kmem_zalloc(naggs * sizeof (*aggs), KM_SLEEP);
+
+ if (oaggs != NULL) {
+ bcopy(oaggs, aggs, onaggs * sizeof (*aggs));
+ kmem_free(oaggs, onaggs * sizeof (*aggs));
+ }
+
+ state->dts_aggregations = aggs;
+ state->dts_naggregations = naggs;
+ }
+
+ ASSERT(state->dts_aggregations[aggid - 1] == NULL);
+ state->dts_aggregations[(agg->dtag_id = aggid) - 1] = agg;
+
+ frec = &agg->dtag_first->dta_rec;
+ if (frec->dtrd_alignment < sizeof (dtrace_aggid_t))
+ frec->dtrd_alignment = sizeof (dtrace_aggid_t);
+
+ for (act = agg->dtag_first; act != NULL; act = act->dta_next) {
+ ASSERT(!act->dta_intuple);
+ act->dta_intuple = 1;
+ }
+
+ return (&agg->dtag_action);
+}
+
+static void
+dtrace_ecb_aggregation_destroy(dtrace_ecb_t *ecb, dtrace_action_t *act)
+{
+ dtrace_aggregation_t *agg = (dtrace_aggregation_t *)act;
+ dtrace_state_t *state = ecb->dte_state;
+ dtrace_aggid_t aggid = agg->dtag_id;
+
+ ASSERT(DTRACEACT_ISAGG(act->dta_kind));
+ vmem_free(state->dts_aggid_arena, (void *)(uintptr_t)aggid, 1);
+
+ ASSERT(state->dts_aggregations[aggid - 1] == agg);
+ state->dts_aggregations[aggid - 1] = NULL;
+
+ kmem_free(agg, sizeof (dtrace_aggregation_t));
+}
+
+static int
+dtrace_ecb_action_add(dtrace_ecb_t *ecb, dtrace_actdesc_t *desc)
+{
+ dtrace_action_t *action, *last;
+ dtrace_difo_t *dp = desc->dtad_difo;
+ uint32_t size = 0, align = sizeof (uint8_t), mask;
+ uint16_t format = 0;
+ dtrace_recdesc_t *rec;
+ dtrace_state_t *state = ecb->dte_state;
+ dtrace_optval_t *opt = state->dts_options, nframes VBDTUNASS(0), strsize;
+ uint64_t arg = desc->dtad_arg;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(ecb->dte_action == NULL || ecb->dte_action->dta_refcnt == 1);
+
+ if (DTRACEACT_ISAGG(desc->dtad_kind)) {
+ /*
+ * If this is an aggregating action, there must be neither
+ * a speculate nor a commit on the action chain.
+ */
+ dtrace_action_t *act;
+
+ for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
+ if (act->dta_kind == DTRACEACT_COMMIT)
+ return (EINVAL);
+
+ if (act->dta_kind == DTRACEACT_SPECULATE)
+ return (EINVAL);
+ }
+
+ action = dtrace_ecb_aggregation_create(ecb, desc);
+
+ if (action == NULL)
+ return (EINVAL);
+ } else {
+ if (DTRACEACT_ISDESTRUCTIVE(desc->dtad_kind) ||
+ (desc->dtad_kind == DTRACEACT_DIFEXPR &&
+ dp != NULL && dp->dtdo_destructive)) {
+ state->dts_destructive = 1;
+ }
+
+ switch (desc->dtad_kind) {
+ case DTRACEACT_PRINTF:
+ case DTRACEACT_PRINTA:
+ case DTRACEACT_SYSTEM:
+ case DTRACEACT_FREOPEN:
+ /*
+ * We know that our arg is a string -- turn it into a
+ * format.
+ */
+ if (arg == NULL) {
+ ASSERT(desc->dtad_kind == DTRACEACT_PRINTA);
+ format = 0;
+ } else {
+ ASSERT(arg != NULL);
+ ASSERT(VBDT_IS_VALID_KRNL_ADDR(arg));
+ format = dtrace_format_add(state,
+ (char *)(uintptr_t)arg);
+ }
+
+ RT_FALL_THRU();
+ case DTRACEACT_LIBACT:
+ case DTRACEACT_DIFEXPR:
+ if (dp == NULL)
+ return (EINVAL);
+
+ if ((size = dp->dtdo_rtype.dtdt_size) != 0)
+ break;
+
+ if (dp->dtdo_rtype.dtdt_kind == DIF_TYPE_STRING) {
+ if (!(dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF))
+ return (EINVAL);
+
+ size = opt[DTRACEOPT_STRSIZE];
+ }
+
+ break;
+
+ case DTRACEACT_STACK:
+ if ((nframes = arg) == 0) {
+ nframes = opt[DTRACEOPT_STACKFRAMES];
+ ASSERT(nframes > 0);
+ arg = nframes;
+ }
+
+ size = VBDTCAST(uint32_t)(nframes * sizeof (pc_t));
+ break;
+
+ case DTRACEACT_JSTACK:
+ if ((strsize = DTRACE_USTACK_STRSIZE(arg)) == 0)
+ strsize = opt[DTRACEOPT_JSTACKSTRSIZE];
+
+ if ((nframes = DTRACE_USTACK_NFRAMES(arg)) == 0)
+ nframes = opt[DTRACEOPT_JSTACKFRAMES];
+
+ arg = DTRACE_USTACK_ARG(nframes, strsize);
+
+ RT_FALL_THRU();
+ case DTRACEACT_USTACK:
+ if (desc->dtad_kind != DTRACEACT_JSTACK &&
+ (nframes = DTRACE_USTACK_NFRAMES(arg)) == 0) {
+ strsize = DTRACE_USTACK_STRSIZE(arg);
+ nframes = opt[DTRACEOPT_USTACKFRAMES];
+ ASSERT(nframes > 0);
+ arg = DTRACE_USTACK_ARG(nframes, strsize);
+ }
+
+ /*
+ * Save a slot for the pid.
+ */
+ size = VBDTCAST(uint32_t)((nframes + 1) * sizeof (uint64_t));
+ size += DTRACE_USTACK_STRSIZE(arg);
+ size = P2ROUNDUP(size, (uint32_t)(sizeof (uintptr_t)));
+
+ break;
+
+ case DTRACEACT_SYM:
+ case DTRACEACT_MOD:
+ if (dp == NULL || ((size = dp->dtdo_rtype.dtdt_size) !=
+ sizeof (uint64_t)) ||
+ (dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF))
+ return (EINVAL);
+ break;
+
+ case DTRACEACT_USYM:
+ case DTRACEACT_UMOD:
+ case DTRACEACT_UADDR:
+ if (dp == NULL ||
+ (dp->dtdo_rtype.dtdt_size != sizeof (uint64_t)) ||
+ (dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF))
+ return (EINVAL);
+
+ /*
+ * We have a slot for the pid, plus a slot for the
+ * argument. To keep things simple (aligned with
+ * bitness-neutral sizing), we store each as a 64-bit
+ * quantity.
+ */
+ size = 2 * sizeof (uint64_t);
+ break;
+
+ case DTRACEACT_STOP:
+ case DTRACEACT_BREAKPOINT:
+ case DTRACEACT_PANIC:
+ break;
+
+ case DTRACEACT_CHILL:
+ case DTRACEACT_DISCARD:
+ case DTRACEACT_RAISE:
+ if (dp == NULL)
+ return (EINVAL);
+ break;
+
+ case DTRACEACT_EXIT:
+ if (dp == NULL ||
+ (size = dp->dtdo_rtype.dtdt_size) != sizeof (int) ||
+ (dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF))
+ return (EINVAL);
+ break;
+
+ case DTRACEACT_SPECULATE:
+ if (ecb->dte_size > sizeof (dtrace_epid_t))
+ return (EINVAL);
+
+ if (dp == NULL)
+ return (EINVAL);
+
+ state->dts_speculates = 1;
+ break;
+
+ case DTRACEACT_COMMIT: {
+ dtrace_action_t *act = ecb->dte_action;
+
+ for (; act != NULL; act = act->dta_next) {
+ if (act->dta_kind == DTRACEACT_COMMIT)
+ return (EINVAL);
+ }
+
+ if (dp == NULL)
+ return (EINVAL);
+ break;
+ }
+
+ default:
+ return (EINVAL);
+ }
+
+ if (size != 0 || desc->dtad_kind == DTRACEACT_SPECULATE) {
+ /*
+ * If this is a data-storing action or a speculate,
+ * we must be sure that there isn't a commit on the
+ * action chain.
+ */
+ dtrace_action_t *act = ecb->dte_action;
+
+ for (; act != NULL; act = act->dta_next) {
+ if (act->dta_kind == DTRACEACT_COMMIT)
+ return (EINVAL);
+ }
+ }
+
+ action = kmem_zalloc(sizeof (dtrace_action_t), KM_SLEEP);
+ action->dta_rec.dtrd_size = size;
+ }
+
+ action->dta_refcnt = 1;
+ rec = &action->dta_rec;
+ size = rec->dtrd_size;
+
+ for (mask = sizeof (uint64_t) - 1; size != 0 && mask > 0; mask >>= 1) {
+ if (!(size & mask)) {
+ align = mask + 1;
+ break;
+ }
+ }
+
+ action->dta_kind = desc->dtad_kind;
+
+ if ((action->dta_difo = dp) != NULL)
+ dtrace_difo_hold(dp);
+
+ rec->dtrd_action = action->dta_kind;
+ rec->dtrd_arg = arg;
+ rec->dtrd_uarg = desc->dtad_uarg;
+ rec->dtrd_alignment = (uint16_t)align;
+ rec->dtrd_format = format;
+
+ if ((last = ecb->dte_action_last) != NULL) {
+ ASSERT(ecb->dte_action != NULL);
+ action->dta_prev = last;
+ last->dta_next = action;
+ } else {
+ ASSERT(ecb->dte_action == NULL);
+ ecb->dte_action = action;
+ }
+
+ ecb->dte_action_last = action;
+
+ return (0);
+}
+
+static void
+dtrace_ecb_action_remove(dtrace_ecb_t *ecb)
+{
+ dtrace_action_t *act = ecb->dte_action, *next;
+ dtrace_vstate_t *vstate = &ecb->dte_state->dts_vstate;
+ dtrace_difo_t *dp;
+ uint16_t format;
+
+ if (act != NULL && act->dta_refcnt > 1) {
+ ASSERT(act->dta_next == NULL || act->dta_next->dta_refcnt == 1);
+ act->dta_refcnt--;
+ } else {
+ for (; act != NULL; act = next) {
+ next = act->dta_next;
+ ASSERT(next != NULL || act == ecb->dte_action_last);
+ ASSERT(act->dta_refcnt == 1);
+
+ if ((format = act->dta_rec.dtrd_format) != 0)
+ dtrace_format_remove(ecb->dte_state, format);
+
+ if ((dp = act->dta_difo) != NULL)
+ dtrace_difo_release(dp, vstate);
+
+ if (DTRACEACT_ISAGG(act->dta_kind)) {
+ dtrace_ecb_aggregation_destroy(ecb, act);
+ } else {
+ kmem_free(act, sizeof (dtrace_action_t));
+ }
+ }
+ }
+
+ ecb->dte_action = NULL;
+ ecb->dte_action_last = NULL;
+ ecb->dte_size = sizeof (dtrace_epid_t);
+}
+
+static void
+dtrace_ecb_disable(dtrace_ecb_t *ecb)
+{
+ /*
+ * We disable the ECB by removing it from its probe.
+ */
+ dtrace_ecb_t *pecb, *prev = NULL;
+ dtrace_probe_t *probe = ecb->dte_probe;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (probe == NULL) {
+ /*
+ * This is the NULL probe; there is nothing to disable.
+ */
+ return;
+ }
+
+ for (pecb = probe->dtpr_ecb; pecb != NULL; pecb = pecb->dte_next) {
+ if (pecb == ecb)
+ break;
+ prev = pecb;
+ }
+
+ ASSERT(pecb != NULL);
+
+ if (prev == NULL) {
+ probe->dtpr_ecb = ecb->dte_next;
+ } else {
+ prev->dte_next = ecb->dte_next;
+ }
+
+ if (ecb == probe->dtpr_ecb_last) {
+ ASSERT(ecb->dte_next == NULL);
+ probe->dtpr_ecb_last = prev;
+ }
+
+ /*
+ * The ECB has been disconnected from the probe; now sync to assure
+ * that all CPUs have seen the change before returning.
+ */
+ dtrace_sync();
+
+ if (probe->dtpr_ecb == NULL) {
+ /*
+ * That was the last ECB on the probe; clear the predicate
+ * cache ID for the probe, disable it and sync one more time
+ * to assure that we'll never hit it again.
+ */
+ dtrace_provider_t *prov = probe->dtpr_provider;
+
+ ASSERT(ecb->dte_next == NULL);
+ ASSERT(probe->dtpr_ecb_last == NULL);
+ probe->dtpr_predcache = DTRACE_CACHEIDNONE;
+ prov->dtpv_pops.dtps_disable(prov->dtpv_arg,
+ probe->dtpr_id, probe->dtpr_arg);
+ dtrace_sync();
+ } else {
+ /*
+ * There is at least one ECB remaining on the probe. If there
+ * is _exactly_ one, set the probe's predicate cache ID to be
+ * the predicate cache ID of the remaining ECB.
+ */
+ ASSERT(probe->dtpr_ecb_last != NULL);
+ ASSERT(probe->dtpr_predcache == DTRACE_CACHEIDNONE);
+
+ if (probe->dtpr_ecb == probe->dtpr_ecb_last) {
+ dtrace_predicate_t *p = probe->dtpr_ecb->dte_predicate;
+
+ ASSERT(probe->dtpr_ecb->dte_next == NULL);
+
+ if (p != NULL)
+ probe->dtpr_predcache = p->dtp_cacheid;
+ }
+
+ ecb->dte_next = NULL;
+ }
+}
+
+static void
+dtrace_ecb_destroy(dtrace_ecb_t *ecb)
+{
+ dtrace_state_t *state = ecb->dte_state;
+ dtrace_vstate_t *vstate = &state->dts_vstate;
+ dtrace_predicate_t *pred;
+ dtrace_epid_t epid = ecb->dte_epid;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(ecb->dte_next == NULL);
+ ASSERT(ecb->dte_probe == NULL || ecb->dte_probe->dtpr_ecb != ecb);
+
+ if ((pred = ecb->dte_predicate) != NULL)
+ dtrace_predicate_release(pred, vstate);
+
+ dtrace_ecb_action_remove(ecb);
+
+ ASSERT(state->dts_ecbs[epid - 1] == ecb);
+ state->dts_ecbs[epid - 1] = NULL;
+
+ kmem_free(ecb, sizeof (dtrace_ecb_t));
+}
+
+static dtrace_ecb_t *
+dtrace_ecb_create(dtrace_state_t *state, dtrace_probe_t *probe,
+ dtrace_enabling_t *enab)
+{
+ dtrace_ecb_t *ecb;
+ dtrace_predicate_t *pred;
+ dtrace_actdesc_t *act;
+ dtrace_provider_t *prov;
+ dtrace_ecbdesc_t *desc = enab->dten_current;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(state != NULL);
+
+ ecb = dtrace_ecb_add(state, probe);
+ ecb->dte_uarg = desc->dted_uarg;
+
+ if ((pred = desc->dted_pred.dtpdd_predicate) != NULL) {
+ dtrace_predicate_hold(pred);
+ ecb->dte_predicate = pred;
+ }
+
+ if (probe != NULL) {
+ /*
+ * If the provider shows more leg than the consumer is old
+ * enough to see, we need to enable the appropriate implicit
+ * predicate bits to prevent the ecb from activating at
+ * revealing times.
+ *
+ * Providers specifying DTRACE_PRIV_USER at register time
+ * are stating that they need the /proc-style privilege
+ * model to be enforced, and this is what DTRACE_COND_OWNER
+ * and DTRACE_COND_ZONEOWNER will then do at probe time.
+ */
+ prov = probe->dtpr_provider;
+ if (!(state->dts_cred.dcr_visible & DTRACE_CRV_ALLPROC) &&
+ (prov->dtpv_priv.dtpp_flags & DTRACE_PRIV_USER))
+ ecb->dte_cond |= DTRACE_COND_OWNER;
+
+ if (!(state->dts_cred.dcr_visible & DTRACE_CRV_ALLZONE) &&
+ (prov->dtpv_priv.dtpp_flags & DTRACE_PRIV_USER))
+ ecb->dte_cond |= DTRACE_COND_ZONEOWNER;
+
+ /*
+ * If the provider shows us kernel innards and the user
+ * is lacking sufficient privilege, enable the
+ * DTRACE_COND_USERMODE implicit predicate.
+ */
+ if (!(state->dts_cred.dcr_visible & DTRACE_CRV_KERNEL) &&
+ (prov->dtpv_priv.dtpp_flags & DTRACE_PRIV_KERNEL))
+ ecb->dte_cond |= DTRACE_COND_USERMODE;
+ }
+
+ if (dtrace_ecb_create_cache != NULL) {
+ /*
+ * If we have a cached ecb, we'll use its action list instead
+ * of creating our own (saving both time and space).
+ */
+ dtrace_ecb_t *cached = dtrace_ecb_create_cache;
+ dtrace_action_t *act2 = cached->dte_action;
+
+ if (act2 != NULL) {
+ ASSERT(act2->dta_refcnt > 0);
+ act2->dta_refcnt++;
+ ecb->dte_action = act2;
+ ecb->dte_action_last = cached->dte_action_last;
+ ecb->dte_needed = cached->dte_needed;
+ ecb->dte_size = cached->dte_size;
+ ecb->dte_alignment = cached->dte_alignment;
+ }
+
+ return (ecb);
+ }
+
+ for (act = desc->dted_action; act != NULL; act = act->dtad_next) {
+ if ((enab->dten_error = dtrace_ecb_action_add(ecb, act)) != 0) {
+ dtrace_ecb_destroy(ecb);
+ return (NULL);
+ }
+ }
+
+ dtrace_ecb_resize(ecb);
+
+ return (dtrace_ecb_create_cache = ecb);
+}
+
+static int
+dtrace_ecb_create_enable(dtrace_probe_t *probe, void *arg)
+{
+ dtrace_ecb_t *ecb;
+ dtrace_enabling_t *enab = arg;
+ dtrace_state_t *state = enab->dten_vstate->dtvs_state;
+
+ ASSERT(state != NULL);
+
+ if (probe != NULL && probe->dtpr_gen < enab->dten_probegen) {
+ /*
+ * This probe was created in a generation for which this
+ * enabling has previously created ECBs; we don't want to
+ * enable it again, so just kick out.
+ */
+ return (DTRACE_MATCH_NEXT);
+ }
+
+ if ((ecb = dtrace_ecb_create(state, probe, enab)) == NULL)
+ return (DTRACE_MATCH_DONE);
+
+ if (dtrace_ecb_enable(ecb) < 0)
+ return (DTRACE_MATCH_FAIL);
+
+ return (DTRACE_MATCH_NEXT);
+}
+
+static dtrace_ecb_t *
+dtrace_epid2ecb(dtrace_state_t *state, dtrace_epid_t id)
+{
+ dtrace_ecb_t *ecb; NOREF(ecb);
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (id == 0 || VBDTCAST(int64_t)id > state->dts_necbs)
+ return (NULL);
+
+ ASSERT(state->dts_necbs > 0 && state->dts_ecbs != NULL);
+ ASSERT((ecb = state->dts_ecbs[id - 1]) == NULL || ecb->dte_epid == id);
+
+ return (state->dts_ecbs[id - 1]);
+}
+
+static dtrace_aggregation_t *
+dtrace_aggid2agg(dtrace_state_t *state, dtrace_aggid_t id)
+{
+ dtrace_aggregation_t *agg; NOREF(agg);
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (id == 0 || VBDTCAST(int64_t)id > state->dts_naggregations)
+ return (NULL);
+
+ ASSERT(state->dts_naggregations > 0 && state->dts_aggregations != NULL);
+ ASSERT((agg = state->dts_aggregations[id - 1]) == NULL ||
+ agg->dtag_id == id);
+
+ return (state->dts_aggregations[id - 1]);
+}
+
+/*
+ * DTrace Buffer Functions
+ *
+ * The following functions manipulate DTrace buffers. Most of these functions
+ * are called in the context of establishing or processing consumer state;
+ * exceptions are explicitly noted.
+ */
+
+/*
+ * Note: called from cross call context. This function switches the two
+ * buffers on a given CPU. The atomicity of this operation is assured by
+ * disabling interrupts while the actual switch takes place; the disabling of
+ * interrupts serializes the execution with any execution of dtrace_probe() on
+ * the same CPU.
+ */
+static void
+dtrace_buffer_switch(dtrace_buffer_t *buf)
+{
+ caddr_t tomax = buf->dtb_tomax;
+ caddr_t xamot = buf->dtb_xamot;
+ dtrace_icookie_t cookie;
+
+ ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
+ ASSERT(!(buf->dtb_flags & DTRACEBUF_RING));
+
+ cookie = dtrace_interrupt_disable();
+ buf->dtb_tomax = xamot;
+ buf->dtb_xamot = tomax;
+ buf->dtb_xamot_drops = buf->dtb_drops;
+ buf->dtb_xamot_offset = buf->dtb_offset;
+ buf->dtb_xamot_errors = buf->dtb_errors;
+ buf->dtb_xamot_flags = buf->dtb_flags;
+ buf->dtb_offset = 0;
+ buf->dtb_drops = 0;
+ buf->dtb_errors = 0;
+ buf->dtb_flags &= ~(DTRACEBUF_ERROR | DTRACEBUF_DROPPED);
+ dtrace_interrupt_enable(cookie);
+}
+
+#ifdef VBOX
+static DECLCALLBACK(void) dtrace_buffer_switch_wrapper(RTCPUID idCpu, void *pvUser1, void *pvUser2)
+{
+ dtrace_buffer_switch((dtrace_buffer_t *)pvUser1);
+ NOREF(pvUser2); NOREF(idCpu);
+}
+#endif
+
+/*
+ * Note: called from cross call context. This function activates a buffer
+ * on a CPU. As with dtrace_buffer_switch(), the atomicity of the operation
+ * is guaranteed by the disabling of interrupts.
+ */
+static void
+dtrace_buffer_activate(dtrace_state_t *state)
+{
+ dtrace_buffer_t *buf;
+ dtrace_icookie_t cookie = dtrace_interrupt_disable();
+
+ buf = &state->dts_buffer[VBDT_GET_CPUID()];
+
+ if (buf->dtb_tomax != NULL) {
+ /*
+ * We might like to assert that the buffer is marked inactive,
+ * but this isn't necessarily true: the buffer for the CPU
+ * that processes the BEGIN probe has its buffer activated
+ * manually. In this case, we take the (harmless) action
+ * re-clearing the bit INACTIVE bit.
+ */
+ buf->dtb_flags &= ~DTRACEBUF_INACTIVE;
+ }
+
+ dtrace_interrupt_enable(cookie);
+}
+
+#ifdef VBOX
+static DECLCALLBACK(void) dtrace_buffer_activate_wrapper(RTCPUID idCpu, void *pvUser1, void *pvUser2)
+{
+ dtrace_buffer_activate((dtrace_state_t *)pvUser1);
+ NOREF(pvUser2); NOREF(idCpu);
+}
+#endif
+
+static int
+dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags,
+ processorid_t cpu)
+{
+#ifndef VBOX
+ cpu_t *cp;
+#else
+ RTCPUSET CpuSet;
+ unsigned iCpu;
+#endif
+ dtrace_buffer_t *buf;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (VBDTCAST(int64_t)size > dtrace_nonroot_maxsize
+#ifndef VBOX
+ && !PRIV_POLICY_CHOICE(CRED(), PRIV_ALL, B_FALSE)
+#endif
+ )
+ return (EFBIG);
+
+#ifndef VBOX
+ cp = cpu_list;
+#else
+ RTMpGetSet(&CpuSet);
+#endif
+
+#ifndef VBOX
+ do {
+ if (cpu != DTRACE_CPUALL && cpu != cp->cpu_id)
+ continue;
+
+ buf = &bufs[cp->cpu_id];
+#else
+ for (iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++) {
+ if ( !RTCpuSetIsMember(&CpuSet, iCpu)
+ || (cpu != (processorid_t)DTRACE_CPUALL && cpu != iCpu))
+ continue;
+
+ buf = &bufs[iCpu];
+#endif
+
+ /*
+ * If there is already a buffer allocated for this CPU, it
+ * is only possible that this is a DR event. In this case,
+ * the buffer size must match our specified size.
+ */
+ if (buf->dtb_tomax != NULL) {
+ ASSERT(buf->dtb_size == size);
+ continue;
+ }
+
+ ASSERT(buf->dtb_xamot == NULL);
+
+ if ((buf->dtb_tomax = kmem_zalloc(size, KM_NOSLEEP)) == NULL)
+ goto err;
+
+ buf->dtb_size = size;
+ buf->dtb_flags = flags;
+ buf->dtb_offset = 0;
+ buf->dtb_drops = 0;
+
+ if (flags & DTRACEBUF_NOSWITCH)
+ continue;
+
+ if ((buf->dtb_xamot = kmem_zalloc(size, KM_NOSLEEP)) == NULL)
+ goto err;
+#ifndef VBOX
+ } while ((cp = cp->cpu_next) != cpu_list);
+#else
+ }
+#endif
+
+ return (0);
+
+err:
+#ifndef VBOX
+ cp = cpu_list;
+
+ do {
+ if (cpu != DTRACE_CPUALL && cpu != cp->cpu_id)
+ continue;
+
+ buf = &bufs[cp->cpu_id];
+#else
+ for (iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++) {
+ if ( !RTCpuSetIsMember(&CpuSet, iCpu)
+ || (cpu != (processorid_t)DTRACE_CPUALL && cpu != iCpu))
+ continue;
+
+ buf = &bufs[iCpu];
+#endif
+
+ if (buf->dtb_xamot != NULL) {
+ ASSERT(buf->dtb_tomax != NULL);
+ ASSERT(buf->dtb_size == size);
+ kmem_free(buf->dtb_xamot, size);
+ }
+
+ if (buf->dtb_tomax != NULL) {
+ ASSERT(buf->dtb_size == size);
+ kmem_free(buf->dtb_tomax, size);
+ }
+
+ buf->dtb_tomax = NULL;
+ buf->dtb_xamot = NULL;
+ buf->dtb_size = 0;
+#ifndef VBOX
+ } while ((cp = cp->cpu_next) != cpu_list);
+#else
+ }
+#endif
+
+ return (ENOMEM);
+}
+
+/*
+ * Note: called from probe context. This function just increments the drop
+ * count on a buffer. It has been made a function to allow for the
+ * possibility of understanding the source of mysterious drop counts. (A
+ * problem for which one may be particularly disappointed that DTrace cannot
+ * be used to understand DTrace.)
+ */
+static void
+dtrace_buffer_drop(dtrace_buffer_t *buf)
+{
+ buf->dtb_drops++;
+}
+
+/*
+ * Note: called from probe context. This function is called to reserve space
+ * in a buffer. If mstate is non-NULL, sets the scratch base and size in the
+ * mstate. Returns the new offset in the buffer, or a negative value if an
+ * error has occurred.
+ */
+static intptr_t
+dtrace_buffer_reserve(dtrace_buffer_t *buf, size_t needed, size_t align,
+ dtrace_state_t *state, dtrace_mstate_t *mstate)
+{
+ intptr_t offs = buf->dtb_offset, soffs;
+ intptr_t woffs;
+ caddr_t tomax;
+ size_t total;
+
+ if (buf->dtb_flags & DTRACEBUF_INACTIVE)
+ return (-1);
+
+ if ((tomax = buf->dtb_tomax) == NULL) {
+ dtrace_buffer_drop(buf);
+ return (-1);
+ }
+
+ if (!(buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL))) {
+ while (offs & (align - 1)) {
+ /*
+ * Assert that our alignment is off by a number which
+ * is itself sizeof (uint32_t) aligned.
+ */
+ ASSERT(!((align - (offs & (align - 1))) &
+ (sizeof (uint32_t) - 1)));
+ DTRACE_STORE(uint32_t, tomax, offs, DTRACE_EPIDNONE);
+ offs += sizeof (uint32_t);
+ }
+
+ if (VBDTCAST(uintptr_t)(soffs = offs + needed) > buf->dtb_size) {
+ dtrace_buffer_drop(buf);
+ return (-1);
+ }
+
+ if (mstate == NULL)
+ return (offs);
+
+ mstate->dtms_scratch_base = (uintptr_t)tomax + soffs;
+ mstate->dtms_scratch_size = buf->dtb_size - soffs;
+ mstate->dtms_scratch_ptr = mstate->dtms_scratch_base;
+
+ return (offs);
+ }
+
+ if (buf->dtb_flags & DTRACEBUF_FILL) {
+ if (state->dts_activity != DTRACE_ACTIVITY_COOLDOWN &&
+ (buf->dtb_flags & DTRACEBUF_FULL))
+ return (-1);
+ goto out;
+ }
+
+ total = needed + (offs & (align - 1));
+
+ /*
+ * For a ring buffer, life is quite a bit more complicated. Before
+ * we can store any padding, we need to adjust our wrapping offset.
+ * (If we've never before wrapped or we're not about to, no adjustment
+ * is required.)
+ */
+ if ((buf->dtb_flags & DTRACEBUF_WRAPPED) ||
+ offs + total > buf->dtb_size) {
+ woffs = buf->dtb_xamot_offset;
+
+ if (offs + total > buf->dtb_size) {
+ /*
+ * We can't fit in the end of the buffer. First, a
+ * sanity check that we can fit in the buffer at all.
+ */
+ if (total > buf->dtb_size) {
+ dtrace_buffer_drop(buf);
+ return (-1);
+ }
+
+ /*
+ * We're going to be storing at the top of the buffer,
+ * so now we need to deal with the wrapped offset. We
+ * only reset our wrapped offset to 0 if it is
+ * currently greater than the current offset. If it
+ * is less than the current offset, it is because a
+ * previous allocation induced a wrap -- but the
+ * allocation didn't subsequently take the space due
+ * to an error or false predicate evaluation. In this
+ * case, we'll just leave the wrapped offset alone: if
+ * the wrapped offset hasn't been advanced far enough
+ * for this allocation, it will be adjusted in the
+ * lower loop.
+ */
+ if (buf->dtb_flags & DTRACEBUF_WRAPPED) {
+ if (woffs >= offs)
+ woffs = 0;
+ } else {
+ woffs = 0;
+ }
+
+ /*
+ * Now we know that we're going to be storing to the
+ * top of the buffer and that there is room for us
+ * there. We need to clear the buffer from the current
+ * offset to the end (there may be old gunk there).
+ */
+ while (VBDTCAST(uintptr_t)offs < buf->dtb_size)
+ tomax[offs++] = 0;
+
+ /*
+ * We need to set our offset to zero. And because we
+ * are wrapping, we need to set the bit indicating as
+ * much. We can also adjust our needed space back
+ * down to the space required by the ECB -- we know
+ * that the top of the buffer is aligned.
+ */
+ offs = 0;
+ total = needed;
+ buf->dtb_flags |= DTRACEBUF_WRAPPED;
+ } else {
+ /*
+ * There is room for us in the buffer, so we simply
+ * need to check the wrapped offset.
+ */
+ if (woffs < offs) {
+ /*
+ * The wrapped offset is less than the offset.
+ * This can happen if we allocated buffer space
+ * that induced a wrap, but then we didn't
+ * subsequently take the space due to an error
+ * or false predicate evaluation. This is
+ * okay; we know that _this_ allocation isn't
+ * going to induce a wrap. We still can't
+ * reset the wrapped offset to be zero,
+ * however: the space may have been trashed in
+ * the previous failed probe attempt. But at
+ * least the wrapped offset doesn't need to
+ * be adjusted at all...
+ */
+ goto out;
+ }
+ }
+
+ while (VBDTCAST(uintptr_t)offs + total > VBDTCAST(uintptr_t)woffs) {
+ dtrace_epid_t epid = *(uint32_t *)(tomax + woffs);
+ size_t size;
+
+ if (epid == DTRACE_EPIDNONE) {
+ size = sizeof (uint32_t);
+ } else {
+ ASSERT(VBDTCAST(int64_t)epid <= state->dts_necbs);
+ ASSERT(state->dts_ecbs[epid - 1] != NULL);
+
+ size = state->dts_ecbs[epid - 1]->dte_size;
+ }
+
+ ASSERT(woffs + size <= buf->dtb_size);
+ ASSERT(size != 0);
+
+ if (woffs + size == buf->dtb_size) {
+ /*
+ * We've reached the end of the buffer; we want
+ * to set the wrapped offset to 0 and break
+ * out. However, if the offs is 0, then we're
+ * in a strange edge-condition: the amount of
+ * space that we want to reserve plus the size
+ * of the record that we're overwriting is
+ * greater than the size of the buffer. This
+ * is problematic because if we reserve the
+ * space but subsequently don't consume it (due
+ * to a failed predicate or error) the wrapped
+ * offset will be 0 -- yet the EPID at offset 0
+ * will not be committed. This situation is
+ * relatively easy to deal with: if we're in
+ * this case, the buffer is indistinguishable
+ * from one that hasn't wrapped; we need only
+ * finish the job by clearing the wrapped bit,
+ * explicitly setting the offset to be 0, and
+ * zero'ing out the old data in the buffer.
+ */
+ if (offs == 0) {
+ buf->dtb_flags &= ~DTRACEBUF_WRAPPED;
+ buf->dtb_offset = 0;
+ woffs = total;
+
+ while (VBDTCAST(uintptr_t)woffs < buf->dtb_size)
+ tomax[woffs++] = 0;
+ }
+
+ woffs = 0;
+ break;
+ }
+
+ woffs += size;
+ }
+
+ /*
+ * We have a wrapped offset. It may be that the wrapped offset
+ * has become zero -- that's okay.
+ */
+ buf->dtb_xamot_offset = woffs;
+ }
+
+out:
+ /*
+ * Now we can plow the buffer with any necessary padding.
+ */
+ while (offs & (align - 1)) {
+ /*
+ * Assert that our alignment is off by a number which
+ * is itself sizeof (uint32_t) aligned.
+ */
+ ASSERT(!((align - (offs & (align - 1))) &
+ (sizeof (uint32_t) - 1)));
+ DTRACE_STORE(uint32_t, tomax, offs, DTRACE_EPIDNONE);
+ offs += sizeof (uint32_t);
+ }
+
+ if (buf->dtb_flags & DTRACEBUF_FILL) {
+ if (offs + needed > buf->dtb_size - state->dts_reserve) {
+ buf->dtb_flags |= DTRACEBUF_FULL;
+ return (-1);
+ }
+ }
+
+ if (mstate == NULL)
+ return (offs);
+
+ /*
+ * For ring buffers and fill buffers, the scratch space is always
+ * the inactive buffer.
+ */
+ mstate->dtms_scratch_base = (uintptr_t)buf->dtb_xamot;
+ mstate->dtms_scratch_size = buf->dtb_size;
+ mstate->dtms_scratch_ptr = mstate->dtms_scratch_base;
+
+ return (offs);
+}
+
+static void
+dtrace_buffer_polish(dtrace_buffer_t *buf)
+{
+ ASSERT(buf->dtb_flags & DTRACEBUF_RING);
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (!(buf->dtb_flags & DTRACEBUF_WRAPPED))
+ return;
+
+ /*
+ * We need to polish the ring buffer. There are three cases:
+ *
+ * - The first (and presumably most common) is that there is no gap
+ * between the buffer offset and the wrapped offset. In this case,
+ * there is nothing in the buffer that isn't valid data; we can
+ * mark the buffer as polished and return.
+ *
+ * - The second (less common than the first but still more common
+ * than the third) is that there is a gap between the buffer offset
+ * and the wrapped offset, and the wrapped offset is larger than the
+ * buffer offset. This can happen because of an alignment issue, or
+ * can happen because of a call to dtrace_buffer_reserve() that
+ * didn't subsequently consume the buffer space. In this case,
+ * we need to zero the data from the buffer offset to the wrapped
+ * offset.
+ *
+ * - The third (and least common) is that there is a gap between the
+ * buffer offset and the wrapped offset, but the wrapped offset is
+ * _less_ than the buffer offset. This can only happen because a
+ * call to dtrace_buffer_reserve() induced a wrap, but the space
+ * was not subsequently consumed. In this case, we need to zero the
+ * space from the offset to the end of the buffer _and_ from the
+ * top of the buffer to the wrapped offset.
+ */
+ if (buf->dtb_offset < buf->dtb_xamot_offset) {
+ bzero(buf->dtb_tomax + buf->dtb_offset,
+ buf->dtb_xamot_offset - buf->dtb_offset);
+ }
+
+ if (buf->dtb_offset > buf->dtb_xamot_offset) {
+ bzero(buf->dtb_tomax + buf->dtb_offset,
+ buf->dtb_size - buf->dtb_offset);
+ bzero(buf->dtb_tomax, buf->dtb_xamot_offset);
+ }
+}
+
+static void
+dtrace_buffer_free(dtrace_buffer_t *bufs)
+{
+ int i;
+
+ for (i = 0; i < NCPU; i++) {
+ dtrace_buffer_t *buf = &bufs[i];
+
+ if (buf->dtb_tomax == NULL) {
+ ASSERT(buf->dtb_xamot == NULL);
+ ASSERT(buf->dtb_size == 0);
+ continue;
+ }
+
+ if (buf->dtb_xamot != NULL) {
+ ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
+ kmem_free(buf->dtb_xamot, buf->dtb_size);
+ }
+
+ kmem_free(buf->dtb_tomax, buf->dtb_size);
+ buf->dtb_size = 0;
+ buf->dtb_tomax = NULL;
+ buf->dtb_xamot = NULL;
+ }
+}
+
+/*
+ * DTrace Enabling Functions
+ */
+static dtrace_enabling_t *
+dtrace_enabling_create(dtrace_vstate_t *vstate)
+{
+ dtrace_enabling_t *enab;
+
+ enab = kmem_zalloc(sizeof (dtrace_enabling_t), KM_SLEEP);
+ enab->dten_vstate = vstate;
+
+ return (enab);
+}
+
+static void
+dtrace_enabling_add(dtrace_enabling_t *enab, dtrace_ecbdesc_t *ecb)
+{
+ dtrace_ecbdesc_t **ndesc;
+ size_t osize, nsize;
+
+ /*
+ * We can't add to enablings after we've enabled them, or after we've
+ * retained them.
+ */
+ ASSERT(enab->dten_probegen == 0);
+ ASSERT(enab->dten_next == NULL && enab->dten_prev == NULL);
+
+ if (enab->dten_ndesc < enab->dten_maxdesc) {
+ enab->dten_desc[enab->dten_ndesc++] = ecb;
+ return;
+ }
+
+ osize = enab->dten_maxdesc * sizeof (dtrace_enabling_t *);
+
+ if (enab->dten_maxdesc == 0) {
+ enab->dten_maxdesc = 1;
+ } else {
+ enab->dten_maxdesc <<= 1;
+ }
+
+ ASSERT(enab->dten_ndesc < enab->dten_maxdesc);
+
+ nsize = enab->dten_maxdesc * sizeof (dtrace_enabling_t *);
+ ndesc = kmem_zalloc(nsize, KM_SLEEP);
+ bcopy(enab->dten_desc, ndesc, osize);
+ kmem_free(enab->dten_desc, osize);
+
+ enab->dten_desc = ndesc;
+ enab->dten_desc[enab->dten_ndesc++] = ecb;
+}
+
+static void
+dtrace_enabling_addlike(dtrace_enabling_t *enab, dtrace_ecbdesc_t *ecb,
+ dtrace_probedesc_t *pd)
+{
+ dtrace_ecbdesc_t *new;
+ dtrace_predicate_t *pred;
+ dtrace_actdesc_t *act;
+
+ /*
+ * We're going to create a new ECB description that matches the
+ * specified ECB in every way, but has the specified probe description.
+ */
+ new = kmem_zalloc(sizeof (dtrace_ecbdesc_t), KM_SLEEP);
+
+ if ((pred = ecb->dted_pred.dtpdd_predicate) != NULL)
+ dtrace_predicate_hold(pred);
+
+ for (act = ecb->dted_action; act != NULL; act = act->dtad_next)
+ dtrace_actdesc_hold(act);
+
+ new->dted_action = ecb->dted_action;
+ new->dted_pred = ecb->dted_pred;
+ new->dted_probe = *pd;
+ new->dted_uarg = ecb->dted_uarg;
+
+ dtrace_enabling_add(enab, new);
+}
+
+#ifndef VBOX
+static void
+dtrace_enabling_dump(dtrace_enabling_t *enab)
+{
+ int i;
+
+ for (i = 0; i < enab->dten_ndesc; i++) {
+ dtrace_probedesc_t *desc = &enab->dten_desc[i]->dted_probe;
+
+ cmn_err(CE_NOTE, "enabling probe %d (%s:%s:%s:%s)", i,
+ desc->dtpd_provider, desc->dtpd_mod,
+ desc->dtpd_func, desc->dtpd_name);
+ }
+}
+#endif /* !VBOX */
+
+static void
+dtrace_enabling_destroy(dtrace_enabling_t *enab)
+{
+ int i;
+ dtrace_ecbdesc_t *ep;
+ dtrace_vstate_t *vstate = enab->dten_vstate;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ for (i = 0; i < enab->dten_ndesc; i++) {
+ dtrace_actdesc_t *act, *next;
+ dtrace_predicate_t *pred;
+
+ ep = enab->dten_desc[i];
+
+ if ((pred = ep->dted_pred.dtpdd_predicate) != NULL)
+ dtrace_predicate_release(pred, vstate);
+
+ for (act = ep->dted_action; act != NULL; act = next) {
+ next = act->dtad_next;
+ dtrace_actdesc_release(act, vstate);
+ }
+
+ kmem_free(ep, sizeof (dtrace_ecbdesc_t));
+ }
+
+ kmem_free(enab->dten_desc,
+ enab->dten_maxdesc * sizeof (dtrace_enabling_t *));
+
+ /*
+ * If this was a retained enabling, decrement the dts_nretained count
+ * and take it off of the dtrace_retained list.
+ */
+ if (enab->dten_prev != NULL || enab->dten_next != NULL ||
+ dtrace_retained == enab) {
+ ASSERT(enab->dten_vstate->dtvs_state != NULL);
+ ASSERT(enab->dten_vstate->dtvs_state->dts_nretained > 0);
+ enab->dten_vstate->dtvs_state->dts_nretained--;
+ dtrace_retained_gen++;
+ }
+
+ if (enab->dten_prev == NULL) {
+ if (dtrace_retained == enab) {
+ dtrace_retained = enab->dten_next;
+
+ if (dtrace_retained != NULL)
+ dtrace_retained->dten_prev = NULL;
+ }
+ } else {
+ ASSERT(enab != dtrace_retained);
+ ASSERT(dtrace_retained != NULL);
+ enab->dten_prev->dten_next = enab->dten_next;
+ }
+
+ if (enab->dten_next != NULL) {
+ ASSERT(dtrace_retained != NULL);
+ enab->dten_next->dten_prev = enab->dten_prev;
+ }
+
+ kmem_free(enab, sizeof (dtrace_enabling_t));
+}
+
+static int
+dtrace_enabling_retain(dtrace_enabling_t *enab)
+{
+ dtrace_state_t *state;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(enab->dten_next == NULL && enab->dten_prev == NULL);
+ ASSERT(enab->dten_vstate != NULL);
+
+ state = enab->dten_vstate->dtvs_state;
+ ASSERT(state != NULL);
+
+ /*
+ * We only allow each state to retain dtrace_retain_max enablings.
+ */
+ if (state->dts_nretained >= dtrace_retain_max)
+ return (ENOSPC);
+
+ state->dts_nretained++;
+ dtrace_retained_gen++;
+
+ if (dtrace_retained == NULL) {
+ dtrace_retained = enab;
+ return (0);
+ }
+
+ enab->dten_next = dtrace_retained;
+ dtrace_retained->dten_prev = enab;
+ dtrace_retained = enab;
+
+ return (0);
+}
+
+static int
+dtrace_enabling_replicate(dtrace_state_t *state, dtrace_probedesc_t *match,
+ dtrace_probedesc_t *create)
+{
+ dtrace_enabling_t *new, *enab;
+ int found = 0, err = ENOENT;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(strlen(match->dtpd_provider) < DTRACE_PROVNAMELEN);
+ ASSERT(strlen(match->dtpd_mod) < DTRACE_MODNAMELEN);
+ ASSERT(strlen(match->dtpd_func) < DTRACE_FUNCNAMELEN);
+ ASSERT(strlen(match->dtpd_name) < DTRACE_NAMELEN);
+
+ new = dtrace_enabling_create(&state->dts_vstate);
+
+ /*
+ * Iterate over all retained enablings, looking for enablings that
+ * match the specified state.
+ */
+ for (enab = dtrace_retained; enab != NULL; enab = enab->dten_next) {
+ int i;
+
+ /*
+ * dtvs_state can only be NULL for helper enablings -- and
+ * helper enablings can't be retained.
+ */
+ ASSERT(enab->dten_vstate->dtvs_state != NULL);
+
+ if (enab->dten_vstate->dtvs_state != state)
+ continue;
+
+ /*
+ * Now iterate over each probe description; we're looking for
+ * an exact match to the specified probe description.
+ */
+ for (i = 0; i < enab->dten_ndesc; i++) {
+ dtrace_ecbdesc_t *ep = enab->dten_desc[i];
+ dtrace_probedesc_t *pd = &ep->dted_probe;
+
+ if (strcmp(pd->dtpd_provider, match->dtpd_provider))
+ continue;
+
+ if (strcmp(pd->dtpd_mod, match->dtpd_mod))
+ continue;
+
+ if (strcmp(pd->dtpd_func, match->dtpd_func))
+ continue;
+
+ if (strcmp(pd->dtpd_name, match->dtpd_name))
+ continue;
+
+ /*
+ * We have a winning probe! Add it to our growing
+ * enabling.
+ */
+ found = 1;
+ dtrace_enabling_addlike(new, ep, create);
+ }
+ }
+
+ if (!found || (err = dtrace_enabling_retain(new)) != 0) {
+ dtrace_enabling_destroy(new);
+ return (err);
+ }
+
+ return (0);
+}
+
+static void
+dtrace_enabling_retract(dtrace_state_t *state)
+{
+ dtrace_enabling_t *enab, *next;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ /*
+ * Iterate over all retained enablings, destroy the enablings retained
+ * for the specified state.
+ */
+ for (enab = dtrace_retained; enab != NULL; enab = next) {
+ next = enab->dten_next;
+
+ /*
+ * dtvs_state can only be NULL for helper enablings -- and
+ * helper enablings can't be retained.
+ */
+ ASSERT(enab->dten_vstate->dtvs_state != NULL);
+
+ if (enab->dten_vstate->dtvs_state == state) {
+ ASSERT(state->dts_nretained > 0);
+ dtrace_enabling_destroy(enab);
+ }
+ }
+
+ ASSERT(state->dts_nretained == 0);
+}
+
+static int
+dtrace_enabling_match(dtrace_enabling_t *enab, int *nmatched)
+{
+ int i = 0;
+ int total_matched = 0, matched = 0;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ for (i = 0; i < enab->dten_ndesc; i++) {
+ dtrace_ecbdesc_t *ep = enab->dten_desc[i];
+
+ enab->dten_current = ep;
+ enab->dten_error = 0;
+
+ /*
+ * If a provider failed to enable a probe then get out and
+ * let the consumer know we failed.
+ */
+ if ((matched = dtrace_probe_enable(&ep->dted_probe, enab)) < 0)
+ return (EBUSY);
+
+ total_matched += matched;
+
+ if (enab->dten_error != 0) {
+ /*
+ * If we get an error half-way through enabling the
+ * probes, we kick out -- perhaps with some number of
+ * them enabled. Leaving enabled probes enabled may
+ * be slightly confusing for user-level, but we expect
+ * that no one will attempt to actually drive on in
+ * the face of such errors. If this is an anonymous
+ * enabling (indicated with a NULL nmatched pointer),
+ * we cmn_err() a message. We aren't expecting to
+ * get such an error -- such as it can exist at all,
+ * it would be a result of corrupted DOF in the driver
+ * properties.
+ */
+ if (nmatched == NULL) {
+ cmn_err(CE_WARN, "dtrace_enabling_match() "
+ "error on %p: %d", (void *)ep,
+ enab->dten_error);
+ }
+
+ return (enab->dten_error);
+ }
+ }
+
+ enab->dten_probegen = dtrace_probegen;
+ if (nmatched != NULL)
+ *nmatched = total_matched;
+
+ return (0);
+}
+
+static void
+dtrace_enabling_matchall(void)
+{
+ dtrace_enabling_t *enab;
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_lock);
+
+ /*
+ * Iterate over all retained enablings to see if any probes match
+ * against them. We only perform this operation on enablings for which
+ * we have sufficient permissions by virtue of being in the global zone
+ * or in the same zone as the DTrace client. Because we can be called
+ * after dtrace_detach() has been called, we cannot assert that there
+ * are retained enablings. We can safely load from dtrace_retained,
+ * however: the taskq_destroy() at the end of dtrace_detach() will
+ * block pending our completion.
+ */
+ for (enab = dtrace_retained; enab != NULL; enab = enab->dten_next) {
+#ifndef VBOX
+ cred_t *cr = enab->dten_vstate->dtvs_state->dts_cred.dcr_cred;
+
+ if (INGLOBALZONE(curproc) ||
+ cr != NULL && getzoneid() == crgetzoneid(cr))
+#endif
+ (void) dtrace_enabling_match(enab, NULL);
+ }
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+}
+
+/*
+ * If an enabling is to be enabled without having matched probes (that is, if
+ * dtrace_state_go() is to be called on the underlying dtrace_state_t), the
+ * enabling must be _primed_ by creating an ECB for every ECB description.
+ * This must be done to assure that we know the number of speculations, the
+ * number of aggregations, the minimum buffer size needed, etc. before we
+ * transition out of DTRACE_ACTIVITY_INACTIVE. To do this without actually
+ * enabling any probes, we create ECBs for every ECB decription, but with a
+ * NULL probe -- which is exactly what this function does.
+ */
+static void
+dtrace_enabling_prime(dtrace_state_t *state)
+{
+ dtrace_enabling_t *enab;
+ int i;
+
+ for (enab = dtrace_retained; enab != NULL; enab = enab->dten_next) {
+ ASSERT(enab->dten_vstate->dtvs_state != NULL);
+
+ if (enab->dten_vstate->dtvs_state != state)
+ continue;
+
+ /*
+ * We don't want to prime an enabling more than once, lest
+ * we allow a malicious user to induce resource exhaustion.
+ * (The ECBs that result from priming an enabling aren't
+ * leaked -- but they also aren't deallocated until the
+ * consumer state is destroyed.)
+ */
+ if (enab->dten_primed)
+ continue;
+
+ for (i = 0; i < enab->dten_ndesc; i++) {
+ enab->dten_current = enab->dten_desc[i];
+ (void) dtrace_probe_enable(NULL, enab);
+ }
+
+ enab->dten_primed = 1;
+ }
+}
+
+/*
+ * Called to indicate that probes should be provided due to retained
+ * enablings. This is implemented in terms of dtrace_probe_provide(), but it
+ * must take an initial lap through the enabling calling the dtps_provide()
+ * entry point explicitly to allow for autocreated probes.
+ */
+static void
+dtrace_enabling_provide(dtrace_provider_t *prv)
+{
+ int i, all = 0;
+ dtrace_probedesc_t desc;
+ dtrace_genid_t gen;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(MUTEX_HELD(&dtrace_provider_lock));
+
+ if (prv == NULL) {
+ all = 1;
+ prv = dtrace_provider;
+ }
+
+ do {
+ dtrace_enabling_t *enab;
+ void *parg = prv->dtpv_arg;
+
+retry:
+ gen = dtrace_retained_gen;
+ for (enab = dtrace_retained; enab != NULL;
+ enab = enab->dten_next) {
+ for (i = 0; i < enab->dten_ndesc; i++) {
+ desc = enab->dten_desc[i]->dted_probe;
+ mutex_exit(&dtrace_lock);
+ prv->dtpv_pops.dtps_provide(parg, &desc);
+ mutex_enter(&dtrace_lock);
+ /*
+ * Process the retained enablings again if
+ * they have changed while we weren't holding
+ * dtrace_lock.
+ */
+ if (gen != dtrace_retained_gen)
+ goto retry;
+ }
+ }
+ } while (all && (prv = prv->dtpv_next) != NULL);
+
+ mutex_exit(&dtrace_lock);
+ dtrace_probe_provide(NULL, all ? NULL : prv);
+ mutex_enter(&dtrace_lock);
+}
+
+/*
+ * DTrace DOF Functions
+ */
+/*ARGSUSED*/
+static void
+dtrace_dof_error(dof_hdr_t *dof, const char *str)
+{
+ RT_NOREF_PV(dof);
+
+ if (dtrace_err_verbose)
+ cmn_err(CE_WARN, "failed to process DOF: %s", str);
+
+#ifdef DTRACE_ERRDEBUG
+ dtrace_errdebug(str);
+#endif
+}
+
+/*
+ * Create DOF out of a currently enabled state. Right now, we only create
+ * DOF containing the run-time options -- but this could be expanded to create
+ * complete DOF representing the enabled state.
+ */
+static dof_hdr_t *
+dtrace_dof_create(dtrace_state_t *state)
+{
+ dof_hdr_t *dof;
+ dof_sec_t *sec;
+ dof_optdesc_t *opt;
+ int i, len = sizeof (dof_hdr_t) +
+ roundup(sizeof (dof_sec_t), sizeof (uint64_t)) +
+ sizeof (dof_optdesc_t) * DTRACEOPT_MAX;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ dof = kmem_zalloc(len, KM_SLEEP);
+ dof->dofh_ident[DOF_ID_MAG0] = DOF_MAG_MAG0;
+ dof->dofh_ident[DOF_ID_MAG1] = DOF_MAG_MAG1;
+ dof->dofh_ident[DOF_ID_MAG2] = DOF_MAG_MAG2;
+ dof->dofh_ident[DOF_ID_MAG3] = DOF_MAG_MAG3;
+
+ dof->dofh_ident[DOF_ID_MODEL] = DOF_MODEL_NATIVE;
+ dof->dofh_ident[DOF_ID_ENCODING] = DOF_ENCODE_NATIVE;
+ dof->dofh_ident[DOF_ID_VERSION] = DOF_VERSION;
+ dof->dofh_ident[DOF_ID_DIFVERS] = DIF_VERSION;
+ dof->dofh_ident[DOF_ID_DIFIREG] = DIF_DIR_NREGS;
+ dof->dofh_ident[DOF_ID_DIFTREG] = DIF_DTR_NREGS;
+
+ dof->dofh_flags = 0;
+ dof->dofh_hdrsize = sizeof (dof_hdr_t);
+ dof->dofh_secsize = sizeof (dof_sec_t);
+ dof->dofh_secnum = 1; /* only DOF_SECT_OPTDESC */
+ dof->dofh_secoff = sizeof (dof_hdr_t);
+ dof->dofh_loadsz = len;
+ dof->dofh_filesz = len;
+ dof->dofh_pad = 0;
+
+ /*
+ * Fill in the option section header...
+ */
+ sec = (dof_sec_t *)((uintptr_t)dof + sizeof (dof_hdr_t));
+ sec->dofs_type = DOF_SECT_OPTDESC;
+ sec->dofs_align = sizeof (uint64_t);
+ sec->dofs_flags = DOF_SECF_LOAD;
+ sec->dofs_entsize = sizeof (dof_optdesc_t);
+
+ opt = (dof_optdesc_t *)((uintptr_t)sec +
+ roundup(sizeof (dof_sec_t), sizeof (uint64_t)));
+
+ sec->dofs_offset = (uintptr_t)opt - (uintptr_t)dof;
+ sec->dofs_size = sizeof (dof_optdesc_t) * DTRACEOPT_MAX;
+
+ for (i = 0; i < DTRACEOPT_MAX; i++) {
+ opt[i].dofo_option = i;
+ opt[i].dofo_strtab = DOF_SECIDX_NONE;
+ opt[i].dofo_value = state->dts_options[i];
+ }
+
+ return (dof);
+}
+
+static dof_hdr_t *
+dtrace_dof_copyin(uintptr_t uarg, int *errp)
+{
+ dof_hdr_t hdr, *dof;
+
+ ASSERT(!MUTEX_HELD(&dtrace_lock));
+
+ /*
+ * First, we're going to copyin() the sizeof (dof_hdr_t).
+ */
+ if (copyin((void *)uarg, &hdr, sizeof (hdr)) != 0) {
+ dtrace_dof_error(NULL, "failed to copyin DOF header");
+ *errp = EFAULT;
+ return (NULL);
+ }
+
+ /*
+ * Now we'll allocate the entire DOF and copy it in -- provided
+ * that the length isn't outrageous.
+ */
+ if (hdr.dofh_loadsz >= VBDTCAST(uint64_t)dtrace_dof_maxsize) {
+ dtrace_dof_error(&hdr, "load size exceeds maximum");
+ *errp = E2BIG;
+ return (NULL);
+ }
+
+ if (hdr.dofh_loadsz < sizeof (hdr)) {
+ dtrace_dof_error(&hdr, "invalid load size");
+ *errp = EINVAL;
+ return (NULL);
+ }
+
+ dof = kmem_alloc(hdr.dofh_loadsz, KM_SLEEP);
+
+ if (copyin((void *)uarg, dof, hdr.dofh_loadsz) != 0 ||
+ dof->dofh_loadsz != hdr.dofh_loadsz) {
+ kmem_free(dof, hdr.dofh_loadsz);
+ *errp = EFAULT;
+ return (NULL);
+ }
+
+ return (dof);
+}
+
+#ifndef VBOX
+static dof_hdr_t *
+dtrace_dof_property(const char *name)
+{
+#ifndef VBOX
+ uchar_t *buf;
+ uint64_t loadsz;
+ unsigned int len, i;
+ dof_hdr_t *dof;
+
+ /*
+ * Unfortunately, array of values in .conf files are always (and
+ * only) interpreted to be integer arrays. We must read our DOF
+ * as an integer array, and then squeeze it into a byte array.
+ */
+ if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dtrace_devi, 0,
+ (char *)name, (int **)&buf, &len) != DDI_PROP_SUCCESS)
+ return (NULL);
+
+ for (i = 0; i < len; i++)
+ buf[i] = (uchar_t)(((int *)buf)[i]);
+
+ if (len < sizeof (dof_hdr_t)) {
+ ddi_prop_free(buf);
+ dtrace_dof_error(NULL, "truncated header");
+ return (NULL);
+ }
+
+ if (len < (loadsz = ((dof_hdr_t *)buf)->dofh_loadsz)) {
+ ddi_prop_free(buf);
+ dtrace_dof_error(NULL, "truncated DOF");
+ return (NULL);
+ }
+
+ if (loadsz >= dtrace_dof_maxsize) {
+ ddi_prop_free(buf);
+ dtrace_dof_error(NULL, "oversized DOF");
+ return (NULL);
+ }
+
+ dof = kmem_alloc(loadsz, KM_SLEEP);
+ bcopy(buf, dof, loadsz);
+ ddi_prop_free(buf);
+
+ return (dof);
+#else /* VBOX */
+ RT_NOREF_PV(name);
+ return (NULL);
+#endif /* VBOX */
+}
+#endif /* !VBOX */
+
+static void
+dtrace_dof_destroy(dof_hdr_t *dof)
+{
+ kmem_free(dof, dof->dofh_loadsz);
+}
+
+/*
+ * Return the dof_sec_t pointer corresponding to a given section index. If the
+ * index is not valid, dtrace_dof_error() is called and NULL is returned. If
+ * a type other than DOF_SECT_NONE is specified, the header is checked against
+ * this type and NULL is returned if the types do not match.
+ */
+static dof_sec_t *
+dtrace_dof_sect(dof_hdr_t *dof, uint32_t type, dof_secidx_t i)
+{
+ dof_sec_t *sec = (dof_sec_t *)(uintptr_t)
+ ((uintptr_t)dof + dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (i >= dof->dofh_secnum) {
+ dtrace_dof_error(dof, "referenced section index is invalid");
+ return (NULL);
+ }
+
+ if (!(sec->dofs_flags & DOF_SECF_LOAD)) {
+ dtrace_dof_error(dof, "referenced section is not loadable");
+ return (NULL);
+ }
+
+ if (type != DOF_SECT_NONE && type != sec->dofs_type) {
+ dtrace_dof_error(dof, "referenced section is the wrong type");
+ return (NULL);
+ }
+
+ return (sec);
+}
+
+static dtrace_probedesc_t *
+dtrace_dof_probedesc(dof_hdr_t *dof, dof_sec_t *sec, dtrace_probedesc_t *desc)
+{
+ dof_probedesc_t *probe;
+ dof_sec_t *strtab;
+ uintptr_t daddr = (uintptr_t)dof;
+ uintptr_t str;
+ size_t size;
+
+ if (sec->dofs_type != DOF_SECT_PROBEDESC) {
+ dtrace_dof_error(dof, "invalid probe section");
+ return (NULL);
+ }
+
+ if (sec->dofs_align != sizeof (dof_secidx_t)) {
+ dtrace_dof_error(dof, "bad alignment in probe description");
+ return (NULL);
+ }
+
+ if (sec->dofs_offset + sizeof (dof_probedesc_t) > dof->dofh_loadsz) {
+ dtrace_dof_error(dof, "truncated probe description");
+ return (NULL);
+ }
+
+ probe = (dof_probedesc_t *)(uintptr_t)(daddr + sec->dofs_offset);
+ strtab = dtrace_dof_sect(dof, DOF_SECT_STRTAB, probe->dofp_strtab);
+
+ if (strtab == NULL)
+ return (NULL);
+
+ str = daddr + strtab->dofs_offset;
+ size = strtab->dofs_size;
+
+ if (probe->dofp_provider >= strtab->dofs_size) {
+ dtrace_dof_error(dof, "corrupt probe provider");
+ return (NULL);
+ }
+
+ (void) strncpy(desc->dtpd_provider,
+ (char *)(str + probe->dofp_provider),
+ MIN(DTRACE_PROVNAMELEN - 1, size - probe->dofp_provider));
+
+ if (probe->dofp_mod >= strtab->dofs_size) {
+ dtrace_dof_error(dof, "corrupt probe module");
+ return (NULL);
+ }
+
+ (void) strncpy(desc->dtpd_mod, (char *)(str + probe->dofp_mod),
+ MIN(DTRACE_MODNAMELEN - 1, size - probe->dofp_mod));
+
+ if (probe->dofp_func >= strtab->dofs_size) {
+ dtrace_dof_error(dof, "corrupt probe function");
+ return (NULL);
+ }
+
+ (void) strncpy(desc->dtpd_func, (char *)(str + probe->dofp_func),
+ MIN(DTRACE_FUNCNAMELEN - 1, size - probe->dofp_func));
+
+ if (probe->dofp_name >= strtab->dofs_size) {
+ dtrace_dof_error(dof, "corrupt probe name");
+ return (NULL);
+ }
+
+ (void) strncpy(desc->dtpd_name, (char *)(str + probe->dofp_name),
+ MIN(DTRACE_NAMELEN - 1, size - probe->dofp_name));
+
+ return (desc);
+}
+
+static dtrace_difo_t *
+dtrace_dof_difo(dof_hdr_t *dof, dof_sec_t *sec, dtrace_vstate_t *vstate,
+ cred_t *cr)
+{
+ dtrace_difo_t *dp;
+ size_t ttl = 0;
+ dof_difohdr_t *dofd;
+ uintptr_t daddr = (uintptr_t)dof;
+ size_t max = dtrace_difo_maxsize;
+ int i, l, n;
+
+ static const struct {
+ int section;
+ int bufoffs;
+ int lenoffs;
+ int entsize;
+ int align;
+ const char *msg;
+ } difo[] = {
+ { DOF_SECT_DIF, offsetof(dtrace_difo_t, dtdo_buf),
+ offsetof(dtrace_difo_t, dtdo_len), sizeof (dif_instr_t),
+ sizeof (dif_instr_t), "multiple DIF sections" },
+
+ { DOF_SECT_INTTAB, offsetof(dtrace_difo_t, dtdo_inttab),
+ offsetof(dtrace_difo_t, dtdo_intlen), sizeof (uint64_t),
+ sizeof (uint64_t), "multiple integer tables" },
+
+ { DOF_SECT_STRTAB, offsetof(dtrace_difo_t, dtdo_strtab),
+ offsetof(dtrace_difo_t, dtdo_strlen), 0,
+ sizeof (char), "multiple string tables" },
+
+ { DOF_SECT_VARTAB, offsetof(dtrace_difo_t, dtdo_vartab),
+ offsetof(dtrace_difo_t, dtdo_varlen), sizeof (dtrace_difv_t),
+ sizeof (uint_t), "multiple variable tables" },
+
+ { DOF_SECT_NONE, 0, 0, 0, NULL }
+ };
+
+ if (sec->dofs_type != DOF_SECT_DIFOHDR) {
+ dtrace_dof_error(dof, "invalid DIFO header section");
+ return (NULL);
+ }
+
+ if (sec->dofs_align != sizeof (dof_secidx_t)) {
+ dtrace_dof_error(dof, "bad alignment in DIFO header");
+ return (NULL);
+ }
+
+ if (sec->dofs_size < sizeof (dof_difohdr_t) ||
+ sec->dofs_size % sizeof (dof_secidx_t)) {
+ dtrace_dof_error(dof, "bad size in DIFO header");
+ return (NULL);
+ }
+
+ dofd = (dof_difohdr_t *)(uintptr_t)(daddr + sec->dofs_offset);
+ n = (sec->dofs_size - sizeof (*dofd)) / sizeof (dof_secidx_t) + 1;
+
+ dp = kmem_zalloc(sizeof (dtrace_difo_t), KM_SLEEP);
+ dp->dtdo_rtype = dofd->dofd_rtype;
+
+ for (l = 0; l < n; l++) {
+ dof_sec_t *subsec;
+ void **bufp;
+ uint32_t *lenp;
+
+ if ((subsec = dtrace_dof_sect(dof, DOF_SECT_NONE,
+ dofd->dofd_links[l])) == NULL)
+ goto err; /* invalid section link */
+
+ if (ttl + subsec->dofs_size > max) {
+ dtrace_dof_error(dof, "exceeds maximum size");
+ goto err;
+ }
+
+ ttl += subsec->dofs_size;
+
+ for (i = 0; difo[i].section != DOF_SECT_NONE; i++) {
+ if (subsec->dofs_type != VBDTCAST(uint32_t)difo[i].section)
+ continue;
+
+ if (!(subsec->dofs_flags & DOF_SECF_LOAD)) {
+ dtrace_dof_error(dof, "section not loaded");
+ goto err;
+ }
+
+ if (subsec->dofs_align != VBDTCAST(uint32_t)difo[i].align) {
+ dtrace_dof_error(dof, "bad alignment");
+ goto err;
+ }
+
+ bufp = (void **)((uintptr_t)dp + difo[i].bufoffs);
+ lenp = (uint32_t *)((uintptr_t)dp + difo[i].lenoffs);
+
+ if (*bufp != NULL) {
+ dtrace_dof_error(dof, difo[i].msg);
+ goto err;
+ }
+
+ if (VBDTCAST(uint32_t)difo[i].entsize != subsec->dofs_entsize) {
+ dtrace_dof_error(dof, "entry size mismatch");
+ goto err;
+ }
+
+ if (subsec->dofs_entsize != 0 &&
+ (subsec->dofs_size % subsec->dofs_entsize) != 0) {
+ dtrace_dof_error(dof, "corrupt entry size");
+ goto err;
+ }
+
+ *lenp = subsec->dofs_size;
+ *bufp = kmem_alloc(subsec->dofs_size, KM_SLEEP);
+ bcopy((char *)(uintptr_t)(daddr + subsec->dofs_offset),
+ *bufp, subsec->dofs_size);
+
+ if (subsec->dofs_entsize != 0)
+ *lenp /= subsec->dofs_entsize;
+
+ break;
+ }
+
+ /*
+ * If we encounter a loadable DIFO sub-section that is not
+ * known to us, assume this is a broken program and fail.
+ */
+ if (difo[i].section == DOF_SECT_NONE &&
+ (subsec->dofs_flags & DOF_SECF_LOAD)) {
+ dtrace_dof_error(dof, "unrecognized DIFO subsection");
+ goto err;
+ }
+ }
+
+ if (dp->dtdo_buf == NULL) {
+ /*
+ * We can't have a DIF object without DIF text.
+ */
+ dtrace_dof_error(dof, "missing DIF text");
+ goto err;
+ }
+
+ /*
+ * Before we validate the DIF object, run through the variable table
+ * looking for the strings -- if any of their size are under, we'll set
+ * their size to be the system-wide default string size. Note that
+ * this should _not_ happen if the "strsize" option has been set --
+ * in this case, the compiler should have set the size to reflect the
+ * setting of the option.
+ */
+ for (i = 0; VBDTCAST(unsigned)i < dp->dtdo_varlen; i++) {
+ dtrace_difv_t *v = &dp->dtdo_vartab[i];
+ dtrace_diftype_t *t = &v->dtdv_type;
+
+ if (v->dtdv_id < DIF_VAR_OTHER_UBASE)
+ continue;
+
+ if (t->dtdt_kind == DIF_TYPE_STRING && t->dtdt_size == 0)
+ t->dtdt_size = VBDTCAST(uint32_t)dtrace_strsize_default;
+ }
+
+ if (dtrace_difo_validate(dp, vstate, DIF_DIR_NREGS, cr) != 0)
+ goto err;
+
+ dtrace_difo_init(dp, vstate);
+ return (dp);
+
+err:
+ kmem_free(dp->dtdo_buf, dp->dtdo_len * sizeof (dif_instr_t));
+ kmem_free(dp->dtdo_inttab, dp->dtdo_intlen * sizeof (uint64_t));
+ kmem_free(dp->dtdo_strtab, dp->dtdo_strlen);
+ kmem_free(dp->dtdo_vartab, dp->dtdo_varlen * sizeof (dtrace_difv_t));
+
+ kmem_free(dp, sizeof (dtrace_difo_t));
+ return (NULL);
+}
+
+static dtrace_predicate_t *
+dtrace_dof_predicate(dof_hdr_t *dof, dof_sec_t *sec, dtrace_vstate_t *vstate,
+ cred_t *cr)
+{
+ dtrace_difo_t *dp;
+
+ if ((dp = dtrace_dof_difo(dof, sec, vstate, cr)) == NULL)
+ return (NULL);
+
+ return (dtrace_predicate_create(dp));
+}
+
+static dtrace_actdesc_t *
+dtrace_dof_actdesc(dof_hdr_t *dof, dof_sec_t *sec, dtrace_vstate_t *vstate,
+ cred_t *cr)
+{
+ dtrace_actdesc_t *act, *first = NULL, *last = NULL, *next;
+ dof_actdesc_t *desc;
+ dof_sec_t *difosec;
+ size_t offs;
+ uintptr_t daddr = (uintptr_t)dof;
+ uint64_t arg;
+ dtrace_actkind_t kind;
+
+ if (sec->dofs_type != DOF_SECT_ACTDESC) {
+ dtrace_dof_error(dof, "invalid action section");
+ return (NULL);
+ }
+
+ if (sec->dofs_offset + sizeof (dof_actdesc_t) > dof->dofh_loadsz) {
+ dtrace_dof_error(dof, "truncated action description");
+ return (NULL);
+ }
+
+ if (sec->dofs_align != sizeof (uint64_t)) {
+ dtrace_dof_error(dof, "bad alignment in action description");
+ return (NULL);
+ }
+
+ if (sec->dofs_size < sec->dofs_entsize) {
+ dtrace_dof_error(dof, "section entry size exceeds total size");
+ return (NULL);
+ }
+
+ if (sec->dofs_entsize != sizeof (dof_actdesc_t)) {
+ dtrace_dof_error(dof, "bad entry size in action description");
+ return (NULL);
+ }
+
+ if (sec->dofs_size / sec->dofs_entsize > dtrace_actions_max) {
+ dtrace_dof_error(dof, "actions exceed dtrace_actions_max");
+ return (NULL);
+ }
+
+ for (offs = 0; offs < sec->dofs_size; offs += sec->dofs_entsize) {
+ desc = (dof_actdesc_t *)(daddr +
+ (uintptr_t)sec->dofs_offset + offs);
+ kind = (dtrace_actkind_t)desc->dofa_kind;
+
+ if (DTRACEACT_ISPRINTFLIKE(kind) &&
+ (kind != DTRACEACT_PRINTA ||
+ desc->dofa_strtab != DOF_SECIDX_NONE)) {
+ dof_sec_t *strtab;
+ char *str, *fmt;
+ uint64_t i;
+
+ /*
+ * printf()-like actions must have a format string.
+ */
+ if ((strtab = dtrace_dof_sect(dof,
+ DOF_SECT_STRTAB, desc->dofa_strtab)) == NULL)
+ goto err;
+
+ str = (char *)((uintptr_t)dof +
+ (uintptr_t)strtab->dofs_offset);
+
+ for (i = desc->dofa_arg; i < strtab->dofs_size; i++) {
+ if (str[i] == '\0')
+ break;
+ }
+
+ if (i >= strtab->dofs_size) {
+ dtrace_dof_error(dof, "bogus format string");
+ goto err;
+ }
+
+ if (i == desc->dofa_arg) {
+ dtrace_dof_error(dof, "empty format string");
+ goto err;
+ }
+
+ i -= desc->dofa_arg;
+ fmt = kmem_alloc(i + 1, KM_SLEEP);
+ bcopy(&str[desc->dofa_arg], fmt, i + 1);
+ arg = (uint64_t)(uintptr_t)fmt;
+ } else {
+ if (kind == DTRACEACT_PRINTA) {
+ ASSERT(desc->dofa_strtab == DOF_SECIDX_NONE);
+ arg = 0;
+ } else {
+ arg = desc->dofa_arg;
+ }
+ }
+
+ act = dtrace_actdesc_create(kind, desc->dofa_ntuple,
+ desc->dofa_uarg, arg);
+
+ if (last != NULL) {
+ last->dtad_next = act;
+ } else {
+ first = act;
+ }
+
+ last = act;
+
+ if (desc->dofa_difo == DOF_SECIDX_NONE)
+ continue;
+
+ if ((difosec = dtrace_dof_sect(dof,
+ DOF_SECT_DIFOHDR, desc->dofa_difo)) == NULL)
+ goto err;
+
+ act->dtad_difo = dtrace_dof_difo(dof, difosec, vstate, cr);
+
+ if (act->dtad_difo == NULL)
+ goto err;
+ }
+
+ ASSERT(first != NULL);
+ return (first);
+
+err:
+ for (act = first; act != NULL; act = next) {
+ next = act->dtad_next;
+ dtrace_actdesc_release(act, vstate);
+ }
+
+ return (NULL);
+}
+
+static dtrace_ecbdesc_t *
+dtrace_dof_ecbdesc(dof_hdr_t *dof, dof_sec_t *sec, dtrace_vstate_t *vstate,
+ cred_t *cr)
+{
+ dtrace_ecbdesc_t *ep;
+ dof_ecbdesc_t *ecb;
+ dtrace_probedesc_t *desc;
+ dtrace_predicate_t *pred = NULL;
+
+ if (sec->dofs_size < sizeof (dof_ecbdesc_t)) {
+ dtrace_dof_error(dof, "truncated ECB description");
+ return (NULL);
+ }
+
+ if (sec->dofs_align != sizeof (uint64_t)) {
+ dtrace_dof_error(dof, "bad alignment in ECB description");
+ return (NULL);
+ }
+
+ ecb = (dof_ecbdesc_t *)((uintptr_t)dof + (uintptr_t)sec->dofs_offset);
+ sec = dtrace_dof_sect(dof, DOF_SECT_PROBEDESC, ecb->dofe_probes);
+
+ if (sec == NULL)
+ return (NULL);
+
+ ep = kmem_zalloc(sizeof (dtrace_ecbdesc_t), KM_SLEEP);
+ ep->dted_uarg = ecb->dofe_uarg;
+ desc = &ep->dted_probe;
+
+ if (dtrace_dof_probedesc(dof, sec, desc) == NULL)
+ goto err;
+
+ if (ecb->dofe_pred != DOF_SECIDX_NONE) {
+ if ((sec = dtrace_dof_sect(dof,
+ DOF_SECT_DIFOHDR, ecb->dofe_pred)) == NULL)
+ goto err;
+
+ if ((pred = dtrace_dof_predicate(dof, sec, vstate, cr)) == NULL)
+ goto err;
+
+ ep->dted_pred.dtpdd_predicate = pred;
+ }
+
+ if (ecb->dofe_actions != DOF_SECIDX_NONE) {
+ if ((sec = dtrace_dof_sect(dof,
+ DOF_SECT_ACTDESC, ecb->dofe_actions)) == NULL)
+ goto err;
+
+ ep->dted_action = dtrace_dof_actdesc(dof, sec, vstate, cr);
+
+ if (ep->dted_action == NULL)
+ goto err;
+ }
+
+ return (ep);
+
+err:
+ if (pred != NULL)
+ dtrace_predicate_release(pred, vstate);
+ kmem_free(ep, sizeof (dtrace_ecbdesc_t));
+ return (NULL);
+}
+
+/*
+ * Apply the relocations from the specified 'sec' (a DOF_SECT_URELHDR) to the
+ * specified DOF. At present, this amounts to simply adding 'ubase' to the
+ * site of any user SETX relocations to account for load object base address.
+ * In the future, if we need other relocations, this function can be extended.
+ */
+static int
+dtrace_dof_relocate(dof_hdr_t *dof, dof_sec_t *sec, uint64_t ubase)
+{
+ uintptr_t daddr = (uintptr_t)dof;
+ dof_relohdr_t *dofr =
+ (dof_relohdr_t *)(uintptr_t)(daddr + sec->dofs_offset);
+ dof_sec_t *ss, *rs, *ts;
+ dof_relodesc_t *r;
+ uint_t i, n;
+
+ if (sec->dofs_size < sizeof (dof_relohdr_t) ||
+ sec->dofs_align != sizeof (dof_secidx_t)) {
+ dtrace_dof_error(dof, "invalid relocation header");
+ return (-1);
+ }
+
+ ss = dtrace_dof_sect(dof, DOF_SECT_STRTAB, dofr->dofr_strtab);
+ rs = dtrace_dof_sect(dof, DOF_SECT_RELTAB, dofr->dofr_relsec);
+ ts = dtrace_dof_sect(dof, DOF_SECT_NONE, dofr->dofr_tgtsec);
+
+ if (ss == NULL || rs == NULL || ts == NULL)
+ return (-1); /* dtrace_dof_error() has been called already */
+
+ if (rs->dofs_entsize < sizeof (dof_relodesc_t) ||
+ rs->dofs_align != sizeof (uint64_t)) {
+ dtrace_dof_error(dof, "invalid relocation section");
+ return (-1);
+ }
+
+ r = (dof_relodesc_t *)(uintptr_t)(daddr + rs->dofs_offset);
+ n = rs->dofs_size / rs->dofs_entsize;
+
+ for (i = 0; i < n; i++) {
+ uintptr_t taddr = daddr + ts->dofs_offset + r->dofr_offset;
+
+ switch (r->dofr_type) {
+ case DOF_RELO_NONE:
+ break;
+ case DOF_RELO_SETX:
+ if (r->dofr_offset >= ts->dofs_size || r->dofr_offset +
+ sizeof (uint64_t) > ts->dofs_size) {
+ dtrace_dof_error(dof, "bad relocation offset");
+ return (-1);
+ }
+
+ if (!IS_P2ALIGNED(taddr, sizeof (uint64_t))) {
+ dtrace_dof_error(dof, "misaligned setx relo");
+ return (-1);
+ }
+
+ *(uint64_t *)taddr += ubase;
+ break;
+ default:
+ dtrace_dof_error(dof, "invalid relocation type");
+ return (-1);
+ }
+
+ r = (dof_relodesc_t *)((uintptr_t)r + rs->dofs_entsize);
+ }
+
+ return (0);
+}
+
+/*
+ * The dof_hdr_t passed to dtrace_dof_slurp() should be a partially validated
+ * header: it should be at the front of a memory region that is at least
+ * sizeof (dof_hdr_t) in size -- and then at least dof_hdr.dofh_loadsz in
+ * size. It need not be validated in any other way.
+ */
+static int
+dtrace_dof_slurp(dof_hdr_t *dof, dtrace_vstate_t *vstate, cred_t *cr,
+ dtrace_enabling_t **enabp, uint64_t ubase, int noprobes)
+{
+ uint64_t len = dof->dofh_loadsz, seclen;
+ uintptr_t daddr = (uintptr_t)dof;
+ dtrace_ecbdesc_t *ep;
+ dtrace_enabling_t *enab;
+ uint_t i;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(dof->dofh_loadsz >= sizeof (dof_hdr_t));
+
+ /*
+ * Check the DOF header identification bytes. In addition to checking
+ * valid settings, we also verify that unused bits/bytes are zeroed so
+ * we can use them later without fear of regressing existing binaries.
+ */
+ if (bcmp(&dof->dofh_ident[DOF_ID_MAG0],
+ DOF_MAG_STRING, DOF_MAG_STRLEN) != 0) {
+ dtrace_dof_error(dof, "DOF magic string mismatch");
+ return (-1);
+ }
+
+ if (dof->dofh_ident[DOF_ID_MODEL] != DOF_MODEL_ILP32 &&
+ dof->dofh_ident[DOF_ID_MODEL] != DOF_MODEL_LP64) {
+ dtrace_dof_error(dof, "DOF has invalid data model");
+ return (-1);
+ }
+
+ if (dof->dofh_ident[DOF_ID_ENCODING] != DOF_ENCODE_NATIVE) {
+ dtrace_dof_error(dof, "DOF encoding mismatch");
+ return (-1);
+ }
+
+ if (dof->dofh_ident[DOF_ID_VERSION] != DOF_VERSION_1 &&
+ dof->dofh_ident[DOF_ID_VERSION] != DOF_VERSION_2) {
+ dtrace_dof_error(dof, "DOF version mismatch");
+ return (-1);
+ }
+
+ if (dof->dofh_ident[DOF_ID_DIFVERS] != DIF_VERSION_2) {
+ dtrace_dof_error(dof, "DOF uses unsupported instruction set");
+ return (-1);
+ }
+
+ if (dof->dofh_ident[DOF_ID_DIFIREG] > DIF_DIR_NREGS) {
+ dtrace_dof_error(dof, "DOF uses too many integer registers");
+ return (-1);
+ }
+
+ if (dof->dofh_ident[DOF_ID_DIFTREG] > DIF_DTR_NREGS) {
+ dtrace_dof_error(dof, "DOF uses too many tuple registers");
+ return (-1);
+ }
+
+ for (i = DOF_ID_PAD; i < DOF_ID_SIZE; i++) {
+ if (dof->dofh_ident[i] != 0) {
+ dtrace_dof_error(dof, "DOF has invalid ident byte set");
+ return (-1);
+ }
+ }
+
+ if (dof->dofh_flags & ~DOF_FL_VALID) {
+ dtrace_dof_error(dof, "DOF has invalid flag bits set");
+ return (-1);
+ }
+
+ if (dof->dofh_secsize == 0) {
+ dtrace_dof_error(dof, "zero section header size");
+ return (-1);
+ }
+
+ /*
+ * Check that the section headers don't exceed the amount of DOF
+ * data. Note that we cast the section size and number of sections
+ * to uint64_t's to prevent possible overflow in the multiplication.
+ */
+ seclen = (uint64_t)dof->dofh_secnum * (uint64_t)dof->dofh_secsize;
+
+ if (dof->dofh_secoff > len || seclen > len ||
+ dof->dofh_secoff + seclen > len) {
+ dtrace_dof_error(dof, "truncated section headers");
+ return (-1);
+ }
+
+ if (!IS_P2ALIGNED(dof->dofh_secoff, sizeof (uint64_t))) {
+ dtrace_dof_error(dof, "misaligned section headers");
+ return (-1);
+ }
+
+ if (!IS_P2ALIGNED(dof->dofh_secsize, sizeof (uint64_t))) {
+ dtrace_dof_error(dof, "misaligned section size");
+ return (-1);
+ }
+
+ /*
+ * Take an initial pass through the section headers to be sure that
+ * the headers don't have stray offsets. If the 'noprobes' flag is
+ * set, do not permit sections relating to providers, probes, or args.
+ */
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)(daddr +
+ (uintptr_t)dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (noprobes) {
+ switch (sec->dofs_type) {
+ case DOF_SECT_PROVIDER:
+ case DOF_SECT_PROBES:
+ case DOF_SECT_PRARGS:
+ case DOF_SECT_PROFFS:
+ dtrace_dof_error(dof, "illegal sections "
+ "for enabling");
+ return (-1);
+ }
+ }
+
+ if (DOF_SEC_ISLOADABLE(sec->dofs_type) &&
+ !(sec->dofs_flags & DOF_SECF_LOAD)) {
+ dtrace_dof_error(dof, "loadable section with load "
+ "flag unset");
+ return (-1);
+ }
+
+ if (!(sec->dofs_flags & DOF_SECF_LOAD))
+ continue; /* just ignore non-loadable sections */
+
+ if (sec->dofs_align & (sec->dofs_align - 1)) {
+ dtrace_dof_error(dof, "bad section alignment");
+ return (-1);
+ }
+
+ if (sec->dofs_offset & (sec->dofs_align - 1)) {
+ dtrace_dof_error(dof, "misaligned section");
+ return (-1);
+ }
+
+ if (sec->dofs_offset > len || sec->dofs_size > len ||
+ sec->dofs_offset + sec->dofs_size > len) {
+ dtrace_dof_error(dof, "corrupt section header");
+ return (-1);
+ }
+
+ if (sec->dofs_type == DOF_SECT_STRTAB && *((char *)daddr +
+ sec->dofs_offset + sec->dofs_size - 1) != '\0') {
+ dtrace_dof_error(dof, "non-terminating string table");
+ return (-1);
+ }
+ }
+
+ /*
+ * Take a second pass through the sections and locate and perform any
+ * relocations that are present. We do this after the first pass to
+ * be sure that all sections have had their headers validated.
+ */
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)(daddr +
+ (uintptr_t)dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (!(sec->dofs_flags & DOF_SECF_LOAD))
+ continue; /* skip sections that are not loadable */
+
+ switch (sec->dofs_type) {
+ case DOF_SECT_URELHDR:
+ if (dtrace_dof_relocate(dof, sec, ubase) != 0)
+ return (-1);
+ break;
+ }
+ }
+
+ if ((enab = *enabp) == NULL)
+ enab = *enabp = dtrace_enabling_create(vstate);
+
+ for (i = 0; i < dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)(daddr +
+ (uintptr_t)dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (sec->dofs_type != DOF_SECT_ECBDESC)
+ continue;
+
+ if ((ep = dtrace_dof_ecbdesc(dof, sec, vstate, cr)) == NULL) {
+ dtrace_enabling_destroy(enab);
+ *enabp = NULL;
+ return (-1);
+ }
+
+ dtrace_enabling_add(enab, ep);
+ }
+
+ return (0);
+}
+
+/*
+ * Process DOF for any options. This routine assumes that the DOF has been
+ * at least processed by dtrace_dof_slurp().
+ */
+static int
+dtrace_dof_options(dof_hdr_t *dof, dtrace_state_t *state)
+{
+ int i, rval;
+ uint32_t entsize;
+ size_t offs;
+ dof_optdesc_t *desc;
+
+ for (i = 0; VBDTCAST(unsigned)i < dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)((uintptr_t)dof +
+ (uintptr_t)dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (sec->dofs_type != DOF_SECT_OPTDESC)
+ continue;
+
+ if (sec->dofs_align != sizeof (uint64_t)) {
+ dtrace_dof_error(dof, "bad alignment in "
+ "option description");
+ return (EINVAL);
+ }
+
+ if ((entsize = sec->dofs_entsize) == 0) {
+ dtrace_dof_error(dof, "zeroed option entry size");
+ return (EINVAL);
+ }
+
+ if (entsize < sizeof (dof_optdesc_t)) {
+ dtrace_dof_error(dof, "bad option entry size");
+ return (EINVAL);
+ }
+
+ for (offs = 0; offs < sec->dofs_size; offs += entsize) {
+ desc = (dof_optdesc_t *)((uintptr_t)dof +
+ (uintptr_t)sec->dofs_offset + offs);
+
+ if (desc->dofo_strtab != DOF_SECIDX_NONE) {
+ dtrace_dof_error(dof, "non-zero option string");
+ return (EINVAL);
+ }
+
+ if (desc->dofo_value == VBDTCAST(uint64_t)DTRACEOPT_UNSET) {
+ dtrace_dof_error(dof, "unset option");
+ return (EINVAL);
+ }
+
+ if ((rval = dtrace_state_option(state,
+ desc->dofo_option, desc->dofo_value)) != 0) {
+ dtrace_dof_error(dof, "rejected option");
+ return (rval);
+ }
+ }
+ }
+
+ return (0);
+}
+
+/*
+ * DTrace Consumer State Functions
+ */
+VBDTSTATIC int
+dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size)
+{
+ size_t hashsize, maxper, min, chunksize = dstate->dtds_chunksize;
+ void *base;
+ uintptr_t limit;
+ dtrace_dynvar_t *dvar, *next, *start;
+ VBDTTYPE(size_t,int) i;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(dstate->dtds_base == NULL && dstate->dtds_percpu == NULL);
+
+ bzero(dstate, sizeof (dtrace_dstate_t));
+
+ if ((dstate->dtds_chunksize = chunksize) == 0)
+ dstate->dtds_chunksize = DTRACE_DYNVAR_CHUNKSIZE;
+
+ if (size < (min = dstate->dtds_chunksize + sizeof (dtrace_dynhash_t)))
+ size = min;
+
+ if ((base = kmem_zalloc(size, KM_NOSLEEP)) == NULL)
+ return (ENOMEM);
+
+ dstate->dtds_size = size;
+ dstate->dtds_base = base;
+ dstate->dtds_percpu = kmem_cache_alloc(dtrace_state_cache, KM_SLEEP);
+ bzero(dstate->dtds_percpu, NCPU * sizeof (dtrace_dstate_percpu_t));
+
+ hashsize = size / (dstate->dtds_chunksize + sizeof (dtrace_dynhash_t));
+
+ if (hashsize != 1 && (hashsize & 1))
+ hashsize--;
+
+ dstate->dtds_hashsize = hashsize;
+ dstate->dtds_hash = dstate->dtds_base;
+
+ /*
+ * Set all of our hash buckets to point to the single sink, and (if
+ * it hasn't already been set), set the sink's hash value to be the
+ * sink sentinel value. The sink is needed for dynamic variable
+ * lookups to know that they have iterated over an entire, valid hash
+ * chain.
+ */
+ for (i = 0; i < hashsize; i++)
+ dstate->dtds_hash[i].dtdh_chain = &dtrace_dynhash_sink;
+
+ if (dtrace_dynhash_sink.dtdv_hashval != DTRACE_DYNHASH_SINK)
+ dtrace_dynhash_sink.dtdv_hashval = DTRACE_DYNHASH_SINK;
+
+ /*
+ * Determine number of active CPUs. Divide free list evenly among
+ * active CPUs.
+ */
+ start = (dtrace_dynvar_t *)
+ ((uintptr_t)base + hashsize * sizeof (dtrace_dynhash_t));
+ limit = (uintptr_t)base + size;
+
+ maxper = (limit - (uintptr_t)start) / NCPU;
+ maxper = (maxper / dstate->dtds_chunksize) * dstate->dtds_chunksize;
+
+ for (i = 0; i < NCPU; i++) {
+ dstate->dtds_percpu[i].dtdsc_free = dvar = start;
+
+ /*
+ * If we don't even have enough chunks to make it once through
+ * NCPUs, we're just going to allocate everything to the first
+ * CPU. And if we're on the last CPU, we're going to allocate
+ * whatever is left over. In either case, we set the limit to
+ * be the limit of the dynamic variable space.
+ */
+ if (maxper == 0 || i == NCPU - 1) {
+ limit = (uintptr_t)base + size;
+ start = NULL;
+ } else {
+ limit = (uintptr_t)start + maxper;
+ start = (dtrace_dynvar_t *)limit;
+ }
+
+ ASSERT(limit <= (uintptr_t)base + size);
+
+ for (;;) {
+ next = (dtrace_dynvar_t *)((uintptr_t)dvar +
+ dstate->dtds_chunksize);
+
+ if ((uintptr_t)next + dstate->dtds_chunksize >= limit)
+ break;
+
+ dvar->dtdv_next = next;
+ dvar = next;
+ }
+
+ if (maxper == 0)
+ break;
+ }
+
+ return (0);
+}
+
+VBDTSTATIC void
+dtrace_dstate_fini(dtrace_dstate_t *dstate)
+{
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ if (dstate->dtds_base == NULL)
+ return;
+
+ kmem_free(dstate->dtds_base, dstate->dtds_size);
+ kmem_cache_free(dtrace_state_cache, dstate->dtds_percpu);
+}
+
+static void
+dtrace_vstate_fini(dtrace_vstate_t *vstate)
+{
+ /*
+ * Logical XOR, where are you?
+ */
+ ASSERT((vstate->dtvs_nglobals == 0) ^ (vstate->dtvs_globals != NULL));
+
+ if (vstate->dtvs_nglobals > 0) {
+ kmem_free(vstate->dtvs_globals, vstate->dtvs_nglobals *
+ sizeof (dtrace_statvar_t *));
+ }
+
+ if (vstate->dtvs_ntlocals > 0) {
+ kmem_free(vstate->dtvs_tlocals, vstate->dtvs_ntlocals *
+ sizeof (dtrace_difv_t));
+ }
+
+ ASSERT((vstate->dtvs_nlocals == 0) ^ (vstate->dtvs_locals != NULL));
+
+ if (vstate->dtvs_nlocals > 0) {
+ kmem_free(vstate->dtvs_locals, vstate->dtvs_nlocals *
+ sizeof (dtrace_statvar_t *));
+ }
+}
+
+static void
+dtrace_state_clean(dtrace_state_t *state)
+{
+ if (state->dts_activity == DTRACE_ACTIVITY_INACTIVE)
+ return;
+
+ dtrace_dynvar_clean(&state->dts_vstate.dtvs_dynvars);
+ dtrace_speculation_clean(state);
+}
+#ifdef VBOX
+static DECLCALLBACK(void) dtrace_state_clean_timer(PRTTIMER pTimer, void *pvUser, uint64_t iTick)
+{
+ dtrace_state_clean((dtrace_state_t *)pvUser);
+ NOREF(pTimer); NOREF(iTick);
+}
+#endif
+
+static void
+dtrace_state_deadman(dtrace_state_t *state)
+{
+ hrtime_t now;
+
+ dtrace_sync();
+
+ now = dtrace_gethrtime();
+
+ if (state != dtrace_anon.dta_state &&
+ now - state->dts_laststatus >= dtrace_deadman_user)
+ return;
+
+ /*
+ * We must be sure that dts_alive never appears to be less than the
+ * value upon entry to dtrace_state_deadman(), and because we lack a
+ * dtrace_cas64(), we cannot store to it atomically. We thus instead
+ * store INT64_MAX to it, followed by a memory barrier, followed by
+ * the new value. This assures that dts_alive never appears to be
+ * less than its true value, regardless of the order in which the
+ * stores to the underlying storage are issued.
+ */
+ state->dts_alive = INT64_MAX;
+ dtrace_membar_producer();
+ state->dts_alive = now;
+}
+
+#ifdef VBOX
+static DECLCALLBACK(void) dtrace_state_deadman_timer(PRTTIMER pTimer, void *pvUser, uint64_t iTick)
+{
+ dtrace_state_deadman((dtrace_state_t *)pvUser);
+ NOREF(pTimer); NOREF(iTick);
+}
+#endif
+
+VBDTSTATIC dtrace_state_t *
+#ifdef VBOX
+dtrace_state_create(cred_t *cr)
+#else
+dtrace_state_create(dev_t *devp, cred_t *cr)
+#endif
+{
+#ifndef VBOX
+ minor_t minor;
+ major_t major;
+#endif
+ char c[30];
+ dtrace_state_t *state;
+ dtrace_optval_t *opt;
+ int bufsize = NCPU * sizeof (dtrace_buffer_t), i;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+#ifndef VBOX
+ minor = (minor_t)(uintptr_t)vmem_alloc(dtrace_minor, 1,
+ VM_BESTFIT | VM_SLEEP);
+
+ if (ddi_soft_state_zalloc(dtrace_softstate, minor) != DDI_SUCCESS) {
+ vmem_free(dtrace_minor, (void *)(uintptr_t)minor, 1);
+ return (NULL);
+ }
+
+ state = ddi_get_soft_state(dtrace_softstate, minor);
+#else
+ state = kmem_zalloc(sizeof (*state), KM_SLEEP);
+ if (!state) {
+ return (NULL);
+ }
+#endif
+ state->dts_epid = DTRACE_EPIDNONE + 1;
+
+#ifndef VBOX
+ (void) snprintf(c, sizeof (c), "dtrace_aggid_%d", minor);
+#else
+ (void) snprintf(c, sizeof (c), "dtrace_aggid_%p", state);
+#endif
+#ifndef VBOX /* Avoid idProbe = UINT32_MAX as it is used as invalid value by VTG. */
+ state->dts_aggid_arena = vmem_create(c, (void *)1, UINT32_MAX, 1,
+ NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
+#else
+ state->dts_aggid_arena = vmem_create(c, (void *)(uintptr_t)1, _1G, 1,
+ NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
+#endif
+
+#ifndef VBOX
+ if (devp != NULL) {
+ major = getemajor(*devp);
+ } else {
+ major = ddi_driver_major(dtrace_devi);
+ }
+
+ state->dts_dev = makedevice(major, minor);
+
+ if (devp != NULL)
+ *devp = state->dts_dev;
+#endif
+
+ /*
+ * We allocate NCPU buffers. On the one hand, this can be quite
+ * a bit of memory per instance (nearly 36K on a Starcat). On the
+ * other hand, it saves an additional memory reference in the probe
+ * path.
+ */
+ state->dts_buffer = kmem_zalloc(bufsize, KM_SLEEP);
+ state->dts_aggbuffer = kmem_zalloc(bufsize, KM_SLEEP);
+ state->dts_cleaner = CYCLIC_NONE;
+ state->dts_deadman = CYCLIC_NONE;
+ state->dts_vstate.dtvs_state = state;
+
+ for (i = 0; i < DTRACEOPT_MAX; i++)
+ state->dts_options[i] = DTRACEOPT_UNSET;
+
+ /*
+ * Set the default options.
+ */
+ opt = state->dts_options;
+ opt[DTRACEOPT_BUFPOLICY] = DTRACEOPT_BUFPOLICY_SWITCH;
+ opt[DTRACEOPT_BUFRESIZE] = DTRACEOPT_BUFRESIZE_AUTO;
+ opt[DTRACEOPT_NSPEC] = dtrace_nspec_default;
+ opt[DTRACEOPT_SPECSIZE] = dtrace_specsize_default;
+ opt[DTRACEOPT_CPU] = (dtrace_optval_t)DTRACE_CPUALL;
+ opt[DTRACEOPT_STRSIZE] = dtrace_strsize_default;
+ opt[DTRACEOPT_STACKFRAMES] = dtrace_stackframes_default;
+ opt[DTRACEOPT_USTACKFRAMES] = dtrace_ustackframes_default;
+ opt[DTRACEOPT_CLEANRATE] = dtrace_cleanrate_default;
+ opt[DTRACEOPT_AGGRATE] = dtrace_aggrate_default;
+ opt[DTRACEOPT_SWITCHRATE] = dtrace_switchrate_default;
+ opt[DTRACEOPT_STATUSRATE] = dtrace_statusrate_default;
+ opt[DTRACEOPT_JSTACKFRAMES] = dtrace_jstackframes_default;
+ opt[DTRACEOPT_JSTACKSTRSIZE] = dtrace_jstackstrsize_default;
+
+ state->dts_activity = DTRACE_ACTIVITY_INACTIVE;
+
+ /*
+ * Depending on the user credentials, we set flag bits which alter probe
+ * visibility or the amount of destructiveness allowed. In the case of
+ * actual anonymous tracing, or the possession of all privileges, all of
+ * the normal checks are bypassed.
+ */
+ if (cr == NULL || PRIV_POLICY_ONLY(cr, PRIV_ALL, B_FALSE)) {
+ state->dts_cred.dcr_visible = DTRACE_CRV_ALL;
+ state->dts_cred.dcr_action = DTRACE_CRA_ALL;
+ } else {
+ /*
+ * Set up the credentials for this instantiation. We take a
+ * hold on the credential to prevent it from disappearing on
+ * us; this in turn prevents the zone_t referenced by this
+ * credential from disappearing. This means that we can
+ * examine the credential and the zone from probe context.
+ */
+ crhold(cr);
+ state->dts_cred.dcr_cred = cr;
+
+ /*
+ * CRA_PROC means "we have *some* privilege for dtrace" and
+ * unlocks the use of variables like pid, zonename, etc.
+ */
+ if (PRIV_POLICY_ONLY(cr, PRIV_DTRACE_USER, B_FALSE) ||
+ PRIV_POLICY_ONLY(cr, PRIV_DTRACE_PROC, B_FALSE)) {
+ state->dts_cred.dcr_action |= DTRACE_CRA_PROC;
+ }
+
+ /*
+ * dtrace_user allows use of syscall and profile providers.
+ * If the user also has proc_owner and/or proc_zone, we
+ * extend the scope to include additional visibility and
+ * destructive power.
+ */
+ if (PRIV_POLICY_ONLY(cr, PRIV_DTRACE_USER, B_FALSE)) {
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_OWNER, B_FALSE)) {
+ state->dts_cred.dcr_visible |=
+ DTRACE_CRV_ALLPROC;
+
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER;
+ }
+
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_ZONE, B_FALSE)) {
+ state->dts_cred.dcr_visible |=
+ DTRACE_CRV_ALLZONE;
+
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE;
+ }
+
+ /*
+ * If we have all privs in whatever zone this is,
+ * we can do destructive things to processes which
+ * have altered credentials.
+ */
+ if (priv_isequalset(priv_getset(cr, PRIV_EFFECTIVE),
+ cr->cr_zone->zone_privset)) {
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG;
+ }
+ }
+
+ /*
+ * Holding the dtrace_kernel privilege also implies that
+ * the user has the dtrace_user privilege from a visibility
+ * perspective. But without further privileges, some
+ * destructive actions are not available.
+ */
+ if (PRIV_POLICY_ONLY(cr, PRIV_DTRACE_KERNEL, B_FALSE)) {
+ /*
+ * Make all probes in all zones visible. However,
+ * this doesn't mean that all actions become available
+ * to all zones.
+ */
+ state->dts_cred.dcr_visible |= DTRACE_CRV_KERNEL |
+ DTRACE_CRV_ALLPROC | DTRACE_CRV_ALLZONE;
+
+ state->dts_cred.dcr_action |= DTRACE_CRA_KERNEL |
+ DTRACE_CRA_PROC;
+ /*
+ * Holding proc_owner means that destructive actions
+ * for *this* zone are allowed.
+ */
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_OWNER, B_FALSE))
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER;
+
+ /*
+ * Holding proc_zone means that destructive actions
+ * for this user/group ID in all zones is allowed.
+ */
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_ZONE, B_FALSE))
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE;
+
+ /*
+ * If we have all privs in whatever zone this is,
+ * we can do destructive things to processes which
+ * have altered credentials.
+ */
+ if (priv_isequalset(priv_getset(cr, PRIV_EFFECTIVE),
+ cr->cr_zone->zone_privset)) {
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG;
+ }
+ }
+
+ /*
+ * Holding the dtrace_proc privilege gives control over fasttrap
+ * and pid providers. We need to grant wider destructive
+ * privileges in the event that the user has proc_owner and/or
+ * proc_zone.
+ */
+ if (PRIV_POLICY_ONLY(cr, PRIV_DTRACE_PROC, B_FALSE)) {
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_OWNER, B_FALSE))
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER;
+
+ if (PRIV_POLICY_ONLY(cr, PRIV_PROC_ZONE, B_FALSE))
+ state->dts_cred.dcr_action |=
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE;
+ }
+ }
+
+ return (state);
+}
+
+static int
+dtrace_state_buffer(dtrace_state_t *state, dtrace_buffer_t *buf, int which)
+{
+ dtrace_optval_t *opt = state->dts_options, size;
+ processorid_t cpu VBDTUNASS((processorid_t)DTRACE_CPUALL);
+ int flags = 0, rval;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(MUTEX_HELD(&cpu_lock));
+ ASSERT(which < DTRACEOPT_MAX);
+ ASSERT(state->dts_activity == DTRACE_ACTIVITY_INACTIVE ||
+ (state == dtrace_anon.dta_state &&
+ state->dts_activity == DTRACE_ACTIVITY_ACTIVE));
+
+ if (opt[which] == DTRACEOPT_UNSET || opt[which] == 0)
+ return (0);
+
+ if (opt[DTRACEOPT_CPU] != DTRACEOPT_UNSET)
+ cpu = opt[DTRACEOPT_CPU];
+
+ if (which == DTRACEOPT_SPECSIZE)
+ flags |= DTRACEBUF_NOSWITCH;
+
+ if (which == DTRACEOPT_BUFSIZE) {
+ if (opt[DTRACEOPT_BUFPOLICY] == DTRACEOPT_BUFPOLICY_RING)
+ flags |= DTRACEBUF_RING;
+
+ if (opt[DTRACEOPT_BUFPOLICY] == DTRACEOPT_BUFPOLICY_FILL)
+ flags |= DTRACEBUF_FILL;
+
+ if (state != dtrace_anon.dta_state ||
+ state->dts_activity != DTRACE_ACTIVITY_ACTIVE)
+ flags |= DTRACEBUF_INACTIVE;
+ }
+
+ for (size = opt[which]; size >= VBDTCAST(dtrace_optval_t)sizeof (uint64_t); size >>= 1) {
+ /*
+ * The size must be 8-byte aligned. If the size is not 8-byte
+ * aligned, drop it down by the difference.
+ */
+ if (size & (sizeof (uint64_t) - 1))
+ size -= size & (sizeof (uint64_t) - 1);
+
+ if (size < state->dts_reserve) {
+ /*
+ * Buffers always must be large enough to accommodate
+ * their prereserved space. We return E2BIG instead
+ * of ENOMEM in this case to allow for user-level
+ * software to differentiate the cases.
+ */
+ return (E2BIG);
+ }
+
+ rval = dtrace_buffer_alloc(buf, size, flags, cpu);
+
+ if (rval != ENOMEM) {
+ opt[which] = size;
+ return (rval);
+ }
+
+ if (opt[DTRACEOPT_BUFRESIZE] == DTRACEOPT_BUFRESIZE_MANUAL)
+ return (rval);
+ }
+
+ return (ENOMEM);
+}
+
+static int
+dtrace_state_buffers(dtrace_state_t *state)
+{
+ dtrace_speculation_t *spec = state->dts_speculations;
+ int rval, i;
+
+ if ((rval = dtrace_state_buffer(state, state->dts_buffer,
+ DTRACEOPT_BUFSIZE)) != 0)
+ return (rval);
+
+ if ((rval = dtrace_state_buffer(state, state->dts_aggbuffer,
+ DTRACEOPT_AGGSIZE)) != 0)
+ return (rval);
+
+ for (i = 0; i < state->dts_nspeculations; i++) {
+ if ((rval = dtrace_state_buffer(state,
+ spec[i].dtsp_buffer, DTRACEOPT_SPECSIZE)) != 0)
+ return (rval);
+ }
+
+ return (0);
+}
+
+static void
+dtrace_state_prereserve(dtrace_state_t *state)
+{
+ dtrace_ecb_t *ecb;
+ dtrace_probe_t *probe;
+
+ state->dts_reserve = 0;
+
+ if (state->dts_options[DTRACEOPT_BUFPOLICY] != DTRACEOPT_BUFPOLICY_FILL)
+ return;
+
+ /*
+ * If our buffer policy is a "fill" buffer policy, we need to set the
+ * prereserved space to be the space required by the END probes.
+ */
+ probe = dtrace_probes[dtrace_probeid_end - 1];
+ ASSERT(probe != NULL);
+
+ for (ecb = probe->dtpr_ecb; ecb != NULL; ecb = ecb->dte_next) {
+ if (ecb->dte_state != state)
+ continue;
+
+ state->dts_reserve += VBDTCAST(uint32_t)ecb->dte_needed + ecb->dte_alignment;
+ }
+}
+
+static int
+dtrace_state_go(dtrace_state_t *state, processorid_t *cpu)
+{
+ dtrace_optval_t *opt = state->dts_options, sz, nspec;
+ dtrace_speculation_t *spec;
+ dtrace_buffer_t *buf;
+#ifndef VBOX
+ cyc_handler_t hdlr;
+ cyc_time_t when;
+#endif
+ int rval = 0, i, bufsize = NCPU * sizeof (dtrace_buffer_t);
+ dtrace_icookie_t cookie;
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_lock);
+
+ if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE) {
+ rval = EBUSY;
+ goto out;
+ }
+
+ /*
+ * Before we can perform any checks, we must prime all of the
+ * retained enablings that correspond to this state.
+ */
+ dtrace_enabling_prime(state);
+
+ if (state->dts_destructive && !state->dts_cred.dcr_destructive) {
+ rval = EACCES;
+ goto out;
+ }
+
+ dtrace_state_prereserve(state);
+
+ /*
+ * Now we want to do is try to allocate our speculations.
+ * We do not automatically resize the number of speculations; if
+ * this fails, we will fail the operation.
+ */
+ nspec = opt[DTRACEOPT_NSPEC];
+ ASSERT(nspec != DTRACEOPT_UNSET);
+
+ if (nspec > INT_MAX) {
+ rval = ENOMEM;
+ goto out;
+ }
+
+ spec = kmem_zalloc(nspec * sizeof (dtrace_speculation_t), KM_NOSLEEP);
+
+ if (spec == NULL) {
+ rval = ENOMEM;
+ goto out;
+ }
+
+ state->dts_speculations = spec;
+ state->dts_nspeculations = (int)nspec;
+
+ for (i = 0; i < nspec; i++) {
+ if ((buf = kmem_zalloc(bufsize, KM_NOSLEEP)) == NULL) {
+ rval = ENOMEM;
+ goto err;
+ }
+
+ spec[i].dtsp_buffer = buf;
+ }
+
+ if (opt[DTRACEOPT_GRABANON] != DTRACEOPT_UNSET) {
+ if (dtrace_anon.dta_state == NULL) {
+ rval = ENOENT;
+ goto out;
+ }
+
+ if (state->dts_necbs != 0) {
+ rval = EALREADY;
+ goto out;
+ }
+
+ state->dts_anon = dtrace_anon_grab();
+ ASSERT(state->dts_anon != NULL);
+ state = state->dts_anon;
+
+ /*
+ * We want "grabanon" to be set in the grabbed state, so we'll
+ * copy that option value from the grabbing state into the
+ * grabbed state.
+ */
+ state->dts_options[DTRACEOPT_GRABANON] =
+ opt[DTRACEOPT_GRABANON];
+
+ *cpu = dtrace_anon.dta_beganon;
+
+ /*
+ * If the anonymous state is active (as it almost certainly
+ * is if the anonymous enabling ultimately matched anything),
+ * we don't allow any further option processing -- but we
+ * don't return failure.
+ */
+ if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE)
+ goto out;
+ }
+
+ if (opt[DTRACEOPT_AGGSIZE] != DTRACEOPT_UNSET &&
+ opt[DTRACEOPT_AGGSIZE] != 0) {
+ if (state->dts_aggregations == NULL) {
+ /*
+ * We're not going to create an aggregation buffer
+ * because we don't have any ECBs that contain
+ * aggregations -- set this option to 0.
+ */
+ opt[DTRACEOPT_AGGSIZE] = 0;
+ } else {
+ /*
+ * If we have an aggregation buffer, we must also have
+ * a buffer to use as scratch.
+ */
+ if (opt[DTRACEOPT_BUFSIZE] == DTRACEOPT_UNSET ||
+ opt[DTRACEOPT_BUFSIZE] < VBDTCAST(dtrace_optval_t)state->dts_needed) {
+ opt[DTRACEOPT_BUFSIZE] = state->dts_needed;
+ }
+ }
+ }
+
+ if (opt[DTRACEOPT_SPECSIZE] != DTRACEOPT_UNSET &&
+ opt[DTRACEOPT_SPECSIZE] != 0) {
+ if (!state->dts_speculates) {
+ /*
+ * We're not going to create speculation buffers
+ * because we don't have any ECBs that actually
+ * speculate -- set the speculation size to 0.
+ */
+ opt[DTRACEOPT_SPECSIZE] = 0;
+ }
+ }
+
+ /*
+ * The bare minimum size for any buffer that we're actually going to
+ * do anything to is sizeof (uint64_t).
+ */
+ sz = sizeof (uint64_t);
+
+ if ((state->dts_needed != 0 && opt[DTRACEOPT_BUFSIZE] < sz) ||
+ (state->dts_speculates && opt[DTRACEOPT_SPECSIZE] < sz) ||
+ (state->dts_aggregations != NULL && opt[DTRACEOPT_AGGSIZE] < sz)) {
+ /*
+ * A buffer size has been explicitly set to 0 (or to a size
+ * that will be adjusted to 0) and we need the space -- we
+ * need to return failure. We return ENOSPC to differentiate
+ * it from failing to allocate a buffer due to failure to meet
+ * the reserve (for which we return E2BIG).
+ */
+ rval = ENOSPC;
+ goto out;
+ }
+
+ if ((rval = dtrace_state_buffers(state)) != 0)
+ goto err;
+
+ if ((sz = opt[DTRACEOPT_DYNVARSIZE]) == DTRACEOPT_UNSET)
+ sz = dtrace_dstate_defsize;
+
+ do {
+ rval = dtrace_dstate_init(&state->dts_vstate.dtvs_dynvars, sz);
+
+ if (rval == 0)
+ break;
+
+ if (opt[DTRACEOPT_BUFRESIZE] == DTRACEOPT_BUFRESIZE_MANUAL)
+ goto err;
+ } while (sz >>= 1);
+
+ opt[DTRACEOPT_DYNVARSIZE] = sz;
+
+ if (rval != 0)
+ goto err;
+
+ if (opt[DTRACEOPT_STATUSRATE] > dtrace_statusrate_max)
+ opt[DTRACEOPT_STATUSRATE] = dtrace_statusrate_max;
+
+ if (opt[DTRACEOPT_CLEANRATE] == 0)
+ opt[DTRACEOPT_CLEANRATE] = dtrace_cleanrate_max;
+
+ if (opt[DTRACEOPT_CLEANRATE] < dtrace_cleanrate_min)
+ opt[DTRACEOPT_CLEANRATE] = dtrace_cleanrate_min;
+
+ if (opt[DTRACEOPT_CLEANRATE] > dtrace_cleanrate_max)
+ opt[DTRACEOPT_CLEANRATE] = dtrace_cleanrate_max;
+
+#ifndef VBOX
+ hdlr.cyh_func = (cyc_func_t)dtrace_state_clean;
+ hdlr.cyh_arg = state;
+ hdlr.cyh_level = CY_LOW_LEVEL;
+
+ when.cyt_when = 0;
+ when.cyt_interval = opt[DTRACEOPT_CLEANRATE];
+
+ state->dts_cleaner = cyclic_add(&hdlr, &when);
+
+ hdlr.cyh_func = (cyc_func_t)dtrace_state_deadman;
+ hdlr.cyh_arg = state;
+ hdlr.cyh_level = CY_LOW_LEVEL;
+
+ when.cyt_when = 0;
+ when.cyt_interval = dtrace_deadman_interval;
+
+ state->dts_alive = state->dts_laststatus = dtrace_gethrtime();
+ state->dts_deadman = cyclic_add(&hdlr, &when);
+#else /* VBOX */
+
+ rval = RTTimerCreateEx(&state->dts_cleaner, opt[DTRACEOPT_CLEANRATE],
+ RTTIMER_FLAGS_CPU_ANY, dtrace_state_clean_timer, state);
+ if (RT_FAILURE(rval)) {
+ rval = RTErrConvertToErrno(rval);
+ goto err;
+ }
+
+ state->dts_alive = state->dts_laststatus = dtrace_gethrtime();
+ rval = RTTimerCreateEx(&state->dts_deadman, dtrace_deadman_interval,
+ RTTIMER_FLAGS_CPU_ANY, dtrace_state_deadman_timer, state);
+ if (RT_FAILURE(rval)) {
+ RTTimerDestroy(state->dts_cleaner);
+ state->dts_cleaner = CYCLIC_NONE;
+ state->dts_deadman = CYCLIC_NONE;
+ rval = RTErrConvertToErrno(rval);
+ goto err;
+ }
+
+ rval = RTTimerStart(state->dts_cleaner, 0);
+ if (RT_SUCCESS(rval))
+ rval = RTTimerStart(state->dts_deadman, 0);
+ if (RT_FAILURE(rval)) {
+ rval = RTErrConvertToErrno(rval);
+ goto err;
+ }
+#endif /* VBOX */
+
+ state->dts_activity = DTRACE_ACTIVITY_WARMUP;
+
+ /*
+ * Now it's time to actually fire the BEGIN probe. We need to disable
+ * interrupts here both to record the CPU on which we fired the BEGIN
+ * probe (the data from this CPU will be processed first at user
+ * level) and to manually activate the buffer for this CPU.
+ */
+ cookie = dtrace_interrupt_disable();
+ *cpu = VBDT_GET_CPUID();
+ ASSERT(state->dts_buffer[*cpu].dtb_flags & DTRACEBUF_INACTIVE);
+ state->dts_buffer[*cpu].dtb_flags &= ~DTRACEBUF_INACTIVE;
+
+ dtrace_probe(dtrace_probeid_begin,
+ (uint64_t)(uintptr_t)state, 0, 0, 0, 0);
+ dtrace_interrupt_enable(cookie);
+ /*
+ * We may have had an exit action from a BEGIN probe; only change our
+ * state to ACTIVE if we're still in WARMUP.
+ */
+ ASSERT(state->dts_activity == DTRACE_ACTIVITY_WARMUP ||
+ state->dts_activity == DTRACE_ACTIVITY_DRAINING);
+
+ if (state->dts_activity == DTRACE_ACTIVITY_WARMUP)
+ state->dts_activity = DTRACE_ACTIVITY_ACTIVE;
+
+ /*
+ * Regardless of whether or not now we're in ACTIVE or DRAINING, we
+ * want each CPU to transition its principal buffer out of the
+ * INACTIVE state. Doing this assures that no CPU will suddenly begin
+ * processing an ECB halfway down a probe's ECB chain; all CPUs will
+ * atomically transition from processing none of a state's ECBs to
+ * processing all of them.
+ */
+#ifndef VBOX
+ dtrace_xcall(DTRACE_CPUALL,
+ (dtrace_xcall_t)dtrace_buffer_activate, state);
+#else
+ RTMpOnAll(dtrace_buffer_activate_wrapper, state, NULL);
+#endif
+ goto out;
+
+err:
+ dtrace_buffer_free(state->dts_buffer);
+ dtrace_buffer_free(state->dts_aggbuffer);
+
+ if ((nspec = state->dts_nspeculations) == 0) {
+ ASSERT(state->dts_speculations == NULL);
+ goto out;
+ }
+
+ spec = state->dts_speculations;
+ ASSERT(spec != NULL);
+
+ for (i = 0; i < state->dts_nspeculations; i++) {
+ if ((buf = spec[i].dtsp_buffer) == NULL)
+ break;
+
+ dtrace_buffer_free(buf);
+ kmem_free(buf, bufsize);
+ }
+
+ kmem_free(spec, nspec * sizeof (dtrace_speculation_t));
+ state->dts_nspeculations = 0;
+ state->dts_speculations = NULL;
+
+out:
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+
+ return (rval);
+}
+
+static int
+dtrace_state_stop(dtrace_state_t *state, processorid_t *cpu)
+{
+ dtrace_icookie_t cookie;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (state->dts_activity != DTRACE_ACTIVITY_ACTIVE &&
+ state->dts_activity != DTRACE_ACTIVITY_DRAINING)
+ return (EINVAL);
+
+ /*
+ * We'll set the activity to DTRACE_ACTIVITY_DRAINING, and issue a sync
+ * to be sure that every CPU has seen it. See below for the details
+ * on why this is done.
+ */
+ state->dts_activity = DTRACE_ACTIVITY_DRAINING;
+ dtrace_sync();
+
+ /*
+ * By this point, it is impossible for any CPU to be still processing
+ * with DTRACE_ACTIVITY_ACTIVE. We can thus set our activity to
+ * DTRACE_ACTIVITY_COOLDOWN and know that we're not racing with any
+ * other CPU in dtrace_buffer_reserve(). This allows dtrace_probe()
+ * and callees to know that the activity is DTRACE_ACTIVITY_COOLDOWN
+ * iff we're in the END probe.
+ */
+ state->dts_activity = DTRACE_ACTIVITY_COOLDOWN;
+ dtrace_sync();
+ ASSERT(state->dts_activity == DTRACE_ACTIVITY_COOLDOWN);
+
+ /*
+ * Finally, we can release the reserve and call the END probe. We
+ * disable interrupts across calling the END probe to allow us to
+ * return the CPU on which we actually called the END probe. This
+ * allows user-land to be sure that this CPU's principal buffer is
+ * processed last.
+ */
+ state->dts_reserve = 0;
+
+ cookie = dtrace_interrupt_disable();
+ *cpu = VBDT_GET_CPUID();
+ dtrace_probe(dtrace_probeid_end,
+ (uint64_t)(uintptr_t)state, 0, 0, 0, 0);
+ dtrace_interrupt_enable(cookie);
+
+ state->dts_activity = DTRACE_ACTIVITY_STOPPED;
+ dtrace_sync();
+
+ return (0);
+}
+
+static int
+dtrace_state_option(dtrace_state_t *state, dtrace_optid_t option,
+ dtrace_optval_t val)
+{
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE)
+ return (EBUSY);
+
+ if (option >= DTRACEOPT_MAX)
+ return (EINVAL);
+
+ if (option != DTRACEOPT_CPU && val < 0)
+ return (EINVAL);
+
+ switch (option) {
+ case DTRACEOPT_DESTRUCTIVE:
+ if (dtrace_destructive_disallow)
+ return (EACCES);
+
+ state->dts_cred.dcr_destructive = 1;
+ break;
+
+ case DTRACEOPT_BUFSIZE:
+ case DTRACEOPT_DYNVARSIZE:
+ case DTRACEOPT_AGGSIZE:
+ case DTRACEOPT_SPECSIZE:
+ case DTRACEOPT_STRSIZE:
+ if (val < 0)
+ return (EINVAL);
+
+ if (val >= LONG_MAX) {
+ /*
+ * If this is an otherwise negative value, set it to
+ * the highest multiple of 128m less than LONG_MAX.
+ * Technically, we're adjusting the size without
+ * regard to the buffer resizing policy, but in fact,
+ * this has no effect -- if we set the buffer size to
+ * ~LONG_MAX and the buffer policy is ultimately set to
+ * be "manual", the buffer allocation is guaranteed to
+ * fail, if only because the allocation requires two
+ * buffers. (We set the the size to the highest
+ * multiple of 128m because it ensures that the size
+ * will remain a multiple of a megabyte when
+ * repeatedly halved -- all the way down to 15m.)
+ */
+ val = LONG_MAX - (1 << 27) + 1;
+ }
+ }
+
+ state->dts_options[option] = val;
+
+ return (0);
+}
+
+static void
+dtrace_state_destroy(dtrace_state_t *state)
+{
+ dtrace_ecb_t *ecb;
+ dtrace_vstate_t *vstate = &state->dts_vstate;
+#ifndef VBOX
+ minor_t minor = getminor(state->dts_dev);
+#endif
+ int i, bufsize = NCPU * sizeof (dtrace_buffer_t);
+ dtrace_speculation_t *spec = state->dts_speculations;
+ int nspec = state->dts_nspeculations;
+ uint32_t match;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ /*
+ * First, retract any retained enablings for this state.
+ */
+ dtrace_enabling_retract(state);
+ ASSERT(state->dts_nretained == 0);
+
+ if (state->dts_activity == DTRACE_ACTIVITY_ACTIVE ||
+ state->dts_activity == DTRACE_ACTIVITY_DRAINING) {
+ /*
+ * We have managed to come into dtrace_state_destroy() on a
+ * hot enabling -- almost certainly because of a disorderly
+ * shutdown of a consumer. (That is, a consumer that is
+ * exiting without having called dtrace_stop().) In this case,
+ * we're going to set our activity to be KILLED, and then
+ * issue a sync to be sure that everyone is out of probe
+ * context before we start blowing away ECBs.
+ */
+ state->dts_activity = DTRACE_ACTIVITY_KILLED;
+ dtrace_sync();
+ }
+
+ /*
+ * Release the credential hold we took in dtrace_state_create().
+ */
+ if (state->dts_cred.dcr_cred != NULL)
+ crfree(state->dts_cred.dcr_cred);
+
+ /*
+ * Now we can safely disable and destroy any enabled probes. Because
+ * any DTRACE_PRIV_KERNEL probes may actually be slowing our progress
+ * (especially if they're all enabled), we take two passes through the
+ * ECBs: in the first, we disable just DTRACE_PRIV_KERNEL probes, and
+ * in the second we disable whatever is left over.
+ */
+ for (match = DTRACE_PRIV_KERNEL; ; match = 0) {
+ for (i = 0; i < state->dts_necbs; i++) {
+ if ((ecb = state->dts_ecbs[i]) == NULL)
+ continue;
+
+ if (match && ecb->dte_probe != NULL) {
+ dtrace_probe_t *probe = ecb->dte_probe;
+ dtrace_provider_t *prov = probe->dtpr_provider;
+
+ if (!(prov->dtpv_priv.dtpp_flags & match))
+ continue;
+ }
+
+ dtrace_ecb_disable(ecb);
+ dtrace_ecb_destroy(ecb);
+ }
+
+ if (!match)
+ break;
+ }
+
+ /*
+ * Before we free the buffers, perform one more sync to assure that
+ * every CPU is out of probe context.
+ */
+ dtrace_sync();
+
+ dtrace_buffer_free(state->dts_buffer);
+ dtrace_buffer_free(state->dts_aggbuffer);
+
+ for (i = 0; i < nspec; i++)
+ dtrace_buffer_free(spec[i].dtsp_buffer);
+
+ if (state->dts_cleaner != CYCLIC_NONE)
+ cyclic_remove(state->dts_cleaner);
+
+ if (state->dts_deadman != CYCLIC_NONE)
+ cyclic_remove(state->dts_deadman);
+
+ dtrace_dstate_fini(&vstate->dtvs_dynvars);
+ dtrace_vstate_fini(vstate);
+ kmem_free(state->dts_ecbs, state->dts_necbs * sizeof (dtrace_ecb_t *));
+
+ if (state->dts_aggregations != NULL) {
+#ifdef DEBUG
+ for (i = 0; i < state->dts_naggregations; i++)
+ ASSERT(state->dts_aggregations[i] == NULL);
+#endif
+ ASSERT(state->dts_naggregations > 0);
+ kmem_free(state->dts_aggregations,
+ state->dts_naggregations * sizeof (dtrace_aggregation_t *));
+ }
+
+ kmem_free(state->dts_buffer, bufsize);
+ kmem_free(state->dts_aggbuffer, bufsize);
+
+ for (i = 0; i < nspec; i++)
+ kmem_free(spec[i].dtsp_buffer, bufsize);
+
+ kmem_free(spec, nspec * sizeof (dtrace_speculation_t));
+
+ dtrace_format_destroy(state);
+
+ vmem_destroy(state->dts_aggid_arena);
+#ifndef VBOX
+ ddi_soft_state_free(dtrace_softstate, minor);
+ vmem_free(dtrace_minor, (void *)(uintptr_t)minor, 1);
+#else
+ kmem_free(state, sizeof (*state));
+#endif
+}
+
+/*
+ * DTrace Anonymous Enabling Functions
+ */
+static dtrace_state_t *
+dtrace_anon_grab(void)
+{
+ dtrace_state_t *state;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if ((state = dtrace_anon.dta_state) == NULL) {
+ ASSERT(dtrace_anon.dta_enabling == NULL);
+ return (NULL);
+ }
+
+ ASSERT(dtrace_anon.dta_enabling != NULL);
+ ASSERT(dtrace_retained != NULL);
+
+ dtrace_enabling_destroy(dtrace_anon.dta_enabling);
+ dtrace_anon.dta_enabling = NULL;
+ dtrace_anon.dta_state = NULL;
+
+ return (state);
+}
+
+#ifndef VBOX
+static void
+dtrace_anon_property(void)
+{
+ int i, rv;
+ dtrace_state_t *state;
+ dof_hdr_t *dof;
+ char c[32]; /* enough for "dof-data-" + digits */
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ for (i = 0; ; i++) {
+ (void) snprintf(c, sizeof (c), "dof-data-%d", i);
+
+ dtrace_err_verbose = 1;
+
+ if ((dof = dtrace_dof_property(c)) == NULL) {
+ dtrace_err_verbose = 0;
+ break;
+ }
+
+#ifndef VBOX
+ /*
+ * We want to create anonymous state, so we need to transition
+ * the kernel debugger to indicate that DTrace is active. If
+ * this fails (e.g. because the debugger has modified text in
+ * some way), we won't continue with the processing.
+ */
+ if (kdi_dtrace_set(KDI_DTSET_DTRACE_ACTIVATE) != 0) {
+ cmn_err(CE_NOTE, "kernel debugger active; anonymous "
+ "enabling ignored.");
+ dtrace_dof_destroy(dof);
+ break;
+ }
+#endif
+
+ /*
+ * If we haven't allocated an anonymous state, we'll do so now.
+ */
+ if ((state = dtrace_anon.dta_state) == NULL) {
+ state = dtrace_state_create(NULL, NULL);
+ dtrace_anon.dta_state = state;
+
+ if (state == NULL) {
+ /*
+ * This basically shouldn't happen: the only
+ * failure mode from dtrace_state_create() is a
+ * failure of ddi_soft_state_zalloc() that
+ * itself should never happen. Still, the
+ * interface allows for a failure mode, and
+ * we want to fail as gracefully as possible:
+ * we'll emit an error message and cease
+ * processing anonymous state in this case.
+ */
+ cmn_err(CE_WARN, "failed to create "
+ "anonymous state");
+ dtrace_dof_destroy(dof);
+ break;
+ }
+ }
+
+ rv = dtrace_dof_slurp(dof, &state->dts_vstate, CRED(),
+ &dtrace_anon.dta_enabling, 0, B_TRUE);
+
+ if (rv == 0)
+ rv = dtrace_dof_options(dof, state);
+
+ dtrace_err_verbose = 0;
+ dtrace_dof_destroy(dof);
+
+ if (rv != 0) {
+ /*
+ * This is malformed DOF; chuck any anonymous state
+ * that we created.
+ */
+ ASSERT(dtrace_anon.dta_enabling == NULL);
+ dtrace_state_destroy(state);
+ dtrace_anon.dta_state = NULL;
+ break;
+ }
+
+ ASSERT(dtrace_anon.dta_enabling != NULL);
+ }
+
+ if (dtrace_anon.dta_enabling != NULL) {
+ int rval;
+
+ /*
+ * dtrace_enabling_retain() can only fail because we are
+ * trying to retain more enablings than are allowed -- but
+ * we only have one anonymous enabling, and we are guaranteed
+ * to be allowed at least one retained enabling; we assert
+ * that dtrace_enabling_retain() returns success.
+ */
+ rval = dtrace_enabling_retain(dtrace_anon.dta_enabling);
+ ASSERT(rval == 0);
+
+ dtrace_enabling_dump(dtrace_anon.dta_enabling);
+ }
+}
+#endif /* !VBOX */
+
+/*
+ * DTrace Helper Functions
+ */
+#ifndef VBOX /* No helper stuff */
+static void
+dtrace_helper_trace(dtrace_helper_action_t *helper,
+ dtrace_mstate_t *mstate, dtrace_vstate_t *vstate, int where)
+{
+ uint32_t size, next, nnext, i;
+ dtrace_helptrace_t *ent;
+ uint16_t flags = cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+
+ if (!dtrace_helptrace_enabled)
+ return;
+
+ ASSERT(vstate->dtvs_nlocals <= VBDTCAST(int32_t)dtrace_helptrace_nlocals);
+
+ /*
+ * What would a tracing framework be without its own tracing
+ * framework? (Well, a hell of a lot simpler, for starters...)
+ */
+ size = sizeof (dtrace_helptrace_t) + dtrace_helptrace_nlocals *
+ sizeof (uint64_t) - sizeof (uint64_t);
+
+ /*
+ * Iterate until we can allocate a slot in the trace buffer.
+ */
+ do {
+ next = dtrace_helptrace_next;
+
+ if (next + size < VBDTCAST(unsigned)dtrace_helptrace_bufsize) {
+ nnext = next + size;
+ } else {
+ nnext = size;
+ }
+ } while (dtrace_cas32(&dtrace_helptrace_next, next, nnext) != next);
+
+ /*
+ * We have our slot; fill it in.
+ */
+ if (nnext == size)
+ next = 0;
+
+ ent = (dtrace_helptrace_t *)&dtrace_helptrace_buffer[next];
+ ent->dtht_helper = helper;
+ ent->dtht_where = where;
+ ent->dtht_nlocals = vstate->dtvs_nlocals;
+
+ ent->dtht_fltoffs = (mstate->dtms_present & DTRACE_MSTATE_FLTOFFS) ?
+ mstate->dtms_fltoffs : -1;
+ ent->dtht_fault = DTRACE_FLAGS2FLT(flags);
+ ent->dtht_illval = cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
+
+ for (i = 0; VBDTCAST(int32_t)i < vstate->dtvs_nlocals; i++) {
+ dtrace_statvar_t *svar;
+
+ if ((svar = vstate->dtvs_locals[i]) == NULL)
+ continue;
+
+ ASSERT(svar->dtsv_size >= NCPU * sizeof (uint64_t));
+ ent->dtht_locals[i] =
+ ((uint64_t *)(uintptr_t)svar->dtsv_data)[VBDT_GET_CPUID()];
+ }
+}
+
+static uint64_t
+dtrace_helper(int which, dtrace_mstate_t *mstate,
+ dtrace_state_t *state, uint64_t arg0, uint64_t arg1)
+{
+ VBDTTYPE(uint16_t volatile *, uint16_t *)flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
+ uint64_t sarg0 = mstate->dtms_arg[0];
+ uint64_t sarg1 = mstate->dtms_arg[1];
+ uint64_t rval VBDTUNASS(666);
+ dtrace_helpers_t *helpers = curproc->p_dtrace_helpers;
+ dtrace_helper_action_t *helper;
+ dtrace_vstate_t *vstate;
+ dtrace_difo_t *pred;
+ int i, trace = dtrace_helptrace_enabled;
+
+ ASSERT(which >= 0 && which < DTRACE_NHELPER_ACTIONS);
+
+ if (helpers == NULL)
+ return (0);
+
+ if ((helper = helpers->dthps_actions[which]) == NULL)
+ return (0);
+
+ vstate = &helpers->dthps_vstate;
+ mstate->dtms_arg[0] = arg0;
+ mstate->dtms_arg[1] = arg1;
+
+ /*
+ * Now iterate over each helper. If its predicate evaluates to 'true',
+ * we'll call the corresponding actions. Note that the below calls
+ * to dtrace_dif_emulate() may set faults in machine state. This is
+ * okay: our caller (the outer dtrace_dif_emulate()) will simply plow
+ * the stored DIF offset with its own (which is the desired behavior).
+ * Also, note the calls to dtrace_dif_emulate() may allocate scratch
+ * from machine state; this is okay, too.
+ */
+ for (; helper != NULL; helper = helper->dtha_next) {
+ if ((pred = helper->dtha_predicate) != NULL) {
+ if (trace)
+ dtrace_helper_trace(helper, mstate, vstate, 0);
+
+ if (!dtrace_dif_emulate(pred, mstate, vstate, state))
+ goto next;
+
+ if (*flags & CPU_DTRACE_FAULT)
+ goto err;
+ }
+
+ for (i = 0; i < helper->dtha_nactions; i++) {
+ if (trace)
+ dtrace_helper_trace(helper,
+ mstate, vstate, i + 1);
+
+ rval = dtrace_dif_emulate(helper->dtha_actions[i],
+ mstate, vstate, state);
+
+ if (*flags & CPU_DTRACE_FAULT)
+ goto err;
+ }
+
+next:
+ if (trace)
+ dtrace_helper_trace(helper, mstate, vstate,
+ DTRACE_HELPTRACE_NEXT);
+ }
+
+ if (trace)
+ dtrace_helper_trace(helper, mstate, vstate,
+ DTRACE_HELPTRACE_DONE);
+
+ /*
+ * Restore the arg0 that we saved upon entry.
+ */
+ mstate->dtms_arg[0] = sarg0;
+ mstate->dtms_arg[1] = sarg1;
+
+ return (rval);
+
+err:
+ if (trace)
+ dtrace_helper_trace(helper, mstate, vstate,
+ DTRACE_HELPTRACE_ERR);
+
+ /*
+ * Restore the arg0 that we saved upon entry.
+ */
+ mstate->dtms_arg[0] = sarg0;
+ mstate->dtms_arg[1] = sarg1;
+
+ return (NULL);
+}
+
+static void
+dtrace_helper_action_destroy(dtrace_helper_action_t *helper,
+ dtrace_vstate_t *vstate)
+{
+ int i;
+
+ if (helper->dtha_predicate != NULL)
+ dtrace_difo_release(helper->dtha_predicate, vstate);
+
+ for (i = 0; i < helper->dtha_nactions; i++) {
+ ASSERT(helper->dtha_actions[i] != NULL);
+ dtrace_difo_release(helper->dtha_actions[i], vstate);
+ }
+
+ kmem_free(helper->dtha_actions,
+ helper->dtha_nactions * sizeof (dtrace_difo_t *));
+ kmem_free(helper, sizeof (dtrace_helper_action_t));
+}
+
+static int
+dtrace_helper_destroygen(int gen)
+{
+ proc_t *p = curproc;
+ dtrace_helpers_t *help = p->p_dtrace_helpers;
+ dtrace_vstate_t *vstate;
+ VBDTTYPE(uint_t,int) i;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if (help == NULL || gen > help->dthps_generation)
+ return (EINVAL);
+
+ vstate = &help->dthps_vstate;
+
+ for (i = 0; i < DTRACE_NHELPER_ACTIONS; i++) {
+ dtrace_helper_action_t *last = NULL, *h, *next;
+
+ for (h = help->dthps_actions[i]; h != NULL; h = next) {
+ next = h->dtha_next;
+
+ if (h->dtha_generation == gen) {
+ if (last != NULL) {
+ last->dtha_next = next;
+ } else {
+ help->dthps_actions[i] = next;
+ }
+
+ dtrace_helper_action_destroy(h, vstate);
+ } else {
+ last = h;
+ }
+ }
+ }
+
+ /*
+ * Interate until we've cleared out all helper providers with the
+ * given generation number.
+ */
+ for (;;) {
+ dtrace_helper_provider_t *prov VBDTGCC(NULL);
+
+ /*
+ * Look for a helper provider with the right generation. We
+ * have to start back at the beginning of the list each time
+ * because we drop dtrace_lock. It's unlikely that we'll make
+ * more than two passes.
+ */
+ for (i = 0; i < help->dthps_nprovs; i++) {
+ prov = help->dthps_provs[i];
+
+ if (prov->dthp_generation == gen)
+ break;
+ }
+
+ /*
+ * If there were no matches, we're done.
+ */
+ if (i == help->dthps_nprovs)
+ break;
+
+ /*
+ * Move the last helper provider into this slot.
+ */
+ help->dthps_nprovs--;
+ help->dthps_provs[i] = help->dthps_provs[help->dthps_nprovs];
+ help->dthps_provs[help->dthps_nprovs] = NULL;
+
+ mutex_exit(&dtrace_lock);
+
+ /*
+ * If we have a meta provider, remove this helper provider.
+ */
+ mutex_enter(&dtrace_meta_lock);
+ if (dtrace_meta_pid != NULL) {
+ ASSERT(dtrace_deferred_pid == NULL);
+ dtrace_helper_provider_remove(&prov->dthp_prov,
+ p->p_pid);
+ }
+ mutex_exit(&dtrace_meta_lock);
+
+ dtrace_helper_provider_destroy(prov);
+
+ mutex_enter(&dtrace_lock);
+ }
+
+ return (0);
+}
+
+static int
+dtrace_helper_validate(dtrace_helper_action_t *helper)
+{
+ int err = 0, i;
+ dtrace_difo_t *dp;
+
+ if ((dp = helper->dtha_predicate) != NULL)
+ err += dtrace_difo_validate_helper(dp);
+
+ for (i = 0; i < helper->dtha_nactions; i++)
+ err += dtrace_difo_validate_helper(helper->dtha_actions[i]);
+
+ return (err == 0);
+}
+
+static int
+dtrace_helper_action_add(int which, dtrace_ecbdesc_t *ep)
+{
+ dtrace_helpers_t *help;
+ dtrace_helper_action_t *helper, *last;
+ dtrace_actdesc_t *act;
+ dtrace_vstate_t *vstate;
+ dtrace_predicate_t *pred;
+ int count = 0, nactions = 0, i;
+
+ if (which < 0 || which >= DTRACE_NHELPER_ACTIONS)
+ return (EINVAL);
+
+ help = curproc->p_dtrace_helpers;
+ last = help->dthps_actions[which];
+ vstate = &help->dthps_vstate;
+
+ for (count = 0; last != NULL; last = last->dtha_next) {
+ count++;
+ if (last->dtha_next == NULL)
+ break;
+ }
+
+ /*
+ * If we already have dtrace_helper_actions_max helper actions for this
+ * helper action type, we'll refuse to add a new one.
+ */
+ if (count >= dtrace_helper_actions_max)
+ return (ENOSPC);
+
+ helper = kmem_zalloc(sizeof (dtrace_helper_action_t), KM_SLEEP);
+ helper->dtha_generation = help->dthps_generation;
+
+ if ((pred = ep->dted_pred.dtpdd_predicate) != NULL) {
+ ASSERT(pred->dtp_difo != NULL);
+ dtrace_difo_hold(pred->dtp_difo);
+ helper->dtha_predicate = pred->dtp_difo;
+ }
+
+ for (act = ep->dted_action; act != NULL; act = act->dtad_next) {
+ if (act->dtad_kind != DTRACEACT_DIFEXPR)
+ goto err;
+
+ if (act->dtad_difo == NULL)
+ goto err;
+
+ nactions++;
+ }
+
+ helper->dtha_actions = kmem_zalloc(sizeof (dtrace_difo_t *) *
+ (helper->dtha_nactions = nactions), KM_SLEEP);
+
+ for (act = ep->dted_action, i = 0; act != NULL; act = act->dtad_next) {
+ dtrace_difo_hold(act->dtad_difo);
+ helper->dtha_actions[i++] = act->dtad_difo;
+ }
+
+ if (!dtrace_helper_validate(helper))
+ goto err;
+
+ if (last == NULL) {
+ help->dthps_actions[which] = helper;
+ } else {
+ last->dtha_next = helper;
+ }
+
+ if (vstate->dtvs_nlocals > VBDTCAST(int32_t)dtrace_helptrace_nlocals) {
+ dtrace_helptrace_nlocals = vstate->dtvs_nlocals;
+ dtrace_helptrace_next = 0;
+ }
+
+ return (0);
+err:
+ dtrace_helper_action_destroy(helper, vstate);
+ return (EINVAL);
+}
+
+static void
+dtrace_helper_provider_register(proc_t *p, dtrace_helpers_t *help,
+ dof_helper_t *dofhp)
+{
+ ASSERT(MUTEX_NOT_HELD(&dtrace_lock));
+
+ mutex_enter(&dtrace_meta_lock);
+ mutex_enter(&dtrace_lock);
+
+ if (!dtrace_attached() || dtrace_meta_pid == NULL) {
+ /*
+ * If the dtrace module is loaded but not attached, or if
+ * there aren't isn't a meta provider registered to deal with
+ * these provider descriptions, we need to postpone creating
+ * the actual providers until later.
+ */
+
+ if (help->dthps_next == NULL && help->dthps_prev == NULL &&
+ dtrace_deferred_pid != help) {
+ help->dthps_deferred = 1;
+ help->dthps_pid = p->p_pid;
+ help->dthps_next = dtrace_deferred_pid;
+ help->dthps_prev = NULL;
+ if (dtrace_deferred_pid != NULL)
+ dtrace_deferred_pid->dthps_prev = help;
+ dtrace_deferred_pid = help;
+ }
+
+ mutex_exit(&dtrace_lock);
+
+ } else if (dofhp != NULL) {
+ /*
+ * If the dtrace module is loaded and we have a particular
+ * helper provider description, pass that off to the
+ * meta provider.
+ */
+
+ mutex_exit(&dtrace_lock);
+
+ dtrace_helper_provide(dofhp, p->p_pid);
+
+ } else {
+ /*
+ * Otherwise, just pass all the helper provider descriptions
+ * off to the meta provider.
+ */
+
+ VBDTTYPE(uint_t,int) i;
+ mutex_exit(&dtrace_lock);
+
+ for (i = 0; i < help->dthps_nprovs; i++) {
+ dtrace_helper_provide(&help->dthps_provs[i]->dthp_prov,
+ p->p_pid);
+ }
+ }
+
+ mutex_exit(&dtrace_meta_lock);
+}
+
+static int
+dtrace_helper_provider_add(dof_helper_t *dofhp, int gen)
+{
+ dtrace_helpers_t *help;
+ dtrace_helper_provider_t *hprov, **tmp_provs;
+ uint_t tmp_maxprovs, i;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ help = curproc->p_dtrace_helpers;
+ ASSERT(help != NULL);
+
+ /*
+ * If we already have dtrace_helper_providers_max helper providers,
+ * we're refuse to add a new one.
+ */
+ if (help->dthps_nprovs >= dtrace_helper_providers_max)
+ return (ENOSPC);
+
+ /*
+ * Check to make sure this isn't a duplicate.
+ */
+ for (i = 0; i < help->dthps_nprovs; i++) {
+ if (dofhp->dofhp_addr ==
+ help->dthps_provs[i]->dthp_prov.dofhp_addr)
+ return (EALREADY);
+ }
+
+ hprov = kmem_zalloc(sizeof (dtrace_helper_provider_t), KM_SLEEP);
+ hprov->dthp_prov = *dofhp;
+ hprov->dthp_ref = 1;
+ hprov->dthp_generation = gen;
+
+ /*
+ * Allocate a bigger table for helper providers if it's already full.
+ */
+ if (help->dthps_maxprovs == help->dthps_nprovs) {
+ tmp_maxprovs = help->dthps_maxprovs;
+ tmp_provs = help->dthps_provs;
+
+ if (help->dthps_maxprovs == 0)
+ help->dthps_maxprovs = 2;
+ else
+ help->dthps_maxprovs *= 2;
+ if (help->dthps_maxprovs > dtrace_helper_providers_max)
+ help->dthps_maxprovs = dtrace_helper_providers_max;
+
+ ASSERT(tmp_maxprovs < help->dthps_maxprovs);
+
+ help->dthps_provs = kmem_zalloc(help->dthps_maxprovs *
+ sizeof (dtrace_helper_provider_t *), KM_SLEEP);
+
+ if (tmp_provs != NULL) {
+ bcopy(tmp_provs, help->dthps_provs, tmp_maxprovs *
+ sizeof (dtrace_helper_provider_t *));
+ kmem_free(tmp_provs, tmp_maxprovs *
+ sizeof (dtrace_helper_provider_t *));
+ }
+ }
+
+ help->dthps_provs[help->dthps_nprovs] = hprov;
+ help->dthps_nprovs++;
+
+ return (0);
+}
+
+static void
+dtrace_helper_provider_destroy(dtrace_helper_provider_t *hprov)
+{
+ mutex_enter(&dtrace_lock);
+
+ if (--hprov->dthp_ref == 0) {
+ dof_hdr_t *dof;
+ mutex_exit(&dtrace_lock);
+ dof = (dof_hdr_t *)(uintptr_t)hprov->dthp_prov.dofhp_dof;
+ dtrace_dof_destroy(dof);
+ kmem_free(hprov, sizeof (dtrace_helper_provider_t));
+ } else {
+ mutex_exit(&dtrace_lock);
+ }
+}
+
+static int
+dtrace_helper_provider_validate(dof_hdr_t *dof, dof_sec_t *sec)
+{
+ uintptr_t daddr = (uintptr_t)dof;
+ dof_sec_t *str_sec, *prb_sec, *arg_sec, *off_sec, *enoff_sec;
+ dof_provider_t *provider;
+ dof_probe_t *probe;
+ uint8_t *arg;
+ char *strtab, *typestr;
+ dof_stridx_t typeidx;
+ size_t typesz;
+ uint_t nprobes, j, k;
+
+ ASSERT(sec->dofs_type == DOF_SECT_PROVIDER);
+
+ if (sec->dofs_offset & (sizeof (uint_t) - 1)) {
+ dtrace_dof_error(dof, "misaligned section offset");
+ return (-1);
+ }
+
+ /*
+ * The section needs to be large enough to contain the DOF provider
+ * structure appropriate for the given version.
+ */
+ if (sec->dofs_size <
+ ((dof->dofh_ident[DOF_ID_VERSION] == DOF_VERSION_1) ?
+ offsetof(dof_provider_t, dofpv_prenoffs) :
+ sizeof (dof_provider_t))) {
+ dtrace_dof_error(dof, "provider section too small");
+ return (-1);
+ }
+
+ provider = (dof_provider_t *)(uintptr_t)(daddr + sec->dofs_offset);
+ str_sec = dtrace_dof_sect(dof, DOF_SECT_STRTAB, provider->dofpv_strtab);
+ prb_sec = dtrace_dof_sect(dof, DOF_SECT_PROBES, provider->dofpv_probes);
+ arg_sec = dtrace_dof_sect(dof, DOF_SECT_PRARGS, provider->dofpv_prargs);
+ off_sec = dtrace_dof_sect(dof, DOF_SECT_PROFFS, provider->dofpv_proffs);
+
+ if (str_sec == NULL || prb_sec == NULL ||
+ arg_sec == NULL || off_sec == NULL)
+ return (-1);
+
+ enoff_sec = NULL;
+
+ if (dof->dofh_ident[DOF_ID_VERSION] != DOF_VERSION_1 &&
+ provider->dofpv_prenoffs != DOF_SECT_NONE &&
+ (enoff_sec = dtrace_dof_sect(dof, DOF_SECT_PRENOFFS,
+ provider->dofpv_prenoffs)) == NULL)
+ return (-1);
+
+ strtab = (char *)(uintptr_t)(daddr + str_sec->dofs_offset);
+
+ if (provider->dofpv_name >= str_sec->dofs_size ||
+ strlen(strtab + provider->dofpv_name) >= DTRACE_PROVNAMELEN) {
+ dtrace_dof_error(dof, "invalid provider name");
+ return (-1);
+ }
+
+ if (prb_sec->dofs_entsize == 0 ||
+ prb_sec->dofs_entsize > prb_sec->dofs_size) {
+ dtrace_dof_error(dof, "invalid entry size");
+ return (-1);
+ }
+
+ if (prb_sec->dofs_entsize & (sizeof (uintptr_t) - 1)) {
+ dtrace_dof_error(dof, "misaligned entry size");
+ return (-1);
+ }
+
+ if (off_sec->dofs_entsize != sizeof (uint32_t)) {
+ dtrace_dof_error(dof, "invalid entry size");
+ return (-1);
+ }
+
+ if (off_sec->dofs_offset & (sizeof (uint32_t) - 1)) {
+ dtrace_dof_error(dof, "misaligned section offset");
+ return (-1);
+ }
+
+ if (arg_sec->dofs_entsize != sizeof (uint8_t)) {
+ dtrace_dof_error(dof, "invalid entry size");
+ return (-1);
+ }
+
+ arg = (uint8_t *)(uintptr_t)(daddr + arg_sec->dofs_offset);
+
+ nprobes = prb_sec->dofs_size / prb_sec->dofs_entsize;
+
+ /*
+ * Take a pass through the probes to check for errors.
+ */
+ for (j = 0; j < nprobes; j++) {
+ probe = (dof_probe_t *)(uintptr_t)(daddr +
+ prb_sec->dofs_offset + j * prb_sec->dofs_entsize);
+
+ if (probe->dofpr_func >= str_sec->dofs_size) {
+ dtrace_dof_error(dof, "invalid function name");
+ return (-1);
+ }
+
+ if (strlen(strtab + probe->dofpr_func) >= DTRACE_FUNCNAMELEN) {
+ dtrace_dof_error(dof, "function name too long");
+ return (-1);
+ }
+
+ if (probe->dofpr_name >= str_sec->dofs_size ||
+ strlen(strtab + probe->dofpr_name) >= DTRACE_NAMELEN) {
+ dtrace_dof_error(dof, "invalid probe name");
+ return (-1);
+ }
+
+ /*
+ * The offset count must not wrap the index, and the offsets
+ * must also not overflow the section's data.
+ */
+ if (probe->dofpr_offidx + probe->dofpr_noffs <
+ probe->dofpr_offidx ||
+ (probe->dofpr_offidx + probe->dofpr_noffs) *
+ off_sec->dofs_entsize > off_sec->dofs_size) {
+ dtrace_dof_error(dof, "invalid probe offset");
+ return (-1);
+ }
+
+ if (dof->dofh_ident[DOF_ID_VERSION] != DOF_VERSION_1) {
+ /*
+ * If there's no is-enabled offset section, make sure
+ * there aren't any is-enabled offsets. Otherwise
+ * perform the same checks as for probe offsets
+ * (immediately above).
+ */
+ if (enoff_sec == NULL) {
+ if (probe->dofpr_enoffidx != 0 ||
+ probe->dofpr_nenoffs != 0) {
+ dtrace_dof_error(dof, "is-enabled "
+ "offsets with null section");
+ return (-1);
+ }
+ } else if (probe->dofpr_enoffidx +
+ probe->dofpr_nenoffs < probe->dofpr_enoffidx ||
+ (probe->dofpr_enoffidx + probe->dofpr_nenoffs) *
+ enoff_sec->dofs_entsize > enoff_sec->dofs_size) {
+ dtrace_dof_error(dof, "invalid is-enabled "
+ "offset");
+ return (-1);
+ }
+
+ if (probe->dofpr_noffs + probe->dofpr_nenoffs == 0) {
+ dtrace_dof_error(dof, "zero probe and "
+ "is-enabled offsets");
+ return (-1);
+ }
+ } else if (probe->dofpr_noffs == 0) {
+ dtrace_dof_error(dof, "zero probe offsets");
+ return (-1);
+ }
+
+ if (probe->dofpr_argidx + probe->dofpr_xargc <
+ probe->dofpr_argidx ||
+ (probe->dofpr_argidx + probe->dofpr_xargc) *
+ arg_sec->dofs_entsize > arg_sec->dofs_size) {
+ dtrace_dof_error(dof, "invalid args");
+ return (-1);
+ }
+
+ typeidx = probe->dofpr_nargv;
+ typestr = strtab + probe->dofpr_nargv;
+ for (k = 0; k < probe->dofpr_nargc; k++) {
+ if (typeidx >= str_sec->dofs_size) {
+ dtrace_dof_error(dof, "bad "
+ "native argument type");
+ return (-1);
+ }
+
+ typesz = strlen(typestr) + 1;
+ if (typesz > DTRACE_ARGTYPELEN) {
+ dtrace_dof_error(dof, "native "
+ "argument type too long");
+ return (-1);
+ }
+ typeidx += VBDTCAST(dof_stridx_t)typesz;
+ typestr += typesz;
+ }
+
+ typeidx = probe->dofpr_xargv;
+ typestr = strtab + probe->dofpr_xargv;
+ for (k = 0; k < probe->dofpr_xargc; k++) {
+ if (arg[probe->dofpr_argidx + k] > probe->dofpr_nargc) {
+ dtrace_dof_error(dof, "bad "
+ "native argument index");
+ return (-1);
+ }
+
+ if (typeidx >= str_sec->dofs_size) {
+ dtrace_dof_error(dof, "bad "
+ "translated argument type");
+ return (-1);
+ }
+
+ typesz = strlen(typestr) + 1;
+ if (typesz > DTRACE_ARGTYPELEN) {
+ dtrace_dof_error(dof, "translated argument "
+ "type too long");
+ return (-1);
+ }
+
+ typeidx += VBDTCAST(dof_stridx_t)typesz;
+ typestr += typesz;
+ }
+ }
+
+ return (0);
+}
+
+static int
+dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp)
+{
+ dtrace_helpers_t *help;
+ dtrace_vstate_t *vstate;
+ dtrace_enabling_t *enab = NULL;
+ int i, gen, rv, nhelpers = 0, nprovs = 0, destroy = 1;
+ uintptr_t daddr = (uintptr_t)dof;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+
+ if ((help = curproc->p_dtrace_helpers) == NULL)
+ help = dtrace_helpers_create(curproc);
+
+ vstate = &help->dthps_vstate;
+
+ if ((rv = dtrace_dof_slurp(dof, vstate, NULL, &enab,
+ dhp != NULL ? dhp->dofhp_addr : 0, B_FALSE)) != 0) {
+ dtrace_dof_destroy(dof);
+ return (rv);
+ }
+
+ /*
+ * Look for helper providers and validate their descriptions.
+ */
+ if (dhp != NULL) {
+ for (i = 0; i < VBDTCAST(int)dof->dofh_secnum; i++) {
+ dof_sec_t *sec = (dof_sec_t *)(uintptr_t)(daddr +
+ dof->dofh_secoff + i * dof->dofh_secsize);
+
+ if (sec->dofs_type != DOF_SECT_PROVIDER)
+ continue;
+
+ if (dtrace_helper_provider_validate(dof, sec) != 0) {
+ dtrace_enabling_destroy(enab);
+ dtrace_dof_destroy(dof);
+ return (-1);
+ }
+
+ nprovs++;
+ }
+ }
+
+ /*
+ * Now we need to walk through the ECB descriptions in the enabling.
+ */
+ for (i = 0; i < enab->dten_ndesc; i++) {
+ dtrace_ecbdesc_t *ep = enab->dten_desc[i];
+ dtrace_probedesc_t *desc = &ep->dted_probe;
+
+ if (strcmp(desc->dtpd_provider, "dtrace") != 0)
+ continue;
+
+ if (strcmp(desc->dtpd_mod, "helper") != 0)
+ continue;
+
+ if (strcmp(desc->dtpd_func, "ustack") != 0)
+ continue;
+
+ if ((rv = dtrace_helper_action_add(DTRACE_HELPER_ACTION_USTACK,
+ ep)) != 0) {
+ /*
+ * Adding this helper action failed -- we are now going
+ * to rip out the entire generation and return failure.
+ */
+ (void) dtrace_helper_destroygen(help->dthps_generation);
+ dtrace_enabling_destroy(enab);
+ dtrace_dof_destroy(dof);
+ return (-1);
+ }
+
+ nhelpers++;
+ }
+
+ if (nhelpers < enab->dten_ndesc)
+ dtrace_dof_error(dof, "unmatched helpers");
+
+ gen = help->dthps_generation++;
+ dtrace_enabling_destroy(enab);
+
+ if (dhp != NULL && nprovs > 0) {
+ dhp->dofhp_dof = (uint64_t)(uintptr_t)dof;
+ if (dtrace_helper_provider_add(dhp, gen) == 0) {
+ mutex_exit(&dtrace_lock);
+ dtrace_helper_provider_register(curproc, help, dhp);
+ mutex_enter(&dtrace_lock);
+
+ destroy = 0;
+ }
+ }
+
+ if (destroy)
+ dtrace_dof_destroy(dof);
+
+ return (gen);
+}
+
+static dtrace_helpers_t *
+dtrace_helpers_create(proc_t *p)
+{
+ dtrace_helpers_t *help;
+
+ ASSERT(MUTEX_HELD(&dtrace_lock));
+ ASSERT(p->p_dtrace_helpers == NULL);
+
+ help = kmem_zalloc(sizeof (dtrace_helpers_t), KM_SLEEP);
+ help->dthps_actions = kmem_zalloc(sizeof (dtrace_helper_action_t *) *
+ DTRACE_NHELPER_ACTIONS, KM_SLEEP);
+
+ p->p_dtrace_helpers = help;
+ dtrace_helpers++;
+
+ return (help);
+}
+
+static void
+dtrace_helpers_destroy(void)
+{
+ dtrace_helpers_t *help;
+ dtrace_vstate_t *vstate;
+ proc_t *p = curproc;
+ VBDTTYPE(uint_t, int) i;
+
+ mutex_enter(&dtrace_lock);
+
+ ASSERT(p->p_dtrace_helpers != NULL);
+ ASSERT(dtrace_helpers > 0);
+
+ help = p->p_dtrace_helpers;
+ vstate = &help->dthps_vstate;
+
+ /*
+ * We're now going to lose the help from this process.
+ */
+ p->p_dtrace_helpers = NULL;
+ dtrace_sync();
+
+ /*
+ * Destory the helper actions.
+ */
+ for (i = 0; i < DTRACE_NHELPER_ACTIONS; i++) {
+ dtrace_helper_action_t *h, *next;
+
+ for (h = help->dthps_actions[i]; h != NULL; h = next) {
+ next = h->dtha_next;
+ dtrace_helper_action_destroy(h, vstate);
+ h = next;
+ }
+ }
+
+ mutex_exit(&dtrace_lock);
+
+ /*
+ * Destroy the helper providers.
+ */
+ if (help->dthps_maxprovs > 0) {
+ mutex_enter(&dtrace_meta_lock);
+ if (dtrace_meta_pid != NULL) {
+ ASSERT(dtrace_deferred_pid == NULL);
+
+ for (i = 0; i < help->dthps_nprovs; i++) {
+ dtrace_helper_provider_remove(
+ &help->dthps_provs[i]->dthp_prov, p->p_pid);
+ }
+ } else {
+ mutex_enter(&dtrace_lock);
+ ASSERT(help->dthps_deferred == 0 ||
+ help->dthps_next != NULL ||
+ help->dthps_prev != NULL ||
+ help == dtrace_deferred_pid);
+
+ /*
+ * Remove the helper from the deferred list.
+ */
+ if (help->dthps_next != NULL)
+ help->dthps_next->dthps_prev = help->dthps_prev;
+ if (help->dthps_prev != NULL)
+ help->dthps_prev->dthps_next = help->dthps_next;
+ if (dtrace_deferred_pid == help) {
+ dtrace_deferred_pid = help->dthps_next;
+ ASSERT(help->dthps_prev == NULL);
+ }
+
+ mutex_exit(&dtrace_lock);
+ }
+
+ mutex_exit(&dtrace_meta_lock);
+
+ for (i = 0; i < help->dthps_nprovs; i++) {
+ dtrace_helper_provider_destroy(help->dthps_provs[i]);
+ }
+
+ kmem_free(help->dthps_provs, help->dthps_maxprovs *
+ sizeof (dtrace_helper_provider_t *));
+ }
+
+ mutex_enter(&dtrace_lock);
+
+ dtrace_vstate_fini(&help->dthps_vstate);
+ kmem_free(help->dthps_actions,
+ sizeof (dtrace_helper_action_t *) * DTRACE_NHELPER_ACTIONS);
+ kmem_free(help, sizeof (dtrace_helpers_t));
+
+ --dtrace_helpers;
+ mutex_exit(&dtrace_lock);
+}
+
+static void
+dtrace_helpers_duplicate(proc_t *from, proc_t *to)
+{
+ dtrace_helpers_t *help, *newhelp;
+ dtrace_helper_action_t *helper, *new, *last;
+ dtrace_difo_t *dp;
+ dtrace_vstate_t *vstate;
+ int i, j, sz, hasprovs = 0;
+
+ mutex_enter(&dtrace_lock);
+ ASSERT(from->p_dtrace_helpers != NULL);
+ ASSERT(dtrace_helpers > 0);
+
+ help = from->p_dtrace_helpers;
+ newhelp = dtrace_helpers_create(to);
+ ASSERT(to->p_dtrace_helpers != NULL);
+
+ newhelp->dthps_generation = help->dthps_generation;
+ vstate = &newhelp->dthps_vstate;
+
+ /*
+ * Duplicate the helper actions.
+ */
+ for (i = 0; i < DTRACE_NHELPER_ACTIONS; i++) {
+ if ((helper = help->dthps_actions[i]) == NULL)
+ continue;
+
+ for (last = NULL; helper != NULL; helper = helper->dtha_next) {
+ new = kmem_zalloc(sizeof (dtrace_helper_action_t),
+ KM_SLEEP);
+ new->dtha_generation = helper->dtha_generation;
+
+ if ((dp = helper->dtha_predicate) != NULL) {
+ dp = dtrace_difo_duplicate(dp, vstate);
+ new->dtha_predicate = dp;
+ }
+
+ new->dtha_nactions = helper->dtha_nactions;
+ sz = sizeof (dtrace_difo_t *) * new->dtha_nactions;
+ new->dtha_actions = kmem_alloc(sz, KM_SLEEP);
+
+ for (j = 0; j < new->dtha_nactions; j++) {
+ dtrace_difo_t *dp2 = helper->dtha_actions[j];
+
+ ASSERT(dp2 != NULL);
+ dp2 = dtrace_difo_duplicate(dp2, vstate);
+ new->dtha_actions[j] = dp2;
+ }
+
+ if (last != NULL) {
+ last->dtha_next = new;
+ } else {
+ newhelp->dthps_actions[i] = new;
+ }
+
+ last = new;
+ }
+ }
+
+ /*
+ * Duplicate the helper providers and register them with the
+ * DTrace framework.
+ */
+ if (help->dthps_nprovs > 0) {
+ newhelp->dthps_nprovs = help->dthps_nprovs;
+ newhelp->dthps_maxprovs = help->dthps_nprovs;
+ newhelp->dthps_provs = kmem_alloc(newhelp->dthps_nprovs *
+ sizeof (dtrace_helper_provider_t *), KM_SLEEP);
+ for (i = 0; i < VBDTCAST(int)newhelp->dthps_nprovs; i++) {
+ newhelp->dthps_provs[i] = help->dthps_provs[i];
+ newhelp->dthps_provs[i]->dthp_ref++;
+ }
+
+ hasprovs = 1;
+ }
+
+ mutex_exit(&dtrace_lock);
+
+ if (hasprovs)
+ dtrace_helper_provider_register(to, newhelp, NULL);
+}
+
+/*
+ * DTrace Hook Functions
+ */
+static void
+dtrace_module_loaded(struct modctl *ctl)
+{
+ dtrace_provider_t *prv;
+
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&mod_lock);
+
+ ASSERT(ctl->mod_busy);
+
+ /*
+ * We're going to call each providers per-module provide operation
+ * specifying only this module.
+ */
+ for (prv = dtrace_provider; prv != NULL; prv = prv->dtpv_next)
+ prv->dtpv_pops.dtps_provide_module(prv->dtpv_arg, ctl);
+
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+
+ /*
+ * If we have any retained enablings, we need to match against them.
+ * Enabling probes requires that cpu_lock be held, and we cannot hold
+ * cpu_lock here -- it is legal for cpu_lock to be held when loading a
+ * module. (In particular, this happens when loading scheduling
+ * classes.) So if we have any retained enablings, we need to dispatch
+ * our task queue to do the match for us.
+ */
+ mutex_enter(&dtrace_lock);
+
+ if (dtrace_retained == NULL) {
+ mutex_exit(&dtrace_lock);
+ return;
+ }
+
+ (void) taskq_dispatch(dtrace_taskq,
+ (task_func_t *)dtrace_enabling_matchall, NULL, TQ_SLEEP);
+
+ mutex_exit(&dtrace_lock);
+
+ /*
+ * And now, for a little heuristic sleaze: in general, we want to
+ * match modules as soon as they load. However, we cannot guarantee
+ * this, because it would lead us to the lock ordering violation
+ * outlined above. The common case, of course, is that cpu_lock is
+ * _not_ held -- so we delay here for a clock tick, hoping that that's
+ * long enough for the task queue to do its work. If it's not, it's
+ * not a serious problem -- it just means that the module that we
+ * just loaded may not be immediately instrumentable.
+ */
+ delay(1);
+}
+
+static void
+dtrace_module_unloaded(struct modctl *ctl)
+{
+ dtrace_probe_t template, *probe, *first, *next;
+ dtrace_provider_t *prov;
+
+ template.dtpr_mod = ctl->mod_modname;
+
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&mod_lock);
+ mutex_enter(&dtrace_lock);
+
+ if (dtrace_bymod == NULL) {
+ /*
+ * The DTrace module is loaded (obviously) but not attached;
+ * we don't have any work to do.
+ */
+ mutex_exit(&dtrace_provider_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_lock);
+ return;
+ }
+
+ for (probe = first = dtrace_hash_lookup(dtrace_bymod, &template);
+ probe != NULL; probe = probe->dtpr_nextmod) {
+ if (probe->dtpr_ecb != NULL) {
+ mutex_exit(&dtrace_provider_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_lock);
+
+ /*
+ * This shouldn't _actually_ be possible -- we're
+ * unloading a module that has an enabled probe in it.
+ * (It's normally up to the provider to make sure that
+ * this can't happen.) However, because dtps_enable()
+ * doesn't have a failure mode, there can be an
+ * enable/unload race. Upshot: we don't want to
+ * assert, but we're not going to disable the
+ * probe, either.
+ */
+ if (dtrace_err_verbose) {
+ cmn_err(CE_WARN, "unloaded module '%s' had "
+ "enabled probes", ctl->mod_modname);
+ }
+
+ return;
+ }
+ }
+
+ probe = first;
+
+ for (first = NULL; probe != NULL; probe = next) {
+ ASSERT(dtrace_probes[probe->dtpr_id - 1] == probe);
+
+ dtrace_probes[probe->dtpr_id - 1] = NULL;
+
+ next = probe->dtpr_nextmod;
+ dtrace_hash_remove(dtrace_bymod, probe);
+ dtrace_hash_remove(dtrace_byfunc, probe);
+ dtrace_hash_remove(dtrace_byname, probe);
+
+ if (first == NULL) {
+ first = probe;
+ probe->dtpr_nextmod = NULL;
+ } else {
+ probe->dtpr_nextmod = first;
+ first = probe;
+ }
+ }
+
+ /*
+ * We've removed all of the module's probes from the hash chains and
+ * from the probe array. Now issue a dtrace_sync() to be sure that
+ * everyone has cleared out from any probe array processing.
+ */
+ dtrace_sync();
+
+ for (probe = first; probe != NULL; probe = first) {
+ first = probe->dtpr_nextmod;
+ prov = probe->dtpr_provider;
+ prov->dtpv_pops.dtps_destroy(prov->dtpv_arg, probe->dtpr_id,
+ probe->dtpr_arg);
+ kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
+ kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
+ kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
+ vmem_free(dtrace_arena, (void *)(uintptr_t)probe->dtpr_id, 1);
+ kmem_free(probe, sizeof (dtrace_probe_t));
+ }
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+}
+
+VBDTSTATIC void
+dtrace_suspend(void)
+{
+ dtrace_probe_foreach(offsetof(dtrace_pops_t, dtps_suspend));
+}
+
+VBDTSTATIC void
+dtrace_resume(void)
+{
+ dtrace_probe_foreach(offsetof(dtrace_pops_t, dtps_resume));
+}
+
+#endif /* !VBOX */
+
+#ifdef VBOX
+typedef enum {
+ CPU_INVALID,
+ CPU_CONFIG,
+ CPU_UNCONFIG
+} cpu_setup_t;
+#endif
+
+#ifndef VBOX
+
+static int
+dtrace_cpu_setup(cpu_setup_t what, processorid_t cpu)
+{
+ ASSERT(MUTEX_HELD(&cpu_lock));
+ mutex_enter(&dtrace_lock);
+
+ switch (what) {
+ case CPU_CONFIG: {
+ dtrace_state_t *state;
+ dtrace_optval_t *opt, rs, c;
+
+ /*
+ * For now, we only allocate a new buffer for anonymous state.
+ */
+ if ((state = dtrace_anon.dta_state) == NULL)
+ break;
+
+ if (state->dts_activity != DTRACE_ACTIVITY_ACTIVE)
+ break;
+
+ opt = state->dts_options;
+ c = opt[DTRACEOPT_CPU];
+
+ if (c != DTRACE_CPUALL && c != DTRACEOPT_UNSET && c != cpu)
+ break;
+
+ /*
+ * Regardless of what the actual policy is, we're going to
+ * temporarily set our resize policy to be manual. We're
+ * also going to temporarily set our CPU option to denote
+ * the newly configured CPU.
+ */
+ rs = opt[DTRACEOPT_BUFRESIZE];
+ opt[DTRACEOPT_BUFRESIZE] = DTRACEOPT_BUFRESIZE_MANUAL;
+ opt[DTRACEOPT_CPU] = (dtrace_optval_t)cpu;
+
+ (void) dtrace_state_buffers(state);
+
+ opt[DTRACEOPT_BUFRESIZE] = rs;
+ opt[DTRACEOPT_CPU] = c;
+
+ break;
+ }
+
+ case CPU_UNCONFIG:
+ /*
+ * We don't free the buffer in the CPU_UNCONFIG case. (The
+ * buffer will be freed when the consumer exits.)
+ */
+ break;
+
+ default:
+ break;
+ }
+
+ mutex_exit(&dtrace_lock);
+ return (0);
+}
+
+static void
+dtrace_cpu_setup_initial(processorid_t cpu)
+{
+ (void) dtrace_cpu_setup(CPU_CONFIG, cpu);
+}
+
+#endif /* !VBOX */
+
+static void
+dtrace_toxrange_add(uintptr_t base, uintptr_t limit)
+{
+ if (dtrace_toxranges >= dtrace_toxranges_max) {
+ int osize, nsize;
+ dtrace_toxrange_t *range;
+
+ osize = dtrace_toxranges_max * sizeof (dtrace_toxrange_t);
+
+ if (osize == 0) {
+ ASSERT(dtrace_toxrange == NULL);
+ ASSERT(dtrace_toxranges_max == 0);
+ dtrace_toxranges_max = 1;
+ } else {
+ dtrace_toxranges_max <<= 1;
+ }
+
+ nsize = dtrace_toxranges_max * sizeof (dtrace_toxrange_t);
+ range = kmem_zalloc(nsize, KM_SLEEP);
+
+ if (dtrace_toxrange != NULL) {
+ ASSERT(osize != 0);
+ bcopy(dtrace_toxrange, range, osize);
+ kmem_free(dtrace_toxrange, osize);
+ }
+
+ dtrace_toxrange = range;
+ }
+
+ ASSERT(dtrace_toxrange[dtrace_toxranges].dtt_base == NULL);
+ ASSERT(dtrace_toxrange[dtrace_toxranges].dtt_limit == NULL);
+
+ dtrace_toxrange[dtrace_toxranges].dtt_base = base;
+ dtrace_toxrange[dtrace_toxranges].dtt_limit = limit;
+ dtrace_toxranges++;
+}
+
+/*
+ * DTrace Driver Cookbook Functions
+ */
+#ifdef VBOX
+int dtrace_attach(void)
+#else
+/*ARGSUSED*/
+static int
+dtrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+#endif
+{
+ dtrace_provider_id_t id;
+ dtrace_state_t *state = NULL;
+ dtrace_enabling_t *enab;
+
+#ifdef VBOX
+ if ( VBoxDtMutexInit(&dtrace_lock)
+ || VBoxDtMutexInit(&dtrace_provider_lock)
+ || VBoxDtMutexInit(&dtrace_meta_lock)
+# ifdef DEBUG
+ || VBoxDtMutexInit(&dtrace_errlock)
+# endif
+ )
+ return (DDI_FAILURE);
+#endif
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&dtrace_lock);
+
+#ifndef VBOX
+ if (ddi_soft_state_init(&dtrace_softstate,
+ sizeof (dtrace_state_t), 0) != 0) {
+ cmn_err(CE_NOTE, "/dev/dtrace failed to initialize soft state");
+ mutex_exit(&cpu_lock);
+ mutex_exit(&dtrace_provider_lock);
+ mutex_exit(&dtrace_lock);
+ return (DDI_FAILURE);
+ }
+
+ if (ddi_create_minor_node(devi, DTRACEMNR_DTRACE, S_IFCHR,
+ DTRACEMNRN_DTRACE, DDI_PSEUDO, NULL) == DDI_FAILURE ||
+ ddi_create_minor_node(devi, DTRACEMNR_HELPER, S_IFCHR,
+ DTRACEMNRN_HELPER, DDI_PSEUDO, NULL) == DDI_FAILURE) {
+ cmn_err(CE_NOTE, "/dev/dtrace couldn't create minor nodes");
+ ddi_remove_minor_node(devi, NULL);
+ ddi_soft_state_fini(&dtrace_softstate);
+ mutex_exit(&cpu_lock);
+ mutex_exit(&dtrace_provider_lock);
+ mutex_exit(&dtrace_lock);
+ return (DDI_FAILURE);
+ }
+
+ ddi_report_dev(devi);
+ dtrace_devi = devi;
+
+ dtrace_modload = dtrace_module_loaded;
+ dtrace_modunload = dtrace_module_unloaded;
+ dtrace_cpu_init = dtrace_cpu_setup_initial;
+ dtrace_helpers_cleanup = dtrace_helpers_destroy;
+ dtrace_helpers_fork = dtrace_helpers_duplicate;
+ dtrace_cpustart_init = dtrace_suspend;
+ dtrace_cpustart_fini = dtrace_resume;
+ dtrace_debugger_init = dtrace_suspend;
+ dtrace_debugger_fini = dtrace_resume;
+
+ register_cpu_setup_func((cpu_setup_func_t *)dtrace_cpu_setup, NULL);
+#else
+ /** @todo some of these hooks needs checking out! */
+#endif
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+#ifndef VBOX /* Reduce the area a bit just to be sure our vmem fake doesn't blow up. */
+ dtrace_arena = vmem_create("dtrace", (void *)1, UINT32_MAX, 1,
+ NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
+#else
+ dtrace_arena = vmem_create("dtrace", (void *)(uintptr_t)1, UINT32_MAX - 16, 1,
+ NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
+#endif
+#ifndef VBOX
+ dtrace_minor = vmem_create("dtrace_minor", (void *)DTRACEMNRN_CLONE,
+ UINT32_MAX - DTRACEMNRN_CLONE, 1, NULL, NULL, NULL, 0,
+ VM_SLEEP | VMC_IDENTIFIER);
+ dtrace_taskq = taskq_create("dtrace_taskq", 1, maxclsyspri,
+ 1, INT_MAX, 0);
+#endif
+
+ dtrace_state_cache = kmem_cache_create("dtrace_state_cache",
+ sizeof (dtrace_dstate_percpu_t) * NCPU, DTRACE_STATE_ALIGN,
+ NULL, NULL, NULL, NULL, NULL, 0);
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+ dtrace_bymod = dtrace_hash_create(offsetof(dtrace_probe_t, dtpr_mod),
+ offsetof(dtrace_probe_t, dtpr_nextmod),
+ offsetof(dtrace_probe_t, dtpr_prevmod));
+
+ dtrace_byfunc = dtrace_hash_create(offsetof(dtrace_probe_t, dtpr_func),
+ offsetof(dtrace_probe_t, dtpr_nextfunc),
+ offsetof(dtrace_probe_t, dtpr_prevfunc));
+
+ dtrace_byname = dtrace_hash_create(offsetof(dtrace_probe_t, dtpr_name),
+ offsetof(dtrace_probe_t, dtpr_nextname),
+ offsetof(dtrace_probe_t, dtpr_prevname));
+
+ if (dtrace_retain_max < 1) {
+ cmn_err(CE_WARN, "illegal value (%lu) for dtrace_retain_max; "
+ "setting to 1", dtrace_retain_max);
+ dtrace_retain_max = 1;
+ }
+
+ /*
+ * Now discover our toxic ranges.
+ */
+ dtrace_toxic_ranges(dtrace_toxrange_add);
+
+ /*
+ * Before we register ourselves as a provider to our own framework,
+ * we would like to assert that dtrace_provider is NULL -- but that's
+ * not true if we were loaded as a dependency of a DTrace provider.
+ * Once we've registered, we can assert that dtrace_provider is our
+ * pseudo provider.
+ */
+ (void) dtrace_register("dtrace", &dtrace_provider_attr,
+ DTRACE_PRIV_NONE, 0, &dtrace_provider_ops, NULL, &id);
+
+ ASSERT(dtrace_provider != NULL);
+ ASSERT((dtrace_provider_id_t)dtrace_provider == id);
+
+ dtrace_probeid_begin = dtrace_probe_create((dtrace_provider_id_t)
+ dtrace_provider, NULL, NULL, "BEGIN", 0, NULL);
+ dtrace_probeid_end = dtrace_probe_create((dtrace_provider_id_t)
+ dtrace_provider, NULL, NULL, "END", 0, NULL);
+ dtrace_probeid_error = dtrace_probe_create((dtrace_provider_id_t)
+ dtrace_provider, NULL, NULL, "ERROR", 1, NULL);
+
+#ifndef VBOX
+ dtrace_anon_property();
+#endif
+ mutex_exit(&cpu_lock);
+
+ /*
+ * If DTrace helper tracing is enabled, we need to allocate the
+ * trace buffer and initialize the values.
+ */
+ if (dtrace_helptrace_enabled) {
+ ASSERT(dtrace_helptrace_buffer == NULL);
+ dtrace_helptrace_buffer =
+ kmem_zalloc(dtrace_helptrace_bufsize, KM_SLEEP);
+ dtrace_helptrace_next = 0;
+ }
+
+ /*
+ * If there are already providers, we must ask them to provide their
+ * probes, and then match any anonymous enabling against them. Note
+ * that there should be no other retained enablings at this time:
+ * the only retained enablings at this time should be the anonymous
+ * enabling.
+ */
+ if (dtrace_anon.dta_enabling != NULL) {
+ ASSERT(dtrace_retained == dtrace_anon.dta_enabling);
+
+ dtrace_enabling_provide(NULL);
+ state = dtrace_anon.dta_state;
+
+ /*
+ * We couldn't hold cpu_lock across the above call to
+ * dtrace_enabling_provide(), but we must hold it to actually
+ * enable the probes. We have to drop all of our locks, pick
+ * up cpu_lock, and regain our locks before matching the
+ * retained anonymous enabling.
+ */
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_provider_lock);
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&dtrace_lock);
+
+ if ((enab = dtrace_anon.dta_enabling) != NULL)
+ (void) dtrace_enabling_match(enab, NULL);
+
+ mutex_exit(&cpu_lock);
+ }
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_provider_lock);
+
+ if (state != NULL) {
+ /*
+ * If we created any anonymous state, set it going now.
+ */
+ (void) dtrace_state_go(state, &dtrace_anon.dta_beganon);
+ }
+
+ return (DDI_SUCCESS);
+}
+
+#ifdef VBOX
+int dtrace_open(dtrace_state_t **ppState, cred_t *cred_p)
+#else
+/*ARGSUSED*/
+static int
+dtrace_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+#endif
+{
+ dtrace_state_t *state;
+ uint32_t priv;
+ uid_t uid;
+ zoneid_t zoneid;
+
+#ifndef VBOX
+ if (getminor(*devp) == DTRACEMNRN_HELPER)
+ return (0);
+
+ /*
+ * If this wasn't an open with the "helper" minor, then it must be
+ * the "dtrace" minor.
+ */
+ if (getminor(*devp) != DTRACEMNRN_DTRACE)
+ return (ENXIO);
+#endif /* !VBOX */
+
+ /*
+ * If no DTRACE_PRIV_* bits are set in the credential, then the
+ * caller lacks sufficient permission to do anything with DTrace.
+ */
+ dtrace_cred2priv(cred_p, &priv, &uid, &zoneid);
+ if (priv == DTRACE_PRIV_NONE)
+ return (EACCES);
+
+ /*
+ * Ask all providers to provide all their probes.
+ */
+ mutex_enter(&dtrace_provider_lock);
+ dtrace_probe_provide(NULL, NULL);
+ mutex_exit(&dtrace_provider_lock);
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_lock);
+ dtrace_opens++;
+ dtrace_membar_producer();
+
+#ifndef VBOX
+ /*
+ * If the kernel debugger is active (that is, if the kernel debugger
+ * modified text in some way), we won't allow the open.
+ */
+ if (kdi_dtrace_set(KDI_DTSET_DTRACE_ACTIVATE) != 0) {
+ dtrace_opens--;
+ mutex_exit(&cpu_lock);
+ mutex_exit(&dtrace_lock);
+ return (EBUSY);
+ }
+#endif
+
+#ifndef VBOX
+ state = dtrace_state_create(devp, cred_p);
+#else
+ state = dtrace_state_create(cred_p);
+#endif
+ mutex_exit(&cpu_lock);
+
+ if (state == NULL) {
+#ifndef VBOX
+ if (--dtrace_opens == 0 && dtrace_anon.dta_enabling == NULL)
+ (void) kdi_dtrace_set(KDI_DTSET_DTRACE_DEACTIVATE);
+#else
+ dtrace_opens--;
+#endif
+ mutex_exit(&dtrace_lock);
+ return (EAGAIN);
+ }
+
+ mutex_exit(&dtrace_lock);
+
+#ifdef VBOX
+ *ppState = state;
+#endif
+ return (0);
+}
+
+#ifdef VBOX
+int dtrace_close(dtrace_state_t *state)
+#else
+/*ARGSUSED*/
+static int
+dtrace_close(dev_t dev, int flag, int otyp, cred_t *cred_p)
+#endif
+{
+#ifndef VBOX
+ minor_t minor = getminor(dev);
+ dtrace_state_t *state;
+
+ if (minor == DTRACEMNRN_HELPER)
+ return (0);
+
+ state = ddi_get_soft_state(dtrace_softstate, minor);
+#endif
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_lock);
+
+ if (state->dts_anon) {
+ /*
+ * There is anonymous state. Destroy that first.
+ */
+ ASSERT(dtrace_anon.dta_state == NULL);
+ dtrace_state_destroy(state->dts_anon);
+ }
+
+ dtrace_state_destroy(state);
+ ASSERT(dtrace_opens > 0);
+
+#ifndef VBOX
+ /*
+ * Only relinquish control of the kernel debugger interface when there
+ * are no consumers and no anonymous enablings.
+ */
+ if (--dtrace_opens == 0 && dtrace_anon.dta_enabling == NULL)
+ (void) kdi_dtrace_set(KDI_DTSET_DTRACE_DEACTIVATE);
+#else
+ dtrace_opens--;
+#endif
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+
+ return (0);
+}
+
+#ifndef VBOX
+/*ARGSUSED*/
+static int
+dtrace_ioctl_helper(int cmd, intptr_t arg, int *rv)
+{
+ int rval;
+ dof_helper_t help, *dhp = NULL;
+
+ switch (cmd) {
+ case DTRACEHIOC_ADDDOF:
+ if (copyin((void *)arg, &help, sizeof (help)) != 0) {
+ dtrace_dof_error(NULL, "failed to copyin DOF helper");
+ return (EFAULT);
+ }
+
+ dhp = &help;
+ arg = (intptr_t)help.dofhp_dof;
+ RT_FALL_THRU();
+
+ case DTRACEHIOC_ADD: {
+ dof_hdr_t *dof = dtrace_dof_copyin(arg, &rval);
+
+ if (dof == NULL)
+ return (rval);
+
+ mutex_enter(&dtrace_lock);
+
+ /*
+ * dtrace_helper_slurp() takes responsibility for the dof --
+ * it may free it now or it may save it and free it later.
+ */
+ if ((rval = dtrace_helper_slurp(dof, dhp)) != -1) {
+ *rv = rval;
+ rval = 0;
+ } else {
+ rval = EINVAL;
+ }
+
+ mutex_exit(&dtrace_lock);
+ return (rval);
+ }
+
+ case DTRACEHIOC_REMOVE: {
+ mutex_enter(&dtrace_lock);
+ rval = dtrace_helper_destroygen(arg);
+ mutex_exit(&dtrace_lock);
+
+ return (rval);
+ }
+
+ default:
+ break;
+ }
+
+ return (ENOTTY);
+}
+#endif /* !VBOX */
+
+#ifdef VBOX
+int dtrace_ioctl(dtrace_state_t *state, int cmd, intptr_t arg, int32_t *rv)
+#else
+/*ARGSUSED*/
+static int
+dtrace_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
+#endif
+{
+#ifndef VBOX
+ minor_t minor = getminor(dev);
+ dtrace_state_t *state;
+#endif
+ int rval;
+
+#ifndef VBOX
+ if (minor == DTRACEMNRN_HELPER)
+ return (dtrace_ioctl_helper(cmd, arg, rv));
+
+ state = ddi_get_soft_state(dtrace_softstate, minor);
+#endif
+
+ if (state->dts_anon) {
+ ASSERT(dtrace_anon.dta_state == NULL);
+ state = state->dts_anon;
+ }
+
+ switch (cmd) {
+ case DTRACEIOC_PROVIDER: {
+ dtrace_providerdesc_t pvd;
+ dtrace_provider_t *pvp;
+
+ if (copyin((void *)arg, &pvd, sizeof (pvd)) != 0)
+ return (EFAULT);
+
+ pvd.dtvd_name[DTRACE_PROVNAMELEN - 1] = '\0';
+ mutex_enter(&dtrace_provider_lock);
+
+ for (pvp = dtrace_provider; pvp != NULL; pvp = pvp->dtpv_next) {
+ if (strcmp(pvp->dtpv_name, pvd.dtvd_name) == 0)
+ break;
+ }
+
+ mutex_exit(&dtrace_provider_lock);
+
+ if (pvp == NULL)
+ return (ESRCH);
+
+ bcopy(&pvp->dtpv_priv, &pvd.dtvd_priv, sizeof (dtrace_ppriv_t));
+ bcopy(&pvp->dtpv_attr, &pvd.dtvd_attr, sizeof (dtrace_pattr_t));
+ if (copyout(&pvd, (void *)arg, sizeof (pvd)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_EPROBE: {
+ dtrace_eprobedesc_t epdesc;
+ dtrace_ecb_t *ecb;
+ dtrace_action_t *act;
+ void *buf;
+ size_t size;
+ uintptr_t dest;
+ int nrecs;
+
+ if (copyin((void *)arg, &epdesc, sizeof (epdesc)) != 0)
+ return (EFAULT);
+
+ mutex_enter(&dtrace_lock);
+
+ if ((ecb = dtrace_epid2ecb(state, epdesc.dtepd_epid)) == NULL) {
+ mutex_exit(&dtrace_lock);
+ return (EINVAL);
+ }
+
+ if (ecb->dte_probe == NULL) {
+ mutex_exit(&dtrace_lock);
+ return (EINVAL);
+ }
+
+ epdesc.dtepd_probeid = ecb->dte_probe->dtpr_id;
+ epdesc.dtepd_uarg = ecb->dte_uarg;
+ epdesc.dtepd_size = VBDTCAST(uint32_t)ecb->dte_size;
+
+ nrecs = epdesc.dtepd_nrecs;
+ epdesc.dtepd_nrecs = 0;
+ for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
+ if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
+ continue;
+
+ epdesc.dtepd_nrecs++;
+ }
+
+ /*
+ * Now that we have the size, we need to allocate a temporary
+ * buffer in which to store the complete description. We need
+ * the temporary buffer to be able to drop dtrace_lock()
+ * across the copyout(), below.
+ */
+ size = sizeof (dtrace_eprobedesc_t) +
+ (epdesc.dtepd_nrecs * sizeof (dtrace_recdesc_t));
+
+ buf = kmem_alloc(size, KM_SLEEP);
+ dest = (uintptr_t)buf;
+
+ bcopy(&epdesc, (void *)dest, sizeof (epdesc));
+ dest += offsetof(dtrace_eprobedesc_t, dtepd_rec[0]);
+
+ for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
+ if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
+ continue;
+
+ if (nrecs-- == 0)
+ break;
+
+ bcopy(&act->dta_rec, (void *)dest,
+ sizeof (dtrace_recdesc_t));
+ dest += sizeof (dtrace_recdesc_t);
+ }
+
+ mutex_exit(&dtrace_lock);
+
+ if (copyout(buf, (void *)arg, dest - (uintptr_t)buf) != 0) {
+ kmem_free(buf, size);
+ return (EFAULT);
+ }
+
+ kmem_free(buf, size);
+ return (0);
+ }
+
+ case DTRACEIOC_AGGDESC: {
+ dtrace_aggdesc_t aggdesc;
+ dtrace_action_t *act;
+ dtrace_aggregation_t *agg;
+ int nrecs;
+ uint32_t offs;
+ dtrace_recdesc_t *lrec;
+ void *buf;
+ size_t size;
+ uintptr_t dest;
+
+ if (copyin((void *)arg, &aggdesc, sizeof (aggdesc)) != 0)
+ return (EFAULT);
+
+ mutex_enter(&dtrace_lock);
+
+ if ((agg = dtrace_aggid2agg(state, aggdesc.dtagd_id)) == NULL) {
+ mutex_exit(&dtrace_lock);
+ return (EINVAL);
+ }
+
+ aggdesc.dtagd_epid = agg->dtag_ecb->dte_epid;
+
+ nrecs = aggdesc.dtagd_nrecs;
+ aggdesc.dtagd_nrecs = 0;
+
+ offs = agg->dtag_base;
+ lrec = &agg->dtag_action.dta_rec;
+ aggdesc.dtagd_size = lrec->dtrd_offset + lrec->dtrd_size - offs;
+
+ for (act = agg->dtag_first; ; act = act->dta_next) {
+ ASSERT(act->dta_intuple ||
+ DTRACEACT_ISAGG(act->dta_kind));
+
+ /*
+ * If this action has a record size of zero, it
+ * denotes an argument to the aggregating action.
+ * Because the presence of this record doesn't (or
+ * shouldn't) affect the way the data is interpreted,
+ * we don't copy it out to save user-level the
+ * confusion of dealing with a zero-length record.
+ */
+ if (act->dta_rec.dtrd_size == 0) {
+ ASSERT(agg->dtag_hasarg);
+ continue;
+ }
+
+ aggdesc.dtagd_nrecs++;
+
+ if (act == &agg->dtag_action)
+ break;
+ }
+
+ /*
+ * Now that we have the size, we need to allocate a temporary
+ * buffer in which to store the complete description. We need
+ * the temporary buffer to be able to drop dtrace_lock()
+ * across the copyout(), below.
+ */
+ size = sizeof (dtrace_aggdesc_t) +
+ (aggdesc.dtagd_nrecs * sizeof (dtrace_recdesc_t));
+
+ buf = kmem_alloc(size, KM_SLEEP);
+ dest = (uintptr_t)buf;
+
+ bcopy(&aggdesc, (void *)dest, sizeof (aggdesc));
+ dest += offsetof(dtrace_aggdesc_t, dtagd_rec[0]);
+
+ for (act = agg->dtag_first; ; act = act->dta_next) {
+ dtrace_recdesc_t rec = act->dta_rec;
+
+ /*
+ * See the comment in the above loop for why we pass
+ * over zero-length records.
+ */
+ if (rec.dtrd_size == 0) {
+ ASSERT(agg->dtag_hasarg);
+ continue;
+ }
+
+ if (nrecs-- == 0)
+ break;
+
+ rec.dtrd_offset -= offs;
+ bcopy(&rec, (void *)dest, sizeof (rec));
+ dest += sizeof (dtrace_recdesc_t);
+
+ if (act == &agg->dtag_action)
+ break;
+ }
+
+ mutex_exit(&dtrace_lock);
+
+ if (copyout(buf, (void *)arg, dest - (uintptr_t)buf) != 0) {
+ kmem_free(buf, size);
+ return (EFAULT);
+ }
+
+ kmem_free(buf, size);
+ return (0);
+ }
+
+ case DTRACEIOC_ENABLE: {
+ dof_hdr_t *dof;
+ dtrace_enabling_t *enab = NULL;
+ dtrace_vstate_t *vstate;
+ int err = 0;
+#ifdef VBOX
+ cred_t *cr = CRED();
+#endif
+
+ *rv = 0;
+
+ /*
+ * If a NULL argument has been passed, we take this as our
+ * cue to reevaluate our enablings.
+ */
+ if (arg == NULL) {
+ dtrace_enabling_matchall();
+
+ return (0);
+ }
+
+ if ((dof = dtrace_dof_copyin(arg, &rval)) == NULL)
+ return (rval);
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_lock);
+ vstate = &state->dts_vstate;
+
+ if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+ dtrace_dof_destroy(dof);
+ return (EBUSY);
+ }
+
+ if (dtrace_dof_slurp(dof, vstate, cr, &enab, 0, B_TRUE) != 0) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+ dtrace_dof_destroy(dof);
+ return (EINVAL);
+ }
+
+ if ((rval = dtrace_dof_options(dof, state)) != 0) {
+ dtrace_enabling_destroy(enab);
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+ dtrace_dof_destroy(dof);
+ return (rval);
+ }
+
+ if ((err = dtrace_enabling_match(enab, rv)) == 0) {
+ err = dtrace_enabling_retain(enab);
+ } else {
+ dtrace_enabling_destroy(enab);
+ }
+
+ mutex_exit(&cpu_lock);
+ mutex_exit(&dtrace_lock);
+ dtrace_dof_destroy(dof);
+
+ return (err);
+ }
+
+ case DTRACEIOC_REPLICATE: {
+ dtrace_repldesc_t desc;
+ dtrace_probedesc_t *match = &desc.dtrpd_match;
+ dtrace_probedesc_t *create = &desc.dtrpd_create;
+ int err;
+
+ if (copyin((void *)arg, &desc, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ match->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
+ match->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
+ match->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
+ match->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
+
+ create->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
+ create->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
+ create->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
+ create->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
+
+ mutex_enter(&dtrace_lock);
+ err = dtrace_enabling_replicate(state, match, create);
+ mutex_exit(&dtrace_lock);
+
+ return (err);
+ }
+
+ case DTRACEIOC_PROBEMATCH:
+ case DTRACEIOC_PROBES: {
+ dtrace_probe_t *probe = NULL;
+ dtrace_probedesc_t desc;
+ dtrace_probekey_t pkey;
+ dtrace_id_t i;
+ int m = 0;
+ uint32_t priv;
+ uid_t uid;
+ zoneid_t zoneid;
+#ifdef VBOX
+ cred_t *cr = CRED();
+#endif
+
+ if (copyin((void *)arg, &desc, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ desc.dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
+ desc.dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
+ desc.dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
+ desc.dtpd_name[DTRACE_NAMELEN - 1] = '\0';
+
+ /*
+ * Before we attempt to match this probe, we want to give
+ * all providers the opportunity to provide it.
+ */
+ if (desc.dtpd_id == DTRACE_IDNONE) {
+ mutex_enter(&dtrace_provider_lock);
+ dtrace_probe_provide(&desc, NULL);
+ mutex_exit(&dtrace_provider_lock);
+ desc.dtpd_id++;
+ }
+
+ if (cmd == DTRACEIOC_PROBEMATCH) {
+ dtrace_probekey(&desc, &pkey);
+ pkey.dtpk_id = DTRACE_IDNONE;
+ }
+
+ dtrace_cred2priv(cr, &priv, &uid, &zoneid);
+
+ mutex_enter(&dtrace_lock);
+
+ if (cmd == DTRACEIOC_PROBEMATCH) {
+ for (i = desc.dtpd_id; i <= dtrace_nprobes; i++) {
+ if ((probe = dtrace_probes[i - 1]) != NULL &&
+ (m = dtrace_match_probe(probe, &pkey,
+ priv, uid, zoneid)) != 0)
+ break;
+ }
+
+ if (m < 0) {
+ mutex_exit(&dtrace_lock);
+ return (EINVAL);
+ }
+
+ } else {
+ for (i = desc.dtpd_id; i <= dtrace_nprobes; i++) {
+ if ((probe = dtrace_probes[i - 1]) != NULL &&
+ dtrace_match_priv(probe, priv, uid, zoneid))
+ break;
+ }
+ }
+
+ if (probe == NULL) {
+ mutex_exit(&dtrace_lock);
+ return (ESRCH);
+ }
+
+ dtrace_probe_description(probe, &desc);
+ mutex_exit(&dtrace_lock);
+
+ if (copyout(&desc, (void *)arg, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_PROBEARG: {
+ dtrace_argdesc_t desc;
+ dtrace_probe_t *probe;
+ dtrace_provider_t *prov;
+
+ if (copyin((void *)arg, &desc, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ if (desc.dtargd_id == DTRACE_IDNONE)
+ return (EINVAL);
+
+ if (desc.dtargd_ndx == DTRACE_ARGNONE)
+ return (EINVAL);
+
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&mod_lock);
+ mutex_enter(&dtrace_lock);
+
+ if (desc.dtargd_id > dtrace_nprobes) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+ return (EINVAL);
+ }
+
+ if ((probe = dtrace_probes[desc.dtargd_id - 1]) == NULL) {
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+ return (EINVAL);
+ }
+
+ mutex_exit(&dtrace_lock);
+
+ prov = probe->dtpr_provider;
+
+ if (prov->dtpv_pops.dtps_getargdesc == NULL) {
+ /*
+ * There isn't any typed information for this probe.
+ * Set the argument number to DTRACE_ARGNONE.
+ */
+ desc.dtargd_ndx = DTRACE_ARGNONE;
+ } else {
+ desc.dtargd_native[0] = '\0';
+ desc.dtargd_xlate[0] = '\0';
+ desc.dtargd_mapping = desc.dtargd_ndx;
+
+ prov->dtpv_pops.dtps_getargdesc(prov->dtpv_arg,
+ probe->dtpr_id, probe->dtpr_arg, &desc);
+ }
+
+ mutex_exit(&mod_lock);
+ mutex_exit(&dtrace_provider_lock);
+
+ if (copyout(&desc, (void *)arg, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_GO: {
+ processorid_t cpuid;
+ rval = dtrace_state_go(state, &cpuid);
+
+ if (rval != 0)
+ return (rval);
+
+ if (copyout(&cpuid, (void *)arg, sizeof (cpuid)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_STOP: {
+ processorid_t cpuid;
+
+ mutex_enter(&dtrace_lock);
+ rval = dtrace_state_stop(state, &cpuid);
+ mutex_exit(&dtrace_lock);
+
+ if (rval != 0)
+ return (rval);
+
+ if (copyout(&cpuid, (void *)arg, sizeof (cpuid)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_DOFGET: {
+ dof_hdr_t hdr, *dof;
+ uint64_t len;
+
+ if (copyin((void *)arg, &hdr, sizeof (hdr)) != 0)
+ return (EFAULT);
+
+ mutex_enter(&dtrace_lock);
+ dof = dtrace_dof_create(state);
+ mutex_exit(&dtrace_lock);
+
+ len = MIN(hdr.dofh_loadsz, dof->dofh_loadsz);
+ rval = copyout(dof, (void *)arg, len);
+ dtrace_dof_destroy(dof);
+
+ return (rval == 0 ? 0 : EFAULT);
+ }
+
+ case DTRACEIOC_AGGSNAP:
+ case DTRACEIOC_BUFSNAP: {
+ dtrace_bufdesc_t desc;
+ caddr_t cached;
+ dtrace_buffer_t *buf;
+
+ if (copyin((void *)arg, &desc, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ if (/*VBox value is is unsigned: desc.dtbd_cpu < 0 ||*/ desc.dtbd_cpu >= NCPU)
+ return (EINVAL);
+
+ mutex_enter(&dtrace_lock);
+
+ if (cmd == DTRACEIOC_BUFSNAP) {
+ buf = &state->dts_buffer[desc.dtbd_cpu];
+ } else {
+ buf = &state->dts_aggbuffer[desc.dtbd_cpu];
+ }
+
+ if (buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL)) {
+ size_t sz = buf->dtb_offset;
+
+ if (state->dts_activity != DTRACE_ACTIVITY_STOPPED) {
+ mutex_exit(&dtrace_lock);
+ return (EBUSY);
+ }
+
+ /*
+ * If this buffer has already been consumed, we're
+ * going to indicate that there's nothing left here
+ * to consume.
+ */
+ if (buf->dtb_flags & DTRACEBUF_CONSUMED) {
+ mutex_exit(&dtrace_lock);
+
+ desc.dtbd_size = 0;
+ desc.dtbd_drops = 0;
+ desc.dtbd_errors = 0;
+ desc.dtbd_oldest = 0;
+ sz = sizeof (desc);
+
+ if (copyout(&desc, (void *)arg, sz) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ /*
+ * If this is a ring buffer that has wrapped, we want
+ * to copy the whole thing out.
+ */
+ if (buf->dtb_flags & DTRACEBUF_WRAPPED) {
+ dtrace_buffer_polish(buf);
+ sz = buf->dtb_size;
+ }
+
+ if (copyout(buf->dtb_tomax, desc.dtbd_data, sz) != 0) {
+ mutex_exit(&dtrace_lock);
+ return (EFAULT);
+ }
+
+ desc.dtbd_size = sz;
+ desc.dtbd_drops = buf->dtb_drops;
+ desc.dtbd_errors = buf->dtb_errors;
+ desc.dtbd_oldest = buf->dtb_xamot_offset;
+
+ mutex_exit(&dtrace_lock);
+
+ if (copyout(&desc, (void *)arg, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ buf->dtb_flags |= DTRACEBUF_CONSUMED;
+
+ return (0);
+ }
+
+ if (buf->dtb_tomax == NULL) {
+ ASSERT(buf->dtb_xamot == NULL);
+ mutex_exit(&dtrace_lock);
+ return (ENOENT);
+ }
+
+ cached = buf->dtb_tomax;
+ ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
+
+#ifndef VBOX
+ dtrace_xcall(desc.dtbd_cpu,
+ (dtrace_xcall_t)dtrace_buffer_switch, buf);
+#else
+ if (desc.dtbd_cpu == DTRACE_CPUALL)
+ RTMpOnAll(dtrace_buffer_switch_wrapper, buf, NULL);
+ else
+ RTMpOnSpecific(desc.dtbd_cpu, dtrace_buffer_switch_wrapper, buf, NULL);
+#endif
+
+ state->dts_errors += buf->dtb_xamot_errors;
+
+ /*
+ * If the buffers did not actually switch, then the cross call
+ * did not take place -- presumably because the given CPU is
+ * not in the ready set. If this is the case, we'll return
+ * ENOENT.
+ */
+ if (buf->dtb_tomax == cached) {
+ ASSERT(buf->dtb_xamot != cached);
+ mutex_exit(&dtrace_lock);
+ return (ENOENT);
+ }
+
+ ASSERT(cached == buf->dtb_xamot);
+
+ /*
+ * We have our snapshot; now copy it out.
+ */
+ if (copyout(buf->dtb_xamot, desc.dtbd_data,
+ buf->dtb_xamot_offset) != 0) {
+ mutex_exit(&dtrace_lock);
+ return (EFAULT);
+ }
+
+ desc.dtbd_size = buf->dtb_xamot_offset;
+ desc.dtbd_drops = buf->dtb_xamot_drops;
+ desc.dtbd_errors = buf->dtb_xamot_errors;
+ desc.dtbd_oldest = 0;
+
+ mutex_exit(&dtrace_lock);
+
+ /*
+ * Finally, copy out the buffer description.
+ */
+ if (copyout(&desc, (void *)arg, sizeof (desc)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_CONF: {
+ dtrace_conf_t conf;
+
+ bzero(&conf, sizeof (conf));
+ conf.dtc_difversion = DIF_VERSION;
+ conf.dtc_difintregs = DIF_DIR_NREGS;
+ conf.dtc_diftupregs = DIF_DTR_NREGS;
+ conf.dtc_ctfmodel = CTF_MODEL_NATIVE;
+
+ if (copyout(&conf, (void *)arg, sizeof (conf)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_STATUS: {
+ dtrace_status_t stat;
+ dtrace_dstate_t *dstate;
+ int i, j;
+ uint64_t nerrs;
+
+ /*
+ * See the comment in dtrace_state_deadman() for the reason
+ * for setting dts_laststatus to INT64_MAX before setting
+ * it to the correct value.
+ */
+ state->dts_laststatus = INT64_MAX;
+ dtrace_membar_producer();
+ state->dts_laststatus = dtrace_gethrtime();
+
+ bzero(&stat, sizeof (stat));
+
+ mutex_enter(&dtrace_lock);
+
+ if (state->dts_activity == DTRACE_ACTIVITY_INACTIVE) {
+ mutex_exit(&dtrace_lock);
+ return (ENOENT);
+ }
+
+ if (state->dts_activity == DTRACE_ACTIVITY_DRAINING)
+ stat.dtst_exiting = 1;
+
+ nerrs = state->dts_errors;
+ dstate = &state->dts_vstate.dtvs_dynvars;
+
+ for (i = 0; i < NCPU; i++) {
+ dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[i];
+
+ stat.dtst_dyndrops += dcpu->dtdsc_drops;
+ stat.dtst_dyndrops_dirty += dcpu->dtdsc_dirty_drops;
+ stat.dtst_dyndrops_rinsing += dcpu->dtdsc_rinsing_drops;
+
+ if (state->dts_buffer[i].dtb_flags & DTRACEBUF_FULL)
+ stat.dtst_filled++;
+
+ nerrs += state->dts_buffer[i].dtb_errors;
+
+ for (j = 0; j < state->dts_nspeculations; j++) {
+ dtrace_speculation_t *spec;
+ dtrace_buffer_t *buf;
+
+ spec = &state->dts_speculations[j];
+ buf = &spec->dtsp_buffer[i];
+ stat.dtst_specdrops += buf->dtb_xamot_drops;
+ }
+ }
+
+ stat.dtst_specdrops_busy = state->dts_speculations_busy;
+ stat.dtst_specdrops_unavail = state->dts_speculations_unavail;
+ stat.dtst_stkstroverflows = state->dts_stkstroverflows;
+ stat.dtst_dblerrors = state->dts_dblerrors;
+ stat.dtst_killed =
+ (state->dts_activity == DTRACE_ACTIVITY_KILLED);
+ stat.dtst_errors = nerrs;
+
+ mutex_exit(&dtrace_lock);
+
+ if (copyout(&stat, (void *)arg, sizeof (stat)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ case DTRACEIOC_FORMAT: {
+ dtrace_fmtdesc_t fmt;
+ char *str;
+ int len;
+
+ if (copyin((void *)arg, &fmt, sizeof (fmt)) != 0)
+ return (EFAULT);
+
+ mutex_enter(&dtrace_lock);
+
+ if (fmt.dtfd_format == 0 ||
+ fmt.dtfd_format > state->dts_nformats) {
+ mutex_exit(&dtrace_lock);
+ return (EINVAL);
+ }
+
+ /*
+ * Format strings are allocated contiguously and they are
+ * never freed; if a format index is less than the number
+ * of formats, we can assert that the format map is non-NULL
+ * and that the format for the specified index is non-NULL.
+ */
+ ASSERT(state->dts_formats != NULL);
+ str = state->dts_formats[fmt.dtfd_format - 1];
+ ASSERT(str != NULL);
+
+ len = VBDTCAST(int)strlen(str) + 1;
+
+ if (len > fmt.dtfd_length) {
+ fmt.dtfd_length = len;
+
+ if (copyout(&fmt, (void *)arg, sizeof (fmt)) != 0) {
+ mutex_exit(&dtrace_lock);
+ return (EINVAL);
+ }
+ } else {
+ if (copyout(str, fmt.dtfd_string, len) != 0) {
+ mutex_exit(&dtrace_lock);
+ return (EINVAL);
+ }
+ }
+
+ mutex_exit(&dtrace_lock);
+ return (0);
+ }
+
+ default:
+ break;
+ }
+
+ return (ENOTTY);
+}
+
+#ifdef VBOX
+int dtrace_detach(void)
+#else
+/*ARGSUSED*/
+static int
+dtrace_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
+#endif
+{
+ dtrace_state_t *state;
+
+#ifndef VBOX
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+
+ default:
+ return (DDI_FAILURE);
+ }
+#endif
+
+ mutex_enter(&cpu_lock);
+ mutex_enter(&dtrace_provider_lock);
+ mutex_enter(&dtrace_lock);
+
+ ASSERT(dtrace_opens == 0);
+
+ if (dtrace_helpers > 0) {
+ mutex_exit(&dtrace_provider_lock);
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+ return (DDI_FAILURE);
+ }
+
+ if (dtrace_unregister((dtrace_provider_id_t)dtrace_provider) != 0) {
+ mutex_exit(&dtrace_provider_lock);
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&cpu_lock);
+ return (DDI_FAILURE);
+ }
+
+ dtrace_provider = NULL;
+
+ if ((state = dtrace_anon_grab()) != NULL) {
+ /*
+ * If there were ECBs on this state, the provider should
+ * have not been allowed to detach; assert that there is
+ * none.
+ */
+ ASSERT(state->dts_necbs == 0);
+ dtrace_state_destroy(state);
+
+#ifndef VBOX
+ /*
+ * If we're being detached with anonymous state, we need to
+ * indicate to the kernel debugger that DTrace is now inactive.
+ */
+ (void) kdi_dtrace_set(KDI_DTSET_DTRACE_DEACTIVATE);
+#endif
+ }
+
+ bzero(&dtrace_anon, sizeof (dtrace_anon_t));
+#ifndef VBOX /** @todo CPU hooks */
+ unregister_cpu_setup_func((cpu_setup_func_t *)dtrace_cpu_setup, NULL);
+ dtrace_cpu_init = NULL;
+ dtrace_helpers_cleanup = NULL;
+ dtrace_helpers_fork = NULL;
+ dtrace_cpustart_init = NULL;
+ dtrace_cpustart_fini = NULL;
+ dtrace_debugger_init = NULL;
+ dtrace_debugger_fini = NULL;
+ dtrace_modload = NULL;
+ dtrace_modunload = NULL;
+#endif
+
+ mutex_exit(&cpu_lock);
+
+ if (dtrace_helptrace_enabled) {
+ kmem_free(dtrace_helptrace_buffer, dtrace_helptrace_bufsize);
+ dtrace_helptrace_buffer = NULL;
+ }
+
+ kmem_free(dtrace_probes, dtrace_nprobes * sizeof (dtrace_probe_t *));
+ dtrace_probes = NULL;
+ dtrace_nprobes = 0;
+
+ dtrace_hash_destroy(dtrace_bymod);
+ dtrace_hash_destroy(dtrace_byfunc);
+ dtrace_hash_destroy(dtrace_byname);
+ dtrace_bymod = NULL;
+ dtrace_byfunc = NULL;
+ dtrace_byname = NULL;
+
+ kmem_cache_destroy(dtrace_state_cache);
+#ifndef VBOX
+ vmem_destroy(dtrace_minor);
+#endif
+ vmem_destroy(dtrace_arena);
+
+ if (dtrace_toxrange != NULL) {
+ kmem_free(dtrace_toxrange,
+ dtrace_toxranges_max * sizeof (dtrace_toxrange_t));
+ dtrace_toxrange = NULL;
+ dtrace_toxranges = 0;
+ dtrace_toxranges_max = 0;
+ }
+
+#ifndef VBOX
+ ddi_remove_minor_node(dtrace_devi, NULL);
+ dtrace_devi = NULL;
+
+ ddi_soft_state_fini(&dtrace_softstate);
+#endif
+
+ ASSERT(dtrace_vtime_references == 0);
+ ASSERT(dtrace_opens == 0);
+ ASSERT(dtrace_retained == NULL);
+
+ mutex_exit(&dtrace_lock);
+ mutex_exit(&dtrace_provider_lock);
+#ifdef VBOX
+ VBoxDtMutexDelete(&dtrace_lock);
+ VBoxDtMutexDelete(&dtrace_provider_lock);
+ VBoxDtMutexDelete(&dtrace_meta_lock);
+# ifdef DEBUG
+ VBoxDtMutexDelete(&dtrace_errlock);
+# endif
+#endif
+
+ /*
+ * We don't destroy the task queue until after we have dropped our
+ * locks (taskq_destroy() may block on running tasks). To prevent
+ * attempting to do work after we have effectively detached but before
+ * the task queue has been destroyed, all tasks dispatched via the
+ * task queue must check that DTrace is still attached before
+ * performing any operation.
+ */
+#ifndef VBOX
+ taskq_destroy(dtrace_taskq);
+ dtrace_taskq = NULL;
+#endif
+
+ return (DDI_SUCCESS);
+}
+
+#ifndef VBOX
+/*ARGSUSED*/
+static int
+dtrace_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *)dtrace_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+static struct cb_ops dtrace_cb_ops = {
+ dtrace_open, /* open */
+ dtrace_close, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ dtrace_ioctl, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_NEW | D_MP /* Driver compatibility flag */
+};
+
+static struct dev_ops dtrace_ops = {
+ DEVO_REV, /* devo_rev */
+ 0, /* refcnt */
+ dtrace_info, /* get_dev_info */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ dtrace_attach, /* attach */
+ dtrace_detach, /* detach */
+ nodev, /* reset */
+ &dtrace_cb_ops, /* driver operations */
+ NULL, /* bus operations */
+ nodev, /* dev power */
+ ddi_quiesce_not_needed, /* quiesce */
+};
+
+static struct modldrv modldrv = {
+ &mod_driverops, /* module type (this is a pseudo driver) */
+ "Dynamic Tracing", /* name of module */
+ &dtrace_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1,
+ (void *)&modldrv,
+ NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
+
+#endif /* !VBOX */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.conf
new file mode 100644
index 00000000..6c4ec26b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.conf
@@ -0,0 +1,28 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+name="dtrace" parent="pseudo" instance=0;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/fasttrap.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/fasttrap.c
new file mode 100644
index 00000000..42263e4e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/fasttrap.c
@@ -0,0 +1,2378 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#include <sys/atomic.h>
+#include <sys/errno.h>
+#include <sys/stat.h>
+#include <sys/modctl.h>
+#include <sys/conf.h>
+#include <sys/systm.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/cpuvar.h>
+#include <sys/kmem.h>
+#include <sys/strsubr.h>
+#include <sys/fasttrap.h>
+#include <sys/fasttrap_impl.h>
+#include <sys/fasttrap_isa.h>
+#include <sys/dtrace.h>
+#include <sys/dtrace_impl.h>
+#include <sys/sysmacros.h>
+#include <sys/proc.h>
+#include <sys/priv.h>
+#include <sys/policy.h>
+#include <util/qsort.h>
+
+/*
+ * User-Land Trap-Based Tracing
+ * ----------------------------
+ *
+ * The fasttrap provider allows DTrace consumers to instrument any user-level
+ * instruction to gather data; this includes probes with semantic
+ * signifigance like entry and return as well as simple offsets into the
+ * function. While the specific techniques used are very ISA specific, the
+ * methodology is generalizable to any architecture.
+ *
+ *
+ * The General Methodology
+ * -----------------------
+ *
+ * With the primary goal of tracing every user-land instruction and the
+ * limitation that we can't trust user space so don't want to rely on much
+ * information there, we begin by replacing the instructions we want to trace
+ * with trap instructions. Each instruction we overwrite is saved into a hash
+ * table keyed by process ID and pc address. When we enter the kernel due to
+ * this trap instruction, we need the effects of the replaced instruction to
+ * appear to have occurred before we proceed with the user thread's
+ * execution.
+ *
+ * Each user level thread is represented by a ulwp_t structure which is
+ * always easily accessible through a register. The most basic way to produce
+ * the effects of the instruction we replaced is to copy that instruction out
+ * to a bit of scratch space reserved in the user thread's ulwp_t structure
+ * (a sort of kernel-private thread local storage), set the PC to that
+ * scratch space and single step. When we reenter the kernel after single
+ * stepping the instruction we must then adjust the PC to point to what would
+ * normally be the next instruction. Of course, special care must be taken
+ * for branches and jumps, but these represent such a small fraction of any
+ * instruction set that writing the code to emulate these in the kernel is
+ * not too difficult.
+ *
+ * Return probes may require several tracepoints to trace every return site,
+ * and, conversely, each tracepoint may activate several probes (the entry
+ * and offset 0 probes, for example). To solve this muliplexing problem,
+ * tracepoints contain lists of probes to activate and probes contain lists
+ * of tracepoints to enable. If a probe is activated, it adds its ID to
+ * existing tracepoints or creates new ones as necessary.
+ *
+ * Most probes are activated _before_ the instruction is executed, but return
+ * probes are activated _after_ the effects of the last instruction of the
+ * function are visible. Return probes must be fired _after_ we have
+ * single-stepped the instruction whereas all other probes are fired
+ * beforehand.
+ *
+ *
+ * Lock Ordering
+ * -------------
+ *
+ * The lock ordering below -- both internally and with respect to the DTrace
+ * framework -- is a little tricky and bears some explanation. Each provider
+ * has a lock (ftp_mtx) that protects its members including reference counts
+ * for enabled probes (ftp_rcount), consumers actively creating probes
+ * (ftp_ccount) and USDT consumers (ftp_mcount); all three prevent a provider
+ * from being freed. A provider is looked up by taking the bucket lock for the
+ * provider hash table, and is returned with its lock held. The provider lock
+ * may be taken in functions invoked by the DTrace framework, but may not be
+ * held while calling functions in the DTrace framework.
+ *
+ * To ensure consistency over multiple calls to the DTrace framework, the
+ * creation lock (ftp_cmtx) should be held. Naturally, the creation lock may
+ * not be taken when holding the provider lock as that would create a cyclic
+ * lock ordering. In situations where one would naturally take the provider
+ * lock and then the creation lock, we instead up a reference count to prevent
+ * the provider from disappearing, drop the provider lock, and acquire the
+ * creation lock.
+ *
+ * Briefly:
+ * bucket lock before provider lock
+ * DTrace before provider lock
+ * creation lock before DTrace
+ * never hold the provider lock and creation lock simultaneously
+ */
+
+static dev_info_t *fasttrap_devi;
+static dtrace_meta_provider_id_t fasttrap_meta_id;
+
+static timeout_id_t fasttrap_timeout;
+static kmutex_t fasttrap_cleanup_mtx;
+static uint_t fasttrap_cleanup_work;
+
+/*
+ * Generation count on modifications to the global tracepoint lookup table.
+ */
+static volatile uint64_t fasttrap_mod_gen;
+
+/*
+ * When the fasttrap provider is loaded, fasttrap_max is set to either
+ * FASTTRAP_MAX_DEFAULT or the value for fasttrap-max-probes in the
+ * fasttrap.conf file. Each time a probe is created, fasttrap_total is
+ * incremented by the number of tracepoints that may be associated with that
+ * probe; fasttrap_total is capped at fasttrap_max.
+ */
+#define FASTTRAP_MAX_DEFAULT 250000
+static uint32_t fasttrap_max;
+static uint32_t fasttrap_total;
+
+
+#define FASTTRAP_TPOINTS_DEFAULT_SIZE 0x4000
+#define FASTTRAP_PROVIDERS_DEFAULT_SIZE 0x100
+#define FASTTRAP_PROCS_DEFAULT_SIZE 0x100
+
+#define FASTTRAP_PID_NAME "pid"
+
+fasttrap_hash_t fasttrap_tpoints;
+static fasttrap_hash_t fasttrap_provs;
+static fasttrap_hash_t fasttrap_procs;
+
+static uint64_t fasttrap_pid_count; /* pid ref count */
+static kmutex_t fasttrap_count_mtx; /* lock on ref count */
+
+#define FASTTRAP_ENABLE_FAIL 1
+#define FASTTRAP_ENABLE_PARTIAL 2
+
+static int fasttrap_tracepoint_enable(proc_t *, fasttrap_probe_t *, uint_t);
+static void fasttrap_tracepoint_disable(proc_t *, fasttrap_probe_t *, uint_t);
+
+static fasttrap_provider_t *fasttrap_provider_lookup(pid_t, const char *,
+ const dtrace_pattr_t *);
+static void fasttrap_provider_retire(pid_t, const char *, int);
+static void fasttrap_provider_free(fasttrap_provider_t *);
+
+static fasttrap_proc_t *fasttrap_proc_lookup(pid_t);
+static void fasttrap_proc_release(fasttrap_proc_t *);
+
+#define FASTTRAP_PROVS_INDEX(pid, name) \
+ ((fasttrap_hash_str(name) + (pid)) & fasttrap_provs.fth_mask)
+
+#define FASTTRAP_PROCS_INDEX(pid) ((pid) & fasttrap_procs.fth_mask)
+
+static int
+fasttrap_highbit(ulong_t i)
+{
+ int h = 1;
+
+ if (i == 0)
+ return (0);
+#ifdef _LP64
+ if (i & 0xffffffff00000000ul) {
+ h += 32; i >>= 32;
+ }
+#endif
+ if (i & 0xffff0000) {
+ h += 16; i >>= 16;
+ }
+ if (i & 0xff00) {
+ h += 8; i >>= 8;
+ }
+ if (i & 0xf0) {
+ h += 4; i >>= 4;
+ }
+ if (i & 0xc) {
+ h += 2; i >>= 2;
+ }
+ if (i & 0x2) {
+ h += 1;
+ }
+ return (h);
+}
+
+static uint_t
+fasttrap_hash_str(const char *p)
+{
+ unsigned int g;
+ uint_t hval = 0;
+
+ while (*p) {
+ hval = (hval << 4) + *p++;
+ if ((g = (hval & 0xf0000000)) != 0)
+ hval ^= g >> 24;
+ hval &= ~g;
+ }
+ return (hval);
+}
+
+void
+fasttrap_sigtrap(proc_t *p, kthread_t *t, uintptr_t pc)
+{
+ sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
+
+ sqp->sq_info.si_signo = SIGTRAP;
+ sqp->sq_info.si_code = TRAP_DTRACE;
+ sqp->sq_info.si_addr = (caddr_t)pc;
+
+ mutex_enter(&p->p_lock);
+ sigaddqa(p, t, sqp);
+ mutex_exit(&p->p_lock);
+
+ if (t != NULL)
+ aston(t);
+}
+
+/*
+ * This function ensures that no threads are actively using the memory
+ * associated with probes that were formerly live.
+ */
+static void
+fasttrap_mod_barrier(uint64_t gen)
+{
+ int i;
+
+ if (gen < fasttrap_mod_gen)
+ return;
+
+ fasttrap_mod_gen++;
+
+ for (i = 0; i < NCPU; i++) {
+ mutex_enter(&cpu_core[i].cpuc_pid_lock);
+ mutex_exit(&cpu_core[i].cpuc_pid_lock);
+ }
+}
+
+/*
+ * This is the timeout's callback for cleaning up the providers and their
+ * probes.
+ */
+/*ARGSUSED*/
+static void
+fasttrap_pid_cleanup_cb(void *data)
+{
+ fasttrap_provider_t **fpp, *fp;
+ fasttrap_bucket_t *bucket;
+ dtrace_provider_id_t provid;
+ int i, later;
+
+ static volatile int in = 0;
+ ASSERT(in == 0);
+ in = 1;
+
+ mutex_enter(&fasttrap_cleanup_mtx);
+ while (fasttrap_cleanup_work) {
+ fasttrap_cleanup_work = 0;
+ mutex_exit(&fasttrap_cleanup_mtx);
+
+ later = 0;
+
+ /*
+ * Iterate over all the providers trying to remove the marked
+ * ones. If a provider is marked but not retired, we just
+ * have to take a crack at removing it -- it's no big deal if
+ * we can't.
+ */
+ for (i = 0; i < fasttrap_provs.fth_nent; i++) {
+ bucket = &fasttrap_provs.fth_table[i];
+ mutex_enter(&bucket->ftb_mtx);
+ fpp = (fasttrap_provider_t **)&bucket->ftb_data;
+
+ while ((fp = *fpp) != NULL) {
+ if (!fp->ftp_marked) {
+ fpp = &fp->ftp_next;
+ continue;
+ }
+
+ mutex_enter(&fp->ftp_mtx);
+
+ /*
+ * If this provider has consumers actively
+ * creating probes (ftp_ccount) or is a USDT
+ * provider (ftp_mcount), we can't unregister
+ * or even condense.
+ */
+ if (fp->ftp_ccount != 0 ||
+ fp->ftp_mcount != 0) {
+ mutex_exit(&fp->ftp_mtx);
+ fp->ftp_marked = 0;
+ continue;
+ }
+
+ if (!fp->ftp_retired || fp->ftp_rcount != 0)
+ fp->ftp_marked = 0;
+
+ mutex_exit(&fp->ftp_mtx);
+
+ /*
+ * If we successfully unregister this
+ * provider we can remove it from the hash
+ * chain and free the memory. If our attempt
+ * to unregister fails and this is a retired
+ * provider, increment our flag to try again
+ * pretty soon. If we've consumed more than
+ * half of our total permitted number of
+ * probes call dtrace_condense() to try to
+ * clean out the unenabled probes.
+ */
+ provid = fp->ftp_provid;
+ if (dtrace_unregister(provid) != 0) {
+ if (fasttrap_total > fasttrap_max / 2)
+ (void) dtrace_condense(provid);
+ later += fp->ftp_marked;
+ fpp = &fp->ftp_next;
+ } else {
+ *fpp = fp->ftp_next;
+ fasttrap_provider_free(fp);
+ }
+ }
+ mutex_exit(&bucket->ftb_mtx);
+ }
+
+ mutex_enter(&fasttrap_cleanup_mtx);
+ }
+
+ ASSERT(fasttrap_timeout != 0);
+
+ /*
+ * If we were unable to remove a retired provider, try again after
+ * a second. This situation can occur in certain circumstances where
+ * providers cannot be unregistered even though they have no probes
+ * enabled because of an execution of dtrace -l or something similar.
+ * If the timeout has been disabled (set to 1 because we're trying
+ * to detach), we set fasttrap_cleanup_work to ensure that we'll
+ * get a chance to do that work if and when the timeout is reenabled
+ * (if detach fails).
+ */
+ if (later > 0 && fasttrap_timeout != (timeout_id_t)1)
+ fasttrap_timeout = timeout(&fasttrap_pid_cleanup_cb, NULL, hz);
+ else if (later > 0)
+ fasttrap_cleanup_work = 1;
+ else
+ fasttrap_timeout = 0;
+
+ mutex_exit(&fasttrap_cleanup_mtx);
+ in = 0;
+}
+
+/*
+ * Activates the asynchronous cleanup mechanism.
+ */
+static void
+fasttrap_pid_cleanup(void)
+{
+ mutex_enter(&fasttrap_cleanup_mtx);
+ fasttrap_cleanup_work = 1;
+ if (fasttrap_timeout == 0)
+ fasttrap_timeout = timeout(&fasttrap_pid_cleanup_cb, NULL, 1);
+ mutex_exit(&fasttrap_cleanup_mtx);
+}
+
+/*
+ * This is called from cfork() via dtrace_fasttrap_fork(). The child
+ * process's address space is (roughly) a copy of the parent process's so
+ * we have to remove all the instrumentation we had previously enabled in the
+ * parent.
+ */
+static void
+fasttrap_fork(proc_t *p, proc_t *cp)
+{
+ pid_t ppid = p->p_pid;
+ int i;
+
+ ASSERT(curproc == p);
+ ASSERT(p->p_proc_flag & P_PR_LOCK);
+ ASSERT(p->p_dtrace_count > 0);
+ ASSERT(cp->p_dtrace_count == 0);
+
+ /*
+ * This would be simpler and faster if we maintained per-process
+ * hash tables of enabled tracepoints. It could, however, potentially
+ * slow down execution of a tracepoint since we'd need to go
+ * through two levels of indirection. In the future, we should
+ * consider either maintaining per-process ancillary lists of
+ * enabled tracepoints or hanging a pointer to a per-process hash
+ * table of enabled tracepoints off the proc structure.
+ */
+
+ /*
+ * We don't have to worry about the child process disappearing
+ * because we're in fork().
+ */
+ mutex_enter(&cp->p_lock);
+ sprlock_proc(cp);
+ mutex_exit(&cp->p_lock);
+
+ /*
+ * Iterate over every tracepoint looking for ones that belong to the
+ * parent process, and remove each from the child process.
+ */
+ for (i = 0; i < fasttrap_tpoints.fth_nent; i++) {
+ fasttrap_tracepoint_t *tp;
+ fasttrap_bucket_t *bucket = &fasttrap_tpoints.fth_table[i];
+
+ mutex_enter(&bucket->ftb_mtx);
+ for (tp = bucket->ftb_data; tp != NULL; tp = tp->ftt_next) {
+ if (tp->ftt_pid == ppid &&
+ tp->ftt_proc->ftpc_acount != 0) {
+ int ret = fasttrap_tracepoint_remove(cp, tp);
+ ASSERT(ret == 0);
+
+ /*
+ * The count of active providers can only be
+ * decremented (i.e. to zero) during exec,
+ * exit, and removal of a meta provider so it
+ * should be impossible to drop the count
+ * mid-fork.
+ */
+ ASSERT(tp->ftt_proc->ftpc_acount != 0);
+ }
+ }
+ mutex_exit(&bucket->ftb_mtx);
+ }
+
+ mutex_enter(&cp->p_lock);
+ sprunlock(cp);
+}
+
+/*
+ * This is called from proc_exit() or from exec_common() if p_dtrace_probes
+ * is set on the proc structure to indicate that there is a pid provider
+ * associated with this process.
+ */
+static void
+fasttrap_exec_exit(proc_t *p)
+{
+ ASSERT(p == curproc);
+ ASSERT(MUTEX_HELD(&p->p_lock));
+
+ mutex_exit(&p->p_lock);
+
+ /*
+ * We clean up the pid provider for this process here; user-land
+ * static probes are handled by the meta-provider remove entry point.
+ */
+ fasttrap_provider_retire(p->p_pid, FASTTRAP_PID_NAME, 0);
+
+ mutex_enter(&p->p_lock);
+}
+
+
+/*ARGSUSED*/
+static void
+fasttrap_pid_provide(void *arg, const dtrace_probedesc_t *desc)
+{
+ /*
+ * There are no "default" pid probes.
+ */
+}
+
+static int
+fasttrap_tracepoint_enable(proc_t *p, fasttrap_probe_t *probe, uint_t index)
+{
+ fasttrap_tracepoint_t *tp, *new_tp = NULL;
+ fasttrap_bucket_t *bucket;
+ fasttrap_id_t *id;
+ pid_t pid;
+ uintptr_t pc;
+
+ ASSERT(index < probe->ftp_ntps);
+
+ pid = probe->ftp_pid;
+ pc = probe->ftp_tps[index].fit_tp->ftt_pc;
+ id = &probe->ftp_tps[index].fit_id;
+
+ ASSERT(probe->ftp_tps[index].fit_tp->ftt_pid == pid);
+
+ ASSERT(!(p->p_flag & SVFORK));
+
+ /*
+ * Before we make any modifications, make sure we've imposed a barrier
+ * on the generation in which this probe was last modified.
+ */
+ fasttrap_mod_barrier(probe->ftp_gen);
+
+ bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
+
+ /*
+ * If the tracepoint has already been enabled, just add our id to the
+ * list of interested probes. This may be our second time through
+ * this path in which case we'll have constructed the tracepoint we'd
+ * like to install. If we can't find a match, and have an allocated
+ * tracepoint ready to go, enable that one now.
+ *
+ * A tracepoint whose process is defunct is also considered defunct.
+ */
+again:
+ mutex_enter(&bucket->ftb_mtx);
+ for (tp = bucket->ftb_data; tp != NULL; tp = tp->ftt_next) {
+ /*
+ * Note that it's safe to access the active count on the
+ * associated proc structure because we know that at least one
+ * provider (this one) will still be around throughout this
+ * operation.
+ */
+ if (tp->ftt_pid != pid || tp->ftt_pc != pc ||
+ tp->ftt_proc->ftpc_acount == 0)
+ continue;
+
+ /*
+ * Now that we've found a matching tracepoint, it would be
+ * a decent idea to confirm that the tracepoint is still
+ * enabled and the trap instruction hasn't been overwritten.
+ * Since this is a little hairy, we'll punt for now.
+ */
+
+ /*
+ * This can't be the first interested probe. We don't have
+ * to worry about another thread being in the midst of
+ * deleting this tracepoint (which would be the only valid
+ * reason for a tracepoint to have no interested probes)
+ * since we're holding P_PR_LOCK for this process.
+ */
+ ASSERT(tp->ftt_ids != NULL || tp->ftt_retids != NULL);
+
+ switch (id->fti_ptype) {
+ case DTFTP_ENTRY:
+ case DTFTP_OFFSETS:
+ case DTFTP_IS_ENABLED:
+ id->fti_next = tp->ftt_ids;
+ membar_producer();
+ tp->ftt_ids = id;
+ membar_producer();
+ break;
+
+ case DTFTP_RETURN:
+ case DTFTP_POST_OFFSETS:
+ id->fti_next = tp->ftt_retids;
+ membar_producer();
+ tp->ftt_retids = id;
+ membar_producer();
+ break;
+
+ default:
+ ASSERT(0);
+ }
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ if (new_tp != NULL) {
+ new_tp->ftt_ids = NULL;
+ new_tp->ftt_retids = NULL;
+ }
+
+ return (0);
+ }
+
+ /*
+ * If we have a good tracepoint ready to go, install it now while
+ * we have the lock held and no one can screw with us.
+ */
+ if (new_tp != NULL) {
+ int rc = 0;
+
+ new_tp->ftt_next = bucket->ftb_data;
+ membar_producer();
+ bucket->ftb_data = new_tp;
+ membar_producer();
+ mutex_exit(&bucket->ftb_mtx);
+
+ /*
+ * Activate the tracepoint in the ISA-specific manner.
+ * If this fails, we need to report the failure, but
+ * indicate that this tracepoint must still be disabled
+ * by calling fasttrap_tracepoint_disable().
+ */
+ if (fasttrap_tracepoint_install(p, new_tp) != 0)
+ rc = FASTTRAP_ENABLE_PARTIAL;
+
+ /*
+ * Increment the count of the number of tracepoints active in
+ * the victim process.
+ */
+ ASSERT(p->p_proc_flag & P_PR_LOCK);
+ p->p_dtrace_count++;
+
+ return (rc);
+ }
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ /*
+ * Initialize the tracepoint that's been preallocated with the probe.
+ */
+ new_tp = probe->ftp_tps[index].fit_tp;
+
+ ASSERT(new_tp->ftt_pid == pid);
+ ASSERT(new_tp->ftt_pc == pc);
+ ASSERT(new_tp->ftt_proc == probe->ftp_prov->ftp_proc);
+ ASSERT(new_tp->ftt_ids == NULL);
+ ASSERT(new_tp->ftt_retids == NULL);
+
+ switch (id->fti_ptype) {
+ case DTFTP_ENTRY:
+ case DTFTP_OFFSETS:
+ case DTFTP_IS_ENABLED:
+ id->fti_next = NULL;
+ new_tp->ftt_ids = id;
+ break;
+
+ case DTFTP_RETURN:
+ case DTFTP_POST_OFFSETS:
+ id->fti_next = NULL;
+ new_tp->ftt_retids = id;
+ break;
+
+ default:
+ ASSERT(0);
+ }
+
+ /*
+ * If the ISA-dependent initialization goes to plan, go back to the
+ * beginning and try to install this freshly made tracepoint.
+ */
+ if (fasttrap_tracepoint_init(p, new_tp, pc, id->fti_ptype) == 0)
+ goto again;
+
+ new_tp->ftt_ids = NULL;
+ new_tp->ftt_retids = NULL;
+
+ return (FASTTRAP_ENABLE_FAIL);
+}
+
+static void
+fasttrap_tracepoint_disable(proc_t *p, fasttrap_probe_t *probe, uint_t index)
+{
+ fasttrap_bucket_t *bucket;
+ fasttrap_provider_t *provider = probe->ftp_prov;
+ fasttrap_tracepoint_t **pp, *tp;
+ fasttrap_id_t *id, **idp;
+ pid_t pid;
+ uintptr_t pc;
+
+ ASSERT(index < probe->ftp_ntps);
+
+ pid = probe->ftp_pid;
+ pc = probe->ftp_tps[index].fit_tp->ftt_pc;
+ id = &probe->ftp_tps[index].fit_id;
+
+ ASSERT(probe->ftp_tps[index].fit_tp->ftt_pid == pid);
+
+ /*
+ * Find the tracepoint and make sure that our id is one of the
+ * ones registered with it.
+ */
+ bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
+ mutex_enter(&bucket->ftb_mtx);
+ for (tp = bucket->ftb_data; tp != NULL; tp = tp->ftt_next) {
+ if (tp->ftt_pid == pid && tp->ftt_pc == pc &&
+ tp->ftt_proc == provider->ftp_proc)
+ break;
+ }
+
+ /*
+ * If we somehow lost this tracepoint, we're in a world of hurt.
+ */
+ ASSERT(tp != NULL);
+
+ switch (id->fti_ptype) {
+ case DTFTP_ENTRY:
+ case DTFTP_OFFSETS:
+ case DTFTP_IS_ENABLED:
+ ASSERT(tp->ftt_ids != NULL);
+ idp = &tp->ftt_ids;
+ break;
+
+ case DTFTP_RETURN:
+ case DTFTP_POST_OFFSETS:
+ ASSERT(tp->ftt_retids != NULL);
+ idp = &tp->ftt_retids;
+ break;
+
+ default:
+ ASSERT(0);
+ }
+
+ while ((*idp)->fti_probe != probe) {
+ idp = &(*idp)->fti_next;
+ ASSERT(*idp != NULL);
+ }
+
+ id = *idp;
+ *idp = id->fti_next;
+ membar_producer();
+
+ ASSERT(id->fti_probe == probe);
+
+ /*
+ * If there are other registered enablings of this tracepoint, we're
+ * all done, but if this was the last probe assocated with this
+ * this tracepoint, we need to remove and free it.
+ */
+ if (tp->ftt_ids != NULL || tp->ftt_retids != NULL) {
+
+ /*
+ * If the current probe's tracepoint is in use, swap it
+ * for an unused tracepoint.
+ */
+ if (tp == probe->ftp_tps[index].fit_tp) {
+ fasttrap_probe_t *tmp_probe;
+ fasttrap_tracepoint_t **tmp_tp;
+ uint_t tmp_index;
+
+ if (tp->ftt_ids != NULL) {
+ tmp_probe = tp->ftt_ids->fti_probe;
+ /* LINTED - alignment */
+ tmp_index = FASTTRAP_ID_INDEX(tp->ftt_ids);
+ tmp_tp = &tmp_probe->ftp_tps[tmp_index].fit_tp;
+ } else {
+ tmp_probe = tp->ftt_retids->fti_probe;
+ /* LINTED - alignment */
+ tmp_index = FASTTRAP_ID_INDEX(tp->ftt_retids);
+ tmp_tp = &tmp_probe->ftp_tps[tmp_index].fit_tp;
+ }
+
+ ASSERT(*tmp_tp != NULL);
+ ASSERT(*tmp_tp != probe->ftp_tps[index].fit_tp);
+ ASSERT((*tmp_tp)->ftt_ids == NULL);
+ ASSERT((*tmp_tp)->ftt_retids == NULL);
+
+ probe->ftp_tps[index].fit_tp = *tmp_tp;
+ *tmp_tp = tp;
+ }
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ /*
+ * Tag the modified probe with the generation in which it was
+ * changed.
+ */
+ probe->ftp_gen = fasttrap_mod_gen;
+ return;
+ }
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ /*
+ * We can't safely remove the tracepoint from the set of active
+ * tracepoints until we've actually removed the fasttrap instruction
+ * from the process's text. We can, however, operate on this
+ * tracepoint secure in the knowledge that no other thread is going to
+ * be looking at it since we hold P_PR_LOCK on the process if it's
+ * live or we hold the provider lock on the process if it's dead and
+ * gone.
+ */
+
+ /*
+ * We only need to remove the actual instruction if we're looking
+ * at an existing process
+ */
+ if (p != NULL) {
+ /*
+ * If we fail to restore the instruction we need to kill
+ * this process since it's in a completely unrecoverable
+ * state.
+ */
+ if (fasttrap_tracepoint_remove(p, tp) != 0)
+ fasttrap_sigtrap(p, NULL, pc);
+
+ /*
+ * Decrement the count of the number of tracepoints active
+ * in the victim process.
+ */
+ ASSERT(p->p_proc_flag & P_PR_LOCK);
+ p->p_dtrace_count--;
+ }
+
+ /*
+ * Remove the probe from the hash table of active tracepoints.
+ */
+ mutex_enter(&bucket->ftb_mtx);
+ pp = (fasttrap_tracepoint_t **)&bucket->ftb_data;
+ ASSERT(*pp != NULL);
+ while (*pp != tp) {
+ pp = &(*pp)->ftt_next;
+ ASSERT(*pp != NULL);
+ }
+
+ *pp = tp->ftt_next;
+ membar_producer();
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ /*
+ * Tag the modified probe with the generation in which it was changed.
+ */
+ probe->ftp_gen = fasttrap_mod_gen;
+}
+
+static void
+fasttrap_enable_callbacks(void)
+{
+ /*
+ * We don't have to play the rw lock game here because we're
+ * providing something rather than taking something away --
+ * we can be sure that no threads have tried to follow this
+ * function pointer yet.
+ */
+ mutex_enter(&fasttrap_count_mtx);
+ if (fasttrap_pid_count == 0) {
+ ASSERT(dtrace_pid_probe_ptr == NULL);
+ ASSERT(dtrace_return_probe_ptr == NULL);
+ dtrace_pid_probe_ptr = &fasttrap_pid_probe;
+ dtrace_return_probe_ptr = &fasttrap_return_probe;
+ }
+ ASSERT(dtrace_pid_probe_ptr == &fasttrap_pid_probe);
+ ASSERT(dtrace_return_probe_ptr == &fasttrap_return_probe);
+ fasttrap_pid_count++;
+ mutex_exit(&fasttrap_count_mtx);
+}
+
+static void
+fasttrap_disable_callbacks(void)
+{
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ mutex_enter(&fasttrap_count_mtx);
+ ASSERT(fasttrap_pid_count > 0);
+ fasttrap_pid_count--;
+ if (fasttrap_pid_count == 0) {
+ cpu_t *cur, *cpu = CPU;
+
+ for (cur = cpu->cpu_next_onln; cur != cpu;
+ cur = cur->cpu_next_onln) {
+ rw_enter(&cur->cpu_ft_lock, RW_WRITER);
+ }
+
+ dtrace_pid_probe_ptr = NULL;
+ dtrace_return_probe_ptr = NULL;
+
+ for (cur = cpu->cpu_next_onln; cur != cpu;
+ cur = cur->cpu_next_onln) {
+ rw_exit(&cur->cpu_ft_lock);
+ }
+ }
+ mutex_exit(&fasttrap_count_mtx);
+}
+
+/*ARGSUSED*/
+static int
+fasttrap_pid_enable(void *arg, dtrace_id_t id, void *parg)
+{
+ fasttrap_probe_t *probe = parg;
+ proc_t *p;
+ int i, rc;
+
+ ASSERT(probe != NULL);
+ ASSERT(!probe->ftp_enabled);
+ ASSERT(id == probe->ftp_id);
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ /*
+ * Increment the count of enabled probes on this probe's provider;
+ * the provider can't go away while the probe still exists. We
+ * must increment this even if we aren't able to properly enable
+ * this probe.
+ */
+ mutex_enter(&probe->ftp_prov->ftp_mtx);
+ probe->ftp_prov->ftp_rcount++;
+ mutex_exit(&probe->ftp_prov->ftp_mtx);
+
+ /*
+ * If this probe's provider is retired (meaning it was valid in a
+ * previously exec'ed incarnation of this address space), bail out. The
+ * provider can't go away while we're in this code path.
+ */
+ if (probe->ftp_prov->ftp_retired)
+ return (0);
+
+ /*
+ * If we can't find the process, it may be that we're in the context of
+ * a fork in which the traced process is being born and we're copying
+ * USDT probes. Otherwise, the process is gone so bail.
+ */
+ if ((p = sprlock(probe->ftp_pid)) == NULL) {
+ if ((curproc->p_flag & SFORKING) == 0)
+ return (0);
+
+ mutex_enter(&pidlock);
+ p = prfind(probe->ftp_pid);
+
+ /*
+ * Confirm that curproc is indeed forking the process in which
+ * we're trying to enable probes.
+ */
+ ASSERT(p != NULL);
+ ASSERT(p->p_parent == curproc);
+ ASSERT(p->p_stat == SIDL);
+
+ mutex_enter(&p->p_lock);
+ mutex_exit(&pidlock);
+
+ sprlock_proc(p);
+ }
+
+ ASSERT(!(p->p_flag & SVFORK));
+ mutex_exit(&p->p_lock);
+
+ /*
+ * We have to enable the trap entry point before any user threads have
+ * the chance to execute the trap instruction we're about to place
+ * in their process's text.
+ */
+ fasttrap_enable_callbacks();
+
+ /*
+ * Enable all the tracepoints and add this probe's id to each
+ * tracepoint's list of active probes.
+ */
+ for (i = 0; i < probe->ftp_ntps; i++) {
+ if ((rc = fasttrap_tracepoint_enable(p, probe, i)) != 0) {
+ /*
+ * If enabling the tracepoint failed completely,
+ * we don't have to disable it; if the failure
+ * was only partial we must disable it.
+ */
+ if (rc == FASTTRAP_ENABLE_FAIL)
+ i--;
+ else
+ ASSERT(rc == FASTTRAP_ENABLE_PARTIAL);
+
+ /*
+ * Back up and pull out all the tracepoints we've
+ * created so far for this probe.
+ */
+ while (i >= 0) {
+ fasttrap_tracepoint_disable(p, probe, i);
+ i--;
+ }
+
+ mutex_enter(&p->p_lock);
+ sprunlock(p);
+
+ /*
+ * Since we're not actually enabling this probe,
+ * drop our reference on the trap table entry.
+ */
+ fasttrap_disable_callbacks();
+ return (0);
+ }
+ }
+
+ mutex_enter(&p->p_lock);
+ sprunlock(p);
+
+ probe->ftp_enabled = 1;
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+fasttrap_pid_disable(void *arg, dtrace_id_t id, void *parg)
+{
+ fasttrap_probe_t *probe = parg;
+ fasttrap_provider_t *provider = probe->ftp_prov;
+ proc_t *p;
+ int i, whack = 0;
+
+ ASSERT(id == probe->ftp_id);
+
+ /*
+ * We won't be able to acquire a /proc-esque lock on the process
+ * iff the process is dead and gone. In this case, we rely on the
+ * provider lock as a point of mutual exclusion to prevent other
+ * DTrace consumers from disabling this probe.
+ */
+ if ((p = sprlock(probe->ftp_pid)) != NULL) {
+ ASSERT(!(p->p_flag & SVFORK));
+ mutex_exit(&p->p_lock);
+ }
+
+ mutex_enter(&provider->ftp_mtx);
+
+ /*
+ * Disable all the associated tracepoints (for fully enabled probes).
+ */
+ if (probe->ftp_enabled) {
+ for (i = 0; i < probe->ftp_ntps; i++) {
+ fasttrap_tracepoint_disable(p, probe, i);
+ }
+ }
+
+ ASSERT(provider->ftp_rcount > 0);
+ provider->ftp_rcount--;
+
+ if (p != NULL) {
+ /*
+ * Even though we may not be able to remove it entirely, we
+ * mark this retired provider to get a chance to remove some
+ * of the associated probes.
+ */
+ if (provider->ftp_retired && !provider->ftp_marked)
+ whack = provider->ftp_marked = 1;
+ mutex_exit(&provider->ftp_mtx);
+
+ mutex_enter(&p->p_lock);
+ sprunlock(p);
+ } else {
+ /*
+ * If the process is dead, we're just waiting for the
+ * last probe to be disabled to be able to free it.
+ */
+ if (provider->ftp_rcount == 0 && !provider->ftp_marked)
+ whack = provider->ftp_marked = 1;
+ mutex_exit(&provider->ftp_mtx);
+ }
+
+ if (whack)
+ fasttrap_pid_cleanup();
+
+ if (!probe->ftp_enabled)
+ return;
+
+ probe->ftp_enabled = 0;
+
+ ASSERT(MUTEX_HELD(&cpu_lock));
+ fasttrap_disable_callbacks();
+}
+
+/*ARGSUSED*/
+static void
+fasttrap_pid_getargdesc(void *arg, dtrace_id_t id, void *parg,
+ dtrace_argdesc_t *desc)
+{
+ fasttrap_probe_t *probe = parg;
+ char *str;
+ int i, ndx;
+
+ desc->dtargd_native[0] = '\0';
+ desc->dtargd_xlate[0] = '\0';
+
+ if (probe->ftp_prov->ftp_retired != 0 ||
+ desc->dtargd_ndx >= probe->ftp_nargs) {
+ desc->dtargd_ndx = DTRACE_ARGNONE;
+ return;
+ }
+
+ ndx = (probe->ftp_argmap != NULL) ?
+ probe->ftp_argmap[desc->dtargd_ndx] : desc->dtargd_ndx;
+
+ str = probe->ftp_ntypes;
+ for (i = 0; i < ndx; i++) {
+ str += strlen(str) + 1;
+ }
+
+ ASSERT(strlen(str + 1) < sizeof (desc->dtargd_native));
+ (void) strcpy(desc->dtargd_native, str);
+
+ if (probe->ftp_xtypes == NULL)
+ return;
+
+ str = probe->ftp_xtypes;
+ for (i = 0; i < desc->dtargd_ndx; i++) {
+ str += strlen(str) + 1;
+ }
+
+ ASSERT(strlen(str + 1) < sizeof (desc->dtargd_xlate));
+ (void) strcpy(desc->dtargd_xlate, str);
+}
+
+/*ARGSUSED*/
+static void
+fasttrap_pid_destroy(void *arg, dtrace_id_t id, void *parg)
+{
+ fasttrap_probe_t *probe = parg;
+ int i;
+ size_t size;
+
+ ASSERT(probe != NULL);
+ ASSERT(!probe->ftp_enabled);
+ ASSERT(fasttrap_total >= probe->ftp_ntps);
+
+ atomic_add_32(&fasttrap_total, -probe->ftp_ntps);
+ size = offsetof(fasttrap_probe_t, ftp_tps[probe->ftp_ntps]);
+
+ if (probe->ftp_gen + 1 >= fasttrap_mod_gen)
+ fasttrap_mod_barrier(probe->ftp_gen);
+
+ for (i = 0; i < probe->ftp_ntps; i++) {
+ kmem_free(probe->ftp_tps[i].fit_tp,
+ sizeof (fasttrap_tracepoint_t));
+ }
+
+ kmem_free(probe, size);
+}
+
+
+static const dtrace_pattr_t pid_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+};
+
+static dtrace_pops_t pid_pops = {
+ fasttrap_pid_provide,
+ NULL,
+ fasttrap_pid_enable,
+ fasttrap_pid_disable,
+ NULL,
+ NULL,
+ fasttrap_pid_getargdesc,
+ fasttrap_pid_getarg,
+ NULL,
+ fasttrap_pid_destroy
+};
+
+static dtrace_pops_t usdt_pops = {
+ fasttrap_pid_provide,
+ NULL,
+ fasttrap_pid_enable,
+ fasttrap_pid_disable,
+ NULL,
+ NULL,
+ fasttrap_pid_getargdesc,
+ fasttrap_usdt_getarg,
+ NULL,
+ fasttrap_pid_destroy
+};
+
+static fasttrap_proc_t *
+fasttrap_proc_lookup(pid_t pid)
+{
+ fasttrap_bucket_t *bucket;
+ fasttrap_proc_t *fprc, *new_fprc;
+
+ bucket = &fasttrap_procs.fth_table[FASTTRAP_PROCS_INDEX(pid)];
+ mutex_enter(&bucket->ftb_mtx);
+
+ for (fprc = bucket->ftb_data; fprc != NULL; fprc = fprc->ftpc_next) {
+ if (fprc->ftpc_pid == pid && fprc->ftpc_acount != 0) {
+ mutex_enter(&fprc->ftpc_mtx);
+ mutex_exit(&bucket->ftb_mtx);
+ fprc->ftpc_rcount++;
+ atomic_add_64(&fprc->ftpc_acount, 1);
+ ASSERT(fprc->ftpc_acount <= fprc->ftpc_rcount);
+ mutex_exit(&fprc->ftpc_mtx);
+
+ return (fprc);
+ }
+ }
+
+ /*
+ * Drop the bucket lock so we don't try to perform a sleeping
+ * allocation under it.
+ */
+ mutex_exit(&bucket->ftb_mtx);
+
+ new_fprc = kmem_zalloc(sizeof (fasttrap_proc_t), KM_SLEEP);
+ new_fprc->ftpc_pid = pid;
+ new_fprc->ftpc_rcount = 1;
+ new_fprc->ftpc_acount = 1;
+
+ mutex_enter(&bucket->ftb_mtx);
+
+ /*
+ * Take another lap through the list to make sure a proc hasn't
+ * been created for this pid while we weren't under the bucket lock.
+ */
+ for (fprc = bucket->ftb_data; fprc != NULL; fprc = fprc->ftpc_next) {
+ if (fprc->ftpc_pid == pid && fprc->ftpc_acount != 0) {
+ mutex_enter(&fprc->ftpc_mtx);
+ mutex_exit(&bucket->ftb_mtx);
+ fprc->ftpc_rcount++;
+ atomic_add_64(&fprc->ftpc_acount, 1);
+ ASSERT(fprc->ftpc_acount <= fprc->ftpc_rcount);
+ mutex_exit(&fprc->ftpc_mtx);
+
+ kmem_free(new_fprc, sizeof (fasttrap_proc_t));
+
+ return (fprc);
+ }
+ }
+
+ new_fprc->ftpc_next = bucket->ftb_data;
+ bucket->ftb_data = new_fprc;
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ return (new_fprc);
+}
+
+static void
+fasttrap_proc_release(fasttrap_proc_t *proc)
+{
+ fasttrap_bucket_t *bucket;
+ fasttrap_proc_t *fprc, **fprcp;
+ pid_t pid = proc->ftpc_pid;
+
+ mutex_enter(&proc->ftpc_mtx);
+
+ ASSERT(proc->ftpc_rcount != 0);
+ ASSERT(proc->ftpc_acount <= proc->ftpc_rcount);
+
+ if (--proc->ftpc_rcount != 0) {
+ mutex_exit(&proc->ftpc_mtx);
+ return;
+ }
+
+ mutex_exit(&proc->ftpc_mtx);
+
+ /*
+ * There should definitely be no live providers associated with this
+ * process at this point.
+ */
+ ASSERT(proc->ftpc_acount == 0);
+
+ bucket = &fasttrap_procs.fth_table[FASTTRAP_PROCS_INDEX(pid)];
+ mutex_enter(&bucket->ftb_mtx);
+
+ fprcp = (fasttrap_proc_t **)&bucket->ftb_data;
+ while ((fprc = *fprcp) != NULL) {
+ if (fprc == proc)
+ break;
+
+ fprcp = &fprc->ftpc_next;
+ }
+
+ /*
+ * Something strange has happened if we can't find the proc.
+ */
+ ASSERT(fprc != NULL);
+
+ *fprcp = fprc->ftpc_next;
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ kmem_free(fprc, sizeof (fasttrap_proc_t));
+}
+
+/*
+ * Lookup a fasttrap-managed provider based on its name and associated pid.
+ * If the pattr argument is non-NULL, this function instantiates the provider
+ * if it doesn't exist otherwise it returns NULL. The provider is returned
+ * with its lock held.
+ */
+static fasttrap_provider_t *
+fasttrap_provider_lookup(pid_t pid, const char *name,
+ const dtrace_pattr_t *pattr)
+{
+ fasttrap_provider_t *fp, *new_fp = NULL;
+ fasttrap_bucket_t *bucket;
+ char provname[DTRACE_PROVNAMELEN];
+ proc_t *p;
+ cred_t *cred;
+
+ ASSERT(strlen(name) < sizeof (fp->ftp_name));
+ ASSERT(pattr != NULL);
+
+ bucket = &fasttrap_provs.fth_table[FASTTRAP_PROVS_INDEX(pid, name)];
+ mutex_enter(&bucket->ftb_mtx);
+
+ /*
+ * Take a lap through the list and return the match if we find it.
+ */
+ for (fp = bucket->ftb_data; fp != NULL; fp = fp->ftp_next) {
+ if (fp->ftp_pid == pid && strcmp(fp->ftp_name, name) == 0 &&
+ !fp->ftp_retired) {
+ mutex_enter(&fp->ftp_mtx);
+ mutex_exit(&bucket->ftb_mtx);
+ return (fp);
+ }
+ }
+
+ /*
+ * Drop the bucket lock so we don't try to perform a sleeping
+ * allocation under it.
+ */
+ mutex_exit(&bucket->ftb_mtx);
+
+ /*
+ * Make sure the process exists, isn't a child created as the result
+ * of a vfork(2), and isn't a zombie (but may be in fork).
+ */
+ mutex_enter(&pidlock);
+ if ((p = prfind(pid)) == NULL) {
+ mutex_exit(&pidlock);
+ return (NULL);
+ }
+ mutex_enter(&p->p_lock);
+ mutex_exit(&pidlock);
+ if (p->p_flag & (SVFORK | SEXITING)) {
+ mutex_exit(&p->p_lock);
+ return (NULL);
+ }
+
+ /*
+ * Increment p_dtrace_probes so that the process knows to inform us
+ * when it exits or execs. fasttrap_provider_free() decrements this
+ * when we're done with this provider.
+ */
+ p->p_dtrace_probes++;
+
+ /*
+ * Grab the credentials for this process so we have
+ * something to pass to dtrace_register().
+ */
+ mutex_enter(&p->p_crlock);
+ crhold(p->p_cred);
+ cred = p->p_cred;
+ mutex_exit(&p->p_crlock);
+ mutex_exit(&p->p_lock);
+
+ new_fp = kmem_zalloc(sizeof (fasttrap_provider_t), KM_SLEEP);
+ new_fp->ftp_pid = pid;
+ new_fp->ftp_proc = fasttrap_proc_lookup(pid);
+
+ ASSERT(new_fp->ftp_proc != NULL);
+
+ mutex_enter(&bucket->ftb_mtx);
+
+ /*
+ * Take another lap through the list to make sure a provider hasn't
+ * been created for this pid while we weren't under the bucket lock.
+ */
+ for (fp = bucket->ftb_data; fp != NULL; fp = fp->ftp_next) {
+ if (fp->ftp_pid == pid && strcmp(fp->ftp_name, name) == 0 &&
+ !fp->ftp_retired) {
+ mutex_enter(&fp->ftp_mtx);
+ mutex_exit(&bucket->ftb_mtx);
+ fasttrap_provider_free(new_fp);
+ crfree(cred);
+ return (fp);
+ }
+ }
+
+ (void) strcpy(new_fp->ftp_name, name);
+
+ /*
+ * Fail and return NULL if either the provider name is too long
+ * or we fail to register this new provider with the DTrace
+ * framework. Note that this is the only place we ever construct
+ * the full provider name -- we keep it in pieces in the provider
+ * structure.
+ */
+ if (snprintf(provname, sizeof (provname), "%s%u", name, (uint_t)pid) >=
+ sizeof (provname) ||
+ dtrace_register(provname, pattr,
+ DTRACE_PRIV_PROC | DTRACE_PRIV_OWNER | DTRACE_PRIV_ZONEOWNER, cred,
+ pattr == &pid_attr ? &pid_pops : &usdt_pops, new_fp,
+ &new_fp->ftp_provid) != 0) {
+ mutex_exit(&bucket->ftb_mtx);
+ fasttrap_provider_free(new_fp);
+ crfree(cred);
+ return (NULL);
+ }
+
+ new_fp->ftp_next = bucket->ftb_data;
+ bucket->ftb_data = new_fp;
+
+ mutex_enter(&new_fp->ftp_mtx);
+ mutex_exit(&bucket->ftb_mtx);
+
+ crfree(cred);
+ return (new_fp);
+}
+
+static void
+fasttrap_provider_free(fasttrap_provider_t *provider)
+{
+ pid_t pid = provider->ftp_pid;
+ proc_t *p;
+
+ /*
+ * There need to be no associated enabled probes, no consumers
+ * creating probes, and no meta providers referencing this provider.
+ */
+ ASSERT(provider->ftp_rcount == 0);
+ ASSERT(provider->ftp_ccount == 0);
+ ASSERT(provider->ftp_mcount == 0);
+
+ /*
+ * If this provider hasn't been retired, we need to explicitly drop the
+ * count of active providers on the associated process structure.
+ */
+ if (!provider->ftp_retired) {
+ atomic_add_64(&provider->ftp_proc->ftpc_acount, -1);
+ ASSERT(provider->ftp_proc->ftpc_acount <
+ provider->ftp_proc->ftpc_rcount);
+ }
+
+ fasttrap_proc_release(provider->ftp_proc);
+
+ kmem_free(provider, sizeof (fasttrap_provider_t));
+
+ /*
+ * Decrement p_dtrace_probes on the process whose provider we're
+ * freeing. We don't have to worry about clobbering somone else's
+ * modifications to it because we have locked the bucket that
+ * corresponds to this process's hash chain in the provider hash
+ * table. Don't sweat it if we can't find the process.
+ */
+ mutex_enter(&pidlock);
+ if ((p = prfind(pid)) == NULL) {
+ mutex_exit(&pidlock);
+ return;
+ }
+
+ mutex_enter(&p->p_lock);
+ mutex_exit(&pidlock);
+
+ p->p_dtrace_probes--;
+ mutex_exit(&p->p_lock);
+}
+
+static void
+fasttrap_provider_retire(pid_t pid, const char *name, int mprov)
+{
+ fasttrap_provider_t *fp;
+ fasttrap_bucket_t *bucket;
+ dtrace_provider_id_t provid;
+
+ ASSERT(strlen(name) < sizeof (fp->ftp_name));
+
+ bucket = &fasttrap_provs.fth_table[FASTTRAP_PROVS_INDEX(pid, name)];
+ mutex_enter(&bucket->ftb_mtx);
+
+ for (fp = bucket->ftb_data; fp != NULL; fp = fp->ftp_next) {
+ if (fp->ftp_pid == pid && strcmp(fp->ftp_name, name) == 0 &&
+ !fp->ftp_retired)
+ break;
+ }
+
+ if (fp == NULL) {
+ mutex_exit(&bucket->ftb_mtx);
+ return;
+ }
+
+ mutex_enter(&fp->ftp_mtx);
+ ASSERT(!mprov || fp->ftp_mcount > 0);
+ if (mprov && --fp->ftp_mcount != 0) {
+ mutex_exit(&fp->ftp_mtx);
+ mutex_exit(&bucket->ftb_mtx);
+ return;
+ }
+
+ /*
+ * Mark the provider to be removed in our post-processing step, mark it
+ * retired, and drop the active count on its proc. Marking it indicates
+ * that we should try to remove it; setting the retired flag indicates
+ * that we're done with this provider; dropping the active the proc
+ * releases our hold, and when this reaches zero (as it will during
+ * exit or exec) the proc and associated providers become defunct.
+ *
+ * We obviously need to take the bucket lock before the provider lock
+ * to perform the lookup, but we need to drop the provider lock
+ * before calling into the DTrace framework since we acquire the
+ * provider lock in callbacks invoked from the DTrace framework. The
+ * bucket lock therefore protects the integrity of the provider hash
+ * table.
+ */
+ atomic_add_64(&fp->ftp_proc->ftpc_acount, -1);
+ ASSERT(fp->ftp_proc->ftpc_acount < fp->ftp_proc->ftpc_rcount);
+
+ fp->ftp_retired = 1;
+ fp->ftp_marked = 1;
+ provid = fp->ftp_provid;
+ mutex_exit(&fp->ftp_mtx);
+
+ /*
+ * We don't have to worry about invalidating the same provider twice
+ * since fasttrap_provider_lookup() will ignore provider that have
+ * been marked as retired.
+ */
+ dtrace_invalidate(provid);
+
+ mutex_exit(&bucket->ftb_mtx);
+
+ fasttrap_pid_cleanup();
+}
+
+static int
+fasttrap_uint32_cmp(const void *ap, const void *bp)
+{
+ return (*(const uint32_t *)ap - *(const uint32_t *)bp);
+}
+
+static int
+fasttrap_uint64_cmp(const void *ap, const void *bp)
+{
+ return (*(const uint64_t *)ap - *(const uint64_t *)bp);
+}
+
+static int
+fasttrap_add_probe(fasttrap_probe_spec_t *pdata)
+{
+ fasttrap_provider_t *provider;
+ fasttrap_probe_t *pp;
+ fasttrap_tracepoint_t *tp;
+ char *name;
+ int i, aframes, whack;
+
+ /*
+ * There needs to be at least one desired trace point.
+ */
+ if (pdata->ftps_noffs == 0)
+ return (EINVAL);
+
+ switch (pdata->ftps_type) {
+ case DTFTP_ENTRY:
+ name = "entry";
+ aframes = FASTTRAP_ENTRY_AFRAMES;
+ break;
+ case DTFTP_RETURN:
+ name = "return";
+ aframes = FASTTRAP_RETURN_AFRAMES;
+ break;
+ case DTFTP_OFFSETS:
+ name = NULL;
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if ((provider = fasttrap_provider_lookup(pdata->ftps_pid,
+ FASTTRAP_PID_NAME, &pid_attr)) == NULL)
+ return (ESRCH);
+
+ /*
+ * Increment this reference count to indicate that a consumer is
+ * actively adding a new probe associated with this provider. This
+ * prevents the provider from being deleted -- we'll need to check
+ * for pending deletions when we drop this reference count.
+ */
+ provider->ftp_ccount++;
+ mutex_exit(&provider->ftp_mtx);
+
+ /*
+ * Grab the creation lock to ensure consistency between calls to
+ * dtrace_probe_lookup() and dtrace_probe_create() in the face of
+ * other threads creating probes. We must drop the provider lock
+ * before taking this lock to avoid a three-way deadlock with the
+ * DTrace framework.
+ */
+ mutex_enter(&provider->ftp_cmtx);
+
+ if (name == NULL) {
+ for (i = 0; i < pdata->ftps_noffs; i++) {
+ char name_str[17];
+
+ (void) sprintf(name_str, "%llx",
+ (unsigned long long)pdata->ftps_offs[i]);
+
+ if (dtrace_probe_lookup(provider->ftp_provid,
+ pdata->ftps_mod, pdata->ftps_func, name_str) != 0)
+ continue;
+
+ atomic_add_32(&fasttrap_total, 1);
+
+ if (fasttrap_total > fasttrap_max) {
+ atomic_add_32(&fasttrap_total, -1);
+ goto no_mem;
+ }
+
+ pp = kmem_zalloc(sizeof (fasttrap_probe_t), KM_SLEEP);
+
+ pp->ftp_prov = provider;
+ pp->ftp_faddr = pdata->ftps_pc;
+ pp->ftp_fsize = pdata->ftps_size;
+ pp->ftp_pid = pdata->ftps_pid;
+ pp->ftp_ntps = 1;
+
+ tp = kmem_zalloc(sizeof (fasttrap_tracepoint_t),
+ KM_SLEEP);
+
+ tp->ftt_proc = provider->ftp_proc;
+ tp->ftt_pc = pdata->ftps_offs[i] + pdata->ftps_pc;
+ tp->ftt_pid = pdata->ftps_pid;
+
+ pp->ftp_tps[0].fit_tp = tp;
+ pp->ftp_tps[0].fit_id.fti_probe = pp;
+ pp->ftp_tps[0].fit_id.fti_ptype = pdata->ftps_type;
+
+ pp->ftp_id = dtrace_probe_create(provider->ftp_provid,
+ pdata->ftps_mod, pdata->ftps_func, name_str,
+ FASTTRAP_OFFSET_AFRAMES, pp);
+ }
+
+ } else if (dtrace_probe_lookup(provider->ftp_provid, pdata->ftps_mod,
+ pdata->ftps_func, name) == 0) {
+ atomic_add_32(&fasttrap_total, pdata->ftps_noffs);
+
+ if (fasttrap_total > fasttrap_max) {
+ atomic_add_32(&fasttrap_total, -pdata->ftps_noffs);
+ goto no_mem;
+ }
+
+ /*
+ * Make sure all tracepoint program counter values are unique.
+ * We later assume that each probe has exactly one tracepoint
+ * for a given pc.
+ */
+ qsort(pdata->ftps_offs, pdata->ftps_noffs,
+ sizeof (uint64_t), fasttrap_uint64_cmp);
+ for (i = 1; i < pdata->ftps_noffs; i++) {
+ if (pdata->ftps_offs[i] > pdata->ftps_offs[i - 1])
+ continue;
+
+ atomic_add_32(&fasttrap_total, -pdata->ftps_noffs);
+ goto no_mem;
+ }
+
+ ASSERT(pdata->ftps_noffs > 0);
+ pp = kmem_zalloc(offsetof(fasttrap_probe_t,
+ ftp_tps[pdata->ftps_noffs]), KM_SLEEP);
+
+ pp->ftp_prov = provider;
+ pp->ftp_faddr = pdata->ftps_pc;
+ pp->ftp_fsize = pdata->ftps_size;
+ pp->ftp_pid = pdata->ftps_pid;
+ pp->ftp_ntps = pdata->ftps_noffs;
+
+ for (i = 0; i < pdata->ftps_noffs; i++) {
+ tp = kmem_zalloc(sizeof (fasttrap_tracepoint_t),
+ KM_SLEEP);
+
+ tp->ftt_proc = provider->ftp_proc;
+ tp->ftt_pc = pdata->ftps_offs[i] + pdata->ftps_pc;
+ tp->ftt_pid = pdata->ftps_pid;
+
+ pp->ftp_tps[i].fit_tp = tp;
+ pp->ftp_tps[i].fit_id.fti_probe = pp;
+ pp->ftp_tps[i].fit_id.fti_ptype = pdata->ftps_type;
+ }
+
+ pp->ftp_id = dtrace_probe_create(provider->ftp_provid,
+ pdata->ftps_mod, pdata->ftps_func, name, aframes, pp);
+ }
+
+ mutex_exit(&provider->ftp_cmtx);
+
+ /*
+ * We know that the provider is still valid since we incremented the
+ * creation reference count. If someone tried to clean up this provider
+ * while we were using it (e.g. because the process called exec(2) or
+ * exit(2)), take note of that and try to clean it up now.
+ */
+ mutex_enter(&provider->ftp_mtx);
+ provider->ftp_ccount--;
+ whack = provider->ftp_retired;
+ mutex_exit(&provider->ftp_mtx);
+
+ if (whack)
+ fasttrap_pid_cleanup();
+
+ return (0);
+
+no_mem:
+ /*
+ * If we've exhausted the allowable resources, we'll try to remove
+ * this provider to free some up. This is to cover the case where
+ * the user has accidentally created many more probes than was
+ * intended (e.g. pid123:::).
+ */
+ mutex_exit(&provider->ftp_cmtx);
+ mutex_enter(&provider->ftp_mtx);
+ provider->ftp_ccount--;
+ provider->ftp_marked = 1;
+ mutex_exit(&provider->ftp_mtx);
+
+ fasttrap_pid_cleanup();
+
+ return (ENOMEM);
+}
+
+/*ARGSUSED*/
+static void *
+fasttrap_meta_provide(void *arg, dtrace_helper_provdesc_t *dhpv, pid_t pid)
+{
+ fasttrap_provider_t *provider;
+
+ /*
+ * A 32-bit unsigned integer (like a pid for example) can be
+ * expressed in 10 or fewer decimal digits. Make sure that we'll
+ * have enough space for the provider name.
+ */
+ if (strlen(dhpv->dthpv_provname) + 10 >=
+ sizeof (provider->ftp_name)) {
+ cmn_err(CE_WARN, "failed to instantiate provider %s: "
+ "name too long to accomodate pid", dhpv->dthpv_provname);
+ return (NULL);
+ }
+
+ /*
+ * Don't let folks spoof the true pid provider.
+ */
+ if (strcmp(dhpv->dthpv_provname, FASTTRAP_PID_NAME) == 0) {
+ cmn_err(CE_WARN, "failed to instantiate provider %s: "
+ "%s is an invalid name", dhpv->dthpv_provname,
+ FASTTRAP_PID_NAME);
+ return (NULL);
+ }
+
+ /*
+ * The highest stability class that fasttrap supports is ISA; cap
+ * the stability of the new provider accordingly.
+ */
+ if (dhpv->dthpv_pattr.dtpa_provider.dtat_class > DTRACE_CLASS_ISA)
+ dhpv->dthpv_pattr.dtpa_provider.dtat_class = DTRACE_CLASS_ISA;
+ if (dhpv->dthpv_pattr.dtpa_mod.dtat_class > DTRACE_CLASS_ISA)
+ dhpv->dthpv_pattr.dtpa_mod.dtat_class = DTRACE_CLASS_ISA;
+ if (dhpv->dthpv_pattr.dtpa_func.dtat_class > DTRACE_CLASS_ISA)
+ dhpv->dthpv_pattr.dtpa_func.dtat_class = DTRACE_CLASS_ISA;
+ if (dhpv->dthpv_pattr.dtpa_name.dtat_class > DTRACE_CLASS_ISA)
+ dhpv->dthpv_pattr.dtpa_name.dtat_class = DTRACE_CLASS_ISA;
+ if (dhpv->dthpv_pattr.dtpa_args.dtat_class > DTRACE_CLASS_ISA)
+ dhpv->dthpv_pattr.dtpa_args.dtat_class = DTRACE_CLASS_ISA;
+
+ if ((provider = fasttrap_provider_lookup(pid, dhpv->dthpv_provname,
+ &dhpv->dthpv_pattr)) == NULL) {
+ cmn_err(CE_WARN, "failed to instantiate provider %s for "
+ "process %u", dhpv->dthpv_provname, (uint_t)pid);
+ return (NULL);
+ }
+
+ /*
+ * Up the meta provider count so this provider isn't removed until
+ * the meta provider has been told to remove it.
+ */
+ provider->ftp_mcount++;
+
+ mutex_exit(&provider->ftp_mtx);
+
+ return (provider);
+}
+
+/*ARGSUSED*/
+static void
+fasttrap_meta_create_probe(void *arg, void *parg,
+ dtrace_helper_probedesc_t *dhpb)
+{
+ fasttrap_provider_t *provider = parg;
+ fasttrap_probe_t *pp;
+ fasttrap_tracepoint_t *tp;
+ int i, j;
+ uint32_t ntps;
+
+ /*
+ * Since the meta provider count is non-zero we don't have to worry
+ * about this provider disappearing.
+ */
+ ASSERT(provider->ftp_mcount > 0);
+
+ /*
+ * The offsets must be unique.
+ */
+ qsort(dhpb->dthpb_offs, dhpb->dthpb_noffs, sizeof (uint32_t),
+ fasttrap_uint32_cmp);
+ for (i = 1; i < dhpb->dthpb_noffs; i++) {
+ if (dhpb->dthpb_base + dhpb->dthpb_offs[i] <=
+ dhpb->dthpb_base + dhpb->dthpb_offs[i - 1])
+ return;
+ }
+
+ qsort(dhpb->dthpb_enoffs, dhpb->dthpb_nenoffs, sizeof (uint32_t),
+ fasttrap_uint32_cmp);
+ for (i = 1; i < dhpb->dthpb_nenoffs; i++) {
+ if (dhpb->dthpb_base + dhpb->dthpb_enoffs[i] <=
+ dhpb->dthpb_base + dhpb->dthpb_enoffs[i - 1])
+ return;
+ }
+
+ /*
+ * Grab the creation lock to ensure consistency between calls to
+ * dtrace_probe_lookup() and dtrace_probe_create() in the face of
+ * other threads creating probes.
+ */
+ mutex_enter(&provider->ftp_cmtx);
+
+ if (dtrace_probe_lookup(provider->ftp_provid, dhpb->dthpb_mod,
+ dhpb->dthpb_func, dhpb->dthpb_name) != 0) {
+ mutex_exit(&provider->ftp_cmtx);
+ return;
+ }
+
+ ntps = dhpb->dthpb_noffs + dhpb->dthpb_nenoffs;
+ ASSERT(ntps > 0);
+
+ atomic_add_32(&fasttrap_total, ntps);
+
+ if (fasttrap_total > fasttrap_max) {
+ atomic_add_32(&fasttrap_total, -ntps);
+ mutex_exit(&provider->ftp_cmtx);
+ return;
+ }
+
+ pp = kmem_zalloc(offsetof(fasttrap_probe_t, ftp_tps[ntps]), KM_SLEEP);
+
+ pp->ftp_prov = provider;
+ pp->ftp_pid = provider->ftp_pid;
+ pp->ftp_ntps = ntps;
+ pp->ftp_nargs = dhpb->dthpb_xargc;
+ pp->ftp_xtypes = dhpb->dthpb_xtypes;
+ pp->ftp_ntypes = dhpb->dthpb_ntypes;
+
+ /*
+ * First create a tracepoint for each actual point of interest.
+ */
+ for (i = 0; i < dhpb->dthpb_noffs; i++) {
+ tp = kmem_zalloc(sizeof (fasttrap_tracepoint_t), KM_SLEEP);
+
+ tp->ftt_proc = provider->ftp_proc;
+ tp->ftt_pc = dhpb->dthpb_base + dhpb->dthpb_offs[i];
+ tp->ftt_pid = provider->ftp_pid;
+
+ pp->ftp_tps[i].fit_tp = tp;
+ pp->ftp_tps[i].fit_id.fti_probe = pp;
+#ifdef __sparc
+ pp->ftp_tps[i].fit_id.fti_ptype = DTFTP_POST_OFFSETS;
+#else
+ pp->ftp_tps[i].fit_id.fti_ptype = DTFTP_OFFSETS;
+#endif
+ }
+
+ /*
+ * Then create a tracepoint for each is-enabled point.
+ */
+ for (j = 0; i < ntps; i++, j++) {
+ tp = kmem_zalloc(sizeof (fasttrap_tracepoint_t), KM_SLEEP);
+
+ tp->ftt_proc = provider->ftp_proc;
+ tp->ftt_pc = dhpb->dthpb_base + dhpb->dthpb_enoffs[j];
+ tp->ftt_pid = provider->ftp_pid;
+
+ pp->ftp_tps[i].fit_tp = tp;
+ pp->ftp_tps[i].fit_id.fti_probe = pp;
+ pp->ftp_tps[i].fit_id.fti_ptype = DTFTP_IS_ENABLED;
+ }
+
+ /*
+ * If the arguments are shuffled around we set the argument remapping
+ * table. Later, when the probe fires, we only remap the arguments
+ * if the table is non-NULL.
+ */
+ for (i = 0; i < dhpb->dthpb_xargc; i++) {
+ if (dhpb->dthpb_args[i] != i) {
+ pp->ftp_argmap = dhpb->dthpb_args;
+ break;
+ }
+ }
+
+ /*
+ * The probe is fully constructed -- register it with DTrace.
+ */
+ pp->ftp_id = dtrace_probe_create(provider->ftp_provid, dhpb->dthpb_mod,
+ dhpb->dthpb_func, dhpb->dthpb_name, FASTTRAP_OFFSET_AFRAMES, pp);
+
+ mutex_exit(&provider->ftp_cmtx);
+}
+
+/*ARGSUSED*/
+static void
+fasttrap_meta_remove(void *arg, dtrace_helper_provdesc_t *dhpv, pid_t pid)
+{
+ /*
+ * Clean up the USDT provider. There may be active consumers of the
+ * provider busy adding probes, no damage will actually befall the
+ * provider until that count has dropped to zero. This just puts
+ * the provider on death row.
+ */
+ fasttrap_provider_retire(pid, dhpv->dthpv_provname, 1);
+}
+
+static dtrace_mops_t fasttrap_mops = {
+ fasttrap_meta_create_probe,
+ fasttrap_meta_provide,
+ fasttrap_meta_remove
+};
+
+/*ARGSUSED*/
+static int
+fasttrap_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+{
+ return (0);
+}
+
+/*ARGSUSED*/
+static int
+fasttrap_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
+{
+ if (!dtrace_attached())
+ return (EAGAIN);
+
+ if (cmd == FASTTRAPIOC_MAKEPROBE) {
+ fasttrap_probe_spec_t *uprobe = (void *)arg;
+ fasttrap_probe_spec_t *probe;
+ uint64_t noffs;
+ size_t size;
+ int ret;
+ char *c;
+
+ if (copyin(&uprobe->ftps_noffs, &noffs,
+ sizeof (uprobe->ftps_noffs)))
+ return (EFAULT);
+
+ /*
+ * Probes must have at least one tracepoint.
+ */
+ if (noffs == 0)
+ return (EINVAL);
+
+ size = sizeof (fasttrap_probe_spec_t) +
+ sizeof (probe->ftps_offs[0]) * (noffs - 1);
+
+ if (size > 1024 * 1024)
+ return (ENOMEM);
+
+ probe = kmem_alloc(size, KM_SLEEP);
+
+ if (copyin(uprobe, probe, size) != 0 ||
+ probe->ftps_noffs != noffs) {
+ kmem_free(probe, size);
+ return (EFAULT);
+ }
+
+ /*
+ * Verify that the function and module strings contain no
+ * funny characters.
+ */
+ for (c = &probe->ftps_func[0]; *c != '\0'; c++) {
+ if (*c < 0x20 || 0x7f <= *c) {
+ ret = EINVAL;
+ goto err;
+ }
+ }
+
+ for (c = &probe->ftps_mod[0]; *c != '\0'; c++) {
+ if (*c < 0x20 || 0x7f <= *c) {
+ ret = EINVAL;
+ goto err;
+ }
+ }
+
+ if (!PRIV_POLICY_CHOICE(cr, PRIV_ALL, B_FALSE)) {
+ proc_t *p;
+ pid_t pid = probe->ftps_pid;
+
+ mutex_enter(&pidlock);
+ /*
+ * Report an error if the process doesn't exist
+ * or is actively being birthed.
+ */
+ if ((p = prfind(pid)) == NULL || p->p_stat == SIDL) {
+ mutex_exit(&pidlock);
+ return (ESRCH);
+ }
+ mutex_enter(&p->p_lock);
+ mutex_exit(&pidlock);
+
+ if ((ret = priv_proc_cred_perm(cr, p, NULL,
+ VREAD | VWRITE)) != 0) {
+ mutex_exit(&p->p_lock);
+ return (ret);
+ }
+
+ mutex_exit(&p->p_lock);
+ }
+
+ ret = fasttrap_add_probe(probe);
+err:
+ kmem_free(probe, size);
+
+ return (ret);
+
+ } else if (cmd == FASTTRAPIOC_GETINSTR) {
+ fasttrap_instr_query_t instr;
+ fasttrap_tracepoint_t *tp;
+ uint_t index;
+ int ret;
+
+ if (copyin((void *)arg, &instr, sizeof (instr)) != 0)
+ return (EFAULT);
+
+ if (!PRIV_POLICY_CHOICE(cr, PRIV_ALL, B_FALSE)) {
+ proc_t *p;
+ pid_t pid = instr.ftiq_pid;
+
+ mutex_enter(&pidlock);
+ /*
+ * Report an error if the process doesn't exist
+ * or is actively being birthed.
+ */
+ if ((p = prfind(pid)) == NULL || p->p_stat == SIDL) {
+ mutex_exit(&pidlock);
+ return (ESRCH);
+ }
+ mutex_enter(&p->p_lock);
+ mutex_exit(&pidlock);
+
+ if ((ret = priv_proc_cred_perm(cr, p, NULL,
+ VREAD)) != 0) {
+ mutex_exit(&p->p_lock);
+ return (ret);
+ }
+
+ mutex_exit(&p->p_lock);
+ }
+
+ index = FASTTRAP_TPOINTS_INDEX(instr.ftiq_pid, instr.ftiq_pc);
+
+ mutex_enter(&fasttrap_tpoints.fth_table[index].ftb_mtx);
+ tp = fasttrap_tpoints.fth_table[index].ftb_data;
+ while (tp != NULL) {
+ if (instr.ftiq_pid == tp->ftt_pid &&
+ instr.ftiq_pc == tp->ftt_pc &&
+ tp->ftt_proc->ftpc_acount != 0)
+ break;
+
+ tp = tp->ftt_next;
+ }
+
+ if (tp == NULL) {
+ mutex_exit(&fasttrap_tpoints.fth_table[index].ftb_mtx);
+ return (ENOENT);
+ }
+
+ bcopy(&tp->ftt_instr, &instr.ftiq_instr,
+ sizeof (instr.ftiq_instr));
+ mutex_exit(&fasttrap_tpoints.fth_table[index].ftb_mtx);
+
+ if (copyout(&instr, (void *)arg, sizeof (instr)) != 0)
+ return (EFAULT);
+
+ return (0);
+ }
+
+ return (EINVAL);
+}
+
+static struct cb_ops fasttrap_cb_ops = {
+ fasttrap_open, /* open */
+ nodev, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ fasttrap_ioctl, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_NEW | D_MP /* Driver compatibility flag */
+};
+
+/*ARGSUSED*/
+static int
+fasttrap_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *)fasttrap_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+static int
+fasttrap_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+{
+ ulong_t nent;
+
+ switch (cmd) {
+ case DDI_ATTACH:
+ break;
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (ddi_create_minor_node(devi, "fasttrap", S_IFCHR, 0,
+ DDI_PSEUDO, NULL) == DDI_FAILURE) {
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_FAILURE);
+ }
+
+ ddi_report_dev(devi);
+ fasttrap_devi = devi;
+
+ /*
+ * Install our hooks into fork(2), exec(2), and exit(2).
+ */
+ dtrace_fasttrap_fork_ptr = &fasttrap_fork;
+ dtrace_fasttrap_exit_ptr = &fasttrap_exec_exit;
+ dtrace_fasttrap_exec_ptr = &fasttrap_exec_exit;
+
+ fasttrap_max = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
+ "fasttrap-max-probes", FASTTRAP_MAX_DEFAULT);
+ fasttrap_total = 0;
+
+ /*
+ * Conjure up the tracepoints hashtable...
+ */
+ nent = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
+ "fasttrap-hash-size", FASTTRAP_TPOINTS_DEFAULT_SIZE);
+
+ if (nent == 0 || nent > 0x1000000)
+ nent = FASTTRAP_TPOINTS_DEFAULT_SIZE;
+
+ if ((nent & (nent - 1)) == 0)
+ fasttrap_tpoints.fth_nent = nent;
+ else
+ fasttrap_tpoints.fth_nent = 1 << fasttrap_highbit(nent);
+ ASSERT(fasttrap_tpoints.fth_nent > 0);
+ fasttrap_tpoints.fth_mask = fasttrap_tpoints.fth_nent - 1;
+ fasttrap_tpoints.fth_table = kmem_zalloc(fasttrap_tpoints.fth_nent *
+ sizeof (fasttrap_bucket_t), KM_SLEEP);
+
+ /*
+ * ... and the providers hash table...
+ */
+ nent = FASTTRAP_PROVIDERS_DEFAULT_SIZE;
+ if ((nent & (nent - 1)) == 0)
+ fasttrap_provs.fth_nent = nent;
+ else
+ fasttrap_provs.fth_nent = 1 << fasttrap_highbit(nent);
+ ASSERT(fasttrap_provs.fth_nent > 0);
+ fasttrap_provs.fth_mask = fasttrap_provs.fth_nent - 1;
+ fasttrap_provs.fth_table = kmem_zalloc(fasttrap_provs.fth_nent *
+ sizeof (fasttrap_bucket_t), KM_SLEEP);
+
+ /*
+ * ... and the procs hash table.
+ */
+ nent = FASTTRAP_PROCS_DEFAULT_SIZE;
+ if ((nent & (nent - 1)) == 0)
+ fasttrap_procs.fth_nent = nent;
+ else
+ fasttrap_procs.fth_nent = 1 << fasttrap_highbit(nent);
+ ASSERT(fasttrap_procs.fth_nent > 0);
+ fasttrap_procs.fth_mask = fasttrap_procs.fth_nent - 1;
+ fasttrap_procs.fth_table = kmem_zalloc(fasttrap_procs.fth_nent *
+ sizeof (fasttrap_bucket_t), KM_SLEEP);
+
+ (void) dtrace_meta_register("fasttrap", &fasttrap_mops, NULL,
+ &fasttrap_meta_id);
+
+ return (DDI_SUCCESS);
+}
+
+static int
+fasttrap_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
+{
+ int i, fail = 0;
+ timeout_id_t tmp;
+
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ /*
+ * Unregister the meta-provider to make sure no new fasttrap-
+ * managed providers come along while we're trying to close up
+ * shop. If we fail to detach, we'll need to re-register as a
+ * meta-provider. We can fail to unregister as a meta-provider
+ * if providers we manage still exist.
+ */
+ if (fasttrap_meta_id != DTRACE_METAPROVNONE &&
+ dtrace_meta_unregister(fasttrap_meta_id) != 0)
+ return (DDI_FAILURE);
+
+ /*
+ * Prevent any new timeouts from running by setting fasttrap_timeout
+ * to a non-zero value, and wait for the current timeout to complete.
+ */
+ mutex_enter(&fasttrap_cleanup_mtx);
+ fasttrap_cleanup_work = 0;
+
+ while (fasttrap_timeout != (timeout_id_t)1) {
+ tmp = fasttrap_timeout;
+ fasttrap_timeout = (timeout_id_t)1;
+
+ if (tmp != 0) {
+ mutex_exit(&fasttrap_cleanup_mtx);
+ (void) untimeout(tmp);
+ mutex_enter(&fasttrap_cleanup_mtx);
+ }
+ }
+
+ fasttrap_cleanup_work = 0;
+ mutex_exit(&fasttrap_cleanup_mtx);
+
+ /*
+ * Iterate over all of our providers. If there's still a process
+ * that corresponds to that pid, fail to detach.
+ */
+ for (i = 0; i < fasttrap_provs.fth_nent; i++) {
+ fasttrap_provider_t **fpp, *fp;
+ fasttrap_bucket_t *bucket = &fasttrap_provs.fth_table[i];
+
+ mutex_enter(&bucket->ftb_mtx);
+ fpp = (fasttrap_provider_t **)&bucket->ftb_data;
+ while ((fp = *fpp) != NULL) {
+ /*
+ * Acquire and release the lock as a simple way of
+ * waiting for any other consumer to finish with
+ * this provider. A thread must first acquire the
+ * bucket lock so there's no chance of another thread
+ * blocking on the provider's lock.
+ */
+ mutex_enter(&fp->ftp_mtx);
+ mutex_exit(&fp->ftp_mtx);
+
+ if (dtrace_unregister(fp->ftp_provid) != 0) {
+ fail = 1;
+ fpp = &fp->ftp_next;
+ } else {
+ *fpp = fp->ftp_next;
+ fasttrap_provider_free(fp);
+ }
+ }
+
+ mutex_exit(&bucket->ftb_mtx);
+ }
+
+ if (fail) {
+ uint_t work;
+ /*
+ * If we're failing to detach, we need to unblock timeouts
+ * and start a new timeout if any work has accumulated while
+ * we've been unsuccessfully trying to detach.
+ */
+ mutex_enter(&fasttrap_cleanup_mtx);
+ fasttrap_timeout = 0;
+ work = fasttrap_cleanup_work;
+ mutex_exit(&fasttrap_cleanup_mtx);
+
+ if (work)
+ fasttrap_pid_cleanup();
+
+ (void) dtrace_meta_register("fasttrap", &fasttrap_mops, NULL,
+ &fasttrap_meta_id);
+
+ return (DDI_FAILURE);
+ }
+
+#ifdef DEBUG
+ mutex_enter(&fasttrap_count_mtx);
+ ASSERT(fasttrap_pid_count == 0);
+ mutex_exit(&fasttrap_count_mtx);
+#endif
+
+ kmem_free(fasttrap_tpoints.fth_table,
+ fasttrap_tpoints.fth_nent * sizeof (fasttrap_bucket_t));
+ fasttrap_tpoints.fth_nent = 0;
+
+ kmem_free(fasttrap_provs.fth_table,
+ fasttrap_provs.fth_nent * sizeof (fasttrap_bucket_t));
+ fasttrap_provs.fth_nent = 0;
+
+ kmem_free(fasttrap_procs.fth_table,
+ fasttrap_procs.fth_nent * sizeof (fasttrap_bucket_t));
+ fasttrap_procs.fth_nent = 0;
+
+ /*
+ * We know there are no tracepoints in any process anywhere in
+ * the system so there is no process which has its p_dtrace_count
+ * greater than zero, therefore we know that no thread can actively
+ * be executing code in fasttrap_fork(). Similarly for p_dtrace_probes
+ * and fasttrap_exec() and fasttrap_exit().
+ */
+ ASSERT(dtrace_fasttrap_fork_ptr == &fasttrap_fork);
+ dtrace_fasttrap_fork_ptr = NULL;
+
+ ASSERT(dtrace_fasttrap_exec_ptr == &fasttrap_exec_exit);
+ dtrace_fasttrap_exec_ptr = NULL;
+
+ ASSERT(dtrace_fasttrap_exit_ptr == &fasttrap_exec_exit);
+ dtrace_fasttrap_exit_ptr = NULL;
+
+ ddi_remove_minor_node(devi, NULL);
+
+ return (DDI_SUCCESS);
+}
+
+static struct dev_ops fasttrap_ops = {
+ DEVO_REV, /* devo_rev */
+ 0, /* refcnt */
+ fasttrap_info, /* get_dev_info */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ fasttrap_attach, /* attach */
+ fasttrap_detach, /* detach */
+ nodev, /* reset */
+ &fasttrap_cb_ops, /* driver operations */
+ NULL, /* bus operations */
+ nodev, /* dev power */
+ ddi_quiesce_not_needed, /* quiesce */
+};
+
+/*
+ * Module linkage information for the kernel.
+ */
+static struct modldrv modldrv = {
+ &mod_driverops, /* module type (this is a pseudo driver) */
+ "Fasttrap Tracing", /* name of module */
+ &fasttrap_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1,
+ (void *)&modldrv,
+ NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.c
new file mode 100644
index 00000000..69c8b725
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.c
@@ -0,0 +1,343 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/open.h>
+#include <sys/file.h>
+#include <sys/conf.h>
+#include <sys/modctl.h>
+#include <sys/cmn_err.h>
+#include <sys/bitmap.h>
+#include <sys/debug.h>
+#include <sys/kmem.h>
+#include <sys/errno.h>
+#include <sys/sysmacros.h>
+#include <sys/lockstat.h>
+#include <sys/atomic.h>
+#include <sys/dtrace.h>
+
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+typedef struct lockstat_probe {
+ const char *lsp_func;
+ const char *lsp_name;
+ int lsp_probe;
+ dtrace_id_t lsp_id;
+} lockstat_probe_t;
+
+lockstat_probe_t lockstat_probes[] =
+{
+ { LS_MUTEX_ENTER, LSA_ACQUIRE, LS_MUTEX_ENTER_ACQUIRE },
+ { LS_MUTEX_ENTER, LSA_BLOCK, LS_MUTEX_ENTER_BLOCK },
+ { LS_MUTEX_ENTER, LSA_SPIN, LS_MUTEX_ENTER_SPIN },
+ { LS_MUTEX_EXIT, LSA_RELEASE, LS_MUTEX_EXIT_RELEASE },
+ { LS_MUTEX_DESTROY, LSA_RELEASE, LS_MUTEX_DESTROY_RELEASE },
+ { LS_MUTEX_TRYENTER, LSA_ACQUIRE, LS_MUTEX_TRYENTER_ACQUIRE },
+ { LS_LOCK_SET, LSS_ACQUIRE, LS_LOCK_SET_ACQUIRE },
+ { LS_LOCK_SET, LSS_SPIN, LS_LOCK_SET_SPIN },
+ { LS_LOCK_SET_SPL, LSS_ACQUIRE, LS_LOCK_SET_SPL_ACQUIRE },
+ { LS_LOCK_SET_SPL, LSS_SPIN, LS_LOCK_SET_SPL_SPIN },
+ { LS_LOCK_TRY, LSS_ACQUIRE, LS_LOCK_TRY_ACQUIRE },
+ { LS_LOCK_CLEAR, LSS_RELEASE, LS_LOCK_CLEAR_RELEASE },
+ { LS_LOCK_CLEAR_SPLX, LSS_RELEASE, LS_LOCK_CLEAR_SPLX_RELEASE },
+ { LS_CLOCK_UNLOCK, LSS_RELEASE, LS_CLOCK_UNLOCK_RELEASE },
+ { LS_RW_ENTER, LSR_ACQUIRE, LS_RW_ENTER_ACQUIRE },
+ { LS_RW_ENTER, LSR_BLOCK, LS_RW_ENTER_BLOCK },
+ { LS_RW_EXIT, LSR_RELEASE, LS_RW_EXIT_RELEASE },
+ { LS_RW_TRYENTER, LSR_ACQUIRE, LS_RW_TRYENTER_ACQUIRE },
+ { LS_RW_TRYUPGRADE, LSR_UPGRADE, LS_RW_TRYUPGRADE_UPGRADE },
+ { LS_RW_DOWNGRADE, LSR_DOWNGRADE, LS_RW_DOWNGRADE_DOWNGRADE },
+ { LS_THREAD_LOCK, LST_SPIN, LS_THREAD_LOCK_SPIN },
+ { LS_THREAD_LOCK_HIGH, LST_SPIN, LS_THREAD_LOCK_HIGH_SPIN },
+ { NULL }
+};
+
+static dev_info_t *lockstat_devi; /* saved in xxattach() for xxinfo() */
+static kmutex_t lockstat_test; /* for testing purposes only */
+static dtrace_provider_id_t lockstat_id;
+
+/*ARGSUSED*/
+static int
+lockstat_enable(void *arg, dtrace_id_t id, void *parg)
+{
+ lockstat_probe_t *probe = parg;
+
+ ASSERT(!lockstat_probemap[probe->lsp_probe]);
+
+ lockstat_probemap[probe->lsp_probe] = id;
+ membar_producer();
+
+ lockstat_hot_patch();
+ membar_producer();
+
+ /*
+ * Immediately generate a record for the lockstat_test mutex
+ * to verify that the mutex hot-patch code worked as expected.
+ */
+ mutex_enter(&lockstat_test);
+ mutex_exit(&lockstat_test);
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+lockstat_disable(void *arg, dtrace_id_t id, void *parg)
+{
+ lockstat_probe_t *probe = parg;
+ int i;
+
+ ASSERT(lockstat_probemap[probe->lsp_probe]);
+
+ lockstat_probemap[probe->lsp_probe] = 0;
+ lockstat_hot_patch();
+ membar_producer();
+
+ /*
+ * See if we have any probes left enabled.
+ */
+ for (i = 0; i < LS_NPROBES; i++) {
+ if (lockstat_probemap[i]) {
+ /*
+ * This probe is still enabled. We don't need to deal
+ * with waiting for all threads to be out of the
+ * lockstat critical sections; just return.
+ */
+ return;
+ }
+ }
+
+ /*
+ * The delay() here isn't as cheesy as you might think. We don't
+ * want to busy-loop in the kernel, so we have to give up the
+ * CPU between calls to lockstat_active_threads(); that much is
+ * obvious. But the reason it's a do..while loop rather than a
+ * while loop is subtle. The memory barrier above guarantees that
+ * no threads will enter the lockstat code from this point forward.
+ * However, another thread could already be executing lockstat code
+ * without our knowledge if the update to its t_lockstat field hasn't
+ * cleared its CPU's store buffer. Delaying for one clock tick
+ * guarantees that either (1) the thread will have *ample* time to
+ * complete its work, or (2) the thread will be preempted, in which
+ * case it will have to grab and release a dispatcher lock, which
+ * will flush that CPU's store buffer. Either way we're covered.
+ */
+ do {
+ delay(1);
+ } while (lockstat_active_threads());
+}
+
+/*ARGSUSED*/
+static int
+lockstat_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+{
+ return (0);
+}
+
+/* ARGSUSED */
+static int
+lockstat_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *) lockstat_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+/*ARGSUSED*/
+static void
+lockstat_provide(void *arg, const dtrace_probedesc_t *desc)
+{
+ int i = 0;
+
+ for (i = 0; lockstat_probes[i].lsp_func != NULL; i++) {
+ lockstat_probe_t *probe = &lockstat_probes[i];
+
+ if (dtrace_probe_lookup(lockstat_id, "genunix",
+ probe->lsp_func, probe->lsp_name) != 0)
+ continue;
+
+ ASSERT(!probe->lsp_id);
+ probe->lsp_id = dtrace_probe_create(lockstat_id,
+ "genunix", probe->lsp_func, probe->lsp_name,
+ 1, probe);
+ }
+}
+
+/*ARGSUSED*/
+static void
+lockstat_destroy(void *arg, dtrace_id_t id, void *parg)
+{
+ lockstat_probe_t *probe = parg;
+
+ ASSERT(!lockstat_probemap[probe->lsp_probe]);
+ probe->lsp_id = 0;
+}
+
+static dtrace_pattr_t lockstat_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+};
+
+static dtrace_pops_t lockstat_pops = {
+ lockstat_provide,
+ NULL,
+ lockstat_enable,
+ lockstat_disable,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ lockstat_destroy
+};
+
+static int
+lockstat_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_ATTACH:
+ break;
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (ddi_create_minor_node(devi, "lockstat", S_IFCHR, 0,
+ DDI_PSEUDO, 0) == DDI_FAILURE ||
+ dtrace_register("lockstat", &lockstat_attr, DTRACE_PRIV_KERNEL,
+ NULL, &lockstat_pops, NULL, &lockstat_id) != 0) {
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_FAILURE);
+ }
+
+ lockstat_probe = dtrace_probe;
+ membar_producer();
+
+ ddi_report_dev(devi);
+ lockstat_devi = devi;
+ return (DDI_SUCCESS);
+}
+
+static int
+lockstat_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (dtrace_unregister(lockstat_id) != 0)
+ return (DDI_FAILURE);
+
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_SUCCESS);
+}
+
+/*
+ * Configuration data structures
+ */
+static struct cb_ops lockstat_cb_ops = {
+ lockstat_open, /* open */
+ nodev, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ nodev, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_MP | D_NEW /* Driver compatibility flag */
+};
+
+static struct dev_ops lockstat_ops = {
+ DEVO_REV, /* devo_rev, */
+ 0, /* refcnt */
+ lockstat_info, /* getinfo */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ lockstat_attach, /* attach */
+ lockstat_detach, /* detach */
+ nulldev, /* reset */
+ &lockstat_cb_ops, /* cb_ops */
+ NULL, /* bus_ops */
+ NULL, /* power */
+ ddi_quiesce_not_needed, /* quiesce */
+};
+
+static struct modldrv modldrv = {
+ &mod_driverops, /* Type of module. This one is a driver */
+ "Lock Statistics", /* name of module */
+ &lockstat_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1, (void *)&modldrv, NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.conf
new file mode 100644
index 00000000..6d29b6a8
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/lockstat.conf
@@ -0,0 +1,28 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 1997-2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+name="lockstat" parent="pseudo" instance=0;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.c
new file mode 100644
index 00000000..c1a2d1f1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.c
@@ -0,0 +1,577 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#include <sys/errno.h>
+#include <sys/stat.h>
+#include <sys/modctl.h>
+#include <sys/conf.h>
+#include <sys/systm.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/cpuvar.h>
+#include <sys/kmem.h>
+#include <sys/strsubr.h>
+#include <sys/dtrace.h>
+#include <sys/cyclic.h>
+#include <sys/atomic.h>
+
+static dev_info_t *profile_devi;
+static dtrace_provider_id_t profile_id;
+
+/*
+ * Regardless of platform, the stack frames look like this in the case of the
+ * profile provider:
+ *
+ * profile_fire
+ * cyclic_expire
+ * cyclic_fire
+ * [ cbe ]
+ * [ interrupt code ]
+ *
+ * On x86, there are five frames from the generic interrupt code; further, the
+ * interrupted instruction appears as its own stack frame, giving us a total of
+ * 10.
+ *
+ * On SPARC, the picture is further complicated because the compiler
+ * optimizes away tail-calls -- so the following frames are optimized away:
+ *
+ * profile_fire
+ * cyclic_expire
+ *
+ * This gives three frames. However, on DEBUG kernels, the cyclic_expire
+ * frame cannot be tail-call eliminated, yielding four frames in this case.
+ *
+ * All of the above constraints lead to the mess below. Yes, the profile
+ * provider should ideally figure this out on-the-fly by hitting one of its own
+ * probes and then walking its own stack trace. This is complicated, however,
+ * and the static definition doesn't seem to be overly brittle. Still, we
+ * allow for a manual override in case we get it completely wrong.
+ */
+#ifdef __x86
+#define PROF_ARTIFICIAL_FRAMES 10
+#else
+#ifdef __sparc
+#ifdef DEBUG
+#define PROF_ARTIFICIAL_FRAMES 4
+#else
+#define PROF_ARTIFICIAL_FRAMES 3
+#endif
+#endif
+#endif
+
+#define PROF_NAMELEN 15
+
+#define PROF_PROFILE 0
+#define PROF_TICK 1
+#define PROF_PREFIX_PROFILE "profile-"
+#define PROF_PREFIX_TICK "tick-"
+
+typedef struct profile_probe {
+ char prof_name[PROF_NAMELEN];
+ dtrace_id_t prof_id;
+ int prof_kind;
+ hrtime_t prof_interval;
+ cyclic_id_t prof_cyclic;
+} profile_probe_t;
+
+typedef struct profile_probe_percpu {
+ hrtime_t profc_expected;
+ hrtime_t profc_interval;
+ profile_probe_t *profc_probe;
+} profile_probe_percpu_t;
+
+hrtime_t profile_interval_min = NANOSEC / 5000; /* 5000 hz */
+int profile_aframes = 0; /* override */
+
+static int profile_rates[] = {
+ 97, 199, 499, 997, 1999,
+ 4001, 4999, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0
+};
+
+static int profile_ticks[] = {
+ 1, 10, 100, 500, 1000,
+ 5000, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0
+};
+
+/*
+ * profile_max defines the upper bound on the number of profile probes that
+ * can exist (this is to prevent malicious or clumsy users from exhausing
+ * system resources by creating a slew of profile probes). At mod load time,
+ * this gets its value from PROFILE_MAX_DEFAULT or profile-max-probes if it's
+ * present in the profile.conf file.
+ */
+#define PROFILE_MAX_DEFAULT 1000 /* default max. number of probes */
+static uint32_t profile_max; /* maximum number of profile probes */
+static uint32_t profile_total; /* current number of profile probes */
+
+static void
+profile_fire(void *arg)
+{
+ profile_probe_percpu_t *pcpu = arg;
+ profile_probe_t *prof = pcpu->profc_probe;
+ hrtime_t late;
+
+ late = dtrace_gethrtime() - pcpu->profc_expected;
+ pcpu->profc_expected += pcpu->profc_interval;
+
+ dtrace_probe(prof->prof_id, CPU->cpu_profile_pc,
+ CPU->cpu_profile_upc, late, 0, 0);
+}
+
+static void
+profile_tick(void *arg)
+{
+ profile_probe_t *prof = arg;
+
+ dtrace_probe(prof->prof_id, CPU->cpu_profile_pc,
+ CPU->cpu_profile_upc, 0, 0, 0);
+}
+
+static void
+profile_create(hrtime_t interval, const char *name, int kind)
+{
+ profile_probe_t *prof;
+ int nr_frames = PROF_ARTIFICIAL_FRAMES + dtrace_mach_aframes();
+
+ if (profile_aframes)
+ nr_frames = profile_aframes;
+
+ if (interval < profile_interval_min)
+ return;
+
+ if (dtrace_probe_lookup(profile_id, NULL, NULL, name) != 0)
+ return;
+
+ atomic_add_32(&profile_total, 1);
+ if (profile_total > profile_max) {
+ atomic_add_32(&profile_total, -1);
+ return;
+ }
+
+ prof = kmem_zalloc(sizeof (profile_probe_t), KM_SLEEP);
+ (void) strcpy(prof->prof_name, name);
+ prof->prof_interval = interval;
+ prof->prof_cyclic = CYCLIC_NONE;
+ prof->prof_kind = kind;
+ prof->prof_id = dtrace_probe_create(profile_id,
+ NULL, NULL, name, nr_frames, prof);
+}
+
+/*ARGSUSED*/
+static void
+profile_provide(void *arg, const dtrace_probedesc_t *desc)
+{
+ int i, j, rate, kind;
+ hrtime_t val = 0, mult = 1, len;
+ const char *name, *suffix = NULL;
+
+ const struct {
+ char *prefix;
+ int kind;
+ } types[] = {
+ { PROF_PREFIX_PROFILE, PROF_PROFILE },
+ { PROF_PREFIX_TICK, PROF_TICK },
+ { NULL, NULL }
+ };
+
+ const struct {
+ char *name;
+ hrtime_t mult;
+ } suffixes[] = {
+ { "ns", NANOSEC / NANOSEC },
+ { "nsec", NANOSEC / NANOSEC },
+ { "us", NANOSEC / MICROSEC },
+ { "usec", NANOSEC / MICROSEC },
+ { "ms", NANOSEC / MILLISEC },
+ { "msec", NANOSEC / MILLISEC },
+ { "s", NANOSEC / SEC },
+ { "sec", NANOSEC / SEC },
+ { "m", NANOSEC * (hrtime_t)60 },
+ { "min", NANOSEC * (hrtime_t)60 },
+ { "h", NANOSEC * (hrtime_t)(60 * 60) },
+ { "hour", NANOSEC * (hrtime_t)(60 * 60) },
+ { "d", NANOSEC * (hrtime_t)(24 * 60 * 60) },
+ { "day", NANOSEC * (hrtime_t)(24 * 60 * 60) },
+ { "hz", 0 },
+ { NULL }
+ };
+
+ if (desc == NULL) {
+ char n[PROF_NAMELEN];
+
+ /*
+ * If no description was provided, provide all of our probes.
+ */
+ for (i = 0; i < sizeof (profile_rates) / sizeof (int); i++) {
+ if ((rate = profile_rates[i]) == 0)
+ continue;
+
+ (void) snprintf(n, PROF_NAMELEN, "%s%d",
+ PROF_PREFIX_PROFILE, rate);
+ profile_create(NANOSEC / rate, n, PROF_PROFILE);
+ }
+
+ for (i = 0; i < sizeof (profile_ticks) / sizeof (int); i++) {
+ if ((rate = profile_ticks[i]) == 0)
+ continue;
+
+ (void) snprintf(n, PROF_NAMELEN, "%s%d",
+ PROF_PREFIX_TICK, rate);
+ profile_create(NANOSEC / rate, n, PROF_TICK);
+ }
+
+ return;
+ }
+
+ name = desc->dtpd_name;
+
+ for (i = 0; types[i].prefix != NULL; i++) {
+ len = strlen(types[i].prefix);
+
+ if (strncmp(name, types[i].prefix, len) != 0)
+ continue;
+ break;
+ }
+
+ if (types[i].prefix == NULL)
+ return;
+
+ kind = types[i].kind;
+ j = strlen(name) - len;
+
+ /*
+ * We need to start before any time suffix.
+ */
+ for (j = strlen(name); j >= len; j--) {
+ if (name[j] >= '0' && name[j] <= '9')
+ break;
+ suffix = &name[j];
+ }
+
+ ASSERT(suffix != NULL);
+
+ /*
+ * Now determine the numerical value present in the probe name.
+ */
+ for (; j >= len; j--) {
+ if (name[j] < '0' || name[j] > '9')
+ return;
+
+ val += (name[j] - '0') * mult;
+ mult *= (hrtime_t)10;
+ }
+
+ if (val == 0)
+ return;
+
+ /*
+ * Look-up the suffix to determine the multiplier.
+ */
+ for (i = 0, mult = 0; suffixes[i].name != NULL; i++) {
+ if (strcasecmp(suffixes[i].name, suffix) == 0) {
+ mult = suffixes[i].mult;
+ break;
+ }
+ }
+
+ if (suffixes[i].name == NULL && *suffix != '\0')
+ return;
+
+ if (mult == 0) {
+ /*
+ * The default is frequency-per-second.
+ */
+ val = NANOSEC / val;
+ } else {
+ val *= mult;
+ }
+
+ profile_create(val, name, kind);
+}
+
+/*ARGSUSED*/
+static void
+profile_destroy(void *arg, dtrace_id_t id, void *parg)
+{
+ profile_probe_t *prof = parg;
+
+ ASSERT(prof->prof_cyclic == CYCLIC_NONE);
+ kmem_free(prof, sizeof (profile_probe_t));
+
+ ASSERT(profile_total >= 1);
+ atomic_add_32(&profile_total, -1);
+}
+
+/*ARGSUSED*/
+static void
+profile_online(void *arg, cpu_t *cpu, cyc_handler_t *hdlr, cyc_time_t *when)
+{
+ profile_probe_t *prof = arg;
+ profile_probe_percpu_t *pcpu;
+
+ pcpu = kmem_zalloc(sizeof (profile_probe_percpu_t), KM_SLEEP);
+ pcpu->profc_probe = prof;
+
+ hdlr->cyh_func = profile_fire;
+ hdlr->cyh_arg = pcpu;
+ hdlr->cyh_level = CY_HIGH_LEVEL;
+
+ when->cyt_interval = prof->prof_interval;
+ when->cyt_when = dtrace_gethrtime() + when->cyt_interval;
+
+ pcpu->profc_expected = when->cyt_when;
+ pcpu->profc_interval = when->cyt_interval;
+}
+
+/*ARGSUSED*/
+static void
+profile_offline(void *arg, cpu_t *cpu, void *oarg)
+{
+ profile_probe_percpu_t *pcpu = oarg;
+
+ ASSERT(pcpu->profc_probe == arg);
+ kmem_free(pcpu, sizeof (profile_probe_percpu_t));
+}
+
+/*ARGSUSED*/
+static int
+profile_enable(void *arg, dtrace_id_t id, void *parg)
+{
+ profile_probe_t *prof = parg;
+ cyc_omni_handler_t omni;
+ cyc_handler_t hdlr;
+ cyc_time_t when;
+
+ ASSERT(prof->prof_interval != 0);
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ if (prof->prof_kind == PROF_TICK) {
+ hdlr.cyh_func = profile_tick;
+ hdlr.cyh_arg = prof;
+ hdlr.cyh_level = CY_HIGH_LEVEL;
+
+ when.cyt_interval = prof->prof_interval;
+ when.cyt_when = dtrace_gethrtime() + when.cyt_interval;
+ } else {
+ ASSERT(prof->prof_kind == PROF_PROFILE);
+ omni.cyo_online = profile_online;
+ omni.cyo_offline = profile_offline;
+ omni.cyo_arg = prof;
+ }
+
+ if (prof->prof_kind == PROF_TICK) {
+ prof->prof_cyclic = cyclic_add(&hdlr, &when);
+ } else {
+ prof->prof_cyclic = cyclic_add_omni(&omni);
+ }
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+profile_disable(void *arg, dtrace_id_t id, void *parg)
+{
+ profile_probe_t *prof = parg;
+
+ ASSERT(prof->prof_cyclic != CYCLIC_NONE);
+ ASSERT(MUTEX_HELD(&cpu_lock));
+
+ cyclic_remove(prof->prof_cyclic);
+ prof->prof_cyclic = CYCLIC_NONE;
+}
+
+/*ARGSUSED*/
+static int
+profile_usermode(void *arg, dtrace_id_t id, void *parg)
+{
+ return (CPU->cpu_profile_pc == 0);
+}
+
+static dtrace_pattr_t profile_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+};
+
+static dtrace_pops_t profile_pops = {
+ profile_provide,
+ NULL,
+ profile_enable,
+ profile_disable,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ profile_usermode,
+ profile_destroy
+};
+
+static int
+profile_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_ATTACH:
+ break;
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (ddi_create_minor_node(devi, "profile", S_IFCHR, 0,
+ DDI_PSEUDO, NULL) == DDI_FAILURE ||
+ dtrace_register("profile", &profile_attr,
+ DTRACE_PRIV_KERNEL | DTRACE_PRIV_USER, NULL,
+ &profile_pops, NULL, &profile_id) != 0) {
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_FAILURE);
+ }
+
+ profile_max = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
+ "profile-max-probes", PROFILE_MAX_DEFAULT);
+
+ ddi_report_dev(devi);
+ profile_devi = devi;
+ return (DDI_SUCCESS);
+}
+
+static int
+profile_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (dtrace_unregister(profile_id) != 0)
+ return (DDI_FAILURE);
+
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_SUCCESS);
+}
+
+/*ARGSUSED*/
+static int
+profile_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *)profile_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+/*ARGSUSED*/
+static int
+profile_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+{
+ return (0);
+}
+
+static struct cb_ops profile_cb_ops = {
+ profile_open, /* open */
+ nodev, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ nodev, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_NEW | D_MP /* Driver compatibility flag */
+};
+
+static struct dev_ops profile_ops = {
+ DEVO_REV, /* devo_rev, */
+ 0, /* refcnt */
+ profile_info, /* get_dev_info */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ profile_attach, /* attach */
+ profile_detach, /* detach */
+ nodev, /* reset */
+ &profile_cb_ops, /* driver operations */
+ NULL, /* bus operations */
+ nodev, /* dev power */
+ ddi_quiesce_not_needed, /* quiesce */
+};
+
+/*
+ * Module linkage information for the kernel.
+ */
+static struct modldrv modldrv = {
+ &mod_driverops, /* module type (this is a pseudo driver) */
+ "Profile Interrupt Tracing", /* name of module */
+ &profile_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1,
+ (void *)&modldrv,
+ NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.conf
new file mode 100644
index 00000000..618ff60f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/profile.conf
@@ -0,0 +1,28 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+name="profile" parent="pseudo" instance=0;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/sdt_subr.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/sdt_subr.c
new file mode 100644
index 00000000..24218507
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/sdt_subr.c
@@ -0,0 +1,1191 @@
+/*
+ * 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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <sys/sdt_impl.h>
+
+static dtrace_pattr_t vtrace_attr = {
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pattr_t info_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pattr_t fc_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pattr_t fpu_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_CPU },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pattr_t fsinfo_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pattr_t stab_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pattr_t sdt_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pattr_t xpv_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_PLATFORM },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
+};
+
+static dtrace_pattr_t iscsi_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+};
+
+sdt_provider_t sdt_providers[] = {
+ { "vtrace", "__vtrace_", &vtrace_attr, 0 },
+ { "sysinfo", "__cpu_sysinfo_", &info_attr, 0 },
+ { "vminfo", "__cpu_vminfo_", &info_attr, 0 },
+ { "fpuinfo", "__fpuinfo_", &fpu_attr, 0 },
+ { "sched", "__sched_", &stab_attr, 0 },
+ { "proc", "__proc_", &stab_attr, 0 },
+ { "io", "__io_", &stab_attr, 0 },
+ { "ip", "__ip_", &stab_attr, 0 },
+ { "tcp", "__tcp_", &stab_attr, 0 },
+ { "udp", "__udp_", &stab_attr, 0 },
+ { "mib", "__mib_", &stab_attr, 0 },
+ { "fsinfo", "__fsinfo_", &fsinfo_attr, 0 },
+ { "iscsi", "__iscsi_", &iscsi_attr, 0 },
+ { "nfsv3", "__nfsv3_", &stab_attr, 0 },
+ { "nfsv4", "__nfsv4_", &stab_attr, 0 },
+ { "xpv", "__xpv_", &xpv_attr, 0 },
+ { "fc", "__fc_", &fc_attr, 0 },
+ { "srp", "__srp_", &fc_attr, 0 },
+ { "sysevent", "__sysevent_", &stab_attr, 0 },
+ { "sdt", NULL, &sdt_attr, 0 },
+ { NULL }
+};
+
+sdt_argdesc_t sdt_args[] = {
+ { "sched", "wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "dequeue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "dequeue", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "dequeue", 2, 1, "disp_t *", "cpuinfo_t *" },
+ { "sched", "enqueue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "enqueue", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "enqueue", 2, 1, "disp_t *", "cpuinfo_t *" },
+ { "sched", "enqueue", 3, 2, "int" },
+ { "sched", "off-cpu", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "off-cpu", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "tick", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "tick", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "change-pri", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "change-pri", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "change-pri", 2, 1, "pri_t" },
+ { "sched", "schedctl-nopreempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "schedctl-nopreempt", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "schedctl-nopreempt", 2, 1, "int" },
+ { "sched", "schedctl-preempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "schedctl-preempt", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "schedctl-yield", 0, 0, "int" },
+ { "sched", "surrender", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "surrender", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "cpucaps-sleep", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "cpucaps-sleep", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "sched", "cpucaps-wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "sched", "cpucaps-wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
+
+ { "proc", "create", 0, 0, "proc_t *", "psinfo_t *" },
+ { "proc", "exec", 0, 0, "string" },
+ { "proc", "exec-failure", 0, 0, "int" },
+ { "proc", "exit", 0, 0, "int" },
+ { "proc", "fault", 0, 0, "int" },
+ { "proc", "fault", 1, 1, "siginfo_t *" },
+ { "proc", "lwp-create", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "proc", "lwp-create", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "proc", "signal-clear", 0, 0, "int" },
+ { "proc", "signal-clear", 1, 1, "siginfo_t *" },
+ { "proc", "signal-discard", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "proc", "signal-discard", 1, 1, "proc_t *", "psinfo_t *" },
+ { "proc", "signal-discard", 2, 2, "int" },
+ { "proc", "signal-handle", 0, 0, "int" },
+ { "proc", "signal-handle", 1, 1, "siginfo_t *" },
+ { "proc", "signal-handle", 2, 2, "void (*)(void)" },
+ { "proc", "signal-send", 0, 0, "kthread_t *", "lwpsinfo_t *" },
+ { "proc", "signal-send", 1, 0, "kthread_t *", "psinfo_t *" },
+ { "proc", "signal-send", 2, 1, "int" },
+
+ { "io", "start", 0, 0, "buf_t *", "bufinfo_t *" },
+ { "io", "start", 1, 0, "buf_t *", "devinfo_t *" },
+ { "io", "start", 2, 0, "buf_t *", "fileinfo_t *" },
+ { "io", "done", 0, 0, "buf_t *", "bufinfo_t *" },
+ { "io", "done", 1, 0, "buf_t *", "devinfo_t *" },
+ { "io", "done", 2, 0, "buf_t *", "fileinfo_t *" },
+ { "io", "wait-start", 0, 0, "buf_t *", "bufinfo_t *" },
+ { "io", "wait-start", 1, 0, "buf_t *", "devinfo_t *" },
+ { "io", "wait-start", 2, 0, "buf_t *", "fileinfo_t *" },
+ { "io", "wait-done", 0, 0, "buf_t *", "bufinfo_t *" },
+ { "io", "wait-done", 1, 0, "buf_t *", "devinfo_t *" },
+ { "io", "wait-done", 2, 0, "buf_t *", "fileinfo_t *" },
+
+ { "mib", NULL, 0, 0, "int" },
+
+ { "fsinfo", NULL, 0, 0, "vnode_t *", "fileinfo_t *" },
+ { "fsinfo", NULL, 1, 1, "int", "int" },
+
+ { "iscsi", "async-send", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "async-send", 1, 1, "iscsi_async_evt_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "login-command", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "login-command", 1, 1, "iscsi_login_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "login-response", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "login-response", 1, 1, "iscsi_login_rsp_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "logout-command", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "logout-command", 1, 1, "iscsi_logout_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "logout-response", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "logout-response", 1, 1, "iscsi_logout_rsp_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "data-request", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "data-request", 1, 1, "iscsi_rtt_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "data-send", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "data-send", 1, 1, "iscsi_data_rsp_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "data-receive", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "data-receive", 1, 1, "iscsi_data_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "nop-send", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "nop-send", 1, 1, "iscsi_nop_in_hdr_t *", "iscsiinfo_t *" },
+ { "iscsi", "nop-receive", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "nop-receive", 1, 1, "iscsi_nop_out_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "scsi-command", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "scsi-command", 1, 1, "iscsi_scsi_cmd_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "scsi-command", 2, 2, "scsi_task_t *", "scsicmd_t *" },
+ { "iscsi", "scsi-response", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "scsi-response", 1, 1, "iscsi_scsi_rsp_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "task-command", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "task-command", 1, 1, "iscsi_scsi_task_mgt_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "task-response", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "task-response", 1, 1, "iscsi_scsi_task_mgt_rsp_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "text-command", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "text-command", 1, 1, "iscsi_text_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "text-response", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "text-response", 1, 1, "iscsi_text_rsp_hdr_t *",
+ "iscsiinfo_t *" },
+ { "iscsi", "xfer-start", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "xfer-start", 1, 0, "idm_conn_t *", "iscsiinfo_t *" },
+ { "iscsi", "xfer-start", 2, 1, "uintptr_t", "xferinfo_t *" },
+ { "iscsi", "xfer-start", 3, 2, "uint32_t"},
+ { "iscsi", "xfer-start", 4, 3, "uintptr_t"},
+ { "iscsi", "xfer-start", 5, 4, "uint32_t"},
+ { "iscsi", "xfer-start", 6, 5, "uint32_t"},
+ { "iscsi", "xfer-start", 7, 6, "uint32_t"},
+ { "iscsi", "xfer-start", 8, 7, "int"},
+ { "iscsi", "xfer-done", 0, 0, "idm_conn_t *", "conninfo_t *" },
+ { "iscsi", "xfer-done", 1, 0, "idm_conn_t *", "iscsiinfo_t *" },
+ { "iscsi", "xfer-done", 2, 1, "uintptr_t", "xferinfo_t *" },
+ { "iscsi", "xfer-done", 3, 2, "uint32_t"},
+ { "iscsi", "xfer-done", 4, 3, "uintptr_t"},
+ { "iscsi", "xfer-done", 5, 4, "uint32_t"},
+ { "iscsi", "xfer-done", 6, 5, "uint32_t"},
+ { "iscsi", "xfer-done", 7, 6, "uint32_t"},
+ { "iscsi", "xfer-done", 8, 7, "int"},
+
+ { "nfsv3", "op-getattr-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-getattr-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-getattr-start", 2, 3, "GETATTR3args *" },
+ { "nfsv3", "op-getattr-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-getattr-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-getattr-done", 2, 3, "GETATTR3res *" },
+ { "nfsv3", "op-setattr-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-setattr-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-setattr-start", 2, 3, "SETATTR3args *" },
+ { "nfsv3", "op-setattr-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-setattr-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-setattr-done", 2, 3, "SETATTR3res *" },
+ { "nfsv3", "op-lookup-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-lookup-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-lookup-start", 2, 3, "LOOKUP3args *" },
+ { "nfsv3", "op-lookup-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-lookup-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-lookup-done", 2, 3, "LOOKUP3res *" },
+ { "nfsv3", "op-access-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-access-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-access-start", 2, 3, "ACCESS3args *" },
+ { "nfsv3", "op-access-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-access-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-access-done", 2, 3, "ACCESS3res *" },
+ { "nfsv3", "op-commit-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-commit-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-commit-start", 2, 3, "COMMIT3args *" },
+ { "nfsv3", "op-commit-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-commit-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-commit-done", 2, 3, "COMMIT3res *" },
+ { "nfsv3", "op-create-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-create-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-create-start", 2, 3, "CREATE3args *" },
+ { "nfsv3", "op-create-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-create-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-create-done", 2, 3, "CREATE3res *" },
+ { "nfsv3", "op-fsinfo-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-fsinfo-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-fsinfo-start", 2, 3, "FSINFO3args *" },
+ { "nfsv3", "op-fsinfo-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-fsinfo-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-fsinfo-done", 2, 3, "FSINFO3res *" },
+ { "nfsv3", "op-fsstat-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-fsstat-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-fsstat-start", 2, 3, "FSSTAT3args *" },
+ { "nfsv3", "op-fsstat-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-fsstat-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-fsstat-done", 2, 3, "FSSTAT3res *" },
+ { "nfsv3", "op-link-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-link-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-link-start", 2, 3, "LINK3args *" },
+ { "nfsv3", "op-link-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-link-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-link-done", 2, 3, "LINK3res *" },
+ { "nfsv3", "op-mkdir-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-mkdir-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-mkdir-start", 2, 3, "MKDIR3args *" },
+ { "nfsv3", "op-mkdir-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-mkdir-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-mkdir-done", 2, 3, "MKDIR3res *" },
+ { "nfsv3", "op-mknod-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-mknod-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-mknod-start", 2, 3, "MKNOD3args *" },
+ { "nfsv3", "op-mknod-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-mknod-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-mknod-done", 2, 3, "MKNOD3res *" },
+ { "nfsv3", "op-null-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-null-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-null-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-null-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-pathconf-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-pathconf-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-pathconf-start", 2, 3, "PATHCONF3args *" },
+ { "nfsv3", "op-pathconf-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-pathconf-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-pathconf-done", 2, 3, "PATHCONF3res *" },
+ { "nfsv3", "op-read-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-read-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-read-start", 2, 3, "READ3args *" },
+ { "nfsv3", "op-read-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-read-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-read-done", 2, 3, "READ3res *" },
+ { "nfsv3", "op-readdir-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-readdir-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-readdir-start", 2, 3, "READDIR3args *" },
+ { "nfsv3", "op-readdir-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-readdir-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-readdir-done", 2, 3, "READDIR3res *" },
+ { "nfsv3", "op-readdirplus-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-readdirplus-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-readdirplus-start", 2, 3, "READDIRPLUS3args *" },
+ { "nfsv3", "op-readdirplus-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-readdirplus-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-readdirplus-done", 2, 3, "READDIRPLUS3res *" },
+ { "nfsv3", "op-readlink-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-readlink-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-readlink-start", 2, 3, "READLINK3args *" },
+ { "nfsv3", "op-readlink-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-readlink-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-readlink-done", 2, 3, "READLINK3res *" },
+ { "nfsv3", "op-remove-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-remove-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-remove-start", 2, 3, "REMOVE3args *" },
+ { "nfsv3", "op-remove-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-remove-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-remove-done", 2, 3, "REMOVE3res *" },
+ { "nfsv3", "op-rename-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-rename-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-rename-start", 2, 3, "RENAME3args *" },
+ { "nfsv3", "op-rename-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-rename-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-rename-done", 2, 3, "RENAME3res *" },
+ { "nfsv3", "op-rmdir-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-rmdir-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-rmdir-start", 2, 3, "RMDIR3args *" },
+ { "nfsv3", "op-rmdir-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-rmdir-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-rmdir-done", 2, 3, "RMDIR3res *" },
+ { "nfsv3", "op-setattr-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-setattr-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-setattr-start", 2, 3, "SETATTR3args *" },
+ { "nfsv3", "op-setattr-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-setattr-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-setattr-done", 2, 3, "SETATTR3res *" },
+ { "nfsv3", "op-symlink-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-symlink-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-symlink-start", 2, 3, "SYMLINK3args *" },
+ { "nfsv3", "op-symlink-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-symlink-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-symlink-done", 2, 3, "SYMLINK3res *" },
+ { "nfsv3", "op-write-start", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-write-start", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-write-start", 2, 3, "WRITE3args *" },
+ { "nfsv3", "op-write-done", 0, 0, "struct svc_req *",
+ "conninfo_t *" },
+ { "nfsv3", "op-write-done", 1, 1, "nfsv3oparg_t *",
+ "nfsv3opinfo_t *" },
+ { "nfsv3", "op-write-done", 2, 3, "WRITE3res *" },
+
+ { "nfsv4", "null-start", 0, 0, "struct svc_req *", "conninfo_t *" },
+ { "nfsv4", "null-done", 0, 0, "struct svc_req *", "conninfo_t *" },
+ { "nfsv4", "compound-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "compound-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "compound-start", 2, 1, "COMPOUND4args *" },
+ { "nfsv4", "compound-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "compound-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "compound-done", 2, 1, "COMPOUND4res *" },
+ { "nfsv4", "op-access-start", 0, 0, "struct compound_state *",
+ "conninfo_t *"},
+ { "nfsv4", "op-access-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-access-start", 2, 1, "ACCESS4args *" },
+ { "nfsv4", "op-access-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-access-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-access-done", 2, 1, "ACCESS4res *" },
+ { "nfsv4", "op-close-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-close-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-close-start", 2, 1, "CLOSE4args *" },
+ { "nfsv4", "op-close-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-close-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-close-done", 2, 1, "CLOSE4res *" },
+ { "nfsv4", "op-commit-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-commit-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-commit-start", 2, 1, "COMMIT4args *" },
+ { "nfsv4", "op-commit-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-commit-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-commit-done", 2, 1, "COMMIT4res *" },
+ { "nfsv4", "op-create-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-create-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-create-start", 2, 1, "CREATE4args *" },
+ { "nfsv4", "op-create-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-create-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-create-done", 2, 1, "CREATE4res *" },
+ { "nfsv4", "op-delegpurge-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-delegpurge-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-delegpurge-start", 2, 1, "DELEGPURGE4args *" },
+ { "nfsv4", "op-delegpurge-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-delegpurge-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-delegpurge-done", 2, 1, "DELEGPURGE4res *" },
+ { "nfsv4", "op-delegreturn-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-delegreturn-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-delegreturn-start", 2, 1, "DELEGRETURN4args *" },
+ { "nfsv4", "op-delegreturn-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-delegreturn-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-delegreturn-done", 2, 1, "DELEGRETURN4res *" },
+ { "nfsv4", "op-getattr-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-getattr-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-getattr-start", 2, 1, "GETATTR4args *" },
+ { "nfsv4", "op-getattr-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-getattr-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-getattr-done", 2, 1, "GETATTR4res *" },
+ { "nfsv4", "op-getfh-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-getfh-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-getfh-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-getfh-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-getfh-done", 2, 1, "GETFH4res *" },
+ { "nfsv4", "op-link-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-link-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-link-start", 2, 1, "LINK4args *" },
+ { "nfsv4", "op-link-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-link-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-link-done", 2, 1, "LINK4res *" },
+ { "nfsv4", "op-lock-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lock-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lock-start", 2, 1, "LOCK4args *" },
+ { "nfsv4", "op-lock-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lock-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lock-done", 2, 1, "LOCK4res *" },
+ { "nfsv4", "op-lockt-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lockt-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lockt-start", 2, 1, "LOCKT4args *" },
+ { "nfsv4", "op-lockt-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lockt-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lockt-done", 2, 1, "LOCKT4res *" },
+ { "nfsv4", "op-locku-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-locku-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-locku-start", 2, 1, "LOCKU4args *" },
+ { "nfsv4", "op-locku-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-locku-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-locku-done", 2, 1, "LOCKU4res *" },
+ { "nfsv4", "op-lookup-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lookup-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lookup-start", 2, 1, "LOOKUP4args *" },
+ { "nfsv4", "op-lookup-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lookup-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lookup-done", 2, 1, "LOOKUP4res *" },
+ { "nfsv4", "op-lookupp-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lookupp-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lookupp-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-lookupp-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-lookupp-done", 2, 1, "LOOKUPP4res *" },
+ { "nfsv4", "op-nverify-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-nverify-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-nverify-start", 2, 1, "NVERIFY4args *" },
+ { "nfsv4", "op-nverify-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-nverify-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-nverify-done", 2, 1, "NVERIFY4res *" },
+ { "nfsv4", "op-open-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-open-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-open-start", 2, 1, "OPEN4args *" },
+ { "nfsv4", "op-open-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-open-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-open-done", 2, 1, "OPEN4res *" },
+ { "nfsv4", "op-open-confirm-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-open-confirm-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-open-confirm-start", 2, 1, "OPEN_CONFIRM4args *" },
+ { "nfsv4", "op-open-confirm-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-open-confirm-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-open-confirm-done", 2, 1, "OPEN_CONFIRM4res *" },
+ { "nfsv4", "op-open-downgrade-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-open-downgrade-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-open-downgrade-start", 2, 1, "OPEN_DOWNGRADE4args *" },
+ { "nfsv4", "op-open-downgrade-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-open-downgrade-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-open-downgrade-done", 2, 1, "OPEN_DOWNGRADE4res *" },
+ { "nfsv4", "op-openattr-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-openattr-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-openattr-start", 2, 1, "OPENATTR4args *" },
+ { "nfsv4", "op-openattr-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-openattr-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-openattr-done", 2, 1, "OPENATTR4res *" },
+ { "nfsv4", "op-putfh-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-putfh-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-putfh-start", 2, 1, "PUTFH4args *" },
+ { "nfsv4", "op-putfh-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-putfh-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-putfh-done", 2, 1, "PUTFH4res *" },
+ { "nfsv4", "op-putpubfh-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-putpubfh-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-putpubfh-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-putpubfh-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-putpubfh-done", 2, 1, "PUTPUBFH4res *" },
+ { "nfsv4", "op-putrootfh-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-putrootfh-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-putrootfh-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-putrootfh-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-putrootfh-done", 2, 1, "PUTROOTFH4res *" },
+ { "nfsv4", "op-read-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-read-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-read-start", 2, 1, "READ4args *" },
+ { "nfsv4", "op-read-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-read-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-read-done", 2, 1, "READ4res *" },
+ { "nfsv4", "op-readdir-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-readdir-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-readdir-start", 2, 1, "READDIR4args *" },
+ { "nfsv4", "op-readdir-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-readdir-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-readdir-done", 2, 1, "READDIR4res *" },
+ { "nfsv4", "op-readlink-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-readlink-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-readlink-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-readlink-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-readlink-done", 2, 1, "READLINK4res *" },
+ { "nfsv4", "op-release-lockowner-start", 0, 0,
+ "struct compound_state *", "conninfo_t *" },
+ { "nfsv4", "op-release-lockowner-start", 1, 0,
+ "struct compound_state *", "nfsv4opinfo_t *" },
+ { "nfsv4", "op-release-lockowner-start", 2, 1,
+ "RELEASE_LOCKOWNER4args *" },
+ { "nfsv4", "op-release-lockowner-done", 0, 0,
+ "struct compound_state *", "conninfo_t *" },
+ { "nfsv4", "op-release-lockowner-done", 1, 0,
+ "struct compound_state *", "nfsv4opinfo_t *" },
+ { "nfsv4", "op-release-lockowner-done", 2, 1,
+ "RELEASE_LOCKOWNER4res *" },
+ { "nfsv4", "op-remove-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-remove-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-remove-start", 2, 1, "REMOVE4args *" },
+ { "nfsv4", "op-remove-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-remove-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-remove-done", 2, 1, "REMOVE4res *" },
+ { "nfsv4", "op-rename-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-rename-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-rename-start", 2, 1, "RENAME4args *" },
+ { "nfsv4", "op-rename-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-rename-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-rename-done", 2, 1, "RENAME4res *" },
+ { "nfsv4", "op-renew-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-renew-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-renew-start", 2, 1, "RENEW4args *" },
+ { "nfsv4", "op-renew-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-renew-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-renew-done", 2, 1, "RENEW4res *" },
+ { "nfsv4", "op-restorefh-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-restorefh-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-restorefh-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-restorefh-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-restorefh-done", 2, 1, "RESTOREFH4res *" },
+ { "nfsv4", "op-savefh-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-savefh-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-savefh-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-savefh-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-savefh-done", 2, 1, "SAVEFH4res *" },
+ { "nfsv4", "op-secinfo-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-secinfo-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-secinfo-start", 2, 1, "SECINFO4args *" },
+ { "nfsv4", "op-secinfo-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-secinfo-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-secinfo-done", 2, 1, "SECINFO4res *" },
+ { "nfsv4", "op-setattr-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-setattr-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-setattr-start", 2, 1, "SETATTR4args *" },
+ { "nfsv4", "op-setattr-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-setattr-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-setattr-done", 2, 1, "SETATTR4res *" },
+ { "nfsv4", "op-setclientid-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-setclientid-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-setclientid-start", 2, 1, "SETCLIENTID4args *" },
+ { "nfsv4", "op-setclientid-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-setclientid-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-setclientid-done", 2, 1, "SETCLIENTID4res *" },
+ { "nfsv4", "op-setclientid-confirm-start", 0, 0,
+ "struct compound_state *", "conninfo_t *" },
+ { "nfsv4", "op-setclientid-confirm-start", 1, 0,
+ "struct compound_state *", "nfsv4opinfo_t *" },
+ { "nfsv4", "op-setclientid-confirm-start", 2, 1,
+ "SETCLIENTID_CONFIRM4args *" },
+ { "nfsv4", "op-setclientid-confirm-done", 0, 0,
+ "struct compound_state *", "conninfo_t *" },
+ { "nfsv4", "op-setclientid-confirm-done", 1, 0,
+ "struct compound_state *", "nfsv4opinfo_t *" },
+ { "nfsv4", "op-setclientid-confirm-done", 2, 1,
+ "SETCLIENTID_CONFIRM4res *" },
+ { "nfsv4", "op-verify-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-verify-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-verify-start", 2, 1, "VERIFY4args *" },
+ { "nfsv4", "op-verify-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-verify-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-verify-done", 2, 1, "VERIFY4res *" },
+ { "nfsv4", "op-write-start", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-write-start", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-write-start", 2, 1, "WRITE4args *" },
+ { "nfsv4", "op-write-done", 0, 0, "struct compound_state *",
+ "conninfo_t *" },
+ { "nfsv4", "op-write-done", 1, 0, "struct compound_state *",
+ "nfsv4opinfo_t *" },
+ { "nfsv4", "op-write-done", 2, 1, "WRITE4res *" },
+ { "nfsv4", "cb-recall-start", 0, 0, "rfs4_client_t *",
+ "conninfo_t *" },
+ { "nfsv4", "cb-recall-start", 1, 1, "rfs4_deleg_state_t *",
+ "nfsv4cbinfo_t *" },
+ { "nfsv4", "cb-recall-start", 2, 2, "CB_RECALL4args *" },
+ { "nfsv4", "cb-recall-done", 0, 0, "rfs4_client_t *",
+ "conninfo_t *" },
+ { "nfsv4", "cb-recall-done", 1, 1, "rfs4_deleg_state_t *",
+ "nfsv4cbinfo_t *" },
+ { "nfsv4", "cb-recall-done", 2, 2, "CB_RECALL4res *" },
+
+ { "ip", "send", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "ip", "send", 1, 1, "conn_t *", "csinfo_t *" },
+ { "ip", "send", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "ip", "send", 3, 3, "__dtrace_ipsr_ill_t *", "ifinfo_t *" },
+ { "ip", "send", 4, 4, "ipha_t *", "ipv4info_t *" },
+ { "ip", "send", 5, 5, "ip6_t *", "ipv6info_t *" },
+ { "ip", "send", 6, 6, "int" }, /* used by __dtrace_ipsr_ill_t */
+ { "ip", "receive", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "ip", "receive", 1, 1, "conn_t *", "csinfo_t *" },
+ { "ip", "receive", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "ip", "receive", 3, 3, "__dtrace_ipsr_ill_t *", "ifinfo_t *" },
+ { "ip", "receive", 4, 4, "ipha_t *", "ipv4info_t *" },
+ { "ip", "receive", 5, 5, "ip6_t *", "ipv6info_t *" },
+ { "ip", "receive", 6, 6, "int" }, /* used by __dtrace_ipsr_ill_t */
+
+ { "tcp", "connect-established", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "tcp", "connect-established", 1, 1, "ip_xmit_attr_t *",
+ "csinfo_t *" },
+ { "tcp", "connect-established", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "tcp", "connect-established", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "connect-established", 4, 4, "tcph_t *", "tcpinfo_t *" },
+ { "tcp", "connect-refused", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "tcp", "connect-refused", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "tcp", "connect-refused", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "tcp", "connect-refused", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "connect-refused", 4, 4, "tcph_t *", "tcpinfo_t *" },
+ { "tcp", "connect-request", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "tcp", "connect-request", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "tcp", "connect-request", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "tcp", "connect-request", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "connect-request", 4, 4, "tcph_t *", "tcpinfo_t *" },
+ { "tcp", "accept-established", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "tcp", "accept-established", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "tcp", "accept-established", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "tcp", "accept-established", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "accept-established", 4, 4, "tcph_t *", "tcpinfo_t *" },
+ { "tcp", "accept-refused", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "tcp", "accept-refused", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "tcp", "accept-refused", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "tcp", "accept-refused", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "accept-refused", 4, 4, "tcph_t *", "tcpinfo_t *" },
+ { "tcp", "state-change", 0, 0, "void", "void" },
+ { "tcp", "state-change", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "tcp", "state-change", 2, 2, "void", "void" },
+ { "tcp", "state-change", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "state-change", 4, 4, "void", "void" },
+ { "tcp", "state-change", 5, 5, "int32_t", "tcplsinfo_t *" },
+ { "tcp", "send", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "tcp", "send", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "tcp", "send", 2, 2, "__dtrace_tcp_void_ip_t *", "ipinfo_t *" },
+ { "tcp", "send", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "send", 4, 4, "__dtrace_tcp_tcph_t *", "tcpinfo_t *" },
+ { "tcp", "receive", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "tcp", "receive", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "tcp", "receive", 2, 2, "__dtrace_tcp_void_ip_t *", "ipinfo_t *" },
+ { "tcp", "receive", 3, 3, "tcp_t *", "tcpsinfo_t *" },
+ { "tcp", "receive", 4, 4, "__dtrace_tcp_tcph_t *", "tcpinfo_t *" },
+
+ { "udp", "send", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "udp", "send", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "udp", "send", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "udp", "send", 3, 3, "udp_t *", "udpsinfo_t *" },
+ { "udp", "send", 4, 4, "udpha_t *", "udpinfo_t *" },
+ { "udp", "receive", 0, 0, "mblk_t *", "pktinfo_t *" },
+ { "udp", "receive", 1, 1, "ip_xmit_attr_t *", "csinfo_t *" },
+ { "udp", "receive", 2, 2, "void_ip_t *", "ipinfo_t *" },
+ { "udp", "receive", 3, 3, "udp_t *", "udpsinfo_t *" },
+ { "udp", "receive", 4, 4, "udpha_t *", "udpinfo_t *" },
+
+ { "sysevent", "post", 0, 0, "evch_bind_t *", "syseventchaninfo_t *" },
+ { "sysevent", "post", 1, 1, "sysevent_impl_t *", "syseventinfo_t *" },
+
+ { "xpv", "add-to-physmap-end", 0, 0, "int" },
+ { "xpv", "add-to-physmap-start", 0, 0, "domid_t" },
+ { "xpv", "add-to-physmap-start", 1, 1, "uint_t" },
+ { "xpv", "add-to-physmap-start", 2, 2, "ulong_t" },
+ { "xpv", "add-to-physmap-start", 3, 3, "ulong_t" },
+ { "xpv", "decrease-reservation-end", 0, 0, "int" },
+ { "xpv", "decrease-reservation-start", 0, 0, "domid_t" },
+ { "xpv", "decrease-reservation-start", 1, 1, "ulong_t" },
+ { "xpv", "decrease-reservation-start", 2, 2, "uint_t" },
+ { "xpv", "decrease-reservation-start", 3, 3, "ulong_t *" },
+ { "xpv", "dom-create-start", 0, 0, "xen_domctl_t *" },
+ { "xpv", "dom-destroy-start", 0, 0, "domid_t" },
+ { "xpv", "dom-pause-start", 0, 0, "domid_t" },
+ { "xpv", "dom-unpause-start", 0, 0, "domid_t" },
+ { "xpv", "dom-create-end", 0, 0, "int" },
+ { "xpv", "dom-destroy-end", 0, 0, "int" },
+ { "xpv", "dom-pause-end", 0, 0, "int" },
+ { "xpv", "dom-unpause-end", 0, 0, "int" },
+ { "xpv", "evtchn-op-end", 0, 0, "int" },
+ { "xpv", "evtchn-op-start", 0, 0, "int" },
+ { "xpv", "evtchn-op-start", 1, 1, "void *" },
+ { "xpv", "increase-reservation-end", 0, 0, "int" },
+ { "xpv", "increase-reservation-start", 0, 0, "domid_t" },
+ { "xpv", "increase-reservation-start", 1, 1, "ulong_t" },
+ { "xpv", "increase-reservation-start", 2, 2, "uint_t" },
+ { "xpv", "increase-reservation-start", 3, 3, "ulong_t *" },
+ { "xpv", "mmap-end", 0, 0, "int" },
+ { "xpv", "mmap-entry", 0, 0, "ulong_t" },
+ { "xpv", "mmap-entry", 1, 1, "ulong_t" },
+ { "xpv", "mmap-entry", 2, 2, "ulong_t" },
+ { "xpv", "mmap-start", 0, 0, "domid_t" },
+ { "xpv", "mmap-start", 1, 1, "int" },
+ { "xpv", "mmap-start", 2, 2, "privcmd_mmap_entry_t *" },
+ { "xpv", "mmapbatch-end", 0, 0, "int" },
+ { "xpv", "mmapbatch-end", 1, 1, "struct seg *" },
+ { "xpv", "mmapbatch-end", 2, 2, "caddr_t" },
+ { "xpv", "mmapbatch-start", 0, 0, "domid_t" },
+ { "xpv", "mmapbatch-start", 1, 1, "int" },
+ { "xpv", "mmapbatch-start", 2, 2, "caddr_t" },
+ { "xpv", "mmu-ext-op-end", 0, 0, "int" },
+ { "xpv", "mmu-ext-op-start", 0, 0, "int" },
+ { "xpv", "mmu-ext-op-start", 1, 1, "struct mmuext_op *" },
+ { "xpv", "mmu-update-start", 0, 0, "int" },
+ { "xpv", "mmu-update-start", 1, 1, "int" },
+ { "xpv", "mmu-update-start", 2, 2, "mmu_update_t *" },
+ { "xpv", "mmu-update-end", 0, 0, "int" },
+ { "xpv", "populate-physmap-end", 0, 0, "int" },
+ { "xpv", "populate-physmap-start", 0, 0, "domid_t" },
+ { "xpv", "populate-physmap-start", 1, 1, "ulong_t" },
+ { "xpv", "populate-physmap-start", 2, 2, "ulong_t *" },
+ { "xpv", "set-memory-map-end", 0, 0, "int" },
+ { "xpv", "set-memory-map-start", 0, 0, "domid_t" },
+ { "xpv", "set-memory-map-start", 1, 1, "int" },
+ { "xpv", "set-memory-map-start", 2, 2, "struct xen_memory_map *" },
+ { "xpv", "setvcpucontext-end", 0, 0, "int" },
+ { "xpv", "setvcpucontext-start", 0, 0, "domid_t" },
+ { "xpv", "setvcpucontext-start", 1, 1, "vcpu_guest_context_t *" },
+
+ { "srp", "service-up", 0, 0, "srpt_session_t *", "conninfo_t *" },
+ { "srp", "service-up", 1, 0, "srpt_session_t *", "srp_portinfo_t *" },
+ { "srp", "service-down", 0, 0, "srpt_session_t *", "conninfo_t *" },
+ { "srp", "service-down", 1, 0, "srpt_session_t *",
+ "srp_portinfo_t *" },
+ { "srp", "login-command", 0, 0, "srpt_session_t *", "conninfo_t *" },
+ { "srp", "login-command", 1, 0, "srpt_session_t *",
+ "srp_portinfo_t *" },
+ { "srp", "login-command", 2, 1, "srp_login_req_t *",
+ "srp_logininfo_t *" },
+ { "srp", "login-response", 0, 0, "srpt_session_t *", "conninfo_t *" },
+ { "srp", "login-response", 1, 0, "srpt_session_t *",
+ "srp_portinfo_t *" },
+ { "srp", "login-response", 2, 1, "srp_login_rsp_t *",
+ "srp_logininfo_t *" },
+ { "srp", "login-response", 3, 2, "srp_login_rej_t *" },
+ { "srp", "logout-command", 0, 0, "srpt_channel_t *", "conninfo_t *" },
+ { "srp", "logout-command", 1, 0, "srpt_channel_t *",
+ "srp_portinfo_t *" },
+ { "srp", "task-command", 0, 0, "srpt_channel_t *", "conninfo_t *" },
+ { "srp", "task-command", 1, 0, "srpt_channel_t *",
+ "srp_portinfo_t *" },
+ { "srp", "task-command", 2, 1, "srp_cmd_req_t *", "srp_taskinfo_t *" },
+ { "srp", "task-response", 0, 0, "srpt_channel_t *", "conninfo_t *" },
+ { "srp", "task-response", 1, 0, "srpt_channel_t *",
+ "srp_portinfo_t *" },
+ { "srp", "task-response", 2, 1, "srp_rsp_t *", "srp_taskinfo_t *" },
+ { "srp", "task-response", 3, 2, "scsi_task_t *" },
+ { "srp", "task-response", 4, 3, "int8_t" },
+ { "srp", "scsi-command", 0, 0, "srpt_channel_t *", "conninfo_t *" },
+ { "srp", "scsi-command", 1, 0, "srpt_channel_t *",
+ "srp_portinfo_t *" },
+ { "srp", "scsi-command", 2, 1, "scsi_task_t *", "scsicmd_t *" },
+ { "srp", "scsi-command", 3, 2, "srp_cmd_req_t *", "srp_taskinfo_t *" },
+ { "srp", "scsi-response", 0, 0, "srpt_channel_t *", "conninfo_t *" },
+ { "srp", "scsi-response", 1, 0, "srpt_channel_t *",
+ "srp_portinfo_t *" },
+ { "srp", "scsi-response", 2, 1, "srp_rsp_t *", "srp_taskinfo_t *" },
+ { "srp", "scsi-response", 3, 2, "scsi_task_t *" },
+ { "srp", "scsi-response", 4, 3, "int8_t" },
+ { "srp", "xfer-start", 0, 0, "srpt_channel_t *", "conninfo_t *" },
+ { "srp", "xfer-start", 1, 0, "srpt_channel_t *",
+ "srp_portinfo_t *" },
+ { "srp", "xfer-start", 2, 1, "ibt_wr_ds_t *", "xferinfo_t *" },
+ { "srp", "xfer-start", 3, 2, "srpt_iu_t *", "srp_taskinfo_t *" },
+ { "srp", "xfer-start", 4, 3, "ibt_send_wr_t *"},
+ { "srp", "xfer-start", 5, 4, "uint32_t" },
+ { "srp", "xfer-start", 6, 5, "uint32_t" },
+ { "srp", "xfer-start", 7, 6, "uint32_t" },
+ { "srp", "xfer-start", 8, 7, "uint32_t" },
+ { "srp", "xfer-done", 0, 0, "srpt_channel_t *", "conninfo_t *" },
+ { "srp", "xfer-done", 1, 0, "srpt_channel_t *",
+ "srp_portinfo_t *" },
+ { "srp", "xfer-done", 2, 1, "ibt_wr_ds_t *", "xferinfo_t *" },
+ { "srp", "xfer-done", 3, 2, "srpt_iu_t *", "srp_taskinfo_t *" },
+ { "srp", "xfer-done", 4, 3, "ibt_send_wr_t *"},
+ { "srp", "xfer-done", 5, 4, "uint32_t" },
+ { "srp", "xfer-done", 6, 5, "uint32_t" },
+ { "srp", "xfer-done", 7, 6, "uint32_t" },
+ { "srp", "xfer-done", 8, 7, "uint32_t" },
+
+ { "fc", "link-up", 0, 0, "fct_i_local_port_t *", "conninfo_t *" },
+ { "fc", "link-down", 0, 0, "fct_i_local_port_t *", "conninfo_t *" },
+ { "fc", "fabric-login-start", 0, 0, "fct_i_local_port_t *",
+ "conninfo_t *" },
+ { "fc", "fabric-login-start", 1, 0, "fct_i_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "fabric-login-end", 0, 0, "fct_i_local_port_t *",
+ "conninfo_t *" },
+ { "fc", "fabric-login-end", 1, 0, "fct_i_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-login-start", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "rport-login-start", 1, 1, "fct_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-login-start", 2, 2, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-login-start", 3, 3, "int", "int" },
+ { "fc", "rport-login-end", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "rport-login-end", 1, 1, "fct_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-login-end", 2, 2, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-login-end", 3, 3, "int", "int" },
+ { "fc", "rport-login-end", 4, 4, "int", "int" },
+ { "fc", "rport-logout-start", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "rport-logout-start", 1, 1, "fct_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-logout-start", 2, 2, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-logout-start", 3, 3, "int", "int" },
+ { "fc", "rport-logout-end", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "rport-logout-end", 1, 1, "fct_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-logout-end", 2, 2, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "rport-logout-end", 3, 3, "int", "int" },
+ { "fc", "scsi-command", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "scsi-command", 1, 1, "fct_i_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "scsi-command", 2, 2, "scsi_task_t *",
+ "scsicmd_t *" },
+ { "fc", "scsi-command", 3, 3, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "scsi-response", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "scsi-response", 1, 1, "fct_i_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "scsi-response", 2, 2, "scsi_task_t *",
+ "scsicmd_t *" },
+ { "fc", "scsi-response", 3, 3, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "xfer-start", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "xfer-start", 1, 1, "fct_i_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "xfer-start", 2, 2, "scsi_task_t *",
+ "scsicmd_t *" },
+ { "fc", "xfer-start", 3, 3, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "xfer-start", 4, 4, "stmf_data_buf_t *",
+ "fc_xferinfo_t *" },
+ { "fc", "xfer-done", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "xfer-done", 1, 1, "fct_i_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "xfer-done", 2, 2, "scsi_task_t *",
+ "scsicmd_t *" },
+ { "fc", "xfer-done", 3, 3, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "xfer-done", 4, 4, "stmf_data_buf_t *",
+ "fc_xferinfo_t *" },
+ { "fc", "rscn-receive", 0, 0, "fct_i_local_port_t *",
+ "conninfo_t *" },
+ { "fc", "rscn-receive", 1, 1, "int", "int"},
+ { "fc", "abts-receive", 0, 0, "fct_cmd_t *",
+ "conninfo_t *" },
+ { "fc", "abts-receive", 1, 1, "fct_i_local_port_t *",
+ "fc_port_info_t *" },
+ { "fc", "abts-receive", 2, 2, "fct_i_remote_port_t *",
+ "fc_port_info_t *" },
+
+
+ { NULL }
+};
+
+/*ARGSUSED*/
+void
+sdt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
+{
+ sdt_probe_t *sdp = parg;
+ int i;
+
+ desc->dtargd_native[0] = '\0';
+ desc->dtargd_xlate[0] = '\0';
+
+ for (i = 0; sdt_args[i].sda_provider != NULL; i++) {
+ sdt_argdesc_t *a = &sdt_args[i];
+
+ if (strcmp(sdp->sdp_provider->sdtp_name, a->sda_provider) != 0)
+ continue;
+
+ if (a->sda_name != NULL &&
+ strcmp(sdp->sdp_name, a->sda_name) != 0)
+ continue;
+
+ if (desc->dtargd_ndx != a->sda_ndx)
+ continue;
+
+ if (a->sda_native != NULL)
+ (void) strcpy(desc->dtargd_native, a->sda_native);
+
+ if (a->sda_xlate != NULL)
+ (void) strcpy(desc->dtargd_xlate, a->sda_xlate);
+
+ desc->dtargd_mapping = a->sda_mapping;
+ return;
+ }
+
+ desc->dtargd_ndx = DTRACE_ARGNONE;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.c
new file mode 100644
index 00000000..b864041c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.c
@@ -0,0 +1,374 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#include <sys/dtrace.h>
+#include <sys/systrace.h>
+#include <sys/stat.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/atomic.h>
+
+#define SYSTRACE_ARTIFICIAL_FRAMES 1
+
+#define SYSTRACE_SHIFT 16
+#define SYSTRACE_ISENTRY(x) ((int)(x) >> SYSTRACE_SHIFT)
+#define SYSTRACE_SYSNUM(x) ((int)(x) & ((1 << SYSTRACE_SHIFT) - 1))
+#define SYSTRACE_ENTRY(id) ((1 << SYSTRACE_SHIFT) | (id))
+#define SYSTRACE_RETURN(id) (id)
+
+#if ((1 << SYSTRACE_SHIFT) <= NSYSCALL)
+#error 1 << SYSTRACE_SHIFT must exceed number of system calls
+#endif
+
+static dev_info_t *systrace_devi;
+static dtrace_provider_id_t systrace_id;
+
+static void
+systrace_init(struct sysent *actual, systrace_sysent_t **interposed)
+{
+ systrace_sysent_t *sysent = *interposed;
+ int i;
+
+ if (sysent == NULL) {
+ *interposed = sysent = kmem_zalloc(sizeof (systrace_sysent_t) *
+ NSYSCALL, KM_SLEEP);
+ }
+
+ for (i = 0; i < NSYSCALL; i++) {
+ struct sysent *a = &actual[i];
+ systrace_sysent_t *s = &sysent[i];
+
+ if (LOADABLE_SYSCALL(a) && !LOADED_SYSCALL(a))
+ continue;
+
+ if (a->sy_callc == dtrace_systrace_syscall)
+ continue;
+
+#ifdef _SYSCALL32_IMPL
+ if (a->sy_callc == dtrace_systrace_syscall32)
+ continue;
+#endif
+
+ s->stsy_underlying = a->sy_callc;
+ }
+}
+
+/*ARGSUSED*/
+static void
+systrace_provide(void *arg, const dtrace_probedesc_t *desc)
+{
+ int i;
+
+ if (desc != NULL)
+ return;
+
+ systrace_init(sysent, &systrace_sysent);
+#ifdef _SYSCALL32_IMPL
+ systrace_init(sysent32, &systrace_sysent32);
+#endif
+
+ for (i = 0; i < NSYSCALL; i++) {
+ if (systrace_sysent[i].stsy_underlying == NULL)
+ continue;
+
+ if (dtrace_probe_lookup(systrace_id, NULL,
+ syscallnames[i], "entry") != 0)
+ continue;
+
+ (void) dtrace_probe_create(systrace_id, NULL, syscallnames[i],
+ "entry", SYSTRACE_ARTIFICIAL_FRAMES,
+ (void *)((uintptr_t)SYSTRACE_ENTRY(i)));
+ (void) dtrace_probe_create(systrace_id, NULL, syscallnames[i],
+ "return", SYSTRACE_ARTIFICIAL_FRAMES,
+ (void *)((uintptr_t)SYSTRACE_RETURN(i)));
+
+ systrace_sysent[i].stsy_entry = DTRACE_IDNONE;
+ systrace_sysent[i].stsy_return = DTRACE_IDNONE;
+#ifdef _SYSCALL32_IMPL
+ systrace_sysent32[i].stsy_entry = DTRACE_IDNONE;
+ systrace_sysent32[i].stsy_return = DTRACE_IDNONE;
+#endif
+ }
+}
+
+/*ARGSUSED*/
+static void
+systrace_destroy(void *arg, dtrace_id_t id, void *parg)
+{
+ int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg);
+
+ /*
+ * There's nothing to do here but assert that we have actually been
+ * disabled.
+ */
+ if (SYSTRACE_ISENTRY((uintptr_t)parg)) {
+ ASSERT(systrace_sysent[sysnum].stsy_entry == DTRACE_IDNONE);
+#ifdef _SYSCALL32_IMPL
+ ASSERT(systrace_sysent32[sysnum].stsy_entry == DTRACE_IDNONE);
+#endif
+ } else {
+ ASSERT(systrace_sysent[sysnum].stsy_return == DTRACE_IDNONE);
+#ifdef _SYSCALL32_IMPL
+ ASSERT(systrace_sysent32[sysnum].stsy_return == DTRACE_IDNONE);
+#endif
+ }
+}
+
+/*ARGSUSED*/
+static int
+systrace_enable(void *arg, dtrace_id_t id, void *parg)
+{
+ int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg);
+ int enabled = (systrace_sysent[sysnum].stsy_entry != DTRACE_IDNONE ||
+ systrace_sysent[sysnum].stsy_return != DTRACE_IDNONE);
+
+ if (SYSTRACE_ISENTRY((uintptr_t)parg)) {
+ systrace_sysent[sysnum].stsy_entry = id;
+#ifdef _SYSCALL32_IMPL
+ systrace_sysent32[sysnum].stsy_entry = id;
+#endif
+ } else {
+ systrace_sysent[sysnum].stsy_return = id;
+#ifdef _SYSCALL32_IMPL
+ systrace_sysent32[sysnum].stsy_return = id;
+#endif
+ }
+
+ if (enabled) {
+ ASSERT(sysent[sysnum].sy_callc == dtrace_systrace_syscall);
+ return (0);
+ }
+
+ (void) casptr(&sysent[sysnum].sy_callc,
+ (void *)systrace_sysent[sysnum].stsy_underlying,
+ (void *)dtrace_systrace_syscall);
+#ifdef _SYSCALL32_IMPL
+ (void) casptr(&sysent32[sysnum].sy_callc,
+ (void *)systrace_sysent32[sysnum].stsy_underlying,
+ (void *)dtrace_systrace_syscall32);
+#endif
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+systrace_disable(void *arg, dtrace_id_t id, void *parg)
+{
+ int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg);
+ int disable = (systrace_sysent[sysnum].stsy_entry == DTRACE_IDNONE ||
+ systrace_sysent[sysnum].stsy_return == DTRACE_IDNONE);
+
+ if (disable) {
+ (void) casptr(&sysent[sysnum].sy_callc,
+ (void *)dtrace_systrace_syscall,
+ (void *)systrace_sysent[sysnum].stsy_underlying);
+
+#ifdef _SYSCALL32_IMPL
+ (void) casptr(&sysent32[sysnum].sy_callc,
+ (void *)dtrace_systrace_syscall32,
+ (void *)systrace_sysent32[sysnum].stsy_underlying);
+#endif
+ }
+
+ if (SYSTRACE_ISENTRY((uintptr_t)parg)) {
+ systrace_sysent[sysnum].stsy_entry = DTRACE_IDNONE;
+#ifdef _SYSCALL32_IMPL
+ systrace_sysent32[sysnum].stsy_entry = DTRACE_IDNONE;
+#endif
+ } else {
+ systrace_sysent[sysnum].stsy_return = DTRACE_IDNONE;
+#ifdef _SYSCALL32_IMPL
+ systrace_sysent32[sysnum].stsy_return = DTRACE_IDNONE;
+#endif
+ }
+}
+
+static dtrace_pattr_t systrace_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pops_t systrace_pops = {
+ systrace_provide,
+ NULL,
+ systrace_enable,
+ systrace_disable,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ systrace_destroy
+};
+
+static int
+systrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_ATTACH:
+ break;
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ systrace_probe = (void (*)())dtrace_probe;
+ membar_enter();
+
+ if (ddi_create_minor_node(devi, "systrace", S_IFCHR, 0,
+ DDI_PSEUDO, NULL) == DDI_FAILURE ||
+ dtrace_register("syscall", &systrace_attr, DTRACE_PRIV_USER, NULL,
+ &systrace_pops, NULL, &systrace_id) != 0) {
+ systrace_probe = systrace_stub;
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_FAILURE);
+ }
+
+ ddi_report_dev(devi);
+ systrace_devi = devi;
+
+ return (DDI_SUCCESS);
+}
+
+static int
+systrace_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (dtrace_unregister(systrace_id) != 0)
+ return (DDI_FAILURE);
+
+ ddi_remove_minor_node(devi, NULL);
+ systrace_probe = systrace_stub;
+ return (DDI_SUCCESS);
+}
+
+/*ARGSUSED*/
+static int
+systrace_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *)systrace_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+/*ARGSUSED*/
+static int
+systrace_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+{
+ return (0);
+}
+
+static struct cb_ops systrace_cb_ops = {
+ systrace_open, /* open */
+ nodev, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ nodev, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_NEW | D_MP /* Driver compatibility flag */
+};
+
+static struct dev_ops systrace_ops = {
+ DEVO_REV, /* devo_rev, */
+ 0, /* refcnt */
+ systrace_info, /* get_dev_info */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ systrace_attach, /* attach */
+ systrace_detach, /* detach */
+ nodev, /* reset */
+ &systrace_cb_ops, /* driver operations */
+ NULL, /* bus operations */
+ nodev, /* dev power */
+ ddi_quiesce_not_needed, /* quiesce */
+};
+
+/*
+ * Module linkage information for the kernel.
+ */
+static struct modldrv modldrv = {
+ &mod_driverops, /* module type (this is a pseudo driver) */
+ "System Call Tracing", /* name of module */
+ &systrace_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1,
+ (void *)&modldrv,
+ NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.conf
new file mode 100644
index 00000000..02b0dac7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/systrace.conf
@@ -0,0 +1,28 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+name="systrace" parent="pseudo" instance=0;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/dtrace_subr.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/dtrace_subr.c
new file mode 100644
index 00000000..f2a9ac1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/os/dtrace_subr.c
@@ -0,0 +1,337 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <sys/dtrace.h>
+#include <sys/cmn_err.h>
+#include <sys/tnf.h>
+#include <sys/atomic.h>
+#include <sys/prsystm.h>
+#include <sys/modctl.h>
+#include <sys/aio_impl.h>
+
+#ifdef __sparc
+#include <sys/privregs.h>
+#endif
+
+void (*dtrace_cpu_init)(processorid_t);
+void (*dtrace_modload)(struct modctl *);
+void (*dtrace_modunload)(struct modctl *);
+void (*dtrace_helpers_cleanup)(void);
+void (*dtrace_helpers_fork)(proc_t *, proc_t *);
+void (*dtrace_cpustart_init)(void);
+void (*dtrace_cpustart_fini)(void);
+void (*dtrace_cpc_fire)(uint64_t);
+
+void (*dtrace_debugger_init)(void);
+void (*dtrace_debugger_fini)(void);
+
+dtrace_vtime_state_t dtrace_vtime_active = 0;
+dtrace_cacheid_t dtrace_predcache_id = DTRACE_CACHEIDNONE + 1;
+
+/*
+ * dtrace_cpc_in_use usage statement: this global variable is used by the cpc
+ * hardware overflow interrupt handler and the kernel cpc framework to check
+ * whether or not the DTrace cpc provider is currently in use. The variable is
+ * set before counters are enabled with the first enabling and cleared when
+ * the last enabling is disabled. Its value at any given time indicates the
+ * number of active dcpc based enablings. The global 'kcpc_cpuctx_lock' rwlock
+ * is held during initial setting to protect races between kcpc_open() and the
+ * first enabling. The locking provided by the DTrace subsystem, the kernel
+ * cpc framework and the cpu management framework protect consumers from race
+ * conditions on enabling and disabling probes.
+ */
+uint32_t dtrace_cpc_in_use = 0;
+
+typedef struct dtrace_hrestime {
+ lock_t dthr_lock; /* lock for this element */
+ timestruc_t dthr_hrestime; /* hrestime value */
+ int64_t dthr_adj; /* hrestime_adj value */
+ hrtime_t dthr_hrtime; /* hrtime value */
+} dtrace_hrestime_t;
+
+static dtrace_hrestime_t dtrace_hrestime[2];
+
+/*
+ * Making available adjustable high-resolution time in DTrace is regrettably
+ * more complicated than one might think it should be. The problem is that
+ * the variables related to adjusted high-resolution time (hrestime,
+ * hrestime_adj and friends) are adjusted under hres_lock -- and this lock may
+ * be held when we enter probe context. One might think that we could address
+ * this by having a single snapshot copy that is stored under a different lock
+ * from hres_tick(), using the snapshot iff hres_lock is locked in probe
+ * context. Unfortunately, this too won't work: because hres_lock is grabbed
+ * in more than just hres_tick() context, we could enter probe context
+ * concurrently on two different CPUs with both locks (hres_lock and the
+ * snapshot lock) held. As this implies, the fundamental problem is that we
+ * need to have access to a snapshot of these variables that we _know_ will
+ * not be locked in probe context. To effect this, we have two snapshots
+ * protected by two different locks, and we mandate that these snapshots are
+ * recorded in succession by a single thread calling dtrace_hres_tick(). (We
+ * assure this by calling it out of the same CY_HIGH_LEVEL cyclic that calls
+ * hres_tick().) A single thread can't be in two places at once: one of the
+ * snapshot locks is guaranteed to be unheld at all times. The
+ * dtrace_gethrestime() algorithm is thus to check first one snapshot and then
+ * the other to find the unlocked snapshot.
+ */
+void
+dtrace_hres_tick(void)
+{
+ int i;
+ ushort_t spl;
+
+ for (i = 0; i < 2; i++) {
+ dtrace_hrestime_t tmp;
+
+ spl = hr_clock_lock();
+ tmp.dthr_hrestime = hrestime;
+ tmp.dthr_adj = hrestime_adj;
+ tmp.dthr_hrtime = dtrace_gethrtime();
+ hr_clock_unlock(spl);
+
+ lock_set(&dtrace_hrestime[i].dthr_lock);
+ dtrace_hrestime[i].dthr_hrestime = tmp.dthr_hrestime;
+ dtrace_hrestime[i].dthr_adj = tmp.dthr_adj;
+ dtrace_hrestime[i].dthr_hrtime = tmp.dthr_hrtime;
+ dtrace_membar_producer();
+
+ /*
+ * To allow for lock-free examination of this lock, we use
+ * the same trick that is used hres_lock; for more details,
+ * see the description of this technique in sun4u/sys/clock.h.
+ */
+ dtrace_hrestime[i].dthr_lock++;
+ }
+}
+
+hrtime_t
+dtrace_gethrestime(void)
+{
+ dtrace_hrestime_t snap;
+ hrtime_t now;
+ int i = 0, adj, nslt;
+
+ for (;;) {
+ snap.dthr_lock = dtrace_hrestime[i].dthr_lock;
+ dtrace_membar_consumer();
+ snap.dthr_hrestime = dtrace_hrestime[i].dthr_hrestime;
+ snap.dthr_hrtime = dtrace_hrestime[i].dthr_hrtime;
+ snap.dthr_adj = dtrace_hrestime[i].dthr_adj;
+ dtrace_membar_consumer();
+
+ if ((snap.dthr_lock & ~1) == dtrace_hrestime[i].dthr_lock)
+ break;
+
+ /*
+ * If we're here, the lock was either locked, or it
+ * transitioned while we were taking the snapshot. Either
+ * way, we're going to try the other dtrace_hrestime element;
+ * we know that it isn't possible for both to be locked
+ * simultaneously, so we will ultimately get a good snapshot.
+ */
+ i ^= 1;
+ }
+
+ /*
+ * We have a good snapshot. Now perform any necessary adjustments.
+ */
+ nslt = dtrace_gethrtime() - snap.dthr_hrtime;
+ ASSERT(nslt >= 0);
+
+ now = ((hrtime_t)snap.dthr_hrestime.tv_sec * (hrtime_t)NANOSEC) +
+ snap.dthr_hrestime.tv_nsec;
+
+ if (snap.dthr_adj != 0) {
+ if (snap.dthr_adj > 0) {
+ adj = (nslt >> adj_shift);
+ if (adj > snap.dthr_adj)
+ adj = (int)snap.dthr_adj;
+ } else {
+ adj = -(nslt >> adj_shift);
+ if (adj < snap.dthr_adj)
+ adj = (int)snap.dthr_adj;
+ }
+ now += adj;
+ }
+
+ return (now);
+}
+
+void
+dtrace_vtime_enable(void)
+{
+ dtrace_vtime_state_t state, nstate;
+
+ do {
+ state = dtrace_vtime_active;
+
+ switch (state) {
+ case DTRACE_VTIME_INACTIVE:
+ nstate = DTRACE_VTIME_ACTIVE;
+ break;
+
+ case DTRACE_VTIME_INACTIVE_TNF:
+ nstate = DTRACE_VTIME_ACTIVE_TNF;
+ break;
+
+ case DTRACE_VTIME_ACTIVE:
+ case DTRACE_VTIME_ACTIVE_TNF:
+ panic("DTrace virtual time already enabled");
+ /*NOTREACHED*/
+ }
+
+ } while (cas32((uint32_t *)&dtrace_vtime_active,
+ state, nstate) != state);
+}
+
+void
+dtrace_vtime_disable(void)
+{
+ dtrace_vtime_state_t state, nstate;
+
+ do {
+ state = dtrace_vtime_active;
+
+ switch (state) {
+ case DTRACE_VTIME_ACTIVE:
+ nstate = DTRACE_VTIME_INACTIVE;
+ break;
+
+ case DTRACE_VTIME_ACTIVE_TNF:
+ nstate = DTRACE_VTIME_INACTIVE_TNF;
+ break;
+
+ case DTRACE_VTIME_INACTIVE:
+ case DTRACE_VTIME_INACTIVE_TNF:
+ panic("DTrace virtual time already disabled");
+ /*NOTREACHED*/
+ }
+
+ } while (cas32((uint32_t *)&dtrace_vtime_active,
+ state, nstate) != state);
+}
+
+void
+dtrace_vtime_enable_tnf(void)
+{
+ dtrace_vtime_state_t state, nstate;
+
+ do {
+ state = dtrace_vtime_active;
+
+ switch (state) {
+ case DTRACE_VTIME_ACTIVE:
+ nstate = DTRACE_VTIME_ACTIVE_TNF;
+ break;
+
+ case DTRACE_VTIME_INACTIVE:
+ nstate = DTRACE_VTIME_INACTIVE_TNF;
+ break;
+
+ case DTRACE_VTIME_ACTIVE_TNF:
+ case DTRACE_VTIME_INACTIVE_TNF:
+ panic("TNF already active");
+ /*NOTREACHED*/
+ }
+
+ } while (cas32((uint32_t *)&dtrace_vtime_active,
+ state, nstate) != state);
+}
+
+void
+dtrace_vtime_disable_tnf(void)
+{
+ dtrace_vtime_state_t state, nstate;
+
+ do {
+ state = dtrace_vtime_active;
+
+ switch (state) {
+ case DTRACE_VTIME_ACTIVE_TNF:
+ nstate = DTRACE_VTIME_ACTIVE;
+ break;
+
+ case DTRACE_VTIME_INACTIVE_TNF:
+ nstate = DTRACE_VTIME_INACTIVE;
+ break;
+
+ case DTRACE_VTIME_ACTIVE:
+ case DTRACE_VTIME_INACTIVE:
+ panic("TNF already inactive");
+ /*NOTREACHED*/
+ }
+
+ } while (cas32((uint32_t *)&dtrace_vtime_active,
+ state, nstate) != state);
+}
+
+void
+dtrace_vtime_switch(kthread_t *next)
+{
+ dtrace_icookie_t cookie;
+ hrtime_t ts;
+
+ if (tnf_tracing_active) {
+ tnf_thread_switch(next);
+
+ if (dtrace_vtime_active == DTRACE_VTIME_INACTIVE_TNF)
+ return;
+ }
+
+ cookie = dtrace_interrupt_disable();
+ ts = dtrace_gethrtime();
+
+ if (curthread->t_dtrace_start != 0) {
+ curthread->t_dtrace_vtime += ts - curthread->t_dtrace_start;
+ curthread->t_dtrace_start = 0;
+ }
+
+ next->t_dtrace_start = ts;
+
+ dtrace_interrupt_enable(cookie);
+}
+
+void (*dtrace_fasttrap_fork_ptr)(proc_t *, proc_t *);
+void (*dtrace_fasttrap_exec_ptr)(proc_t *);
+void (*dtrace_fasttrap_exit_ptr)(proc_t *);
+
+/*
+ * This function is called by cfork() in the event that it appears that
+ * there may be dtrace tracepoints active in the parent process's address
+ * space. This first confirms the existence of dtrace tracepoints in the
+ * parent process and calls into the fasttrap module to remove the
+ * corresponding tracepoints from the child. By knowing that there are
+ * existing tracepoints, and ensuring they can't be removed, we can rely
+ * on the fasttrap module remaining loaded.
+ */
+void
+dtrace_fasttrap_fork(proc_t *p, proc_t *cp)
+{
+ ASSERT(p->p_proc_flag & P_PR_LOCK);
+ ASSERT(p->p_dtrace_count > 0);
+ ASSERT(dtrace_fasttrap_fork_ptr != NULL);
+
+ dtrace_fasttrap_fork_ptr(p, cp);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf.h
new file mode 100644
index 00000000..c23d5977
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf.h
@@ -0,0 +1,364 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _CTF_H
+#define _CTF_H
+
+#ifndef VBOX
+# pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#ifndef VBOX
+# include <sys/types.h>
+#else
+# include "VBoxDTraceTypes.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * CTF - Compact ANSI-C Type Format
+ *
+ * This file format can be used to compactly represent the information needed
+ * by a debugger to interpret the ANSI-C types used by a given program.
+ * Traditionally, this kind of information is generated by the compiler when
+ * invoked with the -g flag and is stored in "stabs" strings or in the more
+ * modern DWARF format. CTF provides a representation of only the information
+ * that is relevant to debugging a complex, optimized C program such as the
+ * operating system kernel in a form that is significantly more compact than
+ * the equivalent stabs or DWARF representation. The format is data-model
+ * independent, so consumers do not need different code depending on whether
+ * they are 32-bit or 64-bit programs. CTF assumes that a standard ELF symbol
+ * table is available for use in the debugger, and uses the structure and data
+ * of the symbol table to avoid storing redundant information. The CTF data
+ * may be compressed on disk or in memory, indicated by a bit in the header.
+ * CTF may be interpreted in a raw disk file, or it may be stored in an ELF
+ * section, typically named .SUNW_ctf. Data structures are aligned so that
+ * a raw CTF file or CTF ELF section may be manipulated using mmap(2).
+ *
+ * The CTF file or section itself has the following structure:
+ *
+ * +--------+--------+---------+----------+-------+--------+
+ * | file | type | data | function | data | string |
+ * | header | labels | objects | info | types | table |
+ * +--------+--------+---------+----------+-------+--------+
+ *
+ * The file header stores a magic number and version information, encoding
+ * flags, and the byte offset of each of the sections relative to the end of the
+ * header itself. If the CTF data has been uniquified against another set of
+ * CTF data, a reference to that data also appears in the the header. This
+ * reference is the name of the label corresponding to the types uniquified
+ * against.
+ *
+ * Following the header is a list of labels, used to group the types included in
+ * the data types section. Each label is accompanied by a type ID i. A given
+ * label refers to the group of types whose IDs are in the range [0, i].
+ *
+ * Data object and function records are stored in the same order as they appear
+ * in the corresponding symbol table, except that symbols marked SHN_UNDEF are
+ * not stored and symbols that have no type data are padded out with zeroes.
+ * For each data object, the type ID (a small integer) is recorded. For each
+ * function, the type ID of the return type and argument types is recorded.
+ *
+ * The data types section is a list of variable size records that represent each
+ * type, in order by their ID. The types themselves form a directed graph,
+ * where each node may contain one or more outgoing edges to other type nodes,
+ * denoted by their ID.
+ *
+ * Strings are recorded as a string table ID (0 or 1) and a byte offset into the
+ * string table. String table 0 is the internal CTF string table. String table
+ * 1 is the external string table, which is the string table associated with the
+ * ELF symbol table for this object. CTF does not record any strings that are
+ * already in the symbol table, and the CTF string table does not contain any
+ * duplicated strings.
+ *
+ * If the CTF data has been merged with another parent CTF object, some outgoing
+ * edges may refer to type nodes that exist in another CTF object. The debugger
+ * and libctf library are responsible for connecting the appropriate objects
+ * together so that the full set of types can be explored and manipulated.
+ */
+
+#define CTF_MAX_TYPE 0xffff /* max type identifier value */
+#define CTF_MAX_NAME 0x7fffffff /* max offset into a string table */
+#define CTF_MAX_VLEN 0x3ff /* max struct, union, enum members or args */
+#define CTF_MAX_INTOFF 0xff /* max offset of intrinsic value in bits */
+#define CTF_MAX_INTBITS 0xffff /* max size of an intrinsic in bits */
+
+/* See ctf_type_t */
+#define CTF_MAX_SIZE 0xfffe /* max size of a type in bytes */
+#define CTF_LSIZE_SENT 0xffff /* sentinel for ctt_size */
+#define CTF_MAX_LSIZE UINT64_MAX
+
+typedef struct ctf_preamble {
+ ushort_t ctp_magic; /* magic number (CTF_MAGIC) */
+ uchar_t ctp_version; /* data format version number (CTF_VERSION) */
+ uchar_t ctp_flags; /* flags (see below) */
+} ctf_preamble_t;
+
+typedef struct ctf_header {
+ ctf_preamble_t cth_preamble;
+ uint_t cth_parlabel; /* ref to name of parent lbl uniq'd against */
+ uint_t cth_parname; /* ref to basename of parent */
+ uint_t cth_lbloff; /* offset of label section */
+ uint_t cth_objtoff; /* offset of object section */
+ uint_t cth_funcoff; /* offset of function section */
+ uint_t cth_typeoff; /* offset of type section */
+ uint_t cth_stroff; /* offset of string section */
+ uint_t cth_strlen; /* length of string section in bytes */
+} ctf_header_t;
+
+#define cth_magic cth_preamble.ctp_magic
+#define cth_version cth_preamble.ctp_version
+#define cth_flags cth_preamble.ctp_flags
+
+#ifdef CTF_OLD_VERSIONS
+
+typedef struct ctf_header_v1 {
+ ctf_preamble_t cth_preamble;
+ uint_t cth_objtoff;
+ uint_t cth_funcoff;
+ uint_t cth_typeoff;
+ uint_t cth_stroff;
+ uint_t cth_strlen;
+} ctf_header_v1_t;
+
+#endif /* CTF_OLD_VERSIONS */
+
+#define CTF_MAGIC 0xcff1 /* magic number identifying header */
+
+/* data format version number */
+#define CTF_VERSION_1 1
+#define CTF_VERSION_2 2
+#define CTF_VERSION CTF_VERSION_2 /* current version */
+
+#define CTF_F_COMPRESS 0x1 /* data buffer is compressed */
+
+typedef struct ctf_lblent {
+ uint_t ctl_label; /* ref to name of label */
+ uint_t ctl_typeidx; /* last type associated with this label */
+} ctf_lblent_t;
+
+typedef struct ctf_stype {
+ uint_t ctt_name; /* reference to name in string table */
+ ushort_t ctt_info; /* encoded kind, variant length (see below) */
+ union {
+ ushort_t _size; /* size of entire type in bytes */
+ ushort_t _type; /* reference to another type */
+ } _u;
+} ctf_stype_t;
+
+/*
+ * type sizes, measured in bytes, come in two flavors. 99% of them fit within
+ * (USHRT_MAX - 1), and thus can be stored in the ctt_size member of a
+ * ctf_stype_t. The maximum value for these sizes is CTF_MAX_SIZE. The sizes
+ * larger than CTF_MAX_SIZE must be stored in the ctt_lsize member of a
+ * ctf_type_t. Use of this member is indicated by the presence of
+ * CTF_LSIZE_SENT in ctt_size.
+ */
+typedef struct ctf_type {
+ uint_t ctt_name; /* reference to name in string table */
+ ushort_t ctt_info; /* encoded kind, variant length (see below) */
+ union {
+ ushort_t _size; /* always CTF_LSIZE_SENT */
+ ushort_t _type; /* do not use */
+ } _u;
+ uint_t ctt_lsizehi; /* high 32 bits of type size in bytes */
+ uint_t ctt_lsizelo; /* low 32 bits of type size in bytes */
+} ctf_type_t;
+
+#define ctt_size _u._size /* for fundamental types that have a size */
+#define ctt_type _u._type /* for types that reference another type */
+
+/*
+ * The following macros compose and decompose values for ctt_info and
+ * ctt_name, as well as other structures that contain name references.
+ *
+ * ------------------------
+ * ctt_info: | kind | isroot | vlen |
+ * ------------------------
+ * 15 11 10 9 0
+ *
+ * kind = CTF_INFO_KIND(c.ctt_info); <-- CTF_K_* value (see below)
+ * vlen = CTF_INFO_VLEN(c.ctt_info); <-- length of variable data list
+ *
+ * stid = CTF_NAME_STID(c.ctt_name); <-- string table id number (0 or 1)
+ * offset = CTF_NAME_OFFSET(c.ctt_name); <-- string table byte offset
+ *
+ * c.ctt_info = CTF_TYPE_INFO(kind, vlen);
+ * c.ctt_name = CTF_TYPE_NAME(stid, offset);
+ */
+
+#define CTF_INFO_KIND(info) (((info) & 0xf800) >> 11)
+#define CTF_INFO_ISROOT(info) (((info) & 0x0400) >> 10)
+#define CTF_INFO_VLEN(info) (((info) & CTF_MAX_VLEN))
+
+#define CTF_NAME_STID(name) ((name) >> 31)
+#define CTF_NAME_OFFSET(name) ((name) & 0x7fffffff)
+
+#define CTF_TYPE_INFO(kind, isroot, vlen) \
+ (((kind) << 11) | (((isroot) ? 1 : 0) << 10) | ((vlen) & CTF_MAX_VLEN))
+
+#define CTF_TYPE_NAME(stid, offset) \
+ (((stid) << 31) | ((offset) & 0x7fffffff))
+
+#define CTF_TYPE_ISPARENT(id) ((id) < 0x8000)
+#define CTF_TYPE_ISCHILD(id) ((id) > 0x7fff)
+
+#define CTF_TYPE_TO_INDEX(id) ((id) & 0x7fff)
+#define CTF_INDEX_TO_TYPE(id, child) ((child) ? ((id) | 0x8000) : (id))
+#define CTF_PARENT_SHIFT 15
+
+#define CTF_STRTAB_0 0 /* symbolic define for string table id 0 */
+#define CTF_STRTAB_1 1 /* symbolic define for string table id 1 */
+
+#define CTF_TYPE_LSIZE(cttp) \
+ (((uint64_t)(cttp)->ctt_lsizehi) << 32 | (cttp)->ctt_lsizelo)
+#define CTF_SIZE_TO_LSIZE_HI(size) ((uint32_t)((uint64_t)(size) >> 32))
+#define CTF_SIZE_TO_LSIZE_LO(size) ((uint32_t)(size))
+
+#ifdef CTF_OLD_VERSIONS
+
+#define CTF_INFO_KIND_V1(info) (((info) & 0xf000) >> 12)
+#define CTF_INFO_ISROOT_V1(info) (((info) & 0x0800) >> 11)
+#define CTF_INFO_VLEN_V1(info) (((info) & 0x07ff))
+
+#define CTF_TYPE_INFO_V1(kind, isroot, vlen) \
+ (((kind) << 12) | (((isroot) ? 1 : 0) << 11) | ((vlen) & 0x07ff))
+
+#endif /* CTF_OLD_VERSIONS */
+
+/*
+ * Values for CTF_TYPE_KIND(). If the kind has an associated data list,
+ * CTF_INFO_VLEN() will extract the number of elements in the list, and
+ * the type of each element is shown in the comments below.
+ */
+#define CTF_K_UNKNOWN 0 /* unknown type (used for padding) */
+#define CTF_K_INTEGER 1 /* variant data is CTF_INT_DATA() (see below) */
+#define CTF_K_FLOAT 2 /* variant data is CTF_FP_DATA() (see below) */
+#define CTF_K_POINTER 3 /* ctt_type is referenced type */
+#define CTF_K_ARRAY 4 /* variant data is single ctf_array_t */
+#define CTF_K_FUNCTION 5 /* ctt_type is return type, variant data is */
+ /* list of argument types (ushort_t's) */
+#define CTF_K_STRUCT 6 /* variant data is list of ctf_member_t's */
+#define CTF_K_UNION 7 /* variant data is list of ctf_member_t's */
+#define CTF_K_ENUM 8 /* variant data is list of ctf_enum_t's */
+#define CTF_K_FORWARD 9 /* no additional data; ctt_name is tag */
+#define CTF_K_TYPEDEF 10 /* ctt_type is referenced type */
+#define CTF_K_VOLATILE 11 /* ctt_type is base type */
+#define CTF_K_CONST 12 /* ctt_type is base type */
+#define CTF_K_RESTRICT 13 /* ctt_type is base type */
+
+#define CTF_K_MAX 31 /* Maximum possible CTF_K_* value */
+
+/*
+ * Values for ctt_type when kind is CTF_K_INTEGER. The flags, offset in bits,
+ * and size in bits are encoded as a single word using the following macros.
+ */
+#define CTF_INT_ENCODING(data) (((data) & 0xff000000) >> 24)
+#define CTF_INT_OFFSET(data) (((data) & 0x00ff0000) >> 16)
+#define CTF_INT_BITS(data) (((data) & 0x0000ffff))
+
+#define CTF_INT_DATA(encoding, offset, bits) \
+ (((encoding) << 24) | ((offset) << 16) | (bits))
+
+#define CTF_INT_SIGNED 0x01 /* integer is signed (otherwise unsigned) */
+#define CTF_INT_CHAR 0x02 /* character display format */
+#define CTF_INT_BOOL 0x04 /* boolean display format */
+#define CTF_INT_VARARGS 0x08 /* varargs display format */
+
+/*
+ * Values for ctt_type when kind is CTF_K_FLOAT. The encoding, offset in bits,
+ * and size in bits are encoded as a single word using the following macros.
+ */
+#define CTF_FP_ENCODING(data) (((data) & 0xff000000) >> 24)
+#define CTF_FP_OFFSET(data) (((data) & 0x00ff0000) >> 16)
+#define CTF_FP_BITS(data) (((data) & 0x0000ffff))
+
+#define CTF_FP_DATA(encoding, offset, bits) \
+ (((encoding) << 24) | ((offset) << 16) | (bits))
+
+#define CTF_FP_SINGLE 1 /* IEEE 32-bit float encoding */
+#define CTF_FP_DOUBLE 2 /* IEEE 64-bit float encoding */
+#define CTF_FP_CPLX 3 /* Complex encoding */
+#define CTF_FP_DCPLX 4 /* Double complex encoding */
+#define CTF_FP_LDCPLX 5 /* Long double complex encoding */
+#define CTF_FP_LDOUBLE 6 /* Long double encoding */
+#define CTF_FP_INTRVL 7 /* Interval (2x32-bit) encoding */
+#define CTF_FP_DINTRVL 8 /* Double interval (2x64-bit) encoding */
+#define CTF_FP_LDINTRVL 9 /* Long double interval (2x128-bit) encoding */
+#define CTF_FP_IMAGRY 10 /* Imaginary (32-bit) encoding */
+#define CTF_FP_DIMAGRY 11 /* Long imaginary (64-bit) encoding */
+#define CTF_FP_LDIMAGRY 12 /* Long double imaginary (128-bit) encoding */
+
+#define CTF_FP_MAX 12 /* Maximum possible CTF_FP_* value */
+
+typedef struct ctf_array {
+ ushort_t cta_contents; /* reference to type of array contents */
+ ushort_t cta_index; /* reference to type of array index */
+ uint_t cta_nelems; /* number of elements */
+} ctf_array_t;
+
+/*
+ * Most structure members have bit offsets that can be expressed using a
+ * short. Some don't. ctf_member_t is used for structs which cannot
+ * contain any of these large offsets, whereas ctf_lmember_t is used in the
+ * latter case. If ctt_size for a given struct is >= 8192 bytes, all members
+ * will be stored as type ctf_lmember_t.
+ */
+
+#define CTF_LSTRUCT_THRESH 8192
+
+typedef struct ctf_member {
+ uint_t ctm_name; /* reference to name in string table */
+ ushort_t ctm_type; /* reference to type of member */
+ ushort_t ctm_offset; /* offset of this member in bits */
+} ctf_member_t;
+
+typedef struct ctf_lmember {
+ uint_t ctlm_name; /* reference to name in string table */
+ ushort_t ctlm_type; /* reference to type of member */
+ ushort_t ctlm_pad; /* padding */
+ uint_t ctlm_offsethi; /* high 32 bits of member offset in bits */
+ uint_t ctlm_offsetlo; /* low 32 bits of member offset in bits */
+} ctf_lmember_t;
+
+#define CTF_LMEM_OFFSET(ctlmp) \
+ (((uint64_t)(ctlmp)->ctlm_offsethi) << 32 | (ctlmp)->ctlm_offsetlo)
+#define CTF_OFFSET_TO_LMEMHI(offset) ((uint32_t)((uint64_t)(offset) >> 32))
+#define CTF_OFFSET_TO_LMEMLO(offset) ((uint32_t)(offset))
+
+typedef struct ctf_enum {
+ uint_t cte_name; /* reference to name in string table */
+ int cte_value; /* value associated with this name */
+} ctf_enum_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CTF_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf_api.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf_api.h
new file mode 100644
index 00000000..7baa37e6
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/ctf_api.h
@@ -0,0 +1,251 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * This header file defines the interfaces available from the CTF debugger
+ * library, libctf, and an equivalent kernel module. This API can be used by
+ * a debugger to operate on data in the Compact ANSI-C Type Format (CTF).
+ * This is NOT a public interface, although it may eventually become one in
+ * the fullness of time after we gain more experience with the interfaces.
+ *
+ * In the meantime, be aware that any program linked with this API in this
+ * release of Solaris is almost guaranteed to break in the next release.
+ *
+ * In short, do not user this header file or the CTF routines for any purpose.
+ */
+
+#ifndef _CTF_API_H
+#define _CTF_API_H
+
+#ifndef VBOX
+# pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#ifndef VBOX
+# include <sys/types.h>
+# include <sys/param.h>
+# include <sys/elf.h>
+#else
+# include "VBoxDTraceTypes.h"
+#endif
+#include <sys/ctf.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Clients can open one or more CTF containers and obtain a pointer to an
+ * opaque ctf_file_t. Types are identified by an opaque ctf_id_t token.
+ * These opaque definitions allow libctf to evolve without breaking clients.
+ */
+typedef struct ctf_file ctf_file_t;
+typedef long ctf_id_t;
+
+/*
+ * If the debugger needs to provide the CTF library with a set of raw buffers
+ * for use as the CTF data, symbol table, and string table, it can do so by
+ * filling in ctf_sect_t structures and passing them to ctf_bufopen():
+ */
+typedef struct ctf_sect {
+ const char *cts_name; /* section name (if any) */
+ ulong_t cts_type; /* section type (ELF SHT_... value) */
+ ulong_t cts_flags; /* section flags (ELF SHF_... value) */
+ const void *cts_data; /* pointer to section data */
+ size_t cts_size; /* size of data in bytes */
+ size_t cts_entsize; /* size of each section entry (symtab only) */
+#ifndef VBOX
+ off64_t cts_offset; /* file offset of this section (if any) */
+#else
+ RTFOFF cts_offset; /* file offset of this section (if any) */
+#endif
+} ctf_sect_t;
+
+/*
+ * Encoding information for integers, floating-point values, and certain other
+ * intrinsics can be obtained by calling ctf_type_encoding(), below. The flags
+ * field will contain values appropriate for the type defined in <sys/ctf.h>.
+ */
+typedef struct ctf_encoding {
+ uint_t cte_format; /* data format (CTF_INT_* or CTF_FP_* flags) */
+ uint_t cte_offset; /* offset of value in bits */
+ uint_t cte_bits; /* size of storage in bits */
+} ctf_encoding_t;
+
+typedef struct ctf_membinfo {
+ ctf_id_t ctm_type; /* type of struct or union member */
+ ulong_t ctm_offset; /* offset of member in bits */
+} ctf_membinfo_t;
+
+typedef struct ctf_arinfo {
+ ctf_id_t ctr_contents; /* type of array contents */
+ ctf_id_t ctr_index; /* type of array index */
+ uint_t ctr_nelems; /* number of elements */
+} ctf_arinfo_t;
+
+typedef struct ctf_funcinfo {
+ ctf_id_t ctc_return; /* function return type */
+ uint_t ctc_argc; /* number of typed arguments to function */
+ uint_t ctc_flags; /* function attributes (see below) */
+} ctf_funcinfo_t;
+
+typedef struct ctf_lblinfo {
+ ctf_id_t ctb_typeidx; /* last type associated with the label */
+} ctf_lblinfo_t;
+
+#define CTF_FUNC_VARARG 0x1 /* function arguments end with varargs */
+
+/*
+ * Functions that return integer status or a ctf_id_t use the following value
+ * to indicate failure. ctf_errno() can be used to obtain an error code.
+ */
+#define CTF_ERR (-1L)
+
+/*
+ * The CTF data model is inferred to be the caller's data model or the data
+ * model of the given object, unless ctf_setmodel() is explicitly called.
+ */
+#define CTF_MODEL_ILP32 1 /* object data model is ILP32 */
+#define CTF_MODEL_LP64 2 /* object data model is LP64 */
+#ifdef _LP64
+#define CTF_MODEL_NATIVE CTF_MODEL_LP64
+#else
+#define CTF_MODEL_NATIVE CTF_MODEL_ILP32
+#endif
+
+/*
+ * Dynamic CTF containers can be created using ctf_create(). The ctf_add_*
+ * routines can be used to add new definitions to the dynamic container.
+ * New types are labeled as root or non-root to determine whether they are
+ * visible at the top-level program scope when subsequently doing a lookup.
+ */
+#define CTF_ADD_NONROOT 0 /* type only visible in nested scope */
+#define CTF_ADD_ROOT 1 /* type visible at top-level scope */
+
+/*
+ * These typedefs are used to define the signature for callback functions
+ * that can be used with the iteration and visit functions below:
+ */
+typedef int ctf_visit_f(const char *, ctf_id_t, ulong_t, int, void *);
+typedef int ctf_member_f(const char *, ctf_id_t, ulong_t, void *);
+typedef int ctf_enum_f(const char *, int, void *);
+typedef int ctf_type_f(ctf_id_t, void *);
+typedef int ctf_label_f(const char *, const ctf_lblinfo_t *, void *);
+
+extern ctf_file_t *ctf_bufopen(const ctf_sect_t *, const ctf_sect_t *,
+ const ctf_sect_t *, int *);
+extern ctf_file_t *ctf_fdopen(int, int *);
+extern ctf_file_t *ctf_open(const char *, int *);
+extern ctf_file_t *ctf_create(int *);
+extern void ctf_close(ctf_file_t *);
+
+extern ctf_file_t *ctf_parent_file(ctf_file_t *);
+extern const char *ctf_parent_name(ctf_file_t *);
+
+extern int ctf_import(ctf_file_t *, ctf_file_t *);
+extern int ctf_setmodel(ctf_file_t *, int);
+extern int ctf_getmodel(ctf_file_t *);
+
+extern void ctf_setspecific(ctf_file_t *, void *);
+extern void *ctf_getspecific(ctf_file_t *);
+
+extern int ctf_errno(ctf_file_t *);
+extern const char *ctf_errmsg(int);
+extern int ctf_version(int);
+
+extern int ctf_func_info(ctf_file_t *, ulong_t, ctf_funcinfo_t *);
+extern int ctf_func_args(ctf_file_t *, ulong_t, uint_t, ctf_id_t *);
+
+extern ctf_id_t ctf_lookup_by_name(ctf_file_t *, const char *);
+extern ctf_id_t ctf_lookup_by_symbol(ctf_file_t *, ulong_t);
+
+extern ctf_id_t ctf_type_resolve(ctf_file_t *, ctf_id_t);
+extern ssize_t ctf_type_lname(ctf_file_t *, ctf_id_t, char *, size_t);
+extern char *ctf_type_name(ctf_file_t *, ctf_id_t, char *, size_t);
+extern ssize_t ctf_type_size(ctf_file_t *, ctf_id_t);
+extern ssize_t ctf_type_align(ctf_file_t *, ctf_id_t);
+extern int ctf_type_kind(ctf_file_t *, ctf_id_t);
+extern ctf_id_t ctf_type_reference(ctf_file_t *, ctf_id_t);
+extern ctf_id_t ctf_type_pointer(ctf_file_t *, ctf_id_t);
+extern int ctf_type_encoding(ctf_file_t *, ctf_id_t, ctf_encoding_t *);
+extern int ctf_type_visit(ctf_file_t *, ctf_id_t, ctf_visit_f *, void *);
+extern int ctf_type_cmp(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t);
+extern int ctf_type_compat(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t);
+
+extern int ctf_member_info(ctf_file_t *, ctf_id_t, const char *,
+ ctf_membinfo_t *);
+extern int ctf_array_info(ctf_file_t *, ctf_id_t, ctf_arinfo_t *);
+
+extern const char *ctf_enum_name(ctf_file_t *, ctf_id_t, int);
+extern int ctf_enum_value(ctf_file_t *, ctf_id_t, const char *, int *);
+
+extern const char *ctf_label_topmost(ctf_file_t *);
+extern int ctf_label_info(ctf_file_t *, const char *, ctf_lblinfo_t *);
+
+extern int ctf_member_iter(ctf_file_t *, ctf_id_t, ctf_member_f *, void *);
+extern int ctf_enum_iter(ctf_file_t *, ctf_id_t, ctf_enum_f *, void *);
+extern int ctf_type_iter(ctf_file_t *, ctf_type_f *, void *);
+extern int ctf_label_iter(ctf_file_t *, ctf_label_f *, void *);
+
+extern ctf_id_t ctf_add_array(ctf_file_t *, uint_t, const ctf_arinfo_t *);
+extern ctf_id_t ctf_add_const(ctf_file_t *, uint_t, ctf_id_t);
+extern ctf_id_t ctf_add_enum(ctf_file_t *, uint_t, const char *);
+extern ctf_id_t ctf_add_float(ctf_file_t *, uint_t,
+ const char *, const ctf_encoding_t *);
+extern ctf_id_t ctf_add_forward(ctf_file_t *, uint_t, const char *, uint_t);
+extern ctf_id_t ctf_add_function(ctf_file_t *, uint_t,
+ const ctf_funcinfo_t *, const ctf_id_t *);
+extern ctf_id_t ctf_add_integer(ctf_file_t *, uint_t,
+ const char *, const ctf_encoding_t *);
+extern ctf_id_t ctf_add_pointer(ctf_file_t *, uint_t, ctf_id_t);
+extern ctf_id_t ctf_add_type(ctf_file_t *, ctf_file_t *, ctf_id_t);
+extern ctf_id_t ctf_add_typedef(ctf_file_t *, uint_t, const char *, ctf_id_t);
+extern ctf_id_t ctf_add_restrict(ctf_file_t *, uint_t, ctf_id_t);
+extern ctf_id_t ctf_add_struct(ctf_file_t *, uint_t, const char *);
+extern ctf_id_t ctf_add_union(ctf_file_t *, uint_t, const char *);
+extern ctf_id_t ctf_add_volatile(ctf_file_t *, uint_t, ctf_id_t);
+
+extern int ctf_add_enumerator(ctf_file_t *, ctf_id_t, const char *, int);
+extern int ctf_add_member(ctf_file_t *, ctf_id_t, const char *, ctf_id_t);
+
+extern int ctf_set_array(ctf_file_t *, ctf_id_t, const ctf_arinfo_t *);
+
+extern int ctf_update(ctf_file_t *);
+extern int ctf_discard(ctf_file_t *);
+extern int ctf_write(ctf_file_t *, int);
+
+#ifdef _KERNEL
+
+struct module;
+extern ctf_file_t *ctf_modopen(struct module *, int *);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CTF_API_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace.h
new file mode 100644
index 00000000..868a94b2
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace.h
@@ -0,0 +1,2276 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_DTRACE_H
+#define _SYS_DTRACE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * DTrace Dynamic Tracing Software: Kernel Interfaces
+ *
+ * Note: The contents of this file are private to the implementation of the
+ * Solaris system and DTrace subsystem and are subject to change at any time
+ * without notice. Applications and drivers using these interfaces will fail
+ * to run on future releases. These interfaces should not be used for any
+ * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
+ * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
+ */
+
+#ifndef _ASM
+
+#ifndef VBOX
+#include <sys/types.h>
+#include <sys/modctl.h>
+#include <sys/processor.h>
+#include <sys/systm.h>
+#include <sys/cyclic.h>
+#include <sys/int_limits.h>
+#else
+# include <VBoxDTraceTypes.h>
+# include <sys/ctf_api.h>
+#endif
+
+/*
+ * DTrace Universal Constants and Typedefs
+ */
+#ifdef VBOX
+#define DTRACE_CPUALL ((processorid_t)-1) /* all CPUs */
+#else
+#define DTRACE_CPUALL -1 /* all CPUs */
+#endif
+#define DTRACE_IDNONE 0 /* invalid probe identifier */
+#define DTRACE_EPIDNONE 0 /* invalid enabled probe identifier */
+#define DTRACE_AGGIDNONE 0 /* invalid aggregation identifier */
+#define DTRACE_AGGVARIDNONE 0 /* invalid aggregation variable ID */
+#define DTRACE_CACHEIDNONE 0 /* invalid predicate cache */
+#define DTRACE_PROVNONE 0 /* invalid provider identifier */
+#define DTRACE_METAPROVNONE 0 /* invalid meta-provider identifier */
+#define DTRACE_ARGNONE -1 /* invalid argument index */
+
+#define DTRACE_PROVNAMELEN 64
+#define DTRACE_MODNAMELEN 64
+#define DTRACE_FUNCNAMELEN 128
+#define DTRACE_NAMELEN 64
+#define DTRACE_FULLNAMELEN (DTRACE_PROVNAMELEN + DTRACE_MODNAMELEN + \
+ DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 4)
+#define DTRACE_ARGTYPELEN 128
+
+typedef uint32_t dtrace_id_t; /* probe identifier */
+typedef uint32_t dtrace_epid_t; /* enabled probe identifier */
+typedef uint32_t dtrace_aggid_t; /* aggregation identifier */
+typedef int64_t dtrace_aggvarid_t; /* aggregation variable identifier */
+typedef uint16_t dtrace_actkind_t; /* action kind */
+typedef int64_t dtrace_optval_t; /* option value */
+typedef uint32_t dtrace_cacheid_t; /* predicate cache identifier */
+
+typedef enum dtrace_probespec {
+ DTRACE_PROBESPEC_NONE = -1,
+ DTRACE_PROBESPEC_PROVIDER = 0,
+ DTRACE_PROBESPEC_MOD,
+ DTRACE_PROBESPEC_FUNC,
+ DTRACE_PROBESPEC_NAME
+} dtrace_probespec_t;
+
+/*
+ * DTrace Intermediate Format (DIF)
+ *
+ * The following definitions describe the DTrace Intermediate Format (DIF), a
+ * a RISC-like instruction set and program encoding used to represent
+ * predicates and actions that can be bound to DTrace probes. The constants
+ * below defining the number of available registers are suggested minimums; the
+ * compiler should use DTRACEIOC_CONF to dynamically obtain the number of
+ * registers provided by the current DTrace implementation.
+ */
+#define DIF_VERSION_1 1 /* DIF version 1: Solaris 10 Beta */
+#define DIF_VERSION_2 2 /* DIF version 2: Solaris 10 FCS */
+#define DIF_VERSION DIF_VERSION_2 /* latest DIF instruction set version */
+#define DIF_DIR_NREGS 8 /* number of DIF integer registers */
+#define DIF_DTR_NREGS 8 /* number of DIF tuple registers */
+
+#define DIF_OP_OR 1 /* or r1, r2, rd */
+#define DIF_OP_XOR 2 /* xor r1, r2, rd */
+#define DIF_OP_AND 3 /* and r1, r2, rd */
+#define DIF_OP_SLL 4 /* sll r1, r2, rd */
+#define DIF_OP_SRL 5 /* srl r1, r2, rd */
+#define DIF_OP_SUB 6 /* sub r1, r2, rd */
+#define DIF_OP_ADD 7 /* add r1, r2, rd */
+#define DIF_OP_MUL 8 /* mul r1, r2, rd */
+#define DIF_OP_SDIV 9 /* sdiv r1, r2, rd */
+#define DIF_OP_UDIV 10 /* udiv r1, r2, rd */
+#define DIF_OP_SREM 11 /* srem r1, r2, rd */
+#define DIF_OP_UREM 12 /* urem r1, r2, rd */
+#define DIF_OP_NOT 13 /* not r1, rd */
+#define DIF_OP_MOV 14 /* mov r1, rd */
+#define DIF_OP_CMP 15 /* cmp r1, r2 */
+#define DIF_OP_TST 16 /* tst r1 */
+#define DIF_OP_BA 17 /* ba label */
+#define DIF_OP_BE 18 /* be label */
+#define DIF_OP_BNE 19 /* bne label */
+#define DIF_OP_BG 20 /* bg label */
+#define DIF_OP_BGU 21 /* bgu label */
+#define DIF_OP_BGE 22 /* bge label */
+#define DIF_OP_BGEU 23 /* bgeu label */
+#define DIF_OP_BL 24 /* bl label */
+#define DIF_OP_BLU 25 /* blu label */
+#define DIF_OP_BLE 26 /* ble label */
+#define DIF_OP_BLEU 27 /* bleu label */
+#define DIF_OP_LDSB 28 /* ldsb [r1], rd */
+#define DIF_OP_LDSH 29 /* ldsh [r1], rd */
+#define DIF_OP_LDSW 30 /* ldsw [r1], rd */
+#define DIF_OP_LDUB 31 /* ldub [r1], rd */
+#define DIF_OP_LDUH 32 /* lduh [r1], rd */
+#define DIF_OP_LDUW 33 /* lduw [r1], rd */
+#define DIF_OP_LDX 34 /* ldx [r1], rd */
+#define DIF_OP_RET 35 /* ret rd */
+#define DIF_OP_NOP 36 /* nop */
+#define DIF_OP_SETX 37 /* setx intindex, rd */
+#define DIF_OP_SETS 38 /* sets strindex, rd */
+#define DIF_OP_SCMP 39 /* scmp r1, r2 */
+#define DIF_OP_LDGA 40 /* ldga var, ri, rd */
+#define DIF_OP_LDGS 41 /* ldgs var, rd */
+#define DIF_OP_STGS 42 /* stgs var, rs */
+#define DIF_OP_LDTA 43 /* ldta var, ri, rd */
+#define DIF_OP_LDTS 44 /* ldts var, rd */
+#define DIF_OP_STTS 45 /* stts var, rs */
+#define DIF_OP_SRA 46 /* sra r1, r2, rd */
+#define DIF_OP_CALL 47 /* call subr, rd */
+#define DIF_OP_PUSHTR 48 /* pushtr type, rs, rr */
+#define DIF_OP_PUSHTV 49 /* pushtv type, rs, rv */
+#define DIF_OP_POPTS 50 /* popts */
+#define DIF_OP_FLUSHTS 51 /* flushts */
+#define DIF_OP_LDGAA 52 /* ldgaa var, rd */
+#define DIF_OP_LDTAA 53 /* ldtaa var, rd */
+#define DIF_OP_STGAA 54 /* stgaa var, rs */
+#define DIF_OP_STTAA 55 /* sttaa var, rs */
+#define DIF_OP_LDLS 56 /* ldls var, rd */
+#define DIF_OP_STLS 57 /* stls var, rs */
+#define DIF_OP_ALLOCS 58 /* allocs r1, rd */
+#define DIF_OP_COPYS 59 /* copys r1, r2, rd */
+#define DIF_OP_STB 60 /* stb r1, [rd] */
+#define DIF_OP_STH 61 /* sth r1, [rd] */
+#define DIF_OP_STW 62 /* stw r1, [rd] */
+#define DIF_OP_STX 63 /* stx r1, [rd] */
+#define DIF_OP_ULDSB 64 /* uldsb [r1], rd */
+#define DIF_OP_ULDSH 65 /* uldsh [r1], rd */
+#define DIF_OP_ULDSW 66 /* uldsw [r1], rd */
+#define DIF_OP_ULDUB 67 /* uldub [r1], rd */
+#define DIF_OP_ULDUH 68 /* ulduh [r1], rd */
+#define DIF_OP_ULDUW 69 /* ulduw [r1], rd */
+#define DIF_OP_ULDX 70 /* uldx [r1], rd */
+#define DIF_OP_RLDSB 71 /* rldsb [r1], rd */
+#define DIF_OP_RLDSH 72 /* rldsh [r1], rd */
+#define DIF_OP_RLDSW 73 /* rldsw [r1], rd */
+#define DIF_OP_RLDUB 74 /* rldub [r1], rd */
+#define DIF_OP_RLDUH 75 /* rlduh [r1], rd */
+#define DIF_OP_RLDUW 76 /* rlduw [r1], rd */
+#define DIF_OP_RLDX 77 /* rldx [r1], rd */
+#define DIF_OP_XLATE 78 /* xlate xlrindex, rd */
+#define DIF_OP_XLARG 79 /* xlarg xlrindex, rd */
+
+#define DIF_INTOFF_MAX 0xffff /* highest integer table offset */
+#define DIF_STROFF_MAX 0xffff /* highest string table offset */
+#define DIF_REGISTER_MAX 0xff /* highest register number */
+#define DIF_VARIABLE_MAX 0xffff /* highest variable identifier */
+#define DIF_SUBROUTINE_MAX 0xffff /* highest subroutine code */
+
+#define DIF_VAR_ARRAY_MIN 0x0000 /* lowest numbered array variable */
+#define DIF_VAR_ARRAY_UBASE 0x0080 /* lowest user-defined array */
+#define DIF_VAR_ARRAY_MAX 0x00ff /* highest numbered array variable */
+
+#define DIF_VAR_OTHER_MIN 0x0100 /* lowest numbered scalar or assc */
+#define DIF_VAR_OTHER_UBASE 0x0500 /* lowest user-defined scalar or assc */
+#define DIF_VAR_OTHER_MAX 0xffff /* highest numbered scalar or assc */
+
+#define DIF_VAR_ARGS 0x0000 /* arguments array */
+#define DIF_VAR_REGS 0x0001 /* registers array */
+#define DIF_VAR_UREGS 0x0002 /* user registers array */
+#define DIF_VAR_CURTHREAD 0x0100 /* thread pointer */
+#define DIF_VAR_TIMESTAMP 0x0101 /* timestamp */
+#define DIF_VAR_VTIMESTAMP 0x0102 /* virtual timestamp */
+#define DIF_VAR_IPL 0x0103 /* interrupt priority level */
+#define DIF_VAR_EPID 0x0104 /* enabled probe ID */
+#define DIF_VAR_ID 0x0105 /* probe ID */
+#define DIF_VAR_ARG0 0x0106 /* first argument */
+#define DIF_VAR_ARG1 0x0107 /* second argument */
+#define DIF_VAR_ARG2 0x0108 /* third argument */
+#define DIF_VAR_ARG3 0x0109 /* fourth argument */
+#define DIF_VAR_ARG4 0x010a /* fifth argument */
+#define DIF_VAR_ARG5 0x010b /* sixth argument */
+#define DIF_VAR_ARG6 0x010c /* seventh argument */
+#define DIF_VAR_ARG7 0x010d /* eighth argument */
+#define DIF_VAR_ARG8 0x010e /* ninth argument */
+#define DIF_VAR_ARG9 0x010f /* tenth argument */
+#define DIF_VAR_STACKDEPTH 0x0110 /* stack depth */
+#define DIF_VAR_CALLER 0x0111 /* caller */
+#define DIF_VAR_PROBEPROV 0x0112 /* probe provider */
+#define DIF_VAR_PROBEMOD 0x0113 /* probe module */
+#define DIF_VAR_PROBEFUNC 0x0114 /* probe function */
+#define DIF_VAR_PROBENAME 0x0115 /* probe name */
+#define DIF_VAR_PID 0x0116 /* process ID */
+#define DIF_VAR_TID 0x0117 /* (per-process) thread ID */
+#define DIF_VAR_EXECNAME 0x0118 /* name of executable */
+#define DIF_VAR_ZONENAME 0x0119 /* zone name associated with process */
+#define DIF_VAR_WALLTIMESTAMP 0x011a /* wall-clock timestamp */
+#define DIF_VAR_USTACKDEPTH 0x011b /* user-land stack depth */
+#define DIF_VAR_UCALLER 0x011c /* user-level caller */
+#define DIF_VAR_PPID 0x011d /* parent process ID */
+#define DIF_VAR_UID 0x011e /* process user ID */
+#define DIF_VAR_GID 0x011f /* process group ID */
+#define DIF_VAR_ERRNO 0x0120 /* thread errno */
+
+#define DIF_SUBR_RAND 0
+#define DIF_SUBR_MUTEX_OWNED 1
+#define DIF_SUBR_MUTEX_OWNER 2
+#define DIF_SUBR_MUTEX_TYPE_ADAPTIVE 3
+#define DIF_SUBR_MUTEX_TYPE_SPIN 4
+#define DIF_SUBR_RW_READ_HELD 5
+#define DIF_SUBR_RW_WRITE_HELD 6
+#define DIF_SUBR_RW_ISWRITER 7
+#define DIF_SUBR_COPYIN 8
+#define DIF_SUBR_COPYINSTR 9
+#define DIF_SUBR_SPECULATION 10
+#define DIF_SUBR_PROGENYOF 11
+#define DIF_SUBR_STRLEN 12
+#define DIF_SUBR_COPYOUT 13
+#define DIF_SUBR_COPYOUTSTR 14
+#define DIF_SUBR_ALLOCA 15
+#define DIF_SUBR_BCOPY 16
+#define DIF_SUBR_COPYINTO 17
+#define DIF_SUBR_MSGDSIZE 18
+#define DIF_SUBR_MSGSIZE 19
+#define DIF_SUBR_GETMAJOR 20
+#define DIF_SUBR_GETMINOR 21
+#define DIF_SUBR_DDI_PATHNAME 22
+#define DIF_SUBR_STRJOIN 23
+#define DIF_SUBR_LLTOSTR 24
+#define DIF_SUBR_BASENAME 25
+#define DIF_SUBR_DIRNAME 26
+#define DIF_SUBR_CLEANPATH 27
+#define DIF_SUBR_STRCHR 28
+#define DIF_SUBR_STRRCHR 29
+#define DIF_SUBR_STRSTR 30
+#define DIF_SUBR_STRTOK 31
+#define DIF_SUBR_SUBSTR 32
+#define DIF_SUBR_INDEX 33
+#define DIF_SUBR_RINDEX 34
+#define DIF_SUBR_HTONS 35
+#define DIF_SUBR_HTONL 36
+#define DIF_SUBR_HTONLL 37
+#define DIF_SUBR_NTOHS 38
+#define DIF_SUBR_NTOHL 39
+#define DIF_SUBR_NTOHLL 40
+#define DIF_SUBR_INET_NTOP 41
+#define DIF_SUBR_INET_NTOA 42
+#define DIF_SUBR_INET_NTOA6 43
+
+#define DIF_SUBR_MAX 43 /* max subroutine value */
+
+typedef uint32_t dif_instr_t;
+
+#define DIF_INSTR_OP(i) (((i) >> 24) & 0xff)
+#define DIF_INSTR_R1(i) (((i) >> 16) & 0xff)
+#define DIF_INSTR_R2(i) (((i) >> 8) & 0xff)
+#define DIF_INSTR_RD(i) ((i) & 0xff)
+#define DIF_INSTR_RS(i) ((i) & 0xff)
+#define DIF_INSTR_LABEL(i) ((i) & 0xffffff)
+#define DIF_INSTR_VAR(i) (((i) >> 8) & 0xffff)
+#define DIF_INSTR_INTEGER(i) (((i) >> 8) & 0xffff)
+#define DIF_INSTR_STRING(i) (((i) >> 8) & 0xffff)
+#define DIF_INSTR_SUBR(i) (((i) >> 8) & 0xffff)
+#define DIF_INSTR_TYPE(i) (((i) >> 16) & 0xff)
+#define DIF_INSTR_XLREF(i) (((i) >> 8) & 0xffff)
+
+#define DIF_INSTR_FMT(op, r1, r2, d) \
+ (((op) << 24) | ((r1) << 16) | ((r2) << 8) | (d))
+
+#define DIF_INSTR_NOT(r1, d) (DIF_INSTR_FMT(DIF_OP_NOT, r1, 0, d))
+#define DIF_INSTR_MOV(r1, d) (DIF_INSTR_FMT(DIF_OP_MOV, r1, 0, d))
+#define DIF_INSTR_CMP(op, r1, r2) (DIF_INSTR_FMT(op, r1, r2, 0))
+#define DIF_INSTR_TST(r1) (DIF_INSTR_FMT(DIF_OP_TST, r1, 0, 0))
+#define DIF_INSTR_BRANCH(op, label) (((op) << 24) | (label))
+#define DIF_INSTR_LOAD(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d))
+#define DIF_INSTR_STORE(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d))
+#define DIF_INSTR_SETX(i, d) ((DIF_OP_SETX << 24) | ((i) << 8) | (d))
+#define DIF_INSTR_SETS(s, d) ((DIF_OP_SETS << 24) | ((s) << 8) | (d))
+#define DIF_INSTR_RET(d) (DIF_INSTR_FMT(DIF_OP_RET, 0, 0, d))
+#define DIF_INSTR_NOP (DIF_OP_NOP << 24)
+#define DIF_INSTR_LDA(op, v, r, d) (DIF_INSTR_FMT(op, v, r, d))
+#define DIF_INSTR_LDV(op, v, d) (((op) << 24) | ((v) << 8) | (d))
+#define DIF_INSTR_STV(op, v, rs) (((op) << 24) | ((v) << 8) | (rs))
+#define DIF_INSTR_CALL(s, d) ((DIF_OP_CALL << 24) | ((s) << 8) | (d))
+#define DIF_INSTR_PUSHTS(op, t, r2, rs) (DIF_INSTR_FMT(op, t, r2, rs))
+#define DIF_INSTR_POPTS (DIF_OP_POPTS << 24)
+#define DIF_INSTR_FLUSHTS (DIF_OP_FLUSHTS << 24)
+#define DIF_INSTR_ALLOCS(r1, d) (DIF_INSTR_FMT(DIF_OP_ALLOCS, r1, 0, d))
+#define DIF_INSTR_COPYS(r1, r2, d) (DIF_INSTR_FMT(DIF_OP_COPYS, r1, r2, d))
+#define DIF_INSTR_XLATE(op, r, d) (((op) << 24) | ((r) << 8) | (d))
+
+#define DIF_REG_R0 0 /* %r0 is always set to zero */
+
+/*
+ * A DTrace Intermediate Format Type (DIF Type) is used to represent the types
+ * of variables, function and associative array arguments, and the return type
+ * for each DIF object (shown below). It contains a description of the type,
+ * its size in bytes, and a module identifier.
+ */
+typedef struct dtrace_diftype {
+ uint8_t dtdt_kind; /* type kind (see below) */
+ uint8_t dtdt_ckind; /* type kind in CTF */
+ uint8_t dtdt_flags; /* type flags (see below) */
+ uint8_t dtdt_pad; /* reserved for future use */
+ uint32_t dtdt_size; /* type size in bytes (unless string) */
+} dtrace_diftype_t;
+
+#define DIF_TYPE_CTF 0 /* type is a CTF type */
+#define DIF_TYPE_STRING 1 /* type is a D string */
+
+#define DIF_TF_BYREF 0x1 /* type is passed by reference */
+
+/*
+ * A DTrace Intermediate Format variable record is used to describe each of the
+ * variables referenced by a given DIF object. It contains an integer variable
+ * identifier along with variable scope and properties, as shown below. The
+ * size of this structure must be sizeof (int) aligned.
+ */
+typedef struct dtrace_difv {
+ uint32_t dtdv_name; /* variable name index in dtdo_strtab */
+ uint32_t dtdv_id; /* variable reference identifier */
+ uint8_t dtdv_kind; /* variable kind (see below) */
+ uint8_t dtdv_scope; /* variable scope (see below) */
+ uint16_t dtdv_flags; /* variable flags (see below) */
+ dtrace_diftype_t dtdv_type; /* variable type (see above) */
+} dtrace_difv_t;
+
+#define DIFV_KIND_ARRAY 0 /* variable is an array of quantities */
+#define DIFV_KIND_SCALAR 1 /* variable is a scalar quantity */
+
+#define DIFV_SCOPE_GLOBAL 0 /* variable has global scope */
+#define DIFV_SCOPE_THREAD 1 /* variable has thread scope */
+#define DIFV_SCOPE_LOCAL 2 /* variable has local scope */
+
+#define DIFV_F_REF 0x1 /* variable is referenced by DIFO */
+#define DIFV_F_MOD 0x2 /* variable is written by DIFO */
+
+/*
+ * DTrace Actions
+ *
+ * The upper byte determines the class of the action; the low bytes determines
+ * the specific action within that class. The classes of actions are as
+ * follows:
+ *
+ * [ no class ] <= May record process- or kernel-related data
+ * DTRACEACT_PROC <= Only records process-related data
+ * DTRACEACT_PROC_DESTRUCTIVE <= Potentially destructive to processes
+ * DTRACEACT_KERNEL <= Only records kernel-related data
+ * DTRACEACT_KERNEL_DESTRUCTIVE <= Potentially destructive to the kernel
+ * DTRACEACT_SPECULATIVE <= Speculation-related action
+ * DTRACEACT_AGGREGATION <= Aggregating action
+ */
+#define DTRACEACT_NONE 0 /* no action */
+#define DTRACEACT_DIFEXPR 1 /* action is DIF expression */
+#define DTRACEACT_EXIT 2 /* exit() action */
+#define DTRACEACT_PRINTF 3 /* printf() action */
+#define DTRACEACT_PRINTA 4 /* printa() action */
+#define DTRACEACT_LIBACT 5 /* library-controlled action */
+
+#define DTRACEACT_PROC 0x0100
+#define DTRACEACT_USTACK (DTRACEACT_PROC + 1)
+#define DTRACEACT_JSTACK (DTRACEACT_PROC + 2)
+#define DTRACEACT_USYM (DTRACEACT_PROC + 3)
+#define DTRACEACT_UMOD (DTRACEACT_PROC + 4)
+#define DTRACEACT_UADDR (DTRACEACT_PROC + 5)
+
+#define DTRACEACT_PROC_DESTRUCTIVE 0x0200
+#define DTRACEACT_STOP (DTRACEACT_PROC_DESTRUCTIVE + 1)
+#define DTRACEACT_RAISE (DTRACEACT_PROC_DESTRUCTIVE + 2)
+#define DTRACEACT_SYSTEM (DTRACEACT_PROC_DESTRUCTIVE + 3)
+#define DTRACEACT_FREOPEN (DTRACEACT_PROC_DESTRUCTIVE + 4)
+
+#define DTRACEACT_PROC_CONTROL 0x0300
+
+#define DTRACEACT_KERNEL 0x0400
+#define DTRACEACT_STACK (DTRACEACT_KERNEL + 1)
+#define DTRACEACT_SYM (DTRACEACT_KERNEL + 2)
+#define DTRACEACT_MOD (DTRACEACT_KERNEL + 3)
+
+#define DTRACEACT_KERNEL_DESTRUCTIVE 0x0500
+#define DTRACEACT_BREAKPOINT (DTRACEACT_KERNEL_DESTRUCTIVE + 1)
+#define DTRACEACT_PANIC (DTRACEACT_KERNEL_DESTRUCTIVE + 2)
+#define DTRACEACT_CHILL (DTRACEACT_KERNEL_DESTRUCTIVE + 3)
+
+#define DTRACEACT_SPECULATIVE 0x0600
+#define DTRACEACT_SPECULATE (DTRACEACT_SPECULATIVE + 1)
+#define DTRACEACT_COMMIT (DTRACEACT_SPECULATIVE + 2)
+#define DTRACEACT_DISCARD (DTRACEACT_SPECULATIVE + 3)
+
+#define DTRACEACT_CLASS(x) ((x) & 0xff00)
+
+#define DTRACEACT_ISDESTRUCTIVE(x) \
+ (DTRACEACT_CLASS(x) == DTRACEACT_PROC_DESTRUCTIVE || \
+ DTRACEACT_CLASS(x) == DTRACEACT_KERNEL_DESTRUCTIVE)
+
+#define DTRACEACT_ISSPECULATIVE(x) \
+ (DTRACEACT_CLASS(x) == DTRACEACT_SPECULATIVE)
+
+#define DTRACEACT_ISPRINTFLIKE(x) \
+ ((x) == DTRACEACT_PRINTF || (x) == DTRACEACT_PRINTA || \
+ (x) == DTRACEACT_SYSTEM || (x) == DTRACEACT_FREOPEN)
+
+/*
+ * DTrace Aggregating Actions
+ *
+ * These are functions f(x) for which the following is true:
+ *
+ * f(f(x_0) U f(x_1) U ... U f(x_n)) = f(x_0 U x_1 U ... U x_n)
+ *
+ * where x_n is a set of arbitrary data. Aggregating actions are in their own
+ * DTrace action class, DTTRACEACT_AGGREGATION. The macros provided here allow
+ * for easier processing of the aggregation argument and data payload for a few
+ * aggregating actions (notably: quantize(), lquantize(), and ustack()).
+ */
+#define DTRACEACT_AGGREGATION 0x0700
+#define DTRACEAGG_COUNT (DTRACEACT_AGGREGATION + 1)
+#define DTRACEAGG_MIN (DTRACEACT_AGGREGATION + 2)
+#define DTRACEAGG_MAX (DTRACEACT_AGGREGATION + 3)
+#define DTRACEAGG_AVG (DTRACEACT_AGGREGATION + 4)
+#define DTRACEAGG_SUM (DTRACEACT_AGGREGATION + 5)
+#define DTRACEAGG_STDDEV (DTRACEACT_AGGREGATION + 6)
+#define DTRACEAGG_QUANTIZE (DTRACEACT_AGGREGATION + 7)
+#define DTRACEAGG_LQUANTIZE (DTRACEACT_AGGREGATION + 8)
+
+#define DTRACEACT_ISAGG(x) \
+ (DTRACEACT_CLASS(x) == DTRACEACT_AGGREGATION)
+
+#define DTRACE_QUANTIZE_NBUCKETS \
+ (((sizeof (uint64_t) * NBBY) - 1) * 2 + 1)
+
+#define DTRACE_QUANTIZE_ZEROBUCKET (VBDTCAST(int)(sizeof (uint64_t) * NBBY) - 1)
+
+#define DTRACE_QUANTIZE_BUCKETVAL(buck) \
+ (int64_t)((buck) < DTRACE_QUANTIZE_ZEROBUCKET ? \
+ -(1LL << (DTRACE_QUANTIZE_ZEROBUCKET - 1 - (buck))) : \
+ (buck) == DTRACE_QUANTIZE_ZEROBUCKET ? 0 : \
+ 1LL << ((buck) - DTRACE_QUANTIZE_ZEROBUCKET - 1))
+
+#define DTRACE_LQUANTIZE_STEPSHIFT 48
+#define DTRACE_LQUANTIZE_STEPMASK ((uint64_t)UINT16_MAX << 48)
+#define DTRACE_LQUANTIZE_LEVELSHIFT 32
+#define DTRACE_LQUANTIZE_LEVELMASK ((uint64_t)UINT16_MAX << 32)
+#define DTRACE_LQUANTIZE_BASESHIFT 0
+#define DTRACE_LQUANTIZE_BASEMASK UINT32_MAX
+
+#define DTRACE_LQUANTIZE_STEP(x) \
+ (uint16_t)(((x) & DTRACE_LQUANTIZE_STEPMASK) >> \
+ DTRACE_LQUANTIZE_STEPSHIFT)
+
+#define DTRACE_LQUANTIZE_LEVELS(x) \
+ (uint16_t)(((x) & DTRACE_LQUANTIZE_LEVELMASK) >> \
+ DTRACE_LQUANTIZE_LEVELSHIFT)
+
+#define DTRACE_LQUANTIZE_BASE(x) \
+ (int32_t)(((x) & DTRACE_LQUANTIZE_BASEMASK) >> \
+ DTRACE_LQUANTIZE_BASESHIFT)
+
+#define DTRACE_USTACK_NFRAMES(x) (uint32_t)((x) & UINT32_MAX)
+#define DTRACE_USTACK_STRSIZE(x) (uint32_t)((x) >> 32)
+#define DTRACE_USTACK_ARG(x, y) \
+ ((((uint64_t)(y)) << 32) | ((x) & UINT32_MAX))
+
+#ifndef _LP64
+#ifndef _LITTLE_ENDIAN
+#define DTRACE_PTR(type, name) uint32_t name##pad; type *name
+#else
+#define DTRACE_PTR(type, name) type *name; uint32_t name##pad
+#endif
+#else
+#define DTRACE_PTR(type, name) type *name
+#endif
+
+/*
+ * DTrace Object Format (DOF)
+ *
+ * DTrace programs can be persistently encoded in the DOF format so that they
+ * may be embedded in other programs (for example, in an ELF file) or in the
+ * dtrace driver configuration file for use in anonymous tracing. The DOF
+ * format is versioned and extensible so that it can be revised and so that
+ * internal data structures can be modified or extended compatibly. All DOF
+ * structures use fixed-size types, so the 32-bit and 64-bit representations
+ * are identical and consumers can use either data model transparently.
+ *
+ * The file layout is structured as follows:
+ *
+ * +---------------+-------------------+----- ... ----+---- ... ------+
+ * | dof_hdr_t | dof_sec_t[ ... ] | loadable | non-loadable |
+ * | (file header) | (section headers) | section data | section data |
+ * +---------------+-------------------+----- ... ----+---- ... ------+
+ * |<------------ dof_hdr.dofh_loadsz --------------->| |
+ * |<------------ dof_hdr.dofh_filesz ------------------------------->|
+ *
+ * The file header stores meta-data including a magic number, data model for
+ * the instrumentation, data encoding, and properties of the DIF code within.
+ * The header describes its own size and the size of the section headers. By
+ * convention, an array of section headers follows the file header, and then
+ * the data for all loadable sections and unloadable sections. This permits
+ * consumer code to easily download the headers and all loadable data into the
+ * DTrace driver in one contiguous chunk, omitting other extraneous sections.
+ *
+ * The section headers describe the size, offset, alignment, and section type
+ * for each section. Sections are described using a set of #defines that tell
+ * the consumer what kind of data is expected. Sections can contain links to
+ * other sections by storing a dof_secidx_t, an index into the section header
+ * array, inside of the section data structures. The section header includes
+ * an entry size so that sections with data arrays can grow their structures.
+ *
+ * The DOF data itself can contain many snippets of DIF (i.e. >1 DIFOs), which
+ * are represented themselves as a collection of related DOF sections. This
+ * permits us to change the set of sections associated with a DIFO over time,
+ * and also permits us to encode DIFOs that contain different sets of sections.
+ * When a DOF section wants to refer to a DIFO, it stores the dof_secidx_t of a
+ * section of type DOF_SECT_DIFOHDR. This section's data is then an array of
+ * dof_secidx_t's which in turn denote the sections associated with this DIFO.
+ *
+ * This loose coupling of the file structure (header and sections) to the
+ * structure of the DTrace program itself (ECB descriptions, action
+ * descriptions, and DIFOs) permits activities such as relocation processing
+ * to occur in a single pass without having to understand D program structure.
+ *
+ * Finally, strings are always stored in ELF-style string tables along with a
+ * string table section index and string table offset. Therefore strings in
+ * DOF are always arbitrary-length and not bound to the current implementation.
+ */
+
+#define DOF_ID_SIZE 16 /* total size of dofh_ident[] in bytes */
+
+typedef struct dof_hdr {
+ uint8_t dofh_ident[DOF_ID_SIZE]; /* identification bytes (see below) */
+ uint32_t dofh_flags; /* file attribute flags (if any) */
+ uint32_t dofh_hdrsize; /* size of file header in bytes */
+ uint32_t dofh_secsize; /* size of section header in bytes */
+ uint32_t dofh_secnum; /* number of section headers */
+ uint64_t dofh_secoff; /* file offset of section headers */
+ uint64_t dofh_loadsz; /* file size of loadable portion */
+ uint64_t dofh_filesz; /* file size of entire DOF file */
+ uint64_t dofh_pad; /* reserved for future use */
+} dof_hdr_t;
+
+#define DOF_ID_MAG0 0 /* first byte of magic number */
+#define DOF_ID_MAG1 1 /* second byte of magic number */
+#define DOF_ID_MAG2 2 /* third byte of magic number */
+#define DOF_ID_MAG3 3 /* fourth byte of magic number */
+#define DOF_ID_MODEL 4 /* DOF data model (see below) */
+#define DOF_ID_ENCODING 5 /* DOF data encoding (see below) */
+#define DOF_ID_VERSION 6 /* DOF file format major version (see below) */
+#define DOF_ID_DIFVERS 7 /* DIF instruction set version */
+#define DOF_ID_DIFIREG 8 /* DIF integer registers used by compiler */
+#define DOF_ID_DIFTREG 9 /* DIF tuple registers used by compiler */
+#define DOF_ID_PAD 10 /* start of padding bytes (all zeroes) */
+
+#define DOF_MAG_MAG0 0x7F /* DOF_ID_MAG[0-3] */
+#define DOF_MAG_MAG1 'D'
+#define DOF_MAG_MAG2 'O'
+#define DOF_MAG_MAG3 'F'
+
+#define DOF_MAG_STRING "\177DOF"
+#define DOF_MAG_STRLEN 4
+
+#define DOF_MODEL_NONE 0 /* DOF_ID_MODEL */
+#define DOF_MODEL_ILP32 1
+#define DOF_MODEL_LP64 2
+
+#ifdef _LP64
+#define DOF_MODEL_NATIVE DOF_MODEL_LP64
+#else
+#define DOF_MODEL_NATIVE DOF_MODEL_ILP32
+#endif
+
+#define DOF_ENCODE_NONE 0 /* DOF_ID_ENCODING */
+#define DOF_ENCODE_LSB 1
+#define DOF_ENCODE_MSB 2
+
+#ifdef _BIG_ENDIAN
+#define DOF_ENCODE_NATIVE DOF_ENCODE_MSB
+#else
+#define DOF_ENCODE_NATIVE DOF_ENCODE_LSB
+#endif
+
+#define DOF_VERSION_1 1 /* DOF version 1: Solaris 10 FCS */
+#define DOF_VERSION_2 2 /* DOF version 2: Solaris Express 6/06 */
+#define DOF_VERSION DOF_VERSION_2 /* Latest DOF version */
+
+#define DOF_FL_VALID 0 /* mask of all valid dofh_flags bits */
+
+typedef uint32_t dof_secidx_t; /* section header table index type */
+typedef uint32_t dof_stridx_t; /* string table index type */
+
+#define DOF_SECIDX_NONE (~1U) /* null value for section indices */
+#define DOF_STRIDX_NONE (~1U) /* null value for string indices */
+
+typedef struct dof_sec {
+ uint32_t dofs_type; /* section type (see below) */
+ uint32_t dofs_align; /* section data memory alignment */
+ uint32_t dofs_flags; /* section flags (if any) */
+ uint32_t dofs_entsize; /* size of section entry (if table) */
+ uint64_t dofs_offset; /* offset of section data within file */
+ uint64_t dofs_size; /* size of section data in bytes */
+} dof_sec_t;
+
+#define DOF_SECT_NONE 0 /* null section */
+#define DOF_SECT_COMMENTS 1 /* compiler comments */
+#define DOF_SECT_SOURCE 2 /* D program source code */
+#define DOF_SECT_ECBDESC 3 /* dof_ecbdesc_t */
+#define DOF_SECT_PROBEDESC 4 /* dof_probedesc_t */
+#define DOF_SECT_ACTDESC 5 /* dof_actdesc_t array */
+#define DOF_SECT_DIFOHDR 6 /* dof_difohdr_t (variable length) */
+#define DOF_SECT_DIF 7 /* uint32_t array of byte code */
+#define DOF_SECT_STRTAB 8 /* string table */
+#define DOF_SECT_VARTAB 9 /* dtrace_difv_t array */
+#define DOF_SECT_RELTAB 10 /* dof_relodesc_t array */
+#define DOF_SECT_TYPTAB 11 /* dtrace_diftype_t array */
+#define DOF_SECT_URELHDR 12 /* dof_relohdr_t (user relocations) */
+#define DOF_SECT_KRELHDR 13 /* dof_relohdr_t (kernel relocations) */
+#define DOF_SECT_OPTDESC 14 /* dof_optdesc_t array */
+#define DOF_SECT_PROVIDER 15 /* dof_provider_t */
+#define DOF_SECT_PROBES 16 /* dof_probe_t array */
+#define DOF_SECT_PRARGS 17 /* uint8_t array (probe arg mappings) */
+#define DOF_SECT_PROFFS 18 /* uint32_t array (probe arg offsets) */
+#define DOF_SECT_INTTAB 19 /* uint64_t array */
+#define DOF_SECT_UTSNAME 20 /* struct utsname */
+#define DOF_SECT_XLTAB 21 /* dof_xlref_t array */
+#define DOF_SECT_XLMEMBERS 22 /* dof_xlmember_t array */
+#define DOF_SECT_XLIMPORT 23 /* dof_xlator_t */
+#define DOF_SECT_XLEXPORT 24 /* dof_xlator_t */
+#define DOF_SECT_PREXPORT 25 /* dof_secidx_t array (exported objs) */
+#define DOF_SECT_PRENOFFS 26 /* uint32_t array (enabled offsets) */
+
+#define DOF_SECF_LOAD 1 /* section should be loaded */
+
+#define DOF_SEC_ISLOADABLE(x) \
+ (((x) == DOF_SECT_ECBDESC) || ((x) == DOF_SECT_PROBEDESC) || \
+ ((x) == DOF_SECT_ACTDESC) || ((x) == DOF_SECT_DIFOHDR) || \
+ ((x) == DOF_SECT_DIF) || ((x) == DOF_SECT_STRTAB) || \
+ ((x) == DOF_SECT_VARTAB) || ((x) == DOF_SECT_RELTAB) || \
+ ((x) == DOF_SECT_TYPTAB) || ((x) == DOF_SECT_URELHDR) || \
+ ((x) == DOF_SECT_KRELHDR) || ((x) == DOF_SECT_OPTDESC) || \
+ ((x) == DOF_SECT_PROVIDER) || ((x) == DOF_SECT_PROBES) || \
+ ((x) == DOF_SECT_PRARGS) || ((x) == DOF_SECT_PROFFS) || \
+ ((x) == DOF_SECT_INTTAB) || ((x) == DOF_SECT_XLTAB) || \
+ ((x) == DOF_SECT_XLMEMBERS) || ((x) == DOF_SECT_XLIMPORT) || \
+ ((x) == DOF_SECT_XLIMPORT) || ((x) == DOF_SECT_XLEXPORT) || \
+ ((x) == DOF_SECT_PREXPORT) || ((x) == DOF_SECT_PRENOFFS))
+
+typedef struct dof_ecbdesc {
+ dof_secidx_t dofe_probes; /* link to DOF_SECT_PROBEDESC */
+ dof_secidx_t dofe_pred; /* link to DOF_SECT_DIFOHDR */
+ dof_secidx_t dofe_actions; /* link to DOF_SECT_ACTDESC */
+ uint32_t dofe_pad; /* reserved for future use */
+ uint64_t dofe_uarg; /* user-supplied library argument */
+} dof_ecbdesc_t;
+
+typedef struct dof_probedesc {
+ dof_secidx_t dofp_strtab; /* link to DOF_SECT_STRTAB section */
+ dof_stridx_t dofp_provider; /* provider string */
+ dof_stridx_t dofp_mod; /* module string */
+ dof_stridx_t dofp_func; /* function string */
+ dof_stridx_t dofp_name; /* name string */
+ uint32_t dofp_id; /* probe identifier (or zero) */
+} dof_probedesc_t;
+
+typedef struct dof_actdesc {
+ dof_secidx_t dofa_difo; /* link to DOF_SECT_DIFOHDR */
+ dof_secidx_t dofa_strtab; /* link to DOF_SECT_STRTAB section */
+ uint32_t dofa_kind; /* action kind (DTRACEACT_* constant) */
+ uint32_t dofa_ntuple; /* number of subsequent tuple actions */
+ uint64_t dofa_arg; /* kind-specific argument */
+ uint64_t dofa_uarg; /* user-supplied argument */
+} dof_actdesc_t;
+
+typedef struct dof_difohdr {
+ dtrace_diftype_t dofd_rtype; /* return type for this fragment */
+ dof_secidx_t dofd_links[1]; /* variable length array of indices */
+} dof_difohdr_t;
+
+typedef struct dof_relohdr {
+ dof_secidx_t dofr_strtab; /* link to DOF_SECT_STRTAB for names */
+ dof_secidx_t dofr_relsec; /* link to DOF_SECT_RELTAB for relos */
+ dof_secidx_t dofr_tgtsec; /* link to section we are relocating */
+} dof_relohdr_t;
+
+typedef struct dof_relodesc {
+ dof_stridx_t dofr_name; /* string name of relocation symbol */
+ uint32_t dofr_type; /* relo type (DOF_RELO_* constant) */
+ uint64_t dofr_offset; /* byte offset for relocation */
+ uint64_t dofr_data; /* additional type-specific data */
+} dof_relodesc_t;
+
+#define DOF_RELO_NONE 0 /* empty relocation entry */
+#define DOF_RELO_SETX 1 /* relocate setx value */
+
+typedef struct dof_optdesc {
+ uint32_t dofo_option; /* option identifier */
+ dof_secidx_t dofo_strtab; /* string table, if string option */
+ uint64_t dofo_value; /* option value or string index */
+} dof_optdesc_t;
+
+typedef uint32_t dof_attr_t; /* encoded stability attributes */
+
+#define DOF_ATTR(n, d, c) (((n) << 24) | ((d) << 16) | ((c) << 8))
+#define DOF_ATTR_NAME(a) (((a) >> 24) & 0xff)
+#define DOF_ATTR_DATA(a) (((a) >> 16) & 0xff)
+#define DOF_ATTR_CLASS(a) (((a) >> 8) & 0xff)
+
+typedef struct dof_provider {
+ dof_secidx_t dofpv_strtab; /* link to DOF_SECT_STRTAB section */
+ dof_secidx_t dofpv_probes; /* link to DOF_SECT_PROBES section */
+ dof_secidx_t dofpv_prargs; /* link to DOF_SECT_PRARGS section */
+ dof_secidx_t dofpv_proffs; /* link to DOF_SECT_PROFFS section */
+ dof_stridx_t dofpv_name; /* provider name string */
+ dof_attr_t dofpv_provattr; /* provider attributes */
+ dof_attr_t dofpv_modattr; /* module attributes */
+ dof_attr_t dofpv_funcattr; /* function attributes */
+ dof_attr_t dofpv_nameattr; /* name attributes */
+ dof_attr_t dofpv_argsattr; /* args attributes */
+ dof_secidx_t dofpv_prenoffs; /* link to DOF_SECT_PRENOFFS section */
+} dof_provider_t;
+
+typedef struct dof_probe {
+ uint64_t dofpr_addr; /* probe base address or offset */
+ dof_stridx_t dofpr_func; /* probe function string */
+ dof_stridx_t dofpr_name; /* probe name string */
+ dof_stridx_t dofpr_nargv; /* native argument type strings */
+ dof_stridx_t dofpr_xargv; /* translated argument type strings */
+ uint32_t dofpr_argidx; /* index of first argument mapping */
+ uint32_t dofpr_offidx; /* index of first offset entry */
+ uint8_t dofpr_nargc; /* native argument count */
+ uint8_t dofpr_xargc; /* translated argument count */
+ uint16_t dofpr_noffs; /* number of offset entries for probe */
+ uint32_t dofpr_enoffidx; /* index of first is-enabled offset */
+ uint16_t dofpr_nenoffs; /* number of is-enabled offsets */
+ uint16_t dofpr_pad1; /* reserved for future use */
+ uint32_t dofpr_pad2; /* reserved for future use */
+} dof_probe_t;
+
+typedef struct dof_xlator {
+ dof_secidx_t dofxl_members; /* link to DOF_SECT_XLMEMBERS section */
+ dof_secidx_t dofxl_strtab; /* link to DOF_SECT_STRTAB section */
+ dof_stridx_t dofxl_argv; /* input parameter type strings */
+ uint32_t dofxl_argc; /* input parameter list length */
+ dof_stridx_t dofxl_type; /* output type string name */
+ dof_attr_t dofxl_attr; /* output stability attributes */
+} dof_xlator_t;
+
+typedef struct dof_xlmember {
+ dof_secidx_t dofxm_difo; /* member link to DOF_SECT_DIFOHDR */
+ dof_stridx_t dofxm_name; /* member name */
+ dtrace_diftype_t dofxm_type; /* member type */
+} dof_xlmember_t;
+
+typedef struct dof_xlref {
+ dof_secidx_t dofxr_xlator; /* link to DOF_SECT_XLATORS section */
+ uint32_t dofxr_member; /* index of referenced dof_xlmember */
+ uint32_t dofxr_argn; /* index of argument for DIF_OP_XLARG */
+} dof_xlref_t;
+
+/*
+ * DTrace Intermediate Format Object (DIFO)
+ *
+ * A DIFO is used to store the compiled DIF for a D expression, its return
+ * type, and its string and variable tables. The string table is a single
+ * buffer of character data into which sets instructions and variable
+ * references can reference strings using a byte offset. The variable table
+ * is an array of dtrace_difv_t structures that describe the name and type of
+ * each variable and the id used in the DIF code. This structure is described
+ * above in the DIF section of this header file. The DIFO is used at both
+ * user-level (in the library) and in the kernel, but the structure is never
+ * passed between the two: the DOF structures form the only interface. As a
+ * result, the definition can change depending on the presence of _KERNEL.
+ */
+typedef struct dtrace_difo {
+ dif_instr_t *dtdo_buf; /* instruction buffer */
+ uint64_t *dtdo_inttab; /* integer table (optional) */
+ char *dtdo_strtab; /* string table (optional) */
+ dtrace_difv_t *dtdo_vartab; /* variable table (optional) */
+ uint_t dtdo_len; /* length of instruction buffer */
+ uint_t dtdo_intlen; /* length of integer table */
+ uint_t dtdo_strlen; /* length of string table */
+ uint_t dtdo_varlen; /* length of variable table */
+ dtrace_diftype_t dtdo_rtype; /* return type */
+ uint_t dtdo_refcnt; /* owner reference count */
+ uint_t dtdo_destructive; /* invokes destructive subroutines */
+#if !defined(_KERNEL) || defined(IN_RING3)
+ dof_relodesc_t *dtdo_kreltab; /* kernel relocations */
+ dof_relodesc_t *dtdo_ureltab; /* user relocations */
+ struct dt_node **dtdo_xlmtab; /* translator references */
+ uint_t dtdo_krelen; /* length of krelo table */
+ uint_t dtdo_urelen; /* length of urelo table */
+ uint_t dtdo_xlmlen; /* length of translator table */
+#endif
+} dtrace_difo_t;
+
+/*
+ * DTrace Enabling Description Structures
+ *
+ * When DTrace is tracking the description of a DTrace enabling entity (probe,
+ * predicate, action, ECB, record, etc.), it does so in a description
+ * structure. These structures all end in "desc", and are used at both
+ * user-level and in the kernel -- but (with the exception of
+ * dtrace_probedesc_t) they are never passed between them. Typically,
+ * user-level will use the description structures when assembling an enabling.
+ * It will then distill those description structures into a DOF object (see
+ * above), and send it into the kernel. The kernel will again use the
+ * description structures to create a description of the enabling as it reads
+ * the DOF. When the description is complete, the enabling will be actually
+ * created -- turning it into the structures that represent the enabling
+ * instead of merely describing it. Not surprisingly, the description
+ * structures bear a strong resemblance to the DOF structures that act as their
+ * conduit.
+ */
+struct dtrace_predicate;
+
+typedef struct dtrace_probedesc {
+ dtrace_id_t dtpd_id; /* probe identifier */
+ char dtpd_provider[DTRACE_PROVNAMELEN]; /* probe provider name */
+ char dtpd_mod[DTRACE_MODNAMELEN]; /* probe module name */
+ char dtpd_func[DTRACE_FUNCNAMELEN]; /* probe function name */
+ char dtpd_name[DTRACE_NAMELEN]; /* probe name */
+} dtrace_probedesc_t;
+
+typedef struct dtrace_repldesc {
+ dtrace_probedesc_t dtrpd_match; /* probe descr. to match */
+ dtrace_probedesc_t dtrpd_create; /* probe descr. to create */
+} dtrace_repldesc_t;
+
+typedef struct dtrace_preddesc {
+ dtrace_difo_t *dtpdd_difo; /* pointer to DIF object */
+ struct dtrace_predicate *dtpdd_predicate; /* pointer to predicate */
+} dtrace_preddesc_t;
+
+typedef struct dtrace_actdesc {
+ dtrace_difo_t *dtad_difo; /* pointer to DIF object */
+ struct dtrace_actdesc *dtad_next; /* next action */
+ dtrace_actkind_t dtad_kind; /* kind of action */
+ uint32_t dtad_ntuple; /* number in tuple */
+ uint64_t dtad_arg; /* action argument */
+ uint64_t dtad_uarg; /* user argument */
+ int dtad_refcnt; /* reference count */
+} dtrace_actdesc_t;
+
+typedef struct dtrace_ecbdesc {
+ dtrace_actdesc_t *dted_action; /* action description(s) */
+ dtrace_preddesc_t dted_pred; /* predicate description */
+ dtrace_probedesc_t dted_probe; /* probe description */
+ uint64_t dted_uarg; /* library argument */
+ int dted_refcnt; /* reference count */
+} dtrace_ecbdesc_t;
+
+/*
+ * DTrace Metadata Description Structures
+ *
+ * DTrace separates the trace data stream from the metadata stream. The only
+ * metadata tokens placed in the data stream are enabled probe identifiers
+ * (EPIDs) or (in the case of aggregations) aggregation identifiers. In order
+ * to determine the structure of the data, DTrace consumers pass the token to
+ * the kernel, and receive in return a corresponding description of the enabled
+ * probe (via the dtrace_eprobedesc structure) or the aggregation (via the
+ * dtrace_aggdesc structure). Both of these structures are expressed in terms
+ * of record descriptions (via the dtrace_recdesc structure) that describe the
+ * exact structure of the data. Some record descriptions may also contain a
+ * format identifier; this additional bit of metadata can be retrieved from the
+ * kernel, for which a format description is returned via the dtrace_fmtdesc
+ * structure. Note that all four of these structures must be bitness-neutral
+ * to allow for a 32-bit DTrace consumer on a 64-bit kernel.
+ */
+typedef struct dtrace_recdesc {
+ dtrace_actkind_t dtrd_action; /* kind of action */
+ uint32_t dtrd_size; /* size of record */
+ uint32_t dtrd_offset; /* offset in ECB's data */
+ uint16_t dtrd_alignment; /* required alignment */
+ uint16_t dtrd_format; /* format, if any */
+ uint64_t dtrd_arg; /* action argument */
+ uint64_t dtrd_uarg; /* user argument */
+} dtrace_recdesc_t;
+
+typedef struct dtrace_eprobedesc {
+ dtrace_epid_t dtepd_epid; /* enabled probe ID */
+ dtrace_id_t dtepd_probeid; /* probe ID */
+ uint64_t dtepd_uarg; /* library argument */
+ uint32_t dtepd_size; /* total size */
+ int dtepd_nrecs; /* number of records */
+ dtrace_recdesc_t dtepd_rec[1]; /* records themselves */
+} dtrace_eprobedesc_t;
+
+typedef struct dtrace_aggdesc {
+ DTRACE_PTR(char, dtagd_name); /* not filled in by kernel */
+ dtrace_aggvarid_t dtagd_varid; /* not filled in by kernel */
+ int dtagd_flags; /* not filled in by kernel */
+ dtrace_aggid_t dtagd_id; /* aggregation ID */
+ dtrace_epid_t dtagd_epid; /* enabled probe ID */
+ uint32_t dtagd_size; /* size in bytes */
+ int dtagd_nrecs; /* number of records */
+ uint32_t dtagd_pad; /* explicit padding */
+ dtrace_recdesc_t dtagd_rec[1]; /* record descriptions */
+} dtrace_aggdesc_t;
+
+typedef struct dtrace_fmtdesc {
+ DTRACE_PTR(char, dtfd_string); /* format string */
+ int dtfd_length; /* length of format string */
+ uint16_t dtfd_format; /* format identifier */
+} dtrace_fmtdesc_t;
+
+#define DTRACE_SIZEOF_EPROBEDESC(desc) \
+ (sizeof (dtrace_eprobedesc_t) + ((desc)->dtepd_nrecs ? \
+ (((desc)->dtepd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
+
+#define DTRACE_SIZEOF_AGGDESC(desc) \
+ (sizeof (dtrace_aggdesc_t) + ((desc)->dtagd_nrecs ? \
+ (((desc)->dtagd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
+
+/*
+ * DTrace Option Interface
+ *
+ * Run-time DTrace options are set and retrieved via DOF_SECT_OPTDESC sections
+ * in a DOF image. The dof_optdesc structure contains an option identifier and
+ * an option value. The valid option identifiers are found below; the mapping
+ * between option identifiers and option identifying strings is maintained at
+ * user-level. Note that the value of DTRACEOPT_UNSET is such that all of the
+ * following are potentially valid option values: all positive integers, zero
+ * and negative one. Some options (notably "bufpolicy" and "bufresize") take
+ * predefined tokens as their values; these are defined with
+ * DTRACEOPT_{option}_{token}.
+ */
+#define DTRACEOPT_BUFSIZE 0 /* buffer size */
+#define DTRACEOPT_BUFPOLICY 1 /* buffer policy */
+#define DTRACEOPT_DYNVARSIZE 2 /* dynamic variable size */
+#define DTRACEOPT_AGGSIZE 3 /* aggregation size */
+#define DTRACEOPT_SPECSIZE 4 /* speculation size */
+#define DTRACEOPT_NSPEC 5 /* number of speculations */
+#define DTRACEOPT_STRSIZE 6 /* string size */
+#define DTRACEOPT_CLEANRATE 7 /* dynvar cleaning rate */
+#define DTRACEOPT_CPU 8 /* CPU to trace */
+#define DTRACEOPT_BUFRESIZE 9 /* buffer resizing policy */
+#define DTRACEOPT_GRABANON 10 /* grab anonymous state, if any */
+#define DTRACEOPT_FLOWINDENT 11 /* indent function entry/return */
+#define DTRACEOPT_QUIET 12 /* only output explicitly traced data */
+#define DTRACEOPT_STACKFRAMES 13 /* number of stack frames */
+#define DTRACEOPT_USTACKFRAMES 14 /* number of user stack frames */
+#define DTRACEOPT_AGGRATE 15 /* aggregation snapshot rate */
+#define DTRACEOPT_SWITCHRATE 16 /* buffer switching rate */
+#define DTRACEOPT_STATUSRATE 17 /* status rate */
+#define DTRACEOPT_DESTRUCTIVE 18 /* destructive actions allowed */
+#define DTRACEOPT_STACKINDENT 19 /* output indent for stack traces */
+#define DTRACEOPT_RAWBYTES 20 /* always print bytes in raw form */
+#define DTRACEOPT_JSTACKFRAMES 21 /* number of jstack() frames */
+#define DTRACEOPT_JSTACKSTRSIZE 22 /* size of jstack() string table */
+#define DTRACEOPT_AGGSORTKEY 23 /* sort aggregations by key */
+#define DTRACEOPT_AGGSORTREV 24 /* reverse-sort aggregations */
+#define DTRACEOPT_AGGSORTPOS 25 /* agg. position to sort on */
+#define DTRACEOPT_AGGSORTKEYPOS 26 /* agg. key position to sort on */
+#define DTRACEOPT_MAX 27 /* number of options */
+
+#define DTRACEOPT_UNSET (dtrace_optval_t)-2 /* unset option */
+
+#define DTRACEOPT_BUFPOLICY_RING 0 /* ring buffer */
+#define DTRACEOPT_BUFPOLICY_FILL 1 /* fill buffer, then stop */
+#define DTRACEOPT_BUFPOLICY_SWITCH 2 /* switch buffers */
+
+#define DTRACEOPT_BUFRESIZE_AUTO 0 /* automatic resizing */
+#define DTRACEOPT_BUFRESIZE_MANUAL 1 /* manual resizing */
+
+/*
+ * DTrace Buffer Interface
+ *
+ * In order to get a snapshot of the principal or aggregation buffer,
+ * user-level passes a buffer description to the kernel with the dtrace_bufdesc
+ * structure. This describes which CPU user-level is interested in, and
+ * where user-level wishes the kernel to snapshot the buffer to (the
+ * dtbd_data field). The kernel uses the same structure to pass back some
+ * information regarding the buffer: the size of data actually copied out, the
+ * number of drops, the number of errors, and the offset of the oldest record.
+ * If the buffer policy is a "switch" policy, taking a snapshot of the
+ * principal buffer has the additional effect of switching the active and
+ * inactive buffers. Taking a snapshot of the aggregation buffer _always_ has
+ * the additional effect of switching the active and inactive buffers.
+ */
+typedef struct dtrace_bufdesc {
+ uint64_t dtbd_size; /* size of buffer */
+ uint32_t dtbd_cpu; /* CPU or DTRACE_CPUALL */
+ uint32_t dtbd_errors; /* number of errors */
+ uint64_t dtbd_drops; /* number of drops */
+ DTRACE_PTR(char, dtbd_data); /* data */
+ uint64_t dtbd_oldest; /* offset of oldest record */
+} dtrace_bufdesc_t;
+
+/*
+ * DTrace Status
+ *
+ * The status of DTrace is relayed via the dtrace_status structure. This
+ * structure contains members to count drops other than the capacity drops
+ * available via the buffer interface (see above). This consists of dynamic
+ * drops (including capacity dynamic drops, rinsing drops and dirty drops), and
+ * speculative drops (including capacity speculative drops, drops due to busy
+ * speculative buffers and drops due to unavailable speculative buffers).
+ * Additionally, the status structure contains a field to indicate the number
+ * of "fill"-policy buffers have been filled and a boolean field to indicate
+ * that exit() has been called. If the dtst_exiting field is non-zero, no
+ * further data will be generated until tracing is stopped (at which time any
+ * enablings of the END action will be processed); if user-level sees that
+ * this field is non-zero, tracing should be stopped as soon as possible.
+ */
+typedef struct dtrace_status {
+ uint64_t dtst_dyndrops; /* dynamic drops */
+ uint64_t dtst_dyndrops_rinsing; /* dyn drops due to rinsing */
+ uint64_t dtst_dyndrops_dirty; /* dyn drops due to dirty */
+ uint64_t dtst_specdrops; /* speculative drops */
+ uint64_t dtst_specdrops_busy; /* spec drops due to busy */
+ uint64_t dtst_specdrops_unavail; /* spec drops due to unavail */
+ uint64_t dtst_errors; /* total errors */
+ uint64_t dtst_filled; /* number of filled bufs */
+ uint64_t dtst_stkstroverflows; /* stack string tab overflows */
+ uint64_t dtst_dblerrors; /* errors in ERROR probes */
+ char dtst_killed; /* non-zero if killed */
+ char dtst_exiting; /* non-zero if exit() called */
+ char dtst_pad[6]; /* pad out to 64-bit align */
+} dtrace_status_t;
+
+/*
+ * DTrace Configuration
+ *
+ * User-level may need to understand some elements of the kernel DTrace
+ * configuration in order to generate correct DIF. This information is
+ * conveyed via the dtrace_conf structure.
+ */
+typedef struct dtrace_conf {
+ uint_t dtc_difversion; /* supported DIF version */
+ uint_t dtc_difintregs; /* # of DIF integer registers */
+ uint_t dtc_diftupregs; /* # of DIF tuple registers */
+ uint_t dtc_ctfmodel; /* CTF data model */
+ uint_t dtc_pad[8]; /* reserved for future use */
+} dtrace_conf_t;
+
+/*
+ * DTrace Faults
+ *
+ * The constants below DTRACEFLT_LIBRARY indicate probe processing faults;
+ * constants at or above DTRACEFLT_LIBRARY indicate faults in probe
+ * postprocessing at user-level. Probe processing faults induce an ERROR
+ * probe and are replicated in unistd.d to allow users' ERROR probes to decode
+ * the error condition using thse symbolic labels.
+ */
+#define DTRACEFLT_UNKNOWN 0 /* Unknown fault */
+#define DTRACEFLT_BADADDR 1 /* Bad address */
+#define DTRACEFLT_BADALIGN 2 /* Bad alignment */
+#define DTRACEFLT_ILLOP 3 /* Illegal operation */
+#define DTRACEFLT_DIVZERO 4 /* Divide-by-zero */
+#define DTRACEFLT_NOSCRATCH 5 /* Out of scratch space */
+#define DTRACEFLT_KPRIV 6 /* Illegal kernel access */
+#define DTRACEFLT_UPRIV 7 /* Illegal user access */
+#define DTRACEFLT_TUPOFLOW 8 /* Tuple stack overflow */
+#define DTRACEFLT_BADSTACK 9 /* Bad stack */
+
+#define DTRACEFLT_LIBRARY 1000 /* Library-level fault */
+
+/*
+ * DTrace Argument Types
+ *
+ * Because it would waste both space and time, argument types do not reside
+ * with the probe. In order to determine argument types for args[X]
+ * variables, the D compiler queries for argument types on a probe-by-probe
+ * basis. (This optimizes for the common case that arguments are either not
+ * used or used in an untyped fashion.) Typed arguments are specified with a
+ * string of the type name in the dtragd_native member of the argument
+ * description structure. Typed arguments may be further translated to types
+ * of greater stability; the provider indicates such a translated argument by
+ * filling in the dtargd_xlate member with the string of the translated type.
+ * Finally, the provider may indicate which argument value a given argument
+ * maps to by setting the dtargd_mapping member -- allowing a single argument
+ * to map to multiple args[X] variables.
+ */
+typedef struct dtrace_argdesc {
+ dtrace_id_t dtargd_id; /* probe identifier */
+ int dtargd_ndx; /* arg number (-1 iff none) */
+ int dtargd_mapping; /* value mapping */
+ char dtargd_native[DTRACE_ARGTYPELEN]; /* native type name */
+ char dtargd_xlate[DTRACE_ARGTYPELEN]; /* translated type name */
+} dtrace_argdesc_t;
+
+/*
+ * DTrace Stability Attributes
+ *
+ * Each DTrace provider advertises the name and data stability of each of its
+ * probe description components, as well as its architectural dependencies.
+ * The D compiler can query the provider attributes (dtrace_pattr_t below) in
+ * order to compute the properties of an input program and report them.
+ */
+typedef uint8_t dtrace_stability_t; /* stability code (see attributes(5)) */
+typedef uint8_t dtrace_class_t; /* architectural dependency class */
+
+#define DTRACE_STABILITY_INTERNAL 0 /* private to DTrace itself */
+#define DTRACE_STABILITY_PRIVATE 1 /* private to Sun (see docs) */
+#define DTRACE_STABILITY_OBSOLETE 2 /* scheduled for removal */
+#define DTRACE_STABILITY_EXTERNAL 3 /* not controlled by Sun */
+#define DTRACE_STABILITY_UNSTABLE 4 /* new or rapidly changing */
+#define DTRACE_STABILITY_EVOLVING 5 /* less rapidly changing */
+#define DTRACE_STABILITY_STABLE 6 /* mature interface from Sun */
+#define DTRACE_STABILITY_STANDARD 7 /* industry standard */
+#define DTRACE_STABILITY_MAX 7 /* maximum valid stability */
+
+#define DTRACE_CLASS_UNKNOWN 0 /* unknown architectural dependency */
+#define DTRACE_CLASS_CPU 1 /* CPU-module-specific */
+#define DTRACE_CLASS_PLATFORM 2 /* platform-specific (uname -i) */
+#define DTRACE_CLASS_GROUP 3 /* hardware-group-specific (uname -m) */
+#define DTRACE_CLASS_ISA 4 /* ISA-specific (uname -p) */
+#define DTRACE_CLASS_COMMON 5 /* common to all systems */
+#define DTRACE_CLASS_MAX 5 /* maximum valid class */
+
+#define DTRACE_PRIV_NONE 0x0000
+#define DTRACE_PRIV_KERNEL 0x0001
+#define DTRACE_PRIV_USER 0x0002
+#define DTRACE_PRIV_PROC 0x0004
+#define DTRACE_PRIV_OWNER 0x0008
+#define DTRACE_PRIV_ZONEOWNER 0x0010
+
+#define DTRACE_PRIV_ALL \
+ (DTRACE_PRIV_KERNEL | DTRACE_PRIV_USER | \
+ DTRACE_PRIV_PROC | DTRACE_PRIV_OWNER | DTRACE_PRIV_ZONEOWNER)
+
+typedef struct dtrace_ppriv {
+ uint32_t dtpp_flags; /* privilege flags */
+ uid_t dtpp_uid; /* user ID */
+ zoneid_t dtpp_zoneid; /* zone ID */
+} dtrace_ppriv_t;
+
+typedef struct dtrace_attribute {
+ dtrace_stability_t dtat_name; /* entity name stability */
+ dtrace_stability_t dtat_data; /* entity data stability */
+ dtrace_class_t dtat_class; /* entity data dependency */
+} dtrace_attribute_t;
+
+typedef struct dtrace_pattr {
+ dtrace_attribute_t dtpa_provider; /* provider attributes */
+ dtrace_attribute_t dtpa_mod; /* module attributes */
+ dtrace_attribute_t dtpa_func; /* function attributes */
+ dtrace_attribute_t dtpa_name; /* name attributes */
+ dtrace_attribute_t dtpa_args; /* args[] attributes */
+} dtrace_pattr_t;
+
+typedef struct dtrace_providerdesc {
+ char dtvd_name[DTRACE_PROVNAMELEN]; /* provider name */
+ dtrace_pattr_t dtvd_attr; /* stability attributes */
+ dtrace_ppriv_t dtvd_priv; /* privileges required */
+} dtrace_providerdesc_t;
+
+/*
+ * DTrace Pseudodevice Interface
+ *
+ * DTrace is controlled through ioctl(2)'s to the in-kernel dtrace:dtrace
+ * pseudodevice driver. These ioctls comprise the user-kernel interface to
+ * DTrace.
+ */
+#define DTRACEIOC (('d' << 24) | ('t' << 16) | ('r' << 8))
+#define DTRACEIOC_PROVIDER (DTRACEIOC | 1) /* provider query */
+#define DTRACEIOC_PROBES (DTRACEIOC | 2) /* probe query */
+#define DTRACEIOC_BUFSNAP (DTRACEIOC | 4) /* snapshot buffer */
+#define DTRACEIOC_PROBEMATCH (DTRACEIOC | 5) /* match probes */
+#define DTRACEIOC_ENABLE (DTRACEIOC | 6) /* enable probes */
+#define DTRACEIOC_AGGSNAP (DTRACEIOC | 7) /* snapshot agg. */
+#define DTRACEIOC_EPROBE (DTRACEIOC | 8) /* get eprobe desc. */
+#define DTRACEIOC_PROBEARG (DTRACEIOC | 9) /* get probe arg */
+#define DTRACEIOC_CONF (DTRACEIOC | 10) /* get config. */
+#define DTRACEIOC_STATUS (DTRACEIOC | 11) /* get status */
+#define DTRACEIOC_GO (DTRACEIOC | 12) /* start tracing */
+#define DTRACEIOC_STOP (DTRACEIOC | 13) /* stop tracing */
+#define DTRACEIOC_AGGDESC (DTRACEIOC | 15) /* get agg. desc. */
+#define DTRACEIOC_FORMAT (DTRACEIOC | 16) /* get format str */
+#define DTRACEIOC_DOFGET (DTRACEIOC | 17) /* get DOF */
+#define DTRACEIOC_REPLICATE (DTRACEIOC | 18) /* replicate enab */
+
+/*
+ * DTrace Helpers
+ *
+ * In general, DTrace establishes probes in processes and takes actions on
+ * processes without knowing their specific user-level structures. Instead of
+ * existing in the framework, process-specific knowledge is contained by the
+ * enabling D program -- which can apply process-specific knowledge by making
+ * appropriate use of DTrace primitives like copyin() and copyinstr() to
+ * operate on user-level data. However, there may exist some specific probes
+ * of particular semantic relevance that the application developer may wish to
+ * explicitly export. For example, an application may wish to export a probe
+ * at the point that it begins and ends certain well-defined transactions. In
+ * addition to providing probes, programs may wish to offer assistance for
+ * certain actions. For example, in highly dynamic environments (e.g., Java),
+ * it may be difficult to obtain a stack trace in terms of meaningful symbol
+ * names (the translation from instruction addresses to corresponding symbol
+ * names may only be possible in situ); these environments may wish to define
+ * a series of actions to be applied in situ to obtain a meaningful stack
+ * trace.
+ *
+ * These two mechanisms -- user-level statically defined tracing and assisting
+ * DTrace actions -- are provided via DTrace _helpers_. Helpers are specified
+ * via DOF, but unlike enabling DOF, helper DOF may contain definitions of
+ * providers, probes and their arguments. If a helper wishes to provide
+ * action assistance, probe descriptions and corresponding DIF actions may be
+ * specified in the helper DOF. For such helper actions, however, the probe
+ * description describes the specific helper: all DTrace helpers have the
+ * provider name "dtrace" and the module name "helper", and the name of the
+ * helper is contained in the function name (for example, the ustack() helper
+ * is named "ustack"). Any helper-specific name may be contained in the name
+ * (for example, if a helper were to have a constructor, it might be named
+ * "dtrace:helper:<helper>:init"). Helper actions are only called when the
+ * action that they are helping is taken. Helper actions may only return DIF
+ * expressions, and may only call the following subroutines:
+ *
+ * alloca() <= Allocates memory out of the consumer's scratch space
+ * bcopy() <= Copies memory to scratch space
+ * copyin() <= Copies memory from user-level into consumer's scratch
+ * copyinto() <= Copies memory into a specific location in scratch
+ * copyinstr() <= Copies a string into a specific location in scratch
+ *
+ * Helper actions may only access the following built-in variables:
+ *
+ * curthread <= Current kthread_t pointer
+ * tid <= Current thread identifier
+ * pid <= Current process identifier
+ * ppid <= Parent process identifier
+ * uid <= Current user ID
+ * gid <= Current group ID
+ * execname <= Current executable name
+ * zonename <= Current zone name
+ *
+ * Helper actions may not manipulate or allocate dynamic variables, but they
+ * may have clause-local and statically-allocated global variables. The
+ * helper action variable state is specific to the helper action -- variables
+ * used by the helper action may not be accessed outside of the helper
+ * action, and the helper action may not access variables that like outside
+ * of it. Helper actions may not load from kernel memory at-large; they are
+ * restricting to loading current user state (via copyin() and variants) and
+ * scratch space. As with probe enablings, helper actions are executed in
+ * program order. The result of the helper action is the result of the last
+ * executing helper expression.
+ *
+ * Helpers -- composed of either providers/probes or probes/actions (or both)
+ * -- are added by opening the "helper" minor node, and issuing an ioctl(2)
+ * (DTRACEHIOC_ADDDOF) that specifies the dof_helper_t structure. This
+ * encapsulates the name and base address of the user-level library or
+ * executable publishing the helpers and probes as well as the DOF that
+ * contains the definitions of those helpers and probes.
+ *
+ * The DTRACEHIOC_ADD and DTRACEHIOC_REMOVE are left in place for legacy
+ * helpers and should no longer be used. No other ioctls are valid on the
+ * helper minor node.
+ */
+#define DTRACEHIOC (('d' << 24) | ('t' << 16) | ('h' << 8))
+#define DTRACEHIOC_ADD (DTRACEHIOC | 1) /* add helper */
+#define DTRACEHIOC_REMOVE (DTRACEHIOC | 2) /* remove helper */
+#define DTRACEHIOC_ADDDOF (DTRACEHIOC | 3) /* add helper DOF */
+
+typedef struct dof_helper {
+ char dofhp_mod[DTRACE_MODNAMELEN]; /* executable or library name */
+ uint64_t dofhp_addr; /* base address of object */
+ uint64_t dofhp_dof; /* address of helper DOF */
+} dof_helper_t;
+
+#define DTRACEMNR_DTRACE "dtrace" /* node for DTrace ops */
+#define DTRACEMNR_HELPER "helper" /* node for helpers */
+#define DTRACEMNRN_DTRACE 0 /* minor for DTrace ops */
+#define DTRACEMNRN_HELPER 1 /* minor for helpers */
+#define DTRACEMNRN_CLONE 2 /* first clone minor */
+
+#if defined(_KERNEL) || defined(IN_RING0)
+
+/*
+ * DTrace Provider API
+ *
+ * The following functions are implemented by the DTrace framework and are
+ * used to implement separate in-kernel DTrace providers. Common functions
+ * are provided in uts/common/os/dtrace.c. ISA-dependent subroutines are
+ * defined in uts/<isa>/dtrace/dtrace_asm.s or uts/<isa>/dtrace/dtrace_isa.c.
+ *
+ * The provider API has two halves: the API that the providers consume from
+ * DTrace, and the API that providers make available to DTrace.
+ *
+ * 1 Framework-to-Provider API
+ *
+ * 1.1 Overview
+ *
+ * The Framework-to-Provider API is represented by the dtrace_pops structure
+ * that the provider passes to the framework when registering itself. This
+ * structure consists of the following members:
+ *
+ * dtps_provide() <-- Provide all probes, all modules
+ * dtps_provide_module() <-- Provide all probes in specified module
+ * dtps_enable() <-- Enable specified probe
+ * dtps_disable() <-- Disable specified probe
+ * dtps_suspend() <-- Suspend specified probe
+ * dtps_resume() <-- Resume specified probe
+ * dtps_getargdesc() <-- Get the argument description for args[X]
+ * dtps_getargval() <-- Get the value for an argX or args[X] variable
+ * dtps_usermode() <-- Find out if the probe was fired in user mode
+ * dtps_destroy() <-- Destroy all state associated with this probe
+ *
+ * 1.2 void dtps_provide(void *arg, const dtrace_probedesc_t *spec)
+ *
+ * 1.2.1 Overview
+ *
+ * Called to indicate that the provider should provide all probes. If the
+ * specified description is non-NULL, dtps_provide() is being called because
+ * no probe matched a specified probe -- if the provider has the ability to
+ * create custom probes, it may wish to create a probe that matches the
+ * specified description.
+ *
+ * 1.2.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is a pointer to a probe description that the provider may
+ * wish to consider when creating custom probes. The provider is expected to
+ * call back into the DTrace framework via dtrace_probe_create() to create
+ * any necessary probes. dtps_provide() may be called even if the provider
+ * has made available all probes; the provider should check the return value
+ * of dtrace_probe_create() to handle this case. Note that the provider need
+ * not implement both dtps_provide() and dtps_provide_module(); see
+ * "Arguments and Notes" for dtrace_register(), below.
+ *
+ * 1.2.3 Return value
+ *
+ * None.
+ *
+ * 1.2.4 Caller's context
+ *
+ * dtps_provide() is typically called from open() or ioctl() context, but may
+ * be called from other contexts as well. The DTrace framework is locked in
+ * such a way that providers may not register or unregister. This means that
+ * the provider may not call any DTrace API that affects its registration with
+ * the framework, including dtrace_register(), dtrace_unregister(),
+ * dtrace_invalidate(), and dtrace_condense(). However, the context is such
+ * that the provider may (and indeed, is expected to) call probe-related
+ * DTrace routines, including dtrace_probe_create(), dtrace_probe_lookup(),
+ * and dtrace_probe_arg().
+ *
+ * 1.3 void dtps_provide_module(void *arg, struct modctl *mp)
+ *
+ * 1.3.1 Overview
+ *
+ * Called to indicate that the provider should provide all probes in the
+ * specified module.
+ *
+ * 1.3.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is a pointer to a modctl structure that indicates the
+ * module for which probes should be created.
+ *
+ * 1.3.3 Return value
+ *
+ * None.
+ *
+ * 1.3.4 Caller's context
+ *
+ * dtps_provide_module() may be called from open() or ioctl() context, but
+ * may also be called from a module loading context. mod_lock is held, and
+ * the DTrace framework is locked in such a way that providers may not
+ * register or unregister. This means that the provider may not call any
+ * DTrace API that affects its registration with the framework, including
+ * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and
+ * dtrace_condense(). However, the context is such that the provider may (and
+ * indeed, is expected to) call probe-related DTrace routines, including
+ * dtrace_probe_create(), dtrace_probe_lookup(), and dtrace_probe_arg(). Note
+ * that the provider need not implement both dtps_provide() and
+ * dtps_provide_module(); see "Arguments and Notes" for dtrace_register(),
+ * below.
+ *
+ * 1.4 int dtps_enable(void *arg, dtrace_id_t id, void *parg)
+ *
+ * 1.4.1 Overview
+ *
+ * Called to enable the specified probe.
+ *
+ * 1.4.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the probe to be enabled. The third
+ * argument is the probe argument as passed to dtrace_probe_create().
+ * dtps_enable() will be called when a probe transitions from not being
+ * enabled at all to having one or more ECB. The number of ECBs associated
+ * with the probe may change without subsequent calls into the provider.
+ * When the number of ECBs drops to zero, the provider will be explicitly
+ * told to disable the probe via dtps_disable(). dtrace_probe() should never
+ * be called for a probe identifier that hasn't been explicitly enabled via
+ * dtps_enable().
+ *
+ * 1.4.3 Return value
+ *
+ * On success, dtps_enable() should return 0. On failure, -1 should be
+ * returned.
+ *
+ * 1.4.4 Caller's context
+ *
+ * The DTrace framework is locked in such a way that it may not be called
+ * back into at all. cpu_lock is held. mod_lock is not held and may not
+ * be acquired.
+ *
+ * 1.5 void dtps_disable(void *arg, dtrace_id_t id, void *parg)
+ *
+ * 1.5.1 Overview
+ *
+ * Called to disable the specified probe.
+ *
+ * 1.5.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the probe to be disabled. The third
+ * argument is the probe argument as passed to dtrace_probe_create().
+ * dtps_disable() will be called when a probe transitions from being enabled
+ * to having zero ECBs. dtrace_probe() should never be called for a probe
+ * identifier that has been explicitly enabled via dtps_disable().
+ *
+ * 1.5.3 Return value
+ *
+ * None.
+ *
+ * 1.5.4 Caller's context
+ *
+ * The DTrace framework is locked in such a way that it may not be called
+ * back into at all. cpu_lock is held. mod_lock is not held and may not
+ * be acquired.
+ *
+ * 1.6 void dtps_suspend(void *arg, dtrace_id_t id, void *parg)
+ *
+ * 1.6.1 Overview
+ *
+ * Called to suspend the specified enabled probe. This entry point is for
+ * providers that may need to suspend some or all of their probes when CPUs
+ * are being powered on or when the boot monitor is being entered for a
+ * prolonged period of time.
+ *
+ * 1.6.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the probe to be suspended. The
+ * third argument is the probe argument as passed to dtrace_probe_create().
+ * dtps_suspend will only be called on an enabled probe. Providers that
+ * provide a dtps_suspend entry point will want to take roughly the action
+ * that it takes for dtps_disable.
+ *
+ * 1.6.3 Return value
+ *
+ * None.
+ *
+ * 1.6.4 Caller's context
+ *
+ * Interrupts are disabled. The DTrace framework is in a state such that the
+ * specified probe cannot be disabled or destroyed for the duration of
+ * dtps_suspend(). As interrupts are disabled, the provider is afforded
+ * little latitude; the provider is expected to do no more than a store to
+ * memory.
+ *
+ * 1.7 void dtps_resume(void *arg, dtrace_id_t id, void *parg)
+ *
+ * 1.7.1 Overview
+ *
+ * Called to resume the specified enabled probe. This entry point is for
+ * providers that may need to resume some or all of their probes after the
+ * completion of an event that induced a call to dtps_suspend().
+ *
+ * 1.7.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the probe to be resumed. The
+ * third argument is the probe argument as passed to dtrace_probe_create().
+ * dtps_resume will only be called on an enabled probe. Providers that
+ * provide a dtps_resume entry point will want to take roughly the action
+ * that it takes for dtps_enable.
+ *
+ * 1.7.3 Return value
+ *
+ * None.
+ *
+ * 1.7.4 Caller's context
+ *
+ * Interrupts are disabled. The DTrace framework is in a state such that the
+ * specified probe cannot be disabled or destroyed for the duration of
+ * dtps_resume(). As interrupts are disabled, the provider is afforded
+ * little latitude; the provider is expected to do no more than a store to
+ * memory.
+ *
+ * 1.8 void dtps_getargdesc(void *arg, dtrace_id_t id, void *parg,
+ * dtrace_argdesc_t *desc)
+ *
+ * 1.8.1 Overview
+ *
+ * Called to retrieve the argument description for an args[X] variable.
+ *
+ * 1.8.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the current probe. The third
+ * argument is the probe argument as passed to dtrace_probe_create(). The
+ * fourth argument is a pointer to the argument description. This
+ * description is both an input and output parameter: it contains the
+ * index of the desired argument in the dtargd_ndx field, and expects
+ * the other fields to be filled in upon return. If there is no argument
+ * corresponding to the specified index, the dtargd_ndx field should be set
+ * to DTRACE_ARGNONE.
+ *
+ * 1.8.3 Return value
+ *
+ * None. The dtargd_ndx, dtargd_native, dtargd_xlate and dtargd_mapping
+ * members of the dtrace_argdesc_t structure are all output values.
+ *
+ * 1.8.4 Caller's context
+ *
+ * dtps_getargdesc() is called from ioctl() context. mod_lock is held, and
+ * the DTrace framework is locked in such a way that providers may not
+ * register or unregister. This means that the provider may not call any
+ * DTrace API that affects its registration with the framework, including
+ * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and
+ * dtrace_condense().
+ *
+ * 1.9 uint64_t dtps_getargval(void *arg, dtrace_id_t id, void *parg,
+ * int argno, int aframes)
+ *
+ * 1.9.1 Overview
+ *
+ * Called to retrieve a value for an argX or args[X] variable.
+ *
+ * 1.9.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the current probe. The third
+ * argument is the probe argument as passed to dtrace_probe_create(). The
+ * fourth argument is the number of the argument (the X in the example in
+ * 1.9.1). The fifth argument is the number of stack frames that were used
+ * to get from the actual place in the code that fired the probe to
+ * dtrace_probe() itself, the so-called artificial frames. This argument may
+ * be used to descend an appropriate number of frames to find the correct
+ * values. If this entry point is left NULL, the dtrace_getarg() built-in
+ * function is used.
+ *
+ * 1.9.3 Return value
+ *
+ * The value of the argument.
+ *
+ * 1.9.4 Caller's context
+ *
+ * This is called from within dtrace_probe() meaning that interrupts
+ * are disabled. No locks should be taken within this entry point.
+ *
+ * 1.10 int dtps_usermode(void *arg, dtrace_id_t id, void *parg)
+ *
+ * 1.10.1 Overview
+ *
+ * Called to determine if the probe was fired in a user context.
+ *
+ * 1.10.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the current probe. The third
+ * argument is the probe argument as passed to dtrace_probe_create(). This
+ * entry point must not be left NULL for providers whose probes allow for
+ * mixed mode tracing, that is to say those probes that can fire during
+ * kernel- _or_ user-mode execution
+ *
+ * 1.10.3 Return value
+ *
+ * A boolean value.
+ *
+ * 1.10.4 Caller's context
+ *
+ * This is called from within dtrace_probe() meaning that interrupts
+ * are disabled. No locks should be taken within this entry point.
+ *
+ * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg)
+ *
+ * 1.11.1 Overview
+ *
+ * Called to destroy the specified probe.
+ *
+ * 1.11.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_register(). The
+ * second argument is the identifier of the probe to be destroyed. The third
+ * argument is the probe argument as passed to dtrace_probe_create(). The
+ * provider should free all state associated with the probe. The framework
+ * guarantees that dtps_destroy() is only called for probes that have either
+ * been disabled via dtps_disable() or were never enabled via dtps_enable().
+ * Once dtps_disable() has been called for a probe, no further call will be
+ * made specifying the probe.
+ *
+ * 1.11.3 Return value
+ *
+ * None.
+ *
+ * 1.11.4 Caller's context
+ *
+ * The DTrace framework is locked in such a way that it may not be called
+ * back into at all. mod_lock is held. cpu_lock is not held, and may not be
+ * acquired.
+ *
+ *
+ * 2 Provider-to-Framework API
+ *
+ * 2.1 Overview
+ *
+ * The Provider-to-Framework API provides the mechanism for the provider to
+ * register itself with the DTrace framework, to create probes, to lookup
+ * probes and (most importantly) to fire probes. The Provider-to-Framework
+ * consists of:
+ *
+ * dtrace_register() <-- Register a provider with the DTrace framework
+ * dtrace_unregister() <-- Remove a provider's DTrace registration
+ * dtrace_invalidate() <-- Invalidate the specified provider
+ * dtrace_condense() <-- Remove a provider's unenabled probes
+ * dtrace_attached() <-- Indicates whether or not DTrace has attached
+ * dtrace_probe_create() <-- Create a DTrace probe
+ * dtrace_probe_lookup() <-- Lookup a DTrace probe based on its name
+ * dtrace_probe_arg() <-- Return the probe argument for a specific probe
+ * dtrace_probe() <-- Fire the specified probe
+ *
+ * 2.2 int dtrace_register(const char *name, const dtrace_pattr_t *pap,
+ * uint32_t priv, cred_t *cr, const dtrace_pops_t *pops, void *arg,
+ * dtrace_provider_id_t *idp)
+ *
+ * 2.2.1 Overview
+ *
+ * dtrace_register() registers the calling provider with the DTrace
+ * framework. It should generally be called by DTrace providers in their
+ * attach(9E) entry point.
+ *
+ * 2.2.2 Arguments and Notes
+ *
+ * The first argument is the name of the provider. The second argument is a
+ * pointer to the stability attributes for the provider. The third argument
+ * is the privilege flags for the provider, and must be some combination of:
+ *
+ * DTRACE_PRIV_NONE <= All users may enable probes from this provider
+ *
+ * DTRACE_PRIV_PROC <= Any user with privilege of PRIV_DTRACE_PROC may
+ * enable probes from this provider
+ *
+ * DTRACE_PRIV_USER <= Any user with privilege of PRIV_DTRACE_USER may
+ * enable probes from this provider
+ *
+ * DTRACE_PRIV_KERNEL <= Any user with privilege of PRIV_DTRACE_KERNEL
+ * may enable probes from this provider
+ *
+ * DTRACE_PRIV_OWNER <= This flag places an additional constraint on
+ * the privilege requirements above. These probes
+ * require either (a) a user ID matching the user
+ * ID of the cred passed in the fourth argument
+ * or (b) the PRIV_PROC_OWNER privilege.
+ *
+ * DTRACE_PRIV_ZONEOWNER<= This flag places an additional constraint on
+ * the privilege requirements above. These probes
+ * require either (a) a zone ID matching the zone
+ * ID of the cred passed in the fourth argument
+ * or (b) the PRIV_PROC_ZONE privilege.
+ *
+ * Note that these flags designate the _visibility_ of the probes, not
+ * the conditions under which they may or may not fire.
+ *
+ * The fourth argument is the credential that is associated with the
+ * provider. This argument should be NULL if the privilege flags don't
+ * include DTRACE_PRIV_OWNER or DTRACE_PRIV_ZONEOWNER. If non-NULL, the
+ * framework stashes the uid and zoneid represented by this credential
+ * for use at probe-time, in implicit predicates. These limit visibility
+ * of the probes to users and/or zones which have sufficient privilege to
+ * access them.
+ *
+ * The fifth argument is a DTrace provider operations vector, which provides
+ * the implementation for the Framework-to-Provider API. (See Section 1,
+ * above.) This must be non-NULL, and each member must be non-NULL. The
+ * exceptions to this are (1) the dtps_provide() and dtps_provide_module()
+ * members (if the provider so desires, _one_ of these members may be left
+ * NULL -- denoting that the provider only implements the other) and (2)
+ * the dtps_suspend() and dtps_resume() members, which must either both be
+ * NULL or both be non-NULL.
+ *
+ * The sixth argument is a cookie to be specified as the first argument for
+ * each function in the Framework-to-Provider API. This argument may have
+ * any value.
+ *
+ * The final argument is a pointer to dtrace_provider_id_t. If
+ * dtrace_register() successfully completes, the provider identifier will be
+ * stored in the memory pointed to be this argument. This argument must be
+ * non-NULL.
+ *
+ * 2.2.3 Return value
+ *
+ * On success, dtrace_register() returns 0 and stores the new provider's
+ * identifier into the memory pointed to by the idp argument. On failure,
+ * dtrace_register() returns an errno:
+ *
+ * EINVAL The arguments passed to dtrace_register() were somehow invalid.
+ * This may because a parameter that must be non-NULL was NULL,
+ * because the name was invalid (either empty or an illegal
+ * provider name) or because the attributes were invalid.
+ *
+ * No other failure code is returned.
+ *
+ * 2.2.4 Caller's context
+ *
+ * dtrace_register() may induce calls to dtrace_provide(); the provider must
+ * hold no locks across dtrace_register() that may also be acquired by
+ * dtrace_provide(). cpu_lock and mod_lock must not be held.
+ *
+ * 2.3 int dtrace_unregister(dtrace_provider_t id)
+ *
+ * 2.3.1 Overview
+ *
+ * Unregisters the specified provider from the DTrace framework. It should
+ * generally be called by DTrace providers in their detach(9E) entry point.
+ *
+ * 2.3.2 Arguments and Notes
+ *
+ * The only argument is the provider identifier, as returned from a
+ * successful call to dtrace_register(). As a result of calling
+ * dtrace_unregister(), the DTrace framework will call back into the provider
+ * via the dtps_destroy() entry point. Once dtrace_unregister() successfully
+ * completes, however, the DTrace framework will no longer make calls through
+ * the Framework-to-Provider API.
+ *
+ * 2.3.3 Return value
+ *
+ * On success, dtrace_unregister returns 0. On failure, dtrace_unregister()
+ * returns an errno:
+ *
+ * EBUSY There are currently processes that have the DTrace pseudodevice
+ * open, or there exists an anonymous enabling that hasn't yet
+ * been claimed.
+ *
+ * No other failure code is returned.
+ *
+ * 2.3.4 Caller's context
+ *
+ * Because a call to dtrace_unregister() may induce calls through the
+ * Framework-to-Provider API, the caller may not hold any lock across
+ * dtrace_register() that is also acquired in any of the Framework-to-
+ * Provider API functions. Additionally, mod_lock may not be held.
+ *
+ * 2.4 void dtrace_invalidate(dtrace_provider_id_t id)
+ *
+ * 2.4.1 Overview
+ *
+ * Invalidates the specified provider. All subsequent probe lookups for the
+ * specified provider will fail, but its probes will not be removed.
+ *
+ * 2.4.2 Arguments and note
+ *
+ * The only argument is the provider identifier, as returned from a
+ * successful call to dtrace_register(). In general, a provider's probes
+ * always remain valid; dtrace_invalidate() is a mechanism for invalidating
+ * an entire provider, regardless of whether or not probes are enabled or
+ * not. Note that dtrace_invalidate() will _not_ prevent already enabled
+ * probes from firing -- it will merely prevent any new enablings of the
+ * provider's probes.
+ *
+ * 2.5 int dtrace_condense(dtrace_provider_id_t id)
+ *
+ * 2.5.1 Overview
+ *
+ * Removes all the unenabled probes for the given provider. This function is
+ * not unlike dtrace_unregister(), except that it doesn't remove the
+ * provider just as many of its associated probes as it can.
+ *
+ * 2.5.2 Arguments and Notes
+ *
+ * As with dtrace_unregister(), the sole argument is the provider identifier
+ * as returned from a successful call to dtrace_register(). As a result of
+ * calling dtrace_condense(), the DTrace framework will call back into the
+ * given provider's dtps_destroy() entry point for each of the provider's
+ * unenabled probes.
+ *
+ * 2.5.3 Return value
+ *
+ * Currently, dtrace_condense() always returns 0. However, consumers of this
+ * function should check the return value as appropriate; its behavior may
+ * change in the future.
+ *
+ * 2.5.4 Caller's context
+ *
+ * As with dtrace_unregister(), the caller may not hold any lock across
+ * dtrace_condense() that is also acquired in the provider's entry points.
+ * Also, mod_lock may not be held.
+ *
+ * 2.6 int dtrace_attached()
+ *
+ * 2.6.1 Overview
+ *
+ * Indicates whether or not DTrace has attached.
+ *
+ * 2.6.2 Arguments and Notes
+ *
+ * For most providers, DTrace makes initial contact beyond registration.
+ * That is, once a provider has registered with DTrace, it waits to hear
+ * from DTrace to create probes. However, some providers may wish to
+ * proactively create probes without first being told by DTrace to do so.
+ * If providers wish to do this, they must first call dtrace_attached() to
+ * determine if DTrace itself has attached. If dtrace_attached() returns 0,
+ * the provider must not make any other Provider-to-Framework API call.
+ *
+ * 2.6.3 Return value
+ *
+ * dtrace_attached() returns 1 if DTrace has attached, 0 otherwise.
+ *
+ * 2.7 int dtrace_probe_create(dtrace_provider_t id, const char *mod,
+ * const char *func, const char *name, int aframes, void *arg)
+ *
+ * 2.7.1 Overview
+ *
+ * Creates a probe with specified module name, function name, and name.
+ *
+ * 2.7.2 Arguments and Notes
+ *
+ * The first argument is the provider identifier, as returned from a
+ * successful call to dtrace_register(). The second, third, and fourth
+ * arguments are the module name, function name, and probe name,
+ * respectively. Of these, module name and function name may both be NULL
+ * (in which case the probe is considered to be unanchored), or they may both
+ * be non-NULL. The name must be non-NULL, and must point to a non-empty
+ * string.
+ *
+ * The fifth argument is the number of artificial stack frames that will be
+ * found on the stack when dtrace_probe() is called for the new probe. These
+ * artificial frames will be automatically be pruned should the stack() or
+ * stackdepth() functions be called as part of one of the probe's ECBs. If
+ * the parameter doesn't add an artificial frame, this parameter should be
+ * zero.
+ *
+ * The final argument is a probe argument that will be passed back to the
+ * provider when a probe-specific operation is called. (e.g., via
+ * dtps_enable(), dtps_disable(), etc.)
+ *
+ * Note that it is up to the provider to be sure that the probe that it
+ * creates does not already exist -- if the provider is unsure of the probe's
+ * existence, it should assure its absence with dtrace_probe_lookup() before
+ * calling dtrace_probe_create().
+ *
+ * 2.7.3 Return value
+ *
+ * dtrace_probe_create() always succeeds, and always returns the identifier
+ * of the newly-created probe.
+ *
+ * 2.7.4 Caller's context
+ *
+ * While dtrace_probe_create() is generally expected to be called from
+ * dtps_provide() and/or dtps_provide_module(), it may be called from other
+ * non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
+ *
+ * 2.8 dtrace_id_t dtrace_probe_lookup(dtrace_provider_t id, const char *mod,
+ * const char *func, const char *name)
+ *
+ * 2.8.1 Overview
+ *
+ * Looks up a probe based on provdider and one or more of module name,
+ * function name and probe name.
+ *
+ * 2.8.2 Arguments and Notes
+ *
+ * The first argument is the provider identifier, as returned from a
+ * successful call to dtrace_register(). The second, third, and fourth
+ * arguments are the module name, function name, and probe name,
+ * respectively. Any of these may be NULL; dtrace_probe_lookup() will return
+ * the identifier of the first probe that is provided by the specified
+ * provider and matches all of the non-NULL matching criteria.
+ * dtrace_probe_lookup() is generally used by a provider to be check the
+ * existence of a probe before creating it with dtrace_probe_create().
+ *
+ * 2.8.3 Return value
+ *
+ * If the probe exists, returns its identifier. If the probe does not exist,
+ * return DTRACE_IDNONE.
+ *
+ * 2.8.4 Caller's context
+ *
+ * While dtrace_probe_lookup() is generally expected to be called from
+ * dtps_provide() and/or dtps_provide_module(), it may also be called from
+ * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
+ *
+ * 2.9 void *dtrace_probe_arg(dtrace_provider_t id, dtrace_id_t probe)
+ *
+ * 2.9.1 Overview
+ *
+ * Returns the probe argument associated with the specified probe.
+ *
+ * 2.9.2 Arguments and Notes
+ *
+ * The first argument is the provider identifier, as returned from a
+ * successful call to dtrace_register(). The second argument is a probe
+ * identifier, as returned from dtrace_probe_lookup() or
+ * dtrace_probe_create(). This is useful if a probe has multiple
+ * provider-specific components to it: the provider can create the probe
+ * once with provider-specific state, and then add to the state by looking
+ * up the probe based on probe identifier.
+ *
+ * 2.9.3 Return value
+ *
+ * Returns the argument associated with the specified probe. If the
+ * specified probe does not exist, or if the specified probe is not provided
+ * by the specified provider, NULL is returned.
+ *
+ * 2.9.4 Caller's context
+ *
+ * While dtrace_probe_arg() is generally expected to be called from
+ * dtps_provide() and/or dtps_provide_module(), it may also be called from
+ * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
+ *
+ * 2.10 void dtrace_probe(dtrace_id_t probe, uintptr_t arg0, uintptr_t arg1,
+ * uintptr_t arg2, uintptr_t arg3, uintptr_t arg4)
+ *
+ * 2.10.1 Overview
+ *
+ * The epicenter of DTrace: fires the specified probes with the specified
+ * arguments.
+ *
+ * 2.10.2 Arguments and Notes
+ *
+ * The first argument is a probe identifier as returned by
+ * dtrace_probe_create() or dtrace_probe_lookup(). The second through sixth
+ * arguments are the values to which the D variables "arg0" through "arg4"
+ * will be mapped.
+ *
+ * dtrace_probe() should be called whenever the specified probe has fired --
+ * however the provider defines it.
+ *
+ * 2.10.3 Return value
+ *
+ * None.
+ *
+ * 2.10.4 Caller's context
+ *
+ * dtrace_probe() may be called in virtually any context: kernel, user,
+ * interrupt, high-level interrupt, with arbitrary adaptive locks held, with
+ * dispatcher locks held, with interrupts disabled, etc. The only latitude
+ * that must be afforded to DTrace is the ability to make calls within
+ * itself (and to its in-kernel subroutines) and the ability to access
+ * arbitrary (but mapped) memory. On some platforms, this constrains
+ * context. For example, on UltraSPARC, dtrace_probe() cannot be called
+ * from any context in which TL is greater than zero. dtrace_probe() may
+ * also not be called from any routine which may be called by dtrace_probe()
+ * -- which includes functions in the DTrace framework and some in-kernel
+ * DTrace subroutines. All such functions "dtrace_"; providers that
+ * instrument the kernel arbitrarily should be sure to not instrument these
+ * routines.
+ */
+typedef struct dtrace_pops {
+ void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec);
+ void (*dtps_provide_module)(void *arg, struct modctl *mp);
+ int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
+ void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
+ void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
+ void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg);
+ void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg,
+ dtrace_argdesc_t *desc);
+ uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg,
+ int argno, int aframes);
+ int (*dtps_usermode)(void *arg, dtrace_id_t id, void *parg);
+ void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg);
+} dtrace_pops_t;
+
+typedef uintptr_t dtrace_provider_id_t;
+
+extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t,
+ cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *);
+extern int dtrace_unregister(dtrace_provider_id_t);
+extern int dtrace_condense(dtrace_provider_id_t);
+extern void dtrace_invalidate(dtrace_provider_id_t);
+extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *,
+ const char *, const char *);
+extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *,
+ const char *, const char *, int, void *);
+extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t);
+extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
+ uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
+
+/*
+ * DTrace Meta Provider API
+ *
+ * The following functions are implemented by the DTrace framework and are
+ * used to implement meta providers. Meta providers plug into the DTrace
+ * framework and are used to instantiate new providers on the fly. At
+ * present, there is only one type of meta provider and only one meta
+ * provider may be registered with the DTrace framework at a time. The
+ * sole meta provider type provides user-land static tracing facilities
+ * by taking meta probe descriptions and adding a corresponding provider
+ * into the DTrace framework.
+ *
+ * 1 Framework-to-Provider
+ *
+ * 1.1 Overview
+ *
+ * The Framework-to-Provider API is represented by the dtrace_mops structure
+ * that the meta provider passes to the framework when registering itself as
+ * a meta provider. This structure consists of the following members:
+ *
+ * dtms_create_probe() <-- Add a new probe to a created provider
+ * dtms_provide_pid() <-- Create a new provider for a given process
+ * dtms_remove_pid() <-- Remove a previously created provider
+ *
+ * 1.2 void dtms_create_probe(void *arg, void *parg,
+ * dtrace_helper_probedesc_t *probedesc);
+ *
+ * 1.2.1 Overview
+ *
+ * Called by the DTrace framework to create a new probe in a provider
+ * created by this meta provider.
+ *
+ * 1.2.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_meta_register().
+ * The second argument is the provider cookie for the associated provider;
+ * this is obtained from the return value of dtms_provide_pid(). The third
+ * argument is the helper probe description.
+ *
+ * 1.2.3 Return value
+ *
+ * None
+ *
+ * 1.2.4 Caller's context
+ *
+ * dtms_create_probe() is called from either ioctl() or module load context.
+ * The DTrace framework is locked in such a way that meta providers may not
+ * register or unregister. This means that the meta provider cannot call
+ * dtrace_meta_register() or dtrace_meta_unregister(). However, the context is
+ * such that the provider may (and is expected to) call provider-related
+ * DTrace provider APIs including dtrace_probe_create().
+ *
+ * 1.3 void *dtms_provide_pid(void *arg, dtrace_meta_provider_t *mprov,
+ * pid_t pid)
+ *
+ * 1.3.1 Overview
+ *
+ * Called by the DTrace framework to instantiate a new provider given the
+ * description of the provider and probes in the mprov argument. The
+ * meta provider should call dtrace_register() to insert the new provider
+ * into the DTrace framework.
+ *
+ * 1.3.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_meta_register().
+ * The second argument is a pointer to a structure describing the new
+ * helper provider. The third argument is the process identifier for
+ * process associated with this new provider. Note that the name of the
+ * provider as passed to dtrace_register() should be the contatenation of
+ * the dtmpb_provname member of the mprov argument and the processs
+ * identifier as a string.
+ *
+ * 1.3.3 Return value
+ *
+ * The cookie for the provider that the meta provider creates. This is
+ * the same value that it passed to dtrace_register().
+ *
+ * 1.3.4 Caller's context
+ *
+ * dtms_provide_pid() is called from either ioctl() or module load context.
+ * The DTrace framework is locked in such a way that meta providers may not
+ * register or unregister. This means that the meta provider cannot call
+ * dtrace_meta_register() or dtrace_meta_unregister(). However, the context
+ * is such that the provider may -- and is expected to -- call
+ * provider-related DTrace provider APIs including dtrace_register().
+ *
+ * 1.4 void dtms_remove_pid(void *arg, dtrace_meta_provider_t *mprov,
+ * pid_t pid)
+ *
+ * 1.4.1 Overview
+ *
+ * Called by the DTrace framework to remove a provider that had previously
+ * been instantiated via the dtms_provide_pid() entry point. The meta
+ * provider need not remove the provider immediately, but this entry
+ * point indicates that the provider should be removed as soon as possible
+ * using the dtrace_unregister() API.
+ *
+ * 1.4.2 Arguments and notes
+ *
+ * The first argument is the cookie as passed to dtrace_meta_register().
+ * The second argument is a pointer to a structure describing the helper
+ * provider. The third argument is the process identifier for process
+ * associated with this new provider.
+ *
+ * 1.4.3 Return value
+ *
+ * None
+ *
+ * 1.4.4 Caller's context
+ *
+ * dtms_remove_pid() is called from either ioctl() or exit() context.
+ * The DTrace framework is locked in such a way that meta providers may not
+ * register or unregister. This means that the meta provider cannot call
+ * dtrace_meta_register() or dtrace_meta_unregister(). However, the context
+ * is such that the provider may -- and is expected to -- call
+ * provider-related DTrace provider APIs including dtrace_unregister().
+ */
+typedef struct dtrace_helper_probedesc {
+ char *dthpb_mod; /* probe module */
+ char *dthpb_func; /* probe function */
+ char *dthpb_name; /* probe name */
+ uint64_t dthpb_base; /* base address */
+ uint32_t *dthpb_offs; /* offsets array */
+ uint32_t *dthpb_enoffs; /* is-enabled offsets array */
+ uint32_t dthpb_noffs; /* offsets count */
+ uint32_t dthpb_nenoffs; /* is-enabled offsets count */
+ uint8_t *dthpb_args; /* argument mapping array */
+ uint8_t dthpb_xargc; /* translated argument count */
+ uint8_t dthpb_nargc; /* native argument count */
+ char *dthpb_xtypes; /* translated types strings */
+ char *dthpb_ntypes; /* native types strings */
+} dtrace_helper_probedesc_t;
+
+typedef struct dtrace_helper_provdesc {
+ char *dthpv_provname; /* provider name */
+ dtrace_pattr_t dthpv_pattr; /* stability attributes */
+} dtrace_helper_provdesc_t;
+
+typedef struct dtrace_mops {
+ void (*dtms_create_probe)(void *, void *, dtrace_helper_probedesc_t *);
+ void *(*dtms_provide_pid)(void *, dtrace_helper_provdesc_t *, pid_t);
+ void (*dtms_remove_pid)(void *, dtrace_helper_provdesc_t *, pid_t);
+} dtrace_mops_t;
+
+typedef uintptr_t dtrace_meta_provider_id_t;
+
+extern int dtrace_meta_register(const char *, const dtrace_mops_t *, void *,
+ dtrace_meta_provider_id_t *);
+extern int dtrace_meta_unregister(dtrace_meta_provider_id_t);
+
+/*
+ * DTrace Kernel Hooks
+ *
+ * The following functions are implemented by the base kernel and form a set of
+ * hooks used by the DTrace framework. DTrace hooks are implemented in either
+ * uts/common/os/dtrace_subr.c, an ISA-specific assembly file, or in a
+ * uts/<platform>/os/dtrace_subr.c corresponding to each hardware platform.
+ */
+
+typedef enum dtrace_vtime_state {
+ DTRACE_VTIME_INACTIVE = 0, /* No DTrace, no TNF */
+ DTRACE_VTIME_ACTIVE, /* DTrace virtual time, no TNF */
+ DTRACE_VTIME_INACTIVE_TNF, /* No DTrace, TNF active */
+ DTRACE_VTIME_ACTIVE_TNF /* DTrace virtual time _and_ TNF */
+} dtrace_vtime_state_t;
+
+extern dtrace_vtime_state_t dtrace_vtime_active;
+extern void dtrace_vtime_switch(kthread_t *next);
+extern void dtrace_vtime_enable_tnf(void);
+extern void dtrace_vtime_disable_tnf(void);
+extern void dtrace_vtime_enable(void);
+extern void dtrace_vtime_disable(void);
+
+struct regs;
+
+extern int (*dtrace_pid_probe_ptr)(struct regs *);
+extern int (*dtrace_return_probe_ptr)(struct regs *);
+extern void (*dtrace_fasttrap_fork_ptr)(proc_t *, proc_t *);
+extern void (*dtrace_fasttrap_exec_ptr)(proc_t *);
+extern void (*dtrace_fasttrap_exit_ptr)(proc_t *);
+extern void dtrace_fasttrap_fork(proc_t *, proc_t *);
+
+typedef uintptr_t dtrace_icookie_t;
+typedef void (*dtrace_xcall_t)(void *);
+
+extern dtrace_icookie_t dtrace_interrupt_disable(void);
+extern void dtrace_interrupt_enable(dtrace_icookie_t);
+
+extern void dtrace_membar_producer(void);
+extern void dtrace_membar_consumer(void);
+
+extern void (*dtrace_cpu_init)(processorid_t);
+extern void (*dtrace_modload)(struct modctl *);
+extern void (*dtrace_modunload)(struct modctl *);
+extern void (*dtrace_helpers_cleanup)(VBDTVOID);
+extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child);
+extern void (*dtrace_cpustart_init)(VBDTVOID);
+extern void (*dtrace_cpustart_fini)(VBDTVOID);
+
+extern void (*dtrace_debugger_init)(VBDTVOID);
+extern void (*dtrace_debugger_fini)(VBDTVOID);
+extern dtrace_cacheid_t dtrace_predcache_id;
+
+extern hrtime_t dtrace_gethrtime(void);
+extern void dtrace_sync(void);
+extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
+extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
+#ifdef VBOX
+extern void dtrace_vpanic(const char *, va_list);
+#else
+extern void dtrace_vpanic(const char *, __va_list);
+#endif
+extern void dtrace_panic(const char *, ...);
+
+extern int dtrace_safe_defer_signal(void);
+extern void dtrace_safe_synchronous_signal(void);
+
+extern int dtrace_mach_aframes(void);
+
+#if defined(__i386) || defined(__amd64)
+extern int dtrace_instr_size(uchar_t *instr);
+extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
+extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t));
+extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t));
+extern void dtrace_invop_callsite(void);
+#endif
+
+#ifdef __sparc
+extern int dtrace_blksuword32(uintptr_t, uint32_t *, int);
+extern void dtrace_getfsr(uint64_t *);
+#endif
+
+#ifndef VBOX
+# define VBDT_GET_CPUID() (CPU->cpu_id)
+# define VBDT_GET_PROC() (ttoproc(curthread))
+#else
+# define VBDT_GET_CPUID() (RTMpCpuId())
+# define VBDT_GET_PROC() (VBoxDtGetCurrentProc())
+proc_t *VBoxDtGetCurrentProc(void);
+#endif
+
+#define DTRACE_CPUFLAG_ISSET(flag) \
+ (cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags & (flag))
+
+#define DTRACE_CPUFLAG_SET(flag) \
+ (cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= (flag))
+
+#define DTRACE_CPUFLAG_CLEAR(flag) \
+ (cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags &= ~(flag))
+
+#endif /* _KERNEL || IN_RING0 */
+
+#endif /* _ASM */
+
+#if defined(__i386) || defined(__amd64)
+
+#define DTRACE_INVOP_PUSHL_EBP 1
+#define DTRACE_INVOP_POPL_EBP 2
+#define DTRACE_INVOP_LEAVE 3
+#define DTRACE_INVOP_NOP 4
+#define DTRACE_INVOP_RET 5
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_DTRACE_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace_impl.h b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace_impl.h
new file mode 100644
index 00000000..a0e53d5a
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace_impl.h
@@ -0,0 +1,1304 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_DTRACE_IMPL_H
+#define _SYS_DTRACE_IMPL_H
+
+#ifndef VBOX
+#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * DTrace Dynamic Tracing Software: Kernel Implementation Interfaces
+ *
+ * Note: The contents of this file are private to the implementation of the
+ * Solaris system and DTrace subsystem and are subject to change at any time
+ * without notice. Applications and drivers using these interfaces will fail
+ * to run on future releases. These interfaces should not be used for any
+ * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
+ * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
+ */
+
+#include <sys/dtrace.h>
+
+/*
+ * DTrace Implementation Constants and Typedefs
+ */
+#define DTRACE_MAXPROPLEN 128
+#define DTRACE_DYNVAR_CHUNKSIZE 256
+
+struct dtrace_probe;
+struct dtrace_ecb;
+struct dtrace_predicate;
+struct dtrace_action;
+struct dtrace_provider;
+struct dtrace_state;
+
+typedef struct dtrace_probe dtrace_probe_t;
+typedef struct dtrace_ecb dtrace_ecb_t;
+typedef struct dtrace_predicate dtrace_predicate_t;
+typedef struct dtrace_action dtrace_action_t;
+typedef struct dtrace_provider dtrace_provider_t;
+typedef struct dtrace_meta dtrace_meta_t;
+typedef struct dtrace_state dtrace_state_t;
+typedef uint32_t dtrace_optid_t;
+typedef uint32_t dtrace_specid_t;
+typedef uint64_t dtrace_genid_t;
+
+/*
+ * DTrace Probes
+ *
+ * The probe is the fundamental unit of the DTrace architecture. Probes are
+ * created by DTrace providers, and managed by the DTrace framework. A probe
+ * is identified by a unique <provider, module, function, name> tuple, and has
+ * a unique probe identifier assigned to it. (Some probes are not associated
+ * with a specific point in text; these are called _unanchored probes_ and have
+ * no module or function associated with them.) Probes are represented as a
+ * dtrace_probe structure. To allow quick lookups based on each element of the
+ * probe tuple, probes are hashed by each of provider, module, function and
+ * name. (If a lookup is performed based on a regular expression, a
+ * dtrace_probekey is prepared, and a linear search is performed.) Each probe
+ * is additionally pointed to by a linear array indexed by its identifier. The
+ * identifier is the provider's mechanism for indicating to the DTrace
+ * framework that a probe has fired: the identifier is passed as the first
+ * argument to dtrace_probe(), where it is then mapped into the corresponding
+ * dtrace_probe structure. From the dtrace_probe structure, dtrace_probe() can
+ * iterate over the probe's list of enabling control blocks; see "DTrace
+ * Enabling Control Blocks", below.)
+ */
+struct dtrace_probe {
+ dtrace_id_t dtpr_id; /* probe identifier */
+ dtrace_ecb_t *dtpr_ecb; /* ECB list; see below */
+ dtrace_ecb_t *dtpr_ecb_last; /* last ECB in list */
+ void *dtpr_arg; /* provider argument */
+ dtrace_cacheid_t dtpr_predcache; /* predicate cache ID */
+ int dtpr_aframes; /* artificial frames */
+ dtrace_provider_t *dtpr_provider; /* pointer to provider */
+ char *dtpr_mod; /* probe's module name */
+ char *dtpr_func; /* probe's function name */
+ char *dtpr_name; /* probe's name */
+ dtrace_probe_t *dtpr_nextmod; /* next in module hash */
+ dtrace_probe_t *dtpr_prevmod; /* previous in module hash */
+ dtrace_probe_t *dtpr_nextfunc; /* next in function hash */
+ dtrace_probe_t *dtpr_prevfunc; /* previous in function hash */
+ dtrace_probe_t *dtpr_nextname; /* next in name hash */
+ dtrace_probe_t *dtpr_prevname; /* previous in name hash */
+ dtrace_genid_t dtpr_gen; /* probe generation ID */
+};
+
+typedef int dtrace_probekey_f(const char *, const char *, int);
+
+typedef struct dtrace_probekey {
+ const char *dtpk_prov; /* provider name to match */
+ dtrace_probekey_f *dtpk_pmatch; /* provider matching function */
+ const char *dtpk_mod; /* module name to match */
+ dtrace_probekey_f *dtpk_mmatch; /* module matching function */
+ const char *dtpk_func; /* func name to match */
+ dtrace_probekey_f *dtpk_fmatch; /* func matching function */
+ const char *dtpk_name; /* name to match */
+ dtrace_probekey_f *dtpk_nmatch; /* name matching function */
+ dtrace_id_t dtpk_id; /* identifier to match */
+} dtrace_probekey_t;
+
+typedef struct dtrace_hashbucket {
+ struct dtrace_hashbucket *dthb_next; /* next on hash chain */
+ dtrace_probe_t *dthb_chain; /* chain of probes */
+ int dthb_len; /* number of probes here */
+} dtrace_hashbucket_t;
+
+typedef struct dtrace_hash {
+ dtrace_hashbucket_t **dth_tab; /* hash table */
+ int dth_size; /* size of hash table */
+ int dth_mask; /* mask to index into table */
+ int dth_nbuckets; /* total number of buckets */
+ uintptr_t dth_nextoffs; /* offset of next in probe */
+ uintptr_t dth_prevoffs; /* offset of prev in probe */
+ uintptr_t dth_stroffs; /* offset of str in probe */
+} dtrace_hash_t;
+
+/*
+ * DTrace Enabling Control Blocks
+ *
+ * When a provider wishes to fire a probe, it calls into dtrace_probe(),
+ * passing the probe identifier as the first argument. As described above,
+ * dtrace_probe() maps the identifier into a pointer to a dtrace_probe_t
+ * structure. This structure contains information about the probe, and a
+ * pointer to the list of Enabling Control Blocks (ECBs). Each ECB points to
+ * DTrace consumer state, and contains an optional predicate, and a list of
+ * actions. (Shown schematically below.) The ECB abstraction allows a single
+ * probe to be multiplexed across disjoint consumers, or across disjoint
+ * enablings of a single probe within one consumer.
+ *
+ * Enabling Control Block
+ * dtrace_ecb_t
+ * +------------------------+
+ * | dtrace_epid_t ---------+--------------> Enabled Probe ID (EPID)
+ * | dtrace_state_t * ------+--------------> State associated with this ECB
+ * | dtrace_predicate_t * --+---------+
+ * | dtrace_action_t * -----+----+ |
+ * | dtrace_ecb_t * ---+ | | | Predicate (if any)
+ * +-------------------+----+ | | dtrace_predicate_t
+ * | | +---> +--------------------+
+ * | | | dtrace_difo_t * ---+----> DIFO
+ * | | +--------------------+
+ * | |
+ * Next ECB | | Action
+ * (if any) | | dtrace_action_t
+ * : +--> +-------------------+
+ * : | dtrace_actkind_t -+------> kind
+ * v | dtrace_difo_t * --+------> DIFO (if any)
+ * | dtrace_recdesc_t -+------> record descr.
+ * | dtrace_action_t * +------+
+ * +-------------------+ |
+ * | Next action
+ * +-------------------------------+ (if any)
+ * |
+ * | Action
+ * | dtrace_action_t
+ * +--> +-------------------+
+ * | dtrace_actkind_t -+------> kind
+ * | dtrace_difo_t * --+------> DIFO (if any)
+ * | dtrace_action_t * +------+
+ * +-------------------+ |
+ * | Next action
+ * +-------------------------------+ (if any)
+ * |
+ * :
+ * v
+ *
+ *
+ * dtrace_probe() iterates over the ECB list. If the ECB needs less space
+ * than is available in the principal buffer, the ECB is processed: if the
+ * predicate is non-NULL, the DIF object is executed. If the result is
+ * non-zero, the action list is processed, with each action being executed
+ * accordingly. When the action list has been completely executed, processing
+ * advances to the next ECB. processing advances to the next ECB. If the
+ * result is non-zero; For each ECB, it first determines the The ECB
+ * abstraction allows disjoint consumers to multiplex on single probes.
+ */
+struct dtrace_ecb {
+ dtrace_epid_t dte_epid; /* enabled probe ID */
+ uint32_t dte_alignment; /* required alignment */
+ size_t dte_needed; /* bytes needed */
+ size_t dte_size; /* total size of payload */
+ dtrace_predicate_t *dte_predicate; /* predicate, if any */
+ dtrace_action_t *dte_action; /* actions, if any */
+ dtrace_ecb_t *dte_next; /* next ECB on probe */
+ dtrace_state_t *dte_state; /* pointer to state */
+ uint32_t dte_cond; /* security condition */
+ dtrace_probe_t *dte_probe; /* pointer to probe */
+ dtrace_action_t *dte_action_last; /* last action on ECB */
+ uint64_t dte_uarg; /* library argument */
+};
+
+struct dtrace_predicate {
+ dtrace_difo_t *dtp_difo; /* DIF object */
+ dtrace_cacheid_t dtp_cacheid; /* cache identifier */
+ int dtp_refcnt; /* reference count */
+};
+
+struct dtrace_action {
+ dtrace_actkind_t dta_kind; /* kind of action */
+ uint16_t dta_intuple; /* boolean: in aggregation */
+ uint32_t dta_refcnt; /* reference count */
+ dtrace_difo_t *dta_difo; /* pointer to DIFO */
+ dtrace_recdesc_t dta_rec; /* record description */
+ dtrace_action_t *dta_prev; /* previous action */
+ dtrace_action_t *dta_next; /* next action */
+};
+
+typedef struct dtrace_aggregation {
+ dtrace_action_t dtag_action; /* action; must be first */
+ dtrace_aggid_t dtag_id; /* identifier */
+ dtrace_ecb_t *dtag_ecb; /* corresponding ECB */
+ dtrace_action_t *dtag_first; /* first action in tuple */
+ uint32_t dtag_base; /* base of aggregation */
+ uint8_t dtag_hasarg; /* boolean: has argument */
+ uint64_t dtag_initial; /* initial value */
+ void (*dtag_aggregate)(uint64_t *, uint64_t, uint64_t);
+} dtrace_aggregation_t;
+
+/*
+ * DTrace Buffers
+ *
+ * Principal buffers, aggregation buffers, and speculative buffers are all
+ * managed with the dtrace_buffer structure. By default, this structure
+ * includes twin data buffers -- dtb_tomax and dtb_xamot -- that serve as the
+ * active and passive buffers, respectively. For speculative buffers,
+ * dtb_xamot will be NULL; for "ring" and "fill" buffers, dtb_xamot will point
+ * to a scratch buffer. For all buffer types, the dtrace_buffer structure is
+ * always allocated on a per-CPU basis; a single dtrace_buffer structure is
+ * never shared among CPUs. (That is, there is never true sharing of the
+ * dtrace_buffer structure; to prevent false sharing of the structure, it must
+ * always be aligned to the coherence granularity -- generally 64 bytes.)
+ *
+ * One of the critical design decisions of DTrace is that a given ECB always
+ * stores the same quantity and type of data. This is done to assure that the
+ * only metadata required for an ECB's traced data is the EPID. That is, from
+ * the EPID, the consumer can determine the data layout. (The data buffer
+ * layout is shown schematically below.) By assuring that one can determine
+ * data layout from the EPID, the metadata stream can be separated from the
+ * data stream -- simplifying the data stream enormously.
+ *
+ * base of data buffer ---> +------+--------------------+------+
+ * | EPID | data | EPID |
+ * +------+--------+------+----+------+
+ * | data | EPID | data |
+ * +---------------+------+-----------+
+ * | data, cont. |
+ * +------+--------------------+------+
+ * | EPID | data | |
+ * +------+--------------------+ |
+ * | || |
+ * | || |
+ * | \/ |
+ * : :
+ * . .
+ * . .
+ * . .
+ * : :
+ * | |
+ * limit of data buffer ---> +----------------------------------+
+ *
+ * When evaluating an ECB, dtrace_probe() determines if the ECB's needs of the
+ * principal buffer (both scratch and payload) exceed the available space. If
+ * the ECB's needs exceed available space (and if the principal buffer policy
+ * is the default "switch" policy), the ECB is dropped, the buffer's drop count
+ * is incremented, and processing advances to the next ECB. If the ECB's needs
+ * can be met with the available space, the ECB is processed, but the offset in
+ * the principal buffer is only advanced if the ECB completes processing
+ * without error.
+ *
+ * When a buffer is to be switched (either because the buffer is the principal
+ * buffer with a "switch" policy or because it is an aggregation buffer), a
+ * cross call is issued to the CPU associated with the buffer. In the cross
+ * call context, interrupts are disabled, and the active and the inactive
+ * buffers are atomically switched. This involves switching the data pointers,
+ * copying the various state fields (offset, drops, errors, etc.) into their
+ * inactive equivalents, and clearing the state fields. Because interrupts are
+ * disabled during this procedure, the switch is guaranteed to appear atomic to
+ * dtrace_probe().
+ *
+ * DTrace Ring Buffering
+ *
+ * To process a ring buffer correctly, one must know the oldest valid record.
+ * Processing starts at the oldest record in the buffer and continues until
+ * the end of the buffer is reached. Processing then resumes starting with
+ * the record stored at offset 0 in the buffer, and continues until the
+ * youngest record is processed. If trace records are of a fixed-length,
+ * determining the oldest record is trivial:
+ *
+ * - If the ring buffer has not wrapped, the oldest record is the record
+ * stored at offset 0.
+ *
+ * - If the ring buffer has wrapped, the oldest record is the record stored
+ * at the current offset.
+ *
+ * With variable length records, however, just knowing the current offset
+ * doesn't suffice for determining the oldest valid record: assuming that one
+ * allows for arbitrary data, one has no way of searching forward from the
+ * current offset to find the oldest valid record. (That is, one has no way
+ * of separating data from metadata.) It would be possible to simply refuse to
+ * process any data in the ring buffer between the current offset and the
+ * limit, but this leaves (potentially) an enormous amount of otherwise valid
+ * data unprocessed.
+ *
+ * To effect ring buffering, we track two offsets in the buffer: the current
+ * offset and the _wrapped_ offset. If a request is made to reserve some
+ * amount of data, and the buffer has wrapped, the wrapped offset is
+ * incremented until the wrapped offset minus the current offset is greater
+ * than or equal to the reserve request. This is done by repeatedly looking
+ * up the ECB corresponding to the EPID at the current wrapped offset, and
+ * incrementing the wrapped offset by the size of the data payload
+ * corresponding to that ECB. If this offset is greater than or equal to the
+ * limit of the data buffer, the wrapped offset is set to 0. Thus, the
+ * current offset effectively "chases" the wrapped offset around the buffer.
+ * Schematically:
+ *
+ * base of data buffer ---> +------+--------------------+------+
+ * | EPID | data | EPID |
+ * +------+--------+------+----+------+
+ * | data | EPID | data |
+ * +---------------+------+-----------+
+ * | data, cont. |
+ * +------+---------------------------+
+ * | EPID | data |
+ * current offset ---> +------+---------------------------+
+ * | invalid data |
+ * wrapped offset ---> +------+--------------------+------+
+ * | EPID | data | EPID |
+ * +------+--------+------+----+------+
+ * | data | EPID | data |
+ * +---------------+------+-----------+
+ * : :
+ * . .
+ * . ... valid data ... .
+ * . .
+ * : :
+ * +------+-------------+------+------+
+ * | EPID | data | EPID | data |
+ * +------+------------++------+------+
+ * | data, cont. | leftover |
+ * limit of data buffer ---> +-------------------+--------------+
+ *
+ * If the amount of requested buffer space exceeds the amount of space
+ * available between the current offset and the end of the buffer:
+ *
+ * (1) all words in the data buffer between the current offset and the limit
+ * of the data buffer (marked "leftover", above) are set to
+ * DTRACE_EPIDNONE
+ *
+ * (2) the wrapped offset is set to zero
+ *
+ * (3) the iteration process described above occurs until the wrapped offset
+ * is greater than the amount of desired space.
+ *
+ * The wrapped offset is implemented by (re-)using the inactive offset.
+ * In a "switch" buffer policy, the inactive offset stores the offset in
+ * the inactive buffer; in a "ring" buffer policy, it stores the wrapped
+ * offset.
+ *
+ * DTrace Scratch Buffering
+ *
+ * Some ECBs may wish to allocate dynamically-sized temporary scratch memory.
+ * To accommodate such requests easily, scratch memory may be allocated in
+ * the buffer beyond the current offset plus the needed memory of the current
+ * ECB. If there isn't sufficient room in the buffer for the requested amount
+ * of scratch space, the allocation fails and an error is generated. Scratch
+ * memory is tracked in the dtrace_mstate_t and is automatically freed when
+ * the ECB ceases processing. Note that ring buffers cannot allocate their
+ * scratch from the principal buffer -- lest they needlessly overwrite older,
+ * valid data. Ring buffers therefore have their own dedicated scratch buffer
+ * from which scratch is allocated.
+ */
+#define DTRACEBUF_RING 0x0001 /* bufpolicy set to "ring" */
+#define DTRACEBUF_FILL 0x0002 /* bufpolicy set to "fill" */
+#define DTRACEBUF_NOSWITCH 0x0004 /* do not switch buffer */
+#define DTRACEBUF_WRAPPED 0x0008 /* ring buffer has wrapped */
+#define DTRACEBUF_DROPPED 0x0010 /* drops occurred */
+#define DTRACEBUF_ERROR 0x0020 /* errors occurred */
+#define DTRACEBUF_FULL 0x0040 /* "fill" buffer is full */
+#define DTRACEBUF_CONSUMED 0x0080 /* buffer has been consumed */
+#define DTRACEBUF_INACTIVE 0x0100 /* buffer is not yet active */
+
+typedef struct dtrace_buffer {
+ uint64_t dtb_offset; /* current offset in buffer */
+ uint64_t dtb_size; /* size of buffer */
+ uint32_t dtb_flags; /* flags */
+ uint32_t dtb_drops; /* number of drops */
+ caddr_t dtb_tomax; /* active buffer */
+ caddr_t dtb_xamot; /* inactive buffer */
+ uint32_t dtb_xamot_flags; /* inactive flags */
+ uint32_t dtb_xamot_drops; /* drops in inactive buffer */
+ uint64_t dtb_xamot_offset; /* offset in inactive buffer */
+ uint32_t dtb_errors; /* number of errors */
+ uint32_t dtb_xamot_errors; /* errors in inactive buffer */
+#ifndef _LP64
+ uint64_t dtb_pad1;
+#endif
+} dtrace_buffer_t;
+
+/*
+ * DTrace Aggregation Buffers
+ *
+ * Aggregation buffers use much of the same mechanism as described above
+ * ("DTrace Buffers"). However, because an aggregation is fundamentally a
+ * hash, there exists dynamic metadata associated with an aggregation buffer
+ * that is not associated with other kinds of buffers. This aggregation
+ * metadata is _only_ relevant for the in-kernel implementation of
+ * aggregations; it is not actually relevant to user-level consumers. To do
+ * this, we allocate dynamic aggregation data (hash keys and hash buckets)
+ * starting below the _limit_ of the buffer, and we allocate data from the
+ * _base_ of the buffer. When the aggregation buffer is copied out, _only_ the
+ * data is copied out; the metadata is simply discarded. Schematically,
+ * aggregation buffers look like:
+ *
+ * base of data buffer ---> +-------+------+-----------+-------+
+ * | aggid | key | value | aggid |
+ * +-------+------+-----------+-------+
+ * | key |
+ * +-------+-------+-----+------------+
+ * | value | aggid | key | value |
+ * +-------+------++-----+------+-----+
+ * | aggid | key | value | |
+ * +-------+------+-------------+ |
+ * | || |
+ * | || |
+ * | \/ |
+ * : :
+ * . .
+ * . .
+ * . .
+ * : :
+ * | /\ |
+ * | || +------------+
+ * | || | |
+ * +---------------------+ |
+ * | hash keys |
+ * | (dtrace_aggkey structures) |
+ * | |
+ * +----------------------------------+
+ * | hash buckets |
+ * | (dtrace_aggbuffer structure) |
+ * | |
+ * limit of data buffer ---> +----------------------------------+
+ *
+ *
+ * As implied above, just as we assure that ECBs always store a constant
+ * amount of data, we assure that a given aggregation -- identified by its
+ * aggregation ID -- always stores data of a constant quantity and type.
+ * As with EPIDs, this allows the aggregation ID to serve as the metadata for a
+ * given record.
+ *
+ * Note that the size of the dtrace_aggkey structure must be sizeof (uintptr_t)
+ * aligned. (If this the structure changes such that this becomes false, an
+ * assertion will fail in dtrace_aggregate().)
+ */
+typedef struct dtrace_aggkey {
+ uint32_t dtak_hashval; /* hash value */
+ uint32_t dtak_action:4; /* action -- 4 bits */
+ uint32_t dtak_size:28; /* size -- 28 bits */
+ caddr_t dtak_data; /* data pointer */
+ struct dtrace_aggkey *dtak_next; /* next in hash chain */
+} dtrace_aggkey_t;
+
+typedef struct dtrace_aggbuffer {
+ uintptr_t dtagb_hashsize; /* number of buckets */
+ uintptr_t dtagb_free; /* free list of keys */
+ dtrace_aggkey_t **dtagb_hash; /* hash table */
+} dtrace_aggbuffer_t;
+
+/*
+ * DTrace Speculations
+ *
+ * Speculations have a per-CPU buffer and a global state. Once a speculation
+ * buffer has been comitted or discarded, it cannot be reused until all CPUs
+ * have taken the same action (commit or discard) on their respective
+ * speculative buffer. However, because DTrace probes may execute in arbitrary
+ * context, other CPUs cannot simply be cross-called at probe firing time to
+ * perform the necessary commit or discard. The speculation states thus
+ * optimize for the case that a speculative buffer is only active on one CPU at
+ * the time of a commit() or discard() -- for if this is the case, other CPUs
+ * need not take action, and the speculation is immediately available for
+ * reuse. If the speculation is active on multiple CPUs, it must be
+ * asynchronously cleaned -- potentially leading to a higher rate of dirty
+ * speculative drops. The speculation states are as follows:
+ *
+ * DTRACESPEC_INACTIVE <= Initial state; inactive speculation
+ * DTRACESPEC_ACTIVE <= Allocated, but not yet speculatively traced to
+ * DTRACESPEC_ACTIVEONE <= Speculatively traced to on one CPU
+ * DTRACESPEC_ACTIVEMANY <= Speculatively traced to on more than one CPU
+ * DTRACESPEC_COMMITTING <= Currently being commited on one CPU
+ * DTRACESPEC_COMMITTINGMANY <= Currently being commited on many CPUs
+ * DTRACESPEC_DISCARDING <= Currently being discarded on many CPUs
+ *
+ * The state transition diagram is as follows:
+ *
+ * +----------------------------------------------------------+
+ * | |
+ * | +------------+ |
+ * | +-------------------| COMMITTING |<-----------------+ |
+ * | | +------------+ | |
+ * | | copied spec. ^ commit() on | | discard() on
+ * | | into principal | active CPU | | active CPU
+ * | | | commit() | |
+ * V V | | |
+ * +----------+ +--------+ +-----------+
+ * | INACTIVE |---------------->| ACTIVE |--------------->| ACTIVEONE |
+ * +----------+ speculation() +--------+ speculate() +-----------+
+ * ^ ^ | | |
+ * | | | discard() | |
+ * | | asynchronously | discard() on | | speculate()
+ * | | cleaned V inactive CPU | | on inactive
+ * | | +------------+ | | CPU
+ * | +-------------------| DISCARDING |<-----------------+ |
+ * | +------------+ |
+ * | asynchronously ^ |
+ * | copied spec. | discard() |
+ * | into principal +------------------------+ |
+ * | | V
+ * +----------------+ commit() +------------+
+ * | COMMITTINGMANY |<----------------------------------| ACTIVEMANY |
+ * +----------------+ +------------+
+ */
+typedef enum dtrace_speculation_state {
+ DTRACESPEC_INACTIVE = 0,
+ DTRACESPEC_ACTIVE,
+ DTRACESPEC_ACTIVEONE,
+ DTRACESPEC_ACTIVEMANY,
+ DTRACESPEC_COMMITTING,
+ DTRACESPEC_COMMITTINGMANY,
+ DTRACESPEC_DISCARDING
+} dtrace_speculation_state_t;
+
+typedef struct dtrace_speculation {
+ dtrace_speculation_state_t dtsp_state; /* current speculation state */
+ int dtsp_cleaning; /* non-zero if being cleaned */
+ dtrace_buffer_t *dtsp_buffer; /* speculative buffer */
+} dtrace_speculation_t;
+
+/*
+ * DTrace Dynamic Variables
+ *
+ * The dynamic variable problem is obviously decomposed into two subproblems:
+ * allocating new dynamic storage, and freeing old dynamic storage. The
+ * presence of the second problem makes the first much more complicated -- or
+ * rather, the absence of the second renders the first trivial. This is the
+ * case with aggregations, for which there is effectively no deallocation of
+ * dynamic storage. (Or more accurately, all dynamic storage is deallocated
+ * when a snapshot is taken of the aggregation.) As DTrace dynamic variables
+ * allow for both dynamic allocation and dynamic deallocation, the
+ * implementation of dynamic variables is quite a bit more complicated than
+ * that of their aggregation kin.
+ *
+ * We observe that allocating new dynamic storage is tricky only because the
+ * size can vary -- the allocation problem is much easier if allocation sizes
+ * are uniform. We further observe that in D, the size of dynamic variables is
+ * actually _not_ dynamic -- dynamic variable sizes may be determined by static
+ * analysis of DIF text. (This is true even of putatively dynamically-sized
+ * objects like strings and stacks, the sizes of which are dictated by the
+ * "stringsize" and "stackframes" variables, respectively.) We exploit this by
+ * performing this analysis on all DIF before enabling any probes. For each
+ * dynamic load or store, we calculate the dynamically-allocated size plus the
+ * size of the dtrace_dynvar structure plus the storage required to key the
+ * data. For all DIF, we take the largest value and dub it the _chunksize_.
+ * We then divide dynamic memory into two parts: a hash table that is wide
+ * enough to have every chunk in its own bucket, and a larger region of equal
+ * chunksize units. Whenever we wish to dynamically allocate a variable, we
+ * always allocate a single chunk of memory. Depending on the uniformity of
+ * allocation, this will waste some amount of memory -- but it eliminates the
+ * non-determinism inherent in traditional heap fragmentation.
+ *
+ * Dynamic objects are allocated by storing a non-zero value to them; they are
+ * deallocated by storing a zero value to them. Dynamic variables are
+ * complicated enormously by being shared between CPUs. In particular,
+ * consider the following scenario:
+ *
+ * CPU A CPU B
+ * +---------------------------------+ +---------------------------------+
+ * | | | |
+ * | allocates dynamic object a[123] | | |
+ * | by storing the value 345 to it | | |
+ * | ---------> |
+ * | | | wishing to load from object |
+ * | | | a[123], performs lookup in |
+ * | | | dynamic variable space |
+ * | <--------- |
+ * | deallocates object a[123] by | | |
+ * | storing 0 to it | | |
+ * | | | |
+ * | allocates dynamic object b[567] | | performs load from a[123] |
+ * | by storing the value 789 to it | | |
+ * : : : :
+ * . . . .
+ *
+ * This is obviously a race in the D program, but there are nonetheless only
+ * two valid values for CPU B's load from a[123]: 345 or 0. Most importantly,
+ * CPU B may _not_ see the value 789 for a[123].
+ *
+ * There are essentially two ways to deal with this:
+ *
+ * (1) Explicitly spin-lock variables. That is, if CPU B wishes to load
+ * from a[123], it needs to lock a[123] and hold the lock for the
+ * duration that it wishes to manipulate it.
+ *
+ * (2) Avoid reusing freed chunks until it is known that no CPU is referring
+ * to them.
+ *
+ * The implementation of (1) is rife with complexity, because it requires the
+ * user of a dynamic variable to explicitly decree when they are done using it.
+ * Were all variables by value, this perhaps wouldn't be debilitating -- but
+ * dynamic variables of non-scalar types are tracked by reference. That is, if
+ * a dynamic variable is, say, a string, and that variable is to be traced to,
+ * say, the principal buffer, the DIF emulation code returns to the main
+ * dtrace_probe() loop a pointer to the underlying storage, not the contents of
+ * the storage. Further, code calling on DIF emulation would have to be aware
+ * that the DIF emulation has returned a reference to a dynamic variable that
+ * has been potentially locked. The variable would have to be unlocked after
+ * the main dtrace_probe() loop is finished with the variable, and the main
+ * dtrace_probe() loop would have to be careful to not call any further DIF
+ * emulation while the variable is locked to avoid deadlock. More generally,
+ * if one were to implement (1), DIF emulation code dealing with dynamic
+ * variables could only deal with one dynamic variable at a time (lest deadlock
+ * result). To sum, (1) exports too much subtlety to the users of dynamic
+ * variables -- increasing maintenance burden and imposing serious constraints
+ * on future DTrace development.
+ *
+ * The implementation of (2) is also complex, but the complexity is more
+ * manageable. We need to be sure that when a variable is deallocated, it is
+ * not placed on a traditional free list, but rather on a _dirty_ list. Once a
+ * variable is on a dirty list, it cannot be found by CPUs performing a
+ * subsequent lookup of the variable -- but it may still be in use by other
+ * CPUs. To assure that all CPUs that may be seeing the old variable have
+ * cleared out of probe context, a dtrace_sync() can be issued. Once the
+ * dtrace_sync() has completed, it can be known that all CPUs are done
+ * manipulating the dynamic variable -- the dirty list can be atomically
+ * appended to the free list. Unfortunately, there's a slight hiccup in this
+ * mechanism: dtrace_sync() may not be issued from probe context. The
+ * dtrace_sync() must be therefore issued asynchronously from non-probe
+ * context. For this we rely on the DTrace cleaner, a cyclic that runs at the
+ * "cleanrate" frequency. To ease this implementation, we define several chunk
+ * lists:
+ *
+ * - Dirty. Deallocated chunks, not yet cleaned. Not available.
+ *
+ * - Rinsing. Formerly dirty chunks that are currently being asynchronously
+ * cleaned. Not available, but will be shortly. Dynamic variable
+ * allocation may not spin or block for availability, however.
+ *
+ * - Clean. Clean chunks, ready for allocation -- but not on the free list.
+ *
+ * - Free. Available for allocation.
+ *
+ * Moreover, to avoid absurd contention, _each_ of these lists is implemented
+ * on a per-CPU basis. This is only for performance, not correctness; chunks
+ * may be allocated from another CPU's free list. The algorithm for allocation
+ * then is this:
+ *
+ * (1) Attempt to atomically allocate from current CPU's free list. If list
+ * is non-empty and allocation is successful, allocation is complete.
+ *
+ * (2) If the clean list is non-empty, atomically move it to the free list,
+ * and reattempt (1).
+ *
+ * (3) If the dynamic variable space is in the CLEAN state, look for free
+ * and clean lists on other CPUs by setting the current CPU to the next
+ * CPU, and reattempting (1). If the next CPU is the current CPU (that
+ * is, if all CPUs have been checked), atomically switch the state of
+ * the dynamic variable space based on the following:
+ *
+ * - If no free chunks were found and no dirty chunks were found,
+ * atomically set the state to EMPTY.
+ *
+ * - If dirty chunks were found, atomically set the state to DIRTY.
+ *
+ * - If rinsing chunks were found, atomically set the state to RINSING.
+ *
+ * (4) Based on state of dynamic variable space state, increment appropriate
+ * counter to indicate dynamic drops (if in EMPTY state) vs. dynamic
+ * dirty drops (if in DIRTY state) vs. dynamic rinsing drops (if in
+ * RINSING state). Fail the allocation.
+ *
+ * The cleaning cyclic operates with the following algorithm: for all CPUs
+ * with a non-empty dirty list, atomically move the dirty list to the rinsing
+ * list. Perform a dtrace_sync(). For all CPUs with a non-empty rinsing list,
+ * atomically move the rinsing list to the clean list. Perform another
+ * dtrace_sync(). By this point, all CPUs have seen the new clean list; the
+ * state of the dynamic variable space can be restored to CLEAN.
+ *
+ * There exist two final races that merit explanation. The first is a simple
+ * allocation race:
+ *
+ * CPU A CPU B
+ * +---------------------------------+ +---------------------------------+
+ * | | | |
+ * | allocates dynamic object a[123] | | allocates dynamic object a[123] |
+ * | by storing the value 345 to it | | by storing the value 567 to it |
+ * | | | |
+ * : : : :
+ * . . . .
+ *
+ * Again, this is a race in the D program. It can be resolved by having a[123]
+ * hold the value 345 or a[123] hold the value 567 -- but it must be true that
+ * a[123] have only _one_ of these values. (That is, the racing CPUs may not
+ * put the same element twice on the same hash chain.) This is resolved
+ * simply: before the allocation is undertaken, the start of the new chunk's
+ * hash chain is noted. Later, after the allocation is complete, the hash
+ * chain is atomically switched to point to the new element. If this fails
+ * (because of either concurrent allocations or an allocation concurrent with a
+ * deletion), the newly allocated chunk is deallocated to the dirty list, and
+ * the whole process of looking up (and potentially allocating) the dynamic
+ * variable is reattempted.
+ *
+ * The final race is a simple deallocation race:
+ *
+ * CPU A CPU B
+ * +---------------------------------+ +---------------------------------+
+ * | | | |
+ * | deallocates dynamic object | | deallocates dynamic object |
+ * | a[123] by storing the value 0 | | a[123] by storing the value 0 |
+ * | to it | | to it |
+ * | | | |
+ * : : : :
+ * . . . .
+ *
+ * Once again, this is a race in the D program, but it is one that we must
+ * handle without corrupting the underlying data structures. Because
+ * deallocations require the deletion of a chunk from the middle of a hash
+ * chain, we cannot use a single-word atomic operation to remove it. For this,
+ * we add a spin lock to the hash buckets that is _only_ used for deallocations
+ * (allocation races are handled as above). Further, this spin lock is _only_
+ * held for the duration of the delete; before control is returned to the DIF
+ * emulation code, the hash bucket is unlocked.
+ */
+typedef struct dtrace_key {
+ uint64_t dttk_value; /* data value or data pointer */
+ uint64_t dttk_size; /* 0 if by-val, >0 if by-ref */
+} dtrace_key_t;
+
+typedef struct dtrace_tuple {
+ uint32_t dtt_nkeys; /* number of keys in tuple */
+ uint32_t dtt_pad; /* padding */
+ dtrace_key_t dtt_key[1]; /* array of tuple keys */
+} dtrace_tuple_t;
+
+typedef struct dtrace_dynvar {
+ uint64_t dtdv_hashval; /* hash value -- 0 if free */
+ struct dtrace_dynvar *dtdv_next; /* next on list or hash chain */
+ void *dtdv_data; /* pointer to data */
+ dtrace_tuple_t dtdv_tuple; /* tuple key */
+} dtrace_dynvar_t;
+
+typedef enum dtrace_dynvar_op {
+ DTRACE_DYNVAR_ALLOC,
+ DTRACE_DYNVAR_NOALLOC,
+ DTRACE_DYNVAR_DEALLOC
+} dtrace_dynvar_op_t;
+
+typedef struct dtrace_dynhash {
+ dtrace_dynvar_t *dtdh_chain; /* hash chain for this bucket */
+ uintptr_t dtdh_lock; /* deallocation lock */
+#ifdef _LP64
+ uintptr_t dtdh_pad[6]; /* pad to avoid false sharing */
+#else
+ uintptr_t dtdh_pad[14]; /* pad to avoid false sharing */
+#endif
+} dtrace_dynhash_t;
+
+typedef struct dtrace_dstate_percpu {
+ dtrace_dynvar_t *dtdsc_free; /* free list for this CPU */
+ dtrace_dynvar_t *dtdsc_dirty; /* dirty list for this CPU */
+ dtrace_dynvar_t *dtdsc_rinsing; /* rinsing list for this CPU */
+ dtrace_dynvar_t *dtdsc_clean; /* clean list for this CPU */
+ uint64_t dtdsc_drops; /* number of capacity drops */
+ uint64_t dtdsc_dirty_drops; /* number of dirty drops */
+ uint64_t dtdsc_rinsing_drops; /* number of rinsing drops */
+#ifdef _LP64
+ uint64_t dtdsc_pad; /* pad to avoid false sharing */
+#else
+ uint64_t dtdsc_pad[2]; /* pad to avoid false sharing */
+#endif
+} dtrace_dstate_percpu_t;
+
+typedef enum dtrace_dstate_state {
+ DTRACE_DSTATE_CLEAN = 0,
+ DTRACE_DSTATE_EMPTY,
+ DTRACE_DSTATE_DIRTY,
+ DTRACE_DSTATE_RINSING
+} dtrace_dstate_state_t;
+
+typedef struct dtrace_dstate {
+ void *dtds_base; /* base of dynamic var. space */
+ size_t dtds_size; /* size of dynamic var. space */
+ size_t dtds_hashsize; /* number of buckets in hash */
+ size_t dtds_chunksize; /* size of each chunk */
+ dtrace_dynhash_t *dtds_hash; /* pointer to hash table */
+ dtrace_dstate_state_t dtds_state; /* current dynamic var. state */
+ dtrace_dstate_percpu_t *dtds_percpu; /* per-CPU dyn. var. state */
+} dtrace_dstate_t;
+
+/*
+ * DTrace Variable State
+ *
+ * The DTrace variable state tracks user-defined variables in its dtrace_vstate
+ * structure. Each DTrace consumer has exactly one dtrace_vstate structure,
+ * but some dtrace_vstate structures may exist without a corresponding DTrace
+ * consumer (see "DTrace Helpers", below). As described in <sys/dtrace.h>,
+ * user-defined variables can have one of three scopes:
+ *
+ * DIFV_SCOPE_GLOBAL => global scope
+ * DIFV_SCOPE_THREAD => thread-local scope (i.e. "self->" variables)
+ * DIFV_SCOPE_LOCAL => clause-local scope (i.e. "this->" variables)
+ *
+ * The variable state tracks variables by both their scope and their allocation
+ * type:
+ *
+ * - The dtvs_globals and dtvs_locals members each point to an array of
+ * dtrace_statvar structures. These structures contain both the variable
+ * metadata (dtrace_difv structures) and the underlying storage for all
+ * statically allocated variables, including statically allocated
+ * DIFV_SCOPE_GLOBAL variables and all DIFV_SCOPE_LOCAL variables.
+ *
+ * - The dtvs_tlocals member points to an array of dtrace_difv structures for
+ * DIFV_SCOPE_THREAD variables. As such, this array tracks _only_ the
+ * variable metadata for DIFV_SCOPE_THREAD variables; the underlying storage
+ * is allocated out of the dynamic variable space.
+ *
+ * - The dtvs_dynvars member is the dynamic variable state associated with the
+ * variable state. The dynamic variable state (described in "DTrace Dynamic
+ * Variables", above) tracks all DIFV_SCOPE_THREAD variables and all
+ * dynamically-allocated DIFV_SCOPE_GLOBAL variables.
+ */
+typedef struct dtrace_statvar {
+ uint64_t dtsv_data; /* data or pointer to it */
+ size_t dtsv_size; /* size of pointed-to data */
+ int dtsv_refcnt; /* reference count */
+ dtrace_difv_t dtsv_var; /* variable metadata */
+} dtrace_statvar_t;
+
+typedef struct dtrace_vstate {
+ dtrace_state_t *dtvs_state; /* back pointer to state */
+ dtrace_statvar_t **dtvs_globals; /* statically-allocated glbls */
+ int dtvs_nglobals; /* number of globals */
+ dtrace_difv_t *dtvs_tlocals; /* thread-local metadata */
+ int dtvs_ntlocals; /* number of thread-locals */
+ dtrace_statvar_t **dtvs_locals; /* clause-local data */
+ int dtvs_nlocals; /* number of clause-locals */
+ dtrace_dstate_t dtvs_dynvars; /* dynamic variable state */
+} dtrace_vstate_t;
+
+/*
+ * DTrace Machine State
+ *
+ * In the process of processing a fired probe, DTrace needs to track and/or
+ * cache some per-CPU state associated with that particular firing. This is
+ * state that is always discarded after the probe firing has completed, and
+ * much of it is not specific to any DTrace consumer, remaining valid across
+ * all ECBs. This state is tracked in the dtrace_mstate structure.
+ */
+#define DTRACE_MSTATE_ARGS 0x00000001
+#define DTRACE_MSTATE_PROBE 0x00000002
+#define DTRACE_MSTATE_EPID 0x00000004
+#define DTRACE_MSTATE_TIMESTAMP 0x00000008
+#define DTRACE_MSTATE_STACKDEPTH 0x00000010
+#define DTRACE_MSTATE_CALLER 0x00000020
+#define DTRACE_MSTATE_IPL 0x00000040
+#define DTRACE_MSTATE_FLTOFFS 0x00000080
+#define DTRACE_MSTATE_WALLTIMESTAMP 0x00000100
+#define DTRACE_MSTATE_USTACKDEPTH 0x00000200
+#define DTRACE_MSTATE_UCALLER 0x00000400
+
+typedef struct dtrace_mstate {
+ uintptr_t dtms_scratch_base; /* base of scratch space */
+ uintptr_t dtms_scratch_ptr; /* current scratch pointer */
+ size_t dtms_scratch_size; /* scratch size */
+ uint32_t dtms_present; /* variables that are present */
+ uint64_t dtms_arg[5]; /* cached arguments */
+ dtrace_epid_t dtms_epid; /* current EPID */
+ uint64_t dtms_timestamp; /* cached timestamp */
+ hrtime_t dtms_walltimestamp; /* cached wall timestamp */
+ int dtms_stackdepth; /* cached stackdepth */
+ int dtms_ustackdepth; /* cached ustackdepth */
+ struct dtrace_probe *dtms_probe; /* current probe */
+ uintptr_t dtms_caller; /* cached caller */
+ uint64_t dtms_ucaller; /* cached user-level caller */
+ int dtms_ipl; /* cached interrupt pri lev */
+ int dtms_fltoffs; /* faulting DIFO offset */
+ uintptr_t dtms_strtok; /* saved strtok() pointer */
+ uint32_t dtms_access; /* memory access rights */
+ dtrace_difo_t *dtms_difo; /* current dif object */
+} dtrace_mstate_t;
+
+#define DTRACE_COND_OWNER 0x1
+#define DTRACE_COND_USERMODE 0x2
+#define DTRACE_COND_ZONEOWNER 0x4
+
+#define DTRACE_PROBEKEY_MAXDEPTH 8 /* max glob recursion depth */
+
+/*
+ * Access flag used by dtrace_mstate.dtms_access.
+ */
+#define DTRACE_ACCESS_KERNEL 0x1 /* the priv to read kmem */
+
+
+/*
+ * DTrace Activity
+ *
+ * Each DTrace consumer is in one of several states, which (for purposes of
+ * avoiding yet-another overloading of the noun "state") we call the current
+ * _activity_. The activity transitions on dtrace_go() (from DTRACIOCGO), on
+ * dtrace_stop() (from DTRACIOCSTOP) and on the exit() action. Activities may
+ * only transition in one direction; the activity transition diagram is a
+ * directed acyclic graph. The activity transition diagram is as follows:
+ *
+ *
+ * +----------+ +--------+ +--------+
+ * | INACTIVE |------------------>| WARMUP |------------------>| ACTIVE |
+ * +----------+ dtrace_go(), +--------+ dtrace_go(), +--------+
+ * before BEGIN | after BEGIN | | |
+ * | | | |
+ * exit() action | | | |
+ * from BEGIN ECB | | | |
+ * | | | |
+ * v | | |
+ * +----------+ exit() action | | |
+ * +-----------------------------| DRAINING |<-------------------+ | |
+ * | +----------+ | |
+ * | | | |
+ * | dtrace_stop(), | | |
+ * | before END | | |
+ * | | | |
+ * | v | |
+ * | +---------+ +----------+ | |
+ * | | STOPPED |<----------------| COOLDOWN |<----------------------+ |
+ * | +---------+ dtrace_stop(), +----------+ dtrace_stop(), |
+ * | after END before END |
+ * | |
+ * | +--------+ |
+ * +----------------------------->| KILLED |<--------------------------+
+ * deadman timeout or +--------+ deadman timeout or
+ * killed consumer killed consumer
+ *
+ * Note that once a DTrace consumer has stopped tracing, there is no way to
+ * restart it; if a DTrace consumer wishes to restart tracing, it must reopen
+ * the DTrace pseudodevice.
+ */
+typedef enum dtrace_activity {
+ DTRACE_ACTIVITY_INACTIVE = 0, /* not yet running */
+ DTRACE_ACTIVITY_WARMUP, /* while starting */
+ DTRACE_ACTIVITY_ACTIVE, /* running */
+ DTRACE_ACTIVITY_DRAINING, /* before stopping */
+ DTRACE_ACTIVITY_COOLDOWN, /* while stopping */
+ DTRACE_ACTIVITY_STOPPED, /* after stopping */
+ DTRACE_ACTIVITY_KILLED /* killed */
+} dtrace_activity_t;
+
+/*
+ * DTrace Helper Implementation
+ *
+ * A description of the helper architecture may be found in <sys/dtrace.h>.
+ * Each process contains a pointer to its helpers in its p_dtrace_helpers
+ * member. This is a pointer to a dtrace_helpers structure, which contains an
+ * array of pointers to dtrace_helper structures, helper variable state (shared
+ * among a process's helpers) and a generation count. (The generation count is
+ * used to provide an identifier when a helper is added so that it may be
+ * subsequently removed.) The dtrace_helper structure is self-explanatory,
+ * containing pointers to the objects needed to execute the helper. Note that
+ * helpers are _duplicated_ across fork(2), and destroyed on exec(2). No more
+ * than dtrace_helpers_max are allowed per-process.
+ */
+#define DTRACE_HELPER_ACTION_USTACK 0
+#define DTRACE_NHELPER_ACTIONS 1
+
+typedef struct dtrace_helper_action {
+ int dtha_generation; /* helper action generation */
+ int dtha_nactions; /* number of actions */
+ dtrace_difo_t *dtha_predicate; /* helper action predicate */
+ dtrace_difo_t **dtha_actions; /* array of actions */
+ struct dtrace_helper_action *dtha_next; /* next helper action */
+} dtrace_helper_action_t;
+
+typedef struct dtrace_helper_provider {
+ int dthp_generation; /* helper provider generation */
+ uint32_t dthp_ref; /* reference count */
+ dof_helper_t dthp_prov; /* DOF w/ provider and probes */
+} dtrace_helper_provider_t;
+
+typedef struct dtrace_helpers {
+ dtrace_helper_action_t **dthps_actions; /* array of helper actions */
+ dtrace_vstate_t dthps_vstate; /* helper action var. state */
+ dtrace_helper_provider_t **dthps_provs; /* array of providers */
+ uint_t dthps_nprovs; /* count of providers */
+ uint_t dthps_maxprovs; /* provider array size */
+ int dthps_generation; /* current generation */
+ pid_t dthps_pid; /* pid of associated proc */
+ int dthps_deferred; /* helper in deferred list */
+ struct dtrace_helpers *dthps_next; /* next pointer */
+ struct dtrace_helpers *dthps_prev; /* prev pointer */
+} dtrace_helpers_t;
+
+/*
+ * DTrace Helper Action Tracing
+ *
+ * Debugging helper actions can be arduous. To ease the development and
+ * debugging of helpers, DTrace contains a tracing-framework-within-a-tracing-
+ * framework: helper tracing. If dtrace_helptrace_enabled is non-zero (which
+ * it is by default on DEBUG kernels), all helper activity will be traced to a
+ * global, in-kernel ring buffer. Each entry includes a pointer to the specific
+ * helper, the location within the helper, and a trace of all local variables.
+ * The ring buffer may be displayed in a human-readable format with the
+ * ::dtrace_helptrace mdb(1) dcmd.
+ */
+#define DTRACE_HELPTRACE_NEXT (-1)
+#define DTRACE_HELPTRACE_DONE (-2)
+#define DTRACE_HELPTRACE_ERR (-3)
+
+typedef struct dtrace_helptrace {
+ dtrace_helper_action_t *dtht_helper; /* helper action */
+ int dtht_where; /* where in helper action */
+ int dtht_nlocals; /* number of locals */
+ int dtht_fault; /* type of fault (if any) */
+ int dtht_fltoffs; /* DIF offset */
+ uint64_t dtht_illval; /* faulting value */
+ uint64_t dtht_locals[1]; /* local variables */
+} dtrace_helptrace_t;
+
+/*
+ * DTrace Credentials
+ *
+ * In probe context, we have limited flexibility to examine the credentials
+ * of the DTrace consumer that created a particular enabling. We use
+ * the Least Privilege interfaces to cache the consumer's cred pointer and
+ * some facts about that credential in a dtrace_cred_t structure. These
+ * can limit the consumer's breadth of visibility and what actions the
+ * consumer may take.
+ */
+#define DTRACE_CRV_ALLPROC 0x01
+#define DTRACE_CRV_KERNEL 0x02
+#define DTRACE_CRV_ALLZONE 0x04
+
+#define DTRACE_CRV_ALL (DTRACE_CRV_ALLPROC | DTRACE_CRV_KERNEL | \
+ DTRACE_CRV_ALLZONE)
+
+#define DTRACE_CRA_PROC 0x0001
+#define DTRACE_CRA_PROC_CONTROL 0x0002
+#define DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER 0x0004
+#define DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE 0x0008
+#define DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG 0x0010
+#define DTRACE_CRA_KERNEL 0x0020
+#define DTRACE_CRA_KERNEL_DESTRUCTIVE 0x0040
+
+#define DTRACE_CRA_ALL (DTRACE_CRA_PROC | \
+ DTRACE_CRA_PROC_CONTROL | \
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER | \
+ DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE | \
+ DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG | \
+ DTRACE_CRA_KERNEL | \
+ DTRACE_CRA_KERNEL_DESTRUCTIVE)
+
+typedef struct dtrace_cred {
+ cred_t *dcr_cred;
+ uint8_t dcr_destructive;
+ uint8_t dcr_visible;
+ uint16_t dcr_action;
+} dtrace_cred_t;
+
+/*
+ * DTrace Consumer State
+ *
+ * Each DTrace consumer has an associated dtrace_state structure that contains
+ * its in-kernel DTrace state -- including options, credentials, statistics and
+ * pointers to ECBs, buffers, speculations and formats. A dtrace_state
+ * structure is also allocated for anonymous enablings. When anonymous state
+ * is grabbed, the grabbing consumers dts_anon pointer is set to the grabbed
+ * dtrace_state structure.
+ */
+struct dtrace_state {
+#ifndef VBOX
+ dev_t dts_dev; /* device */
+#endif
+ int dts_necbs; /* total number of ECBs */
+ dtrace_ecb_t **dts_ecbs; /* array of ECBs */
+ dtrace_epid_t dts_epid; /* next EPID to allocate */
+ size_t dts_needed; /* greatest needed space */
+ struct dtrace_state *dts_anon; /* anon. state, if grabbed */
+ dtrace_activity_t dts_activity; /* current activity */
+ dtrace_vstate_t dts_vstate; /* variable state */
+ dtrace_buffer_t *dts_buffer; /* principal buffer */
+ dtrace_buffer_t *dts_aggbuffer; /* aggregation buffer */
+ dtrace_speculation_t *dts_speculations; /* speculation array */
+ int dts_nspeculations; /* number of speculations */
+ int dts_naggregations; /* number of aggregations */
+ dtrace_aggregation_t **dts_aggregations; /* aggregation array */
+ vmem_t *dts_aggid_arena; /* arena for aggregation IDs */
+ uint64_t dts_errors; /* total number of errors */
+ uint32_t dts_speculations_busy; /* number of spec. busy */
+ uint32_t dts_speculations_unavail; /* number of spec unavail */
+ uint32_t dts_stkstroverflows; /* stack string tab overflows */
+ uint32_t dts_dblerrors; /* errors in ERROR probes */
+ uint32_t dts_reserve; /* space reserved for END */
+ hrtime_t dts_laststatus; /* time of last status */
+ cyclic_id_t dts_cleaner; /* cleaning cyclic */
+ cyclic_id_t dts_deadman; /* deadman cyclic */
+ hrtime_t dts_alive; /* time last alive */
+ char dts_speculates; /* boolean: has speculations */
+ char dts_destructive; /* boolean: has dest. actions */
+ int dts_nformats; /* number of formats */
+ char **dts_formats; /* format string array */
+ dtrace_optval_t dts_options[DTRACEOPT_MAX]; /* options */
+ dtrace_cred_t dts_cred; /* credentials */
+ size_t dts_nretained; /* number of retained enabs */
+};
+
+struct dtrace_provider {
+ dtrace_pattr_t dtpv_attr; /* provider attributes */
+ dtrace_ppriv_t dtpv_priv; /* provider privileges */
+ dtrace_pops_t dtpv_pops; /* provider operations */
+ char *dtpv_name; /* provider name */
+ void *dtpv_arg; /* provider argument */
+ uint_t dtpv_defunct; /* boolean: defunct provider */
+ struct dtrace_provider *dtpv_next; /* next provider */
+};
+
+struct dtrace_meta {
+ dtrace_mops_t dtm_mops; /* meta provider operations */
+ char *dtm_name; /* meta provider name */
+ void *dtm_arg; /* meta provider user arg */
+ uint64_t dtm_count; /* no. of associated provs. */
+};
+
+/*
+ * DTrace Enablings
+ *
+ * A dtrace_enabling structure is used to track a collection of ECB
+ * descriptions -- before they have been turned into actual ECBs. This is
+ * created as a result of DOF processing, and is generally used to generate
+ * ECBs immediately thereafter. However, enablings are also generally
+ * retained should the probes they describe be created at a later time; as
+ * each new module or provider registers with the framework, the retained
+ * enablings are reevaluated, with any new match resulting in new ECBs. To
+ * prevent probes from being matched more than once, the enabling tracks the
+ * last probe generation matched, and only matches probes from subsequent
+ * generations.
+ */
+typedef struct dtrace_enabling {
+ dtrace_ecbdesc_t **dten_desc; /* all ECB descriptions */
+ int dten_ndesc; /* number of ECB descriptions */
+ int dten_maxdesc; /* size of ECB array */
+ dtrace_vstate_t *dten_vstate; /* associated variable state */
+ dtrace_genid_t dten_probegen; /* matched probe generation */
+ dtrace_ecbdesc_t *dten_current; /* current ECB description */
+ int dten_error; /* current error value */
+ int dten_primed; /* boolean: set if primed */
+ struct dtrace_enabling *dten_prev; /* previous enabling */
+ struct dtrace_enabling *dten_next; /* next enabling */
+} dtrace_enabling_t;
+
+/*
+ * DTrace Anonymous Enablings
+ *
+ * Anonymous enablings are DTrace enablings that are not associated with a
+ * controlling process, but rather derive their enabling from DOF stored as
+ * properties in the dtrace.conf file. If there is an anonymous enabling, a
+ * DTrace consumer state and enabling are created on attach. The state may be
+ * subsequently grabbed by the first consumer specifying the "grabanon"
+ * option. As long as an anonymous DTrace enabling exists, dtrace(7D) will
+ * refuse to unload.
+ */
+typedef struct dtrace_anon {
+ dtrace_state_t *dta_state; /* DTrace consumer state */
+ dtrace_enabling_t *dta_enabling; /* pointer to enabling */
+ processorid_t dta_beganon; /* which CPU BEGIN ran on */
+} dtrace_anon_t;
+
+/*
+ * DTrace Error Debugging
+ */
+#ifdef DEBUG
+#define DTRACE_ERRDEBUG
+#endif
+
+#ifdef DTRACE_ERRDEBUG
+
+typedef struct dtrace_errhash {
+ const char *dter_msg; /* error message */
+ int dter_count; /* number of times seen */
+} dtrace_errhash_t;
+
+#define DTRACE_ERRHASHSZ 256 /* must be > number of err msgs */
+
+#endif /* DTRACE_ERRDEBUG */
+
+/*
+ * DTrace Toxic Ranges
+ *
+ * DTrace supports safe loads from probe context; if the address turns out to
+ * be invalid, a bit will be set by the kernel indicating that DTrace
+ * encountered a memory error, and DTrace will propagate the error to the user
+ * accordingly. However, there may exist some regions of memory in which an
+ * arbitrary load can change system state, and from which it is impossible to
+ * recover from such a load after it has been attempted. Examples of this may
+ * include memory in which programmable I/O registers are mapped (for which a
+ * read may have some implications for the device) or (in the specific case of
+ * UltraSPARC-I and -II) the virtual address hole. The platform is required
+ * to make DTrace aware of these toxic ranges; DTrace will then check that
+ * target addresses are not in a toxic range before attempting to issue a
+ * safe load.
+ */
+typedef struct dtrace_toxrange {
+ uintptr_t dtt_base; /* base of toxic range */
+ uintptr_t dtt_limit; /* limit of toxic range */
+} dtrace_toxrange_t;
+
+extern uint64_t dtrace_getarg(int, int);
+extern greg_t dtrace_getfp(void);
+extern int dtrace_getipl(void);
+extern uintptr_t dtrace_caller(int);
+extern uint32_t dtrace_cas32(uint32_t *, uint32_t, uint32_t);
+extern void *dtrace_casptr(void *, void *, void *);
+extern void dtrace_copyin(uintptr_t, uintptr_t, size_t, volatile uint16_t *);
+extern void dtrace_copyinstr(uintptr_t, uintptr_t, size_t, volatile uint16_t *);
+extern void dtrace_copyout(uintptr_t, uintptr_t, size_t, volatile uint16_t *);
+extern void dtrace_copyoutstr(uintptr_t, uintptr_t, size_t,
+ volatile uint16_t *);
+extern void dtrace_getpcstack(pc_t *, int, int, uint32_t *);
+extern ulong_t dtrace_getreg(struct regs *, uint_t);
+extern int dtrace_getstackdepth(int);
+extern void dtrace_getupcstack(uint64_t *, int);
+extern void dtrace_getufpstack(uint64_t *, uint64_t *, int);
+extern int dtrace_getustackdepth(void);
+extern uintptr_t dtrace_fulword(void *);
+extern uint8_t dtrace_fuword8(void *);
+extern uint16_t dtrace_fuword16(void *);
+extern uint32_t dtrace_fuword32(void *);
+extern uint64_t dtrace_fuword64(void *);
+extern void dtrace_probe_error(dtrace_state_t *, dtrace_epid_t, int, int,
+ int, uintptr_t);
+extern int dtrace_assfail(const char *, const char *, int);
+extern int dtrace_attached(void);
+extern hrtime_t dtrace_gethrestime(void);
+
+#ifdef __sparc
+extern void dtrace_flush_windows(void);
+extern void dtrace_flush_user_windows(void);
+extern uint_t dtrace_getotherwin(void);
+extern uint_t dtrace_getfprs(void);
+#else
+extern void dtrace_copy(uintptr_t, uintptr_t, size_t);
+extern void dtrace_copystr(uintptr_t, uintptr_t, size_t, volatile uint16_t *);
+#endif
+
+#ifndef VBOX /* got our own assert thing */
+/*
+ * DTrace Assertions
+ *
+ * DTrace calls ASSERT from probe context. To assure that a failed ASSERT
+ * does not induce a markedly more catastrophic failure (e.g., one from which
+ * a dump cannot be gleaned), DTrace must define its own ASSERT to be one that
+ * may safely be called from probe context. This header file must thus be
+ * included by any DTrace component that calls ASSERT from probe context, and
+ * _only_ by those components. (The only exception to this is kernel
+ * debugging infrastructure at user-level that doesn't depend on calling
+ * ASSERT.)
+ */
+#undef ASSERT
+#ifdef DEBUG
+#define ASSERT(EX) ((void)((EX) || \
+ dtrace_assfail(#EX, __FILE__, __LINE__)))
+#else
+#define ASSERT(X) ((void)0)
+#endif
+#endif /* !VBOX */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_DTRACE_IMPL_H */
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/dtrace_subr.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/dtrace_subr.c
new file mode 100644
index 00000000..baf79197
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/i86pc/os/dtrace_subr.c
@@ -0,0 +1,400 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <sys/dtrace.h>
+#include <sys/fasttrap.h>
+#include <sys/x_call.h>
+#include <sys/cmn_err.h>
+#include <sys/trap.h>
+#include <sys/psw.h>
+#include <sys/privregs.h>
+#include <sys/machsystm.h>
+#include <vm/seg_kmem.h>
+
+typedef struct dtrace_invop_hdlr {
+ int (*dtih_func)(uintptr_t, uintptr_t *, uintptr_t);
+ struct dtrace_invop_hdlr *dtih_next;
+} dtrace_invop_hdlr_t;
+
+dtrace_invop_hdlr_t *dtrace_invop_hdlr;
+
+int
+dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
+{
+ dtrace_invop_hdlr_t *hdlr;
+ int rval;
+
+ for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next) {
+ if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0)
+ return (rval);
+ }
+
+ return (0);
+}
+
+void
+dtrace_invop_add(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+{
+ dtrace_invop_hdlr_t *hdlr;
+
+ hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+ hdlr->dtih_func = func;
+ hdlr->dtih_next = dtrace_invop_hdlr;
+ dtrace_invop_hdlr = hdlr;
+}
+
+void
+dtrace_invop_remove(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+{
+ dtrace_invop_hdlr_t *hdlr = dtrace_invop_hdlr, *prev = NULL;
+
+ for (;;) {
+ if (hdlr == NULL)
+ panic("attempt to remove non-existent invop handler");
+
+ if (hdlr->dtih_func == func)
+ break;
+
+ prev = hdlr;
+ hdlr = hdlr->dtih_next;
+ }
+
+ if (prev == NULL) {
+ ASSERT(dtrace_invop_hdlr == hdlr);
+ dtrace_invop_hdlr = hdlr->dtih_next;
+ } else {
+ ASSERT(dtrace_invop_hdlr != hdlr);
+ prev->dtih_next = hdlr->dtih_next;
+ }
+
+ kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
+}
+
+int
+dtrace_getipl(void)
+{
+ return (CPU->cpu_pri);
+}
+
+/*ARGSUSED*/
+void
+dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
+{
+#ifdef __amd64
+ extern uintptr_t toxic_addr;
+ extern size_t toxic_size;
+
+ (*func)(0, _userlimit);
+
+ if (hole_end > hole_start)
+ (*func)(hole_start, hole_end);
+ (*func)(toxic_addr, toxic_addr + toxic_size);
+#else
+ extern void *device_arena_contains(void *, size_t, size_t *);
+ caddr_t vaddr;
+ size_t len;
+
+ for (vaddr = (caddr_t)kernelbase; vaddr < (caddr_t)KERNEL_TEXT;
+ vaddr += len) {
+ len = (caddr_t)KERNEL_TEXT - vaddr;
+ vaddr = device_arena_contains(vaddr, len, &len);
+ if (vaddr == NULL)
+ break;
+ (*func)((uintptr_t)vaddr, (uintptr_t)vaddr + len);
+ }
+#endif
+ (*func)(0, _userlimit);
+}
+
+static int
+dtrace_xcall_func(dtrace_xcall_t func, void *arg)
+{
+ (*func)(arg);
+
+ return (0);
+}
+
+/*ARGSUSED*/
+void
+dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg)
+{
+ cpuset_t set;
+
+ CPUSET_ZERO(set);
+
+ if (cpu == DTRACE_CPUALL) {
+ CPUSET_ALL(set);
+ } else {
+ CPUSET_ADD(set, cpu);
+ }
+
+ kpreempt_disable();
+ xc_sync((xc_arg_t)func, (xc_arg_t)arg, 0, CPUSET2BV(set),
+ (xc_func_t)dtrace_xcall_func);
+ kpreempt_enable();
+}
+
+void
+dtrace_sync_func(void)
+{}
+
+void
+dtrace_sync(void)
+{
+ dtrace_xcall(DTRACE_CPUALL, (dtrace_xcall_t)dtrace_sync_func, NULL);
+}
+
+int (*dtrace_pid_probe_ptr)(struct regs *);
+int (*dtrace_return_probe_ptr)(struct regs *);
+
+void
+dtrace_user_probe(struct regs *rp, caddr_t addr, processorid_t cpuid)
+{
+ krwlock_t *rwp;
+ proc_t *p = curproc;
+ extern void trap(struct regs *, caddr_t, processorid_t);
+
+ if (USERMODE(rp->r_cs) || (rp->r_ps & PS_VM)) {
+ if (curthread->t_cred != p->p_cred) {
+ cred_t *oldcred = curthread->t_cred;
+ /*
+ * DTrace accesses t_cred in probe context. t_cred
+ * must always be either NULL, or point to a valid,
+ * allocated cred structure.
+ */
+ curthread->t_cred = crgetcred();
+ crfree(oldcred);
+ }
+ }
+
+ if (rp->r_trapno == T_DTRACE_RET) {
+ uint8_t step = curthread->t_dtrace_step;
+ uint8_t ret = curthread->t_dtrace_ret;
+ uintptr_t npc = curthread->t_dtrace_npc;
+
+ if (curthread->t_dtrace_ast) {
+ aston(curthread);
+ curthread->t_sig_check = 1;
+ }
+
+ /*
+ * Clear all user tracing flags.
+ */
+ curthread->t_dtrace_ft = 0;
+
+ /*
+ * If we weren't expecting to take a return probe trap, kill
+ * the process as though it had just executed an unassigned
+ * trap instruction.
+ */
+ if (step == 0) {
+ tsignal(curthread, SIGILL);
+ return;
+ }
+
+ /*
+ * If we hit this trap unrelated to a return probe, we're
+ * just here to reset the AST flag since we deferred a signal
+ * until after we logically single-stepped the instruction we
+ * copied out.
+ */
+ if (ret == 0) {
+ rp->r_pc = npc;
+ return;
+ }
+
+ /*
+ * We need to wait until after we've called the
+ * dtrace_return_probe_ptr function pointer to set %pc.
+ */
+ rwp = &CPU->cpu_ft_lock;
+ rw_enter(rwp, RW_READER);
+ if (dtrace_return_probe_ptr != NULL)
+ (void) (*dtrace_return_probe_ptr)(rp);
+ rw_exit(rwp);
+ rp->r_pc = npc;
+
+ } else if (rp->r_trapno == T_BPTFLT) {
+ uint8_t instr, instr2;
+ caddr_t linearpc;
+ rwp = &CPU->cpu_ft_lock;
+
+ /*
+ * The DTrace fasttrap provider uses the breakpoint trap
+ * (int 3). We let DTrace take the first crack at handling
+ * this trap; if it's not a probe that DTrace knowns about,
+ * we call into the trap() routine to handle it like a
+ * breakpoint placed by a conventional debugger.
+ */
+ rw_enter(rwp, RW_READER);
+ if (dtrace_pid_probe_ptr != NULL &&
+ (*dtrace_pid_probe_ptr)(rp) == 0) {
+ rw_exit(rwp);
+ return;
+ }
+ rw_exit(rwp);
+
+ if (dtrace_linear_pc(rp, p, &linearpc) != 0) {
+ trap(rp, addr, cpuid);
+ return;
+ }
+
+ /*
+ * If the instruction that caused the breakpoint trap doesn't
+ * look like an int 3 anymore, it may be that this tracepoint
+ * was removed just after the user thread executed it. In
+ * that case, return to user land to retry the instuction.
+ * Note that we assume the length of the instruction to retry
+ * is 1 byte because that's the length of FASTTRAP_INSTR.
+ * We check for r_pc > 0 and > 2 so that we don't have to
+ * deal with segment wraparound.
+ */
+ if (rp->r_pc > 0 && fuword8(linearpc - 1, &instr) == 0 &&
+ instr != FASTTRAP_INSTR &&
+ (instr != 3 || (rp->r_pc >= 2 &&
+ (fuword8(linearpc - 2, &instr2) != 0 || instr2 != 0xCD)))) {
+ rp->r_pc--;
+ return;
+ }
+
+ trap(rp, addr, cpuid);
+
+ } else {
+ trap(rp, addr, cpuid);
+ }
+}
+
+void
+dtrace_safe_synchronous_signal(void)
+{
+ kthread_t *t = curthread;
+ struct regs *rp = lwptoregs(ttolwp(t));
+ size_t isz = t->t_dtrace_npc - t->t_dtrace_pc;
+
+ ASSERT(t->t_dtrace_on);
+
+ /*
+ * If we're not in the range of scratch addresses, we're not actually
+ * tracing user instructions so turn off the flags. If the instruction
+ * we copied out caused a synchonous trap, reset the pc back to its
+ * original value and turn off the flags.
+ */
+ if (rp->r_pc < t->t_dtrace_scrpc ||
+ rp->r_pc > t->t_dtrace_astpc + isz) {
+ t->t_dtrace_ft = 0;
+ } else if (rp->r_pc == t->t_dtrace_scrpc ||
+ rp->r_pc == t->t_dtrace_astpc) {
+ rp->r_pc = t->t_dtrace_pc;
+ t->t_dtrace_ft = 0;
+ }
+}
+
+int
+dtrace_safe_defer_signal(void)
+{
+ kthread_t *t = curthread;
+ struct regs *rp = lwptoregs(ttolwp(t));
+ size_t isz = t->t_dtrace_npc - t->t_dtrace_pc;
+
+ ASSERT(t->t_dtrace_on);
+
+ /*
+ * If we're not in the range of scratch addresses, we're not actually
+ * tracing user instructions so turn off the flags.
+ */
+ if (rp->r_pc < t->t_dtrace_scrpc ||
+ rp->r_pc > t->t_dtrace_astpc + isz) {
+ t->t_dtrace_ft = 0;
+ return (0);
+ }
+
+ /*
+ * If we've executed the original instruction, but haven't performed
+ * the jmp back to t->t_dtrace_npc or the clean up of any registers
+ * used to emulate %rip-relative instructions in 64-bit mode, do that
+ * here and take the signal right away. We detect this condition by
+ * seeing if the program counter is the range [scrpc + isz, astpc).
+ */
+ if (t->t_dtrace_astpc - rp->r_pc <
+ t->t_dtrace_astpc - t->t_dtrace_scrpc - isz) {
+#ifdef __amd64
+ /*
+ * If there is a scratch register and we're on the
+ * instruction immediately after the modified instruction,
+ * restore the value of that scratch register.
+ */
+ if (t->t_dtrace_reg != 0 &&
+ rp->r_pc == t->t_dtrace_scrpc + isz) {
+ switch (t->t_dtrace_reg) {
+ case REG_RAX:
+ rp->r_rax = t->t_dtrace_regv;
+ break;
+ case REG_RCX:
+ rp->r_rcx = t->t_dtrace_regv;
+ break;
+ case REG_R8:
+ rp->r_r8 = t->t_dtrace_regv;
+ break;
+ case REG_R9:
+ rp->r_r9 = t->t_dtrace_regv;
+ break;
+ }
+ }
+#endif
+ rp->r_pc = t->t_dtrace_npc;
+ t->t_dtrace_ft = 0;
+ return (0);
+ }
+
+ /*
+ * Otherwise, make sure we'll return to the kernel after executing
+ * the copied out instruction and defer the signal.
+ */
+ if (!t->t_dtrace_step) {
+ ASSERT(rp->r_pc < t->t_dtrace_astpc);
+ rp->r_pc += t->t_dtrace_astpc - t->t_dtrace_scrpc;
+ t->t_dtrace_step = 1;
+ }
+
+ t->t_dtrace_ast = 1;
+
+ return (1);
+}
+
+/*
+ * Additional artificial frames for the machine type. For i86pc, we're already
+ * accounted for, so return 0. On the hypervisor, we have an additional frame
+ * (xen_callback_handler).
+ */
+int
+dtrace_mach_aframes(void)
+{
+#ifdef __xpv
+ return (1);
+#else
+ return (0);
+#endif
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile
new file mode 100644
index 00000000..5cd153e3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile
@@ -0,0 +1,76 @@
+#
+# 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 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+UTSBASE = ../..
+
+MODULE = dtrace
+OBJECTS = $(DTRACE_OBJS:%=$(OBJS_DIR)/%)
+LINTS = $(DTRACE_OBJS:%.o=$(LINTS_DIR)/%.ln)
+ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE)
+CONF_SRCDIR = $(UTSBASE)/common/dtrace
+
+include $(UTSBASE)/intel/Makefile.intel
+
+#
+# For now, disable these lint checks; maintainers should endeavor
+# to investigate and remove these for maximum lint coverage.
+# Please do not carry these forward to new Makefiles.
+#
+LINTTAGS += -erroff=E_SUSPICIOUS_COMPARISON
+LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN
+LINTTAGS += -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
+LINTTAGS += -erroff=E_STATIC_UNUSED
+LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW
+LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV
+
+ALL_TARGET = $(BINARY) $(SRC_CONFILE)
+LINT_TARGET = $(MODULE).lint
+INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE)
+AS_INC_PATH += -I$(DSF_DIR)/$(OBJS_DIR)
+
+ASSYM_H = $(DSF_DIR)/$(OBJS_DIR)/assym.h
+
+.KEEP_STATE:
+
+def: $(DEF_DEPS)
+
+all: $(ALL_DEPS)
+
+clean: $(CLEAN_DEPS)
+
+clobber: $(CLOBBER_DEPS)
+
+lint: $(LINT_DEPS)
+
+modlintlib: $(MODLINTLIB_DEPS)
+
+clean.lint: $(CLEAN_LINT_DEPS)
+
+install: $(INSTALL_DEPS)
+
+$(BINARY): $(ASSYM_H)
+
+include $(UTSBASE)/intel/Makefile.targ
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_asm.s b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_asm.s
new file mode 100644
index 00000000..47b981d1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_asm.s
@@ -0,0 +1,457 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+#include <sys/regset.h>
+
+#if defined(lint)
+#include <sys/dtrace_impl.h>
+#else
+#include "assym.h"
+#endif
+
+#if defined(lint) || defined(__lint)
+
+greg_t
+dtrace_getfp(void)
+{ return (0); }
+
+#else /* lint */
+
+#if defined(__amd64)
+
+ ENTRY_NP(dtrace_getfp)
+ movq %rbp, %rax
+ ret
+ SET_SIZE(dtrace_getfp)
+
+#elif defined(__i386)
+
+ ENTRY_NP(dtrace_getfp)
+ movl %ebp, %eax
+ ret
+ SET_SIZE(dtrace_getfp)
+
+#endif /* __i386 */
+#endif /* lint */
+
+
+#if defined(lint) || defined(__lint)
+
+uint32_t
+dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
+{
+ uint32_t old;
+
+ if ((old = *target) == cmp)
+ *target = new;
+ return (old);
+}
+
+void *
+dtrace_casptr(void *target, void *cmp, void *new)
+{
+ void *old;
+
+ if ((old = *(void **)target) == cmp)
+ *(void **)target = new;
+ return (old);
+}
+
+#else /* lint */
+
+#if defined(__amd64)
+
+ ENTRY(dtrace_cas32)
+ movl %esi, %eax
+ lock
+ cmpxchgl %edx, (%rdi)
+ ret
+ SET_SIZE(dtrace_cas32)
+
+ ENTRY(dtrace_casptr)
+ movq %rsi, %rax
+ lock
+ cmpxchgq %rdx, (%rdi)
+ ret
+ SET_SIZE(dtrace_casptr)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_cas32)
+ ALTENTRY(dtrace_casptr)
+ movl 4(%esp), %edx
+ movl 8(%esp), %eax
+ movl 12(%esp), %ecx
+ lock
+ cmpxchgl %ecx, (%edx)
+ ret
+ SET_SIZE(dtrace_casptr)
+ SET_SIZE(dtrace_cas32)
+
+#endif /* __i386 */
+#endif /* lint */
+
+#if defined(lint)
+
+/*ARGSUSED*/
+uintptr_t
+dtrace_caller(int aframes)
+{
+ return (0);
+}
+
+#else /* lint */
+
+#if defined(__amd64)
+ ENTRY(dtrace_caller)
+ movq $-1, %rax
+ ret
+ SET_SIZE(dtrace_caller)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_caller)
+ movl $-1, %eax
+ ret
+ SET_SIZE(dtrace_caller)
+
+#endif /* __i386 */
+#endif /* lint */
+
+#if defined(lint)
+
+/*ARGSUSED*/
+void
+dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
+{}
+
+#else
+
+#if defined(__amd64)
+
+ ENTRY(dtrace_copy)
+ pushq %rbp
+ movq %rsp, %rbp
+
+ xchgq %rdi, %rsi /* make %rsi source, %rdi dest */
+ movq %rdx, %rcx /* load count */
+ repz /* repeat for count ... */
+ smovb /* move from %ds:rsi to %ed:rdi */
+ leave
+ ret
+ SET_SIZE(dtrace_copy)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_copy)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+ pushl %edi
+
+ movl 8(%ebp), %esi / Load source address
+ movl 12(%ebp), %edi / Load destination address
+ movl 16(%ebp), %ecx / Load count
+ repz / Repeat for count...
+ smovb / move from %ds:si to %es:di
+
+ popl %edi
+ popl %esi
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ SET_SIZE(dtrace_copy)
+
+#endif /* __i386 */
+#endif
+
+#if defined(lint)
+
+/*ARGSUSED*/
+void
+dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
+ volatile uint16_t *flags)
+{}
+
+#else
+
+#if defined(__amd64)
+
+ ENTRY(dtrace_copystr)
+ pushq %rbp
+ movq %rsp, %rbp
+
+0:
+ movb (%rdi), %al /* load from source */
+ movb %al, (%rsi) /* store to destination */
+ addq $1, %rdi /* increment source pointer */
+ addq $1, %rsi /* increment destination pointer */
+ subq $1, %rdx /* decrement remaining count */
+ cmpb $0, %al
+ je 2f
+ testq $0xfff, %rdx /* test if count is 4k-aligned */
+ jnz 1f /* if not, continue with copying */
+ testq $CPU_DTRACE_BADADDR, (%rcx) /* load and test dtrace flags */
+ jnz 2f
+1:
+ cmpq $0, %rdx
+ jne 0b
+2:
+ leave
+ ret
+
+ SET_SIZE(dtrace_copystr)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_copystr)
+
+ pushl %ebp / Setup stack frame
+ movl %esp, %ebp
+ pushl %ebx / Save registers
+
+ movl 8(%ebp), %ebx / Load source address
+ movl 12(%ebp), %edx / Load destination address
+ movl 16(%ebp), %ecx / Load count
+
+0:
+ movb (%ebx), %al / Load from source
+ movb %al, (%edx) / Store to destination
+ incl %ebx / Increment source pointer
+ incl %edx / Increment destination pointer
+ decl %ecx / Decrement remaining count
+ cmpb $0, %al
+ je 2f
+ testl $0xfff, %ecx / Check if count is 4k-aligned
+ jnz 1f
+ movl 20(%ebp), %eax / load flags pointer
+ testl $CPU_DTRACE_BADADDR, (%eax) / load and test dtrace flags
+ jnz 2f
+1:
+ cmpl $0, %ecx
+ jne 0b
+
+2:
+ popl %ebx
+ movl %ebp, %esp
+ popl %ebp
+ ret
+
+ SET_SIZE(dtrace_copystr)
+
+#endif /* __i386 */
+#endif
+
+#if defined(lint)
+
+/*ARGSUSED*/
+uintptr_t
+dtrace_fulword(void *addr)
+{ return (0); }
+
+#else
+#if defined(__amd64)
+
+ ENTRY(dtrace_fulword)
+ movq (%rdi), %rax
+ ret
+ SET_SIZE(dtrace_fulword)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_fulword)
+ movl 4(%esp), %ecx
+ xorl %eax, %eax
+ movl (%ecx), %eax
+ ret
+ SET_SIZE(dtrace_fulword)
+
+#endif /* __i386 */
+#endif
+
+#if defined(lint)
+
+/*ARGSUSED*/
+uint8_t
+dtrace_fuword8_nocheck(void *addr)
+{ return (0); }
+
+#else
+#if defined(__amd64)
+
+ ENTRY(dtrace_fuword8_nocheck)
+ xorq %rax, %rax
+ movb (%rdi), %al
+ ret
+ SET_SIZE(dtrace_fuword8_nocheck)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_fuword8_nocheck)
+ movl 4(%esp), %ecx
+ xorl %eax, %eax
+ movzbl (%ecx), %eax
+ ret
+ SET_SIZE(dtrace_fuword8_nocheck)
+
+#endif /* __i386 */
+#endif
+
+#if defined(lint)
+
+/*ARGSUSED*/
+uint16_t
+dtrace_fuword16_nocheck(void *addr)
+{ return (0); }
+
+#else
+#if defined(__amd64)
+
+ ENTRY(dtrace_fuword16_nocheck)
+ xorq %rax, %rax
+ movw (%rdi), %ax
+ ret
+ SET_SIZE(dtrace_fuword16_nocheck)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_fuword16_nocheck)
+ movl 4(%esp), %ecx
+ xorl %eax, %eax
+ movzwl (%ecx), %eax
+ ret
+ SET_SIZE(dtrace_fuword16_nocheck)
+
+#endif /* __i386 */
+#endif
+
+#if defined(lint)
+
+/*ARGSUSED*/
+uint32_t
+dtrace_fuword32_nocheck(void *addr)
+{ return (0); }
+
+#else
+#if defined(__amd64)
+
+ ENTRY(dtrace_fuword32_nocheck)
+ xorq %rax, %rax
+ movl (%rdi), %eax
+ ret
+ SET_SIZE(dtrace_fuword32_nocheck)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_fuword32_nocheck)
+ movl 4(%esp), %ecx
+ xorl %eax, %eax
+ movl (%ecx), %eax
+ ret
+ SET_SIZE(dtrace_fuword32_nocheck)
+
+#endif /* __i386 */
+#endif
+
+#if defined(lint)
+
+/*ARGSUSED*/
+uint64_t
+dtrace_fuword64_nocheck(void *addr)
+{ return (0); }
+
+#else
+#if defined(__amd64)
+
+ ENTRY(dtrace_fuword64_nocheck)
+ movq (%rdi), %rax
+ ret
+ SET_SIZE(dtrace_fuword64_nocheck)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_fuword64_nocheck)
+ movl 4(%esp), %ecx
+ xorl %eax, %eax
+ xorl %edx, %edx
+ movl (%ecx), %eax
+ movl 4(%ecx), %edx
+ ret
+ SET_SIZE(dtrace_fuword64_nocheck)
+
+#endif /* __i386 */
+#endif
+
+#if defined(lint) || defined(__lint)
+
+/*ARGSUSED*/
+void
+dtrace_probe_error(dtrace_state_t *state, dtrace_epid_t epid, int which,
+ int fault, int fltoffs, uintptr_t illval)
+{}
+
+#else /* lint */
+#if defined(__amd64)
+
+ ENTRY(dtrace_probe_error)
+ pushq %rbp
+ movq %rsp, %rbp
+ subq $0x8, %rsp
+ movq %r9, (%rsp)
+ movq %r8, %r9
+ movq %rcx, %r8
+ movq %rdx, %rcx
+ movq %rsi, %rdx
+ movq %rdi, %rsi
+ movl dtrace_probeid_error(%rip), %edi
+ call dtrace_probe
+ addq $0x8, %rsp
+ leave
+ ret
+ SET_SIZE(dtrace_probe_error)
+
+#elif defined(__i386)
+
+ ENTRY(dtrace_probe_error)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl 0x1c(%ebp)
+ pushl 0x18(%ebp)
+ pushl 0x14(%ebp)
+ pushl 0x10(%ebp)
+ pushl 0xc(%ebp)
+ pushl 0x8(%ebp)
+ pushl dtrace_probeid_error
+ call dtrace_probe
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ SET_SIZE(dtrace_probe_error)
+
+#endif /* __i386 */
+#endif
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_isa.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_isa.c
new file mode 100644
index 00000000..6b5a4e1b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/dtrace_isa.c
@@ -0,0 +1,746 @@
+/*
+ * 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 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/dtrace_impl.h>
+#include <sys/stack.h>
+#include <sys/frame.h>
+#include <sys/cmn_err.h>
+#include <sys/privregs.h>
+#include <sys/sysmacros.h>
+
+extern uintptr_t kernelbase;
+
+int dtrace_ustackdepth_max = 2048;
+
+void
+dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
+ uint32_t *intrpc)
+{
+ struct frame *fp = (struct frame *)dtrace_getfp();
+ struct frame *nextfp, *minfp, *stacktop;
+ int depth = 0;
+ int on_intr, last = 0;
+ uintptr_t pc;
+ uintptr_t caller = CPU->cpu_dtrace_caller;
+
+ if ((on_intr = CPU_ON_INTR(CPU)) != 0)
+ stacktop = (struct frame *)(CPU->cpu_intr_stack + SA(MINFRAME));
+ else
+ stacktop = (struct frame *)curthread->t_stk;
+ minfp = fp;
+
+ aframes++;
+
+ if (intrpc != NULL && depth < pcstack_limit)
+ pcstack[depth++] = (pc_t)intrpc;
+
+ while (depth < pcstack_limit) {
+ nextfp = (struct frame *)fp->fr_savfp;
+ pc = fp->fr_savpc;
+
+ if (nextfp <= minfp || nextfp >= stacktop) {
+ if (on_intr) {
+ /*
+ * Hop from interrupt stack to thread stack.
+ */
+ stacktop = (struct frame *)curthread->t_stk;
+ minfp = (struct frame *)curthread->t_stkbase;
+ on_intr = 0;
+ continue;
+ }
+
+ /*
+ * This is the last frame we can process; indicate
+ * that we should return after processing this frame.
+ */
+ last = 1;
+ }
+
+ if (aframes > 0) {
+ if (--aframes == 0 && caller != NULL) {
+ /*
+ * We've just run out of artificial frames,
+ * and we have a valid caller -- fill it in
+ * now.
+ */
+ ASSERT(depth < pcstack_limit);
+ pcstack[depth++] = (pc_t)caller;
+ caller = NULL;
+ }
+ } else {
+ if (depth < pcstack_limit)
+ pcstack[depth++] = (pc_t)pc;
+ }
+
+ if (last) {
+ while (depth < pcstack_limit)
+ pcstack[depth++] = NULL;
+ return;
+ }
+
+ fp = nextfp;
+ minfp = fp;
+ }
+}
+
+static int
+dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc,
+ uintptr_t sp)
+{
+ klwp_t *lwp = ttolwp(curthread);
+ proc_t *p = curproc;
+ uintptr_t oldcontext = lwp->lwp_oldcontext;
+ uintptr_t oldsp;
+ volatile uint16_t *flags =
+ (volatile uint16_t *)&cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
+ size_t s1, s2;
+ int ret = 0;
+
+ ASSERT(pcstack == NULL || pcstack_limit > 0);
+ ASSERT(dtrace_ustackdepth_max > 0);
+
+ if (p->p_model == DATAMODEL_NATIVE) {
+ s1 = sizeof (struct frame) + 2 * sizeof (long);
+ s2 = s1 + sizeof (siginfo_t);
+ } else {
+ s1 = sizeof (struct frame32) + 3 * sizeof (int);
+ s2 = s1 + sizeof (siginfo32_t);
+ }
+
+ while (pc != 0) {
+ /*
+ * We limit the number of times we can go around this
+ * loop to account for a circular stack.
+ */
+ if (ret++ >= dtrace_ustackdepth_max) {
+ *flags |= CPU_DTRACE_BADSTACK;
+ cpu_core[CPU->cpu_id].cpuc_dtrace_illval = sp;
+ break;
+ }
+
+ if (pcstack != NULL) {
+ *pcstack++ = (uint64_t)pc;
+ pcstack_limit--;
+ if (pcstack_limit <= 0)
+ break;
+ }
+
+ if (sp == 0)
+ break;
+
+ oldsp = sp;
+
+ if (oldcontext == sp + s1 || oldcontext == sp + s2) {
+ if (p->p_model == DATAMODEL_NATIVE) {
+ ucontext_t *ucp = (ucontext_t *)oldcontext;
+ greg_t *gregs = ucp->uc_mcontext.gregs;
+
+ sp = dtrace_fulword(&gregs[REG_FP]);
+ pc = dtrace_fulword(&gregs[REG_PC]);
+
+ oldcontext = dtrace_fulword(&ucp->uc_link);
+ } else {
+ ucontext32_t *ucp = (ucontext32_t *)oldcontext;
+ greg32_t *gregs = ucp->uc_mcontext.gregs;
+
+ sp = dtrace_fuword32(&gregs[EBP]);
+ pc = dtrace_fuword32(&gregs[EIP]);
+
+ oldcontext = dtrace_fuword32(&ucp->uc_link);
+ }
+ } else {
+ if (p->p_model == DATAMODEL_NATIVE) {
+ struct frame *fr = (struct frame *)sp;
+
+ pc = dtrace_fulword(&fr->fr_savpc);
+ sp = dtrace_fulword(&fr->fr_savfp);
+ } else {
+ struct frame32 *fr = (struct frame32 *)sp;
+
+ pc = dtrace_fuword32(&fr->fr_savpc);
+ sp = dtrace_fuword32(&fr->fr_savfp);
+ }
+ }
+
+ if (sp == oldsp) {
+ *flags |= CPU_DTRACE_BADSTACK;
+ cpu_core[CPU->cpu_id].cpuc_dtrace_illval = sp;
+ break;
+ }
+
+ /*
+ * This is totally bogus: if we faulted, we're going to clear
+ * the fault and break. This is to deal with the apparently
+ * broken Java stacks on x86.
+ */
+ if (*flags & CPU_DTRACE_FAULT) {
+ *flags &= ~CPU_DTRACE_FAULT;
+ break;
+ }
+ }
+
+ return (ret);
+}
+
+void
+dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit)
+{
+ klwp_t *lwp = ttolwp(curthread);
+ proc_t *p = curproc;
+ struct regs *rp;
+ uintptr_t pc, sp;
+ int n;
+
+ ASSERT(DTRACE_CPUFLAG_ISSET(CPU_DTRACE_NOFAULT));
+
+ if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_FAULT))
+ return;
+
+ if (pcstack_limit <= 0)
+ return;
+
+ /*
+ * If there's no user context we still need to zero the stack.
+ */
+ if (lwp == NULL || p == NULL || (rp = lwp->lwp_regs) == NULL)
+ goto zero;
+
+ *pcstack++ = (uint64_t)p->p_pid;
+ pcstack_limit--;
+
+ if (pcstack_limit <= 0)
+ return;
+
+ pc = rp->r_pc;
+ sp = rp->r_fp;
+
+ if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
+ *pcstack++ = (uint64_t)pc;
+ pcstack_limit--;
+ if (pcstack_limit <= 0)
+ return;
+
+ if (p->p_model == DATAMODEL_NATIVE)
+ pc = dtrace_fulword((void *)rp->r_sp);
+ else
+ pc = dtrace_fuword32((void *)rp->r_sp);
+ }
+
+ n = dtrace_getustack_common(pcstack, pcstack_limit, pc, sp);
+ ASSERT(n >= 0);
+ ASSERT(n <= pcstack_limit);
+
+ pcstack += n;
+ pcstack_limit -= n;
+
+zero:
+ while (pcstack_limit-- > 0)
+ *pcstack++ = NULL;
+}
+
+int
+dtrace_getustackdepth(void)
+{
+ klwp_t *lwp = ttolwp(curthread);
+ proc_t *p = curproc;
+ struct regs *rp;
+ uintptr_t pc, sp;
+ int n = 0;
+
+ if (lwp == NULL || p == NULL || (rp = lwp->lwp_regs) == NULL)
+ return (0);
+
+ if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_FAULT))
+ return (-1);
+
+ pc = rp->r_pc;
+ sp = rp->r_fp;
+
+ if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
+ n++;
+
+ if (p->p_model == DATAMODEL_NATIVE)
+ pc = dtrace_fulword((void *)rp->r_sp);
+ else
+ pc = dtrace_fuword32((void *)rp->r_sp);
+ }
+
+ n += dtrace_getustack_common(NULL, 0, pc, sp);
+
+ return (n);
+}
+
+void
+dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit)
+{
+ klwp_t *lwp = ttolwp(curthread);
+ proc_t *p = curproc;
+ struct regs *rp;
+ uintptr_t pc, sp, oldcontext;
+ volatile uint16_t *flags =
+ (volatile uint16_t *)&cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
+ size_t s1, s2;
+
+ if (*flags & CPU_DTRACE_FAULT)
+ return;
+
+ if (pcstack_limit <= 0)
+ return;
+
+ /*
+ * If there's no user context we still need to zero the stack.
+ */
+ if (lwp == NULL || p == NULL || (rp = lwp->lwp_regs) == NULL)
+ goto zero;
+
+ *pcstack++ = (uint64_t)p->p_pid;
+ pcstack_limit--;
+
+ if (pcstack_limit <= 0)
+ return;
+
+ pc = rp->r_pc;
+ sp = rp->r_fp;
+ oldcontext = lwp->lwp_oldcontext;
+
+ if (p->p_model == DATAMODEL_NATIVE) {
+ s1 = sizeof (struct frame) + 2 * sizeof (long);
+ s2 = s1 + sizeof (siginfo_t);
+ } else {
+ s1 = sizeof (struct frame32) + 3 * sizeof (int);
+ s2 = s1 + sizeof (siginfo32_t);
+ }
+
+ if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
+ *pcstack++ = (uint64_t)pc;
+ *fpstack++ = 0;
+ pcstack_limit--;
+ if (pcstack_limit <= 0)
+ return;
+
+ if (p->p_model == DATAMODEL_NATIVE)
+ pc = dtrace_fulword((void *)rp->r_sp);
+ else
+ pc = dtrace_fuword32((void *)rp->r_sp);
+ }
+
+ while (pc != 0) {
+ *pcstack++ = (uint64_t)pc;
+ *fpstack++ = sp;
+ pcstack_limit--;
+ if (pcstack_limit <= 0)
+ break;
+
+ if (sp == 0)
+ break;
+
+ if (oldcontext == sp + s1 || oldcontext == sp + s2) {
+ if (p->p_model == DATAMODEL_NATIVE) {
+ ucontext_t *ucp = (ucontext_t *)oldcontext;
+ greg_t *gregs = ucp->uc_mcontext.gregs;
+
+ sp = dtrace_fulword(&gregs[REG_FP]);
+ pc = dtrace_fulword(&gregs[REG_PC]);
+
+ oldcontext = dtrace_fulword(&ucp->uc_link);
+ } else {
+ ucontext_t *ucp = (ucontext_t *)oldcontext;
+ greg_t *gregs = ucp->uc_mcontext.gregs;
+
+ sp = dtrace_fuword32(&gregs[EBP]);
+ pc = dtrace_fuword32(&gregs[EIP]);
+
+ oldcontext = dtrace_fuword32(&ucp->uc_link);
+ }
+ } else {
+ if (p->p_model == DATAMODEL_NATIVE) {
+ struct frame *fr = (struct frame *)sp;
+
+ pc = dtrace_fulword(&fr->fr_savpc);
+ sp = dtrace_fulword(&fr->fr_savfp);
+ } else {
+ struct frame32 *fr = (struct frame32 *)sp;
+
+ pc = dtrace_fuword32(&fr->fr_savpc);
+ sp = dtrace_fuword32(&fr->fr_savfp);
+ }
+ }
+
+ /*
+ * This is totally bogus: if we faulted, we're going to clear
+ * the fault and break. This is to deal with the apparently
+ * broken Java stacks on x86.
+ */
+ if (*flags & CPU_DTRACE_FAULT) {
+ *flags &= ~CPU_DTRACE_FAULT;
+ break;
+ }
+ }
+
+zero:
+ while (pcstack_limit-- > 0)
+ *pcstack++ = NULL;
+}
+
+/*ARGSUSED*/
+uint64_t
+dtrace_getarg(int arg, int aframes)
+{
+ uintptr_t val;
+ struct frame *fp = (struct frame *)dtrace_getfp();
+ uintptr_t *stack;
+ int i;
+#if defined(__amd64)
+ /*
+ * A total of 6 arguments are passed via registers; any argument with
+ * index of 5 or lower is therefore in a register.
+ */
+ int inreg = 5;
+#endif
+
+ for (i = 1; i <= aframes; i++) {
+ fp = (struct frame *)(fp->fr_savfp);
+
+ if (fp->fr_savpc == (pc_t)dtrace_invop_callsite) {
+#if !defined(__amd64)
+ /*
+ * If we pass through the invalid op handler, we will
+ * use the pointer that it passed to the stack as the
+ * second argument to dtrace_invop() as the pointer to
+ * the stack. When using this stack, we must step
+ * beyond the EIP/RIP that was pushed when the trap was
+ * taken -- hence the "+ 1" below.
+ */
+ stack = ((uintptr_t **)&fp[1])[1] + 1;
+#else
+ /*
+ * In the case of amd64, we will use the pointer to the
+ * regs structure that was pushed when we took the
+ * trap. To get this structure, we must increment
+ * beyond the frame structure, and then again beyond
+ * the calling RIP stored in dtrace_invop(). If the
+ * argument that we're seeking is passed on the stack,
+ * we'll pull the true stack pointer out of the saved
+ * registers and decrement our argument by the number
+ * of arguments passed in registers; if the argument
+ * we're seeking is passed in regsiters, we can just
+ * load it directly.
+ */
+ struct regs *rp = (struct regs *)((uintptr_t)&fp[1] +
+ sizeof (uintptr_t));
+
+ if (arg <= inreg) {
+ stack = (uintptr_t *)&rp->r_rdi;
+ } else {
+ stack = (uintptr_t *)(rp->r_rsp);
+ arg -= inreg;
+ }
+#endif
+ goto load;
+ }
+
+ }
+
+ /*
+ * We know that we did not come through a trap to get into
+ * dtrace_probe() -- the provider simply called dtrace_probe()
+ * directly. As this is the case, we need to shift the argument
+ * that we're looking for: the probe ID is the first argument to
+ * dtrace_probe(), so the argument n will actually be found where
+ * one would expect to find argument (n + 1).
+ */
+ arg++;
+
+#if defined(__amd64)
+ if (arg <= inreg) {
+ /*
+ * This shouldn't happen. If the argument is passed in a
+ * register then it should have been, well, passed in a
+ * register...
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return (0);
+ }
+
+ arg -= (inreg + 1);
+#endif
+ stack = (uintptr_t *)&fp[1];
+
+load:
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ val = stack[arg];
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+
+ return (val);
+}
+
+/*ARGSUSED*/
+int
+dtrace_getstackdepth(int aframes)
+{
+ struct frame *fp = (struct frame *)dtrace_getfp();
+ struct frame *nextfp, *minfp, *stacktop;
+ int depth = 0;
+ int on_intr;
+
+ if ((on_intr = CPU_ON_INTR(CPU)) != 0)
+ stacktop = (struct frame *)(CPU->cpu_intr_stack + SA(MINFRAME));
+ else
+ stacktop = (struct frame *)curthread->t_stk;
+ minfp = fp;
+
+ aframes++;
+
+ for (;;) {
+ depth++;
+
+ nextfp = (struct frame *)fp->fr_savfp;
+
+ if (nextfp <= minfp || nextfp >= stacktop) {
+ if (on_intr) {
+ /*
+ * Hop from interrupt stack to thread stack.
+ */
+ stacktop = (struct frame *)curthread->t_stk;
+ minfp = (struct frame *)curthread->t_stkbase;
+ on_intr = 0;
+ continue;
+ }
+ break;
+ }
+
+ fp = nextfp;
+ minfp = fp;
+ }
+
+ if (depth <= aframes)
+ return (0);
+
+ return (depth - aframes);
+}
+
+ulong_t
+dtrace_getreg(struct regs *rp, uint_t reg)
+{
+#if defined(__amd64)
+ int regmap[] = {
+ REG_GS, /* GS */
+ REG_FS, /* FS */
+ REG_ES, /* ES */
+ REG_DS, /* DS */
+ REG_RDI, /* EDI */
+ REG_RSI, /* ESI */
+ REG_RBP, /* EBP */
+ REG_RSP, /* ESP */
+ REG_RBX, /* EBX */
+ REG_RDX, /* EDX */
+ REG_RCX, /* ECX */
+ REG_RAX, /* EAX */
+ REG_TRAPNO, /* TRAPNO */
+ REG_ERR, /* ERR */
+ REG_RIP, /* EIP */
+ REG_CS, /* CS */
+ REG_RFL, /* EFL */
+ REG_RSP, /* UESP */
+ REG_SS /* SS */
+ };
+
+ if (reg <= SS) {
+ if (reg >= sizeof (regmap) / sizeof (int)) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return (0);
+ }
+
+ reg = regmap[reg];
+ } else {
+ reg -= SS + 1;
+ }
+
+ switch (reg) {
+ case REG_RDI:
+ return (rp->r_rdi);
+ case REG_RSI:
+ return (rp->r_rsi);
+ case REG_RDX:
+ return (rp->r_rdx);
+ case REG_RCX:
+ return (rp->r_rcx);
+ case REG_R8:
+ return (rp->r_r8);
+ case REG_R9:
+ return (rp->r_r9);
+ case REG_RAX:
+ return (rp->r_rax);
+ case REG_RBX:
+ return (rp->r_rbx);
+ case REG_RBP:
+ return (rp->r_rbp);
+ case REG_R10:
+ return (rp->r_r10);
+ case REG_R11:
+ return (rp->r_r11);
+ case REG_R12:
+ return (rp->r_r12);
+ case REG_R13:
+ return (rp->r_r13);
+ case REG_R14:
+ return (rp->r_r14);
+ case REG_R15:
+ return (rp->r_r15);
+ case REG_DS:
+ return (rp->r_ds);
+ case REG_ES:
+ return (rp->r_es);
+ case REG_FS:
+ return (rp->r_fs);
+ case REG_GS:
+ return (rp->r_gs);
+ case REG_TRAPNO:
+ return (rp->r_trapno);
+ case REG_ERR:
+ return (rp->r_err);
+ case REG_RIP:
+ return (rp->r_rip);
+ case REG_CS:
+ return (rp->r_cs);
+ case REG_SS:
+ return (rp->r_ss);
+ case REG_RFL:
+ return (rp->r_rfl);
+ case REG_RSP:
+ return (rp->r_rsp);
+ default:
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return (0);
+ }
+
+#else
+ if (reg > SS) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return (0);
+ }
+
+ return ((&rp->r_gs)[reg]);
+#endif
+}
+
+static int
+dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size)
+{
+ ASSERT(kaddr >= kernelbase && kaddr + size >= kaddr);
+
+ if (uaddr + size >= kernelbase || uaddr + size < uaddr) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[CPU->cpu_id].cpuc_dtrace_illval = uaddr;
+ return (0);
+ }
+
+ return (1);
+}
+
+/*ARGSUSED*/
+void
+dtrace_copyin(uintptr_t uaddr, uintptr_t kaddr, size_t size,
+ volatile uint16_t *flags)
+{
+ if (dtrace_copycheck(uaddr, kaddr, size))
+ dtrace_copy(uaddr, kaddr, size);
+}
+
+/*ARGSUSED*/
+void
+dtrace_copyout(uintptr_t kaddr, uintptr_t uaddr, size_t size,
+ volatile uint16_t *flags)
+{
+ if (dtrace_copycheck(uaddr, kaddr, size))
+ dtrace_copy(kaddr, uaddr, size);
+}
+
+void
+dtrace_copyinstr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
+ volatile uint16_t *flags)
+{
+ if (dtrace_copycheck(uaddr, kaddr, size))
+ dtrace_copystr(uaddr, kaddr, size, flags);
+}
+
+void
+dtrace_copyoutstr(uintptr_t kaddr, uintptr_t uaddr, size_t size,
+ volatile uint16_t *flags)
+{
+ if (dtrace_copycheck(uaddr, kaddr, size))
+ dtrace_copystr(kaddr, uaddr, size, flags);
+}
+
+uint8_t
+dtrace_fuword8(void *uaddr)
+{
+ extern uint8_t dtrace_fuword8_nocheck(void *);
+ if ((uintptr_t)uaddr >= _userlimit) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[CPU->cpu_id].cpuc_dtrace_illval = (uintptr_t)uaddr;
+ return (0);
+ }
+ return (dtrace_fuword8_nocheck(uaddr));
+}
+
+uint16_t
+dtrace_fuword16(void *uaddr)
+{
+ extern uint16_t dtrace_fuword16_nocheck(void *);
+ if ((uintptr_t)uaddr >= _userlimit) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[CPU->cpu_id].cpuc_dtrace_illval = (uintptr_t)uaddr;
+ return (0);
+ }
+ return (dtrace_fuword16_nocheck(uaddr));
+}
+
+uint32_t
+dtrace_fuword32(void *uaddr)
+{
+ extern uint32_t dtrace_fuword32_nocheck(void *);
+ if ((uintptr_t)uaddr >= _userlimit) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[CPU->cpu_id].cpuc_dtrace_illval = (uintptr_t)uaddr;
+ return (0);
+ }
+ return (dtrace_fuword32_nocheck(uaddr));
+}
+
+uint64_t
+dtrace_fuword64(void *uaddr)
+{
+ extern uint64_t dtrace_fuword64_nocheck(void *);
+ if ((uintptr_t)uaddr >= _userlimit) {
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
+ cpu_core[CPU->cpu_id].cpuc_dtrace_illval = (uintptr_t)uaddr;
+ return (0);
+ }
+ return (dtrace_fuword64_nocheck(uaddr));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap.conf
new file mode 100644
index 00000000..a25f883f
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap.conf
@@ -0,0 +1,39 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+name="fasttrap" parent="pseudo" instance=0;
+
+# fasttrap-max-probes is the limit on the number of tracepoints created
+# by DTrace's pid provider. This value should be increased if DTrace is
+# unable to create the desired probes because the limit has been hit.
+#fasttrap-max-probes=250000;
+
+# fasttrap-hash-size determines the size of the hash table used to store
+# enabled DTrace pid provider tracepoints. If there are many enabled
+# tracepoints or many tracepoints hash to the same value, increasing this
+# variable can improve the performance of executing a traced instruction.
+#fasttrap-hash-size=16384;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap_isa.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap_isa.c
new file mode 100644
index 00000000..c4b58453
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fasttrap_isa.c
@@ -0,0 +1,1745 @@
+/*
+ * 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 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/fasttrap_isa.h>
+#include <sys/fasttrap_impl.h>
+#include <sys/dtrace.h>
+#include <sys/dtrace_impl.h>
+#include <sys/cmn_err.h>
+#include <sys/regset.h>
+#include <sys/privregs.h>
+#include <sys/segments.h>
+#include <sys/x86_archext.h>
+#include <sys/sysmacros.h>
+#include <sys/trap.h>
+#include <sys/archsystm.h>
+
+/*
+ * Lossless User-Land Tracing on x86
+ * ---------------------------------
+ *
+ * The execution of most instructions is not dependent on the address; for
+ * these instructions it is sufficient to copy them into the user process's
+ * address space and execute them. To effectively single-step an instruction
+ * in user-land, we copy out the following sequence of instructions to scratch
+ * space in the user thread's ulwp_t structure.
+ *
+ * We then set the program counter (%eip or %rip) to point to this scratch
+ * space. Once execution resumes, the original instruction is executed and
+ * then control flow is redirected to what was originally the subsequent
+ * instruction. If the kernel attemps to deliver a signal while single-
+ * stepping, the signal is deferred and the program counter is moved into the
+ * second sequence of instructions. The second sequence ends in a trap into
+ * the kernel where the deferred signal is then properly handled and delivered.
+ *
+ * For instructions whose execute is position dependent, we perform simple
+ * emulation. These instructions are limited to control transfer
+ * instructions in 32-bit mode, but in 64-bit mode there's the added wrinkle
+ * of %rip-relative addressing that means that almost any instruction can be
+ * position dependent. For all the details on how we emulate generic
+ * instructions included %rip-relative instructions, see the code in
+ * fasttrap_pid_probe() below where we handle instructions of type
+ * FASTTRAP_T_COMMON (under the header: Generic Instruction Tracing).
+ */
+
+#define FASTTRAP_MODRM_MOD(modrm) (((modrm) >> 6) & 0x3)
+#define FASTTRAP_MODRM_REG(modrm) (((modrm) >> 3) & 0x7)
+#define FASTTRAP_MODRM_RM(modrm) ((modrm) & 0x7)
+#define FASTTRAP_MODRM(mod, reg, rm) (((mod) << 6) | ((reg) << 3) | (rm))
+
+#define FASTTRAP_SIB_SCALE(sib) (((sib) >> 6) & 0x3)
+#define FASTTRAP_SIB_INDEX(sib) (((sib) >> 3) & 0x7)
+#define FASTTRAP_SIB_BASE(sib) ((sib) & 0x7)
+
+#define FASTTRAP_REX_W(rex) (((rex) >> 3) & 1)
+#define FASTTRAP_REX_R(rex) (((rex) >> 2) & 1)
+#define FASTTRAP_REX_X(rex) (((rex) >> 1) & 1)
+#define FASTTRAP_REX_B(rex) ((rex) & 1)
+#define FASTTRAP_REX(w, r, x, b) \
+ (0x40 | ((w) << 3) | ((r) << 2) | ((x) << 1) | (b))
+
+/*
+ * Single-byte op-codes.
+ */
+#define FASTTRAP_PUSHL_EBP 0x55
+
+#define FASTTRAP_JO 0x70
+#define FASTTRAP_JNO 0x71
+#define FASTTRAP_JB 0x72
+#define FASTTRAP_JAE 0x73
+#define FASTTRAP_JE 0x74
+#define FASTTRAP_JNE 0x75
+#define FASTTRAP_JBE 0x76
+#define FASTTRAP_JA 0x77
+#define FASTTRAP_JS 0x78
+#define FASTTRAP_JNS 0x79
+#define FASTTRAP_JP 0x7a
+#define FASTTRAP_JNP 0x7b
+#define FASTTRAP_JL 0x7c
+#define FASTTRAP_JGE 0x7d
+#define FASTTRAP_JLE 0x7e
+#define FASTTRAP_JG 0x7f
+
+#define FASTTRAP_NOP 0x90
+
+#define FASTTRAP_MOV_EAX 0xb8
+#define FASTTRAP_MOV_ECX 0xb9
+
+#define FASTTRAP_RET16 0xc2
+#define FASTTRAP_RET 0xc3
+
+#define FASTTRAP_LOOPNZ 0xe0
+#define FASTTRAP_LOOPZ 0xe1
+#define FASTTRAP_LOOP 0xe2
+#define FASTTRAP_JCXZ 0xe3
+
+#define FASTTRAP_CALL 0xe8
+#define FASTTRAP_JMP32 0xe9
+#define FASTTRAP_JMP8 0xeb
+
+#define FASTTRAP_INT3 0xcc
+#define FASTTRAP_INT 0xcd
+
+#define FASTTRAP_2_BYTE_OP 0x0f
+#define FASTTRAP_GROUP5_OP 0xff
+
+/*
+ * Two-byte op-codes (second byte only).
+ */
+#define FASTTRAP_0F_JO 0x80
+#define FASTTRAP_0F_JNO 0x81
+#define FASTTRAP_0F_JB 0x82
+#define FASTTRAP_0F_JAE 0x83
+#define FASTTRAP_0F_JE 0x84
+#define FASTTRAP_0F_JNE 0x85
+#define FASTTRAP_0F_JBE 0x86
+#define FASTTRAP_0F_JA 0x87
+#define FASTTRAP_0F_JS 0x88
+#define FASTTRAP_0F_JNS 0x89
+#define FASTTRAP_0F_JP 0x8a
+#define FASTTRAP_0F_JNP 0x8b
+#define FASTTRAP_0F_JL 0x8c
+#define FASTTRAP_0F_JGE 0x8d
+#define FASTTRAP_0F_JLE 0x8e
+#define FASTTRAP_0F_JG 0x8f
+
+#define FASTTRAP_EFLAGS_OF 0x800
+#define FASTTRAP_EFLAGS_DF 0x400
+#define FASTTRAP_EFLAGS_SF 0x080
+#define FASTTRAP_EFLAGS_ZF 0x040
+#define FASTTRAP_EFLAGS_AF 0x010
+#define FASTTRAP_EFLAGS_PF 0x004
+#define FASTTRAP_EFLAGS_CF 0x001
+
+/*
+ * Instruction prefixes.
+ */
+#define FASTTRAP_PREFIX_OPERAND 0x66
+#define FASTTRAP_PREFIX_ADDRESS 0x67
+#define FASTTRAP_PREFIX_CS 0x2E
+#define FASTTRAP_PREFIX_DS 0x3E
+#define FASTTRAP_PREFIX_ES 0x26
+#define FASTTRAP_PREFIX_FS 0x64
+#define FASTTRAP_PREFIX_GS 0x65
+#define FASTTRAP_PREFIX_SS 0x36
+#define FASTTRAP_PREFIX_LOCK 0xF0
+#define FASTTRAP_PREFIX_REP 0xF3
+#define FASTTRAP_PREFIX_REPNE 0xF2
+
+#define FASTTRAP_NOREG 0xff
+
+/*
+ * Map between instruction register encodings and the kernel constants which
+ * correspond to indicies into struct regs.
+ */
+#ifdef __amd64
+static const uint8_t regmap[16] = {
+ REG_RAX, REG_RCX, REG_RDX, REG_RBX, REG_RSP, REG_RBP, REG_RSI, REG_RDI,
+ REG_R8, REG_R9, REG_R10, REG_R11, REG_R12, REG_R13, REG_R14, REG_R15,
+};
+#else
+static const uint8_t regmap[8] = {
+ EAX, ECX, EDX, EBX, UESP, EBP, ESI, EDI
+};
+#endif
+
+static ulong_t fasttrap_getreg(struct regs *, uint_t);
+
+static uint64_t
+fasttrap_anarg(struct regs *rp, int function_entry, int argno)
+{
+ uint64_t value;
+ int shift = function_entry ? 1 : 0;
+
+#ifdef __amd64
+ if (curproc->p_model == DATAMODEL_LP64) {
+ uintptr_t *stack;
+
+ /*
+ * In 64-bit mode, the first six arguments are stored in
+ * registers.
+ */
+ if (argno < 6)
+ return ((&rp->r_rdi)[argno]);
+
+ stack = (uintptr_t *)rp->r_sp;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ value = dtrace_fulword(&stack[argno - 6 + shift]);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT | CPU_DTRACE_BADADDR);
+ } else {
+#endif
+ uint32_t *stack = (uint32_t *)rp->r_sp;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ value = dtrace_fuword32(&stack[argno + shift]);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT | CPU_DTRACE_BADADDR);
+#ifdef __amd64
+ }
+#endif
+
+ return (value);
+}
+
+/*ARGSUSED*/
+int
+fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc,
+ fasttrap_probe_type_t type)
+{
+ uint8_t instr[FASTTRAP_MAX_INSTR_SIZE + 10];
+ size_t len = FASTTRAP_MAX_INSTR_SIZE;
+ size_t first = MIN(len, PAGESIZE - (pc & PAGEOFFSET));
+ uint_t start = 0;
+ int rmindex, size;
+ uint8_t seg, rex = 0;
+
+ /*
+ * Read the instruction at the given address out of the process's
+ * address space. We don't have to worry about a debugger
+ * changing this instruction before we overwrite it with our trap
+ * instruction since P_PR_LOCK is set. Since instructions can span
+ * pages, we potentially read the instruction in two parts. If the
+ * second part fails, we just zero out that part of the instruction.
+ */
+ if (uread(p, &instr[0], first, pc) != 0)
+ return (-1);
+ if (len > first &&
+ uread(p, &instr[first], len - first, pc + first) != 0) {
+ bzero(&instr[first], len - first);
+ len = first;
+ }
+
+ /*
+ * If the disassembly fails, then we have a malformed instruction.
+ */
+ if ((size = dtrace_instr_size_isa(instr, p->p_model, &rmindex)) <= 0)
+ return (-1);
+
+ /*
+ * Make sure the disassembler isn't completely broken.
+ */
+ ASSERT(-1 <= rmindex && rmindex < size);
+
+ /*
+ * If the computed size is greater than the number of bytes read,
+ * then it was a malformed instruction possibly because it fell on a
+ * page boundary and the subsequent page was missing or because of
+ * some malicious user.
+ */
+ if (size > len)
+ return (-1);
+
+ tp->ftt_size = (uint8_t)size;
+ tp->ftt_segment = FASTTRAP_SEG_NONE;
+
+ /*
+ * Find the start of the instruction's opcode by processing any
+ * legacy prefixes.
+ */
+ for (;;) {
+ seg = 0;
+ switch (instr[start]) {
+ case FASTTRAP_PREFIX_SS:
+ seg++;
+ RT_FALL_THRU();
+ case FASTTRAP_PREFIX_GS:
+ seg++;
+ RT_FALL_THRU();
+ case FASTTRAP_PREFIX_FS:
+ seg++;
+ RT_FALL_THRU();
+ case FASTTRAP_PREFIX_ES:
+ seg++;
+ RT_FALL_THRU();
+ case FASTTRAP_PREFIX_DS:
+ seg++;
+ RT_FALL_THRU();
+ case FASTTRAP_PREFIX_CS:
+ seg++;
+ RT_FALL_THRU();
+ case FASTTRAP_PREFIX_OPERAND:
+ case FASTTRAP_PREFIX_ADDRESS:
+ case FASTTRAP_PREFIX_LOCK:
+ case FASTTRAP_PREFIX_REP:
+ case FASTTRAP_PREFIX_REPNE:
+ if (seg != 0) {
+ /*
+ * It's illegal for an instruction to specify
+ * two segment prefixes -- give up on this
+ * illegal instruction.
+ */
+ if (tp->ftt_segment != FASTTRAP_SEG_NONE)
+ return (-1);
+
+ tp->ftt_segment = seg;
+ }
+ start++;
+ continue;
+ }
+ break;
+ }
+
+#ifdef __amd64
+ /*
+ * Identify the REX prefix on 64-bit processes.
+ */
+ if (p->p_model == DATAMODEL_LP64 && (instr[start] & 0xf0) == 0x40)
+ rex = instr[start++];
+#endif
+
+ /*
+ * Now that we're pretty sure that the instruction is okay, copy the
+ * valid part to the tracepoint.
+ */
+ bcopy(instr, tp->ftt_instr, FASTTRAP_MAX_INSTR_SIZE);
+
+ tp->ftt_type = FASTTRAP_T_COMMON;
+ if (instr[start] == FASTTRAP_2_BYTE_OP) {
+ switch (instr[start + 1]) {
+ case FASTTRAP_0F_JO:
+ case FASTTRAP_0F_JNO:
+ case FASTTRAP_0F_JB:
+ case FASTTRAP_0F_JAE:
+ case FASTTRAP_0F_JE:
+ case FASTTRAP_0F_JNE:
+ case FASTTRAP_0F_JBE:
+ case FASTTRAP_0F_JA:
+ case FASTTRAP_0F_JS:
+ case FASTTRAP_0F_JNS:
+ case FASTTRAP_0F_JP:
+ case FASTTRAP_0F_JNP:
+ case FASTTRAP_0F_JL:
+ case FASTTRAP_0F_JGE:
+ case FASTTRAP_0F_JLE:
+ case FASTTRAP_0F_JG:
+ tp->ftt_type = FASTTRAP_T_JCC;
+ tp->ftt_code = (instr[start + 1] & 0x0f) | FASTTRAP_JO;
+ tp->ftt_dest = pc + tp->ftt_size +
+ /* LINTED - alignment */
+ *(int32_t *)&instr[start + 2];
+ break;
+ }
+ } else if (instr[start] == FASTTRAP_GROUP5_OP) {
+ uint_t mod = FASTTRAP_MODRM_MOD(instr[start + 1]);
+ uint_t reg = FASTTRAP_MODRM_REG(instr[start + 1]);
+ uint_t rm = FASTTRAP_MODRM_RM(instr[start + 1]);
+
+ if (reg == 2 || reg == 4) {
+ uint_t i, sz;
+
+ if (reg == 2)
+ tp->ftt_type = FASTTRAP_T_CALL;
+ else
+ tp->ftt_type = FASTTRAP_T_JMP;
+
+ if (mod == 3)
+ tp->ftt_code = 2;
+ else
+ tp->ftt_code = 1;
+
+ ASSERT(p->p_model == DATAMODEL_LP64 || rex == 0);
+
+ /*
+ * See AMD x86-64 Architecture Programmer's Manual
+ * Volume 3, Section 1.2.7, Table 1-12, and
+ * Appendix A.3.1, Table A-15.
+ */
+ if (mod != 3 && rm == 4) {
+ uint8_t sib = instr[start + 2];
+ uint_t index = FASTTRAP_SIB_INDEX(sib);
+ uint_t base = FASTTRAP_SIB_BASE(sib);
+
+ tp->ftt_scale = FASTTRAP_SIB_SCALE(sib);
+
+ tp->ftt_index = (index == 4) ?
+ FASTTRAP_NOREG :
+ regmap[index | (FASTTRAP_REX_X(rex) << 3)];
+ tp->ftt_base = (mod == 0 && base == 5) ?
+ FASTTRAP_NOREG :
+ regmap[base | (FASTTRAP_REX_B(rex) << 3)];
+
+ i = 3;
+ sz = mod == 1 ? 1 : 4;
+ } else {
+ /*
+ * In 64-bit mode, mod == 0 and r/m == 5
+ * denotes %rip-relative addressing; in 32-bit
+ * mode, the base register isn't used. In both
+ * modes, there is a 32-bit operand.
+ */
+ if (mod == 0 && rm == 5) {
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_LP64)
+ tp->ftt_base = REG_RIP;
+ else
+#endif
+ tp->ftt_base = FASTTRAP_NOREG;
+ sz = 4;
+ } else {
+ uint8_t base = rm |
+ (FASTTRAP_REX_B(rex) << 3);
+
+ tp->ftt_base = regmap[base];
+ sz = mod == 1 ? 1 : mod == 2 ? 4 : 0;
+ }
+ tp->ftt_index = FASTTRAP_NOREG;
+ i = 2;
+ }
+
+ if (sz == 1) {
+ tp->ftt_dest = *(int8_t *)&instr[start + i];
+ } else if (sz == 4) {
+ /* LINTED - alignment */
+ tp->ftt_dest = *(int32_t *)&instr[start + i];
+ } else {
+ tp->ftt_dest = 0;
+ }
+ }
+ } else {
+ switch (instr[start]) {
+ case FASTTRAP_RET:
+ tp->ftt_type = FASTTRAP_T_RET;
+ break;
+
+ case FASTTRAP_RET16:
+ tp->ftt_type = FASTTRAP_T_RET16;
+ /* LINTED - alignment */
+ tp->ftt_dest = *(uint16_t *)&instr[start + 1];
+ break;
+
+ case FASTTRAP_JO:
+ case FASTTRAP_JNO:
+ case FASTTRAP_JB:
+ case FASTTRAP_JAE:
+ case FASTTRAP_JE:
+ case FASTTRAP_JNE:
+ case FASTTRAP_JBE:
+ case FASTTRAP_JA:
+ case FASTTRAP_JS:
+ case FASTTRAP_JNS:
+ case FASTTRAP_JP:
+ case FASTTRAP_JNP:
+ case FASTTRAP_JL:
+ case FASTTRAP_JGE:
+ case FASTTRAP_JLE:
+ case FASTTRAP_JG:
+ tp->ftt_type = FASTTRAP_T_JCC;
+ tp->ftt_code = instr[start];
+ tp->ftt_dest = pc + tp->ftt_size +
+ (int8_t)instr[start + 1];
+ break;
+
+ case FASTTRAP_LOOPNZ:
+ case FASTTRAP_LOOPZ:
+ case FASTTRAP_LOOP:
+ tp->ftt_type = FASTTRAP_T_LOOP;
+ tp->ftt_code = instr[start];
+ tp->ftt_dest = pc + tp->ftt_size +
+ (int8_t)instr[start + 1];
+ break;
+
+ case FASTTRAP_JCXZ:
+ tp->ftt_type = FASTTRAP_T_JCXZ;
+ tp->ftt_dest = pc + tp->ftt_size +
+ (int8_t)instr[start + 1];
+ break;
+
+ case FASTTRAP_CALL:
+ tp->ftt_type = FASTTRAP_T_CALL;
+ tp->ftt_dest = pc + tp->ftt_size +
+ /* LINTED - alignment */
+ *(int32_t *)&instr[start + 1];
+ tp->ftt_code = 0;
+ break;
+
+ case FASTTRAP_JMP32:
+ tp->ftt_type = FASTTRAP_T_JMP;
+ tp->ftt_dest = pc + tp->ftt_size +
+ /* LINTED - alignment */
+ *(int32_t *)&instr[start + 1];
+ break;
+ case FASTTRAP_JMP8:
+ tp->ftt_type = FASTTRAP_T_JMP;
+ tp->ftt_dest = pc + tp->ftt_size +
+ (int8_t)instr[start + 1];
+ break;
+
+ case FASTTRAP_PUSHL_EBP:
+ if (start == 0)
+ tp->ftt_type = FASTTRAP_T_PUSHL_EBP;
+ break;
+
+ case FASTTRAP_NOP:
+#ifdef __amd64
+ ASSERT(p->p_model == DATAMODEL_LP64 || rex == 0);
+
+ /*
+ * On amd64 we have to be careful not to confuse a nop
+ * (actually xchgl %eax, %eax) with an instruction using
+ * the same opcode, but that does something different
+ * (e.g. xchgl %r8d, %eax or xcghq %r8, %rax).
+ */
+ if (FASTTRAP_REX_B(rex) == 0)
+#endif
+ tp->ftt_type = FASTTRAP_T_NOP;
+ break;
+
+ case FASTTRAP_INT3:
+ /*
+ * The pid provider shares the int3 trap with debugger
+ * breakpoints so we can't instrument them.
+ */
+ ASSERT(instr[start] == FASTTRAP_INSTR);
+ return (-1);
+
+ case FASTTRAP_INT:
+ /*
+ * Interrupts seem like they could be traced with
+ * no negative implications, but it's possible that
+ * a thread could be redirected by the trap handling
+ * code which would eventually return to the
+ * instruction after the interrupt. If the interrupt
+ * were in our scratch space, the subsequent
+ * instruction might be overwritten before we return.
+ * Accordingly we refuse to instrument any interrupt.
+ */
+ return (-1);
+ }
+ }
+
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_LP64 && tp->ftt_type == FASTTRAP_T_COMMON) {
+ /*
+ * If the process is 64-bit and the instruction type is still
+ * FASTTRAP_T_COMMON -- meaning we're going to copy it out an
+ * execute it -- we need to watch for %rip-relative
+ * addressing mode. See the portion of fasttrap_pid_probe()
+ * below where we handle tracepoints with type
+ * FASTTRAP_T_COMMON for how we emulate instructions that
+ * employ %rip-relative addressing.
+ */
+ if (rmindex != -1) {
+ uint_t mod = FASTTRAP_MODRM_MOD(instr[rmindex]);
+ uint_t reg = FASTTRAP_MODRM_REG(instr[rmindex]);
+ uint_t rm = FASTTRAP_MODRM_RM(instr[rmindex]);
+
+ ASSERT(rmindex > start);
+
+ if (mod == 0 && rm == 5) {
+ /*
+ * We need to be sure to avoid other
+ * registers used by this instruction. While
+ * the reg field may determine the op code
+ * rather than denoting a register, assuming
+ * that it denotes a register is always safe.
+ * We leave the REX field intact and use
+ * whatever value's there for simplicity.
+ */
+ if (reg != 0) {
+ tp->ftt_ripmode = FASTTRAP_RIP_1 |
+ (FASTTRAP_RIP_X *
+ FASTTRAP_REX_B(rex));
+ rm = 0;
+ } else {
+ tp->ftt_ripmode = FASTTRAP_RIP_2 |
+ (FASTTRAP_RIP_X *
+ FASTTRAP_REX_B(rex));
+ rm = 1;
+ }
+
+ tp->ftt_modrm = tp->ftt_instr[rmindex];
+ tp->ftt_instr[rmindex] =
+ FASTTRAP_MODRM(2, reg, rm);
+ }
+ }
+ }
+#endif
+
+ return (0);
+}
+
+int
+fasttrap_tracepoint_install(proc_t *p, fasttrap_tracepoint_t *tp)
+{
+ fasttrap_instr_t instr = FASTTRAP_INSTR;
+
+ if (uwrite(p, &instr, 1, tp->ftt_pc) != 0)
+ return (-1);
+
+ return (0);
+}
+
+int
+fasttrap_tracepoint_remove(proc_t *p, fasttrap_tracepoint_t *tp)
+{
+ uint8_t instr;
+
+ /*
+ * Distinguish between read or write failures and a changed
+ * instruction.
+ */
+ if (uread(p, &instr, 1, tp->ftt_pc) != 0)
+ return (0);
+ if (instr != FASTTRAP_INSTR)
+ return (0);
+ if (uwrite(p, &tp->ftt_instr[0], 1, tp->ftt_pc) != 0)
+ return (-1);
+
+ return (0);
+}
+
+#ifdef __amd64
+static uintptr_t
+fasttrap_fulword_noerr(const void *uaddr)
+{
+ uintptr_t ret;
+
+ if (fasttrap_fulword(uaddr, &ret) == 0)
+ return (ret);
+
+ return (0);
+}
+#endif
+
+static uint32_t
+fasttrap_fuword32_noerr(const void *uaddr)
+{
+ uint32_t ret;
+
+ if (fasttrap_fuword32(uaddr, &ret) == 0)
+ return (ret);
+
+ return (0);
+}
+
+static void
+fasttrap_return_common(struct regs *rp, uintptr_t pc, pid_t pid,
+ uintptr_t new_pc)
+{
+ fasttrap_tracepoint_t *tp;
+ fasttrap_bucket_t *bucket;
+ fasttrap_id_t *id;
+ kmutex_t *pid_mtx;
+
+ pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
+ mutex_enter(pid_mtx);
+ bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
+
+ for (tp = bucket->ftb_data; tp != NULL; tp = tp->ftt_next) {
+ if (pid == tp->ftt_pid && pc == tp->ftt_pc &&
+ tp->ftt_proc->ftpc_acount != 0)
+ break;
+ }
+
+ /*
+ * Don't sweat it if we can't find the tracepoint again; unlike
+ * when we're in fasttrap_pid_probe(), finding the tracepoint here
+ * is not essential to the correct execution of the process.
+ */
+ if (tp == NULL) {
+ mutex_exit(pid_mtx);
+ return;
+ }
+
+ for (id = tp->ftt_retids; id != NULL; id = id->fti_next) {
+ /*
+ * If there's a branch that could act as a return site, we
+ * need to trace it, and check here if the program counter is
+ * external to the function.
+ */
+ if (tp->ftt_type != FASTTRAP_T_RET &&
+ tp->ftt_type != FASTTRAP_T_RET16 &&
+ new_pc - id->fti_probe->ftp_faddr <
+ id->fti_probe->ftp_fsize)
+ continue;
+
+ dtrace_probe(id->fti_probe->ftp_id,
+ pc - id->fti_probe->ftp_faddr,
+ rp->r_r0, rp->r_r1, 0, 0);
+ }
+
+ mutex_exit(pid_mtx);
+}
+
+static void
+fasttrap_sigsegv(proc_t *p, kthread_t *t, uintptr_t addr)
+{
+ sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
+
+ sqp->sq_info.si_signo = SIGSEGV;
+ sqp->sq_info.si_code = SEGV_MAPERR;
+ sqp->sq_info.si_addr = (caddr_t)addr;
+
+ mutex_enter(&p->p_lock);
+ sigaddqa(p, t, sqp);
+ mutex_exit(&p->p_lock);
+
+ if (t != NULL)
+ aston(t);
+}
+
+#ifdef __amd64
+static void
+fasttrap_usdt_args64(fasttrap_probe_t *probe, struct regs *rp, int argc,
+ uintptr_t *argv)
+{
+ int i, x, cap = MIN(argc, probe->ftp_nargs);
+ uintptr_t *stack = (uintptr_t *)rp->r_sp;
+
+ for (i = 0; i < cap; i++) {
+ x = probe->ftp_argmap[i];
+
+ if (x < 6)
+ argv[i] = (&rp->r_rdi)[x];
+ else
+ argv[i] = fasttrap_fulword_noerr(&stack[x]);
+ }
+
+ for (; i < argc; i++) {
+ argv[i] = 0;
+ }
+}
+#endif
+
+static void
+fasttrap_usdt_args32(fasttrap_probe_t *probe, struct regs *rp, int argc,
+ uint32_t *argv)
+{
+ int i, x, cap = MIN(argc, probe->ftp_nargs);
+ uint32_t *stack = (uint32_t *)rp->r_sp;
+
+ for (i = 0; i < cap; i++) {
+ x = probe->ftp_argmap[i];
+
+ argv[i] = fasttrap_fuword32_noerr(&stack[x]);
+ }
+
+ for (; i < argc; i++) {
+ argv[i] = 0;
+ }
+}
+
+static int
+fasttrap_do_seg(fasttrap_tracepoint_t *tp, struct regs *rp, uintptr_t *addr)
+{
+ proc_t *p = curproc;
+ user_desc_t *desc;
+ uint16_t sel, ndx, type;
+ uintptr_t limit;
+
+ switch (tp->ftt_segment) {
+ case FASTTRAP_SEG_CS:
+ sel = rp->r_cs;
+ break;
+ case FASTTRAP_SEG_DS:
+ sel = rp->r_ds;
+ break;
+ case FASTTRAP_SEG_ES:
+ sel = rp->r_es;
+ break;
+ case FASTTRAP_SEG_FS:
+ sel = rp->r_fs;
+ break;
+ case FASTTRAP_SEG_GS:
+ sel = rp->r_gs;
+ break;
+ case FASTTRAP_SEG_SS:
+ sel = rp->r_ss;
+ break;
+ }
+
+ /*
+ * Make sure the given segment register specifies a user priority
+ * selector rather than a kernel selector.
+ */
+ if (!SELISUPL(sel))
+ return (-1);
+
+ ndx = SELTOIDX(sel);
+
+ /*
+ * Check the bounds and grab the descriptor out of the specified
+ * descriptor table.
+ */
+ if (SELISLDT(sel)) {
+ if (ndx > p->p_ldtlimit)
+ return (-1);
+
+ desc = p->p_ldt + ndx;
+
+ } else {
+ if (ndx >= NGDT)
+ return (-1);
+
+ desc = cpu_get_gdt() + ndx;
+ }
+
+ /*
+ * The descriptor must have user privilege level and it must be
+ * present in memory.
+ */
+ if (desc->usd_dpl != SEL_UPL || desc->usd_p != 1)
+ return (-1);
+
+ type = desc->usd_type;
+
+ /*
+ * If the S bit in the type field is not set, this descriptor can
+ * only be used in system context.
+ */
+ if ((type & 0x10) != 0x10)
+ return (-1);
+
+ limit = USEGD_GETLIMIT(desc) * (desc->usd_gran ? PAGESIZE : 1);
+
+ if (tp->ftt_segment == FASTTRAP_SEG_CS) {
+ /*
+ * The code/data bit and readable bit must both be set.
+ */
+ if ((type & 0xa) != 0xa)
+ return (-1);
+
+ if (*addr > limit)
+ return (-1);
+ } else {
+ /*
+ * The code/data bit must be clear.
+ */
+ if ((type & 0x8) != 0)
+ return (-1);
+
+ /*
+ * If the expand-down bit is clear, we just check the limit as
+ * it would naturally be applied. Otherwise, we need to check
+ * that the address is the range [limit + 1 .. 0xffff] or
+ * [limit + 1 ... 0xffffffff] depending on if the default
+ * operand size bit is set.
+ */
+ if ((type & 0x4) == 0) {
+ if (*addr > limit)
+ return (-1);
+ } else if (desc->usd_def32) {
+ if (*addr < limit + 1 || 0xffff < *addr)
+ return (-1);
+ } else {
+ if (*addr < limit + 1 || 0xffffffff < *addr)
+ return (-1);
+ }
+ }
+
+ *addr += USEGD_GETBASE(desc);
+
+ return (0);
+}
+
+int
+fasttrap_pid_probe(struct regs *rp)
+{
+ proc_t *p = curproc;
+ uintptr_t pc = rp->r_pc - 1, new_pc = 0;
+ fasttrap_bucket_t *bucket;
+ kmutex_t *pid_mtx;
+ fasttrap_tracepoint_t *tp, tp_local;
+ pid_t pid;
+ dtrace_icookie_t cookie;
+ uint_t is_enabled = 0;
+
+ /*
+ * It's possible that a user (in a veritable orgy of bad planning)
+ * could redirect this thread's flow of control before it reached the
+ * return probe fasttrap. In this case we need to kill the process
+ * since it's in a unrecoverable state.
+ */
+ if (curthread->t_dtrace_step) {
+ ASSERT(curthread->t_dtrace_on);
+ fasttrap_sigtrap(p, curthread, pc);
+ return (0);
+ }
+
+ /*
+ * Clear all user tracing flags.
+ */
+ curthread->t_dtrace_ft = 0;
+ curthread->t_dtrace_pc = 0;
+ curthread->t_dtrace_npc = 0;
+ curthread->t_dtrace_scrpc = 0;
+ curthread->t_dtrace_astpc = 0;
+#ifdef __amd64
+ curthread->t_dtrace_regv = 0;
+#endif
+
+ /*
+ * Treat a child created by a call to vfork(2) as if it were its
+ * parent. We know that there's only one thread of control in such a
+ * process: this one.
+ */
+ while (p->p_flag & SVFORK) {
+ p = p->p_parent;
+ }
+
+ pid = p->p_pid;
+ pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
+ mutex_enter(pid_mtx);
+ bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
+
+ /*
+ * Lookup the tracepoint that the process just hit.
+ */
+ for (tp = bucket->ftb_data; tp != NULL; tp = tp->ftt_next) {
+ if (pid == tp->ftt_pid && pc == tp->ftt_pc &&
+ tp->ftt_proc->ftpc_acount != 0)
+ break;
+ }
+
+ /*
+ * If we couldn't find a matching tracepoint, either a tracepoint has
+ * been inserted without using the pid<pid> ioctl interface (see
+ * fasttrap_ioctl), or somehow we have mislaid this tracepoint.
+ */
+ if (tp == NULL) {
+ mutex_exit(pid_mtx);
+ return (-1);
+ }
+
+ /*
+ * Set the program counter to the address of the traced instruction
+ * so that it looks right in ustack() output.
+ */
+ rp->r_pc = pc;
+
+ if (tp->ftt_ids != NULL) {
+ fasttrap_id_t *id;
+
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_LP64) {
+ for (id = tp->ftt_ids; id != NULL; id = id->fti_next) {
+ fasttrap_probe_t *probe = id->fti_probe;
+
+ if (id->fti_ptype == DTFTP_ENTRY) {
+ /*
+ * We note that this was an entry
+ * probe to help ustack() find the
+ * first caller.
+ */
+ cookie = dtrace_interrupt_disable();
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ENTRY);
+ dtrace_probe(probe->ftp_id, rp->r_rdi,
+ rp->r_rsi, rp->r_rdx, rp->r_rcx,
+ rp->r_r8);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_ENTRY);
+ dtrace_interrupt_enable(cookie);
+ } else if (id->fti_ptype == DTFTP_IS_ENABLED) {
+ /*
+ * Note that in this case, we don't
+ * call dtrace_probe() since it's only
+ * an artificial probe meant to change
+ * the flow of control so that it
+ * encounters the true probe.
+ */
+ is_enabled = 1;
+ } else if (probe->ftp_argmap == NULL) {
+ dtrace_probe(probe->ftp_id, rp->r_rdi,
+ rp->r_rsi, rp->r_rdx, rp->r_rcx,
+ rp->r_r8);
+ } else {
+ uintptr_t t[5];
+
+ fasttrap_usdt_args64(probe, rp,
+ sizeof (t) / sizeof (t[0]), t);
+
+ dtrace_probe(probe->ftp_id, t[0], t[1],
+ t[2], t[3], t[4]);
+ }
+ }
+ } else {
+#endif
+ uintptr_t s0, s1, s2, s3, s4, s5;
+ uint32_t *stack = (uint32_t *)rp->r_sp;
+
+ /*
+ * In 32-bit mode, all arguments are passed on the
+ * stack. If this is a function entry probe, we need
+ * to skip the first entry on the stack as it
+ * represents the return address rather than a
+ * parameter to the function.
+ */
+ s0 = fasttrap_fuword32_noerr(&stack[0]);
+ s1 = fasttrap_fuword32_noerr(&stack[1]);
+ s2 = fasttrap_fuword32_noerr(&stack[2]);
+ s3 = fasttrap_fuword32_noerr(&stack[3]);
+ s4 = fasttrap_fuword32_noerr(&stack[4]);
+ s5 = fasttrap_fuword32_noerr(&stack[5]);
+
+ for (id = tp->ftt_ids; id != NULL; id = id->fti_next) {
+ fasttrap_probe_t *probe = id->fti_probe;
+
+ if (id->fti_ptype == DTFTP_ENTRY) {
+ /*
+ * We note that this was an entry
+ * probe to help ustack() find the
+ * first caller.
+ */
+ cookie = dtrace_interrupt_disable();
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ENTRY);
+ dtrace_probe(probe->ftp_id, s1, s2,
+ s3, s4, s5);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_ENTRY);
+ dtrace_interrupt_enable(cookie);
+ } else if (id->fti_ptype == DTFTP_IS_ENABLED) {
+ /*
+ * Note that in this case, we don't
+ * call dtrace_probe() since it's only
+ * an artificial probe meant to change
+ * the flow of control so that it
+ * encounters the true probe.
+ */
+ is_enabled = 1;
+ } else if (probe->ftp_argmap == NULL) {
+ dtrace_probe(probe->ftp_id, s0, s1,
+ s2, s3, s4);
+ } else {
+ uint32_t t[5];
+
+ fasttrap_usdt_args32(probe, rp,
+ sizeof (t) / sizeof (t[0]), t);
+
+ dtrace_probe(probe->ftp_id, t[0], t[1],
+ t[2], t[3], t[4]);
+ }
+ }
+#ifdef __amd64
+ }
+#endif
+ }
+
+ /*
+ * We're about to do a bunch of work so we cache a local copy of
+ * the tracepoint to emulate the instruction, and then find the
+ * tracepoint again later if we need to light up any return probes.
+ */
+ tp_local = *tp;
+ mutex_exit(pid_mtx);
+ tp = &tp_local;
+
+ /*
+ * Set the program counter to appear as though the traced instruction
+ * had completely executed. This ensures that fasttrap_getreg() will
+ * report the expected value for REG_RIP.
+ */
+ rp->r_pc = pc + tp->ftt_size;
+
+ /*
+ * If there's an is-enabled probe connected to this tracepoint it
+ * means that there was a 'xorl %eax, %eax' or 'xorq %rax, %rax'
+ * instruction that was placed there by DTrace when the binary was
+ * linked. As this probe is, in fact, enabled, we need to stuff 1
+ * into %eax or %rax. Accordingly, we can bypass all the instruction
+ * emulation logic since we know the inevitable result. It's possible
+ * that a user could construct a scenario where the 'is-enabled'
+ * probe was on some other instruction, but that would be a rather
+ * exotic way to shoot oneself in the foot.
+ */
+ if (is_enabled) {
+ rp->r_r0 = 1;
+ new_pc = rp->r_pc;
+ goto done;
+ }
+
+ /*
+ * We emulate certain types of instructions to ensure correctness
+ * (in the case of position dependent instructions) or optimize
+ * common cases. The rest we have the thread execute back in user-
+ * land.
+ */
+ switch (tp->ftt_type) {
+ case FASTTRAP_T_RET:
+ case FASTTRAP_T_RET16:
+ {
+ uintptr_t dst;
+ uintptr_t addr;
+ int ret;
+
+ /*
+ * We have to emulate _every_ facet of the behavior of a ret
+ * instruction including what happens if the load from %esp
+ * fails; in that case, we send a SIGSEGV.
+ */
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_NATIVE) {
+#endif
+ ret = fasttrap_fulword((void *)rp->r_sp, &dst);
+ addr = rp->r_sp + sizeof (uintptr_t);
+#ifdef __amd64
+ } else {
+ uint32_t dst32;
+ ret = fasttrap_fuword32((void *)rp->r_sp, &dst32);
+ dst = dst32;
+ addr = rp->r_sp + sizeof (uint32_t);
+ }
+#endif
+
+ if (ret == -1) {
+ fasttrap_sigsegv(p, curthread, rp->r_sp);
+ new_pc = pc;
+ break;
+ }
+
+ if (tp->ftt_type == FASTTRAP_T_RET16)
+ addr += tp->ftt_dest;
+
+ rp->r_sp = addr;
+ new_pc = dst;
+ break;
+ }
+
+ case FASTTRAP_T_JCC:
+ {
+ uint_t taken;
+
+ switch (tp->ftt_code) {
+ case FASTTRAP_JO:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_OF) != 0;
+ break;
+ case FASTTRAP_JNO:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_OF) == 0;
+ break;
+ case FASTTRAP_JB:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_CF) != 0;
+ break;
+ case FASTTRAP_JAE:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_CF) == 0;
+ break;
+ case FASTTRAP_JE:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_ZF) != 0;
+ break;
+ case FASTTRAP_JNE:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_ZF) == 0;
+ break;
+ case FASTTRAP_JBE:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_CF) != 0 ||
+ (rp->r_ps & FASTTRAP_EFLAGS_ZF) != 0;
+ break;
+ case FASTTRAP_JA:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_CF) == 0 &&
+ (rp->r_ps & FASTTRAP_EFLAGS_ZF) == 0;
+ break;
+ case FASTTRAP_JS:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_SF) != 0;
+ break;
+ case FASTTRAP_JNS:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_SF) == 0;
+ break;
+ case FASTTRAP_JP:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_PF) != 0;
+ break;
+ case FASTTRAP_JNP:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_PF) == 0;
+ break;
+ case FASTTRAP_JL:
+ taken = ((rp->r_ps & FASTTRAP_EFLAGS_SF) == 0) !=
+ ((rp->r_ps & FASTTRAP_EFLAGS_OF) == 0);
+ break;
+ case FASTTRAP_JGE:
+ taken = ((rp->r_ps & FASTTRAP_EFLAGS_SF) == 0) ==
+ ((rp->r_ps & FASTTRAP_EFLAGS_OF) == 0);
+ break;
+ case FASTTRAP_JLE:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_ZF) != 0 ||
+ ((rp->r_ps & FASTTRAP_EFLAGS_SF) == 0) !=
+ ((rp->r_ps & FASTTRAP_EFLAGS_OF) == 0);
+ break;
+ case FASTTRAP_JG:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_ZF) == 0 &&
+ ((rp->r_ps & FASTTRAP_EFLAGS_SF) == 0) ==
+ ((rp->r_ps & FASTTRAP_EFLAGS_OF) == 0);
+ break;
+
+ }
+
+ if (taken)
+ new_pc = tp->ftt_dest;
+ else
+ new_pc = pc + tp->ftt_size;
+ break;
+ }
+
+ case FASTTRAP_T_LOOP:
+ {
+ uint_t taken;
+#ifdef __amd64
+ greg_t cx = rp->r_rcx--;
+#else
+ greg_t cx = rp->r_ecx--;
+#endif
+
+ switch (tp->ftt_code) {
+ case FASTTRAP_LOOPNZ:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_ZF) == 0 &&
+ cx != 0;
+ break;
+ case FASTTRAP_LOOPZ:
+ taken = (rp->r_ps & FASTTRAP_EFLAGS_ZF) != 0 &&
+ cx != 0;
+ break;
+ case FASTTRAP_LOOP:
+ taken = (cx != 0);
+ break;
+ }
+
+ if (taken)
+ new_pc = tp->ftt_dest;
+ else
+ new_pc = pc + tp->ftt_size;
+ break;
+ }
+
+ case FASTTRAP_T_JCXZ:
+ {
+#ifdef __amd64
+ greg_t cx = rp->r_rcx;
+#else
+ greg_t cx = rp->r_ecx;
+#endif
+
+ if (cx == 0)
+ new_pc = tp->ftt_dest;
+ else
+ new_pc = pc + tp->ftt_size;
+ break;
+ }
+
+ case FASTTRAP_T_PUSHL_EBP:
+ {
+ int ret;
+ uintptr_t addr;
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_NATIVE) {
+#endif
+ addr = rp->r_sp - sizeof (uintptr_t);
+ ret = fasttrap_sulword((void *)addr, rp->r_fp);
+#ifdef __amd64
+ } else {
+ addr = rp->r_sp - sizeof (uint32_t);
+ ret = fasttrap_suword32((void *)addr,
+ (uint32_t)rp->r_fp);
+ }
+#endif
+
+ if (ret == -1) {
+ fasttrap_sigsegv(p, curthread, addr);
+ new_pc = pc;
+ break;
+ }
+
+ rp->r_sp = addr;
+ new_pc = pc + tp->ftt_size;
+ break;
+ }
+
+ case FASTTRAP_T_NOP:
+ new_pc = pc + tp->ftt_size;
+ break;
+
+ case FASTTRAP_T_JMP:
+ case FASTTRAP_T_CALL:
+ if (tp->ftt_code == 0) {
+ new_pc = tp->ftt_dest;
+ } else {
+ uintptr_t value, addr = tp->ftt_dest;
+
+ if (tp->ftt_base != FASTTRAP_NOREG)
+ addr += fasttrap_getreg(rp, tp->ftt_base);
+ if (tp->ftt_index != FASTTRAP_NOREG)
+ addr += fasttrap_getreg(rp, tp->ftt_index) <<
+ tp->ftt_scale;
+
+ if (tp->ftt_code == 1) {
+ /*
+ * If there's a segment prefix for this
+ * instruction, we'll need to check permissions
+ * and bounds on the given selector, and adjust
+ * the address accordingly.
+ */
+ if (tp->ftt_segment != FASTTRAP_SEG_NONE &&
+ fasttrap_do_seg(tp, rp, &addr) != 0) {
+ fasttrap_sigsegv(p, curthread, addr);
+ new_pc = pc;
+ break;
+ }
+
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_NATIVE) {
+#endif
+ if (fasttrap_fulword((void *)addr,
+ &value) == -1) {
+ fasttrap_sigsegv(p, curthread,
+ addr);
+ new_pc = pc;
+ break;
+ }
+ new_pc = value;
+#ifdef __amd64
+ } else {
+ uint32_t value32;
+ addr = (uintptr_t)(uint32_t)addr;
+ if (fasttrap_fuword32((void *)addr,
+ &value32) == -1) {
+ fasttrap_sigsegv(p, curthread,
+ addr);
+ new_pc = pc;
+ break;
+ }
+ new_pc = value32;
+ }
+#endif
+ } else {
+ new_pc = addr;
+ }
+ }
+
+ /*
+ * If this is a call instruction, we need to push the return
+ * address onto the stack. If this fails, we send the process
+ * a SIGSEGV and reset the pc to emulate what would happen if
+ * this instruction weren't traced.
+ */
+ if (tp->ftt_type == FASTTRAP_T_CALL) {
+ int ret;
+ uintptr_t addr;
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_NATIVE) {
+ addr = rp->r_sp - sizeof (uintptr_t);
+ ret = fasttrap_sulword((void *)addr,
+ pc + tp->ftt_size);
+ } else {
+#endif
+ addr = rp->r_sp - sizeof (uint32_t);
+ ret = fasttrap_suword32((void *)addr,
+ (uint32_t)(pc + tp->ftt_size));
+#ifdef __amd64
+ }
+#endif
+
+ if (ret == -1) {
+ fasttrap_sigsegv(p, curthread, addr);
+ new_pc = pc;
+ break;
+ }
+
+ rp->r_sp = addr;
+ }
+
+ break;
+
+ case FASTTRAP_T_COMMON:
+ {
+ uintptr_t addr;
+#if defined(__amd64)
+ uint8_t scratch[2 * FASTTRAP_MAX_INSTR_SIZE + 22];
+#else
+ uint8_t scratch[2 * FASTTRAP_MAX_INSTR_SIZE + 7];
+#endif
+ uint_t i = 0;
+ klwp_t *lwp = ttolwp(curthread);
+
+ /*
+ * Compute the address of the ulwp_t and step over the
+ * ul_self pointer. The method used to store the user-land
+ * thread pointer is very different on 32- and 64-bit
+ * kernels.
+ */
+#if defined(__amd64)
+ if (p->p_model == DATAMODEL_LP64) {
+ addr = lwp->lwp_pcb.pcb_fsbase;
+ addr += sizeof (void *);
+ } else {
+ addr = lwp->lwp_pcb.pcb_gsbase;
+ addr += sizeof (caddr32_t);
+ }
+#else
+ addr = USEGD_GETBASE(&lwp->lwp_pcb.pcb_gsdesc);
+ addr += sizeof (void *);
+#endif
+
+ /*
+ * Generic Instruction Tracing
+ * ---------------------------
+ *
+ * This is the layout of the scratch space in the user-land
+ * thread structure for our generated instructions.
+ *
+ * 32-bit mode bytes
+ * ------------------------ -----
+ * a: <original instruction> <= 15
+ * jmp <pc + tp->ftt_size> 5
+ * b: <original instrction> <= 15
+ * int T_DTRACE_RET 2
+ * -----
+ * <= 37
+ *
+ * 64-bit mode bytes
+ * ------------------------ -----
+ * a: <original instruction> <= 15
+ * jmp 0(%rip) 6
+ * <pc + tp->ftt_size> 8
+ * b: <original instruction> <= 15
+ * int T_DTRACE_RET 2
+ * -----
+ * <= 46
+ *
+ * The %pc is set to a, and curthread->t_dtrace_astpc is set
+ * to b. If we encounter a signal on the way out of the
+ * kernel, trap() will set %pc to curthread->t_dtrace_astpc
+ * so that we execute the original instruction and re-enter
+ * the kernel rather than redirecting to the next instruction.
+ *
+ * If there are return probes (so we know that we're going to
+ * need to reenter the kernel after executing the original
+ * instruction), the scratch space will just contain the
+ * original instruction followed by an interrupt -- the same
+ * data as at b.
+ *
+ * %rip-relative Addressing
+ * ------------------------
+ *
+ * There's a further complication in 64-bit mode due to %rip-
+ * relative addressing. While this is clearly a beneficial
+ * architectural decision for position independent code, it's
+ * hard not to see it as a personal attack against the pid
+ * provider since before there was a relatively small set of
+ * instructions to emulate; with %rip-relative addressing,
+ * almost every instruction can potentially depend on the
+ * address at which it's executed. Rather than emulating
+ * the broad spectrum of instructions that can now be
+ * position dependent, we emulate jumps and others as in
+ * 32-bit mode, and take a different tack for instructions
+ * using %rip-relative addressing.
+ *
+ * For every instruction that uses the ModRM byte, the
+ * in-kernel disassembler reports its location. We use the
+ * ModRM byte to identify that an instruction uses
+ * %rip-relative addressing and to see what other registers
+ * the instruction uses. To emulate those instructions,
+ * we modify the instruction to be %rax-relative rather than
+ * %rip-relative (or %rcx-relative if the instruction uses
+ * %rax; or %r8- or %r9-relative if the REX.B is present so
+ * we don't have to rewrite the REX prefix). We then load
+ * the value that %rip would have been into the scratch
+ * register and generate an instruction to reset the scratch
+ * register back to its original value. The instruction
+ * sequence looks like this:
+ *
+ * 64-mode %rip-relative bytes
+ * ------------------------ -----
+ * a: <modified instruction> <= 15
+ * movq $<value>, %<scratch> 6
+ * jmp 0(%rip) 6
+ * <pc + tp->ftt_size> 8
+ * b: <modified instruction> <= 15
+ * int T_DTRACE_RET 2
+ * -----
+ * 52
+ *
+ * We set curthread->t_dtrace_regv so that upon receiving
+ * a signal we can reset the value of the scratch register.
+ */
+
+ ASSERT(tp->ftt_size < FASTTRAP_MAX_INSTR_SIZE);
+
+ curthread->t_dtrace_scrpc = addr;
+ bcopy(tp->ftt_instr, &scratch[i], tp->ftt_size);
+ i += tp->ftt_size;
+
+#ifdef __amd64
+ if (tp->ftt_ripmode != 0) {
+ greg_t *reg;
+
+ ASSERT(p->p_model == DATAMODEL_LP64);
+ ASSERT(tp->ftt_ripmode &
+ (FASTTRAP_RIP_1 | FASTTRAP_RIP_2));
+
+ /*
+ * If this was a %rip-relative instruction, we change
+ * it to be either a %rax- or %rcx-relative
+ * instruction (depending on whether those registers
+ * are used as another operand; or %r8- or %r9-
+ * relative depending on the value of REX.B). We then
+ * set that register and generate a movq instruction
+ * to reset the value.
+ */
+ if (tp->ftt_ripmode & FASTTRAP_RIP_X)
+ scratch[i++] = FASTTRAP_REX(1, 0, 0, 1);
+ else
+ scratch[i++] = FASTTRAP_REX(1, 0, 0, 0);
+
+ if (tp->ftt_ripmode & FASTTRAP_RIP_1)
+ scratch[i++] = FASTTRAP_MOV_EAX;
+ else
+ scratch[i++] = FASTTRAP_MOV_ECX;
+
+ switch (tp->ftt_ripmode) {
+ case FASTTRAP_RIP_1:
+ reg = &rp->r_rax;
+ curthread->t_dtrace_reg = REG_RAX;
+ break;
+ case FASTTRAP_RIP_2:
+ reg = &rp->r_rcx;
+ curthread->t_dtrace_reg = REG_RCX;
+ break;
+ case FASTTRAP_RIP_1 | FASTTRAP_RIP_X:
+ reg = &rp->r_r8;
+ curthread->t_dtrace_reg = REG_R8;
+ break;
+ case FASTTRAP_RIP_2 | FASTTRAP_RIP_X:
+ reg = &rp->r_r9;
+ curthread->t_dtrace_reg = REG_R9;
+ break;
+ }
+
+ /* LINTED - alignment */
+ *(uint64_t *)&scratch[i] = *reg;
+ curthread->t_dtrace_regv = *reg;
+ *reg = pc + tp->ftt_size;
+ i += sizeof (uint64_t);
+ }
+#endif
+
+ /*
+ * Generate the branch instruction to what would have
+ * normally been the subsequent instruction. In 32-bit mode,
+ * this is just a relative branch; in 64-bit mode this is a
+ * %rip-relative branch that loads the 64-bit pc value
+ * immediately after the jmp instruction.
+ */
+#ifdef __amd64
+ if (p->p_model == DATAMODEL_LP64) {
+ scratch[i++] = FASTTRAP_GROUP5_OP;
+ scratch[i++] = FASTTRAP_MODRM(0, 4, 5);
+ /* LINTED - alignment */
+ *(uint32_t *)&scratch[i] = 0;
+ i += sizeof (uint32_t);
+ /* LINTED - alignment */
+ *(uint64_t *)&scratch[i] = pc + tp->ftt_size;
+ i += sizeof (uint64_t);
+ } else {
+#endif
+ /*
+ * Set up the jmp to the next instruction; note that
+ * the size of the traced instruction cancels out.
+ */
+ scratch[i++] = FASTTRAP_JMP32;
+ /* LINTED - alignment */
+ *(uint32_t *)&scratch[i] = pc - addr - 5;
+ i += sizeof (uint32_t);
+#ifdef __amd64
+ }
+#endif
+
+ curthread->t_dtrace_astpc = addr + i;
+ bcopy(tp->ftt_instr, &scratch[i], tp->ftt_size);
+ i += tp->ftt_size;
+ scratch[i++] = FASTTRAP_INT;
+ scratch[i++] = T_DTRACE_RET;
+
+ ASSERT(i <= sizeof (scratch));
+
+ if (fasttrap_copyout(scratch, (char *)addr, i)) {
+ fasttrap_sigtrap(p, curthread, pc);
+ new_pc = pc;
+ break;
+ }
+
+ if (tp->ftt_retids != NULL) {
+ curthread->t_dtrace_step = 1;
+ curthread->t_dtrace_ret = 1;
+ new_pc = curthread->t_dtrace_astpc;
+ } else {
+ new_pc = curthread->t_dtrace_scrpc;
+ }
+
+ curthread->t_dtrace_pc = pc;
+ curthread->t_dtrace_npc = pc + tp->ftt_size;
+ curthread->t_dtrace_on = 1;
+ break;
+ }
+
+ default:
+ panic("fasttrap: mishandled an instruction");
+ }
+
+done:
+ /*
+ * If there were no return probes when we first found the tracepoint,
+ * we should feel no obligation to honor any return probes that were
+ * subsequently enabled -- they'll just have to wait until the next
+ * time around.
+ */
+ if (tp->ftt_retids != NULL) {
+ /*
+ * We need to wait until the results of the instruction are
+ * apparent before invoking any return probes. If this
+ * instruction was emulated we can just call
+ * fasttrap_return_common(); if it needs to be executed, we
+ * need to wait until the user thread returns to the kernel.
+ */
+ if (tp->ftt_type != FASTTRAP_T_COMMON) {
+ /*
+ * Set the program counter to the address of the traced
+ * instruction so that it looks right in ustack()
+ * output. We had previously set it to the end of the
+ * instruction to simplify %rip-relative addressing.
+ */
+ rp->r_pc = pc;
+
+ fasttrap_return_common(rp, pc, pid, new_pc);
+ } else {
+ ASSERT(curthread->t_dtrace_ret != 0);
+ ASSERT(curthread->t_dtrace_pc == pc);
+ ASSERT(curthread->t_dtrace_scrpc != 0);
+ ASSERT(new_pc == curthread->t_dtrace_astpc);
+ }
+ }
+
+ rp->r_pc = new_pc;
+
+ return (0);
+}
+
+int
+fasttrap_return_probe(struct regs *rp)
+{
+ proc_t *p = curproc;
+ uintptr_t pc = curthread->t_dtrace_pc;
+ uintptr_t npc = curthread->t_dtrace_npc;
+
+ curthread->t_dtrace_pc = 0;
+ curthread->t_dtrace_npc = 0;
+ curthread->t_dtrace_scrpc = 0;
+ curthread->t_dtrace_astpc = 0;
+
+ /*
+ * Treat a child created by a call to vfork(2) as if it were its
+ * parent. We know that there's only one thread of control in such a
+ * process: this one.
+ */
+ while (p->p_flag & SVFORK) {
+ p = p->p_parent;
+ }
+
+ /*
+ * We set rp->r_pc to the address of the traced instruction so
+ * that it appears to dtrace_probe() that we're on the original
+ * instruction, and so that the user can't easily detect our
+ * complex web of lies. dtrace_return_probe() (our caller)
+ * will correctly set %pc after we return.
+ */
+ rp->r_pc = pc;
+
+ fasttrap_return_common(rp, pc, p->p_pid, npc);
+
+ return (0);
+}
+
+/*ARGSUSED*/
+uint64_t
+fasttrap_pid_getarg(void *arg, dtrace_id_t id, void *parg, int argno,
+ int aframes)
+{
+ return (fasttrap_anarg(ttolwp(curthread)->lwp_regs, 1, argno));
+}
+
+/*ARGSUSED*/
+uint64_t
+fasttrap_usdt_getarg(void *arg, dtrace_id_t id, void *parg, int argno,
+ int aframes)
+{
+ return (fasttrap_anarg(ttolwp(curthread)->lwp_regs, 0, argno));
+}
+
+static ulong_t
+fasttrap_getreg(struct regs *rp, uint_t reg)
+{
+#ifdef __amd64
+ switch (reg) {
+ case REG_R15: return (rp->r_r15);
+ case REG_R14: return (rp->r_r14);
+ case REG_R13: return (rp->r_r13);
+ case REG_R12: return (rp->r_r12);
+ case REG_R11: return (rp->r_r11);
+ case REG_R10: return (rp->r_r10);
+ case REG_R9: return (rp->r_r9);
+ case REG_R8: return (rp->r_r8);
+ case REG_RDI: return (rp->r_rdi);
+ case REG_RSI: return (rp->r_rsi);
+ case REG_RBP: return (rp->r_rbp);
+ case REG_RBX: return (rp->r_rbx);
+ case REG_RDX: return (rp->r_rdx);
+ case REG_RCX: return (rp->r_rcx);
+ case REG_RAX: return (rp->r_rax);
+ case REG_TRAPNO: return (rp->r_trapno);
+ case REG_ERR: return (rp->r_err);
+ case REG_RIP: return (rp->r_rip);
+ case REG_CS: return (rp->r_cs);
+ case REG_RFL: return (rp->r_rfl);
+ case REG_RSP: return (rp->r_rsp);
+ case REG_SS: return (rp->r_ss);
+ case REG_FS: return (rp->r_fs);
+ case REG_GS: return (rp->r_gs);
+ case REG_DS: return (rp->r_ds);
+ case REG_ES: return (rp->r_es);
+ case REG_FSBASE: return (rdmsr(MSR_AMD_FSBASE));
+ case REG_GSBASE: return (rdmsr(MSR_AMD_GSBASE));
+ }
+
+ panic("dtrace: illegal register constant");
+ /*NOTREACHED*/
+#else
+ if (reg >= _NGREG)
+ panic("dtrace: illegal register constant");
+
+ return (((greg_t *)&rp->r_gs)[reg]);
+#endif
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.c
new file mode 100644
index 00000000..b9353bd3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.c
@@ -0,0 +1,849 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#include <sys/modctl.h>
+#include <sys/dtrace.h>
+#include <sys/kobj.h>
+#include <sys/stat.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/conf.h>
+
+#define FBT_PUSHL_EBP 0x55
+#define FBT_MOVL_ESP_EBP0_V0 0x8b
+#define FBT_MOVL_ESP_EBP1_V0 0xec
+#define FBT_MOVL_ESP_EBP0_V1 0x89
+#define FBT_MOVL_ESP_EBP1_V1 0xe5
+#define FBT_REX_RSP_RBP 0x48
+
+#define FBT_POPL_EBP 0x5d
+#define FBT_RET 0xc3
+#define FBT_RET_IMM16 0xc2
+#define FBT_LEAVE 0xc9
+
+#ifdef __amd64
+#define FBT_PATCHVAL 0xcc
+#else
+#define FBT_PATCHVAL 0xf0
+#endif
+
+#define FBT_ENTRY "entry"
+#define FBT_RETURN "return"
+#define FBT_ADDR2NDX(addr) ((((uintptr_t)(addr)) >> 4) & fbt_probetab_mask)
+#define FBT_PROBETAB_SIZE 0x8000 /* 32k entries -- 128K total */
+
+typedef struct fbt_probe {
+ struct fbt_probe *fbtp_hashnext;
+ uint8_t *fbtp_patchpoint;
+ int8_t fbtp_rval;
+ uint8_t fbtp_patchval;
+ uint8_t fbtp_savedval;
+ uintptr_t fbtp_roffset;
+ dtrace_id_t fbtp_id;
+ char *fbtp_name;
+ struct modctl *fbtp_ctl;
+ int fbtp_loadcnt;
+ int fbtp_symndx;
+ int fbtp_primary;
+ struct fbt_probe *fbtp_next;
+} fbt_probe_t;
+
+static dev_info_t *fbt_devi;
+static dtrace_provider_id_t fbt_id;
+static fbt_probe_t **fbt_probetab;
+static int fbt_probetab_size;
+static int fbt_probetab_mask;
+static int fbt_verbose = 0;
+
+static int
+fbt_invop(uintptr_t addr, uintptr_t *stack, uintptr_t rval)
+{
+ uintptr_t stack0, stack1, stack2, stack3, stack4;
+ fbt_probe_t *fbt = fbt_probetab[FBT_ADDR2NDX(addr)];
+
+ for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
+ if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
+ if (fbt->fbtp_roffset == 0) {
+ int i = 0;
+ /*
+ * When accessing the arguments on the stack,
+ * we must protect against accessing beyond
+ * the stack. We can safely set NOFAULT here
+ * -- we know that interrupts are already
+ * disabled.
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ CPU->cpu_dtrace_caller = stack[i++];
+#ifdef __amd64
+ /*
+ * On amd64, stack[0] contains the dereferenced
+ * stack pointer, stack[1] contains savfp,
+ * stack[2] contains savpc. We want to step
+ * over these entries.
+ */
+ i += 2;
+#endif
+ stack0 = stack[i++];
+ stack1 = stack[i++];
+ stack2 = stack[i++];
+ stack3 = stack[i++];
+ stack4 = stack[i++];
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT |
+ CPU_DTRACE_BADADDR);
+
+ dtrace_probe(fbt->fbtp_id, stack0, stack1,
+ stack2, stack3, stack4);
+
+ CPU->cpu_dtrace_caller = NULL;
+ } else {
+#ifdef __amd64
+ /*
+ * On amd64, we instrument the ret, not the
+ * leave. We therefore need to set the caller
+ * to assure that the top frame of a stack()
+ * action is correct.
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ CPU->cpu_dtrace_caller = stack[0];
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT |
+ CPU_DTRACE_BADADDR);
+#endif
+
+ dtrace_probe(fbt->fbtp_id, fbt->fbtp_roffset,
+ rval, 0, 0, 0);
+ CPU->cpu_dtrace_caller = NULL;
+ }
+
+ return (fbt->fbtp_rval);
+ }
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+fbt_provide_module(void *arg, struct modctl *ctl)
+{
+ struct module *mp = ctl->mod_mp;
+ char *str = mp->strings;
+ int nsyms = mp->nsyms;
+ Shdr *symhdr = mp->symhdr;
+ char *modname = ctl->mod_modname;
+ char *name;
+ fbt_probe_t *fbt, *retfbt;
+ size_t symsize;
+ int i, size;
+
+ /*
+ * Employees of dtrace and their families are ineligible. Void
+ * where prohibited.
+ */
+ if (strcmp(modname, "dtrace") == 0)
+ return;
+
+ if (ctl->mod_requisites != NULL) {
+ struct modctl_list *list;
+
+ list = (struct modctl_list *)ctl->mod_requisites;
+
+ for (; list != NULL; list = list->modl_next) {
+ if (strcmp(list->modl_modp->mod_modname, "dtrace") == 0)
+ return;
+ }
+ }
+
+ /*
+ * KMDB is ineligible for instrumentation -- it may execute in
+ * any context, including probe context.
+ */
+ if (strcmp(modname, "kmdbmod") == 0)
+ return;
+
+ if (str == NULL || symhdr == NULL || symhdr->sh_addr == NULL) {
+ /*
+ * If this module doesn't (yet) have its string or symbol
+ * table allocated, clear out.
+ */
+ return;
+ }
+
+ symsize = symhdr->sh_entsize;
+
+ if (mp->fbt_nentries) {
+ /*
+ * This module has some FBT entries allocated; we're afraid
+ * to screw with it.
+ */
+ return;
+ }
+
+ for (i = 1; i < nsyms; i++) {
+ uint8_t *instr, *limit;
+ Sym *sym = (Sym *)(symhdr->sh_addr + i * symsize);
+ int j;
+
+ if (ELF_ST_TYPE(sym->st_info) != STT_FUNC)
+ continue;
+
+ /*
+ * Weak symbols are not candidates. This could be made to
+ * work (where weak functions and their underlying function
+ * appear as two disjoint probes), but it's not simple.
+ */
+ if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
+ continue;
+
+ name = str + sym->st_name;
+
+ if (strstr(name, "dtrace_") == name &&
+ strstr(name, "dtrace_safe_") != name) {
+ /*
+ * Anything beginning with "dtrace_" may be called
+ * from probe context unless it explitly indicates
+ * that it won't be called from probe context by
+ * using the prefix "dtrace_safe_".
+ */
+ continue;
+ }
+
+ if (strstr(name, "kdi_") == name ||
+ strstr(name, "_kdi_") != NULL) {
+ /*
+ * Any function name beginning with "kdi_" or
+ * containing the string "_kdi_" is a part of the
+ * kernel debugger interface and may be called in
+ * arbitrary context -- including probe context.
+ */
+ continue;
+ }
+
+ /*
+ * Due to 4524008, _init and _fini may have a bloated st_size.
+ * While this bug was fixed quite some time ago, old drivers
+ * may be lurking. We need to develop a better solution to
+ * this problem, such that correct _init and _fini functions
+ * (the vast majority) may be correctly traced. One solution
+ * may be to scan through the entire symbol table to see if
+ * any symbol overlaps with _init. If none does, set a bit in
+ * the module structure that this module has correct _init and
+ * _fini sizes. This will cause some pain the first time a
+ * module is scanned, but at least it would be O(N) instead of
+ * O(N log N)...
+ */
+ if (strcmp(name, "_init") == 0)
+ continue;
+
+ if (strcmp(name, "_fini") == 0)
+ continue;
+
+ /*
+ * In order to be eligible, the function must begin with the
+ * following sequence:
+ *
+ * pushl %esp
+ * movl %esp, %ebp
+ *
+ * Note that there are two variants of encodings that generate
+ * the movl; we must check for both. For 64-bit, we would
+ * normally insist that a function begin with the following
+ * sequence:
+ *
+ * pushq %rbp
+ * movq %rsp, %rbp
+ *
+ * However, the compiler for 64-bit often splits these two
+ * instructions -- and the first instruction in the function
+ * is often not the pushq. As a result, on 64-bit we look
+ * for any "pushq %rbp" in the function and we instrument
+ * this with a breakpoint instruction.
+ */
+ instr = (uint8_t *)sym->st_value;
+ limit = (uint8_t *)(sym->st_value + sym->st_size);
+
+#ifdef __amd64
+ while (instr < limit) {
+ if (*instr == FBT_PUSHL_EBP)
+ break;
+
+ if ((size = dtrace_instr_size(instr)) <= 0)
+ break;
+
+ instr += size;
+ }
+
+ if (instr >= limit || *instr != FBT_PUSHL_EBP) {
+ /*
+ * We either don't save the frame pointer in this
+ * function, or we ran into some disassembly
+ * screw-up. Either way, we bail.
+ */
+ continue;
+ }
+#else
+ if (instr[0] != FBT_PUSHL_EBP)
+ continue;
+
+ if (!(instr[1] == FBT_MOVL_ESP_EBP0_V0 &&
+ instr[2] == FBT_MOVL_ESP_EBP1_V0) &&
+ !(instr[1] == FBT_MOVL_ESP_EBP0_V1 &&
+ instr[2] == FBT_MOVL_ESP_EBP1_V1))
+ continue;
+#endif
+
+ fbt = kmem_zalloc(sizeof (fbt_probe_t), KM_SLEEP);
+ fbt->fbtp_name = name;
+ fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
+ name, FBT_ENTRY, 3, fbt);
+ fbt->fbtp_patchpoint = instr;
+ fbt->fbtp_ctl = ctl;
+ fbt->fbtp_loadcnt = ctl->mod_loadcnt;
+ fbt->fbtp_rval = DTRACE_INVOP_PUSHL_EBP;
+ fbt->fbtp_savedval = *instr;
+ fbt->fbtp_patchval = FBT_PATCHVAL;
+
+ fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];
+ fbt->fbtp_symndx = i;
+ fbt_probetab[FBT_ADDR2NDX(instr)] = fbt;
+
+ mp->fbt_nentries++;
+
+ retfbt = NULL;
+again:
+ if (instr >= limit)
+ continue;
+
+ /*
+ * If this disassembly fails, then we've likely walked off into
+ * a jump table or some other unsuitable area. Bail out of the
+ * disassembly now.
+ */
+ if ((size = dtrace_instr_size(instr)) <= 0)
+ continue;
+
+#ifdef __amd64
+ /*
+ * We only instrument "ret" on amd64 -- we don't yet instrument
+ * ret imm16, largely because the compiler doesn't seem to
+ * (yet) emit them in the kernel...
+ */
+ if (*instr != FBT_RET) {
+ instr += size;
+ goto again;
+ }
+#else
+ if (!(size == 1 &&
+ (*instr == FBT_POPL_EBP || *instr == FBT_LEAVE) &&
+ (*(instr + 1) == FBT_RET ||
+ *(instr + 1) == FBT_RET_IMM16))) {
+ instr += size;
+ goto again;
+ }
+#endif
+
+ /*
+ * We (desperately) want to avoid erroneously instrumenting a
+ * jump table, especially given that our markers are pretty
+ * short: two bytes on x86, and just one byte on amd64. To
+ * determine if we're looking at a true instruction sequence
+ * or an inline jump table that happens to contain the same
+ * byte sequences, we resort to some heuristic sleeze: we
+ * treat this instruction as being contained within a pointer,
+ * and see if that pointer points to within the body of the
+ * function. If it does, we refuse to instrument it.
+ */
+ for (j = 0; j < sizeof (uintptr_t); j++) {
+ uintptr_t check = (uintptr_t)instr - j;
+ uint8_t *ptr;
+
+ if (check < sym->st_value)
+ break;
+
+ if (check + sizeof (uintptr_t) > (uintptr_t)limit)
+ continue;
+
+ ptr = *(uint8_t **)check;
+
+ if (ptr >= (uint8_t *)sym->st_value && ptr < limit) {
+ instr += size;
+ goto again;
+ }
+ }
+
+ /*
+ * We have a winner!
+ */
+ fbt = kmem_zalloc(sizeof (fbt_probe_t), KM_SLEEP);
+ fbt->fbtp_name = name;
+
+ if (retfbt == NULL) {
+ fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
+ name, FBT_RETURN, 3, fbt);
+ } else {
+ retfbt->fbtp_next = fbt;
+ fbt->fbtp_id = retfbt->fbtp_id;
+ }
+
+ retfbt = fbt;
+ fbt->fbtp_patchpoint = instr;
+ fbt->fbtp_ctl = ctl;
+ fbt->fbtp_loadcnt = ctl->mod_loadcnt;
+
+#ifndef __amd64
+ if (*instr == FBT_POPL_EBP) {
+ fbt->fbtp_rval = DTRACE_INVOP_POPL_EBP;
+ } else {
+ ASSERT(*instr == FBT_LEAVE);
+ fbt->fbtp_rval = DTRACE_INVOP_LEAVE;
+ }
+ fbt->fbtp_roffset =
+ (uintptr_t)(instr - (uint8_t *)sym->st_value) + 1;
+
+#else
+ ASSERT(*instr == FBT_RET);
+ fbt->fbtp_rval = DTRACE_INVOP_RET;
+ fbt->fbtp_roffset =
+ (uintptr_t)(instr - (uint8_t *)sym->st_value);
+#endif
+
+ fbt->fbtp_savedval = *instr;
+ fbt->fbtp_patchval = FBT_PATCHVAL;
+ fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];
+ fbt->fbtp_symndx = i;
+ fbt_probetab[FBT_ADDR2NDX(instr)] = fbt;
+
+ mp->fbt_nentries++;
+
+ instr += size;
+ goto again;
+ }
+}
+
+/*ARGSUSED*/
+static void
+fbt_destroy(void *arg, dtrace_id_t id, void *parg)
+{
+ fbt_probe_t *fbt = parg, *next, *hash, *last;
+ struct modctl *ctl = fbt->fbtp_ctl;
+ int ndx;
+
+ do {
+ if (ctl != NULL && ctl->mod_loadcnt == fbt->fbtp_loadcnt) {
+ if ((ctl->mod_loadcnt == fbt->fbtp_loadcnt &&
+ ctl->mod_loaded)) {
+ ((struct module *)
+ (ctl->mod_mp))->fbt_nentries--;
+ }
+ }
+
+ /*
+ * Now we need to remove this probe from the fbt_probetab.
+ */
+ ndx = FBT_ADDR2NDX(fbt->fbtp_patchpoint);
+ last = NULL;
+ hash = fbt_probetab[ndx];
+
+ while (hash != fbt) {
+ ASSERT(hash != NULL);
+ last = hash;
+ hash = hash->fbtp_hashnext;
+ }
+
+ if (last != NULL) {
+ last->fbtp_hashnext = fbt->fbtp_hashnext;
+ } else {
+ fbt_probetab[ndx] = fbt->fbtp_hashnext;
+ }
+
+ next = fbt->fbtp_next;
+ kmem_free(fbt, sizeof (fbt_probe_t));
+
+ fbt = next;
+ } while (fbt != NULL);
+}
+
+/*ARGSUSED*/
+static int
+fbt_enable(void *arg, dtrace_id_t id, void *parg)
+{
+ fbt_probe_t *fbt = parg;
+ struct modctl *ctl = fbt->fbtp_ctl;
+
+ ctl->mod_nenabled++;
+
+ if (!ctl->mod_loaded) {
+ if (fbt_verbose) {
+ cmn_err(CE_NOTE, "fbt is failing for probe %s "
+ "(module %s unloaded)",
+ fbt->fbtp_name, ctl->mod_modname);
+ }
+
+ return (0);
+ }
+
+ /*
+ * Now check that our modctl has the expected load count. If it
+ * doesn't, this module must have been unloaded and reloaded -- and
+ * we're not going to touch it.
+ */
+ if (ctl->mod_loadcnt != fbt->fbtp_loadcnt) {
+ if (fbt_verbose) {
+ cmn_err(CE_NOTE, "fbt is failing for probe %s "
+ "(module %s reloaded)",
+ fbt->fbtp_name, ctl->mod_modname);
+ }
+
+ return (0);
+ }
+
+ for (; fbt != NULL; fbt = fbt->fbtp_next)
+ *fbt->fbtp_patchpoint = fbt->fbtp_patchval;
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+fbt_disable(void *arg, dtrace_id_t id, void *parg)
+{
+ fbt_probe_t *fbt = parg;
+ struct modctl *ctl = fbt->fbtp_ctl;
+
+ ASSERT(ctl->mod_nenabled > 0);
+ ctl->mod_nenabled--;
+
+ if (!ctl->mod_loaded || (ctl->mod_loadcnt != fbt->fbtp_loadcnt))
+ return;
+
+ for (; fbt != NULL; fbt = fbt->fbtp_next)
+ *fbt->fbtp_patchpoint = fbt->fbtp_savedval;
+}
+
+/*ARGSUSED*/
+static void
+fbt_suspend(void *arg, dtrace_id_t id, void *parg)
+{
+ fbt_probe_t *fbt = parg;
+ struct modctl *ctl = fbt->fbtp_ctl;
+
+ ASSERT(ctl->mod_nenabled > 0);
+
+ if (!ctl->mod_loaded || (ctl->mod_loadcnt != fbt->fbtp_loadcnt))
+ return;
+
+ for (; fbt != NULL; fbt = fbt->fbtp_next)
+ *fbt->fbtp_patchpoint = fbt->fbtp_savedval;
+}
+
+/*ARGSUSED*/
+static void
+fbt_resume(void *arg, dtrace_id_t id, void *parg)
+{
+ fbt_probe_t *fbt = parg;
+ struct modctl *ctl = fbt->fbtp_ctl;
+
+ ASSERT(ctl->mod_nenabled > 0);
+
+ if (!ctl->mod_loaded || (ctl->mod_loadcnt != fbt->fbtp_loadcnt))
+ return;
+
+ for (; fbt != NULL; fbt = fbt->fbtp_next)
+ *fbt->fbtp_patchpoint = fbt->fbtp_patchval;
+}
+
+/*ARGSUSED*/
+static void
+fbt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
+{
+ fbt_probe_t *fbt = parg;
+ struct modctl *ctl = fbt->fbtp_ctl;
+ struct module *mp = ctl->mod_mp;
+ ctf_file_t *fp = NULL, *pfp;
+ ctf_funcinfo_t f;
+ int error;
+ ctf_id_t argv[32], type;
+ int argc = sizeof (argv) / sizeof (ctf_id_t);
+ const char *parent;
+
+ if (!ctl->mod_loaded || (ctl->mod_loadcnt != fbt->fbtp_loadcnt))
+ goto err;
+
+ if (fbt->fbtp_roffset != 0 && desc->dtargd_ndx == 0) {
+ (void) strcpy(desc->dtargd_native, "int");
+ return;
+ }
+
+ if ((fp = ctf_modopen(mp, &error)) == NULL) {
+ /*
+ * We have no CTF information for this module -- and therefore
+ * no args[] information.
+ */
+ goto err;
+ }
+
+ /*
+ * If we have a parent container, we must manually import it.
+ */
+ if ((parent = ctf_parent_name(fp)) != NULL) {
+ struct modctl *mp = &modules;
+ struct modctl *mod = NULL;
+
+ /*
+ * We must iterate over all modules to find the module that
+ * is our parent.
+ */
+ do {
+ if (strcmp(mp->mod_modname, parent) == 0) {
+ mod = mp;
+ break;
+ }
+ } while ((mp = mp->mod_next) != &modules);
+
+ if (mod == NULL)
+ goto err;
+
+ if ((pfp = ctf_modopen(mod->mod_mp, &error)) == NULL) {
+ goto err;
+ }
+
+ if (ctf_import(fp, pfp) != 0) {
+ ctf_close(pfp);
+ goto err;
+ }
+
+ ctf_close(pfp);
+ }
+
+ if (ctf_func_info(fp, fbt->fbtp_symndx, &f) == CTF_ERR)
+ goto err;
+
+ if (fbt->fbtp_roffset != 0) {
+ if (desc->dtargd_ndx > 1)
+ goto err;
+
+ ASSERT(desc->dtargd_ndx == 1);
+ type = f.ctc_return;
+ } else {
+ if (desc->dtargd_ndx + 1 > f.ctc_argc)
+ goto err;
+
+ if (ctf_func_args(fp, fbt->fbtp_symndx, argc, argv) == CTF_ERR)
+ goto err;
+
+ type = argv[desc->dtargd_ndx];
+ }
+
+ if (ctf_type_name(fp, type, desc->dtargd_native,
+ DTRACE_ARGTYPELEN) != NULL) {
+ ctf_close(fp);
+ return;
+ }
+err:
+ if (fp != NULL)
+ ctf_close(fp);
+
+ desc->dtargd_ndx = DTRACE_ARGNONE;
+}
+
+static dtrace_pattr_t fbt_attr = {
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
+{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
+{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
+};
+
+static dtrace_pops_t fbt_pops = {
+ NULL,
+ fbt_provide_module,
+ fbt_enable,
+ fbt_disable,
+ fbt_suspend,
+ fbt_resume,
+ fbt_getargdesc,
+ NULL,
+ NULL,
+ fbt_destroy
+};
+
+static void
+fbt_cleanup(dev_info_t *devi)
+{
+ dtrace_invop_remove(fbt_invop);
+ ddi_remove_minor_node(devi, NULL);
+ kmem_free(fbt_probetab, fbt_probetab_size * sizeof (fbt_probe_t *));
+ fbt_probetab = NULL;
+ fbt_probetab_mask = 0;
+}
+
+static int
+fbt_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_ATTACH:
+ break;
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (fbt_probetab_size == 0)
+ fbt_probetab_size = FBT_PROBETAB_SIZE;
+
+ fbt_probetab_mask = fbt_probetab_size - 1;
+ fbt_probetab =
+ kmem_zalloc(fbt_probetab_size * sizeof (fbt_probe_t *), KM_SLEEP);
+
+ dtrace_invop_add(fbt_invop);
+
+ if (ddi_create_minor_node(devi, "fbt", S_IFCHR, 0,
+ DDI_PSEUDO, NULL) == DDI_FAILURE ||
+ dtrace_register("fbt", &fbt_attr, DTRACE_PRIV_KERNEL, NULL,
+ &fbt_pops, NULL, &fbt_id) != 0) {
+ fbt_cleanup(devi);
+ return (DDI_FAILURE);
+ }
+
+ ddi_report_dev(devi);
+ fbt_devi = devi;
+
+ return (DDI_SUCCESS);
+}
+
+static int
+fbt_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+ default:
+ return (DDI_FAILURE);
+ }
+
+ if (dtrace_unregister(fbt_id) != 0)
+ return (DDI_FAILURE);
+
+ fbt_cleanup(devi);
+
+ return (DDI_SUCCESS);
+}
+
+/*ARGSUSED*/
+static int
+fbt_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *)fbt_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+/*ARGSUSED*/
+static int
+fbt_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+{
+ return (0);
+}
+
+static struct cb_ops fbt_cb_ops = {
+ fbt_open, /* open */
+ nodev, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ nodev, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_NEW | D_MP /* Driver compatibility flag */
+};
+
+static struct dev_ops fbt_ops = {
+ DEVO_REV, /* devo_rev */
+ 0, /* refcnt */
+ fbt_info, /* get_dev_info */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ fbt_attach, /* attach */
+ fbt_detach, /* detach */
+ nodev, /* reset */
+ &fbt_cb_ops, /* driver operations */
+ NULL, /* bus operations */
+ nodev, /* dev power */
+ ddi_quiesce_not_needed, /* quiesce */
+};
+
+/*
+ * Module linkage information for the kernel.
+ */
+static struct modldrv modldrv = {
+ &mod_driverops, /* module type (this is a pseudo driver) */
+ "Function Boundary Tracing", /* name of module */
+ &fbt_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1,
+ (void *)&modldrv,
+ NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.conf
new file mode 100644
index 00000000..8e7cbe1e
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/fbt.conf
@@ -0,0 +1,28 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+
+name="fbt" parent="pseudo" instance=0;
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.c
new file mode 100644
index 00000000..38be2233
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.c
@@ -0,0 +1,557 @@
+/*
+ * 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 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+
+#include <sys/modctl.h>
+#include <sys/sunddi.h>
+#include <sys/dtrace.h>
+#include <sys/kobj.h>
+#include <sys/stat.h>
+#include <sys/conf.h>
+#include <vm/seg_kmem.h>
+#include <sys/stack.h>
+#include <sys/frame.h>
+#include <sys/dtrace_impl.h>
+#include <sys/cmn_err.h>
+#include <sys/sysmacros.h>
+#include <sys/privregs.h>
+#include <sys/sdt_impl.h>
+
+#define SDT_PATCHVAL 0xf0
+#define SDT_ADDR2NDX(addr) ((((uintptr_t)(addr)) >> 4) & sdt_probetab_mask)
+#define SDT_PROBETAB_SIZE 0x1000 /* 4k entries -- 16K total */
+
+static dev_info_t *sdt_devi;
+static int sdt_verbose = 0;
+static sdt_probe_t **sdt_probetab;
+static int sdt_probetab_size;
+static int sdt_probetab_mask;
+
+/*ARGSUSED*/
+static int
+sdt_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
+{
+ uintptr_t stack0, stack1, stack2, stack3, stack4;
+ int i = 0;
+ sdt_probe_t *sdt = sdt_probetab[SDT_ADDR2NDX(addr)];
+
+#ifdef __amd64
+ /*
+ * On amd64, stack[0] contains the dereferenced stack pointer,
+ * stack[1] contains savfp, stack[2] contains savpc. We want
+ * to step over these entries.
+ */
+ i += 3;
+#endif
+
+ for (; sdt != NULL; sdt = sdt->sdp_hashnext) {
+ if ((uintptr_t)sdt->sdp_patchpoint == addr) {
+ /*
+ * When accessing the arguments on the stack, we must
+ * protect against accessing beyond the stack. We can
+ * safely set NOFAULT here -- we know that interrupts
+ * are already disabled.
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ stack0 = stack[i++];
+ stack1 = stack[i++];
+ stack2 = stack[i++];
+ stack3 = stack[i++];
+ stack4 = stack[i++];
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT |
+ CPU_DTRACE_BADADDR);
+
+ dtrace_probe(sdt->sdp_id, stack0, stack1,
+ stack2, stack3, stack4);
+
+ return (DTRACE_INVOP_NOP);
+ }
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+sdt_provide_module(void *arg, struct modctl *ctl)
+{
+ struct module *mp = ctl->mod_mp;
+ char *modname = ctl->mod_modname;
+ sdt_probedesc_t *sdpd;
+ sdt_probe_t *sdp, *old;
+ sdt_provider_t *prov;
+ int len;
+
+ /*
+ * One for all, and all for one: if we haven't yet registered all of
+ * our providers, we'll refuse to provide anything.
+ */
+ for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) {
+ if (prov->sdtp_id == DTRACE_PROVNONE)
+ return;
+ }
+
+ if (mp->sdt_nprobes != 0 || (sdpd = mp->sdt_probes) == NULL)
+ return;
+
+ for (sdpd = mp->sdt_probes; sdpd != NULL; sdpd = sdpd->sdpd_next) {
+ char *name = sdpd->sdpd_name, *func, *nname;
+ int i, j;
+ sdt_provider_t *prov;
+ ulong_t offs;
+ dtrace_id_t id;
+
+ for (prov = sdt_providers; prov->sdtp_prefix != NULL; prov++) {
+ char *prefix = prov->sdtp_prefix;
+
+ if (strncmp(name, prefix, strlen(prefix)) == 0) {
+ name += strlen(prefix);
+ break;
+ }
+ }
+
+ nname = kmem_alloc(len = strlen(name) + 1, KM_SLEEP);
+
+ for (i = 0, j = 0; name[j] != '\0'; i++) {
+ if (name[j] == '_' && name[j + 1] == '_') {
+ nname[i] = '-';
+ j += 2;
+ } else {
+ nname[i] = name[j++];
+ }
+ }
+
+ nname[i] = '\0';
+
+ sdp = kmem_zalloc(sizeof (sdt_probe_t), KM_SLEEP);
+ sdp->sdp_loadcnt = ctl->mod_loadcnt;
+ sdp->sdp_ctl = ctl;
+ sdp->sdp_name = nname;
+ sdp->sdp_namelen = len;
+ sdp->sdp_provider = prov;
+
+ func = kobj_searchsym(mp, sdpd->sdpd_offset, &offs);
+
+ if (func == NULL)
+ func = "<unknown>";
+
+ /*
+ * We have our provider. Now create the probe.
+ */
+ if ((id = dtrace_probe_lookup(prov->sdtp_id, modname,
+ func, nname)) != DTRACE_IDNONE) {
+ old = dtrace_probe_arg(prov->sdtp_id, id);
+ ASSERT(old != NULL);
+
+ sdp->sdp_next = old->sdp_next;
+ sdp->sdp_id = id;
+ old->sdp_next = sdp;
+ } else {
+ sdp->sdp_id = dtrace_probe_create(prov->sdtp_id,
+ modname, func, nname, 3, sdp);
+
+ mp->sdt_nprobes++;
+ }
+
+ sdp->sdp_hashnext =
+ sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)];
+ sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)] = sdp;
+
+ sdp->sdp_patchval = SDT_PATCHVAL;
+ sdp->sdp_patchpoint = (uint8_t *)sdpd->sdpd_offset;
+ sdp->sdp_savedval = *sdp->sdp_patchpoint;
+ }
+}
+
+/*ARGSUSED*/
+static void
+sdt_destroy(void *arg, dtrace_id_t id, void *parg)
+{
+ sdt_probe_t *sdp = parg, *old, *last, *hash;
+ struct modctl *ctl = sdp->sdp_ctl;
+ int ndx;
+
+ if (ctl != NULL && ctl->mod_loadcnt == sdp->sdp_loadcnt) {
+ if ((ctl->mod_loadcnt == sdp->sdp_loadcnt &&
+ ctl->mod_loaded)) {
+ ((struct module *)(ctl->mod_mp))->sdt_nprobes--;
+ }
+ }
+
+ while (sdp != NULL) {
+ old = sdp;
+
+ /*
+ * Now we need to remove this probe from the sdt_probetab.
+ */
+ ndx = SDT_ADDR2NDX(sdp->sdp_patchpoint);
+ last = NULL;
+ hash = sdt_probetab[ndx];
+
+ while (hash != sdp) {
+ ASSERT(hash != NULL);
+ last = hash;
+ hash = hash->sdp_hashnext;
+ }
+
+ if (last != NULL) {
+ last->sdp_hashnext = sdp->sdp_hashnext;
+ } else {
+ sdt_probetab[ndx] = sdp->sdp_hashnext;
+ }
+
+ kmem_free(sdp->sdp_name, sdp->sdp_namelen);
+ sdp = sdp->sdp_next;
+ kmem_free(old, sizeof (sdt_probe_t));
+ }
+}
+
+/*ARGSUSED*/
+static int
+sdt_enable(void *arg, dtrace_id_t id, void *parg)
+{
+ sdt_probe_t *sdp = parg;
+ struct modctl *ctl = sdp->sdp_ctl;
+
+ ctl->mod_nenabled++;
+
+ /*
+ * If this module has disappeared since we discovered its probes,
+ * refuse to enable it.
+ */
+ if (!ctl->mod_loaded) {
+ if (sdt_verbose) {
+ cmn_err(CE_NOTE, "sdt is failing for probe %s "
+ "(module %s unloaded)",
+ sdp->sdp_name, ctl->mod_modname);
+ }
+ goto err;
+ }
+
+ /*
+ * Now check that our modctl has the expected load count. If it
+ * doesn't, this module must have been unloaded and reloaded -- and
+ * we're not going to touch it.
+ */
+ if (ctl->mod_loadcnt != sdp->sdp_loadcnt) {
+ if (sdt_verbose) {
+ cmn_err(CE_NOTE, "sdt is failing for probe %s "
+ "(module %s reloaded)",
+ sdp->sdp_name, ctl->mod_modname);
+ }
+ goto err;
+ }
+
+ while (sdp != NULL) {
+ *sdp->sdp_patchpoint = sdp->sdp_patchval;
+ sdp = sdp->sdp_next;
+ }
+err:
+ return (0);
+}
+
+/*ARGSUSED*/
+static void
+sdt_disable(void *arg, dtrace_id_t id, void *parg)
+{
+ sdt_probe_t *sdp = parg;
+ struct modctl *ctl = sdp->sdp_ctl;
+
+ ctl->mod_nenabled--;
+
+ if (!ctl->mod_loaded || ctl->mod_loadcnt != sdp->sdp_loadcnt)
+ goto err;
+
+ while (sdp != NULL) {
+ *sdp->sdp_patchpoint = sdp->sdp_savedval;
+ sdp = sdp->sdp_next;
+ }
+
+err:
+ ;
+}
+
+/*ARGSUSED*/
+uint64_t
+sdt_getarg(void *arg, dtrace_id_t id, void *parg, int argno, int aframes)
+{
+ uintptr_t val;
+ struct frame *fp = (struct frame *)dtrace_getfp();
+ uintptr_t *stack;
+ int i;
+#if defined(__amd64)
+ /*
+ * A total of 6 arguments are passed via registers; any argument with
+ * index of 5 or lower is therefore in a register.
+ */
+ int inreg = 5;
+#endif
+
+ for (i = 1; i <= aframes; i++) {
+ fp = (struct frame *)(fp->fr_savfp);
+
+ if (fp->fr_savpc == (pc_t)dtrace_invop_callsite) {
+#if !defined(__amd64)
+ /*
+ * If we pass through the invalid op handler, we will
+ * use the pointer that it passed to the stack as the
+ * second argument to dtrace_invop() as the pointer to
+ * the stack.
+ */
+ stack = ((uintptr_t **)&fp[1])[1];
+#else
+ /*
+ * In the case of amd64, we will use the pointer to the
+ * regs structure that was pushed when we took the
+ * trap. To get this structure, we must increment
+ * beyond the frame structure. If the argument that
+ * we're seeking is passed on the stack, we'll pull
+ * the true stack pointer out of the saved registers
+ * and decrement our argument by the number of
+ * arguments passed in registers; if the argument
+ * we're seeking is passed in regsiters, we can just
+ * load it directly.
+ */
+ struct regs *rp = (struct regs *)((uintptr_t)&fp[1] +
+ sizeof (uintptr_t));
+
+ if (argno <= inreg) {
+ stack = (uintptr_t *)&rp->r_rdi;
+ } else {
+ stack = (uintptr_t *)(rp->r_rsp);
+ argno -= (inreg + 1);
+ }
+#endif
+ goto load;
+ }
+ }
+
+ /*
+ * We know that we did not come through a trap to get into
+ * dtrace_probe() -- the provider simply called dtrace_probe()
+ * directly. As this is the case, we need to shift the argument
+ * that we're looking for: the probe ID is the first argument to
+ * dtrace_probe(), so the argument n will actually be found where
+ * one would expect to find argument (n + 1).
+ */
+ argno++;
+
+#if defined(__amd64)
+ if (argno <= inreg) {
+ /*
+ * This shouldn't happen. If the argument is passed in a
+ * register then it should have been, well, passed in a
+ * register...
+ */
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+ return (0);
+ }
+
+ argno -= (inreg + 1);
+#endif
+ stack = (uintptr_t *)&fp[1];
+
+load:
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
+ val = stack[argno];
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
+
+ return (val);
+}
+
+static dtrace_pops_t sdt_pops = {
+ NULL,
+ sdt_provide_module,
+ sdt_enable,
+ sdt_disable,
+ NULL,
+ NULL,
+ sdt_getargdesc,
+ sdt_getarg,
+ NULL,
+ sdt_destroy
+};
+
+/*ARGSUSED*/
+static int
+sdt_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
+{
+ sdt_provider_t *prov;
+
+ if (ddi_create_minor_node(devi, "sdt", S_IFCHR,
+ 0, DDI_PSEUDO, NULL) == DDI_FAILURE) {
+ cmn_err(CE_NOTE, "/dev/sdt couldn't create minor node");
+ ddi_remove_minor_node(devi, NULL);
+ return (DDI_FAILURE);
+ }
+
+ ddi_report_dev(devi);
+ sdt_devi = devi;
+
+ if (sdt_probetab_size == 0)
+ sdt_probetab_size = SDT_PROBETAB_SIZE;
+
+ sdt_probetab_mask = sdt_probetab_size - 1;
+ sdt_probetab =
+ kmem_zalloc(sdt_probetab_size * sizeof (sdt_probe_t *), KM_SLEEP);
+ dtrace_invop_add(sdt_invop);
+
+ for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) {
+ if (dtrace_register(prov->sdtp_name, prov->sdtp_attr,
+ DTRACE_PRIV_KERNEL, NULL,
+ &sdt_pops, prov, &prov->sdtp_id) != 0) {
+ cmn_err(CE_WARN, "failed to register sdt provider %s",
+ prov->sdtp_name);
+ }
+ }
+
+ return (DDI_SUCCESS);
+}
+
+/*ARGSUSED*/
+static int
+sdt_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
+{
+ sdt_provider_t *prov;
+
+ switch (cmd) {
+ case DDI_DETACH:
+ break;
+
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+
+ default:
+ return (DDI_FAILURE);
+ }
+
+ for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) {
+ if (prov->sdtp_id != DTRACE_PROVNONE) {
+ if (dtrace_unregister(prov->sdtp_id) != 0)
+ return (DDI_FAILURE);
+
+ prov->sdtp_id = DTRACE_PROVNONE;
+ }
+ }
+
+ dtrace_invop_remove(sdt_invop);
+ kmem_free(sdt_probetab, sdt_probetab_size * sizeof (sdt_probe_t *));
+
+ return (DDI_SUCCESS);
+}
+
+/*ARGSUSED*/
+static int
+sdt_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
+{
+ int error;
+
+ switch (infocmd) {
+ case DDI_INFO_DEVT2DEVINFO:
+ *result = (void *)sdt_devi;
+ error = DDI_SUCCESS;
+ break;
+ case DDI_INFO_DEVT2INSTANCE:
+ *result = (void *)0;
+ error = DDI_SUCCESS;
+ break;
+ default:
+ error = DDI_FAILURE;
+ }
+ return (error);
+}
+
+/*ARGSUSED*/
+static int
+sdt_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+{
+ return (0);
+}
+
+static struct cb_ops sdt_cb_ops = {
+ sdt_open, /* open */
+ nodev, /* close */
+ nulldev, /* strategy */
+ nulldev, /* print */
+ nodev, /* dump */
+ nodev, /* read */
+ nodev, /* write */
+ nodev, /* ioctl */
+ nodev, /* devmap */
+ nodev, /* mmap */
+ nodev, /* segmap */
+ nochpoll, /* poll */
+ ddi_prop_op, /* cb_prop_op */
+ 0, /* streamtab */
+ D_NEW | D_MP /* Driver compatibility flag */
+};
+
+static struct dev_ops sdt_ops = {
+ DEVO_REV, /* devo_rev, */
+ 0, /* refcnt */
+ sdt_info, /* get_dev_info */
+ nulldev, /* identify */
+ nulldev, /* probe */
+ sdt_attach, /* attach */
+ sdt_detach, /* detach */
+ nodev, /* reset */
+ &sdt_cb_ops, /* driver operations */
+ NULL, /* bus operations */
+ nodev, /* dev power */
+ ddi_quiesce_not_needed, /* quiesce */
+};
+
+/*
+ * Module linkage information for the kernel.
+ */
+static struct modldrv modldrv = {
+ &mod_driverops, /* module type (this is a pseudo driver) */
+ "Statically Defined Tracing", /* name of module */
+ &sdt_ops, /* driver ops */
+};
+
+static struct modlinkage modlinkage = {
+ MODREV_1,
+ (void *)&modldrv,
+ NULL
+};
+
+int
+_init(void)
+{
+ return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+ return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&modlinkage));
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.conf b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.conf
new file mode 100644
index 00000000..bde2149c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/intel/dtrace/sdt.conf
@@ -0,0 +1,28 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (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 2003 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+name="sdt" parent="pseudo" instance=0;