-
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 strjoin() subroutine
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
- Loading branch information
Showing
22 changed files
with
376 additions
and
9 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,57 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. | ||
*/ | ||
|
||
#define DT_STRLEN_BYTES 2 | ||
|
||
#define BPF_FUNC_probe_read_str 45 | ||
|
||
/* | ||
* void dt_strjoin(char *dst, const char *s1, const char *s2) | ||
*/ | ||
.text | ||
.align 4 | ||
.global dt_strjoin | ||
.type dt_strjoin, @function | ||
dt_strjoin: | ||
mov %r9, %r1 /* %r9 = dst */ | ||
mov %r7, %r2 /* %r7 = s1 */ | ||
mov %r8, %r3 /* %r8 = s2 */ | ||
|
||
mov %r1, %r7 | ||
call dt_strlen | ||
mov %r6, %r0 /* len = dt_strlen(s1) */ | ||
add %r7, DT_STRLEN_BYTES /* s1 += 2 */ | ||
|
||
mov %r1, %r8 | ||
call dt_strlen | ||
add %r6, %r0 /* len += dt_strlen(s2) */ | ||
add %r8, DT_STRLEN_BYTES /* s2 += 2 */ | ||
|
||
mov %r1, %r6 | ||
mov %r2, %r9 | ||
call dt_strlen_store /* dt_strlen_store(len, dst) */ | ||
add %r9, DT_STRLEN_BYTES /* dst += 2 */ | ||
|
||
lddw %r6, STRSZ | ||
add %r6, 1 | ||
and %r6, 0xffffffff /* len = (STRSZ + 1) & 0xffffffff */ | ||
|
||
mov %r1, %r9 | ||
mov %r2, %r6 | ||
mov %r3, %r7 | ||
call BPF_FUNC_probe_read_str /* cnt = bpf_probe_read_str(dst, len s1) */ | ||
jslt %r0, 0, .L1 /* if (cnt < 0) goto .L1 */ | ||
jslt %r0, 1, .L2 /* if (cnt < 1) goto .L2 */ | ||
sub %r0, 1 /* cnt-- */ | ||
add %r9, %r0 /* dst += cnt */ | ||
sub %r6, %r0 /* len -= cnt */ | ||
.L2: | ||
mov %r1, %r9 | ||
mov %r2, %r6 | ||
mov %r3, %r8 | ||
call BPF_FUNC_probe_read_str /* bpf_probe_read_str(dst, len, s2 */ | ||
.L1: | ||
exit | ||
.size dt_strjoin, .-dt_strjoin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, 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. | ||
*/ | ||
|
||
/* | ||
* Ensure that we do not leak registers with void expressions. | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN { | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
strlen("a"); | ||
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 @@ | ||
|
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,36 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, 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. | ||
*/ | ||
|
||
/* | ||
* Ensure that we do not leak tstrings with void expressions. | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN { | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
strjoin("a", "b"); | ||
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 @@ | ||
|
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,36 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, 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. | ||
*/ | ||
|
||
/* | ||
* Ensure that we do not leak tstrings with variable assignments. | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN { | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
x = strjoin("a", "b"); | ||
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 @@ | ||
|
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,6 +1,10 @@ | ||
/* @@xfail: dtv2 */ | ||
BEGIN | ||
{ | ||
trace(strjoin(probeprov, probename)); | ||
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,28 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, 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. | ||
*/ | ||
|
||
#pragma D option rawbytes | ||
#pragma D option strsize=6 | ||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
x = probeprov; | ||
y = probename; | ||
z = strjoin(x, y); | ||
|
||
trace(x); | ||
trace(y); | ||
trace(z); | ||
|
||
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,10 @@ | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 06 64 74 72 61 63 65 00 ..dtrace. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 42 45 47 49 4e 00 00 ..BEGIN.. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 06 64 74 72 61 63 65 00 ..dtrace. | ||
|
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,28 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, 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. | ||
*/ | ||
|
||
#pragma D option rawbytes | ||
#pragma D option strsize=6 | ||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
x = probeprov; | ||
y = probeprov; | ||
z = strjoin(x, y); | ||
|
||
trace(x); | ||
trace(y); | ||
trace(z); | ||
|
||
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,10 @@ | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 06 64 74 72 61 63 65 00 ..dtrace. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 06 64 74 72 61 63 65 00 ..dtrace. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 06 64 74 72 61 63 65 00 ..dtrace. | ||
|
Oops, something went wrong.