-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore order of bcopy() arg evaluations
In c26e2e5 ("Add support for copyinto() subroutine"), the order of arg evaluations for bcopy() was changed from evaluating the last arg (size) last to evaluating it first. This has semantic implications when the order of arguments matters. Restore the previous order (to agree with Solaris semantics) and add tests for both bcopy() and copyinto(). Signed-off-by: Eugene Loh <eugene.loh@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
Showing
5 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Arguments are evaluated in the correct order. | ||
* | ||
* SECTION: Actions and Subroutines/bcopy() | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
src = (char *)alloca(8); | ||
dst = (char *)alloca(8); | ||
|
||
/* initialize src */ | ||
src[ 0] = 'a'; src[ 1] = 'b'; src[ 2] = 'c'; src[ 3] = 'd'; | ||
src[ 4] = 'e'; src[ 5] = 'f'; src[ 6] = 'g'; src[ 7] = 'h'; | ||
|
||
/* initialize dst with '.' */ | ||
dst[ 0] = dst[ 1] = dst[ 2] = dst[ 3] = | ||
dst[ 4] = dst[ 5] = dst[ 6] = dst[ 7] = '.'; | ||
|
||
/* execute subroutine with order-dependent arguments */ | ||
n = 2; | ||
bcopy((void*)(src + (n++)), (void*)(dst + (n++)), (n++)); | ||
|
||
/* print results */ | ||
printf("%c%c%c%c%c%c%c%c\n", | ||
dst[ 0], dst[ 1], dst[ 2], dst[ 3], | ||
dst[ 4], dst[ 5], dst[ 6], dst[ 7]); | ||
|
||
/* repeat all that but with order-independent arguments */ | ||
dst[ 0] = dst[ 1] = dst[ 2] = dst[ 3] = | ||
dst[ 4] = dst[ 5] = dst[ 6] = dst[ 7] = '.'; | ||
bcopy((void*)(src + 2), (void*)(dst + 3), 4); | ||
printf("%c%c%c%c%c%c%c%c\n", | ||
dst[ 0], dst[ 1], dst[ 2], dst[ 3], | ||
dst[ 4], dst[ 5], dst[ 6], dst[ 7]); | ||
|
||
exit(0); | ||
} | ||
|
||
ERROR | ||
{ | ||
exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
...cdef. | ||
...cdef. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* ASSERTION: Arguments are evaluated in the correct order. | ||
* | ||
* SECTION: Actions and Subroutines/copyinto() | ||
*/ | ||
/* @@trigger: delaydie */ | ||
|
||
#pragma D option quiet | ||
|
||
syscall::write:entry | ||
/pid == $target/ | ||
{ | ||
ptr = (char *)alloca(16); | ||
|
||
/* initialize with '.' */ | ||
ptr[ 0] = ptr[ 1] = ptr[ 2] = ptr[ 3] = | ||
ptr[ 4] = ptr[ 5] = ptr[ 6] = ptr[ 7] = | ||
ptr[ 8] = ptr[ 9] = ptr[10] = ptr[11] = | ||
ptr[12] = ptr[13] = ptr[14] = ptr[15] = '.'; | ||
|
||
/* execute subroutine with order-dependent arguments */ | ||
n = 2; | ||
copyinto(arg1 + (n++), (n++), (void*)(ptr + (n++))); | ||
|
||
/* print results */ | ||
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", | ||
ptr[ 0], ptr[ 1], ptr[ 2], ptr[ 3], | ||
ptr[ 4], ptr[ 5], ptr[ 6], ptr[ 7], | ||
ptr[ 8], ptr[ 9], ptr[10], ptr[11], | ||
ptr[12], ptr[13], ptr[14], ptr[15]); | ||
|
||
/* repeat all that but with order-independent arguments */ | ||
ptr[ 0] = ptr[ 1] = ptr[ 2] = ptr[ 3] = | ||
ptr[ 4] = ptr[ 5] = ptr[ 6] = ptr[ 7] = | ||
ptr[ 8] = ptr[ 9] = ptr[10] = ptr[11] = | ||
ptr[12] = ptr[13] = ptr[14] = ptr[15] = '.'; | ||
copyinto(arg1 + 2, 3, (void *)(ptr + 4)); | ||
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", | ||
ptr[ 0], ptr[ 1], ptr[ 2], ptr[ 3], | ||
ptr[ 4], ptr[ 5], ptr[ 6], ptr[ 7], | ||
ptr[ 8], ptr[ 9], ptr[10], ptr[11], | ||
ptr[12], ptr[13], ptr[14], ptr[15]); | ||
|
||
exit(0); | ||
} | ||
|
||
ERROR | ||
{ | ||
exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
....lay......... | ||
....lay......... | ||
|
||
-- @@stderr -- | ||
Delay in ns needed in delay env var. |