diff options
Diffstat (limited to 'src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/translators')
33 files changed, 2119 insertions, 0 deletions
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); +} |