diff options
author | pfg <pfg@FreeBSD.org> | 2013-07-28 00:45:20 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2013-07-28 00:45:20 +0000 |
commit | 46097436dce0630481061f04e049041976f3e295 (patch) | |
tree | 826c16a4321d19d6fd89afb4e5b9ce87a74528d3 /cddl | |
parent | 9932d6357cd2745b8b313b513e4c8711a63cb77c (diff) | |
parent | 455309093315aa6181951cba3a699d09aca5ba5d (diff) | |
download | FreeBSD-src-46097436dce0630481061f04e049041976f3e295.zip FreeBSD-src-46097436dce0630481061f04e049041976f3e295.tar.gz |
DTrace: re-merge remainder of r249367 (original from Illumos).
Bring back some important fixes from Illumos:
3022 DTrace: keys should not affect the sort order when sorting by value
3023 it should be possible to dereference dynamic variables
3024 D integer narrowing needs some work
We particularly avoid the LD_NOLAZYLOAD changes that Illumos made
as those don't apply to FreeBSD and were causing problems in
interactive mode.
Illumos Revision: 13758:23432da34147
Reference:
https://www.illumos.org/issues/3022
https://www.illumos.org/issues/3023
https://www.illumos.org/issues/3024
MFC after: 1 month
Tested by: markj
Diffstat (limited to 'cddl')
34 files changed, 813 insertions, 274 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl index 7b47580..db15741 100755 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl @@ -583,6 +583,8 @@ if ($opt_x) { die "$PNAME: failed to open $PNAME.$$.log: $!\n" unless (!$opt_l || open(LOG, ">$PNAME.$$.log")); +$ENV{'DTRACE_DEBUG_REGSET'} = 'true'; + if ($opt_g) { $ENV{'UMEM_DEBUG'} = 'default,verbose'; $ENV{'UMEM_LOGGING'} = 'fail,contents'; diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d new file mode 100644 index 0000000..bb3ed47 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d @@ -0,0 +1,35 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +#pragma D option quiet + +/* + * Make sure the sizes of compatible keys doesn't affect the sort order. + */ + +BEGIN +{ + @[(int)1, 0] = sum(10); + @[(uint64_t)2, 0] = sum(20); + @[(int)3, 0] = sum(30); + @[(uint64_t)4, 0] = sum(40); + printa(@); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d.out new file mode 100644 index 0000000..83252ad --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d.out @@ -0,0 +1,6 @@ + + 1 0 10 + 2 0 20 + 3 0 30 + 4 0 40 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d.out new file mode 100644 index 0000000..d3b6af8 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d.out @@ -0,0 +1,8 @@ +The value of i is 6 +The value of i is 18 +The value of i is 72 +The value of i is 25920 +The value of i is 935761216 +The value of i is -91738734 +The value of i is -91738729 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d new file mode 100644 index 0000000..714fbe3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +/* + * Test compile-time casting between integer types of different size. + */ + +#pragma D option quiet + +int64_t x; + +BEGIN +{ + x = (int32_t)(int16_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + x = (int32_t)(uint16_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + x = (uint32_t)(int16_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + x = (uint32_t)(uint16_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + printf("\n"); + + x = (int16_t)(int32_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + x = (int16_t)(uint32_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + x = (uint16_t)(int32_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + x = (uint16_t)(uint32_t)0xfff0; + printf("%16x %20d %20u\n", x, x, x); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d.out new file mode 100644 index 0000000..d43df27 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d.out @@ -0,0 +1,10 @@ +fffffffffffffff0 -16 18446744073709551600 + fff0 65520 65520 + fffffff0 4294967280 4294967280 + fff0 65520 65520 + +fffffffffffffff0 -16 18446744073709551600 +fffffffffffffff0 -16 18446744073709551600 + fff0 65520 65520 + fff0 65520 65520 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d deleted file mode 100644 index 2db1b63..0000000 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d +++ /dev/null @@ -1,57 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ASSERTION: - * Complex expressions. - * Call complex expressions and make sure test succeeds. - * Match expected output in tst.complex.d.out - * - * SECTION: Types, Operators, and Expressions/Arithmetic Operators - * - */ - -#pragma D option quiet - -BEGIN -{ - i = 0; - i = i++ + ++i; - printf("The value of i is %d\n", i); - i = i-- - --i; - printf("The value of i is %d\n", i); - i = i-- + ++i; - printf("The value of i is %d\n", i); - i += i++ + -- i + ++i - ++i * i ; - printf("The value of i is %d\n", i); - i -= i++ * 3; - printf("The value of i is %d\n", i); - i = i++/i--+i++-++i-++i; - printf("The value of i is %d\n", i); - exit (0); -} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d new file mode 100644 index 0000000..0589b72 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d @@ -0,0 +1,36 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +/* + * Test narrowing at assignment. + */ + +#pragma D option quiet + +uint16_t x; +uint32_t y; + +BEGIN +{ + x = 0xbeefcafe; + y = x; + printf("%x", y); /* where's the beef? */ + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d.out new file mode 100644 index 0000000..ea17b16 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d.out @@ -0,0 +1 @@ +cafe diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d new file mode 100644 index 0000000..a7017bf --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +/* + * Test execution-time casting between integer types of different size. + */ + +#pragma D option quiet + +int64_t x; + +BEGIN +{ + z = 0xfff0; + + x = (int32_t)(int16_t)z; + printf("%16x %20d %20u\n", x, x, x); + x = (int32_t)(uint16_t)z; + printf("%16x %20d %20u\n", x, x, x); + x = (uint32_t)(int16_t)z; + printf("%16x %20d %20u\n", x, x, x); + x = (uint32_t)(uint16_t)z; + printf("%16x %20d %20u\n", x, x, x); + printf("\n"); + + x = (int16_t)(int32_t)z; + printf("%16x %20d %20u\n", x, x, x); + x = (int16_t)(uint32_t)z; + printf("%16x %20d %20u\n", x, x, x); + x = (uint16_t)(int32_t)z; + printf("%16x %20d %20u\n", x, x, x); + x = (uint16_t)(uint32_t)z; + printf("%16x %20d %20u\n", x, x, x); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d.out new file mode 100644 index 0000000..d43df27 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d.out @@ -0,0 +1,10 @@ +fffffffffffffff0 -16 18446744073709551600 + fff0 65520 65520 + fffffff0 4294967280 4294967280 + fff0 65520 65520 + +fffffffffffffff0 -16 18446744073709551600 +fffffffffffffff0 -16 18446744073709551600 + fff0 65520 65520 + fff0 65520 65520 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/err.D_PRINT_DYN.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/err.D_PRINT_DYN.bad.d deleted file mode 100644 index 892b445..0000000 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/err.D_PRINT_DYN.bad.d +++ /dev/null @@ -1,29 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright (c) 2011 by Delphix. All rights reserved. - */ - -BEGIN -{ - print(*curpsinfo); -} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.dyn.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.dyn.d new file mode 100644 index 0000000..f17551f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.dyn.d @@ -0,0 +1,28 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +BEGIN +{ + print(*curpsinfo); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.xlate.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.xlate.d new file mode 100644 index 0000000..e8125d4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.xlate.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +#pragma D option quiet + +typedef struct pancakes { + int i; + string s; + timespec_t t; +} pancakes_t; + +translator pancakes_t < void *V > { + i = 2 * 10; + s = strjoin("I like ", "pancakes"); + t = *(timespec_t *)`dtrace_zero; +}; + +BEGIN +{ + print(*(xlate < pancakes_t * > ((void *)NULL))); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.xlate.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.xlate.d.out new file mode 100644 index 0000000..9b01402 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/tst.xlate.d.out @@ -0,0 +1,8 @@ +pancakes_t { + int i = 0x14 + string s = [ "I like pancakes" ] + timespec_t t = { + time_t tv_sec = 0 + long tv_nsec = 0 + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.ints.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.ints.d.out index 4d2bb11..bc7eaed 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.ints.d.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.ints.d.out @@ -1,6 +1,6 @@ -239 -52719 +-17 +-12817 -1867788817 1311768467294899695 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.signs.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.signs.d new file mode 100644 index 0000000..64e565e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.signs.d @@ -0,0 +1,38 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +/* + * Check %d v. %i v. %u. + */ + +#pragma D option quiet + +uint16_t x; +int16_t y; + +BEGIN +{ + x = 0xffffffff; + y = 0xffffffff; + + printf("%d %i %u\n", x, x, x); + printf("%d %i %u\n", y, y, y); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.signs.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.signs.d.out new file mode 100644 index 0000000..169ac59 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.signs.d.out @@ -0,0 +1,3 @@ +65535 -1 65535 +-1 -1 65535 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/trace/tst.dyn.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/trace/tst.dyn.d new file mode 100644 index 0000000..24ad80f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/trace/tst.dyn.d @@ -0,0 +1,28 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +BEGIN +{ + trace(*curpsinfo); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d deleted file mode 100644 index c664188..0000000 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d +++ /dev/null @@ -1,61 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ASSERTION: - * The D inline translation mechanism can be used to facilitate stable - * translations. - * - * SECTION: Translators/ Translator Declarations - * SECTION: Translators/ Translate Operator - * SECTION: Translators/Stable Translations - * - * NOTES: Uncomment the pragma that explicitly resets the attributes of - * myinfo identifier to Stable/Stable/Common from Private/Private/Unknown. - * Run the program with and without the comments as: - * /usr/sbin/dtrace -vs man.TestTransStability.d - */ - -#pragma D option quiet - -inline lwpsinfo_t *myinfo = xlate < lwpsinfo_t *> (curthread); - -/* -#pragma D attributes Stable/Stable/Common myinfo -*/ - -BEGIN -{ - trace(myinfo->pr_flag); - exit(0); -} - -ERROR -{ - exit(1); -} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh new file mode 100644 index 0000000..16eeda3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh @@ -0,0 +1,62 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2012 by Delphix. All rights reserved. +# + +# +# Test the output for stable translations. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -v -s /dev/stdin <<EOF + +#pragma D option quiet + +inline lwpsinfo_t *myinfo = xlate < lwpsinfo_t *> (curthread); + +#pragma D attributes Stable/Stable/Common myinfo + +BEGIN +{ + this->a = myinfo->pr_flag; + exit(0); +} + +BEGIN +{ + exit(1); +} +EOF + +exit $? diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh.out new file mode 100644 index 0000000..43c1adb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh.out @@ -0,0 +1,14 @@ + +Stability attributes for script /dev/stdin: + + Minimum Probe Description Attributes + Identifier Names: Unstable + Data Semantics: Unstable + Dependency Class: Common + + Minimum Statement Attributes + Identifier Names: Stable + Data Semantics: Stable + Dependency Class: Common + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh new file mode 100644 index 0000000..82070cd --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh @@ -0,0 +1,60 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2012 by Delphix. All rights reserved. +# + +# +# Test the output of unstable translations. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -v -s /dev/stdin <<EOF + +#pragma D option quiet + +inline lwpsinfo_t *myinfo = xlate < lwpsinfo_t *> (curthread); + +BEGIN +{ + this->a = myinfo->pr_flag; + exit(0); +} + +BEGIN +{ + exit(1); +} +EOF + +exit $? diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh.out new file mode 100644 index 0000000..f4b70f9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh.out @@ -0,0 +1,14 @@ + +Stability attributes for script /dev/stdin: + + Minimum Probe Description Attributes + Identifier Names: Unstable + Data Semantics: Unstable + Dependency Class: Common + + Minimum Statement Attributes + Identifier Names: Private + Data Semantics: Private + Dependency Class: Unknown + + diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c index 42b6645..b0f2b4a 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c @@ -26,6 +26,7 @@ /* * Copyright (c) 2011, Joyent, Inc. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include <stdlib.h> @@ -894,33 +895,14 @@ dt_aggregate_valcmp(const void *lhs, const void *rhs) caddr_t rdata = rh->dtahe_data.dtada_data; dtrace_recdesc_t *lrec, *rrec; int64_t *laddr, *raddr; - int rval, i; - - if ((rval = dt_aggregate_hashcmp(lhs, rhs)) != 0) - return (rval); - - if (lagg->dtagd_nrecs > ragg->dtagd_nrecs) - return (DT_GREATERTHAN); - - if (lagg->dtagd_nrecs < ragg->dtagd_nrecs) - return (DT_LESSTHAN); + int rval; - for (i = 0; i < lagg->dtagd_nrecs; i++) { - lrec = &lagg->dtagd_rec[i]; - rrec = &ragg->dtagd_rec[i]; + assert(lagg->dtagd_nrecs == ragg->dtagd_nrecs); - if (lrec->dtrd_offset < rrec->dtrd_offset) - return (DT_LESSTHAN); - - if (lrec->dtrd_offset > rrec->dtrd_offset) - return (DT_GREATERTHAN); + lrec = &lagg->dtagd_rec[lagg->dtagd_nrecs - 1]; + rrec = &ragg->dtagd_rec[ragg->dtagd_nrecs - 1]; - if (lrec->dtrd_action < rrec->dtrd_action) - return (DT_LESSTHAN); - - if (lrec->dtrd_action > rrec->dtrd_action) - return (DT_GREATERTHAN); - } + assert(lrec->dtrd_action == rrec->dtrd_action); laddr = (int64_t *)(uintptr_t)(ldata + lrec->dtrd_offset); raddr = (int64_t *)(uintptr_t)(rdata + rrec->dtrd_offset); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c index 0ac4795..5700993 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Joyent Inc. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ /* @@ -664,63 +664,48 @@ static void dt_action_trace(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) { dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp); + boolean_t istrace = (dnp->dn_ident->di_id == DT_ACT_TRACE); + const char *act = istrace ? "trace" : "print"; if (dt_node_is_void(dnp->dn_args)) { - dnerror(dnp->dn_args, D_TRACE_VOID, - "trace( ) may not be applied to a void expression\n"); + dnerror(dnp->dn_args, istrace ? D_TRACE_VOID : D_PRINT_VOID, + "%s( ) may not be applied to a void expression\n", act); } - if (dt_node_is_dynamic(dnp->dn_args)) { - dnerror(dnp->dn_args, D_TRACE_DYN, - "trace( ) may not be applied to a dynamic expression\n"); + if (dt_node_resolve(dnp->dn_args, DT_IDENT_XLPTR) != NULL) { + dnerror(dnp->dn_args, istrace ? D_TRACE_DYN : D_PRINT_DYN, + "%s( ) may not be applied to a translated pointer\n", act); } dt_cg(yypcb, dnp->dn_args); - ap->dtad_difo = dt_as(yypcb); - ap->dtad_kind = DTRACEACT_DIFEXPR; -} -/* - * The print() action behaves identically to trace(), except that it stores the - * CTF type of the argument (if present) within the DOF for the DIFEXPR action. - * To do this, we set the 'dtsd_strdata' to point to the fully-qualified CTF - * type ID for the result of the DIF action. We use the ID instead of the name - * to handles complex types like arrays and function pointers that can't be - * resolved by ctf_type_lookup(). This is later processed by - * dtrace_dof_create() and turned into a reference into the string table so - * that we can get the type information when we process the data after the - * fact. - */ -static void -dt_action_print(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) -{ - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp); - dt_node_t *dret; - size_t len; - dt_module_t *dmp; + /* + * The print() action behaves identically to trace(), except that it + * stores the CTF type of the argument (if present) within the DOF for + * the DIFEXPR action. To do this, we set the 'dtsd_strdata' to point + * to the fully-qualified CTF type ID for the result of the DIF + * action. We use the ID instead of the name to handles complex types + * like arrays and function pointers that can't be resolved by + * ctf_type_lookup(). This is later processed by dtrace_dof_create() + * and turned into a reference into the string table so that we can + * get the type information when we process the data after the fact. + */ + if (dnp->dn_ident->di_id == DT_ACT_PRINT) { + dt_node_t *dret; + size_t n; + dt_module_t *dmp; - if (dt_node_is_void(dnp->dn_args)) { - dnerror(dnp->dn_args, D_PRINT_VOID, - "print( ) may not be applied to a void expression\n"); - } + dret = yypcb->pcb_dret; + dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp); - if (dt_node_is_dynamic(dnp->dn_args)) { - dnerror(dnp->dn_args, D_PRINT_DYN, - "print( ) may not be applied to a dynamic expression\n"); + n = snprintf(NULL, 0, "%s`%ld", dmp->dm_name, dret->dn_type) + 1; + sdp->dtsd_strdata = dt_alloc(dtp, n); + if (sdp->dtsd_strdata == NULL) + longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); + (void) snprintf(sdp->dtsd_strdata, n, "%s`%ld", dmp->dm_name, + dret->dn_type); } - dt_cg(yypcb, dnp->dn_args); - - dret = yypcb->pcb_dret; - dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp); - - len = snprintf(NULL, 0, "%s`%ld", dmp->dm_name, dret->dn_type) + 1; - sdp->dtsd_strdata = dt_alloc(dtp, len); - if (sdp->dtsd_strdata == NULL) - longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); - (void) snprintf(sdp->dtsd_strdata, len, "%s`%ld", dmp->dm_name, - dret->dn_type); - ap->dtad_difo = dt_as(yypcb); ap->dtad_kind = DTRACEACT_DIFEXPR; } @@ -1145,6 +1130,9 @@ dt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) case DT_ACT_PANIC: dt_action_panic(dtp, dnp->dn_expr, sdp); break; + case DT_ACT_PRINT: + dt_action_trace(dtp, dnp->dn_expr, sdp); + break; case DT_ACT_PRINTA: dt_action_printa(dtp, dnp->dn_expr, sdp); break; @@ -1181,9 +1169,6 @@ dt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) case DT_ACT_TRACE: dt_action_trace(dtp, dnp->dn_expr, sdp); break; - case DT_ACT_PRINT: - dt_action_print(dtp, dnp->dn_expr, sdp); - break; case DT_ACT_TRACEMEM: dt_action_tracemem(dtp, dnp->dn_expr, sdp); break; @@ -2559,7 +2544,8 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg, } out: - if (context != DT_CTX_DTYPE && DT_TREEDUMP_PASS(dtp, 3)) + if (context != DT_CTX_DTYPE && yypcb->pcb_root != NULL && + DT_TREEDUMP_PASS(dtp, 3)) dt_node_printr(yypcb->pcb_root, stderr, 0); if (dtp->dt_cdefs_fd != -1 && (ftruncate64(dtp->dt_cdefs_fd, 0) == -1 || diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c index 6c60219..e748ff2 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c @@ -1387,6 +1387,162 @@ dt_cg_func_typeref(dtrace_hdl_t *dtp, dt_node_t *dnp) typs->dn_value = ctf_type_size(dtt.dtt_ctfp, dtt.dtt_type); } +typedef struct dt_xlmemb { + dt_ident_t *dtxl_idp; /* translated ident */ + dt_irlist_t *dtxl_dlp; /* instruction list */ + dt_regset_t *dtxl_drp; /* register set */ + int dtxl_sreg; /* location of the translation input */ + int dtxl_dreg; /* location of our allocated buffer */ +} dt_xlmemb_t; + +/*ARGSUSED*/ +static int +dt_cg_xlate_member(const char *name, ctf_id_t type, ulong_t off, void *arg) +{ + dt_xlmemb_t *dx = arg; + dt_ident_t *idp = dx->dtxl_idp; + dt_irlist_t *dlp = dx->dtxl_dlp; + dt_regset_t *drp = dx->dtxl_drp; + + dt_node_t *mnp; + dt_xlator_t *dxp; + + int reg, treg; + uint32_t instr; + size_t size; + + /* Generate code for the translation. */ + dxp = idp->di_data; + mnp = dt_xlator_member(dxp, name); + + /* If there's no translator for the given member, skip it. */ + if (mnp == NULL) + return (0); + + dxp->dx_ident->di_flags |= DT_IDFLG_CGREG; + dxp->dx_ident->di_id = dx->dtxl_sreg; + + dt_cg_node(mnp->dn_membexpr, dlp, drp); + + dxp->dx_ident->di_flags &= ~DT_IDFLG_CGREG; + dxp->dx_ident->di_id = 0; + + treg = mnp->dn_membexpr->dn_reg; + + /* Compute the offset into our buffer and store the result there. */ + reg = dt_regset_alloc(drp); + + dt_cg_setx(dlp, reg, off / NBBY); + instr = DIF_INSTR_FMT(DIF_OP_ADD, dx->dtxl_dreg, reg, reg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + + size = ctf_type_size(mnp->dn_membexpr->dn_ctfp, + mnp->dn_membexpr->dn_type); + if (dt_node_is_scalar(mnp->dn_membexpr)) { + /* + * Copying scalars is simple. + */ + switch (size) { + case 1: + instr = DIF_INSTR_STORE(DIF_OP_STB, treg, reg); + break; + case 2: + instr = DIF_INSTR_STORE(DIF_OP_STH, treg, reg); + break; + case 4: + instr = DIF_INSTR_STORE(DIF_OP_STW, treg, reg); + break; + case 8: + instr = DIF_INSTR_STORE(DIF_OP_STX, treg, reg); + break; + default: + xyerror(D_UNKNOWN, "internal error -- unexpected " + "size: %lu\n", (ulong_t)size); + } + + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + + } else if (dt_node_is_string(mnp->dn_membexpr)) { + int szreg; + + /* + * Use the copys instruction for strings. + */ + szreg = dt_regset_alloc(drp); + dt_cg_setx(dlp, szreg, size); + instr = DIF_INSTR_COPYS(treg, szreg, reg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + dt_regset_free(drp, szreg); + } else { + int szreg; + + /* + * If it's anything else then we'll just bcopy it. + */ + szreg = dt_regset_alloc(drp); + dt_cg_setx(dlp, szreg, size); + dt_irlist_append(dlp, + dt_cg_node_alloc(DT_LBL_NONE, DIF_INSTR_FLUSHTS)); + instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF, + DIF_REG_R0, treg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF, + DIF_REG_R0, reg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF, + DIF_REG_R0, szreg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + instr = DIF_INSTR_CALL(DIF_SUBR_BCOPY, szreg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + dt_regset_free(drp, szreg); + } + + dt_regset_free(drp, reg); + dt_regset_free(drp, treg); + + return (0); +} + +/* + * If we're expanding a translated type, we create an appropriately sized + * buffer with alloca() and then translate each member into it. + */ +static int +dt_cg_xlate_expand(dt_node_t *dnp, dt_ident_t *idp, dt_irlist_t *dlp, + dt_regset_t *drp) +{ + dt_xlmemb_t dlm; + uint32_t instr; + int dreg; + size_t size; + + dreg = dt_regset_alloc(drp); + size = ctf_type_size(dnp->dn_ident->di_ctfp, dnp->dn_ident->di_type); + + /* Call alloca() to create the buffer. */ + dt_cg_setx(dlp, dreg, size); + + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, DIF_INSTR_FLUSHTS)); + + instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF, DIF_REG_R0, dreg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + + instr = DIF_INSTR_CALL(DIF_SUBR_ALLOCA, dreg); + dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); + + /* Generate the translation for each member. */ + dlm.dtxl_idp = idp; + dlm.dtxl_dlp = dlp; + dlm.dtxl_drp = drp; + dlm.dtxl_sreg = dnp->dn_reg; + dlm.dtxl_dreg = dreg; + (void) ctf_member_iter(dnp->dn_ident->di_ctfp, + dnp->dn_ident->di_type, dt_cg_xlate_member, + &dlm); + + return (dreg); +} + static void dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp) { @@ -1600,7 +1756,16 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp) dt_cg_node(dnp->dn_child, dlp, drp); dnp->dn_reg = dnp->dn_child->dn_reg; - if (!(dnp->dn_flags & DT_NF_REF)) { + if (dt_node_is_dynamic(dnp->dn_child)) { + int reg; + idp = dt_node_resolve(dnp->dn_child, DT_IDENT_XLPTR); + assert(idp != NULL); + reg = dt_cg_xlate_expand(dnp, idp, dlp, drp); + + dt_regset_free(drp, dnp->dn_child->dn_reg); + dnp->dn_reg = reg; + + } else if (!(dnp->dn_flags & DT_NF_REF)) { uint_t ubit = dnp->dn_flags & DT_NF_USERLAND; /* @@ -1998,6 +2163,13 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp) dt_cg_node(dnp, &pcb->pcb_ir, pcb->pcb_regs); + if ((idp = dt_node_resolve(dnp, DT_IDENT_XLSOU)) != NULL) { + int reg = dt_cg_xlate_expand(dnp, idp, + &pcb->pcb_ir, pcb->pcb_regs); + dt_regset_free(pcb->pcb_regs, dnp->dn_reg); + dnp->dn_reg = reg; + } + instr = DIF_INSTR_RET(dnp->dn_reg); dt_regset_free(pcb->pcb_regs, dnp->dn_reg); dt_irlist_append(&pcb->pcb_ir, dt_cg_node_alloc(DT_LBL_NONE, instr)); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index c88a92c..8d9e494 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -2018,13 +2018,13 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, uint64_t tracememsize = 0; dtrace_probedata_t data; uint64_t drops; - data.dtpda_flow = dtp->dt_flow; - data.dtpda_indent = dtp->dt_indent; - data.dtpda_prefix = dtp->dt_prefix; bzero(&data, sizeof (data)); data.dtpda_handle = dtp; data.dtpda_cpu = cpu; + data.dtpda_flow = dtp->dt_flow; + data.dtpda_indent = dtp->dt_indent; + data.dtpda_prefix = dtp->dt_prefix; for (offs = buf->dtbd_oldest; offs < buf->dtbd_size; ) { dtrace_eprobedesc_t *epd; @@ -2611,7 +2611,7 @@ typedef struct dt_begin { static int dt_consume_begin_probe(const dtrace_probedata_t *data, void *arg) { - dt_begin_t *begin = (dt_begin_t *)arg; + dt_begin_t *begin = arg; dtrace_probedesc_t *pd = data->dtpda_pdesc; int r1 = (strcmp(pd->dtpd_provider, "dtrace") == 0); @@ -2636,7 +2636,7 @@ static int dt_consume_begin_record(const dtrace_probedata_t *data, const dtrace_recdesc_t *rec, void *arg) { - dt_begin_t *begin = (dt_begin_t *)arg; + dt_begin_t *begin = arg; return (begin->dtbgn_recfunc(data, rec, begin->dtbgn_arg)); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c index 75814c1..66776be 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h index c066b03..e4b1db5 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h @@ -468,7 +468,6 @@ enum { EDT_VERSREDUCED, /* requested API version has been reduced */ EDT_CTF, /* libctf called failed (dt_ctferr has more) */ EDT_COMPILER, /* error in D program compilation */ - EDT_NOREG, /* register allocation failure */ EDT_NOTUPREG, /* tuple register allocation failure */ EDT_NOMEM, /* memory allocation failure */ EDT_INT2BIG, /* integer limit exceeded */ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c index aafe647..5b3be7d 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c @@ -23,6 +23,7 @@ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2011, Joyent Inc. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -96,6 +97,7 @@ */ #include <sys/param.h> +#include <sys/sysmacros.h> #include <limits.h> #include <setjmp.h> #include <strings.h> @@ -1862,6 +1864,38 @@ dt_node_op1(int op, dt_node_t *cp) return (dnp); } +/* + * If an integer constant is being cast to another integer type, we can + * perform the cast as part of integer constant folding in this pass. We must + * take action when the integer is being cast to a smaller type or if it is + * changing signed-ness. If so, we first shift rp's bits bits high (losing + * excess bits if narrowing) and then shift them down with either a logical + * shift (unsigned) or arithmetic shift (signed). + */ +static void +dt_cast(dt_node_t *lp, dt_node_t *rp) +{ + size_t srcsize = dt_node_type_size(rp); + size_t dstsize = dt_node_type_size(lp); + + if (dstsize < srcsize) { + int n = (sizeof (uint64_t) - dstsize) * NBBY; + rp->dn_value <<= n; + rp->dn_value >>= n; + } else if (dstsize > srcsize) { + int n = (sizeof (uint64_t) - srcsize) * NBBY; + int s = (dstsize - srcsize) * NBBY; + + rp->dn_value <<= n; + if (rp->dn_flags & DT_NF_SIGNED) { + rp->dn_value = (intmax_t)rp->dn_value >> s; + rp->dn_value >>= n - s; + } else { + rp->dn_value >>= n; + } + } +} + dt_node_t * dt_node_op2(int op, dt_node_t *lp, dt_node_t *rp) { @@ -2011,32 +2045,9 @@ dt_node_op2(int op, dt_node_t *lp, dt_node_t *rp) } } - /* - * If an integer constant is being cast to another integer type, we can - * perform the cast as part of integer constant folding in this pass. - * We must take action when the integer is being cast to a smaller type - * or if it is changing signed-ness. If so, we first shift rp's bits - * bits high (losing excess bits if narrowing) and then shift them down - * with either a logical shift (unsigned) or arithmetic shift (signed). - */ if (op == DT_TOK_LPAR && rp->dn_kind == DT_NODE_INT && dt_node_is_integer(lp)) { - size_t srcsize = dt_node_type_size(rp); - size_t dstsize = dt_node_type_size(lp); - - if ((dstsize < srcsize) || ((lp->dn_flags & DT_NF_SIGNED) ^ - (rp->dn_flags & DT_NF_SIGNED))) { - int n = dstsize < srcsize ? - (sizeof (uint64_t) * NBBY - dstsize * NBBY) : - (sizeof (uint64_t) * NBBY - srcsize * NBBY); - - rp->dn_value <<= n; - if (lp->dn_flags & DT_NF_SIGNED) - rp->dn_value = (intmax_t)rp->dn_value >> n; - else - rp->dn_value = rp->dn_value >> n; - } - + dt_cast(lp, rp); dt_node_type_propagate(lp, rp); dt_node_attr_assign(rp, dt_attr_min(lp->dn_attr, rp->dn_attr)); dt_node_free(lp); @@ -2895,14 +2906,14 @@ dt_cook_op1(dt_node_t *dnp, uint_t idflags) case DT_TOK_DEREF: /* * If the deref operator is applied to a translated pointer, - * we can just set our output type to the base translation. + * we set our output type to the output of the translation. */ if ((idp = dt_node_resolve(cp, DT_IDENT_XLPTR)) != NULL) { dt_xlator_t *dxp = idp->di_data; dnp->dn_ident = &dxp->dx_souid; dt_node_type_assign(dnp, - DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp)); + dnp->dn_ident->di_ctfp, dnp->dn_ident->di_type); break; } @@ -3078,6 +3089,31 @@ dt_cook_op1(dt_node_t *dnp, uint_t idflags) return (dnp); } +static void +dt_assign_common(dt_node_t *dnp) +{ + dt_node_t *lp = dnp->dn_left; + dt_node_t *rp = dnp->dn_right; + int op = dnp->dn_op; + + if (rp->dn_kind == DT_NODE_INT) + dt_cast(lp, rp); + + if (!(lp->dn_flags & DT_NF_LVALUE)) { + xyerror(D_OP_LVAL, "operator %s requires modifiable " + "lvalue as an operand\n", opstr(op)); + /* see K&R[A7.17] */ + } + + if (!(lp->dn_flags & DT_NF_WRITABLE)) { + xyerror(D_OP_WRITE, "operator %s can only be applied " + "to a writable variable\n", opstr(op)); + } + + dt_node_type_propagate(lp, dnp); /* see K&R[A7.17] */ + dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr)); +} + static dt_node_t * dt_cook_op2(dt_node_t *dnp, uint_t idflags) { @@ -3556,19 +3592,7 @@ dt_cook_op2(dt_node_t *dnp, uint_t idflags) } } asgn_common: - if (!(lp->dn_flags & DT_NF_LVALUE)) { - xyerror(D_OP_LVAL, "operator %s requires modifiable " - "lvalue as an operand\n", opstr(op)); - /* see K&R[A7.17] */ - } - - if (!(lp->dn_flags & DT_NF_WRITABLE)) { - xyerror(D_OP_WRITE, "operator %s can only be applied " - "to a writable variable\n", opstr(op)); - } - - dt_node_type_propagate(lp, dnp); /* see K&R[A7.17] */ - dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr)); + dt_assign_common(dnp); break; case DT_TOK_PTR: @@ -3873,6 +3897,14 @@ asgn_common: dt_node_type_propagate(lp, dnp); /* see K&R[A7.5] */ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr)); + + /* + * If it's a pointer then should be able to (attempt to) + * assign to it. + */ + if (lkind == CTF_K_POINTER) + dnp->dn_flags |= DT_NF_WRITABLE; + break; } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c index 51f87b0..24682b2 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Joyent, Inc. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #if defined(sun) @@ -161,7 +162,7 @@ static int pfcheck_dint(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp) { if (dnp->dn_flags & DT_NF_SIGNED) - pfd->pfd_flags |= DT_PFCONV_SIGNED; + pfd->pfd_fmt[strlen(pfd->pfd_fmt) - 1] = 'i'; else pfd->pfd_fmt[strlen(pfd->pfd_fmt) - 1] = 'u'; @@ -664,7 +665,7 @@ static const dt_pfconv_t _dtrace_conversions[] = { { "hu", "u", "unsigned short", pfcheck_type, pfprint_uint }, { "hx", "x", "short", pfcheck_xshort, pfprint_uint }, { "hX", "X", "short", pfcheck_xshort, pfprint_uint }, -{ "i", "i", pfproto_xint, pfcheck_dint, pfprint_dint }, +{ "i", "i", pfproto_xint, pfcheck_xint, pfprint_sint }, { "I", "s", pfproto_cstr, pfcheck_str, pfprint_inetaddr }, { "k", "s", "stack", pfcheck_stack, pfprint_stack }, { "lc", "lc", "int", pfcheck_type, pfprint_sint }, /* a.k.a. wint_t */ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c index df34eec..87211a2 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c @@ -21,6 +21,7 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. * Use is subject to license terms. */ @@ -617,8 +618,8 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...) size_t avail; /* - * It's not legal to use buffered ouput if there is not a - * handler for buffered output. + * Using buffered output is not allowed if a handler has + * not been installed. */ if (dtp->dt_bufhdlr == NULL) { va_end(ap); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c b/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c index f11ae48..9479e83 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c @@ -24,6 +24,10 @@ * Use is subject to license terms. */ +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + #include <stdlib.h> #include <assert.h> #include <errno.h> @@ -525,7 +529,8 @@ dt_instr_size(uchar_t *instr, dtrace_hdl_t *dtp, pid_t pid, uintptr_t addr, * another debugger attached to this process. The original instruction * can't be recovered so this must fail. */ - if (x86dis.d86_len == 1 && instr[0] == FASTTRAP_INSTR) + if (x86dis.d86_len == 1 && + (uchar_t)x86dis.d86_bytes[0] == FASTTRAP_INSTR) return (-1); return (x86dis.d86_len); |