From f215e02bf85f68d3a6106c2a1f4f7f063f819064 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:17:27 +0200 Subject: Adding upstream version 7.0.14-dfsg. Signed-off-by: Daniel Baumann --- .../cmd/dtrace/test/tst/common/sizeof/Makefile.kup | 0 .../common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d | 51 +++++++++ .../sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d | 42 +++++++ .../test/tst/common/sizeof/err.D_SIZEOF_TYPE.d | 41 +++++++ .../tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d | 42 +++++++ .../test/tst/common/sizeof/tst.SizeofArray.d | 61 +++++++++++ .../test/tst/common/sizeof/tst.SizeofDataTypes.d | 122 +++++++++++++++++++++ .../test/tst/common/sizeof/tst.SizeofExpression.d | 64 +++++++++++ .../dtrace/test/tst/common/sizeof/tst.SizeofNULL.d | 48 ++++++++ .../test/tst/common/sizeof/tst.SizeofStrConst.d | 42 +++++++ .../tst/common/sizeof/tst.SizeofStrConst.d.out | 2 + .../test/tst/common/sizeof/tst.SizeofString1.d | 51 +++++++++ .../test/tst/common/sizeof/tst.SizeofString1.d.out | 3 + .../test/tst/common/sizeof/tst.SizeofString2.d | 44 ++++++++ .../test/tst/common/sizeof/tst.SizeofString2.d.out | 2 + 15 files changed, 615 insertions(+) create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/Makefile.kup create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out (limited to 'src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof') diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/Makefile.kup new file mode 100644 index 00000000..e69de29b diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d new file mode 100644 index 00000000..9ace4197 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: sizeof returns the size in bytes of any D expression or data + * type. For an associative array, the D compiler should throw an error since + * an associative array does not have a fixed size. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ +#pragma D option quiet + +BEGIN +{ + assoc_array[0] = 010; + assoc_array[1] = 100; + assoc_array[2] = 210; + + printf("sizeof (assoc_array): %d\n", sizeof (assoc_array)); + printf("sizeof (assoc_array[0]): %d\n", sizeof (assoc_array[0])); + printf("sizeof (assoc_array[1]): %d\n", sizeof (assoc_array[1])); + printf("sizeof (assoc_array[2]): %d\n", sizeof (assoc_array[2])); + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d new file mode 100644 index 00000000..f2dcdfab --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: The D compiler throws a D_IDENT_UNDEF error when sizeof is passed + * an unknown symbol. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ +#pragma D option quiet + +BEGIN +{ + printf("sizeof (`): %d\n", sizeof (`)); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d new file mode 100644 index 00000000..43c493a5 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * sizeof() should handle invalid types + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ + +BEGIN +{ + trace(sizeof (void)); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d new file mode 100644 index 00000000..85519e6d --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: sizeof returns the size in bytes of any D expression or data + * type. When an operator or non-symbol is passed as an argument to sizeof + * operator, the D_SYNTAX error is thrown by the compiler. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + */ +#pragma D option quiet + +BEGIN +{ + printf("sizeof (*): %d\n", sizeof (*)); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d new file mode 100644 index 00000000..8843728c --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofArray.d @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: sizeof returns the size in bytes of any D expression or data + * type. For a simpler array, the sizeof on the array variable itself gives + * the sum total of memory allocated to the array in bytes. With individual + * members of the array it gives their respective sizes. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ +#pragma D option quiet + +int array[5]; + +BEGIN +{ + array[0] = 010; + array[1] = 100; + array[2] = 210; + + printf("sizeof (array): %d\n", sizeof (array)); + printf("sizeof (array[0]): %d\n", sizeof (array[0])); + printf("sizeof (array[1]): %d\n", sizeof (array[1])); + printf("sizeof (array[2]): %d\n", sizeof (array[2])); + + exit(0); +} + +END +/(20 != sizeof (array)) || (4 != sizeof (array[0])) || (4 != sizeof (array[1])) + || (4 != sizeof (array[2]))/ +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d new file mode 100644 index 00000000..fe558e8e --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofDataTypes.d @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: sizeof returns the size in bytes of any D expression or data + * type. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + */ +#pragma D option quiet + +char new_char; +short new_short; +int new_int; +long new_long; +long long new_long_long; +int8_t new_int8; +int16_t new_int16; +int32_t new_int32; +int64_t new_int64; +intptr_t new_intptr; +uint8_t new_uint8; +uint16_t new_uint16; +uint32_t new_uint32; +uint64_t new_uint64; +uintptr_t new_uintptr; + +/* +float new_float; +double new_double; +long double new_long_double; + +string new_string; +*/ + +struct record { + char ch; + int in; +} new_struct; + +struct { + char ch; + int in; +} anon_struct; + +union record { + char ch; + int in; +} new_union; + +union { + char ch; + int in; +} anon_union; + +enum colors { + RED, + GREEN, + BLUE +} new_enum; + + +int *pointer; + +BEGIN +{ + printf("sizeof (new_char): %d\n", sizeof (new_char)); + printf("sizeof (new_short): %d\n", sizeof (new_short)); + printf("sizeof (new_int): %d\n", sizeof (new_int)); + printf("sizeof (new_long): %d\n", sizeof (new_long)); + printf("sizeof (new_long_long): %d\n", sizeof (new_long_long)); + printf("sizeof (new_int8): %d\n", sizeof (new_int8)); + printf("sizeof (new_int16): %d\n", sizeof (new_int16)); + printf("sizeof (new_int32): %d\n", sizeof (new_int32)); + printf("sizeof (new_int64): %d\n", sizeof (new_int64)); + printf("sizeof (pointer): %d\n", sizeof (pointer)); + printf("sizeof (intptr_t): %d\n", sizeof (intptr_t)); + printf("sizeof (new_struct): %d\n", sizeof (new_struct)); + printf("sizeof (anon_struct): %d\n", sizeof (anon_struct)); + printf("sizeof (new_union): %d\n", sizeof (new_union)); + printf("sizeof (anon_union): %d\n", sizeof (anon_union)); + printf("sizeof (new_enum): %d\n", sizeof (new_enum)); + exit(0); +} + +END +/(1 != sizeof (new_char)) || (2 != sizeof (new_short)) || + (4 != sizeof (new_int)) || + ((4 != sizeof (new_long)) && (8 != sizeof (new_long))) || + (8 != sizeof (new_long_long)) || + (1 != sizeof (new_int8)) || (2 != sizeof (new_int16)) || + (4 != sizeof (new_int32)) || (8 != sizeof (new_int64)) || + (sizeof (pointer) != sizeof (new_intptr)) || (8 != sizeof (new_struct)) || + (4 != sizeof (new_union)) || (4 != sizeof (new_enum))/ +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d new file mode 100644 index 00000000..0bb7f686 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofExpression.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test the use of sizeof with expressions. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ + +#pragma D option quiet + +BEGIN +{ + printf("sizeof ('c') : %d\n", sizeof ('c')); + printf("sizeof (10 * 'c') : %d\n", sizeof (10 * 'c')); + printf("sizeof (100 + 12345) : %d\n", sizeof (100 + 12345)); + printf("sizeof (1234567890) : %d\n", sizeof (1234567890)); + + printf("sizeof (1234512345 * 1234512345 * 12345678 * 1ULL) : %d\n", + sizeof (1234512345 * 1234512345 * 12345678 * 1ULL)); + printf("sizeof (-129) : %d\n", sizeof (-129)); + printf("sizeof (0x67890/0x77000) : %d\n", sizeof (0x67890/0x77000)); + + printf("sizeof (3 > 2 ? 3 : 2) : %d\n", sizeof (3 > 2 ? 3 : 2)); + + exit(0); +} + +END +/(4 != sizeof ('c')) || (4 != sizeof (10 * 'c')) || + (4 != sizeof (100 + 12345)) || (4 != sizeof (1234567890)) || + (8 != sizeof (1234512345 * 1234512345 * 12345678 * 1ULL)) || + (4 != sizeof (-129)) || (4 != sizeof (0x67890/0x77000)) || + (4 != sizeof (3 > 2 ? 3 : 2))/ +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d new file mode 100644 index 00000000..4bd8a484 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofNULL.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: The size of the inbuilt variable NULL is the same as that of an + * integer. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ +#pragma D option quiet + +BEGIN +{ + printf("sizeof (NULL): %d\n", sizeof (NULL)); + exit(0); +} + +END +/4 != sizeof (NULL)/ +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d new file mode 100644 index 00000000..51f72505 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: sizeof returns the size in bytes of any D expression or data + * type. When a raw string is passed to the sizeof operator, the compiler + * throws a D_SYNTAX error. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + */ +#pragma D option quiet + +BEGIN +{ + printf("sizeof \"hi\": %d\n", sizeof ("hi")); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out new file mode 100644 index 00000000..3fe02aaf --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofStrConst.d.out @@ -0,0 +1,2 @@ +sizeof "hi": 3 + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d new file mode 100644 index 00000000..0be9e457 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: sizeof returns the size in bytes of any D expression or data + * type. For sizeof strings the D compiler throws D_SIZEOF_TYPE. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ +#pragma D option quiet +#pragma D option strsize=256 + +BEGIN +{ + assoc_array["hello"] = "hello"; + assoc_array["hi"] = "hi"; + assoc_array["hello"] = "hello, world"; + + printf("sizeof (assoc_array[\"hello\"]): %d\n", + sizeof (assoc_array["hello"])); + printf("sizeof (assoc_array[\"hi\"]): %d\n", + sizeof (assoc_array["hi"])); + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out new file mode 100644 index 00000000..9c43b1e3 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString1.d.out @@ -0,0 +1,3 @@ +sizeof (assoc_array["hello"]): 256 +sizeof (assoc_array["hi"]): 256 + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d new file mode 100644 index 00000000..f12a6003 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: sizeof returns the size in bytes of any D expression or data + * type. For a string variable, the D compiler throws a D_SIZEOF_TYPE. + * + * SECTION: Structs and Unions/Member Sizes and Offsets + * + */ +#pragma D option quiet +#pragma D option strsize=256 + +BEGIN +{ + var = "hello"; + printf("sizeof (var): %d\n", sizeof (var)); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out new file mode 100644 index 00000000..fdeca699 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/sizeof/tst.SizeofString2.d.out @@ -0,0 +1,2 @@ +sizeof (var): 256 + -- cgit v1.2.3