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 --- .../dtrace/test/tst/common/pointers/Makefile.kup | 0 .../dtrace/test/tst/common/pointers/err.BadAlign.d | 50 ++++++ .../common/pointers/err.D_ADDROF_VAR.ArrayVar.d | 47 ++++++ .../common/pointers/err.D_ADDROF_VAR.DynamicVar.d | 50 ++++++ .../tst/common/pointers/err.D_ADDROF_VAR.agg.d | 42 +++++ .../tst/common/pointers/err.D_DEREF_NONPTR.noptr.d | 46 ++++++ .../pointers/err.D_DEREF_VOID.VoidPointerDeref.d | 52 ++++++ .../pointers/err.D_OP_ARRFUN.ArrayAssignment.d | 61 ++++++++ .../pointers/err.D_OP_INCOMPAT.VoidPointerArith.d | 46 ++++++ .../common/pointers/err.D_OP_LVAL.AddressChange.d | 50 ++++++ .../pointers/err.D_OP_PTR.NonPointerAccess.d | 59 +++++++ .../tst/common/pointers/err.D_OP_PTR.badpointer.d | 50 ++++++ .../pointers/err.D_OP_SOU.BadPointerAccess.d | 51 ++++++ .../tst/common/pointers/err.D_OP_SOU.badpointer.d | 44 ++++++ .../test/tst/common/pointers/err.InvalidAddress1.d | 52 ++++++ .../test/tst/common/pointers/err.InvalidAddress2.d | 52 ++++++ .../test/tst/common/pointers/err.InvalidAddress3.d | 50 ++++++ .../test/tst/common/pointers/err.InvalidAddress4.d | 52 ++++++ .../test/tst/common/pointers/err.InvalidAddress5.d | 75 +++++++++ .../test/tst/common/pointers/tst.ArrayPointer1.d | 174 +++++++++++++++++++++ .../test/tst/common/pointers/tst.ArrayPointer2.d | 71 +++++++++ .../test/tst/common/pointers/tst.ArrayPointer3.d | 72 +++++++++ .../test/tst/common/pointers/tst.GlobalVar.d | 59 +++++++ .../tst/common/pointers/tst.IntegerArithmetic1.d | 72 +++++++++ .../tst/common/pointers/tst.PointerArithmetic1.d | 58 +++++++ .../tst/common/pointers/tst.PointerArithmetic2.d | 72 +++++++++ .../tst/common/pointers/tst.PointerArithmetic3.d | 61 ++++++++ .../tst/common/pointers/tst.PointerAssignment.d | 71 +++++++++ .../test/tst/common/pointers/tst.ValidPointer1.d | 49 ++++++ .../test/tst/common/pointers/tst.ValidPointer2.d | 49 ++++++ .../dtrace/test/tst/common/pointers/tst.VoidCast.d | 59 +++++++ .../dtrace/test/tst/common/pointers/tst.basic1.d | 47 ++++++ .../dtrace/test/tst/common/pointers/tst.basic2.d | 47 ++++++ 33 files changed, 1890 insertions(+) create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/Makefile.kup create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d create mode 100644 src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d (limited to 'src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers') diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/Makefile.kup new file mode 100644 index 00000000..e69de29b diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d new file mode 100644 index 00000000..ab4106db --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.BadAlign.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: This test reproduces the alignment error. + * + * SECTION: Type and Constant Definitions/Enumerations + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + x = (int *) 64; + y = *x; + trace(y); +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d new file mode 100644 index 00000000..b6832087 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.ArrayVar.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Trying to access the address of a user defined array variable should throw + * a D_ADDROF_VAR error. + * + * SECTION: Pointers and Arrays/Pointers and Address Spaces + */ + +#pragma D option quiet + +int a[5]; +int *p; + +BEGIN +{ + p = &a; + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d new file mode 100644 index 00000000..028a30a4 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.DynamicVar.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Trying to access the address of a user defined dynamic variable should throw + * a D_ADDROF_VAR error. + * + * SECTION: Pointers and Arrays/Generic Pointers + * SECTION: Pointers and Arrays/Pointers to Dtrace Objects + */ + +#pragma D option quiet + +int i; +int *p; + +BEGIN +{ + i = 10; + p = &i; + + printf("Integer: %d, Pointer: %d\n", i, *p); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d new file mode 100644 index 00000000..8b592620 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_ADDROF_VAR.agg.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test that the & operator fails with D_ADDROF_VAR if its operand + * is a dynamic variable such as an aggregation. + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * SECTION: Pointers and Arrays/Pointers to Dtrace Objects + */ + +BEGIN +{ + @a = count(); + trace(&@a); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d new file mode 100644 index 00000000..96d25b40 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_NONPTR.noptr.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Can not dereference non-pointers + * + * SECTION: Pointers and Arrays/Pointer Safety + * + * NOTES: + * + */ + +#pragma D option quiet + +int x; + +BEGIN +{ + b = *x; +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d new file mode 100644 index 00000000..f2fa5b31 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_DEREF_VOID.VoidPointerDeref.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Cannot dereference a void * pointer. + * + * SECTION: Pointers and Arrays/Generic Pointers + */ + +#pragma D option quiet + +void *p; + +int array[3]; + +BEGIN +{ + array[0] = 234; + array[1] = 334; + array[2] = 434; + + p = &array[0]; + + printf("array[0]: %d, p: %d\n", array[0], *p); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d new file mode 100644 index 00000000..94814a7b --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_ARRFUN.ArrayAssignment.d @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Arrays may not be assigned as a whole in D. + * + * SECTION: Pointers and Arrays/Pointer and Array Relationship + * + * NOTES: + * + */ + +#pragma D option quiet + +int array1[3]; +int array2[3]; + +BEGIN +{ + array1[0] = 200; + array1[1] = 400; + array1[2] = 600; + + array2[0] = 300; + array2[1] = 500; + array2[2] = 700; + + array2 = array1; + + printf("array1[0]: %d\tarray2[0]: %d\n", array1[0], array2[0]); + printf("array1[1]: %d\tarray2[1]: %d\n", array1[1], array2[1]); + printf("array1[2]: %d\tarray2[2]: %d\n", array1[2], array2[2]); + + exit(0); + +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d new file mode 100644 index 00000000..e81c2bd8 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_INCOMPAT.VoidPointerArith.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * May not apply pointer arithmetic to an object of type void * + * + * SECTION: Pointers and Arrays/Generic Pointers + */ + +#pragma D option quiet + +void *p; + +BEGIN +{ + printf("p: %d\n", (int) p); + printf("p+1: %d\n", (int) (p+1)); + printf("p+2: %d\n", (int) (p+2)); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d new file mode 100644 index 00000000..98282402 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_LVAL.AddressChange.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: D pointers do not allow invalid address changes. + * + * SECTION: Pointers and Arrays/Pointer Safety + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + &`kmem_flags = (int *) 0x185ede4; + printf("Address of kmem_flags: %d\n", (int) kmemAddress); + printf("Value of kmem_flags: %d\n", `kmem_flags); +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d new file mode 100644 index 00000000..6f253277 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.NonPointerAccess.d @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Accessing the members of a struct using the pointer notation using a + * nonpointer variable throws a D_OP_PTR error. + * + * SECTION: Structs and Unions/Pointers to Structs + * + */ + +#pragma D option quiet + +struct myinput_struct { + int i; + char c; +}; + +struct myinput_struct f; + +BEGIN +{ + f.i = 10; + f.c = 'c'; + + printf("f->i: %d\tf->c: %c\n", f->i, f->c); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d new file mode 100644 index 00000000..b1524e53 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_PTR.badpointer.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * -> can only be used with pointer operands. + * + * SECTION: Pointers and Arrays/Pointers and Address Spaces + */ + +#pragma D option quiet + +struct teststruct { + int a; + int b; +}; + +struct teststruct xyz; + +BEGIN +{ + xyz->a = 1; + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d new file mode 100644 index 00000000..75635773 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.BadPointerAccess.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Accessing a pointer to a struct like a non pointer throws a D_OP_SOU. + * + * SECTION: Structs and Unions/Pointers to Structs + * + */ + +#pragma D option quiet + +struct myinput_struct { + int i; + char c; +}; + +struct myinput_struct *f; +BEGIN +{ + f.i = 10; + f.c = 'c'; + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d new file mode 100644 index 00000000..1b351f34 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.D_OP_SOU.badpointer.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * -> can only be used with pointer to structs and unions. + * + * SECTION: Pointers and Arrays/Pointers and Address Spaces + */ + +#pragma D option quiet + +int *abc; + +BEGIN +{ + abc->a = 1; + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d new file mode 100644 index 00000000..9c9d2f0f --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress1.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: D pointers do not allow invalid pointer accesses. + * + * SECTION: Pointers and Arrays/Pointer Safety + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + kmemAddress = &`kmem_flags; + *kmemAddress = 20; + printf("Address of kmem_flags: %d\n", (int) kmemAddress); + printf("Value of kmem_flags: %d\n", `kmem_flags); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d new file mode 100644 index 00000000..324f4011 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress2.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: D pointers do not allow invalid pointer accesses. + * + * SECTION: Pointers and Arrays/Pointer Safety + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + x = (int *)alloca(sizeof (int)); + trace(x); + y = (int *) (x - 3300778156056); + *y = 3; + trace(*y); +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d new file mode 100644 index 00000000..39bd1140 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress3.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: D pointers do not allow invalid pointer accesses. + * + * SECTION: Pointers and Arrays/Pointer Safety + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + y = (int *) (-33007); + *y = 3; + trace(*y); +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d new file mode 100644 index 00000000..9d6b1440 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress4.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Demonstrating valid memory access. + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + x = (int *)alloca(sizeof (int)); + printf("Address x: %x\n", (int) x); + y = (int *) (x - 2); + *y = 3; + printf("Address y: %x\tValue: %d\n", (int) y, *y); +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d new file mode 100644 index 00000000..64b77289 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using integer arithmetic providing a non-aligned memory address will throw + * a runtime error. + * + * SECTION: Pointers and Arrays/Generic Pointers + * + * NOTES: + * This test doesn't apply to x86; for the time being, we're working + * around this with the preprocessor. + */ + +#pragma D option quiet + +int array[3]; +uintptr_t uptr; +int *p; +int *q; +int *r; + +BEGIN +{ +#ifdef __i386 + exit(1); +#else + array[0] = 20; + array[1] = 40; + array[2] = 80; + + uptr = (uintptr_t) &array[0]; + + p = (int *) (uptr); + q = (int *) (uptr + 2); + r = (int *) (uptr + 3); + + printf("array[0]: %d\t*p: %d\n", array[0], *p); + printf("array[1]: %d\t*q: %d\n", array[1], *q); + printf("array[2]: %d\t*r: %d\n", array[2], *r); + + exit(0); +#endif +} + +ERROR +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d new file mode 100644 index 00000000..fb9db752 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer1.d @@ -0,0 +1,174 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Declare arrays of different data types and verify that the + * addresses of the individual elements differ by an amount equal to the number + * elements separating them multiplied by the size of each element. + * + * SECTION: Pointers and Arrays/Array Declarations and Storage; + * Pointers and Arrays/Pointer Arithmetic + * + * NOTES: + * + */ + +#pragma D option quiet + +char char_array[5]; +short short_array[5]; +int int_array[5]; +long long_array[5]; +long long long_long_array[5]; +int8_t int8_array[5]; +int16_t int16_array[5]; +int32_t int32_array[5]; +int64_t int64_array[5]; +intptr_t intptr_array[5]; +uint8_t uint8_array[5]; +uint16_t uint16_array[5]; +uint32_t uint32_array[5]; +uint64_t uint64_array[5]; +uintptr_t uintptr_array[5]; + +/* +float float_array[5]; +double double_array[5]; +long double long_double_array[5]; + +string string_array[5]; +*/ + +struct record { + char ch; + int in; +} struct_array[5]; + +struct { + char ch; + int in; +} anon_struct_array[5]; + +union record { + char ch; + int in; +} union_array[5]; + +union { + char ch; + int in; +} anon_union_array[5]; + +enum colors { + RED, + GREEN, + BLUE +} enum_array[5]; + +BEGIN +{ + char_var0 = &char_array[0]; char_var2 = &char_array[2]; + short_var0 = &short_array[0]; short_var3 = &short_array[3]; + int_var3 = &int_array[3]; int_var5 = &int_array[5]; + + long_var0 = &long_array[0]; long_var4 = &long_array[4]; + long_long_var0 = &long_long_array[0]; + long_long_var2 = &long_long_array[2]; + int8_var3 = &int8_array[3]; int8_var5 = &int8_array[5]; + + int16_var0 = &int16_array[0]; int16_var4 = &int16_array[4]; + int32_var0 = &int32_array[0]; int32_var3 = &int32_array[3]; + int64_var0 = &int64_array[0]; int64_var1 = &int64_array[1]; + + uintptr_var0 = &uintptr_array[0]; uintptr_var2 = &uintptr_array[2]; + struct_var0 = &struct_array[0]; struct_var2 = &struct_array[2]; + anon_struct_var3 = &anon_struct_array[3]; + anon_struct_var5 = &anon_struct_array[5]; + + union_var0 = &union_array[0]; union_var3 = &union_array[3]; + anon_union_var0 = &anon_union_array[0]; + anon_union_var4 = &anon_union_array[4]; + enum_var0 = &enum_array[0]; enum_var2 = &enum_array[2]; + + printf("char_var2 - char_var0: %d\n", + (int) char_var2 - (int) char_var0); + printf("short_var3 - short_var0: %d\n", + (int) short_var3 - (int) short_var0); + printf("int_var5 - int_var3: %d\n", (int) int_var5 - (int) int_var3); + + printf("long_var4 - long_var0: %d\n", + (int) long_var4 - (int) long_var0); + printf("long_long_var2 - long_long_var0: %d\n", + (int) long_long_var2 - (int) long_long_var0); + printf("int8_var5 - int8_var3: %d\n", + (int) int8_var5 - (int) int8_var3); + + printf("int16_var4 - int16_var0: %d\n", + (int) int16_var4 - (int) int16_var0); + printf("int32_var3 - int32_var0: %d\n", + (int) int32_var3 - (int) int32_var0); + printf("int64_var1 - int64_var0: %d\n", + (int) int64_var1 - (int) int64_var0); + + printf("uintptr_var2 - uintptr_var0: %d\n", + (int) uintptr_var2 - (int) uintptr_var0); + printf("struct_var2 - struct_var0: %d\n", + (int) struct_var2 - (int) struct_var0); + printf("anon_struct_var5 - anon_struct_var3: %d\n", + (int) anon_struct_var5 - (int) anon_struct_var3); + + printf("union_var3 - union_var0: %d\n", + (int) union_var3 - (int) union_var0); + printf("anon_union_var4 - anon_union_var0: %d\n", + (int) anon_union_var4 - (int) anon_union_var0); + printf("enum_var2 - enum_var0: %d\n", + (int) enum_var2 - (int) enum_var0); + exit(0); +} + +END +/(2 != ((int) char_var2 - (int) char_var0)) || + (6 != ((int) short_var3 - (int) short_var0)) || + (8 != ((int) int_var5 - (int) int_var3)) || + ((32 != ((int) long_var4 - (int) long_var0)) && + (16 != ((int) long_var4 - (int) long_var0))) || + (16 != ((int) long_long_var2 - (int) long_long_var0)) || + (2 != ((int) int8_var5 - (int) int8_var3)) + || (8 != ((int) int16_var4 - (int) int16_var0)) || + (12 != ((int) int32_var3 - (int) int32_var0)) || + (8 != ((int) int64_var1 - (int) int64_var0)) || + ((16 != ((int) uintptr_var2 - (int) uintptr_var0)) + && (8 != ((int) uintptr_var2 - (int) uintptr_var0))) || + (16 != ((int) struct_var2 - (int) struct_var0)) || + (16 != ((int) anon_struct_var5 - (int) anon_struct_var3)) + || (12 != ((int) union_var3 - (int) union_var0)) || + (16 != ((int) anon_union_var4 - (int) anon_union_var0)) || + (8 != ((int) enum_var2 - (int) enum_var0))/ +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d new file mode 100644 index 00000000..bf645398 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer2.d @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: D permits the use of array [] index notation with both pointer + * variables and array variables. + * + * SECTION: Pointers and Arrays/Pointer and Array Relationship + * + * NOTES: + * + */ + +#pragma D option quiet + +int array[5]; +BEGIN +{ + array[0] = 100; + array[1] = 200; + array[2] = 300; + array[3] = 400; + array[4] = 500; + + p = &array[0]; + + printf("array[0]: %d\tp[0]: %d\n", array[0], p[0]); + printf("array[1]: %d\tp[1]: %d\n", array[1], p[1]); + printf("array[2]: %d\tp[2]: %d\n", array[2], p[2]); + printf("array[3]: %d\tp[3]: %d\n", array[3], p[3]); + printf("array[4]: %d\tp[4]: %d\n", array[4], p[4]); + + exit(0); + +} + +END +/(array[0] != p[0]) || (array[1] != p[1]) || (array[2] != p[2]) || + (array[3] != p[3]) || (array[4] != p[4])/ +{ + printf("Error"); + exit(1); +} + + + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d new file mode 100644 index 00000000..a0be1306 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ArrayPointer3.d @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: In D, the an array variable can be assigned to a pointer. + * + * SECTION: Pointers and Arrays/Pointer and Array Relationship + * + * NOTES: + * + */ + +#pragma D option quiet + +int array[5]; +int *p; + +BEGIN +{ + array[0] = 100; + array[1] = 200; + array[2] = 300; + array[3] = 400; + array[4] = 500; + + p = array; + + printf("array[0]: %d\tp[0]: %d\n", array[0], p[0]); + printf("array[1]: %d\tp[1]: %d\n", array[1], p[1]); + printf("array[2]: %d\tp[2]: %d\n", array[2], p[2]); + printf("array[3]: %d\tp[3]: %d\n", array[3], p[3]); + printf("array[4]: %d\tp[4]: %d\n", array[4], p[4]); + + exit(0); + +} + +END +/(array[0] != p[0]) || (array[1] != p[1]) || (array[2] != p[2]) || + (array[3] != p[3]) || (array[4] != p[4])/ +{ + printf("Error"); + exit(1); +} + + + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d new file mode 100644 index 00000000..8b7f36e3 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.GlobalVar.d @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Pointer declarations are global. + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + kmemAddress = &`kmem_flags; + kmemValue = *kmemAddress; + printf("Address of kmem_flags: %x\n", (int) kmemAddress); + printf("Value of kmem_flags: %d\n", kmemValue); +} + +profile:::tick-1sec +/(i < 1) && (&`kmem_flags == kmemAddress) && (*kmemAddress == kmemValue)/ +{ + exit(1); +} + +END +/(&`kmem_flags == kmemAddress) && (*kmemAddress == kmemValue)/ +{ + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d new file mode 100644 index 00000000..99cbd7e5 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.IntegerArithmetic1.d @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Integer arithmetic can be performed on pointers by casting to uintptr_t. + * + * SECTION: Pointers and Arrays/Generic Pointers + * + * NOTES: + * + */ + +#pragma D option quiet + +int array[3]; +uintptr_t uptr; +int *p; +int *q; +int *r; + +BEGIN +{ + array[0] = 20; + array[1] = 40; + array[2] = 80; + + uptr = (uintptr_t) &array[0]; + + p = (int *) (uptr); + q = (int *) (uptr + 4); + r = (int *) (uptr + 8); + + printf("array[0]: %d\t*p: %d\n", array[0], *p); + printf("array[1]: %d\t*q: %d\n", array[1], *q); + printf("array[2]: %d\t*r: %d\n", array[2], *r); + + exit(0); +} + +END +/(20 != *p) || (40 != *q) || (80 != *r)/ +{ + printf("Error"); + exit(1); +} + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d new file mode 100644 index 00000000..3a968325 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic1.d @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Pointer arithmetic implicitly adjusts the underlying address by + * multiplying or dividing the operands by the size of the type referenced + * by the pointer. + * + * SECTION: Pointers and Arrays/Pointer Arithmetic + * + * NOTES: + * + */ + +#pragma D option quiet + +int *x; + +BEGIN +{ + printf("x: %x\n", (int) x); + printf("x + 1: %x\n", (int) (x+1)); + printf("x + 2: %x\n", (int) (x+2)); + exit(0); +} + +END +/(0 != (int) x) || (4 != (int) (x+1)) || (8 != (int) (x+2))/ +{ + printf("Error"); + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d new file mode 100644 index 00000000..ac55eb44 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic2.d @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * D pointers can be used to refer to consecutive storage locations like + * arrays. + * + * SECTION: Pointers and Arrays/Pointer and Array Relationship + * + * NOTES: + * + */ + +#pragma D option quiet + +int array[5]; +BEGIN +{ + array[0] = 100; + array[1] = 200; + array[2] = 300; + array[3] = 400; + array[4] = 500; + + p = &array[0]; + + printf("array[0]: %d\t*p: %d\n", array[0], *p); + printf("array[1]: %d\t*(p+1): %d\n", array[1], *(p+1)); + printf("array[2]: %d\t*(p+2): %d\n", array[2], *(p+2)); + printf("array[3]: %d\t*(p+3): %d\n", array[3], *(p+3)); + printf("array[4]: %d\t*(p+4): %d\n", array[4], *(p+4)); + + exit(0); + +} + +END +/(array[0] != *p) || (array[1] != *(p+1)) || (array[2] != *(p+2)) + || (array[3] != *(p+3)) || (array[4] != *(p+4))/ +{ + printf("Error"); + exit(1); +} + + + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d new file mode 100644 index 00000000..a4f4bfc4 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerArithmetic3.d @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Pointer arithmetic implicitly adjusts the underlying address by + * multiplying or dividing the operands by the size of the type referenced + * by the pointer. + * + * SECTION: Pointers and Arrays/Pointer Arithmetic + * + * NOTES: + * + */ + +#pragma D option quiet + +int *x; +int *y; +int a[5]; + +BEGIN +{ + x = &a[0]; + y = &a[2]; + + printf("y-x: %x\n", (int) (y-x)); + exit(0); +} + +END +/(2 != (int) (y-x)) / +{ + printf("Error"); + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d new file mode 100644 index 00000000..3a496869 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.PointerAssignment.d @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Pointers assignment simply copies over the pointer address in the + * variable on the right hand side into the variable on the left hand side. + * + * SECTION: Pointers and Arrays/Pointer and Array Relationship + * + * NOTES: + * + */ + +#pragma D option quiet + +int array[3]; +int *ptr1; +int *ptr2; + +BEGIN +{ + array[0] = 200; + array[1] = 400; + array[2] = 600; + + ptr1 = array; + ptr2 = ptr1; + + ptr2[0] = 400; + ptr2[1] = 800; + ptr2[2] = 1200; + + printf("array[0]: %d\tptr2[0]: %d\n", array[0], ptr2[0]); + printf("array[1]: %d\tptr2[1]: %d\n", array[1], ptr2[1]); + printf("array[2]: %d\tptr2[2]: %d\n", array[2], ptr2[2]); + + exit(0); + +} + +END +/(array[0] != 400) || (array[1] != 800) || (array[2] != 1200)/ +{ + printf("Error"); + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d new file mode 100644 index 00000000..5d9db388 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer1.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Demonstrating valid memory access. + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + x = (int *)alloca(sizeof (int)); + printf("Address x: %x\n", (int) x); + y = (int *) (x); + *y = 3; + printf("Address y: %x\tValue: %d\n", (int) y, *y); + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d new file mode 100644 index 00000000..26d698ae --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.ValidPointer2.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Demonstrating valid memory access. + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + x = (int *)alloca(sizeof (int)); + printf("Address x: %x\n", (int) x); + y = (int *) (x + 2); + *y = 3; + printf("Address y: %x\tValue: %d\n", (int) y, *y); + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d new file mode 100644 index 00000000..296fdf40 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.VoidCast.d @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Can dereference a void * pointer only by casting it to another type. + * + * SECTION: Pointers and Arrays/Generic Pointers + */ + +#pragma D option quiet + +void *p; + +int array[3]; + +BEGIN +{ + array[0] = 234; + array[1] = 334; + array[2] = 434; + + p = &array[0]; + newp = (int *) p; + + printf("array[0]: %d, newp: %d\n", array[0], *newp); + exit(0); +} + +END +/234 != *newp/ +{ + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d new file mode 100644 index 00000000..bf3154a0 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic1.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Pointers can be stored in variables. + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + kmemAddress = &`kmem_flags; + kmemValue = *kmemAddress; + printf("Address of kmem_flags: %x\n", (int) kmemAddress); + printf("Value of kmem_flags: %d\n", kmemValue); + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d new file mode 100644 index 00000000..6b72b632 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/pointers/tst.basic2.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Pointers can be stored in associative arrays. + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * + * NOTES: + * + */ + +#pragma D option quiet + +BEGIN +{ + assoc_array["kmemAddress"] = &`kmem_flags; + kmemValue = *(assoc_array["kmemAddress"]); + printf("Address of kmem_flags: %x\n", (int) assoc_array["kmemAddress"]); + printf("Value of kmem_flags: %d\n", kmemValue); + exit(0); +} -- cgit v1.2.3