-
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.
Add support for progenyof() subroutine
Also, clean up err*progeny*.d tests. In particular, *) err.D_FUNC_UNDEF.progenyofbad1.d was failing because it had always been wrong: the test was mislabeled. The test was introduced in patch c17a42e "Add the OpenSolaris dtrace testsuite." with a .r results file that explicitly indicates D_PROTO_LEN, even though the test name expects D_FUNC_UNDEF. However, runtest.sh did not check the error tag. Though runtest.sh was eventually fixed, the test fail was simply dismissed XFAIL. *) err.D_PROTO_LEN.progenyofbad2.d was passing, but for reasons unrelated to progenyof() or its argument checks. The test used progenyof(trace()) and therefore did not test progenyof() at all; rather, it failed on trace(), which is missing its argument. Signed-off-by: Eugene Loh <eugene.loh@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
Showing
17 changed files
with
203 additions
and
22 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,88 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. | ||
*/ | ||
|
||
#define BPF_FUNC_probe_read 4 | ||
#define BPF_FUNC_get_current_task 35 | ||
|
||
.text | ||
.align 4 | ||
.global dt_progenyof | ||
.type dt_progenyof, @function | ||
dt_progenyof: | ||
#define ARG %r6 | ||
#define CNT %r7 | ||
#define PTR %r8 | ||
#define VAL %r9 | ||
|
||
/* uint64_t dt_progenyof(pid_t arg); */ | ||
mov ARG, %r1 | ||
lsh ARG, 32 | ||
rsh ARG, 32 | ||
|
||
/* assure the BPF verifier there is no infinite loop */ | ||
mov CNT, 256 | ||
|
||
/* ptr = bpf_get_current_task() */ | ||
call BPF_FUNC_get_current_task | ||
mov PTR, %r0 | ||
|
||
.Lloop: | ||
/* if (ptr == 0) goto Lret0 */ | ||
jeq PTR, 0, .Lret0 | ||
|
||
/* if (count <= 0) goto Lret0 */ | ||
jsle CNT, 0, .Lret0 | ||
|
||
/* val = *((uint32_t *)(ptr + TASK_PID)), using [%fp+-8] as temp */ | ||
mov %r1, %fp | ||
add %r1, -8 | ||
mov %r2, 4 | ||
lddw %r3, TASK_PID | ||
add %r3, PTR | ||
call BPF_FUNC_probe_read | ||
jne %r0, 0, .Lret0 | ||
ldxw VAL, [%fp+-8] | ||
lsh VAL, 32 | ||
rsh VAL, 32 | ||
|
||
/* if (val == arg) goto Lret1 */ | ||
jeq VAL, ARG, .Lret1 | ||
|
||
/* val = *((uint64_t *)(ptr + TASK_REAL_PARENT)), using [%fp+-8] as temp */ | ||
mov %r1, %fp | ||
add %r1, -8 | ||
mov %r2, 8 | ||
lddw %r3, TASK_REAL_PARENT | ||
add %r3, PTR | ||
call BPF_FUNC_probe_read | ||
jne %r0, 0, .Lret0 | ||
ldxdw VAL, [%fp+-8] | ||
|
||
/* if (val == ptr) goto Lret0 */ | ||
jeq VAL, PTR, .Lret0 | ||
|
||
/* ptr = val */ | ||
mov PTR, VAL | ||
|
||
/* count-- */ | ||
sub CNT, 1 | ||
|
||
/* goto Lloop */ | ||
ja .Lloop | ||
|
||
.Lret0: | ||
/* return 0 */ | ||
mov %r0, 0 | ||
exit | ||
|
||
.Lret1: | ||
/* return 1 */ | ||
mov %r0, 1 | ||
exit | ||
.size dt_progenyof, .-dt_progenyof | ||
#undef ARG | ||
#undef CNT | ||
#undef PTR | ||
#undef VAL |
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
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
This file was deleted.
Oops, something went wrong.
11 changes: 3 additions & 8 deletions
11
...est/funcs/err.D_PROTO_LEN.progenyofbad2.d → ...est/funcs/err.D_PROTO_ARG.progenyofbad1.d
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 |
---|---|---|
@@ -1,23 +1,18 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2022, 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: | ||
* progenyof() should return an error if the argument is an | ||
* incorrect type. | ||
* ASSERTION: progenyof() should take a pid_t argument. | ||
* | ||
* SECTION: Actions and Subroutines/progenyof() | ||
* | ||
*/ | ||
|
||
|
||
BEGIN | ||
{ | ||
progenyof(trace()); | ||
progenyof("some_string"); | ||
exit(0); | ||
} | ||
|
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,4 @@ | ||
-- @@stderr -- | ||
dtrace: failed to compile script test/unittest/funcs/err.D_PROTO_ARG.progenyofbad1.d: [D_PROTO_ARG] line 16: progenyof( ) argument #1 is incompatible with prototype: | ||
prototype: pid_t | ||
argument: string |
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,18 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2007, 2022, 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: progenyof() should take a pid_t argument. | ||
* | ||
* SECTION: Actions and Subroutines/progenyof() | ||
*/ | ||
|
||
BEGIN | ||
{ | ||
progenyof(trace(1)); | ||
exit(0); | ||
} |
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,4 @@ | ||
-- @@stderr -- | ||
dtrace: failed to compile script test/unittest/funcs/err.D_PROTO_ARG.progenyofbad2.d: [D_PROTO_ARG] line 16: progenyof( ) argument #1 is incompatible with prototype: | ||
prototype: pid_t | ||
argument: void |
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2022, 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: progenyof() should take one argument. | ||
* | ||
* SECTION: Actions and Subroutines/progenyof() | ||
*/ | ||
|
||
BEGIN | ||
{ | ||
progenyof(); | ||
exit(0); | ||
} |
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,2 @@ | ||
-- @@stderr -- | ||
dtrace: failed to compile script test/unittest/funcs/err.D_PROTO_LEN.progenyoftoofew.d: [D_PROTO_LEN] line 16: progenyof( ) prototype mismatch: 0 args passed, 1 expected |
10 changes: 3 additions & 7 deletions
10
...st/funcs/err.D_FUNC_UNDEF.progenyofbad1.d → .../funcs/err.D_PROTO_LEN.progenyoftoomany.d
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 |
---|---|---|
@@ -1,22 +1,18 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2006, 2022, 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. | ||
*/ | ||
/* @@xfail: dtv2 */ | ||
|
||
/* | ||
* ASSERTION: | ||
* progenyof() should accept one argument - a pid | ||
* ASSERTION: progenyof() should take one argument. | ||
* | ||
* SECTION: Actions and Subroutines/progenyof() | ||
* | ||
*/ | ||
|
||
|
||
BEGIN | ||
{ | ||
progenyof(1, 2); | ||
exit(0); | ||
} | ||
|
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,2 @@ | ||
-- @@stderr -- | ||
dtrace: failed to compile script test/unittest/funcs/err.D_PROTO_LEN.progenyoftoomany.d: [D_PROTO_LEN] line 16: progenyof( ) prototype mismatch: 2 args passed, 1 expected |
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