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
This commit is contained in:
commit
46097436dc
@ -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';
|
||||
|
@ -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);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
|
||||
1 0 10
|
||||
2 0 20
|
||||
3 0 30
|
||||
4 0 40
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -0,0 +1 @@
|
||||
cafe
|
@ -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);
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
|
||||
239
|
||||
52719
|
||||
-17
|
||||
-12817
|
||||
-1867788817
|
||||
1311768467294899695
|
||||
|
||||
|
@ -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);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
65535 -1 65535
|
||||
-1 -1 65535
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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 $?
|
@ -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
|
||||
|
||||
|
@ -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 $?
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
int rval;
|
||||
|
||||
if ((rval = dt_aggregate_hashcmp(lhs, rhs)) != 0)
|
||||
return (rval);
|
||||
assert(lagg->dtagd_nrecs == ragg->dtagd_nrecs);
|
||||
|
||||
if (lagg->dtagd_nrecs > ragg->dtagd_nrecs)
|
||||
return (DT_GREATERTHAN);
|
||||
lrec = &lagg->dtagd_rec[lagg->dtagd_nrecs - 1];
|
||||
rrec = &ragg->dtagd_rec[ragg->dtagd_nrecs - 1];
|
||||
|
||||
if (lagg->dtagd_nrecs < ragg->dtagd_nrecs)
|
||||
return (DT_LESSTHAN);
|
||||
|
||||
for (i = 0; i < lagg->dtagd_nrecs; i++) {
|
||||
lrec = &lagg->dtagd_rec[i];
|
||||
rrec = &ragg->dtagd_rec[i];
|
||||
|
||||
if (lrec->dtrd_offset < rrec->dtrd_offset)
|
||||
return (DT_LESSTHAN);
|
||||
|
||||
if (lrec->dtrd_offset > rrec->dtrd_offset)
|
||||
return (DT_GREATERTHAN);
|
||||
|
||||
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);
|
||||
|
@ -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,62 +664,47 @@ 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");
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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");
|
||||
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);
|
||||
|
||||
dret = yypcb->pcb_dret;
|
||||
dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp);
|
||||
/*
|
||||
* 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;
|
||||
|
||||
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);
|
||||
dret = yypcb->pcb_dret;
|
||||
dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 ||
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user