aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf')
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid.d21
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid2.d21
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid3.d21
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh35
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh36
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh90
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.c48
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh45
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.c79
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh76
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh.out4
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.c29
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh46
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.linkmap.ksh44
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh69
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh70
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.c72
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh69
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh.out16
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh70
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh83
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh.out4
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh72
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh.out4
24 files changed, 1124 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid.d
new file mode 100644
index 000000000000..4865d81ee1e9
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid.d
@@ -0,0 +1,21 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2013 Joyent, Inc. All rights reserved.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace((pidfoo`int)0);
+}
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid2.d
new file mode 100644
index 000000000000..bafed1217279
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid2.d
@@ -0,0 +1,21 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2013 Joyent, Inc. All rights reserved.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace((pid8foo`int)0);
+}
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid3.d
new file mode 100644
index 000000000000..fb9443a828ea
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidpid3.d
@@ -0,0 +1,21 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2013 Joyent, Inc. All rights reserved.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ trace((pid0`int)0);
+}
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh
new file mode 100644
index 000000000000..432a9fccb44f
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh
@@ -0,0 +1,35 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# While it's hard to be completely certain that a type of the name we want
+# doesn't exist, we're going to try to pick a name which is rather unique.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="season_8_mountain_of_madness_t"
+pid=$$
+
+$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }"
+rc=$?
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh
new file mode 100644
index 000000000000..d1b48769ba6c
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh
@@ -0,0 +1,36 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# While it's hard to be completely certain that a type of the name we want
+# doesn't exist, we're going to try to pick a name which is rather
+# unique. This time we're also going to use the pid$target alias.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="season_8_mountain_of_madness_t"
+pid=$$
+
+$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }" -p $pid
+rc=$?
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh
new file mode 100644
index 000000000000..4eaf169f06dd
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh
@@ -0,0 +1,90 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# This test is purposefully using a 64-bit DTrace and thus 64-bit types
+# when compared with a 32-bit process. This test uses the userland
+# keyword and so the implicit copyin should access illegal memory and
+# thus exit.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="zelda_info_t"
+exe="tst.chasestrings.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -64 -qs /dev/stdin <<EOF
+typedef struct info {
+ char *zi_gamename;
+ int zi_ndungeons;
+ char *zi_villain;
+ int zi_haszelda;
+} info_t;
+
+pid$pid::has_princess:entry
+/next == 0/
+{
+ this->t = (userland info_t *)arg0;
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(this->t->zi_gamename), this->t->zi_ndungeons,
+ stringof(this->t->zi_villain), this->t->zi_haszelda);
+ next = 1;
+}
+
+pid$pid::has_dungeons:entry
+/next == 1/
+{
+ this->t = (userland info_t *)arg0;
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(this->t->zi_gamename), this->t->zi_ndungeons,
+ stringof(this->t->zi_villain), this->t->zi_haszelda);
+ next = 2;
+}
+
+pid$pid::has_villain:entry
+/next == 2/
+{
+ this->t = (userland info_t *)arg0;
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(this->t->zi_gamename), this->t->zi_ndungeons,
+ stringof(this->t->zi_villain), this->t->zi_haszelda);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.c
new file mode 100644
index 000000000000..8b1595325f6c
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.c
@@ -0,0 +1,48 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2013 (c) Joyent, Inc. All rights reserved.
+ */
+
+/*
+ * This test tries to make sure that we have CTF data for a type that only this
+ * binary would reasonably have. In this case, the
+ * season_7_lisa_the_vegetarian_t.
+ */
+#include <unistd.h>
+
+typedef struct season_7_lisa_the_vegetarian {
+ int fr_salad;
+} season_7_lisa_the_vegetarian_t;
+
+int sleeper(season_7_lisa_the_vegetarian_t *);
+
+int
+sleeper(season_7_lisa_the_vegetarian_t *lp)
+{
+ for (;;) {
+ sleep(lp->fr_salad);
+ }
+ /*NOTREACHED*/
+ return (0);
+}
+
+int
+main(void)
+{
+ season_7_lisa_the_vegetarian_t l;
+ l.fr_salad = 100;
+
+ sleeper(&l);
+
+ return (0);
+}
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh
new file mode 100644
index 000000000000..95b26c82d7ab
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh
@@ -0,0 +1,45 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# Lookup a type that is inside a.out.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="season_7_lisa_the_vegetarian_t *"
+exe="tst.aouttype.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.c
new file mode 100644
index 000000000000..8606629fdbd5
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.c
@@ -0,0 +1,79 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2013 (c) Joyent, Inc. All rights reserved.
+ */
+
+/*
+ * This test takes data from the current binary which is basically running in a
+ * loop between two functions and our goal is to have two unique types that they
+ * contain which we can print.
+ */
+
+#include <unistd.h>
+
+typedef struct zelda_info {
+ const char *zi_gamename;
+ int zi_ndungeons;
+ const char *zi_villain;
+ int zi_haszelda;
+} zelda_info_t;
+
+static int
+has_princess(zelda_info_t *z)
+{
+ return (z->zi_haszelda);
+}
+
+static int
+has_dungeons(zelda_info_t *z)
+{
+ return (z->zi_ndungeons != 0);
+}
+
+static const char *
+has_villain(zelda_info_t *z)
+{
+ return (z->zi_villain);
+}
+
+int
+main(void)
+{
+ zelda_info_t oot;
+ zelda_info_t la;
+ zelda_info_t lttp;
+
+ oot.zi_gamename = "Ocarina of Time";
+ oot.zi_ndungeons = 10;
+ oot.zi_villain = "Ganondorf";
+ oot.zi_haszelda = 1;
+
+ la.zi_gamename = "Link's Awakening";
+ la.zi_ndungeons = 9;
+ la.zi_villain = "Nightmare";
+ la.zi_haszelda = 0;
+
+ lttp.zi_gamename = "A Link to the Past";
+ lttp.zi_ndungeons = 12;
+ lttp.zi_villain = "Ganon";
+ lttp.zi_haszelda = 1;
+
+ for (;;) {
+ (void) has_princess(&oot);
+ (void) has_dungeons(&la);
+ (void) has_villain(&lttp);
+ sleep(1);
+ }
+
+ return (0);
+}
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh
new file mode 100644
index 000000000000..d754c194b4b4
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh
@@ -0,0 +1,76 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# This test is checking that we can read members and that pointers inside
+# members point to valid data that is intelligible, eg. strings.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="zelda_info_t"
+exe="tst.chasestrings.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -qs /dev/stdin <<EOF
+pid$pid::has_princess:entry
+/next == 0/
+{
+ this->t = (pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t)));
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ copyinstr((uintptr_t)this->t->zi_gamename), this->t->zi_ndungeons,
+ copyinstr((uintptr_t)this->t->zi_villain), this->t->zi_haszelda);
+ next = 1;
+}
+
+pid$pid::has_dungeons:entry
+/next == 1/
+{
+ this->t = (pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t)));
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ copyinstr((uintptr_t)this->t->zi_gamename), this->t->zi_ndungeons,
+ copyinstr((uintptr_t)this->t->zi_villain), this->t->zi_haszelda);
+ next = 2;
+}
+
+pid$pid::has_villain:entry
+/next == 2/
+{
+ this->t = (pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t)));
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ copyinstr((uintptr_t)this->t->zi_gamename), this->t->zi_ndungeons,
+ copyinstr((uintptr_t)this->t->zi_villain), this->t->zi_haszelda);
+ exit(0);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh.out
new file mode 100644
index 000000000000..219e406e61d6
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh.out
@@ -0,0 +1,4 @@
+game: Ocarina of Time, dungeon: 10, villain: Ganondorf, zelda: 1
+game: Link's Awakening, dungeon: 9, villain: Nightmare, zelda: 0
+game: A Link to the Past, dungeon: 12, villain: Ganon, zelda: 1
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.c
new file mode 100644
index 000000000000..916a5b51b949
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.c
@@ -0,0 +1,29 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2013 (c) Joyent, Inc. All rights reserved.
+ */
+
+/*
+ * We're linked against libc which has types, though we do not.
+ */
+#include <unistd.h>
+
+int
+main(void)
+{
+ for (;;) {
+ sleep(1000);
+ }
+ /*NOTREACHED*/
+ return (0);
+}
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh
new file mode 100644
index 000000000000..233616619e7d
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh
@@ -0,0 +1,46 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# Here we want to make sure that the program in question does not have ctf data
+# in its a.out; however, we can get types out of a linked libc.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="int"
+exe="tst.libtype.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -eq 0 ]]; then
+ echo "CTF exists in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.linkmap.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.linkmap.ksh
new file mode 100644
index 000000000000..f767def53de8
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.linkmap.ksh
@@ -0,0 +1,44 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# We should be able to see both strstr from libc and from ld on an
+# alternate linkmap.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -q -p $$ -s /dev/stdin <<EOF
+pid\$target:LM1\`ld.so.1:strstr:entry,
+pid\$target:libc.so.1:strstr:entry
+{
+ exit (0);
+}
+
+BEGIN
+{
+ exit (0);
+}
+EOF
+rc=$?
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh
new file mode 100644
index 000000000000..e5902faf2cb2
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh
@@ -0,0 +1,69 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# Use print() on userland CTF types and verify we get the data we expect.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="final_fantasy_info_t"
+exe="tst.printtype.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -qs /dev/stdin <<EOF
+pid$pid::ff_getgameid:entry
+/next == 0/
+{
+ print(*args[0]);
+ printf("\n");
+ next = 1;
+}
+
+pid$pid::ff_getpartysize:entry
+/next == 1/
+{
+ print(*args[0]);
+ printf("\n");
+ next = 2;
+}
+
+pid$pid::ff_getsummons:entry
+/next == 2/
+{
+ print(*args[0]);
+ printf("\n");
+ exit(0);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh
new file mode 100644
index 000000000000..5e92cf924c2a
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh
@@ -0,0 +1,70 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# Use print() on userland CTF types and verify we get the data we
+# expect. This time, use $target to make sure that path works correctly.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="final_fantasy_info_t"
+exe="tst.printtype.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -p $pid -qs /dev/stdin <<EOF
+pid\$target::ff_getgameid:entry
+/next == 0/
+{
+ print(*args[0]);
+ printf("\n");
+ next = 1;
+}
+
+pid\$target::ff_getpartysize:entry
+/next == 1/
+{
+ print(*args[0]);
+ printf("\n");
+ next = 2;
+}
+
+pid\$target::ff_getsummons:entry
+/next == 2/
+{
+ print(*args[0]);
+ printf("\n");
+ exit(0);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.c
new file mode 100644
index 000000000000..471a84cd5862
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.c
@@ -0,0 +1,72 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2013 (c) Joyent, Inc. All rights reserved.
+ */
+
+/*
+ * The point of this is to use print() on various functions to make sure that we
+ * can print basic structures. Note that we purposefully are making sure that
+ * there are no pointers here.
+ */
+#include <unistd.h>
+
+typedef struct final_fantasy_info {
+ int ff_gameid;
+ int ff_partysize;
+ int ff_hassummons;
+} final_fantasy_info_t;
+
+static int
+ff_getgameid(final_fantasy_info_t *f __unused)
+{
+ return (0);
+}
+
+static int
+ff_getpartysize(final_fantasy_info_t *f __unused)
+{
+ return (0);
+}
+
+static int
+ff_getsummons(final_fantasy_info_t *f __unused)
+{
+ return (0);
+}
+
+int
+main(void)
+{
+ final_fantasy_info_t ffiii, ffx, ffi;
+
+ ffi.ff_gameid = 1;
+ ffi.ff_partysize = 4;
+ ffi.ff_hassummons = 0;
+
+ ffiii.ff_gameid = 6;
+ ffiii.ff_partysize = 4;
+ ffiii.ff_hassummons = 1;
+
+ ffx.ff_gameid = 10;
+ ffx.ff_partysize = 3;
+ ffx.ff_hassummons = 1;
+
+ for (;;) {
+ ff_getgameid(&ffi);
+ ff_getpartysize(&ffx);
+ ff_getsummons(&ffiii);
+ sleep(1);
+ }
+ /*NOTREACHED*/
+ return (0);
+}
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh
new file mode 100644
index 000000000000..a93a3b8722c3
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh
@@ -0,0 +1,69 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# Use print() on userland CTF types and verify we get the data we expect.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="final_fantasy_info_t"
+exe="tst.printtype.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -qs /dev/stdin <<EOF
+pid$pid::ff_getgameid:entry
+/next == 0/
+{
+ print(*(pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t))));
+ printf("\n");
+ next = 1;
+}
+
+pid$pid::ff_getpartysize:entry
+/next == 1/
+{
+ print(*(pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t))));
+ printf("\n");
+ next = 2;
+}
+
+pid$pid::ff_getsummons:entry
+/next == 2/
+{
+ print(*(pid$pid\`$t *)(copyin(arg0, sizeof (pid$pid\`$t))));
+ printf("\n");
+ exit(0);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh.out
new file mode 100644
index 000000000000..1770ba23548f
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh.out
@@ -0,0 +1,16 @@
+final_fantasy_info_t {
+ int ff_gameid = 0x1
+ int ff_partysize = 0x4
+ int ff_hassummons = 0
+}
+final_fantasy_info_t {
+ int ff_gameid = 0xa
+ int ff_partysize = 0x3
+ int ff_hassummons = 0x1
+}
+final_fantasy_info_t {
+ int ff_gameid = 0x6
+ int ff_partysize = 0x4
+ int ff_hassummons = 0x1
+}
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh
new file mode 100644
index 000000000000..fa080a53f3ff
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh
@@ -0,0 +1,70 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# Use print() on userland CTF types and verify we get the data we
+# expect. Use the pid` alias for $target.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="final_fantasy_info_t"
+exe="tst.printtype.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -p $pid -qs /dev/stdin <<EOF
+pid\$target::ff_getgameid:entry
+/next == 0/
+{
+ print(*(pid\`$t *)(copyin(arg0, sizeof (pid\`$t))));
+ printf("\n");
+ next = 1;
+}
+
+pid\$target::ff_getpartysize:entry
+/next == 1/
+{
+ print(*(pid\`$t *)(copyin(arg0, sizeof (pid\`$t))));
+ printf("\n");
+ next = 2;
+}
+
+pid\$target::ff_getsummons:entry
+/next == 2/
+{
+ print(*(pid\`$t *)(copyin(arg0, sizeof (pid\`$t))));
+ printf("\n");
+ exit(0);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh
new file mode 100644
index 000000000000..54d975f63aff
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh
@@ -0,0 +1,83 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# Simple test that if we manually use the userland keyword that it
+# works.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+t="zelda_info_t"
+exe="tst.chasestrings.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -qs /dev/stdin <<EOF
+typedef struct info {
+ char *zi_gamename;
+ int zi_ndungeons;
+ char *zi_villain;
+ int zi_haszelda;
+} info_t;
+
+pid$pid::has_princess:entry
+/next == 0/
+{
+ this->t = (userland info_t *)arg0;
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(this->t->zi_gamename), this->t->zi_ndungeons,
+ stringof(this->t->zi_villain), this->t->zi_haszelda);
+ next = 1;
+}
+
+pid$pid::has_dungeons:entry
+/next == 1/
+{
+ this->t = (userland info_t *)arg0;
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(this->t->zi_gamename), this->t->zi_ndungeons,
+ stringof(this->t->zi_villain), this->t->zi_haszelda);
+ next = 2;
+}
+
+pid$pid::has_villain:entry
+/next == 2/
+{
+ this->t = (userland info_t *)arg0;
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(this->t->zi_gamename), this->t->zi_ndungeons,
+ stringof(this->t->zi_villain), this->t->zi_haszelda);
+ exit(0);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh.out
new file mode 100644
index 000000000000..219e406e61d6
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh.out
@@ -0,0 +1,4 @@
+game: Ocarina of Time, dungeon: 10, villain: Ganondorf, zelda: 1
+game: Link's Awakening, dungeon: 9, villain: Nightmare, zelda: 0
+game: A Link to the Past, dungeon: 12, villain: Ganon, zelda: 1
+
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh
new file mode 100644
index 000000000000..c5a105b3a55c
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh
@@ -0,0 +1,72 @@
+#! /usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+#
+# This test is checking that we can read members and that pointers inside
+# members point to valid data that is intelligible, eg. strings.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+exe="tst.chasestrings.exe"
+
+elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
+if [[ $? -ne 0 ]]; then
+ echo "CTF does not exist in $exe, that's a bug" >&2
+ exit 1
+fi
+
+./$exe &
+pid=$!
+
+$dtrace -qs /dev/stdin <<EOF
+pid$pid::has_princess:entry
+/next == 0/
+{
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(args[0]->zi_gamename), args[0]->zi_ndungeons,
+ stringof(args[0]->zi_villain), args[0]->zi_haszelda);
+ next = 1;
+}
+
+pid$pid::has_dungeons:entry
+/next == 1/
+{
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(args[0]->zi_gamename), args[0]->zi_ndungeons,
+ stringof(args[0]->zi_villain), args[0]->zi_haszelda);
+ next = 2;
+}
+
+pid$pid::has_villain:entry
+/next == 2/
+{
+ printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n",
+ stringof(args[0]->zi_gamename), args[0]->zi_ndungeons,
+ stringof(args[0]->zi_villain), args[0]->zi_haszelda);
+ exit(0);
+}
+EOF
+rc=$?
+
+kill -9 $pid
+
+exit $rc
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh.out
new file mode 100644
index 000000000000..219e406e61d6
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh.out
@@ -0,0 +1,4 @@
+game: Ocarina of Time, dungeon: 10, villain: Ganondorf, zelda: 1
+game: Link's Awakening, dungeon: 9, villain: Nightmare, zelda: 0
+game: A Link to the Past, dungeon: 12, villain: Ganon, zelda: 1
+